Skip to content

Add local-only cycle execution policy - #23

Merged
datacas merged 2 commits into
mainfrom
fix/local-only-cycle-runner
Sep 22, 2026
Merged

datacas merged 2 commits into
mainfrom
fix/local-only-cycle-runner

Conversation

@datacas

@datacas datacas commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an explicit --local-only mode that requires a Git worktree via --cwd
  • carry the no-publish boundary through stage prompts and telemetry
  • require structured orchestration output even when a stage is blocked
  • document the policy and add regression coverage

Verification

  • python3 -m unittest discover -s tests -v (435 tests, OK)
  • python3 scripts/validate-package.py (VALID)

The PR is ready for review and is not merged.

@datacas

datacas commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Initial review — CHANGES_REQUESTED

[CCR-20260922-005] · manual_reviewer · anthropic/claude-opus-5→? · high · schema:1

Manual invocation, so no executor dispatch receipt exists and the resolved model
is written ? rather than filled in by the agent.

Scope reviewed

Accumulated diff b4fdda5..c9b6bcd (merge-base b4fdda5, the tip of main),
6 files, +113/−18: scripts/run_cycle.py, scripts/cycle.py,
scripts/telemetry.py, tests/test_run_cycle.py, README.md,
docs/instrumentation.md. No linked work item is named in the description. This
is the first review, so no prior findings exist and IDs start at REV-001.

The plumbing is clean and the honesty is good. --local-only is threaded through
run_cycle → CycleRecorder → every telemetry row, LOCAL_ONLY_REQUEST is a
named constant rather than an inline sentence, local_only passes the
FIELD_SPECS gate as a typed flag, and both validate_local_only_cwd and the
README say plainly that this is an orchestration policy and not an OS sandbox.
The STRUCTURED_REQUEST addition also matches what the three cycle skills
already promise: the block is emitted when a stage is BLOCKED.

What is missing is the other half of the feature. The flag changes what the
cycle skills are told to do, but no skill was changed, and the stages after
implement are defined entirely over a change request that the no-publish
boundary prevents from existing.

Findings

[REV-001] · medium · open · - · blocks:yes — The no-publish boundary contradicts the cycle skills, so a local-only cycle cannot get past implementation

scripts/run_cycle.py:80 (LOCAL_ONLY_REQUEST). No file under skills/ is
changed by this pull request.

LOCAL_ONLY_REQUEST instructs every stage not to "publish issue or review
comments" and not to create a non-draft pull request. The skills those stages run
say the opposite, and they say it as a requirement:

  • skills/cc-implement-issue/SKILL.md:86 — "If the user explicitly asks for
    local-only work, stop after the requested local checks and report that no PR
    was created." So the implement stage correctly produces no pull request, which
    the prompt's "create only a draft" clause does not override.
  • skills/cc-initial-review/SKILL.md:422 — "Always publish one comment on the
    change request containing: …". There is no local-only exception, and the
    comment is the machine-readable record every later stage recovers from.
  • skills/cc-rereview/SKILL.md:320 — step 11, "Always publish an updated
    change-request comment."
  • cc-resolve-comments recovers findings from published comments, which under
    this policy never exist.

So run_cycle dispatches cc-initial-review for a change request that the
previous stage was told not to create, and that stage is then simultaneously
required to publish a comment and forbidden from publishing one. The realistic
outcome is BLOCKED at stage 2 — which the widened STRUCTURED_REQUEST
("Do not omit the block when the stage is blocked") reads like an anticipation
of, but nothing in README.md or docs/instrumentation.md tells an operator
that a local-only rehearsal is expected to stop there. The README describes it as
a rehearsal that "adds the no-publish boundary to every stage prompt", which
reads as a cycle that runs.

The end-to-end test does not catch this because Talker
(tests/test_run_cycle.py:44) answers APPROVED/COMPLETED from a canned table
regardless of the prompt it is handed, so
test_local_only_prompt_is_explicit_and_recorded asserting rc.APPROVED_END
proves the flag is plumbed, not that a local-only cycle completes.

Either teach the cycle skills the boundary — a local-only clause beside their
publication requirement, so the review record has a defined home when no comment
may be published — or state in the README and in docs/instrumentation.md what a
local-only run is expected to produce and where it is expected to stop. The
plumbing here is right either way; what is missing is the contract on the other
side of the prompt.

[REV-002] · low · open · - · blocks:no — The precondition is checked after the telemetry database is created

