Repository navigation
fix(consent): persist resume grants before dispatch - #527
Conversation
Implementation summaryIssue #522 is implemented on Diagnosis: isolated defect; the issue's recorded cause matches the implementation path. One work unit, independently reversible. Agent-reported verification (schema 2){
"version": 2,
"checks": [
{
"id": "configured-test",
"command": "python3 -m unittest discover -s tests",
"executor": "claude",
"profile": "cheap_coder",
"context": "project",
"required": true,
"criteria": ["AC-1", "AC-2", "AC-3", "AC-4", "AC-5"],
"level": "test",
"provenance": "project",
"reason": "configured test command",
"head_sha": "8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6",
"result": "pass",
"evidence": {"exit_code": 0, "executed": 2758},
"attempts": [
{"head_sha": "4e6e62754b71f6777532fe4235ca8cb51ffbf90d", "result": "fail", "evidence": {"exit_code": 1, "executed": 2808}, "cause": "The first run exposed the immutable asked-scope update bug, inherited regression tests, and missing fast-path test registration; those were corrected before rerunning."},
{"head_sha": "4e6e62754b71f6777532fe4235ca8cb51ffbf90d", "result": "pass", "evidence": {"exit_code": 0, "executed": 2758}, "cause": "Passed before the final scope-record validation refinement; rerun on the final head is the result above."}
]
},
{
"id": "acceptance-regressions",
"command": "python3 -m unittest discover -s tests -p test_compose_consent.py",
"executor": "claude",
"profile": "cheap_coder",
"context": "project",
"required": true,
"criteria": ["AC-1", "AC-2", "AC-3", "AC-4", "AC-5"],
"level": "test",
"provenance": "agent",
"reason": "regressions for the runtime acceptance criteria",
"head_sha": "8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6",
"result": "pass",
"evidence": {"exit_code": 0, "executed": 76},
"attempts": []
},
{
"id": "package-validator",
"command": "python3 scripts/validate-package.py",
"executor": "claude",
"profile": "cheap_coder",
"context": "project",
"required": true,
"criteria": [],
"level": "static",
"provenance": "project",
"reason": "configured verification command",
"head_sha": "8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6",
"result": "pass",
"evidence": {"exit_code": 0, "executed": null},
"attempts": [
{"head_sha": "4e6e62754b71f6777532fe4235ca8cb51ffbf90d", "result": "fail", "evidence": {"exit_code": 1, "executed": null}, "cause": "The first run reported five type errors in Compose hash comparison; the types were narrowed and checked again."},
{"head_sha": "4e6e62754b71f6777532fe4235ca8cb51ffbf90d", "result": "pass", "evidence": {"exit_code": 0, "executed": null}, "cause": "Passed before the final scope-record validation refinement; rerun on the final head is the result above."}
]
},
{
"id": "basedpyright",
"command": "basedpyright",
"executor": "claude",
"profile": "cheap_coder",
"context": "project",
"required": true,
"criteria": ["AC-1", "AC-2", "AC-3", "AC-4"],
"level": "static",
"provenance": "project",
"reason": "Python type check after source changes",
"head_sha": "8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6",
"result": "pass",
"evidence": {"exit_code": 0, "executed": null},
"attempts": []
},
{
"id": "configured-unittest-alias",
"command": "python3 -m unittest",
"executor": "claude",
"profile": "cheap_coder",
"context": "project",
"required": false,
"criteria": [],
"level": "test",
"provenance": "project",
"reason": "supplemental configured command; it discovers zero tests",
"head_sha": "8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6",
"result": "unverified",
"evidence": {"exit_code": 0, "executed": 0},
"cause": "command exited 0 but discovered 0 tests",
"attempts": []
},
{
"id": "cli-boundary",
"command": "rtk python3 scripts/run_cycle.py --repo datacas/code-cycle-toolkit --task 522 --dry-run --json --no-config",
"executor": "claude",
"profile": "cheap_coder",
"context": "project",
"required": true,
"criteria": [],
"level": "boundary",
"provenance": "agent",
"reason": "real CLI entry-point boundary check; dry-run prevents a stage dispatch",
"head_sha": "8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6",
"result": "pass",
"evidence": {"exit_code": 0, "executed": null},
"attempts": []
}
],
"conclusion": "verified_with_reservations",
"boundary": "required"
}Security review: ran ( Checks of pushed head |
[CCR-20261124-002] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2Verdict: CHANGES_REQUESTED for
Security audit ran: no confirmed vulnerability. CI: 7/7 passed. Local: 2,758 tests OK. Findings, evidence, verification, CI and historyFindings[REV-001] · medium · open · - · blocks:yes — An earlier permission request is hidden by a newer non-permission record
The function stops at the newest Failure scenario: stop A asks for X and Y. The resume answers Y only and stops on Z before reaching X, or stops at an issue-review readiness gate. A later resume with This contradicts #522's expected behaviour ("never reports 'no matching grant is registered' for an id the cycle itself asked about"). It also contradicts the new Why it now blocks: CCR-20261124-001 recorded this finding as Fix: iterate the matching records newest-first, skip those without a Evidence: code inspection. An inline reproduction ( [REV-002] · low · open · - · blocks:no — The AC-3 "no note for X" assertion is vacuous
[REV-003] · low · open · - · blocks:no — The Compose drift note truncates the consent question's risk disclosure
The prefix "Compose configuration changed: previous config_sha256 <64>; current config_sha256 <64>. " is 208 characters. It is prepended to a Fix: abbreviate the hashes in the prompt (the full ones are in the permission record's Evidence: code inspection. Acceptance criteria (tests.version=2)
Verification (executed on
|
| Command | Result |
|---|---|
python3 -m unittest discover -s tests |
exit 0, Ran 2758 tests in 752.167s, OK (skipped=1). The host moved it to the background at 600 s; it ran to completion and its exit status was observed. |
python3 -m unittest discover -s tests -p test_compose_consent.py |
exit 0, 76 tests OK |
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 (no tests at the repository root) |
basedpyright |
exit 0: 0 errors, 0 warnings, 0 notes |
Security
Triage: the deterministic rule did not fire. .code-cycle.yml declares no security_review.always_when, and no changed path matches the mandatory minimum. The audit ran because the runtime plan requires it (security_required) and because reviewer judgement also requires it: the change touches consent, authorization and persisted grants.
Result: cc-security-review ran for 8b50f26 and found no confirmed vulnerability. The new trust input, decisions-*.json, is guarded as follows:
- it is filtered by repo and task and capped at 1 MB;
- it goes through strict
from_entryvalidation; - the rebuilt grant ID must equal the ID the user typed;
- effective scope, risks and isolation are recomputed and must match.
Potential risk: anyone who can write ~/.config/code-cycle-toolkit/decisions can mark a scope as asked, so a user-typed answer persists. Stage sandboxes do not include that directory as writable.
CI (policy: parallel, read once)
Validate package on 8b50f26: all 7 checks are COMPLETED/SUCCESS (Classify the change; Skills, manifests, and Bash installer; Windows test shard windows-1..4; PowerShell installer).
Residual risk
- REV-001 was not reproduced by execution, because the reproduction command was refused by the stage policy.
- Real Docker Compose drift is only emulated by the tests.
- The
cycle_cli.pywiring ofload_resume_requestshas no end-to-end test.
History
[CCR-20261124-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2
The earlier attempt on the same head returned APPROVED, with REV-001 and REV-002 open and blocks:no.
[CCT-20261124-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6 · schema:2Triage before edits: all findings are valid against [REV-001] · medium · open · valid · blocks:yes — An earlier permission request is hidden by a newer non-permission recordThe loader can hide older requests behind newer records. I’ll scan newest-first and test X behind Y and readiness records. [REV-002] · low · open · valid · blocks:no — The AC-3 “no note for X” assertion is vacuousThe assertion checks a broker with no answers. I’ll assert after [REV-003] · low · open · valid · blocks:no — The Compose drift note truncates the consent question’s risk disclosureThe full hash prefix uses the question’s 600-character budget. I’ll retain both hashes and test that |
[CCT-20261124-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6 · schema:2Resolved all 3 valid findings on Findings, verification, CI and stage history[REV-001] · medium · resolved · valid · blocks:yes — An earlier permission request is hidden by a newer non-permission record
[REV-002] · low · resolved · valid · blocks:no — The AC-3 “no note for X” assertion is vacuousThe AC-3 regression now asserts the resumed broker’s notes after [REV-003] · low · resolved · valid · blocks:no — The Compose drift note truncates the consent question’s risk disclosureThe hash prefix is shorter and no longer truncates the original prompt. Regression coverage asserts both configuration hashes and Acceptance criteria (tests.version=2)
Agent-reported verification (schema 2){
"version": 2,
"checks": [
{"id":"configured-test","command":"python3 -m unittest discover -s tests","executor":"codex","profile":"cheap_coder","context":"project","required":true,"criteria":["AC-1","AC-2","AC-3","AC-4","AC-5"],"level":"test","provenance":"runtime","reason":"runtime","head_sha":"4084fce51f485878d2bd5fd70ce6e9373a5f55ba","result":"pass","evidence":{"exit_code":0,"executed":2758},"attempts":[]},
{"id":"acceptance-regressions","command":"python3 -m unittest discover -s tests -p test_compose_consent.py","executor":"codex","profile":"cheap_coder","context":"project","required":true,"criteria":["AC-1","AC-2","AC-3","AC-4","AC-5"],"level":"test","provenance":"runtime","reason":"runtime","head_sha":"4084fce51f485878d2bd5fd70ce6e9373a5f55ba","result":"pass","evidence":{"exit_code":0,"executed":76},"attempts":[]},
{"id":"package-validator","command":"python3 scripts/validate-package.py","executor":"codex","profile":"cheap_coder","context":"project","required":true,"criteria":[],"level":"static","provenance":"runtime","reason":"runtime","head_sha":"4084fce51f485878d2bd5fd70ce6e9373a5f55ba","result":"pass","evidence":{"exit_code":0,"executed":null},"attempts":[]},
{"id":"basedpyright","command":"basedpyright","executor":"codex","profile":"cheap_coder","context":"project","required":true,"criteria":["AC-1","AC-2","AC-3","AC-4"],"level":"static","provenance":"runtime","reason":"runtime","head_sha":"4084fce51f485878d2bd5fd70ce6e9373a5f55ba","result":"pass","evidence":{"exit_code":0,"executed":null},"attempts":[]},
{"id":"configured-unittest-alias","command":"python3 -m unittest","executor":"codex","profile":"cheap_coder","context":"project","required":false,"criteria":[],"level":"test","provenance":"runtime","reason":"runtime","head_sha":"4084fce51f485878d2bd5fd70ce6e9373a5f55ba","result":"unverified","evidence":{"exit_code":0,"executed":0},"cause":"The command exited 0 but discovered zero tests.","attempts":[]},
{"id":"cli-boundary","command":"sha256:3752ba3c0d3cd77a1a0d9c025a08a431d7686c1aa2878bc22654714515a66223","executor":"codex","profile":"cheap_coder","context":"project","required":true,"criteria":[],"level":"boundary","provenance":"runtime","reason":"runtime","head_sha":"4084fce51f485878d2bd5fd70ce6e9373a5f55ba","result":"pass","evidence":{"exit_code":0,"executed":null},"attempts":[]}
],
"conclusion":"verified_with_reservations",
"boundary":"required"
}Security: Checks of pushed head
|
| Check | State |
|---|---|
| Classify the change | in progress |
| Skills, manifests, and Bash installer | queued |
History
[CCR-20261124-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2
[CCR-20261124-002] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2
[CCT-20261124-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6 · schema:2
Triage dispositions for REV-001, REV-002, and REV-003 were recorded before edits; all are valid.
[CCR-20261124-003] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2Verdict: REVIEW_PASSED_AWAITING_CI for
Security audit ran: no confirmed vulnerability. Local: 2,758 tests OK. Findings, verification, security, CI and historyFindings[REV-001] · medium · resolved · valid · blocks:yes — An earlier permission request is hidden by a newer non-permission record
[REV-002] · low · resolved · valid · blocks:no — The AC-3 "no note for X" assertion is vacuous
[REV-003] · low · resolved · valid · blocks:no — The Compose drift note truncates the consent question's risk disclosure
[REV-004] · low · open · - · blocks:no — The Compose drift question prompt exceeds the 600-character question contract
Cause: the REV-003 fix prepends about 180 characters, the prefix plus two 64-character hashes, to a Contract: Display: the terminal line Fix: abbreviate the hashes in the prompt (for example the first 12 hex characters), since the full ones are in the record's Evidence: code inspection and length arithmetic. The test asserts Acceptance criteria (tests.version=2)
Verification (agent-reported, executed on
|
| Check | State |
|---|---|
| Classify the change | pass |
| PowerShell installer | pass |
| Windows test shard (windows-1) | pass |
| Windows test shard (windows-2) | pass |
| Windows test shard (windows-3) | pass |
| Windows test shard (windows-4) | pass |
| Skills, manifests, and Bash installer | pending |
Residual risk
- REV-004 is based on inspection only.
- Real Docker Compose drift is only emulated by the tests.
- The
cycle_cli.pywiring ofload_resume_requestshas no end-to-end test. Thecli-boundarydry-run was not executed in this stage.
History
[CCR-20261124-001] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2
[CCR-20261124-002] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2
[CCT-20261124-001] · cheap_coder · openai/gpt-6-luna→? · high · triaged:8b50f2654cfe1a1b390546ffffb8b6d07c8d27b6 · schema:2
All three findings were triaged valid before the edits. The resolve stage claimed all three as resolved on 4084fce.
Diagnosis
On resume, a
--grantanswer for a pending command could be forgotten when the resumed stage stopped on a different refusal first. The supplied issue reproduction from 2026-11-23 matches the code path:ConsentBroker.prepare_answerscould only resolve built-in, stored, or in-memory operation definitions, while the previous permission request existed only in the decisions record. Since the first operation was not reached, its answer was never applied toconsents.json.The fix restores this invariant: an answer applies only to an operation and effective scope that the same work item previously showed the user, and it is processed before dispatch. Preflight reconstructs and validates the operation from the latest matching decisions record. Persistent answers are saved at the repository scope, cycle answers use the existing cycle lineage, and an unknown ID still gets an actionable note. A repeated Compose question now names both configuration hashes when that is the only change.
The issue is an isolated defect; the cause matches the issue. Related issues #323, #441, #483, #486, and #500 were checked in the issue context, along with the local consent implementation and tests. This change does not claim to resolve those items.
docs/host-permissions.mdnow documents resume persistence.Work units
WU-1scripts/grants.py,scripts/cycle_cli.py,scripts/run_cycle.py,tests/test_compose_consent.py,scripts/fast-path-tests.json,docs/host-permissions.mdpython3 -m unittest discover -s tests;python3 scripts/validate-package.py;basedpyrightVerification
python3 -m unittest discover -s tests: 2,758 tests passed, 1 skipped.python3 scripts/validate-package.py: passed.basedpyright: passed with 0 errors, 0 warnings, 0 notes.python3 -m unittest: exited 0 but discovered 0 tests.The local suite used the installed Python and test dependencies. Compose behavior is emulated by the repository tests; no Docker daemon or user-global Git identity was needed. The pushed head's CI checks are reported separately in the stage summary.