Skip to content

feat(resolve): retry publication of verified local resolutions - #572

Merged
datacas merged 7 commits into
mainfrom
feat/504-publication-retry
Dec 3, 2026
Merged

datacas merged 7 commits into
mainfrom
feat/504-publication-retry

Conversation

@datacas

@datacas datacas commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Summary

Complete #504 by adding a standalone upload for the verified resolution candidate introduced in #567. The first upload records authorization for the inspected commit and branch. A retry reuses that authorization and reconciles the branch and pull request heads before sending a push. Confirmed retries leave the remote untouched.

Diagnosis

This is a feature request for the remaining publication path. The earlier resolver could prepare a local candidate, but it had no independent upload action that could reuse the candidate's verified plan and the operator's authorization. The standalone command uses the existing journal, verification plan and in-sandbox GitHub publication helper. A verified result applies to one exact candidate, and upload uses a normal fast-forward update. Related work reviewed includes #284, #446, #491, #503 and #567.

Work units

Unit Behaviour Files Tests Verification Rollback
WU-1 Authorize, reconcile and publish the verified candidate without dispatching resolve again Runtime CLI, journal and plan integration, and GitHub publication helper tests/test_publication.py, tests/test_run_cycle.py Configured discovery and focused publication tests cover AC-1 through AC-8 Revert the publication unit together with its follow-up fixes
WU-2 Anchor the existing stats test to its recorded data when the host clock moves backward tests/test_stats.py Existing stats report tests Configured unittest discovery Independently revert the existing test-only commit

Documentation review

The branch updates docs/review-cycle.md, docs/role-workspace-policy.md, docs/execution-plan.md, docs/workflows.md, docs/configuration.md, docs/instrumentation.md, docs/capability-parity-audit.md and skills/cc-resolve-comments/SKILL.md. These cover the CLI action, candidate and consent records, transport behavior, and post-publication review. The documentation index, README, CONTRIBUTING, AGENTS, SECURITY and GitHub template inventory were checked. The existing links and contribution instructions already cover the affected workflow.

Security review

Reviewed the authorization scope, journal and plan validation, sandboxed subprocess arguments, Git destination and refspec, receipt reconciliation and error redaction. No confirmed security issue was found in the diff. The focused run exercises Git's receive boundary against a disposable repository and uses a GitHub CLI fixture. Subsequent rereview and provider CI remain part of the merge workflow.

Verification (agent-reported)

Head aab664bf33160c405de13d8d0f20204169f4d592.

Check Command Exit Tests
configured-test python3 -m unittest discover -s tests 0 2910
ref-8ccc5e4478464d6ddcde25c59b2c6e895e5e6f1ea520b62dd0f6b48a0bd44048 python3 scripts/validate-package.py 0 —
ref-a1d5411ab9a121395d20bf8de37920799e10ef82ba8a27d00ee498c5bc89f21b python3 -m unittest 0 0
verify:basedpyright basedpyright 0 —
prepared-publication-boundary python3 -m unittest tests.test_publication tests.test_run_cycle.PublicationCompletionTests 0 28

The configured discovery suite reported one skip. Bare unittest exited successfully with zero tests. The configured discovery and focused publication checks are linked to AC-1 through AC-8. Local checks ran on Linux, and the focused fixture uses real local Git processes with a disposable remote. Provider CI runs separately on the pushed head.

…andidate

The candidate record now exists only for a local-only resolve, so the test's
partial CycleSession sets local_only as __init__ always does, and covers that a
LOCAL_PREPARED report outside a local-only resolve records no candidate.
A host time sync can step the wall clock backwards between recording rows and
aggregating them, leaving earlier rows after the period end. The flaky
test_report_aggregates_rates_and_never_returns_task_ids counted 5 of 10 tasks
under the full suite on WSL. Pre-existing; independent of #504.
@datacas

datacas commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

Published the existing implementation at aab664bf33160c405de13d8d0f20204169f4d592 and confirmed the pull request points to that commit. The configured discovery suite reported 2,910 tests with one skip. All 28 focused publication tests passed. Package validation and BasedPyright passed. Bare unittest ran zero tests. The required security audit found no confirmed issue.

