fix(v5): reject weakened frozen power planning inputs

Draft
TH
2mo ago
+460-39

Purpose: stop silently weakening frozen V5 development power planning

This is a DRAFT code-quality successor to #325, with no change to the frozen scientific branch, the original 307 evidence entries, the official repo owner or main.

Reproduced defects on pre-fix planner

Before this patch, scripts/v5_power_margin_plan.py accepted all of:

  • desired_power=0.51 instead of the V5 frozen 0.90;
  • family_alpha=0.20 instead of the V5 frozen familywise 0.05;
  • planned_clusters=2 rather than the present prospective planning value 4096;
  • a one-character string masquerading as the domain-floor justification SHA-256;
  • paired_sd=false, interpreted as a spurious zero variance.

A fabricated arbitrary full-length 64-digit hash may still satisfy syntax; this utility cannot establish a reviewed file's identity or content without a separate source-bound review stage.

Corrective measures

  • Enforce exactly family_alpha=0.05, desired_power=0.90, planned_clusters=4096 for this frozen planning version. A different design/count requires review and explicit versioning under statistical gate #326.
  • Reject Boolean/numeric-string/overflow SD, floor and repeatability input rather than converting them.
  • Require syntactically valid, lowercase 64-character SHA-256 provenance fields for each metric. This is a syntax prerequisite, not standalone evidence verification.
  • Make the output explicitly declare family_membership_frozen_and_independently_reviewed=false, source_case_seed_nuisance_qualified=false, final_90_percent_power_qualified=false and confirmatory_execution_authorized=false, regardless of apparent illustrative planning success.
  • Add 16 synthetic negative regressions and a separate exact-PR-head GitHub CI with read-only contents permissions, no persisted checkout credentials, pinned pytest, no model/GPU/API/PHI or experimental data access.

Exact-head local evidence

  • macOS V5 specialized tests: 339 passed, 86 subtests passed (prior to the last additional overflow regression).
  • Complete repository suite after all new tests: 1,392 passed, 264 subtests passed.
  • Focused statistical guard suite after all new tests: 28 passed.
  • Frozen original file verification: 307/307 PASS.
  • Python/CI YAML parse and scope policy checks, git diff whitespace: PASS.
  • Alibaba OCR local delegate preview: 2 code/config files eligible. This is NOT an external independent OCR model review verdict.
  • GitHub cryptographic signature unverified until GitHub/appropriate independent gate says otherwise; commit is DCO-signed off only.

Scientific and governance boundaries

This change does not enumerate, freeze or approve the true Holm primary non-target hypothesis family/count. Three training seeds and 72 descriptive within-seed source-task SD cells are not a qualified crossed source-case × training-seed nuisance model. It does not calculate a final valid power certificate, prove clinical utility, permit confirmatory/reserve materialization, authorize independent-family replication, merge pending draft PRs, or publish a paper. All missing review/founder/signature/method steps are tracked transparently in #326.

Review request: verify the input trust-boundary correction and negative tests without promoting a syntactic validation PASS into scientific qualification.


Summary by cubic

Hardens the V5 development power planner so callers can no longer silently weaken frozen planning inputs, fabricate evidence identifiers, or mask a high-variance cell with another intervention's descriptive variance. Output moves to schema v2 with per-hypothesis plans and an explicit intersection aggregate.

  • Rejects any deviation from the frozen V5 constants (family_alpha 0.05, desired_power 0.90, planned_clusters 4096), and rejects Booleans, numeric strings, overflow, and non-SHA-256-shaped evidence identifiers.
  • Finite but unrepresentable nuisance values now raise a fail-closed PowerPlanContractError instead of an uncontrolled numeric error or fabricated success.
  • Replaces metric-level paired_sd with paired_nuisance_by_hypothesis, requiring one unqualified descriptive record per declared hypothesis so a shared metric SD cannot stand in for an intervention cell.
  • Requires primary_non_target_hypotheses to match primary_non_target_family_size, with validated unique IDs, metric presence, coupling tag, SOURCE_CASE unit, and primary flag; the ordered list is bound to a deterministic SHA-256.
  • Output emits explicit false flags for family freeze, nuisance qualification, power qualification, and confirmatory authorization, and the CLI reports PASS_DEVELOPMENT_ONLY_INPUT_CONTRACT.
  • The CLI now resolves the repository root directly, so it runs without PYTHONPATH.

New Features

  • Adds exact-PR-head CI with read-only permissions, pinned pytest, and no persisted credentials.
  • Adds synthetic negative regressions covering relaxed constants, forged hashes, typed inputs, overflow, and hypothesis/nuisance drift, plus a mechanics-only validation document.