fix(zcode): keep a team-configured hook timeout instead of the per-event default - #582
Merged
jeff-r2026 merged 1 commit intoSep 16, 2026
Conversation
…ent default toZcodeEntry took its timeoutMs only from the ZCODE_TIMEOUT_MS table added in Tencent#555 and never looked at def.timeout, so on ZCode a timeout the team wrote down was silently discarded: a `timeout:` on a hook in hooks/hooks.yaml, and the `builtin.overrides.<key>.timeout` knob documented in the usage guide. Before Tencent#555 the writer honored it (`timeoutMs: def.timeout * 1000`); the table is the right default for the builtin dispatch hooks, but it took over the explicit values too. Observed end-to-end with the built CLI: a team hook declaring `timeout: 300` and `builtin.overrides."Hook dispatch stop".timeout: 240` both landed in .zcode/cli/config.json as `timeoutMs: 60000`. Every other tool honors the same fields, so a hook long enough to matter on ZCode was capped at the default and killed mid-run. The table now serves as the default only, and a stated timeout wins. Builtin defs for zcode carry no timeout (builtinHookDefs sets withTimeout false for the tool), so the rendered output for a config without overrides is unchanged -- hooks-golden stays green.
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.
Summary
toZcodeEntryreads itstimeoutMsonly from theZCODE_TIMEOUT_MStable introduced in #555 and never looks atdef.timeout, so on ZCode a timeout the team wrote down is silently dropped: atimeout:on a hook inhooks/hooks.yaml, and thebuiltin.overrides.<key>.timeoutknob the usage guide documents ("Only thetimeoutof a built-in hook can be overridden"). Before #555 the writer honored it (timeoutMs: def.timeout * 1000). The per-event table is the right default for the builtin dispatch hooks — a session-start pull really does need more than the 10–15s shell defaults — but it also took over the values a team had stated explicitly.I kept the table as the default and let a stated timeout win, which is what every other tool's writer already does.
Type of Change
Test Plan
npx tsc --noEmitpassesnpx vitest runpasses (see scope note below)End-to-end with the built CLI, single-repo mode,
--agent zcode,.teamai/hooks/hooks.yaml:After
npm run buildandteamai hooks inject, theStopentries in.zcode/cli/config.json:Unit side,
src/__tests__/zcode.test.tsgains one case drivingreconcileHooks(..., 'zcode', ...)with both fields. On the currentmainit fails withexpected 60000 to be 300000; with the change the whole ZCode file passes (11/11).I also ran the neighbouring hook suites —
hooks-golden,hooks-team,hooks-dispatch-format,builtin-hooks,hooks-reconcile-scope,hooks-hasteamaihooks,hooks-security,hooks-shell-check— 72/72 green. The golden fixtures matter here:builtinHookDefssetswithTimeout = falsefor zcode, so builtin defs carry notimeoutand the rendered output for a config without overrides is byte-identical. Only a config that states a timeout changes.Scope note, so you can weigh it: I ran the suite on Windows, where a number of pre-existing cases fail for reasons unrelated to this change (POSIX path separators asserted in test strings,
0600mode checks, git-backed fixtures timing out). The eight suites above and the full ZCode file are green here, and none of the touched code is platform-conditional beyond thewin32branch #555 added, which this change leaves alone.Related Issues
Follow-up to #555, which added the per-event table.
Notes for Reviewers
The one judgement call is precedence. I read the table as ZCode's default rather than an override, because
HookDef.timeoutis documented as "per-hook timeout in seconds (tool-specific; omitted = tool default)" and the guide listsbuiltin.overrides.<key>.timeoutas a supported knob. If you would rather the table stay a hard floor for the builtin dispatch hooks and only team hooks fromhooks.yamlbe honored, that is a one-line change in the same spot and I am happy to make it.I did not add a CHANGELOG entry: most recent fixes here don't carry one, so it looked like something you curate at release time. Say the word and I will add it.
Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.