Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/execution-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ The verification contract contains:
The configured test command is `configured-test` and required. Every check
linked to a criterion is required. An agent can add checks and promote an
obligation; it cannot remove or demote an existing one.
- A resolver may return `LOCAL_PREPARED` when explicitly run with
`--local-only`. This records a local candidate after required local checks;
its full SHA and tree must match the clean worktree, and its `plan_id`,
`revision`, and `digest` must match the frozen receipt given to the resolver.
A missing or mismatched receipt blocks with the candidate retained. This does
not mark the change request remotely resolved or satisfy review, CI, or merge
controls.
- `results`: append-only check ID, verified HEAD, `pass|fail|unverified`,
evidence, cause and attempts. Unexecuted results carry an explicit cause;
a null HEAD is permitted only for an unverified result whose target is unknown.
Expand Down
20 changes: 17 additions & 3 deletions docs/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,15 @@ checkout is dirty. Failure to read that head blocks the stage with
`stage_not_completed`; a dirty checkout blocks with `worktree_dirty` when a
move is needed, and a non-fast-forward uses `worktree_diverged`.

A local-only `resolve` that reaches `LOCAL_PREPARED` records a
`correlation.local_candidate` in its runtime `stage_result`. It binds the
candidate's full commit and tree SHAs to the execution plan's `plan_id`,
`revision`, and `digest`, and retains the frozen verification checks and their
reported results. Its environment records the selected executor and profile,
the runtime platform and architecture, and the Python and Git versions. This
is durable local evidence for inspection and retry; it is not provider CI or a
claim that the change request has received the candidate.

