Skip to content

Fix rejected receipt attribution on resume - #574

Open
datacas wants to merge 2 commits into
mainfrom
fix/issue-410-rereview-receipt-field
Open

datacas wants to merge 2 commits into
mainfrom
fix/issue-410-rereview-receipt-field

Conversation

@datacas

@datacas datacas commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Fix rejected receipt attribution on resume

Closes #410

Summary

Rejected schema-2 receipts from trusted change-request comments now report the invalid field, the carrying comment ID and URL, and the receipt's declared attempt ID. On resume, the runtime compares that declaration with the journaled last review or rereview attempt for this change request and current head. A matching rejection stops with a diagnosis; a different or unavailable journal identity is a warning and the current head is reviewed again. Rejected receipts are never reused as evidence. Explicit --from review or --from rereview dispatches a fresh attempt and clears the old gate.

Stop causes are preserved as separate, deterministic, deduplicated text entries. The result and telemetry schemas are unchanged.

Diagnosis

The incident described in #410 is historically documented. A regression now builds a rejected receipt inside the same published-comment fixture used by the cycle and verifies its comment and attempt identity. Command: python3 -m unittest tests.test_ci_policy.AccumulatingCommentTests tests.test_ci_policy.StopCauseTests tests.test_ci_policy.ResumeTests — passed, 22 tests.

The refined issue hypothesis was confirmed in scripts/cycle_review_gate.py: resume parsed trusted comments with a generic exception path, losing comment identity, and review_attempts is reset for each new session instead of being recovered from journaled review dispatches. The invariant is that only the journaled dispatch for this pull request and exact head can make its rejected receipt a stop; a rejected receipt is never evidence. A permission refusal remains a separate cause.

Related items reviewed: #406, #393, #382, #438 and #459. #406, #393, #438 and #459 are closed; #382 remains open and is out of scope. The code search covered the review gate, journal event records, resume dispatch path, and the owning execution-plan documentation.

Work units

Unit Behaviour Files Tests Verification Rollback
WU-1 Attribute rejected receipts to published comment metadata and the journaled review attempt; keep warnings and stop causes distinct; document recovery. scripts/cycle_review_gate.py, scripts/cycle_session.py, tests/test_ci_policy.py, docs/execution-plan.md Published-comment identity, resume gate/recovery, and stop-cause regressions. Focused 22-test suite passed; python3 scripts/validate-package.py, basedpyright, and git diff --check passed. Full discovery exceeded the 10-minute limit and remains unverified. independent

Verification

  • Passed: python3 -m unittest tests.test_ci_policy.AccumulatingCommentTests tests.test_ci_policy.StopCauseTests tests.test_ci_policy.ResumeTests (22 tests).
  • Passed: python3 scripts/validate-package.py.
  • Passed: basedpyright (0 errors, 0 warnings, 0 notes).
  • Passed: python3 -m unittest (0 tests discovered by this command).
  • Unverified: python3 -m unittest discover -s tests did not finish within the required 10-minute limit; it was stopped at 10 minutes. The command emitted some errors and a failure before timing out, without reaching its traceback summary.
  • Passed: rtk git diff --check.

Documentation review

Reviewed docs/execution-plan.md (updated), docs/README.md, README.md, CONTRIBUTING.md, AGENTS.md, SECURITY.md, and .github/ISSUE_TEMPLATE/work-item.md. There is no pull-request template. The behavior belongs in the execution-plan guide; the index and overview only link to topic pages, and the other reviewed guidance remains current.

CI policy is parallel. The code-host checks for the pushed head are reported separately after publication; this stage does not wait for them.

Checks of the published head

Head: 43d5a08fc0c1ff15be51db6312702cae51f91102.

  • Classify the change: passed.
  • Windows test shard (windows-1): pending.
  • Windows test shard (windows-2): pending.
  • Windows test shard (windows-3): pending.
  • Windows test shard (windows-4): pending.
  • Skills, manifests, and Bash installer: pending.

@datacas

datacas commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

Implementation summary for issue #410

Rejected receipts now include their invalid field, comment identity, and declared attempt. Resume compares that declaration with the journaled review attempt for the current change request and head; only a match stops. Other rejected receipts are warnings and trigger a fresh review. --from review or --from rereview dispatches a replacement attempt. The execution-plan guide documents the behavior and recovery path.

