Skip to content

fix: skill gate hooks outlive the gate deadline, so a slow gate no longer fails open - #4072

Merged
capy-ai[bot] merged 2 commits into
mainfrom
gst-1615-gate-hook-timeout
Nov 6, 2026
Merged

capy-ai[bot] merged 2 commits into
mainfrom
gst-1615-gate-hook-timeout

Conversation

@garrytan

@garrytan garrytan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 4072,
  "head": "5698cf748415ba997f7d4d4d76e4152abb314873",
  "version": "1.96.0.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 61,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "f74c11223d512ba71024ebfa08598c5fea8412ff",
  "product_patch_id": "decc2d0fe0ad53b75ef9c7d5ee646403dc520a6c",
  "gstack_version": "1.96.0.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 40,
    "rules": "70895942bb8a8ee2",
    "base": "63489d06503a0fddad46d57328ec366c4e3e3d98",
    "registry": "63489d06503a0fddad46d57328ec366c4e3e3d98",
    "gate_scan": {
      "tagged": 0,
      "head": "5698cf748415ba997f7d4d4d76e4152abb314873"
    },
    "reasons": [
      "runtime=40"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @f74c11223d51 (7 checks, current for 5698cf748415)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/42220000316/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42220000316/attempts/1",
    "windows-setup-e2e.yml/windows-setup: https://github.com/garrytan/gstack/actions/runs/42222081952/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/42222074705/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=f74c11223d51 tests=35907 skipped=111 runs=42220000316/1 profiles=ci-reuse/free-tests heads=5698cf748415 verified=2026-11-06T13:00:08.657Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      4045
    ],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "README.md and docs/ (138 files) against the 8 changed files, base 937b360 to head 5698cf7; reader reviewed docs/skill-gates.md, the changelog fragment, README.md, CLAUDE.md, AGENTS.md, docs/skills.md, docs/troubleshooting.md"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 3,
    "deferred": 1,
    "noted": 1,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "est_input_tokens": 6669,
    "unrecorded": 2,
    "ledgers_read": 3,
    "dispatches": {
      "specialist-batched": 1
    }
  }
}

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

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
--- Before · before.txt · captured output
+++ After · after.txt · captured output
@@ ⋯ 8 unchanged ⋯ @@
           {
             "type": "command",
             "command": "<gstack>/hosts/claude/hooks/ceo-review-gate-stop",
+            "timeout": 25
-            "timeout": 10
           }
         ]
       }
@@ ⋯ 4 unchanged ⋯ @@
           {
             "type": "command",
             "command": "<gstack>/hosts/claude/hooks/ceo-review-gate-subagent-stop",
+            "timeout": 25
-            "timeout": 10
           }
         ]
       }

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_MS could 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 recorded GATE_TIMEOUT.

Blast radius

The change touches the two skill-gate registrations (gstack-skill-gates settings and ./setup), the gate deadline in lib/skill-gates.ts, and one paid-eval selection expectation; the routing and contract hooks keep their own timeouts. It is safe because setup's existing ensure-event path raises an older 10 s registration to 25 s in place without a duplicate entry (script ran at f114a21, and bin/gstack-settings-hook is 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:540 drops 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.ts adds ship-skipped-queued-finding to 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 report could not see it. The gate deadline now tops out at 20 s, the hook timeout is derived from it (25 s), and a new gstack-skill-gates hook-timeout subcommand gives ./setup the same number. Because setup now runs bin/gstack-skill-gates, the paid-eval narrow screens for #4045 and #4047 also select ship-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 reads unrecorded=2.

  • setup:4978 (adversarial, FIXABLE, Low): if gstack-skill-gates hook-timeout fails, 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): deadlineFromEnv clamps 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 whole SKILL_GATE_HOOK_TIMEOUT setup 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.

  • Deferred: unfiled — CRITICAL by /ship's rule (the reviewer marked it FIXABLE, Medium, Blocks: no) lib/investigate-gate.ts:156 Synchronous 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.

  • INFORMATIONAL setup:4957 Re-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.
  • INFORMATIONAL lib/skill-gates.ts:31 HOOK_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.
  • INFORMATIONAL docs/skill-gates.md:122 Hand-written or older claude -p --settings files 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-timeout prints 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 main falls back to the full PR selection because setup is 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:

  • docs/skill-gates.md: current. The 20 s deadline clamp, 25 s HOOK_TIMEOUT_S, 5 s margin and hook-timeout subcommand match the code.
  • changelog.d/gst-1615-gate-hook-timeout.md: current and consistent with docs/skill-gates.md#hook-timeout.
  • README.md, CLAUDE.md, AGENTS.md: not affected.

Coverage debt: gstack-skill-gates hook-timeout and HOOK_TIMEOUT_S have 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)
  • Free Tests (workflow_dispatch run 42220000316 at 5698cf7): green, carried by CI_CARRY (35907 tests, tree f74c11223d51)
  • Windows Smoke (run 42222074705) and Windows Setup E2E (run 42222081952) at 5698cf7: green, cleared in the pregate

garrytan and others added 2 commits November 6, 2026 12:07
…-1615)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…se once setup runs gstack-skill-gates (GST-1615)

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

trunk-io Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot merged commit bd36aa0 into main Nov 6, 2026
72 checks passed
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