scripts/run_cycle.py:305 (validate_local_only_cwd, called from run_cycle),
and scripts/run_cycle.py:609-625 (main).

Every other argument precondition lives in plan(args), whose docstring states
the rule: an unknown profile "is refused by load_profiles, and learning that
after a stage has already run would mean paying for a cycle to discover a typo.
So this happens first". --local-only without --cwd is exactly that kind of
typo, but it is validated inside run_cycle, which main reaches only after
constructing Telemetry(...) — and Telemetry.__init__
(scripts/telemetry.py:415-420) creates the parent directory and writes the
schema. Observed:

$ python3 scripts/run_cycle.py --repo owner/api --task API-7 --local-only \
    --no-config --database "$T/telemetry/cycle.db"
run_cycle: error: --local-only requires an explicit --cwd worktree
exit=2
db exists after: yes   (20480 bytes)

A rejected invocation leaves a database behind. plan(args) already receives
args, so moving the check there costs one line and restores the module's own
ordering rule.

The compensating try/except CycleDriverError now wraps the whole of
run_cycle, not just the validation. CycleDriverError is also raised from
compose (scripts/run_cycle.py:285) during the cycle; should that ever fire, it
would be reported through parser.error() as a command-line usage error with a
usage: dump and exit 2, and both report.explain() and the recorded in …
line would be skipped after agents had already been dispatched and paid for. That
path is not reachable today, since roles come from a fixed table, so this is
noted with the placement rather than as a defect of its own.

[REV-003] · low · open · - · blocks:no — The CLI layer of the new flag is untested

tests/test_run_cycle.py:114.

The three new tests cover compose and the run_cycle library entry point.
Nothing calls main() with --local-only, so the argparse flag, the new
except CycleDriverError around run_cycle, and the exit code are unexercised.
The --local-only without --cwd branch has no test either —
test_local_only_requires_a_git_worktree covers only the directory-without-.git
case. The sentence added to STRUCTURED_REQUEST is likewise unasserted:
test_compose_can_request_a_local_only_run checks that ORCHESTRATION_RESULT
appears, which was already true before this change.

[REV-004] · low · open · - · blocks:no — The worktree check cannot tell a disposable worktree from the live repository

scripts/run_cycle.py:295 (validate_local_only_cwd).

The check accepts any directory containing .git, which correctly covers both a
repository and a linked worktree, but it also accepts the repository the
coordinator is running in: --local-only --cwd . passes. The docstring is
narrowly accurate — it says the check stops the flag running in the current
directory silently, and an explicit --cwd . is not silent — but the README
sells the mode as "a rehearsal that must stay in a disposable Git worktree",
which is a stronger promise than the code makes. Either align the README wording
with what is enforced, or check for a linked worktree specifically: in one,
.git is a file pointing at the parent repository, not a directory.

Security triage and audit

Sensitive: the change adds a safety boundary intended to prevent remote writes,
and it touches deployment-facing CLI configuration and telemetry. The audit ran
inline rather than as a separately dispatched cc-security-review, so treat that
pass as degraded; its scope was the new boundary, the CLI surface, and the
telemetry field.

Result: no vulnerability. The boundary is advisory — it is a sentence in a prompt
— and the change says so in three places rather than overselling it
(validate_local_only_cwd's docstring, README.md:320-326,
docs/instrumentation.md:527-531), each pointing the operator at credential and
network isolation for a hard guarantee. That is the right framing for a control an
agent can ignore. local_only is a boolean passing the FIELD_SPECS gate, so it
carries no free text into the telemetry store, which is the boundary
docs/instrumentation.md:380-392 exists to protect. No credential, token, or
authorization surface is touched.

Worth keeping in view rather than fixing here: a control named --local-only
invites being trusted as an enforcement, and the only thing standing between it
and a published comment is an agent's compliance. REV-001 is the sharp edge of
that, since the skills currently instruct the agent the other way.

Executed commands and observed results

Command Result
python3 -m unittest discover -s tests 435 tests, OK
python3 scripts/validate-package.py VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned
git diff --check clean
run_cycle.py --local-only without --cwd exit 2, usage error, telemetry database created — as quoted in REV-002
grep of the publication requirements in the four cycle skills as quoted in REV-001

Runtime: Python 3.10.12. The working tree is already checked out at c9b6bcd,
which matches the change-request head; nothing was modified.

