opencode-swarm 7.161.1 → 7.162.1

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 (89) hide show
  1. package/dist/background/pr-review-contract.d.ts +1 -24
  2. package/dist/cli/authorization-vstrh7ra.js +23 -0
  3. package/dist/cli/{coder-settlement-2jteb5vy.js → coder-settlement-zrda71k0.js} +9 -9
  4. package/dist/cli/{config-doctor-1yn317qf.js → config-doctor-gjw4hdvt.js} +2 -2
  5. package/dist/cli/{core-k687jrr3.js → core-q5j5a7fh.js} +1 -1
  6. package/dist/cli/{curation-policy-ej9xc0cd.js → curation-policy-nv31cr6t.js} +5 -5
  7. package/dist/cli/{curator-llm-factory-m1ke17eq.js → curator-llm-factory-8d6kqsj1.js} +33 -31
  8. package/dist/cli/{curator-q017rjfk.js → curator-njskp28b.js} +33 -31
  9. package/dist/cli/{evidence-summary-service-6jzfa547.js → evidence-summary-service-5rry81jm.js} +13 -13
  10. package/dist/cli/{gate-evidence-j6nskaka.js → gate-evidence-b6k9wng8.js} +5 -5
  11. package/dist/cli/{guardrail-explain-xw3ma90f.js → guardrail-explain-5yw549sm.js} +34 -32
  12. package/dist/cli/{guardrail-log-etmzhbge.js → guardrail-log-nrnx87ac.js} +7 -7
  13. package/dist/cli/{guardrail-reset-z9fkxksy.js → guardrail-reset-zm5an5bw.js} +33 -31
  14. package/dist/cli/{hive-promoter-dmwjya83.js → hive-promoter-zzgnfhxr.js} +33 -31
  15. package/dist/cli/{index-32avgbyq.js → index-0myjf1y2.js} +2 -2
  16. package/dist/cli/{index-dq41vsf9.js → index-1eqbnwm6.js} +1 -1
  17. package/dist/cli/{index-dh5q6z7y.js → index-3b762978.js} +7 -4
  18. package/dist/cli/{index-qd9mrd7e.js → index-3fs3p6ck.js} +5 -5
  19. package/dist/cli/{index-cbcfpgz9.js → index-3gym3fjj.js} +6 -6
  20. package/dist/cli/{index-c6zyqgpq.js → index-3nsewz46.js} +1 -1
  21. package/dist/cli/{index-nm0cpfrv.js → index-5a8nk165.js} +4 -4
  22. package/dist/cli/{index-d8st72j7.js → index-63s6t3z4.js} +1 -1
  23. package/dist/cli/{index-7d79mj06.js → index-7322jr05.js} +9 -9
  24. package/dist/cli/{index-bn78ywnb.js → index-9cvfa8p8.js} +1 -1
  25. package/dist/cli/{index-k55td019.js → index-9m1ze4z4.js} +1 -1
  26. package/dist/cli/{index-hvfsz7e3.js → index-a1bh2e4f.js} +6 -6
  27. package/dist/cli/{index-c1geyan9.js → index-bgzdwkpe.js} +1 -1
  28. package/dist/cli/{index-epjvntnm.js → index-cjjcey0h.js} +1 -1
  29. package/dist/cli/{index-29f9te70.js → index-f18bqg18.js} +5 -3
  30. package/dist/cli/{index-awjx0wgk.js → index-fckfgptr.js} +1 -1
  31. package/dist/cli/{index-88wb0z9r.js → index-gss86tj3.js} +2 -2
  32. package/dist/cli/{index-za42r41w.js → index-gwbxeh8j.js} +14 -643
  33. package/dist/cli/{index-1j532307.js → index-hq1gdz0g.js} +2 -2
  34. package/dist/cli/{index-zhdfqz89.js → index-j1gq4qm8.js} +5 -5
  35. package/dist/cli/{index-4p6x3xxy.js → index-m24pv3f4.js} +4 -4
  36. package/dist/cli/{index-jm21vbyp.js → index-m516tpxe.js} +2 -2
  37. package/dist/cli/index-mmngnxev.js +883 -0
  38. package/dist/cli/{index-134d35c1.js → index-n249fbw7.js} +9 -0
  39. package/dist/cli/{index-s33ee2w3.js → index-nbfpnb0w.js} +1 -1
  40. package/dist/cli/{index-7619tk9a.js → index-rkr19fdv.js} +1 -1
  41. package/dist/cli/{index-9kp3cp5n.js → index-ttdjphep.js} +3 -3
  42. package/dist/cli/{index-f5axf6vq.js → index-v0t8z5ab.js} +1 -1
  43. package/dist/cli/{index-rracnf2y.js → index-vcen0ne4.js} +1 -1
  44. package/dist/cli/{index-y14mwbk8.js → index-w1sfjffe.js} +2 -2
  45. package/dist/cli/index-w7ekntej.js +643 -0
  46. package/dist/cli/{index-hq57ytm5.js → index-wvfgkms6.js} +1 -1
  47. package/dist/cli/{index-e0re84cx.js → index-xsv6zv7n.js} +35 -33
  48. package/dist/cli/{index-cs9w1hfs.js → index-xtjvg1wx.js} +2691 -2781
  49. package/dist/cli/{index-k4xey4kh.js → index-y3fgbx8g.js} +1 -1
  50. package/dist/cli/{index-yhadrxka.js → index-z74stz9p.js} +4 -4
  51. package/dist/cli/index.js +33 -31
  52. package/dist/cli/{knowledge-escalator-cqyxfjfh.js → knowledge-escalator-8y3adkn0.js} +11 -11
  53. package/dist/cli/{knowledge-events-g707awjf.js → knowledge-events-mnexhwe2.js} +9 -9
  54. package/dist/cli/{knowledge-link-8knefv8x.js → knowledge-link-jr8rqr39.js} +4 -4
  55. package/dist/cli/{knowledge-store-byhv66xq.js → knowledge-store-cp42ccd1.js} +5 -5
  56. package/dist/cli/{knowledge-validator-qfkr8eje.js → knowledge-validator-hwp1t6x3.js} +7 -7
  57. package/dist/cli/{pending-delegations-n3baz9m3.js → pending-delegations-jj5vaq9q.js} +5 -4
  58. package/dist/cli/{pr-subscriptions-3zwthnan.js → pr-subscriptions-mm6kyyv0.js} +4 -4
  59. package/dist/cli/{runner-fzgkd6m1.js → runner-d402vnq3.js} +5 -5
  60. package/dist/cli/{scan-cursor-fbtgyeft.js → scan-cursor-d75dh3hv.js} +6 -6
  61. package/dist/cli/{schema-xb7d31wq.js → schema-djm1bhb8.js} +1 -1
  62. package/dist/cli/{scope-persistence-5npzdfjf.js → scope-persistence-g0yc6dfa.js} +8 -8
  63. package/dist/cli/{skill-generator-k1e7nee3.js → skill-generator-9ppgxz4j.js} +13 -13
  64. package/dist/cli/{sqlite-loader-r1kgt2pq.js → sqlite-loader-c92413n7.js} +1 -1
  65. package/dist/cli/{worktree-collision-ownership-jfam09nj.js → worktree-collision-ownership-061zmyyp.js} +6 -5
  66. package/dist/cli/{worktree-isolation-avp3yxcs.js → worktree-isolation-vk82698z.js} +33 -31
  67. package/dist/db/sqlite-loader.d.ts +1 -0
  68. package/dist/hooks/pr-workflow-gate.d.ts +20 -245
  69. package/dist/index.js +392 -378
  70. package/dist/memory/curator-decision-helpers.d.ts +1 -0
  71. package/dist/memory/index.d.ts +1 -1
  72. package/dist/memory/local-jsonl-provider.d.ts +2 -0
  73. package/dist/memory/proposal-load.d.ts +15 -0
  74. package/dist/memory/relation-constants.d.ts +3 -0
  75. package/dist/memory/relations.d.ts +8 -0
  76. package/dist/memory/schema.d.ts +8 -0
  77. package/dist/memory/sqlite-provider.d.ts +3 -0
  78. package/dist/memory/types.d.ts +21 -0
  79. package/dist/{hooks/pr-review-reentry-authorization.d.ts → pr-review/authorization.d.ts} +32 -10
  80. package/dist/{hooks/pr-review-resilience-circuit.d.ts → pr-review/circuit.d.ts} +60 -3
  81. package/dist/pr-review/completion.d.ts +373 -0
  82. package/dist/pr-review/critic-routing.d.ts +37 -0
  83. package/dist/pr-review/guardrails.d.ts +67 -0
  84. package/dist/pr-review/legacy-transcript-adapter.d.ts +276 -0
  85. package/dist/pr-review/persistence.d.ts +107 -0
  86. package/dist/pr-review/reducer.d.ts +54 -0
  87. package/dist/pr-review/types.d.ts +225 -0
  88. package/package.json +1 -1
  89. package/dist/cli/pr-review-reentry-authorization-ttctn8xv.js +0 -301
