Skip to content

fix(runtime): reconcile effects before every consent rerun - #295

Merged
datacas merged 1 commit into
mainfrom
fix/293-consent-rerun-reconciliation
Oct 20, 2026
Merged

datacas merged 1 commit into
mainfrom
fix/293-consent-rerun-reconciliation

Conversation

@datacas

@datacas datacas commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Fix the consent-answer path so a full stage rerun uses the existing effect guard even when it keeps the same executor. A grant or denial can no longer replay a stage that already published or changed its workspace.

Work item: #293.

Diagnosis

The same-executor consent path checked process exit but skipped reroute_gate(). A synthetic adapter and broker reproduced two dispatches after the first attempt changed publication evidence; the regression expected one dispatch and failed with 1 != 2. Reproduction: python3 -m unittest discover -s /tmp/code-cycle-tmp-enx0bu9b -p reproduce.py (exit 1; the targeted assertion failed).

Classification: isolated defect; decision: implement. The cause matches the issue. The invariant is that every full rerun must prove exit and reconcile the preceding attempt's effects before redispatch.

Related work was searched beyond the issue links using consent/reconciliation and reroute/publication searches. #268 and merged PR #277 establish the guard; #288/#290 own continuation and verification, #289 owns grant lifecycle, and #187 owns the later stage refactor. This change preserves those boundaries and introduces no grant or continuation mechanism.

The fix reuses the full guard rather than adding separate consent reconciliation. As permitted by the scope clarification, an already dirty workspace also stops conservatively, even if unchanged. Clean snapshots permit rerunning; changed publications, remote refs, commits or workspace, unknown evidence, and unproven exits stop. permission_answered retains its meaning for permitted reruns, while stopped reruns record the guard's reason.

Work units

Unit Behaviour Files Tests Verification Rollback
WU-1 Reconcile every consent rerun before dispatch, preserving closed telemetry reasons scripts/cycle.py, tests/test_environment_recovery.py, tests/test_run_cycle.py, docs/routing.md Changed/unknown effects under cycle/persistent/deny; unproven exit; conservative dirty stop; clean rerun and telemetry; consent driver flows Focused recovery: 22 passed; driver: 211 passed; package validator passed Independent: revert 9690049a44afcb8c2f70c73ebbdd1ff432193dca

Verification (agent-reported)

  • python3 -m unittest discover -s tests: exit 0, 1642 tests passed in 579.576 seconds on the completed patch.
  • python3 -m unittest discover -s tests -p test_environment_recovery.py: exit 0, 22 tests passed.
  • python3 -m unittest discover -s tests -p test_run_cycle.py -k PermissionConsentTests: exit 0, 8 tests passed.
  • python3 -m unittest discover -s tests -p test_run_cycle.py: exit 0, 211 tests passed.
  • python3 scripts/validate-package.py: exit 0; all 16 skills valid and shared sections/manifests aligned.
  • git diff --check: exit 0.

An earlier full run, before the consent fixture correction, also reported one statistics assertion (10 != 0). It did not reproduce: python3 -m unittest discover -s tests -p test_stats.py passed all 42 tests, and the final full suite above passed. The earlier failure's cause was not established.

Additional type analysis: basedpyright scripts/cycle.py tests/test_environment_recovery.py tests/test_run_cycle.py exits 1 with 111 errors and 2948 warnings. The unchanged-HEAD comparison exits 1 with 112 errors and 2866 warnings; matching error messages as multisets finds no introduced errors and one removed optional-member error. The repository has no Pyright configuration; no type-check settings were changed. Warning counts increase with the additional tests. These diagnostics remain a verification reservation, not a claimed type-check pass.

The tests use synthetic adapters, isolated telemetry/consent stores and controlled snapshots; they do not grant Docker access or publish synthetic effects. The full suite uses its existing host-environment isolation. No installed native sandbox campaign is needed for this in-process decision change. Setup evidence was prepared, with no failed or incomplete setup item reported.

