audit-tools 0.30.2 → 0.30.4

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 (141) hide show
  1. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  2. package/dist/audit/cli/auditStep.js +24 -13
  3. package/dist/audit/cli/auditStep.js.map +1 -1
  4. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  5. package/dist/audit/cli/nextStepHelpers.js +11 -6
  6. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  7. package/dist/audit/cli/prompts.d.ts.map +1 -1
  8. package/dist/audit/cli/prompts.js +3 -1
  9. package/dist/audit/cli/prompts.js.map +1 -1
  10. package/dist/audit/cli/reviewRun.d.ts.map +1 -1
  11. package/dist/audit/cli/reviewRun.js +9 -4
  12. package/dist/audit/cli/reviewRun.js.map +1 -1
  13. package/dist/audit/contracts/workerSchemas.d.ts +22 -4
  14. package/dist/audit/contracts/workerSchemas.d.ts.map +1 -1
  15. package/dist/audit/contracts/wrapperResponse.d.ts +12 -12
  16. package/dist/audit/orchestrator/artifactFreshness.d.ts +2 -1
  17. package/dist/audit/orchestrator/artifactFreshness.d.ts.map +1 -1
  18. package/dist/audit/orchestrator/artifactFreshness.js +5 -15
  19. package/dist/audit/orchestrator/artifactFreshness.js.map +1 -1
  20. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  21. package/dist/audit/orchestrator/executorRunners.js +10 -9
  22. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  23. package/dist/audit/orchestrator/ingestionExecutors.d.ts.map +1 -1
  24. package/dist/audit/orchestrator/ingestionExecutors.js +5 -1
  25. package/dist/audit/orchestrator/ingestionExecutors.js.map +1 -1
  26. package/dist/audit/orchestrator/intentCheckpointGate.d.ts +129 -0
  27. package/dist/audit/orchestrator/intentCheckpointGate.d.ts.map +1 -0
  28. package/dist/audit/orchestrator/intentCheckpointGate.js +193 -0
  29. package/dist/audit/orchestrator/intentCheckpointGate.js.map +1 -0
  30. package/dist/audit/orchestrator/ledger.d.ts +30 -0
  31. package/dist/audit/orchestrator/ledger.d.ts.map +1 -0
  32. package/dist/audit/orchestrator/ledger.js +126 -0
  33. package/dist/audit/orchestrator/ledger.js.map +1 -0
  34. package/dist/audit/orchestrator/nextStep.d.ts +11 -29
  35. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  36. package/dist/audit/orchestrator/nextStep.js +11 -29
  37. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  38. package/dist/audit/orchestrator/resultBaseline.d.ts +82 -0
  39. package/dist/audit/orchestrator/resultBaseline.d.ts.map +1 -0
  40. package/dist/audit/orchestrator/resultBaseline.js +79 -0
  41. package/dist/audit/orchestrator/resultBaseline.js.map +1 -0
  42. package/dist/audit/quota/index.d.ts +17 -12
  43. package/dist/audit/quota/index.d.ts.map +1 -1
  44. package/dist/audit/types/artifactMetadata.d.ts +9 -0
  45. package/dist/audit/types/artifactMetadata.d.ts.map +1 -1
  46. package/dist/audit/types.d.ts +13 -4
  47. package/dist/audit/types.d.ts.map +1 -1
  48. package/dist/audit/types.js +8 -0
  49. package/dist/audit/types.js.map +1 -1
  50. package/dist/remediate/steps/dispatch.d.ts.map +1 -1
  51. package/dist/remediate/steps/dispatch.js +16 -22
  52. package/dist/remediate/steps/dispatch.js.map +1 -1
  53. package/dist/remediate/steps/nextStep.d.ts +11 -23
  54. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  55. package/dist/remediate/steps/nextStep.js +49 -43
  56. package/dist/remediate/steps/nextStep.js.map +1 -1
  57. package/dist/shared/contentKey.d.ts +83 -0
  58. package/dist/shared/contentKey.d.ts.map +1 -0
  59. package/dist/shared/contentKey.js +163 -0
  60. package/dist/shared/contentKey.js.map +1 -0
  61. package/dist/shared/dispatch/rollingDispatch.d.ts.map +1 -1
  62. package/dist/shared/dispatch/rollingDispatch.js +7 -3
  63. package/dist/shared/dispatch/rollingDispatch.js.map +1 -1
  64. package/dist/shared/friction/captureFrictionEvent.d.ts +50 -0
  65. package/dist/shared/friction/captureFrictionEvent.d.ts.map +1 -0
  66. package/dist/shared/friction/captureFrictionEvent.js +34 -0
  67. package/dist/shared/friction/captureFrictionEvent.js.map +1 -0
  68. package/dist/shared/friction/triage.d.ts +126 -0
  69. package/dist/shared/friction/triage.d.ts.map +1 -0
  70. package/dist/shared/friction/triage.js +149 -0
  71. package/dist/shared/friction/triage.js.map +1 -0
  72. package/dist/shared/index.d.ts +15 -3
  73. package/dist/shared/index.d.ts.map +1 -1
  74. package/dist/shared/index.js +11 -3
  75. package/dist/shared/index.js.map +1 -1
  76. package/dist/shared/io/auditToolsPaths.d.ts +9 -0
  77. package/dist/shared/io/auditToolsPaths.d.ts.map +1 -1
  78. package/dist/shared/io/auditToolsPaths.js +11 -0
  79. package/dist/shared/io/auditToolsPaths.js.map +1 -1
  80. package/dist/shared/io/frictionCapture.d.ts +2 -0
  81. package/dist/shared/io/frictionCapture.d.ts.map +1 -1
  82. package/dist/shared/io/frictionCapture.js +1 -1
  83. package/dist/shared/io/frictionCapture.js.map +1 -1
  84. package/dist/shared/quota/apiPool.d.ts +1 -1
  85. package/dist/shared/quota/apiPool.d.ts.map +1 -1
  86. package/dist/shared/quota/apiPool.js +29 -7
  87. package/dist/shared/quota/apiPool.js.map +1 -1
  88. package/dist/shared/quota/capacity.d.ts +19 -4
  89. package/dist/shared/quota/capacity.d.ts.map +1 -1
  90. package/dist/shared/quota/capacity.js +5 -0
  91. package/dist/shared/quota/capacity.js.map +1 -1
  92. package/dist/shared/quota/claudeOAuthQuotaSource.d.ts +8 -0
  93. package/dist/shared/quota/claudeOAuthQuotaSource.d.ts.map +1 -1
  94. package/dist/shared/quota/claudeOAuthQuotaSource.js +15 -0
  95. package/dist/shared/quota/claudeOAuthQuotaSource.js.map +1 -1
  96. package/dist/shared/quota/codexQuotaSource.d.ts +3 -0
  97. package/dist/shared/quota/codexQuotaSource.d.ts.map +1 -1
  98. package/dist/shared/quota/codexQuotaSource.js +8 -0
  99. package/dist/shared/quota/codexQuotaSource.js.map +1 -1
  100. package/dist/shared/quota/compositeQuotaSource.d.ts +22 -0
  101. package/dist/shared/quota/compositeQuotaSource.d.ts.map +1 -1
  102. package/dist/shared/quota/compositeQuotaSource.js +42 -0
  103. package/dist/shared/quota/compositeQuotaSource.js.map +1 -1
  104. package/dist/shared/quota/coverage.d.ts +45 -0
  105. package/dist/shared/quota/coverage.d.ts.map +1 -0
  106. package/dist/shared/quota/coverage.js +77 -0
  107. package/dist/shared/quota/coverage.js.map +1 -0
  108. package/dist/shared/quota/httpQuotaSource.d.ts +24 -1
  109. package/dist/shared/quota/httpQuotaSource.d.ts.map +1 -1
  110. package/dist/shared/quota/httpQuotaSource.js +46 -6
  111. package/dist/shared/quota/httpQuotaSource.js.map +1 -1
  112. package/dist/shared/quota/quotaCoverageNudge.d.ts +26 -0
  113. package/dist/shared/quota/quotaCoverageNudge.d.ts.map +1 -0
  114. package/dist/shared/quota/quotaCoverageNudge.js +82 -0
  115. package/dist/shared/quota/quotaCoverageNudge.js.map +1 -0
  116. package/dist/shared/quota/quotaSource.d.ts +25 -2
  117. package/dist/shared/quota/quotaSource.d.ts.map +1 -1
  118. package/dist/shared/quota/quotaSource.js +15 -0
  119. package/dist/shared/quota/quotaSource.js.map +1 -1
  120. package/dist/shared/quota/scheduler.d.ts +10 -2
  121. package/dist/shared/quota/scheduler.d.ts.map +1 -1
  122. package/dist/shared/quota/scheduler.js +12 -3
  123. package/dist/shared/quota/scheduler.js.map +1 -1
  124. package/dist/shared/repair/emitValidateRepair.d.ts +124 -0
  125. package/dist/shared/repair/emitValidateRepair.d.ts.map +1 -0
  126. package/dist/shared/repair/emitValidateRepair.js +179 -0
  127. package/dist/shared/repair/emitValidateRepair.js.map +1 -0
  128. package/dist/shared/repair/index.d.ts +8 -0
  129. package/dist/shared/repair/index.d.ts.map +1 -0
  130. package/dist/shared/repair/index.js +2 -0
  131. package/dist/shared/repair/index.js.map +1 -0
  132. package/dist/shared/stableStringify.d.ts +14 -0
  133. package/dist/shared/stableStringify.d.ts.map +1 -0
  134. package/dist/shared/stableStringify.js +28 -0
  135. package/dist/shared/stableStringify.js.map +1 -0
  136. package/dist/shared/types/sessionConfig.d.ts +16 -0
  137. package/dist/shared/types/sessionConfig.d.ts.map +1 -1
  138. package/dist/shared/types/sessionConfig.js.map +1 -1
  139. package/package.json +1 -1
  140. package/schemas/audit_result.schema.json +9 -0
  141. package/schemas/audit_results.schema.json +9 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intentCheckpointGate.js","sourceRoot":"","sources":["../../../src/audit/orchestrator/intentCheckpointGate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAkCxF,mEAAmE;AACnE,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACvD,OAAO,EAAE,gCAAgC;IACzC,cAAc,EAAE,CAAC,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,CAAC;CAC9F,CAAC;AAEF,wEAAwE;AACxE,MAAM,CAAC,MAAM,mCAAmC,GAAG,mCAAmC,CAAC;AAEvF;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAAwC,EACxC,SAA0B,wBAAwB;IAElD,IAAI,CAAC,UAAU;QAAE,OAAO,eAAe,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,UAAU,GAA4B,EAAE,CAAC;IAC/C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,2EAA2E;YAC3E,uDAAuD;YACvD,UAAU,CAAC,KAAe,CAAC;gBACzB,OAAO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gG;aACjH,EACD,YAAY,CACb,CAAC;QACJ,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { AuditResult } from "../types.js";
