Skip to content

State safety: implement the declared first-cycle analysis (before its data exists) - #116

Merged
SamMausberg merged 12 commits into
mainfrom
state/first-cycle-analysis
Oct 1, 2026
Merged

SamMausberg merged 12 commits into
mainfrom
state/first-cycle-analysis

Conversation

@SamMausberg

Copy link
Copy Markdown
Owner

Implements the declared first-cycle analysis (declared in #114, merged at b918c8b). This PR is opened before any data for the test exists: the runs are queued from a clean checkout at b918c8b and none has started, so ~/vp-data/state/runs_fresh doesn't exist yet.

What's in it

experiments/state_safety/first_cycle.py follows the declaration step by step.

  • Pairs: each pair has a reference R, a compared run C and a labelling run L.
    • Primary: R = plain c1 and C = L = MTP c1, for steps 5 and the tree.
    • Control: R = L = MTP c1 and C = MTP c32.
  • Positions: positions up to and including the first token difference between R and C. A position is fragile when R's top-2 gap is at most 0.25 nats.
  • Cycles: L's chunk 1 is the first cycle and later chunks are later cycles. Only fragile divergences count.
  • Population: prompts common to all five runs, minus any prompt that one of the four MTP runs doesn't stream as one chunk per cycle. The number excluded is reported.
  • Statistics: pooled log odds ratios with +0.5 per cell. The bootstrap uses one shared prompt resample per replicate across all four pairs: 10,000 replicates with numpy.random.default_rng(0) and percentile bounds.
  • Decision:
    • (a) the 5th percentile of L_p is above 0;
    • (b) the 5th percentile of L_p − L_c is above 0;
    • the result is supported only if both hold, and inconclusive otherwise;
    • the secondary test is a one-sided Fisher exact test on the pooled primary table.
  • Void: missing runs, pools other than the declared pin, or generation settings other than 256 tokens and top-5 make the result void, and then no results are written.

analyze_all.sh runs the analysis once all five runs exist. The README section notes the implementation.

Tests

tests/test_state_safety_first_cycle.py runs on synthetic runs:

  • position counting (prefill excluded, first cycle against later, fragile only);
  • the +0.5 correction;
  • a supported case and an inconclusive case;
  • the void conditions.

31 state tests pass, both with and without SciPy, and pre-commit passes, including the host-identity hook and mypy.

first_cycle.py follows the declaration in the experiments README:
- the R/C/L pairs (plain c1 against MTP c1; MTP c1 against c32), with fragility
  from R and cycles from L, counting only fragile divergences;
- a common population that excludes prompts with irregular chunking;
- pooled log odds ratios with +0.5 per cell, and one shared prompt resample
  per bootstrap replicate across all four pairs (10,000, seed 0, percentile);
- (a) and (b) as declared, with the Fisher test as a secondary.
Missing runs, unpinned pools or other generation settings make the result void,
and then no results are written. Tests cover the position counts, the cell
correction, both decisions and the void conditions. analyze_all.sh runs it once
all five runs exist.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T13:54:31.970026Z a493cbf Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Review on the exact head 0fc71a8 ("Implement the declared first-cycle analysis before its data exists"), against the declaration merged in #114 (experiments/state_safety/README.md, "Declared follow-up", b918c8b). ~/vp-data/state/runs_fresh does not exist yet, so no data predates this code.

Matches the declaration

  • R/C/L for each pair. PRIMARY is (plain c1, MTP c1, MTP c1) and CONTROL is (MTP c1, MTP c32, MTP c1), for steps 5 and the tree. Fragility comes from R's top-2 gap (at most FRAGILE_GAP, 0.25 nats), and the cycles come from L's chunks.
  • Positions. counts runs through the first R/C difference, inclusive. L's chunk 0 (the prefill token) counts in neither group, chunk 1 is the first cycle and later chunks are later cycles. A divergence is counted only at a fragile position.
  • Population. A prompt is excluded from every pair if any of the four MTP runs fails spec_cycles_consistent, and the count is reported.
  • Statistic. log_odds is (a + 0.5)(f0 - c + 0.5) / ((f1 - a + 0.5)(c + 0.5)) on the pooled tables, the declared odds ratio with 0.5 added to every cell.
  • Bootstrap and rule. 10,000 replicates with default_rng(0), and one idx per replicate applied to both the primary and the control arrays, which share the prompt order. (a) is the 5th percentile of L_p above 0, and (b) the 5th percentile of L_p - L_c above 0. The decision is "supported" only if both hold, and "inconclusive" otherwise. The secondary is a one-sided Fisher test (alternative='greater') on the pooled primary table.
  • Tests and hooks. tests/test_state_safety_first_cycle.py gives 4 passed, both with and without SciPy. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.

Blocking. The void conditions do not check that the runs are the declared runs. Both checks are cheap from what each run already records, and both should hold before any data exists.

  1. Configuration. void_reasons checks the pools and 256/top-5, but not that each run is the configuration its path names.
    • A run's .meta.json already records concurrency, flags and server_info, with speculative_algorithm, speculative_num_steps, speculative_eagle_topk, disable_radix_cache and disable_overlap_schedule.
    • Please void unless:
      • plain is non-speculative;
      • mtp_s5 is EAGLE with 5 steps and top-k 1;
      • mtp_tree is EAGLE with 3 steps and top-k 2;
      • each cN run has concurrency N;
      • the radix cache and the overlap scheduler are on, as declared.
  2. Prompt coverage. analyse silently uses the intersection of the five runs' prompt IDs and reports only prompts_common. A run with missing prompts, or a run on the wrong prompt set, would still be analysed.
    • Please void unless every run's ID set equals the fresh set's, taken from the frozen evidence/state_safety/prompt_manifest_fresh.json or from prompts_fresh.jsonl checked against that manifest's input_ids_sha256.
    • Report the expected count (960) next to prompts_common and prompts_included.
    • Add a test for each of the two voids.

Suggestions (non-blocking)

  • The Fisher p-value is written as None when SciPy is missing. That is fine for the tests, but on the evidence path a missing SciPy should fail rather than write a result without its secondary.
  • When a void occurs, first_cycle.py exits non-zero, so analyze_all.sh (which has set -e) stops there. That is presumably intended, failing closed, but one comment in analyze_all.sh would make it explicit.

first_cycle.py now voids, and writes no results, when:
- a run's configuration differs from the declaration (plain non-speculative,
  MTP steps 5 at top-k 1, the tree at 3 steps and top-k 2, each pass at its
  declared concurrency, radix cache and overlap on);
- a run's prompt IDs are not exactly the 960 fresh prompts, after the prompt
  file is checked against the frozen manifest.