GitHub reported Classify the change and Skills, manifests, and Bash installer as queued on this head.

@datacas

datacas commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261203-001] · senior_reviewer · anthropic/claude-fable-5-2→? · medium · schema:2

CHANGES_REQUESTED at aab664bf33160c405de13d8d0f20204169f4d592. Full accumulated diff reviewed (988 lines, base aec305f). 2 new findings, both block.

  • REV-001 (high): the new resolve guard stops every resolve dispatch while a candidate "awaits upload", including a LOCAL_PREPARED row that never became a verified preparation. --publish-prepared refuses that row, so the work item has no toolkit path forward. Fix: block only on a publishable candidate and give an explicit way to discard or supersede one. Test: rerun resolve after a failed barrier.
  • REV-002 (medium): the candidate and consent records pass through journal redaction, which rewrites branch names such as feat/task-management. Publication then always reports a mismatch. Fix: store these references unredacted or validate instead of rewriting. Test: prepare and publish from such a branch.

Security audit ran: no confirmed vulnerability. CI is still running (1 passed, 5 pending).

Findings, evidence, verification, CI and receipt

[REV-001] · high · open · - · blocks:yes — Resolve guard dead-ends a work item whose candidate cannot be published

scripts/cycle_dispatch.py:809-822, scripts/prepared_publication.py:31-48,90-92, scripts/cycle_loop.py:417-479

StageDispatch.advance now returns BLOCKED (publication_unverified) for every resolve dispatch, local-only or not, when awaiting_upload is true. latest_preparation also matches the runtime LOCAL_PREPARED row that journal_result writes before the loop validates anything. The verified prepared_resolution row is written only after the verification barrier, the SHA/tree/plan match and the unpublished-head check all pass.

Consequences, from code inspection:

  1. A local-only resolve whose agent reports LOCAL_PREPARED and then stops at the barrier (a required verification check failed, verification_unverified, or the verification_decision question answered with --verification-answer), at candidate_mismatch, or at candidate_state_missing leaves only the runtime row. Every later --from resolve --pr <id> is refused with "use --publish-prepared", and publish raises "no durable verified preparation exists". Neither command can make progress, and no command clears the state.
  2. A verified candidate the operator rejects after inspection, amends, or resets has the same outcome: publish reports a worktree mismatch and resolve stays refused.
  3. Before this change the same rerun was dispatched (base aec305f added only an instruction to retry publication).

The same agent can run the resolve skill directly in that worktree, so this is a toolkit-only veto under the capability-parity rule in AGENTS.md. docs/capability-parity-audit.md PA-56 classifies the upload precondition as a role contract but does not record this refusal of resolve, and docs/review-cycle.md does not describe it.

Not covered by tests: PublicationCompletionTests asserts the refusal only for a verified candidate that is then published.

Suggested direction: refuse only when the latest preparation is a verified, still-matching candidate; let a new local-only resolve supersede an unverified or stale one; give the operator an explicit discard; add the audit row and the docs/review-cycle.md text.

[REV-002] · medium · open · - · blocks:yes — Journal redaction alters the recorded branch, so publication cannot match it

scripts/cycle_loop.py:472-476, scripts/prepared_publication.py:96-104,129-141, scripts/cycle_journal.py:160-181,266-269

The verified preparation and the authorized decision store branch, SHAs, digest and base in correlation. record_event passes every correlation value through redact(value, 200). redact applies _TOKENS without a name boundary, so sk- followed by eight or more word characters is replaced: feat/task-management is stored as feat/ta[REDACTED] (the module itself notes the flask-sqlalchemy case at line 156 and uses a bounded pattern elsewhere). Branch names containing task-, risk-, desk-, mask- plus a long suffix are affected.

publish compares candidate["branch"] with git branch --show-current, so it raises "the prepared candidate does not match the clean worktree, branch, commit and tree" for a candidate that matches. The stored authorization scope is compared with == against the unredacted scope, so consent reuse also fails. The message names the wrong condition, and with REV-001 the work item cannot continue through the toolkit.

It fails closed, so nothing is published wrongly. Evidence is code inspection; an execution probe was refused by the stage policy (see below).

