codex-multi-auth 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +9 -0
- package/README.md +4 -2
- package/dist/lib/auth/device-auth.d.ts.map +1 -1
- package/dist/lib/auth/device-auth.js +15 -0
- package/dist/lib/auth/device-auth.js.map +1 -1
- package/dist/lib/auth/server.d.ts.map +1 -1
- package/dist/lib/auth/server.js +12 -7
- package/dist/lib/auth/server.js.map +1 -1
- package/dist/lib/capability-policy.d.ts.map +1 -1
- package/dist/lib/capability-policy.js +5 -0
- package/dist/lib/capability-policy.js.map +1 -1
- package/dist/lib/codex-cli/state.d.ts.map +1 -1
- package/dist/lib/codex-cli/state.js +28 -7
- package/dist/lib/codex-cli/state.js.map +1 -1
- package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/best.js +2 -2
- package/dist/lib/codex-manager/commands/best.js.map +1 -1
- package/dist/lib/codex-manager/commands/budget.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/budget.js +6 -0
- package/dist/lib/codex-manager/commands/budget.js.map +1 -1
- package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/forecast.js +9 -7
- package/dist/lib/codex-manager/commands/forecast.js.map +1 -1
- package/dist/lib/codex-manager/commands/integrations.js +2 -2
- package/dist/lib/codex-manager/commands/integrations.js.map +1 -1
- package/dist/lib/codex-manager/commands/models.js +3 -3
- package/dist/lib/codex-manager/commands/models.js.map +1 -1
- package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.js +9 -7
- package/dist/lib/codex-manager/commands/report.js.map +1 -1
- package/dist/lib/codex-manager/commands/workspace.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/workspace.js +12 -1
- package/dist/lib/codex-manager/commands/workspace.js.map +1 -1
- package/dist/lib/codex-manager/forecast-report-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-commands.js +11 -10
- package/dist/lib/codex-manager/forecast-report-commands.js.map +1 -1
- package/dist/lib/codex-manager/help.d.ts.map +1 -1
- package/dist/lib/codex-manager/help.js +7 -5
- package/dist/lib/codex-manager/help.js.map +1 -1
- package/dist/lib/codex-manager/repair-commands.js +7 -7
- package/dist/lib/codex-manager/repair-commands.js.map +1 -1
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +72 -32
- package/dist/lib/codex-manager.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +217 -13
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/forecast.d.ts +1 -0
- package/dist/lib/forecast.d.ts.map +1 -1
- package/dist/lib/forecast.js +47 -3
- package/dist/lib/forecast.js.map +1 -1
- package/dist/lib/integration-generators.d.ts.map +1 -1
- package/dist/lib/integration-generators.js +1 -1
- package/dist/lib/integration-generators.js.map +1 -1
- package/dist/lib/local-client-tokens.d.ts.map +1 -1
- package/dist/lib/local-client-tokens.js +117 -64
- package/dist/lib/local-client-tokens.js.map +1 -1
- package/dist/lib/model-capability-matrix.d.ts.map +1 -1
- package/dist/lib/model-capability-matrix.js +13 -10
- package/dist/lib/model-capability-matrix.js.map +1 -1
- package/dist/lib/policy/runtime-policy.d.ts.map +1 -1
- package/dist/lib/policy/runtime-policy.js +8 -0
- package/dist/lib/policy/runtime-policy.js.map +1 -1
- package/dist/lib/prompts/codex.d.ts +1 -1
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +4 -4
- package/dist/lib/prompts/codex.js.map +1 -1
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +16 -1
- package/dist/lib/quota-cache.js.map +1 -1
- package/dist/lib/quota-probe.d.ts.map +1 -1
- package/dist/lib/quota-probe.js +2 -1
- package/dist/lib/quota-probe.js.map +1 -1
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +3 -0
- package/dist/lib/request/fetch-helpers.js.map +1 -1
- package/dist/lib/request/helpers/model-map.d.ts +1 -0
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
- package/dist/lib/request/helpers/model-map.js +10 -0
- package/dist/lib/request/helpers/model-map.js.map +1 -1
- package/dist/lib/routing-mutex.d.ts +12 -0
- package/dist/lib/routing-mutex.d.ts.map +1 -1
- package/dist/lib/routing-mutex.js +38 -1
- package/dist/lib/routing-mutex.js.map +1 -1
- package/dist/lib/runtime/quota-probe.d.ts.map +1 -1
- package/dist/lib/runtime/quota-probe.js +2 -5
- package/dist/lib/runtime/quota-probe.js.map +1 -1
- package/dist/lib/runtime/runtime-observability.d.ts +9 -0
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +28 -0
- package/dist/lib/runtime/runtime-observability.js.map +1 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +23 -1
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +135 -12
- package/dist/lib/runtime-rotation-proxy.js.map +1 -1
- package/dist/lib/storage/account-persistence.d.ts.map +1 -1
- package/dist/lib/storage/account-persistence.js +11 -1
- package/dist/lib/storage/account-persistence.js.map +1 -1
- package/dist/lib/storage/record-utils.d.ts.map +1 -1
- package/dist/lib/storage/record-utils.js +6 -1
- package/dist/lib/storage/record-utils.js.map +1 -1
- package/dist/lib/storage/transactions.d.ts +8 -0
- package/dist/lib/storage/transactions.d.ts.map +1 -1
- package/dist/lib/storage/transactions.js +14 -1
- package/dist/lib/storage/transactions.js.map +1 -1
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +46 -9
- package/dist/lib/storage.js.map +1 -1
- package/package.json +4 -3
- package/scripts/codex-bin-resolver.js +28 -1
- package/scripts/mcodex.js +367 -0
- package/scripts/mcodex +0 -117
|
@@ -1 +1 @@
|
|
|
1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CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YACjE,OAAO,QAAQ,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC;QACpD,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yCAAyC;IAC9D,MAAM,IAAI,GAAG,eAAe,EAAE,CAAC;IAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAiD,CAAC;QAC/E,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAED,MAAM,UAAU,yCAAyC;IACxD,aAAa,GAAG,qBAAqB,EAAE,CAAC;IACxC,YAAY,GAAG,IAAI,CAAC;AACrB,CAAC"}
|
|
@@ -40,7 +40,11 @@ export interface StorageMeta {
|
|
|
40
40
|
affinityGeneration: number;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Cheap, hot-path-safe single read with mtime-cache short-circuit.
|
|
43
|
+
* Cheap, hot-path-safe single read with mtime-cache short-circuit. When the
|
|
44
|
+
* file's `mtimeMs` and `size` match the cached snapshot for this path we
|
|
45
|
+
* return the cached value WITHOUT reading or hashing the file. Only when
|
|
46
|
+
* mtime/size differ (or were never cached) do we `readFileSync` + sha1 and,
|
|
47
|
+
* if the content hash still matches, skip the `JSON.parse`. Transient
|
|
44
48
|
* failures (EBUSY/EPERM/EACCES/EAGAIN, partial-write SyntaxError) fall through
|
|
45
49
|
* to the last cached value for this path; defaults are only returned when the
|
|
46
50
|
* file has never been successfully read.
|
|
@@ -70,6 +74,24 @@ export declare function resetPinCacheForTesting(): void;
|
|
|
70
74
|
*/
|
|
71
75
|
export declare function maybeInvalidateAffinityFromDisk(sessionAffinityStore: SessionAffinityStore | null, lastObservedGeneration: number, storagePath?: string): number;
|
|
72
76
|
export declare function buildTokenInvalidationBody(upstreamBodyText: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* `chooseAccount` is a SYNC selector that internally advances the rotation
|
|
79
|
+
* cursor (the session-affinity-preferred branch and the round-robin fallback
|
|
80
|
+
* both call `accountManager.markSwitched(...)`, and the hybrid selector advances
|
|
81
|
+
* its own cursor). It does NOT acquire the routing mutex itself.
|
|
82
|
+
*
|
|
83
|
+
* Concurrency (L4): when `routingMutex === "enabled"`, the proxy hot path runs
|
|
84
|
+
* this whole call AND the subsequent `markSwitchedLocked` commit inside a single
|
|
85
|
+
* `withRoutingMutex` acquisition, so concurrent requests serialize selection +
|
|
86
|
+
* cursor advance and cannot stampede the same account. `withRoutingMutex` is
|
|
87
|
+
* reentrant (AsyncLocalStorage), so the nested `markSwitchedLocked` — and the
|
|
88
|
+
* later one in `persistRuntimeActiveAccount` — run inline without re-acquiring
|
|
89
|
+
* the non-reentrant FIFO queue (no deadlock). In legacy mode the inline
|
|
90
|
+
* `markSwitched` calls below are used unchanged and no lock is taken, so default
|
|
91
|
+
* behavior and perf are identical. See the hot-path caller in
|
|
92
|
+
* `startRuntimeRotationProxy` and the regression in
|
|
93
|
+
* `test/runtime-rotation-proxy.test.ts`.
|
|
94
|
+
*/
|
|
73
95
|
export declare function chooseAccount(params: {
|
|
74
96
|
accountManager: AccountManager;
|
|
75
97
|
sessionAffinityStore: SessionAffinityStore | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-rotation-proxy.d.ts","sourceRoot":"","sources":["../../lib/runtime-rotation-proxy.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,cAAc,EAEd,KAAK,cAAc,EACnB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"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EAAE,MAAM,CAAC,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,cAAc,GAAG,IAAI,CA0HxB;AAgED;;;;;;GAMG;AACH,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,kCAAkC,CAAC;IACzC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED,wBAAgB,+BAA+B,CAC9C,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7C,0BAA0B,CAqB5B;AA0ED,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,0BAA0B,CAAC,CAw4BrC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
4
|
import { AccountManager, extractAccountId, } from "./accounts.js";
|
|
5
|
+
import { withRoutingMutex } from "./routing-mutex.js";
|
|
5
6
|
import { getStoragePath } from "./storage.js";
|
|
6
7
|
import { getFetchTimeoutMs, getNetworkErrorCooldownMs, getRetryAllAccountsMaxRetries, getServerErrorCooldownMs, getSessionAffinity, getSessionAffinityMaxEntries, getSessionAffinityTtlMs, getStreamStallTimeoutMs, getMinRotationIntervalMs, getTokenInvalidationCooldownMs, getTokenRefreshSkewMs, getPidOffsetEnabled, getRoutingMutexMode, loadPluginConfig, } from "./config.js";
|
|
7
8
|
import { CODEX_BASE_URL, HTTP_STATUS, OPENAI_HEADERS, OPENAI_HEADER_VALUES, URL_PATHS, } from "./constants.js";
|
|
8
9
|
import { getModelFamily } from "./prompts/codex.js";
|
|
10
|
+
import { CURRENT_CODEX_MODEL } from "./request/helpers/model-map.js";
|
|
9
11
|
import { queuedRefresh } from "./refresh-queue.js";
|
|
10
|
-
import { mutateRuntimeObservabilitySnapshot, recordRuntimePoolExhaustion, recordRuntimeReload, recordRuntimeReset, } from "./runtime/runtime-observability.js";
|
|
12
|
+
import { mutateRuntimeObservabilitySnapshot, recordRuntimeAccountRecovery, recordRuntimePoolExhaustion, recordRuntimeReload, recordRuntimeReset, } from "./runtime/runtime-observability.js";
|
|
11
13
|
import { createRuntimeUsageRecorder, evaluateRuntimePolicy, loadRuntimePolicyState, } from "./policy/runtime-policy.js";
|
|
12
14
|
import { isWorkspaceDisabledError } from "./request/fetch-helpers.js";
|
|
13
15
|
import { createLogger, maskString, runWithCorrelationId } from "./logger.js";
|
|
@@ -203,6 +205,17 @@ function recordLastRuntimeAccount(status, identity) {
|
|
|
203
205
|
// vitest workers (each pointing at their own temp storage file) cannot
|
|
204
206
|
// corrupt each other's snapshots. See issue #474.
|
|
205
207
|
const STORAGE_META_CACHE = new Map();
|
|
208
|
+
// The mtime+size short-circuit (L3) may only be trusted once the cached
|
|
209
|
+
// mtime is far enough in the past that no *subsequent* write could share the
|
|
210
|
+
// same coarse mtime tick. Filesystems report mtime at wildly different
|
|
211
|
+
// granularities (ext4 ns, FAT 2s, some network/Windows volumes ~1s, and CI
|
|
212
|
+
// containers occasionally coarser), and our writers use atomic rename, so two
|
|
213
|
+
// rapid CLI bumps can land on an identical mtimeMs. Within this settle window
|
|
214
|
+
// we therefore ignore mtime equality and fall back to the read + sha1 path
|
|
215
|
+
// (the real source of truth). Outside it, the file has been quiescent long
|
|
216
|
+
// enough that mtime equality provably means "unchanged", so we skip the read.
|
|
217
|
+
// 2s comfortably exceeds the coarsest mtime granularity we expect in practice.
|
|
218
|
+
const MTIME_SHORTCIRCUIT_SETTLE_MS = 2_000;
|
|
206
219
|
function hashStorageBytes(bytes) {
|
|
207
220
|
return createHash("sha1").update(bytes).digest("hex");
|
|
208
221
|
}
|
|
@@ -213,7 +226,11 @@ function metaFromSnapshot(snapshot) {
|
|
|
213
226
|
};
|
|
214
227
|
}
|
|
215
228
|
/**
|
|
216
|
-
* Cheap, hot-path-safe single read with mtime-cache short-circuit.
|
|
229
|
+
* Cheap, hot-path-safe single read with mtime-cache short-circuit. When the
|
|
230
|
+
* file's `mtimeMs` and `size` match the cached snapshot for this path we
|
|
231
|
+
* return the cached value WITHOUT reading or hashing the file. Only when
|
|
232
|
+
* mtime/size differ (or were never cached) do we `readFileSync` + sha1 and,
|
|
233
|
+
* if the content hash still matches, skip the `JSON.parse`. Transient
|
|
217
234
|
* failures (EBUSY/EPERM/EACCES/EAGAIN, partial-write SyntaxError) fall through
|
|
218
235
|
* to the last cached value for this path; defaults are only returned when the
|
|
219
236
|
* file has never been successfully read.
|
|
@@ -229,11 +246,36 @@ export function readStorageMetaFromDisk(storagePath = getStoragePath()) {
|
|
|
229
246
|
return { pinnedAccountIndex: null, affinityGeneration: 0 };
|
|
230
247
|
}
|
|
231
248
|
try {
|
|
249
|
+
// mtime+size short-circuit (L3): when neither has changed since the last
|
|
250
|
+
// successful read AND the cached mtime has settled (see
|
|
251
|
+
// MTIME_SHORTCIRCUIT_SETTLE_MS) we return the cached snapshot without
|
|
252
|
+
// reading or hashing the file. During the settle window we deliberately
|
|
253
|
+
// fall through to the read + sha1 path below, which stays the source of
|
|
254
|
+
// truth and protects against the coarse-mtime collision described on
|
|
255
|
+
// StorageMetaSnapshot. So this is a pure fast path for the common
|
|
256
|
+
// "file quiescent, proxy polling every request" case.
|
|
257
|
+
const stats = statSync(storagePath);
|
|
258
|
+
const cachedByStat = STORAGE_META_CACHE.get(storagePath);
|
|
259
|
+
if (cachedByStat &&
|
|
260
|
+
cachedByStat.mtimeMs === stats.mtimeMs &&
|
|
261
|
+
cachedByStat.size === stats.size &&
|
|
262
|
+
Date.now() - stats.mtimeMs > MTIME_SHORTCIRCUIT_SETTLE_MS) {
|
|
263
|
+
return metaFromSnapshot(cachedByStat);
|
|
264
|
+
}
|
|
232
265
|
const bytes = readFileSync(storagePath);
|
|
233
266
|
const contentHash = hashStorageBytes(bytes);
|
|
234
267
|
const cached = STORAGE_META_CACHE.get(storagePath);
|
|
235
268
|
if (cached && cached.contentHash === contentHash) {
|
|
236
|
-
|
|
269
|
+
// Content is byte-identical despite the mtime/size change (e.g. an
|
|
270
|
+
// atomic-rename rewrite of the same bytes). Refresh the stat fields so
|
|
271
|
+
// the next request takes the fast path, but skip the JSON.parse.
|
|
272
|
+
const refreshed = {
|
|
273
|
+
...cached,
|
|
274
|
+
mtimeMs: stats.mtimeMs,
|
|
275
|
+
size: stats.size,
|
|
276
|
+
};
|
|
277
|
+
STORAGE_META_CACHE.set(storagePath, refreshed);
|
|
278
|
+
return metaFromSnapshot(refreshed);
|
|
237
279
|
}
|
|
238
280
|
const parsed = JSON.parse(bytes.toString("utf8"));
|
|
239
281
|
const pinnedAccountIndex = typeof parsed.pinnedAccountIndex === "number" &&
|
|
@@ -247,6 +289,8 @@ export function readStorageMetaFromDisk(storagePath = getStoragePath()) {
|
|
|
247
289
|
? parsed.affinityGeneration
|
|
248
290
|
: 0;
|
|
249
291
|
const snapshot = {
|
|
292
|
+
mtimeMs: stats.mtimeMs,
|
|
293
|
+
size: stats.size,
|
|
250
294
|
contentHash,
|
|
251
295
|
pinnedAccountIndex,
|
|
252
296
|
affinityGeneration,
|
|
@@ -311,7 +355,21 @@ async function persistRuntimeActiveAccount(accountManager, account, family, isPi
|
|
|
311
355
|
// (syncCodexCliActiveSelectionForIndex), which is the lost-update window the
|
|
312
356
|
// mutex exists to close. In legacy mode markSwitchedLocked runs inline, so
|
|
313
357
|
// behavior is unchanged by default.
|
|
314
|
-
|
|
358
|
+
//
|
|
359
|
+
// L4 fix: in "enabled" mode the SELECTION path already committed the cursor
|
|
360
|
+
// for this account inside the routing mutex (atomic select+commit, see the
|
|
361
|
+
// hot-path caller). Re-running markSwitchedLocked here — after the upstream
|
|
362
|
+
// fetch, in a *separate* critical section — would redundantly re-advance the
|
|
363
|
+
// cursor and could clobber a concurrent request's atomic advance that landed
|
|
364
|
+
// while this request was awaiting upstream. So only do the locked cursor
|
|
365
|
+
// commit in legacy mode, where selection does NOT commit under a lock and
|
|
366
|
+
// this remains the sole commit site (preserving legacy behavior exactly).
|
|
367
|
+
// `saveToDiskDebounced` + CLI sync still run in both modes: they snapshot the
|
|
368
|
+
// current in-memory state / mirror the CLI selection and do not advance the
|
|
369
|
+
// in-memory rotation cursor.
|
|
370
|
+
if (accountManager.getRoutingMutexMode() !== "enabled") {
|
|
371
|
+
await accountManager.markSwitchedLocked(account, "rotation", family);
|
|
372
|
+
}
|
|
315
373
|
accountManager.saveToDiskDebounced();
|
|
316
374
|
await accountManager.syncCodexCliActiveSelectionForIndex(account.index);
|
|
317
375
|
}
|
|
@@ -439,7 +497,11 @@ function buildResponsesRequestContext(req, body) {
|
|
|
439
497
|
method: "POST",
|
|
440
498
|
upstreamPath: URL_PATHS.CODEX_RESPONSES,
|
|
441
499
|
model,
|
|
442
|
-
|
|
500
|
+
// The /codex/responses path is codex-family. A model-less request must
|
|
501
|
+
// bucket into the codex family (rotation/cooldown/budget), so fall back to
|
|
502
|
+
// the current codex model — NOT the general DEFAULT_MODEL (gpt-5.5), whose
|
|
503
|
+
// family is gpt-5.2 and would mis-account a pass-through codex request.
|
|
504
|
+
family: getModelFamily(model ?? CURRENT_CODEX_MODEL),
|
|
443
505
|
stream: parsedBody?.stream === true,
|
|
444
506
|
sessionKey: resolveSessionKey(headers, parsedBody),
|
|
445
507
|
};
|
|
@@ -779,6 +841,24 @@ function getQuotaNearExhaustionWaitMs(headers, remainingThreshold, now) {
|
|
|
779
841
|
}
|
|
780
842
|
return candidates.length > 0 ? Math.max(...candidates) : 0;
|
|
781
843
|
}
|
|
844
|
+
/**
|
|
845
|
+
* `chooseAccount` is a SYNC selector that internally advances the rotation
|
|
846
|
+
* cursor (the session-affinity-preferred branch and the round-robin fallback
|
|
847
|
+
* both call `accountManager.markSwitched(...)`, and the hybrid selector advances
|
|
848
|
+
* its own cursor). It does NOT acquire the routing mutex itself.
|
|
849
|
+
*
|
|
850
|
+
* Concurrency (L4): when `routingMutex === "enabled"`, the proxy hot path runs
|
|
851
|
+
* this whole call AND the subsequent `markSwitchedLocked` commit inside a single
|
|
852
|
+
* `withRoutingMutex` acquisition, so concurrent requests serialize selection +
|
|
853
|
+
* cursor advance and cannot stampede the same account. `withRoutingMutex` is
|
|
854
|
+
* reentrant (AsyncLocalStorage), so the nested `markSwitchedLocked` — and the
|
|
855
|
+
* later one in `persistRuntimeActiveAccount` — run inline without re-acquiring
|
|
856
|
+
* the non-reentrant FIFO queue (no deadlock). In legacy mode the inline
|
|
857
|
+
* `markSwitched` calls below are used unchanged and no lock is taken, so default
|
|
858
|
+
* behavior and perf are identical. See the hot-path caller in
|
|
859
|
+
* `startRuntimeRotationProxy` and the regression in
|
|
860
|
+
* `test/runtime-rotation-proxy.test.ts`.
|
|
861
|
+
*/
|
|
782
862
|
export function chooseAccount(params) {
|
|
783
863
|
const { accountManager, sessionAffinityStore, sessionKey, family, model, attemptedIndexes, now, policy, pinnedIndex, skipReasons, stickyBoostByAccount, pidOffsetEnabled, } = params;
|
|
784
864
|
// Manual pin (from `codex-multi-auth switch <n>`) overrides every other
|
|
@@ -820,6 +900,7 @@ export function chooseAccount(params) {
|
|
|
820
900
|
skipReasons?.set(preferred.index, reason);
|
|
821
901
|
}
|
|
822
902
|
else {
|
|
903
|
+
// L4 (deferred): unlocked cursor mutation — see chooseAccount header.
|
|
823
904
|
accountManager.markSwitched(preferred, "rotation", family);
|
|
824
905
|
return preferred;
|
|
825
906
|
}
|
|
@@ -857,6 +938,7 @@ export function chooseAccount(params) {
|
|
|
857
938
|
const live = accountManager.getAccountByIndex(account.index);
|
|
858
939
|
if (!live)
|
|
859
940
|
continue;
|
|
941
|
+
// L4 (deferred): unlocked cursor mutation — see chooseAccount header.
|
|
860
942
|
accountManager.markSwitched(live, "rotation", family);
|
|
861
943
|
return live;
|
|
862
944
|
}
|
|
@@ -1100,6 +1182,16 @@ export async function startRuntimeRotationProxy(options) {
|
|
|
1100
1182
|
let accountManager = activeAccountManager;
|
|
1101
1183
|
try {
|
|
1102
1184
|
const incomingUrl = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
1185
|
+
// Authenticate before discriminating path/method so an unauthenticated
|
|
1186
|
+
// caller cannot enumerate which endpoints exist: an unknown caller always
|
|
1187
|
+
// gets 401, never a 404 that would confirm a path is invalid (vs. just
|
|
1188
|
+
// unauthorized). Authorized callers still fall through to the 404 below
|
|
1189
|
+
// when they hit an unsupported path/method.
|
|
1190
|
+
const incomingHeaders = headersFromIncoming(req);
|
|
1191
|
+
if (!isAuthorizedClient(incomingHeaders, clientApiKey)) {
|
|
1192
|
+
writeUnauthorized(res);
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1103
1195
|
const isResponsesRequest = req.method === "POST" && isResponsesPath(incomingUrl.pathname);
|
|
1104
1196
|
const isModelsRequest = req.method === "GET" && isModelsPath(incomingUrl.pathname);
|
|
1105
1197
|
const isThreadGoalRequest = (req.method === "GET" || req.method === "POST") &&
|
|
@@ -1108,11 +1200,6 @@ export async function startRuntimeRotationProxy(options) {
|
|
|
1108
1200
|
writeMethodOrPathError(res);
|
|
1109
1201
|
return;
|
|
1110
1202
|
}
|
|
1111
|
-
const incomingHeaders = headersFromIncoming(req);
|
|
1112
|
-
if (!isAuthorizedClient(incomingHeaders, clientApiKey)) {
|
|
1113
|
-
writeUnauthorized(res);
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
1203
|
status.totalRequests += 1;
|
|
1117
1204
|
const requestBody = isResponsesRequest || (isThreadGoalRequest && req.method === "POST")
|
|
1118
1205
|
? await readRequestBody(req, maxRequestBodyBytes)
|
|
@@ -1218,7 +1305,22 @@ export async function startRuntimeRotationProxy(options) {
|
|
|
1218
1305
|
now() - lastGlobalSwitchAt < minRotationIntervalMs
|
|
1219
1306
|
? { [lastGlobalAccountIndex]: 1000 }
|
|
1220
1307
|
: {};
|
|
1221
|
-
|
|
1308
|
+
// L4 fix (routing mutex): when `routingMutex === "enabled"`, run the
|
|
1309
|
+
// selection AND the cursor commit inside ONE mutex acquisition so two
|
|
1310
|
+
// concurrent requests cannot read the same cursor and stampede before
|
|
1311
|
+
// the locked commit lands. `chooseAccount` is sync and mutates the
|
|
1312
|
+
// cursor internally (session-affinity `markSwitched`, the hybrid
|
|
1313
|
+
// selector's own advance, and the round-robin fallback `markSwitched`);
|
|
1314
|
+
// holding the mutex across the whole call serializes all of those.
|
|
1315
|
+
// We then `markSwitchedLocked` the winner to (a) re-commit the cursor
|
|
1316
|
+
// under the lock across the await boundary and (b) hand
|
|
1317
|
+
// `persistRuntimeActiveAccount` a cursor that is already correct. That
|
|
1318
|
+
// later `markSwitchedLocked` runs INLINE (reentrant) within this held
|
|
1319
|
+
// section, so there is no double-acquire and no deadlock on the
|
|
1320
|
+
// non-reentrant FIFO queue. In legacy mode the inline `markSwitched`
|
|
1321
|
+
// calls inside `chooseAccount` are used unchanged and no lock is taken,
|
|
1322
|
+
// so default behavior and perf are identical to before.
|
|
1323
|
+
const selectAccount = () => chooseAccount({
|
|
1222
1324
|
accountManager,
|
|
1223
1325
|
sessionAffinityStore,
|
|
1224
1326
|
sessionKey: context.sessionKey,
|
|
@@ -1232,6 +1334,20 @@ export async function startRuntimeRotationProxy(options) {
|
|
|
1232
1334
|
stickyBoostByAccount: rotationStickyBoost,
|
|
1233
1335
|
pidOffsetEnabled,
|
|
1234
1336
|
});
|
|
1337
|
+
const selected = routingMutexMode === "enabled"
|
|
1338
|
+
? await withRoutingMutex(routingMutexMode, async () => {
|
|
1339
|
+
const candidate = selectAccount();
|
|
1340
|
+
if (candidate && pinnedIndex === null) {
|
|
1341
|
+
// Re-commit the cursor under the held mutex. Skipped when a
|
|
1342
|
+
// manual pin is active so the proxy never clobbers the pin
|
|
1343
|
+
// (see #474); pinned selections are deterministic and need no
|
|
1344
|
+
// cursor advance. Runs inline via reentrancy — see comment
|
|
1345
|
+
// above.
|
|
1346
|
+
await accountManager.markSwitchedLocked(candidate, "rotation", context.family);
|
|
1347
|
+
}
|
|
1348
|
+
return candidate;
|
|
1349
|
+
})
|
|
1350
|
+
: selectAccount();
|
|
1235
1351
|
if (!selected) {
|
|
1236
1352
|
if (!reloadedAfterNoAccount &&
|
|
1237
1353
|
!isPinned &&
|
|
@@ -1510,6 +1626,13 @@ export async function startRuntimeRotationProxy(options) {
|
|
|
1510
1626
|
return;
|
|
1511
1627
|
}
|
|
1512
1628
|
accountManager.recordSuccess(refreshed.account, context.family, context.model);
|
|
1629
|
+
// A successful request proves the account is usable, so clear any
|
|
1630
|
+
// stale runtime skip reason persisted for it on a prior pool
|
|
1631
|
+
// exhaustion. Without this the overlay reason (e.g. "token-exhausted",
|
|
1632
|
+
// "rate-limited") lingers on disk until an explicit runtime reset and
|
|
1633
|
+
// the forecast keeps reporting this working account as unavailable.
|
|
1634
|
+
// No-op when no reason is recorded, so the hot path stays write-free.
|
|
1635
|
+
recordRuntimeAccountRecovery(refreshed.account.index);
|
|
1513
1636
|
const nearExhaustionWaitMs = getQuotaNearExhaustionWaitMs(upstream.headers, quotaRemainingPercentThreshold, now());
|
|
1514
1637
|
if (nearExhaustionWaitMs > 0) {
|
|
1515
1638
|
accountManager.markRateLimitedWithReason(refreshed.account, nearExhaustionWaitMs, context.family, "quota", context.model);
|