The result reports prompts_declared next to prompts_common and
prompts_included. On the evidence path the Fisher secondary always runs; only
the tests skip it. Each void condition has a test. analyze_all.sh says that a
void stops it under set -e.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fc71a8184

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +107 to +108
if m.get('max_new_tokens') != 256 or m.get('top_logprobs_num') != 5:
reasons.append(f'{run}: generation settings differ from the declaration')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject runs outside the declared fresh prompt set

The validation never checks the prompt population, so the analysis can publish a result for the wrong experiment. In particular, run_matrix.py defaults --prompts to the original 320-prompt prompts.jsonl; running it with --out-dir ~/vp-data/state/runs_fresh but forgetting the prompt override produces files that pass these checks and are reported as the declared 960-prompt fresh test. Validate the expected fresh prompt IDs/count or a recorded manifest digest before analyzing.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 86b0cf1. void_reasons() first checks the fresh prompt file against the frozen prompt_manifest_fresh.json (SHA-256 of IDs and tokens, num_prompts, and the declared 960). It then requires every run's prompt-ID set to equal that set exactly, reporting how many are missing and how many extra. A run made with run_matrix.py's default 320-prompt file is therefore void, and no results are written. On the existing pinned runs it reports 960 missing and 320 extra for each run. The output gains prompts_declared next to prompts_common and prompts_included, and there are tests for a missing prompt and for an unfrozen prompt file.

Comment thread experiments/state_safety/first_cycle.py Outdated
Comment on lines +104 to +106
pin = expected_pools(pool_flags())
if m.get('pool_pin') != pin or m['server_info'].get('resolved_pools') != POOL_PIN:
reasons.append(f'{run}: pools not pinned as declared')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate the declared server configuration

Checking only the resolved pools still accepts runs produced under conditions excluded by the declaration. For example, run_matrix.py --extra-flags='--disable-radix-cache' retains the expected mtp_s5/c1.jsonl path and pinned pool metadata, yet changes a declared condition and is silently analyzed; the same applies to disabled overlap or an unexpected model/configuration. Verify each run's recorded config, flags, model revision, concurrency, and warm state before treating it as this experiment.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 86b0cf1 and 86b0cf1. Each run must match its declared configuration: the speculative algorithm, steps and top-k (plain non-speculative, MTP steps 5 at top-k 1, the tree at 3 steps and top-k 2), concurrency N for cN, and the radix cache and overlap scheduler on. 86b0cf1 adds four more checks: the recorded config name; flags exactly equal to that configuration's flags plus the pin, so any --extra-flags such as --disable-radix-cache voids the run; the pinned model revision with FlashInfer attention; and a cold pass (warm false). Every condition has a test. On the existing pinned runs, all of these checks pass and the only void reason is prompt coverage.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction to my reply above: the extra checks are in 7589a07, not 86b0cf1. My earlier commit attempt failed a formatting hook, so the hash in that reply was wrong. 7589a07 adds four checks: the recorded config name; flags exactly equal to CONFIGS[config] + pool_flags(); the pinned model revision with FlashInfer attention; and a cold pass. Each has a test. 86b0cf1 holds the speculative, concurrency, radix/overlap and prompt-coverage checks.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on two conditions: Codex's review of 86b0cf1 was still running when I posted this, and the two Codex threads on 0fc71a8 need replies. I will re-check both on this head before merge.)

Re-review on the exact head 86b0cf1 ("Void the first-cycle result unless the runs are the declared runs").

  • My blocking item 1 (configuration) is fixed. void_reasons checks each run's .meta.json against DECLARED:

    • plain c1 non-speculative;
    • mtp_s5 EAGLE with 5 steps and top-k 1;
    • mtp_tree EAGLE with 3 steps and top-k 2;
    • concurrency equal to N for each cN;
    • neither disable_radix_cache nor disable_overlap_schedule set.

    These are the fields the existing pinned runs actually record (plain: speculative_algorithm None and concurrency 1; mtp_s5/c32: EAGLE 5 1 and 32), so the check reads real metadata.

  • My blocking item 2 (prompt coverage) is fixed.

    • The fresh prompt file must match the frozen prompt_manifest_fresh.json: the SHA-256 of IDs and tokens, the prompt count, and 960.
    • Each run's ID set must equal it exactly, and the message reports how many prompts are missing and how many are extra.
    • The output reports prompts_declared next to prompts_common and prompts_included.
  • The tests cover every void. test_each_departure_from_the_declaration_makes_the_result_void covers nine: a missing run, unpinned pools, a speculative plain run, wrong steps, wrong tree top-k, wrong concurrency, the radix cache off, a missing prompt, and a prompt file that is not frozen. test_declared_runs_are_not_void covers the declared case.

  • Both suggestions are in. Fisher always runs on the evidence path, and only the tests pass fisher=False. analyze_all.sh says that a void stops it under set -e.

  • Checks. tests/test_state_safety_first_cycle.py gives 5 passed, with and without SciPy. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.

Conditions before merge. Codex's P1 r4155620314 and P2 r4155620330 on 0fc71a8 raise the same two points, and the code fixes them, but neither thread has a reply yet. Please reply on both, citing 86b0cf1.

Blocking: none in the code. Suggestions: none.

@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

Codex's P2 asked for more than the server's speculative and cache settings.
void_reasons() now also requires each run's recorded config name, and its flags
equal to that configuration's flags plus the pin with nothing extra (so
--extra-flags such as --disable-radix-cache voids the run). It also requires
the pinned model revision, FlashInfer attention and a cold pass. Each check has
a test. On the existing pinned runs, prompt coverage is the only void reason.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 7589a07 was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 7589a07 ("Check each run's config, flags, model revision and pass type"). It supersedes my approval of 86b0cf1, where Codex had not finished before the branch moved.

  • New checks, beyond my two items (Codex P2 r4155620330). Each run must also have:

    • its recorded config equal to the declared one;
    • flags exactly CONFIGS[config] + pool_flags() with nothing extra, so --disable-radix-cache or any other added flag voids the run;
    • model_revision equal to the pin and attention_backend flashinfer;
    • warm false.

    server.py (CONFIGS, pool_flags, MODEL_REVISION) is unchanged since b918c8b, the commit the runs are queued from, so the declared invocation and the check agree.

  • Tests. The void test adds three cases (an extra flag, a warm pass, another model revision), for twelve voids plus the declared case. tests/test_state_safety_first_cycle.py gives 5 passed.

  • Codex threads. Both threads on 0fc71a8 (P1 r4155620314, P2 r4155620330) now have replies. The P2 reply's wrong hash is corrected in a follow-up reply, which cites 7589a07.

  • Hooks and attribution. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.

  • Everything from my 86b0cf1 review still holds.

Blocking: none. Suggestions: none.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7589a071d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +163 to +167
if (
m.get('model_revision') != MODEL_REVISION
or info.get('attention_backend') != 'flashinfer'
):
reasons.append(f'{run}: model revision or attention backend differs')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject runs from an unpinned SGLang checkout

