audit-tools 0.34.21 → 0.34.23

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 (51) hide show
  1. package/dist/audit/cli/rollingAuditDispatch.d.ts.map +1 -1
  2. package/dist/audit/cli/rollingAuditDispatch.js +5 -1
  3. package/dist/audit/cli/rollingAuditDispatch.js.map +1 -1
  4. package/dist/audit/orchestrator/rollingDispatch.d.ts.map +1 -1
  5. package/dist/audit/orchestrator/rollingDispatch.js +1 -0
  6. package/dist/audit/orchestrator/rollingDispatch.js.map +1 -1
  7. package/dist/remediate/steps/nextStep.d.ts +8 -1
  8. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  9. package/dist/remediate/steps/nextStep.js +6 -1
  10. package/dist/remediate/steps/nextStep.js.map +1 -1
  11. package/dist/shared/dispatch/admissionLoop.d.ts +537 -69
  12. package/dist/shared/dispatch/admissionLoop.d.ts.map +1 -1
  13. package/dist/shared/dispatch/admissionLoop.js +167 -36
  14. package/dist/shared/dispatch/admissionLoop.js.map +1 -1
  15. package/dist/shared/dispatch/dispatchDecisionLog.d.ts +116 -0
  16. package/dist/shared/dispatch/dispatchDecisionLog.d.ts.map +1 -0
  17. package/dist/shared/dispatch/dispatchDecisionLog.js +65 -0
  18. package/dist/shared/dispatch/dispatchDecisionLog.js.map +1 -0
  19. package/dist/shared/dispatch/dispatchQuotaContract.d.ts +293 -35
  20. package/dist/shared/dispatch/dispatchQuotaContract.d.ts.map +1 -1
  21. package/dist/shared/dispatch/rollingDispatch.d.ts +11 -0
  22. package/dist/shared/dispatch/rollingDispatch.d.ts.map +1 -1
  23. package/dist/shared/dispatch/rollingDispatch.js +220 -40
  24. package/dist/shared/dispatch/rollingDispatch.js.map +1 -1
  25. package/dist/shared/dispatch/unifiedRolling.d.ts +9 -0
  26. package/dist/shared/dispatch/unifiedRolling.d.ts.map +1 -1
  27. package/dist/shared/dispatch/unifiedRolling.js +1 -0
  28. package/dist/shared/dispatch/unifiedRolling.js.map +1 -1
  29. package/dist/shared/index.d.ts +4 -2
  30. package/dist/shared/index.d.ts.map +1 -1
  31. package/dist/shared/index.js +4 -1
  32. package/dist/shared/index.js.map +1 -1
  33. package/dist/shared/providers/auditorSources.d.ts +9 -1
  34. package/dist/shared/providers/auditorSources.d.ts.map +1 -1
  35. package/dist/shared/providers/auditorSources.js +26 -3
  36. package/dist/shared/providers/auditorSources.js.map +1 -1
  37. package/dist/shared/quota/apiPool.d.ts +1 -1
  38. package/dist/shared/quota/apiPool.d.ts.map +1 -1
  39. package/dist/shared/quota/apiPool.js +31 -1
  40. package/dist/shared/quota/apiPool.js.map +1 -1
  41. package/dist/shared/types/rollingDispatch.d.ts +10 -0
  42. package/dist/shared/types/rollingDispatch.d.ts.map +1 -1
  43. package/dist/shared/types/rollingDispatch.js.map +1 -1
  44. package/dist/shared/types/sessionConfig.d.ts +44 -5
  45. package/dist/shared/types/sessionConfig.d.ts.map +1 -1
  46. package/dist/shared/types/sessionConfig.js +64 -8
  47. package/dist/shared/types/sessionConfig.js.map +1 -1
  48. package/dist/shared/validation/sessionConfig.d.ts.map +1 -1
  49. package/dist/shared/validation/sessionConfig.js +33 -1
  50. package/dist/shared/validation/sessionConfig.js.map +1 -1
  51. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { ReservationLedger } from "../quota/reservationLedger.js";
2
+ import type { ConstraintOutcome, ReservationLedger } from "../quota/reservationLedger.js";
3
3
  import type { DispatchCapacityPoolSummary } from "../quota/capacity.js";
4
4
  import type { DispatchModelTier } from "../types/stepContract.js";
5
5
  import type { WindowBudget } from "../quota/types.js";
