opencode-swarm 7.153.1 → 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 (76) 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-ze21qs6b.js → config-doctor-8p9y543t.js} +2 -2
  4. package/dist/cli/{core-qdmhh1kx.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-s8atmc2n.js → curator-llm-factory-ypwf3a90.js} +29 -29
  7. package/dist/cli/{curator-hxb3wsxr.js → curator-yj00z1qz.js} +29 -29
  8. package/dist/cli/{evidence-summary-service-wzzym9r7.js → evidence-summary-service-npq04240.js} +12 -12
  9. package/dist/cli/{gate-evidence-f71dn9vv.js → gate-evidence-4b6t0ycn.js} +6 -6
  10. package/dist/cli/{guardrail-explain-5kzeem4m.js → guardrail-explain-dyxbhrdj.js} +30 -30
  11. package/dist/cli/{guardrail-log-38jnajpa.js → guardrail-log-eyecsekk.js} +5 -5
  12. package/dist/cli/{guardrail-reset-wzvtmpn2.js → guardrail-reset-269jdwhd.js} +29 -29
  13. package/dist/cli/{hive-promoter-55qcqgfx.js → hive-promoter-5936am48.js} +29 -29
  14. package/dist/cli/{index-0tyc8kdg.js → index-10zvxqra.js} +1 -1
  15. package/dist/cli/{index-6ybjrqf7.js → index-1tdsddab.js} +284 -107
  16. package/dist/cli/{index-23rneydq.js → index-2kzxkx50.js} +31 -31
  17. package/dist/cli/{index-tdzbm974.js → index-2mbs5q26.js} +108 -8
  18. package/dist/cli/{index-x3y6zhgj.js → index-3db7xza0.js} +1 -1
  19. package/dist/cli/{index-gn26q90p.js → index-3hdnfmhp.js} +2 -2
  20. package/dist/cli/{index-0tzv5zg2.js → index-3mhgv8d6.js} +2 -2
  21. package/dist/cli/{index-6vgb5fyb.js → index-48m4841x.js} +1 -1
  22. package/dist/cli/{index-mb7b1gye.js → index-4g00jhbs.js} +3 -3
  23. package/dist/cli/{index-1akn19mp.js → index-4y7g04py.js} +1 -1
  24. package/dist/cli/{index-n5pxkera.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-af0cqe6n.js → index-dwh02jmv.js} +7 -7
  30. package/dist/cli/{index-3cegckkq.js → index-garsang6.js} +1 -1
  31. package/dist/cli/{index-k10qtq71.js → index-hk4wa0v1.js} +6 -6
  32. package/dist/cli/{index-8v9sj4aq.js → index-mddgkqg9.js} +2 -2
  33. package/dist/cli/{index-4g0g3dqz.js → index-nkr634n6.js} +1 -1
  34. package/dist/cli/{index-ajkxx2k6.js → index-p4y7jefb.js} +2 -2
  35. package/dist/cli/{index-xkjrg9k4.js → index-pcj7jk4t.js} +3 -3
  36. package/dist/cli/{index-v689bmr2.js → index-qcz4xprd.js} +4 -4
  37. package/dist/cli/{index-zppxpc3y.js → index-s0a4ewkb.js} +2 -2
  38. package/dist/cli/{index-1dtshrzg.js → index-s70tmqn3.js} +5 -5
  39. package/dist/cli/{index-smqsp8hs.js → index-snnps1vm.js} +5 -5
  40. package/dist/cli/{index-n823qsae.js → index-tnm9bb8b.js} +11 -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-9v8d3c0k.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-w05ztgvk.js → knowledge-escalator-bxpzeth0.js} +11 -11
  49. package/dist/cli/{knowledge-events-pwm9jc0m.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-4xv65tj2.js → knowledge-store-336hyzs8.js} +6 -6
  52. package/dist/cli/{knowledge-validator-0ttfsca7.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-b6n15w8d.js → scan-cursor-3xxqtxwx.js} +7 -7
  57. package/dist/cli/{schema-jkbfwqr2.js → schema-jdx83m4m.js} +1 -1
  58. package/dist/cli/{scope-persistence-5xt2m5ep.js → scope-persistence-wgxn2kba.js} +8 -8
  59. package/dist/cli/{skill-generator-3keadpf7.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-1ymaxn4h.js → worktree-isolation-peb4bkg3.js} +29 -29
  63. package/dist/commands/pr-monitor-status.d.ts +8 -1
  64. package/dist/commands/registry.d.ts +1 -1
  65. package/dist/commands/reset-session.d.ts +8 -2
  66. package/dist/config/schema.d.ts +8 -0
  67. package/dist/hooks/knowledge-application-gate.d.ts +10 -1
  68. package/dist/hooks/knowledge-receipt-ledger.d.ts +1 -1
  69. package/dist/hooks/pr-review-resilience-circuit.d.ts +232 -0
  70. package/dist/hooks/pr-workflow-gate.d.ts +10 -11
  71. package/dist/index.js +249 -240
  72. package/dist/observability/catalog.d.ts +6 -3
  73. package/dist/state.d.ts +6 -4
  74. package/dist/telemetry.d.ts +21 -1
  75. package/package.json +7 -1
  76. 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.