The new configuration checks still ignore the recorded sglang_sha and sglang_dirty fields, so runs produced by a modified or different SGLang revision pass validation as long as their model revision and reported flags match. Since engine changes can directly alter speculative-cycle boundaries and divergence behavior, this can publish results for a different experiment; require the pinned bd66ce343e4f6e2f2b75d7e820fe4d0718a8d824 revision and a clean checkout. This is fresh evidence beyond the earlier configuration comment because its fix validates flags and the model revision but still does not inspect either SGLang provenance field.

AGENTS.md reference: AGENTS.md:L7-L9

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9b6a17a. Every run must record sglang_sha equal to the pin bd66ce343e4f6e2f2b75d7e820fe4d0718a8d824, with sglang_dirty false. That is exactly what the queued holds will record: they source sglang_env.sh without SGLANG_WORKTREE, so they import ~/sglang, which sits at the pin with no local changes (the earlier pinned runs recorded the same). The state tap and the verify-split patch live in a separate engine worktree that these runs don't use. repo_sha must be the declaration's commit b918c8b or a descendant, with run_matrix.py, server.py and client.py identical to that commit. There are tests for another engine SHA, a dirty engine and other runner code.

Comment on lines +92 to +95
if ci == 0 or i >= len(r['top_logprobs']):
continue # the prefill token belongs to neither group
top = sorted((lp for lp, _ in r['top_logprobs'][i]), reverse=True)
if len(top) < 2 or top[0] - top[1] > FRAGILE_GAP:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject incomplete top-logprob records

When a record has fewer top_logprobs entries than output tokens, or a position contains fewer than two candidates, this silently drops the position instead of invalidating the run. The metadata only records that top-5 logprobs were requested; it does not prove they were returned, so a truncated or malformed streaming response can remove fragile exposures selectively while the prompt remains in the bootstrap population and can change both bounds. Validate the per-record logprob shape before analysis rather than skipping missing observations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9b6a17a. Before any analysis, every record in every run must have exactly one top-logprobs entry per output token, each with at least two candidates. If any record fails, the run is void and reported with a count of the failing records, so counts() never drops positions silently. There are tests for a short logprob list and for a position with a single candidate. On the existing pinned runs no record fails.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 7589a07 (#116 (comment)), which I withdraw. Codex finished its review of 7589a07 at 13:05:33 and left a P1 and a P2. Neither has a reply or fix yet, and both are sound: each is a way for a run that is not the declared experiment to pass validation.

Blocking

  1. P1: reject runs from an unpinned SGLang checkout (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)).
    • Each run's .meta.json records sglang_sha and sglang_dirty (the pinned runs have sglang_sha = bd66ce34... and sglang_dirty = false), but void_reasons does not check them.
    • An engine change can move cycle boundaries and divergences. Please void unless sglang_sha is the pin and sglang_dirty is false, and add a test for each case.
    • repo_sha should arguably be checked too, against the commit the runs are declared to come from (b918c8b, or at least a commit whose experiments/state_safety matches it).
  2. P2: reject incomplete top-logprob records (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)).
    • counts skips a position when i >= len(r['top_logprobs']) or when a position has fewer than two candidates. A truncated or malformed response would therefore remove fragile positions silently while the prompt stays in the population.
    • Please check the shape before the analysis: every record's top_logprobs should have one entry per output token, each with at least two candidates (five requested). Void the run if any record fails, report where, and add a test.

Everything else from my 7589a07 review still holds.

…logprobs

Codex P1 (r4155663010) and P2 (r4155663017):
- The engine must be the clean pin, sglang_sha bd66ce343e with sglang_dirty
  false. That is what the queued holds record: they run ~/sglang, unpatched at
  the pin.
- repo_sha must be the declaration's commit b918c8b or a descendant, with
  run_matrix.py, server.py and client.py unchanged from it.
- Every record must carry top-k logprobs for every output token, each with at
  least two candidates. A run that fails is void and reported; counts() no
  longer gets the chance to skip positions.
Each check has a test. On the existing pinned runs the engine and shape checks
pass; those runs predate b918c8b, so the runner-code and prompt checks void
them, as intended.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 9b6a17a was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 9b6a17a ("Void first-cycle runs on another engine, other runner code, or short logprobs").

  • Codex P1 r4155663010 (engine pin) is fixed and has a reply. A run is void unless sglang_sha is bd66ce343e… and sglang_dirty is false.
  • The runner-code check is in. A run is void unless repo_sha is b918c8b or a descendant, with run_matrix.py, server.py and client.py byte-identical to b918c8b. The check uses git in the analysing clone, where b918c8b is present.
  • Codex P2 r4155663017 (logprob shape) is fixed and has a reply. A run is void if any record's top_logprobs does not cover every output token with at least two candidates, and the count of such records is reported.
  • Tests and checks.
    • The void test now covers 17 conditions, plus the declared case against the real b918c8b. tests/test_state_safety_first_cycle.py gives 5 passed.
    • Pre-commit passes on origin/main..HEAD.
    • The commit is by Samuel Mausberg, with no AI lines.

Blocking: none.

Suggestion (non-blocking). The shape check requires at least two candidates, which is what fragility needs, but its message says "lack top-5 logprobs". Either check for five, as declared, or reword the message to "fewer than two candidates".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b6a17a5a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread experiments/state_safety/first_cycle.py Outdated
Comment on lines +207 to +208
if not runner_code_matches(str(m.get('repo_sha'))):
reasons.append(f'{run}: runner code differs from the declaration ({DECLARATION[:7]})')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject runs produced by dirty runner worktrees

When run_matrix.py is executed with uncommitted changes to run_matrix.py, server.py, or client.py, the metadata still records only the committed repo_sha; this check then compares that commit's files with the declaration and accepts the run even though different code actually produced it. Record and validate repository cleanliness or hashes of the files used at runtime before publishing the experiment.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8b671e4. Every run must record repo_sha equal to b918c8b. Because repo_sha can't show a clean tree, a new attest_runner.py --watch runs outside the holds, started at 13:13 UTC before either hold began. Whenever the run_matrix.py process writing to runs_fresh/ appears or exits, it records that checkout's HEAD, git status --porcelain and the SHA-256 of run_matrix.py, server.py and client.py into runs_fresh/attest/-<before|after>.json. It polls every 2 s and matches only the Python process, since gpu_lock.sh and flock carry the command while they wait. A hold's runs are void unless both records exist, have empty porcelain, are at b918c8b, and their file hashes equal those of b918c8b's blobs. The queued hold scripts and the state-fc worktree are untouched. The README documents the script, its timing and the 2 s window it can't see. There are tests for missing, dirty and edited attestations, a wrong repo_sha, and the watcher's process matching.

