Repository navigation
Run host enrollment SessionStart hook without --quiet - #11
Merged
Merged
Conversation
The managed host enrollment bootstrap hook ran with --quiet, which makes _emit a no-op and swallows every status the bootstrap produces on SessionStart -- including the pigs_fly_not_enabled gate bail, pending browser approvals, and errors. During dogfooding this means a misconfigured host (flag unset, unreachable worker) produces zero feedback, so the enrollment flow appears to silently do nothing. Render the Claude and Codex SessionStart hook commands without --quiet so each session start surfaces the bootstrap status. The binary still accepts --quiet for manual quiet runs.
Codex Bug BotNo new bugs detected in this PR. |
adit-chandra
added a commit
that referenced
this pull request
Jun 30, 2026
) ## Problem Codex now fails the host-enrollment `SessionStart` hook every session: ``` • SessionStart hook (failed) error: hook returned invalid session start JSON output ``` The bootstrap writes its **full diagnostic status object** to **stdout** on every `SessionStart`: ```json {"host":"codex","needs_restart":true,"status":"needs_restart","systemMessage":"Promptless telemetry configured for Codex. Restart Codex to start telemetry."} ``` Codex validates SessionStart hook **stdout** against a strict schema — its Rust parser deserializes into a fixed struct with serde `deny_unknown_fields`, accepting only `continue` / `stopReason` / `systemMessage` / `suppressOutput` / `hookSpecificOutput`. Our diagnostic keys (`status`, `host`, `needs_restart`, `reason`) are outside that schema, so Codex rejects the whole object as *"invalid session start JSON output"*. This hits **every** Codex session — including the common gate-disabled steady state (`{"status":"disabled",...}`), not just the configured case. (Strict per-event validation confirmed by [openai/codex#18887](openai/codex#18887), [#27052](openai/codex#27052).) The premise added in #15 — *"the extra field is ignored by the host hook parsers"* — holds for **Claude Code** (lenient: ignores unrecognized top-level fields, which is why Claude never errored) but is **false for Codex** (strict). The error actually first appeared in #11, which dropped `--quiet` and started writing this JSON to Codex's stdout; #15 added `systemMessage` on the same wrong assumption and so didn't fix it. ## Fix Split the streams in `_emit`: - **stdout** carries only the schema-valid `systemMessage` (`{"systemMessage": "..."}`), and **nothing at all** when there is no message — Codex treats empty stdout as success. - **stderr** carries the full diagnostic object (`status` / `host` / `needs_restart` / `reason`, plus the message), which neither host parses as hook output but stays available for manual troubleshooting (the `--quiet`-off intent from #11). Claude keeps rendering the `systemMessage` banner; Codex stops erroring. ## Tests - A shared `_assert_session_start_streams` helper now asserts the split on **every** bootstrap run: stdout is empty or exactly `{systemMessage}` (never the schema-breaking keys), stderr carries the diagnostic. This guards all existing cases against future stdout leaks. - New `test_bootstrap_stdout_stays_codex_schema_safe` pins the exact Codex-breaking fields out of stdout and verifies steady-state stdout is empty. - Updated two gate-disabled assertions (`stderr == ""` → `stdout == ""`) since the diagnostic now lives on stderr. ## Validation - `uv run pytest` — **136 passed** - `uv run ruff check src tests`, `uv run ruff format --check src tests`, `uv run ty check src tests` — clean - Bootstrap script (extensionless, missed by CI globs) `py_compile`s and is ruff/format-clean - Manual smoke test of the gate-disabled Codex path: stdout is now empty (Codex success), diagnostic on stderr
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
The managed host enrollment bootstrap hook is rendered with
--quiet, which turns_emitinto a no-op and suppresses every status the bootstrap produces onSessionStart— thepigs_fly_not_enabledgate bail, pending browser approvals,needs_restart/configured/blocked, and caught errors all go to nowhere.During dogfooding this means a misconfigured host (flag unset, unreachable worker, missing worker bridge endpoints) produces zero feedback, so the enrollment flow appears to silently do nothing and there's nothing to debug from.
--quietonly ever suppressed status text; it never gated side effects, so dropping it changes nothing about what the bootstrap does — only that the hook now reports what happened.Changes
SessionStarthook commands without--quiet(managed_runtime.py).--quietfor manual quiet runs; only the generated hook changes.test_build_injects_managed_bootstrap_runtimeto assert the rendered command omits--quiet.Checks
uv run ruff check .uv run ty check srcuv run pytest(130 passed)