Skip to content

fix(verify): finalize interrupted receipts - #4109

Merged
Sinity merged 1 commit into
masterfrom
fix/verification/full-receipt-timeout
Aug 23, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/verification/full-receipt-timeout

Conversation

@Sinity

@Sinity Sinity commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Summary

Persist terminal verification receipts when an outer runtime interrupts a run.

Problem

Full verification run 20260823T144002Z-all-951463-294cd855 stopped after 10,958 of 20,138 tests at the one-hour boundary, leaving its receipt in running. AgentCTL’s Polylogue project declaration has no one-hour operation timeout, so an external supervisor can end a run without a locally classified outcome.

Solution

  • Translate SIGTERM and SIGINT into a verifier interruption after receipt creation.
  • Finalize active steps and the run receipt as verification_interrupted, including signal reason and conventional exit code.
  • Cover SIGTERM during the pytest step with a receipt persistence test.

SIGKILL cannot be handled by any process; normal terminating signals now leave durable evidence for an operator to extend or retry the declared AgentCTL operation.

Verification

  • devtools test tests/unit/devtools/test_verify.py → 7 passed
  • devtools verify --quick → success (49.26s)
  • Pre-push devtools verify --quick → success

Bead disposition

Bead Disposition
polylogue-012fi Satisfied by this PR after merge

Scope carrier

  • devtools/verify.py: terminal-signal receipt finalization
  • tests/unit/devtools/test_verify.py: SIGTERM regression coverage

Ref polylogue-012fi

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 38d31ef6-966a-4693-8512-51317ab0d580


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.

@Sinity
Sinity merged commit 13b801b into master Aug 23, 2026
1 of 3 checks passed
@Sinity
Sinity deleted the fix/verification/full-receipt-timeout branch August 23, 2026 15:58

@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: 675984a97c

ℹ️ 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 added a commit that referenced this pull request Sep 29, 2026
…#5802)

## Summary

Salvages ChatGPT fleet worker 15 (Codex review debt, beads
polylogue-1tyq5.45, .47, .48, .51, .52: devtools parts 4/6/7, docs,
nix). Of 79 findings: 13 fixed here, 56 already fixed on master, 4
stale, 6 not reached. The worker's patch was built on snapshot
`e1510b53ea`, not master. It was ported hunk by hunk onto current
master, keeping the newer OOM attribution and trusted-parent work in
`verify.py`, `verify_runs.py`, `run_tests.py` and `pytest_slot.py`.

## Problem

- `devtools test --outliers` globbed `last-pytest-*.json` shards. No
verifier writes these any more: each pytest step's report is rebound
into its run step directory, and only `last-pytest.json` is projected.
The command therefore read nothing or stale files (45.01, 45.02).
- A focused `devtools test` that got SIGTERM died in `subprocess.run`.
It wrote no terminal receipt, history or evidence (45.06).
- Queued slot interruptions dropped the start-time worktree provenance
(45.08).
- When a selected directory was missing, pytest exited 4 (usage error).
The missing-path diagnostic only ran on exit 5 (45.10).
- The focused verdict printed a checkout-relative receipt path. `main()`
has `chdir`ed to ROOT, so the path did not resolve from the caller's
directory (45.12).
- `canonical_verification_receipt` preferred `final_git_head`. It
attributed passing tests to a head that moved under the run and was
never executed (45.14).
- The verifier's interruption handlers did not cover selection,
admission or verdict assembly. A signal there left the run `running`
(47.03).
- A refused affected plan returned before any static gate ran (47.21).
- The Home Manager readiness lane required the removed role-ladder
expressions. It rejected the intact module and could not detect a
dropped capability switch (47.22).
- Pattern help and docs advertised `path:sha1[:count]`, but the parser
requires `path:sha1:context_sha1[:count]` (48.01). The SHA-1 anchors
used the security-default constructor (48.03).
- Reconciliation retried publication only for abandoned runs adopted as
failure. A run adopted as success whose first publication was
interrupted never reached history (48.20).

## Solution