Comment on lines +177 to +180
m = json.loads(meta.read_text())
info = m.get('server_info', {})
if m.get('pool_pin') != pin or info.get('resolved_pools') != POOL_PIN:
reasons.append(f'{run}: pools not pinned as declared')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require each c1/c32 pair to use the same server

If the c1 and c32 artifacts for an MTP configuration are copied from separate otherwise-valid sessions, every per-run check here passes even though the declared design requires each configuration to be served from one server (experiments/state_safety/README.md:170-176). Since the control statistic directly compares those passes and the metadata already records server_info.server_id, validate that the two IDs match for mtp_s5 and for mtp_tree.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8b671e4. The run is void unless server_info.server_id is present and equal for mtp_s5/c1 and mtp_s5/c32, and likewise for mtp_tree. There is a test.

Comment thread experiments/state_safety/first_cycle.py Outdated
Comment on lines +224 to +225
ids = sorted(set.intersection(*(set(runs[r]) for r in RUNS)))
included = [p for p in ids if all(spec_cycles_consistent(runs[r][p]) for r in MTP_RUNS)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify every chunk advances exactly one cycle

When a streamed record has irregular cumulative counters, such as chunks with verify counts [0, 2, 2], spec_cycles_consistent still returns true because it checks only len(chunks) - 1 == final_count. This includes a prompt that should be excluded, then treats a chunk spanning multiple verifies as the first cycle and the repeated-count chunk as a later cycle, corrupting the declared tables; validate that the first count is zero and every subsequent count advances by exactly one.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partly feasible, fixed in 8b671e4 with what the data allows. The suggested check, first counter 0 and then +1 per chunk, can't hold: the server reports the cumulative spec_verify_ct only in the final chunk's meta, and every earlier chunk carries 0. That's true of all 2,560 pinned MTP records. So a prompt is now excluded from every pair, as the declaration does for skipped prompts, unless all four MTP runs show three things. Every chunk but the last carries 0. The last carries the number of chunks after the prefill token, which equals spec_verify_ct. And every chunk after the prefill token holds 1 to steps + 1 tokens (6 for steps 5, 4 for the tree), the most one verify cycle can commit. All 2,560 pinned records pass that, and there is a test.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 9b6a17a (#116 (comment)), which I withdraw. Codex finished its review of 9b6a17a and left three comments, none with a reply yet.

Blocking

  1. P1: reject runs produced by dirty runner worktrees (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)). It is right.
    • repo_sha records only the committed code. A run made with uncommitted edits to run_matrix.py, server.py or client.py would pass, and the run metadata has no dirty flag for the repository (it has sglang_dirty, not a repo_dirty).
    • Changing the runner files would itself break the byte-identity check against b918c8b. So the natural place for this is the hold wrapper: it can write the worktree's git status --porcelain and git rev-parse HEAD into runs_fresh/ before the runs. first_cycle.py would then void unless that record exists, is clean, and matches each run's repo_sha.
    • If the queued holds don't write such a record yet, they need to before they run.
  2. P2: require each c1/c32 pair to come from the same server (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)). It is right and cheap.
    • The declaration says each configuration is served from one server, and server_info.server_id is recorded.
    • Void unless mtp_s5/c1 and mtp_s5/c32 share a server_id, and likewise for mtp_tree. Add a test.
  3. P2: verify that every chunk advances exactly one cycle (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)). The concern is right, but the suggested check cannot work on these records.
    • In every streamed chunk the second field (client.py: "cumulative spec_verify_ct") is 0. I checked all 2,560 records of the eight pinned MTP runs: the field is 0 in every chunk except where the final count arrives, so "first count 0, then +1 each" would void every record.
    • Please reply on the thread with that. Then add what the data can show: every chunk after the first carries at least 1 and at most steps + 1 tokens (6 for steps 5; 4 for the tree, 3 steps), together with the existing count equality. Void or exclude a prompt that fails, and add a test.

Everything else from my 9b6a17a review still holds.

Codex on 9b6a17a:
- P1 r4155719933: repo_sha cannot show a clean tree. Runs must record repo_sha
  equal to b918c8b. attest_runner.py --watch, started before the holds and
  running outside them, records each hold's checkout HEAD, git status
  --porcelain and the runner files' SHA-256 before and after the hold. A hold's
  runs are void unless both records are clean, at b918c8b, and match b918c8b's
  files.
- P2 r4155719949: the c1 and c32 passes of mtp_s5, and of mtp_tree, must share
  a server_id.
- P2 r4155719961: the server streams the cumulative verify count only in the
  final chunk, so per-chunk counters cannot be checked. A prompt is excluded
  from every pair unless:
  - every chunk but the last carries 0;
  - the last carries the chunk count, which equals spec_verify_ct;
  - every chunk after the prefill token holds 1 to steps + 1 tokens.
Each condition has a test, as does attest_runner itself.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 8b671e4 was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 8b671e4 ("Attest the runner checkout around each hold; check servers and chunks").

  • P1 r4155719933 (dirty runner) is fixed by attestation and has a reply.
    • attest_runner.py --watch records the checkout's HEAD, git status --porcelain and the SHA-256 of run_matrix.py, server.py and client.py when a hold's Python run_matrix.py process appears and again when it exits.
    • first_cycle.py voids a hold unless both records exist, are clean, are at b918c8b, and match b918c8b's blob hashes. Runs must record repo_sha equal to b918c8b.
    • I checked the live setup:
      • The watcher (pid 4133101) runs a scratchpad copy whose SHA-256 equals the committed attest_runner.py.
      • ~/vp-wt/state-fc is at b918c8b with an empty git status --porcelain.
      • The queued plain hold's command (python run_matrix.py --configs plain ... --out-dir /home/ubuntu/vp-data/state/runs_fresh) matches the watcher's process filter: it starts with python, contains run_matrix.py, the runs path and --configs plain . The bash -c and flock wrappers do not.
    • The 2 s blind window is documented.
  • P2 r4155719949 (same server) is fixed and has a reply. A run is void unless the c1 and c32 runs of mtp_s5, and of mtp_tree, both carry a server_id and share it.
  • P2 r4155719961 (chunks) is answered with evidence and has a reply.
    • chunk_counters_ok requires the counter to be 0 in every chunk but the last, the last to equal both the chunk count and spec_verify_ct, and every chunk after the prefill token to carry 1 to steps + 1 tokens.
    • A prompt that fails is excluded from every pair.
    • All 2,560 pinned MTP records pass, consistent with my own check of the counter pattern.
  • Tests and hooks. tests/test_state_safety_first_cycle.py gives 7 passed. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.

Blocking: none. Suggestions: none.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b671e4a21

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

p_tab = prim.sum(0).astype(int)
fisher_p = None
if fisher: # always on the evidence path; the tests' environment has no SciPy
from scipy.stats import fisher_exact

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Make the secondary test available in the declared environment