@@ -119,81 +119,338 @@ export declare function deriveThroughputConcurrency(params: {
119
119
  * spec/dispatch-cost-speed-dial.md), and the context-window fit ceiling.
120
120
  */
121
121
  export declare function admissionPoolsFromSummaries(summaries: readonly DispatchCapacityPoolSummary[], confirmedCostPositions?: Map<string, number> | null): AdmissionPool[];
122
+ /**
123
+ * One constraint's evaluation, serialized for the persisted explain artifact —
124
+ * the wire form of the ledger's {@link ConstraintOutcome} (legibility invariant,
125
+ * spec/audit/dispatch-admission-control.md Resolved decision 3).
126
+ *
127
+ * `headroom_before: null` means UNBOUNDED, not unknown — a cold-start pool with
128
+ * no real ceiling computes `headroomBefore = +Infinity`, which `JSON.stringify`
129
+ * (the artifact's actual emit path) collapses to `null`; `.number()` alone
130
+ * rejects that on read-back even though it accepts `Infinity` in memory, so
131
+ * `null` is the honest encoding of what the artifact actually contains on disk.
132
+ */
133
+ export declare const ConstraintOutcomeRecordSchema: z.ZodObject<{
134
+ resource_key: z.ZodString;
135
+ headroom_before: z.ZodNullable<z.ZodNumber>;
136
+ outstanding_before: z.ZodNumber;
137
+ cost: z.ZodNumber;
138
+ /** Whether this constraint alone had room. Admission requires ALL true. */
139
+ cleared: z.ZodBoolean;
140
+ }, "strict", z.ZodTypeAny, {
141
+ cost: number;
142
+ resource_key: string;
143
+ headroom_before: number | null;
144
+ outstanding_before: number;
145
+ cleared: boolean;
146
+ }, {
147
+ cost: number;
148
+ resource_key: string;
149
+ headroom_before: number | null;
150
+ outstanding_before: number;
151
+ cleared: boolean;
152
+ }>;
153
+ export type ConstraintOutcomeRecord = z.infer<typeof ConstraintOutcomeRecordSchema>;
154
+ /** Serialize ledger outcomes for the artifact (non-finite headroom → null). */
155
+ export declare function toConstraintOutcomeRecords(outcomes: readonly ConstraintOutcome[]): ConstraintOutcomeRecord[];
156
+ /**
157
+ * One NON-decisive pool consultation during a packet's admission walk — a pool
158
+ * that was tried and refused before the decision landed elsewhere (the decisive
159
+ * pool's data lives on the explain record itself, never duplicated here). The
160
+ * refusal vocabulary is shared with {@link AdmissionExplain.reason} so one
161
+ * parser covers both.
162
+ */
163
+ export declare const AdmissionAttemptSchema: z.ZodObject<{
164
+ pool_id: z.ZodString;
165
+ reason: z.ZodEnum<["budget_exhausted", "cap_reached", "window_uncalibrated"]>;
166
+ /** Ledger outcomes when the attempt reached the ledger; [] otherwise. */
167
+ constraints: z.ZodArray<z.ZodObject<{
168
+ resource_key: z.ZodString;
169
+ headroom_before: z.ZodNullable<z.ZodNumber>;
170
+ outstanding_before: z.ZodNumber;
171
+ cost: z.ZodNumber;
172
+ /** Whether this constraint alone had room. Admission requires ALL true. */
173
+ cleared: z.ZodBoolean;
174
+ }, "strict", z.ZodTypeAny, {
175
+ cost: number;
176
+ resource_key: string;
177
+ headroom_before: number | null;
178
+ outstanding_before: number;
179
+ cleared: boolean;
180
+ }, {
181
+ cost: number;
182
+ resource_key: string;
183
+ headroom_before: number | null;
184
+ outstanding_before: number;
185
+ cleared: boolean;
186
+ }>, "many">;
187
+ /** cap_reached only: the in-flight count and cap that refused. */
188
+ in_flight_before: z.ZodOptional<z.ZodNumber>;
189
+ cap: z.ZodOptional<z.ZodNumber>;
190
+ /** window_uncalibrated only: labels of the windows that could not price. */
191
+ unpriced_windows: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
192
+ }, "strict", z.ZodTypeAny, {
193
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
194
+ pool_id: string;
195
+ constraints: {
196
+ cost: number;
197
+ resource_key: string;
198
+ headroom_before: number | null;
199
+ outstanding_before: number;
200
+ cleared: boolean;
201
+ }[];
202
+ in_flight_before?: number | undefined;
203
+ cap?: number | undefined;
204
+ unpriced_windows?: string[] | undefined;
205
+ }, {
206
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
207
+ pool_id: string;
208
+ constraints: {
209
+ cost: number;
210
+ resource_key: string;
211
+ headroom_before: number | null;
212
+ outstanding_before: number;
213
+ cleared: boolean;
214
+ }[];
215
+ in_flight_before?: number | undefined;
216
+ cap?: number | undefined;
217
+ unpriced_windows?: string[] | undefined;
218
+ }>;
219
+ export type AdmissionAttempt = z.infer<typeof AdmissionAttemptSchema>;
122
220
  /** A successful admission: one packet leased to one pool. */
123
221
  export interface AdmissionGrant {
124
222
  packet_id: string;
125
223
  pool_id: string;
126
224
  /**
127
- * DIAGNOSTIC PROVENANCE ONLY not the reconcile key. `reconcile(leaseId)`
128
- * sweeps every key the lease was recorded under, precisely so no caller has to
129
- * know which keys those were. Once steps 3-4 supply multiple constraints this
130
- * field records only ONE of N and will look authoritative while being partial
131
- * ([[write-only-data-looks-authoritative]]); make it a key array or drop it then.
132
- * Tracked in `docs/backlog.md`.
225
+ * EVERY resource key the lease was recorded under (deduped, in constraint
226
+ * order) never one of N. Diagnostic provenance only: `reconcile(leaseId)`
227
+ * sweeps every key itself, so no caller needs this to release the lease.
133
228
  */
134
- resource_key: string;
229
+ resource_keys: string[];
135
230
  lease_id: string;
136
231
  cost: number;
137
232
  }
138
233
  export declare const AdmissionGrantSchema: z.ZodObject<{
139
234
  packet_id: z.ZodString;
140
235
  pool_id: z.ZodString;
141
- resource_key: z.ZodString;
236
+ resource_keys: z.ZodArray<z.ZodString, "many">;
142
237
  lease_id: z.ZodString;
143
238
  cost: z.ZodNumber;
144
239
  }, "strict", z.ZodTypeAny, {
145
240
  pool_id: string;
146
241
  cost: number;
147
242
  packet_id: string;
148
- resource_key: string;
243
+ resource_keys: string[];
149
244
  lease_id: string;
150
245
  }, {
151
246
  pool_id: string;
152
247
  cost: number;
153
248
  packet_id: string;
154
- resource_key: string;
249
+ resource_keys: string[];
155
250
  lease_id: string;
156
251
  }>;
157
- /** Why a packet was admitted or blocked — the per-admission explain record. */
252
+ /**
253
+ * Why a packet was admitted or blocked — the per-admission explain record.
254
+ * Carries the FULL constraint-outcome array the decision was taken against
255
+ * (every key consulted, its headroom before, the packet's cost against it,
256
+ * which key refused) plus the non-decisive walk trail — never a one-of-N
257
+ * scalar that looks authoritative while being partial
258
+ * ([[write-only-data-looks-authoritative]]).
259
+ */
158
260
  export declare const AdmissionExplainSchema: z.ZodObject<{
159
261
  packet_id: z.ZodString;
160
- /** null only when NO pool was capable of the packet at all. */
262
+ /** null when NO pool was capable, or on a plan-only (`planned`) grant. */
161
263
  pool_id: z.ZodNullable<z.ZodString>;
162
- resource_key: z.ZodNullable<z.ZodString>;
163
264
  admitted: z.ZodBoolean;
164
- reason: z.ZodEnum<["admitted", "no_capable_pool", "budget_exhausted", "cap_reached", "packet_oversized", "window_uncalibrated"]>;
265
+ reason: z.ZodEnum<["admitted", "planned", "no_capable_pool", "budget_exhausted", "cap_reached", "packet_oversized", "window_uncalibrated"]>;
165
266
  /**
166
- * Present on an admit attempt against a real pool (budget headroom before
167
- * it). `null` means UNBOUNDED, not unknown a cold-start pool with no real
168
- * ceiling yet computes `headroomBefore = +Infinity`, which `JSON.stringify`
169
- * (the artifact's actual emit path) collapses to `null`; `.number()` alone
170
- * rejects that on read-back even though it happily accepts `Infinity` in
171
- * memory, so the round trip a real reader performs was silently unparseable.
172
- * `null` is the honest, back-compat-safe encoding: it matches the literal
173
- * bytes already on disk in pre-existing artifacts (e.g.
174
- * `.audit-tools/audit/fanout-quota/design_review/dispatch-quota.json`).
267
+ * The DECISIVE attempt's full constraint-outcome array: on a grant, the
268
+ * successful admit's; on a ledger refusal, the refusing decision's. Empty
269
+ * when the ledger was never reached (no_capable_pool / cap_reached /
270
+ * window_uncalibrated / planned / packet_oversized).
175
271
  */
176
- headroom_before: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
177
- outstanding_before: z.ZodOptional<z.ZodNumber>;
272
+ constraints: z.ZodArray<z.ZodObject<{
273
+ resource_key: z.ZodString;
274
+ headroom_before: z.ZodNullable<z.ZodNumber>;
275
+ outstanding_before: z.ZodNumber;
276
+ cost: z.ZodNumber;
277
+ /** Whether this constraint alone had room. Admission requires ALL true. */
278
+ cleared: z.ZodBoolean;
279
+ }, "strict", z.ZodTypeAny, {
280
+ cost: number;
281
+ resource_key: string;
282
+ headroom_before: number | null;
283
+ outstanding_before: number;
284
+ cleared: boolean;
285
+ }, {
286
+ cost: number;
287
+ resource_key: string;
288
+ headroom_before: number | null;
289
+ outstanding_before: number;
290
+ cleared: boolean;
291
+ }>, "many">;
292
+ /**
293
+ * The tightest (or refusing) constraint of the decisive attempt — the
294
+ * binding window a report should name, as its full outcome row. Null when
295
+ * the ledger was never reached.
296
+ */
297
+ binding: z.ZodNullable<z.ZodObject<{
298
+ resource_key: z.ZodString;
299
+ headroom_before: z.ZodNullable<z.ZodNumber>;
300
+ outstanding_before: z.ZodNumber;
301
+ cost: z.ZodNumber;
302
+ /** Whether this constraint alone had room. Admission requires ALL true. */
303
+ cleared: z.ZodBoolean;
304
+ }, "strict", z.ZodTypeAny, {
305
+ cost: number;
306
+ resource_key: string;
307
+ headroom_before: number | null;
308
+ outstanding_before: number;
309
+ cleared: boolean;
310
+ }, {
311
+ cost: number;
312
+ resource_key: string;
313
+ headroom_before: number | null;
314
+ outstanding_before: number;
315
+ cleared: boolean;
316
+ }>>;
317
+ /** Pools consulted and refused BEFORE the decision, in walk order. */
318
+ attempts: z.ZodArray<z.ZodObject<{
319
+ pool_id: z.ZodString;
320
+ reason: z.ZodEnum<["budget_exhausted", "cap_reached", "window_uncalibrated"]>;
321
+ /** Ledger outcomes when the attempt reached the ledger; [] otherwise. */
322
+ constraints: z.ZodArray<z.ZodObject<{
323
+ resource_key: z.ZodString;
324
+ headroom_before: z.ZodNullable<z.ZodNumber>;
325
+ outstanding_before: z.ZodNumber;
326
+ cost: z.ZodNumber;
327
+ /** Whether this constraint alone had room. Admission requires ALL true. */
328
+ cleared: z.ZodBoolean;
329
+ }, "strict", z.ZodTypeAny, {
330
+ cost: number;
331
+ resource_key: string;
332
+ headroom_before: number | null;
333
+ outstanding_before: number;
334
+ cleared: boolean;
335
+ }, {
336
+ cost: number;
337
+ resource_key: string;
338
+ headroom_before: number | null;
339
+ outstanding_before: number;
340
+ cleared: boolean;
341
+ }>, "many">;
342
+ /** cap_reached only: the in-flight count and cap that refused. */
343
+ in_flight_before: z.ZodOptional<z.ZodNumber>;
344
+ cap: z.ZodOptional<z.ZodNumber>;
345
+ /** window_uncalibrated only: labels of the windows that could not price. */
346
+ unpriced_windows: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
347
+ }, "strict", z.ZodTypeAny, {
348
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
349
+ pool_id: string;
350
+ constraints: {
351
+ cost: number;
352
+ resource_key: string;
353
+ headroom_before: number | null;
354
+ outstanding_before: number;
355
+ cleared: boolean;
356
+ }[];
357
+ in_flight_before?: number | undefined;
358
+ cap?: number | undefined;
359
+ unpriced_windows?: string[] | undefined;
360
+ }, {
361
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
362
+ pool_id: string;
363
+ constraints: {
364
+ cost: number;
365
+ resource_key: string;
366
+ headroom_before: number | null;
367
+ outstanding_before: number;
368
+ cleared: boolean;
369
+ }[];
370
+ in_flight_before?: number | undefined;
371
+ cap?: number | undefined;
372
+ unpriced_windows?: string[] | undefined;
373
+ }>, "many">;
374
+ /** cap_reached refusal only: the in-flight count and cap that refused. */
375
+ in_flight_before: z.ZodOptional<z.ZodNumber>;
376
+ cap: z.ZodOptional<z.ZodNumber>;
377
+ /** window_uncalibrated refusal only: labels of the unpriceable windows. */
378
+ unpriced_windows: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
178
379
  cost: z.ZodNumber;
179
380
  }, "strict", z.ZodTypeAny, {
180
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
381
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "planned" | "packet_oversized" | "window_uncalibrated";
181
382
  pool_id: string | null;
182
383
  cost: number;
183
384
  admitted: boolean;
184
385
  packet_id: string;
185
- resource_key: string | null;
186
- headroom_before?: number | null | undefined;
187
- outstanding_before?: number | undefined;
386
+ constraints: {
387
+ cost: number;
388
+ resource_key: string;
389
+ headroom_before: number | null;
390
+ outstanding_before: number;
391
+ cleared: boolean;
392
+ }[];
393
+ binding: {
394
+ cost: number;
395
+ resource_key: string;
396
+ headroom_before: number | null;
397
+ outstanding_before: number;
398
+ cleared: boolean;
399
+ } | null;
400
+ attempts: {
401
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
402
+ pool_id: string;
403
+ constraints: {
404
+ cost: number;
405
+ resource_key: string;
406
+ headroom_before: number | null;
407
+ outstanding_before: number;
408
+ cleared: boolean;
409
+ }[];
410
+ in_flight_before?: number | undefined;
411
+ cap?: number | undefined;
412
+ unpriced_windows?: string[] | undefined;
413
+ }[];
414
+ in_flight_before?: number | undefined;
415
+ cap?: number | undefined;
416
+ unpriced_windows?: string[] | undefined;
188
417
  }, {
189
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
418
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "planned" | "packet_oversized" | "window_uncalibrated";
190
419
  pool_id: string | null;
191
420
  cost: number;
192
421
  admitted: boolean;
193
422
  packet_id: string;
194
- resource_key: string | null;
195
- headroom_before?: number | null | undefined;
196
- outstanding_before?: number | undefined;
423
+ constraints: {
424
+ cost: number;
425
+ resource_key: string;
426
+ headroom_before: number | null;
427
+ outstanding_before: number;
428
+ cleared: boolean;
429
+ }[];
430
+ binding: {
431
+ cost: number;
432
+ resource_key: string;
433
+ headroom_before: number | null;
434
+ outstanding_before: number;
435
+ cleared: boolean;
436
+ } | null;
437
+ attempts: {
438
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
439
+ pool_id: string;
440
+ constraints: {
441
+ cost: number;
442
+ resource_key: string;
443
+ headroom_before: number | null;
444
+ outstanding_before: number;
445
+ cleared: boolean;
446
+ }[];
447
+ in_flight_before?: number | undefined;
448
+ cap?: number | undefined;
449
+ unpriced_windows?: string[] | undefined;
450
+ }[];
451
+ in_flight_before?: number | undefined;
452
+ cap?: number | undefined;
453
+ unpriced_windows?: string[] | undefined;
197
454
  }>;
198
455
  export type AdmissionExplain = z.infer<typeof AdmissionExplainSchema>;
199
456
  /**
@@ -210,101 +467,312 @@ export declare const DispatchAdmissionSchema: z.ZodObject<{
210
467
  leases: z.ZodArray<z.ZodObject<{
211
468
  packet_id: z.ZodString;
212
469
  pool_id: z.ZodString;
213
- resource_key: z.ZodString;
470
+ resource_keys: z.ZodArray<z.ZodString, "many">;
214
471
  lease_id: z.ZodString;
215
472
  cost: z.ZodNumber;
216
473
  }, "strict", z.ZodTypeAny, {
217
474
  pool_id: string;
218
475
  cost: number;
219
476
  packet_id: string;
220
- resource_key: string;
477
+ resource_keys: string[];
221
478
  lease_id: string;
222
479
  }, {
223
480
  pool_id: string;
224
481
  cost: number;
225
482
  packet_id: string;
226
- resource_key: string;
483
+ resource_keys: string[];
227
484
  lease_id: string;
228
485
  }>, "many">;
229
486
  explains: z.ZodArray<z.ZodObject<{
230
487
  packet_id: z.ZodString;
231
- /** null only when NO pool was capable of the packet at all. */
488
+ /** null when NO pool was capable, or on a plan-only (`planned`) grant. */
232
489
  pool_id: z.ZodNullable<z.ZodString>;
233
- resource_key: z.ZodNullable<z.ZodString>;
234
490
  admitted: z.ZodBoolean;
235
- reason: z.ZodEnum<["admitted", "no_capable_pool", "budget_exhausted", "cap_reached", "packet_oversized", "window_uncalibrated"]>;
491
+ reason: z.ZodEnum<["admitted", "planned", "no_capable_pool", "budget_exhausted", "cap_reached", "packet_oversized", "window_uncalibrated"]>;
492
+ /**
493
+ * The DECISIVE attempt's full constraint-outcome array: on a grant, the
494
+ * successful admit's; on a ledger refusal, the refusing decision's. Empty
495
+ * when the ledger was never reached (no_capable_pool / cap_reached /
496
+ * window_uncalibrated / planned / packet_oversized).
497
+ */
498
+ constraints: z.ZodArray<z.ZodObject<{
499
+ resource_key: z.ZodString;
500
+ headroom_before: z.ZodNullable<z.ZodNumber>;
501
+ outstanding_before: z.ZodNumber;
502
+ cost: z.ZodNumber;
503
+ /** Whether this constraint alone had room. Admission requires ALL true. */
504
+ cleared: z.ZodBoolean;
505
+ }, "strict", z.ZodTypeAny, {
506
+ cost: number;
507
+ resource_key: string;
508
+ headroom_before: number | null;
509
+ outstanding_before: number;
510
+ cleared: boolean;
511
+ }, {
512
+ cost: number;
513
+ resource_key: string;
514
+ headroom_before: number | null;
515
+ outstanding_before: number;
516
+ cleared: boolean;
517
+ }>, "many">;
236
518
  /**
237
- * Present on an admit attempt against a real pool (budget headroom before
238
- * it). `null` means UNBOUNDED, not unknown a cold-start pool with no real
239
- * ceiling yet computes `headroomBefore = +Infinity`, which `JSON.stringify`
240
- * (the artifact's actual emit path) collapses to `null`; `.number()` alone
241
- * rejects that on read-back even though it happily accepts `Infinity` in
242
- * memory, so the round trip a real reader performs was silently unparseable.
243
- * `null` is the honest, back-compat-safe encoding: it matches the literal
244
- * bytes already on disk in pre-existing artifacts (e.g.
245
- * `.audit-tools/audit/fanout-quota/design_review/dispatch-quota.json`).
519
+ * The tightest (or refusing) constraint of the decisive attempt the
520
+ * binding window a report should name, as its full outcome row. Null when
521
+ * the ledger was never reached.
246
522
  */
247
- headroom_before: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
248
- outstanding_before: z.ZodOptional<z.ZodNumber>;
523
+ binding: z.ZodNullable<z.ZodObject<{
524
+ resource_key: z.ZodString;
525
+ headroom_before: z.ZodNullable<z.ZodNumber>;
526
+ outstanding_before: z.ZodNumber;
527
+ cost: z.ZodNumber;
528
+ /** Whether this constraint alone had room. Admission requires ALL true. */
529
+ cleared: z.ZodBoolean;
530
+ }, "strict", z.ZodTypeAny, {
531
+ cost: number;
532
+ resource_key: string;
533
+ headroom_before: number | null;
534
+ outstanding_before: number;
535
+ cleared: boolean;
536
+ }, {
537
+ cost: number;
538
+ resource_key: string;
539
+ headroom_before: number | null;
540
+ outstanding_before: number;
541
+ cleared: boolean;
542
+ }>>;
543
+ /** Pools consulted and refused BEFORE the decision, in walk order. */
544
+ attempts: z.ZodArray<z.ZodObject<{
545
+ pool_id: z.ZodString;
546
+ reason: z.ZodEnum<["budget_exhausted", "cap_reached", "window_uncalibrated"]>;
547
+ /** Ledger outcomes when the attempt reached the ledger; [] otherwise. */
548
+ constraints: z.ZodArray<z.ZodObject<{
549
+ resource_key: z.ZodString;
550
+ headroom_before: z.ZodNullable<z.ZodNumber>;
551
+ outstanding_before: z.ZodNumber;
552
+ cost: z.ZodNumber;
553
+ /** Whether this constraint alone had room. Admission requires ALL true. */
554
+ cleared: z.ZodBoolean;
555
+ }, "strict", z.ZodTypeAny, {
556
+ cost: number;
557
+ resource_key: string;
558
+ headroom_before: number | null;
559
+ outstanding_before: number;
560
+ cleared: boolean;
561
+ }, {
562
+ cost: number;
563
+ resource_key: string;
564
+ headroom_before: number | null;
565
+ outstanding_before: number;
566
+ cleared: boolean;
567
+ }>, "many">;
568
+ /** cap_reached only: the in-flight count and cap that refused. */
569
+ in_flight_before: z.ZodOptional<z.ZodNumber>;
570
+ cap: z.ZodOptional<z.ZodNumber>;
571
+ /** window_uncalibrated only: labels of the windows that could not price. */
572
+ unpriced_windows: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
573
+ }, "strict", z.ZodTypeAny, {
574
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
575
+ pool_id: string;
576
+ constraints: {
577
+ cost: number;
578
+ resource_key: string;
579
+ headroom_before: number | null;
580
+ outstanding_before: number;
581
+ cleared: boolean;
582
+ }[];
583
+ in_flight_before?: number | undefined;
584
+ cap?: number | undefined;
585
+ unpriced_windows?: string[] | undefined;
586
+ }, {
587
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
588
+ pool_id: string;
589
+ constraints: {
590
+ cost: number;
591
+ resource_key: string;
592
+ headroom_before: number | null;
593
+ outstanding_before: number;
594
+ cleared: boolean;
595
+ }[];
596
+ in_flight_before?: number | undefined;
597
+ cap?: number | undefined;
598
+ unpriced_windows?: string[] | undefined;
599
+ }>, "many">;
600
+ /** cap_reached refusal only: the in-flight count and cap that refused. */
601
+ in_flight_before: z.ZodOptional<z.ZodNumber>;
602
+ cap: z.ZodOptional<z.ZodNumber>;
603
+ /** window_uncalibrated refusal only: labels of the unpriceable windows. */
604
+ unpriced_windows: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
249
605
  cost: z.ZodNumber;
250
606
  }, "strict", z.ZodTypeAny, {
251
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
607
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "planned" | "packet_oversized" | "window_uncalibrated";
252
608
  pool_id: string | null;
253
609
  cost: number;
254
610
  admitted: boolean;
255
611
  packet_id: string;
256
- resource_key: string | null;
257
- headroom_before?: number | null | undefined;
258
- outstanding_before?: number | undefined;
612
+ constraints: {
613
+ cost: number;
614
+ resource_key: string;
615
+ headroom_before: number | null;
616
+ outstanding_before: number;
617
+ cleared: boolean;
618
+ }[];
619
+ binding: {
620
+ cost: number;
621
+ resource_key: string;
622
+ headroom_before: number | null;
623
+ outstanding_before: number;
624
+ cleared: boolean;
625
+ } | null;
626
+ attempts: {
627
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
628
+ pool_id: string;
629
+ constraints: {
630
+ cost: number;
631
+ resource_key: string;
632
+ headroom_before: number | null;
633
+ outstanding_before: number;
634
+ cleared: boolean;
635
+ }[];
636
+ in_flight_before?: number | undefined;
637
+ cap?: number | undefined;
638
+ unpriced_windows?: string[] | undefined;
639
+ }[];
640
+ in_flight_before?: number | undefined;
641
+ cap?: number | undefined;
642
+ unpriced_windows?: string[] | undefined;
259
643
  }, {
260
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
644
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "planned" | "packet_oversized" | "window_uncalibrated";
261
645
  pool_id: string | null;
262
646
  cost: number;
263
647
  admitted: boolean;
264
648
  packet_id: string;
265
- resource_key: string | null;
266
- headroom_before?: number | null | undefined;
267
- outstanding_before?: number | undefined;
649
+ constraints: {
650
+ cost: number;
651
+ resource_key: string;
652
+ headroom_before: number | null;
653
+ outstanding_before: number;
654
+ cleared: boolean;
655
+ }[];
656
+ binding: {
657
+ cost: number;
658
+ resource_key: string;
659
+ headroom_before: number | null;
660
+ outstanding_before: number;
661
+ cleared: boolean;
662
+ } | null;
663
+ attempts: {
664
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
665
+ pool_id: string;
666
+ constraints: {
667
+ cost: number;
668
+ resource_key: string;
669
+ headroom_before: number | null;
670
+ outstanding_before: number;
671
+ cleared: boolean;
672
+ }[];
673
+ in_flight_before?: number | undefined;
674
+ cap?: number | undefined;
675
+ unpriced_windows?: string[] | undefined;
676
+ }[];
677
+ in_flight_before?: number | undefined;
678
+ cap?: number | undefined;
679
+ unpriced_windows?: string[] | undefined;
268
680
  }>, "many">;