@@ -845,7 +845,7 @@ export declare const COMMAND_REGISTRY: {
845
845
  readonly 'reset-session': {
846
846
  readonly handler: (ctx: CommandContext) => Promise<string>;
847
847
  readonly description: "Clear session state while preserving plan, evidence, and knowledge";
848
- readonly details: "Deletes only .swarm/session/state.json and any other session files. Clears in-memory agent sessions, delegation chains, and active-agent mappings. Preserves plan, evidence, and knowledge for cross-session continuity. Also recovers stale coder settlements, releasing in-flight ownership held by this process, so dispatches cannot stay wedged on CODER_DISPATCH_IN_PROGRESS (issue #2268). Before deleting, auto-backs up the session files it removes to .swarm/reset-backups/<timestamp>/ (newest 5 kept).";
848
+ readonly details: "Deletes only .swarm/session/state.json and other session files. Clears in-memory agent sessions, delegation chains, and active-agent mappings. Preserves plan, evidence, and knowledge. Also releases this session's pending knowledge-gate obligations (#2398) and recovers stale coder settlements so dispatches cannot wedge on CODER_DISPATCH_IN_PROGRESS (#2268). Auto-backs up removed files to .swarm/reset-backups/ (newest 5 kept).";
849
849
  readonly args: "";
850
850
  readonly category: "utility";
851
851
  readonly toolPolicy: "restricted";
@@ -1,3 +1,4 @@
1
+ import { commitGateReleaseBatch, queryLiveMemberships } from '../hooks/knowledge-receipt-ledger';
1
2
  import { recoverStaleCoderSettlements } from '../workflow/coder-settlement.js';
2
3
  import { type OrphanCleanupResult } from '../worktree/merge';
3
4
  import { type ResetBackupResult } from './reset-backup';
@@ -11,11 +12,16 @@ export declare const _internals: {
11
12
  cleanupOrphanedBranches: (directory: string, activeSessionIds: string[]) => Promise<OrphanCleanupResult>;
12
13
  backupSwarmStateBeforeReset: (directory: string, kind: 'reset' | 'reset-session', relEntries: string[]) => ResetBackupResult;
13
14
  recoverStaleCoderSettlements: typeof recoverStaleCoderSettlements;
15
+ queryLiveMemberships: typeof queryLiveMemberships;
16
+ commitGateReleaseBatch: typeof commitGateReleaseBatch;
17
+ releaseKnowledgeGateObligations: (directory: string, sessionID: string) => Promise<string[]>;
14
18
  };
15
19
  /**
16
20
  * Handles the /swarm reset-session command.
17
21
  * Deletes only the session state file (.swarm/session/state.json)
18
22
  * and clears in-memory agent sessions. Preserves plan, evidence,
19
- * and knowledge for continuity across sessions.
23
+ * and knowledge for continuity across sessions — but DOES release this
24
+ * session's pending knowledge-application gate obligations (issue #2398) so
25
+ * the reset is a real escape from an enforce-mode lockout.
20
26
  */
21
- export declare function handleResetSessionCommand(directory: string, _args: string[]): Promise<string>;
27
+ export declare function handleResetSessionCommand(directory: string, _args: string[], sessionID?: string): Promise<string>;
@@ -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<{
@@ -30,13 +30,22 @@
30
30
  * - update_task_status
31
31
  * - phase_complete
32
32
  * - Task (delegations to coder/reviewer/test_engineer/sme/docs/designer)
33
+ * - skill_regenerate
34
+ * - skill_retire
33
35
  *
34
36
  * Non-architect agents are never gated.
35
37
  */
36
38
  import { type KnowledgeApplicationConfig } from './knowledge-application.js';
37
39
  import { type ReceiptMembership } from './knowledge-receipt-ledger.js';
38
40
  import type { MessageWithParts } from './knowledge-types.js';
39
- /** Tools that require knowledge-directive acknowledgment before execution. */
41
+ /**
42
+ * Fallback set used only when `config.high_risk_tools` is absent. The parsed
43
+ * config schema (`KnowledgeApplicationConfigSchema`) defaults
44
+ * `high_risk_tools` to a 5-tool list (save_plan, update_task_status,
45
+ * phase_complete, task, Task) that is always populated post-parse, so this
46
+ * constant is shadowed in practice and `skill_regenerate` / `skill_retire`
47
+ * are NOT gated unless the operator's config lists them explicitly.
48
+ */
40
49
  export declare const HIGH_RISK_TOOLS: Set<string>;
41
50
  export interface GateInput {
42
51
  tool: unknown;
@@ -27,7 +27,7 @@ export declare const RECEIPT_TERMINAL_OUTCOMES: ReadonlySet<ReceiptOutcome>;
27
27
  * preserved as `'unknown'` and is never coerced to delegate, ignored, or any
28
28
  * other class. New producers must stamp one of the closed values below.
29
29
  */
30
- export type ReceiptSourceCode = 'delegate' | 'reviewer' | 'architect' | 'architect_marker' | 'test_engineer' | 'phase_override' | 'application_gate_staleness_release' | 'application_gate_denial_limit_release' | 'manual' | 'migration' | 'unknown';
30
+ export type ReceiptSourceCode = 'delegate' | 'reviewer' | 'architect' | 'architect_marker' | 'test_engineer' | 'phase_override' | 'application_gate_staleness_release' | 'application_gate_denial_limit_release' | 'application_gate_session_reset_release' | 'manual' | 'migration' | 'unknown';
31
31
  /** Closed set form of {@link ReceiptSourceCode}. */
32
32
  export declare const CANONICAL_RECEIPT_SOURCES: ReadonlySet<string>;
33
33
  /**
@@ -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;