In the documented repository environment, requirements-cpu.txt installs only NumPy and requirements-dev.txt adds no SciPy, but the evidence path always calls analyse(..., fisher=True). Consequently this import raises ModuleNotFoundError after the runs validate, so first_cycle.py writes no result and analyze_all.sh stops under set -e; either pin SciPy as a runtime dependency or provide a dependency-free/optional implementation of the secondary test.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 98f412a. analyze_all.sh's header and the README now say the analysis runs in the SGLang venv, which provides SciPy. analyze_all.sh already sources scripts/sglang_env.sh, and cycles.py already relies on it. The repository .venv has no SciPy, and its tests skip those calls (fisher=False, and the empty-outcome branch). I left SciPy out of requirements-cpu/dev rather than add a heavy dependency for code that only runs in the SGLang environment.

Comment on lines +75 to +80
hold = running_hold(runs)
if hold is not None and current is None:
current = hold
write(runs, hold, 'before', checkout)
elif hold is None and current is not None:
write(runs, current, 'after', checkout)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle an immediate handoff between watched holds

When the queued MTP hold starts within the two-second polling interval after the plain hold exits, running_hold() changes directly from plain to mtp while current is still non-null. Neither branch handles that transition, so the watcher eventually records plain-after only after MTP has finished, never records either MTP attestation, and waits forever; close the previous hold and open the new one whenever hold != current.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 98f412a. watch() now acts whenever the running hold changes. It writes the current hold's after record and then the new hold's before record, so plain followed by MTP within one poll attests both and the watcher exits. A new test covers back-to-back holds. The watcher started at 13:13Z was stopped before either hold began (runs_fresh/ didn't exist yet). It was restarted at 13:19:55Z from a copy byte-identical to attest_runner.py at 98f412a, as logged in logs/attest_first_cycle.out, and the README says so.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 8b671e4 (#116 (comment)), which I withdraw. Codex finished its review of 8b671e4 and left a P1 and a P2. Neither has a reply yet, and both are right. The P2 affects the watcher that is already running.

Blocking

  1. P2: handle an immediate handoff between watched holds (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)). It is urgent, because it affects the live watcher (pid 4133101, the frozen copy of this file).
    • In watch(), if the MTP hold's Python process appears within one 2 s poll of the plain hold's exit, running_hold() goes straight from plain to mtp while current is still plain. Neither branch fires.
    • plain-after would then be written only after MTP ends (with MTP's timing), mtp-before and mtp-after would never be written, and the watcher would wait forever. The MTP runs would void, and the plain attestation would be wrong.
    • Please handle hold != current with both non-null (write current-after, then hold-before) and add a test.
    • The plain hold has not started yet (it is about 21st in the queue, and runs_fresh/attest/ does not exist), so there is time to restart the watcher from the fixed, committed file before it does. Please say in the README which copy is running and from when.
  2. P1: make the secondary test available in the declared environment (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)).
    • analyse(..., fisher=True) imports SciPy, which requirements-cpu.txt and requirements-dev.txt do not provide. analyze_all.sh sources scripts/sglang_env.sh and so runs in the SGLang venv, which has SciPy; cycles.py already relies on that for its chi-square test. But nothing in the repository states that requirement.
    • Either add SciPy to the CPU requirements, or state in analyze_all.sh and the README that the evidence path runs in the SGLang environment and requires SciPy. The second is what the scripts already do.

Everything else from my 8b671e4 review still holds.

Codex P2 r4155781436: if the MTP hold's Python started within one poll of the
plain hold's exit, watch() missed the change, never attested the MTP hold and
never exited. It now closes the current hold and opens the next whenever the
running hold changes. A test covers back-to-back holds.

Codex P1 r4155781430: analyze_all.sh and the README now state that the analysis
runs in the SGLang venv, which provides SciPy; the repository .venv does not.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 98f412a was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 98f412a ("Attest back-to-back holds; state the SciPy environment").

  • Codex P2 r4155781436 (handoff between holds) is fixed and has a reply.
    • watch() now acts whenever the running hold changes. It writes the old hold's after record, then the new hold's before record, and then sets current. A plain-then-MTP sequence inside one poll is covered by the new test.
    • The live watcher. The process started at 13:19:55 UTC runs a copy whose SHA-256 equals attest_runner.py at 98f412a. ~/vp-data/state/runs_fresh does not exist yet, so no hold had started when the old watcher was replaced.
  • Codex P1 r4155781430 (SciPy) is answered and has a reply. analyze_all.sh and the README now state that the analysis runs in the SGLang venv, which provides SciPy, as cycles.py already requires.
  • Tests and hooks. tests/test_state_safety_first_cycle.py gives 8 passed. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.
  • Everything from my 8b671e4 review still holds.

Blocking: none. Suggestions: none.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 98f412a90f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to +67
if line.startswith('python') and 'run_matrix.py' in line and str(runs) in line:
for hold, configs in HOLDS.items():
if f'--configs {configs} ' in line + ' ':
return hold

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind attestations to the observed runner process

When the watcher points --checkout at a clean worktree but the matched run_matrix.py process is running from a different dirty worktree at the same commit, this records the clean checkout and the run's unchanged repo_sha still passes validation. Fresh evidence beyond the earlier dirty-runner comment is that running_hold() retains only the hold label and never captures or verifies the process's cwd/script path, so the attestation is not tied to the code that produced the artifacts; derive the checkout from the observed PID or verify its cwd before writing the record.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ba630d. running_hold() now returns the matched Python process's PID. At hold start the watcher reads that process's /proc//cwd, and each attestation records pid, process_cwd and runner_dir (the attested checkout's experiments/state_safety, resolved). first_cycle.py voids a hold's runs unless both records name the same PID and process_cwd equals runner_dir, so the runs must have been produced in the attested checkout. Tests cover a different PID in the after record and a process cwd outside the checkout. The live watcher was restarted at 13:27:02Z from a copy byte-identical to attest_runner.py at 6ba630d, before either hold began; runs_fresh/ doesn't exist yet.

Comment on lines +203 to +206
for r in run.values():
top = r.get('top_logprobs') or []
if len(top) != len(r['output_ids']) or any(len(t) < 2 for t in top):
bad += 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject incomplete generation records

When a plain streaming response ends early while keeping output_ids and top_logprobs aligned, this shape check accepts it even though finish_reason is absent, completion_tokens is inconsistent, or aborted_by_client is true. counts() then treats the shortened common prefix as a completed non-divergent generation and removes later exposure, which can bias both primary tables. Fresh evidence beyond the earlier incomplete-top-logprobs comment is that aligned-but-unfinished records still pass; validate the recorded completion metadata as well as logprob shape.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ba630d. A run is void if any record lacks a finish_reason, has completion_tokens different from len(output_ids), or has aborted_by_client set, in addition to the existing top-logprobs shape check. All 4,480 pinned records pass. Tests cover each of the three cases.

