opencode-swarm 7.167.2 → 7.168.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 (102) hide show
  1. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  2. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  3. package/dist/cli/{coder-settlement-jy9rad28.js → coder-settlement-54a3d97g.js} +12 -12
  4. package/dist/cli/{config-doctor-p66vnpy3.js → config-doctor-vzp6b3ng.js} +3 -3
  5. package/dist/cli/{core-tw0wtntz.js → core-yynse50x.js} +2 -2
  6. package/dist/cli/{curation-policy-ndp27v0c.js → curation-policy-mgwv8h2k.js} +5 -5
  7. package/dist/cli/{curator-5nzde80g.js → curator-agdhhzqt.js} +38 -38
  8. package/dist/cli/{curator-drift-gb651hcw.js → curator-drift-k0zrnm09.js} +5 -5
  9. package/dist/cli/curator-llm-factory-ygxd6hfx.js +71 -0
  10. package/dist/cli/{evidence-summary-service-bzpfaypy.js → evidence-summary-service-6mmcekr7.js} +17 -17
  11. package/dist/cli/{gate-evidence-wa8cj8h6.js → gate-evidence-xqvkqhrk.js} +7 -7
  12. package/dist/cli/guardrail-explain-vjtjhgzs.js +72 -0
  13. package/dist/cli/{guardrail-log-7dv73e0q.js → guardrail-log-5wa5c77w.js} +8 -8
  14. package/dist/cli/{guardrail-reset-1kng6y8x.js → guardrail-reset-dh78tbcf.js} +38 -38
  15. package/dist/cli/{hive-promoter-87kk2pg5.js → hive-promoter-3czsx7c6.js} +38 -38
  16. package/dist/cli/{index-18rfc7qv.js → index-2xbww1x0.js} +7 -7
  17. package/dist/cli/{index-3ws11dq0.js → index-3jmb4ppa.js} +2 -2
  18. package/dist/cli/{index-79234evf.js → index-4kv1ew3q.js} +1 -1
  19. package/dist/cli/{index-vgpedapd.js → index-4r5pmtvk.js} +2 -2
  20. package/dist/cli/{index-rrne6g2m.js → index-5g6rhkn7.js} +6 -2
  21. package/dist/cli/{index-m7cwnt9r.js → index-5zqakgp4.js} +2 -2
  22. package/dist/cli/{index-m3z83nhs.js → index-6df6wbvj.js} +8 -8
  23. package/dist/cli/{index-0q839sg6.js → index-8ybjqg51.js} +1 -1
  24. package/dist/cli/{index-wjet7x0a.js → index-91ww9hyr.js} +1 -1
  25. package/dist/cli/{index-pdcperq5.js → index-9b2105n0.js} +2 -2
  26. package/dist/cli/{index-z6we1abx.js → index-a8xbvsse.js} +2 -2
  27. package/dist/cli/{index-2b1hd1fx.js → index-apy1qfj0.js} +13 -4
  28. package/dist/cli/{index-gmjg65tm.js → index-bvqqwx84.js} +2 -2
  29. package/dist/cli/{index-ce8p9t28.js → index-bw9x8d8n.js} +5 -5
  30. package/dist/cli/{index-dme7wvwg.js → index-chebm5h5.js} +4 -4
  31. package/dist/cli/{index-mtepgqan.js → index-dfyv3xkd.js} +7 -7
  32. package/dist/cli/{index-sjkg2hc4.js → index-f1fps3w9.js} +6 -6
  33. package/dist/cli/index-gh9ybrrs.js +2008 -0
  34. package/dist/cli/{index-3r6k6qa7.js → index-gmpmgtzn.js} +4 -4
  35. package/dist/cli/{index-83r0v5tn.js → index-gp9yzr1v.js} +1 -1
  36. package/dist/cli/{index-962qme08.js → index-h439y187.js} +1 -1
  37. package/dist/cli/{index-5sjq3shs.js → index-j0bxxz9d.js} +8 -8
  38. package/dist/cli/{index-8vbahc4c.js → index-kear8gb7.js} +11 -6
  39. package/dist/cli/{index-y1sj2e1n.js → index-kkmezerc.js} +2094 -1686
  40. package/dist/cli/{index-syedr4e3.js → index-m35hybf0.js} +1 -1
  41. package/dist/cli/{index-f8cc92g7.js → index-nwwk3dej.js} +1 -1
  42. package/dist/cli/{index-g409c7ke.js → index-pyf517sz.js} +2 -2
  43. package/dist/cli/{index-ehq2vtkq.js → index-q8091q8b.js} +4 -4
  44. package/dist/cli/{index-k73ehxa1.js → index-qhey6vc3.js} +1 -1
  45. package/dist/cli/{index-09gv90d7.js → index-qkwtth00.js} +2 -2
  46. package/dist/cli/{index-shrf0wt3.js → index-qthc56c4.js} +4 -4
  47. package/dist/cli/{index-gs12223x.js → index-qwsh0h2g.js} +2 -2
  48. package/dist/cli/{index-n4fzmqz8.js → index-rdm3px0g.js} +4 -2
  49. package/dist/cli/{index-g5m43paw.js → index-sxt7fgcw.js} +1 -0
  50. package/dist/cli/{index-x7pm61wk.js → index-v3xc4sde.js} +9 -8
  51. package/dist/cli/{index-arqv4psy.js → index-w1dfkp1q.js} +57 -101
  52. package/dist/cli/{index-25xeyjfx.js → index-w3x1dmrf.js} +38 -38
  53. package/dist/cli/{index-hhkm64wh.js → index-wst6n478.js} +103 -3
  54. package/dist/cli/{index-f91fhch0.js → index-xhb4gryr.js} +4 -4
  55. package/dist/cli/{index-s7a9dqtb.js → index-xkf3672y.js} +4 -3
  56. package/dist/cli/{index-jhd3pmd1.js → index-y85aptep.js} +7 -7
  57. package/dist/cli/{index-65s0vgb1.js → index-yt9n9zt3.js} +40 -40
  58. package/dist/cli/{index-tcj8v6my.js → index-z6qreakh.js} +6 -6
  59. package/dist/cli/index.js +38 -38
  60. package/dist/cli/{knowledge-escalator-5e4zxan5.js → knowledge-escalator-135dz4eh.js} +13 -13
  61. package/dist/cli/{knowledge-events-abzm5vfh.js → knowledge-events-27gwv47q.js} +11 -11
  62. package/dist/cli/{knowledge-link-9ga6hyd5.js → knowledge-link-dr3xnwyd.js} +4 -4
  63. package/dist/cli/{knowledge-store-q4a92eq7.js → knowledge-store-80m44bfw.js} +5 -5
  64. package/dist/cli/{knowledge-validator-pn3m5r41.js → knowledge-validator-crsfb2cc.js} +7 -7
  65. package/dist/cli/{model-preflight-mw895vgt.js → model-preflight-1ycat9jz.js} +1 -1
  66. package/dist/cli/{pending-delegations-3z0xjppd.js → pending-delegations-gwgjzzkz.js} +12 -12
  67. package/dist/cli/{pr-subscriptions-h7mwnp62.js → pr-subscriptions-g633nhz4.js} +12 -12
  68. package/dist/cli/{pr-workflow-gate-fec04fa0.js → pr-workflow-gate-4dc5nt2e.js} +38 -38
  69. package/dist/cli/{runner-d9833azt.js → runner-k0ycgv8x.js} +5 -5
  70. package/dist/cli/{scan-cursor-ymfvzdkz.js → scan-cursor-avxjsm4w.js} +6 -6
  71. package/dist/cli/{schema-chc4aez6.js → schema-3ja77k4y.js} +4 -2
  72. package/dist/cli/{scope-persistence-3xnr59y8.js → scope-persistence-f540tc50.js} +16 -16
  73. package/dist/cli/{skill-generator-3mvaghxk.js → skill-generator-kcqqpg1g.js} +15 -15
  74. package/dist/cli/{snapshot-coordination-init-arnc77r9.js → snapshot-coordination-init-e4s8bn4p.js} +38 -38
  75. package/dist/cli/{sqlite-loader-xrnf6bq8.js → sqlite-loader-amp9z7ty.js} +1 -1
  76. package/dist/cli/{telemetry-g9pppt9e.js → telemetry-2wzapf11.js} +1 -1
  77. package/dist/cli/{workspace-snapshot-hvsjtepd.js → workspace-snapshot-rkgxhj9b.js} +3 -3
  78. package/dist/cli/{worktree-collision-ownership-vj8anvb7.js → worktree-collision-ownership-rk9gz638.js} +13 -13
  79. package/dist/cli/{worktree-isolation-mt7z75hz.js → worktree-isolation-1bdzfgky.js} +38 -38
  80. package/dist/commands/reset.d.ts +10 -0
  81. package/dist/commands/rollback.d.ts +9 -0
  82. package/dist/config/schema.d.ts +29 -0
  83. package/dist/db/project-db.d.ts +8 -0
  84. package/dist/db/sqlite-loader.d.ts +2 -1
  85. package/dist/dispatch/spawn-circuit.d.ts +121 -0
  86. package/dist/dispatch/token-bucket.d.ts +46 -0
  87. package/dist/hooks/delegation-gate/dead-lane-reclaim.d.ts +61 -0
  88. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +22 -0
  89. package/dist/hooks/issue-trace.d.ts +3 -0
  90. package/dist/hooks/utils.d.ts +1 -1
  91. package/dist/index.js +657 -572
  92. package/dist/plan/ledger-sqlite.d.ts +226 -0
  93. package/dist/plan/ledger.d.ts +24 -0
  94. package/dist/plan/manager.d.ts +19 -0
  95. package/dist/retention/sweep.d.ts +2 -0
  96. package/dist/services/spec-drift-recovery.d.ts +2 -1
  97. package/dist/utils/ephemeral-session-teardown.d.ts +55 -2
  98. package/opencode-swarm.schema.json +41 -0
  99. package/package.json +1 -1
  100. package/dist/cli/curator-llm-factory-xy96x5x8.js +0 -71
  101. package/dist/cli/guardrail-explain-1ef5he6j.js +0 -72
  102. package/dist/cli/index-z7z3g5wt.js +0 -1017
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Low-level SQLite plan-ledger store (#2484).
3
+ *
4
+ * This module deliberately does not import `ledger.ts`. The file ledger and
5
+ * the SQLite ledger can therefore validate one another without creating a
6
+ * circular dependency. Callers provide canonical event bytes plus optional
7
+ * typed metadata; this store owns the SQL transaction and preserves the bytes
8
+ * exactly as supplied.
9
+ */
10
+ export type SqliteLedgerAuthorityMode = 'file_shadow' | 'sqlite';
11
+ export type SqliteLedgerParityStatus = 'pending' | 'clean' | 'diverged' | 'failed';
12
+ export type CanonicalEventBytes = Uint8Array | ArrayBuffer | string;
13
+ export interface SqliteLedgerEventMetadata {
14
+ seq: number;
15
+ timestamp: string;
16
+ planId: string;
17
+ eventType: string;
18
+ taskId: string | null;
19
+ phaseId: number | null;
20
+ fromStatus: string | null;
21
+ toStatus: string | null;
22
+ source: string;
23
+ planHashBefore: string;
24
+ planHashAfter: string;
25
+ schemaVersion: string;
26
+ eventHash: string;
27
+ rootEventHash: string | null;
28
+ planEpoch: string | null;
29
+ payloadHash: string | null;
30
+ payload: unknown;
31
+ }
32
+ export interface SqliteLedgerEventRow extends SqliteLedgerEventMetadata {
33
+ /** Exact canonical JSON bytes, excluding the JSONL line terminator. */
34
+ canonicalEvent: Uint8Array;
35
+ /** SQL-shaped aliases are useful to direct migration/diagnostic callers. */
36
+ canonical_event: Uint8Array;
37
+ event: unknown;
38
+ parsed: unknown;
39
+ }
40
+ export interface PlanLedgerState {
41
+ id: 1;
42
+ authorityMode: SqliteLedgerAuthorityMode;
43
+ shadowStartedVersion: string | null;
44
+ parityStatus: SqliteLedgerParityStatus;
45
+ fileReplayHash: string | null;
46
+ sqliteReplayHash: string | null;
47
+ terminalProjectionHash: string;
48
+ lastSeq: number;
49
+ lastEventHash: string | null;
50
+ rootEventHash: string | null;
51
+ planId: string | null;
52
+ planEpoch: string | null;
53
+ terminalPlanHash: string | null;
54
+ terminalProjection: Uint8Array | null;
55
+ terminalProjectionJson: string | null;
56
+ terminalMetadata: unknown;
57
+ updatedAt: string;
58
+ authority_mode: SqliteLedgerAuthorityMode;
59
+ shadow_started_version: string | null;
60
+ parity_status: SqliteLedgerParityStatus;
61
+ file_replay_hash: string | null;
62
+ sqlite_replay_hash: string | null;
63
+ terminal_projection_hash: string;
64
+ last_seq: number;
65
+ }
66
+ export interface SqliteLedgerImportRow {
67
+ source: string;
68
+ sourceHash: string;
69
+ archivePath: string | null;
70
+ archiveHash: string | null;
71
+ archiveSize: number | null;
72
+ archiveCreatedAt: string | null;
73
+ mode: string;
74
+ version: string | null;
75
+ rowCount: number;
76
+ importedAt: string;
77
+ }
78
+ export interface SqliteLedgerReadResult {
79
+ events: SqliteLedgerEventRow[];
80
+ state: PlanLedgerState | null;
81
+ import: SqliteLedgerImportRow | null;
82
+ }
83
+ export interface SqliteLedgerStateInput {
84
+ authorityMode?: SqliteLedgerAuthorityMode;
85
+ authority_mode?: SqliteLedgerAuthorityMode;
86
+ shadowStartedVersion?: string | null;
87
+ shadow_started_version?: string | null;
88
+ parityStatus?: SqliteLedgerParityStatus;
89
+ parity_status?: SqliteLedgerParityStatus;
90
+ fileReplayHash?: string | null;
91
+ file_replay_hash?: string | null;
92
+ sqliteReplayHash?: string | null;
93
+ sqlite_replay_hash?: string | null;
94
+ terminalProjectionHash?: string;
95
+ terminal_projection_hash?: string;
96
+ lastSeq?: number;
97
+ last_seq?: number;
98
+ lastEventHash?: string | null;
99
+ last_event_hash?: string | null;
100
+ rootEventHash?: string | null;
101
+ root_event_hash?: string | null;
102
+ planId?: string | null;
103
+ plan_id?: string | null;
104
+ planEpoch?: string | null;
105
+ plan_epoch?: string | null;
106
+ terminalPlanHash?: string | null;
107
+ terminal_plan_hash?: string | null;
108
+ terminalProjection?: CanonicalEventBytes | null;
109
+ terminal_projection?: CanonicalEventBytes | null;
110
+ terminalProjectionJson?: string | null;
111
+ terminal_projection_json?: string | null;
112
+ terminalMetadata?: unknown;
113
+ terminal_metadata?: unknown;
114
+ }
115
+ export interface SqliteLedgerCanonicalEventInput {
116
+ canonicalEvent?: CanonicalEventBytes;
117
+ canonical_event?: CanonicalEventBytes;
118
+ bytes?: CanonicalEventBytes;
119
+ event?: unknown;
120
+ metadata?: Partial<SqliteLedgerEventMetadata> & Record<string, unknown>;
121
+ seq?: number;
122
+ timestamp?: string;
123
+ plan_id?: string;
124
+ event_type?: string;
125
+ task_id?: string | null;
126
+ phase_id?: number | null;
127
+ from_status?: string | null;
128
+ to_status?: string | null;
129
+ source?: string;
130
+ plan_hash_before?: string;
131
+ plan_hash_after?: string;
132
+ schema_version?: string;
133
+ root_event_hash?: string | null;
134
+ plan_epoch?: string | null;
135
+ payload_hash?: string | null;
136
+ }
137
+ export interface SqliteLedgerImportInput {
138
+ canonicalEvents: Array<SqliteLedgerCanonicalEventInput | CanonicalEventBytes>;
139
+ state?: SqliteLedgerStateInput;
140
+ source?: string;
141
+ sourceHash?: string;
142
+ source_hash?: string;
143
+ archivePath?: string | null;
144
+ archive_path?: string | null;
145
+ archiveHash?: string | null;
146
+ archive_hash?: string | null;
147
+ archiveSize?: number | null;
148
+ archive_size?: number | null;
149
+ archiveCreatedAt?: string | null;
150
+ archive_created_at?: string | null;
151
+ mode?: string;
152
+ version?: string | null;
153
+ }
154
+ export interface SqliteLedgerAppendInput {
155
+ canonicalEvent: CanonicalEventBytes;
156
+ metadata?: Partial<SqliteLedgerEventMetadata> & Record<string, unknown>;
157
+ state?: SqliteLedgerStateInput;
158
+ expectedSeq?: number;
159
+ expected_seq?: number;
160
+ expectedHash?: string;
161
+ expected_hash?: string;
162
+ }
163
+ export interface SqliteLedgerParityInput {
164
+ fileReplayHash: string;
165
+ sqliteReplayHash: string;
166
+ terminalProjectionHash?: string;
167
+ parityStatus?: SqliteLedgerParityStatus;
168
+ file_replay_hash?: string;
169
+ sqlite_replay_hash?: string;
170
+ terminal_projection_hash?: string;
171
+ parity_status?: SqliteLedgerParityStatus;
172
+ }
173
+ export interface SqliteLedgerCutoverInput {
174
+ expectedShadowStartedVersion?: string;
175
+ expected_shadow_started_version?: string;
176
+ version?: string;
177
+ }
178
+ export declare class SqliteLedgerStaleWriterError extends Error {
179
+ constructor(message: string);
180
+ }
181
+ export declare class SqliteLedgerImportError extends Error {
182
+ constructor(message: string);
183
+ }
184
+ type DirectoryInput<T> = T & {
185
+ directory: string;
186
+ };
187
+ declare function bytesOf(value: CanonicalEventBytes): Uint8Array;
188
+ declare function sha256(bytes: Uint8Array): string;
189
+ declare function parseCanonical(bytes: Uint8Array): Record<string, unknown>;
190
+ declare function metadataFor(input: SqliteLedgerCanonicalEventInput, bytes: Uint8Array, parsed: Record<string, unknown>, index?: number): SqliteLedgerEventMetadata;
191
+ declare function normalizeEvent(value: SqliteLedgerCanonicalEventInput | CanonicalEventBytes, index?: number): {
192
+ bytes: Uint8Array;
193
+ parsed: Record<string, unknown>;
194
+ metadata: SqliteLedgerEventMetadata;
195
+ };
196
+ type StateDbRow = Record<string, unknown>;
197
+ declare function readStateFromRow(row: StateDbRow | null | undefined): PlanLedgerState | null;
198
+ export declare function hasSqliteLedger(directory: string): boolean;
199
+ export declare function getPlanLedgerState(directory: string): PlanLedgerState | null;
200
+ /** Read authority metadata without opening the writable project DB. */
201
+ export declare function getPlanLedgerStateReadOnly(directory: string): PlanLedgerState | null;
202
+ export declare function readSqliteLedgerEvents(directory: string): SqliteLedgerReadResult;
203
+ /** Read ledger rows without creating, migrating, journaling, or caching a DB. */
204
+ export declare function readSqliteLedgerEventsReadOnly(directory: string): SqliteLedgerReadResult;
205
+ export declare function appendSqliteLedger(directory: string, input: SqliteLedgerAppendInput): SqliteLedgerEventRow;
206
+ export declare function appendSqliteLedger(input: DirectoryInput<SqliteLedgerAppendInput>): SqliteLedgerEventRow;
207
+ export declare function importSqliteLedger(directory: string, input: SqliteLedgerImportInput): SqliteLedgerReadResult;
208
+ export declare function importSqliteLedger(input: DirectoryInput<SqliteLedgerImportInput>): SqliteLedgerReadResult;
209
+ export declare function replaceSqliteLedger(directory: string, input: SqliteLedgerImportInput): SqliteLedgerReadResult;
210
+ export declare function replaceSqliteLedger(input: DirectoryInput<SqliteLedgerImportInput>): SqliteLedgerReadResult;
211
+ export declare function recordSqliteLedgerParity(directory: string, input: SqliteLedgerParityInput): PlanLedgerState;
212
+ export declare function recordSqliteLedgerParity(input: DirectoryInput<SqliteLedgerParityInput>): PlanLedgerState;
213
+ export declare function cutoverSqliteLedger(directory: string, input?: SqliteLedgerCutoverInput): PlanLedgerState;
214
+ export declare function cutoverSqliteLedger(input: DirectoryInput<SqliteLedgerCutoverInput>): PlanLedgerState;
215
+ export declare function clearSqliteLedger(directory: string): void;
216
+ /** Internal seams are intentionally narrow: fault injection can wrap a named
217
+ * transaction boundary without mocking the runtime-portable SQLite loader. */
218
+ export declare const _sqliteInternals: {
219
+ bytesOf: typeof bytesOf;
220
+ parseCanonical: typeof parseCanonical;
221
+ sha256: typeof sha256;
222
+ metadataFor: typeof metadataFor;
223
+ readStateFromRow: typeof readStateFromRow;
224
+ normalizeEvent: typeof normalizeEvent;
225
+ };
226
+ export {};
@@ -111,6 +111,11 @@ declare function readLedgerDirectory(directory: string): string[];
111
111
  */
112
112
  declare function writeFileFsyncedThenRename(tempPath: string, targetPath: string, data: string | Uint8Array): void;
113
113
  declare function fsyncRecoveryDirectory(directory: string): void;
114
+ declare function writePortableLedger(directory: string, lines: Uint8Array[]): void;
115
+ declare function archiveLegacyLedger(directory: string, bytes: Buffer): {
116
+ path: string;
117
+ hash: string;
118
+ };
114
119
  /**
115
120
  * Compute a SHA-256 digest of the FULL plan state for the ledger hash chain.
116
121
  * Uses deterministic JSON serialization for consistent hashing.
@@ -353,6 +358,14 @@ export declare function replaceTruncatedLedgerWithRecoveryRoot(directory: string
353
358
  seq: number;
354
359
  ledgerHash: string;
355
360
  }): Promise<TruncatedLedgerRecoveryResult>;
361
+ /** Clear authoritative plan-ledger rows after the reset command has archived them. */
362
+ export declare function clearPlanLedgerForReset(directory: string): Promise<void>;
363
+ /**
364
+ * Re-root the authoritative history for an explicit checkpoint rollback.
365
+ * Existing JSONL bytes are content-addressed before the SQLite transaction;
366
+ * the portable export is published only after the new SQLite root commits.
367
+ */
368
+ export declare function replacePlanLedgerWithRoot(directory: string, plan: Plan, source: string): Promise<void>;
356
369
  /**
357
370
  * Options for replayFromLedger
358
371
  */
@@ -395,6 +408,14 @@ export interface ReplayStatusResult {
395
408
  * @returns Reconstructed Plan from ledger events, or null if plan.json doesn't exist or ledger is empty
396
409
  */
397
410
  export declare function replayFromLedger(directory: string, options?: ReplayOptions): Promise<Plan | null>;
411
+ /**
412
+ * Reconstruct a plan without repairing either ledger authority or its
413
+ * projections. This is deliberately separate from `replayFromLedgerWithStatus`:
414
+ * ordinary replay coordinates the file/SQLite shadows and quarantines corrupted
415
+ * suffixes, both of which are writes. Lifecycle previews need a strictly
416
+ * observational view even when plan.json is missing.
417
+ */
418
+ export declare function peekPlanFromLedger(directory: string, _options?: ReplayOptions): Promise<ReplayStatusResult>;
398
419
  /**
399
420
  * Replay ledger events to reconstruct plan state, threading the integrity
400
421
  * verdict back to the caller.
@@ -564,6 +585,7 @@ export declare const _internals: {
564
585
  takeSnapshotEvent: typeof takeSnapshotEvent;
565
586
  replayFromLedger: typeof replayFromLedger;
566
587
  replayFromLedgerWithStatus: typeof replayFromLedgerWithStatus;
588
+ peekPlanFromLedger: typeof peekPlanFromLedger;
567
589
  applyEventToPlan: typeof applyEventToPlan;
568
590
  readLedgerEventsWithIntegrity: typeof readLedgerEventsWithIntegrity;
569
591
  quarantineLedgerSuffix: typeof quarantineLedgerSuffix;
@@ -571,6 +593,8 @@ export declare const _internals: {
571
593
  loadLastPlanCriticApprovedSnapshot: typeof loadLastPlanCriticApprovedSnapshot;
572
594
  getLedgerPath: typeof getLedgerPath;
573
595
  getPlanJsonPath: typeof getPlanJsonPath;
596
+ archiveLegacyLedger: typeof archiveLegacyLedger;
597
+ writePortableLedger: typeof writePortableLedger;
574
598
  writeFileFsyncedThenRename: typeof writeFileFsyncedThenRename;
575
599
  fsyncRecoveryDirectory: typeof fsyncRecoveryDirectory;
576
600
  readLedgerDirectory: typeof readLedgerDirectory;
@@ -59,6 +59,8 @@ export declare function resetStartupLedgerCheck(): void;
59
59
  export declare const _internals: {
60
60
  loadPlan: typeof loadPlan;
61
61
  loadPlanJsonOnly: typeof loadPlanJsonOnly;
62
+ readPlanJsonUtf8: typeof readPlanJsonUtf8;
63
+ readPlanFileUtf8: typeof readPlanFileUtf8;
62
64
  regeneratePlanMarkdown: typeof regeneratePlanMarkdown;
63
65
  isGitRepo: typeof isGitRepo;
64
66
  isEpicModeActiveForProject: typeof isEpicModeActiveForProject;
@@ -93,6 +95,13 @@ export declare function retryCasWithBackoff(directory: string, eventInput: Ledge
93
95
  * Use this when you want to check for structured plans without triggering migration.
94
96
  */
95
97
  export declare function loadPlanJsonOnly(directory: string): Promise<Plan | null>;
98
+ /**
99
+ * Read the canonical plan projection with fatal UTF-8 decoding. A literal U+FFFD
100
+ * in valid UTF-8 is data and must survive; only malformed byte sequences are
101
+ * rejected by the decoder. ENOENT is the normal projection-missing signal.
102
+ */
103
+ declare function readPlanJsonUtf8(directory: string): Promise<string | null>;
104
+ declare function readPlanFileUtf8(filePath: string): Promise<string>;
96
105
  /**
97
106
  * Check if plan.md is derived from the given plan by comparing content hashes.
98
107
  * Returns true if plan.md exists and matches the plan's content hash.
@@ -137,6 +146,15 @@ export declare function savePlanWithAutoAcknowledgedRemovals(directory: string,
137
146
  }): Promise<{
138
147
  removedCount: number;
139
148
  }>;
149
+ /**
150
+ * Serialize a lifecycle transition with all regular plan writers.
151
+ *
152
+ * Lock ordering is intentionally `plan.json` then `plan-ledger`: `savePlan`
153
+ * already acquires the plan lock before it reaches any ledger operation. Reset
154
+ * and rollback must use the same order or a writer can resurrect a projection
155
+ * after authority has changed (or deadlock by taking the locks in reverse).
156
+ */
157
+ export declare function withPlanLifecycleLock<T>(directory: string, taskId: string, fn: () => Promise<T>): Promise<T>;
140
158
  /**
141
159
  * Validate against PlanSchema (throw on invalid), write to .swarm/plan.json via atomic temp+rename pattern,
142
160
  * then derive and write .swarm/plan.md
@@ -246,3 +264,4 @@ export declare function getCurrentTaskId(plan: Plan | null | undefined): string
246
264
  * Convert existing plan.md to plan.json. PURE function — no I/O.
247
265
  */
248
266
  export declare function migrateLegacyPlan(planContent: string, swarmId?: string): Plan;
267
+ export {};
@@ -34,6 +34,8 @@ export declare const EVOLUTION_BACKSTOP_AGE_DAYS = 90;
34
34
  export declare const PR_REVIEW_KEEP_NEWEST_RUNS = 50;
35
35
  export declare const LANE_RESULTS_KEEP_NEWEST_BATCHES = 100;
36
36
  export declare const REVIEW_RECEIPTS_KEEP_NEWEST = 1000;
37
+ /** Legacy plan-ledger imports are forensic only; keep a bounded recent window. */
38
+ export declare const LEGACY_LEDGER_ARCHIVES_KEEP_NEWEST = 16;
37
39
  export interface RetentionSweepOptions {
38
40
  /** Clock injection point for tests/checks. */
39
41
  now?: number;
@@ -1,6 +1,6 @@
1
1
  import { validateSwarmPath } from '../hooks/utils.js';
2
2
  import { tryAcquireLock } from '../parallel/file-locks.js';
3
- import { takeSnapshotEvent } from '../plan/ledger.js';
3
+ import { readLedgerEvents, takeSnapshotEvent } from '../plan/ledger.js';
4
4
  import { loadPlanJsonOnly, savePlan } from '../plan/manager.js';
5
5
  import { readEffectiveSpecSync } from '../sdd/effective-spec.js';
6
6
  import type { SpecDriftAcknowledgedEvent, SpecDriftRepairedEvent } from '../types/events.js';
@@ -52,6 +52,7 @@ export declare const _internals: {
52
52
  parseMarker: typeof parseMarker;
53
53
  parseWal: typeof parseWal;
54
54
  readEffectiveSpecSync: typeof readEffectiveSpecSync;
55
+ readLedgerEvents: typeof readLedgerEvents;
55
56
  readFileText: typeof readFileText;
56
57
  savePlan: typeof savePlan;
57
58
  tryAcquireLock: typeof tryAcquireLock;
@@ -44,6 +44,16 @@ export interface EphemeralSessionLifecycle {
44
44
  id: string;
45
45
  };
46
46
  }) => Promise<unknown>;
47
+ /**
48
+ * Read the session back (issue #2599). Used by `teardownEphemeralSessionVerified`
49
+ * as the bounded existence check; optional because some shims lack it —
50
+ * absence degrades verification to a typed unverified result.
51
+ */
52
+ get?: (args: {
53
+ path: {
54
+ id: string;
55
+ };
56
+ }) => Promise<unknown>;
47
57
  }
48
58
  export declare const DEFAULT_EPHEMERAL_ABORT_TIMEOUT_MS = 5000;
49
59
  export declare const DEFAULT_EPHEMERAL_TEARDOWN_DELETE_TIMEOUT_MS = 2000;
@@ -85,14 +95,57 @@ export declare function boundedDeleteEphemeralSession(session: EphemeralSessionL
85
95
  * Callers that need cleanup guaranteed before they return should `await` this.
86
96
  * Fire-and-forget callers may `void` it — the abort→delete ordering still holds
87
97
  * inside the unit, so the FK race is closed regardless; only the caller's own
88
- * completion timing is detached (process exit before completion leaks a
89
- * session, same as the prior fire-and-forget delete, and is harmless).
98
+ * completion timing is detached. A caller that exits before completion leaks
99
+ * the session. For a lane-directory child session that leak is NOT harmless:
100
+ * the leaked session's plugin activity keeps the lane's `swarm.db` WAL handle
101
+ * open, which locks the lane directory against deletion on Windows (issue
102
+ * #2599) — those callers must use `teardownEphemeralSessionVerified`, which
103
+ * confirms the session actually died and returns a typed failure when it
104
+ * survives.
90
105
  */
91
106
  export declare function teardownEphemeralSession(session: EphemeralSessionLifecycle, sessionId: string, options?: TeardownEphemeralSessionOptions): Promise<void>;
107
+ export declare const DEFAULT_EPHEMERAL_VERIFY_TIMEOUT_MS = 2000;
108
+ export declare const DEFAULT_EPHEMERAL_MAX_DELETE_ATTEMPTS = 3;
109
+ export interface TeardownEphemeralSessionVerifiedOptions extends TeardownEphemeralSessionOptions {
110
+ /** Bounded timeout for the post-delete existence check (`session.get`). */
111
+ verifyTimeoutMs?: number;
112
+ /**
113
+ * Total bounded delete attempts (initial + retries) when the session
114
+ * survives the first delete. Bounded to [2, 6].
115
+ */
116
+ maxDeleteAttempts?: number;
117
+ }
118
+ export type EphemeralTeardownVerification = {
119
+ ok: true;
120
+ sessionId: string;
121
+ attempts: number;
122
+ } | {
123
+ ok: false;
124
+ sessionId: string;
125
+ attempts: number;
126
+ /** Stable marker for telemetry/routing; see issue #2599 AC3. */
127
+ kind: 'ephemeral-session-teardown-unverified';
128
+ reason: string;
129
+ };
130
+ /**
131
+ * Bounded existence check via `session.get`. `get` throwing (session-gone
132
+ * errors surface as rejections on the SDK surface) or returning an empty body
133
+ * both mean the session is gone (mirrors the reason-forwarding resolver
134
+ * precedent in `src/hooks/pr-workflow-session-resolver.ts`).
135
+ */
136
+ declare function sessionExists(session: EphemeralSessionLifecycle, sessionId: string, verifyTimeoutMs: number): Promise<boolean>;
137
+ /**
138
+ * Verified teardown (issue #2599): bounded abort → bounded delete → bounded
139
+ * existence check, retrying the delete a bounded number of times when the
140
+ * session survives, and returning a typed `ephemeral-session-teardown-unverified`
141
+ * failure when it still does. Never throws; the caller decides how to escalate.
142
+ */
143
+ export declare function teardownEphemeralSessionVerified(session: EphemeralSessionLifecycle, sessionId: string, options?: TeardownEphemeralSessionVerifiedOptions): Promise<EphemeralTeardownVerification>;
92
144
  export declare const _internals: {
93
145
  boundedSessionCall: typeof boundedSessionCall;
94
146
  boundedAbort: typeof boundedAbortEphemeralSession;
95
147
  boundedDelete: typeof boundedDeleteEphemeralSession;
148
+ sessionExists: typeof sessionExists;
96
149
  log: typeof log;
97
150
  };
98
151
  export {};
@@ -386,6 +386,41 @@
386
386
  },
387
387
  "additionalProperties": false
388
388
  },
389
+ "dispatch_protection": {
390
+ "description": "Dispatch protection: action-local spawn-failure circuit breaker and token-bucket rate limiting for native task delegations.",
391
+ "type": "object",
392
+ "properties": {
393
+ "enabled": {
394
+ "default": true,
395
+ "type": "boolean"
396
+ },
397
+ "spawn_failure_threshold": {
398
+ "default": 3,
399
+ "type": "integer",
400
+ "minimum": 1,
401
+ "maximum": 50
402
+ },
403
+ "half_open_after_ms": {
404
+ "default": 30000,
405
+ "type": "integer",
406
+ "minimum": 1,
407
+ "maximum": 3600000
408
+ },
409
+ "rate_per_second": {
410
+ "default": 10,
411
+ "type": "number",
412
+ "minimum": 0,
413
+ "maximum": 10000
414
+ },
415
+ "burst_capacity": {
416
+ "default": 10,
417
+ "type": "integer",
418
+ "minimum": 1,
419
+ "maximum": 10000
420
+ }
421
+ },
422
+ "additionalProperties": false
423
+ },
389
424
  "pr_review_legacy_transcript_compatibility": {
390
425
  "description": "Deprecated migration-only opt-in for transcript-row PR-review base and micro discovery lanes.",
391
426
  "type": "boolean"
@@ -4162,6 +4197,12 @@
4162
4197
  "exclusiveMinimum": 0,
4163
4198
  "maximum": 9007199254740991
4164
4199
  },
4200
+ "session_create_timeout_ms": {
4201
+ "default": 30000,
4202
+ "type": "integer",
4203
+ "minimum": 1000,
4204
+ "maximum": 120000
4205
+ },
4165
4206
  "runtime_isolation": {
4166
4207
  "type": "object",
4167
4208
  "properties": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.167.2",
3
+ "version": "7.168.1",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,71 +0,0 @@
1
- // @bun
2
- import {
3
- createCuratorLLMDelegate
4
- } from "./index-y1sj2e1n.js";
5
- import"./index-d5qf7hvh.js";
6
- import"./index-k73ehxa1.js";
7
- import"./index-dme7wvwg.js";
8
- import"./index-f8cc92g7.js";
9
- import"./index-rrne6g2m.js";
10
- import"./index-arqv4psy.js";
11
- import"./index-83r0v5tn.js";
12
- import"./index-txdagbh7.js";
13
- import"./index-9br68j86.js";
14
- import"./index-cw912re7.js";
15
- import"./index-f91fhch0.js";
16
- import"./index-ce8p9t28.js";
17
- import"./index-pdcperq5.js";
18
- import"./index-fyfbpz4f.js";
19
- import"./index-mtepgqan.js";
20
- import"./index-zsrtt42s.js";
21
- import"./index-5sjq3shs.js";
22
- import"./index-m7cwnt9r.js";
23
- import"./index-gmjg65tm.js";
24
- import"./index-b43rt5ph.js";
25
- import"./index-q7sjgr1y.js";
26
- import"./index-3r6k6qa7.js";
27
- import"./index-09gv90d7.js";
28
- import"./index-sjkg2hc4.js";
29
- import"./index-m3z83nhs.js";
30
- import"./index-8vbahc4c.js";
31
- import"./index-p612v1mv.js";
32
- import"./index-shrf0wt3.js";
33
- import"./index-syedr4e3.js";
34
- import"./index-rtry5xyf.js";
35
- import"./index-s7a9dqtb.js";
36
- import"./index-3qf1vxtb.js";
37
- import"./index-n832052r.js";
38
- import"./index-jhd3pmd1.js";
39
- import"./index-z7z3g5wt.js";
40
- import"./index-z6we1abx.js";
41
- import"./index-g409c7ke.js";
42
- import"./index-962qme08.js";
43
- import"./index-hhkm64wh.js";
44
- import"./index-n4fzmqz8.js";
45
- import"./index-ry16d01s.js";
46
- import"./index-gs12223x.js";
47
- import"./index-18rfc7qv.js";
48
- import"./index-vzm6zre7.js";
49
- import"./index-ae75rja9.js";
50
- import"./index-0q839sg6.js";
51
- import"./index-vgpedapd.js";
52
- import"./index-7g4c7s5r.js";
53
- import"./index-x7pm61wk.js";
54
- import"./index-tcj8v6my.js";
55
- import"./index-1xnse449.js";
56
- import"./index-ee6ydtfe.js";
57
- import"./index-wjet7x0a.js";
58
- import"./index-0mhftbpp.js";
59
- import"./index-a1w58b47.js";
60
- import"./index-2b1hd1fx.js";
61
- import"./index-g5m43paw.js";
62
- import"./index-bk5tah7q.js";
63
- import"./index-bpmtbmy9.js";
64
- import"./index-zpsr8rpc.js";
65
- import"./index-q1r1cfww.js";
66
- import"./index-yzjaj53h.js";
67
- import"./index-zgwm4ryv.js";
68
- import"./index-a76rekgs.js";
69
- export {
70
- createCuratorLLMDelegate
71
- };
@@ -1,72 +0,0 @@
1
- // @bun
2
- import {
3
- handleGuardrailExplain
4
- } from "./index-3ws11dq0.js";
5
- import"./index-y1sj2e1n.js";
6
- import"./index-d5qf7hvh.js";
7
- import"./index-k73ehxa1.js";
8
- import"./index-dme7wvwg.js";
9
- import"./index-f8cc92g7.js";
10
- import"./index-rrne6g2m.js";
11
- import"./index-arqv4psy.js";
12
- import"./index-83r0v5tn.js";
13
- import"./index-txdagbh7.js";
14
- import"./index-9br68j86.js";
15
- import"./index-cw912re7.js";
16
- import"./index-f91fhch0.js";
17
- import"./index-ce8p9t28.js";
18
- import"./index-pdcperq5.js";
19
- import"./index-fyfbpz4f.js";
20
- import"./index-mtepgqan.js";
21
- import"./index-zsrtt42s.js";
22
- import"./index-5sjq3shs.js";
23
- import"./index-m7cwnt9r.js";
24
- import"./index-gmjg65tm.js";
25
- import"./index-b43rt5ph.js";
26
- import"./index-q7sjgr1y.js";
27
- import"./index-3r6k6qa7.js";
28
- import"./index-09gv90d7.js";
29
- import"./index-sjkg2hc4.js";
30
- import"./index-m3z83nhs.js";
31
- import"./index-8vbahc4c.js";
32
- import"./index-p612v1mv.js";
33
- import"./index-shrf0wt3.js";
34
- import"./index-syedr4e3.js";
35
- import"./index-rtry5xyf.js";
36
- import"./index-s7a9dqtb.js";
37
- import"./index-3qf1vxtb.js";
38
- import"./index-n832052r.js";
39
- import"./index-jhd3pmd1.js";
40
- import"./index-z7z3g5wt.js";
41
- import"./index-z6we1abx.js";
42
- import"./index-g409c7ke.js";
43
- import"./index-962qme08.js";
44
- import"./index-hhkm64wh.js";
45
- import"./index-n4fzmqz8.js";
46
- import"./index-ry16d01s.js";
47
- import"./index-gs12223x.js";
48
- import"./index-18rfc7qv.js";
49
- import"./index-vzm6zre7.js";
50
- import"./index-ae75rja9.js";
51
- import"./index-0q839sg6.js";
52
- import"./index-vgpedapd.js";
53
- import"./index-7g4c7s5r.js";
54
- import"./index-x7pm61wk.js";
55
- import"./index-tcj8v6my.js";
56
- import"./index-1xnse449.js";
57
- import"./index-ee6ydtfe.js";
58
- import"./index-wjet7x0a.js";
59
- import"./index-0mhftbpp.js";
60
- import"./index-a1w58b47.js";
61
- import"./index-2b1hd1fx.js";
62
- import"./index-g5m43paw.js";
63
- import"./index-bk5tah7q.js";
64
- import"./index-bpmtbmy9.js";
65
- import"./index-zpsr8rpc.js";
66
- import"./index-q1r1cfww.js";
67
- import"./index-yzjaj53h.js";
68
- import"./index-zgwm4ryv.js";
69
- import"./index-a76rekgs.js";
70
- export {
71
- handleGuardrailExplain
72
- };