- `print_outliers` selects every pytest lane of the newest completed
`--all` receipt (tier `all`, status `success`,
`complete_corpus_covered`). It refuses when a lane report is missing.
The shard glob, its constant and the verifier's `_clear_full_run_shards`
are removed.
- `devtools test` installs a SIGTERM handler around the launch. The
slot's own handler chains into it after it stops the child. The run
finishes with exit 143 and `termination_reason=sigterm`, and the prior
handler is restored.
- Both slot interruption writers pass the captured
`worktree_provenance`.
- The missing-path diagnostic runs on exit 4 and exit 5. The "every path
exists" hint stays exit-5 only.
- Receipt and artifact paths print absolute.
- `source_revision` is set only when the ending head equals the executed
head. It is also unset when the tree is unknown or dirty.
- `_main` runs selection, admission, steps and verdict assembly inside
the interruption handlers. Publication
(`_finish_and_record_verification`) stays outside so a signal cannot
finish a run twice. A refused plan now runs the quick gates through the
same path, keeps the first failing gate's exit and diagnosis, and
otherwise returns exit 2 with `affected_admission_refused`.
- The HM lane checks the three `cfg.mcpEnable*` mappings.
- The pattern gate hashes with `usedforsecurity=False`. The help,
catalog, regenerated `docs/devtools.md` and `docs/structured-logging.md`
name the context-anchor format.
- Reconciliation retries publication for abandoned runs adopted as
success too. The existing per-run dedup keeps it idempotent.

Diverges from the worker: its 47.03 change put publication inside the
handler. That could append a second history row for a run already
finished. Publication is kept outside, and crash-consistent publication
stays with 47.12 (not reached). Its 47.25 change is dropped because
master already rejects malformed registries more strictly.

## Verification

All through AgentCTL on the pushed head's tree or its immediate
predecessor:

- `agentctl job start polylogue verify_quick --workspace
/realm/worktrees/salvage-w15 --wait`: job 2319 on `75059a9ddc` (rebased
head): `verify: PASSED exit=0`.
- `agentctl job start polylogue pytest_focused --workspace
/realm/worktrees/salvage-w15 --wait --
tests/unit/devtools/test_verification_terminal_receipts.py
tests/unit/devtools/test_verify.py tests/unit/devtools/test_run_tests.py
tests/unit/devtools/test_verify_patterns.py
tests/unit/devtools/test_agent_integration_module.py
tests/unit/devtools/test_verify_runs.py
tests/unit/devtools/test_verification_evidence_lane.py
tests/unit/devtools/test_pytest_slot.py`: job 2300 on `4e72110e57`: `2
failed`, both inherited (see residuals); everything else passed.
- After the mypy typing commit: job 2312, `pytest_focused --
tests/unit/devtools/test_verification_terminal_receipts.py
tests/unit/devtools/test_verify_patterns.py
tests/unit/devtools/test_run_tests.py`: `devtools test: PASSED exit=0`.
- Red on master: job 2242 ran the new and changed tests in a detached
master worktree (`e14b47662d`) with production code unchanged. Every new
regression failed: 13 in `test_verification_terminal_receipts.py`, the
sha1 pattern test, the HM lane pass case, both
`test_affected_admission_refuses_without_launching_pytest` params and
the adapted outliers test. The `ending == executed head` canonical
parameter passed there as expected. The same job reproduced the two
inherited failures.
- Derived-identity closure: scratch job 2202 ran `python -m devtools
schema closure` on all 8 changed production files, and every one
reported `out`. The same job regenerated `docs/devtools.md` with
`devtools render devtools-reference`.

## Self-review

- **Sibling sites.** The artifacts line got the same absolute-path fix
as the receipt (45.12). `docs/structured-logging.md` carried the same
stale anchor spelling (48.01). Both slot interruption writers are fixed
(45.08). The verifier's shard clearing was the other half of the dead
shard protocol and is removed with the reader.
- **Cancellation and shutdown.** The focused SIGTERM handler is
installed after the temp-tree guard and restored in `finally`. The held
slot's handler restores it and re-signals, so the two chain. Verifier
publication is outside the handler, which avoids double finishing.
- **Unbounded reads.** The outliers reader globs `runs/*/run.json`,
which retention already bounds (8 successful runs).
- **Fail-open fallbacks.** Outliers refuse on a missing or malformed
lane rather than fall back to older reports. An unknown ending head
yields no `source_revision`.
- **Compatibility shims.** None. The shard constant and clearing are
deleted, not kept alongside.
- **Removed symbols.** `PYTEST_PARALLEL_REPORT_PATTERN` and
`_clear_full_run_shards` have no remaining references in code, tests or
docs.
- **Production route.** The tests drive `run_tests.main`, `verify.main`,
`pytest_slot._run_launch`, `reconcile_and_record_abandoned_verify_runs`,
`verify_patterns.main` and the real lane function. Only host
observations (Git, processes, signals) are replaced.

