Skip to content

run_cycle: resume an existing change request (--from review|resolve|rereview --pr N) - #95

Merged
datacas merged 2 commits into
mainfrom
issue-75-run-cycle-resume
Sep 25, 2026
Merged

datacas merged 2 commits into
mainfrom
issue-75-run-cycle-resume

Conversation

@datacas

@datacas datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Closes #75 — #75

What changes

  • run_cycle.py --from implement|review|resolve|rereview (default implement, today's behaviour) and --pr N.
    • review: fresh initial review, then the resolve → rereview loop.
    • resolve: enters the loop at resolution; the stage recovers the earlier findings from the PR's comments through review.trusted_authors.
    • rereview: rereview first, then the loop.
    • Skipped stages are not run. The rest keep the full cycle's routing, recording and --max-iterations.
  • Refused before any dispatch (and before the telemetry DB is created): --from other than implement without --pr, --pr with --from implement, --local-only with a resume, and an unsafe --pr reference.
  • Before dispatching a resume, the CLI reads the PR with gh and stops with a named reason unless it is open, its head branch exists (gh api repos/<head>/branches/<branch>), and --cwd has that branch checked out. A configured code_host other than GitHub is refused, since only gh is used.
  • A resumed run is a new cycle (new cycle_id). Every row now carries started_from (telemetry schema 5).
  • first_pass_approved is only written on cycles that started at implement. Telemetry.first_pass_rate (measured routing) and cc-stats' _first_pass ignore rows whose started_from isn't implement. Rows without the field read as implement.
  • Docs: docs/workflows.md (runtime driver), docs/configuration.md (flags), docs/telemetry.md / docs/instrumentation.md (field), CHANGELOG.md.

Verification

  • python3 -m unittest discover -s tests → 698 tests, OK
  • python3 scripts/validate-package.py → VALID
  • New tests: the default run is unchanged and records started_from=implement. --from resolve runs resolve → rereview with scripted executors and stops at --max-iterations. --from review and --from rereview are covered. A resume without --pr is refused before dispatch, in-process and through the CLI with no DB created. The PR check covers closed, missing-branch and wrong-branch cases. first_pass_rate and cc-stats ignore resumed cycles.
  • Live CLI: --from resolve without --pr → --from resolve requires --pr. --from resolve --pr 94 (merged) → pull request 94 is MERGED, not open, and no DB is created.

Residual risk

  • The PR check is GitHub-only. Bitbucket resumes are refused rather than supported.
  • No real end-to-end resumed cycle was dispatched against live executors. It was tested with scripted executors only.

run_cycle.py always started at implement, so continuing a cycle that
stopped midway meant implementing an issue whose PR already existed.

--from review|resolve|rereview --pr N now skips the earlier stages and
runs the rest with the same routing, recording and iteration limit. A
resume without --pr, --pr without a resume, and --local-only with a
resume are refused before any dispatch; the CLI then reads the pull
request with gh and stops unless it is open, its head branch exists and
--cwd has that branch checked out.

A resumed run is a new cycle whose rows carry started_from (telemetry
schema 5). first_pass_approved is only written for cycles that started at
implement, and both first-pass readers (Telemetry.first_pass_rate and
cc-stats) ignore rows from resumed cycles.

Closes #75
@datacas

datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260925-001] · ? · ?/?→? · ? · schema:1

Review summary

Reviewed PR #95, “run_cycle: resume an existing change request (--from review|resolve|rereview --pr N),” against main from merge base 73508f5cde6307c94d4382a967e5ccdb60eb03ef through head 3ec28a749467dcfed16bf1a5158036c24979e237 (13 changed files). The PR is linked to issue #75, is open and not a draft, and has no labels. Repository guidance was taken from CONTRIBUTING.md and the toolkit review workflow; no AGENTS.md or CLAUDE.md is present.

The resume flow, stage selection, telemetry tagging, first-pass accounting, documentation, and tests were reviewed. The review found one blocking correctness issue.

Findings

[REV-001] · medium · open · - · blocks:yes — Resume accepts a stale checkout of the PR branch

