opencode-swarm 7.153.2 → 7.154.0

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 (71) hide show
  1. package/dist/background/pending-delegations.d.ts +29 -0
  2. package/dist/background/pr-subscriptions.d.ts +258 -27
  3. package/dist/cli/{config-doctor-tv0ar88m.js → config-doctor-8p9y543t.js} +2 -2
  4. package/dist/cli/{core-kmsm50zn.js → core-1h6x6k59.js} +1 -1
  5. package/dist/cli/{curation-policy-twa6agf8.js → curation-policy-9r902jw4.js} +6 -6
  6. package/dist/cli/{curator-llm-factory-dxkhdhwg.js → curator-llm-factory-ypwf3a90.js} +29 -29
  7. package/dist/cli/{curator-wxe863k9.js → curator-yj00z1qz.js} +29 -29
  8. package/dist/cli/{evidence-summary-service-9akrdg9t.js → evidence-summary-service-npq04240.js} +12 -12
  9. package/dist/cli/{gate-evidence-bdzqbg2y.js → gate-evidence-4b6t0ycn.js} +6 -6
  10. package/dist/cli/{guardrail-explain-kx9rem51.js → guardrail-explain-dyxbhrdj.js} +30 -30
  11. package/dist/cli/{guardrail-log-zxzyx1de.js → guardrail-log-eyecsekk.js} +5 -5
  12. package/dist/cli/{guardrail-reset-1mc3st34.js → guardrail-reset-269jdwhd.js} +29 -29
  13. package/dist/cli/{hive-promoter-gncwtq0z.js → hive-promoter-5936am48.js} +29 -29
  14. package/dist/cli/{index-hhv2pvab.js → index-10zvxqra.js} +1 -1
  15. package/dist/cli/{index-j4f8sz67.js → index-1tdsddab.js} +192 -102
  16. package/dist/cli/{index-kenz5bja.js → index-2kzxkx50.js} +31 -31
  17. package/dist/cli/{index-3bh4h6ve.js → index-2mbs5q26.js} +7 -7
  18. package/dist/cli/{index-x3y6zhgj.js → index-3db7xza0.js} +1 -1
  19. package/dist/cli/{index-h3zhb18p.js → index-3hdnfmhp.js} +2 -2
  20. package/dist/cli/{index-84m4per1.js → index-3mhgv8d6.js} +2 -2
  21. package/dist/cli/{index-21pt4jwf.js → index-48m4841x.js} +1 -1
  22. package/dist/cli/{index-ebshrg4x.js → index-4g00jhbs.js} +3 -3
  23. package/dist/cli/{index-5zp4c36c.js → index-4y7g04py.js} +1 -1
  24. package/dist/cli/{index-vhbds89e.js → index-68w5jxv5.js} +4 -4
  25. package/dist/cli/{index-4pjkdcgc.js → index-6yc06dx9.js} +1 -1
  26. package/dist/cli/{index-2mqmvxac.js → index-7jnh1sgb.js} +7 -1
  27. package/dist/cli/{index-pk1gbqmq.js → index-c6dfyzdh.js} +1 -1
  28. package/dist/cli/{index-td0jz8xe.js → index-c809a69b.js} +2 -2
  29. package/dist/cli/{index-0azn976d.js → index-dwh02jmv.js} +7 -7
  30. package/dist/cli/{index-3cegckkq.js → index-garsang6.js} +1 -1
  31. package/dist/cli/{index-bw55r5bz.js → index-hk4wa0v1.js} +6 -6
  32. package/dist/cli/{index-5ad8xcv3.js → index-mddgkqg9.js} +2 -2
  33. package/dist/cli/{index-s6b8jgtn.js → index-nkr634n6.js} +1 -1
  34. package/dist/cli/{index-3fpqpyp6.js → index-p4y7jefb.js} +2 -2
  35. package/dist/cli/{index-kvk65qzz.js → index-pcj7jk4t.js} +3 -3
  36. package/dist/cli/{index-56ejcj07.js → index-qcz4xprd.js} +4 -4
  37. package/dist/cli/{index-zppxpc3y.js → index-s0a4ewkb.js} +2 -2
  38. package/dist/cli/{index-h06112sh.js → index-s70tmqn3.js} +5 -5
  39. package/dist/cli/{index-yvepnbyd.js → index-snnps1vm.js} +5 -5
  40. package/dist/cli/{index-a58nmnmz.js → index-tnm9bb8b.js} +5 -3
  41. package/dist/cli/{index-x8vw6ap1.js → index-ttqnhxxq.js} +59 -42
  42. package/dist/cli/{index-891g7hbf.js → index-vtdwkfbv.js} +1 -1
  43. package/dist/cli/index-wfxg3s7n.js +1158 -0
  44. package/dist/cli/{index-02rbfrab.js → index-wpstzk85.js} +4 -4
  45. package/dist/cli/{index-1gzdnjg9.js → index-y64jrbch.js} +2 -2
  46. package/dist/cli/{index-3ttktt56.js → index-yve4e8fx.js} +1 -1
  47. package/dist/cli/index.js +29 -29
  48. package/dist/cli/{knowledge-escalator-gp3mpbqe.js → knowledge-escalator-bxpzeth0.js} +11 -11
  49. package/dist/cli/{knowledge-events-nvkhtqvn.js → knowledge-events-jxdpg2hj.js} +9 -9
  50. package/dist/cli/{knowledge-link-ge0rddxw.js → knowledge-link-nwxykjya.js} +5 -5
  51. package/dist/cli/{knowledge-store-2ngh8xvv.js → knowledge-store-336hyzs8.js} +6 -6
  52. package/dist/cli/{knowledge-validator-4bphyrec.js → knowledge-validator-9wkvnsv0.js} +8 -8
  53. package/dist/cli/{pending-delegations-nk78wx7h.js → pending-delegations-0fmj1qy6.js} +3 -3
  54. package/dist/cli/{pr-subscriptions-dq1f61ye.js → pr-subscriptions-1ndwgtbw.js} +15 -4
  55. package/dist/cli/{runner-n50w1y4w.js → runner-06dvm53x.js} +6 -6
  56. package/dist/cli/{scan-cursor-c16xtygz.js → scan-cursor-3xxqtxwx.js} +7 -7
  57. package/dist/cli/{schema-83tbte2g.js → schema-jdx83m4m.js} +1 -1
  58. package/dist/cli/{scope-persistence-gdbw8xh8.js → scope-persistence-wgxn2kba.js} +8 -8
  59. package/dist/cli/{skill-generator-gr13xeha.js → skill-generator-vmxsc2fm.js} +13 -13
  60. package/dist/cli/{telemetry-hh1j99za.js → telemetry-q2km2zrz.js} +1 -1
  61. package/dist/cli/{worktree-collision-ownership-4drcjymy.js → worktree-collision-ownership-gsay5210.js} +5 -5
  62. package/dist/cli/{worktree-isolation-jjkfg2pg.js → worktree-isolation-peb4bkg3.js} +29 -29
  63. package/dist/commands/pr-monitor-status.d.ts +8 -1
  64. package/dist/config/schema.d.ts +8 -0
  65. package/dist/hooks/pr-review-resilience-circuit.d.ts +232 -0
  66. package/dist/hooks/pr-workflow-gate.d.ts +10 -11
  67. package/dist/index.js +298 -289
  68. package/dist/observability/catalog.d.ts +6 -3
  69. package/dist/telemetry.d.ts +21 -1
  70. package/package.json +1 -1
  71. package/dist/cli/index-meg33yyv.js +0 -247
