opencode-swarm 7.164.11 → 7.164.12

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 (107) hide show
  1. package/.opencode/skills/engineering-conventions/SKILL.md +1 -1
  2. package/dist/background/pending-delegations.d.ts +7 -2
  3. package/dist/background/pr-subscriptions.d.ts +3 -3
  4. package/dist/cli/{coder-settlement-0rfk8y11.js → coder-settlement-yh1q5fr3.js} +15 -16
  5. package/dist/cli/{config-doctor-j17b7qq2.js → config-doctor-bd4yzmh7.js} +3 -3
  6. package/dist/cli/{core-evhjjrtt.js → core-y0s1vmyc.js} +2 -2
  7. package/dist/cli/{curation-policy-vj6z5hvr.js → curation-policy-gs1qakn7.js} +5 -6
  8. package/dist/cli/{curator-vqd5yeck.js → curator-brqack0j.js} +48 -46
  9. package/dist/cli/{curator-drift-ez81vg2t.js → curator-drift-1sg9yk2m.js} +14 -12
  10. package/dist/cli/curator-llm-factory-dtsjc3zf.js +70 -0
  11. package/dist/cli/{dispatch-dqybvj8v.js → dispatch-c7xjt7js.js} +3 -3
  12. package/dist/cli/{evidence-summary-service-937x7rbg.js → evidence-summary-service-nqbcvp30.js} +24 -23
  13. package/dist/cli/{gate-evidence-q1cehr4k.js → gate-evidence-9stdtpej.js} +9 -10
  14. package/dist/cli/guardrail-explain-3ff1z3fm.js +71 -0
  15. package/dist/cli/{guardrail-log-3g93f3g2.js → guardrail-log-sf39x00b.js} +10 -10
  16. package/dist/cli/{guardrail-reset-qe2r5qzq.js → guardrail-reset-9wr6a60s.js} +48 -46
  17. package/dist/cli/hive-promoter-bqtj8261.js +85 -0
  18. package/dist/cli/{index-kv2tdkk5.js → index-03enxdaq.js} +1 -1
  19. package/dist/cli/{index-ggrp3v00.js → index-0byep4pe.js} +15 -17
  20. package/dist/cli/{index-2bgr671r.js → index-2bhz5k91.js} +20 -2
  21. package/dist/cli/{index-mmjamc9b.js → index-3fnym6ac.js} +5 -5
  22. package/dist/cli/{index-d9entpn3.js → index-40twgsyh.js} +4 -4
  23. package/dist/cli/{index-ggtmsm84.js → index-4mjmnysc.js} +1 -1
  24. package/dist/cli/{index-e90em0x4.js → index-4vb56w2k.js} +12 -17
  25. package/dist/cli/{index-r656jh9j.js → index-5wc5pbzc.js} +3700 -2609
  26. package/dist/cli/{index-w3gtqey0.js → index-6chhqq2n.js} +4 -4
  27. package/dist/cli/{index-qbw3yw2d.js → index-888pq4xx.js} +11 -11
  28. package/dist/cli/{index-3146wmgv.js → index-8d90gzaz.js} +1 -1
  29. package/dist/cli/{index-5jx22kwc.js → index-8vw2pjgr.js} +544 -15
  30. package/dist/cli/{index-b2nj04q6.js → index-9ss2m4rs.js} +1 -434
  31. package/dist/cli/{index-x43debgx.js → index-ad9064j9.js} +15 -17
  32. package/dist/cli/{index-5kcvrpkt.js → index-b25t91a3.js} +1 -1
  33. package/dist/cli/index-c45662wc.js +361 -0
  34. package/dist/cli/{index-aqppaaqx.js → index-cgewrpw5.js} +3 -2
  35. package/dist/cli/{index-zfs3zqeq.js → index-d3mpxsmy.js} +771 -21
  36. package/dist/cli/{index-y1yqmkv7.js → index-d7j3n5ra.js} +52 -50
  37. package/dist/cli/{index-4vb6qa73.js → index-ebce775n.js} +36 -2
  38. package/dist/cli/{index-dsg9dw3b.js → index-eed0gkv6.js} +2 -2
  39. package/dist/cli/index-es64amqt.js +675 -0
  40. package/dist/cli/{index-9gxbjkts.js → index-ewv8qa8q.js} +22 -19
  41. package/dist/cli/{index-1ww7wj8d.js → index-hb7bh4r2.js} +15 -15
  42. package/dist/cli/{index-kc2tgcm7.js → index-hg09xemc.js} +4 -4
  43. package/dist/cli/{index-w95vxjde.js → index-hvz4ad2t.js} +39 -8
  44. package/dist/cli/{index-77z98j76.js → index-k0s8n6m5.js} +314 -130
  45. package/dist/cli/{index-7m32fjb4.js → index-kxv193aq.js} +9 -9
  46. package/dist/cli/{index-hp22pzn5.js → index-m8xrbdmn.js} +2 -2
  47. package/dist/cli/{index-4gqxppcx.js → index-mee9maf5.js} +2 -2
  48. package/dist/cli/{index-r3mvsbtq.js → index-p612v1mv.js} +7 -1
  49. package/dist/cli/{index-r5q5gd2a.js → index-qgajv9rd.js} +2 -2
  50. package/dist/cli/{index-zjg4chy2.js → index-qqq04n70.js} +2 -2
  51. package/dist/cli/{index-ww6zm5hr.js → index-r2p0pgst.js} +3 -3
  52. package/dist/cli/{index-47kh2103.js → index-r69gzes2.js} +14 -14
  53. package/dist/cli/{index-vdn32nws.js → index-sphahrmq.js} +3 -3
  54. package/dist/cli/{index-rhqdsc1x.js → index-vw66q1rw.js} +9 -9
  55. package/dist/cli/{index-kch6yenm.js → index-wasdrhev.js} +7 -7
  56. package/dist/cli/{index-c5v1w13g.js → index-wknpkfm8.js} +807 -629
  57. package/dist/cli/{index-pp2nya9v.js → index-x39hjdf1.js} +2 -4
  58. package/dist/cli/{index-n8688d12.js → index-xxfk62zd.js} +2 -2
  59. package/dist/cli/index-yvqg6kn5.js +429 -0
  60. package/dist/cli/{index-nqsj0g5y.js → index-ztm0q26v.js} +8 -8
  61. package/dist/cli/index.js +50 -48
  62. package/dist/cli/{knowledge-escalator-j04g450p.js → knowledge-escalator-01vva51d.js} +17 -18
  63. package/dist/cli/{knowledge-events-53z45rs0.js → knowledge-events-dpfwh1hs.js} +15 -16
  64. package/dist/cli/{knowledge-link-a6kfg3qm.js → knowledge-link-2rvp966j.js} +4 -5
  65. package/dist/cli/{knowledge-store-whm0gagt.js → knowledge-store-aw58ae7b.js} +6 -7
  66. package/dist/cli/{knowledge-validator-h8m7065g.js → knowledge-validator-yhd31ryf.js} +8 -9
  67. package/dist/cli/{pending-delegations-6hkpe5ze.js → pending-delegations-fjetcz8e.js} +17 -8
  68. package/dist/cli/{pr-subscriptions-11zca1mh.js → pr-subscriptions-cwwtfs8w.js} +17 -8
  69. package/dist/cli/{pr-workflow-gate-6g29rkg7.js → pr-workflow-gate-5xwtg1k2.js} +50 -48
  70. package/dist/cli/{runner-5abw3t35.js → runner-mb51twxt.js} +6 -7
  71. package/dist/cli/{scan-cursor-mkfx410t.js → scan-cursor-j11qwf0v.js} +9 -10
  72. package/dist/cli/{schema-jbbam3ev.js → schema-0xp3bde3.js} +1 -1
  73. package/dist/cli/{scope-persistence-q1ct4k42.js → scope-persistence-brrk806y.js} +19 -12
  74. package/dist/cli/{skill-generator-cv8fg96x.js → skill-generator-j8qzmet9.js} +20 -21
  75. package/dist/cli/snapshot-coordination-init-h0xmtftq.js +84 -0
  76. package/dist/cli/{telemetry-mbqqamsj.js → telemetry-m84ap0pp.js} +1 -1
  77. package/dist/cli/{workspace-snapshot-eh18vgkn.js → workspace-snapshot-6z9rk7xw.js} +3 -3
  78. package/dist/cli/{worktree-collision-ownership-xgnn8dsq.js → worktree-collision-ownership-j9zykj18.js} +21 -12
  79. package/dist/cli/{worktree-isolation-k2dgfmeg.js → worktree-isolation-jd39xz6h.js} +48 -46
  80. package/dist/commands/close.d.ts +13 -6
  81. package/dist/commands/reset-session.d.ts +4 -0
  82. package/dist/db/coordination-store.d.ts +85 -0
  83. package/dist/db/durability.d.ts +22 -5
  84. package/dist/db/index.d.ts +1 -0
  85. package/dist/db/project-db.d.ts +12 -0
  86. package/dist/index.js +810 -705
  87. package/dist/memory/schema.d.ts +3 -3
  88. package/dist/pr-review/authorization.d.ts +5 -4
  89. package/dist/pr-review/persistence.d.ts +10 -1
  90. package/dist/scope/scope-binding.d.ts +10 -0
  91. package/dist/scope/scope-persistence.d.ts +10 -0
  92. package/dist/services/handoff-service.d.ts +2 -0
  93. package/dist/services/status-service.d.ts +4 -0
  94. package/dist/session/snapshot-coordination-init.d.ts +49 -0
  95. package/dist/session/snapshot-reader.d.ts +2 -0
  96. package/dist/session/snapshot-store.d.ts +42 -0
  97. package/dist/session/snapshot-writer.d.ts +4 -1
  98. package/dist/state.d.ts +6 -3
  99. package/dist/turbo/epic/state.d.ts +4 -20
  100. package/dist/utils/bun-compat.d.ts +10 -0
  101. package/dist/utils/external-tool-runner.d.ts +2 -0
  102. package/package.json +3 -2
  103. package/dist/cli/curator-llm-factory-sxcpmcqq.js +0 -68
  104. package/dist/cli/guardrail-explain-xv9aw1bf.js +0 -69
  105. package/dist/cli/hive-promoter-09yc9mp5.js +0 -83
  106. package/dist/cli/index-xnb3tk7x.js +0 -24
  107. package/dist/cli/{ast-diff-ekd9v10f.js → ast-diff-b0esr2kf.js} +3 -3