2
+ /**
3
+ * Stamp a result with its seam-derived ledger keys (instance_id, identity_key,
4
+ * idempotency_key) when they are not already present. Idempotent: a record that
5
+ * already carries an idempotency_key keeps its identity/idempotency keys (so a
6
+ * replay hashes identically), and only re-mints an absent instance_id.
7
+ */
8
+ export declare function stampLedgerKeys(result: AuditResult): AuditResult;
9
+ /**
10
+ * Append incoming results to the existing ledger, append-only and IDEMPOTENT on
11
+ * idempotency_key. Each appended record gets a fresh instance_id; a replay (an
12
+ * incoming result whose idempotency_key already exists in the ledger OR collides
13
+ * with an earlier record in the same batch) is a no-op. Distinct idempotency_keys
14
+ * always both persist — never merged, never last-writer-wins (fail-2).
15
+ *
16
+ * The existing ledger is returned by reference-extended copy; existing records
17
+ * are left untouched (append-only).
18
+ */
19
+ export declare function appendResultsToLedger(existing: AuditResult[] | undefined, incoming: AuditResult[]): AuditResult[];
20
+ /**
21
+ * Re-associate ledger records to tasks. Groups one-to-many by `identity_key`
22
+ * (multiple distinct results legitimately share a coordinate — base vs. deepening
23
+ * / steward) and resolves logical identity by `idempotency_key`. Records are
24
+ * stamped on read if a legacy entry predates the keys, so a ledger written before
25
+ * O2 still groups correctly. RETAIN-UNASSIGNED: every record appears in exactly
26
+ * one group keyed by its identity_key — none is dropped because its task is
27
+ * absent (INV-3); the caller decides what to do with a group whose task is gone.
28
+ */
29
+ export declare function groupLedgerByIdentity(ledger: AuditResult[]): Map<string, AuditResult[]>;
30
+ //# sourceMappingURL=ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/audit/orchestrator/ledger.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAoB/C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAwBhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,WAAW,EAAE,GAAG,SAAS,EACnC,QAAQ,EAAE,WAAW,EAAE,GACtB,WAAW,EAAE,CAkBf;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,WAAW,EAAE,GACpB,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAS5B"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * O2 — the append-only, instance-keyed, idempotent audit-results ledger.
3
+ *
4
+ * `audit_results.jsonl` is the cumulative store of every accepted AuditResult.
5
+ * This module is the SOLE place the ledger grows, so its three invariants hold
6
+ * by construction (never by a caller remembering them):
7
+ *
8
+ * - APPEND-ONLY, INSTANCE-KEYED (INV-1 / CE-001 / fail-2): every appended record
9
+ * carries a fresh per-record `instance_id` minted from the shared seam
10
+ * (`newInstanceId`). The ledger keys on this, so identity_key / idempotency_key
11
+ * are grouping/idempotency keys, NEVER primary keys — distinct records are never
12
+ * merged or last-writer-wins'd.
13
+ *
14
+ * - IDEMPOTENT ON idempotency_key (INV-2 / CE-001b / fail-4): a record is appended
15
+ * only when no existing record shares its `idempotency_key`. A replay of the same
16
+ * logical result is therefore a no-op. Two genuinely-different same-coordinate
17
+ * results (base vs. deepening / steward / re-dispatch) carry distinct
18
+ * discriminators → distinct idempotency_keys → both persist (CE-001).
19
+ *
20
+ * - RETAIN-UNASSIGNED (INV-3): re-association groups records to tasks by
21
+ * `identity_key` one-to-many and resolves logical identity by `idempotency_key`.
22
+ * A result whose owning task is absent from the active manifest is NEVER pruned —
23
+ * it stays in the ledger, just un-associated.
24
+ *
25
+ * All three keys are imported from the single content-key seam
26
+ * (`src/shared/contentKey.ts`); this module never re-derives a key.
27
+ */
28
+ import { buildResultContentDiscriminator, identityKey, idempotencyKey, newInstanceId, } from "audit-tools/shared";
29
+ /**
30
+ * Deterministic, TOOL-OWNED mapping from a result's coordinate to its emit
31
+ * source. The discriminator recipe lives in the seam; the SOURCE selection lives
32
+ * here because it is audit-domain knowledge: selective-deepening / steward tasks
33
+ * are minted with `deepening:` / `steward:` task-id prefixes (see
34
+ * `selectiveDeepening/shared.ts#taskIdFor`), so a deepening or steward result
35
+ * that shares a base result's {unit_id, lens, pass_id} coordinate legitimately
36
+ * gets a DISTINCT idempotency_key and both persist (CE-001). Anything else is a
37
+ * base result. (Re-dispatch attempts are not yet stamped on results; when O3
38
+ * adds an attempt counter it maps to `source: 'redispatch'` here.)
39
+ */
40
+ function emitSourceFor(result) {
41
+ const taskId = result.task_id ?? "";
42
+ if (taskId.startsWith("steward:"))
43
+ return "steward";
44
+ if (taskId.startsWith("deepening:"))
45
+ return "deepening";
46
+ return "base";
47
+ }
48
+ /**
49
+ * Stamp a result with its seam-derived ledger keys (instance_id, identity_key,
50
+ * idempotency_key) when they are not already present. Idempotent: a record that
51
+ * already carries an idempotency_key keeps its identity/idempotency keys (so a
52
+ * replay hashes identically), and only re-mints an absent instance_id.
53
+ */
54
+ export function stampLedgerKeys(result) {
55
+ const identity_key = result.identity_key ??
56
+ identityKey({
57
+ unit_id: result.unit_id,
58
+ lens: result.lens,
59
+ pass_id: result.pass_id,
60
+ });
61
+ const idempotency_key = result.idempotency_key ??
62
+ idempotencyKey({
63
+ unit_id: result.unit_id,
64
+ lens: result.lens,
65
+ pass_id: result.pass_id,
66
+ result_content_discriminator: buildResultContentDiscriminator({
67
+ source: emitSourceFor(result),
68
+ }),
69
+ });
70
+ return {
71
+ ...result,
72
+ instance_id: result.instance_id ?? newInstanceId(),
73
+ identity_key,
74
+ idempotency_key,
75
+ };
76
+ }
77
+ /**
78
+ * Append incoming results to the existing ledger, append-only and IDEMPOTENT on
79
+ * idempotency_key. Each appended record gets a fresh instance_id; a replay (an
80
+ * incoming result whose idempotency_key already exists in the ledger OR collides
81
+ * with an earlier record in the same batch) is a no-op. Distinct idempotency_keys
82
+ * always both persist — never merged, never last-writer-wins (fail-2).
83
+ *
84
+ * The existing ledger is returned by reference-extended copy; existing records
85
+ * are left untouched (append-only).
86
+ */
87
+ export function appendResultsToLedger(existing, incoming) {
88
+ const ledger = [...(existing ?? [])];
89
+ const seen = new Set();
90
+ for (const record of ledger) {
91
+ const key = record.idempotency_key;
92
+ if (typeof key === "string")
93
+ seen.add(key);
94
+ }
95
+ for (const raw of incoming) {
96
+ const stamped = stampLedgerKeys(raw);
97
+ const key = stamped.idempotency_key;
98
+ if (seen.has(key)) {
99
+ // Replay of an already-ingested logical result — no-op (INV-2).
100
+ continue;
101
+ }
102
+ seen.add(key);
103
+ ledger.push(stamped);
104
+ }
105
+ return ledger;
106
+ }
107
+ /**
108
+ * Re-associate ledger records to tasks. Groups one-to-many by `identity_key`
109
+ * (multiple distinct results legitimately share a coordinate — base vs. deepening
110
+ * / steward) and resolves logical identity by `idempotency_key`. Records are
111
+ * stamped on read if a legacy entry predates the keys, so a ledger written before
112
+ * O2 still groups correctly. RETAIN-UNASSIGNED: every record appears in exactly
113
+ * one group keyed by its identity_key — none is dropped because its task is
114
+ * absent (INV-3); the caller decides what to do with a group whose task is gone.
115
+ */
116
+ export function groupLedgerByIdentity(ledger) {
117
+ const byIdentity = new Map();
118
+ for (const raw of ledger) {
119
+ const record = stampLedgerKeys(raw);
120
+ const group = byIdentity.get(record.identity_key) ?? [];
121
+ group.push(record);
122
+ byIdentity.set(record.identity_key, group);
123
+ }
124
+ return byIdentity;
125
+ }
126
+ //# sourceMappingURL=ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src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,CAAC,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC;QACnC,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,OAAO,CAAC,eAAgB,CAAC;QACrC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAClB,gEAAgE;YAChE,SAAS;QACX,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAAqB;IAErB,MAAM,UAAU,GAAG,IAAI,GAAG,EAAyB,CAAC;IACpD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,YAAa,CAAC,IAAI,EAAE,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,YAAa,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { type FrictionTriageDecision } from "audit-tools/shared";
1
2
  import type { ArtifactBundle } from "../io/artifacts.js";