269
681
  }, "strict", z.ZodTypeAny, {
270
682
  leases: {
271
683
  pool_id: string;
272
684
  cost: number;
273
685
  packet_id: string;
274
- resource_key: string;
686
+ resource_keys: string[];
275
687
  lease_id: string;
276
688
  }[];
277
689
  granted_packet_ids: string[];
278
690
  declared_cap: number | null;
279
691
  explains: {
280
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
692
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "planned" | "packet_oversized" | "window_uncalibrated";
281
693
  pool_id: string | null;
282
694
  cost: number;
283
695
  admitted: boolean;
284
696
  packet_id: string;
285
- resource_key: string | null;
286
- headroom_before?: number | null | undefined;
287
- outstanding_before?: number | undefined;
697
+ constraints: {
698
+ cost: number;
699
+ resource_key: string;
700
+ headroom_before: number | null;
701
+ outstanding_before: number;
702
+ cleared: boolean;
703
+ }[];
704
+ binding: {
705
+ cost: number;
706
+ resource_key: string;
707
+ headroom_before: number | null;
708
+ outstanding_before: number;
709
+ cleared: boolean;
710
+ } | null;
711
+ attempts: {
712
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
713
+ pool_id: string;
714
+ constraints: {
715
+ cost: number;
716
+ resource_key: string;
717
+ headroom_before: number | null;
718
+ outstanding_before: number;
719
+ cleared: boolean;
720
+ }[];
721
+ in_flight_before?: number | undefined;
722
+ cap?: number | undefined;
723
+ unpriced_windows?: string[] | undefined;
724
+ }[];
725
+ in_flight_before?: number | undefined;
726
+ cap?: number | undefined;
727
+ unpriced_windows?: string[] | undefined;
288
728
  }[];
289
729
  }, {
290
730
  leases: {
291
731
  pool_id: string;
292
732
  cost: number;
293
733
  packet_id: string;
294
- resource_key: string;
734
+ resource_keys: string[];
295
735
  lease_id: string;
296
736
  }[];
297
737
  granted_packet_ids: string[];
298
738
  declared_cap: number | null;
299
739
  explains: {
300
- reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "packet_oversized" | "window_uncalibrated";
740
+ reason: "budget_exhausted" | "cap_reached" | "no_capable_pool" | "admitted" | "planned" | "packet_oversized" | "window_uncalibrated";
301
741
  pool_id: string | null;
302
742
  cost: number;
303
743
  admitted: boolean;
304
744
  packet_id: string;
305
- resource_key: string | null;
306
- headroom_before?: number | null | undefined;
307
- outstanding_before?: number | undefined;
745
+ constraints: {
746
+ cost: number;
747
+ resource_key: string;
748
+ headroom_before: number | null;
749
+ outstanding_before: number;
750
+ cleared: boolean;
751
+ }[];
752
+ binding: {
753
+ cost: number;
754
+ resource_key: string;
755
+ headroom_before: number | null;
756
+ outstanding_before: number;
757
+ cleared: boolean;
758
+ } | null;
759
+ attempts: {
760
+ reason: "budget_exhausted" | "cap_reached" | "window_uncalibrated";
761
+ pool_id: string;
762
+ constraints: {
763
+ cost: number;
764
+ resource_key: string;
765
+ headroom_before: number | null;
766
+ outstanding_before: number;
767
+ cleared: boolean;
768
+ }[];
769
+ in_flight_before?: number | undefined;
770
+ cap?: number | undefined;
771
+ unpriced_windows?: string[] | undefined;
772
+ }[];
773
+ in_flight_before?: number | undefined;
774
+ cap?: number | undefined;
775
+ unpriced_windows?: string[] | undefined;
308
776
  }[];
309
777
  }>;
310
778
  export type DispatchAdmission = z.infer<typeof DispatchAdmissionSchema>;