Skip to content

fix(review): diagnose malformed triage run lines - #299

Merged
datacas merged 3 commits into
mainfrom
task-253
Oct 21, 2026
Merged

datacas merged 3 commits into
mainfrom
task-253

Conversation

@datacas

@datacas datacas commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Keep the strict run-line contract and add actionable diagnostics for missing triaged:<sha>, invalid SHA tokens, and an extra leading stage token.
  • Validate the resolver's staged comment with the shared parser before publication, and block a tracked publication if readback cannot validate it.
  • Preserve malformed history as a BLOCKED stop with a comment link, line number, rejected token, and manual repair instructions.

Closes #253

Diagnosis

The issue reports a resumed cycle stopping when a trusted resolver comment contains a malformed CCT- run line. parse_run_line correctly rejected the missing triaged:<sha> token, while history recovery wrapped that error as an unreadable-history stop without naming the line or repair. A reported production example also had a leading resolve token, which shifted the fields and made high the rejected token. The invariant is that triage history remains strict and is never dropped or reinterpreted, while every malformed line identifies the exact correction needed. Related work was searched widely: #298 tracks approved runtime-assisted repair separately; #279 is the closed environment issue that surfaced the additional reproduction; #247/#252 are the work-item and change-request context.

Work units

Unit Behaviour Files Verification Rollback
WU-1 Add diagnostics and shared staged-comment validation, enforce resolver prepublication and tracked postpublication checks, and cover malformed resume history scripts/review_contract.py, scripts/run_cycle.py, scripts/stage_permissions.py, scripts/validate-triage-comment.py, scripts/runtime.manifest, skills/cc-resolve-comments/SKILL.md, and related tests python3 -m unittest discover -s tests; python3 scripts/validate-package.py independent; reverting this commit restores the previous generic stop and no resolver validator

Verification

Agent-reported evidence:

  • rtk python3 -m unittest discover -s tests — passed, 1,658 tests.
  • rtk python3 scripts/validate-package.py — passed (VALID).
  • rtk python3 -m unittest — exit 0, 0 tests discovered.
  • rtk git diff --cached --check — passed.

Boundary verification is required for the validator CLI. The implement-stage command table does not permit invoking it; the exact invocation is resolver-only. The shared validator and the resolver command rule are covered by the configured suite, but direct CLI execution remains unverified in this stage.

Commit: 4990a4c517f985e7117f5f6016f7441a6d1db2e5.

CI checks

Pushed head: 4990a4c517f985e7117f5f6016f7441a6d1db2e5.

  • Skills, manifests, and Bash installer — pending (queued).
  • Windows test shard (windows-1) — pending (in progress).
  • Windows test shard (windows-2) — pending (in progress).
  • Windows test shard (windows-3) — pending (queued).
  • Windows test shard (windows-4) — pending (queued).

@datacas

datacas commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

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

Initial review — CHANGES_REQUESTED

Scope: accumulated diff origin/main...4990a4c517f985e7117f5f6016f7441a6d1db2e5 (345 lines, merge base a1afafdb425ff9c8a3ad0fb66e79109811ad9b73), work item #253. Repository conventions applied: AGENTS.md (routing only; no review rules), skill defaults.

Summary: the diagnostics in parse_comment and the tracked postpublication validation work as described and are covered by tests. One blocking problem: the resolver's validator command is a path relative to the working directory, so it only works inside the toolkit's own repository.

Findings

[REV-001] · medium · open · - · blocks:yes — Resolver validator is invoked by a repo-relative path

skills/cc-resolve-comments/SKILL.md:695, scripts/stage_permissions.py:533, scripts/stage_permissions.py:1176

The skill and the command table authorise exactly python3 scripts/validate-triage-comment.py <TMPDIR>/pr-comment.md. That path is resolved against the stage's working directory, which is the clone of the project being worked on. The file is shipped through runtime.manifest into the installed runtime, not into the project clone. In any project other than the toolkit itself:

  • the command fails with "No such file", so the mandatory "validate before publishing" step cannot be carried out; or
  • if the project (or the PR under work) contains a file at that path, the allow-list lets the resolver execute project-controlled code, which is outside the closed command table's intent.

Inspection-based: the CLI could not be run in this review stage (see Unverified). Suggested direction: reference the validator through the installed runtime location (or have the runtime inject its absolute path into the policy and prompt) and match that path in _check_words/allowed_tool_patterns.

