Skip to content

Commit 4bdc0f6

Browse files
authored
fix(codex): restore GPT-5.6 for entitled accounts by raising the gated client-version floor (#3035)
* docs(devlog): plan the priority-70+ entitlement and spill train Roadmap cycle for #3022, #3023, and #3011. Research lanes established three things the issues did not: - The repository already contains a live measurement (260817 unit) that contradicts its own bundled snapshot: upstream returns gpt-5.6 only at client_version >= 0.144.0, while the snapshot records 0.142.2. The tier-3 floor derives from that snapshot, so background sync asks a question upstream answers with an empty gated set. - An empty parsed roster produces a truthy Set, so it is recorded as a CONFIRMED negative with the 5-minute success TTL rather than the 15-second failure TTL. A size>0 guard does not cover the reported short roster, which contains gpt-5.5 while every gated slug is absent. - PR #3018 fixes the /healthz stall correctly but leaves a shutdown boundary: flushResponseState never awaits responseSpillPublicationTail, and residents over 2 MiB are excluded from the snapshot, so a continuation can be lost. wp3 therefore lands a drain on top of that head instead of merging as-is. Docs only; no production code in this commit. * docs(devlog): amend the train after a FAIL plan audit An adversarial sol-high plan auditor returned FAIL with four blockers, all verified in-tree before acceptance: - wp1's single account-wide flag would have applied model-scoped doubt as an account-wide denial. confirmed is one bit for the whole roster and every projection drops the account when it is false, so the draft would have hidden gpt-5.5 and gpt-5.4 too, and denied gpt-daybreak-blue-latest, which is gated but has no snapshot row and therefore no measured minimum. Split into an account-scoped usable-answer test and a model-scoped absence-authority test; positive evidence needs no version check. - wp2's refresh rule missed forever when logged out: the main account is always a candidate but is filtered out before any cache entry exists, so every poll re-entered the resolver. Needs a bounded negative memo for absent credentials. - wp3's drain was not actually bounded. The async icacls timer kills the child and still awaits proc.exited, and the draft's snapshot fallback is impossible because oversized residents are excluded from snapshots. - wp2's diagnostic had no transport: /api/models is a bare array the GUI and ocx export both depend on. Split to wp4 with /api/providers as the home. Also corrected an over-claim: 372000 in the snapshot does not feed NATIVE_GPT56_CONTEXT_WINDOW, which is independently 272000 and overrides it, so leaving the snapshot stale is behaviourally safe. Docs only. * docs(devlog): collapse wp1 and bound wp3 after a second FAIL audit Round 2 closed two blockers and kept two open. Both remaining ones were real. wp1's model-scoped absence rule is not implementable inside a symptom fix. The answering client_version is recorded on the cache entry but discarded when the snapshot is built, and the three projections are positive-only: a third boolean term either narrows redundantly or widens into granting a model upstream never gave. Unknown has no slot to occupy. wp1 is now Change 1 plus the account-scoped empty-roster fix only; the tri-state contract becomes wp5. The round-1 draft also asserted that gpt-5.5 survives over-denial, but gpt-5.5 is not in ACCOUNT_GATED_NATIVE_OPENAI_MODELS, so it was never at risk and the test was vacuous. Withdrawn with 2b. wp3's cap-expiry fallback was outside its own cap: the synchronous writer hardens directory and temp as separate calls and each resolves its own 30s budget, documented at ~90s worst case. A 5s cap followed by a 60s fallback is not a bound. wp3 now requires one end-to-end budget, remaining-budget plumbing, and explicit supersession so a late writer cannot overwrite the fallback. Three regressions the first list omitted are added, and the split condition is now abandon-and-file rather than hang. wp4 dropped an unreachable state: wp1 makes every empty roster unconfirmed, and without a completeness marker the system cannot honestly claim an account owns nothing. Docs only. * docs(devlog): clear wp1 and correct a wrong baseline in wp3 Round 3 closed blocker 1 and positively traced the reduced wp1 to a fix for #3022: with tier 3 raised to the measured 0.144.0, a fresh install with no runtime file and no inbound version queries upstream under a version that returns the gated rows, and catalog projection retains them. Two corrections. wp3 had two requirements that cancel: entering the fallback at cap expiry while also giving the fallback the remaining budget leaves it zero time when the drain spends the deadline. The budget is now split up front with a reserved fallback slice sized for two separate harden calls. More seriously, wp3 claimed abandoning an outstanding job equals today's behaviour. It does not. On dev, oversized candidates are published synchronously before the request returns, so dev has no shutdown-loss window for that case. Abandonment matches PR #3018's head instead, which is the state that introduced the loss. Measuring a regression against an unmerged PR rather than dev is how a regression gets waved through. The split condition is withdrawn: wp3 lands the bounded fallback or #3018 stays unmerged, since dev is correct on durability and only slow on Windows. wp4 gained a prerequisite: parsed-empty and network failure produce the identical cache entry today, so the diagnostic cannot honestly name them separately until failure provenance is recorded. Docs only. * docs(devlog): record the wp0 roadmap receipt and what the audits changed Verification ran on lidge, not locally: privacy scan and typecheck exit 0, and repo-hygiene passes 12/12. That file is the focused check that actually covers a devlog change, so it is the right narrow gate for a docs-only phase. Also records the diff between the first draft and the landed roadmap, which is the real output of this phase: wp1 shrank after the audit showed it would apply model-scoped doubt as account-wide denial, wp3 inverted from review-and-merge to land-a-drain-then-merge, two work phases were born from blockers, and three vacuous or impossible test plans were caught before any code was written. * fix(codex): restore GPT-5.6 for entitled accounts by raising the gated client-version floor (#3022) 2.36.0 removed gpt-5.6 sol/terra/luna from ChatGPT Plus accounts that own them; 2.35.0 shows them. Two independent defects, both in src/codex/model-entitlements.ts. The client-version floor used for background discovery is derived from the bundled snapshot, which records 0.142.2 for the gated rows. Upstream answers 0.142.2 with 200 and five models, none of them gpt-5.6; 0.144.0 and above return them. So the question we asked had an honest answer of "no gpt-5.6", and the fail-closed gate read that absence as a confirmed denial. The floor is now the highest of the derived value, an independently measured minimum of 0.144.0, and the existing fallback. Composed rather than hardcoded so a future snapshot recording a newer requirement takes over and the constant goes inert. Separately, an empty roster was treated as a confirmation. `models` is a Set and an empty Set is truthy, so `{"models":[]}` earned confirmed:true and the five-minute success TTL. That is absence of evidence recorded as evidence of absence, held for twenty times longer than a failure. A roster with no usable rows is now unconfirmed on the 15s failure TTL. Non-empty rosters are unchanged. The 15s TTL is demand-driven, not timer-driven: refetch happens only through /v1/models, Direct gated authorization, catalog sync and convergence, requests for one account and version coalesce onto a single flight, and distinct versions are capped at four concurrent per account. Dashboard polling does not reach this path today. Verification: eight regressions, each driven red against the unfixed source and green after. One existing assertion intentionally flips — tests/codex-model-entitlements.test.ts previously asserted an all-filtered roster was confirmed. The existing no-inbound test mocked upstream at minor >= 142, which is precisely why the suite never caught this; its threshold moves to >= 144. Refs #3022 #2886 --------- Co-authored-by: lidge-jun <[email protected]>
1 parent 7666f7d commit 4bdc0f6

17 files changed

Lines changed: 1849 additions & 12 deletions
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# 260831 — priority-70+ train: entitlement floor, roster TTL, Windows spill drain
2+
3+
Frozen scope taken at 2026-08-31T01:1x KST from the open bug backlog. Three
4+
targets, dependency-ordered. Each implementation phase consumes exactly one
5+
decade doc as one full PABCD cycle.
6+
7+
| wp | target | doc | priority |
8+
| --- | --- | --- | --- |
9+
| wp0 | this roadmap | `000`-`009` | — |
10+
| wp1 | #3022 entitlement client_version floor + empty-vs-negative roster | `010` | 78/80 |
11+
| wp2 | #3023 roster TTL expiry drops entitled rows | `020` | 71/80 |
12+
| wp3 | #3011 Windows ACL spill stall (PR #3018 audit) | `030` | 71/80 |
13+
14+
## Why this order
15+
16+
wp1 is the stack base: it changes what `resolveCodexModelEntitlements` records
17+
for an account. wp2 changes *when* the management surfaces re-read that record.
18+
Landing wp2 first would leave the shared entry point refreshing a value that is
19+
still wrong, so the fix would look effective on a warm cache and fail on a cold
20+
one.
21+
22+
wp3 is independent of both — it touches `src/responses/spill-store.ts` and
23+
`src/responses/state.ts`, no catalog code — so it does not stack on wp1/wp2 and
24+
can land in parallel.
25+
26+
## Evidence provenance
27+
28+
Three read-only `gpt-5.6-sol` high-effort research lanes were dispatched at wp0.
29+
Their file:line findings are recorded in `001`-`003`. Every claim below that is
30+
load-bearing was re-verified directly in the tree by the main session before
31+
being written here.
32+
33+
## Verification constraint (user-imposed)
34+
35+
Local full test suites are forbidden for this train. Focused
36+
`bun test <file>` runs locally; every suite, typecheck, and privacy scan runs on
37+
`ssh lidge` (Linux x86_64, bun + git + gh present). Every completion claim
38+
carries a receipt: command, exit code, pass/fail counts. Each regression test is
39+
driven red against pre-fix code and that red result recorded.
40+
41+
## Delivery
42+
43+
Stacked PRs per `DEV-STACK-01`, pushed `--no-verify` (the pre-push hook runs the
44+
forbidden local suite). Merge into `dev` is authorized for this goal.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# 001 — #3022: the entitlement client_version floor is below what upstream honours
2+
3+
Verified against `origin/dev` `870a2adb6` (package 2.37.0).
4+
5+
## The two defects
6+
7+
This issue is two defects wearing one symptom. Fixing either alone leaves the
8+
other able to reproduce it.
9+
10+
### Defect A — the derived floor is wrong
11+
12+
`resolveCodexEntitlementClientVersion` has three tiers
13+
(`src/codex/model-entitlements.ts:122`): inbound request version, persisted
14+
runtime `selectedVersion`, then `GATED_MODEL_CLIENT_VERSION_FLOOR`.
15+
16+
Tier 3 is derived from the bundled snapshot, not hardcoded
17+
(`src/codex/model-entitlements.ts:59`, `:81`, `:83`):
18+
19+
```
20+
GATED_MODEL_CLIENT_VERSION_FLOOR = deriveGatedClientVersionFloor(snapshot) ?? FALLBACK
21+
```
22+
23+
Measured in-tree:
24+
25+
```
26+
GATED_MODEL_CLIENT_VERSION_FLOOR -> 0.142.2
27+
28+
src/codex/data/upstream-models.json
29+
gpt-5.6-sol minimal_client_version = 0.142.2 context_window = 372000
30+
gpt-5.6-terra minimal_client_version = 0.142.2 context_window = 372000
31+
gpt-5.6-luna minimal_client_version = 0.142.2 context_window = 372000
32+
```
33+
34+
**The repository already contains a live measurement that contradicts its own
35+
snapshot.** `devlog/_fin/260817_native_gpt56_1m_context/001_measurement_evidence.md`
36+
records `GET /backend-api/codex/models?client_version=<v>` against a real Codex
37+
login:
38+
39+
| client_version | rows returned |
40+
| --- | --- |
41+
| 0.60.0 | 0 |
42+
| 0.142.2 | 5 — **no gpt-5.6** |
43+
| >= 0.144.0 | 8 — includes sol/terra/luna |
44+
45+
and records the live rows as `minimal_client_version = 0.144.0`,
46+
`context_window = 272000`. The reporter measurement on #2886 (0.142.2 -> 200
47+
without gpt-5.6; 0.144.0 / 0.146.0 -> 200 with) independently reproduces this on
48+
a different account and machine.
49+
50+
So the snapshot's `0.142.2` and `372000` are both stale — they are PR #31684-era
51+
values. Deriving the floor from that file faithfully produces a version upstream
52+
does not honour, and tier 3 recreates the very defect #2891 set out to fix.
53+
54+
**Raising `GATED_MODEL_CLIENT_VERSION_FLOOR_FALLBACK` fixes nothing.** The
55+
expression is `derived ?? fallback`; derivation succeeds, so the fallback is
56+
unreachable (`src/codex/model-entitlements.ts:83`). Confirmed by reading the
57+
code, not assumed.
58+
59+
### Defect B — an empty roster is recorded as a confirmed negative
60+
61+
`parseAccountModels` returns a `Set` for any payload whose `models` is an array
62+
(`src/codex/model-entitlements.ts:374`). `{"models":[]}` therefore yields an
63+
**empty but non-null** `Set`. Rows filtered for `visibility === "hide"` or
64+
`supported_in_api !== true` can empty it the same way.
65+
66+
`fetchAccountModels` then converts non-null into confirmation
67+
(`src/codex/model-entitlements.ts:414`, `:420`):
68+
69+
```ts
70+
expiresAt: now + (models ? MODEL_ROSTER_TTL_MS : MODEL_ROSTER_FAILURE_TTL_MS),
71+
models: models ?? new Set(),
72+
confirmed: models !== null,
73+
```
74+
75+
An empty `Set` is truthy, so the account is marked `confirmed` **and** gets the
76+
five-minute success TTL instead of the fifteen-second failure TTL. Downstream,
77+
the account enters `confirmedAccountIds` with a set that lacks the gated slugs,
78+
and every projection reads that omission as a decided denial
79+
(`:547`, `:573`). Catalog sync then strips the gated bare and selector rows
80+
(`src/codex/catalog/sync.ts:1579`, `:1616`) and runtime auth excludes the account
81+
(`src/codex/auth-context.ts:458`).
82+
83+
**`models.size > 0` is not a sufficient guard.** The reported short roster
84+
contains `gpt-5.5`, so the set is non-empty while every gated row is absent. The
85+
distinction that matters is whether the roster was obtained under a version
86+
capable of returning the gated rows at all.
87+
88+
## Why it reaches users
89+
90+
Tier 1 and tier 2 mask the defect. It surfaces on the path with neither: a
91+
background catalog sync or convergence pass with no inbound request
92+
(`src/codex/catalog/sync.ts:1834`, `src/codex/convergence.ts:409`) on a host
93+
where no Codex runtime was ever resolved, so `codex-runtime.json` carries no
94+
`selectedVersion`. That matches the #2886 reporter's clean-reinstall reproduction
95+
on a machine with no `codex` CLI.
96+
97+
## Fix surface
98+
99+
`src/codex/model-entitlements.ts`, and the snapshot only if its stale metadata is
100+
corrected as a separate concern.
101+
102+
1. Tier 3 must not be a bare snapshot derivation. Take
103+
`max(derived, independently-measured minimum)` so a stale snapshot can lower
104+
documentation but never lower the question we ask upstream. The numeric
105+
comparator at `:88` already supports this.
106+
2. An empty usable roster must be unconfirmed and take the failure TTL.
107+
3. A roster fetched under a version below the trustworthy minimum must not make
108+
omission authoritative for gated slugs.
109+
110+
## Must not change
111+
112+
- The fail-closed posture itself (#2550). Unknown stays ineligible; this unit
113+
makes *unknown* distinguishable from *denied*, it does not admit unknown.
114+
- Per-account and per-version cache keys (`:269`) — collapsing them reintroduces
115+
cross-version evidence leakage.
116+
- Inbound/runtime precedence. Hardcoding every request to one version would
117+
advertise models to genuinely older clients (`:100`).
118+
119+
## Open question carried forward
120+
121+
The roster contract has no completeness marker and no per-model denial field, so
122+
omission is the only signal available pre-dispatch. Whether `0.144.0` is stable
123+
across all accounts is unproven: both measurements used one credential each,
124+
though they were different credentials on different machines and agreed.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# 002 — #3023: expired roster silently shortens every management model surface
2+
3+
Verified against `origin/dev` `870a2adb6`.
4+
5+
## Mechanism
6+
7+
`listManagementModelRows` builds native rows through `nativeModelRows(config)`
8+
(`src/server/management/model-rows.ts:50`). A gated slug is included only when
9+
`cachedAvailableAccountGatedNativeModels(Date.now(), ...)` returns it
10+
(`src/codex/catalog/metadata.ts:414`). That projection is **synchronous** and
11+
requires a confirmed entry with `expiresAt > now`
12+
(`src/codex/model-entitlements.ts:596`).
13+
14+
So a never-fetched roster and an *expired* roster project identically: empty.
15+
16+
`listManagementModelRows` calls only `fetchAllModels`
17+
(`src/server/management/shared.ts:173`), which gathers routed providers and never
18+
resolves Codex entitlements. `/v1/models` differs — it runs `fetchAllModels` and
19+
`resolveCodexModelEntitlements` together (`src/server/index.ts:1143`) — which is
20+
exactly why one `GET /v1/models` repairs all three surfaces.
21+
22+
## The three surfaces are not identical
23+
24+
The reporter treated them as one path; they are three paths over one entry point:
25+
26+
- `/api/models` calls `listManagementModelRows` directly
27+
(`src/server/management/model-routes.ts:352`).
28+
- `/api/client-config` goes through `loadExportModels`
29+
(`:393`, `src/server/management/model-rows.ts:164`).
30+
- `ocx export` does **not** use `loadExportModels`. It requests `/api/models`
31+
over HTTP and serializes the rows itself
32+
(`src/cli/export-command.ts:169`).
33+
34+
That third detail matters for the test plan: a fixture that stubs rows instead of
35+
going through the real management handler cannot see this defect.
36+
37+
## Why an unconditional refresh is not acceptable
38+
39+
The dashboard polls `/api/sidecar-settings` every 5 seconds
40+
(`gui/src/pages/use-dashboard-data.ts:237`), and that route computes vision and
41+
web-search candidates independently
42+
(`src/server/management/config-routes.ts:589`), so each tick reaches the shared
43+
list **twice**. The Models page adds `/api/models` every 10 seconds
44+
(`gui/src/pages/Models.tsx:452`).
45+
46+
That is ~24 shared-list calls/minute with the dashboard open, ~30 with the Models
47+
catalog active. Polls pause while the document is hidden
48+
(`gui/src/client-resource.ts:538`). An unconditional `resolveCodexModelEntitlements`
49+
at the shared entry point would put credential enumeration on that cadence.
50+
51+
## Fix surface
52+
53+
Add a cheap ensure/freshness operation in `src/codex/model-entitlements.ts` and
54+
await it from `listManagementModelRows` before `nativeModelRows`, in parallel with
55+
`fetchAllModels` — the shape `/v1/models` already uses
56+
(`src/server/index.ts:1155`). It must:
57+
58+
- treat confirmed-empty and the 15-second unconfirmed entry as *cached answers*,
59+
not as cache misses;
60+
- preserve per-account/version keys and in-flight deduplication
61+
(`:223`, `:455`) so concurrent pollers collapse into one fetch;
62+
- never refresh from inside the synchronous `nativeModelRows`.
63+
64+
## Must not change
65+
66+
- The expiry check itself. Serving expired grants while refreshing would stop the
67+
visual disappearance but break fail-closed revocation (`:509`).
68+
- `/v1/models` authorization or version behaviour.
69+
- Failure must stay a bounded fail-closed roster result, not an exception: a throw
70+
from the shared entry would degrade sidecar candidates and could turn
71+
client-config into a 503 (`src/sidecar/candidates.ts:29`).
72+
73+
## The dishonest status is a separate, additive change
74+
75+
`discovery: {"status":"ok"}` comes from routed-provider discovery
76+
(`src/codex/catalog/provider-fetch.ts:1510`, `src/codex/model-cache.ts:94`), not
77+
from entitlements, which never write it. So "ok" is *true* for what it describes.
78+
Overloading it would erase a simultaneously-correct routed result. The honest fix
79+
is an additive entitlement diagnostic; GUI types currently admit only provider
80+
discovery states (`gui/src/models-groups.ts:2`).
81+
82+
## Test plan
83+
84+
- `tests/codex-model-entitlements.test.ts` — repeated fresh ensure calls do zero
85+
refetches; at TTL+1 concurrent callers produce exactly one; failed refresh stays
86+
unconfirmed with no retry for 15s.
87+
- `tests/native-model-toggle.test.ts` — expired confirmed roster, then
88+
`/api/models` still lists sol/terra/luna. Red today.
89+
- `tests/management-client-config-route.test.ts` — same fixture, OpenCode map
90+
contains the GPT-5.6 entries, entitlement fetch count is 1.
91+
- `tests/cli-export-command.test.ts` — point its fake proxy at the real
92+
`/api/models` handler; its current stubbed rows bypass the defective boundary.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# 003 — #3011 / PR #3018 audit: correct fix, one shutdown blocker
2+
3+
PR #3018, branch `ingw/fix-3011-async-acl-spill`, exact head `aec717722`,
4+
rebased onto `870a2adb6` by this train. Repository CI green, 0 failures.
5+
6+
## Verdict: the fix is right, and it is not yet mergeable
7+
8+
CI-green is not correctness evidence here, because the gap is in a path no test
9+
exercises.
10+
11+
### What the PR gets right
12+
13+
It genuinely removes the ACL subprocess wait from the response event loop. On
14+
`dev`, `writeResponseSpillDurably` calls synchronous `harden()`
15+
(`src/responses/spill-store.ts:180`, `:324`) which runs `Bun.spawnSync()`
16+
(`src/lib/windows-secret-acl.ts:307`). `/healthz` shares that Bun fetch handler
17+
(`src/server/index.ts:884`), so it cannot run during the wait — that is the 47s
18+
stall.
19+
20+
The PR queues Windows publications on a serialized promise tail
21+
(`aec717722:src/responses/state.ts:280-308`) and awaits
22+
`hardenSecretDirAsync`/`hardenSecretPathAsync`, which use `Bun.spawn()` plus
23+
`await proc.exited` (`src/lib/windows-secret-acl.ts:329`).
24+
25+
Linux and macOS are genuinely untouched: all three async routing points are gated
26+
on `windowsSecretAclApplies()`, and false continues to the existing synchronous
27+
`writeResponseSpillDurably` (`aec717722:src/responses/state.ts:547`, `:575`,
28+
`:1250`).
29+
30+
No Lab import is introduced, and no Node-only API — `Bun.spawn` is Bun-native.
31+
32+
### Blocker — graceful shutdown does not drain pending publications
33+
34+
`responseSpillPublicationTail` is awaited in exactly one place, and it is marked
35+
test-only:
36+
37+
```
38+
state.ts:187 let responseSpillPublicationTail: Promise<void> = Promise.resolve();
39+
state.ts:306 responseSpillPublicationTail = responseSpillPublicationTail.then(...)
40+
state.ts:328 await responseSpillPublicationTail; <- flushPendingResponseSpillsForTests
41+
```
42+
43+
`flushResponseState()` — the function shutdown actually calls
44+
(`src/server/lifecycle.ts:492`) — awaits only `persistGate` and the snapshot
45+
write. It never observes the publication tail. Verified by reading the function
46+
body at the PR head.
47+
48+
The loss is concrete because oversized residents are deliberately excluded from
49+
the snapshot (`aec717722:src/responses/state.ts:1015`):
50+
51+
```ts
52+
if (state.kind === "resident" && size > SNAPSHOT_ENTRY_MAX_BYTES) continue;
53+
```
54+
55+
with `SNAPSHOT_ENTRY_MAX_BYTES = 2 * 1024 * 1024` (`:35`).
56+
57+
So: a request queues a Windows spill for a payload over 2 MiB and returns while
58+
`icacls` is still in flight. Shutdown flushes the snapshot, which *skips* that
59+
resident because it is oversized, and the spill stub that would have replaced it
60+
is not installed yet. The stop paths then call `process.exit()`
61+
(`src/server/lifecycle.ts:489`, `src/server/management-api.ts:278`,
62+
`src/cli/index.ts:365`), which also bypasses the writer's temp cleanup
63+
(`aec717722:src/responses/spill-store.ts:467-505`). The continuation is lost and a
64+
temp file can be orphaned.
65+
66+
Before the PR this race did not exist: publication was synchronous, so by the time
67+
the request returned the stub was already installed.
68+
69+
### Required remediation
70+
71+
Drain the publication tail to a **stable fixed point** before writing the shutdown
72+
snapshot: repeatedly capture and await the tail until the captured promise still
73+
equals the current one. A single `await` is insufficient because a settling job can
74+
append another (`:306`).
75+
76+
Surface: `src/responses/state.ts` (production drain + call it from
77+
`flushResponseState` before snapshot serialization), `tests/responses-state.test.ts`,
78+
and a note in `structure/02_config-and-codex-home.md`, whose current text describes
79+
queueing but not shutdown ordering. `src/server/lifecycle.ts` needs no change — it
80+
already calls `flushResponseState()` at the right boundary.
81+
82+
## Coverage gaps in the PR's own tests
83+
84+
The three added tests are real regressions — two wait on an injected async runner
85+
the old synchronous path never enters (`aec717722:tests/responses-state.test.ts:720-818`).
86+
They cover yielding, timeout recovery, and same-id supersession. They do not cover:
87+
ordinary (non-timeout) ACL failure, cross-id serialization, shutdown, or
88+
copy-fallback cleanup.
89+
90+
## Security check
91+
92+
Required-mode ACL failure appears to fail closed: the required helpers throw
93+
(`src/lib/windows-secret-acl.ts:872`) and the state catch replaces the entry with a
94+
failure marker (`aec717722:src/responses/state.ts:261`). Not covered by a test,
95+
which is why the plan adds one.
96+
97+
Residual, unresolved without a real Windows host: if ACL hardening fails *and*
98+
unlink also fails, cleanup is best-effort
99+
(`aec717722:src/responses/spill-store.ts:310`, `:498`) and a full payload can remain
100+
on disk. Whether another local user can read it depends on the resulting NTFS ACL.
101+
Recorded as a follow-up, not a blocker for this unit — it predates the PR.
102+
103+
## Disposition
104+
105+
wp3 is not "merge #3018". It is: land the drain fix on top of the PR head, prove it
106+
with the shutdown regression, then merge. The author's work is correct as far as it
107+
goes; the missing piece is the boundary his change created.

0 commit comments

Comments
 (0)