That boundary is enforced rather than asserted, by one typed table covering
**every** field — columns included. `FIELD_SPECS` is the only gate, and there
are no exempt fields.
Expand Down Expand Up @@ -712,9 +721,14 @@ failed during a publishing stage, whoever caused it), `publication_unverified`
(schema 24: the audited refs or change-request state could not be read; see
*Publication audit* in `role-workspace-policy.md`), `verification_unverified`
(schema 25: required check evidence, criteria coverage, or security audit
completion is unverified; generic CI success cannot clear it), `worktree_dirty`, or
`worktree_diverged`. The last two stop before changing files when a dirty tree
or non-fast-forward prevents syncing an open pull request head. A closing row from an earlier version has none, and
completion is unverified; generic CI success cannot clear it), `local_prepared`
(a local-only resolve prepared a verified candidate), `candidate_mismatch` (the
reported candidate SHA, tree, plan, or checkout did not match local state),
`candidate_state_missing` (the candidate has no durable unpublished record),
`publication_reconciliation` (the remote publication state could not be safely
reconciled), `worktree_dirty`, or `worktree_diverged`. The last two stop before
changing files when a dirty tree or non-fast-forward prevents syncing an open
pull request head. A closing row from an earlier version has none, and
`cc-stats` reads it as unknown. A stage row's `reroute_reason` may then be
`permission_required` or `permission_answered`, or, for a quota stop of a
writing stage (#503), `checkpoint_handoff` (handed to the fallback from a
Expand Down
16 changes: 16 additions & 0 deletions docs/review-cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ stage verifies both the remote branch ref and PR head before claiming success;
the runtime blocks completion when the claimed SHA differs from the PR head.
See [the publication path](role-workspace-policy.md#github-upload-from-a-writing-stage).

### Local resolution preparation

For an existing change request, `--from resolve --pr <id> --local-only` runs
resolution in an explicitly selected linked worktree without writing remote
comments or pushing. The resolver reports `LOCAL_PREPARED`, the full candidate
SHA and tree, the frozen plan receipt, and verification evidence. The runtime
checks the SHA and tree against the clean named worktree, requires the
`plan_id`, `revision`, and `digest` to match the receipt given to the resolver,
and runs the required verification barrier before returning that status. A
missing or mismatched plan receipt blocks while retaining the candidate for
inspection. Inspect the candidate before publishing it. `LOCAL_PREPARED`
records local work only; it is not `RESOLVED` and does not satisfy review,
provider CI, or merge requirements. Resume with `--from resolve` without
`--local-only`; the runtime reuses the recorded candidate and instructs the
stage to retry only publication, not resolution.

## CI policy

A cycle runs under one of two CI policies, set by `ci.policy` in `.code-cycle.yml`, by `--ci-policy` for one `run_cycle.py` run, or by `ci_policy=` for one orchestrator invocation. The override wins.
Expand Down
6 changes: 6 additions & 0 deletions docs/role-workspace-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ same upload after a failure; it creates no new commit. On resume, reuse an
existing success publication rather than duplicating it. Bitbucket and Orca
transport recovery are not verified by this GitHub native path.

`--local-only` is also available for an explicit `resolve` resume. That path
uses the existing linked worktree, grants the resolve role no publication
permissions, and suppresses remote triage and progress comment writes. It records a
local `LOCAL_PREPARED` result after required checks and candidate SHA/tree
validation. It does not publish or imply remote completion.

## Publication audit

The cycle never merges, force-pushes or deletes refs. A stage's command table
Expand Down
2 changes: 1 addition & 1 deletion docs/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Acts on review feedback.
2. fixes valid findings with the smallest change, reproduces each original problem, and verifies each fix;
3. then runs `cc-code-review` on the new diff, security triage again, and `cc-verify`;
4. commits, pushes, replies in threads, and publishes a summary.
- **Statuses:** `RESOLVED`, `PARTIALLY_RESOLVED`, `BLOCKED`, `FAILED`.
- **Statuses:** `LOCAL_PREPARED` (explicit local-only resolve preparation), `RESOLVED`, `PARTIALLY_RESOLVED`, `BLOCKED`, `FAILED`.
- **CI failures:** under the `parallel` CI policy it may be told, by SHA and count, that required checks failed on the reviewed head; it diagnoses them beside the findings, never as findings.
- **Parallel policy:** reviews its fix delta from the latest trusted review receipt (or the accumulated diff when that base is unusable), verifies locally, publishes, and reads checks once without waiting. `strict` keeps the accumulated review and CI wait. See [CI policy](review-cycle.md#ci-policy).
- **Never:** declares approval, or changes code just to silence a review.
Expand Down
6 changes: 3 additions & 3 deletions docs/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ From a toolkit checkout: `python3 scripts/run_cycle.py …`
| `--ci-timeout` | `ci.timeout`, else `900` seconds | How long the `parallel` CI gate waits for one SHA |
| `--cwd` | current directory | Where the executor runs and `.code-cycle.yml` is read |
| `code_cycle.worktree_dir` | `.worktree` | Repository-relative base for persistent worker worktrees; review clones remain temporary and outside it |
| `--local-only` | off | Rehearsal: implement only, no publishing; requires `--workspace current` and a linked worktree in `--cwd` |
| `--local-only` | off | No publishing; use for an implementation rehearsal or `--from resolve --pr <id>` local preparation. Requires `--workspace current` and a linked worktree in `--cwd` |
| `--timeout` | adapter default (21600 s / 6 h) | Maximum time for one dispatch. `--detach` only avoids the launching host's task limit; it does not change this per-dispatch timeout. |
| `--detach` | off | Start the cycle in its own session and return at once, printing its process ID, a log path, and a `cycle_status.py --line --cursor-file <path>` command. Use it whenever an agent or another host that limits a task's time launches the cycle |
| `--verbose` | off | Print stage starts, changed progress, and stage results as they happen; the final report is always printed |
Expand Down Expand Up @@ -312,7 +312,7 @@ when the environment still cannot verify. Changed inputs use ordinary plan
reconciliation. Hotfix additionally requires test-first reproduction and focused
regression proof; see [Verification](verification.md).

**Local-only rehearsal:** `--cwd /path/to/linked-worktree --workspace current --local-only` refuses the live repository. The explicit `current` policy is required so workspace selection cannot create another task worktree. It runs implementation only, adds a no-publish boundary to the prompt, marks each row `local_only`, and ends with `HUMAN_INTERVENTION` because there is no PR to review. It is a policy, not a network sandbox.
**Local-only work:** `--cwd /path/to/linked-worktree --workspace current --local-only` refuses the live repository. The explicit `current` policy is required so workspace selection cannot create another task worktree. With the default start it runs an implementation rehearsal and ends with `HUMAN_INTERVENTION`. With `--from resolve --pr <id>` it applies resolution fixes and required local verification without writing remote triage or success comments or pushing, checks the reported candidate SHA/tree against the worktree, and ends `LOCAL_PREPARED`. Inspect this candidate before publishing it; `LOCAL_PREPARED` does not mean remotely resolved or merge-ready. This is a policy, not a network sandbox.

Implementation workflows use a task-specific linked Git worktree by default.

Expand Down Expand Up @@ -355,7 +355,7 @@ python3 ~/.code-cycle/runtime/run_cycle.py --task 72 --pr 74 --from review #
python3 ~/.code-cycle/runtime/run_cycle.py --task 72 --pr 74 --from rereview # rereview first, then loop
```

The stages before `--from` are skipped. The rest run with the same routing, recording, and `--max-iterations` as a full cycle. `resolve` and `rereview` rely on the pull request's comments carrying the previous review; the stage recovers those findings through `review.trusted_authors`. Before anything is dispatched, the driver refuses `--from` without `--pr`, `--pr` without a resuming `--from`, and `--local-only` with a resume. It then reads the pull request with `gh` and stops with the reason unless it is open, its head branch still exists, and `--cwd` has that branch checked out at the pull request's head commit, so a stale or unpushed checkout is never reviewed or fixed in its place. Only GitHub pull requests can be resumed. A resumed run is a **new cycle** with its own `cycle_id`, and every row carries `started_from`, so its review never counts as a first pass.
The stages before `--from` are skipped. The rest run with the same routing, recording, and `--max-iterations` as a full cycle. `resolve` and `rereview` rely on the pull request's comments carrying the previous review; the stage recovers those findings through `review.trusted_authors`. Before anything is dispatched, the driver refuses `--from` without `--pr` and `--pr` without a resuming `--from`. `--local-only` may resume only `resolve`; it requires `--workspace current` and a linked worktree, and it prepares a local candidate without publishing. For normal resumes, the driver reads the pull request with `gh` and stops with the reason unless it is open, its head branch still exists, and `--cwd` has that branch checked out at the pull request's head commit, so a stale or unpushed checkout is never reviewed or fixed in its place. Only GitHub pull requests can be resumed. A resumed run is a **new cycle** with its own `cycle_id`, and every row carries `started_from`, so its review never counts as a first pass.

**Issue review:** in the default `auto` mode, a new cycle first runs `cc-issue-review` read-only and implements only on a confirmed `READY`. `NEEDS_REFINEMENT` stops before any code work and prints one `decisions` line, the first question, and the path of a decisions record holding the other questions and the findings, evidence, and proposed issue edits; nothing is posted to the work item. `--issue-review off` or `issue_review.mode: off` restores the original flow. See [Review lifecycle → Issue review](review-cycle.md#issue-review-before-implementation).

Expand Down
4 changes: 2 additions & 2 deletions scripts/cycle_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def main(api: Any, argv: list[str] | None = None) -> int:
help="workspace policy: task worktree by default, or current checkout")
parser.add_argument("--local-only", action="store_true",
help=("run only in the explicit --cwd linked worktree "
"with --workspace current; "
"stop after implementation without publishing"))
"with --workspace current; either rehearse implementation "
"or prepare a resolution locally without publishing"))
parser.add_argument("--timeout", type=int, default=None,
help="seconds one dispatch may take")
parser.add_argument("--detach", action="store_true",
Expand Down
17 changes: 16 additions & 1 deletion scripts/cycle_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def run(self: Any, role: str, instruction: str = "", *,
self.report.stages.append(outcome)
attempt_id = (outcome.result.artifacts.get("dispatch_attempt_id")
if outcome.result is not None else None)
if publishes:
if publishes and not self.local_only:
self.expect_publication(role, change_request_id, attempt_id)
if (role == "resolve" and change_request_id and isinstance(attempt_id, str)
and resolve_start_head and self.state.history_store is not None):
Expand Down Expand Up @@ -815,6 +815,14 @@ def advance(self: Any, role: str, instruction: str = "", *,
if unpublished is None:
synchronized = self.api.synchronize_worktree(change_request_id, self.cwd, target_head=target_head)
else:
instruction += (
" A durable local resolution candidate is already recorded for this "
"change request. Do not rerun resolution or recreate its commit. "
"Reconcile the current PR head and worktree, preserve the recorded "
"candidate, and retry only its normal fast-forward publication. If "
"the candidate, branch, tree, or PR ancestry differs, stop and name "
"the mismatch without force-pushing or publishing a recovery ref."
)
synchronized = self.api.synchronize_worktree(
change_request_id, self.cwd, target_head=target_head, unpublished_heads=unpublished)
except self.api.WorktreeSyncError as error:
Expand Down Expand Up @@ -861,6 +869,13 @@ def advance(self: Any, role: str, instruction: str = "", *,
return reported, stopped
# Only a stage the audit let through can have been reconciled (#364).
self.record_reconciliation(role, reported, outcome)
if (role == "resolve" and reported.status == "LOCAL_PREPARED"
and not self.local_only):
return reported, self.stop(
"LOCAL_PREPARED is valid only for an explicitly local-only resolve; "
"the candidate was not accepted as a completed resolution",
"BLOCKED", reported=reported,
stop_reason="stage_not_completed")
if role == "resolve" and outcome.decision is not None:
self.state.previous_resolve_target = outcome.decision.target
self.state.previous_resolve_used_fallback = outcome.decision.used_fallback
Expand Down
Loading
Loading