2
3
  import type { AuditObligation, AuditState } from "../types/auditState.js";
3
4
  export interface NextStepDecision {
@@ -15,35 +16,16 @@ export declare const FRICTION_CAPTURE_OBLIGATION_ID = "friction_capture_current"
15
16
  export declare const PRIORITY: string[];
16
17
  export declare function findObligation(obligations: AuditObligation[]): AuditObligation | undefined;
17
18
  export declare function decideNextStep(bundle: ArtifactBundle): NextStepDecision;
18
- /** The terminal friction-capture close-out decision for the audit half. */
19
- export interface AuditFrictionCloseoutDecision {
20
- /**
21
- * "capture" → the close-out must fire this pass (a friction step is emitted and a
22
- * degrade-clean record persisted). "captured" → already recorded for this run_id;
23
- * the close-out is satisfied and the run proceeds to its complete/present terminal.
24
- */
25
- action: "capture" | "captured";
26
- /** The run_id-keyed friction record path (always set, for the handoff pointer). */
27
- recordPath: string;
28
- }
29
19
  /**
30
- * Resolve (and, on first fire, satisfy) the terminal friction-capture close-out for
31
- * the audit half. This is the audit analog of remediate-code's friction gate in
32
- * `handleComplete`:
33
- *
34
- * - DETERMINISTIC: keyed only off the on-disk record at `(artifactsDir, runId)` via
35
- * the SINGLE shared helper never host discretion or a bundle flag.
36
- * - DEGRADE-CLEANLY: on first fire it persists a zero-friction record up front, so
37
- * the close-out is immediately satisfiable and can NEVER block completion.
38
- * - NEVER RE-LOOP: once a record exists, returns "captured" and the run proceeds —
39
- * the close-out fires at most once per run.
40
- * - PARITY: identical shape + persist helper to the remediate side (single-sourced
41
- * in `audit-tools/shared`), so the two halves cannot drift.
42
- * - NEVER couples to any repo's backlog doc — the record lives under the run's own
43
- * artifacts dir.
44
- *
45
- * Returns "capture" the first time (the host should be prompted to optionally enrich
46
- * the persisted record), "captured" thereafter.
20
+ * The terminal friction-TRIAGE close-out for the audit half. Thin delegation to the
21
+ * single-sourced `decideFrictionTriage` (`audit-tools/shared`) so the triage shape,
22
+ * disposition vocabulary, blocking semantics, and close-out logic cannot drift from
23
+ * the remediate half. Drops the former false-green (an empty up-front record no
24
+ * longer satisfies): the close-out blocks ("dispose") until every captured
25
+ * mechanical event AND every surfaced agent-feedback reflection carries a
26
+ * disposition; an empty set (zero events AND zero reflections) is trivially
27
+ * "disposed". Keyed only off `(artifactsDir, runId)`; never coupled to any repo's
28
+ * backlog doc.
47
29
  */
48
- export declare function decideAuditFrictionCloseout(artifactsDir: string, runId: string): Promise<AuditFrictionCloseoutDecision>;
30
+ export declare function decideAuditFrictionCloseout(artifactsDir: string, runId: string): Promise<FrictionTriageDecision>;
49
31
  //# sourceMappingURL=nextStep.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nextStep.d.ts","sourceRoot":"","sources":["../../../src/audit/orchestrator/nextStep.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAI1E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,6BAA6B,CAAC;AAEzE,eAAO,MAAM,QAAQ,EAAE,MAAM,EAwB5B,CAAC;AAMF,wBAAgB,cAAc,CAC5B,WAAW,EAAE,eAAe,EAAE,GAC7B,eAAe,GAAG,SAAS,CAE7B;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAqCvE;AAED,2EAA2E;AAC3E,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;IAC/B,mFAAmF;IACnF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,6BAA6B,CAAC,CAYxC"}
1
+ {"version":3,"file":"nextStep.d.ts","sourceRoot":"","sources":["../../../src/audit/orchestrator/nextStep.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAI1E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,6BAA6B,CAAC;AAEzE,eAAO,MAAM,QAAQ,EAAE,MAAM,EAwB5B,CAAC;AAMF,wBAAgB,cAAc,CAC5B,WAAW,EAAE,eAAe,EAAE,GAC7B,eAAe,GAAG,SAAS,CAE7B;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAqCvE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAEjC"}
@@ -1,5 +1,5 @@
1
1
  import { findFirstActionableObligation } from "audit-tools/shared";
2
- import { frictionCaptured, persistFrictionCapture, frictionCapturePath, } from "audit-tools/shared";
2
+ import { decideFrictionTriage, } from "audit-tools/shared";
3
3
  import { EXECUTOR_REGISTRY } from "./executors.js";
4
4
  import { deriveAuditState } from "./state.js";
5
5
  /**
@@ -74,35 +74,17 @@ export function decideNextStep(bundle) {
74
74
  };
75
75
  }
76
76
  /**
77
- * Resolve (and, on first fire, satisfy) the terminal friction-capture close-out for
78
- * the audit half. This is the audit analog of remediate-code's friction gate in
79
- * `handleComplete`:
80
- *
81
- * - DETERMINISTIC: keyed only off the on-disk record at `(artifactsDir, runId)` via
82
- * the SINGLE shared helper never host discretion or a bundle flag.
83
- * - DEGRADE-CLEANLY: on first fire it persists a zero-friction record up front, so
84
- * the close-out is immediately satisfiable and can NEVER block completion.
85
- * - NEVER RE-LOOP: once a record exists, returns "captured" and the run proceeds —
86
- * the close-out fires at most once per run.
87
- * - PARITY: identical shape + persist helper to the remediate side (single-sourced
88
- * in `audit-tools/shared`), so the two halves cannot drift.
89
- * - NEVER couples to any repo's backlog doc — the record lives under the run's own
90
- * artifacts dir.
91
- *
92
- * Returns "capture" the first time (the host should be prompted to optionally enrich
93
- * the persisted record), "captured" thereafter.
77
+ * The terminal friction-TRIAGE close-out for the audit half. Thin delegation to the
78
+ * single-sourced `decideFrictionTriage` (`audit-tools/shared`) so the triage shape,
79
+ * disposition vocabulary, blocking semantics, and close-out logic cannot drift from
80
+ * the remediate half. Drops the former false-green (an empty up-front record no
81
+ * longer satisfies): the close-out blocks ("dispose") until every captured
82
+ * mechanical event AND every surfaced agent-feedback reflection carries a
83
+ * disposition; an empty set (zero events AND zero reflections) is trivially
84
+ * "disposed". Keyed only off `(artifactsDir, runId)`; never coupled to any repo's
85
+ * backlog doc.
94
86
  */
95
87
  export async function decideAuditFrictionCloseout(artifactsDir, runId) {
96
- const recordPath = frictionCapturePath(artifactsDir, runId);
97
- if (await frictionCaptured(artifactsDir, runId)) {
98
- return { action: "captured", recordPath };
99
- }
100
- await persistFrictionCapture({
101
- artifactsDir,
102
- runId,
103
- tool: "audit-code",
104
- frictions: [],
105
- });
106
- return { action: "capture", recordPath };
88
+ return decideFrictionTriage(artifactsDir, runId, "audit-code");
107
89
  }
108
90
  //# sourceMappingURL=nextStep.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nextStep.js","sourceRoot":"","sources":["../../../src/audit/orchestrator/nextStep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,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,WAAW,CAAC,CAAC;IAE/C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;YACL,KAAK;YACL,mBAAmB,EAAE,IAAI;YACzB,iBAAiB,EAAE,IAAI;YACvB,MAAM,EACJ,KAAK,CAAC,MAAM,KAAK,UAAU;gBACzB,CAAC,CAAC,gDAAgD;gBAClD,CAAC,CAAC,6CAA6C;SACpD,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAC/C,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CACtC,CAAC;IACF,OAAO;QACL,KAAK;QACL,mBAAmB,EAAE,IAAI,CAAC,EAAE;QAC5B,iBAAiB,EAAE,QAAQ,EAAE,EAAE,IAAI,IAAI;QACvC,MAAM,EAAE,QAAQ;YACd,CAAC,CAAC,mDAAmD,IAAI,CAAC,EAAE,GAAG;YAC/D,CAAC,CAAC,oCAAoC,IAAI,CAAC,EAAE,8IAA8I;KAC9L,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,YAAoB,EACpB,KAAa;IAEb,OAAO,oBAAoB,CAAC,YAAY,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * O2 ↔ F1 residual-risk fix for judge-accepted CE-011: element-staleness for an
3
+ * already-ingested logical result must compare a FRESHLY-COMPUTED current
4
+ * `contentKey` (derived from the LIVE `task_content_signature` at advance time)
5
+ * against a prior BASELINE `contentKey` — and that baseline must live OUTSIDE the
6
+ * immutable per-record ledger instance.
7
+ *
8
+ * Why not read the contentKey off the ledger record? The append-only ledger
9
+ * (INV-O2-1) keys records on `idempotency_key`, which is signature-STABLE: a
10
+ * benign content edit (C1 → C2) does NOT move it, so idempotent re-ingest of the
11
+ * already-ingested result stays a no-op (no duplicate record is appended). If
12
+ * staleness ALSO read its prior contentKey from that same immutable record, the
13
+ * record would still carry C1 and a benign edit could never fire staleness — the
14
+ * exact CE-011 residual hole. So the baseline contentKey is persisted in a
15
+ * SEPARATE store (`artifact_metadata.result_baselines`, keyed by
16
+ * `idempotency_key`) that the staleness gate updates as the live signature moves,
17
+ * while the ledger record itself is never mutated. Append-only ledger invariants
18
+ * are therefore untouched.
19
+ *
20
+ * The comparison driver is the seam's `contentKey` (signature-SENSITIVE), so:
21
+ * live C2 != baseline C1 ⟹ staleness FIRES,
22
+ * while the seam's signature-STABLE `idempotencyKey` keeps idempotent re-ingest a
23
+ * no-op. The two are reconciled by construction (see src/shared/contentKey.ts).
24
+ */
25
+ import { type ResultEmitSource } from "audit-tools/shared";
26
+ /**
27
+ * The baseline store — the per-logical-result contentKey snapshot, keyed by the
28
+ * signature-STABLE `idempotency_key`. Persisted in `artifact_metadata` OUTSIDE
29
+ * the per-record ledger, so updating a baseline never mutates an immutable ledger
30
+ * record (INV-O2-1 untouched).
31
+ */
32
+ export type ResultBaselineStore = Record<string, string>;
33
+ /** The live coordinate + signature needed to freshly compute the current keys. */
34
+ export interface LiveResultKeyInput {
35
+ unit_id: string;
36
+ lens: string;
37
+ pass_id: string;
38
+ /** Tool-owned emit source (base | deepening | steward | redispatch). */
39
+ source: ResultEmitSource;
40
+ /** Required when `source === 'redispatch'`. */
41
+ attempt?: number;
42
+ /**
43
+ * The LIVE task-content signature derived from the current task content at
44
+ * advance time — NEVER a value read off a stored ledger record.
45
+ */
46
+ task_content_signature: string;
47
+ }
48
+ /**
49
+ * Freshly derive the {idempotency_key, content_key} pair for a live result from
50
+ * the seam — both computed from the live `task_content_signature` at advance
51
+ * time. `idempotency_key` is the baseline-store key (signature-STABLE);
52
+ * `content_key` is the staleness driver (signature-SENSITIVE).
53
+ */
54
+ export declare function deriveLiveResultKeys(input: LiveResultKeyInput): {
55
+ idempotency_key: string;
56
+ content_key: string;
57
+ };
58
+ /**
59
+ * Is the already-ingested logical result stale, given its LIVE keys? Stale iff a
60
+ * baseline exists for the idempotency_key AND the freshly-computed live
61
+ * content_key differs from it. A result with no recorded baseline is NOT stale —
62
+ * it has simply never been compared (the first ingest establishes the baseline).
63
+ *
64
+ * The caller supplies live keys via `deriveLiveResultKeys` (freshly computed from
65
+ * the live signature) — this function NEVER reads a contentKey off a ledger
66
+ * record.
67
+ */
68
+ export declare function isResultStaleAgainstBaseline(baselines: ResultBaselineStore | undefined, liveKeys: {
69
+ idempotency_key: string;
70
+ content_key: string;
71
+ }): boolean;
72
+ /**
73
+ * Return an updated baseline store with this logical result's baseline set to its
74
+ * live content_key. Pure: returns a new object, never mutates the input — so a
75
+ * caller persists the result through the normal artifact_metadata write path.
76
+ * Idempotent: recording the same content_key again yields an equal store.
77
+ */
78
+ export declare function recordResultBaseline(baselines: ResultBaselineStore | undefined, liveKeys: {
79
+ idempotency_key: string;
80
+ content_key: string;
81
+ }): ResultBaselineStore;
82
+ //# sourceMappingURL=resultBaseline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultBaseline.d.ts","sourceRoot":"","sources":["../../../src/audit/orchestrator/resultBaseline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzD,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,MAAM,EAAE,gBAAgB,CAAC;IACzB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG;IAC/D,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAkBA;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,mBAAmB,GAAG,SAAS,EAC1C,QAAQ,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACzD,OAAO,CAIT;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,mBAAmB,GAAG,SAAS,EAC1C,QAAQ,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACzD,mBAAmB,CAKrB"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * O2 ↔ F1 residual-risk fix for judge-accepted CE-011: element-staleness for an
3
+ * already-ingested logical result must compare a FRESHLY-COMPUTED current
4
+ * `contentKey` (derived from the LIVE `task_content_signature` at advance time)
5
+ * against a prior BASELINE `contentKey` — and that baseline must live OUTSIDE the
6
+ * immutable per-record ledger instance.
7
+ *
8
+ * Why not read the contentKey off the ledger record? The append-only ledger
9
+ * (INV-O2-1) keys records on `idempotency_key`, which is signature-STABLE: a
10
+ * benign content edit (C1 → C2) does NOT move it, so idempotent re-ingest of the
11
+ * already-ingested result stays a no-op (no duplicate record is appended). If
12
+ * staleness ALSO read its prior contentKey from that same immutable record, the
13
+ * record would still carry C1 and a benign edit could never fire staleness — the
14
+ * exact CE-011 residual hole. So the baseline contentKey is persisted in a
15
+ * SEPARATE store (`artifact_metadata.result_baselines`, keyed by
16
+ * `idempotency_key`) that the staleness gate updates as the live signature moves,
17
+ * while the ledger record itself is never mutated. Append-only ledger invariants
18
+ * are therefore untouched.
19
+ *
20
+ * The comparison driver is the seam's `contentKey` (signature-SENSITIVE), so:
21
+ * live C2 != baseline C1 ⟹ staleness FIRES,
22
+ * while the seam's signature-STABLE `idempotencyKey` keeps idempotent re-ingest a
23
+ * no-op. The two are reconciled by construction (see src/shared/contentKey.ts).
24
+ */
25
+ import { buildResultContentDiscriminator, contentKey, idempotencyKey, } from "audit-tools/shared";
26
+ /**
27
+ * Freshly derive the {idempotency_key, content_key} pair for a live result from
28
+ * the seam — both computed from the live `task_content_signature` at advance
29
+ * time. `idempotency_key` is the baseline-store key (signature-STABLE);
30
+ * `content_key` is the staleness driver (signature-SENSITIVE).
31
+ */
32
+ export function deriveLiveResultKeys(input) {
33
+ const discriminator = buildResultContentDiscriminator({
34
+ source: input.source,
35
+ attempt: input.attempt,
36
+ });
37
+ const coordinate = {
38
+ unit_id: input.unit_id,
39
+ lens: input.lens,
40
+ pass_id: input.pass_id,
41
+ result_content_discriminator: discriminator,
42
+ };
43
+ return {
44
+ idempotency_key: idempotencyKey(coordinate),
45
+ content_key: contentKey({
46
+ ...coordinate,
47
+ task_content_signature: input.task_content_signature,
48
+ }),
49
+ };
50
+ }
51
+ /**
52
+ * Is the already-ingested logical result stale, given its LIVE keys? Stale iff a
53
+ * baseline exists for the idempotency_key AND the freshly-computed live
54
+ * content_key differs from it. A result with no recorded baseline is NOT stale —
55
+ * it has simply never been compared (the first ingest establishes the baseline).
56
+ *
57
+ * The caller supplies live keys via `deriveLiveResultKeys` (freshly computed from
58
+ * the live signature) — this function NEVER reads a contentKey off a ledger
59
+ * record.
60
+ */
61
+ export function isResultStaleAgainstBaseline(baselines, liveKeys) {
62
+ const baseline = baselines?.[liveKeys.idempotency_key];
63
+ if (baseline === undefined)
64
+ return false;
65
+ return baseline !== liveKeys.content_key;
66
+ }
67
+ /**
68
+ * Return an updated baseline store with this logical result's baseline set to its
69
+ * live content_key. Pure: returns a new object, never mutates the input — so a
70
+ * caller persists the result through the normal artifact_metadata write path.
71
+ * Idempotent: recording the same content_key again yields an equal store.
72
+ */
73
+ export function recordResultBaseline(baselines, liveKeys) {
74
+ return {
75
+ ...(baselines ?? {}),
76
+ [liveKeys.idempotency_key]: liveKeys.content_key,
77
+ };
78
+ }
79
+ //# sourceMappingURL=resultBaseline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultBaseline.js","sourceRoot":"","sources":["../../../src/audit/orchestrator/resultBaseline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,+BAA+B,EAC/B,UAAU,EACV,cAAc,GAEf,MAAM,oBAAoB,CAAC;AA0B5B;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAyB;IAI5D,MAAM,aAAa,GAAG,+BAA+B,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC;IACH,MAAM,UAAU,GAAG;QACjB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,4BAA4B,EAAE,aAAa;KAC5C,CAAC;IACF,OAAO;QACL,eAAe,EAAE,cAAc,CAAC,UAAU,CAAC;QAC3C,WAAW,EAAE,UAAU,CAAC;YACtB,GAAG,UAAU;YACb,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;SACrD,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,4BAA4B,CAC1C,SAA0C,EAC1C,QAA0D;IAE1D,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IACvD,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACzC,OAAO,QAAQ,KAAK,QAAQ,CAAC,WAAW,CAAC;AAC3C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAA0C,EAC1C,QAA0D;IAE1D,OAAO;QACL,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;QACpB,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,WAAW;KACjD,CAAC;AACJ,CAAC"}
@@ -105,21 +105,22 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
105
105
  captured_at: z.ZodString;
106
106
  source: z.ZodString;
107
107
  }, "strict", z.ZodTypeAny, {
108
+ captured_at: string;
108
109
  remaining_pct: number | null;
109
110
  reset_at: string | null;
110
111
  requests_remaining: number | null;
111
112
  tokens_remaining: number | null;
112
- captured_at: string;
113
113
  source: string;
114
114
  }, {
115
+ captured_at: string;
115
116
  remaining_pct: number | null;
116
117
  reset_at: string | null;
117
118
  requests_remaining: number | null;
118
119
  tokens_remaining: number | null;
119
- captured_at: string;
120
120
  source: string;
121
121
  }>>>;
122
122
  quota_signal_degraded: z.ZodOptional<z.ZodBoolean>;
123
+ quota_coverage: z.ZodOptional<z.ZodEnum<["established", "reactive_only", "unestablished"]>>;
123
124
  }, "strict", z.ZodTypeAny, {
124
125
  confidence: "high" | "low" | "medium";
125
126
  source: "default" | "explicit_config" | "discovered_capability" | "cli_flags" | "provider_default" | "learned";
@@ -143,14 +144,15 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
143
144
  binding_cap: "none" | "learned" | "rpm" | "tpm" | "fallback" | "first_contact" | "cooldown" | "host_concurrency";
144
145
  rank?: "deep" | "small" | "standard" | undefined;
145
146
  quota_source_snapshot?: {
147
+ captured_at: string;
146
148
  remaining_pct: number | null;
147
149
  reset_at: string | null;
148
150
  requests_remaining: number | null;
149
151
  tokens_remaining: number | null;
150
- captured_at: string;
151
152
  source: string;
152
153
  } | null | undefined;
153
154
  quota_signal_degraded?: boolean | undefined;
155
+ quota_coverage?: "established" | "reactive_only" | "unestablished" | undefined;
154
156
  }, {
155
157
  confidence: "high" | "low" | "medium";
156
158
  source: "default" | "explicit_config" | "discovered_capability" | "cli_flags" | "provider_default" | "learned";
@@ -174,14 +176,15 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
174
176
  binding_cap: "none" | "learned" | "rpm" | "tpm" | "fallback" | "first_contact" | "cooldown" | "host_concurrency";
175
177
  rank?: "deep" | "small" | "standard" | undefined;
176
178
  quota_source_snapshot?: {
179
+ captured_at: string;
177
180
  remaining_pct: number | null;
178
181
  reset_at: string | null;
179
182
  requests_remaining: number | null;
180
183
  tokens_remaining: number | null;
181
- captured_at: string;
182
184
  source: string;
183
185
  } | null | undefined;
184
186
  quota_signal_degraded?: boolean | undefined;
187
+ quota_coverage?: "established" | "reactive_only" | "unestablished" | undefined;
185
188
  }>, "many">>;