Security

Required by the runtime plan (security_required); cc-security-review ran as a delegated pass on this head. Deterministic rule: no changed path matches the mandatory minimum; the plan requirement and the reviewer's reading (publication authorization, credentials, sandboxed push) activate it.

No confirmed vulnerability. Reviewed: consent scope and reuse, argv construction (no shell, validated repository, branch, PR number and SHAs), the pre-push guard and its environment, HTTPS destination and rewrite detection, cross-repository refusal, error and command redaction, sandbox write and network scope.

Potential risk, informational, not a finding: the guard chains to the checkout's existing pre-push hook inside a sandbox that can read the GitHub CLI credential store. An ordinary git push runs that hook too, so this is parity, but a hook written during an earlier agent stage would run with that access. Not reviewed: the real srt sandbox behaviour of the upload and a real GitHub remote; tests use a local bare repository and a gh fixture.

Verification (run by this review, Linux, head aab664b)

Check Command Result
configured-test python3 -m unittest discover -s tests exit 0, 2910 tests, 1 skipped, 686 s (exceeded the 10-minute foreground limit and finished in the host's background task)
package python3 scripts/validate-package.py exit 0, VALID: 16 skills
bare unittest python3 -m unittest exit 0, 0 tests
types basedpyright exit 0, 0 errors

Not verified by execution: REV-001 and REV-002 reproductions. The stage policy refused a probe script in $TMPDIR and multi-word git grep reads; both findings rest on the cited code.

Acceptance criteria: AC-1 to AC-8 are linked to configured-test. AC-8 (missing or corrupt state names the unresolved condition; repeated resumes stay usable) is not met for the states in REV-001 and REV-002.

CI (parallel policy, read once)

Classify the change: pass. Pending: Skills, manifests, and Bash installer, Windows test shard (windows-1) to (windows-4).

Documentation

The owning pages are updated and the PR lists its documentation review. The gap is the undocumented resolve refusal, tracked in REV-001.

Residual risk

Sandboxed upload against GitHub is untested end to end. Windows behaviour of the POSIX pre-push guard depends on pending shards.

@datacas

datacas commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

[CCT-20261203-001] · deep_coder · openai/gpt-6.2-sol→? · high · triaged:aab664bf33160c405de13d8d0f20204169f4d592 · schema:2

RESOLVED at d1deee8a0c4102282e4d4aa8e1a3a5acf142baac.

  • REV-001 allowed provisional or stale state to block resolve. Local-only reruns now preserve and reverify the candidate. Tests cover a failed barrier, missing attribution, and an amended commit.
  • REV-002 matched journal text that redaction could rewrite. Exact branch and base digests preserve the scope. Tests cover feat/task-management, consent reuse, and changed refs.

Discovery reported 2,911 tests with one skip. All 29 publication tests passed. The required security audit found no confirmed vulnerability. GitHub reported two checks in progress on the pushed head.

Review history, verification and receipt

[CCR-20261203-001] · senior_reviewer · anthropic/claude-fable-5-2→? · medium · schema:2

[REV-001] · high · resolved · valid · blocks:yes — Resolve guard dead-ends a work item whose candidate cannot be published

scripts/cycle_dispatch.py, scripts/cycle_session.py, scripts/prepared_publication.py

A plain resolve redirects to prepared upload only when the verified preparation matches the checkout, the frozen plan, the known base, and the PR head. A local-only rerun can retain a clean candidate at the selected checkout when the fetched PR head is its ancestor. Successful repreparation creates a new consent scope. Publication tests cover retrying after failed verification or missing attribution, and repreparing an amended commit.

[REV-002] · medium · resolved · valid · blocks:yes — Journal redaction alters the recorded branch, so publication cannot match it

scripts/cycle_loop.py, scripts/prepared_publication.py

Candidate records bind the branch digest. Upload consent binds the digests of the branch and base, along with the exact candidate and its verification plan. Journal redaction remains active. The consent regression exercises an interrupted upload, a branch and base containing token-like text, rejection after either ref changes, and idempotent retry.

Fix delta and security

The trusted review head aab664bf33160c405de13d8d0f20204169f4d592 is an ancestor of the pushed fix. The delegated code review and required security audit covered the fix delta. The audit checked candidate provenance, the worktree and ancestry boundary, consent reuse, and transport validation. It found no confirmed vulnerability. The prepared-upload checks use disposable Git repositories and a GitHub CLI fixture.

Verification (agent-reported)

The committed tree matches the tested tree on Linux. The configured discovery and publication boundary checks cover AC-1 through AC-8.

Check Command Exit Tests
configured-test python3 -m unittest discover -s tests 0 2,911 with one skip
Package validation python3 scripts/validate-package.py 0 —
Bare unittest python3 -m unittest 0 0
verify:basedpyright basedpyright 0 —
prepared-publication-boundary python3 -m unittest tests.test_publication tests.test_run_cycle.PublicationCompletionTests 0 29
Handler inventory python3 -m unittest tests.test_precheck_causes.PrecheckCauseTests.test_every_broad_handler_has_an_inventory_row 0 1

The first discovery run caught a missing handler inventory row. The focused check and final discovery rerun passed after the inventory was updated.

Provider checks

On d1deee8a0c4102282e4d4aa8e1a3a5acf142baac, Classify the change and Skills, manifests, and Bash installer were in progress. The four Windows shards and PowerShell installer had yet to appear in the check rollup.

Documentation

Updated the review lifecycle, runtime workflows, configuration, worktree policy, instrumentation, capability parity audit, and resolver skill. Reviewed the execution plan page, documentation index, README, CONTRIBUTING, AGENTS, SECURITY, and GitHub templates for affected guidance. The existing links and contribution instructions cover this change.

@datacas

datacas commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261203-002] · senior_reviewer · anthropic/claude-fable-5-2→? · medium · schema:2

