@claudexor/daemon 3.19.0 → 3.22.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 (60) hide show
  1. package/dist/command-retention.d.ts +1 -1
  2. package/dist/command-retention.d.ts.map +1 -1
  3. package/dist/command-retention.js +20 -4
  4. package/dist/command-retention.js.map +1 -1
  5. package/dist/continuation-admission.d.ts +11 -0
  6. package/dist/continuation-admission.d.ts.map +1 -0
  7. package/dist/continuation-admission.js +16 -0
  8. package/dist/continuation-admission.js.map +1 -0
  9. package/dist/credential-generation.d.ts +18 -0
  10. package/dist/credential-generation.d.ts.map +1 -0
  11. package/dist/credential-generation.js +43 -0
  12. package/dist/credential-generation.js.map +1 -0
  13. package/dist/credential-unusable-ledger.d.ts +26 -22
  14. package/dist/credential-unusable-ledger.d.ts.map +1 -1
  15. package/dist/credential-unusable-ledger.js +178 -38
  16. package/dist/credential-unusable-ledger.js.map +1 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/journal-fold-policy.d.ts.map +1 -1
  22. package/dist/journal-fold-policy.js +26 -2
  23. package/dist/journal-fold-policy.js.map +1 -1
  24. package/dist/pre-progress-refusal-ledger.d.ts +3 -6
  25. package/dist/pre-progress-refusal-ledger.d.ts.map +1 -1
  26. package/dist/pre-progress-refusal-ledger.js +7 -16
  27. package/dist/pre-progress-refusal-ledger.js.map +1 -1
  28. package/dist/project-partitions.d.ts +4 -0
  29. package/dist/project-partitions.d.ts.map +1 -1
  30. package/dist/project-partitions.js +7 -0
  31. package/dist/project-partitions.js.map +1 -1
  32. package/dist/quota-poll-lanes.d.ts +27 -9
  33. package/dist/quota-poll-lanes.d.ts.map +1 -1
  34. package/dist/quota-poll-lanes.js +95 -20
  35. package/dist/quota-poll-lanes.js.map +1 -1
  36. package/dist/quota-poll-pacer.d.ts +33 -36
  37. package/dist/quota-poll-pacer.d.ts.map +1 -1
  38. package/dist/quota-poll-pacer.js +115 -63
  39. package/dist/quota-poll-pacer.js.map +1 -1
  40. package/dist/quota-registry-support.d.ts +74 -0
  41. package/dist/quota-registry-support.d.ts.map +1 -1
  42. package/dist/quota-registry-support.js +154 -8
  43. package/dist/quota-registry-support.js.map +1 -1
  44. package/dist/quota-registry.d.ts +32 -7
  45. package/dist/quota-registry.d.ts.map +1 -1
  46. package/dist/quota-registry.js +76 -73
  47. package/dist/quota-registry.js.map +1 -1
  48. package/dist/server.d.ts.map +1 -1
  49. package/dist/server.js +2 -1
  50. package/dist/server.js.map +1 -1
  51. package/dist/terminal-authority.d.ts +1 -0
  52. package/dist/terminal-authority.d.ts.map +1 -1
  53. package/dist/thread-store-support.d.ts.map +1 -1
  54. package/dist/thread-store-support.js +10 -1
  55. package/dist/thread-store-support.js.map +1 -1
  56. package/dist/threads.d.ts +3 -1
  57. package/dist/threads.d.ts.map +1 -1
  58. package/dist/threads.js +2 -2
  59. package/dist/threads.js.map +1 -1
  60. package/package.json +6 -5
@@ -1,4 +1,4 @@
1
- import { QUOTA_GAP_ABSENCE_REASONS } from "@claudexor/schema";
1
+ import { QUOTA_GAP_ABSENCE_REASONS, quotaSourceTraits } from "@claudexor/schema";
2
2
  import { QuotaPollPacer } from "./quota-poll-pacer.js";
3
3
  import { earliestFreshRenewalAt, earliestQuotaRenewalAt, latestQuotaRenewalObservedAt, quotaSubjectIdentity, remainingQuotaRefreshDemand, } from "./quota-refresh-demand.js";
4
4
  export const QUOTA_POLL_INTERVAL_MS = 60_000;
