Repository navigation
State safety: implement the declared first-cycle analysis (before its data exists) - #116
Conversation
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
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 ( Matches the declaration
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.
Suggestions (non-blocking)
|
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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| if m.get('max_new_tokens') != 256 or m.get('top_logprobs_num') != 5: | ||
| reasons.append(f'{run}: generation settings differ from the declaration') |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| 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') |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
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").
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. |
|
@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.
|
@codex review |
|
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.
Blocking: none. Suggestions: none. |
There was a problem hiding this comment.
💡 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".
| if ( | ||
| m.get('model_revision') != MODEL_REVISION | ||
| or info.get('attention_backend') != 'flashinfer' | ||
| ): | ||
| reasons.append(f'{run}: model revision or attention backend differs') |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| 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: |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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
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.
|
@codex review |
|
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").
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". |
There was a problem hiding this comment.
💡 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".
| if not runner_code_matches(str(m.get('repo_sha'))): | ||
| reasons.append(f'{run}: runner code differs from the declaration ({DECLARATION[:7]})') |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| 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') |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| 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)] |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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
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.
|
@codex review |
|
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").
Blocking: none. Suggestions: none. |
There was a problem hiding this comment.
💡 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 |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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
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.
|
@codex review |
|
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").
Blocking: none. Suggestions: none. |
There was a problem hiding this comment.
💡 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".
| 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 |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| 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'] |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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
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.
|
@codex review |
|
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
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.
|
@codex review |
|
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").
Blocking: none. Suggestions: none. |
There was a problem hiding this comment.
💡 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".
| 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') |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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
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.
|
@codex review |
|
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").
Blocking: none. Suggestions: none. |
There was a problem hiding this comment.
💡 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".
| if ids is not None: | ||
| run_ids = {r['id'] for r in records.values()} | ||
| if run_ids != ids: |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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
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.
|
@codex review |
|
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").
Blocking: none. Suggestions: none. |
There was a problem hiding this comment.
💡 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))) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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
Everything else from my c2d6c5c review still holds. The watcher needs no restart for this change: it touches only |
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.
|
@codex review |
|
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").
Blocking: none. Suggestions: none. |
There was a problem hiding this comment.
💡 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".
| or not r.get('finish_reason') | ||
| or r.get('completion_tokens') != n | ||
| or r.get('aborted_by_client') |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
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
Everything else from my 3589f38 review still holds. Only |
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.
|
@codex review |
|
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").
Blocking: none. Suggestions: none. |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Verdict: APPROVE (confirmed on a493cbf) Codex finished its review of a493cbf at 13:54:30 with "Didn't find any major issues". |
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_freshdoesn't exist yet.What's in it
experiments/state_safety/first_cycle.pyfollows the declaration step by step.numpy.random.default_rng(0)and percentile bounds.analyze_all.shruns the analysis once all five runs exist. The README section notes the implementation.Tests
tests/test_state_safety_first_cycle.pyruns on synthetic runs:31 state tests pass, both with and without SciPy, and pre-commit passes, including the host-identity hook and mypy.