Skip to content

fix(agent-hooks): deliver hook events that fire while Orca is restarting (STA-5329) - #16685

Merged
brennanb2025 merged 13 commits into
mainfrom
brennanb2025/sta-5329-hook-spool
Aug 27, 2026
Merged

brennanb2025 merged 13 commits into
mainfrom
brennanb2025/sta-5329-hook-spool

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​446 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​445
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​398 $\color{#cf222e}{\Huge{\mathbf{−}}}$​22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​376

ELI5

When an agent finishes a turn it tells Orca over a tiny local HTTP call. If Orca happens to be restarting at that moment, nobody is listening, the message is thrown away, and the sidebar keeps showing "working" forever. This makes the agent write that message to a file instead, and Orca reads it on next launch.

What Changed

Writer (shared, 11 POSIX providers). buildPosixHookSpoolLines in agent-hooks/hook-stdin-contract.ts adds a spool_hook_event shell function, wired into antigravity, claude, codex, command-code, copilot, cursor, devin, droid, gemini, grok and kimi. It runs only on failure paths: the missing-endpoint guard, and a POST that failed after the Windows curl.exe retry. Nothing is written when the POST succeeds.

Per-pane JSONL beside the endpoint file (<endpointDir>/spool/pane-<id>.jsonl), path derived in-script from ORCA_AGENT_HOOK_ENDPOINT so it follows the WSL-guest and SSH-remote relocations automatically. Leading newline per record so a torn write costs exactly one line. 5 MB cap and a 7-day mtime truncate, both enforced by the writer. Tool-progress events (PreToolUse / PostToolUse / PostToolUseFailure) are skipped — highest volume, largest payloads, worthless to replay.

Drain (agent-hooks/spool.ts, wired in server.ts). Runs at startup before the listener binds, so replay cannot race a live hook. Each record is re-ingested through the existing ingestRemote path with isReplay: true, which already suppresses the side effects that must not re-fire.

Why

The completion hook is fire-and-forget with no retry. Verified on a dev build rather than assumed:

  • Orca stopped, then the hook fired: curl: (7) Failed to connect — the event ceases to exist.
  • The endpoint file survives shutdown by design, so PORT/TOKEN are still set and the script's existing guard does not fire. This is why spooling has to happen on the curl-failure path, not only when the endpoint is missing.
  • After restart the row still read working with the subagent still working.
  • Replaying the lost event cleared it.

This repairs delivery rather than guessing after the fact. A delivered event carries its own launch token, so nothing has to infer which agent generation a pane holds — an inference that is not soundly possible once the event is lost.

Three safety properties, each pinned by a test:

  1. Stale generations are fenced. A spooled event whose launch-token hash does not match the pane's persisted hash is dropped before ingest. Measured on a running build: without this, a stale SubagentStop clears a newer generation's row and overwrites the pane's authority hash.
  2. Replay never claims a live observation. A non-terminal replayed event withdraws the pane from runtimeObservedStatusPaneKeys. Without this, downtime-era evidence marks a pane runtime-observed and permanently masks both the liveness sweep and transcript confirmation — re-creating this very bug through the replay path.
  3. Truncate in place, never unlink. A hook process may hold an append handle; replacing the file would leave live writers appending to an orphaned inode.

Linked Issue

Fixes STA-5329

Visual Proof

N/A — no UI surface changes. The visible effect is an existing sidebar row reaching its correct state instead of remaining working; there is no new or altered component.

Testing

src/main/agent-hooks/spool.test.ts (6) and hook-script-outside-orca.test.ts (3). Full src/main/agent-hooks/ suite: 74 files, 732 passed, 6 skipped. oxfmt + oxlint clean on all 16 changed files.

Both critical tests were confirmed to fail before their fix by reverting the production file and re-running — real assertion failures, not import errors:

  • does not mark a non-terminal downtime replay as runtime-observed → expected true to be false
  • spools when the endpoint is present but the receiver is unavailable → fails against the pre-fix script

Managed hooks run outside Orca too (they live in the user's agent config), so hook-script-outside-orca.test.ts asserts exit status, stdout, stderr and that no files are created, across three cases: no Orca env, pane key without an endpoint, and an endpoint path that does not exist. All silent, exit 0, nothing written.

Manual verification used an isolated dev instance with its own user-data profile.

  • I manually tested these changes locally
  • Automated tests added/updated

Platforms: macOS verified end to end. WSL / SSH inherit the derived path but were not exercised. Windows — see below.

Not covered

  • Windows cmd writer is not implemented. cmd cannot capture stdin into a variable (the payload streams via --data-urlencode "payload@-"), so it needs the tee-to-temp-file approach claude/statusline-script.ts already uses. Windows agents get no spooling from this PR. Tracking separately.
  • Plugin-based providers (amp, opencode, pi, hermes) emit outside the shared shell builder and are untouched.
  • Rows already stuck before this ships stay stuck — their events are gone. They expire on the existing 7-day hydrate TTL.

Relationship to #16538

Complementary, opposite halves of the same restart gap: this recovers terminal events that were lost, #16538 re-derives "still working" when no event fired at all. Neither subsumes the other. A trial merge shows one trivial import-line conflict; either can land first.

Two deliberate points of compatibility: replayed records pass connectionId: null so they are not excluded by that PR's local-only transcript predicate, and this PR strips isReplay at persist time so replay provenance never survives another restart.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-5329-hook-spool branch from bab3b6e to 140701b Compare August 26, 2026 22:15
@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 03320062-8ccb-446b-85cf-292059852f60

📥 Commits

Reviewing files that changed from the base of the PR and between 2180977 and 34df1bc.

📒 Files selected for processing (2)
  • src/main/agent-hooks/server-relay-listener-replay.test.ts
  • src/shared/agent-hook-listener/providers/codex-state.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

POSIX agent hook scripts now spool events when hook context is unavailable or HTTP delivery fails. Spool records use bounded JSONL storage with launch-token validation and safe concurrent draining. Agent hook and relay servers reconstruct and replay valid records during startup. Replay events receive dedicated status and runtime-observation handling. Codex state reconciliation preserves omitted root prompts across lifecycle updates. Tests cover serialization, malformed records, token fencing, restart replay, unavailable receivers, outside-Orca execution, and provider-specific event filtering.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the agent-hook fix and the restart scenario addressed by the changes.
Description check ✅ Passed The description is detailed and covers the change, motivation, linked issue, testing, platform scope, limitations, and compatibility considerations. Some template sections are not explicitly completed…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the change, motivation, linked issue, testing, platform scope, limitations, and compatibility considerations. Some template sections are not explicitly completed, but the required technical context is mostly complete.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/codex/hook-service.ts (1)

851-863: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Treat HTTP error responses as failed delivery. All seven POSIX hooks use curl’s exit status to select spool_hook_event, but curl returns success for HTTP 4xx/5xx responses unless --fail is set. Add --fail to each POST command, including post_codex_hook, so rejected events reach the spool fallback on native and WSL paths.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 40e45904-7bfd-4084-bede-d012e0b57d54

📥 Commits

Reviewing files that changed from the base of the PR and between 0e10fc5 and 140701b.

📒 Files selected for processing (16)
  • src/main/agent-hooks/hook-script-outside-orca.test.ts
  • src/main/agent-hooks/hook-stdin-contract.ts
  • src/main/agent-hooks/server.ts
  • src/main/agent-hooks/spool.test.ts
  • src/main/agent-hooks/spool.ts
  • src/main/antigravity/hook-script.ts
  • src/main/claude/hook-service.ts
  • src/main/codex/hook-service.ts
  • src/main/command-code/command-code-managed-script.ts
  • src/main/copilot/copilot-managed-script.ts
  • src/main/cursor/hook-service.ts
  • src/main/devin/hook-service.ts
  • src/main/droid/hook-service.ts
  • src/main/gemini/hook-service.ts
  • src/main/grok/grok-hook-script.ts
  • src/main/kimi/hook-service.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment on lines +28 to +34
' { printf \'\\n{"paneKey":"%s","tabId":"%s","worktreeId":"%s","env":"%s","version":"%s","launchToken":"%s","source":"%s","receivedAt":%s,"payload":\' "$(spool_json_escape "${ORCA_PANE_KEY:-}")" "$(spool_json_escape "${ORCA_TAB_ID:-}")" "$(spool_json_escape "${ORCA_WORKTREE_ID:-}")" "$(spool_json_escape "${ORCA_AGENT_HOOK_ENV:-}")" "$(spool_json_escape "${ORCA_AGENT_HOOK_VERSION:-}")" "$(spool_json_escape "${ORCA_AGENT_LAUNCH_TOKEN:-}")" "$(spool_json_escape "'.concat(
source,
'")" "$spool_now"; printf "%s}\\n" "$payload"; } >> "$spool_file" 2>/dev/null || :'
)
return [
'spool_hook_event() {',
' case "$payload" in *\'"PreToolUse"\'*|*\'"PostToolUse"\'*|*\'"PostToolUseFailure"\'*) return 0 ;; esac',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve the provider event name. Antigravity gets its event name from ORCA_ANTIGRAVITY_EVENT, not payload, so PreToolUse is spooled and replay lacks the hookEventName sent by the live POST; pass and serialize the provider event name before filtering.

Comment on lines +112 to +120
try {
const fd = openSync(candidate.path, 'r+')
try {
// Keep the inode so a concurrent append handle cannot silently orphan writes.
ftruncateSync(fd, 0)
} finally {
// fstat keeps the descriptor operation observable in tests and documents the inode contract.
fstatSync(fd)
closeSync(fd)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Prevent loss during concurrent spool writes. ftruncateSync can erase an append that occurs after readSpoolRecords completes; use a shared writer/drainer lock or acknowledged offset protocol before truncation.

Comment thread src/main/kimi/hook-service.ts Resolved
- claude: pass the literal source; options.agent does not exist (typecheck)
- kimi: the windows-local ordering runs its guard pre-stdin and before the
  function exists, so it no longer spools there (printed command-not-found)
- writer: require a readable endpoint file before creating a spool tree
- antigravity: carry its out-of-band event name into the record and filter on it
- drain: truncate only the bytes consumed, preserving concurrent appends and a
  torn trailing line

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0abbc80d-8951-4707-9fa3-c56ce6af1f0b

📥 Commits

Reviewing files that changed from the base of the PR and between 140701b and 529c40b.

📒 Files selected for processing (6)
  • src/main/agent-hooks/hook-script-outside-orca.test.ts
  • src/main/agent-hooks/hook-stdin-contract.ts
  • src/main/agent-hooks/spool.ts
  • src/main/antigravity/hook-script.ts
  • src/main/claude/hook-service.ts
  • src/main/kimi/hook-service.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

Comment thread src/shared/agent-hook-spool.ts Resolved
@OrcaWin

OrcaWin commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Windows high-spec + WSL POSIX-hook validation (STA-5329)

Isolated ORCA_DEV_USER_DATA_PATH + CDP 9334 on c533b1ef43. Identity matched Orca: OrcaWin/pr16685-grok-electron. Live WSL PTY used /mnt/c/.../endpoint.cmd (relay bundle missing: WSL hook relay bundle not found; run build:relay).

Writer works. While the receiver was down, the real POSIX Codex hook inside Ubuntu-24.04 spooled a SubagentStop next to the endpoint (curl: (7) Failed to connect). After restart the spool file was truncated in place to 0 bytes.

Drain ingest does not apply writer-shaped records. Replay left the child row in last-status.json and the sidebar. A later live HTTP SubagentStop (same event, receiver up) removed the child. Root cause: POSIX spool payload is raw hook JSON (hook_event_name / agent_id); ingestRemote runs normalizeAgentStatusPayload, which requires state and returns null. The unit test writes a pre-normalized payload, so it misses this.

Production code was not changed. Full notes: .tmp-sta5329-evidence/STA-5329-windows-wsl-validation.md (not committed).

Before restart (working Codex + worker child)

01-before-restart-working.png

After restart (spool drained, child still present — idle/hydrate, not settled)

02-after-restart-child-still-present.png

Contrast: live HTTP SubagentStop after restart (child gone)

03-after-live-subagentstop-child-gone.png

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d58b3bb-3f78-4f9b-904c-cf88571f1b25

📥 Commits

Reviewing files that changed from the base of the PR and between c533b1e and 2180977.

📒 Files selected for processing (5)
  • src/main/agent-hooks/server.ts
  • src/main/agent-hooks/spool.test.ts
  • src/relay/agent-hook-server.test.ts
  • src/relay/agent-hook-server.ts
  • src/shared/agent-hook-spool.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment thread src/relay/agent-hook-server.ts Resolved
@OrcaWin

OrcaWin commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Windows high-spec + WSL POSIX-hook re-validation (STA-5329) — c533b1ef43 failure is fixed by 2180977745

Isolated ORCA_DEV_USER_DATA_PATH + CDP 9334 on exact SHA 218097774518fa4c39c6cbdb72c039550ee49d66. Identity matched Orca: OrcaWin/pr16685-grok-electron (devRepoRoot this worktree). Relay bundle was built (out/relay/wsl, 0.1.0+ea94abeb4398). Live WSL PTY used the guest-relocated endpoint /home/neil/.orca-wsl/agent-hooks/instance-f58e5a06c1cb/endpoint.env (not /mnt/c/.../endpoint.cmd).

The earlier c533b1ef43 failure is fixed by 2180977745. While the receiver/relay was down, the real POSIX Codex hook inside Ubuntu-24.04 spooled a writer-shaped raw SubagentStop next to the guest endpoint (curl: (7) Failed to connect). After restart the guest spool was truncated in place to 0 bytes, last-status.json became hookEventName: SubagentStop with payload.subagents gone, launchTokenHash still matched sta5329-generation, isReplay was not persisted, and no live HTTP SubagentStop was posted. The sidebar child worker row is gone.

Production code was not changed. New screenshots (do not reuse the c533b1ef43 ones). Full notes: .tmp-sta5329-evidence-2180977745/STA-5329-windows-wsl-validation.md (not committed).

Before restart (working Codex + worker child)

01-before-restart-working.png

After restart (guest spool drained + normalized; child gone; no live POST)

02-after-restart-child-gone.png

@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Review complete for PR #16685.

Final pushed SHA: 019773199e05c19c2ed06a231d5b32c6873bf772

What changed during review:

  • Preserved Codex root prompts during replayed child lifecycle events.
  • Added durable spool replay normalization/fencing across desktop, relay, SSH, and WSL paths.
  • Added a narrow relay startup guard so a downstream replay-forwarding exception cannot prevent the loopback listener from binding; failed replay records remain on disk for retry.
  • No unrelated files or scope changes; user-owned COMPARE-16538-FINDINGS.md was preserved.

Verification:

CI:

  • Final exact-SHA run 33024844176: passed.
  • Static analysis, typecheck, shell contracts, Git compatibility, managed hooks, Node 24/26 shards, Windows/Linux packaging, cross-version wire compatibility, SSH isolation, changed E2E specs, and aggregate verify are green.
  • The Windows host-job detached-process liveness test failed once, then passed on the failed-job rerun without code changes, confirming a transient test failure.
  • An earlier run also showed only the repository’s unrelated localization-catalog drift; no locale files are changed here.

Residual risk (non-blocking): the pre-existing in-place spool compaction algorithm has a very narrow append-after-fstat race, and a large backlog can make startup synchronous I/O sizable. These are follow-up design considerations, not regressions introduced by this PR.

The older comment documenting the pre-fix failure at c533b1ef43 is superseded by the corrective validation above.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Additional real-agent validation completed at exact SHA 019773199e05c19c2ed06a231d5b32c6873bf772:

  • Claude Code 2.1.237 (authenticated real session): emitted SessionStart, UserPromptSubmit, and Stop while the receiver was unavailable. Restart replay restored agentType: claude, final done, and the original prompt; the mode-0600 spool drained to zero.
  • Grok 1.0.5 (real PTY session): emitted six real lifecycle records, including working and final stop/result data. Relay replay preserved pane/tab/worktree/launch-token metadata, restored the prompt and final assistant message with agentType: grok, and drained the mode-0600 spool to zero.
  • Antigravity 1.1.21 (authenticated real session): performed a real shell tool call, emitted five lifecycle records, and correctly excluded PreToolUse/PostToolUse progress events from the spool. Relay replay preserved metadata, progressed through working to final done, restored the assistant result, and drained the mode-0600 spool to zero.

All runs used disposable profiles/endpoints. Original user hook/config files were restored and verified byte-for-byte, temporary auth copies and harnesses were removed, and no branch files changed.

@brennanb2025
brennanb2025 merged commit aaef5e8 into main Aug 27, 2026
99 of 101 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 30, 2026
…ing (STA-5329) (stablyai#16685)

* fix(agent-hooks): correct durable spool delivery

* fix(agent-hooks): spool curl failures after retries

* fix(agent-hooks): keep replay out of runtime observations

* test(agent-hooks): pin managed hooks inert outside an Orca terminal

* fix(agent-hooks): address review findings on the durable spool

- claude: pass the literal source; options.agent does not exist (typecheck)
- kimi: the windows-local ordering runs its guard pre-stdin and before the
  function exists, so it no longer spools there (printed command-not-found)
- writer: require a readable endpoint file before creating a spool tree
- antigravity: carry its out-of-band event name into the record and filter on it
- drain: truncate only the bytes consumed, preserving concurrent appends and a
  torn trailing line

* fix(agent-hooks): ignore spool events without pane attribution

* fix(agent-hooks): make spool replay and appends robust

* test(agent-hooks): type spool replay records

* fix(agent-hooks): defer unterminated spool records

* fix(agent-hooks): replay spool events through relays

* fix(agent-hooks): preserve Codex prompt across child replay

* fix(relay): keep startup alive when spool replay fails

* fix(relay): simplify spool replay startup guard

(cherry picked from commit aaef5e8)
maxmilian added a commit to maxmilian/orca that referenced this pull request Oct 1, 2026
Codex fails closed on a hook whose stdout is not valid JSON, so every session
started from an Orca terminal reported "invalid session start/stop hook JSON
output" even though the POST to Orca's listener succeeded (stablyai#16356).

The managed Codex script never wrote anything to stdout. Its siblings all do:
claude (stablyai#14818), gemini, copilot and antigravity each emit neutral JSON as the
first line, before any early-exit guard. Codex was the only one without it.

Rebased onto the module split from stablyai#17260: the builder moved from
hook-service.ts to codex-hook-script.ts, so the two lines land there instead.

hook-script-outside-orca.test.ts (added in stablyai#16685, after this PR was opened)
asserted the managed Codex hook stays silent outside an Orca terminal. Silence
is exactly the failure stablyai#16356 reports, and every sibling hook already prints
"{}" unconditionally, so the stdout assertions now expect the neutral JSON.
The inertness those tests really guard - exit 0, empty stderr, no spool tree
written - is unchanged and still asserted.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ing (STA-5329) (stablyai#16685)

* fix(agent-hooks): correct durable spool delivery

* fix(agent-hooks): spool curl failures after retries

* fix(agent-hooks): keep replay out of runtime observations

* test(agent-hooks): pin managed hooks inert outside an Orca terminal

* fix(agent-hooks): address review findings on the durable spool

- claude: pass the literal source; options.agent does not exist (typecheck)
- kimi: the windows-local ordering runs its guard pre-stdin and before the
  function exists, so it no longer spools there (printed command-not-found)
- writer: require a readable endpoint file before creating a spool tree
- antigravity: carry its out-of-band event name into the record and filter on it
- drain: truncate only the bytes consumed, preserving concurrent appends and a
  torn trailing line

* fix(agent-hooks): ignore spool events without pane attribution

* fix(agent-hooks): make spool replay and appends robust

* test(agent-hooks): type spool replay records

* fix(agent-hooks): defer unterminated spool records

* fix(agent-hooks): replay spool events through relays

* fix(agent-hooks): preserve Codex prompt across child replay

* fix(relay): keep startup alive when spool replay fails

* fix(relay): simplify spool replay startup guard
maxmilian added a commit to maxmilian/orca that referenced this pull request Oct 26, 2026
Codex fails closed on a hook whose stdout is not valid JSON, so every session
started from an Orca terminal reported "invalid session start/stop hook JSON
output" even though the POST to Orca's listener succeeded (stablyai#16356).

The managed Codex script never wrote anything to stdout. Its siblings all do:
claude (stablyai#14818), gemini, copilot and antigravity each emit neutral JSON as the
first line, before any early-exit guard. Codex was the only one without it.

Rebased onto the module split from stablyai#17260: the builder moved from
hook-service.ts to codex-hook-script.ts, so the two lines land there instead.

hook-script-outside-orca.test.ts (added in stablyai#16685, after this PR was opened)
asserted the managed Codex hook stays silent outside an Orca terminal. Silence
is exactly the failure stablyai#16356 reports, and every sibling hook already prints
"{}" unconditionally, so the stdout assertions now expect the neutral JSON.
The inertness those tests really guard - exit 0, empty stderr, no spool tree
written - is unchanged and still asserted.
maxmilian added a commit to maxmilian/orca that referenced this pull request Nov 8, 2026
Codex fails closed on a hook whose stdout is not valid JSON, so every session
started from an Orca terminal reported "invalid session start/stop hook JSON
output" even though the POST to Orca's listener succeeded (stablyai#16356).

The managed Codex script never wrote anything to stdout. Its siblings all do:
claude (stablyai#14818), gemini, copilot and antigravity each emit neutral JSON as the
first line, before any early-exit guard. Codex was the only one without it.

Rebased onto the module split from stablyai#17260: the builder moved from
hook-service.ts to codex-hook-script.ts, so the two lines land there instead.

hook-script-outside-orca.test.ts (added in stablyai#16685, after this PR was opened)
asserted the managed Codex hook stays silent outside an Orca terminal. Silence
is exactly the failure stablyai#16356 reports, and every sibling hook already prints
"{}" unconditionally, so the stdout assertions now expect the neutral JSON.
The inertness those tests really guard - exit 0, empty stderr, no spool tree
written - is unchanged and still asserted.
maxmilian added a commit to maxmilian/orca that referenced this pull request Nov 18, 2026
Codex fails closed on a hook whose stdout is not valid JSON, so every session
started from an Orca terminal reported "invalid session start/stop hook JSON
output" even though the POST to Orca's listener succeeded (stablyai#16356).

The managed Codex script never wrote anything to stdout. Its siblings all do:
claude (stablyai#14818), gemini, copilot and antigravity each emit neutral JSON as the
first line, before any early-exit guard. Codex was the only one without it.

Rebased onto the module split from stablyai#17260: the builder moved from
hook-service.ts to codex-hook-script.ts, so the two lines land there instead.

hook-script-outside-orca.test.ts (added in stablyai#16685, after this PR was opened)
asserted the managed Codex hook stays silent outside an Orca terminal. Silence
is exactly the failure stablyai#16356 reports, and every sibling hook already prints
"{}" unconditionally, so the stdout assertions now expect the neutral JSON.
The inertness those tests really guard - exit 0, empty stderr, no spool tree
written - is unchanged and still asserted.
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.

2 participants