Path: scripts/run_cycle.py:489

check_change_request requests the PR state and branch name, confirms that the remote branch exists, and then compares only git rev-parse --abbrev-ref HEAD with that name. It never reads headRefOid or compares the checked-out HEAD commit with the PR’s current head commit. If the PR advances while the local worktree remains on the same branch name, resume passes its guard and dispatches review or resolution against stale code. That can produce a verdict for code no longer in the PR or edits based on an outdated tree. Fetch the PR head SHA and require the checked-out commit to match before dispatch.

Security triage

.code-cycle.yml has no deterministic security_review.always_when rule. Reviewer triage activated the security audit because this change modifies review/security tooling and change-request handling in scripts/run_cycle.py. The security pass found no separate authentication, authorization, injection, secret-handling, or data-exposure issue; the stale-head mismatch is reported above as a correctness finding.

Verification

  • git diff --check origin/main...origin/issue-75-run-cycle-resume — passed.
  • python3 -m unittest discover -s tests — 698 tests passed.
  • python3 scripts/validate-package.py — VALID.
  • A stubbed execution of the resume guard accepted matching branch names without requesting a PR head SHA; the only local Git check was git rev-parse --abbrev-ref HEAD. This confirms the guard does not detect a stale checkout.
  • A real resumed cycle was not dispatched against live executors. The guard finding is verified by the targeted stubbed execution; live end-to-end behavior remains unverified.

CI

gh pr checks 95 reports both PowerShell installer runs passed and both Skills, manifests, and Bash installer runs passed. No pending, failed, cancelled, or skipped checks were reported. These are the repository’s defined checks for this PR.

Residual risk

Until the local checkout is checked against the PR head SHA, a resumed run can operate on stale code even when its branch name matches. No live executor cycle was run as part of this review.

Verdict

CHANGES_REQUESTED — REV-001 is open and blocks approval.

@datacas

datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

[CCT-20260925-001] · ? · ?/?→? · ? · triaged:3ec28a749467dcfed16bf1a5158036c24979e237 · schema:1

Triage recorded before any code change. Every finding was judged against 3ec28a749467dcfed16bf1a5158036c24979e237.

[REV-001] · medium · open · valid · blocks:yes — Resume accepts a stale checkout of the PR branch

scripts/run_cycle.py check_change_request compares only the branch name. A worktree on the right branch but behind or ahead of the PR head passes, so a resumed review or resolution would work on code that isn't the PR. Planned fix: read headRefOid and require the checked-out HEAD commit to equal it before dispatch.

… head

check_change_request compared only the branch name, so a worktree on the
PR's branch but behind or ahead of it passed and a resumed review or
resolution would work on code that isn't the pull request. It now reads
headRefOid and requires the checked-out HEAD commit to equal it.

Resolves REV-001 on #95.
@datacas

datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260925-001] · ? · ?/?→? · ? · schema:1

[CCT-20260925-001] · ? · ?/?→? · ? · triaged:3ec28a749467dcfed16bf1a5158036c24979e237 · schema:1

Resolution summary

Functional status: RESOLVED. Triage was judged against 3ec28a749467dcfed16bf1a5158036c24979e237. The fix is in commit 2236d7d47d8123a195ac94b6f537c7ade76b4062.

Applied fixes

[REV-001] · medium · resolved · valid · blocks:yes — Resume accepts a stale checkout of the PR branch

Path: scripts/run_cycle.py (check_change_request)

The guard now also requests headRefOid and runs git rev-parse HEAD in --cwd. It refuses the resume unless the checked-out commit equals the PR's head commit, and the error names both short SHAs. A PR payload with no head commit is refused as well. docs/workflows.md and CHANGELOG.md now describe the check.