@@ -66,7 +66,13 @@ export async function performPollSweep(lanes, deps) {
66
66
  * snapshots; an anonymous lane keeps the pre-existing global semantics.
67
67
  * `since` is the start of the cycle being judged: evidence it observed whose
68
68
  * window resets before the next tick is renewal due at that tick. */
69
- export function laneDemand(vendor, snapshots, subjects, now, dueBefore, since) {
69
+ export function laneDemand(vendor, snapshots, subjects, now, dueBefore, since, lanes = []) {
70
+ // A paced subject contributes neither demand nor a renewal horizon until
71
+ // its floor expires, so healthy siblings keep their ordinary cadence.
72
+ subjects = subjects?.filter((subject) => {
73
+ const lane = lanes.find((item) => item.vendor === subject.harness);
74
+ return lane?.pacer.rateLimitCooldownUntil(now, subject) == null;
75
+ });
70
76
  const laneSnapshots = vendor === null
71
77
  ? snapshots
72
78
  : snapshots.filter((snapshot) => snapshot.subject.harness === vendor);
@@ -80,13 +86,13 @@ export function laneDemand(vendor, snapshots, subjects, now, dueBefore, since) {
80
86
  };
81
87
  }
82
88
  /** Select which refreshers one cycle runs. A full (foreground) cycle honors
83
- * each vendor lane's rate-limit floor: a vendor that just said 429 is not
84
- * re-fanned-out by an explicit refresh — its skip is returned for additive
85
- * disclosure. A poll-scoped cycle was already gated by the sweep. Anonymous
89
+ * legacy vendor floors and current subject floors. Fully paced lanes stay
90
+ * idle; a partially paced source receives the same floor callbacks and
91
+ * continues its serial sweep for eligible accounts. Skips are disclosed. A poll-scoped cycle was already gated by the sweep. Anonymous
86
92
  * lanes never carry a floor and always run. Every running refresher is bound
87
93
  * to the cycle kind (foreground vs poll), so a source can honor an explicit
88
94
  * refresh while the registry keeps calling `refresh()`. */
89
- export function selectCycleEntries(refresherLanes, scope, nowMs) {
95
+ export function selectCycleEntries(refresherLanes, scope, nowMs, isCurrent = () => true, subjects = [], snapshots = []) {
90
96
  const skipped = scope === null
91
97
  ? refresherLanes.lanes.flatMap((lane) => {
92
98
  const until = lane.vendor === null ? null : lane.pacer.rateLimitCooldownUntil(nowMs);
@@ -96,13 +102,81 @@ export function selectCycleEntries(refresherLanes, scope, nowMs) {
96
102
  })
97
103
  : [];
98
104
  const skippedVendors = new Set(skipped.map((row) => row.vendor));
99
- const cycle = { foreground: scope === null };
105
+ const subjectSkips = subjects.flatMap((subject) => {
106
+ if (skippedVendors.has(subject.harness) || (scope !== null && scope.vendor !== subject.harness))
107
+ return [];
108
+ const lane = refresherLanes.lanes.find((item) => item.vendor === subject.harness);
109
+ const until = lane?.pacer.rateLimitCooldownUntil(nowMs, subject) ?? null;
110
+ return until === null
111
+ ? []
112
+ : [{ vendor: subject.harness, subject, not_before: new Date(until).toISOString() }];
113
+ });
114
+ for (const lane of refresherLanes.lanes) {
115
+ if (lane.vendor === null)
116
+ continue;
117
+ const owned = subjects.filter((subject) => subject.harness === lane.vendor);
118
+ if (owned.length > 0 &&
119
+ owned.every((subject) => lane.pacer.rateLimitCooldownUntil(nowMs, subject) !== null)) {
120
+ skippedVendors.add(lane.vendor);
121
+ }
122
+ }
100
123
  const running = refresherLanes.entries
101
124
  .filter((entry) => scope === null
102
125
  ? entry.lane.vendor === null || !skippedVendors.has(entry.lane.vendor)
103
- : entry.lane === scope)
104
- .map((entry) => ({ lane: entry.lane, refresh: () => entry.refresh(cycle) }));
105
- return { running, skipped };
126
+ : entry.lane === scope &&
127
+ (entry.lane.vendor === null || !skippedVendors.has(entry.lane.vendor)))
128
+ .map((entry) => ({
129
+ lane: entry.lane,
130
+ refresh: () => entry.refresh({
131
+ foreground: scope === null,
132
+ shouldRefresh: (subject) => scope === null ||
133
+ remainingQuotaRefreshDemand(snapshots.filter((snapshot) => snapshot.subject.credential_route === subject.credential_route), [subject], nowMs + QUOTA_POLL_INTERVAL_MS).size > 0,
134
+ pacing: {
135
+ bindCredentials: (bindings) => {
136
+ if (isCurrent())
137
+ entry.lane.pacer.bindCredentials(bindings);
138
+ },
139
+ cooldownUntil: (subject, now) => entry.lane.pacer.rateLimitCooldownUntil(now, subject),
140
+ noteRateLimited: (subject, observedAt, retryAfterMs) => {
141
+ if (isCurrent())
142
+ entry.lane.pacer.noteRateLimited(observedAt, retryAfterMs, subject);
143
+ },
144
+ },
145
+ }),
146
+ }));
147
+ return { running, skipped: [...skipped, ...subjectSkips] };
148
+ }
149
+ /** Commit validated source pacing independently of quota facts. Immediate
150
+ * producer callbacks already protect token aliases in the serial source pass;
151
+ * re-stating the same 429 here is idempotent. Sources without such callbacks
152
+ * still receive the subject floor after their batch validates. */
153
+ export function noteRefreshPacing(lanes, snapshots, claims, skipped, now) {
154
+ for (const snapshot of snapshots) {
155
+ if (quotaSourceTraits(snapshot.source).refreshDemandHarness !== snapshot.subject.harness)
156
+ continue;
157
+ lanes
158
+ .find((lane) => lane.vendor === snapshot.subject.harness)
159
+ ?.pacer.noteSubjectSuccess(snapshot.subject);
160
+ }
161
+ for (const claim of claims) {
162
+ const lane = lanes.find((item) => item.vendor === claim.subject.harness);
163
+ if (claim.reason === "rate_limited") {
164
+ lane?.pacer.noteRateLimited(Date.parse(claim.observed_at), claim.retry_after_ms ?? null, claim.subject);
165
+ }
166
+ if (claim.reason !== "poll_paced" && claim.reason !== "probe_skipped_rate_limited")
167
+ continue;
168
+ const until = lane?.pacer.rateLimitCooldownUntil(now, claim.subject);
169
+ const alreadySkipped = skipped.some((row) => row.subject &&
170
+ row.subject.harness === claim.subject.harness &&
171
+ row.subject.subject_id === claim.subject.subject_id &&
172
+ row.subject.credential_route === claim.subject.credential_route);
173
+ if (until && !alreadySkipped)
174
+ skipped.push({
175
+ vendor: claim.subject.harness,
176
+ subject: claim.subject,
177
+ not_before: new Date(until).toISOString(),
178
+ });
179
+ }
106
180
  }
107
181
  /** Absence recomputation covers exactly the lanes that RAN: an anonymous
108
182
  * lane's coverage is unknowable, so its cycle keeps the full rebuild. */
@@ -112,8 +186,8 @@ export function recomputeScopeFor(running) {
112
186
  ? null
113
187
  : new Set(ranLanes.map((lane) => lane.vendor));
114
188
  }
115
- /** Derived `poll_paced` gap rows: while a vendor lane's rate-limit floor is
116
- * active, every universe subject of that vendor lacking FRESH snapshot cover
189
+ /** Derived `poll_paced` gap rows: while a subject or legacy vendor floor is
190
+ * active, each affected universe subject lacking FRESH snapshot cover
117
191
  * and lacking a stored absence row is stated as paused — a live projection
118
192
  * (never journaled), stable per floor so the projection signature does not
119
193
  * churn markers on every read. Keeps a suppressed vendor's subjects from
@@ -125,12 +199,12 @@ export function derivePollPacedRows(lanes, subjects, existingRows, freshCovered,
125
199
  for (const lane of lanes) {
126
200
  if (lane.vendor === null)
127
201
  continue;
128
- const until = lane.pacer.rateLimitCooldownUntil(now);
129
- if (until === null)
130
- continue;
131
202
  for (const subject of subjects) {
132
203
  if (subject.harness !== lane.vendor)
133
204
  continue;
205
+ const until = lane.pacer.rateLimitCooldownUntil(now, subject);
206
+ if (until === null)
207
+ continue;
134
208
  const key = quotaSubjectIdentity(subject);
135
209
  if (freshCovered.has(key) || present.has(key))
136
210
  continue;
@@ -138,20 +212,21 @@ export function derivePollPacedRows(lanes, subjects, existingRows, freshCovered,
138
212
  rows.push({
139
213
  subject,
140
214
  reason: "poll_paced",
141
- detail: `vendor poll paused by rate-limit cooldown until ${new Date(until).toISOString()}`,
142
- observed_at: new Date(lane.pacer.rateLimitObservedAt(now)).toISOString(),
215
+ detail: `quota poll paused by rate-limit cooldown until ${new Date(until).toISOString()}`,
216
+ observed_at: new Date(lane.pacer.rateLimitObservedAt(now, subject)).toISOString(),
143
217
  });
144
218
  }
145
219
  }
146
220
  return rows;
147
221
  }
148
- /** Subject-identity cover sets over one active-snapshot view. Gap rows are
149
- * silenced only by the FRESH set; every other reason by any active snapshot. */
222
+ /** Subject-identity cover sets over one active-snapshot view. A partial
223
+ * measured window cannot cover a failed or paced full-inventory read. */
150
224
  export function subjectCoverSets(active) {
151
225
  return {
152
226
  covered: new Set(active.map((snapshot) => quotaSubjectIdentity(snapshot.subject))),
153
227
  freshCovered: new Set(active
154
- .filter((snapshot) => snapshot.freshness === "fresh")
228
+ .filter((snapshot) => snapshot.freshness === "fresh" &&
229
+ quotaSourceTraits(snapshot.source).snapshotMode === "full")
155
230
  .map((snapshot) => quotaSubjectIdentity(snapshot.subject))),
156
231
  };
157
232
  }
@@ -1 +1 @@
1
- {"version":3,"file":"quota-poll-lanes.js","sourceRoot":"","sources":["../src/quota-poll-lanes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,cAAc,EAA6B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Daemon-private persistence for one pacer fact: the per-vendor rate-limit
3
- * floor. Deliberately OUTSIDE the quota journal and every quota projection
3
+ * Daemon-private persistence for poll floors: current subject/route floors and
4
+ * legacy per-vendor floors retained through their recorded deadlines. Deliberately OUTSIDE the quota journal and every quota projection
4
5
  * (owner decision 7=A): a throttled POLL is pacing state, never quota truth —
5
6
  * journaling it as a cooldown would read as "window exhausted" to rotation
6
7
  * and to external consumers of the quota surface.
7
8
  */
8
9
  export interface QuotaPacerStateStore {
9
- /** Millisecond epoch before which the vendor must not be polled; 0 = none. */
10
+ /** Legacy vendor floor, retained for upgrades; 0 = none. */
10
11
  load(vendor: string): number;
11
- save(vendor: string, notBeforeMs: number): void;
12
+ loadSubject?(subject: QuotaSubject): number;
13
+ saveSubject?(subject: QuotaSubject, notBeforeMs: number): void;
12
14
  }
13
15
  /** File-backed store under the daemon dir. Best-effort durability: a missing,
14
16
  * corrupt, or unwritable file only forgets the floor (fail-open to polling),
15
17
  * it never breaks the poll cycle. */
16
18
  export declare function quotaPacerFileStore(dir: string): QuotaPacerStateStore;
17
- /**
18
- * Completion-anchored poll pacing for ONE vendor lane of the quota registry
19
- * (one instance per vendor with a registered refresher), so a permanently
20
- * unsatisfiable subject of one vendor can no longer pin every other vendor's
21
- * refresh cadence at the 15-minute ceiling. Two independent gates:
22
- *
23
- * - the credential-demand backoff (`failures`/`notBefore`): in-memory,
24
- * exponential per unsatisfied cycle, reset by a credential change — the
25
- * pre-existing semantics, now per lane;
26
- * - the vendor rate-limit floor (`rateLimitedNotBefore`): armed when a cycle
27
- * observes a typed `rate_limited` absence for this vendor, honoring the
28
- * vendor's Retry-After when known (max with the exponential ladder, 60s
29
- * minimum). Persisted through the daemon-private store so a restart is not
30
- * a 429 amplifier, and deliberately NOT reset by a credential change —
31
- * logging in again does not un-rate-limit the vendor endpoint.
32
- *
33
- * Evidence/demand semantics stay with QuotaRegistry; this class owns only
34
- * scheduling state. Single-flight of the poll sweep also lives in the
35
- * registry, which drives every lane from one sweep.
36
- */
19
+ /** One vendor lane's demand ladder plus subject/route poll floors. Healthy
20
+ * renewals retain the existing single serial sweep. Only legacy persisted
21
+ * vendor floors suppress the whole lane; new 429s never infer vendor scope. */
37
22
  export declare class QuotaPollPacer {
38
23
  private readonly vendor;
39
24
  private readonly store?;
25
+ private readonly subjectFloors;
26
+ private credentialAliases;
27
+ private readonly subjectFailures;
40
28
  private failures;
41
29
  private notBefore;
42
30
  /** Completion instant of the cycle that armed the current retry ladder
@@ -47,10 +35,8 @@ export declare class QuotaPollPacer {
47
35
  /** When the active floor was observed (0 = unknown, e.g. store-loaded). */
48
36
  private rateLimitedSince;
49
37
  constructor(vendor?: string | null, store?: QuotaPacerStateStore | undefined);
50
- /** Credential/routability change: drop only the credential-demand backoff.
51
- * The vendor rate-limit floor survives — it is about the vendor endpoint,
52
- * not about which credentials exist (and a daemon restart or profile toggle
53
- * must not become a 429 amplifier). */
38
+ /** Credential/routability changes reset retry ladders, never recorded poll
39
+ * floors: a profile toggle or restart must not become a 429 amplifier. */
54
40
  noteCredentialChange(): void;
55
41
  /** May the lane poll now? The vendor rate-limit floor is absolute. The retry
56
42
  * ladder is not: `renewalDueObservedAt` — the latest observation instant of
@@ -60,14 +46,23 @@ export declare class QuotaPollPacer {
60
46
  * ladder was armed and the ladder must not postpone its renewal. Evidence
61
47
  * the arming cycle itself produced is capped by `armBackoff` instead. */
62
48
  pollEligible(now: number, renewalDueObservedAt?: number | null): boolean;
63
- /** The active vendor rate-limit floor, or null when none is in effect. */
64
- rateLimitCooldownUntil(now: number): number | null;
49
+ /** Active floor for a subject, or legacy whole-lane floor when omitted. */
50
+ rateLimitCooldownUntil(now: number, subject?: QuotaSubject): number | null;
51
+ /** Bind the current source's token-identical rows without retaining tokens or
52
+ * hashes on disk. Pre-binding the complete read makes profile order irrelevant
53
+ * after restart: an alias preceding the cooled row inherits its saved floor. */
54
+ bindCredentials(bindings: ReadonlyArray<{
55
+ subject: QuotaSubject;
56
+ credentialHash: string;
57
+ }>): void;
58
+ private subjectFloor;
59
+ private saveSubjectFloor;
65
60
  /** Stable observation stamp for the ACTIVE floor's derived gap rows: the
66
61
  * instant the floor was observed. A store-loaded floor (daemon restart)
67
62
  * has no recorded observation, so the first read anchors it — stability of
68
63
  * the projection signature matters more than the exact historical instant,
69
64
  * and the anchor is honest ("known paused since at least then"). */
70
- rateLimitObservedAt(now: number): number;
65
+ rateLimitObservedAt(now: number, subject?: QuotaSubject): number;
71
66
  /** A cycle for this lane completed: reset on fully satisfied demand, else
72
67
  * exponential backoff anchored at completion (never the stale start) and
73
68
  * capped at `renewalNotBefore` — the tick by which evidence this cycle DID
@@ -77,11 +72,13 @@ export declare class QuotaPollPacer {
77
72
  * the 15-minute ceiling). Null = no satisfied evidence is due later. */
78
73
  notePollSuccess(completedAt: number, demandRemains: boolean, renewalNotBefore?: number | null): void;
79
74
  notePollFailure(completedAt: number, renewalNotBefore?: number | null): void;
80
- /** A cycle observed a typed `rate_limited` absence for this vendor: arm the
81
- * floor at max(exponential ladder, vendor Retry-After), monotonic, and
82
- * persist it (a null Retry-After — Anthropic does not always send one —
83
- * still arms the exponential-derived floor). */
84
- noteRateLimited(observedAt: number, retryAfterMs: number | null): void;
75
+ /** A primary observation resets this subject's missing-header retry ladder.
76
+ * Its already-recorded Retry-After floor is still honored until its deadline. */
77
+ noteSubjectSuccess(subject: QuotaSubject): void;
78
+ /** A 429 paces only its subject and known token-identical aliases. The
79
+ * no-header exponential ladder belongs to that identity too: a healthy
80
+ * sibling's successful renewal must neither reset it nor acquire it. */
81
+ noteRateLimited(observedAt: number, retryAfterMs: number | null, subject: QuotaSubject): void;
85
82
  private armBackoff;
86
83
  }
87
84
  //# sourceMappingURL=quota-poll-pacer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quota-poll-pacer.d.ts","sourceRoot":"","sources":["../src/quota-poll-pacer.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;I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MAAM,GAAG,IAAW,GAAG,OAAO,CAI7E;IAED,2EAA2E;IAC3E,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAIzE;IAED;;oFAEgF;IAChF,eAAe,CACb,QAAQ,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,YAAY,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC,GACzE,IAAI,CAsBN;IAED,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,gBAAgB;IAUxB;;;;wEAIoE;IACpE,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAQ/D;IAED;;;;;;4EAMwE;IACxE,eAAe,CACb,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,OAAO,EACtB,gBAAgB,GAAE,MAAM,GAAG,IAAW,GACrC,IAAI,CAQN;IAED,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,GAAE,MAAM,GAAG,IAAW,GAAG,IAAI,CAEjF;IAED;qFACiF;IACjF,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAI9C;IAED;;4EAEwE;IACxE,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAU5F;IAED,OAAO,CAAC,UAAU;CAOnB"}
@@ -15,55 +15,50 @@ export function quotaPacerFileStore(dir) {
15
15
  const read = () => {
16
16
  try {
17
17
  const parsed = JSON.parse(readFileSync(path, "utf8"));
18
- return parsed?.version === 1 &&
19
- parsed.vendors !== null &&
20
- typeof parsed.vendors === "object" &&
21
- !Array.isArray(parsed.vendors)
22
- ? parsed.vendors
18
+ const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value)
19
+ ? value
23
20
  : {};
21
+ return parsed?.version === 1 || parsed?.version === 2
22
+ ? {
23
+ vendors: record(parsed.vendors),
24
+ subjects: record(parsed.subjects),
25
+ }
26
+ : { vendors: {}, subjects: {} };
24
27
  }
25
28
  catch {
26
- return {};
29
+ return { vendors: {}, subjects: {} };
27
30
  }
28
31
  };
32
+ const load = (section, key) => {
33
+ const iso = read()[section][key]?.not_before;
34
+ const at = typeof iso === "string" ? Date.parse(iso) : Number.NaN;
35
+ return Number.isFinite(at) ? at : 0;
36
+ };
37
+ const save = (section, key, until) => {
38
+ const state = read();
39
+ state[section][key] = { not_before: new Date(until).toISOString() };
40
+ const tmp = `${path}.tmp.${process.pid}`;
41
+ writeFileSync(tmp, `${JSON.stringify({ version: 2, ...state }, null, 2)}\n`);
42
+ renameSync(tmp, path);
43
+ };
29
44
  return {
30
- load(vendor) {
31
- const iso = read()[vendor]?.not_before;
32
- const at = typeof iso === "string" ? Date.parse(iso) : Number.NaN;
33
- return Number.isFinite(at) ? at : 0;
34
- },
35
- save(vendor, notBeforeMs) {
36
- const vendors = read();
37
- vendors[vendor] = { not_before: new Date(notBeforeMs).toISOString() };
38
- const tmp = `${path}.tmp.${process.pid}`;
39
- writeFileSync(tmp, `${JSON.stringify({ version: 1, vendors }, null, 2)}\n`);
40
- renameSync(tmp, path);
41
- },
45
+ load: (vendor) => load("vendors", vendor),
46
+ loadSubject: (subject) => load("subjects", subjectKey(subject)),
47
+ saveSubject: (subject, until) => save("subjects", subjectKey(subject), until),
42
48
  };
43
49
  }
44
- /**
45
- * Completion-anchored poll pacing for ONE vendor lane of the quota registry
46
- * (one instance per vendor with a registered refresher), so a permanently
47
- * unsatisfiable subject of one vendor can no longer pin every other vendor's
48
- * refresh cadence at the 15-minute ceiling. Two independent gates:
49
- *
50
- * - the credential-demand backoff (`failures`/`notBefore`): in-memory,
51
- * exponential per unsatisfied cycle, reset by a credential change — the
52
- * pre-existing semantics, now per lane;
53
- * - the vendor rate-limit floor (`rateLimitedNotBefore`): armed when a cycle
54
- * observes a typed `rate_limited` absence for this vendor, honoring the
55
- * vendor's Retry-After when known (max with the exponential ladder, 60s
56
- * minimum). Persisted through the daemon-private store so a restart is not
57
- * a 429 amplifier, and deliberately NOT reset by a credential change —
58
- * logging in again does not un-rate-limit the vendor endpoint.
59
- *
60
- * Evidence/demand semantics stay with QuotaRegistry; this class owns only
61
- * scheduling state. Single-flight of the poll sweep also lives in the
62
- * registry, which drives every lane from one sweep.
63
- */
50
+ function subjectKey(subject) {
51
+ return JSON.stringify([subject.harness, subject.credential_route, subject.subject_id]);
52
+ }
53
+ /** One vendor lane's demand ladder plus subject/route poll floors. Healthy
54
+ * renewals retain the existing single serial sweep. Only legacy persisted
55
+ * vendor floors suppress the whole lane; new 429s never infer vendor scope. */
64
56
  export class QuotaPollPacer {
65
57
  vendor;
66
58
  store;
59
+ subjectFloors = new Map();
60
+ credentialAliases = new Map();
61
+ subjectFailures = new Map();
67
62
  failures = 0;
68
63
  notBefore = 0;
69
64
  /** Completion instant of the cycle that armed the current retry ladder
@@ -85,14 +80,13 @@ export class QuotaPollPacer {
85
80
  }
86
81
  }
87
82
  }
88
- /** Credential/routability change: drop only the credential-demand backoff.
89
- * The vendor rate-limit floor survives — it is about the vendor endpoint,
90
- * not about which credentials exist (and a daemon restart or profile toggle
91
- * must not become a 429 amplifier). */
83
+ /** Credential/routability changes reset retry ladders, never recorded poll
84
+ * floors: a profile toggle or restart must not become a 429 amplifier. */
92
85
  noteCredentialChange() {
93
86
  this.failures = 0;
94
87
  this.notBefore = 0;
95
88
  this.armedAt = 0;
89
+ this.subjectFailures.clear();
96
90
  }
97
91
  /** May the lane poll now? The vendor rate-limit floor is absolute. The retry
98
92
  * ladder is not: `renewalDueObservedAt` — the latest observation instant of
@@ -108,16 +102,74 @@ export class QuotaPollPacer {
108
102
  return true;
109
103
  return renewalDueObservedAt !== null && renewalDueObservedAt > this.armedAt;
110
104
  }
111
- /** The active vendor rate-limit floor, or null when none is in effect. */
112
- rateLimitCooldownUntil(now) {
113
- return now < this.rateLimitedNotBefore ? this.rateLimitedNotBefore : null;
105
+ /** Active floor for a subject, or legacy whole-lane floor when omitted. */
106
+ rateLimitCooldownUntil(now, subject) {
107
+ const floor = subject === undefined ? 0 : this.subjectFloor(subject).until;
108
+ const until = Math.max(this.rateLimitedNotBefore, floor);
109
+ return now < until ? until : null;
110
+ }
111
+ /** Bind the current source's token-identical rows without retaining tokens or
112
+ * hashes on disk. Pre-binding the complete read makes profile order irrelevant
113
+ * after restart: an alias preceding the cooled row inherits its saved floor. */
114
+ bindCredentials(bindings) {
115
+ const groups = new Map();
116
+ for (const { subject, credentialHash } of bindings) {
117
+ const identity = JSON.stringify([subject.harness, subject.credential_route, credentialHash]);
118
+ const group = groups.get(identity) ?? [];
119
+ group.push(subject);
120
+ groups.set(identity, group);
121
+ }
122
+ this.credentialAliases = new Map();
123
+ for (const group of groups.values()) {
124
+ const floor = group.reduce((current, subject) => {
125
+ const candidate = this.subjectFloor(subject);
126
+ return candidate.until > current.until ? candidate : current;
127
+ }, { until: 0, observed: 0 });
128
+ for (const subject of group) {
129
+ this.credentialAliases.set(subjectKey(subject), group);
130
+ this.saveSubjectFloor(subject, floor.until, floor.observed);
131
+ }
132
+ }
133
+ }
134
+ subjectFloor(subject) {
135
+ const key = subjectKey(subject);
136
+ let floor = this.subjectFloors.get(key);
137
+ if (floor === undefined) {
138
+ let until = 0;
139
+ try {
140
+ until = this.store?.loadSubject?.(subject) ?? 0;
141
+ }
142
+ catch {
143
+ /* fail-open */
144
+ }
145
+ floor = { until, observed: 0 };
146
+ this.subjectFloors.set(key, floor);
147
+ }
148
+ return floor;
149
+ }
150
+ saveSubjectFloor(subject, until, observed) {
151
+ if (until <= this.subjectFloor(subject).until)
152
+ return;
153
+ this.subjectFloors.set(subjectKey(subject), { until, observed });
154
+ try {
155
+ this.store?.saveSubject?.(subject, until);
156
+ }
157
+ catch {
158
+ /* fail-open */
159
+ }
114
160
  }
115
161
  /** Stable observation stamp for the ACTIVE floor's derived gap rows: the
116
162
  * instant the floor was observed. A store-loaded floor (daemon restart)
117
163
  * has no recorded observation, so the first read anchors it — stability of
118
164
  * the projection signature matters more than the exact historical instant,
119
165
  * and the anchor is honest ("known paused since at least then"). */
120
- rateLimitObservedAt(now) {
166
+ rateLimitObservedAt(now, subject) {
167
+ if (subject !== undefined && this.subjectFloor(subject).until > this.rateLimitedNotBefore) {
168
+ const floor = this.subjectFloor(subject);
169
+ if (floor.observed === 0)
170
+ floor.observed = now;
171
+ return floor.observed;
172
+ }
121
173
  if (this.rateLimitedSince === 0)
122
174
  this.rateLimitedSince = now;
123
175
  return this.rateLimitedSince;
@@ -141,25 +193,25 @@ export class QuotaPollPacer {
141
193
  notePollFailure(completedAt, renewalNotBefore = null) {
142
194
  this.armBackoff(completedAt, renewalNotBefore);
143
195
  }
144
- /** A cycle observed a typed `rate_limited` absence for this vendor: arm the
145
- * floor at max(exponential ladder, vendor Retry-After), monotonic, and
146
- * persist it (a null Retry-After — Anthropic does not always send one —
147
- * still arms the exponential-derived floor). */
148
- noteRateLimited(observedAt, retryAfterMs) {
149
- const exponential = Math.min(POLL_BACKOFF_MS * 2 ** Math.max(this.failures - 1, 0), MAX_POLL_BACKOFF_MS);
196
+ /** A primary observation resets this subject's missing-header retry ladder.
197
+ * Its already-recorded Retry-After floor is still honored until its deadline. */
198
+ noteSubjectSuccess(subject) {
199
+ for (const alias of this.credentialAliases.get(subjectKey(subject)) ?? [subject]) {
200
+ this.subjectFailures.delete(subjectKey(alias));
201
+ }
202
+ }
203
+ /** A 429 paces only its subject and known token-identical aliases. The
204
+ * no-header exponential ladder belongs to that identity too: a healthy
205
+ * sibling's successful renewal must neither reset it nor acquire it. */
206
+ noteRateLimited(observedAt, retryAfterMs, subject) {
207
+ const prior = this.subjectFailures.get(subjectKey(subject));
208
+ const count = prior?.observedAt === observedAt ? prior.count : (prior?.count ?? 0) + 1;
209
+ const exponential = Math.min(POLL_BACKOFF_MS * 2 ** (count - 1), MAX_POLL_BACKOFF_MS);
150
210
  const floor = Math.max(exponential, Math.min(retryAfterMs ?? 0, MAX_RATE_LIMIT_FLOOR_MS));
151
211
  const until = observedAt + floor;
152
- if (until <= this.rateLimitedNotBefore)
153
- return;
154
- this.rateLimitedNotBefore = until;
155
- this.rateLimitedSince = observedAt;
156
- if (this.vendor !== null) {
157
- try {
158
- this.store?.save(this.vendor, until);
159
- }
160
- catch {
161
- /* fail-open: losing the durable floor only re-allows polling */
162
- }
212
+ for (const alias of this.credentialAliases.get(subjectKey(subject)) ?? [subject]) {
213
+ this.subjectFailures.set(subjectKey(alias), { observedAt, count });
214
+ this.saveSubjectFloor(alias, until, observedAt);
163
215
  }
164
216
  }
165
217
  armBackoff(completedAt, renewalNotBefore) {
@@ -1 +1 @@
1
- {"version":3,"file":"quota-poll-pacer.js","sourceRoot":"","sources":["../src/quota-poll-pacer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,mBAAmB,GAAG,EAAE,GAAG,MAAM,CAAC;AACxC;;;oDAGoD;AACpD,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;AAerD;;qCAEqC;AACrC,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,wBAAwB,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,GAA6C,EAAE;QAC1D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAGnD,CAAC;YACF,OAAO,MAAM,EAAE,OAAO,KAAK,CAAC;gBAC1B,MAAM,CAAC,OAAO,KAAK,IAAI;gBACvB,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;gBAClC,CAAC,KAAK,C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