APPROVED at d1deee8a0c4102282e4d4aa8e1a3a5acf142baac. Full accumulated diff rereviewed (1276 lines, base aec305f). No open finding blocks approval.

  • REV-001 resolved: a plain resolve is refused only for a verified candidate that still matches the checkout, plan and PR head; a --local-only rerun reverifies or supersedes it. Tests: retry after a failed barrier, missing attribution, amended commit.
  • REV-002 resolved: candidate and consent records bind SHA-256 digests of the branch and base, which redaction cannot rewrite. Test: feat/task-management with base feat/risk-management.
  • REV-003 new (low, does not block): after a direct git push of the candidate, a plain resolve still reports that it "awaits publication".

Security audit ran: no confirmed vulnerability. CI: all 7 checks passed on this head. Merging stays manual.

History, findings, verification, CI and receipt

[CCR-20261203-001] · senior_reviewer · anthropic/claude-fable-5-2→? · medium · schema:2

[CCT-20261203-001] · deep_coder · openai/gpt-6.2-sol→? · high · triaged:aab664bf33160c405de13d8d0f20204169f4d592 · schema:2

Previous reviewed head: aab664bf33160c405de13d8d0f20204169f4d592.

[REV-001] · high · resolved · valid · blocks:yes — Resolve guard dead-ends a work item whose candidate cannot be published

scripts/cycle_dispatch.py:814-878, scripts/prepared_publication.py:41-58, scripts/cycle_loop.py:465-482

Corrected and verified by execution. awaiting_upload is true only for a prepared_resolution row with status verified, so the runtime LOCAL_PREPARED row no longer blocks. The refusal also needs verified_candidate to pass on the current checkout and the PR head to be the candidate or its recorded base. A stale, amended or reset candidate raises HistoryError (a ValueError), which the guard catches and resolution proceeds. A --local-only rerun on the same branch and worktree keeps the current commit, runs the required checks and writes a new preparation that needs its own authorization (the consent key is the new event ID).

Reproduction: tests.test_run_cycle.PublicationCompletionTests.test_local_preparation_can_retry_failed_verification_and_supersede_an_amended_head and the recovery step of the missing-attribution test ran in prepared-publication-boundary (29 tests, exit 0). docs/review-cycle.md and PA-56 in docs/capability-parity-audit.md now describe the redirect and the local-only path.

[REV-002] · medium · resolved · valid · blocks:yes — Journal redaction alters the recorded branch, so publication cannot match it