Run: profile deep_coder, requested model openai/gpt-6.1-sol, effort medium, resolved model ?.

Closes #293

@datacas

datacas commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

Implemented #293 in 9690049a44afcb8c2f70c73ebbdd1ff432193dca.

Every consent-triggered full rerun now uses the existing exit/effect reconciliation guard, including on the same executor. Regression coverage exercises all three answers against changed or unknown effects, clean reruns, unproven exits and telemetry reasons. The full guard conservatively stops on an already dirty workspace, as the issue's fallback scope permits.

Agent-reported verification: 1642 full-suite tests passed; 22 recovery tests and 211 driver tests passed; all 16 skills passed package validation. The optional BasedPyright check remains nonzero (111 errors versus 112 at unchanged HEAD, no introduced error messages). An earlier statistics failure did not reproduce in its 42-test suite or the final full run; its cause is unknown. See the PR body for exact commands and limitations.

Checks read once for head 9690049a44afcb8c2f70c73ebbdd1ff432193dca, under parallel CI policy:

Check State
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)

The push and PR creation succeeded. Git could not save local upstream tracking because the shared .git/config is read-only; the PR confirms the pushed head above. No base branch or remote ref was modified beyond this working branch.

Run: profile deep_coder, requested model openai/gpt-6.1-sol, effort medium, resolved model ?.

@datacas

datacas commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

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

Initial review: PR #295 (work item #293)

Status: APPROVED for head 9690049a44afcb8c2f70c73ebbdd1ff432193dca. The review found no open finding, and all 6 checks of this exact head had passed when I read them.

Scope

Accumulated diff origin/main...HEAD (merge base 36f677e, 136 lines, 4 files): scripts/cycle.py, docs/routing.md, tests/test_environment_recovery.py, tests/test_run_cycle.py. Compared against the #293 description and the repository's AGENTS.md.

Findings

No findings. Checks made:

  • scripts/cycle.py:905-909: every consent answer (cycle, persistent, deny) now goes through reroute_gate(). A missing attempt_id stops with exit_unproven. The gate keeps the old checks (asynchronous or unproven exit, human action required) and adds effect reconciliation. The before snapshot is taken per attempt, so a fallback-to-primary rerun reconciles against the right baseline.
  • The change only adds stop conditions. It cannot widen a grant or skip a stop the old path enforced.
  • Every reroute_reason the path can now record (not_started, no_effects, dirty_workspace, workspace_changed, remote_changed, publication_changed, evidence_unavailable, exit_unproven, human_action, permission_answered) is in the closed telemetry set in scripts/telemetry.py:261-268.
  • docs/routing.md matches the behaviour, including the conservative dirty-workspace stop that the work item allowed.
  • The new tests cover all three answers across the changed and unknown effect cases, the dirty-workspace stop, the unproven exit, and the telemetry reason of an allowed rerun. They assert a single dispatch.

Security triage

No security_review.always_when rule is configured, so the defaults apply. No path or label matched the rule. By my own reading, the change touches the sandbox-grant consent gate, which is a permission decision. I reviewed it for security as part of this pass: the change only narrows when a rerun is allowed, adds no input handling, secrets, or contract changes, and has no widening path. No vulnerability and no potential risk found.

Commands executed (locally, exit status observed)

Command Result
python3 scripts/validate-package.py exit 0, 16 skills valid
python3 -m unittest discover -s tests -p test_environment_recovery.py exit 0, 22 tests OK
python3 -m unittest discover -s tests -p test_run_cycle.py exit 0, 211 tests OK
python3 -m unittest discover -s tests exit 1: 1642 run, 62 errors, 1 failure, all outside the changed code (see Unverified)

Dependency preparation (npm, --ignore-scripts) reported prepared with no failed item. It was not counted as a test run.

