@claudexor/orchestrator 3.4.2 → 3.6.0

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.
Files changed (57) hide show
  1. package/dist/account-pool.d.ts +62 -0
  2. package/dist/account-pool.d.ts.map +1 -0
  3. package/dist/account-pool.js +103 -0
  4. package/dist/account-pool.js.map +1 -0
  5. package/dist/account-resolution.d.ts +85 -0
  6. package/dist/account-resolution.d.ts.map +1 -0
  7. package/dist/account-resolution.js +320 -0
  8. package/dist/account-resolution.js.map +1 -0
  9. package/dist/attemptOutputMarkers.d.ts +30 -0
  10. package/dist/attemptOutputMarkers.d.ts.map +1 -0
  11. package/dist/attemptOutputMarkers.js +31 -0
  12. package/dist/attemptOutputMarkers.js.map +1 -0
  13. package/dist/attemptTelemetry.d.ts +5 -4
  14. package/dist/attemptTelemetry.d.ts.map +1 -1
  15. package/dist/attemptTelemetry.js +4 -2
  16. package/dist/attemptTelemetry.js.map +1 -1
  17. package/dist/credential-cooldown.d.ts +131 -0
  18. package/dist/credential-cooldown.d.ts.map +1 -0
  19. package/dist/credential-cooldown.js +169 -0
  20. package/dist/credential-cooldown.js.map +1 -0
  21. package/dist/credential-differential.d.ts +81 -0
  22. package/dist/credential-differential.d.ts.map +1 -0
  23. package/dist/credential-differential.js +110 -0
  24. package/dist/credential-differential.js.map +1 -0
  25. package/dist/credential-preflight.d.ts +36 -0
  26. package/dist/credential-preflight.d.ts.map +1 -0
  27. package/dist/credential-preflight.js +78 -0
  28. package/dist/credential-preflight.js.map +1 -0
  29. package/dist/credential-profile-rotation.d.ts +80 -54
  30. package/dist/credential-profile-rotation.d.ts.map +1 -1
  31. package/dist/credential-profile-rotation.js +191 -163
  32. package/dist/credential-profile-rotation.js.map +1 -1
  33. package/dist/credential-profiles.d.ts +3 -49
  34. package/dist/credential-profiles.d.ts.map +1 -1
  35. package/dist/credential-profiles.js +2 -46
  36. package/dist/credential-profiles.js.map +1 -1
  37. package/dist/index.d.ts +2 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +2 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/laneStreamEvents.d.ts +54 -0
  42. package/dist/laneStreamEvents.d.ts.map +1 -0
  43. package/dist/laneStreamEvents.js +81 -0
  44. package/dist/laneStreamEvents.js.map +1 -0
  45. package/dist/orchestrator-credentials.d.ts +93 -0
  46. package/dist/orchestrator-credentials.d.ts.map +1 -0
  47. package/dist/orchestrator-credentials.js +156 -0
  48. package/dist/orchestrator-credentials.js.map +1 -0
  49. package/dist/orchestrator.d.ts +17 -30
  50. package/dist/orchestrator.d.ts.map +1 -1
  51. package/dist/orchestrator.js +278 -324
  52. package/dist/orchestrator.js.map +1 -1
  53. package/dist/rotation-predicate.d.ts +71 -0
  54. package/dist/rotation-predicate.d.ts.map +1 -0
  55. package/dist/rotation-predicate.js +29 -0
  56. package/dist/rotation-predicate.js.map +1 -0
  57. package/package.json +17 -17
@@ -1,5 +1,31 @@
1
- import { HarnessRunSpec as HarnessRunSpecSchema } from "@claudexor/schema";
1
+ import { HarnessRunSpec as HarnessRunSpecSchema, RouteCredentialUnusablePayload, } from "@claudexor/schema";
2
2
  import { quotaConstraintAppliesToModel } from "@claudexor/budget";