@@ -54,8 +54,8 @@ export declare const MemorySourceSchema: z.ZodObject<{
54
54
  tool: "tool";
55
55
  test: "test";
56
56
  manual: "manual";
57
- commit: "commit";
58
57
  user: "user";
58
+ commit: "commit";
59
59
  repo: "repo";
60
60
  web: "web";
61
61
  }>;
@@ -119,8 +119,8 @@ export declare const MemoryRecordSchema: z.ZodObject<{
119
119
  tool: "tool";
120
120
  test: "test";
121
121
  manual: "manual";
122
- commit: "commit";
123
122
  user: "user";
123
+ commit: "commit";
124
124
  repo: "repo";
125
125
  web: "web";
126
126
  }>;
@@ -217,8 +217,8 @@ export declare const MemoryProposalSchema: z.ZodObject<{
217
217
  tool: "tool";
218
218
  test: "test";
219
219
  manual: "manual";
220
- commit: "commit";
221
220
  user: "user";
221
+ commit: "commit";
222
222
  repo: "repo";
223
223
  web: "web";
224
224
  }>;
@@ -19,10 +19,9 @@
19
19
  * orchestration gate back. The gate binds its
20
20
  * `readPrReviewReentryBindingContext` at module init.
21
21
  *
22
- * Persistence: `.swarm/pr-review/reentry-authorizations/<session-stem>.json`,
23
- * guarded by a `proper-lockfile` lock (the same dependency the candidate
24
- * sidecar store uses). Bounded: at most MAX_ACTIVE_AUTHORIZATIONS unconsumed
25
- * authorizations per session; expired/unconsumed records are pruned on write.
22
+ * Persistence: SQLite coordination state is authoritative; the legacy
23
+ * `.swarm/pr-review/reentry-authorizations/<session-stem>.json` path remains a
24
+ * post-commit shadow projection and one-time import source only.
26
25
  */