Unverified

  • No local-only cycle was run against real executors, so REV-001's outcome is
    argued from the skills' own text and the driver's stage order, not from an
    observed blocked run. The existing test cannot settle it, for the reason given
    in that finding.
  • Windows behaviour was not executed locally; CI covers it and passes.
  • The except CycleDriverError path around run_cycle was not exercised for a
    mid-cycle error, because no reachable mid-cycle raise exists to trigger it.
  • Telemetry rows were inspected through the test suite's store rather than by
    querying a database produced by a real run.

CI

Both jobs the repository defines ran on c9b6bcd and passed on both platforms.

Check State
Skills, manifests, and Bash installer (ubuntu-latest) pass
PowerShell installer (windows-latest) pass

gh pr checks 23 reports 4 passed, 0 failed. Both jobs run
scripts/validate-package.py and unittest discover -s tests, so the new tests
are gated. No defined check is missing, pending, skipped, or cancelled.

Residual risks

--local-only will be read as a guarantee by someone, and it is not one. The
documentation says so clearly, which is the best a prompt-level policy can do,
but the gap between the name and the mechanism is permanent and worth a sentence
wherever the flag is offered to an operator.

The telemetry field records the intent of the run, not whether the boundary
held. A row with local_only=true is evidence of what the coordinator asked for,
not evidence that nothing was published — which is the right thing to record, as
long as nobody reads it as the latter.

Verdict

CHANGES_REQUESTED. The driver-side work is sound, well-placed, and honest about
its own limits. REV-001 blocks approval: the flag tells four skills to do
something their own instructions forbid, no skill was updated, and the one
end-to-end test passes because its fake executors ignore the prompt entirely.
REV-002 through REV-004 are small and non-blocking.

@datacas

datacas commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner Author

Resolution update — RESOLVED

The four findings from the previous review are addressed on f95911a.

[REV-001] · medium · resolved · blocks:yes — The no-publish boundary contradicts the cycle skills, so a local-only cycle cannot get past implementation

Resolved. --local-only now stops the driver after a successful implementation with a recorded HUMAN_INTERVENTION coordinate row. It never dispatches cc-initial-review, so no skill is asked to publish a change-request comment that the local-only policy forbids. README and instrumentation docs describe this stop contract explicitly.

[REV-002] · low · resolved · blocks:no — The precondition is checked after the telemetry database is created

Resolved. plan() validates the local-only worktree before Telemetry is constructed. The CLI regression test confirms an invalid invocation exits with code 2 and leaves no database behind.

[REV-003] · low · resolved · blocks:no — The CLI layer of the new flag is untested

Resolved. Coverage now exercises main() with --local-only and no --cwd, asserts the parser error and exit code, checks the no-database guarantee, and asserts the strengthened structured-result instruction.

[REV-004] · low · resolved · blocks:no — The worktree check cannot tell a disposable worktree from the live repository

Resolved. Local-only mode now requires a linked worktree marker (.git must be a file beginning with gitdir:), rejecting the live repository and ordinary repository directories. The regression suite covers both rejection cases.

Verification

Command Result
python3 -m unittest discover -s tests -v 437 tests, OK
python3 scripts/validate-package.py VALID
git diff --check clean
post-change code review no P0/P1/P2/P3 findings
post-change security review no confirmed vulnerabilities

The local-only policy remains an orchestration boundary rather than an OS-level network sandbox; the documentation retains that residual risk and recommends isolated credentials and remote access controls for a hard no-publish guarantee.

All four GitHub checks for f95911a have now passed.

@datacas

datacas commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Re-review — APPROVED

[CCR-20260922-006] · manual_reviewer · anthropic/claude-opus-5→? · high · schema:1

Manual invocation, so no executor dispatch receipt exists and the resolved model
is written ? rather than filled in by the agent.

What changed since the previous review

Previous reviewed head c9b6bcd, current head f95911a, one new commit
(Make local-only cycles stop before review): +64/−20 across four files.
Accumulated diff against main is +158/−19 over six files.

The design question REV-001 raised is answered by narrowing the feature rather
than by stretching the skills. --local-only now runs the implementation stage
and stops, returning UNRESOLVED_END — which is HUMAN_INTERVENTION
(scripts/run_cycle.py:112), so the README and docs/instrumentation.md name
the status correctly. cc-initial-review is never dispatched, so no skill is
asked to publish a comment it is forbidden to publish, and
LOCAL_ONLY_REQUEST lost the draft-pull-request clause that contradicted
cc-implement-issue. The precondition moved into plan() ahead of
resolve_config, the worktree check now demands a gitdir: marker file, and the
CLI error path has a test.

