Skip to content

fix(devtools): State verify's verdict where a pipeline cannot lose it - #5417

Merged
Sinity merged 1 commit into
masterfrom
work/stale-branches
Sep 22, 2026
Merged

Sinity merged 1 commit into
masterfrom
work/stale-branches

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Summary

devtools verify ended its output with a gate's ok line whether it passed or failed, so devtools verify | tail reported tail's exit 0 whatever the gates found. Salvaged from fix/test-verify-reds, a two-week-old branch whose other five defects all turned out to be superseded.

Problem

Measured at base 74e1aa3d0: the last line of a green verify --quick is

  gate population-coverage ... ok (1.3s)

and a failing run ends identically. The verdict lived only in the exit status, which a pipeline discards. #4718 gave the last-line verdict contract to devtools test (run_tests.py:681) but never to devtools verify, whose _main ended at _emit(payload, ...).

This is the hazard the environment contract already names — read command exit status directly; a pipeline's final status does not prove an earlier check passed — with no way to comply short of not piping.

Solution

_write_verdict_line, called from _emit, covering all four terminal paths: completion, checkout-import mismatch, affected-admission refusal, and interruption.

Written to stderr, so the --json stdout contract stays exactly one document. A green run's absent diagnosis is omitted rather than reported as diagnosis=unknown — an absent determination is not a failed one.

Live production output at the branch tip:

verify: PASSED exit=0 receipt=.cache/verify/runs/20260922T130618Z-quick-1977478-53268ffe/run.json

TESTING.md:146 is corrected; it claimed the last-line-verdict contract for devtools test alone.

Anti-vacuity — four mutations, each executed and restored

  1. delete the write entirely → assert 'gate populat...... ok (1.3s)' == 'verify: FAIL...0922/run.json', plus two IndexError: list index out of range because stderr was empty. That is the defect itself: a run that exited 1 whose last line is a gate's ok.
  2. guard with if exit_code: so only failures speak → exactly 1 red, test_a_passing_run_states_its_verdict_too. The failing case stayed green, so red/green separates on the named axis and a failure-only verdict cannot pass.
  3. write to sys.stdout → json.decoder.JSONDecodeError: Extra data: line 3 column 1 — the prose landed after the document, exactly as the contract test names.
  4. restore payload.get("diagnosis") or "unknown" → exactly 1 red: + verify: PASSED exit=0 diagnosis=unknown receipt=.... The failing case, which has a real diagnosis, stayed green — so the test pins the absence-vs-unknown distinction, not merely the presence of a line.

Verification

  • Inherited-red baseline at base 74e1aa3d0 before any edit: devtools verify --quick exit 0, 25 gates all ok, zero FAILED. Nothing to attribute.
  • devtools verify --quick at the tip: exit 0, 25 gates, gate set byte-identical to the base run (diffed).
  • devtools render all --check: exit 0, grep -c 'out of sync' = 0 — checked explicitly, since this command can print per-surface sync OK and still exit 1.
  • devtools test over test_verify.py, test_run_tests.py, test_pytest_invocation.py: exit 0, 111 passed, selected 111 / terminal 111.
  • Schema closure: both changed files out. Identity measured directly on both trees, not inferred — index=5274c9cc…, ops=86866235…, identical. Unlike several PRs today, this one carries no rebuild-boundary constraint.

The other five defects on that branch were superseded

Reported rather than landed:

  • the rerun report path — landed as pytest_rerun.py:72 _path_for_receipt, identical remedy
  • the venv diagnosis expectation — head is already parametrized [(False, "gate_unprovisioned_environment"), (True, "gate_missing_executable")]
  • the pueue task-id identity hazard — closed by a different, better mechanism: the pueue route is gone, replaced by agentctl job start with a durable job id and a per-pid result file the runner unlinks first
  • the testmon expectation — head carries the branch's exact assertions
  • current-pytest-summary.json — decided the opposite way on purpose. #4718 closed the same bead choosing "stop naming it" over "write it"; run_tests.py:675 states "The receipt is this run's own file, never a current-* name a concurrent run in the same checkout would overwrite." Reviving the branch would have regressed a landed adjudication.

