fix(autoplan): review pass 1 — standing answers bind to the run's project and refuse recommend-edited gates, cost is an upper bound and reaches JSON and the Captain brief

Review pass 1 (6 specialists + red team) on the standing-approval and gate-cost change:
- the standing lookup resolves the approvals record of the repository the run's plan lives in,
  never the caller's cwd (red team: project A's row answered project B's gate)
- standingAnswer refuses a gate that `recommend` edited (rec_rev > 0 or recommended_by), a
  missing or unreadable findings.jsonl, and an outside-plan finding; the STANDING line flattens
  control characters so a crew-writable row cannot forge a protocol line
- coversAutoplanRec matches the recommendation words in the owner's words only and rejects
  negations; STANDING_APPROVAL_ABSENT's fix names every required gstack-approvals flag
- recReopens is the upper bound of the answer/revise rules (a plan change counts every phase,
  a round grant its phase plus Eng); gate_cost rides the JSON payloads, `run` prints the lines
  at its final gate, and `gstack-owner-brief render --captain` appends a ### Cost section
- locate keeps the other mirror roots as read_also so rows mirrored under an earlier rule stay
  visible; gstack-approvals path prints READ_ALSO
- the Eng phase edit is size-neutral: five nearby phrases shortened so every host's autoplan
  SKILL.md stays at its size-guard pin
- tests: isolated fixtures, the run's plan inside its own git repo, cross-project refusal,
  amend_pending vs complete, recommend-then-standing, injection, gate_cost JSON, Captain brief

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-26 21:49:10 +00:00
1 parent e6a094ed0e
commit ff2bcd8686
14 files changed
+266 -134

No files matched your search

+13 -7
View File
@@ -1685,7 +1685,9 @@ from "the record was lost with the old machine". `render` still prints the secti
**Fix.** Run where the record lives, copy the rows back from the thread's report, or make
a Drive mirror resolvable: `GSTACK_APPROVALS_DIR`, an `approvals/` directory in the one
mounted Captain drive (`~/.capy/drive/captain-*/approvals`, readable by the whole crew), or one
`~/.capy/drive/project-user-*` folder. `gstack-approvals path` prints which rule chose the mirror.
`~/.capy/drive/project-user-*` folder. `gstack-approvals path` prints which rule chose the mirror
and, as `READ_ALSO:`, the other roots it still reads (a row mirrored before the Captain created
`approvals/` stays visible).
<a id="approval-record-write-failed"></a>
### `gstack-approvals: ... (APPROVAL_RECORD_WRITE_FAILED)`
@@ -1724,14 +1726,18 @@ finds it.
<a id="standing-approval-inapplicable"></a>
### `gstack-autoplan answer: ... (STANDING_APPROVAL_INAPPLICABLE)`
**Meaning.** The gate carries an urgent or outside-plan finding (`findings.jsonl` rows with
`urgent` or `outside_plan`). Standing words that say "take the recommendations" cover the
plan under review, not news beyond it, so the standing path refuses and nothing was applied.
Exit 3.
**Meaning.** The gate is outside what standing words that say "take the recommendations"
cover: it carries an urgent or outside-plan finding (`findings.jsonl` rows with `urgent` or
`outside_plan`), which is news beyond the plan; or `gstack-autoplan recommend` changed a
recommendation (`rec_rev` > 0 or an item with `recommended_by`), so `rec` would take an
option the relaying agent chose rather than the reviewers'; or `findings.jsonl` is missing or
has an unreadable line, so the urgent check cannot run. The line says which. Nothing was
applied. Exit 3.
**Fix.** Relay the gate render (the `RELAY:` line) to the owner, including the
`## URGENT, outside this plan` block, and answer with their reply through `--reply` and
`--owner-reply`. The standing row still applies to later gates that carry no such finding.
`## URGENT, outside this plan` block, and answer with their reply through `--reply`,
`--owner-reply` and, after a `recommend`, `--rec-hash` from the render they saw. The standing
row still applies to later gates the reviewers alone recommended.
<a id="captain-brief-incomplete"></a>
### `gstack-owner-brief render --captain: ... (CAPTAIN_BRIEF_INCOMPLETE)`