feat(events): add cheap preflight gates - #618
Conversation
# Conflicts: # docs/diagnostics.md # packages/agent-bundle/src/routes/graph.ts
🦋 Changeset detectedLatest commit: 3311f04 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
# Conflicts: # packages/agent-bundle/src/test/render.ts # packages/agent-bundle/tests/entries.test.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 749660d6f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
commit: |
…pper-plan indirection Deslop of the #595 branch, behavior unchanged: drop the one-line eventRoutePreflight helper in favor of ?.preflight at its call sites, collapse the pointless Set spread when composing project-runtime import bindings, remove a redundant eventRoute undefined check in planHooks, restore hookEntries in inspect-bundler to a single map expression without the dead nested runtime-path check, and fix inconsistent indentation left by the planHooksSurface and normalizeHooks edits. Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
# Conflicts: # packages/agent-bundle/src/adapters/hook-contract.ts
…on diagnostics to AB4843–AB4845 #618 took AB4840/AB4841 for event preflight gates and declared providers, so the CLI surface projection codes move: AB4840→AB4843 (orphan/misplaced/duplicate module), AB4841→AB4844 (projection contract), AB4842→AB4845 (grammar binding).
…oc router) into feat/592-authoritative-manifest
Closes #595.
Summary
executestarts the separately bundled heavy executorGate API
An event route uses exactly
export { default as preflight } from './before.preflight.js'. The leaf receives frozen{ canonical, host, signal, terminal }and returns'execute',{ outcome: 'continue' }, or{ outcome: 'deny', reason }.config.providersselects conventional provider keys for executed event routes. Omitted preserves all providers;[]mounts only framework-ownedprocessLifetime; selected providers resolve once per request in deterministic key/source order.Performance evidence
Seven cold starts on Node v22.23.2/Linux, medians:
node -e ''A cargo-hauler scratch migration used locally packed framework artifacts and moved shell-before/shell-after under conventional event routes. Build, typecheck, route tests, and inspect passed. Its irrelevant shell command gate measured 7 runs at a 0.06 s / 51,248 KiB median, below cargo-hauler #90's approximately 0.10 s / 64 MB routed-hook baseline. This is the consumer path described by cargo-hauler #107.
Trace surface
EventTraceEventis a frozen discriminated union with shared execution identity, monotonic time/sequence, and bounded failure summaries.installEventTraceObserversupplies a process-local sink; observers cannot affect execution. Generated shells currently emit preflight and deferred-execute boundaries/failures; provider/render kinds are reserved for #600's unified worker trace.Verification
pnpm buildpnpm typecheckpnpm lintpnpm test:unit(3,995 tests; 0 failures)pnpm docs:site:buildDeslop
Deslop: Cursor Grok 4.6 High Fast, 7 edits. Reused the shared record guard, removed restating comments, flattened wrapper planning/import construction, and replaced a type-bypass cast without changing behavior.
Self-review
Reviewer: Claude Fable 5.1 Thinking High (
change-risk-reviewer), final diff againstorigin/main.Initial findings and dispositions:
agent-bundleandagent-bundle/apiPost-deslop review: Claude Fable 5.1 Thinking High verified all 7 edits preserved behavior. It identified two low-severity items: the benchmark lacked a script entry (fixed with
bench:preflight-cold-start) and the composed preflight deadline also bounded deferred standalone execution (fixed by scoping the timeout signal to the gate and preserving host-deadline render behavior). Final re-review found no actionable merge risks. After reconciling a compatible remote cleanup, a final Fable pass found an inert executor AbortController, one redundant narrowed ternary, and a stale comment; termination is now forwarded from the hook shell to the deferred executor, the residue was removed, and re-review found no remaining risk. Three GitHub review threads were fixed: deferred execution now preserves canonical observations through standalone and shared IPC, route-shaped preflight targets fail with AB4840 without suppressing either route, and terminal traces close before observer delivery. A final Fable pass found and fixed one missing IPC serialization hop; re-review found no actionable findings.