Skip to content

fix(devtools): Close nine live P1 findings and name what a worker retains - #5412

Merged
Sinity merged 5 commits into
masterfrom
fix/p1-review-devtools
Sep 22, 2026
Merged

Sinity merged 5 commits into
masterfrom
fix/p1-review-devtools

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Summary

Nine live P1 review findings closed in the verification harness, from a triage of all 35 anchored devtools findings, plus the first measurement that actually constrains the pytest worker-memory ceiling.

Triage

14 STALE, 6 WONTFIX, 15 LIVE — of the live, 9 fixed, 3 declined or out of scope, 3 duplicate rows.

Stale + wontfix is 20/35 (57%), well above the ~33% measured in storage and sources. The devtools area has been rewritten more recently, so anchored lines survive while the code around them is gone — three findings pointed at a coverage-reuse mechanism (_corpus_already_verified, _packages_drift, _reuse_inputs_still_hold) deleted wholesale in #4551. The filter's accuracy is area-dependent, not a single rate.

Two findings were declined with the reasoning stated rather than implemented:

  • Trace flaky reruns before publishing the graph — the condition reproduces, but the remedy is wrong: enabling testmon on a ≤300-node rerun collection is exactly the graph-truncation hazard of a different finding in the same brief. Focused runs now deliberately never load testmon.
  • Shared mypy cache — LIVE in structure (_git_common_dir(root)/polylogue-mypy, nothing keys it by checkout) and unfixed. It needs a byte-length + whole-second-mtime collision that could not be produced without fabricating it, and gate mypy is green in every worktree on this host. Reported, not fixed on a story.

What is fixed

Finding Defect
schema_promote.py promotion writes through schema_registry() → data_home()/schemas, but the audit read polylogue.schemas.__path__ — it audited a tree promotion does not write
verify.py selection a change set of only tests/data/golden/chatgpt-simple.md returned "none", though that file is compared byte-for-byte by test_ui_visual.py:528
verify_testmon_selection.py both sides of the assertion read CORPUS_MAX_WORKERS, so the gate's own declared mutation left it green — a denominator derived from the thing it checks
pytest_slot.py receipts _on_exit re-signalled before sampler.stop() and dispose() unlinked the telemetry sidecar, so a deadline kill left nothing
schema_fast_forward.py line-at-a-time accumulation handed A; B; to execute() in one call
verify.py admission tests the testmon graph never recorded were not counted before the cap. Measured on this checkout: 1,353 declared test files, 1,343 with a recorded execution; the 10 missing hold 68 tests, none of which appeared in the admitted count
verify_population_coverage.py a retained blob with NULL detected_provider returned None and was marked COVERED with witness "retained blob unavailable"
verify_rebuild_routes.py aliases one function's local import leaked module-wide. Measured −60 wrong edges
verify_rebuild_routes.py qualified isinstance(node.value, ast.Name) skipped every chain of depth ≥ 2. Measured +265 edges

gate rebuild-routes is green on the branch and the graph change is real: base 59,226 edges → head 59,431, measured by running both module versions against polylogue/.

The worker-memory ceiling: two levers ruled out

An opt-in heap-retention census was added to the suite-cost plugin (POLYLOGUE_SUITE_COST_HEAP): at each RSS trajectory point it forces a full gc.collect(), records resident pages on both sides of it, and censuses live objects by type. Then it was run for real — tests/unit/storage, 3,357 tests, single process, 1,775 s.