186
189
  /** Echo of the host-reported model roster (lowest rank first), when given. */
187
190
  host_model_roster: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -210,18 +213,18 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
210
213
  captured_at: z.ZodString;
211
214
  source: z.ZodString;
212
215
  }, "strict", z.ZodTypeAny, {
216
+ captured_at: string;
213
217
  remaining_pct: number | null;
214
218
  reset_at: string | null;
215
219
  requests_remaining: number | null;
216
220
  tokens_remaining: number | null;
217
- captured_at: string;
218
221
  source: string;
219
222
  }, {
223
+ captured_at: string;
220
224
  remaining_pct: number | null;
221
225
  reset_at: string | null;
222
226
  requests_remaining: number | null;
223
227
  tokens_remaining: number | null;
224
- captured_at: string;
225
228
  source: string;
226
229
  }>>>;
227
230
  backoff_state: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -240,6 +243,7 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
240
243
  }, "strict", z.ZodTypeAny, {
241
244
  confidence: "high" | "low" | "medium";
242
245
  contract_version: "audit-code-dispatch-quota/v1alpha1" | "audit-code-dispatch-quota/v1alpha2";
246
+ run_id: string;
243
247
  source: "default" | "explicit_config" | "discovered_capability" | "cli_flags" | "provider_default" | "learned";
244
248
  cooldown_until: string | null;
245
249
  model: string | null;
@@ -255,15 +259,14 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
255
259
  active_subagents: number;
256
260
  description: string;
257
261
  } | null;
