Skip to content

fix(devtools): honest interruption, hash, reaping and scratch receipts - #5830

Merged
Sinity merged 3 commits into
masterfrom
fix/codex-p2-devtools
Sep 29, 2026
Merged

Sinity merged 3 commits into
masterfrom
fix/codex-p2-devtools

Conversation

@Sinity

@Sinity Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes five confirmed Codex P2 defects in devtools: interrupted focused runs recorded as failed, a storage-correctness check that could not fail, a waiter that could leak a queued pytest job, queued pytest output that could not be watched, and a suite scratch peak that ignored the one simultaneous measurement.

Problem

  • Interrupted runs. On Ctrl-C, devtools test recorded termination_reason in local metadata only. The focused aggregate carried none, and _terminal_status recognised only the verification_interrupted diagnosis. The evidence receipt therefore said failed.
  • Content-hash check. The idempotency scenario checked only that the stored content_hash was non-empty, which the table's length CHECK already guarantees. A writer storing any fixed 32-byte digest passed.
  • Waiter reaping. _submit exposed the queued job and wrote the waiting message before it installed the reaping handler. A signal in between killed the waiter under the previous handler and left the job in the pytest pool.
  • Queued output. The slot child writes only to its log file, and the client printed that path only after the job ended. TESTING.md told callers to watch agentctl job logs, which never carries pytest output.
  • Scratch peak. Under xdist the controller walks its basetemp, which contains every worker's directory. The aggregate still took the peak from worker receipts only.

Solution

  • run_tests carries termination_reason into the focused pytest_aggregate. devtools.verification_result.INTERRUPTED_DIAGNOSES (verification_interrupted, pytest_interrupted) is now the one vocabulary that both _terminal_status and the result summary read.
  • The scenario compares the stored hash with session_content_hash(normalize_session_timestamps(session)), computed independently of the writer.
  • The reaping handler is installed before job start. Until the job id is known, the handler removes the launch file, so a job the in-flight start created ends without running pytest. After that it cancels the job by id and reference, as before.
  • The waiting message names the captured log path at submission, and TESTING.md says to follow that file.
  • The scratch peak takes the maximum over every receipt that sampled scratch, the controller included.

No file is in the derived-identity closure; these are devtools modules outside polylogue/.

Verification

  • agentctl job start --workspace <wt> polylogue pytest_focused -- tests/unit/devtools/test_run_tests.py tests/unit/devtools/test_verify_runs.py tests/unit/devtools/test_verification_evidence_lane.py tests/unit/devtools/test_verification_terminal_receipts.py tests/unit/devtools/test_verification_scenario.py tests/unit/devtools/test_pytest_slot.py tests/unit/devtools/test_pytest_suite_cost_plugin.py tests/unit/devtools/test_verify.py tests/unit/devtools/test_verification_result.py (job 3151, on the rebased head): passed 350, failed 5.

  • Four of those failures are inherited, and fail identically at origin/master 0914f89 (job 3104, --on-default-branch: 4 failed): test_zero_exit_without_a_report_is_a_failed_pytest_step, test_reconciled_abandoned_run_joins_the_durable_lane, test_post_gc_rss_is_read_before_heap_census_allocations and test_queued_interruption_keeps_start_time_worktree_provenance.

  • agentctl job start --workspace <wt> polylogue verify_quick (job 3135): succeeded.

  • The fifth failure, test_verification_result.py::test_projection_uses_the_finalized_step_and_aggregate_counts, also fails at origin/master f88b4a6 (job 3163, --on-default-branch). It is inherited.

Self-review

Checklists read: docs/review/codex-review-guide.md, the worker-contract generic list. Passes: 2. The first pass found two copies of the interruption vocabulary, in verify_runs._terminal_status and in verification_result._semantic_status. They now share INTERRUPTED_DIAGNOSES. The second pass was clean.

  1. Criteria on the production path: met. Each test drives the production entry point: run_tests.main with an interrupting runner, run_storage_correctness with a patched writer digest, run_pytest against a fake agentctl, and aggregate_suite_cost over receipts.
  2. Sibling sites: covered. git grep 'verification_interrupted' over devtools/ finds three consumers. verify_runs.py:464, the explicit-terminal set, already listed pytest_interrupted. The other two now share one constant. The waiting message is the only pre-wait output in _submit.
  3. Consumers: checked. INTERRUPTED_DIAGNOSES is new, and _terminal_status keeps its signature. The waiting line's format is human text with no parser in the repository (git grep 'waiting for the host pytest slot' finds the source and the new test only).
  4. Failure paths: visible. An interrupted run is labelled interrupted rather than failed. A hash mismatch raises a typed AssertionError inside the scenario check, and the scenario reports that as a failed check.
  5. Tests fail without the change: each docstring names the change that turns it red.
  6. Public boundary: clean. Fixtures are synthetic.

Findings

finding thread node_id disposition evidence test
19.F052 Preserve interruption status in focused receipts PRRT_kwDOR7_N4c6eyNHq fixed aggregate carries termination_reason; pytest_interrupted is an interruption test_interrupted_focused_run_publishes_an_interrupted_evidence_receipt
19.F059 Keep validating the canonical stored content hash PRRT_kwDOR7_N4c6bidrN fixed stored hash compared with the canonical hash test_storage_correctness_rejects_a_non_canonical_stored_content_hash
19.F038 Install reaping before exposing the queued task PRRT_kwDOR7_N4c6ezaUq fixed _on_exit(reap_owned_job) wraps job start test_an_interrupt_right_after_job_start_still_reaps_the_job
19.F037 Expose queued pytest output to pueue follow PRRT_kwDOR7_N4c6exiej fixed log path named at submission; TESTING.md says to follow it test_a_queued_run_names_its_output_log_when_it_submits
19.F042 Use the controller sample for aggregate scratch peak PRRT_kwDOR7_N4c6hmzoT fixed peak taken over controller and worker receipts test_controller_whole_tree_scratch_walk_sets_the_suite_peak

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

Sinity and others added 3 commits September 29, 2026 15:18
- A focused run interrupted by Ctrl-C or a signal carries its termination
  reason into the pytest aggregate, and pytest_interrupted counts as an
  interruption, so the evidence receipt says interrupted, not failed.
- The storage idempotency scenario compares the stored session hash with
  the canonical hash of the normalized session instead of checking only
  that it is present.
- The queued pytest waiter installs its reaping handler before the job
  exists, so a signal right after job start cancels the job, and it names
  the captured log at submission so a queued run can be watched.
- The suite scratch peak includes the controller's whole-tree walk.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@Sinity
Sinity enabled auto-merge (squash) September 29, 2026 13:24
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 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
🔒 Security Review ✅ Completed 2026-09-29T13:27:44.153021Z 9eeb3e9 PR opened
ℹ️ 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.

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