All four previous findings are fixed and verified by execution. Two new low
findings sit on the edges of the tightened check; neither blocks approval.

Status of previous findings

[REV-001] · medium · resolved · - · blocks:yes — The no-publish boundary contradicts the cycle skills, so a local-only cycle cannot get past implementation

Corrected and verified by execution on f95911a. Observed directly with the
driver's own fakes in a linked worktree:

status:           HUMAN_INTERVENTION
stopped_because:  local-only run stops after implementation; no change request
                  was created for review
implement dispatched: 1 | review dispatched: 0
local_only on every recorded row: [True, True, True]

The review stage is not reached, so the contradiction with
skills/cc-initial-review/SKILL.md:422 and skills/cc-rereview/SKILL.md:320 no
longer arises. Dropping "create only a draft" from LOCAL_ONLY_REQUEST also
settles the disagreement with skills/cc-implement-issue/SKILL.md:86, which
says local-only work reports that no PR was created — the prompt now says the
same thing. The stop contract is stated in both README.md:320-326 and
docs/instrumentation.md:527-533, which is the documentation half the previous
review asked for.

The test that previously masked this was corrected rather than left in place:
test_local_only_prompt_is_explicit_and_recorded now asserts UNRESOLVED_END
and [] == reviewer.dispatched, so the canned Talker reply can no longer make
a local-only run look approved.

[REV-002] · low · resolved · - · blocks:no — The precondition is checked after the telemetry database is created

Corrected and verified by execution. The original reproduction now leaves nothing
behind:

$ python3 scripts/run_cycle.py --repo owner/api --task API-7 --local-only \
    --no-config --database "$T/telemetry/cycle.db"
run_cycle: error: --local-only requires an explicit --cwd worktree
exit=2
db exists after: no
dir exists after: no

plan() validates first, ahead of resolve_config, which is where the module's
own ordering rule puts preconditions. run_cycle keeps its own check, so the
library entry point is still guarded independently — test_local_only_rejects_the_live_repository
exercises that path.

[REV-003] · low · resolved · - · blocks:no — The CLI layer of the new flag is untested

Corrected. MainLocalOnlyTests.test_cli_rejects_missing_worktree_before_creating_telemetry
drives main() with --local-only and no --cwd, asserting exit code 2, the
absence of the database, and the message. PromptContractTests now asserts the
Do not omit the block when the stage is blocked sentence that the previous
review pointed out was unverified. All five tests in the affected classes pass.

[REV-004] · low · resolved · - · blocks:no — The worktree check cannot tell a disposable worktree from the live repository

Corrected and verified by execution. validate_local_only_cwd now requires
.git to be a file beginning with gitdir:, and the live repository is rejected:

validate_local_only_cwd("/home/datacas/www/code-cycle-toolkit")
→ --local-only requires a linked Git worktree, not a live repository: …
validate_local_only_cwd(<dir with .git file "gitdir: …">)
→ accepted

README.md and docs/instrumentation.md both say "linked" now, so the wording
matches what is enforced. See REV-005 for what the tightened check also excludes.

New findings

[REV-005] · low · open · - · blocks:no — A disposable clone is rejected, and the message calls it a live repository

scripts/run_cycle.py:309.

Requiring a gitdir: marker admits linked worktrees only. A throwaway git clone
into a temporary directory — the most common way to make a disposable checkout,
and as safe a rehearsal target as a linked worktree — is refused:

$ git clone --depth 1 file:///…/code-cycle-toolkit /tmp/…/clone
validate_local_only_cwd("/tmp/…/clone")
→ --local-only requires a linked Git worktree, not a live repository: /tmp/…/clone

A fresh clone is not "the live repository", so the message sends the operator
looking for a problem that is not there. If linked worktrees are genuinely the
only supported target, the message should say why a clone is excluded rather than
misdescribing it; if they are not, the check wants a second accepted shape.

[REV-006] · low · open · - · blocks:no — A non-UTF-8 worktree marker escapes as an uncaught UnicodeDecodeError

scripts/run_cycle.py:313-317.

The marker is read with errors="strict" and the surrounding except catches
OSError only. UnicodeDecodeError derives from ValueError, so a .git file
that is not valid UTF-8 bypasses the handler:

.git contains b"\xff\xfe\x00binary"
→ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0

