# Conditional prospective task-level power utility

7 October 2026 Pacific. Source-only preparation for review item19. No source pilot,
private target outcomes, model/native execution, fitting, powered N, price plan,
registration or H1 result. Original confirmatory scope and primary comparison
remain unchanged. The supplied law is hypothetical unless independently authorized
source-development metadata establishes it; the law_kind string authenticates nothing.

Inspected current proposal0.7 primary design: at B*=4×development median billed
single pass, paired joint-minus-individual success; three frozen seeds averaged
within task; two-sided task-clustered95% CI excludes zero for improvement, lower
bound above3pp supports practical target;80% power is a design aim. 10,000 paired
task bootstrap resamples, source/family clustering where needed. Interval construction,
finite-sample rejection convention and family dependence model remain unspecified.
No ordinary independent-seed-row McNemar calculation is justified.

This utility is therefore a CONDITIONAL prospective method, not adoption of a
registered test. Task delta D is the difference of two means of three binary seed
outcomes. Integer tick3D lies in {-3,-2,-1,0,1,2,3}. `task_delta` accepts all six
exact booleans and produces one task observation. Within-task correlation and
paired-arm dependence are absorbed by the task law; no three seed replicates are
counted as independent tasks. Different tasks are sampled IID from the supplied
seven-mass law. If tasks share source/family dependence, this task-IID utility is
insufficient: freeze cluster definition, cluster sampling law, weighting/estimand,
and exact cluster bootstrap before confirmatory power can be planned. No family
structure is invented from absent pilot data.

`simulate(plan)` executes bounded deterministic Monte Carlo. Required exact plan:
schema1; method=PERCENTILE_PAIRED_TASK_BOOTSTRAP_CONDITIONAL_PROPOSAL;
law_kind=HYPOTHETICAL or AUTHORIZED_SOURCE_TASK_LAW; law seven nonnegative finite
probability masses in tick order; sorted distinct task_counts (1..2000, up to8);
trials1..256; bootstrap_resamples exactly10000; nonnegative integer seed; wall_seconds
1..120. Every boolean-as-integer is rejected. Max40,000,000 planned random draws
across all counts; oversized grids refuse before simulations. Cooperative deadline
checks retain no false partial power result: timeout raises. External supervision
is required for a hard whole-lifecycle limit; this source does not claim one.

For each outer trial sample N whole-task deltas. Resample N whole paired-task
deltas with replacement10,000 times and form bootstrap mean deltas. Use explicit
nearest-rank empirical2.5th/97.5th percentiles, ranks ceil(.025B) and ceil(.975B).
A positive directional improvement is counted iff lower>0; negative directional
rejection iff upper<0. A two-sided rejection by itself is not evidence for the
positive H1. Separately count lower>.03; the supplied law mean is reported, never
forced to .03 or assumed to be the expected study result. These percentile/rank
choices require prospective review/adoption; they must not silently replace the
unspecified original method. No studentization, BCa or normal approximation is
claimed. Degenerate/small-sample bootstrap coverage can fail; the utility reports
interval coverage of the known law mean descriptively to expose this issue.

Each N uses a deterministic SHA-derived RNG seed from [base_seed,N], so adding
another N to a grid does not change existing trials. Plan canonical SHA is returned
for bookkeeping, not authentication. Python stdlib RNG/version/source pins need
external freezing for exact future replay. Seed selection must precede results;
scanning favorable seeds or law choices is not allowed.

Monte Carlo rejection frequency has a pointwise95% Wilson interval conditional
on the supplied fixed law and finite randomized10,000-resample bootstrap procedure.
It is simulation uncertainty only, not uncertainty in a law estimated from a small
source pilot, family shift, pool generation, task eligibility, contamination or
pricing. Intervals across searched N are not simultaneous. A handful of trials
will have wide intervals; reaching an estimated .8 is not a validated power claim.
`confirmatory_n_selected` is always null. Future N requires actual authorized
source-pilot variance/law assessment, clustering design, full rejection method,
uncertainty/sensitivity review and budget feasibility before protocol registration.

For orientation only, an IID normal-approximation planning relation is
N≈(z_.975+z_.8)^2 Var(D)/.03^2. This uses one D per task, not seed rows, and is not
an implemented test or final sample-size recommendation. Normal validity and
source variance are unproven; current source pilot is unavailable. The numerical
utility does not turn authored distributions into evidence about natural code tasks.

Local operative API: `power.simulate(plan)` returns per-N counts, frequencies,
pointwise Monte Carlo intervals, known-law coverage diagnostics and explicit limits.
No file/network/model/task execution or authority creation occurs. Tests deliberately
use point-mass authored laws and small analytic kernels, not scientific power
estimates. Nine normal/optimized tests check cluster arithmetic, analytic moments,
constant bootstrap solutions, deterministic sampling, deadline/cap rejection,
strict finite/types, and binomial MC endpoints. Initial Wilson endpoint roundoff
was corrected to exact0/1 at all-failure/all-success boundaries before final passes.

    python3 -B -m unittest -q test_power
    python3 -O -B -m unittest -q test_power

V2 coherence amendment: accepted seven masses must satisfy absolute fsum-total
error<=1e-12. Divide by their fsum; sampling and moments use those identical
normalized weights, with the same cumulative total used by random.choices.
Moments divide by that cumulative total, avoiding near-unit point-mass coverage
mismatch. Original unnormalized plan canonical hash remains unchanged; normalized
sampling weights and explicit normalization policy are separately returned. Binary
floating arithmetic/RNG discreteness still yields numerical approximation for
mixed laws; this is not an exact rational sampling guarantee. No protocol or law
is selected from outcomes; V1 remains immutable with its recorded defect.
