Skip to content

Commit e7df217

Browse files
committed
fix(server): route the startup cache-invalidation flag through a setter
CI typecheck caught what the worktree's partial check could not: the facade still assigned `startupCacheInvalidationWrote` at two points, but that flag moved into the startup-warnings leaf with its reader. An ES import binding is read-only, so the assignment no longer compiles across the module boundary. The flag stays next to `consumeStartupCacheInvalidationWrite`, which is the only thing that reads and clears it, and the composition root now calls `setStartupCacheInvalidationWrite`. Keeping the flag and its reader in one module is the point: splitting them would let a future edit reset one without the other. The startup-warnings import collapsed to a single line, matching the re-export lines already in this file, which keeps the facade at 893 lines. The ratchet only lowers caps, so the cap is 893 rather than the 898 recorded a commit ago.
1 parent eabe985 commit e7df217

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

‎src/server/index.ts‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,7 @@ import {
204204
} from "../lib/package-tree-integrity";
205205
import { detectInstall } from "../update/index";
206206
import { createServeOptions, type ServerIngress } from "./index/serve-options";
207-
import {
208-
inspectStartupOwnership,
209-
warnAgentTaskRecoveryStartup,
210-
warnPlaintextV2AgentMessagesStartup,
211-
type StartServerDeps,
212-
} from "./index/startup-warnings";
207+
import { inspectStartupOwnership, setStartupCacheInvalidationWrite, warnAgentTaskRecoveryStartup, warnPlaintextV2AgentMessagesStartup, type StartServerDeps } from "./index/startup-warnings";
213208

214209
export function startServer(port?: number, deps: StartServerDeps = {}): Server<WsData> {
215210
const localAttestationSecret = deps.localAttestationSecret ?? createLocalAttestationSecret();
@@ -252,7 +247,7 @@ export function startServer(port?: number, deps: StartServerDeps = {}): Server<W
252247
// Resolve unattended service-home authority before any Codex lock, cache, owner,
253248
// journal, or credential path. Both positive foreign evidence and an unprovable
254249
// ownership state are non-authority.
255-
startupCacheInvalidationWrote = false;
250+
setStartupCacheInvalidationWrite(false);
256251
const resolveServiceHomes = deps.resolveServiceHomes ?? currentServiceHomes;
257252
let startupOwnershipHomes: ReturnType<typeof currentServiceHomes> | null = null;
258253
let startupOwnershipStatePaths: readonly string[] | null = null;
@@ -286,7 +281,7 @@ export function startServer(port?: number, deps: StartServerDeps = {}): Server<W
286281
const outcome = withCatalogWriteSerialization(startupCodexHome, permit =>
287282
invalidateCodexModelsCacheWithPermit(permit, startupCodexHome));
288283
// A refused permit is not a write; only a completed run that returned true is.
289-
startupCacheInvalidationWrote = outcome.kind === "completed" && outcome.value === true;
284+
setStartupCacheInvalidationWrite(outcome.kind === "completed" && outcome.value === true);
290285
} catch { /* no readable Codex home: nothing to invalidate */ }
291286
}
292287
// Arm the `claudeCode` hand-edit guard (devlog 260726_claude_auth_auto/040 H1) BEFORE

‎src/server/index/startup-warnings.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,19 @@ export function inspectStartupOwnership(
177177
* deliberately gets no warning — lifecycle diagnostics belong to whoever owns
178178
* the lifecycle.
179179
*/
180-
export let startupCacheInvalidationWrote = false;
180+
let startupCacheInvalidationWrote = false;
181181

182182
/** #1046: did this process's startup cache invalidation actually write? */
183+
/**
184+
* The composition root owns WHEN the startup cache invalidation runs, but the flag lives here
185+
* with its reader. An ES import binding is read-only, so the root cannot assign to it across
186+
* the module boundary the way it did when both sides were one file. This setter is that
187+
* assignment, kept next to the reader so the two cannot drift apart.
188+
*/
189+
export function setStartupCacheInvalidationWrite(wrote: boolean): void {
190+
startupCacheInvalidationWrote = wrote;
191+
}
192+
183193
export function consumeStartupCacheInvalidationWrite(): boolean {
184194
const wrote = startupCacheInvalidationWrote;
185195
startupCacheInvalidationWrote = false;

‎tests/fixtures/file-size-baseline.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"src/codex/catalog/provider-fetch.ts": 54,
2525
"src/config.ts": 460,
2626
"src/providers/registry.ts": 232,
27-
"src/server/index.ts": 898,
27+
"src/server/index.ts": 893,
2828
"src/server/responses/core.ts": 9386,
2929
"tests/ci-workflows/ci-workflows.test.ts": 5628,
3030
"tests/cli/cli-account.test.ts": 2313,

0 commit comments

Comments
 (0)