Skip to content

Carry the owner's autoplan answer across fix-only gates - #4206

Closed
garrytan wants to merge 4 commits into
mainfrom
capy/carry-the-owners-autoplan
Closed

garrytan wants to merge 4 commits into
mainfrom
capy/carry-the-owners-autoplan

Conversation

@garrytan

@garrytan garrytan commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

When an autoplan run's phases were at their round cap, the owner could be asked to approve the same plan twice. In run autoplan-v0-20261109012507 the owner answered gate_rev 1 with "do it". revise at the cap wrote gate_rev 2 with unreviewed-delta items, and its delta check found Highs. The Highs were fixed and revise ran again, which wrote gate_rev 3 with CARRY: no (gate_rev 2 was not answered). The fixes answered the owner's first "do it", but the owner had to approve again.

Carry across fix-only gates (lib/autoplan-carry.ts)

  • When the gate before the new one was never answered, the carry now walks back to the owner's last answered gate. It only skips gates that are unanswered, were never relayed, and hold only p1, items decided at an earlier gate, or post-cap deltas recommending accept. Anything else refuses with its own reason.
  • When gates are skipped, the delta check always runs. It reads every edit since the answered gate (plan-at-gate.r<m>.md), and a High or Critical still leaves the gate for the owner. CARRIED: says across unrelayed gate_rev <n>, and the journal records skipped_gate_revs.
  • finishGate overwrites gate.json at a capped regate, so each gate list is now kept as gate-at-gate.r<n>.json. That lets the walk read the earlier gates.
  • A revise since the answer that put a new axis in scope refuses the carry. That covers ui, dx, or code beyond a docs-only plan, which plan_revised records as scope_widened.

One retry per owner answer: once two skipped gates have dispatched a delta check against the same answer, the next gate goes to the owner. That holds whether those checks failed or were voided by a revise while pending, --unavailable, or a stale result. If a voided check's result file exists, its reservation settles as unknown in spend.json instead of being released.

What counts as relayed: every owner-facing render now journals gate_relayed: gstack-owner-brief render (both forms) and gstack-gate render of a gate in a run directory. A gate with such a row, or with a recommend, is never skipped. If a gate was rendered but never sent, the run falls back to asking the owner, which is how it behaved before this change.

Saying it up front (lib/autoplan-revise.ts, bin/gstack-autoplan): NEW_GATE: says a plan edit at the round cap reopens no reviewer and goes to a new gate, and whether that gate can carry the owner's answer. It is printed in the NEXT lines after an answer that leaves accepted changes, at the top of the revise output, and after a delta check that found a High. A Captain can read it before promising the owner a single review pass.

Checkpoint folder (lib/autoplan-checkpoint.ts): if GSTACK_AUTOPLAN_CHECKPOINT_DIR points at one run's folder, the checkpoint is skipped and nothing is written. One run's folder means a run directory, a <dir>/<run> checkpoint folder, or a folder named after the run. The skip line names the folder to use instead, so the checkpoint no longer silently nests a copy inside it.

Tests: test/autoplan-carry-across-gates.test.ts has the repro, which fails on main. It also has one refusal test each for an intervening user challenge, a relayed gate, a High across gates, and new scope, plus the NEW_GATE forecasts. test/autoplan-checkpoint.test.ts covers the folder-skip case. All eight new tests fail on main. Removing the relay, item, or scope guard makes its test fail. Further tests cover the retry limit, and each of the three void kinds counting toward it and staying in the spend.

Agent notes
  • Bug fix, so no /autoplan. The repro was written first and fails on main 350d419 and on 5164353.
  • lib/autoplan-gate.ts and gstack-autoplan answer are not touched. The lines Refuse agent words on owner-only autoplan answers #4201 changed in assess are kept intact, and this branch is built on main after Refuse agent words on owner-only autoplan answers #4201 landed (5164353).
  • Focused local runs: 74 related files, 1662 pass, 6 skip, 0 fail, run before Refuse agent words on owner-only autoplan answers #4201 landed. After moving onto 5164353, the carry, approval-class and checkpoint files all pass. test/review-plan-targeted-delta.test.ts times out at 5 s on this machine, and it does the same on clean 5164353, so this change didn't cause it.
  • Review at bf8c1e5 is clean; no SHIP_RECEIPT yet. Rounds 1 and 2 plus fix-check 1 ran in an earlier /ship (fixes in 19fb623 and 83352ec). The granted fix-check on 83352ec..bf8c1e5 (grant a-aea3dddb2fef) found nothing blocking: the fix-check reader and the targeted money reader both returned clean, with REVIEW_SCOPE: policy=frozen pass=2 findings=3 note=3 blocking=0. CI carry was accepted at tree 8670f3f0f7a7 (run 42598827640), and the pregate cleared. /ship then stopped before the receipt: gstack-review-scope summary needs a via:ship review pass row, and the rows from rounds 1 and 2 were lost with the earlier machine (REVIEW_SCOPE_INPUT). The PR stays a draft until that is resolved.
  • New notes from the fix-check (informational, not fixed): a failed delta check's carry_refused journal row no longer carries check/check_status (lib/autoplan-carry.ts:340), and releaseOrSettle reads only check.result, not a custom --result path (lib/autoplan-carry.ts:97). From the money reader: a check voided while its reviewer is still running, before the result file exists, is still released instead of settled (lib/autoplan-carry.ts:95). That gap was already there, this change narrows it, and spend stays bounded by the two-checks-per-answer limit.
  • Open informational notes from review: relay rows are not checkpointed until the next mutating command; relay detection is an allowlist of renders; the NEW_GATE forecast can be wrong in edge cases.

Open in Capy

A revise at the round cap whose delta check found a High, fixed and revised again, no longer asks the owner to approve twice: the carry reuses the last answered gate across unrelayed, delta-only gates after a delta check of every edit since. NEW_GATE says up front when a revise opens a gate and whether it can carry. A checkpoint dir that is one run's folder is skipped instead of nesting a copy.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 9, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

garrytan and others added 3 commits November 9, 2026 09:47
…to a checkpoint copy

A delta check dispatched across a gate written before this change (no gate-at-gate copy) fell back to the answered gate at submit, so a relay recorded meanwhile was never read and the carry approved the new gate. Submit now refuses when the gate before the new one has no kept items. Rendering a gate from a checkpoint generation no longer appends gate_relayed to that hash-pinned copy, which made resume reject the newest generation.

Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/outside-voice#2 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A second failed delta check on the same owner answer sends the next gate to the owner, so an agent cannot redraw checks until one passes. The failed check is now journaled with its status, and the NEXT forecast says the next gate cannot carry. Grant: review_loop_grant a-c7c65e1ca065.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A check voided by a revise while pending, --unavailable or a stale result now counts like a failed one, so an agent cannot redraw checks by never submitting them. A voided check whose result file exists settles its reservation as unknown instead of releasing it, so the run spend still shows it. Grant: review_loop_grant a-aea3dddb2fef.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot marked this pull request as draft November 9, 2026 10:13
@capy-ai

capy-ai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Parked until after the 2026-11-21 freeze. The code at bf8c1e5 passed its scoped fix check (no blocking findings), and CI and pregate are green, but there's no /ship receipt: the review pass rows from rounds 1 and 2 were lost with the original lane's machine. Closing for now with the branch capy/carry-the-owners-autoplan kept. It reopens after the freeze with a fresh full review pass. The three informational notes are in the Agent notes above.

@capy-ai capy-ai Bot closed this Nov 9, 2026
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