27
26
  import { z } from 'zod';
28
27
  export type PrReviewReentryRole = 'reviewer' | 'test_engineer';
@@ -79,6 +78,7 @@ declare const AuthorizationFileSchema: z.ZodObject<{
79
78
  }, z.core.$strict>;
80
79
  type AuthorizationFile = z.infer<typeof AuthorizationFileSchema>;
81
80
  declare function reentryAuthorizationFilePath(directory: string, sessionID: string): string;
81
+ declare function reentryAuthorizationCoordinationNamespace(sessionID: string): string;
82
82
  declare function renameWithRetryAsync(tempPath: string, targetPath: string): Promise<void>;
83
83
  declare function writeAuthorizationFile(filePath: string, file: AuthorizationFile): Promise<void>;
84
84
  /**
@@ -122,6 +122,7 @@ export declare const _internals: {
122
122
  AUTHORIZATION_TTL_MS: number;
123
123
  MAX_ACTIVE_AUTHORIZATIONS: number;
124
124
  reentryAuthorizationFilePath: typeof reentryAuthorizationFilePath;
125
+ reentryAuthorizationCoordinationNamespace: typeof reentryAuthorizationCoordinationNamespace;
125
126
  pruneAuthorizations: typeof pruneAuthorizations;
126
127
  authorizationMatchesBinding: typeof authorizationMatchesBinding;
127
128
  hasPrReviewReentryAuthorizationAgainstBinding: typeof hasPrReviewReentryAuthorizationAgainstBinding;
@@ -88,12 +88,21 @@ export declare function writeAtomicJson(directory: string, filePath: string, val
88
88
  * rename contention as canonical gate state.
89
89
  */
90
90
  export declare function writePrWorkflowAtomicJson(directory: string, filePath: string, value: unknown): Promise<void>;
91
- export declare function readPrWorkflowGateStateFromDisk<S extends PrWorkflowPersistedStateBase>(directory: string, sessionID: string): Promise<S | null>;
91
+ export declare function readPrWorkflowGateStateFromDisk<S extends PrWorkflowPersistedStateBase>(directory: string, sessionID: string, options?: {
92
+ allowSalvagedImport?: boolean;
93
+ }): Promise<S | null>;
94
+ export declare function readPrWorkflowGateStateFileRawFromDisk<S extends PrWorkflowPersistedStateBase>(filePath: string, stateLabel: string): Promise<S | null>;
92
95
  export declare function readPrWorkflowGateStateFileFromDisk<S extends PrWorkflowPersistedStateBase>(filePath: string, stateLabel: string): Promise<S | null>;
96
+ export declare function readPrWorkflowGateStateFromCoordination<S extends PrWorkflowPersistedStateBase>(directory: string, sessionID: string): Promise<S | null>;
93
97
  /** Persist one CAS-checked state replacement while the session lock is held. */
94
98
  export declare function writeStateWhileLocked<S extends PrWorkflowPersistedStateBase>(directory: string, state: S, options?: {
95
99
  replaceWorkflowInstanceId?: string;
96
100
  }): Promise<S>;
101
+ /** Remove authoritative PR workflow state while the session mutation lock is held. */
102
+ export declare function deleteStateWhileLocked(directory: string, sessionID: string, options?: {
103
+ expectedStateRevision?: number;
104
+ allowSalvagedRead?: boolean;
105
+ }): Promise<void>;
97
106
  /** A bounded checkout-mutation refusal that never permits unsafe late overlap. */