Comment thread experiments/state_safety/first_cycle.py Outdated
Comment on lines +195 to +196
sizes_ok = all(1 <= int(x[0]) <= max_commit for x in rec['chunks'][1:])
counts_ok = c[0] == 0 and all(x == 0 for x in c[1:-1]) and c[-1] == n == rec['spec_verify_ct']

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify chunks cover the complete output

When an MTP record's chunk lengths do not sum to len(output_ids), or its first chunk contains more than the single prefill token, these checks can still return true. counts() iterates only the declared chunk lengths and skips all of chunk 0, so it silently omits output positions or misclassifies verify positions while keeping the prompt in the analysis. Fresh evidence beyond the earlier counter comment is the missing token-coverage and one-token-prefill invariants; require chunks[0][0] == 1 and total chunk length equal to the output length.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ba630d. chunk_counters_ok() now also requires chunks[0][0] == 1 (the single prefill token) and chunk lengths summing to len(output_ids). A prompt that fails is excluded from every pair, as the declaration does for chunking problems. All 2,560 pinned MTP records pass. Tests cover both cases.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 98f412a (#116 (comment)), which I withdraw. Codex finished its review of 98f412a at 13:24:16 and left one P1 and two P2s. None has a reply yet. All three are sound and cheap to fix, and the two record checks hold on every existing pinned record.

Blocking

  1. P1: bind the attestations to the observed runner process (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)). This also affects the live watcher.
    • running_hold() matches a process by its arguments only, and attest() reads the --checkout given to the watcher. A run_matrix.py started from another worktree at the same commit, possibly dirty, would be attested with the clean checkout's state.
    • Please read the matched process's working directory (/proc/<pid>/cwd). Require it to equal <checkout>/experiments/state_safety, record it and the PID in each record, and void in first_cycle.py if they are missing or wrong. Add a test.
    • The holds have not started (runs_fresh/ does not exist), so restart the watcher from the fixed file before they do.
  2. P2: reject incomplete generation records (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)).
    • Void a run if any record has no finish_reason, has completion_tokens != len(output_ids), or has aborted_by_client true. A short but aligned record would otherwise count as a complete generation that never diverged.
    • All 4,480 records of the existing pinned runs pass these checks, so they reject only broken records. Add a test.
  3. P2: verify that the chunks cover the complete output (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)).
    • Require chunks[0][0] == 1 (the prefill token alone) and that the chunk lengths sum to len(output_ids), for every MTP record. Exclude or void as for the other chunk checks.
    • All 4,480 pinned records pass. Add a test.

Everything else from my 98f412a review still holds.

…unk coverage

Codex on 98f412a:
- P1 r4155847271: an attestation could describe a clean checkout while the
  matched run_matrix.py ran from another one. Each record now holds the
  observed process's PID and its /proc/<pid>/cwd, read at hold start. A hold's
  runs are void unless both records name one PID and that cwd is the attested
  checkout's experiments/state_safety.
- P2 r4155847291: a run is void if any record lacks a finish reason, has
  completion_tokens other than its output length, or was aborted by the client.
- P2 r4155847301: a prompt is excluded from every pair unless each MTP record's
  first chunk is exactly the prefill token and its chunks cover every output
  token.
All 4,480 pinned records pass the new record and chunk checks. Each condition
has a test.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 6ba630d (#116 (comment)), which I withdraw. Codex finished its review of 6ba630d at 13:30:23 and left one P1. It has no reply yet.

Blocking

  1. P1: bind the attestations to the executed runner path (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)). It is right, and the fix is small.
    • The check covers the process's cwd but not the script it runs. A python /elsewhere/experiments/state_safety/run_matrix.py started from the attested directory would pass, and Python would import server.py and client.py from the script's own directory (sys.path[0]), not from the cwd.
    • Please read /proc/<pid>/cmdline with the cwd, and resolve the script argument against the cwd. Record the result, and void unless it equals <runner_dir>/run_matrix.py. Add a test.
    • The holds have still not started (runs_fresh/ does not exist), so the watcher can be restarted from the fixed file once more before they do.

Everything else from my 6ba630d review still holds.

Codex P1 r4155907745: a run_matrix.py started from the attested directory but
pointing at another copy of the script would pass the cwd check, and would
import server.py and client.py from that other copy's directory. Each
attestation now records the script path from /proc/<pid>/cmdline, resolved
against the process's cwd. A hold's runs are void unless it is the attested
checkout's experiments/state_safety/run_matrix.py. Tests cover the parsing and
the void.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 0ff671d was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 0ff671d ("Bind attestations to the run process's script").

  • Codex P1 r4155907745 (script path) is fixed and has a reply.
    • At the start of a hold the watcher reads /proc/<pid>/cmdline, takes the run_matrix.py argument, resolves it against the process cwd, and records it as process_script.
    • first_cycle.py voids a hold unless process_script == <runner_dir>/run_matrix.py. That directory supplies sys.path[0], so it also fixes where server.py and client.py are imported from.
    • The new tests cover relative and absolute script arguments and a script elsewhere.
  • The live watcher. pid 106027, started at 13:32 UTC, runs a copy whose SHA-256 equals attest_runner.py at 0ff671d. ~/vp-data/state/runs_fresh still does not exist, so no hold has started.
  • Tests and hooks. tests/test_state_safety_first_cycle.py passes. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.
  • Everything from my 6ba630d review still holds.

Blocking: none. Suggestions: none.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ff671d400

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +173 to +175
pids = {r.get('pid') for r in recs.values()}
if None in pids or len(pids) != 1:
problems.append(f'hold {hold}: attestations not bound to one run_matrix process')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind the generated artifacts to the attested process

When complete run files from an earlier unobserved or dirty execution remain in runs_fresh, a later clean matching run_matrix.py process can start and exit before overwriting them; the watcher then replaces the before/after attestations, and this check accepts them because it only requires the two records to share a PID. No run metadata, file timestamp, or content digest is tied to that PID, so the stale artifacts can be published as outputs of the clean process. Fresh evidence after the prior process-binding fix is that the PID is compared only between attestation records and never against any generated artifact; record an execution identifier in each run or attest the produced file hashes.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b91043c. The watcher's after record now holds the SHA-256 of every *.jsonl and *.meta.json the hold wrote under runs_fresh//. first_cycle.py voids a run unless its .jsonl and .meta.json still hash to those values, and unless its meta started_at lies between the hold's before and after times. On time zones: run_matrix.py writes started_at in local time (time.localtime, no zone). Each attestation records time_utc and also time_local, which is the same instant in started_at's local format, plus local_utc_offset, and the window check compares started_at with time_local. The host runs in UTC. Tests cover a stale file and a started_at outside the window. The watcher was restarted at 13:36:05Z from a copy byte-identical to attest_runner.py at b91043c, before any hold; runs_fresh/ doesn't exist yet.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 0ff671d (#116 (comment)), which I withdraw. Codex finished its review of 0ff671d at 13:34:16 and left one P1. It has no reply yet.

Blocking

  1. P1: bind the generated artifacts to the attested process (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)).
    • The attestations now pin the process, but nothing ties the analysed run files to it. Run files left in runs_fresh/ by an earlier, unobserved execution would be accepted next to a later clean process's attestations.
    • Each run's .meta.json already records started_at (for example 2026-10-01T11:31:19 in the pinned runs), and each attestation records time_utc. So a small fix covers it:
      • at the after record, the watcher writes the SHA-256 of every run file the hold produced (*.jsonl and *.meta.json);
      • first_cycle.py voids unless the analysed files match those hashes, and each run's started_at lies between that hold's before and after times.
    • Please state the time zone of both fields, add a test for a stale file and for an out-of-window started_at, and restart the watcher once more before the holds start (runs_fresh/ still does not exist).