@@ -9,7 +9,7 @@
9
9
  * Input contract (no args):
10
10
  * /swarm pr status → show session subscriptions
11
11
  */
12
- import { listActive } from '../background/pr-subscriptions.js';
12
+ import { getPrSubscriptionHealth, listActive, type PrSubscriptionHealth } from '../background/pr-subscriptions.js';
13
13
  type MergeGroupRun = {
14
14
  databaseId: number;
15
15
  headBranch: string;
@@ -38,15 +38,22 @@ declare function listMergeGroupRuns(directory: string, repoFullName: string, prN
38
38
  * and a link reference.
39
39
  */
40
40
  declare function formatMergeGroupStatus(status?: string, conclusion?: string, htmlUrl?: string): string;
41
+ /**
42
+ * Format the bounded-store storage-health footer (issue #2042). Counts and
43
+ * bytes only — never a path or repo identity.
44
+ */
45
+ declare function formatStorageHealth(health: PrSubscriptionHealth): string;
41
46
  /**
42
47
  * Exposed for unit testing via _internals.
43
48
  */
44
49
  export declare const _internals: {
45
50
  formatRelativeTime: typeof formatRelativeTime;
46
51
  formatMergeGroupStatus: typeof formatMergeGroupStatus;
52
+ formatStorageHealth: typeof formatStorageHealth;
47
53
  listActive: typeof listActive;
48
54
  listMergeGroupRuns: typeof listMergeGroupRuns;
49
55
  parseMergeGroupRuns: typeof parseMergeGroupRuns;
56
+ getPrSubscriptionHealth: typeof getPrSubscriptionHealth;
50
57
  };
51
58
  /**
52
59
  * Show PR monitor subscription status for the current session.
@@ -1755,6 +1755,12 @@ export interface PrReviewResilienceConfig {
1755
1755
  status_probe_timeout_ms: number;
1756
1756
  correlated_failure_threshold: number;
1757
1757
  max_retry_attempts_after_initial: number;
1758
+ /**
1759
+ * Issue #2382: how long an opened PR-review resilience circuit stays OPEN
1760
+ * before it admits exactly one HALF_OPEN probe. Applies both to the initial
1761
+ * open and to every provider-failure reopen.
1762
+ */
1763
+ circuit_open_duration_ms: number;
1758
1764
  }
1759
1765
  /**
1760
1766
  * Issue #2381: staged PR-review resilience defaults OFF while the #2380 repair
@@ -1770,6 +1776,7 @@ export declare const PrReviewResilienceConfigSchema: z.ZodObject<{
1770
1776
  status_probe_timeout_ms: z.ZodDefault<z.ZodNumber>;
1771
1777
  correlated_failure_threshold: z.ZodDefault<z.ZodNumber>;
1772
1778
  max_retry_attempts_after_initial: z.ZodDefault<z.ZodNumber>;
1779
+ circuit_open_duration_ms: z.ZodDefault<z.ZodNumber>;
1773
1780
  }, z.core.$strict>;
1774
1781
  export declare const PluginConfigSchema: z.ZodObject<{
1775
1782
  config_format_version: z.ZodDefault<z.ZodNumber>;
@@ -1866,6 +1873,7 @@ export declare const PluginConfigSchema: z.ZodObject<{
1866
1873
  status_probe_timeout_ms: z.ZodDefault<z.ZodNumber>;
1867
1874
  correlated_failure_threshold: z.ZodDefault<z.ZodNumber>;
1868
1875
  max_retry_attempts_after_initial: z.ZodDefault<z.ZodNumber>;
1876
+ circuit_open_duration_ms: z.ZodDefault<z.ZodNumber>;
1869
1877
  }, z.core.$strict>>;
1870
1878
  gates: z.ZodOptional<z.ZodObject<{
1871
1879
  syntax_check: z.ZodDefault<z.ZodObject<{
@@ -0,0 +1,232 @@
1
+ /**
2
+ * PR-review resilience circuit — typed, recoverable, versioned (issue #2382).
3
+ *
4
+ * Pure state machine + typed-signal classification for the PR_REVIEW
5
+ * resilience circuit. No I/O: the owning gate (`pr-workflow-gate.ts`) reads
6
+ * the delegation ledger and persists transitions under its CAS write path.
7
+ *
8
+ * Contracts implemented (issue #2382 "Required design"):
9
+ * - Only durable, typed `provider_terminal` signals contribute; every other
10
+ * outcome is an `ignored` kind that can never open, reopen, or close the
11
+ * circuit.
12
+ * - The threshold counts distinct `(generation, batchId, laneId)` contributor
13
+ * lanes per provider class — never owned dimensions, never repeated
14
+ * collections of the same lane.
15
+ * - State is a versioned v2 record: CLOSED → OPEN (bounded interval) →
16
+ * exactly-one HALF_OPEN probe → CLOSED (generation bump + evidence
17
+ * waterline) or back to OPEN (new interval). Legacy unversioned records
18
+ * migrate once to a nonblocking v2 CLOSED record with an evidence waterline;
19
+ * malformed records fail open.
20
+ */
21
+ import { z } from 'zod';
22
+ import type { BackgroundDelegationRecord } from '../background/pending-delegations.js';
23
+ /** Bounded contributor ledger. Mirrors `MAX_WORKFLOW_BATCHES (128) × 6` base dimensions. */
24
+ export declare const PR_REVIEW_CIRCUIT_CONTRIBUTOR_LIMIT = 768;
25
+ export type PrReviewCircuitIgnoredReason = 'observer_deadline' | 'client_unavailable' | 'parser' | 'validation' | 'policy' | 'filesystem' | 'git' | 'cancellation' | 'stale_observation' | 'unknown';
26
+ export type PrReviewCircuitSignal = {
27
+ kind: 'provider_terminal';
28
+ providerClass: string;
29
+ batchId: string;
30
+ laneId: string;
31
+ terminalAtMs: number;
32
+ } | {
33
+ kind: 'ignored';
34
+ reason: PrReviewCircuitIgnoredReason;
35
+ };
36
+ export type PrReviewCircuitState = 'CLOSED' | 'OPEN' | 'HALF_OPEN';
37
+ export interface PrReviewCircuitContributor {
38
+ batchId: string;
39
+ laneId: string;
40
+ /** ISO timestamp of the contributing lane's terminal evidence. */
41
+ terminalAt: string;
42
+ }
43
+ export interface PrReviewCircuitProbeRecord {
44
+ batchId: string;
45
+ laneId: string;
46
+ admittedAt: string;
47
+ }
48
+ export interface PrReviewCircuitRecordV2 {
49
+ version: 2;
50
+ state: PrReviewCircuitState;
51
+ generation: number;
52
+ providerClass?: string;
53
+ contributors: PrReviewCircuitContributor[];
54
+ openedAt?: string;
55
+ openUntil?: string;
56
+ /** Evidence at or before this ISO instant can never contribute again. */
57
+ evidenceWaterline?: string;
58
+ probe?: PrReviewCircuitProbeRecord;
59
+ }
60
+ /** The unversioned pre-#2382 persisted circuit shape. */
61
+ export interface PrReviewCircuitLegacyRecord {
62
+ signature: string;
63
+ count: number;
64
+ contributors: Array<{
65
+ batchId: string;
66
+ laneId: string;
67
+ }>;
68
+ openedAt: string;
69
+ }
70
+ export declare const PrReviewCircuitLegacyRecordSchema: z.ZodObject<{
71
+ signature: z.ZodString;
72
+ count: z.ZodNumber;
73
+ contributors: z.ZodArray<z.ZodObject<{
74
+ batchId: z.ZodString;
75
+ laneId: z.ZodString;
76
+ }, z.core.$strict>>;
77
+ openedAt: z.ZodString;
78
+ }, z.core.$strict>;
79
+ export declare const PrReviewCircuitRecordV2Schema: z.ZodObject<{
80
+ version: z.ZodLiteral<2>;
81
+ state: z.ZodEnum<{
82
+ CLOSED: "CLOSED";
83
+ OPEN: "OPEN";
84
+ HALF_OPEN: "HALF_OPEN";
85
+ }>;
86
+ generation: z.ZodNumber;
87
+ providerClass: z.ZodOptional<z.ZodString>;
88
+ contributors: z.ZodArray<z.ZodObject<{
89
+ batchId: z.ZodString;
90
+ laneId: z.ZodString;
91
+ terminalAt: z.ZodString;
92
+ }, z.core.$strict>>;
93
+ openedAt: z.ZodOptional<z.ZodString>;
94
+ openUntil: z.ZodOptional<z.ZodString>;
95
+ evidenceWaterline: z.ZodOptional<z.ZodString>;
96
+ probe: z.ZodOptional<z.ZodObject<{
97
+ batchId: z.ZodString;
98
+ laneId: z.ZodString;
99
+ admittedAt: z.ZodString;
100
+ }, z.core.$strict>>;
101
+ }, z.core.$strict>;
102
+ export declare const PrReviewCircuitRecordSchema: z.ZodUnion<readonly [z.ZodObject<{
103
+ signature: z.ZodString;
104
+ count: z.ZodNumber;
105
+ contributors: z.ZodArray<z.ZodObject<{
106
+ batchId: z.ZodString;
107
+ laneId: z.ZodString;
108
+ }, z.core.$strict>>;
109
+ openedAt: z.ZodString;
110
+ }, z.core.$strict>, z.ZodObject<{
111
+ version: z.ZodLiteral<2>;
112
+ state: z.ZodEnum<{
113
+ CLOSED: "CLOSED";
114
+ OPEN: "OPEN";
115
+ HALF_OPEN: "HALF_OPEN";
116
+ }>;
117
+ generation: z.ZodNumber;
118
+ providerClass: z.ZodOptional<z.ZodString>;
119
+ contributors: z.ZodArray<z.ZodObject<{
120
+ batchId: z.ZodString;
121
+ laneId: z.ZodString;
122
+ terminalAt: z.ZodString;
123
+ }, z.core.$strict>>;
124
+ openedAt: z.ZodOptional<z.ZodString>;
125
+ openUntil: z.ZodOptional<z.ZodString>;
126
+ evidenceWaterline: z.ZodOptional<z.ZodString>;
127
+ probe: z.ZodOptional<z.ZodObject<{
128
+ batchId: z.ZodString;
129
+ laneId: z.ZodString;
130
+ admittedAt: z.ZodString;
131
+ }, z.core.$strict>>;
132
+ }, z.core.$strict>]>;
133
+ /**
134
+ * Derive the typed circuit signal from a durable delegation record's LATEST
135
+ * terminal state. Returns `null` for anything that is not a terminal failure
136
+ * signal (pending/running lanes, healthy completions).
137
+ *
138
+ * Trust rules: only the structured `terminalErrorClass` captured at settle
139
+ * time can produce `provider_terminal`; display text is never parsed. Records
140
+ * settled before this field existed, launch failures (the child never ran),
141
+ * presumed-stale sweeps, cancellations, and empty completions are `ignored`
142
+ * kinds or no signal at all.
143
+ */
144
+ export declare function classifyPrReviewCircuitSignal(record: Pick<BackgroundDelegationRecord, 'status' | 'result' | 'terminalResult'> & {
145
+ batchId?: string;
146
+ laneId?: string;
147
+ }): PrReviewCircuitSignal | null;
148
+ /**
149
+ * Reduce per-lane signals into per-providerClass distinct-lane evidence under
150
+ * the CURRENT circuit generation. Dedupes on `(generation, batchId, laneId)`,
151
+ * drops evidence at or before the waterline, sorts newest-first, and bounds
152
+ * each class's contributor list with deterministic keep-newest eviction.
153
+ */
154
+ export declare function scanPrReviewCircuitEvidence(signals: readonly PrReviewCircuitSignal[], generation: number, waterlineMs: number | undefined): Map<string, Array<PrReviewCircuitSignal & {
155
+ kind: 'provider_terminal';
156
+ }>>;
157
+ export type PrReviewCircuitAdoptionDiagnostic = {
158
+ code: 'migrated_legacy_circuit';
159
+ legacySignatureCount: number;
160
+ } | {
161
+ code: 'malformed_circuit_dropped';
162
+ bodyHash8: string;
163
+ byteLength: number;
164
+ };
165
+ export type PrReviewCircuitAdoption = {
166
+ kind: 'v2';
167
+ record: PrReviewCircuitRecordV2;
168
+ } | {
169
+ kind: 'absent';
170
+ } | {
171
+ kind: 'migrated';
172
+ record: PrReviewCircuitRecordV2;
173
+ diagnostic: PrReviewCircuitAdoptionDiagnostic;
174
+ } | {
175
+ kind: 'malformed';
176
+ diagnostic: PrReviewCircuitAdoptionDiagnostic;
177
+ };
178
+ /**
179
+ * Adopt a persisted circuit field: v2 records pass through, legacy unversioned
180
+ * records migrate ONCE to a nonblocking v2 CLOSED record whose evidence
181
+ * waterline is `now` (historical evidence can never immediately reopen), and
182
+ * malformed records fail open with a bounded hash-only diagnostic.
183
+ */
184
+ export declare function adoptPrReviewCircuit(raw: unknown, nowMs: number): PrReviewCircuitAdoption;
185
+ export interface PrReviewCircuitAdvanceInput {
186
+ nowMs: number;
187
+ threshold: number;
188
+ openDurationMs: number;
189
+ /** The staged dispatch requesting admission, when this advance guards one. */
190
+ admission?: {
191
+ batchId: string;
192
+ laneId: string;
193
+ };
194
+ /** Latest-record signals for every dispatch lane of the current workflow. */
195
+ laneSignals: readonly PrReviewCircuitSignal[];
196
+ /**
197
+ * Observation of the CURRENT probe lane's latest record (HALF_OPEN only).
198
+ * The gate supplies it only when it read the recorded probe's batch/lane,
199
+ * which structurally drops late results from older generations.
200
+ */
201
+ probeObservation?: {
202
+ terminalStatus: string;
203
+ signal: PrReviewCircuitSignal | null;
204
+ terminalAtMs: number;
205
+ };
206
+ }
207
+ export type PrReviewCircuitAdvanceResult = {
208
+ action: 'admit';
209
+ changed: false;
210
+ } | {
211
+ action: 'admit';
212
+ changed: true;
213
+ record: PrReviewCircuitRecordV2;
214
+ } | {
215
+ action: 'admit_as_probe';
216
+ changed: true;
217
+ record: PrReviewCircuitRecordV2;
218
+ } | {
219
+ action: 'admit_as_probe';
220
+ changed: false;
221
+ } | {
222
+ action: 'block';
223
+ reason: 'circuit_open' | 'probe_in_flight';
224
+ changed: boolean;
225
+ record?: PrReviewCircuitRecordV2;
226
+ };
227
+ /**
228
+ * Advance the circuit one step. `current === null` means no circuit record
229
+ * exists yet (plain birth: no waterline — post-upgrade evidence counts; the
230
+ * gate passes an explicit waterlined record for migration / re-enable births).
231
+ */
232
+ export declare function advancePrReviewCircuit(current: PrReviewCircuitRecordV2 | null, input: PrReviewCircuitAdvanceInput): PrReviewCircuitAdvanceResult;
@@ -7,6 +7,7 @@ import { type PrReviewInlineTriggerRow } from '../background/pr-review-trigger-c
7
7
  import { type RevisionDigestResult, resolveCommitCountSince, resolveCommitCountSinceAsync, resolveCurrentGitHead, resolveCurrentGitHeadAsync, resolveCurrentUpstreamPushTarget, resolveCurrentUpstreamPushTargetAsync, resolveCurrentUpstreamRemoteRef, resolveExactRemoteBranchHead, resolveExactRemoteBranchHeadAsync, resolveIsExactSingleChildCommit, resolveIsExactSingleChildCommitAsync, resolveIsWorkingTreeClean, resolveIsWorkingTreeCleanAsync, resolvePrReviewDiffStats, resolvePrReviewDiffStatsAsync, resolvePrWorkflowRevisionDigest, resolvePrWorkflowRevisionDigestDetailed, resolveRemoteRefsContainingHead, resolveRemoteRefsContainingHeadAsync } from '../background/workspace-snapshot.js';
8
8
  import { type PrReviewResilienceConfig } from '../config/schema.js';
9
9
  import { classifyPrWorkflowGitState, type PrWorkflowGitState } from '../git/pr-workflow-state.js';
10
+ import { classifyPrReviewCircuitSignal, type PrReviewCircuitLegacyRecord, type PrReviewCircuitRecordV2 } from './pr-review-resilience-circuit.js';
10
11
  export declare const PR_REVIEW_BASE_DIMENSION_IDS: readonly ["intent-architecture", "correctness-state", "tests-falsifiability", "security-trust", "reliability-performance", "compatibility-delivery"];
11
12
  export declare const PR_REVIEW_REQUIRED_MICRO_LANE_IDS: ("auth-identity-secrets" | "untrusted-input-boundaries" | "subprocess-platform" | "concurrency-state" | "dependencies-build-release" | "api-schema-migrations" | "test-infrastructure" | "ui-accessibility-i18n" | "privacy-observability" | "generated-provenance" | "unclassified-risk")[];
12
13
  export type PrReviewBaseDimensionId = (typeof PR_REVIEW_BASE_DIMENSION_IDS)[number];
@@ -176,6 +177,8 @@ interface PrReviewResiliencePolicyRecord {
176
177
  statusProbeTimeoutMs: number;
177
178
  correlatedFailureThreshold: number;
178
179
  maxRetryAttemptsAfterInitial: number;
180
+ /** Issue #2382. Optional: policies persisted before the field existed parse unchanged. */
181
+ circuitOpenDurationMs?: number;
179
182
  }
180
183
  interface PrReviewResilienceAttemptRecord {
181
184
  attempt: 0 | 1 | 2;
@@ -186,15 +189,12 @@ interface PrReviewResilienceAttemptRecord {
186
189
  admittedAt: string;
187
190
  fanoutBatchId?: string;
188
191
  }
189
- interface PrReviewResilienceCircuitRecord {
190
- signature: string;
191
- count: number;
192
- contributors: Array<{
193
- batchId: string;
194
- laneId: string;
195
- }>;
196
- openedAt: string;
197
- }
192
+ /**
193
+ * Issue #2382: the persisted circuit is a versioned union. The unversioned
194
+ * pre-#2382 shape migrates once to a nonblocking v2 record on first adoption
195
+ * (see `adoptPrReviewCircuit`); malformed records fail open.
196
+ */
197
+ type PrReviewResilienceCircuitRecord = PrReviewCircuitLegacyRecord | PrReviewCircuitRecordV2;
198
198
  interface PrReviewResilienceStateRecord {
199
199
  policy: PrReviewResiliencePolicyRecord;
200
200
  attempts: PrReviewResilienceAttemptRecord[];
@@ -786,7 +786,6 @@ export declare class PrReviewResilienceRetryExhaustedError extends Error {
786
786
  }
787
787
  declare function snapshotPrReviewResiliencePolicy(policy?: PrReviewResilienceConfig): PrReviewResiliencePolicyRecord;
788
788
  declare function effectivePrReviewResiliencePolicy(state: PrWorkflowGateState, requestedPolicy?: PrReviewResilienceConfig): PrReviewResiliencePolicyRecord;
789
- declare function classifyTerminalFailureSignature(record: BackgroundDelegationRecord): string | null;
790
789
  interface EnforcePrReviewBaseDimensionsOptions {
791
790
  batchId: string;
792
791
  prHeadSha: string;
@@ -903,7 +902,7 @@ export declare function enforcePrWorkflowToolBefore(directory: string, sessionID
903
902
  /** Validate the terminal PR workflow contract before removing its durable gate. */
904
903
  export declare function completePrWorkflow(directory: string, sessionID: string, expectedMode: PrWorkflowMode, prHeadSha: string): Promise<PrWorkflowCompletionStatus>;
905
904
  export declare const _test_exports: {
906
- classifyTerminalFailureSignature: typeof classifyTerminalFailureSignature;
905
+ classifyPrReviewCircuitSignal: typeof classifyPrReviewCircuitSignal;
907
906
  minimumConsolidatedLaneCover: typeof minimumConsolidatedLaneCover;
908
907
  analyzePrReviewBatchRecordIntegrity: typeof analyzePrReviewBatchRecordIntegrity;
909
908
  MAX_COVER_UNIVERSE_BITS: number;