Repository navigation
plan-ceo-review gate: hold the final stop until ranked Findings are written (GST-1461) - #4047
Conversation
E2E Evals: ✅ PASS (flaky: 1 case(s) passed on their one rerun)100 executed, 0 reused rule/judge records | 0 manual accepted (unscored; no score-cache credit) | $32.20 rule/judge cost | reconcile exit: 0 Profile: pr / mode Rule and judge shards
Fail-closed reconciliationSliced lane: planner → duration-packed executors → fail-closed report. Behavior cases run a pre-registered 3-trial panel (PASS at 2/3 with no contract violation); a PASS 2/3 is shown with its failed trial, never as a clean pass. Reused results retain their original provenance and expiry. Flaky: failed once, passed on its one rerun (rule 16)Each failed and passed on its rerun in run 42103721891 at the attempts named above. Logged for the daily flaky-fix pass in this run's Dispatched narrow screen (gstack-ship-queue ready --screen) of merge commit |
…(GST-1461 fc#1) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…e written (GST-1461) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…e lane (GST-1461) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ls/ tree (GST-1461) Review-Finding: p1/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…-1461 ov#5) Review-Finding: bin/gstack-skill-gates:60:outside-voice reader=outside-voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…come from the baseline (GST-1461 ov#1-4) Review-Finding: lib/investigate-gate.ts:126:outside-voice reader=outside-voice Review-Finding: lib/investigate-gate.ts:254:outside-voice reader=outside-voice Review-Finding: lib/investigate-gate.ts:256:outside-voice reader=outside-voice Review-Finding: lib/investigate-gate.ts:64:outside-voice reader=outside-voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…back keeps them (GST-1461) Review-Finding: p2/outside-voice#1 reader=outside-voice Review-Finding: p2/adversarial-native#6 reader=adversarial-native Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… filters the repo scan too (GST-1461) Review-Finding: p2/outside-voice#2 reader=outside-voice Review-Finding: p2/adversarial-native#2 reader=adversarial-native Review-Finding: p2/adversarial-native#3 reader=adversarial-native Review-Finding: p2/red-team#2 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…(GST-1461) Review-Finding: p2/adversarial-native#7 reader=adversarial-native Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…-1461) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
dab8574 to
723671b
Compare
|
😎 This pull request was merged. |
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…nger fails open (#4072) * skill gates: the hook timeout outlives the clamped gate deadline (GST-1615) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: #4045/#4047 narrow screens select the bin/gstack-config gate case once setup runs gstack-skill-gates (GST-1615) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
What changed
The 8 new gate tests fail at the PR's first head (fbedef8) and pass now: skills/ files never count as the CEO review output, rollbacks restore exact bytes, index and mode, attributes come from the baseline, and hook paths with spaces run.
Before/after as text: The 8 new gate tests fail at the PR's first head (fbedef8) and pass now: skills/ files never count as the CEO review output, rollbacks restore exact bytes, index and mode, attributes come from the baseline, and hook paths with spaces run
Why
GST-1461 asked for opt-in hooks that hold the one step each skill exists for, because the skill text alone doesn't: a /plan-ceo-review run can end without the ranked top risks that are its whole output. This PR adds that gate. It also fixes the five rollback and install defects the outside voice reproduced on #4045, which GStack Minder ruled ship here rather than hold #4045.
Blast radius
The change touches Claude Code hook registration (
setup,gstack-settings-hook,gstack-skill-gates settings), the turn-end logic inlib/skill-contract.tsthat /review's contract Stop hook also uses, and the /investigate gate's rollback. Both gates are off by default and every hook error fails open, so a user who never turns a switch on runs none of this code. The contract hook's own tests pass unchanged, and the whole free suite passed at dab8574 (script ran: Free Tests run 42100860275, 35,721 tests; local gate lane 176 tests).Approvals
Approved: yes (record r-0eca9dabd1bd). The full approval record stays private: this repository is public or its visibility is unknown.
Summary
Was stacked on #4045, which landed on main as 9e809ab; this branch was rebased onto it, so the diff below is against main. This adds the second opt-in enforcement gate from GST-1461 (Garry's E1 pick), closes the git-route gap #4045 lists as known (fc#1), and fixes #4045's five open outside-voice findings (ov#1 to ov#5) under GStack Minder's ruling.
plan-ceo-review gate
When
ceo_review_gateis on, a session that ran/plan-ceo-reviewcan't end its final turn (Stop, or SubagentStop for a subagent) until ranked Findings are in its output file. If they're missing, the hook blocks and tells the model where to write them. It picks the first that applies:GSTACK_CEO_REVIEW_OUTPUT, the last.mdthe run wrote, the last.mdplan it read, or a generic "the plan file you reviewed". A file in askills/directory, judged from the repository root, never counts and is never named, so the review's own methodology sections can't become its output. Once the Findings are written, the next stop is released. The hook uses #4045's install path, marker format and record:./setup --ceo-review-gate/--no-ceo-review-gate, envGSTACK_CEO_REVIEW_GATE,gstack-config set ceo_review_gate on, orgstack-skill-gates settings --ceo-reviewfor headlessclaude -p --settings.GSTACK_GATE ceo-review-gate fired|blocked|released|exhausted|skipped|error./review's contract hook already decided when a turn counts as final. That logic now lives in
lib/skill-contract.ts(turnEnd,isFinalTurn), and both hooks share it; the contract hook's tests are unchanged and pass. SubagentStop always counts as final. Ifagent_transcript_pathis missing or empty (CLI 2.1.318 sometimes sends it empty), the hook stays silent. Ifgstack-slugfails, the hook fails open withGATE_SLUG.gstack-skill-gates reportnow countsexhaustedruns alongside fired, blocked, released, observed and errors.investigate gate: commits on branches behind the baseline (fc#1 from #4045's review)
Before this change, if the session started on
featureand the model rangit checkout main, edited a source file and committed, the gate blocked the commit but kept it. Now the baseline records every local branch's tip. A gated commit on another branch is reset with--softto that branch's recorded tip, and same-branch amends still go back to the baseline HEAD. A branch with no recorded tip (created after the baseline, or a detached HEAD) goes back to its newest commit from before the baseline. Two tests cover it, a plain commit onmainand an amend ofmain's tip; both fail at e64c3a0 and pass now.investigate gate: #4045's outside-voice findings (ov#1 to ov#5)
Each fix has a test that failed first (the image above):
*.sh textno longer share one backup.edit; git adddoesn't leave the rejected code staged. The baseline now also records paths that were only staged, so their staged entry survives a rollback.linguist-generatedexemptions come from the baseline commit's attributes (a scratch index, sincecheck-attr --sourceneeds git 2.40 and gstack supports 2.39), so a new worktree.gitattributescan't exempt source.gstack-skill-gates settingsquotes each hook path the way setup'sgsQuoteCmddoes, so a checkout whose path has a space still runs its headless hooks.Test Coverage
Step 7 audit (audit only, no generation): 17 of 18 changed paths have a test at two stars or better; the weak one is
sessionKind()'s fallback whengstack-session-kindfails (returns '' and the turn is treated as not final), proposed and not written.Tests: 1719 test files before and after (cases added inside existing files).
Tests ran: gates 176
Pre-Landing Review
Full panel at the depth
gstack-review-planprinted (REVIEW_DEPTH full: security and money classes, 599 runtime lines). Round 1: batched specialist (testing, security, api-contract, state-machines), red team. Round 2 on the fix range: the same two, then the Step 11 voices on the whole PR diff (native adversarial, outside voice openai/gpt-6.1-sol, targeted money reader). One scoped fix-check on the round-2 fixes under grant a-8df22cddc533.Blocking findings and what was done:
.mdthe run Read, which is the skill's ownsections/review-sections.md, and a Write there released the gate. Fixed in 084370c, then judged from the repo root in 6b51fec.skills/file with a sample Findings list released the gate. Fixed in 6b51fec (also adversarial-native#2 and Project-local .claude/skills/gstack install breaks /browse and setup can report false success #3, red-team#2).REVIEW_LOOP: passes=2 blocking_found=8 deferred=0 noted=6 fixed=9 scope=diff-plus-blocking unbound=4 ledgers_read=5 fix_checks=1 dispatches=4
Scope note: the base policy is
frozen, which would defer ov#1 and ov#3 (code this PR did not change); the classifier ran with--policy diff-plus-blockingunder the Captain's ruling (approval a-b38e0074e735). The 4 unbound trailers are adversarial-native ids the summary does not bind; each duplicates a bound finding.Rebase onto main (723671b):
git range-diff e64c3a0f49a1..dab85740f824 origin/main..723671b3f050shows all 10 commits identical, and the PR diff is the same 26 files, +1165/−171, so no review round reran. The receipt was rewritten at 723671b under a Captain grant, reusing the dab8574 review records. gstack required a fresh targeted money reader at 723671b because its earlier record was bound to a pre-rebase commit; it returned no findings.Gate edits: none detected (gstack-review-plan GATE_SCAN: tagged=0 at 3dbc20b)
Outside review: openai/gpt-6.1-sol (host subagent, reasoning high) completed with "request changes" on its two findings; both were fixed and fix-checked.
Review notes
Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.
hosts/claude/hooks/ceo-review-gate.ts:60A CEO review run ends only at the next /plan-ceo-review load, so an abandoned review, a later skill in the same session, or /autoplan's CEO phase (which Reads plan-ceo-review/SKILL.md) can be held at a final stop, up to the 3-block cap.lib/investigate-gate.ts:66linguist-generated now comes from the baseline commit's .gitattributes, but check-attr still reads $GIT_DIR/info/attributes and core.attributesFile, so a session that writes either can still mark source generated.lib/investigate-gate.ts:73generatedPaths reads the whole baseline tree into a scratch index on each call (36 ms for 4,883 files); a very large repo could approach the hook deadline, which fails open.bin/gstack-skill-gates:23Hook-path quoting matches setup's gsQuoteCmd, so like setup it leaves ' & ; | < > ( * ? unquoted when the path has no space; such a path breaks the sh -c parse.lib/investigate-gate.ts:288If index.lock is held when a rollback resets the index entry, the path is reported as GATE_RESTORE_FAILED (unknown state) even though its content was put back.lib/investigate-gate.ts:97saveBytes writes the backup in place, so a hook killed mid-write could leave a truncated file under its sha256 key that a later restore trusts.lib/ceo-review-gate.ts:108inSkillTree compares a non-realpath file with the realpath repo root, so a project under a skills/ folder reached through a symlinked cwd can still have its written review dropped (fails closed; the repo scan still finds non-ignored files).lib/investigate-gate.ts:275Committing work that was only staged at the baseline is still undone as a fix commit and the index goes to the target tree, so that staged blob survives only in the reflog (unchanged from b433c04 and investigate: opt-in gate that holds root cause before fix, through Bash too (GST-1461) #4045); docs/skill-gates.md's 'staged work is not dropped' covers rollback of an edit, not this commit case.Exploratory QA
The $0 headless smoke ran at dab8574 with Claude Code CLI 2.1.318 against a local stand-in for the Messages API:
SMOKE_RESULT: pass scenarios=2 checks=23 failed=0, covering the /investigate block-and-restore path and the /plan-ceo-review block-then-release path. Step 9.2.1's QA charter reads were not run; the smoke and the failing-first tests are the only end-to-end probes.Design Review
No frontend files changed, so design review was skipped.
Eval Results
No skill prose changed. Because
setupis a shared runtime input, the selector falls back to every gate case. The narrow paid screengstack-ship-queue ready --screen(113 e2e cases, evals.yml run 42103721891) was dispatched under the crew's standing screen approval; its price is pending because these cases have no cost data yet. The lane-scopedeval:bg:prrun (84 shards, profile pr) was not dispatched: its cost is unpriced, it would repeat the screen's gate cases, and the train's full gate runs them again before merge.Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). The approved plan is autoplan run autoplan-20261105173158 (approval a-e18fa72c70b7).
TODOS
No TODO items completed in this PR.
Documentation
Scope: committed diff
e64c3a0f..dab85740oncapy/gst-1461-ceo-review-gate: 26 files, with 3 docs files among them. The worktree had no staged, unstaged or untracked changes. A search of every tracked*.mdand*.tmplfile found no other doc that mentions the investigate or CEO review gates.Result: current.
docs/skill-gates.mddocuments the/plan-ceo-reviewgate (switches, which files count, the block, the cap, subagents, markers,GATE_SLUG, the headless smoke) and the tighter/investigaterollback.docs/skill-routing-and-contracts.mdlinks both gates. The changelog fragment matches.Debt: none found.
Test plan
bun --no-env-file test --timeout=30000 test/ceo-review-gate.test.ts test/investigate-gate.test.ts test/skill-gates.test.ts test/skill-gates-advisory-bytes.test.ts test/setup-skill-hooks-gate.test.ts test/setup-hook-syntax-gate.test.ts test/skill-contract-stop-hook.test.ts test/skill-contract.test.ts: 176 tests, 0 fail at dab8574bun run typecheck: 0 errorsscripts/skill-gates-smoke.ts --claude <2.1.318>:SMOKE_RESULT: pass scenarios=2 checks=23 failed=0at dab8574investigate/andplan-ceo-review/is byte-identical (test/skill-gates-advisory-bytes.test.ts)