258
- run_id: string;
259
262
  max_concurrent_agents: number;
260
263
  binding_cap?: "none" | "learned" | "rpm" | "tpm" | "fallback" | "first_contact" | "cooldown" | "host_concurrency" | undefined;
261
264
  quota_source_snapshot?: {
265
+ captured_at: string;
262
266
  remaining_pct: number | null;
263
267
  reset_at: string | null;
264
268
  requests_remaining: number | null;
265
269
  tokens_remaining: number | null;
266
- captured_at: string;
267
270
  source: string;
268
271
  } | null | undefined;
269
272
  capacity_pools?: {
@@ -289,14 +292,15 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
289
292
  binding_cap: "none" | "learned" | "rpm" | "tpm" | "fallback" | "first_contact" | "cooldown" | "host_concurrency";
290
293
  rank?: "deep" | "small" | "standard" | undefined;
291
294
  quota_source_snapshot?: {
295
+ captured_at: string;
292
296
  remaining_pct: number | null;
293
297
  reset_at: string | null;
294
298
  requests_remaining: number | null;
295
299
  tokens_remaining: number | null;
296
- captured_at: string;
297
300
  source: string;
298
301
  } | null | undefined;
299
302
  quota_signal_degraded?: boolean | undefined;
303
+ quota_coverage?: "established" | "reactive_only" | "unestablished" | undefined;
300
304
  }[] | undefined;