3
+ import { credentialPoolExhausted, liveUnusableFor, poolMemberEvidence, profileQuotaBlock, } from "./credential-cooldown.js";
4
+ import { reactiveRotationEvidence, rotationRetryEligible, } from "./rotation-predicate.js";
5
+ export { rotationRetryEligible } from "./rotation-predicate.js";
6
+ /** The route of a limit decision's subject: a pinned profile decides by its
7
+ * own credential kind; the default subject decides by the caller's route
8
+ * estimate. ONE owner, so every consumer classifies the subject alike. */
9
+ export function limitSubjectRoute(profile, defaultRoute = null) {
10
+ if (!profile)
11
+ return defaultRoute;
12
+ return profile.credential_kind === "api_key" ? "api_key" : "local_session";
13
+ }
14
+ /**
15
+ * THE effective-policy resolver (A6, owner decision 1=A): the stored default
16
+ * `auto` resolves BY CREDENTIAL KIND — `rotate` for subscription
17
+ * (`local_session`) subjects, `fail` for metered API-key or unknown routes —
18
+ * while explicitly persisted `fail`/`ask`/`rotate` pass through untouched
19
+ * (3=A: a stored value is never reinterpreted, only ABSENT changed meaning).
20
+ * Every `limit_action` comparison in the engine and every projection
21
+ * (`next_up`, Accounts) resolves through this one function, so admission and
22
+ * display can never disagree about what `auto` does (INV-135).
23
+ */
24
+ export function effectiveLimitAction(policy, route) {
25
+ if (policy.limit_action !== "auto")
26
+ return policy.limit_action;
27
+ return route === "local_session" ? "rotate" : "fail";
28
+ }
3
29
  /**
4
30
  * Static rotation candidates, before any credential-backed readiness probe.
5
31
  * One owner applies policy order, enabled/harness scope, current identity,
@@ -83,24 +109,35 @@ export function nextEligibleProfile(registry, harnessId, policy, current, snapsh
83
109
  continue;
84
110
  if (profileHeadroomBreach(snapshots, harnessId, candidate.profile_id, policy.headroom_threshold, model))
85
111
  continue;
112
+ // Rotating INTO a subject whose own observed windows are still cooling or
113
+ // spent (A4) is not a failover — it burns an attempt to rediscover the
114
+ // limit the registry already holds, stale-but-live evidence included.
115
+ if (profileQuotaBlock(snapshots, harnessId, candidate.profile_id, limitSubjectRoute(candidate), model))
116
+ continue;
86
117
  return candidate;
87
118
  }
88
119
  return null;
89
120
  }
90
- /**
91
- * `rotation_retry_eligible` (sol #30): a failover retry is allowed ONLY when
92
- * the attempt saw a TYPED vendor limit AND produced no deliverable and no
93
- * workspace mutation a partially-acted attempt never silently reruns.
94
- */
95
- export function rotationRetryEligible(input) {
96
- return input.sawTypedLimit && input.deliverableEmpty;
97
- }
98
- function emitRotationExhausted(args) {
121
+ /** The per-candidate rejection evidence of one exhausted rotation decision:
122
+ * why each registered identity of the harness could not take over, with its
123
+ * own quota evidence (headroom breach / observed block) when it has any. ONE
124
+ * builder feeds both the `route.profile.rotation_exhausted` event and the
125
+ * typed pool-exhausted terminal, so they can never disagree. */
126
+ function rotationExhaustionCandidates(args) {
99
127
  const excluded = args.excluded ?? new Set();
100
- const candidates = args.registry
128
+ return args.registry
101
129
  .filter((profile) => profile.harness_id === args.harnessId && profile.enabled)
102
130
  .map((profile) => {
103
131
  const breach = profileHeadroomBreach(args.snapshots, args.harnessId, profile.profile_id, args.policy.headroom_threshold, args.model);
132
+ // Observed-limit evidence (A4): a candidate skipped because its own
133
+ // windows are cooling/spent says so machine-readably, with the earliest
134
+ // known release instant, instead of hiding behind "not_selected".
135
+ const block = profileQuotaBlock(args.snapshots, args.harnessId, profile.profile_id, limitSubjectRoute(profile), args.model);
136
+ // A7: a candidate refused because ITS CREDENTIAL was observed dead says
137
+ // so typed, instead of hiding behind "not_ready" — a dead credential is
138
+ // not a readiness hiccup, and its quota evidence never carries a
139
+ // reopen promise.
140
+ const dead = liveUnusableFor(args.unusable ?? [], args.harnessId, profile.profile_id, args.model);
104
141
  const rejected = profile.profile_id === args.current?.profile_id
105
142
  ? "current"
106
143
  : args.policy.rotation_eligible.length > 0 &&
@@ -112,18 +149,28 @@ function emitRotationExhausted(args) {
112
149
  ? "credential_kind_mismatch"
113
150
  : args.current === null && profile.credential_kind === "api_key"
114
151
  ? "credential_kind_mismatch"
115
- : !args.readyProfileIds.has(profile.profile_id)
116
- ? "not_ready"
117
- : breach
118
- ? "headroom_exceeded"
119
- : "not_selected";
152
+ : dead
153
+ ? "credential_unusable"
154
+ : !args.readyProfileIds.has(profile.profile_id)
155
+ ? "not_ready"
156
+ : breach
157
+ ? "headroom_exceeded"
158
+ : block
159
+ ? "cooldown"
160
+ : "not_selected";
120
161
  return {
121
162
  profile_id: profile.profile_id,
122
163
  credential_kind: profile.credential_kind,
123
164
  rejected,
124
165
  headroom: breach,
166
+ cooldown: block,
167
+ unusable: dead ? { code: dead.code, source: dead.source } : null,
168
+ resets_at: breach?.resets_at ?? block?.resets_at ?? null,
125
169
  };
126
170
  });
171
+ }
172
+ export function emitRotationExhausted(args) {
173
+ const candidates = rotationExhaustionCandidates(args);
127
174
  args.emit("route.profile.rotation_exhausted", {
128
175
  harness_id: args.harnessId,
129
176
  attempt_id: args.attemptId,
@@ -132,154 +179,35 @@ function emitRotationExhausted(args) {
132
179
  threshold: args.policy.headroom_threshold,
133
180
  candidates,
134
181
  });
182
+ // The same rows feed the typed pool-exhausted terminal (A5): the event and
183
+ // the failure must never disagree about why each candidate was rejected.
184
+ return candidates;
135
185
  }
136
186
  /**
137
- * A spent subscription window, refused MACHINE-READABLY.
138
- *
139
- * The verdict a caller actually needs from this refusal is "not now, come back
140
- * at T" — and the only honest way to deliver T is as a field. Gluing it into
141
- * the sentence and shipping the terminal as `category: internal, code: null`
142
- * left every consumer (a surface, a scheduler, an automating host) to regex
143
- * the prose for a timestamp, which no contract in this repo permits. The
144
- * message stays human-readable; the machine reads `code` and `resetsAt`, which
145
- * the run terminal lifts onto `final/failure.yaml` verbatim.
146
- */
147
- function subscriptionWindowExhausted(profileId, harnessId, breach) {
148
- return Object.assign(new Error(`credential profile "${profileId}" (${harnessId}) is over its headroom threshold ` +
149
- `(${breach.constraint_id} at ${Math.round(breach.used_ratio * 100)}% >= ${Math.round(breach.threshold * 100)}%; ` +
150
- `limit_action=fail${breach.resets_at ? `; resets ${breach.resets_at}` : ""})`), {
151
- code: "subscription_window_exhausted",
152
- // Not `internal`: nothing malfunctioned. The account cannot serve this
153
- // run until its window reopens, which is what harness_unavailable means.
154
- category: "harness_unavailable",
155
- resetsAt: breach.resets_at,
156
- });
157
- }
158
- /**
159
- * `profile_headroom_preflight` (W5.4): BEFORE spawn, the selected profile's
160
- * freshest quota windows are checked against the policy threshold. A breach
161
- * is always a typed event; `rotate` swaps to the next eligible profile with
162
- * provenance, `ask`/`fail` proceed on the selected profile — the runtime
163
- * `vendor_limit_rejected` evidence stays the terminating truth.
164
- */
165
- export function preflightCredentialProfile(args) {
166
- const { profile, harnessId, policy, registry, snapshots, readyProfileIds, model, emit } = args;
167
- const breach = profileHeadroomBreach(snapshots, harnessId, profile.profile_id, policy.headroom_threshold, model);
168
- if (!breach)
169
- return profile;
170
- emit("route.profile.headroom_exceeded", {
171
- harness_id: harnessId,
172
- profile_id: profile.profile_id,
173
- action: policy.limit_action,
174
- constraint_id: breach.constraint_id,
175
- used_ratio: breach.used_ratio,
176
- threshold: breach.threshold,
177
- resets_at: breach.resets_at,
178
- });
179
- if (policy.limit_action === "fail") {
180
- // The documented FAIL action fails (release wave tier1 #4): a FRESH breach
181
- // under fail refuses before spawn with the evidence, instead of silently
182
- // proceeding into a vendor rejection.
183
- throw subscriptionWindowExhausted(profile.profile_id, harnessId, breach);
184
- }
185
- if (policy.limit_action !== "rotate")
186
- return profile;
187
- const next = nextEligibleProfile(registry, harnessId, policy, profile, snapshots, readyProfileIds, new Set(), model);
188
- if (!next) {
189
- emitRotationExhausted({
190
- current: profile,
191
- harnessId,
192
- policy,
193
- registry,
194
- snapshots,
195
- readyProfileIds,
196
- model,
197
- reason: "profile_headroom_preflight",
198
- emit,
199
- });
200
- return profile;
201
- }
202
- emit("route.profile.rotated", {
203
- harness_id: harnessId,
204
- from_profile_id: profile.profile_id,
205
- to_profile_id: next.profile_id,
206
- reason: "profile_headroom_preflight",
207
- constraint_id: breach.constraint_id,
208
- used_ratio: breach.used_ratio,
209
- resets_at: breach.resets_at,
210
- });
211
- return next;
212
- }
213
- /**
214
- * Default-subject start selection (INV-135, owner scope "auto-balance"): when
215
- * NO profile is pinned, the policy is `rotate`, and the DEFAULT store's own
216
- * fresh quota window is at/over the headroom bound, pick the first eligible
217
- * SUBSCRIPTION profile instead of spawning into a near-certain vendor limit.
218
- * Strictly opt-in: `fail`/`ask` keep today's default-user behavior untouched
219
- * (the profile engine's fail action governs PINNED profiles only — throwing
220
- * here would brick every default user at 90% quota). Unknown or stale usage
221
- * never rotates.
222
- */
223
- export function preflightDefaultSubject(args) {
224
- const { harnessId, policy, registry, snapshots, readyProfileIds, defaultRoute, model, emit } = args;
225
- if (policy.limit_action !== "rotate" || defaultRoute !== "local_session")
226
- return null;
227
- const breach = profileHeadroomBreach(snapshots, harnessId, null, policy.headroom_threshold, model);
228
- if (!breach)
229
- return null;
230
- emit("route.profile.headroom_exceeded", {
231
- harness_id: harnessId,
232
- profile_id: null,
233
- action: policy.limit_action,
234
- constraint_id: breach.constraint_id,
235
- used_ratio: breach.used_ratio,
236
- threshold: breach.threshold,
237
- resets_at: breach.resets_at,
238
- });
239
- const next = nextEligibleProfile(registry, harnessId, policy, null, snapshots, readyProfileIds, new Set(), model);
240
- if (!next) {
241
- emitRotationExhausted({
242
- current: null,
243
- harnessId,
244
- policy,
245
- registry,
246
- snapshots,
247
- readyProfileIds,
248
- model,
249
- reason: "profile_headroom_preflight",
250
- emit,
251
- });
252
- return null;
253
- }
254
- emit("route.profile.rotated", {
255
- harness_id: harnessId,
256
- from_profile_id: null,
257
- to_profile_id: next.profile_id,
258
- reason: "profile_headroom_preflight",
259
- constraint_id: breach.constraint_id,
260
- used_ratio: breach.used_ratio,
261
- resets_at: breach.resets_at,
262
- });
263
- return next;
264
- }
265
- /**
266
- * Reactive failover plan (`vendor_limit_rejected`, W5.4): rotation fires ONLY
267
- * on the typed predicate under a `rotate` policy, marks the current profile
268
- * tried (at most once per attempt each), and returns the next target with
269
- * provenance already emitted — or null when the attempt must fail as-is.
187
+ * Reactive failover plan (`vendor_limit_rejected` / structural, W5.4 + A2):
188
+ * rotation fires ONLY on the typed evidence predicate under a `rotate`
189
+ * policy, marks the current profile tried (at most once per attempt each),
190
+ * and returns the next target with provenance already emitted or null when
191
+ * the attempt must fail as-is.
270
192
  * `currentProfile: null` is the DEFAULT subject: allowed ONLY when the caller
271
193
  * proves the attempt's pre-spawn route was vendor_native (a metered default
272
194
  * hitting a limit is a budget fact, not a subscription to fail over from).
273
195
  */
274
196
  export function planReactiveRotation(args) {
275
- if (!rotationRetryEligible(args))
197
+ if (!rotationRetryEligible(args.evidence))
276
198
  return null;
277
- if (args.policy.limit_action !== "rotate")
199
+ const route = limitSubjectRoute(args.currentProfile, args.defaultRouteWasVendorNative === true ? "local_session" : null);
200
+ if (effectiveLimitAction(args.policy, route) !== "rotate")
278
201
  return null;
279
202
  if (args.currentProfile === null && args.defaultRouteWasVendorNative !== true)
280
203
  return null;
281
204
  if (args.currentProfile)
282
205
  args.triedProfiles.add(args.currentProfile.profile_id);
206
+ // Honest provenance: a structural rotation names its own reason — no typed
207
+ // vendor limit was observed, so `vendor_limit_rejected` would be fabricated.
208
+ const reason = args.evidence.sawTypedLimit
209
+ ? "vendor_limit_rejected"
210
+ : "structural_pre_progress_failure";
283
211
  const next = nextEligibleProfile(args.registry, args.harnessId, args.policy, args.currentProfile, args.snapshots, args.readyProfileIds, args.triedProfiles, args.model);
284
212
  if (!next) {
285
213
  emitRotationExhausted({
@@ -290,9 +218,10 @@ export function planReactiveRotation(args) {
290
218
  snapshots: args.snapshots,
291
219
  readyProfileIds: args.readyProfileIds,
292
220
  excluded: args.triedProfiles,
221
+ unusable: args.unusable,
293
222
  attemptId: args.attemptId,
294
223
  model: args.model,
295
- reason: "vendor_limit_rejected",
224
+ reason,
296
225
  emit: args.emit,
297
226
  });
298
227
  return null;
@@ -302,36 +231,135 @@ export function planReactiveRotation(args) {
302
231
  attempt_id: args.attemptId,
303
232
  from_profile_id: args.currentProfile?.profile_id ?? null,
304
233
  to_profile_id: next.profile_id,
305
- reason: "vendor_limit_rejected",
234
+ reason,
306
235
  retry_delay_ms: args.lastLimit?.retryDelayMs ?? null,
307
236
  resets_at: args.lastLimit?.resetsAt ?? null,
308
237
  });
309
238
  return next;
310
239
  }
311
240
  /**
312
- * Shared reactive-failover step for BOTH lanes: given the attempt's typed
313
- * evidence, plan a rotation and rebuild the spec on a NEW vendor session
314
- * under the next profile or return null when the attempt must fail as-is.
241
+ * Shared reactive-failover step for BOTH lanes: fold the try's lane-local
242
+ * facts + output markers into the typed rotation evidence, probe candidate
243
+ * readiness ONLY when the predicate could actually fire (the probe spends
244
+ * seconds), then plan a rotation and rebuild the spec on a NEW vendor session
245
+ * under the next profile. `null` = the failure was never rotation's business
246
+ * (fail as-is: transient machinery, plain errors), or the pool ran out with
247
+ * NO credential evidence anywhere (the evidence gate below) so the attempt
248
+ * keeps its true failure. `{ poolExhausted }` = the
249
+ * failure WAS rotation-eligible under a `rotate` policy, the pool has
250
+ * nowhere left to go, and the decision carries credential evidence — the
251
+ * attempt must terminalize on this typed refusal
252
+ * BEFORE the transient gate can burn same-profile retries on the
253
+ * already-refused subject (A5 ordering: a typed vendor limit classifies as
254
+ * retryable-transient, so falling through would retry the spent credential).
255
+ * Callers invoke this only after the try ended in a terminal error.
315
256
  */
316
- export function rotateSpecOnTypedLimit(args) {
257
+ export async function rotateSpecOnTypedLimit(args) {
258
+ const current = args.spec.credential_profile ?? null;
259
+ const evidence = reactiveRotationEvidence(args);
260
+ if (args.pinned) {
261
+ // Strict pin (D-U6): never rotate. A TYPED vendor limit on the pinned
262
+ // subject still terminalizes TYPED — `subscription_window_exhausted` with
263
+ // the limit's own reset — BEFORE the transient gate burns same-profile
264
+ // retries on the already-refused subject (the A5 ordering, preserved for
265
+ // pins). Anything else (structural/untyped deaths) fails as-is.
266
+ if (current && evidence.sawTypedLimit && rotationRetryEligible(evidence)) {
267
+ return {
268
+ poolExhausted: Object.assign(new Error(`credential profile "${current.profile_id}" (${args.harnessId}) hit a typed ` +
269
+ `vendor limit and a pinned account never rotates` +
270
+ `${args.lastLimit?.resetsAt ? `; resets ${args.lastLimit.resetsAt}` : ""}`), {
271
+ code: "subscription_window_exhausted",
272
+ category: "harness_unavailable",
273
+ resetsAt: args.lastLimit?.resetsAt ?? null,
274
+ }),
275
+ };
276
+ }
277
+ return null;
278
+ }
279
+ const route = limitSubjectRoute(current, args.defaultRouteWasVendorNative === true ? "local_session" : null);
280
+ const eligible = effectiveLimitAction(args.policy, route) === "rotate" &&
281
+ rotationRetryEligible(evidence) &&
282
+ (current !== null || args.defaultRouteWasVendorNative === true);
283
+ if (!eligible)
284
+ return null;
285
+ const readyProfileIds = await args.probeReadyProfiles();
286
+ // A7: the differential probe of the CURRENT subject rides the same eligible
287
+ // decision as the candidate probe — quota-spent stays A4's cooldown story,
288
+ // while a dead credential becomes a typed, emitted, recorded observation.
289
+ const subjectUnusable = (await args.probeCurrentSubject?.()) ?? null;
290
+ if (subjectUnusable) {
291
+ args.emit("route.profile.credential_unusable", RouteCredentialUnusablePayload.parse({ ...subjectUnusable, attempt_id: args.attemptId }));
292
+ }
317
293
  const rotation = planReactiveRotation({
318
- currentProfile: args.spec.credential_profile ?? null,
294
+ currentProfile: current,
319
295
  defaultRouteWasVendorNative: args.defaultRouteWasVendorNative,
320
296
  harnessId: args.harnessId,
321
297
  attemptId: args.attemptId,
322
298
  policy: args.policy,
323
299
  registry: args.registry,
324
300
  snapshots: args.snapshots,
325
- readyProfileIds: args.readyProfileIds,
301
+ readyProfileIds,
326
302
  triedProfiles: args.triedProfiles,
327
- sawTypedLimit: args.sawTypedLimit,
328
- deliverableEmpty: args.deliverableEmpty,
303
+ evidence,
329
304
  lastLimit: args.lastLimit,
305
+ unusable: args.liveUnusable,
330
306
  model: args.spec.model_hint,
331
307
  emit: args.emit,
332
308
  });
333
- if (!rotation)
334
- return null;
309
+ if (!rotation) {
310
+ // planReactiveRotation already emitted `route.profile.rotation_exhausted`;
311
+ // rebuild the same rows (same pure inputs, no second event) for the typed
312
+ // terminal. The subject's own limit joins the fold from the freshest
313
+ // source available: its registry block (default subject has no row), else
314
+ // the typed limit just observed on the stream — the registry may not have
315
+ // ingested it yet, and its unknown reset then honestly nulls the fold.
316
+ const candidates = rotationExhaustionCandidates({
317
+ current,
318
+ harnessId: args.harnessId,
319
+ policy: args.policy,
320
+ registry: args.registry,
321
+ snapshots: args.snapshots,
322
+ readyProfileIds,
323
+ excluded: args.triedProfiles,
324
+ unusable: args.liveUnusable,
325
+ model: args.spec.model_hint,
326
+ });
327
+ // The default subject reached here only via the vendor-native eligibility
328
+ // gate above, so its registry row is the SUBSCRIPTION default — never the
329
+ // managed-api-key default that shares subject_id=null.
330
+ const subjectBlock = current === null
331
+ ? profileQuotaBlock(args.snapshots, args.harnessId, null, "local_session", args.spec.model_hint)
332
+ : null;
333
+ const subjectLimit = subjectBlock ??
334
+ (evidence.sawTypedLimit ? { resets_at: args.lastLimit?.resetsAt ?? null } : null);
335
+ // The pool terminal REQUIRES evidence: "credential_pool_exhausted" claims
336
+ // the credential layer refused the run, so either the triggering subject
337
+ // must carry limit/unusable evidence or some POOL-MEMBER row must carry
338
+ // headroom/cooldown/unusable evidence (`poolMemberEvidence` — rows for
339
+ // identities rotation could never select, e.g. an api_key sibling under a
340
+ // subscription subject, never count). A structural pre-progress death
341
+ // over an empty (or evidence-free) pool proves nothing about credentials —
342
+ // fail as-is and keep the TRUE failure (a vanilla user's crashed run must
343
+ // never terminalize as a pool refusal). The already-emitted
344
+ // `route.profile.rotation_exhausted` event stays: rotation WAS consulted
345
+ // and had nowhere to go; only the terminal's claim is evidence-gated.
346
+ const subjectEvidence = subjectLimit !== null || subjectUnusable !== null;
347
+ const poolEvidence = candidates.some(poolMemberEvidence);
348
+ if (!subjectEvidence && !poolEvidence)
349
+ return null;
350
+ return {
351
+ poolExhausted: credentialPoolExhausted({
352
+ harnessId: args.harnessId,
353
+ profileId: current?.profile_id ?? null,
354
+ reason: evidence.sawTypedLimit
355
+ ? "vendor_limit_rejected"
356
+ : "structural_pre_progress_failure",
357
+ candidates,
358
+ subjectLimit,
359
+ subjectUnusable,
360
+ }),
361
+ };
362
+ }
335
363
  return HarnessRunSpecSchema.parse({
336
364
  ...args.spec,
337
365
  session_id: args.newSessionId(),
@@ -1 +1 @@
1
- {"version":3,"file":"credential-profile-rotation.js","sourceRoot":"","sources":["../src/credential-profile-rotation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAgBlE;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAMxC;IACC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAC/B,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C,2BAA2B;QAC7D,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU;QAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,oBAAoB,CAAC,KAAK,CAAC;QAChC,GAAG,IAAI,CAAC,IAAI;QACZ,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE;QAC/B,kBAAkB,EAAE,QAAQ;QAC5B,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"credential-profile-rotation.js","sourceRoot":"","sources":["../src/credential-profile-rotation.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,IAAI,oBAAoB,EACtC,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,qBAAqB,EAAyB,MAAM,yBAAyB,CAAC;AAavF;;0EAE0E;AAC1E,MAAM,UAAU,iBAAiB,CAC/B,OAA0D,EAC1D,YAAY,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EAAsE;QACtE,2EAA2E;QAC3E,0EAA0E;QAC1E,4DAA4D;QAC5D,yEAAyE;QACzE,sEAAsE;QACtE,MAAM,eAAe,GAAG,YAAY,KAAK,IAAI,IAAI,eAAe,KAAK,IAAI,CAAC;QAC1E,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACzD,IAAI,CAAC,eAAe,IAAI,CAAC,YAAY;YAAE,OAAO,IAAI,CAAC;QACnD,OAAO;YACL,aAAa,EAAE,uBAAuB,CAAC;gBACrC,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,SAAS,EAAE,OAAO,EAAE,UAAU,IAAI,IAAI;gBACtC,MAAM,EAAE,QAAQ,CAAC,aAAa;oBAC5B,CAAC,CAAC,uBAAuB;oBACzB,CAAC,CAAC,iCAAiC;gBACrC,UAAU;gBACV,YAAY;gBACZ,eAAe;aAChB,CAAC;SACH,CAAC;IACJ,CAAC;IACD,OAAO,oBAAoB,CAAC,KAAK,CAAC;QAChC,GAAG,IAAI,CAAC,IAAI;QACZ,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE;QAC/B,kBAAkB,EAAE,QAAQ;QAC5B,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,6 @@
1
- import type { AuthPreference, AuthSourceReadiness, CredentialProfile, CredentialProfileStatus, HarnessEvent, QuotaAbsence, QuotaSnapshot } from "@claudexor/schema";
2
- import { type ProfilePolicy } from "./credential-profile-rotation.js";
3
- export { nextEligibleProfile, planReactiveRotation, preflightCredentialProfile, preflightDefaultSubject, profileHeadroomBreach, rotateSpecOnTypedLimit, rotationRetryEligible, staticRotationCandidates, type ProfilePolicy, } from "./credential-profile-rotation.js";
1
+ import type { AuthPreference, CredentialProfile, CredentialProfileStatus, HarnessEvent, QuotaAbsence, QuotaSnapshot } from "@claudexor/schema";
2
+ export { effectiveLimitAction, limitSubjectRoute, nextEligibleProfile, planReactiveRotation, profileHeadroomBreach, rotateSpecOnTypedLimit, rotationRetryEligible, staticRotationCandidates, type ProfilePolicy, } from "./credential-profile-rotation.js";
3
+ export { preflightDefaultSubject } from "./credential-preflight.js";
4
4
  /**
5
5
  * The ONE resolve owner for credential profiles (INV-135): explicit id →
6
6
  * durable registry entry for exactly this harness. Unknown, disabled, or
@@ -84,52 +84,6 @@ export declare function probeCredentialProfileStatus(profile: CredentialProfile,
84
84
  /** Same precedence used by run admission: the first explicit route wins;
85
85
  * `auto` means fall through rather than shadow a more general setting. */
86
86
  export declare function effectiveAuthPreference(...values: Array<AuthPreference | null | undefined>): AuthPreference;
87
- /** Fresh effective route for the unprofiled/default subject in Accounts. The
88
- * gateway status proves aggregate intent readiness; the schema auth estimator
89
- * then chooses the exact usable source under the same configured preference as
90
- * run admission. Returning the route (not merely a bool) keeps next_up labels
91
- * truthful when a native-capable harness falls back to an API key. */
92
- export declare function defaultCredentialRoute(status: {
93
- status: "ok" | "degraded" | "unavailable";
94
- routableIntents: readonly unknown[];
95
- authSources: readonly AuthSourceReadiness[];
96
- }, requested: AuthPreference): "local_session" | "api_key" | null;
97
- /** The informational identity an UNPINNED run of a harness would route to next
98
- * (INV-135 `next_up`) — the same routing owner that admits and rotates runs,
99
- * exposed for the accounts projection so no surface re-derives it. Never gates
100
- * routing: explicit control is a per-run `--profile` / per-thread pin.
101
- *
102
- * Semantics mirror run-time admission: an unpinned run's default subject is the
103
- * unprofiled/default credential when it participates in the ladder; enabled profiles route
104
- * only by explicit pin or, under `rotate`, as the quota-failover target when the
105
- * default subject is already over headroom. A disabled default leaves an
106
- * unpinned run with nothing routable. */
107
- export type NextUpIdentity = {
108
- kind: "profile";
109
- profileId: string;
110
- } | {
111
- kind: "native";
112
- route: "local_session" | "api_key";
113
- } | {
114
- kind: "none";
115
- reason: string;
116
- };
117
- export declare function nextUpIdentity(args: {
118
- registry: readonly CredentialProfile[];
119
- harnessId: string;
120
- policy: ProfilePolicy;
121
- snapshots: readonly QuotaSnapshot[];
122
- defaultEnabled: boolean;
123
- /** Fresh doctor/admission truth for the unprofiled default subject. */
124
- defaultReady: boolean;
125
- /** Effective source route of that default subject under configured auth preference. */
126
- defaultRoute: "local_session" | "api_key" | null;
127
- /** Profiles admitted by their fresh profile doctor probe in this snapshot. */
128
- readyProfileIds: ReadonlySet<string>;
129
- /** Known configured model, null for the native default, or omitted only when
130
- * this projection has no model context and must stay conservative. */
131
- model?: string | null;
132
- }): NextUpIdentity;
133
87
  /**
134
88
  * INV-135 at the engine boundary: a cached vendor session resumes ONLY under
135
89
  * exactly the profile it was recorded with (null-default equality included) —
@@ -1 +1 @@
1
- {"version":3,"file":"credential-profiles.d.ts","sourceRoot":"","sources":["../src/credential-profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,EACd,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,aAAa,GACnB,MAAM,kCAAkC,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,iBAAiB,CASnB;AAED,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IACvD,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzE;;8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KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,GAAG,cAAc,CAwDjB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,SAAS,EACnE,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAChC,MAAM,GAAG,IAAI,CAGf;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EACD;IACE,iBAAiB,CAAC,EAAE,CAClB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,EAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,KACtB,IAAI,CAAC;CACX,GACD,SAAS,EACb,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,YAAY,GACf,IAAI,CAeN"}
1
+ {"version":3,"file":"credential-profiles.d.ts","sourceRoot":"","sources":["../src/credential-profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,EACd,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,aAAa,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,iBAAiB,CASnB;AAED,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IACvD,QAAQ,EAAE,SAAS,iBAA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AAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,EACnD,MAAM,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACrD,OAAO,CAKT;AAED;+EAC+E;AAC/E,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,iBAAiB,EAC1B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,uBAAuB,CAAC,GACvE,OAAO,CAAC,uBAAuB,CAAC,CAkClC;AAED;0EAC0E;AAC1E,wBAAgB,uBAAuB,CACrC,GAAG,MAAM,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC,GAClD,cAAc,CAIhB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,SAAS,EACnE,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAChC,MAAM,GAAG,IAAI,CAGf;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EACD;IACE,iBAAiB,CAAC,EAAE,CAClB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,EAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,KACtB,IAAI,CAAC;CACX,GACD,SAAS,EACb,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,YAAY,GACf,IAAI,CAeN"}
@@ -1,8 +1,7 @@
1
1
  import { CredentialProfileStatus as CredentialProfileStatusSchema, quotaSourceTraits, } from "@claudexor/schema";
2
2
  import { redactSecrets } from "@claudexor/util";
3
- import { estimateEffectiveAuthRoute } from "@claudexor/schema";
4
- import { nextEligibleProfile, profileHeadroomBreach, } from "./credential-profile-rotation.js";
5
- export { nextEligibleProfile, planReactiveRotation, preflightCredentialProfile, preflightDefaultSubject, profileHeadroomBreach, rotateSpecOnTypedLimit, rotationRetryEligible, staticRotationCandidates, } from "./credential-profile-rotation.js";
3
+ export { effectiveLimitAction, limitSubjectRoute, nextEligibleProfile, planReactiveRotation, profileHeadroomBreach, rotateSpecOnTypedLimit, rotationRetryEligible, staticRotationCandidates, } from "./credential-profile-rotation.js";
4
+ export { preflightDefaultSubject } from "./credential-preflight.js";
6
5
  /**
7
6
  * The ONE resolve owner for credential profiles (INV-135): explicit id →
8
7
  * durable registry entry for exactly this harness. Unknown, disabled, or
@@ -159,49 +158,6 @@ export async function probeCredentialProfileStatus(profile, probe) {
159
158
  export function effectiveAuthPreference(...values) {
160
159
  return (values.find((value) => value !== undefined && value !== null && value !== "auto") ?? "auto");
161
160
  }
162
- /** Fresh effective route for the unprofiled/default subject in Accounts. The
163
- * gateway status proves aggregate intent readiness; the schema auth estimator
164
- * then chooses the exact usable source under the same configured preference as
165
- * run admission. Returning the route (not merely a bool) keeps next_up labels
166
- * truthful when a native-capable harness falls back to an API key. */
167
- export function defaultCredentialRoute(status, requested) {
168
- if (status.status !== "ok" || status.routableIntents.length === 0)
169
- return null;
170
- return estimateEffectiveAuthRoute(requested, status.authSources);
171
- }
172
- export function nextUpIdentity(args) {
173
- const { registry, harnessId, policy, snapshots, defaultEnabled, defaultReady, defaultRoute, readyProfileIds, model, } = args;
174
- if (!defaultEnabled) {
175
- return {
176
- kind: "none",
177
- reason: "the default credential is disabled; enable it or pin an account per-run (--profile)",
178
- };
179
- }
180
- if (!defaultReady) {
181
- return {
182
- kind: "none",
183
- reason: "the default credential is not ready; refresh Accounts or run `claudexor doctor`",
184
- };
185
- }
186
- // Under `rotate`, a native/default subject already over its headroom bound
187
- // fails over to the next eligible enabled profile BEFORE spawn — that is who
188
- // an unpinned run routes to next. `ask`/`fail` proceed on the native default.
189
- if (policy.limit_action === "rotate" && defaultRoute === "local_session") {
190
- const breach = profileHeadroomBreach(snapshots, harnessId, null, policy.headroom_threshold, model);
191
- if (breach) {
192
- const next = nextEligibleProfile(registry, harnessId, policy, null, snapshots, readyProfileIds, new Set(), model);
193
- if (next)
194
- return { kind: "profile", profileId: next.profile_id };
195
- }
196
- }
197
- if (!defaultRoute) {
198
- return {
199
- kind: "none",
200
- reason: "the default credential route is unknown; refresh Accounts or run `claudexor doctor`",
201
- };
202
- }
203
- return { kind: "native", route: defaultRoute };
204
- }
205
161
  /**
206
162
  * INV-135 at the engine boundary: a cached vendor session resumes ONLY under
207
163
  * exactly the profile it was recorded with (null-default equality included) —