audit-tools 0.33.7 → 0.33.10

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 (68) hide show
  1. package/dist/audit/orchestrator/rollingDispatch.js +1 -1
  2. package/dist/audit/orchestrator/rollingDispatch.js.map +1 -1
  3. package/dist/remediate/steps/nextStep.js +1 -1
  4. package/dist/remediate/steps/nextStep.js.map +1 -1
  5. package/dist/shared/dispatch/admissionLeaseReconcile.js +1 -1
  6. package/dist/shared/dispatch/admissionLeaseReconcile.js.map +1 -1
  7. package/dist/shared/dispatch/admissionLoop.d.ts +42 -10
  8. package/dist/shared/dispatch/admissionLoop.d.ts.map +1 -1
  9. package/dist/shared/dispatch/admissionLoop.js +74 -7
  10. package/dist/shared/dispatch/admissionLoop.js.map +1 -1
  11. package/dist/shared/dispatch/dispatchQuotaContract.d.ts +82 -7
  12. package/dist/shared/dispatch/dispatchQuotaContract.d.ts.map +1 -1
  13. package/dist/shared/dispatch/hostDispatchWall.d.ts.map +1 -1
  14. package/dist/shared/dispatch/hostDispatchWall.js +8 -0
  15. package/dist/shared/dispatch/hostDispatchWall.js.map +1 -1
  16. package/dist/shared/dispatch/rollingDispatch.d.ts +17 -10
  17. package/dist/shared/dispatch/rollingDispatch.d.ts.map +1 -1
  18. package/dist/shared/dispatch/rollingDispatch.js +49 -33
  19. package/dist/shared/dispatch/rollingDispatch.js.map +1 -1
  20. package/dist/shared/dispatch/unifiedRolling.d.ts +3 -2
  21. package/dist/shared/dispatch/unifiedRolling.d.ts.map +1 -1
  22. package/dist/shared/dispatch/unifiedRolling.js +12 -4
  23. package/dist/shared/dispatch/unifiedRolling.js.map +1 -1
  24. package/dist/shared/index.d.ts +2 -2
  25. package/dist/shared/index.d.ts.map +1 -1
  26. package/dist/shared/index.js +5 -1
  27. package/dist/shared/index.js.map +1 -1
  28. package/dist/shared/providers/auditorSources.js +16 -0
  29. package/dist/shared/providers/auditorSources.js.map +1 -1
  30. package/dist/shared/quota/accountId.d.ts +70 -0
  31. package/dist/shared/quota/accountId.d.ts.map +1 -1
  32. package/dist/shared/quota/accountId.js +82 -5
  33. package/dist/shared/quota/accountId.js.map +1 -1
  34. package/dist/shared/quota/apiPool.d.ts.map +1 -1
  35. package/dist/shared/quota/apiPool.js +12 -1
  36. package/dist/shared/quota/apiPool.js.map +1 -1
  37. package/dist/shared/quota/capacity.d.ts +82 -0
  38. package/dist/shared/quota/capacity.d.ts.map +1 -1
  39. package/dist/shared/quota/capacity.js +42 -1
  40. package/dist/shared/quota/capacity.js.map +1 -1
  41. package/dist/shared/quota/claudeOAuthQuotaSource.d.ts.map +1 -1
  42. package/dist/shared/quota/claudeOAuthQuotaSource.js +46 -8
  43. package/dist/shared/quota/claudeOAuthQuotaSource.js.map +1 -1
  44. package/dist/shared/quota/quotaSource.d.ts +73 -2
  45. package/dist/shared/quota/quotaSource.d.ts.map +1 -1
  46. package/dist/shared/quota/quotaSource.js +57 -2
  47. package/dist/shared/quota/quotaSource.js.map +1 -1
  48. package/dist/shared/quota/reservationLedger.d.ts +98 -26
  49. package/dist/shared/quota/reservationLedger.d.ts.map +1 -1
  50. package/dist/shared/quota/reservationLedger.js +109 -37
  51. package/dist/shared/quota/reservationLedger.js.map +1 -1
  52. package/dist/shared/quota/scheduler.d.ts +25 -1
  53. package/dist/shared/quota/scheduler.d.ts.map +1 -1
  54. package/dist/shared/quota/scheduler.js +115 -10
  55. package/dist/shared/quota/scheduler.js.map +1 -1
  56. package/dist/shared/quota/state.d.ts +24 -9
  57. package/dist/shared/quota/state.d.ts.map +1 -1
  58. package/dist/shared/quota/state.js +43 -16
  59. package/dist/shared/quota/state.js.map +1 -1
  60. package/dist/shared/quota/types.d.ts +57 -6
  61. package/dist/shared/quota/types.d.ts.map +1 -1
  62. package/dist/shared/quota/types.js.map +1 -1
  63. package/dist/shared/quota/windowConstraints.d.ts +56 -0
  64. package/dist/shared/quota/windowConstraints.d.ts.map +1 -0
  65. package/dist/shared/quota/windowConstraints.js +71 -0
  66. package/dist/shared/quota/windowConstraints.js.map +1 -0
  67. package/docs/audit-pkg/operator-guide.md +4 -1
  68. package/package.json +1 -1