Unverified

  • The full local suite did not pass in this read-only sandbox, for environment reasons. It is not counted as a pass, and the exact-head CI results below complement it.
    • 62 errors, all in test_validate_package.py: copy_package() fails in shutil.copytree with [Errno 13] Permission denied on the sandbox-masked dotfiles in the checkout root (.bashrc, .gitconfig, .mcp.json, .claude/*, among others). python3 scripts/validate-package.py itself passes.
    • 1 failure: test_executors.ReadOnlyVerificationTests.test_scratch_never_uses_a_temp_parent_inside_the_checkout ("no temporary directory outside the dispatch checkout"). The checkout and TMPDIR both sit under /tmp in this disposable clone.
    • None of these tests touch scripts/cycle.py, the consent path, or the other changed files. I did not rerun them on the base, because this stage may not alter the working tree.
  • The agent-reported basedpyright comparison was not rerun. The repository has no type-check configuration or configured command.

CI (policy: parallel, read once, not awaited)

All 6 checks of head 9690049a44afcb8c2f70c73ebbdd1ff432193dca had completed with SUCCESS when I read them:

  • Skills, manifests, and Bash installer
  • Windows test shard (windows-1) to (windows-4)
  • PowerShell installer

Residual risks

The local full suite was not green because of the sandbox. The passing exact-head CI is the evidence for those tests. No other residual risk found.

Verdict

APPROVED: no open finding blocks approval, and every check of the reviewed head passed.

@datacas

datacas commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

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

Initial review: PR #295 (work item #293), recovered-attempt verification

Status: APPROVED for head 9690049a44afcb8c2f70c73ebbdd1ff432193dca. I independently reviewed the full diff and re-verified the recovered attempt attempt-fcf598bbbc02480bb209ee2d4a29ce5f (comment issuecomment-6298643666). I found no open finding, and its conclusion stands. The recovered attempt claimed no finding IDs, so verified_findings is empty.

Scope

Accumulated diff origin/main...HEAD (merge base 36f677e, 136 lines, 4 files), read in full: scripts/cycle.py, docs/routing.md, tests/test_environment_recovery.py, tests/test_run_cycle.py. The PR head still equals the reviewed head.

Findings

None. Checks made:

  • scripts/cycle.py:904-932: every consent answer (cycle, persistent, deny) now goes through reroute_gate(), and a missing attempt_id stops with exit_unproven. before is snapshotted per attempt (:696), so a rerun reconciles against its own baseline.
  • The change only adds stop conditions. It cannot widen a grant or skip a stop that the old path enforced.
  • Every reason the path can record is in the closed telemetry set at scripts/telemetry.py:261-268.
  • docs/routing.md matches the behaviour, including the conservative dirty-workspace stop.
  • The new tests cover the three answers across changed and unknown effects, the dirty workspace, and the unproven exit, and assert a single dispatch.

Security triage

No security_review.always_when rule is configured, so the defaults apply, and no path or label matched. By my own reading, the change touches the sandbox-grant consent gate. I audited it inline: it only narrows when a rerun is allowed and adds no input handling, secrets or contract change. No vulnerability and no potential risk found.

Commands executed (locally)

Command Result
python3 scripts/validate-package.py exit 0, 16 skills valid
python3 -m unittest discover -s tests exit 1: 1642 run, 62 errors, 1 failure, all environmental (see Unverified)

The two narrower test commands in the recovered comment are not in this stage's command table, so I did not rerun them. In the full run, none of the 63 failing tests are in test_environment_recovery.py or test_run_cycle.py.

Unverified

  • The full local suite is not a pass in this read-only sandbox. 62 errors are in test_validate_package.py: copy_package() hits [Errno 13] Permission denied copying sandbox-masked dotfiles (.bashrc, .gitconfig, .claude/*). The one failure is test_executors.ReadOnlyVerificationTests.test_scratch_never_uses_a_temp_parent_inside_the_checkout (checkout and TMPDIR both under /tmp). None of these touch the changed code. I did not rerun them on the base, because this stage may not alter the working tree. The exact-head CI below complements them.
  • The agent-reported basedpyright comparison was not rerun. The repository has no type-check configuration.

CI (policy: parallel, read once, not awaited)

All 6 checks of the head were SUCCESS when I read them: Skills, manifests, and Bash installer, Windows test shard (windows-1) to (windows-4), PowerShell installer.

Residual risks

The local full suite was not green because of the sandbox. Passing exact-head CI is the evidence for those tests. No other residual risk.

Verdict

APPROVED: no open finding blocks approval, and every check of the reviewed head passed.

@datacas

datacas commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

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

Initial review — PR #295 (work item #293)

Verdict: APPROVED. Head 9690049a44afcb8c2f70c73ebbdd1ff432193dca was fully reviewed, no finding is open, and every check of that head passed.

Scope reviewed

Accumulated diff origin/main...HEAD (136 lines, merge base 36f677e): scripts/cycle.py, tests/test_environment_recovery.py, tests/test_run_cycle.py, docs/routing.md. Project instructions applied: AGENTS.md (routing only; nothing version-sensitive here).

Findings

None. Notes (not findings):

  • Every consent answer (cycle/persistent/deny) now goes through reroute_gate() (exit proof → human action → not_started/no_effects → reconcile(before, snapshot())), and attempt_id is None stops with exit_unproven. This matches the stated invariant and the previous fallback-to-primary special case is subsumed.
  • reroute_gate() is also evaluated earlier on the failure path; the second call re-snapshots, which is idempotent (read-only snapshot) and gives a fresher view. Stopped reruns record the guard's closed reason; permission_answered is kept for allowed reruns, as documented in docs/routing.md.
  • Behaviour change worth knowing: an already-dirty workspace now stops a consent rerun even if unchanged (dirty_workspace). The PR states this is intentional and conservative.

Security triage

No security_review.always_when rule is configured, so the defaults applied. The rule matched no path or label (no labels on the PR). Reviewer judgement: the diff touches the sandbox-grant consent flow, so I checked it inline. The change only adds a guard in front of a rerun; it adds no grant path, input handling, credential or secret handling, or dependency. No vulnerability found. A separate cc-security-review pass was not run (inline assessment only).

Execution

  • python3 scripts/validate-package.py → exit 0, VALID: 16 skills.
  • python3 -m unittest discover -s tests -p test_environment_recovery.py → 22 tests OK (includes the new consent regression tests).
  • python3 -m unittest discover -s tests -p test_run_cycle.py → 211 tests OK (includes PermissionConsentTests).
  • python3 -m unittest discover -s tests -p "test_[a-u]*.py" → 1553 tests, 1 failure: test_executors.ReadOnlyVerificationTests.test_scratch_never_uses_a_temp_parent_inside_the_checkout ("no temporary directory outside the dispatch checkout"). The test is in a file this PR does not touch; it comes from this review sandbox, where the temp directory and the checkout both live under /tmp.
  • python3 -m unittest discover -s tests (full) → also errors in test_validate_package (copy_package fails with Permission denied on dot-files in the checkout). It's the same sandbox limitation and unrelated to the diff.

Unverified

The full suite was not green locally because of the two sandbox-caused failures above; the PR's own full-suite run (agent-reported, 1642 tests) and the CI jobs below cover those modules on a normal host. The changed modules passed locally.

CI (parallel policy, read once, not waited on)

All 6 checks of the reviewed head passed: Skills, manifests, and Bash installer, Windows test shard (windows-1), (windows-2), (windows-3), (windows-4), PowerShell installer. None pending, failed or skipped.

Residual risks

  • Dirty-workspace conservatism may stop a legitimate consent rerun; this is a deliberate tradeoff and the stop reason is recorded.
  • The PR reports 111 type-checker errors on both base and head (no new ones); nothing here changes that.

@datacas
datacas merged commit 80bd986 into main Oct 20, 2026
6 checks passed
@datacas
datacas deleted the fix/293-consent-rerun-reconciliation branch October 20, 2026 19:21
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 rerun after a consent answer skips publication reconciliation on the same executor

1 participant