1. A full collection releases nothing. At 12 of 14 sample points RSS went up after gc.collect() (the collector's own allocation); the two that freed anything freed 0.4 and 2 MB.

n=250   rss=372468  after_gc=376304  d=+3836  objs=490884
n=1500  rss=542952  after_gc=542952  d=   +0  objs=741559
n=3357  rss=553772  after_gc=559184  d=+5412  objs=722578

The plateau is not uncollected cycles, so a collection-policy change is not the lever.

2. Live object count plateaus while RSS keeps climbing. 490,884 objects at n=250 → ~741k by n=1500 → 722,578 at n=3357 (flat/declining), while RSS rose ~20 MiB over that same span and ~58 KiB/test overall. Past n≈1500 the growth is not reachable Python objects — it is C-side (SQLite page caches, allocator fragmentation). Object-graph pruning is not the lever either.

3. Two named monotonic Python retainers, not previously named:

  • _pytest.reports.TestReport: 0 → 10,071 (≈3/test — pytest retains every report for the session). At a 15,416-test worker that is ~46k reports.
  • polylogue.schemas.synthetic.relation_solver_runtime._MutualExclusionAnnotation: 0 → 17,425 (≈5/test), plus _StringLengthAnnotation 0 → 2,506. _PARSED_ANNOTATIONS in that module is bounded at 8 entries, so the holder is downstream of that cache, not the cache.

Honest limit, stated rather than smoothed: this directory does not reproduce the 4.7 GiB plateau. It peaked at 547 MiB from an 88 MiB start; linear extrapolation to 15,416 tests gives ~1.3 GiB against the declared WORKER_PEAK_ANON_MIB = 4750. So either retention is superlinear beyond this range, or concentrated in directories not run, or xdist workers differ from a single process. CORPUS_MAX_WORKERS was not moved — nothing here justifies it yet.

Second ceiling-relevant result: with the receipt fix above, a corpus run killed at its deadline now leaves pytest-slot-held-<pid>.result.json carrying its chosen width and measured peak, where the retained-artifact globs collect it. Previously those runs left nothing — the sizing evidence was being destroyed precisely on the runs that most needed it. A final sampler reading is now taken in the signal handler, so the receipt records the live peak rather than "no sample observed the process group".

Anti-vacuity, executed

A combined run with all six of the first commit's edits reverted at once produced exactly 8 failures and no collateral:

test_two_statements_on_one_line_both_apply      SchemaFastForwardError: You can only execute one statement at a time.
test_a_markdown_test_fixture_still_selects_tests  assert 'none' == 'affected'
test_schema_promotion_audits_the_tree_it_writes_to  .../polylogue/schemas == .../xdg-data/polylogue/schemas
test_a_fully_qualified_call_is_reported         'pkg.maintenance.qualified.run_qualified_rebuild' not in frozenset(...)
test_a_local_import_does_not_erase_another_route 'pkg.shadow.real_rebuild' not in frozenset(...)
test_the_width_gate_catches_a_zero_default      assert (... '0 workers' in '...')
test_an_interrupted_held_run_preserves_its_receipt  FileNotFoundError: .../held-run.result.json
test_promotion_audits_the_tree_promotion_writes  .../polylogue/schemas == .../share/polylogue/schemas

Plus separately for the admission estimator — assert (2, 68, None) == (70, 68, None), KeyError: 'unrecorded_tests' ×2 — and for population coverage, assert 'covered' == 'uncovered'.

Each fix also pins the opposite direction so a blanket refusal cannot pass: test_a_completed_held_run_writes_no_interrupted_receipt, test_the_heap_census_is_off_unless_asked_for, test_an_unasked_unrecorded_term_stays_unknown, test_stale_missing_drive_export_uses_only_its_narrow_path_declaration, and pkg.shadow.harmless not in direct_callers.

Verification

Rebased onto d8a52f5ff.

  • devtools verify --quick → exit 0, 25/25 gates green (at the lane's original base this was 21 + the then-known gate atlas red, identical at base and branch; fix(storage): Close seventeen live P1 review findings in the storage tier #5408 has since fixed it on master).
  • devtools render all --check → exit 0, grep -c 'out of sync' = 0.
  • devtools gate schema-closure → 0, observed_count 558 == baseline_count 558, added/removed empty.
  • devtools schema closure → out for every changed production file. Derived identity does not move.
  • Inherited-red baseline: same 6-file selection detached at base → 2 non-passing; on the branch → PASSED, both gone, none added.

Inherited reds fixed forward

test_verify_quick_descriptor_accepts_the_declared_json_projection and test_agentctl_parser_preserves_distinct_verification_pools both assert "checkout" not in complete, but 52c2175db (#5405, the commit immediately before this lane's base) added checkout = "candidate" to [operations.verify_all]. Both were red at base. Fixed rather than left, because the first is in DESCRIPTOR_CONTRACT_TESTS — a descriptor-only devtools verify was red on master.

Collisions and residuals

  • durable_write_census statement identity — measured at HEAD: 12 keys hold >1 distinct statement, hiding 13 durable rewrites (worst: raw_writes.py::execute_raw_admission_plan_async::raw_sessions::update at lines 125/176/189). Declined here: a stable discriminator re-keys all 142 entries of docs/plans/durable-write-census.yaml, and the 12 collided keys need new per-statement adjudications requiring storage-domain judgement. Exact key list is in the lane report.
  • CI queueing headroom — .github/workflows/verify.yml timeout-minutes: 120 vs verify_affected timeout_seconds = 7200. Severity reduced since the workflow is now workflow_dispatch: only. Fix site outside this write scope.
  • _MutualExclusionAnnotation retention lives in polylogue/schemas/synthetic/ and is adjacent to another lane's file. Not touched; reported with numbers.
  • verify_runs.py:1058 still reads covered_by_run, which no code can write since refactor(devtools): excise self-attesting machinery; testmon as one seed #4551 — vestigial, kept because old on-disk receipts may carry it.
  • agent_env.agent_worker_cap has no production caller; only tests reference it.
  • The population-coverage fix is proven on synthetic fixtures only — this checkout reports "Inventory: not evaluated (no source.db)". Against the real archive it may newly report an uncovered construct; that would be a true finding the rule was hiding, not a regression.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

Sinity and others added 5 commits September 22, 2026 11:49
…ness

Triage of 35 P1 review findings at 17566b0; these six reproduce at HEAD.

- pytest_slot: a held run signalled at its deadline (the route verify_all
  and verify_affected take inside the pytest pool) wrote no receipt at all.
  The handler stopped the child and re-raised, so sampler.stop() and the
  return value were never reached, and the caller's disposal removed the
  live telemetry sidecar on the way out. The selected width and the measured
  peak were lost on exactly the runs whose sizing evidence is worth most.
- verify_testmon_selection: the gate's declared anti-vacuity mutation
  (CORPUS_MAX_WORKERS = 0) left it green, because the produced argument and
  the expected value both read the same constant. The refusal is now an
  independent claim about the argument list.
- verify_rebuild_routes: a fully qualified `pkg.mod.rebuild_index(...)` call
  was invisible to the census (only attribute chains rooted directly at an
  ast.Name were read), and module-wide merging of every import let one
  function's local import erase another's binding of the same name. Measured
  over polylogue/: +265 edges, -60 wrong ones.
- verify: the blanket `.md` exemption made a change set of only
  tests/data/golden/chatgpt-simple.md select no pytest, though
  TestGoldenMarkdownRendering::test_chatgpt_simple_session compares that
  exact file. The suffix exemption now stops at tests/.
- schema_promote: the post-promotion audit inspected the installed
  polylogue/schemas package, while promotion writes to the registry's
  data_home()/schemas storage root.
- schema_fast_forward: two semicolon-terminated statements on one line were
  handed to execute() in one call, so a valid transition applied or failed
  on newline formatting alone.

Two inherited reds in tests/unit/devtools/test_verify.py are fixed forward:
#5405 added `checkout = "candidate"` to the verify_all operation without
updating the two assertions that require the key to be absent. One of them
is in DESCRIPTOR_CONTRACT_TESTS, so a descriptor-only verify was red.

Verification: devtools gate format/lint/mypy/rebuild-routes green;
devtools test over the six changed test files green
(.cache/verify/runs/20260922T081111Z-focused-test-1504360-2de9d572 and
20260922T080332Z-focused-test-1486718-9cc77d90).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
The corpus width is bounded by WORKER_PEAK_ANON_MIB = 4750 against a 12 GiB
memory.high, which is why CORPUS_MAX_WORKERS is 2 and a full run takes about
2h43m. Collection is only 583 MiB of that, so ~87% accumulates while the
worker runs tests and plateaus near 4 GiB. The existing RSS trajectory says
WHERE the growth happens; nothing said WHAT holds it, and resident pages look
identical whether something reachable owns them or the collector has not run.

POLYLOGUE_SUITE_COST_HEAP adds, at each trajectory point, a forced full
collection with resident pages recorded on both sides of it and a census of
live objects by type. The pair separates the two cases: pages released by
collecting are a collection-policy problem, pages that survive it are
retention and heap_top names the type holding them.

Opt-in and separate from the O(1) trajectory, because a full gc.collect() plus
one pass over gc.get_objects() is not a cost an ordinary managed run should
pay.

Also renames test_a_later_local_import_does_not_erase_an_earlier_route: its
node id was 108 characters, which conftest rewrites to a digest, leaving the
test unselectable by id.

Verification: devtools test over tests/unit/devtools/test_pytest_suite_cost_plugin.py
and test_verify_rebuild_routes.py green
(.cache/verify/runs/20260922T084553Z-focused-test-1582357-d8458bc8).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
Testmon deselects only what it has recorded; an unrecorded test is unknown
and runs. The affected estimate read its count out of the graph alone, so
every test in a file the graph has no execution for was in the launch and in
none of the arithmetic the 1,000-test cap is applied to. A freshly
initialized or interrupted graph therefore reported a bounded plan and
launched the corpus -- the required-check timeout the admission exists to
refuse.

Measured on this checkout at 2026-09-22: 1,353 declared test files, 1,343
with a recorded execution. The 10 missing ones hold 68 tests, none of which
appeared in the admitted count. Pricing them costs one collect-only pass over
those files: 2.2s standalone, 6.3s on a contended host, against the ~646s the
existing determine_stable() estimate already spends.

The estimate now adds them, and the receipt carries the term separately
because the halves are measured differently -- one from the graph, one from a
collection. Above AFFECTED_MAX_UNRECORDED_FILES the graph is not a partial
oracle but an absent one, and the answer is a typed refusal naming the corpus
boundary rather than a longer collection; that refusal is also reached before
the expensive snapshot, so the worst case gets faster.

Verification: devtools gate format/lint/mypy green; devtools test over
tests/unit/devtools/{test_verify,test_verification_admission,test_testmon_provision,test_verify_test_collection}.py
green (.cache/verify/runs/20260922T092806Z-focused-test-1669979-d189781a).
Anti-vacuity executed: reverting the summation makes the estimate report 2 for
a 70-test plan, and dropping the payload term raises KeyError in two cases
(.cache/verify/runs/20260922T092849Z-focused-test-1671723-4c9cf41f).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
The production half of the previous commit was lost restoring the tree after
its anti-vacuity mutation: `git checkout -- devtools/` discards unstaged work,
not just the mutation, so only the tests landed. This is that half.

Verification: devtools gate format/lint/mypy green; devtools test over
tests/unit/devtools/{test_verify,test_verification_admission,test_testmon_provision,test_verify_test_collection}.py
green (.cache/verify/runs/20260922T093143Z-focused-test-1683453-b0680ab0),
which is the same selection that was red against the mutated source
(.cache/verify/runs/20260922T092849Z-focused-test-1671723-4c9cf41f).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
`_reinspect_unknown_row` returned nothing for two unrelated reasons: the
retained blob is gone, or the blob is right there and the row's nullable
`detected_provider` names no parser to read it with. The stale-row rule
treated every `None` as proof the bytes were unavailable, so a Claude Code
`unknown/decode_failed` row at a declared session path -- which
`coordinator_session_stream` matches with `parse_policy='session'` -- was
marked COVERED by its path alone, with a witness that said "retained blob
unavailable" about bytes the archive still holds. The gate passed without
inspecting them.

The reason is now typed. Only `_BLOB_ABSENT` (no blob tree, or a hash the
store does not hold) is a statement about the archive; a resolution failure
or an unreadable row says the bytes are still here and this check could not
read them, which covers nothing.

Verification: devtools gate mypy/format/lint green; devtools gate
population-coverage PASS; devtools test over
tests/unit/devtools/test_verify_population_coverage.py green
(.cache/verify/runs/20260922T094234Z-focused-test-1720717-368d5739).
Anti-vacuity executed: restoring `observation is None` makes the new case
report 'covered'
(.cache/verify/runs/20260922T094254Z-focused-test-1721437-e956522c).

Residual: this checkout's gate reports "Inventory: not evaluated (no
source.db)", so the change is proven on synthetic fixtures only. Against a
real archive it can newly report an uncovered construct -- that would be a
true finding this rule was hiding, not a regression.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@Sinity
Sinity enabled auto-merge (squash) September 22, 2026 09:55
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 027034e8-fcbc-4f35-97b5-c9d51d6c0361

📥 Commits

Reviewing files that changed from the base of the PR and between 34a9f4c and 316db12.

📒 Files selected for processing (21)
  • devtools/pytest_slot.py
  • devtools/pytest_suite_cost_plugin.py
  • devtools/schema_fast_forward.py
  • devtools/schema_promote.py
  • devtools/testmon_provision.py
  • devtools/verification_admission.py
  • devtools/verify.py
  • devtools/verify_population_coverage.py
  • devtools/verify_rebuild_routes.py
  • devtools/verify_test_collection.py
  • devtools/verify_testmon_selection.py
  • tests/unit/devtools/test_corpus_worker_memory_bound.py
  • tests/unit/devtools/test_pytest_slot.py
  • tests/unit/devtools/test_pytest_suite_cost_plugin.py
  • tests/unit/devtools/test_schema_fast_forward.py
  • tests/unit/devtools/test_schema_lab_commands.py
  • tests/unit/devtools/test_testmon_provision.py
  • tests/unit/devtools/test_verification_admission.py
  • tests/unit/devtools/test_verify.py
  • tests/unit/devtools/test_verify_population_coverage.py
  • tests/unit/devtools/test_verify_rebuild_routes.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 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-09-22T10:05:26.791324Z 316db12 PR opened
🔒 Security Review ✅ Completed 2026-09-22T10:03:03.475214Z 316db12 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.

@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: 316db12306

ℹ️ 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 devtools/testmon_provision.py Resolved
Comment thread devtools/pytest_suite_cost_plugin.py Resolved
Comment thread devtools/pytest_suite_cost_plugin.py Resolved
Comment thread devtools/pytest_suite_cost_plugin.py Resolved
@Sinity
Sinity merged commit 1f996e1 into master Sep 22, 2026
3 checks passed
@Sinity
Sinity deleted the fix/p1-review-devtools branch September 22, 2026 10:08
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