[REV-002] · low · open · - · blocks:no — New BLOCKED paths in after_publication are untested and the docstring is stale

scripts/run_cycle.py:2372-2416

Previously a sync failure (CycleDriverError, ContractError, HistoryError) became a warning ("local history not synced") and the next dispatch retried. Now every one of them, including transient provider/history errors, returns BLOCKED after the stage already published. This matches the PR description, but the docstring still says an unobserved publication "is flagged, and the next dispatch of the same stage retries it". The new store-less branch (history_store is None) and the CycleDriverError/HistoryError stops have no test; only the resume-history path is covered.

[REV-003] · low · open · - · blocks:no — Validator CLI untested; diagnostics depend on error-message substrings

scripts/validate-triage-comment.py, scripts/review_contract.py:405-419

No test executes validate-triage-comment.py (exit code, stderr format, unreadable file). parse_comment selects its repair hint by substring-matching ContractError text from parse_run_line; rewording either side silently degrades the diagnostics to the generic message. Typed errors or a shared constant would make the coupling explicit. The "extra stage token" hint can also misfire for a profile legitimately named review/resolve/rereview, though only on a line that is already rejected.

Security triage

Sensitive by reviewer judgement (the rule in .code-cycle.yml was not separately evaluated; defaults applied): scripts/stage_permissions.py changes the closed command table of a stage. No delegated cc-security-review pass was available in this dispatch; the equivalent checks were done by inspection and produced REV-001 (command-allow-list scope). No other trust-boundary issue found: the validator reads one file and prints to stderr, with no network or write side effects.

Executed

  • python3 -m unittest discover -s tests — exit 0, 1658 tests OK (294 s).
  • python3 scripts/validate-package.py — VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned.
  • python3 -m unittest was not run separately: it discovers 0 tests here and adds nothing over the suite above.

Unverified

  • Direct invocation of scripts/validate-triage-comment.py: the review stage's command table does not allow it and the stage cannot create the staged input file. Behaviour is inferred from reading.
  • REV-001 outside the toolkit repository: inferred from code and install layout, not reproduced.

CI (policy: parallel; head 4990a4c)

All pending at read time: Skills, manifests, and Bash installer, Windows test shard (windows-1) … (windows-4) — in progress. Not waited for.

Residual risk

Windows behaviour of the new path handling in stage_permissions.py (Path(policy.tmpdir) / "pr-comment.md" vs the $TMPDIR form) depends on the pending shards.

Verdict

CHANGES_REQUESTED — blocking: REV-001.

@datacas

datacas commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

Resolution summary

The three findings are resolved in commit 05f273d4ecbb4d291d42dff7dd0ae88001c57c81.

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