@@ -87,12 +87,12 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
87
87
  pool_id: z.ZodNullable<z.ZodString>;
88
88
  resource_key: z.ZodNullable<z.ZodString>;
89
89
  admitted: z.ZodBoolean;
90
- reason: z.ZodEnum<["admitted", "no_capable_pool", "budget_exhausted", "cap_reached", "packet_oversized"]>;
90
+ reason: z.ZodEnum<["admitted", "no_capable_pool", "budget_exhausted", "cap_reached", "packet_oversized", "window_uncalibrated"]>;
91
91
  headroom_before: z.ZodOptional<z.ZodNumber>;
92
92
  outstanding_before: z.ZodOptional<z.ZodNumber>;
93
93
  cost: z.ZodNumber;
94
94
  }, "strict", z.ZodTypeAny, {
95
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized";
95
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
96
96
  pool_id: string | null;
97
97
  cost: number;
98
98
  admitted: boolean;
@@ -101,7 +101,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
101
101
  headroom_before?: number | undefined;
102
102
  outstanding_before?: number | undefined;
103
103
  }, {
104
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized";
104
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
105
105
  pool_id: string | null;
106
106
  cost: number;
107
107
  admitted: boolean;
@@ -121,7 +121,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
121
121
  granted_packet_ids: string[];
122
122
  declared_cap: number | null;
123
123
  explains: {
124
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized";
124
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
125
125
  pool_id: string | null;
126
126
  cost: number;
127
127
  admitted: boolean;
@@ -141,7 +141,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
141
141
  granted_packet_ids: string[];
142
142
  declared_cap: number | null;
143
143
  explains: {
144
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized";
144
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
145
145
  pool_id: string | null;
146
146
  cost: number;
147
147
  admitted: boolean;
@@ -195,6 +195,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
195
195
  is_conversation_host: z.ZodBoolean;
196
196
  cooldown_until: z.ZodNullable<z.ZodString>;
197
197
  estimated_wave_tokens: z.ZodNumber;
198
+ account_key: z.ZodString;
198
199
  binding_cap: z.ZodEnum<["rpm", "tpm", "token_budget", "cooldown", "host_concurrency", "none"]>;
199
200
  remaining_token_budget: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
200
201
  binding_window: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -210,6 +211,28 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
210
211
  reset_at: string | null;
211
212
  budget: number;
212
213
  }>>>;
214
+ window_budgets: z.ZodOptional<z.ZodArray<z.ZodObject<{
215
+ scope: z.ZodEnum<["account", "model"]>;
216
+ label: z.ZodString;
217
+ budget: z.ZodNumber;
218
+ unit: z.ZodEnum<["tokens", "percent"]>;
219
+ tokens_per_pct: z.ZodOptional<z.ZodNumber>;
220
+ reset_at: z.ZodNullable<z.ZodString>;
221
+ }, "strict", z.ZodTypeAny, {
222
+ label: string;
223
+ scope: "model" | "account";
224
+ reset_at: string | null;
225
+ budget: number;
226
+ unit: "tokens" | "percent";
227
+ tokens_per_pct?: number | undefined;
228
+ }, {
229
+ label: string;
230
+ scope: "model" | "account";
231
+ reset_at: string | null;
232
+ budget: number;
233
+ unit: "tokens" | "percent";
234
+ tokens_per_pct?: number | undefined;
235
+ }>, "many">>;
213
236
  in_flight_tokens: z.ZodOptional<z.ZodNumber>;
214
237
  calibrating: z.ZodOptional<z.ZodBoolean>;
215
238
  quota_source_snapshot: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -221,16 +244,19 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
221
244
  source: z.ZodString;
222
245
  windows: z.ZodOptional<z.ZodArray<z.ZodObject<{
223
246
  label: z.ZodString;
247
+ scope: z.ZodEnum<["account", "model"]>;
224
248
  remaining_pct: z.ZodNullable<z.ZodNumber>;
225
249
  reset_at: z.ZodNullable<z.ZodString>;
226
250
  tokens_remaining: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
227
251
  }, "strict", z.ZodTypeAny, {
228
252
  label: string;
253
+ scope: "model" | "account";
229
254
  remaining_pct: number | null;
230
255
  reset_at: string | null;
231
256
  tokens_remaining?: number | null | undefined;
232
257
  }, {
233
258
  label: string;
259
+ scope: "model" | "account";
234
260
  remaining_pct: number | null;
235
261
  reset_at: string | null;
236
262
  tokens_remaining?: number | null | undefined;
@@ -244,6 +270,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
244
270
  source: string;
245
271
  windows?: {
246
272
  label: string;
273
+ scope: "model" | "account";
247
274
  remaining_pct: number | null;
248
275
  reset_at: string | null;
249
276
  tokens_remaining?: number | null | undefined;
@@ -257,6 +284,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
257
284
  source: string;
258
285
  windows?: {
259
286
  label: string;
287
+ scope: "model" | "account";
260
288
  remaining_pct: number | null;
261
289
  reset_at: string | null;
262
290
  tokens_remaining?: number | null | undefined;
@@ -289,6 +317,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
289
317
  } | null;
290
318
  is_conversation_host: boolean;
291
319
  estimated_wave_tokens: number;
320
+ account_key: string;
292
321
  binding_cap: "rpm" | "tpm" | "token_budget" | "cooldown" | "host_concurrency" | "none";
293
322
  capability_rank?: number | null | undefined;
294
323
  rank?: "deep" | "small" | "standard" | undefined;
@@ -299,6 +328,14 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
299
328
  reset_at: string | null;
300
329
  budget: number;
301
330
  } | null | undefined;
331
+ window_budgets?: {
332
+ label: string;
333
+ scope: "model" | "account";
334
+ reset_at: string | null;
335
+ budget: number;
336
+ unit: "tokens" | "percent";
337
+ tokens_per_pct?: number | undefined;
338
+ }[] | undefined;
302
339
  in_flight_tokens?: number | undefined;
303
340
  quota_source_snapshot?: {
304
341
  remaining_pct: number | null;
@@ -309,6 +346,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
309
346
  source: string;
310
347
  windows?: {
311
348
  label: string;
349
+ scope: "model" | "account";
312
350
  remaining_pct: number | null;
313
351
  reset_at: string | null;
314
352
  tokens_remaining?: number | null | undefined;
@@ -340,6 +378,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
340
378
  } | null;
341
379
  is_conversation_host: boolean;
342
380
  estimated_wave_tokens: number;
381
+ account_key: string;
343
382
  binding_cap: "rpm" | "tpm" | "token_budget" | "cooldown" | "host_concurrency" | "none";
344
383
  capability_rank?: number | null | undefined;
345
384
  rank?: "deep" | "small" | "standard" | undefined;
@@ -350,6 +389,14 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
350
389
  reset_at: string | null;
351
390
  budget: number;
352
391
  } | null | undefined;
392
+ window_budgets?: {
393
+ label: string;
394
+ scope: "model" | "account";
395
+ reset_at: string | null;
396
+ budget: number;
397
+ unit: "tokens" | "percent";
398
+ tokens_per_pct?: number | undefined;
399
+ }[] | undefined;
353
400
  in_flight_tokens?: number | undefined;
354
401
  quota_source_snapshot?: {
355
402
  remaining_pct: number | null;
@@ -360,6 +407,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
360
407
  source: string;
361
408
  windows?: {
362
409
  label: string;
410
+ scope: "model" | "account";
363
411
  remaining_pct: number | null;
364
412
  reset_at: string | null;
365
413
  tokens_remaining?: number | null | undefined;
@@ -380,16 +428,19 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
380
428
  source: z.ZodString;
381
429
  windows: z.ZodOptional<z.ZodArray<z.ZodObject<{
382
430
  label: z.ZodString;
431
+ scope: z.ZodEnum<["account", "model"]>;
383
432
  remaining_pct: z.ZodNullable<z.ZodNumber>;
384
433
  reset_at: z.ZodNullable<z.ZodString>;
385
434
  tokens_remaining: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
386
435
  }, "strict", z.ZodTypeAny, {
387
436
  label: string;
437
+ scope: "model" | "account";
388
438
  remaining_pct: number | null;
389
439
  reset_at: string | null;
390
440
  tokens_remaining?: number | null | undefined;
391
441
  }, {
392
442
  label: string;
443
+ scope: "model" | "account";
393
444
  remaining_pct: number | null;
394
445
  reset_at: string | null;
395
446
  tokens_remaining?: number | null | undefined;
@@ -403,6 +454,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
403
454
  source: string;
404
455
  windows?: {
405
456
  label: string;
457
+ scope: "model" | "account";
406
458
  remaining_pct: number | null;
407
459
  reset_at: string | null;
408
460
  tokens_remaining?: number | null | undefined;
@@ -416,6 +468,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
416
468
  source: string;
417
469
  windows?: {
418
470
  label: string;
471
+ scope: "model" | "account";
419
472
  remaining_pct: number | null;
420
473
  reset_at: string | null;
421
474
  tokens_remaining?: number | null | undefined;
@@ -484,7 +537,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
484
537
  granted_packet_ids: string[];
485
538
  declared_cap: number | null;
486
539
  explains: {
487
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized";
540
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
488
541
  pool_id: string | null;
489
542
  cost: number;
490
543
  admitted: boolean;
@@ -505,6 +558,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
505
558
  source: string;
506
559
  windows?: {
507
560
  label: string;
561
+ scope: "model" | "account";
508
562
  remaining_pct: number | null;
509
563
  reset_at: string | null;
510
564
  tokens_remaining?: number | null | undefined;
@@ -531,6 +585,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
531
585
  } | null;
532
586
  is_conversation_host: boolean;
533
587
  estimated_wave_tokens: number;
588
+ account_key: string;
534
589
  binding_cap: "rpm" | "tpm" | "token_budget" | "cooldown" | "host_concurrency" | "none";
535
590
  capability_rank?: number | null | undefined;
536
591
  rank?: "deep" | "small" | "standard" | undefined;
@@ -541,6 +596,14 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
541
596
  reset_at: string | null;
542
597
  budget: number;
543
598
  } | null | undefined;
599
+ window_budgets?: {
600
+ label: string;
601
+ scope: "model" | "account";
602
+ reset_at: string | null;
603
+ budget: number;
604
+ unit: "tokens" | "percent";
605
+ tokens_per_pct?: number | undefined;
606
+ }[] | undefined;
544
607
  in_flight_tokens?: number | undefined;
545
608
  quota_source_snapshot?: {
546
609
  remaining_pct: number | null;
@@ -551,6 +614,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
551
614
  source: string;
552
615
  windows?: {
553
616
  label: string;
617
+ scope: "model" | "account";
554
618
  remaining_pct: number | null;
555
619
  reset_at: string | null;
556
620
  tokens_remaining?: number | null | undefined;
@@ -604,7 +668,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
604
668
  granted_packet_ids: string[];
605
669
  declared_cap: number | null;
606
670
  explains: {
607
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized";
671
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
608
672
  pool_id: string | null;
609
673
  cost: number;
610
674
  admitted: boolean;
@@ -625,6 +689,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
625
689
  source: string;
626
690
  windows?: {
627
691
  label: string;
692
+ scope: "model" | "account";
628
693
  remaining_pct: number | null;
629
694
  reset_at: string | null;
630
695
  tokens_remaining?: number | null | undefined;
@@ -651,6 +716,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
651
716
  } | null;
652
717
  is_conversation_host: boolean;
653
718
  estimated_wave_tokens: number;
719
+ account_key: string;
654
720
  binding_cap: "rpm" | "tpm" | "token_budget" | "cooldown" | "host_concurrency" | "none";
655
721
  capability_rank?: number | null | undefined;
656
722
  rank?: "deep" | "small" | "standard" | undefined;
@@ -661,6 +727,14 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
661
727
  reset_at: string | null;
662
728
  budget: number;
663
729
  } | null | undefined;
730
+ window_budgets?: {
731
+ label: string;
732
+ scope: "model" | "account";
733
+ reset_at: string | null;
734
+ budget: number;
735
+ unit: "tokens" | "percent";
736
+ tokens_per_pct?: number | undefined;
737
+ }[] | undefined;
664
738
  in_flight_tokens?: number | undefined;
665
739
  quota_source_snapshot?: {
666
740
  remaining_pct: number | null;
@@ -671,6 +745,7 @@ export declare const DispatchQuotaContractSchema: z.ZodObject<{
671
745
  source: string;
672
746
  windows?: {
673
747
  label: string;
748
+ scope: "model" | "account";
674
749
  remaining_pct: number | null;
675
750
  reset_at: string | null;
676
751
  tokens_remaining?: number | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"dispatchQuotaContract.d.ts","sourceRoot":"","sources":["../../../src/shared/dispatch/dispatchQuotaContract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAc5B,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE3F,+EAA+E;AAC/E,eAAO,MAAM,+BAA+B,EAAG,mBAA4B,CAAC;AAE5E,eAAO,MAAM,2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F,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAClE,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,gBAAgB,CA6BnB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,aAAa,CAAC;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAC3C,OAAO,CAET;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,kBAAkB,GAAG,IAAI,EACxC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAC5B,MAAM,CAeR"}
@@ -15,6 +15,14 @@ export function classifyEmptyGrantCause(explains) {
15
15
  return "cap_reached";
16
16
  if (blocked.every((e) => e.reason === "no_capable_pool"))
17
17
  return "no_capable_pool";
18
+ // A grant emptied ONLY by uncalibrated windows is a calibration state, not a wall:
19
+ // no allowance ran out, so there is no reset to wait for. Classified as
20
+ // `budget_exhausted` would send the operator to wait on a reset that will never
21
+ // come; leaving it unclassified would drop the reason entirely. It maps to
22
+ // `cap_reached` — the "retry shortly, nothing structural" cause — because the pool
23
+ // re-enters as soon as a slope is observed.
24
+ if (blocked.every((e) => e.reason === "window_uncalibrated"))
25
+ return "cap_reached";
18
26
  return null;
19
27
  }
20
28
  export function detectHostDispatchWall(params) {
@@ -1 +1 @@
1
- {"version":3,"file":"hostDispatchWall.js","sourceRoot":"","sources":["../../../src/shared/dispatch/hostDispatchWall.ts"],"names":[],"mappings":"AAkCA;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAgE;IAEhE,MAAM,OAAO,GAAG,Q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C,aAAa;QAAE,OAAO,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ;QAClC,CAAC,CAAC,UAAU,aAAa,CAAC,QAAQ,EAAE;QACpC,CAAC,CAAC,wBAAwB,CAAC;IAC7B,oFAAoF;IACpF,qFAAqF;IACrF,+EAA+E;IAC/E,MAAM,IAAI,GACR,aAAa,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC;QACrD,CAAC,CAAC,aAAa,GAAG,aAAa,CAAC,MAAM;YACpC,CAAC,CAAC,gCAAgC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,gCAAgC;YAC3F,CAAC,CAAC,gCAAgC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS;QACtE,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,0BAA0B,aAAa,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,sBAAsB,KAAK,GAAG,IAAI,GAAG,CAAC;AACnI,CAAC"}
@@ -58,6 +58,7 @@
58
58
  import type { SessionConfig } from "../types/sessionConfig.js";
59
59
  import type { CapacityPool, PartialCompletionTerminal } from "../quota/capacity.js";
60
60
  import type { QuotaStateEntry } from "../quota/types.js";
61
+ import type { PoolConstraintResolution } from "../quota/windowConstraints.js";
61
62
  import type { WorkerOutputChannel } from "../quota/errorParsing.js";
62
63
  import type { ReservationLedger } from "../quota/reservationLedger.js";
63
64
  import type { DispatchModelTier } from "../types/stepContract.js";
@@ -190,11 +191,12 @@ export interface InFlightEntry<TPacket> {
190
191
  /**
191
192
  * Reservation-ledger lease held for this in-flight packet (spec admission model).
192
193
  * Set only when a `reservationLedger` was configured; reconciled (freed) in
193
- * `handleResult` when the packet completes. `resourceKey` is the pool id the lease
194
- * was taken against, needed to reconcile. Null/undefined when no ledger is wired.
194
+ * `handleResult` when the packet completes. The id alone is sufficient — the
195
+ * ledger sweeps every key it was recorded under, so a lease spanning several
196
+ * metered windows cannot be partially released. Null/undefined when no ledger is
197
+ * wired.
195
198
  */
196
199
  leaseId?: string | null;
197
- resourceKey?: string;
198
200
  }
199
201
  /** Mutable state of the rolling dispatcher. */
200
202
  export interface RollingDispatchState<TPacket> {
@@ -404,13 +406,18 @@ export interface RollingDispatchConfig<TPacket> {
404
406
  */
405
407
  reservationLedger?: ReservationLedger;
406
408
  /**
407
- * Live remaining token budget for a pool's resourceKey (its `pool.id`). Consulted
408
- * only when `reservationLedger` is set — it is the budget the ledger admits
409
- * against (`budget - Σ outstanding_leases >= cost`). Return a non-finite value
410
- * (the default) for an optimistic/unbounded budget, in which case the ledger only
411
- * prevents co-located double-counting and never gates on an absolute token ceiling.
412
- */
413
- resolvePoolBudget?: (poolId: string) => number;
409
+ * Every metered allowance a packet of `tokens` must fit inside on this pool — one
410
+ * constraint per quota WINDOW, in that window's own unit. Consulted only when
411
+ * `reservationLedger` is set; the ledger admits iff EVERY constraint clears.
412
+ *
413
+ * Not a scalar budget: an `account`-scoped window's allowance is shared with every
414
+ * sibling model on the same credential (the N× over-admission), and windows share
415
+ * no denominator, so no single number can express "fits every applicable
416
+ * allowance". Omit to leave the in-process `InFlightTokenTracker` as the sole
417
+ * accounting; a resolution with a non-empty `unpriced` means REFUSE, never admit on
418
+ * the priced subset.
419
+ */
420
+ resolvePoolConstraints?: (poolId: string, tokens: number) => PoolConstraintResolution;
414
421
  /**
415
422
  * Output-token envelope (spec Resolved decision 1) added to a packet's INPUT
416
423
  * `estimatedTokens` to form the reservation cost. Consulted only when
@@ -1 +1 @@
1
- {"version":3,"file":"rollingDispatch.d.ts","sourceRoot":"","sources":["../../../src/shared/dispatch/rollingDispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,y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,OAAO,CAAC,CAi5B5B"}
@@ -318,7 +318,7 @@ capable) {
318
318
  * separate concurrency cap unless `options.maxConcurrentPerPool` is set.
319
319
  */
320
320
  export function createRollingDispatcher(config, options = {}) {
321
- const { confirmedPools, sessionConfig, dispatchPacket, onResult, onCostDrift, onCreditExhausted, onModelUnavailable, onPacketTooLarge, onQuotaUnclassified, costDemotedPoolIds: injectedCostDemotedPoolIds, isPacketEscalated, recordRateLimit, reservationLedger, resolvePoolBudget, resolveOutputReservation: resolveOutputReservationFn, } = config;
321
+ const { confirmedPools, sessionConfig, dispatchPacket, onResult, onCostDrift, onCreditExhausted, onModelUnavailable, onPacketTooLarge, onQuotaUnclassified, costDemotedPoolIds: injectedCostDemotedPoolIds, isPacketEscalated, recordRateLimit, reservationLedger, resolvePoolConstraints, resolveOutputReservation: resolveOutputReservationFn, } = config;
322
322
  const state = {
323
323
  pendingQueue: [],
324
324
  inFlight: new Map(),
@@ -355,7 +355,7 @@ export function createRollingDispatcher(config, options = {}) {
355
355
  return;
356
356
  const pool = confirmedPools.find((p) => p.id === poolId);
357
357
  slopeBaselines.set(poolId, {
358
- pctByLabel: quotaSnapshotWindowPctMap(pool?.quotaSourceSnapshot),
358
+ pctByKey: quotaSnapshotWindowPctMap(pool?.quotaSourceSnapshot),
359
359
  tokensSinceBaseline: 0,
360
360
  });
361
361
  }
@@ -373,9 +373,9 @@ export function createRollingDispatcher(config, options = {}) {
373
373
  baseline.tokensSinceBaseline += Math.max(0, tokens);
374
374
  const pool = confirmedPools.find((p) => p.id === poolId);
375
375
  const current = quotaSnapshotWindowPctMap(pool?.quotaSourceSnapshot);
376
- const folded = await foldSlopeObservationFromPctMaps(poolId, baseline.pctByLabel, current, baseline.tokensSinceBaseline);
376
+ const folded = await foldSlopeObservationFromPctMaps(poolId, baseline.pctByKey, current, baseline.tokensSinceBaseline);
377
377
  if (folded.length > 0) {
378
- slopeBaselines.set(poolId, { pctByLabel: current, tokensSinceBaseline: 0 });
378
+ slopeBaselines.set(poolId, { pctByKey: current, tokensSinceBaseline: 0 });
379
379
  quotaStateCacheDirty = true;
380
380
  }
381
381
  }
@@ -428,7 +428,6 @@ export function createRollingDispatcher(config, options = {}) {
428
428
  estimatedTokens: packet.estimatedTokens,
429
429
  promise,
430
430
  leaseId: lease?.leaseId ?? null,
431
- resourceKey: lease?.resourceKey,
432
431
  };
433
432
  state.inFlight.set(packet.id, entry);
434
433
  }
@@ -443,30 +442,46 @@ export function createRollingDispatcher(config, options = {}) {
443
442
  * - `no_ledger` — no ledger configured; dispatch unconditionally (behaviour
444
443
  * identical to before the ledger existed).
445
444
  * - `admitted` — carry the lease on the in-flight entry; reconciled on completion.
446
- * - `blocked` — budget minus everyone's outstanding leases cannot cover this
447
- * packet. `outstandingBefore` is the sum of OTHERS' (and this loop's own)
448
- * live leases the ledger saw: `0` means nothing anywhere holds budget, so the
449
- * single packet's cost exceeds the WHOLE budget and no completion will ever
450
- * free room — the caller's liveness backstop force-admits it (the reactive 429
451
- * floor still catches the overshoot). A non-zero value means a lease is
452
- * outstanding and will free budget, so the caller waits instead of forcing.
445
+ * - `blocked` — some constraint's budget minus outstanding leases cannot cover
446
+ * this packet. `anyOutstanding` reports whether ANY of the packet's constraints
447
+ * had a live lease against it: `false` means nothing anywhere holds budget, so
448
+ * the packet's cost exceeds a whole budget and no completion will ever free
449
+ * room — the caller's liveness backstop force-admits it (the reactive 429 floor
450
+ * still catches the overshoot). `true` means a lease is outstanding somewhere
451
+ * and will free budget, so the caller waits instead of forcing.
453
452
  *
454
- * `forceUnbounded` overrides the pool budget with +Infinity so the backstop admit
455
- * always succeeds.
453
+ * ⚠ This MUST be the across-constraint aggregate, never one constraint's own
454
+ * outstanding total. Under a multi-window packet, a model window can block at
455
+ * zero outstanding while the shared account window has plenty in flight; taking
456
+ * the blocked constraint's own number would force-dispatch straight into
457
+ * overshoot, and which constraint that was would depend on list order.
458
+ *
459
+ * `forceUnbounded` overrides EVERY constraint's budget with +Infinity so the
460
+ * backstop admit always succeeds — unbounding only one still leaves the others to
461
+ * block it, which would silently disable the anti-deadlock backstop.
456
462
  */
457
463
  async function admitAgainstLedger(packet, slot, forceUnbounded) {
458
464
  if (!reservationLedger)
459
465
  return { status: "no_ledger" };
460
- const resourceKey = slot.poolId;
461
466
  const outputReservation = resolveOutputReservationFn?.(packet, slot.poolId) ?? 0;
462
467
  const cost = Math.max(0, packet.estimatedTokens) + Math.max(0, outputReservation);
463
- const budget = forceUnbounded
464
- ? Number.POSITIVE_INFINITY
465
- : resolvePoolBudget?.(slot.poolId) ?? Number.POSITIVE_INFINITY;
468
+ const resolution = resolvePoolConstraints?.(slot.poolId, cost) ?? {
469
+ constraints: [{ resourceKey: slot.poolId, budget: Number.POSITIVE_INFINITY, cost }],
470
+ unpriced: [],
471
+ };
472
+ if (resolution.unpriced.length > 0) {
473
+ // A window that applies but cannot price this draw. Admitting on the priced
474
+ // subset would meter the packet against fewer allowances than bind it, so
475
+ // refuse — and report nothing outstanding is holding it, since waiting for a
476
+ // lease to free cannot make an unpriceable window priceable. The pool re-enters
477
+ // once a slope is learned (cold-start probe path).
478
+ return { status: "blocked", anyOutstanding: false };
479
+ }
480
+ const constraints = resolution.constraints;
466
481
  const decision = await reservationLedger.admit({
467
- resourceKey,
468
- cost,
469
- budget,
482
+ constraints: forceUnbounded
483
+ ? constraints.map((c) => ({ ...c, budget: Number.POSITIVE_INFINITY }))
484
+ : constraints,
470
485
  poolId: slot.poolId,
471
486
  // The lease guards a live LLM call (minutes); the ledger's seconds-scale
472
487
  // default would expire it mid-flight and hand a concurrent admitter a
@@ -474,9 +489,9 @@ export function createRollingDispatcher(config, options = {}) {
474
489
  leaseTtlMs: DISPATCH_LEASE_TTL_MS,
475
490
  });
476
491
  if (decision.admitted && decision.leaseId !== null) {
477
- return { status: "admitted", lease: { leaseId: decision.leaseId, resourceKey } };
492
+ return { status: "admitted", lease: { leaseId: decision.leaseId } };
478
493
  }
479
- return { status: "blocked", outstandingBefore: decision.outstandingBefore };
494
+ return { status: "blocked", anyOutstanding: decision.anyOutstanding };
480
495
  }
481
496
  async function handleResult(packetId, result) {
482
497
  const entry = state.inFlight.get(packetId);
@@ -493,9 +508,9 @@ export function createRollingDispatcher(config, options = {}) {
493
508
  // real token cost surfaces in the provider's next quota snapshot; the ledger's
494
509
  // job is only to stop reserving it. Best-effort: a ledger failure must never
495
510
  // abort dispatch.
496
- if (reservationLedger && entry.leaseId && entry.resourceKey) {
511
+ if (reservationLedger && entry.leaseId) {
497
512
  try {
498
- await reservationLedger.reconcile(entry.resourceKey, entry.leaseId);
513
+ await reservationLedger.reconcile(entry.leaseId);
499
514
  }
500
515
  catch {
501
516
  // Non-fatal: the lease's TTL expiry reclaims it if reconcile ever fails.
@@ -926,13 +941,14 @@ export function createRollingDispatcher(config, options = {}) {
926
941
  * the reservation ledger (when configured), and dispatch the admitted ones.
927
942
  * Returns how many were dispatched.
928
943
  *
929
- * Liveness backstop: a packet the ledger BLOCKS with `outstandingBefore === 0`
930
- * has a cost exceeding the WHOLE pool budget while nothing anywhere holds a lease
931
- * to ever free room — the FIRST such packet per pass is admitted unbounded so the
932
- * run can never deadlock on a single over-budget packet (the reactive 429 floor
933
- * still catches the overshoot). A block with outstanding leases (`> 0`) means a
934
- * co-located peer or an in-flight packet will free budget, so it waits instead —
935
- * this is what stops two co-located loops from both force-admitting into overshoot.
944
+ * Liveness backstop: a packet the ledger BLOCKS with `anyOutstanding === false`
945
+ * has a cost exceeding a whole budget while nothing anywhere holds a lease to ever
946
+ * free room — the FIRST such packet per pass is admitted unbounded so the run can
947
+ * never deadlock on a single over-budget packet (the reactive 429 floor still
948
+ * catches the overshoot). A block with a lease outstanding against ANY of the
949
+ * packet's constraints means a co-located peer or an in-flight packet will free
950
+ * budget, so it waits instead — this is what stops two co-located loops from both
951
+ * force-admitting into overshoot.
936
952
  */
937
953
  async function dispatchPass() {
938
954
  let dispatched = 0;
@@ -969,7 +985,7 @@ export function createRollingDispatcher(config, options = {}) {
969
985
  lease = admission.lease;
970
986
  }
971
987
  else if (admission.status === "blocked") {
972
- if (admission.outstandingBefore === 0 && !forcedUsed && dispatched === 0) {
988
+ if (!admission.anyOutstanding && !forcedUsed && dispatched === 0) {
973
989
  // Single packet exceeds the whole budget with nothing holding a lease →
974
990
  // force it unbounded so the run can't deadlock. Only the first per pass.
975
991
  const forced = await admitAgainstLedger(packet, slot, true);