Skip to content

Run host enrollment SessionStart hook without --quiet - #11

Merged
adit-chandra merged 1 commit into
mainfrom
adit/bootstrap-hooks-drop-quiet
Jun 30, 2026
Merged

adit-chandra merged 1 commit into
mainfrom
adit/bootstrap-hooks-drop-quiet

Conversation

@adit-chandra

Copy link
Copy Markdown
Contributor

Summary

The managed host enrollment bootstrap hook is rendered with --quiet, which turns _emit into a no-op and suppresses every status the bootstrap produces on SessionStart — the pigs_fly_not_enabled gate 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. --quiet only 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

  • Render the Claude and Codex SessionStart hook commands without --quiet (managed_runtime.py).
  • The binary still accepts --quiet for manual quiet runs; only the generated hook changes.
  • Update test_build_injects_managed_bootstrap_runtime to assert the rendered command omits --quiet.

Checks

  • uv run ruff check .
  • uv run ty check src
  • uv run pytest (130 passed)

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.
@github-actions

Copy link
Copy Markdown

Codex Bug Bot

No new bugs detected in this PR.

@adit-chandra
adit-chandra merged commit d23577d into main Jun 30, 2026
6 checks passed
@adit-chandra
adit-chandra deleted the adit/bootstrap-hooks-drop-quiet branch June 30, 2026 01:38
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
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.

1 participant