Repository navigation
Description
Problem
The resolve → rereview loop can't tell "not converging yet" from "the same finding keeps coming back". The only guards are:
- the iteration limit:
run_cycle.run_cycle(max_iterations, default 3,scripts/run_cycle.py:611) and the orchestrator skills (default 6); - the skills' no-progress guard, which fires only when the same head SHA and the same open finding set repeat (
cc-orchestratorstep 10;cc-orca-orchestratorNo-progress guard). The runtime has no equivalent.
A resolver that pushes a commit which doesn't fix the finding changes the head, so the no-progress guard never fires and the budget is spent on the same finding.
This happened on PR #74. Folding its trusted comment history with review_contract.parse_comment gives:
REV-001 open@CCR-001 → resolved@CCT-002 → open@CCR-003 → not_applicable@CCT-003 → open@CCR-004 → not_applicable@CCT-004
The resolver claimed a resolution twice (once as a fix, once as not applicable), and the next rereview reopened it each time. No guard fired.
Current behavior
- Stable IDs already give identity:
REV-xxxis never renumbered or reused (review_contract.next_finding_id, collision checks inrecover_comment_history). recover_comment_historyfolds history into the latest state and drops the transitions needed to see a reopen.CycleRecorder.failed_attempts/previous_failed_attemptscount failed dispatches, not failed fixes. This issue must not overload that field.
Existing architecture involved
scripts/review_contract.py:parse_comment,recover_comment_history,Findingscripts/run_cycle.py: the resolve/rereview loop,advance,stopscripts/cycle.py:CycleRecorder._pre_routing,close- Result shapes: resolve
finding_outcomes, rereviewverified_findings(both readable after run_cycle: read finding counts from each review skill's documented result shape #81) skills/cc-orchestrator,skills/cc-orca-orchestrator: per-iteration head SHA and open IDs, which they already recordskills/cc-resolve-comments: Triage
Proposed behavior
-
One definition, pure, in
review_contract.py.A finding survives a claimed fix exactly when all three hold:
- (a) same ID: the same
REV-xxxID, which the contract already makes stable identity; - (b) claim: a resolution run (a
CCT-…triage run, or aresolvestructured result) publishes that ID with statusresolvedornot_applicable; - (c) rejection: the next review run after that resolution run (the first later
CCR-…, or the nextrereviewresult) publishes the same ID with statusopen(structured:still_openoropen).
Each (claim, next review) pair counts at most once.
The claim is the status the resolver published, not the disposition. Dispositions (
valid,incorrect, …) are frozen at triage and say whether the finding was right, not whether it was fixed. A resolver that marks a findingincorrectand publishes itnot_applicablehas made a claim. A resolver that marks itvalidbut leaves itopenhas made none.Within one comment or result, the last header for an ID is the run's position. The Allow Claude in read-only roles via isolated worktrees #74 triage comments republish REV-001 as
openand then asresolvedin the same run, and onlyresolvedcounts.These are not survivals and must not be counted:
Sequence Name Why not open@CCR → open@CCT → open@CCRpersisting the resolver never claimed it. The existing no-progress guard and the iteration limit cover it resolved@CCT → resolved@CCRconfirmed fix — resolved@CCT → not_applicable@CCRscope removed the reviewer agreed it no longer applies resolved@CCR → … → open@CCRwith no claim in betweenregression a different phenomenon. It is reported as a regression, not counted here a claim followed by a rereview that couldn't run or returned no readable result unknown no rejection was observed, so nothing is counted Worked example, PR Allow Claude in read-only roles via isolated worktrees #74
REV-001:CCR-001 open (new) CCT-001 open no claim CCR-002 open persisting — not a survival CCT-002 resolved claim #1 CCR-003 open rejection → survival 1 CCT-003 not_applicable claim #2 CCR-004 open rejection → survival 2Result:
{"REV-001": 2}.The function takes an ordered sequence of records and returns survival counts per ID. It works on parsed comments (skills, analysis) and on findings mapped from structured results (runtime).
recover_comment_historyis unchanged. - (a) same ID: the same
-
Runtime.
run_cycletracks survivals from the in-cycle structured results through that function. -
Escalation ladder (named constants, not configuration):
- 1st survival of an ID: the next
resolveprompt names those IDs and requires the agent to:- reproduce with the reviewer's reproduction before editing;
- re-derive the cause, using the diagnosis procedure from cc-implement-issue: systemic triage and diagnosis before editing (related issues, shared cause, stated cause as hypothesis) #82 when present;
- not republish
not_applicablefor them without evidence the rereview did not have. Otherwise it reportsPARTIALLY_RESOLVEDand says the finding is contested.
- 2nd survival of the same ID: stop with
HUMAN_INTERVENTIONbefore dispatching another resolve. The stop reason names the IDs. - No automatic model/profile/provider change. The router escalates only on declared signals (
docs/routing.md). Escalating on repeats is a routing decision for later, informed by the signal below.
Why 2. One survival can be an honestly incomplete fix. Two survivals of one ID across different heads is the Allow Claude in read-only roles via isolated worktrees #74 pattern, and it is exactly what neither existing guard catches. With the runtime's default of 3 iterations, the ladder only bites when the budget would otherwise be spent on one finding.
- 1st survival of an ID: the next
-
Runtime parity.
run_cyclealso applies the skills' existing no-progress guard: samehead_shaand same open set →HUMAN_INTERVENTION. -
Orchestrator skills. Both orchestrators apply the same ladder from the IDs they already record per iteration.
-
Dispositions stay frozen. A survival is status history, never a disposition change.
Scope
review_contract.py (one function), run_cycle.py loop, cycle.py signal and close fields, the two orchestrator skills, one paragraph in cc-resolve-comments, and docs (review-cycle.md Exit conditions, telemetry.md).
Non-goals
- No switching models or profiles.
- No semantic matching of findings reported under different IDs. The ID is the identity, and reviewers must already reuse IDs.
- No change to dispositions or to the comment contract.
- No change to
max_iterationsdefaults. The runtime/skill mismatch (3 vs 6) is noted, not changed here.
Design constraints
- The definition lives in one place, and skills describe it in prose that matches the function.
- Fail closed: an unreadable rereview result doesn't reset or advance counts. The cycle already stops on an unreadable result.
- A resumed cycle (run_cycle: resume an existing change request (--from review|resolve|rereview --pr N) #75) starts with zero survivals. That is conservative (it never stops early) and must be documented.
Acceptance criteria
- The pure function returns
{"REV-001": 2}for the Allow Claude in read-only roles via isolated worktrees #74 history (fixture built from headers only, no prose). - Every row of the "not survivals" table has a unit test that returns 0 for that ID. That covers persisting, confirmed fix, scope removed, regression, and unknown.
- A resolver that leaves a finding
openwith dispositionvalidis not a claim. A resolver that publishesnot_applicablewith dispositionincorrectis. - Multiple headers for one ID in one run: only the last one counts.
- Scripted cycle: a finding reported
resolvedby resolve andstill_openby the next rereview:- after the first survival, the next resolve prompt contains the ID and the directive;
- after the second, the cycle stops with
HUMAN_INTERVENTIONand no third resolve is dispatched.
- Scripted cycle with the same head and the same open set stops as no-progress.
- A finding that is reopened once and then approved completes normally.
Tests / verification
Unit tests for the function (legacy headers and - dispositions included), tests/test_run_cycle.py scripted cycles, and a validate-package.py check that both orchestrators state the ladder.
Dependencies
- run_cycle: read finding counts from each review skill's documented result shape #81 (the runtime must read rereview findings).
- Soft: cc-implement-issue: systemic triage and diagnosis before editing (related issues, shared cause, stated cause as hypothesis) #82 (the diagnosis procedure referenced by the first rung).
- Land after PR Allow Claude in read-only roles via isolated worktrees #74 to avoid conflicts in
cycle.py.
Telemetry / schema impact
Bump SCHEMA_VERSION (next free); payload-only and additive.
repeated_findings(count): IDs that survived at least one claimed fix before this routing. An observed pre-routing signal onresolve/rereviewrows, added toPRE_ROUTING_SIGNALS["observed"]andFIELD_LIMITS.stop_reason(token) on thecyclerow:approved,iteration_limit,no_progress,repeated_findings,stage_not_completed,dispatch_failed,local_only.cc-statsshows stop reasons and cycles with repeated findings. Older rows read as unknown.
Backwards compatibility
No result or comment shape changes. Cycles that converge behave exactly as today.
Suggested implementation areas
scripts/review_contract.py, scripts/run_cycle.py, scripts/cycle.py, scripts/telemetry.py, scripts/stats.py, skills/cc-orchestrator/SKILL.md, skills/cc-orca-orchestrator/SKILL.md, skills/cc-resolve-comments/SKILL.md, docs/review-cycle.md, docs/telemetry.md, docs/instrumentation.md.
Activity