301
305
  host_model_roster?: {
302
306
  context_tokens: number;
@@ -313,6 +317,7 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
313
317
  }, {
314
318
  confidence: "high" | "low" | "medium";
315
319
  contract_version: "audit-code-dispatch-quota/v1alpha1" | "audit-code-dispatch-quota/v1alpha2";
320
+ run_id: string;
316
321
  source: "default" | "explicit_config" | "discovered_capability" | "cli_flags" | "provider_default" | "learned";
317
322
  cooldown_until: string | null;
318
323
  model: string | null;
@@ -328,15 +333,14 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
328
333
  active_subagents: number;
329
334
  description: string;
330
335
  } | null;
331
- run_id: string;
332
336
  max_concurrent_agents: number;
333
337
  binding_cap?: "none" | "learned" | "rpm" | "tpm" | "fallback" | "first_contact" | "cooldown" | "host_concurrency" | undefined;
334
338
  quota_source_snapshot?: {
339
+ captured_at: string;
335
340
  remaining_pct: number | null;
336
341
  reset_at: string | null;
337
342
  requests_remaining: number | null;
338
343
  tokens_remaining: number | null;
339
- captured_at: string;
340
344
  source: string;
341
345
  } | null | undefined;
342
346
  capacity_pools?: {
@@ -362,14 +366,15 @@ export declare const DispatchQuotaSchema: z.ZodObject<{
362
366
  binding_cap: "none" | "learned" | "rpm" | "tpm" | "fallback" | "first_contact" | "cooldown" | "host_concurrency";
363
367
  rank?: "deep" | "small" | "standard" | undefined;
364
368
  quota_source_snapshot?: {
369
+ captured_at: string;
365
370
  remaining_pct: number | null;
366
371
  reset_at: string | null;
367
372
  requests_remaining: number | null;
368
373
  tokens_remaining: number | null;
369
- captured_at: string;
370
374
  source: string;
371
375
  } | null | undefined;
372
376
  quota_signal_degraded?: boolean | undefined;
377
+ quota_coverage?: "established" | "reactive_only" | "unestablished" | undefined;
373
378
  }[] | undefined;
374
379
  host_model_roster?: {
375
380
  context_tokens: number;