Skip to content

fix(hooks): repair execution, decisions and lifecycle - #567

Merged
LeXwDeX merged 7 commits into
mainfrom
fix/557-hooks-runtime-reliability
Sep 7, 2026
Merged

fix(hooks): repair execution, decisions and lifecycle#567
LeXwDeX merged 7 commits into
mainfrom
fix/557-hooks-runtime-reliability

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Closes #557
Closes #558
Closes #559
Closes #560
Closes #561
Closes #562
Closes #563
Closes #564
Closes #565
Closes #566

Why

Hooks could bypass their read-only tool contract, lose blocking decisions, stop processing valid siblings after malformed input, and leave timed-out work running. Full session tests also exposed missing hook services across the session worker boundary: native file tools modified files without firing FileChanged, and asynchronous results could not wake the session.

What changed

  • Execute agent inspection commands directly with validated arguments and system executables. Reject shell composition, interpreter escapes, file-writing options and external Git helpers.
  • Validate file configuration, dynamic registrations and all handler outputs through shared schemas. Ignore failed-command stdout and preserve valid configuration siblings.
  • Honor prompt stop/block and permission denials, preserve post-tool success/failure feedback, and atomically claim one-shot hooks before dispatch. Failure hooks handle native tool defects and rejected MCP calls while preserving session interruption.
  • Propagate cancellation to command processes, agent tools, model requests and MCP calls. Cancel tool hooks separately from tool finalization so interrupted Bash output is still saved normally.
  • Carry handler services and the session rewake callback across runtime boundaries. Derive FileChanged paths from actual native tool metadata, including multi-file patches and rename/delete events.
  • Align handler options across configuration, HTTP registration and the generated SDK. Document reserved fields, provider limitations and Windows inspection-tool support.
  • Refresh the required SpecGit harness to the installed 1.14.0 CLI. Preserve required checks, the repository's 45-minute acceptance window and disabled merge automation.

Evidence

Validated with Bun 1.3.14:

  • Full opencode suite on final repair head b56d931b28dfa0d2a97ff3f151d1ece2bac61d59: 4,551 passed, 23 skipped, 1 todo, 0 failed across 379 files. The focused hooks/session/permission/API/Effect suite passed 492 tests with 5 existing skips and 0 failures.
  • After incorporating current main, the DAG core gate passed 820 tests and every existing coverage floor. The ordinary checkout binding matches GitHub checkout context; all 10 issues and PR fix(hooks): repair execution, decisions and lifecycle #567 remain bound.
  • Real session integration covers denied prompt admission without model calls; native write/edit/patch file events; asynchronous completion and rewake; pre/post-tool process cancellation; and preserved Bash truncation output after cancellation.
  • Real process, local HTTP and MCP adapter tests cover timeout propagation, malformed results and one-shot concurrency. Model handler tests use the AI SDK test model and a local model server.
  • All 29 workspace typechecks pass. Lint reports 4,830 warnings and 0 errors, below the unchanged 4,850 cap.
  • Host executable build and version smoke test pass on the final source. Eight compiled-server checks also pass: health, embedded homepage, invalid hook rejection, handler fields round trip, a real Bash hook blocking a prompt, zero model requests, one-shot consumption, and session cleanup. Build artifacts are kept outside the source tree. The client generator is stable; the SDK was regenerated and its freshness check passes.

Final repair head b56d931b28dfa0d2a97ff3f151d1ece2bac61d59 passes Typecheck and DAG coverage and Linux unit tests, generated client/SDK freshness, HttpAPI contracts, and Linux/Windows E2E. Local specgit finish --json exits 0 with every gate passing; GitHub SpecGit Acceptance also passes. The approved main policy and all required checks remain unchanged.

Live external model/MCP services, OpenAI OAuth hook execution and Windows runtime behavior are not claimed as validated. Reserved output fields remain explicitly diagnosed rather than presented as implemented.

Checklist

  • Regression cases pass on Bun 1.3.14
  • Relevant tests, workspace typechecks and lint pass
  • Configuration guidance and generated SDK match the runtime
  • Current repair-head CI and SpecGit acceptance pass

@LeXwDeX LeXwDeX changed the title fix: enforce read-only execution for agent hook tools fix(hooks): repair execution, decisions and lifecycle Sep 7, 2026
@LeXwDeX
LeXwDeX marked this pull request as ready for review September 7, 2026 04:10
@LeXwDeX
LeXwDeX merged commit b37b336 into main Sep 7, 2026
10 of 11 checks passed
@LeXwDeX
LeXwDeX deleted the fix/557-hooks-runtime-reliability branch September 7, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment