Repository navigation
feat(devtools): bound test execution inside agent jobs - #4540
Conversation
Nine of every ten pytest runs in the last two days were started by lanes themselves, outside admission, with affected selections of a fifth to a half of the corpus. Inside an agent job the affected and complete tiers refuse with the job command to use, focused runs cap at two workers, and bare pytest exits at configuration. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0eff95cc96
ℹ️ 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".
#4682) ## Summary The corpus and the runner's affected tier run at one fixed width of eight workers, sized to the pytest pool's 12 GiB cgroup ceiling. The descriptor no longer overrides the width, the pytest slot launch timeout is 7,200 s, and the selection gate reads the width from the constant. ## Problem `CORPUS_MAX_WORKERS = 2` made a full corpus run take about seven hours (measured 2026-09-05: 5% after 40 minutes), and the runner's affected tier could not finish a stale-graph run inside its 3,600 s slot timeout, so every pull request's required `verify` check timed out (runs 3669329 and 600822, both at 38%). ## Solution Width 8 (47 minutes for 20,860 tests, measured uncontended 2026-09-03), one constant for both tiers, timeout 7,200 s. ## Verification - `devtools verify --quick`: all gates ok, including `testmon-selection` reporting `workers=8`. - Descriptor contract and slot tests updated for the new timeout. ## Residual risk Bead polylogue-m3018 asked for a modest width after eight workers plus lane-side pytest runs drove oomd kills on 2026-09-04; lane-side pytest is now refused (#4540, #4677) and the pool ceiling bounds the run. Browser responsiveness during a corpus run is the receipt m3018 still wants. Beads: polylogue-m3018 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
…aps (#5783) ## Summary Worker 14 of the Codex review-debt batch (devtools parts 1–3: beads polylogue-1tyq5.42, .43, .44; 75 findings). Five findings are real on current master and fixed here. A sixth defect, in the same pipeline-probe function as #4366, is fixed as a sibling. 68 findings are already fixed on master, 1 is stale, and 1 was not reached. ## Problem - **#5431 campaign closure (`campaign_closure.py:128`):** closure membership used the global prerequisite index, but readiness used `blocks_prerequisites(record)`, which kept only edges stored on the record whose `issue_id` they name. An edge exported under the prerequisite's record was dropped, so the dependent task read as unblocked while its prerequisite was open. - **#4228 continuity (`continuity_scenarios.py:684`):** the self-inspection scenario claimed to cover the read-view catalog but recorded only `capability_declaration_count`. Removing a shipped viewport profile left the scenario green. - **#5380 sweep census (`derived_sweep_census.py:436`):** `sites.setdefault(key, …)` kept the first site under a key. A later archive-wide `no_where` rewrite of the same table in the same function was therefore hidden behind an earlier `state_predicate` site. - **#5315 measurement receipts (`measurement_receipts.py:96`):** empty keys were not escaped, so `{"": {"latency": 10}}` and `{"latency": 10}` flattened to the same path and an unexplained shape change was recorded as `unchanged`. - **#4366 pipeline probe (`pipeline_probe/result.py:324`):** with only one RSS component measured, that component was still supplied while both were declared unavailable, and `WorkloadPhaseObservation` raised. - **Sibling in the same function:** an unbudgeted probe passed no aggregate peak, so `peak_rss_bytes` was declared unavailable even though the paired components produced it. Every ordinary `devtools bench pipeline` run raised; the existing `test_main_*` tests fail on master. ## Solution - Readiness reads the same `_prerequisite_index` as closure membership. `blocks_prerequisites` is deleted. - `explain(subject="capability")` returns `read_view_profile_ids`: every profile's `view_id` from `Polylogue.list_read_view_profiles()`. The scenario compares that list with its fixture oracle. The worker's draft returned the full profile payloads, which exceeded the MCP response budget (`response_budget_exceeded`), so the page carries only the identities. Full metadata stays on the facade and on `/api/read-view-profiles`. `docs/atlas/mcp.md` documents the field. - When SQL sites share a key, the census keeps the broadest scope and that site's location. Only entry order in `docs/plans/derived-sweep-census.yaml` changes; no classification changes. - `_leaves` escapes empty keys and keys containing a quote. - Both RSS components are omitted unless both were measured. `peak_rss_bytes` is marked unavailable only when no peak was computed. - Tests are in the existing module test files, not the worker's `test_codex_debt_w14.py`. The MCP test is `tests/unit/mcp/test_explain_read_view_profiles.py`. The self-inspection oracle now includes `compact`, the profile master added. ## Verification - `agentctl job start polylogue verify_quick --workspace /realm/worktrees/salvage-w14 --wait`: job 2336, `verify: PASSED exit=0 ... head=f040f940bd5e`. - `agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w14 --wait -- tests/unit/devtools/test_derived_sweep_census.py tests/unit/mcp/test_explain_read_view_profiles.py tests/unit/devtools/test_pipeline_probe.py tests/unit/devtools/test_campaign_closure.py tests/unit/devtools/test_measurement_receipts.py`: job 2322 at f040f94, 91 passed. - The same selection plus `tests/unit/mcp/test_capability_pointer_routes.py tests/unit/mcp/test_session_projection_table.py tests/integration/test_continuity_replay.py`: job 2301 at 31528cf2ff (the same tree before the last rebase onto #5801), 117 passed. `test_continuity_replay` passing shows the capability page with profile ids fits the continuity byte budget. - Anti-vacuity: the new tests run with the six production files restored from master (job 2018) and fail. For measurement receipts, the empty-parent case is the red one. The three pipeline `test_main_*` tests fail on master's code with `peak_rss_bytes cannot be both observed and unavailable` (job 2073). ## Self-review - **Sibling sites:** the pipeline-probe receipt had a second observed-and-unavailable contradiction (`peak_rss_bytes`), fixed here. The readiness predicate had one duplicate owner, which is now deleted. No other caller of `blocks_prerequisites` exists. - **Cancellation and shutdown:** no loops or long-running work changed. - **Unbounded reads:** the capability page gains one list bounded by the declared profile catalog (20 ids), not by archive size. The full profile payload is not inlined. - **Fail-open fallbacks:** none. An unmeasured component or peak is declared unavailable, not guessed. - **Compatibility shims:** none. `blocks_prerequisites` is removed rather than kept beside the index. `capability_declaration_count` is replaced in both the scenario and the oracle. - **Removed symbols:** nothing in the repo references `blocks_prerequisites`. - **Production route:** the campaign test runs `campaign_closure.main --json`. The measurement test runs `measurement_receipts.main --record`. The census test runs `census_package`. The probe test runs `_build_budget_report`, and the existing `test_main_*` tests run `pipeline_probe.main`. The MCP test calls the registered `explain` tool with the real facade method and removes `chronicle` from `READ_VIEW_PROFILES`. ## Findings | key | disposition | evidence | test | | --- | --- | --- | --- | | #5431 campaign_closure.py:128 | fixed | `build_report` uses `_prerequisite_index` | `test_campaign_closure.py::test_readiness_uses_edges_attached_to_the_prerequisite_record` | | #4228 continuity_scenarios.py:684 | fixed | `server_cutover.py` `read_view_profile_ids`; scenario fact `read_view_ids` | `test_explain_read_view_profiles.py::test_self_inspection_detects_removed_viewport_profile_on_mcp_route` | | #5380 derived_sweep_census.py:436 | fixed | `DerivedSweepCensus.observe.record` keeps the worst scope | `test_derived_sweep_census.py::test_repeated_rewrite_key_keeps_the_broadest_scope_and_its_location` | | #5315 measurement_receipts.py:96 | fixed | `_leaves` key escaping | `test_measurement_receipts.py::test_distinct_payload_shapes_never_flatten_to_one_unchanged_path` | | #4366 pipeline_probe/result.py:324 | fixed (plus sibling) | `_pipeline_workload_receipt` pairs components; peak unavailability decided after the peak is computed | `test_pipeline_probe.py::test_budget_receipt_omits_an_unpaired_rss_component`, `test_main_*` | | #4585 dev_loop_service.py:378 | not reached | ports are still released before the child binds them | none | | #4540 agent_env.py:36 | stale | the `--commit` verify mode no longer exists | none | | 68 others | fixed-already | line-cited per finding in the worker record; spot-checked on master (agent_env zero-worker cap, campaign exit status, click help passthrough, collection cost child high-water, command catalog ownership, cold-model grading, census regex/tiers/regions/bindings/branches/declaration, dev-loop XDG isolation, throughput receipts, lineage truncation, live proof output, measurement leaves/paths/envelopes, pattern YAMLs, pytest evidence/memory/slot/suite-cost, query envelope/memory budget, agent manual continuation, OpenAPI path normalization) | none | ## Derived-identity closure None of the changed files is in `docs/plans/schema-closure-baseline.json`, and the `schema-closure` gate passes. ## Residuals - #4585 remains open. - `tests/unit/agent_integration/test_manual_contract.py::test_published_examples_use_live_operation_vocabularies_and_preconditions` fails on master's code as well (`'messages' in {NoneType, Literal[...]}`). It is unrelated to this change and was left out of the selection. - The measurement-receipt cases `quoted-empty-key` and `quoted-dotted-key` pass on master too. They pin the new escaping's own consistency; only `empty-parent` is the regression. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at bf68918):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
## Summary Fixes the 15 confirmed Codex P1 findings tracked in polylogue-5gj4u, all in devtools: the xdist worker cap, the durable-write census, the mypy cache seed, the schema-manifest gate, and verification receipts. The previous owner's uncommitted lane state was carried onto current master; this PR finishes the census work, which had left `devtools gate layering` at 158 violations. ## Problem Each row is a Codex review thread confirmed against master 64a9bd0 by triage run `r3-devtools`. The reproductions are in the bead and in each linked thread. ## Solution | Finding | Thread | Disposition | Regression test | |---|---|---|---| | 04.F054 Cap explicit xdist worker requests | [#4540](#4540 (comment)) | Fixed: `resize_worker_argument` reads every `-n`/`--numprocesses` before `--`, resolves `auto`/`logical` through xdist's own hook, writes the capped count into every occurrence, and keeps `--pdb` at 0 | `tests/unit/devtools/test_corpus_worker_memory_bound.py`, `tests/unit/devtools/test_run_tests.py` | | 04.F021 Preserve distinct statement identities | [#5377](#5377 (comment)) | Fixed: a site key carries its occurrence, numbered in source order; alternative texts of one call count once, and statements inside one script count separately. The declaration gains a row for each separate statement (15 rows) | `tests/unit/devtools/test_durable_write_census_regressions.py` | | 04.F022 Track in-memory connections by lexical scope | [#5503](#5503 (comment)) | Fixed: a memory binding exempts only its own scope's single, unconditional binding, and only for statements after it | same file | | 04.F023 Reject unresolved dynamic-helper call targets | [#5503](#5503 (comment)) | Fixed: a missing, computed, or partly unknown table argument becomes an explicit `?` target. A conditional with no readable branch stays "not a string" instead of a hole, so the caller-supplied-SQL helper census keeps seeing it | same file | | 04.F024 Scan runtime DDL in every writer module | [#5503](#5503 (comment)) | Fixed: runtime DDL is observed across `polylogue/storage/**` and in any module that writes a canonical archive table. Private stores that never name an archive table (parser spill databases, the browser-capture registry) stay outside archive state; the delegation scratch graph is declared `disposable_scratch`, which any module may now declare with a reason | same file | | 04.F025 Enumerate every table an executescript creates | [#5503](#5503 (comment)) | Fixed: every `CREATE` in a statement text is classified | same file | | 04.F026 Verify foreign-key cleanup data flow | [#5503](#5503 (comment)) | Fixed: each dynamic write in a cleanup helper must take its identifier and connection from the FK metadata loop (or from the catalog loop plus `PRAGMA foreign_key_list` on the same table and connection) | same file | | 04.F029 Isolate incremental mypy state | [#4807](#4807 (comment)) | Fixed: the gate passes mypy its configured `files` as absolute paths rooted at this checkout, so a sibling's cache entry never matches by path and mypy re-hashes the source | `tests/unit/devtools/test_mypy_daemon_lifetime.py` | | 04.F099 Refuse to compare against HEAD | [#4671](#4671 (comment)) | Fixed: `_merge_base` never falls back to HEAD. On the default branch it uses the first parent; with no comparison history it refuses. The GHA lint job fetches full history, and the CircleCI quick gate fetches master | `tests/unit/devtools/test_verify_schema_manifest.py` | | 04.F100 Validate mandatory train sidecars | [#4671](#4671 (comment)) | Fixed: the evolution gate runs the runtime's own `durable_migration_claims` admission per durable tier; shipped sidecars are immutable like their SQL | same file | | 04.F071 Declare the full verification phase plan | [#4111](#4111 (comment)) | Fixed: the complete plan is built and persisted as `workload_spec` before admission; a refusal or interruption withholds steps from execution, not from the plan. The `finalization` placeholder is removed | `tests/unit/devtools/test_verify.py` | | 04.F072 Do not attribute dirty runs to HEAD | [#4111](#4111 (comment)) | Fixed: a dirty tree is `worktree-sha256:<content>`, an unidentified tree is `None`, and a tree that moved during the run has no build id | same file | | 04.F074 Preserve the workload receipt in AgentCTL output | [#4111](#4111 (comment)) | Fixed: the operation result carries the same `workload_receipt` persisted in run.json | same file | | 04.F075 Record configured pytest concurrency | [#4111](#4111 (comment)) | Fixed: `concurrency` is the widest planned fan-out (gate pool or capped xdist width) | same file | | 04.F098 Re-read the receipt after the owner exits | [#5299](#5299 (comment)) | Fixed: after proving the owner dead, the reconciler re-reads run.json and acts only on a receipt still `running` under the same run id | `tests/unit/devtools/test_verify_runs.py` | No derived-identity closure member changes (devtools, tests, CI, and `docs/plans/durable-write-census.yaml` only). ## Verification All runs through AgentCTL declared operations at head `23f57e45e0` (rebased on master `5d56c3a26f`): - `agentctl job start --workspace /realm/worktrees/polylogue-5gj4u polylogue verify_quick` (job 3393): `verify: PASSED exit=0`. Pre-push quick verify: `verify: PASSED exit=0`. - `agentctl job start --workspace … polylogue pytest_focused -- -n 4 <60 affected test files>` (job 3392): 1156 passed, 14 failed. All 14 are inherited or environment-dependent: - 11 fail identically on master `5d56c3a26f` in a detached worktree (`pytest_focused -- <ids> --on-default-branch`, job 3391): `test_daemon_resilience::test_concurrent_access_safety`, `test_web_reader::test_archive_filter_kwargs_cover_every_storage_lowerable_spec_field`, three in `test_cli_acceptance`, `test_pytest_suite_cost_plugin::test_post_gc_rss_is_read_before_heap_census_allocations`, `test_verification_evidence_lane::test_reconciled_abandoned_run_joins_the_durable_lane`, `test_verification_result::test_projection_uses_the_finalized_step_and_aggregate_counts`, `test_verification_terminal_receipts::test_queued_interruption_keeps_start_time_worktree_provenance`, `test_verify::test_zero_exit_without_a_report_is_a_failed_pytest_step`, `test_retention_probe::test_worker_output_is_qualified_and_retention_ranking_is_separate`. - 3 `test_retention_probe` cases fail only inside the mixed `-n 4` run. The file alone passes them on this branch (job 3398) and on master (job 3397), with the same single inherited failure. - `devtools gate layering`: `gate_passed` (0 semantic violations; 158 before this PR's census work). - Every census, worker-cap, mypy, schema-manifest, and receipt regression named in the table passed in job 3392. ## Self-review Checklists re-read: `docs/review/codex-review-guide.md`, `devtools/AGENTS.md` review rules, and the orchestrate worker contract. Three passes; findings from passes 1 and 2 were fixed here, and pass 3 found nothing new. **Pass 1 findings (fixed):** (a) The census WIP left the declaration unchanged: `devtools gate layering` reported 158 violations. (b) Scanning runtime DDL in every module treated about 60 private spill tables (parser scratch databases, the browser-capture registry, schema journals) as archive state. (c) Occurrences were numbered in `ast.walk` order, so nesting an unrelated statement renumbered sites and could swap their declarations. (d) The `IfExp` change turned a conditional with no string branch into a hole, which hid the `_canonical_schema_inventory_for_ddl` caller-supplied-SQL helper. (e) `_dynamic_table_targets` kept an unused `values`. (f) `ast.AST.lineno` typing. **Pass 2 findings (fixed):** (g) Per-call dedupe collapsed two rewrites inside one `executescript` (a red regression test). (h) The regression module sat outside the scanned layer. 1. ✓ **Siblings and owners.** Census runtime DDL now has one scope rule, `_is_archive_storage_module` or `_writes_archive_table`, used by both `census_package` and `verify_layering._package_pass` through `observe_runtime_ddl` (the `reads_runtime_ddl` pre-filter is deleted from both). The worker-width parser `_worker_requests` is the single reader for the slot; `run_tests` still expands clustered flags first (`test_an_explicit_automatic_width_starts_pytest_at_the_capped_count`). 2. ✓ **The fix itself.** A schema-manifest refusal is a typed `RuntimeError`, which `main()` turns into FAIL/exit 1. `durable_migration_claims` errors become violations, not tracebacks. 3. ✓ **Memory and limits.** No new caps. The worker cap applies the existing memory bound to widths xdist would otherwise resolve after it. 4. ✓ **Cost per unit.** `_writes_archive_table` is one extra pass over each module's calls; the census cost stays linear in module size. 5. ✓ **Interruption.** An interrupted verify run records `status=interrupted` with the declared plan and only the steps it finished. 6. ✓ **Ordering and races.** F098: the reconciler re-reads after the liveness check and acts only on a receipt still `running` under the same run id. 7. ✓ **Failure classification.** A missing schema comparison base is refused rather than compared against itself; a shallow clone says so. 8. ✓ **Silent outcomes.** An unresolved dynamic-helper target is an explicit `?` target that fails the gate rather than being skipped. 9. N/A **Cleanup on failure.** The mypy targets response file is written under the checkout lock and removed after the run; nothing else here acquires resources. 10. ✓ **Identity and keys.** Site keys include a source-order occurrence (`test_occurrences_follow_source_order_across_nesting`). Workload build identity is the commit only for a clean tree, otherwise the content digest. 11. ✓ **Lossless transforms.** `resize_worker_argument` rewrites only width values and keeps every other argument in place. 12. ✓ **Degenerate inputs.** `-n 0` stays no xdist; `-n auto --pdb` becomes 0; `-n64` after `--` is a path, not a width. 13. ✓ **Consumers.** `WriteSite.key` and declaration keys change together (`load_declaration` numbers rows the same way); `reads_runtime_ddl` has no remaining caller (grep 0); `iter_site_payloads` publishes `occurrence`. CI configs fetch the comparison history the gate now requires. 14. ✓ **Tests and stubs.** The `_Run` double in `test_verify_gate_independence.py` gained `declare_workload`/`recorded_git_dirty`; `test_verifier_common_finalizer_adds_receipt_on_early_failure` was removed with the fallback it tested. 15. N/A **Trust boundaries.** No credentials or private data are involved. Generic list: 1. ✓ Each finding has a regression test on the gate's own entry points (`census_package`/`collect_violations`, `resize_worker_argument`, `devtools.verify._main` helpers, `verify_schema_manifest.main`, the real mypy binary for F029). 2. ✓ Sibling search: `grep -rn "reads_runtime_ddl\|_is_archive_tier_runtime_module" devtools tests` finds 0 matches. 3. ✓ The HEAD^ fallback and its test are removed; so are the `finalization` placeholder and the `workload_receipt=None` fallback. 4. ✓ Refusals are typed gate failures with named rules. 5. ✓ Each census regression names its anti-vacuity condition in its docstring. 6. ✓ Fixtures are synthetic: temporary repos and modules only. ## Residuals - The census cannot prove which connection a statement runs on. A module outside `polylogue/storage/` that writes no canonical archive table, yet creates and rewrites a table on an archive connection it was handed, is still unseen. The declared scope is the storage layer plus archive writers. - The mypy gate absolutizes only `files` targets; a config using `packages`/`modules` keeps mypy's stat-trust behaviour (Polylogue uses `files`). - An xdist width injected through configuration (`-o addopts=-n64`, `-c other.ini`) is still invisible to the resizer. - The CircleCI fetch step's first hosted run on this PR is its proof. - The 11 inherited failures above are not fixed here: they fail identically on master and sit outside this PR's scope. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Summary
Inside an agent job (
SINNIXD_PRINCIPAL=agent-control),devtools verifywithout--quickrefuses and names the job to use,devtools testcaps at two workers, and barepytestraises a usage error at configuration.Problem
Audit of the last 48 hours: 1,170 pytest runs, 42 hours of wall time, peak 11 concurrent. 1,164 of them were started by lanes in their worktrees, not by verification jobs, so admission never saw the load. Affected selections were 3,398 to 10,899 tests (median 22% of the corpus). The worker contract forbids this in prose; prose did not hold.
Solution
One module,
devtools/agent_env.py, with three pure decisions read from the environment;verify._main, the worker-args helper inrun_tests, andtests/conftest.py::pytest_configureconsult it. Harness-launched runs carryPOLYLOGUE_PYTEST_RUN_IDand pass the conftest guard.Verification
Residuals
The declared
verify_affectedjob is the only test-tier route for a lane; the reactor dispatches it once per head.🤖 Generated with Claude Code
https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz