Repository navigation
fix: the CEO review gate waits for Claude Code's transcript flush (GST-1701) - #4102
Merged
Merged
Conversation
…t before Claude Code flushes it (GST-1701) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…s shared settle helper (GST-1701) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The two early-Stop tests fail on the single-read hook (adbf169) and pass once the CEO gate waits for the flush (a8fbaaa).
Before/after as text: The two early-Stop tests fail on the single-read hook (adbf169) and pass once the CEO gate waits for the flush (a8fbaaa)
Why
GST-1701: the /plan-ceo-review stop gate read the transcript once at Stop, but Claude Code flushes the turn's last lines about 200 ms after Stop fires. A finished review written outside the repository was held because its Write had not landed yet, and a run whose load had not landed stopped unchecked. The gate now waits, like the /autoplan gate, until the transcript holds the stop's final message.
Blast radius
Both opt-in stop gates (
ceo_review_gateandautoplan_gate, off by default) now read throughsettledTranscriptinlib/skill-gates.ts; a stop whose payload has nolast_assistant_message, or whose transcript already ends on it, is read once exactly as before (lib/skill-contract.ts:226-233 read:withFinalMessagereturns the same transcript object, so the loop exits on the first read). The autoplan gate's own tests pass unchanged on the shared helper (43 of 43 with skill-gates.test.ts, probe 003), and every gate error still fails open with GATE_TRANSCRIPT.Approvals
No approvals recorded for branch capy/gst-1701-ceo-gate-settle.
Summary
The CEO review gate judged a transcript Claude Code had not finished writing, so it could hold a finished review or wave through an unfinished one. It now re-reads until the stop's final message is on disk, for at most 2 s or half its deadline, through the same helper the /autoplan gate already used, which moved from the autoplan hook into
lib/skill-gates.ts. Failing-first tests landed first (adbf169), then the fix (a8fbaaa).Test Coverage
Tests: 1748 → 1748 (+0 new in this /ship run; the PR's own commit adbf169 adds 2)
Coverage: 86% value-weighted (86% including 0 weakly covered paths)
Test value: 0 tests written, 1 rejected by the authoring gate, 0 existing tests extended, 0 paths weakly covered.
Proposed (not written): ceo SubagentStop late-flush settle. Rejected as duplicate_protects: the same loop is proven by the Stop flush tests, and the
includeSidechainpassthrough is covered by the existing SubagentStop sidechain tests on a pre-written transcript.Regression proof — fails at HEAD's parent adbf169 (tests only, old hook: 2 of 2 fail) · passes after fix at a8fbaaa (30 of 30).
Tests ran: tests 1623 (files; carried from CI run 42321726904/1 at tree 4503e0678276)
Pre-Landing Review
1 issue (0 critical, 1 informational), 0 fixed.
test/ceo-review-gate.test.ts:227(testing specialist, also the checklist's Timing-Dependent Tests item): the two new early-Stop tests race a fixedBun.sleep(300)against the hook's first read, so on a slow runner they could pass without exercising the settle loop; they cannot fail spuriously, because the 2 s settle window outlasts the 300 ms append. Skipped unattended with the specialist's own alternative: probe 002 below records both tests red against the pre-fix hook on this machine.REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=0 fixed=0 scope=frozen ledgers_read=3 dispatches=1
Gate edits: none detected (2 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: openai/gpt-6.1-sol (host subagent), completed, no actionable findings. Native adversarial (claude-opus-5-5): 4 findings, none blocking, listed under Review notes.
Review notes
Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.
lib/skill-gates.ts:76When last_assistant_message never matches the last text block, the settle loop spends min(2 s, half the 5 s deadline) before the CEO gate's sessionKind, gstack-slug and git scans, so a slow machine can fail open (GATE_SLUG/GATE_TIMEOUT). Opt-in gate; fails open; the autoplan gate already pays the same 2 s.lib/skill-contract.ts:230A turn that repeats its final sentence before a Write can settle early on the first copy and hold a finished review written outside the repo; needs a repeated sentence plus the flush race; block cap 3 bounds it.lib/skill-gates.ts:86A transcript whose only line is half-written throws UnknownShape outside the loop and fails open as GATE_TRANSCRIPT instead of retrying; such a transcript cannot hold a skill load, so no impact; same as before the change.lib/skill-gates.ts:79Each 50 ms poll re-reads and re-parses the whole transcript (up to 32 MB) for at most 2 s; bounded latency, same as the autoplan gate before this change.Exploratory QA
Functional surface, bounded smoke (300 s), 3 probes with repository-native
bun testcommands; verdict pass.bun test test/ceo-review-gate.test.tsat head: 30 pass, 0 fail.bun test test/autoplan-stop-gate.test.ts test/skill-gates.test.ts: 43 pass, 0 fail.Not exercised: real Claude Code flush timing (fixture append at 300 ms) and a ceo SubagentStop late flush.
Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped. The selector's derived references put 265 dependent gate cases in scheduled/release coverage, not PR passes.
Review bot comments
No review bot comments (one trunk-io merge-status comment, no findings).
Scope Drift
Scope Check: CLEAN
Intent: the CEO review gate waits for the transcript flush, through #4100's settle helper (GST-1701).
Delivered: shared
settledTranscriptin lib/skill-gates.ts, both gates call it, two failing-first tests, docs paragraph and changelog fragment.Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). This is a bug fix with failing-first tests (R65), which skips plan review.
Issues
Refs #4100
Verification Results
No Step 8.1 obligations (no plan). Exploratory probes: 3 PASS, 0 FAIL, 0 BLOCKED, 0 NOT RUN.
TODOS
No TODO items completed in this PR.
Documentation
Status: current. The docs already describe the shared transcript-settle helper, so nothing needed editing.
Scope: committed diff ca5dbfc..a8fbaaa (GST-1701):
lib/skill-gates.tsaddssettledTranscript, and the CEO review and /autoplan Stop hooks now use it. Nothing was staged, unstaged or untracked.Documentation health
docs/skill-gates.md: current. The CEO gate settle paragraph (line 72) and the autoplan settle text (line 94) match the code's 2 s / half-deadline bound.changelog.d/capy-gst-1701-ceo-gate-settle.md: current. It matches the behavior.docs/skill-routing-and-contracts.md: current. It only links to the gate docs.Coverage debt:
settledTranscriptis an internal helper with no public surface. The behavior it adds has reference and explanation coverage indocs/skill-gates.md, and no gaps are new. Diagram drift: none, since the touched docs have no diagrams.Test plan
bun run test(free suite): carried from CI run 42321726904/1 at tree 4503e0678276, 1623 files, exit 0bun test test/ceo-review-gate.test.ts: 30 pass, 0 failbun test test/autoplan-stop-gate.test.ts test/skill-gates.test.ts: 43 pass, 0 fail🤖 Generated with Claude Code