Verification: the focused 22-test suite, package validator, BasedPyright, and diff check passed. The required full discovery command exceeded the 10-minute limit and remains unverified, so this implementation attempt is reported as BLOCKED pending that check.

@datacas

datacas commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261203-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:2

CHANGES_REQUESTED on 43d5a08fc0c1. Full diff reviewed (362 lines). 1 blocking finding, 2 non-blocking.

  • REV-001: a rejected receipt of the gated attempt is never stopped or reported on automatic resume (it forces start_from=review|rereview). Fix: tell explicit --from apart from auto-resume and report the gated diagnostic. Test: none for this path.
  • REV-002 (low): declined-check cause is still ;-joined in one entry (AC4).
  • REV-003 (low): any rejected receipt forces a re-review on every resume.
  • Security: audit skipped, no sensitive change. CI: 6 of 7 checks passed, PowerShell installer pending.
Findings, evidence, verification, CI

[REV-001] · high · open · - · blocks:yes — Gated rejected receipt is neither stopped nor reported on automatic resume

Path: scripts/cycle_review_gate.py:314-322 (AC1, AC3). scripts/cycle_cli.py:42 sets args.start_from = resume.start_from on auto-resume, so self.start_from is review or rereview even though nobody passed --from. reusable_review treats that value as the explicit recovery path: it skips the stop, and the gated diagnostic is never added to self.report.notes (only the non-gated diagnostics are). cycle_loop.py:223-227 calls reusable_review for exactly this case.
Evidence (executed, mock session over the PR's own rejected_history and journal_attempt fixtures): start_from=implement returns the stop; start_from=review and start_from=rereview return (None, None), stop is not called and notes == []. The rejected receipt of the journaled attempt is dropped without any output and the head is silently reviewed again. That contradicts AC3 (the gated attempt stops with an explicit diagnosis on resume) and AC1 (the rejection is reported). The new tests only use start_from="implement" or run resume(start_from="review") end to end, so none covers auto-resume. docs/execution-plan.md also says recovery is an explicit request.
Suggested fix: bypass the stop only when --from was explicit (not self.automatic_resume). Also note the gated diagnostic when recovery is taken. Add a regression with automatic_resume=True.

[REV-002] · low · open · - · blocks:no — Declined-check cause is not its own stop entry

Path: scripts/cycle_session.py:445-447. because += "; " + self.declined_summary() is appended before stop_cause_entries, so it stays inside the primary entry and several declined checks stay ; -joined. AC4 asks for each independent cause as its own entry. StopCauseTests only covers receipt and refusal causes.

[REV-003] · low · open · - · blocks:no — Any rejected receipt forces a re-review on every resume

Path: scripts/cycle_review_gate.py:321-322. The rule follows AC3 literally, but a rejected receipt of an old or other attempt stays in the comment history for good. Every later resume then returns (None, None) before the stop_on_repeat duplicate-dispatch guard and ignores a valid clean receipt of the current head. It reverses the #438 behaviour kept in receipt_problem. Residual risk: repeated reviews of an unchanged head. Consider limiting it to rejected receipts newer than the last valid one.

Acceptance criteria

  • AC-1: partially met — format and identity correct on the warning path and the in-run stop; missing on the recovery path (REV-001).
  • AC-2: met — test_..._malformed_receipt_... asserts comment_id, URL and attempt_id from a published-comment fixture.
  • AC-3: not met on auto-resume (REV-001); met for a fresh run and explicit --from.
  • AC-4: partially met (REV-002); no schema change.
  • AC-5: met (docs/execution-plan.md), but see the wording under REV-001.

Security triage

Not a sensitive change: the security audit was skipped after triage (neither the deterministic rule nor review matched; no auth, input, secrets or CI paths touched). security_required: false.

Verification

  • python3 scripts/validate-package.py: passed.
  • basedpyright: 0 errors, 0 warnings.
  • python3 -m unittest tests.test_ci_policy: 58 tests, 1 failure (test_an_invalid_clean_result_is_a_stage_that_did_not_complete, subcase dispatch_failed != stage_not_completed). It passes on its own, and the run overlapped the full suite, so it is likely load-related. Not attributed to this change.
  • python3 -m unittest discover -s tests: exceeded the 10 min limit and was moved to background. not_verified.
  • python3 -m unittest (plain): not run, not_verified.
  • Executed probe of reusable_review as described in REV-001.

CI (parallel policy, read once)

Passed: Classify the change, Skills/manifests/Bash installer, Windows test shards 1-4. Pending: PowerShell installer.

Documentation reviewed

docs/execution-plan.md updated. The README and skills are not affected.

@datacas

datacas commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

[CCT-20261203-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:43d5a08fc0c1ff15be51db6312702cae51f91102 · schema:2

Resolved in 44af9a8c0c382696bc90fdd90903166ed7191f78:

  • REV-001: automatic resume stops with receipt identity; explicit --from dispatches recovery.
  • REV-002: declined checks are separate, deterministic stop causes.
  • REV-003: a later clean same-head receipt supersedes an older rejection; its warning remains.

Delta review found no issues; security audit was not required. Tests: 2,916 passed (1 skipped); package validation and type check passed. No GitHub checks were reported. docs/execution-plan.md updated.

Finding history, evidence, and prior receipts

[CCR-20261203-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:2

[REV-001] · high · open · - · blocks:yes — Gated rejected receipt is neither stopped nor reported on automatic resume

Original finding: scripts/cycle_review_gate.py:314-322. Automatic resume sets start_from to review or rereview, so the prior gate incorrectly treated it as explicit recovery and dropped the diagnostic. Resolved by distinguishing automatic_resume; the stop now includes the rejected field reason, comment_id, URL, and declared attempt_id. The explicit recovery path still dispatches a new attempt.

[REV-002] · low · open · - · blocks:no — Declined-check cause is not its own stop entry

Original finding: scripts/cycle_session.py:445-447. Multiple declined checks were semicolon-joined into a single cause. Resolved by keeping each declined check as its own entry and sorting/deduplicating all stop causes.

[REV-003] · low · open · - · blocks:no — Any rejected receipt forces a re-review on every resume

Original finding: scripts/cycle_review_gate.py:321-322. An older rejected receipt remained in accumulated comments and repeatedly forced review after a newer clean receipt. Resolved by retaining the warning but allowing a later clean runtime review receipt for the same head to supersede the older rejected receipt. Rejected receipts are stripped before trusted receipt recovery and never used as evidence.

[REV-001] · high · resolved · valid · blocks:yes — Gated rejected receipt is neither stopped nor reported on automatic resume

Path: scripts/cycle_review_gate.py.

[REV-002] · low · resolved · valid · blocks:no — Declined-check cause is not its own stop entry

Path: scripts/cycle_session.py.

[REV-003] · low · resolved · valid · blocks:no — Any rejected receipt forces a re-review on every resume

Path: scripts/cycle_review_gate.py.

Agent-reported verification:

Check Result Evidence
configured-test (runtime / runtime, project) pass python3 -m unittest discover -s tests — exit 0; 2,916 tests, 1 skipped; 821.403s
ac-regressions (runtime / runtime, project) pass python3 -m unittest tests.test_ci_policy.AccumulatingCommentTests tests.test_ci_policy.StopCauseTests tests.test_ci_policy.ResumeTests — exit 0; 23 tests
package-validator (runtime / runtime, project) pass python3 scripts/validate-package.py — exit 0
basedpyright (runtime / runtime, project) pass basedpyright — exit 0; 0 errors, 0 warnings, 0 notes
plain-unittest (runtime / runtime, project) pass python3 -m unittest — exit 0; 0 tests discovered
diff-check (runtime / runtime, project) pass git diff --check — exit 0

GitHub checks read once after push on 44af9a8c0c382696bc90fdd90903166ed7191f78: none reported (0 passed, 0 failed, 0 pending).

Documentation reviewed: docs/execution-plan.md updated; docs/README.md, README.md, CONTRIBUTING.md, AGENTS.md, SECURITY.md, .github/ISSUE_TEMPLATE/work-item.md; no pull-request template present.

Prior implementation receipt:

Prior review receipt:

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.

Rereview resume reports an invalid execution plan receipt without naming the field or separating it from other stop causes

1 participant