Candidate performance gates

gate.py runs the ordinary API canisters through the existing planner and PocketIC launcher. Select an explicit list of [collection, placement, size] cohorts; every selected cohort runs its complete operation catalog. The supplied cohorts.json covers 22 cohorts. Add sequence cohorts at 10,000 entries when a candidate affects that geometry. Sizes must match the accepted baseline: 100, 10,000 or 100,000. There are no new canister endpoints or runtime changes here.

Build the candidate first. Place source-before-build.json, source-manifest.json, source-inputs.tar.gz and compiler-input-audit.json in a new bench/results/<timestamp>-<candidate>/ directory. Its manifest must match the already-built live bench/artifacts/source-manifest.json. The gate archives only the small source inputs, selected Wasms, runner and orchestration inputs; it does not copy compiler targets or canister snapshots. Pass plan --candidate path/to/candidate.json to freeze optional candidate identity, base-commit and patch-hash metadata with those mandatory build inputs.

python3 research/experiments/performance-candidates/gate.py plan \
  bench/results/<timestamp>-<candidate> \
  --cohorts research/experiments/performance-candidates/cohorts.json \
  --runner bench/target/x86_64-unknown-linux-gnu/release/api \
  --label candidate-name
python3 research/experiments/performance-candidates/gate.py run \
  bench/results/<timestamp>-<candidate> --jobs 8
python3 research/experiments/performance-candidates/gate.py compare \
  bench/results/<timestamp>-<candidate> \
  --previous bench/results/<previous-completed-candidate>

Omit --previous for the first candidate. The default baseline is the accepted bench/results/2026-10-16-234007/merged/api.json; --baseline can select another complete canonical three-trial raw suite. Partial raw JSON files are rejected. A previous candidate must be a completed gate directory with frozen worker receipts, cover every requested cohort, and use the same catalog and workload. Its actual scope and trial count remain recorded.

The default is a three-trial focused confirmation. Add --screen to plan for an explicitly exploratory one-trial screen. A screen's one sample is compared with all three baseline samples' median, not just baseline trial one. Candidate/reference trial counts are separate in the CSV. Single-trial spread and repetition are unavailable (null in JSON, blank in CSV); one observation does not establish repeatability. Confirmation gates are still subsets, not full suite publications. Run the canonical full suite after selecting a candidate.

Workers run concurrently within one frozen candidate. Serialize candidate builds, source edits and measurements: the ordinary runner executes the live bench/artifacts tree, whose source/Wasms are guarded before and after execution. Frozen copies preserve evidence, not a separate executable source tree. The official launcher manages short temporary paths and verified owned-process cleanup; this tool does not replace its lifecycle logic.

comparison/ contains every case's body/inner medians and deltas, trial spreads, population Store/IC memory metrics, repetition observations, and a JSON summary with raw/source/actual-Wasm/runner/compiler-audit hashes. Missing memory metrics stay missing rather than becoming zero. Body intervals include root admission/finalization; neither counter represents whole IC-call instructions. After successful validation and comparison, only that run's listed recovery journals are deleted, after all raw paths/hashes pass preflight. Complete raw JSON, previous candidates and all receipts remain. Failed runs retain journals.

Offline tooling checks (no builds or PocketIC):

PYTHONDONTWRITEBYTECODE=1 python3 research/experiments/performance-candidates/test_gate.py