98
107
  export declare class PrWorkflowCheckoutMutationTimeoutError extends Error {
99
108
  readonly phase: 'queue' | 'action';
@@ -92,6 +92,16 @@ export declare function getScopeBinding(input: {
92
92
  ownerSessionId: string;
93
93
  ownerMessageId?: string;
94
94
  }): ScopeBinding | null;
95
+ /**
96
+ * Resolve active child bindings that were minted in this process. The
97
+ * synchronous scope API is still used by a few host integrations that cannot
98
+ * await the durable claim path; those bindings remain valid for the current
99
+ * process while the SQLite authority is used on restart/cross-process reads.
100
+ */
101
+ export declare function getActiveScopeBindingsForSession(input: {
102
+ directory: string;
103
+ activeSessionId: string;
104
+ }): ScopeBinding[];
95
105
  export declare function createPrFeedbackScopeBinding(input: {
96
106
  directory: string;
97
107
  taskId: string;
@@ -83,6 +83,14 @@ export interface PersistedScope {
83
83
  files: string[];
84
84
  }
85
85
  export type PersistedScopeBinding = ScopeBinding;
86
+ declare function transitionScopeBindingState(directory: string, binding: ScopeBinding, expectedRevision: number | null): ScopePersistenceResult;
87
+ /**
88
+ * Scope replacement rollback owns one coordination transaction across the
89
+ * successor revocation and every predecessor restore. Re-entering the public
90
+ * transition helper would create nested SQLite transaction scopes that cannot
91
+ * make that whole compensation batch atomic.
92
+ */
93
+ declare function transitionScopeBindingStateWithinTransaction(directory: string, binding: ScopeBinding, expectedRevision: number | null): ScopePersistenceResult;
86
94
  /**
87
95
  * Write the legacy v1 `.swarm/scopes/scope-{taskId}.json` projection atomically.
88
96
  * Safe to call concurrently — proper-lockfile serialises writers per-file.
@@ -190,6 +198,8 @@ export declare function resolveAuthorizedPrFeedbackScopeBindingFromDisk(input: {
190
198
  taskId?: string;
191
199
  }): ScopeBinding | null;
192
200
  export declare const _scopePersistenceInternals: {
201
+ transitionScopeBindingState: typeof transitionScopeBindingState;
202
+ transitionScopeBindingStateWithinTransaction: typeof transitionScopeBindingStateWithinTransaction;
193
203
  liveBindingCapacity: number;
194
204
  bindingFileScanCapacity: number;
195
205
  maintenanceFileScanCapacity: number;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { ExecutionProfile } from '../config/plan-schema';
8
8
  import { loadPlanJsonOnly } from '../plan/manager';
9
+ import { readSnapshotRows } from '../session/snapshot-store.js';
9
10
  /**
10
11
  * Escape HTML special characters to prevent XSS attacks
11
12
  */
@@ -134,5 +135,6 @@ export declare const _internals: {
134
135
  parseSessionState: typeof parseSessionState;
135
136
  extractDecisions: typeof extractDecisions;
136
137
  extractPhaseMetrics: typeof extractPhaseMetrics;
138
+ readSnapshotRows: typeof readSnapshotRows;
137
139
  };
138
140
  export {};
@@ -2,6 +2,7 @@ import type { AgentDefinition } from '../agents';
2
2
  import { type DelegationHealthMaintenanceSection, type DelegationLedgerHealth } from '../background/delegation-health';
3
3
  import { loadFullAutoRunState } from '../full-auto/state';
4
4
  import { type RecentEscalation } from '../hooks/knowledge-escalator';
5
+ import { type SnapshotCoordinationStatus } from '../session/snapshot-coordination-init.js';
5
6
  import { getActiveFullAutoSessionID, hasActiveFullAuto, hasActiveLeanTurbo } from '../state';
6
7
  import { loadLeanTurboRunState } from '../turbo/lean/state';
7
8
  import { summarizeTelemetryCosts } from './cost-accounting.js';
@@ -195,6 +196,8 @@ export interface StatusData {
195
196
  * stores surface as typed uncertainty, never partially-trusted counts.
196
197
  */
197
198
  backgroundWork?: BackgroundWorkStatus;
199
+ /** Post-resolution SQLite import/readiness health (#2481). */
200
+ coordination?: SnapshotCoordinationStatus;
198
201
  /** Issue #2043: compatibility total plus provenance completeness. */
199
202
  costs?: {
200
203
  totalCostUsd: number;
@@ -216,6 +219,7 @@ export interface BackgroundWorkStatus {
216
219
  consumed: number;
217
220
  stale: number;
218
221
  cancelled: number;
222
+ rejected: number;
219
223
  error: number;
220
224
  ingestion_error: number;
221
225
  };
@@ -0,0 +1,49 @@
1
+ /** Post-resolution SQLite snapshot import/readiness lifecycle (#2481). */
2
+ import type { SnapshotData } from './snapshot-writer.js';
3
+ type ReadinessState = 'running' | 'succeeded' | 'failed' | 'timed_out' | 'closing';
4
+ interface ReadinessEntry {
5
+ attemptId: number;
6
+ generation: number;
7
+ state: ReadinessState;
8
+ settled: boolean;
9
+ underlying: Promise<void>;
10
+ error?: string;
11
+ }
12
+ export interface SnapshotCoordinationStatus {
13
+ state: ReadinessState | 'idle';
14
+ attemptId?: number;
15
+ generation?: number;
16
+ settled: boolean;
17
+ error?: string;
18
+ }
19
+ /**
20
+ * Held while reset-session removes the authoritative snapshot and its legacy
21
+ * projection. Callers must release it after the destructive portion is done.
22
+ */
23
+ export interface SnapshotCoordinationResetGuard {
24
+ release(): void;
25
+ closeError?: Error;
26
+ /** True when the prior initializer did not settle before the reset deadline. */
27
+ priorUnsettled?: boolean;
28
+ }
29
+ export declare function startSnapshotCoordinationInitialization(directory: string): Promise<void>;
30
+ export declare function ensureSnapshotCoordinationReady(directory: string): Promise<void>;
31
+ export declare function retrySnapshotCoordinationInitialization(directory: string): Promise<void>;
32
+ export declare function getSnapshotCoordinationStatus(directory: string): SnapshotCoordinationStatus;
33
+ /**
34
+ * Prevent any fresh initializer from observing state while reset-session
35
+ * deletes the SQLite authority and legacy projection. The guard deliberately
36
+ * survives a prior initialization failure: reset remains best-effort, but a
37
+ * concurrent initializer cannot race through the destructive window.
38
+ */
39
+ export declare function beginSnapshotCoordinationReset(directory: string): Promise<SnapshotCoordinationResetGuard>;
40
+ export declare function closeSnapshotCoordinationInitialization(directory: string): Promise<void>;
41
+ export declare function markSnapshotCoordinationClosing(directory: string): void;
42
+ export declare const _snapshotCoordinationInternals: {
43
+ entries: Map<string, ReadinessEntry>;
44
+ initialize: (directory: string) => Promise<void>;
45
+ renameLegacySnapshot: (from: string, to: string) => void;
46
+ writeProjection: (directory: string, snapshot: SnapshotData) => Promise<void>;
47
+ timeoutMs: number;
48
+ };
49
+ export {};
@@ -29,6 +29,8 @@ export declare function deserializeAgentSession(s: SerializedAgentSession): Agen
29
29
  * NEVER throws - always returns null on any error.
30
30
  */
31
31
  export declare function readSnapshot(directory: string): Promise<SnapshotData | null>;
32
+ /** Strict single-candidate reader used by the SQLite import boundary. */
33
+ export declare function readSnapshotFileStrict(directory: string, relativePath: string): Promise<SnapshotData>;
32
34
  /**
33
35
  * Rehydrate swarmState from a SnapshotData object.
34
36
  * Clears existing maps first, then populates from snapshot.
@@ -0,0 +1,42 @@
1
+ /** SQLite row mapping for durable session snapshots (#2481). */
2
+ import type { SnapshotData } from './snapshot-writer.js';
3
+ /** Test-only seam for interleaving a foreign writer after the first snapshot read. */
4
+ export declare const _snapshotStoreInternals: {
5
+ afterSnapshotMetaRead: () => void;
6
+ };
7
+ interface DeletedSessionRowPayload {
8
+ ownerToken?: string;
9
+ reason: 'ended' | 'stale';
10
+ }
11
+ export interface SnapshotWriteOptions {
12
+ /** Do not let rehydrated foreign sessions overwrite their durable owners. */
13
+ onlyLocallyOwnedSessions?: boolean;
14
+ }
15
+ /**
16
+ * Mark a session as local for snapshot writes and reaping. Rehydration never
17
+ * calls this. Only a host invocation for the exact session may opt into
18
+ * takeover, which lets a restarted host resume its own session without letting
19
+ * a passive foreign rehydration overwrite a live peer.
20
+ */
21
+ export declare function claimSnapshotSessionOwnership(sessionId: string, canTakeOver?: boolean): string;
22
+ export declare function isSnapshotSessionOwnedLocally(sessionId: string): boolean;
23
+ export declare function releaseSnapshotSessionOwnership(sessionId: string): void;
24
+ export declare function clearSnapshotSessionOwnerships(): void;
25
+ export declare function writeSnapshotRows(directory: string, snapshot: SnapshotData, options?: SnapshotWriteOptions): void;
26
+ export declare function importSnapshotRowsOnce(directory: string, snapshot: SnapshotData, sourceDigest: string, source?: string): 'imported' | 'already_imported' | 'state_exists';
27
+ export declare function readSnapshotRows(directory: string): SnapshotData | null;
28
+ /**
29
+ * Confirm whether the authoritative durable row is genuinely stale before a
30
+ * local stale sweep is allowed to tombstone it.
31
+ *
32
+ * This re-reads SQLite rather than trusting the caller's in-memory copy so a
33
+ * peer process with a frozen snapshot cannot delete a still-fresh live row.
34
+ * Missing rows are treated as safe-to-evict: there is no durable authority left
35
+ * to protect.
36
+ */
37
+ export declare function isSnapshotSessionAuthoritativelyStale(directory: string, sessionId: string, staleDurationMs: number, now?: number): boolean;
38
+ /** Remove the complete authoritative snapshot as one FULL transaction. */
39
+ export declare function clearSnapshotRows(directory: string): number;
40
+ /** Tombstone the session-keyed rows removed by a host lifecycle event. */
41
+ export declare function deleteSnapshotSessionRows(directory: string, sessionId: string, reason?: DeletedSessionRowPayload['reason']): number;
42
+ export {};
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * Session snapshot writer for OpenCode Swarm plugin.
3
- * Serializes swarmState to .swarm/session/state.json using atomic write (temp-file + rename).
3
+ * Persists swarmState as independently keyed SQLite coordination rows and a
4
+ * non-authoritative, versioned file projection.
4
5
  */
5
6
  import { rename as fsRename } from 'node:fs/promises';
6
7
  import { TASK_WORKFLOW_SCHEMA_MARKER } from '../gate-evidence.js';
7
8
  import type { AgentSessionState, DelegationEntry, ToolAggregate } from '../state';
8
9
  import { swarmState } from '../state';
10
+ export declare const SNAPSHOT_PROJECTION_FILE = "session/state.sqlite-projection.json";
9
11
  /**
10
12
  * Windows can transiently fail a rename with EEXIST/EBUSY/EPERM while another
11
13
  * process (an external snapshot reader, an AV scanner) briefly holds the
@@ -144,6 +146,7 @@ export declare function serializeAgentSession(s: AgentSessionState): SerializedA
144
146
  * Silently swallows errors (non-fatal — never crash the plugin).
145
147
  */
146
148
  export declare function writeSnapshot(directory: string, state: typeof swarmState): Promise<void>;
149
+ export declare function writeSnapshotProjection(directory: string, snapshot: SnapshotData): Promise<void>;
147
150
  /**
148
151
  * Create a snapshot writer hook suitable for use in tool.execute.after.
149
152
  * Writes state immediately on every call. Concurrent calls are serialised so
package/dist/state.d.ts CHANGED
@@ -1003,9 +1003,10 @@ export declare function isReviewerScopeGenerationCurrent(input: {
1003
1003
  *
1004
1004
  * @param staleDurationMs - Age threshold in ms (default 2h)
1005
1005
  * @param now - Current time in ms (injectable for deterministic tests)
1006
+ * @param directory - Optional project root whose locally-owned durable rows are tombstoned
1006
1007
  * @returns The list of evicted session IDs
1007
1008
  */
1008
- export declare function sweepStaleSessions(staleDurationMs?: number, now?: number): string[];
1009
+ export declare function sweepStaleSessions(staleDurationMs?: number, now?: number, directory?: string): string[];
1009
1010
  /**
1010
1011
  * Opportunistic, cooldown-guarded wrapper around sweepStaleSessions, intended
1011
1012
  * to be called from a frequently-hit code path (per-tool-call accounting in
@@ -1024,9 +1025,10 @@ export declare function sweepStaleSessions(staleDurationMs?: number, now?: numbe
1024
1025
  *
1025
1026
  * @param staleDurationMs - Age threshold in ms (default 2h)
1026
1027
  * @param now - Current time in ms (injectable for deterministic tests)
1028
+ * @param directory - Optional project root whose durable rows are tombstoned
1027
1029
  * @returns Evicted session IDs ([] when the cooldown blocks this run)
1028
1030
  */
1029
- export declare function maybeSweepStaleSessions(staleDurationMs?: number, now?: number): string[];
1031
+ export declare function maybeSweepStaleSessions(staleDurationMs?: number, now?: number, directory?: string): string[];
1030
1032
  /**
1031
1033
  * Start a new agent session with initialized guardrail state.
1032
1034
  * Also removes any stale sessions older than staleDurationMs.
@@ -1042,8 +1044,9 @@ export declare function startAgentSession(sessionId: string, agentName: string,
1042
1044
  * teardown) to prevent unbounded Map growth. Double-calls are safe: Map.delete is
1043
1045
  * a no-op for missing keys (FR-010).
1044
1046
  * @param sessionId - The session identifier to remove
1047
+ * @param directory - Optional project root whose durable snapshot row must be tombstoned
1045
1048
  */
1046
- export declare function endAgentSession(sessionId: string): void;
1049
+ export declare function endAgentSession(sessionId: string, directory?: string): void;
1047
1050
  /**
1048
1051
  * Get an agent session state by session ID.
1049
1052
  * @param sessionId - The session identifier
@@ -1,14 +1,9 @@
1
1
  /**
2
- * Durable Epic Mode session state (Capability C).
2
+ * Durable Epic Mode session state.
3
3
  *
4
- * Persists per-session Epic Mode activation state under
5
- * `<projectRoot>/.swarm/epic-state.json` so toggling survives process
6
- * restarts. Mirrors the pattern in `src/turbo/lean/state.ts` (atomic
7
- * `tmp + rename`, per-directory `stateUnreadableMap` for fail-closed
8
- * semantics, sessions-keyed shape) — without modifying that file.
9
- *
10
- * Dependency direction is one-way: this module imports nothing from
11
- * `src/turbo/lean/`. The shape is parallel but independent.
4
+ * The authoritative store is the per-project SQLite coordination DB, with one
5
+ * row per session. `.swarm/epic-state.json` remains a compatibility
6
+ * projection and import source during the cutover.
12
7
  */
13
8
  /** Top-level state for a single session. */
14
9
  export interface EpicSessionState {
@@ -49,17 +44,6 @@ export declare function isEpicModeActive(directory: string, sessionID: string):
49
44
  /**
50
45
  * True iff epic mode is currently active for ANY session in the project.
51
46
  *
52
- * Use this when a code path needs to know "is the project running under
53
- * Epic Mode right now" without caring which session toggled it. The
54
- * session-scoped `isEpicModeActive` answers "did THIS session toggle it" —
55
- * a different question with a different answer.
56
- *
57
- * The architect's session enables Epic via `/swarm epic on`; sub-agents
58
- * (coders, reviewers) dispatched through the `Task` tool run in their own
59
- * sessions and have no record of that toggle. Asking the project-scoped
60
- * check is the only correct way to honor Epic Mode from those flows.
61
- * Rule 2's auto-commit (centralized in Phase 5) is the canonical caller.
62
- *
63
47
  * Fail-closed: returns `false` on unreadable state, matching the rest of
64
48
  * this module's defaults.
65
49
  */
@@ -58,6 +58,16 @@ export declare function bunWrite(filePath: string, data: string | Uint8Array | A
58
58
  * introduce delays in plugin code that must run under both runtimes.
59
59
  */
60
60
  export declare function sleep(ms: number): Promise<void>;
61
+ /**
62
+ * Force a full Bun garbage collection when available.
63
+ *
64
+ * Bun's SQLite query cache can leave evicted Statement wrappers alive after
65
+ * `Database.close(false)`. On Windows those wrappers retain the database file
66
+ * handle until GC, so immediate archive cleanup can fail with EBUSY. This is
67
+ * intentionally best-effort and only called after such an unlink failure;
68
+ * Node-hosted plugin contexts take the no-op path.
69
+ */
70
+ export declare function collectGarbageBestEffort(): void;
61
71
  /**
62
72
  * Stable 32-bit hash. Bun's `Bun.hash` uses xxHash64 by default; on Node we
63
73
  * fall back to a 32-bit djb2 hash — identical hashes are NOT guaranteed
@@ -1,4 +1,5 @@
1
1
  import { bunSpawn } from './bun-compat';
2
+ import { warn } from './logger';
2
3
  export interface ExternalToolRunOptions {
3
4
  executable: string;
4
5
  args: string[];
@@ -32,5 +33,6 @@ export declare const _internals: {
32
33
  clearTimeout: typeof clearTimeout;
33
34
  clampTimeoutMs: typeof clampTimeoutMs;
34
35
  computeSpawnTimeoutMs: typeof computeSpawnTimeoutMs;
36
+ warn: typeof warn;
35
37
  };
36
38
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.164.11",
3
+ "version": "7.164.12",
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",
@@ -98,6 +98,7 @@
98
98
  "lint:ci": "biome ci .",
99
99
  "test:unit:ci": "bun scripts/ci/run-unit-tests-local.ts",
100
100
  "drift:check": "bun run scripts/drift-check.ts",
101
+ "check:pre-push": "bun run scripts/drift-check.ts --enforce --no-report && bun run check:registry-citations",
101
102
  "schema:generate": "bun run scripts/generate-config-schema.ts",
102
103
  "check:runtime-src-refs": "bun run scripts/check-runtime-src-refs.ts",
103
104
  "drift:fix": "bun run scripts/drift-check.ts --fix --confirm",
@@ -141,7 +142,7 @@
141
142
  "proper-lockfile": "^4.1.2",
142
143
  "quick-lru": "^7.3.0",
143
144
  "web-tree-sitter": "^0.25.0",
144
- "zod": "^4.1.8"
145
+ "zod": "4.3.6"
145
146
  },
146
147
  "devDependencies": {
147
148
  "@biomejs/biome": "2.3.14",
@@ -1,68 +0,0 @@
1
- // @bun
2
- import {
3
- createCuratorLLMDelegate
4
- } from "./index-r656jh9j.js";
5
- import"./index-w95vxjde.js";
6
- import"./index-kch6yenm.js";
7
- import"./index-5kcvrpkt.js";
8
- import"./index-77z98j76.js";
9
- import"./index-pp2nya9v.js";
10
- import"./index-txdagbh7.js";
11
- import"./index-cw912re7.js";
12
- import"./index-3146wmgv.js";
13
- import"./index-1ww7wj8d.js";
14
- import"./index-7m32fjb4.js";
15
- import"./index-d9entpn3.js";
16
- import"./index-70ha9e09.js";
17
- import"./index-nqsj0g5y.js";
18
- import"./index-b2nj04q6.js";
19
- import"./index-n4fzmqz8.js";
20
- import"./index-zfs3zqeq.js";
21
- import"./index-zsrtt42s.js";
22
- import"./index-47kh2103.js";
23
- import"./index-w3gtqey0.js";
24
- import"./index-n8688d12.js";
25
- import"./index-kc2tgcm7.js";
26
- import"./index-ggtmsm84.js";
27
- import"./index-rtry5xyf.js";
28
- import"./index-x43debgx.js";
29
- import"./index-4vb6qa73.js";
30
- import"./index-5jx22kwc.js";
31
- import"./index-c5v1w13g.js";
32
- import"./index-e90em0x4.js";
33
- import"./index-ry16d01s.js";
34
- import"./index-4gqxppcx.js";
35
- import"./index-556ja8an.js";
36
- import"./index-4fwbbad3.js";
37
- import"./index-b43rt5ph.js";
38
- import"./index-q7sjgr1y.js";
39
- import"./index-qbw3yw2d.js";
40
- import"./index-ggrp3v00.js";
41
- import"./index-r5q5gd2a.js";
42
- import"./index-3qf1vxtb.js";
43
- import"./index-n832052r.js";
44
- import"./index-zjg4chy2.js";
45
- import"./index-z6xqpmqg.js";
46
- import"./index-r3mvsbtq.js";
47
- import"./index-rhqdsc1x.js";
48
- import"./index-aqppaaqx.js";
49
- import"./index-9e6fdz2h.js";
50
- import"./index-4rhhvd1a.js";
51
- import"./index-dsg9dw3b.js";
52
- import"./index-50j914b5.js";
53
- import"./index-zjygnfay.js";
54
- import"./index-ae75rja9.js";
55
- import"./index-vdn32nws.js";
56
- import"./index-xnb3tk7x.js";
57
- import"./index-bk5tah7q.js";
58
- import"./index-7qefgq4j.js";
59
- import"./index-2bgr671r.js";
60
- import"./index-9gxbjkts.js";
61
- import"./index-ww6zm5hr.js";
62
- import"./index-7g4c7s5r.js";
63
- import"./index-bpmtbmy9.js";
64
- import"./index-zgwm4ryv.js";
65
- import"./index-a76rekgs.js";
66
- export {
67
- createCuratorLLMDelegate
68
- };
@@ -1,69 +0,0 @@
1
- // @bun
2
- import {
3
- handleGuardrailExplain
4
- } from "./index-hp22pzn5.js";
5
- import"./index-r656jh9j.js";
6
- import"./index-w95vxjde.js";
7
- import"./index-kch6yenm.js";
8
- import"./index-5kcvrpkt.js";
9
- import"./index-77z98j76.js";
10
- import"./index-pp2nya9v.js";
11
- import"./index-txdagbh7.js";
12
- import"./index-cw912re7.js";
13
- import"./index-3146wmgv.js";
14
- import"./index-1ww7wj8d.js";
15
- import"./index-7m32fjb4.js";
16
- import"./index-d9entpn3.js";
17
- import"./index-70ha9e09.js";
18
- import"./index-nqsj0g5y.js";
19
- import"./index-b2nj04q6.js";
20
- import"./index-n4fzmqz8.js";
21
- import"./index-zfs3zqeq.js";
22
- import"./index-zsrtt42s.js";
23
- import"./index-47kh2103.js";
24
- import"./index-w3gtqey0.js";
25
- import"./index-n8688d12.js";
26
- import"./index-kc2tgcm7.js";
27
- import"./index-ggtmsm84.js";
28
- import"./index-rtry5xyf.js";
29
- import"./index-x43debgx.js";
30
- import"./index-4vb6qa73.js";
31
- import"./index-5jx22kwc.js";
32
- import"./index-c5v1w13g.js";
33
- import"./index-e90em0x4.js";
34
- import"./index-ry16d01s.js";
35
- import"./index-4gqxppcx.js";
36
- import"./index-556ja8an.js";
37
- import"./index-4fwbbad3.js";
38
- import"./index-b43rt5ph.js";
39
- import"./index-q7sjgr1y.js";
40
- import"./index-qbw3yw2d.js";
41
- import"./index-ggrp3v00.js";
42
- import"./index-r5q5gd2a.js";
43
- import"./index-3qf1vxtb.js";
44
- import"./index-n832052r.js";
45
- import"./index-zjg4chy2.js";
46
- import"./index-z6xqpmqg.js";
47
- import"./index-r3mvsbtq.js";
48
- import"./index-rhqdsc1x.js";
49
- import"./index-aqppaaqx.js";
50
- import"./index-9e6fdz2h.js";
51
- import"./index-4rhhvd1a.js";
52
- import"./index-dsg9dw3b.js";
53
- import"./index-50j914b5.js";
54
- import"./index-zjygnfay.js";
55
- import"./index-ae75rja9.js";
56
- import"./index-vdn32nws.js";
57
- import"./index-xnb3tk7x.js";
58
- import"./index-bk5tah7q.js";
59
- import"./index-7qefgq4j.js";
60
- import"./index-2bgr671r.js";
61
- import"./index-9gxbjkts.js";
62
- import"./index-ww6zm5hr.js";
63
- import"./index-7g4c7s5r.js";
64
- import"./index-bpmtbmy9.js";
65
- import"./index-zgwm4ryv.js";
66
- import"./index-a76rekgs.js";
67
- export {
68
- handleGuardrailExplain
69
- };
@@ -1,83 +0,0 @@
1
- // @bun
2
- import {
3
- _internals2 as _internals,
4
- checkHivePromotions,
5
- countDistinctProjects,
6
- createHivePromoterHook,
7
- isHiveEligible,
8
- promoteFromSwarm,
9
- promoteToHive
10
- } from "./index-r656jh9j.js";
11
- import"./index-w95vxjde.js";
12
- import"./index-kch6yenm.js";
13
- import"./index-5kcvrpkt.js";
14
- import"./index-77z98j76.js";
15
- import"./index-pp2nya9v.js";
16
- import"./index-txdagbh7.js";
17
- import"./index-cw912re7.js";
18
- import"./index-3146wmgv.js";
19
- import"./index-1ww7wj8d.js";
20
- import"./index-7m32fjb4.js";
21
- import"./index-d9entpn3.js";
22
- import"./index-70ha9e09.js";
23
- import"./index-nqsj0g5y.js";
24
- import"./index-b2nj04q6.js";
25
- import"./index-n4fzmqz8.js";
26
- import"./index-zfs3zqeq.js";
27
- import"./index-zsrtt42s.js";
28
- import"./index-47kh2103.js";
29
- import"./index-w3gtqey0.js";
30
- import"./index-n8688d12.js";
31
- import"./index-kc2tgcm7.js";
32
- import"./index-ggtmsm84.js";
33
- import"./index-rtry5xyf.js";
34
- import"./index-x43debgx.js";
35
- import"./index-4vb6qa73.js";
36
- import"./index-5jx22kwc.js";
37
- import"./index-c5v1w13g.js";
38
- import"./index-e90em0x4.js";
39
- import"./index-ry16d01s.js";
40
- import"./index-4gqxppcx.js";
41
- import"./index-556ja8an.js";
42
- import"./index-4fwbbad3.js";
43
- import"./index-b43rt5ph.js";
44
- import"./index-q7sjgr1y.js";
45
- import {
46
- resolveHiveKnowledgePath
47
- } from "./index-qbw3yw2d.js";
48
- import"./index-ggrp3v00.js";
49
- import"./index-r5q5gd2a.js";
50
- import"./index-3qf1vxtb.js";
51
- import"./index-n832052r.js";
52
- import"./index-zjg4chy2.js";
53
- import"./index-z6xqpmqg.js";
54
- import"./index-r3mvsbtq.js";
55
- import"./index-rhqdsc1x.js";
56
- import"./index-aqppaaqx.js";
57
- import"./index-9e6fdz2h.js";
58
- import"./index-4rhhvd1a.js";
59
- import"./index-dsg9dw3b.js";
60
- import"./index-50j914b5.js";
61
- import"./index-zjygnfay.js";
62
- import"./index-ae75rja9.js";
63
- import"./index-vdn32nws.js";
64
- import"./index-xnb3tk7x.js";
65
- import"./index-bk5tah7q.js";
66
- import"./index-7qefgq4j.js";
67
- import"./index-2bgr671r.js";
68
- import"./index-9gxbjkts.js";
69
- import"./index-ww6zm5hr.js";
70
- import"./index-7g4c7s5r.js";
71
- import"./index-bpmtbmy9.js";
72
- import"./index-zgwm4ryv.js";
73
- import"./index-a76rekgs.js";
74
- export {
75
- resolveHiveKnowledgePath,
76
- promoteToHive,
77
- promoteFromSwarm,
78
- isHiveEligible,
79
- createHivePromoterHook,
80
- countDistinctProjects,
81
- checkHivePromotions,
82
- _internals
83
- };