## Findings

| key | disposition | evidence | test |
|---|---|---|---|
| 45.01 #4162 run_tests.py:116 | fixed | shards unwritten since per-step
report binding (`verify._bind_pytest_reports_to_step`) |
test_verification_terminal_receipts.py::test_outliers_read_all_lanes_of_one_completed_receipt,
::test_outliers_refuse_a_missing_lane_instead_of_falling_back_to_older_reports
|
| 45.02 #4162 run_tests.py:116 | fixed (same change; worker had
fixed-already via shard clearing, which cleared names nobody writes) |
receipt-bound selection |
::test_outliers_read_all_lanes_of_one_completed_receipt |
| 45.06 #4267 run_tests.py:352 | fixed | no SIGTERM handling on master |
::test_focused_sigterm_finishes_receipt_and_publications |
| 45.08 #5544 run_tests.py:427 | fixed | `_write_interrupted_result`
lacked provenance |
::test_queued_interruption_keeps_start_time_worktree_provenance |
| 45.10 #4343 run_tests.py:485 | fixed | `if rc == 5` only |
::test_focused_missing_directory_has_a_path_specific_usage_diagnostic |
| 45.12 #4726 run_tests.py:626 | fixed | `run.relative_run_dir` printed
| ::test_focused_verdict_receipt_is_absolute_from_a_nested_invocation |
| 45.14 #5544 run_tests.py:649 | fixed | `final_git_head or git_head` |
::test_canonical_receipt_never_attributes_an_untested_ending_head |
| 47.03 #4109 verify.py:505 | fixed (publication kept outside; see
47.12) | selection/tail outside `try` |
::test_verifier_finalizes_interruptions_outside_the_step_loop |
| 47.21 #4898 verify.py:1019 | fixed | early `return 2` before
`build_verify_steps` |
::test_refused_affected_admission_still_executes_static_gates;
test_verify.py::test_affected_admission_refuses_without_launching_pytest
|
| 47.22 #4266 verify_agent_integration.py:472 | fixed | role-ladder
tokens absent from module |
test_agent_integration_module.py::test_home_manager_lane_checks_independent_capability_switches
|
| 47.25 #4161 verify_patterns.py:37 | fixed-already (worker claimed
fixed) | `_rules` raises on every malformed shape,
verify_patterns.py:36-63;
test_verify_patterns.py::test_malformed_pattern_registry_fails_closed |
none |
| 48.01 #4199 verify_patterns.py:59 | fixed | help said
`path:sha1[:count]` | generated reference refreshed |
| 48.03 #4199 verify_patterns.py:113 | fixed | default-security
`hashlib.sha1` |
test_verify_patterns.py::test_pattern_entrypoint_marks_sha1_as_non_security_use
|
| 48.20 #5299 verify_runs.py:1282 | fixed | retry branch matched `status
== "failed"` only |
::test_successful_abandoned_adoption_retries_an_interrupted_publication
|
| 45.22, 45.25, 47.12, 48.05, 48.06, 48.17 | not reached | still open;
need design (receipt-bound config, resumable GC, crash-consistent
publication, stale-baseline policy, located violations, unknown
duration) | none |
| 47.08, 47.10, 47.15, 47.20 | stale | code paths removed
(`--recompute`/`--commit`, bootstrap selection, parent-root refusal,
graph publication) | none |
| remaining 55 | fixed-already | worker's line evidence, spot-checked on
current master | none |

## Derived-identity closure

None. All 8 changed production files are outside the closure (`devtools
schema closure`, job 2202).

## Residuals

- These two failures reproduce on master `e14b47662d` (job 2242) and are
unrelated to this change:
-
`tests/unit/devtools/test_verification_evidence_lane.py::test_reconciled_abandoned_run_joins_the_durable_lane`:
the relocated-cache evidence target conflicts with the test's
durable-lane expectation.
-
`tests/unit/devtools/test_verify.py::test_zero_exit_without_a_report_is_a_failed_pytest_step`:
pytest-benchmark options are unrecognized in the free-threaded venv.
- A signal that arrives during publication itself still escapes. That is
47.12.
- Abandoned runs with no recorded ending head now publish no
`source_revision`. This is intended: the head was never observed at the
end.

🤖 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]>
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