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,83 @@
1
+ /** Coordinate that groups results: {unit_id, lens, pass_id}. */
2
+ export interface IdentityKeyInput {
3
+ unit_id: string;
4
+ lens: string;
5
+ pass_id: string;
6
+ }
7
+ /**
8
+ * Inputs to `buildTaskContentSignature`. Any task-defining content may be passed;
9
+ * `task_id` and provenance/timestamp fields are accepted but explicitly STRIPPED
10
+ * (FC-002) so renumbering a task id never changes the signature.
11
+ */
12
+ export interface TaskContentSignatureInput {
13
+ [key: string]: unknown;
14
+ task_id?: unknown;
15
+ }
16
+ /**
17
+ * The closed set of emit paths a result can originate from. The discriminator
18
+ * recipe is keyed off this enum (C-002) — callers pick the source, never the
19
+ * discriminator string.
20
+ */
21
+ export type ResultEmitSource = 'base' | 'deepening' | 'steward' | 'redispatch';
22
+ /** Inputs to `buildResultContentDiscriminator`. */
23
+ export interface ResultContentDiscriminatorInput {
24
+ source: ResultEmitSource;
25
+ /**
26
+ * Required for (and ONLY meaningful for) `source: 'redispatch'`: the 1-based
27
+ * attempt counter that distinguishes an O3 re-dispatch from the result it
28
+ * replaces (R2 advisory). A re-dispatch carries a distinct discriminator so its
29
+ * idempotencyKey differs from the prior attempt.
30
+ */
31
+ attempt?: number;
32
+ }
33
+ /** Inputs to `idempotencyKey`: the identity coordinate + the result discriminator. */
34
+ export interface IdempotencyKeyInput extends IdentityKeyInput {
35
+ result_content_discriminator: string;
36
+ }
37
+ /** Inputs to `contentKey`: everything `idempotencyKey` needs + the task signature. */
38
+ export interface ContentKeyInput extends IdempotencyKeyInput {
39
+ task_content_signature: string;
40
+ }
41
+ /**
42
+ * TOOL-OWNED task-content signature (FC-002 / fail-1). Derives a stable signature
43
+ * from the task-defining content ONLY — `task_id` and timestamp/provenance fields
44
+ * are stripped, then the remaining fields are run through the shared
45
+ * `normalizeForMetadataHash` + canonical `stableStringify` (the single serializer,
46
+ * INV-CK-2), so reordered keys produce an identical signature.
47
+ */
48
+ export declare function buildTaskContentSignature(input: TaskContentSignatureInput): string;
49
+ /**
50
+ * TOOL-OWNED result-content discriminator (C-002 / fail-3). The discriminator
51
+ * string is derived from the emit-source enum (plus the attempt counter for a
52
+ * re-dispatch), never chosen by a caller — because it feeds the signature-STABLE
53
+ * idempotencyKey, an operator-chosen value would be a correctness hazard.
54
+ */
55
+ export declare function buildResultContentDiscriminator(input: ResultContentDiscriminatorInput): string;
56
+ /**
57
+ * sha256 over the canonical {unit_id, lens, pass_id} tuple (INV-CK-3). EXCLUDES
58
+ * task_id and all volatile fields. ONE-TO-MANY grouping key (INV-CK-4) — never a
59
+ * primary key. Throws if any component is missing (fail-3).
60
+ */
61
+ export declare function identityKey(input: IdentityKeyInput): string;
62
+ /**
63
+ * sha256 over {identity_key, result_content_discriminator} (INV-CK-7). SIGNATURE-
64
+ * STABLE: the task_content_signature is deliberately NOT an input, so a benign
65
+ * content edit does not move it (fail-4). This is the key O2 ingests on. equal
66
+ * idempotencyKey ⟹ equal identityKey, since identity_key is a signed input.
67
+ */
68
+ export declare function idempotencyKey(input: IdempotencyKeyInput): string;
69
+ /**
70
+ * sha256 over {idempotency_key, task_content_signature} (INV-CK-5). SIGNATURE-
71
+ * SENSITIVE: bumps when the idempotencyKey OR the task_content_signature changes,
72
+ * so it drives staleness (CE-001 / inv-5). equal contentKey ⟹ equal idempotencyKey
73
+ * ⟹ equal identityKey, since each is a signed input of the next.
74
+ */
75
+ export declare function contentKey(input: ContentKeyInput): string;
76
+ /**
77
+ * Mint a fresh per-record instance id (CE-001 / fail-2). The ledger keys on this,
78
+ * so every appended record is distinct and identityKey/idempotencyKey are never
79
+ * primary keys. This is the ONLY non-deterministic helper in the seam — the three
80
+ * key derivations above are pure.
81
+ */
82
+ export declare function newInstanceId(): string;
83
+ //# sourceMappingURL=contentKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentKey.d.ts","sourceRoot":"","sources":["../../src/shared/contentKey.ts"],"names":[],"mappings":"AA8DA,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,CAAC;AAE/E,mDAAmD;AACnD,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,sFAAsF;AACtF,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,4BAA4B,EAAE,MAAM,CAAC;CACtC;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAoBD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,yBAAyB,GAC/B,MAAM,CAcR;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,+BAA+B,GACrC,MAAM,CAmBR;AAaD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAK3D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CASjE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CASzD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * The shared content-key seam (O2 ↔ F1) — the SOLE definition of the workflow's
3
+ * derived keys (INV-CK-1). O2's append-only results ledger (re-association +
4
+ * append-time idempotency) and F1's element-staleness gate both import their keys
5
+ * from HERE, so the two cannot drift.
6
+ *
7
+ * THREE derived keys, one canonical-input derivation chain (OBL-content-key-seam-contract):
8
+ *
9
+ * - `identityKey` (INV-CK-3 / INV-CK-4): sha256 over the canonical
10
+ * {unit_id, lens, pass_id} tuple. EXCLUDES task_id and every volatile/provenance
11
+ * field (INV-CK-3). It is a ONE-TO-MANY GROUPING key (INV-CK-4 / CE-001) used to
12
+ * re-associate ledger records — NEVER a primary key. `{unit_id, lens, pass_id}` is
13
+ * not unique within a pass (base vs. deepening/steward, or an O3 re-dispatch), so
14
+ * multiple distinct results legitimately share one identityKey.
15
+ *
16
+ * - `idempotencyKey` (INV-CK-7, signature-STABLE): sha256 over
17
+ * {identity_key, result_content_discriminator}. It is the anchor O2 ingests on:
18
+ * a replay of the *same* logical result is a no-op (CE-001b / fail-4), because a
19
+ * benign edit to the task content (which only moves the task_content_signature)
20
+ * does NOT move the idempotencyKey. Two genuinely-different same-coordinate
21
+ * results carry distinct discriminators → distinct idempotencyKeys → both persist
22
+ * (CE-001). This is signature-STABLE by construction: task_content_signature is
23
+ * not one of its inputs.
24
+ *
25
+ * - `contentKey` (INV-CK-5, signature-SENSITIVE): sha256 over
26
+ * {idempotency_key, task_content_signature}. It BUMPS when the idempotencyKey OR
27
+ * the task_content_signature changes, so it is the correct driver for staleness:
28
+ * a benign content edit (idempotencyKey fixed, signature C1→C2) bumps ONLY the
29
+ * contentKey (fail-4), letting idempotent re-ingest stay a no-op while staleness
30
+ * still fires.
31
+ *
32
+ * - `newInstanceId`: a per-record unique id (INV-CK / CE-001). The ledger is keyed
33
+ * by this — every appended record is distinct — so identityKey/idempotencyKey are
34
+ * grouping/idempotency keys, never primary keys (fail-2). This is the ONLY
35
+ * non-pure helper here (it mints randomness); the three key derivations above are
36
+ * pure and deterministic (INV-CK-2).
37
+ *
38
+ * Tool-owned inputs (never caller discretion):
39
+ * - `buildTaskContentSignature` (FC-002 / fail-1): the signature recipe lives HERE.
40
+ * Derived ONLY from task-defining content; `task_id` and timestamp/provenance
41
+ * fields are STRIPPED — a caller-built signature is a false-fresh latent bug.
42
+ * - `buildResultContentDiscriminator` (C-002 / fail-3): the discriminator recipe
43
+ * lives HERE too, keyed off the emit-source enum (base | deepening | steward |
44
+ * redispatch). Because the discriminator feeds the signature-STABLE
45
+ * idempotencyKey, a caller-chosen discriminator is a correctness hazard (a wrongly
46
+ * identical one collapses two distinct results; a wrongly distinct one on a replay
47
+ * mints a duplicate). The recipe is owned, never operator-chosen.
48
+ *
49
+ * Relating invariant (INV-CK-6, OBL-content-key-seam-inv-7/inv-8):
50
+ * equal contentKey ⟹ equal idempotencyKey ⟹ equal identityKey
51
+ * (NOT the converses), and `idempotencyKey` is invariant under a change to
52
+ * `task_content_signature` alone. The chain holds because each key nests the prior
53
+ * one as a signed input: contentKey signs idempotency_key, which signs identity_key.
54
+ * One canonical input thus yields all three keys with this documented relation —
55
+ * re-association stability (idempotencyKey) and staleness-on-change (contentKey) are
56
+ * reconciled, not in tension.
57
+ */
58
+ import { createHash, randomUUID } from "node:crypto";
59
+ import { stableStringify } from "./stableStringify.js";
60
+ import { normalizeForMetadataHash } from "../audit/orchestrator/artifactFreshness.js";
61
+ function sha256(value) {
62
+ return createHash('sha256').update(value, 'utf8').digest('hex');
63
+ }
64
+ // Provenance / non-content fields stripped before signing. Renumbering a task,
65
+ // or restamping it, must not change the task-content signature (FC-002). The
66
+ // artifact name routes through the shared normalizeForMetadataHash so the same
67
+ // non-semantic-stripping discipline is reused (INV-CK-2), never re-implemented.
68
+ const TASK_SIGNATURE_ARTIFACT = 'task_content_signature';
69
+ const NON_CONTENT_SIGNATURE_FIELDS = new Set([
70
+ 'task_id',
71
+ 'generated_at',
72
+ 'created_at',
73
+ 'updated_at',
74
+ 'timestamp',
75
+ 'provenance',
76
+ ]);
77
+ /**
78
+ * TOOL-OWNED task-content signature (FC-002 / fail-1). Derives a stable signature
79
+ * from the task-defining content ONLY — `task_id` and timestamp/provenance fields
80
+ * are stripped, then the remaining fields are run through the shared
81
+ * `normalizeForMetadataHash` + canonical `stableStringify` (the single serializer,
82
+ * INV-CK-2), so reordered keys produce an identical signature.
83
+ */
84
+ export function buildTaskContentSignature(input) {
85
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
86
+ throw new Error('buildTaskContentSignature: input must be a plain object of task-defining content');
87
+ }
88
+ const content = Object.fromEntries(Object.entries(input).filter(([key]) => !NON_CONTENT_SIGNATURE_FIELDS.has(key)));
89
+ return sha256(stableStringify(normalizeForMetadataHash(TASK_SIGNATURE_ARTIFACT, content)));
90
+ }
91
+ /**
92
+ * TOOL-OWNED result-content discriminator (C-002 / fail-3). The discriminator
93
+ * string is derived from the emit-source enum (plus the attempt counter for a
94
+ * re-dispatch), never chosen by a caller — because it feeds the signature-STABLE
95
+ * idempotencyKey, an operator-chosen value would be a correctness hazard.
96
+ */
97
+ export function buildResultContentDiscriminator(input) {
98
+ const source = input?.source;
99
+ if (source === 'base' || source === 'deepening' || source === 'steward') {
100
+ return source;
101
+ }
102
+ if (source === 'redispatch') {
103
+ const attempt = input.attempt;
104
+ if (!Number.isInteger(attempt) || attempt < 1) {
105
+ // Without a distinct attempt counter two re-dispatches would collide
106
+ // (fail-3) — refuse rather than mint a colliding discriminator.
107
+ throw new Error("buildResultContentDiscriminator: source 'redispatch' requires an integer attempt >= 1");
108
+ }
109
+ return `redispatch-attempt-${attempt}`;
110
+ }
111
+ throw new Error(`buildResultContentDiscriminator: unknown emit source ${JSON.stringify(source)}`);
112
+ }
113
+ function requireField(value, name) {
114
+ if (typeof value !== 'string' || value.length === 0) {
115
+ // No silent colliding key (fail-3): a missing component would otherwise hash
116
+ // to the same key for distinct coordinates.
117
+ throw new Error(`contentKey: ${name} is required and must be a non-empty string`);
118
+ }
119
+ return value;
120
+ }
121
+ /**
122
+ * sha256 over the canonical {unit_id, lens, pass_id} tuple (INV-CK-3). EXCLUDES
123
+ * task_id and all volatile fields. ONE-TO-MANY grouping key (INV-CK-4) — never a
124
+ * primary key. Throws if any component is missing (fail-3).
125
+ */
126
+ export function identityKey(input) {
127
+ const unit_id = requireField(input?.unit_id, 'unit_id');
128
+ const lens = requireField(input?.lens, 'lens');
129
+ const pass_id = requireField(input?.pass_id, 'pass_id');
130
+ return sha256(stableStringify({ unit_id, lens, pass_id }));
131
+ }
132
+ /**
133
+ * sha256 over {identity_key, result_content_discriminator} (INV-CK-7). SIGNATURE-
134
+ * STABLE: the task_content_signature is deliberately NOT an input, so a benign
135
+ * content edit does not move it (fail-4). This is the key O2 ingests on. equal
136
+ * idempotencyKey ⟹ equal identityKey, since identity_key is a signed input.
137
+ */
138
+ export function idempotencyKey(input) {
139
+ const identity_key = identityKey(input);
140
+ const result_content_discriminator = requireField(input?.result_content_discriminator, 'result_content_discriminator');
141
+ return sha256(stableStringify({ identity_key, result_content_discriminator }));
142
+ }
143
+ /**
144
+ * sha256 over {idempotency_key, task_content_signature} (INV-CK-5). SIGNATURE-
145
+ * SENSITIVE: bumps when the idempotencyKey OR the task_content_signature changes,
146
+ * so it drives staleness (CE-001 / inv-5). equal contentKey ⟹ equal idempotencyKey
147
+ * ⟹ equal identityKey, since each is a signed input of the next.
148
+ */
149
+ export function contentKey(input) {
150
+ const idempotency_key = idempotencyKey(input);
151
+ const task_content_signature = requireField(input?.task_content_signature, 'task_content_signature');
152
+ return sha256(stableStringify({ idempotency_key, task_content_signature }));
153
+ }
154
+ /**
155
+ * Mint a fresh per-record instance id (CE-001 / fail-2). The ledger keys on this,
156
+ * so every appended record is distinct and identityKey/idempotencyKey are never
157
+ * primary keys. This is the ONLY non-deterministic helper in the seam — the three
158
+ * key derivations above are pure.
159
+ */
160
+ export function newInstanceId() {
161
+ return randomUUID();
162
+ }
163
+ //# sourceMappingURL=contentKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentKey.js","sourceRoot":"","sources":["../../src/shared/contentKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAgDtF,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,4BAA4B,GAAwB,IAAI,GAAG,CAAC;IAChE,SAAS;IACT,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,YAAY;CACb,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAgC;IAEhC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAChC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAC1B,C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OAAO,EAC3C,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,GACrC,MAAM,CAER;AA+CD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,OAAO,EACpC,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,EACtC,cAAc,EAAE,YAAY,EAAE,EAC9B,eAAe,EAAE,oBAAoB,EACrC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAClD,aAAa,EAAE,aAAa,EAC5B,gBAAgB,GAAE,WAAW,CAAC,MAAM,CAAa,GAChD,YAAY,GAAG,IAAI,CA4DrB;AAMD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAC7C,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,EACtC,OAAO,GAAE,sBAA2B,GACnC,iBAAiB,CAAC,OAAO,CAAC,CAuQ5B"}
@@ -30,7 +30,7 @@
30
30
  * capability order). This is what makes the real-time quota sources actually