Residual

devtools verify's agent-tier refusal (verify.py:894-912) returns 2 before any VerifyRun exists and still ends in its own prose refusal rather than a verify: line. That is a refusal before a run, not a run with a lost verdict, so it is left alone; if one sentence shape is wanted for every exit, that path is the remaining gap.

Separately, tests/unit/storage/test_index_generation.py:305 still says "which later blocks archive-root relocation", describing a mechanism #5086 deleted. It is the only surviving reference in the tracked tree — a one-line follow-up owed by that change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

`devtools verify` ended its output with the last gate's status line and
nothing else. A pipeline exits with its last command's status, so
`devtools verify | tail` reports tail's 0 whatever the gates found, and
the per-gate `ok` lines do not close the gap: a run whose third gate
failed still ends its gate output with a later gate's `ok`, which reads
as green to exactly the truncating reader who needed the verdict.

`devtools test` already states its verdict as the last line of its own
output (#4718, `run_tests.main`). That adjudication was scoped to the
focused runner and left the broad verifier saying nothing. This is the
same sentence from the other runner, so one reader habit covers both.

The write sits in `_emit`, which every terminal path in `_main` reaches
— completion, checkout-import mismatch, affected-admission refusal, and
interruption — so no terminal outcome is silent. It goes to stderr, so
the `--json` stdout contract stays exactly one document.

A green verification carries no diagnosis: the payload field is `None`,
an absence rather than a determination that failed, so the clause is
omitted instead of reported as `diagnosis=unknown`.

The receipt named is this run's own `run.json`, never a `current-*` path
that a concurrent run in the same checkout would overwrite.

Salvaged from `fix/test-verify-reds` (2026-09-06), whose other four
defects all landed independently: the pueue-task-id identity hazard is
gone with the pueue route itself (`pytest_slot` now waits on an
`agentctl` job id and clears its per-pid result file), the rerun report
path guard landed as `pytest_rerun._path_for_receipt`, the
`current-pytest-summary.json` promise was adjudicated the other way
(#4718 stopped naming it rather than writing it), and both stale test
expectations match head exactly. That branch is now a delete.

Verification:
  devtools verify --quick — exit 0, 25/25 gates ok, no "out of sync"
  devtools render all --check — exit 0, zero "out of sync" lines
  devtools test tests/unit/devtools/{test_verify,test_run_tests,
    test_pytest_invocation}.py — exit 0, 111 passed
  devtools schema closure devtools/verify.py tests/unit/devtools/
    test_verify.py — both `out`; the derived schema identity is unmoved

Anti-vacuity, executed:
  drop the `_write_verdict_line` call → all three red; the failing case's
    last line is literally `gate population-coverage ... ok (1.3s)` for a
    run that exited 1
  guard with `if exit_code:` → only the passing case red
  write to `sys.stdout` → the json case fails decoding on trailing prose
  restore `or "unknown"` → only the passing case red, on `unknown`

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 13:15
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 35 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: d856e925-a659-41d6-bdc1-697bda7e5365

📥 Commits

Reviewing files that changed from the base of the PR and between 0320e1a and 55d77a1.

📒 Files selected for processing (3)
  • TESTING.md
  • devtools/verify.py
  • tests/unit/devtools/test_verify.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-22T13:22:30.780603Z 55d77a1 PR opened
🔒 Security Review ✅ Completed 2026-09-22T13:21:02.842312Z 55d77a1 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: 55d77a110c

ℹ️ 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/verify.py Resolved
Comment thread devtools/verify.py Resolved
Comment thread devtools/verify.py Resolved
@Sinity
Sinity merged commit b9f0dba into master Sep 22, 2026
3 checks passed
@Sinity
Sinity deleted the work/stale-branches branch September 22, 2026 13:28
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