Verification:

  • New regression test test_a_stale_checkout_of_the_right_branch_is_refused. The happy-path test now asserts that headRefOid is requested and that git rev-parse HEAD runs.
  • Live reproduction against this PR: a clone with issue-75-run-cycle-resume checked out at 3ec28a7~1.
    • Before the fix, the check passed.
    • After the fix, it was refused: the working directory is at 73508f5cde63, not at 3ec28a749467, the head commit of pull request 95.
    • The up-to-date worktree still passes.
  • python3 -m unittest discover -s tests: 699 tests, OK. python3 scripts/validate-package.py: VALID. git diff --check: clean.

Post-change workflow

  • Code review of the accumulated fix diff: no new findings.
  • Security triage: security_review.always_when declares no rule and the PR has no labels. The change only adds a read-only git rev-parse HEAD call with fixed arguments, so no security audit was triggered.
  • CI (gh pr checks 95): both PowerShell installer runs and both Skills, manifests, and Bash installer runs passed. None are pending, failed, cancelled or skipped.

Residual risk

No live resumed cycle has been dispatched against real executors. The guard was exercised against the live PR, and the stage loop was exercised with scripted executors.

@datacas

datacas commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260925-001] · ? · ?/?→? · ? · schema:1

[CCR-20260925-002] · ? · ?/?→? · ? · schema:1

Re-review summary

Re-reviewed PR #95 against main, from merge base 73508f5cde6307c94d4382a967e5ccdb60eb03ef through current head 2236d7d47d8123a195ac94b6f537c7ade76b4062. The prior review covered head 3ec28a749467dcfed16bf1a5158036c24979e237. The accumulated diff still spans 13 files.

Since the prior review, commit 2236d7d (fix(run_cycle): refuse to resume from a checkout that isn't at the PR head) changed CHANGELOG.md, docs/workflows.md, scripts/run_cycle.py, and tests/test_run_cycle.py (33 insertions, 6 deletions). The new guard reads the PR's headRefOid, compares it with git rev-parse HEAD, and rejects a mismatch before dispatch. The regression test covers a matching branch name with a stale commit.

Previous findings

[REV-001] · medium · resolved · - · blocks:yes — Resume accepts a stale checkout of the PR branch

Previous location: scripts/run_cycle.py:489
Fix location: scripts/run_cycle.py:492, scripts/run_cycle.py:521

The prior finding is corrected and verified by execution. The resume guard now requests headRefOid and refuses a checkout whose HEAD differs from the PR head. test_a_stale_checkout_of_the_right_branch_is_refused exercises the original case and passes. The disposition remains -, unchanged from the prior record; no resolver has assigned one. No new findings were identified in the accumulated diff.

Security triage

.code-cycle.yml has no deterministic security_review.always_when rule. Reviewer triage activated the security audit because the change modifies review/security tooling and change-request handling in scripts/run_cycle.py. The audit found no additional authentication, authorization, injection, secret-handling, or data-exposure issue.

Verification

  • python3 -m unittest discover -s tests -p test_run_cycle.py — 92 tests passed, including the stale-checkout regression and matching-head case.
  • python3 -m unittest discover -s tests — 699 tests passed.
  • python3 scripts/validate-package.py — VALID.
  • git diff --check origin/main...origin/issue-75-run-cycle-resume — passed.
  • The current PR head SHA was confirmed as 2236d7d47d8123a195ac94b6f537c7ade76b4062, matching the reviewed checkout.
  • A real resumed cycle was not dispatched against live executors; executor behavior remains unverified end to end.

CI

gh pr checks 95 reports both PowerShell installer runs passed and both Skills, manifests, and Bash installer runs passed. No pending, failed, cancelled, or skipped checks were reported. These are the repository's defined checks for this PR.

Residual risk

The stale-checkout guard is covered by its regression test and the full suite. Live execution with real cycle executors was not performed.

Verdict

APPROVED — the only prior blocking finding, REV-001, is resolved and verified; no open blocking findings remain, and all required CI checks pass for the reviewed head.

@datacas
datacas merged commit 29ad33d into main Sep 25, 2026
4 checks passed
@datacas
datacas deleted the issue-75-run-cycle-resume branch October 6, 2026 07:53
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.

run_cycle: resume an existing change request (--from review|resolve|rereview --pr N)

1 participant