31
31
  * redistribute load instead of merely throttling a single chosen pool.
32
32
  */
33
- import { scheduleWave, buildProviderModelKey, DEFAULT_EMPIRICAL_HALF_LIFE_HOURS, QUOTA_REMAINING_PCT_LOW, } from "../quota/scheduler.js";
33
+ import { scheduleWave, DEFAULT_EMPIRICAL_HALF_LIFE_HOURS, QUOTA_REMAINING_PCT_LOW, } from "../quota/scheduler.js";
34
34
  import { recordWaveOutcome, readQuotaState } from "../quota/state.js";
35
35
  import { buildEmptyPoolTerminal } from "../quota/capacity.js";
36
36
  import { tierRank } from "./tierRank.js";
@@ -140,7 +140,9 @@ export function selectProvider(packet, confirmedPools, inFlightTracker, quotaSta
140
140
  // folds in the real-time quota snapshot, learned limits, and any active
141
141
  // cooldown, so it doubles as the health signal for the spill ordering below.
142
142
  const scheduleForPool = (pool) => {
143
- const poolKey = buildProviderModelKey(pool.providerName, pool.hostModel);
143
+ // pool.id is the canonical (provider, account, model) key — use it directly so
144
+ // scheduling and outcome-recording index the SAME account-stamped quota entry.
145
+ const poolKey = pool.id;
144
146
  const quotaStateEntry = pool.quotaStateEntry ?? quotaStateEntries[poolKey] ?? null;
145
147
  const inFlightTokens = inFlightTracker.getInFlightTokens(pool.id);
146
148
  return scheduleWave({
@@ -255,7 +257,9 @@ export function createRollingDispatcher(config, options = {}) {
255
257
  // Record quota outcome. 'error' is a distinct quota outcome (non-quota
256
258
  // failure — no cooldown, only failure weight); 'rate_limited' applies the
257
259
  // backoff cooldown that throttles the exhausted pool's learned limits.
258
- const providerModelKey = buildProviderModelKey(providerSlot.providerName, providerSlot.hostModel);
260
+ // The pool id IS the canonical (provider, account, model) quota key — record the
261
+ // outcome under it so learned state lands on the same entry scheduling reads.
262
+ const providerModelKey = providerSlot.poolId;
259
263
  const quotaOutcome = result.outcome === "success" ? "success"
260
264
  : result.outcome === "rate_limited" ? "rate_limited"
261
265
  : result.outcome === "error" ? "error"
@@ -1 +1 @@
1
- {"version":3,"file":"rollingDispatch.js","sourceRoot":"","sources":["../../../src/shared/dispatch/rollingDispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iCAAiC,EACjC,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAgIzC,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACd,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IAE1D,gBAAgB,CAAC,MAAc,EAAE,MAAc;QAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC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AAC,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;YAC7D,gDAAgD;QAClD,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,SAAS,QAAQ;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,WAAW;QAClB,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC9C,OAAO,sBAAsB,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACjD,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type FrictionCaptureArtifact, type FrictionItem } from '../io/frictionCapture.js';
2
+ /**
3
+ * The single mechanical-friction sink (FC-005). Mechanical seams (O3
4
+ * validation/coercion/repair warnings; O2 recovery / ingest-merge-retry) call
5
+ * `captureFrictionEvent(artifactsDir, runId, event)` with a stable distinct
6
+ * event id; the call accretes the event onto the per-run friction record that
7
+ * `src/shared/io/frictionCapture.ts` owns.
8
+ *
9
+ * This module is landed FIRST, before O1's full triage UI, as a callable,
10
+ * inert-no-op-safe API so O2/O3 can wire it at their seams immediately.
11
+ *
12
+ * Guaranteed properties (INV-O1-5 / INV-O1-6 / INV-O1-7, FC-005):
13
+ * - BEST-EFFORT / NON-FATAL: every read/write is swallowed. A failed or
14
+ * contended capture write NEVER throws into the in-flight obligation — the
15
+ * sink resolves regardless. A caller may `await` it or fire-and-forget.
16
+ * - NO-OP-SAFE: callable before any triage UI exists; with nothing wired it is
17
+ * a pure append to an otherwise-unread per-run record, and a missing/locked
18
+ * artifacts dir simply degrades to a swallowed write.
19
+ * - IDEMPOTENT / PER-EVENT DE-DUP: an event whose `id` already appears in the
20
+ * run record is dropped, so re-entrant passes (re-dispatch, retry) never
21
+ * double-record the same logical event (INV-O1-6, FAIL-O1-5).
22
+ * - OS/PATH-AGNOSTIC: the record path comes only from the substrate's
23
+ * `frictionCapturePath` (node:path joins off `artifactsDir` + `sanitizeRunId`);
24
+ * no platform-baked literal, never coupled to any repo doc (INV-O1-7).
25
+ *
26
+ * This is the substrate-wrapping sink only: live triage dispositions over the
27
+ * accreted events are owned by O1's triage module, the locked append ordering by
28
+ * O2 — this layer just appends one de-duped event, best-effort.
29
+ */
30
+ /** A single mechanical friction event recorded through the sink. */
31
+ export interface FrictionEvent extends FrictionItem {
32
+ /**
33
+ * Stable distinct id for this logical event. Re-recording an event with an id
34
+ * already present in the run record is a no-op (per-event de-dup, INV-O1-6).
35
+ */
36
+ id: string;
37
+ }
38
+ /** A friction record item carrying its mechanical-event de-dup id. */
39
+ export interface CapturedFrictionItem extends FrictionItem {
40
+ id: string;
41
+ }
42
+ /**
43
+ * Append one mechanical friction event to the per-run record, best-effort.
44
+ *
45
+ * Never throws: any failure (missing/locked dir, malformed existing record,
46
+ * write contention) is swallowed so the calling obligation is never broken
47
+ * (INV-O1-5, FAIL-O1-3). De-duped on `event.id` (INV-O1-6, FAIL-O1-5).
48
+ */
49
+ export declare function captureFrictionEvent(artifactsDir: string, runId: string, event: FrictionEvent, tool?: FrictionCaptureArtifact['tool']): Promise<void>;
50
+ //# sourceMappingURL=captureFrictionEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captureFrictionEvent.d.ts","sourceRoot":"","sources":["../../../src/shared/friction/captureFrictionEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EAIlB,MAAM,0BAA0B,CAAC;AAGlC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,oEAAoE;AACpE,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,sEAAsE;AACtE,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,EAAE,EAAE,MAAM,CAAC;CACZ;AAOD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,aAAa,EACpB,IAAI,GAAE,uBAAuB,CAAC,MAAM,CAAoB,GACvD,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
@@ -0,0 +1,34 @@
1
+ import { FRICTION_CAPTURE_SCHEMA_VERSION, frictionCapturePath, sanitizeRunId, } from '../io/frictionCapture.js';
2
+ import { readOptionalJsonFile, writeJsonFile } from '../io/json.js';
3
+ /**
4
+ * Append one mechanical friction event to the per-run record, best-effort.
5
+ *
6
+ * Never throws: any failure (missing/locked dir, malformed existing record,
7
+ * write contention) is swallowed so the calling obligation is never broken
8
+ * (INV-O1-5, FAIL-O1-3). De-duped on `event.id` (INV-O1-6, FAIL-O1-5).
9
+ */
10
+ export async function captureFrictionEvent(artifactsDir, runId, event, tool = 'remediate-code') {
11
+ try {
12
+ const path = frictionCapturePath(artifactsDir, sanitizeRunId(runId));
13
+ const existing = await readOptionalJsonFile(path);
14
+ const frictions = Array.isArray(existing?.frictions)
15
+ ? existing.frictions
16
+ : [];
17
+ // Per-event de-dup: drop an event whose id is already recorded.
18
+ if (frictions.some((item) => item.id === event.id)) {
19
+ return;
20
+ }
21
+ const artifact = {
22
+ schema_version: FRICTION_CAPTURE_SCHEMA_VERSION,
23
+ tool: existing?.tool ?? tool,
24
+ run_id: runId,
25
+ captured_at: new Date().toISOString(),
26
+ frictions: [...frictions, { ...event }],
27
+ };
28
+ await writeJsonFile(path, artifact);
29
+ }
30
+ catch {
31
+ // Best-effort: swallow every failure so capture never breaks the obligation.
32
+ }
33
+ }
34
+ //# sourceMappingURL=captureFrictionEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captureFrictionEvent.js","sourceRoot":"","sources":["../../../src/shared/friction/captureFrictionEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,+BAA+B,EAC/B,mBAAmB,EACnB,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAkDpE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,YAAoB,EACpB,KAAa,EACb,KAAoB,EACpB,OAAwC,gBAAgB;IAExD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,mBAAmB,CAAC,YAAY,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAA2B,IAAI,CAAC,CAAC;QAE5E,MAAM,SAAS,GAA2B,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC;YAC1E,CAAC,CAAC,QAAS,CAAC,SAAS;YACrB,CAAC,CAAC,EAAE,CAAC;QAEP,gEAAgE;QAChE,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YACnD,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAA6B;YACzC,cAAc,EAAE,+BAA+B;YAC/C,IAAI,EAAE,QAAQ,EAAE,IAAI,IAAI,IAAI;YAC5B,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,SAAS,EAAE,CAAC,GAAG,SAAS,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC;SACxC,CAAC;QAEF,MAAM,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,6EAA6E;IAC/E,CAAC;AACH,CAAC"}
@@ -0,0 +1,126 @@
1
+ import { type FrictionCaptureArtifact } from '../io/frictionCapture.js';
2
+ import { type AgentReflection } from '../agentReflections.js';
3
+ import type { CapturedFrictionItem } from './captureFrictionEvent.js';
4
+ /**
5
+ * O1 end-of-run friction TRIAGE — single-sourced for BOTH orchestrators so the
6
+ * triage step shape, the disposition vocabulary, the blocking semantics, and the
7
+ * close-out deciders cannot drift between the two halves of the pipeline. This is
8
+ * the analog (and now the single source) of the former per-orchestrator
9
+ * `decideAuditFrictionCloseout` / `decideRemediateFrictionCloseout` deciders,
10
+ * collapsed here as one parameterized decider.
11
+ *
12
+ * What the triage gates:
13
+ * - The MECHANICAL friction events the O3/O2 seams accreted through the sink
14
+ * (`captureFrictionEvent` → the per-run `friction/<run_id>.json` record).
15
+ * - The OPT-IN agent-feedback reflections workers appended to
16
+ * `agent-feedback.jsonl` during the run.
17
+ *
18
+ * The satisfaction predicate set is the UNION of those two sources. The triage is
19
+ * a MANDATORY, BLOCKING end-of-run step: it stays unsatisfied until every captured
20
+ * event AND every surfaced reflection carries a recorded disposition. This is
21
+ * DISTINCT from the optional, untouched mid-run worker reflection channel — a
22
+ * worker MAY append a reflection line, but the blocking triage is the host's
23
+ * end-of-run obligation to dispose of what was captured.
24
+ *
25
+ * False-green is dropped: an empty up-front zero-friction record NO LONGER
26
+ * satisfies the close-out. Satisfaction requires either:
27
+ * - EMPTY SET: zero events AND zero reflections → trivially disposed (the
28
+ * close-out fires once, persists a disposed record, and never re-loops); or
29
+ * - DISPOSED: every event id and every reflection key has a `keep|discard|
30
+ * annotate` disposition recorded against it.
31
+ *
32
+ * Friction appends ride O2's `withFileLock` (keyed off the friction record path)
33
+ * so a friction append never races the locked critical section.
34
+ */
35
+ /** The triage disposition vocabulary — the host's verdict per captured item. */
36
+ export type FrictionDisposition = 'keep' | 'discard' | 'annotate';
37
+ /** The set of valid dispositions, for validation at the contract boundary. */
38
+ export declare const FRICTION_DISPOSITIONS: readonly FrictionDisposition[];
39
+ /** Whether a value is a valid disposition (mechanical contract check). */
40
+ export declare function isFrictionDisposition(value: unknown): value is FrictionDisposition;
41
+ /**
42
+ * One triage record: a host disposition against a captured item key. `target_id`
43
+ * is the friction-event id (mechanical sink) or the reflection key (a stable key
44
+ * derived from a surfaced agent-feedback reflection). `annotation` is required
45
+ * only for the `annotate` disposition.
46
+ */
47
+ export interface FrictionDispositionRecord {
48
+ target_id: string;
49
+ disposition: FrictionDisposition;
50
+ annotation?: string;
51
+ }
52
+ /** A captured item the host must dispose of, normalized across both sources. */
53
+ export interface TriageSubject {
54
+ /** Stable key the disposition is recorded against. */
55
+ id: string;
56
+ /** Which source surfaced it — a mechanical event or an agent reflection. */
57
+ source: 'event' | 'reflection';
58
+ /** Human-readable summary for the triage prompt. */
59
+ note: string;
60
+ }
61
+ /**
62
+ * The mandatory blocking triage decision. `pending` means the close-out is NOT
63
+ * satisfied — the host must record a disposition for every subject in `pending`
64
+ * before the run can present complete. `action`:
65
+ * - "dispose" → there are pending subjects; the run is BLOCKED on triage.
66
+ * - "disposed" → nothing pending (empty set, or all subjects disposed); the
67
+ * close-out is satisfied and the run proceeds. Fires at most once.
68
+ */
69
+ export interface FrictionTriageDecision {
70
+ action: 'dispose' | 'disposed';
71
+ /** Subjects still awaiting a disposition (empty when `disposed`). */
72
+ pending: TriageSubject[];
73
+ /** The run_id-keyed friction record path (always set, for the handoff). */
74
+ recordPath: string;
75
+ }
76
+ /** A stable key for a surfaced reflection (task_id + ordinal within the run). */
77
+ export declare function reflectionKey(reflection: AgentReflection, ordinal: number): string;
78
+ /**
79
+ * The per-run friction record the triage reads/writes. Extends the captured
80
+ * artifact (mechanical events) with the host's `dispositions[]` — the tool owns
81
+ * every field except the host-recorded disposition content.
82
+ */
83
+ export interface TriagedFrictionArtifact extends Omit<FrictionCaptureArtifact, 'frictions'> {
84
+ frictions: CapturedFrictionItem[];
85
+ dispositions?: FrictionDispositionRecord[];
86
+ }
87
+ /** Where the friction append/triage lock lives (rides O2's withFileLock). */
88
+ export declare function frictionLockPath(artifactsDir: string, runId: string): string;
89
+ /**
90
+ * Build the union triage-subject set for a run: every captured mechanical event
91
+ * UNION every surfaced agent-feedback reflection. Deterministic — pure read off
92
+ * the on-disk record + the reflections file, never host discretion.
93
+ */
94
+ export declare function collectTriageSubjects(artifactsDir: string, runId: string): Promise<TriageSubject[]>;
95
+ /**
96
+ * The MANDATORY BLOCKING end-of-run triage close-out, single-sourced for both
97
+ * orchestrators (caller passes its `tool`). Drops the former false-green: an
98
+ * empty up-front record never satisfies — satisfaction is decided off the union
99
+ * subject set vs. the recorded dispositions:
100
+ *
101
+ * - empty set (zero events AND zero reflections) → "disposed" trivially, and a
102
+ * disposed record is persisted once so it never re-loops;
103
+ * - every subject disposed → "disposed";
104
+ * - any subject undisposed → "dispose" (the run is BLOCKED) with the pending
105
+ * subjects surfaced for the host to dispose of.
106
+ *
107
+ * Deterministic — keyed only off the on-disk record + reflections at
108
+ * `(artifactsDir, runId)`. Never coupled to any repo's backlog doc. The persist
109
+ * on the trivial-empty path rides O2's `withFileLock` so it cannot race a
110
+ * concurrent friction append into the same record.
111
+ */
112
+ export declare function decideFrictionTriage(artifactsDir: string, runId: string, tool: FrictionCaptureArtifact['tool']): Promise<FrictionTriageDecision>;
113
+ /**
114
+ * Mutate the per-run friction record under O2's `withFileLock` so a friction
115
+ * append (mechanical event OR host disposition) never races the locked critical
116
+ * section. The mutator receives the current record (a fresh degrade-clean shell
117
+ * when none exists) and returns the next record to persist atomically.
118
+ */
119
+ export declare function appendFrictionUnderLock(artifactsDir: string, runId: string, mutate: (record: TriagedFrictionArtifact) => Promise<TriagedFrictionArtifact> | TriagedFrictionArtifact, tool?: FrictionCaptureArtifact['tool']): Promise<TriagedFrictionArtifact>;
120
+ /**
121
+ * Record one host disposition against a captured subject, under the shared lock.
122
+ * Re-disposing the same `target_id` overwrites the prior verdict (idempotent on
123
+ * the key). The `annotate` disposition carries the host annotation.
124
+ */
125
+ export declare function recordFrictionDisposition(artifactsDir: string, runId: string, disposition: FrictionDispositionRecord, tool?: FrictionCaptureArtifact['tool']): Promise<TriagedFrictionArtifact>;
126
+ //# sourceMappingURL=triage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triage.d.ts","sourceRoot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