Everything else from my 0ff671d review still holds.

Codex P1 r4155947066: stale files in runs_fresh/ would pass. The watcher's
after record now holds the SHA-256 of every *.jsonl and *.meta.json the hold
wrote. first_cycle.py voids a run unless its files still hash to those values
and its started_at lies between the hold's before and after times.
- started_at is local time, from run_matrix.py's time.localtime.
- Each attestation records time_utc and also time_local with the UTC offset,
  so the window check compares like with like. The host runs in UTC.
Tests cover a stale file and an out-of-window start.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of b91043c was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head b91043c ("Tie the analysed run files to the attested hold").

  • Codex P1 r4155947066 (bind the artifacts) is fixed and has a reply.
    • The after record holds the SHA-256 of every *.jsonl and *.meta.json the hold wrote under runs_fresh/<config>/.
    • first_cycle.py voids a run whose files no longer match those hashes, and a run whose started_at is not between the hold's before and after time_local.
  • The time comparison is sound.
    • started_at is local time in %Y-%m-%dT%H:%M:%S, and each attestation now writes time_local in the same format with local_utc_offset. The host is at +0000, and same-format ISO strings compare correctly as text.
    • The window cannot void a good run. At b918c8b, run_matrix.py takes t0 for started_at per pass, inside launch_with_retry(...), after the server is up. That is well after the watcher's before record, which is written within 2 s of the process starting.
  • The live watcher. pid 138671, started at 13:36 UTC, runs a copy whose SHA-256 equals attest_runner.py at b91043c. runs_fresh/ still does not exist.
  • Tests and hooks. tests/test_state_safety_first_cycle.py passes, including the new stale-file and out-of-window tests. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.
  • Everything from my 0ff671d review still holds.

Blocking: none. Suggestions: none.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b91043cf40

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread experiments/state_safety/first_cycle.py Outdated
Comment on lines +303 to +305
if ids is not None:
run_ids = {r['id'] for r in records.values()}
if run_ids != ids:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind each run to the frozen prompt token digest

When run_matrix.py --prompts points to a file that reuses the 960 expected IDs but contains different input_ids, this set comparison still accepts every run: the code validates the canonical prompt file separately, while the run records retain only each prompt's ID and the metadata records neither the prompt path nor its digest. The analysis can therefore publish results for a different prompt population. Fresh evidence beyond the earlier prompt-population comment is that its fix proves only ID equality, not that the runs consumed the token sequences covered by the frozen manifest; record and validate that digest in each run.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c2d6c5c. The watcher now takes the --prompts path from /proc//cmdline, resolved against the process's cwd, and records it as process_prompts together with the file's SHA-256 (prompts_sha256) in both the before and after records. first_cycle.py voids a hold unless both records name the canonical prompt file, the one it has just checked against the frozen manifest, with that file's current hash. As a cross-check, a run is void if any record's prompt_tokens differs from len(input_ids) for that ID in the frozen file. Tests cover another prompt path, a changed hash, a prompt-length mismatch and the --prompts parsing. The watcher was restarted at 13:41:02Z from a copy byte-identical to attest_runner.py at c2d6c5c, before any hold; runs_fresh/ doesn't exist yet.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of b91043c (#116 (comment)), which I withdraw. Codex finished its review of b91043c at 13:39:23 and left one P1. It has no reply yet.

Blocking

  1. P1: bind each run to the frozen prompt token digest (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)).
    • The analysis checks the canonical prompts_fresh.jsonl against the frozen manifest, and each run's ID set against it. But nothing shows that the runs consumed that file: run_matrix.py --prompts could point at another file with the same 960 IDs and different tokens.
    • The runner code is frozen at b918c8b, so the fix belongs in the watcher, which already reads the process's cmdline:
      • record the --prompts path, resolved against the cwd, and the file's SHA-256 in both the before and after records;
      • in first_cycle.py, void unless both equal the canonical file and the manifest-checked digest.
    • As an independent cross-check from data the runs already record, void if any record's prompt_tokens differs from len(input_ids) of that ID in the frozen file. Every run record carries prompt_tokens.
    • Add a test for each, and restart the watcher before the holds start, as before.

Everything else from my b91043c review still holds.

Codex P1 r4155998329: nothing showed that the runs read the frozen prompts. A
--prompts file with the same IDs and different contents would have passed.
- The watcher records the --prompts path from the process's command line,
  resolved against its cwd, and the file's SHA-256, in both the before and
  after records.
- A hold's runs are void unless both name the canonical, manifest-checked file
  with its current hash.
- As a cross-check, a run is void if any record's prompt_tokens differs from
  the frozen prompt's length for that ID.
Tests cover another prompt file, a changed hash, a prompt-length mismatch and
the --prompts parsing.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex has not yet reviewed c2d6c5c. Its summary still shows b91043c. I will re-check its threads on this head before merge.)