Every other rejection in this function raises CycleDriverError and surfaces as
a clean run_cycle: error: … at exit 2; this one surfaces as a traceback. Adding
ValueError to the handled types, or reading the first bytes and comparing
against b"gitdir:", makes the malformed case look like every other malformed
case. It is reachable only from a corrupt or hand-made .git file, which is why
it is low.

Security triage and audit

Sensitive: the change touches a safety boundary intended to prevent remote
writes, the CLI surface, and telemetry. The audit ran inline rather than as a
separately dispatched cc-security-review, so treat that pass as degraded; its
scope was the boundary, the worktree check, and the stop contract.

Result: no vulnerability, and the boundary is meaningfully stronger than at the
previous review. It is no longer only a sentence in a prompt: the driver now
refuses to dispatch the stages that would publish, which is enforcement rather
than instruction, and it refuses to run against the live repository at all.
REV-006 is an error-handling gap, not a bypass — it fails loudly and dispatches
nothing. The documentation still states plainly, in both places, that this is an
orchestration policy and not an OS sandbox, and still points at credential and
network isolation for a hard guarantee. No credential, token, or authorization
surface is touched, and local_only remains a typed boolean passing the
FIELD_SPECS gate.

Verification evidence

Command Result
python3 -m unittest discover -s tests 437 tests, OK
python3 scripts/validate-package.py VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned
git diff --check clean
direct observation of a local-only cycle in a linked worktree stops at HUMAN_INTERVENTION, review never dispatched — as quoted in REV-001
reproduction of the REV-002 CLI invocation exit 2, no database, no directory
LocalOnlyPolicyTests, MainLocalOnlyTests, PromptContractTests 5 tests, OK
reproduction of REV-005 and REV-006 both reproduced, as quoted above

As a cross-check, this change request's own comment history was folded with
scripts/review_contract.py and trusted_authors={"datacas"}: four findings,
all resolved, no recovery notes, next free ID REV-005. The resolution comment
published four-token headers without the disposition token, which the contract
tolerates and reads as -; the dispositions below are therefore - rather than
lost.

Runtime: Python 3.10.12. The working tree is checked out at f95911a, which
matches the change-request head; nothing was modified.

Unverified

  • No local-only cycle was run against real executors, so REV-001's evidence is a
    driver-level observation with scripted adapters, not an observed agent run. It
    is now sufficient, because the stop is a driver decision rather than something
    an agent has to comply with.
  • Windows behaviour was not executed locally; CI covers it and passes.
  • The except CycleDriverError that wraps the whole of run_cycle in main()
    is unchanged and still has no reachable mid-cycle raise to exercise it; see
    residual risk.
  • Telemetry rows were read through the test suite's store rather than from a
    database written by a real run.

CI

Both jobs the repository defines ran on f95911a and passed on both platforms.

Check State
Skills, manifests, and Bash installer (ubuntu-latest) pass
PowerShell installer (windows-latest) pass

gh pr checks 23 reports 4 passed, 0 failed. Both jobs run
scripts/validate-package.py and unittest discover -s tests, so the new tests
are gated. No defined check is missing, pending, skipped, or cancelled.

Residual risk

A local-only run that does exactly what was asked ends at HUMAN_INTERVENTION,
and scripts/run_cycle.py:646 maps every status but READY_FOR_MANUAL_MERGE to
exit 1. That is consistent with the rest of the driver and arguably correct — the
run really does need a human — but anyone wiring --local-only into a scheduled
rehearsal will read the exit code as failure. One sentence in the README would
close it.

main() still wraps the whole of run_cycle in except CycleDriverError → parser.error, so a mid-cycle driver error would be reported as a usage error at
exit 2 and would suppress report.explain() and the recorded in … line. The
reason this was not raised again is unchanged: no reachable mid-cycle raise
exists today, since roles come from a fixed table.

The feature is now narrower than its name suggests. --local-only is an
implementation-in-a-worktree mode, not a rehearsal of the cycle, and both
documents now say so — but the flag name does not.

Verdict

APPROVED. The reviewed head f95911a matches the change-request head, all four
defined checks pass, and every previous finding is classified as corrected, each
verified by re-running its original reproduction. REV-001 was answered by
narrowing the feature and fixing the test that had hidden the problem, which is
the right order. REV-005 and REV-006 are low, sit on the edges of the tightened
worktree check, and do not block approval.

@datacas
datacas merged commit 54e1ee0 into main Sep 22, 2026
4 checks passed
@datacas
datacas deleted the fix/local-only-cycle-runner branch September 24, 2026 09: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.

1 participant