[CCT-20261021-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:4990a4c517f985e7117f5f6016f7441a6d1db2e5 · schema:2

Findings

[REV-001] · medium · resolved · valid · blocks:yes — Use the installed runtime validator

The resolver now invokes the validator from the installed runtime using the absolute path supplied by the runtime. The hook allows only that exact validator and the staged $TMPDIR/pr-comment.md input. This works from projects that do not contain the toolkit source tree and avoids executing a same-named file controlled by the project. The path is normalized for Windows.

[REV-002] · low · resolved · valid · blocks:no — Clarify publication reconciliation failures

Updated the after_publication docstring to distinguish failed history reconciliation, which blocks after publication, from a successful reconciliation that did not observe this attempt, which is retried on the next dispatch. Added regression coverage for malformed readback and provider read failures when the local history store is unavailable.

[REV-003] · low · resolved · valid · blocks:no — Stabilize validator diagnostics and exercise its CLI

Run-line diagnostics now use typed error categories instead of matching error-message text. The duplicate-stage hint is limited to lines whose fields show the shifted layout. Added CLI coverage for valid comments, contract errors with line numbers, and unreadable files.

Failed check on the reviewed head

On 4990a4c517f985e7117f5f6016f7441a6d1db2e5, Windows test shard (windows-4) failed during its test step; PowerShell installer then failed its aggregate Windows-shard gate. Shard 4 includes test_stage_permissions and test_review_contract. The new resolver permission test passed a raw absolute temporary-file path through the command parser, which treats backslashes as escapes on Windows. I changed it to use the runtime validator path and $TMPDIR expansion, and normalized the runtime path to forward slashes. The GitHub annotation only reports exit code 1; gh run view 39580920275 --job 119158023359 --log-failed could not retrieve the detailed log because the sandbox blocked results-receiver.actions.githubusercontent.com. The Windows jobs on the pushed head are pending, so this remote fix is not yet confirmed there.

Verification

Agent-reported local results:

  • rtk python3 -m unittest discover -s tests — passed, 1,662 tests.
  • rtk python3 scripts/validate-package.py — passed (VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned).
  • rtk python3 -m unittest — exited 0, 0 tests discovered.
  • rtk git diff --check — passed.
  • Post-change cc-code-review — no remaining actionable findings. cc-security-review — no confirmed vulnerabilities.

Checks on pushed head

Head: 05f273d4ecbb4d291d42dff7dd0ae88001c57c81.

  • Skills, manifests, and Bash installer — pending.
  • Windows test shard (windows-1) — pending.
  • Windows test shard (windows-2) — pending.
  • Windows test shard (windows-3) — pending.
  • Windows test shard (windows-4) — pending.

@datacas

datacas commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

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

Rereview — REVIEW_PASSED_AWAITING_CI

Scope: full accumulated diff origin/main...05f273d4ecbb4d291d42dff7dd0ae88001c57c81 (517 lines, merge base a1afafdb425ff9c8a3ad0fb66e79109811ad9b73), work item #253. Previous reviewed head: 4990a4c517f985e7117f5f6016f7441a6d1db2e5 (CCR-20261021-001). Repository conventions applied: AGENTS.md (routing only; no review rules), skill defaults.

What changed since the previous review: the resolver validator is now referenced by the absolute path of the installed runtime (_triage_validator_path) in the hook, the allow pattern and the prompt note; the after_publication docstring was corrected and the store-less/provider-failure BLOCKED paths got tests; run-line diagnostics now use a typed RunLineContractError (kind, token) instead of message substrings, and the duplicate-stage hint requires the shifted layout (tokens[0] a stage name and / in tokens[2]); tests/test_review_contract.py now runs the validator CLI (valid, contract error with line, unreadable file).

Previous findings

[REV-001] · medium · resolved · valid · blocks:yes — Resolver validator is invoked by a repo-relative path

scripts/stage_permissions.py:534, scripts/stage_permissions.py:1177, skills/cc-resolve-comments/SKILL.md

Corrected. The hook matches only python3 <runtime validator path> <TMPDIR>/pr-comment.md, so a same-named file in the project is no longer executable, and the path no longer depends on the working directory. Verified by execution through test_only_the_resolver_gets_the_staged_triage_validator (allowed for resolve, denied for python3 -m unittest, absent from the review patterns, no scripts/validate-triage-comment.py relative form). The behaviour in a project other than the toolkit was not reproduced end to end (see Unverified).

[REV-002] · low · resolved · valid · blocks:no — New BLOCKED paths in after_publication are untested and the docstring is stale

scripts/run_cycle.py:2372-2416

Corrected. The docstring now distinguishes failed reconciliation (BLOCKED after publication) from a successful one that did not observe the attempt (retried). test_publication_readback_blocks_when_the_history_store_is_unavailable covers both the malformed readback and the provider failure with no history store, and passes.

[REV-003] · low · resolved · valid · blocks:no — Validator CLI untested; diagnostics depend on error-message substrings

scripts/validate-triage-comment.py, scripts/review_contract.py:405-419

Corrected. parse_comment branches on RunLineContractError.kind; the three CLI cases run in the suite and pass.

New findings

[REV-004] · low · open · - · blocks:no — Stray backtick in the resolver prompt note breaks the validator command

scripts/stage_permissions.py:1274-1275

The concatenation renders as run `python3 /path/validate-triage-comment.py `"$TMPDIR/pr-comment.md"`.: the inline code span closes before the argument and a literal backtick precedes it. A resolver that copies the command verbatim sends a backtick command substitution, which the closed table rejects, so the "validate before publishing" step fails until the model repairs the quoting. skills/cc-resolve-comments/SKILL.md gives the correct form, which limits the impact. The test only asserts that the validator path occurs in the note, so it does not catch this. Suggested fix: emit `python3 <path> "$TMPDIR/pr-comment.md"` as one span and assert the whole command string in the test.

Security triage

Sensitive by judgement (the always_when rule was not separately evaluated; defaults applied): scripts/stage_permissions.py changes a stage's closed command table. No delegated cc-security-review pass was available in this dispatch; the equivalent checks were done by inspection. The allow rule is an exact word match on the runtime's own validator and the stage's $TMPDIR/pr-comment.md, with no widening of other roles (policy.role == "resolve"), and the validator only reads one file. No vulnerability found.

Executed

  • python3 -m unittest discover -s tests — exit 0, 1662 tests OK (301 s).
  • python3 scripts/validate-package.py — exit 0, VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned.
  • python3 -m unittest — exit 0, 0 tests discovered.

Unverified

  • Direct invocation of the installed validator through the resolver hook, and from a project outside the toolkit: this stage's command table does not allow it. Covered only by the suite's unit and subprocess tests.
  • Windows behaviour of the Path(policy.tmpdir) / "pr-comment.md" match and the forward-slash validator path: depends on the pending shards below.

CI (policy: parallel; head 05f273d)

All in progress at read time, not waited for: Skills, manifests, and Bash installer, Windows test shard (windows-1), (windows-2), (windows-3), (windows-4). 0 passed, 0 failed, 5 pending.

Residual risk

The Windows shard that failed on the previous head (windows-4, test_stage_permissions/test_review_contract) is the one the latest commit targets; its result is the open question for the CI gate.

Verdict

Review complete for this head; no open finding blocks approval. REVIEW_PASSED_AWAITING_CI — not an approval; the cycle's CI gate decides once the checks finish.

Keep the resolver validator allow rule compatible with Windows path separators and render its prompt command as one valid inline-code span.

Fixes the Windows shard failure and rereview finding REV-004.
@datacas

datacas commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

Resolve summary

Resolved the outstanding rereview finding and fixed the in-scope Windows check failure. Findings and checks are recorded separately below.

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

[CCT-20261021-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:4990a4c517f985e7117f5f6016f7441a6d1db2e5 · schema:2

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

[CCT-20261021-002] · cheap_coder · openai/gpt-6-luna→? · high · triaged:05f273d4ecbb4d291d42dff7dd0ae88001c57c81 · schema:2

Review findings

  • REV-001 — resolved, valid (from the prior resolver attempt). The validator uses the installed runtime path and only reads the staged comment file.
  • REV-002 — resolved, valid (from the prior resolver attempt). Publication reconciliation behavior and its failure paths are documented and tested.
  • REV-003 — resolved, valid (from the prior resolver attempt). Typed diagnostics and validator CLI cases are covered.
  • REV-004 — resolved, valid. Fixed the prompt's malformed inline-code quoting and added an assertion for the complete command. Commit: 8eb3674b9a1fd141c333bfc0a1495729a7832d87.

Failed checks on the reviewed head

On 05f273d4ecbb4d291d42dff7dd0ae88001c57c81, Windows test shard (windows-4) failed four cases in test_stage_permissions: the exact validator command was rejected because the parsed $TMPDIR path retained mixed Windows separators while the allow rule constructed a normalized Path. The cause is in this change. PowerShell installer also failed its aggregate gate because a Windows shard had failed; it did not identify an independent installer defect.

Fixed the resolver rule to compare normalized path objects while still requiring the exact runtime validator and pr-comment.md under the dispatch TMPDIR. The full local suite passes with this fix. The pushed Windows checks are queued and were not awaited under the parallel CI policy.

Verification

Agent-reported local results:

  • rtk python3 -m unittest discover -s tests — passed, 1,662 tests.
  • rtk python3 scripts/validate-package.py — passed (VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned).
  • rtk python3 -m unittest — exit 0, 0 tests discovered.
  • rtk git diff --check — passed.
  • rtk python3 /home/datacas/www/code-cycle-toolkit/.worktree/task-253/scripts/validate-triage-comment.py "$TMPDIR/pr-comment.md" — passed; the final summary was validated before publication.
  • rtk basedpyright scripts/stage_permissions.py tests/test_stage_permissions.py — exit 1 (50 errors, 591 warnings). The reported errors are outside the fix delta; the reviewed change lines produced no errors. No unrelated diagnostics were changed.
  • Post-change cc-code-review of 05f273d4ecbb4d291d42dff7dd0ae88001c57c81..8eb3674b9a1fd141c333bfc0a1495729a7832d87 — no findings.
  • Post-change cc-security-review of the command authorization delta — no confirmed vulnerabilities; the rule remains restricted to the exact validator and staged file path.

Checks on pushed head

Head: 8eb3674b9a1fd141c333bfc0a1495729a7832d87.

  • Skills, manifests, and Bash installer — pending (queued).
  • Windows test shard (windows-1) — pending (queued).
  • Windows test shard (windows-2) — pending (queued).
  • Windows test shard (windows-3) — pending (queued).
  • Windows test shard (windows-4) — pending (queued).

@datacas

datacas commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

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

Rereview — APPROVED

Scope: full accumulated diff origin/main...8eb3674b9a1fd141c333bfc0a1495729a7832d87 (519 lines, merge base a1afafdb425ff9c8a3ad0fb66e79109811ad9b73), work item #253. Previous reviewed head: 05f273d4ecbb4d291d42dff7dd0ae88001c57c81 (CCR-20261021-002). Repository conventions applied: AGENTS.md (routing only; no review rules), skill defaults.

What changed since the previous review: commit 8eb3674 ("normalize staged validator path") fixes the prompt note quoting (REV-004: the validator command is now one inline-code span, and the test asserts the whole command) and makes the resolver allow rule compare Path(words[2]) == Path(policy.tmpdir) / "pr-comment.md" so mixed Windows separators in the parsed $TMPDIR no longer reject the exact command.

Previous findings

[REV-001] · medium · resolved · valid · blocks:yes — Resolver validator is invoked by a repo-relative path

scripts/stage_permissions.py:534, scripts/stage_permissions.py:1177, skills/cc-resolve-comments/SKILL.md

Still corrected. The hook matches only python3 <runtime validator path> <TMPDIR>/pr-comment.md for the resolve role. Verified by execution through test_only_the_resolver_gets_the_staged_triage_validator (part of the passing suite) and by the Windows shards, which now pass on this head.

[REV-002] · low · resolved · valid · blocks:no — New BLOCKED paths in after_publication are untested and the docstring is stale

scripts/run_cycle.py:2372-2416

Still corrected; test_publication_readback_blocks_when_the_history_store_is_unavailable passes.

[REV-003] · low · resolved · valid · blocks:no — Validator CLI untested; diagnostics depend on error-message substrings

scripts/validate-triage-comment.py, scripts/review_contract.py:405-419

Still corrected; parse_comment branches on RunLineContractError.kind and the three CLI cases in TriageValidatorCliTests pass.

[REV-004] · low · resolved · valid · blocks:no — Stray backtick in the resolver prompt note breaks the validator command

scripts/stage_permissions.py:1274-1275

Corrected and verified by execution. The note now renders run `python3 <path> "$TMPDIR/pr-comment.md"`. as a single span, and test_only_the_resolver_gets_the_staged_triage_validator asserts run `python3 {validator} "$TMPDIR/pr-comment.md"` .

New findings

None.

Security triage

Sensitive by judgement (the always_when rule was not separately evaluated; defaults applied): scripts/stage_permissions.py changes a stage's closed command table. No delegated cc-security-review pass was available in this dispatch; the equivalent checks were done by inspection. The allow rule is an exact word match (three words) on the runtime's own validator path and the stage's $TMPDIR/pr-comment.md, restricted to policy.role == "resolve". Path equality does not normalise .., so it does not widen the match. The validator only reads one file. No vulnerability found.

Executed

  • python3 -m unittest discover -s tests — exit 0, 1662 tests OK (243 s).
  • python3 scripts/validate-package.py — exit 0, VALID: 16 skills (7 cycle, 9 supporting), shared sections in sync, cross-agent manifests aligned.

Unverified

  • Direct invocation of scripts/validate-triage-comment.py: this stage's command table denies python3 for it ('python3' is not in the rereview stage's command table). Covered by TriageValidatorCliTests in the suite (valid, contract error with line, unreadable file).
  • python3 -m unittest was not run separately: it discovers 0 tests here and adds nothing over the suite above.
  • Behaviour from a project outside the toolkit repository: not reproduced end to end.

CI (policy: parallel; head 8eb3674)

All 6 passed: Skills, manifests, and Bash installer, Windows test shard (windows-1), (windows-2), (windows-3), (windows-4), PowerShell installer. 0 failed, 0 pending.

Residual risk

Low. The remaining risk is the end-to-end resolver hook behaviour in a foreign project, which only unit and subprocess tests cover.

Verdict

APPROVED — the current head was completely rereviewed, every previous finding was classified, no open finding blocks approval and every check passed.

@datacas
datacas merged commit 32f7a84 into main Oct 21, 2026
6 checks passed
@datacas
datacas deleted the task-253 branch October 26, 2026 09:32
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.

A malformed triage run line blocks a resumed cycle permanently instead of giving a recoverable diagnostic

1 participant