@@ -0,0 +1,373 @@
1
+ /**
2
+ * PR-review completion / coverage-settlement authority (issues #2383, #2385).
3
+ *
4
+ * The six-dimension coverage reduction and terminal report eligibility
5
+ * machinery, moved out of `src/hooks/pr-workflow-gate.ts` behind the
6
+ * `src/pr-review/` boundary (issue #2385). This module owns:
7
+ *
8
+ * - the coverage-disclosure record vocabulary (v2 plural + legacy v1 singular),
9
+ * its Zod schemas, and the single legacy→v2 normalization read boundary;
10
+ * - the per-dimension attempt summary (`summarizePrReviewBaseDimensionAttempts`)
11
+ * and the terminal N-of-6 settlement derivation
12
+ * (`derivePrReviewDimensionSettlement`);
13
+ * - the disclosure admission / rollback / settled-assertion state machine
14
+ * (`admitPrReviewPartialBaseCoverage`,
15
+ * `rollbackPrReviewPartialBaseCoverageAdmission`,
16
+ * `assertPrReviewBaseCoverageSettled`);
17
+ * - the verdict eligibility matrix for terminal reports
18
+ * (`allowedPrReviewReportVerdicts`) and the read-only report projection
19
+ * (`readPrReviewTerminalCoverageForReport`).
20
+ *
21
+ * Binding contract (same precedent as `bindPrReviewReentryBindingReader` in
22
+ * `authorization.ts`): the boundary must never import the orchestration gate
23
+ * back. Gate-owned derivation helpers (`successfulObligationsFromExactBatch`,
24
+ * `recordsPassingBatchIntegrity`, `validatePrReviewDiscoveryLaneCompletion`,
25
+ * `validateExactStructuredReceiptCoverage`, `readBoundedSwarmRegularFile`,
26
+ * `createPrReviewGateContext`, `requireBoundState`,
27
+ * `readPrWorkflowGateStateFromDisk`) are supplied by the owning gate through
28
+ * `bindPrReviewCompletionHelpers`, bound once at gate module init.
29
+ *
30
+ * State typing: the moved functions read only the PR-review slice of
31
+ * `PrWorkflowGateState`, expressed as the local structural interface
32
+ * `PrReviewCompletionState`. The gate passes its full state, which satisfies
33
+ * the slice structurally. Durable reads/writes still go through
34
+ * `src/pr-review/persistence.ts` (the atomic persistence boundary) — this
35
+ * module never writes state outside `withSessionStateMutation` /
36
+ * `writeStateWhileLocked`.
37
+ */
38
+ import { z } from 'zod';
39
+ import { type LaneOutputArtifact } from '../background/lane-output-store.js';
40
+ import { type BackgroundDelegationRecord, type BackgroundDelegationResult, type BackgroundDelegationWorkflowLaneFailureClass } from '../background/pending-delegations.js';
41
+ import { type PrReviewBaseDimensionId, type PrReviewResultReceipt } from '../background/pr-review-contract.js';
42
+ /** Declared lane shape of a base dispatch, as the settlement reads it. */
43
+ export interface PrReviewCompletionLane {
44
+ laneId: string;
45
+ workflowLane: string;
46
+ ownedWorkflowLanes?: readonly string[];
47
+ }
48
+ /** Base dispatch batch, as the settlement reads it. */
49
+ export interface PrReviewCompletionBaseDispatchRecord {
50
+ batchId: string;
51
+ lanes: ReadonlyArray<PrReviewCompletionLane>;
52
+ validatedAt: string;
53
+ }
54
+ /**
55
+ * The PR-review slice of the owning gate's `PrWorkflowGateState`: exactly the
56
+ * fields the moved settlement machinery reads. The gate's full state type
57
+ * satisfies this structurally, so the gate passes its state without a
58
+ * projection step. `schemaVersion`/`revision`/`sessionID` mirror
59
+ * `PrWorkflowPersistedStateBase` in `persistence.ts` so the CAS write generic
60
+ * accepts the slice.
61
+ */
62
+ export interface PrReviewCompletionState {
63
+ schemaVersion: number;
64
+ revision: number;
65
+ sessionID: string;
66
+ workflowInstanceId?: string;
67
+ mode?: string;
68
+ prHeadSha?: string;
69
+ prReviewBaseSha?: string;
70
+ prReviewBaseDispatches?: PrReviewCompletionBaseDispatchRecord[];
71
+ prReviewContractRetryDimensions?: PrReviewBaseDimensionId[];
72
+ prReviewReservedRunId?: string;
73
+ prReviewArtifactRunId?: string;
74
+ prReviewArtifactBoundaries?: Array<'post_explorer' | 'post_reviewer' | 'post_critic'>;
75
+ prReviewDimensionCancellations?: Partial<Record<PrReviewBaseDimensionId, PrReviewDimensionCancellationRecord>>;
76
+ prReviewPartialBaseCoverage?: PrReviewPartialBaseCoverageRecord;
77
+ prReviewCoverageDisclosurePath?: string;
78
+ prReviewCoverageDisclosureDigest?: string;
79
+ }
80
+ /** The gate-context surface the settlement consumes (full ctx is gate-owned). */
81
+ export interface PrReviewCompletionGateContext {
82
+ readonly revisionDigest: string;
83
+ }
84
+ /** A batch-integrity-qualified record, as the settlement consumes it. */
85
+ export interface PrReviewCompletionQualifiedRecord {
86
+ record: BackgroundDelegationRecord;
87
+ expectedLane: PrReviewCompletionLane;
88
+ expectedWorkflowLane: string;
89
+ expectedOwnedLanes: string[];
90
+ }
91
+ /** Discovery-lane validation input, as the settlement supplies it. */
92
+ export interface PrReviewCompletionDiscoveryValidationInput {
93
+ record: BackgroundDelegationRecord;
94
+ result: BackgroundDelegationResult;
95
+ artifact: LaneOutputArtifact | null;
96
+ expected: {
97
+ mode: string;
98
+ workflowLane: string;
99
+ ownedWorkflowLanes?: readonly string[];
100
+ prHeadSha: string;
101
+ gitHead: string;
102
+ revisionDigest: string;
103
+ workflowInstanceId?: string;
104
+ workflowRevision?: number;
105
+ baseSha?: string;
106
+ reviewScope?: string;
107
+ checkWorkflowLane?: boolean;
108
+ };
109
+ }
110
+ /** Structured-receipt coverage verdict, as the settlement consumes it. */
111
+ export type PrReviewCompletionStructuredReceiptCoverage = {
112
+ status: 'absent';
113
+ } | {
114
+ status: 'accepted';
115
+ receipt: PrReviewResultReceipt;
116
+ } | {
117
+ status: 'rejected';
118
+ };
119
+ /**
120
+ * Gate-owned derivation helpers, bound by the owning gate at module init so
121
+ * this boundary never imports the gate back. Declared with method syntax on
122
+ * purpose: the gate's implementations accept/return its FULL state and result
123
+ * types, which are structural supersets of the slices below, and interface
124
+ * method parameters are checked bivariantly.
125
+ */
126
+ export interface PrReviewCompletionGateHelpers {
127
+ createPrReviewGateContext(directory: string, state: PrReviewCompletionState): Promise<PrReviewCompletionGateContext>;
128
+ requireBoundState(directory: string, sessionID: string, expectedMode: string): Promise<PrReviewCompletionState>;
129
+ readPrWorkflowGateStateFromDisk(directory: string, sessionID: string): Promise<PrReviewCompletionState | null>;
130
+ readBoundedSwarmRegularFile(directory: string, relativePath: string, maxBytes: number, label: string): Promise<string>;
131
+ successfulObligationsFromExactBatch(directory: string, state: PrReviewCompletionState, batchId: string, expectedLanes: ReadonlyArray<PrReviewCompletionLane>, expectedMode: string, validatedAt: string, checkWorkflowLane?: boolean, forbiddenSubagentSessionIds?: ReadonlySet<string>, expectedRevisionDigest?: string, diagnostics?: string[]): Set<string>;
132
+ recordsPassingBatchIntegrity(directory: string, state: PrReviewCompletionState, batchId: string, expectedLanes: ReadonlyArray<PrReviewCompletionLane>, expectedMode: string, validatedAt: string, checkWorkflowLane?: boolean, forbiddenSubagentSessionIds?: ReadonlySet<string>, diagnostics?: string[]): PrReviewCompletionQualifiedRecord[];
133
+ validatePrReviewDiscoveryLaneCompletion(input: PrReviewCompletionDiscoveryValidationInput): {
134
+ ok: boolean;
135
+ };
136
+ validateExactStructuredReceiptCoverage(input: PrReviewCompletionDiscoveryValidationInput): PrReviewCompletionStructuredReceiptCoverage;
137
+ }
138
+ export declare function bindPrReviewCompletionHelpers(helpers: PrReviewCompletionGateHelpers): void;
139
+ /**
140
+ * Normalized terminal state of one canonical base dimension (issue #2383).
141
+ * Every dimension ends in exactly one of these; completion requires every
142
+ * LAUNCHED lane to be terminal (COVERED/FAILED) or explicitly cancelled, with
143
+ * no in-flight lane and no late result creditable to the active generation.
144
+ */
145
+ export type PrReviewDimensionTerminalState = 'COVERED' | 'FAILED' | 'CANCELLED' | 'NOT_LAUNCHED';
146
+ /** Gate-derived per-dimension terminal evidence for an unresolved dimension. */
147
+ export interface PrReviewUnresolvedDimensionRecord {
148
+ dimension: PrReviewBaseDimensionId;
149
+ terminalState: 'FAILED' | 'CANCELLED' | 'NOT_LAUNCHED';
150
+ reasonKind: 'lane_failure' | 'cancelled' | 'not_launched';
151
+ failureClass?: BackgroundDelegationWorkflowLaneFailureClass;
152
+ terminalEventId?: string;
153
+ /** Contributing lane/batch identity, when available. */
154
+ batchId?: string;
155
+ laneId?: string;
156
+ /**
157
+ * Bounded safe detail derived from the failure-class vocabulary — never
158
+ * lane output, prompts, or secrets.
159
+ */
160
+ safeDetail?: string;
161
+ }
162
+ /** v2 terminal-settlement disclosure (issue #2383). The ONLY shape new writers emit. */
163
+ export interface PrReviewPartialBaseCoverageRecordV2 {
164
+ schemaVersion: 2;
165
+ runId: string;
166
+ prHeadSha: string;
167
+ revisionDigest: string;
168
+ unresolvedDimensions: PrReviewUnresolvedDimensionRecord[];
169
+ admittedAt: string;
170
+ }
171
+ /**
172
+ * Legacy v1 disclosure (pre-#2383): singular `missingDimension` with a typed
173
+ * terminal failure. Read-only — normalized to the v2 in-memory view at the
174
+ * single read boundary; never rewritten on disk.
175
+ */
176
+ export interface PrReviewPartialBaseCoverageRecordV1 {
177
+ runId: string;
178
+ prHeadSha: string;
179
+ revisionDigest: string;
180
+ missingDimension: PrReviewBaseDimensionId;
181
+ failureClass: BackgroundDelegationWorkflowLaneFailureClass;
182
+ terminalEventId: string;
183
+ admittedAt: string;
184
+ }
185
+ export type PrReviewPartialBaseCoverageRecord = PrReviewPartialBaseCoverageRecordV2 | PrReviewPartialBaseCoverageRecordV1;
186
+ /** Terminal report kind of an N-of-6 settlement (issue #2383). */
187
+ export type PrReviewTerminalCoverageKind = 'COMPLETE' | 'PARTIAL' | 'NO_COVERAGE';
188
+ /** Controller-declared terminal verdict for a PR_REVIEW completion (issue #2383). */
189
+ export declare const PR_REVIEW_REPORT_VERDICTS: readonly ["APPROVE", "REQUEST_CHANGES", "INCOMPLETE"];
190
+ export type PrReviewReportVerdict = (typeof PR_REVIEW_REPORT_VERDICTS)[number];
191
+ /**
192
+ * Verdicts a terminal report may carry by coverage kind (issue #2383):
193
+ * PARTIAL may only request changes or declare itself incomplete; NO_COVERAGE
194
+ * is a forced INCOMPLETE operational report. Neither may ever APPROVE or
195
+ * claim a full review.
196
+ */
197
+ export declare function allowedPrReviewReportVerdicts(kind: PrReviewTerminalCoverageKind): readonly PrReviewReportVerdict[];
198
+ export interface PrReviewTerminalCoverageSettlement {
199
+ kind: PrReviewTerminalCoverageKind;
200
+ coveredDimensions: PrReviewBaseDimensionId[];
201
+ unresolvedDimensions: PrReviewUnresolvedDimensionRecord[];
202
+ /** False while any dimension still has a live (in-flight) lane. */
203
+ allLaunchedTerminal: boolean;
204
+ }
205
+ /** Per-dimension explicit cancellation, written by armed recovery (issue #2383). */
206
+ export interface PrReviewDimensionCancellationRecord {
207
+ reason: string;
208
+ cancelledAt: string;
209
+ source: 'armed_recovery';
210
+ }
211
+ export declare const PrReviewPartialBaseCoverageRecordSchema: z.ZodUnion<readonly [z.ZodObject<{
212
+ schemaVersion: z.ZodLiteral<2>;
213
+ runId: z.ZodString;
214
+ prHeadSha: z.ZodString;
215
+ revisionDigest: z.ZodString;
216
+ unresolvedDimensions: z.ZodArray<z.ZodObject<{
217
+ dimension: z.ZodEnum<{
218
+ "intent-architecture": "intent-architecture";
219
+ "correctness-state": "correctness-state";
220
+ "tests-falsifiability": "tests-falsifiability";
221
+ "security-trust": "security-trust";
222
+ "reliability-performance": "reliability-performance";
223
+ "compatibility-delivery": "compatibility-delivery";
224
+ }>;
225
+ terminalState: z.ZodEnum<{
226
+ FAILED: "FAILED";
227
+ CANCELLED: "CANCELLED";
228
+ NOT_LAUNCHED: "NOT_LAUNCHED";
229
+ }>;
230
+ reasonKind: z.ZodEnum<{
231
+ cancelled: "cancelled";
232
+ lane_failure: "lane_failure";
233
+ not_launched: "not_launched";
234
+ }>;
235
+ failureClass: z.ZodOptional<z.ZodEnum<{
236
+ contract: "contract";
237
+ resource: "resource";
238
+ deadline: "deadline";
239
+ }>>;
240
+ terminalEventId: z.ZodOptional<z.ZodString>;
241
+ batchId: z.ZodOptional<z.ZodString>;
242
+ laneId: z.ZodOptional<z.ZodString>;
243
+ safeDetail: z.ZodOptional<z.ZodString>;
244
+ }, z.core.$strict>>;
245
+ admittedAt: z.ZodString;
246
+ }, z.core.$strict>, z.ZodObject<{
247
+ runId: z.ZodString;
248
+ prHeadSha: z.ZodString;
249
+ revisionDigest: z.ZodString;
250
+ missingDimension: z.ZodEnum<{
251
+ "intent-architecture": "intent-architecture";
252
+ "correctness-state": "correctness-state";
253
+ "tests-falsifiability": "tests-falsifiability";
254
+ "security-trust": "security-trust";
255
+ "reliability-performance": "reliability-performance";
256
+ "compatibility-delivery": "compatibility-delivery";
257
+ }>;
258
+ failureClass: z.ZodEnum<{
259
+ contract: "contract";
260
+ resource: "resource";
261
+ deadline: "deadline";
262
+ }>;
263
+ terminalEventId: z.ZodString;
264
+ admittedAt: z.ZodString;
265
+ }, z.core.$strict>]>;
266
+ export declare const PrReviewDimensionCancellationRecordSchema: z.ZodObject<{
267
+ reason: z.ZodString;
268
+ cancelledAt: z.ZodString;
269
+ source: z.ZodLiteral<"armed_recovery">;
270
+ }, z.core.$strict>;
271
+ /**
272
+ * Normalize any disclosure record to the v2 in-memory view. A legacy v1
273
+ * record maps to exactly one FAILED entry; the durable file is never
274
+ * rewritten (its digest stays bound to the original bytes).
275
+ */
276
+ export declare function normalizePrReviewPartialBaseCoverageRecord(record: PrReviewPartialBaseCoverageRecord): PrReviewPartialBaseCoverageRecordV2;
277
+ export interface PrReviewBaseDimensionAttempts {
278
+ /** Dimensions with a currently authoritative successful artifact. */
279
+ successful: Set<string>;
280
+ /** Dimensions with a currently in-flight or retryable recorded lane. */
281
+ inFlight: Set<string>;
282
+ /** Dimensions whose terminal record was a contract failure. */
283
+ contractFailed: Set<string>;
284
+ /** Dimensions that already consumed the dedicated contract retry channel. */
285
+ contractRetried: Set<string>;
286
+ /**
287
+ * The subset of `successful` supplied by a lane that owns that dimension
288
+ * alone. Used by the cumulative tier-L lane floor to decide when an earlier
289
+ * consolidated lane has been superseded and no longer spends lane budget.
290
+ */
291
+ dedicatedSuccessful: Set<string>;
292
+ /** Dimensions whose recorded lane ran to a terminal, non-successful end. */
293
+ terminallyFailed: Set<string>;
294
+ }
295
+ /**
296
+ * Per-dimension success/failure across every recorded base batch.
297
+ *
298
+ * The two halves deliberately use different evidence:
299
+ *
300
+ * - **successful** is revision-aware (`successfulObligationsFromExactBatch`
301
+ * compares each artifact's `revisionDigest` against the current worktree), so
302
+ * a stale artifact is correctly not a current source.
303
+ * - **terminallyFailed** is revision-INdependent on purpose.
304
+ * `recordsPassingBatchIntegrity` plus
305
+ * `hasRevisionIndependentDiscoverySemantics` use the artifact's recorded
306
+ * revision rather than the current worktree digest. If failure were
307
+ * derived from the revision-aware set instead, any working-tree edit would
308
+ * make all six dimensions read as "failed" at once and a caller could then
309
+ * consolidate the whole base wave into two lanes — re-opening the tier-L lane
310
+ * floor by a second route (issue #1968 BL-4).
311
+ */
312
+ export declare function summarizePrReviewBaseDimensionAttempts(directory: string, state: PrReviewCompletionState, revisionDigest: string): PrReviewBaseDimensionAttempts;
313
+ export declare function coverageDisclosureRelativePath(runId: string): string;
314
+ /**
315
+ * Derive the normalized terminal N-of-6 settlement (issue #2383).
316
+ *
317
+ * Pure over durable state: no mutation, no audit. Every dimension maps to
318
+ * exactly one view — COVERED, a terminal unresolved record (FAILED /
319
+ * CANCELLED / NOT_LAUNCHED), or a live (in-flight) dimension that blocks
320
+ * settlement. Coverage success is revision-aware (a stale artifact never
321
+ * counts on the current worktree), and a FAILED dimension carries the typed
322
+ * terminal-failure evidence plus its contributing lane/batch identity.
323
+ */
324
+ export declare function derivePrReviewDimensionSettlement(directory: string, state: PrReviewCompletionState, revisionDigest: string): PrReviewTerminalCoverageSettlement & {
325
+ liveDimensions: PrReviewBaseDimensionId[];
326
+ };
327
+ export declare function admitPrReviewPartialBaseCoverage(directory: string, sessionID: string, runId: string, unresolvedDimensions: readonly PrReviewBaseDimensionId[]): Promise<PrReviewCompletionState>;
328
+ /**
329
+ * Undo a newly admitted partial-base disclosure when the findings checkpoint
330
+ * cannot be completed. The compare-and-clear checks keep a stale writer from
331
+ * deleting a disclosure that another writer has already committed.
332
+ */
333
+ export declare function rollbackPrReviewPartialBaseCoverageAdmission(directory: string, sessionID: string, options: {
334
+ runId: string;
335
+ boundary: 'post_explorer' | 'post_reviewer' | 'post_critic';
336
+ relativePath: string;
337
+ digest: string;
338
+ }): Promise<boolean>;
339
+ /**
340
+ * Validate durable terminal N-of-6 coverage evidence (issue #2383).
341
+ *
342
+ * Returns the settlement: COMPLETE when all six dimensions are covered, or
343
+ * PARTIAL / NO_COVERAGE when an admitted, still-accurate disclosure exactly
344
+ * matches the currently derived terminal settlement. Throws while any
345
+ * unresolved dimension still has a live lane, or when the disclosure has been
346
+ * invalidated by later evidence (e.g. a late success landing on the same
347
+ * revision) — the disclosure is immutable, so such a run must re-settle or
348
+ * restart rather than silently re-crediting.
349
+ */
350
+ export declare function assertPrReviewBaseCoverageSettled(directory: string, sessionID: string, gateContext?: PrReviewCompletionGateContext): Promise<{
351
+ state: PrReviewCompletionState;
352
+ settlement: PrReviewTerminalCoverageSettlement & {
353
+ liveDimensions: PrReviewBaseDimensionId[];
354
+ };
355
+ }>;
356
+ /**
357
+ * Read-only terminal-coverage projection for the completion report surface
358
+ * (issue #2383). Pure derivation over the CURRENT state; returns null when no
359
+ * active PR_REVIEW gate exists. The completion tool reads this BEFORE the
360
+ * terminal clear so the response carries the truthful settlement summary.
361
+ */
362
+ export declare function readPrReviewTerminalCoverageForReport(directory: string, sessionID: string): Promise<{
363
+ kind: PrReviewTerminalCoverageKind;
364
+ coveredDimensions: PrReviewBaseDimensionId[];
365
+ unresolvedDimensions: Array<{
366
+ dimension: PrReviewBaseDimensionId;
367
+ terminal_state: PrReviewUnresolvedDimensionRecord['terminalState'];
368
+ reason_kind: PrReviewUnresolvedDimensionRecord['reasonKind'];
369
+ failure_class?: BackgroundDelegationWorkflowLaneFailureClass;
370
+ }>;
371
+ liveDimensions: PrReviewBaseDimensionId[];
372
+ allowedVerdicts: readonly PrReviewReportVerdict[];
373
+ } | null>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * PR-review critic routing — the single severity/impact/tag predicate
3
+ * (issues #2383, #2385).
4
+ *
5
+ * Issue #2385 makes `src/pr-review/critic-routing.ts` the canonical home of
6
+ * the shared production critic-routing predicate. `src/background/
7
+ * pr-review-contract.ts` re-exports it (single definition, two import paths —
8
+ * no duplication). Every production consumer (critic inventory derivation,
9
+ * artifact-record validation, coverage admission, reducer transitions)
10
+ * imports THIS predicate; inline severity triples are forbidden and a
11
+ * centralization guard test enforces it.
12
+ */
13
+ import type { PrReviewRiskImpact, PrReviewRiskTag } from '../background/pr-review-contract.js';
14
+ export interface PrReviewCriticRoutingInput {
15
+ classification?: string;
16
+ severity?: string;
17
+ risk_impact?: PrReviewRiskImpact;
18
+ risk_tags?: readonly PrReviewRiskTag[];
19
+ }
20
+ /**
21
+ * THE shared production critic-routing predicate (issue #2383).
22
+ *
23
+ * Exactly one definition, imported by every production consumer (critic
24
+ * inventory derivation, artifact-record validation, coverage admission).
25
+ * Inline severity triples are forbidden — a parity/centralization guard test
26
+ * enforces it. Accepts only the normalized canonical shape:
27
+ *
28
+ * - non-CONFIRMED classifications are never critic-routed;
29
+ * - UNKNOWN/missing/invalid risk metadata routes to critic (fail-safe);
30
+ * - CRITICAL/HIGH always route to critic;
31
+ * - MEDIUM routes iff HIGH_IMPACT or at least one risk tag;
32
+ * - LOW/INFO/NONE follow the existing no-critic policy once metadata is known.
33
+ *
34
+ * Paths, dimensions, keywords, and prompt prose may suggest risk to the model
35
+ * but can never override this typed result.
36
+ */
37
+ export declare function prReviewFindingRequiresCritic(input: PrReviewCriticRoutingInput): boolean;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * PR-review recurrence guardrails (issue #2385).
3
+ *
4
+ * Exported source scanners implementing the mechanical guardrails the issue
5
+ * requires. Each scanner is a PURE function over `{ path, content }` source
6
+ * maps; unit tests prove each scanner flags a synthetic violating snippet
7
+ * (the guardrail "biting") and then apply it over the real `src/` tree.
8
+ *
9
+ * 1. `scanObserverTerminalization` — (a) the historical wait-deadline/no-client
10
+ * terminalizer may never reappear by name; (b) in
11
+ * `src/tools/dispatch-lanes.ts`, durable delegation-transition writes are
12
+ * allowed only inside the sanctioned settlement functions.
13
+ * 2. `scanParallelCircuitRuleConstruction` — circuit-record construction may
14
+ * exist only under `src/pr-review/` (the inline-construction recurrence
15
+ * class G-1).
16
+ *
17
+ * Issue #2385 originally specified a third scanner for transcript-parsing
18
+ * locality (the 13 conversion symbols restricted to the legacy adapter),
19
+ * but its only test consumer was a synthetic-input bite demo with no
20
+ * production caller. The boundary is already enforced structurally
21
+ * (the legacy-transcript-adapter is the sole module that owns those symbols,
22
+ * and the two retained scanners cover the real recurrence classes). A
23
+ * scanner with no caller would create the appearance of a guardrail where
24
+ * there is none — per the issue's "no unwired functionality" bar, it was
25
+ * removed instead.
26
+ */
27
+ export interface GuardrailSource {
28
+ path: string;
29
+ content: string;
30
+ }
31
+ export interface GuardrailHit {
32
+ path: string;
33
+ line: number;
34
+ rule: string;
35
+ excerpt: string;
36
+ }
37
+ /**
38
+ * The historical PR-review wait-deadline terminalizer (issue #2381 deleted
39
+ * it). Any reappearance of these names in `src/` is the exact recurrence
40
+ * class the issue forbids: a collection wait budget or an unavailable host
41
+ * messages client must never write a terminal delegation transition.
42
+ */
43
+ export declare const FORBIDDEN_OBSERVER_TERMINALIZER_SYMBOLS: readonly string[];
44
+ /**
45
+ * Enclosing functions in `src/tools/dispatch-lanes.ts` that are allowed to
46
+ * write delegation transitions. Every entry is child-evidence-driven
47
+ * settlement (typed terminal error, explicit caller cancellation, or the
48
+ * age+liveness presumed-stale backstop) — never observer-deadline evidence:
49
+ * - `startAsyncLanePrompt`: `running` transition after a successful launch.
50
+ * - `appendAsyncLaneLaunchError`: typed `error` for a failed child launch.
51
+ * - `collectOnce`: explicit caller `cancelled` transition.
52
+ * - `settleCollectedLane`: `completed`/`error` settlement from child evidence.
53
+ * - `sweepStaleAsyncLaneRecords`: the presumed-stale `stale` backstop.
54
+ * Additions must document their evidence source here.
55
+ */
56
+ export declare const DELEGATION_WRITE_ALLOWED_FUNCTIONS: ReadonlySet<string>;
57
+ /**
58
+ * Guardrail 2. (a) flags any forbidden historical-terminalizer symbol;
59
+ * (b) for `src/tools/dispatch-lanes.ts`, flags delegation-transition writes
60
+ * inside any enclosing function outside the sanctioned allowlist. This
61
+ * module itself is exempt from rule (a): it DEFINES the forbidden names
62
+ * (the definition site is not a recurrence, same reasoning as the adapter
63
+ * allowlist in guardrail 1).
64
+ */
65
+ export declare function scanObserverTerminalization(sources: readonly GuardrailSource[]): GuardrailHit[];
66
+ /** Guardrail 3 (issue #2385 recurrence class G-1). */
67
+ export declare function scanParallelCircuitRuleConstruction(sources: readonly GuardrailSource[]): GuardrailHit[];