# Controller report: Codex startup notice

Brief: CODEX-BRIEF-codex-startup-notice.md. Branch: codex-startup-notice.
Starting revision: a127a14, which contains the brief above main 85d9ea8.

## Changes and path trace

R1: The terminal login probe, launcher preflight, and session handler accept
one account/updated notification per process, with no id and authMode equal
to chatgpt. planType is ignored. A shared predicate checks the frame shape;
each process reader owns its allowance. The probe stops at the account/read
response. Preflight never sends turn/start. The session closes its allowance
under its mutex before its first turn/start call and never reopens it, including
after a completed turn. Duplicate notices, other or missing auth modes, and
ID-bearing frames remain refused.

The session path is reachable: Open starts a preflight process, then a separate
session process whose handler is installed before initialize and account/read.
Both processes receive the recorded startup sequence. The direct-live driver
constructs this same Codex launcher for its exercises and certification, so it
inherits both fixes. Its policy-readback collector only inspects result frames;
its certificate validation does not dispatch account events. There is no second
account-event exception to change. Its fake CLI now emits the recorded sequence.

R2: LoginEnvironment omits TMPDIR for both providers when unset or empty, and
preserves a nonempty value. The prerequisites version command uses a bounded
stdout-only helper; command failure still fails the check. Other command output
handling is unchanged.

R3: Fixtures include the recorded disabled remote-control frame with a fake
installation ID, followed by the ChatGPT/promax notice. Coverage includes the
probe, preflight, session, official login, guided account setup, multiple-account
setup, and direct-live fake CLI. Tests cover ID values (including empty and null),
missing/null/other auth modes, duplicates, arbitrary planType, notices before
initialize, duplicates across initialize, notices during config/thread setup,
and notices both during and after a completed turn. TestCodexPreflightNotification
also checks the shared startup predicate. No runtime copy or README changed.

## Verification

All Go commands use CGO_ENABLED=0 and the default Go caches. New tests use
`t.TempDir()` and do not require TMPDIR. Environment tests explicitly cover
unset, empty and nonempty values. Scratch is under the on-disk TMPDIR.

Before implementation, this command exited 1 at the intended assertions:

```sh
go test ./internal/runner/provider ./internal/runner/provider/codex ./internal/tryequipo -run 'TestCodex(LoginStartupNotice|StartupNotice|SessionStartup|AccountOfficialFlow)|TestLoginEnvironmentTMPDIR|TestOnboardingOfficialLogin$' -count=1
```

The recorded notice was refused in all three readers and the guide; empty and
unset TMPDIR produced an unwanted TMPDIR= entry. The initial test compilation
was corrected to use the concrete terminal driver before recording these failures.

`go test ./internal/tryequipo -run '^TestVersionStdout$' -count=1` also exited 1
with the old merged-output behavior: the version contained the stderr warning.

After implementation:

- `go test ./internal/runner/provider ./internal/runner/provider/codex ./internal/tryequipo ./internal/directlive -count=1`
  exited 0 for all four packages (9.155s, 29.808s, 5.825s and 150.708s).
- `go test ./internal/runner/provider/codex -run '^TestCodex(Startup|SessionStartup|PreflightNotification)' -count=1`
  exited 0, including the final first-turn timing tests.
- `go test ./internal/runner/provider ./internal/tryequipo -run 'TestCodexLoginStartupNotice|TestVersionStdout|TestLoginEnvironmentTMPDIR' -count=1`
  exited 0, including the final cross-initialize probe tests.
- `git diff --check` and `python3 scripts/runner-dead-references.py` exited 0.
  No reference hashes needed remapping.

Each guard mutation used a Go overlay, leaving working source unchanged. The
command form was `go test -overlay=<scratch>/<mutation>.json <packages> -run <pattern> -count=1`.
Every row below exited 1 at the intended test assertion, with no build failures.

| Mutation | Packages | Pattern |
| --- | --- | --- |
| notice-id: allow IDs | ./internal/runner/provider | ^TestCodexLoginStartupNotice$/.*id$ |
| notice-id: allow IDs | ./internal/runner/provider/codex | ^TestCodexStartupNotice$/(preflight\|session)/(id\|empty-id)$ |
| notice-mode: allow another nonempty auth mode | ./internal/runner/provider | ^TestCodexLoginStartupNotice$/api-key$ |
| notice-mode: allow another nonempty auth mode | ./internal/runner/provider/codex | ^TestCodexStartupNotice$/(preflight\|session)/api-key$ |
| probe-duplicate: ignore consumed allowance | ./internal/runner/provider | ^TestCodexLoginStartupNotice$/duplicate$ |
| preflight-duplicate: ignore consumed allowance | ./internal/runner/provider/codex | ^TestCodexStartupNotice$/preflight/duplicate$ |
| session-duplicate: ignore consumed allowance | ./internal/runner/provider/codex | ^TestCodexSessionStartupNoticeConsumed$ |
| turn-cutoff: leave allowance open | ./internal/runner/provider/codex | ^TestCodex(SessionStartupBeforeFirstTurn\|StartupAfterCompletedTurn)$ |
| empty-tmpdir: append even when empty | ./internal/runner/provider | ^TestLoginEnvironmentTMPDIR$ |

The initial shared-predicate mutation commands also selected the launcher
package without matching its nested subtests. The explicit launcher commands
above then verified both preflight and session refusals separately.

## Full gate and delivery

R4: Run one full `make -k ci` after staging the complete candidate, including
this report. The result and any permitted retry are recorded in the commit
body and the required three-line summary. Scratch overlays and logs are removed
before handoff. No live gate, real sign-in, deployment, copy-review server, or
access to the live equipo data directory was performed.