Re-review on the exact head c2d6c5c ("Bind the runs to the frozen prompt file").

  • Codex P1 r4155998329 (prompt digest) is fixed and has a reply.
    • The watcher records process_prompts (the --prompts argument from /proc/<pid>/cmdline, resolved against the cwd) and prompts_sha256 (that file's hash at the moment of each record) in both the before and after records.
    • first_cycle.py voids a hold unless both records name the canonical prompt file (str(prompts.resolve())) and match its current, manifest-checked hash.
    • The queued plain hold passes --prompts /home/ubuntu/vp-data/state/prompts/prompts_fresh.jsonl, which is the canonical path.
  • The cross-check is in. A run is void if any record's prompt_tokens differs from that ID's length in the frozen file.
  • The live watcher. pid 179081, started at 13:41 UTC, runs a copy whose SHA-256 equals attest_runner.py at c2d6c5c. runs_fresh/ still does not exist.
  • Tests and hooks. tests/test_state_safety_first_cycle.py passes, including the new tests for another prompt path, a hash changed during the hold, a length mismatch, and --prompts parsing. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.
  • Everything from my b91043c review still holds.

Blocking: none. Suggestions: none.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2d6c5c45c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

)
prim = per['primary/mtp_s5'] + per['primary/mtp_tree']
ctrl = per['control/mtp_s5'] + per['control/mtp_tree']
lp, lc = float(log_odds(prim.sum(0))), float(log_odds(ctrl.sum(0)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle an entirely excluded prompt population

When every prompt fails at least one MTP chunk-consistency check, included is empty and each per-pair array has shape (0,); consequently prim.sum(0) is a scalar and log_odds raises an indexing error here instead of reporting that all 960 prompts were excluded. This can occur precisely when a systematic streaming/counter problem triggers the declared exclusion rule, so treat a zero-sized population as void or return an explicit inconclusive result before computing the statistic.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3589f38. The per-pair arrays are now built with shape (n, 4) via reshape(-1, 4). When no prompt is included, analyse() returns decision 'void' with prompts_declared, prompts_common, prompts_excluded_chunking and prompts_included = 0 before any statistic is computed, and the command line exits non-zero. A new test covers the all-excluded case.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of c2d6c5c (#116 (comment)), which I withdraw. Codex finished its review of c2d6c5c at 13:44:16 and left one P2. It has no reply yet.

Blocking

  1. P2: handle an entirely excluded prompt population (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)). It is right, and the fix is small.
    • If every prompt fails a chunk check, included is empty, and the per-pair arrays have shape (0,) rather than (0, 4). prim.sum(0) is then a scalar, and log_odds raises an indexing error instead of reporting the exclusion. A systematic streaming problem is exactly the case that would empty the population.
    • Please build the arrays with shape (n, 4) even when n == 0. Then, before computing any statistic, return a result with decision: 'void' and the exclusion counts when prompts_included == 0.
    • Add a test with every prompt excluded.

Everything else from my c2d6c5c review still holds. The watcher needs no restart for this change: it touches only first_cycle.py.

Codex P2 r4156046859: with no included prompts the per-pair arrays had shape
(0,), and log_odds failed on the scalar sum. The arrays now always have shape
(n, 4), and when no prompt is included analyse() returns decision 'void' with
the counts, before computing any statistic. The command line then exits
non-zero. A test covers the all-excluded case.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex has not yet reviewed 3589f38. Its summary still shows c2d6c5c. I will re-check its threads on this head before merge.)

Re-review on the exact head 3589f38 ("Treat an analysis with every prompt excluded as void").

  • Codex P2 r4156046859 (empty population) is fixed and has a reply.
    • The per-pair arrays are reshaped to (-1, 4).
    • With no included prompt, analyse() returns decision: 'void' and the declared, common, excluded and included counts before computing any statistic. The CLI then exits non-zero.
    • test_all_prompts_excluded_is_void covers it, and the README notes the case.
  • Watcher. attest_runner.py is unchanged since c2d6c5c, so the running watcher (pid 179081) still matches the committed file.
  • Tests and hooks. tests/test_state_safety_first_cycle.py gives 10 passed. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.
  • Everything from my c2d6c5c review still holds.

Blocking: none. Suggestions: none.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3589f38257

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread experiments/state_safety/first_cycle.py Outdated
Comment on lines +251 to +253
or not r.get('finish_reason')
or r.get('completion_tokens') != n
or r.get('aborted_by_client')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject server-aborted generation records

When SGLang terminates a request with a truthy non-success finish reason such as {"type": "abort"}, and the returned completion_tokens still matches the accumulated output, this check accepts the shortened record because it only tests that finish_reason exists and aborted_by_client is false. counts() then treats that partial prefix as a completed generation, potentially removing later-cycle exposure and biasing both bounds. Fresh evidence beyond the earlier incomplete-record fix is that server-side abort/error reasons remain accepted; require a successful terminal type such as stop or length.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a493cbf. A record now counts as complete only if finish_reason.type is 'stop', or 'length' with len(output_ids) == 256, the declared limit. An abort or error finish voids the run. All 4,480 pinned records pass (3,023 length with 256 tokens, 1,457 stop). Tests cover a server abort and a 'length' finish short of 256.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 3589f38 (#116 (comment)), which I withdraw. Codex finished its review of 3589f38 at 13:49:19 and left one P2. It has no reply yet.

Blocking

  1. P2: reject server-aborted generation records (State safety: implement the declared first-cycle analysis (before its data exists) #116 (comment)). It is right, and the fix is one condition.
    • The completeness check accepts any truthy finish_reason, so a server-side {"type": "abort"} (or an error) with a matching completion_tokens passes. The shortened output then counts as a complete generation.
    • Please require finish_reason['type'] to be stop or length. For length, also require len(output_ids) == 256, the declared max_new_tokens.
    • Every one of the 4,480 pinned records is stop or length, and every length record has exactly 256 tokens, so neither condition rejects a good record.
    • Add a test.

Everything else from my 3589f38 review still holds. Only first_cycle.py would change, so the watcher needs no restart.

Codex P2 r4156099955: a server abort or error has a truthy finish_reason and
passed the completeness check. A record now counts as complete only if it
finished with stop, or with length at exactly 256 output tokens. Of the 4,480
pinned records, 3,023 are length (all with 256 tokens) and 1,457 are stop, so
all pass. Tests cover a server abort and a short length finish.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex has not yet reviewed a493cbf. Its summary still shows 3589f38. I will re-check its threads on this head before merge.)

Re-review on the exact head a493cbf ("Require a normal finish in every first-cycle record").

  • Codex P2 r4156099955 (server-aborted records) is fixed and has a reply.
    • A record is complete only if finish_reason['type'] is stop, or length with exactly 256 output tokens. An abort or error finish voids the run.
    • The new tests cover a server abort and a length finish short of 256 tokens. The fixtures now end in stop.
    • All 4,480 pinned records pass (3,023 length, all at 256 tokens; 1,457 stop).
  • Watcher. attest_runner.py is unchanged since c2d6c5c, so the running watcher still matches the committed file.
  • Tests and hooks. tests/test_state_safety_first_cycle.py gives 10 passed. Pre-commit passes on origin/main..HEAD. The commit is by Samuel Mausberg, with no AI lines.
  • Everything from my 3589f38 review still holds.

Blocking: none. Suggestions: none.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: a493cbf87e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (confirmed on a493cbf)

Codex finished its review of a493cbf at 13:54:30 with "Didn't find any major issues". gh api --paginate shows no review threads on a493cbf. Every earlier Codex thread on this PR has a reply and a fix. My provisional approval (#116 (comment)) now stands without condition. The branch head is still a493cbf, and the attestation watcher runs the committed attest_runner.py (unchanged since c2d6c5c).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant