Repository navigation
fix: skill gate hooks outlive the gate deadline, so a slow gate no longer fails open - #4072
Merged
Merged
Conversation
…-1615) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
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
gstack-skill-gates settings --ceo-review: the Stop and SubagentStop hooks now register a 25 s timeout instead of 10 s, so Claude Code cannot kill the gate before its own 20 s deadline. (Captured at f114a21; the command's output at head 5698cf7 is byte-identical.)
Before/after as text: gstack-skill-gates settings --ceo-review: the Stop and SubagentStop hooks now register a 25 s timeout instead of 10 s, so Claude Code cannot kill the gate before its own 20 s deadline
Why
The opt-in /investigate and /plan-ceo-review gates were registered with a 10 second Claude Code hook timeout, but
GSTACK_SKILL_GATE_DEADLINE_MScould give the gate a longer deadline. Claude Code kills a hook at its timeout and lets the stop or tool call through with no marker, so a slow gate failed open without a trace. Now the deadline is clamped to 20 seconds and every gate hook is registered for 25 seconds, so a slow scan ends in the gate's own recordedGATE_TIMEOUT.Blast radius
The change touches the two skill-gate registrations (
gstack-skill-gates settingsand./setup), the gate deadline inlib/skill-gates.ts, and one paid-eval selection expectation; the routing and contract hooks keep their own timeouts. It is safe because setup's existingensure-eventpath raises an older 10 s registration to 25 s in place without a duplicate entry (script ran at f114a21, andbin/gstack-settings-hookis unchanged since), and if bun cannot run during setup the timeout is omitted, which leaves Claude Code's longer default (file:line read,bin/gstack-settings-hook:540drops an empty timeout).Approvals
Approved: yes (record r-d333caea7407). The full approval record stays private: this repository is public or its visibility is unknown.
Gate edit at 5698cf7:
test/pr-shared-input-selection.test.tsaddsship-skipped-queued-findingto the #4045/#4047 narrow-screen expected list and retitles the test "six cases". GStack Minder approved it on 2026-11-06 (approval a-03d7257b47a9) as a gate edit that adds coverage and loosens nothing.Summary
A gate that Claude Code killed at its 10 s hook timeout let the stop through with no marker, so
gstack-skill-gates reportcould not see it. The gate deadline now tops out at 20 s, the hook timeout is derived from it (25 s), and a newgstack-skill-gates hook-timeoutsubcommand gives ./setup the same number. Because setup now runsbin/gstack-skill-gates, the paid-eval narrow screens for #4045 and #4047 also selectship-skipped-queued-finding, and the selection test expects that sixth case. docs/skill-gates.md#hook-timeout explains why a killed hook cannot fail closed.Test Coverage
All new code paths have test coverage: each of the 3 changed runtime files (
bin/gstack-skill-gates,lib/skill-gates.ts,setup) has a changed test naming it (test/skill-gates.test.ts, test/setup-skill-hooks-gate.test.ts).Tests ran: focused 61
Pre-Landing Review
Pre-Landing Review: 2 issues — 0 auto-fixed, 1 asked (0 fixed, 1 skipped), 0 deferred, 1 noted. Step 11 adversarial review: 5 findings — 2 asked (0 fixed, 2 skipped), 1 deferred, 2 noted.
REVIEW_LOOP: passes=1 blocking_found=3 deferred=1 noted=1 fixed=0 scope=frozen unrecorded=2 ledgers_read=3 dispatches=1 est_input_tokens=6669
Gate edits: none detected (11 listed, 6 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Reviewers (plan: class=code depth=light next=full dispatches=3): batched specialist (testing, security, state-machines, red-team): 1 informational finding. Native adversarial (claude-opus-5-5): 5 findings, recommendation "Ship as-is". Outside review (openai/gpt-6.1-sol, host subagent): completed, no findings.
Skipped, not fixed (each below the owner's blocking floor: a finding blocks only if it would fail a test, break production, or lose data or secrets). /ship scores a FIXABLE adversarial finding as CRITICAL; the reviewer marked both
Blocks: no. The two Step 11 skips have no review-log row, which is why the loop line readsunrecorded=2.setup:4978(adversarial, FIXABLE, Low): ifgstack-skill-gates hook-timeoutfails, setup registers the gate with no timeout (Claude Code's longer default) and logs nothing. Fail-safe; a warning or a literal 25 fallback would make it visible.lib/skill-gates.ts:40(adversarial, FIXABLE, Low):deadlineFromEnvclamps a deadline above 20000 ms silently; the docs table and changelog state the clamp.test/setup-skill-hooks-gate.test.ts:340(testing specialist, informational, confidence 5): the source test pins the wholeSKILL_GATE_HOOK_TIMEOUTsetup line byte for byte, which the behavioral test already covers.Deferred findings
Blocking findings in code this PR did not change (review scope: frozen). Not filed as an issue from this run, because issues would post under the owner's GitHub account; the Captain files it.
Blocks: no)lib/investigate-gate.ts:156Synchronous file loops in the investigate gate (snapshot ~156, worktreeIds ~113, restore ~271) check the deadline only inside git(), so a very large dirty tree can outlast the 25 s registration and be killed silently; docs/skill-gates.md#hook-timeout says a slow scan ends in GATE_TIMEOUT. Pre-existing code, deferred at f114a21 as well.Review notes
Below the blocking floor; recorded here and not fixed in this PR.
setup:4957Re-running setup over an older 10 s gate registration goes through the re-pointed branch, which logs "hook re-pointed" (bin/gstack-settings-hook:646) for what is a timeout-only update.lib/skill-gates.ts:31HOOK_MARGIN_MS budgets one 3 s lock wait; the handler's own lock wait does not check remainingMs(), so a lock reached just before a 20 s deadline could run past 25 s. It needs about 18 s of pre-lock parsing first.docs/skill-gates.md:122Hand-written or olderclaude -p --settingsfiles keep a 10 s timeout; only users who raised the deadline above about 5 s are exposed, and the doc tells them to keep it at or above 25.Exploratory QA
Functional (CLI) smoke at 5698cf7, 3 probes in a 300 s budget, verdict pass (gstack-qa-evidence materialize):
gstack-skill-gates hook-timeoutprints 25 and exits 0.gstack-skill-gates settings --investigate --ceo-review: all six gate hooks carry timeout 25.deadlineFromEnv: 999999 and Infinity clamp to 20000; 7000 stays; 0, -5, abc and empty fall back to 5000.Not run: a live Claude Code kill-at-timeout probe (the doc cites the GST-1615 probe on CLI 2.1.318), setup's bun-unavailable path (read in code, not executed), and the ensure-event raise of a 10 s registration (probed at f114a21; covered at this head by the focused lane's setup-skill-hooks-gate tests).
Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped. Note:
bun run eval:select --base mainfalls back to the full PR selection becausesetupis a shared runtime input; those behavioral probes were not run by this /ship.Scope Drift
Scope Check: CLEAN
Intent: keep the gate hook registration longer than the gate's own deadline so a slow gate cannot fail open.
Delivered: the deadline clamp, a derived 25 s hook timeout in settings and setup, the hook-timeout subcommand, docs, tests, and the approved selection-test expectation the setup change requires.
Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches).
Issues
Refs #4045
Verification Results
No plan-specific verification items (no plan bound): VERIFY_RESULT=skipped.
TODOS
No TODO items completed in this PR.
Documentation
Status: current. Docs already match the gate hook timeout change, so no edits were needed.
Scope: base 937b360 to head 5698cf7 on gst-1615-gate-hook-timeout. 8 committed files (bin/gstack-skill-gates, lib/skill-gates.ts, setup, docs/skill-gates.md, changelog.d/gst-1615-gate-hook-timeout.md and 3 tests); no staged, unstaged or new files.
Documentation health:
hook-timeoutsubcommand match the code.Coverage debt:
gstack-skill-gates hook-timeoutandHOOK_TIMEOUT_Shave reference and explanation coverage in docs/skill-gates.md#hook-timeout but no how-to, which is acceptable for an internal helper. docs/skill-gates.md is reachable only through docs/skill-routing-and-contracts.md (pre-existing).Diagram drift: none.
Test plan
bun test test/skill-gates.test.ts test/setup-skill-hooks-gate.test.ts test/pr-shared-input-selection.test.ts: 61 pass, 0 fail (receipt FRESH at 5698cf7)