scripts/prepared_publication.py:27-38,146-154, scripts/cycle_loop.py:472-476, scripts/cycle_session.py:260-263

Corrected and verified by execution. The preparation, the runtime row and the consent scope store branch_sha256, base_sha256 and workspace as 64-character hexadecimal digests. No pattern in cycle_journal.redact matches such a value. The published-candidate test renames the branch to feat/task-management, uses base feat/risk-management, and covers an interrupted upload, consent reuse, refusal after the branch or base changes, and an idempotent retry.

[REV-003] · low · open · - · blocks:no — A candidate pushed directly still makes a plain resolve report that it awaits publication

scripts/cycle_dispatch.py:830-843

The guard stops a plain resolve when the PR head is the candidate's recorded base or the candidate itself (target_head in {old, head}). When the operator uploads the verified commit with an ordinary git push, no published row exists, so the next --from resolve --pr <id> returns publication_unverified with "a verified local resolution awaits publication". The commit is already on the PR. --publish-prepared <SHA> clears it without sending a push, so there is a toolkit path forward and nothing is published wrongly. The message names the wrong state, and docs/review-cycle.md says the redirect applies only while a candidate awaits upload.

Evidence is code inspection; no execution probe was run. Suggested direction: when the PR head already equals the candidate, record the reconciliation or let resolve proceed, or word the message for that case.

Security

Required by the runtime plan (security_required); cc-security-review ran as a delegated pass on d1deee8. No changed path matches the mandatory minimum; the plan requirement activates the audit.

No confirmed vulnerability. Reviewed in the fix delta: the consent key is the event ID of one verified preparation and its scope binds operation, candidate SHA, old head, plan digest and the branch and base digests; a superseding preparation cannot reuse earlier consent; the local-only rerun keeps a foreign commit only on the recorded branch and worktree, with a clean checkout and fast-forward ancestry from the fetched PR head, and still passes the verification barrier; upload arguments stay an argv list with validated repository, branch, PR number and SHAs; the pre-push guard and the fast-forward refspec are unchanged.

Potential risk, informational, unchanged: the guard chains to the checkout's existing pre-push hook inside a sandbox that can read the GitHub CLI credential store. An ordinary git push runs that hook too.

Not reviewed: the real srt sandbox behaviour of the upload and a real GitHub remote. Tests use a local bare repository and a gh fixture.

Verification (run by this rereview, Linux, head d1deee8)

Check Command Result
configured-test python3 -m unittest discover -s tests exit 0, 2911 tests, 1 skipped, 1166 s (exceeded the 10-minute foreground limit and finished in the host's background task)
ref-8ccc5e44… python3 scripts/validate-package.py exit 0, VALID: 16 skills
ref-a1d5411a… python3 -m unittest exit 0, 0 tests
verify:basedpyright basedpyright exit 0, 0 errors
prepared-publication-boundary python3 -m unittest tests.test_publication tests.test_run_cycle.PublicationCompletionTests exit 0, 29 tests
audit-handler-inventory python3 -m unittest tests.test_precheck_causes.PrecheckCauseTests.test_every_broad_handler_has_an_inventory_row exit 0, 1 test

Acceptance criteria AC-1 to AC-8 are linked to configured-test and prepared-publication-boundary.

CI (parallel policy, read once)

All 7 checks of d1deee8 passed: Classify the change, Skills, manifests, and Bash installer, Windows test shard (windows-1) to (windows-4), PowerShell installer. None failed or pending.

Documentation

The owning pages (docs/review-cycle.md, docs/workflows.md, docs/configuration.md, docs/role-workspace-policy.md, docs/instrumentation.md, docs/execution-plan.md, docs/capability-parity-audit.md) and the resolver skill are updated, and the PR lists its documentation review. The verification table in the PR description still names head aab664b; the resolve comment carries the current one.

Residual risk

The sandboxed upload against GitHub is untested end to end. REV-003 stays open as a non-blocking follow-up.

@datacas
datacas merged commit f0c98c6 into main Dec 3, 2026
7 checks passed
@datacas
datacas deleted the feat/504-publication-retry branch December 3, 2026 13:46
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.

1 participant