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
@@ -21,68 +21,70 @@ import {
21
21
  sanitizeWorktreeTaskId,
22
22
  standardWorktreeByCallID,
23
23
  standardWorktreeSerializationSessions
24
- } from "./index-r656jh9j.js";
25
- import"./index-w95vxjde.js";
26
- import"./index-kch6yenm.js";
27
- import"./index-5kcvrpkt.js";
28
- import"./index-77z98j76.js";
29
- import"./index-pp2nya9v.js";
24
+ } from "./index-5wc5pbzc.js";
25
+ import"./index-8d90gzaz.js";
26
+ import"./index-hvz4ad2t.js";
27
+ import"./index-wasdrhev.js";
28
+ import"./index-b25t91a3.js";
29
+ import"./index-k0s8n6m5.js";
30
+ import"./index-x39hjdf1.js";
30
31
  import"./index-txdagbh7.js";
31
32
  import"./index-cw912re7.js";
32
- import"./index-3146wmgv.js";
33
- import"./index-1ww7wj8d.js";
34
- import"./index-7m32fjb4.js";
35
- import"./index-d9entpn3.js";
33
+ import"./index-hb7bh4r2.js";
34
+ import"./index-kxv193aq.js";
35
+ import"./index-40twgsyh.js";
36
36
  import"./index-70ha9e09.js";
37
- import"./index-nqsj0g5y.js";
38
- import"./index-b2nj04q6.js";
39
- import"./index-n4fzmqz8.js";
40
- import"./index-zfs3zqeq.js";
37
+ import"./index-ztm0q26v.js";
38
+ import"./index-9ss2m4rs.js";
39
+ import"./index-d3mpxsmy.js";
41
40
  import"./index-zsrtt42s.js";
42
- import"./index-47kh2103.js";
43
- import"./index-w3gtqey0.js";
44
- import"./index-n8688d12.js";
45
- import"./index-kc2tgcm7.js";
46
- import"./index-ggtmsm84.js";
47
- import"./index-rtry5xyf.js";
48
- import"./index-x43debgx.js";
49
- import"./index-4vb6qa73.js";
50
- import"./index-5jx22kwc.js";
51
- import"./index-c5v1w13g.js";
52
- import"./index-e90em0x4.js";
53
- import"./index-ry16d01s.js";
54
- import"./index-4gqxppcx.js";
55
- import"./index-556ja8an.js";
56
- import"./index-4fwbbad3.js";
41
+ import"./index-r69gzes2.js";
42
+ import"./index-6chhqq2n.js";
43
+ import"./index-xxfk62zd.js";
57
44
  import"./index-b43rt5ph.js";
58
45
  import"./index-q7sjgr1y.js";
59
- import"./index-qbw3yw2d.js";
60
- import"./index-ggrp3v00.js";
46
+ import"./index-ad9064j9.js";
47
+ import"./index-ebce775n.js";
48
+ import"./index-8vw2pjgr.js";
49
+ import"./index-0byep4pe.js";
50
+ import"./index-qqq04n70.js";
51
+ import"./index-z6xqpmqg.js";
52
+ import"./index-p612v1mv.js";
53
+ import"./index-hg09xemc.js";
54
+ import"./index-4mjmnysc.js";
55
+ import"./index-rtry5xyf.js";
61
56
  import {
62
57
  resolveWorktreeIsolationConfig
63
- } from "./index-r5q5gd2a.js";
58
+ } from "./index-qgajv9rd.js";
64
59
  import"./index-3qf1vxtb.js";
65
60
  import"./index-n832052r.js";
66
- import"./index-zjg4chy2.js";
67
- import"./index-z6xqpmqg.js";
68
- import"./index-r3mvsbtq.js";
69
- import"./index-rhqdsc1x.js";
70
- import"./index-aqppaaqx.js";
61
+ import"./index-wknpkfm8.js";
62
+ import"./index-4vb56w2k.js";
63
+ import"./index-mee9maf5.js";
64
+ import"./index-556ja8an.js";
65
+ import"./index-yvqg6kn5.js";
66
+ import"./index-c45662wc.js";
67
+ import"./index-es64amqt.js";
68
+ import"./index-ry16d01s.js";
69
+ import"./index-n4fzmqz8.js";
70
+ import"./index-eed0gkv6.js";
71
+ import"./index-888pq4xx.js";
72
+ import"./index-ae75rja9.js";
73
+ import"./index-sphahrmq.js";
74
+ import"./index-7qefgq4j.js";
75
+ import"./index-2bhz5k91.js";
76
+ import"./index-ewv8qa8q.js";
77
+ import"./index-r2p0pgst.js";
78
+ import"./index-7g4c7s5r.js";
79
+ import"./index-vw66q1rw.js";
71
80
  import"./index-9e6fdz2h.js";
72
81
  import"./index-4rhhvd1a.js";
73
- import"./index-dsg9dw3b.js";
82
+ import"./index-cgewrpw5.js";
74
83
  import"./index-50j914b5.js";
75
84
  import"./index-zjygnfay.js";
76
- import"./index-ae75rja9.js";
77
- import"./index-vdn32nws.js";
78
- import"./index-xnb3tk7x.js";
79
85
  import"./index-bk5tah7q.js";
80
- import"./index-7qefgq4j.js";
81
- import"./index-2bgr671r.js";
82
- import"./index-9gxbjkts.js";
83
- import"./index-ww6zm5hr.js";
84
- import"./index-7g4c7s5r.js";
85
86
  import"./index-bpmtbmy9.js";
87
+ import"./index-4fwbbad3.js";
86
88
  import"./index-zgwm4ryv.js";
87
89
  import"./index-a76rekgs.js";
88
90
  export {
@@ -1,3 +1,4 @@
1
+ import * as fsSync from 'node:fs';
1
2
  import { loadPluginConfigWithMeta } from '../config';
2
3
  import type { Plan } from '../config/plan-schema';
3
4
  import { type KnowledgeConfig, type PluginConfig } from '../config/schema';
@@ -8,6 +9,7 @@ import { runCuratorPostMortem } from '../hooks/curator-postmortem';
8
9
  import { checkHivePromotions } from '../hooks/hive-promoter';
9
10
  import { curateAndStoreSwarm } from '../hooks/knowledge-curator';
10
11
  import { reconcilePhaseClose } from '../hooks/knowledge-receipt-ledger.js';
12
+ import { closeSnapshotCoordinationInitialization } from '../session/snapshot-coordination-init.js';
11
13
  import { closeRepoMemory } from '../tools/repo-graph/indexed-storage';
12
14
  /** Narrow seam for receipt/plan ordering tests. */
13
15
  export declare const closeReceiptLifecycleInternals: {
@@ -19,6 +21,7 @@ export declare const closeReceiptLifecycleInternals: {
19
21
  import { runFinalizeRewardSweep } from '../memory/finalize-reward-sweep';
20
22
  import { type SessionReflectionResult } from '../services/session-reflection';
21
23
  import { endAgentSession, resetSwarmStatePreservingSingletons } from '../state';
24
+ import { collectGarbageBestEffort, sleep } from '../utils/bun-compat.js';
22
25
  import { type CloseTerminalResult } from '../workflow/close-terminal.js';
23
26
  import { type SqliteRowCounts } from './archive-sqlite';
24
27
  interface PlanPhase {
@@ -217,13 +220,12 @@ export declare function runArchiveStage(ctx: CloseStageContext): Promise<void>;
217
220
  */
218
221
  export declare function runArchiveEvidenceRetention(ctx: ArchiveStageContext): Promise<void>;
219
222
  /**
220
- * STAGE 3: CLEAN
221
- *
222
- * Removes active-state files and directories that were successfully archived
223
- * (archive-first guard), plus stale config-backup/ledger-sibling/SWARM_PLAN/.tmp
224
- * artifacts. Resets context.md for the next session. All state mutations are
225
- * written back to ctx so the caller can build the close summary.
223
+ * Delete one archived active-state artifact, tolerating the short-lived file
224
+ * locks Windows antivirus and SQLite sidecars can retain after handle close.
225
+ * Non-transient errors fail immediately; the retry budget is bounded to
226
+ * 375 ms so `/swarm close` remains responsive.
226
227
  */
228
+ declare function unlinkActiveStateFileWithRetry(filePath: string): Promise<void>;
227
229
  export declare function runCleanStage(ctx: CloseStageContext): Promise<CleanStageResult>;
228
230
  /**
229
231
  * STAGE 4: ALIGN
@@ -276,7 +278,12 @@ declare function acquireFinalizeLock(directory: string): Promise<{
276
278
  */
277
279
  declare function detectFullAuto(directory: string, sessionID: string): boolean;
278
280
  export declare const _internals: {
281
+ closeSnapshotCoordinationInitialization: typeof closeSnapshotCoordinationInitialization;
279
282
  closeRepoMemory: typeof closeRepoMemory;
283
+ unlinkActiveStateFileWithRetry: typeof unlinkActiveStateFileWithRetry;
284
+ unlink: typeof fsSync.promises.unlink;
285
+ sleep: typeof sleep;
286
+ collectGarbageBestEffort: typeof collectGarbageBestEffort;
280
287
  ACTIVE_STATE_DIRS_TO_CLEAN: string[];
281
288
  countSessionKnowledgeEntries: typeof countSessionKnowledgeEntries;
282
289
  CLOSE_SKILL_REVIEW_TIMEOUT_MS: number;
@@ -1,4 +1,6 @@
1
1
  import { commitGateReleaseBatch, queryLiveMemberships } from '../hooks/knowledge-receipt-ledger';
2
+ import { beginSnapshotCoordinationReset } from '../session/snapshot-coordination-init.js';
3
+ import { clearSnapshotRows } from '../session/snapshot-store.js';
2
4
  import { recoverStaleCoderSettlements } from '../workflow/coder-settlement.js';
3
5
  import { type OrphanCleanupResult } from '../worktree/merge';
4
6
  import { type ResetBackupResult } from './reset-backup';
@@ -14,6 +16,8 @@ export declare const _internals: {
14
16
  recoverStaleCoderSettlements: typeof recoverStaleCoderSettlements;
15
17
  queryLiveMemberships: typeof queryLiveMemberships;
16
18
  commitGateReleaseBatch: typeof commitGateReleaseBatch;
19
+ beginSnapshotCoordinationReset: typeof beginSnapshotCoordinationReset;
20
+ clearSnapshotRows: typeof clearSnapshotRows;
17
21
  releaseKnowledgeGateObligations: (directory: string, sessionID: string) => Promise<string[]>;
18
22
  };
19
23
  /**
@@ -0,0 +1,85 @@
1
+ /** Transactional coordination authority for issue #2481. */
2
+ import type { Database } from 'bun:sqlite';
3
+ export declare const MAX_COORDINATION_STATE_LIST_ROWS = 25000;
4
+ export type CoordinationFaultPoint = 'before_begin' | 'after_event_before_state' | 'before_outer_commit' | 'after_commit_before_archive';
5
+ export declare const _internals: {
6
+ coordinationFaultInjector?: (point: CoordinationFaultPoint, db: Database) => void;
7
+ maxEventsPerStream: number;
8
+ maxTotalEvents: number;
9
+ maxEventFencesPerStream: number;
10
+ maxTotalEventFences: number;
11
+ };
12
+ export interface CoordinationState {
13
+ namespace: string;
14
+ entityKey: string;
15
+ revision: number;
16
+ generation: number;
17
+ status: string;
18
+ payload: string;
19
+ updatedAt: string;
20
+ }
21
+ export interface CoordinationEventInput {
22
+ streamId: string;
23
+ idempotencyKey: string;
24
+ eventType: string;
25
+ payload: string;
26
+ /** Optional compare-and-swap fence for the append-only stream. */
27
+ expectedStreamVersion?: number;
28
+ }
29
+ export interface CoordinationTransitionInput {
30
+ namespace: string;
31
+ entityKey: string;
32
+ expectedRevision?: number | null;
33
+ generation: number;
34
+ status: string;
35
+ payload: string;
36
+ event?: CoordinationEventInput;
37
+ }
38
+ export type CoordinationTransitionOutcome = 'applied' | 'duplicate' | 'idempotency_conflict' | 'revision_conflict' | 'stream_version_conflict' | 'stale_generation';
39
+ export interface CoordinationTransitionResult {
40
+ outcome: CoordinationTransitionOutcome;
41
+ state: CoordinationState | null;
42
+ }
43
+ export declare function withCoordinationTransaction<T>(directory: string, fn: () => T): T;
44
+ export declare function getCoordinationState(directory: string, namespace: string, entityKey: string): CoordinationState | null;
45
+ export declare function listCoordinationStates(directory: string, namespace: string, limit?: number): CoordinationState[];
46
+ /** Return the exact number of authoritative rows in one coordination namespace. */
47
+ export declare function countCoordinationStates(directory: string, namespace: string): number;
48
+ export declare function deleteCoordinationState(directory: string, namespace: string, entityKey: string, expectedRevision?: number): boolean;
49
+ /** Delete one coordination row inside a caller-owned transaction. */
50
+ export declare function deleteCoordinationStateWithinTransaction(directory: string, namespace: string, entityKey: string, expectedRevision?: number): boolean;
51
+ /**
52
+ * Apply one transition inside an already-owned coordination transaction.
53
+ *
54
+ * This is intentionally narrow: orchestration that must make several state
55
+ * transitions all-or-nothing uses it while holding `withCoordinationTransaction`.
56
+ * It must never become a general replacement for `transitionCoordinationState`,
57
+ * which owns the transaction for ordinary callers.
58
+ */
59
+ export declare function transitionCoordinationStateWithinTransaction(directory: string, input: CoordinationTransitionInput): CoordinationTransitionResult;
60
+ export declare function transitionCoordinationState(directory: string, input: CoordinationTransitionInput): CoordinationTransitionResult;
61
+ export interface CoordinationLeaseInput {
62
+ namespace: string;
63
+ entityKey: string;
64
+ generation: number;
65
+ ownerToken: string;
66
+ leaseExpiresAt: string;
67
+ payload: string;
68
+ }
69
+ export interface CoordinationLease extends CoordinationLeaseInput {
70
+ updatedAt: string;
71
+ }
72
+ export declare function getCoordinationLease(directory: string, namespace: string, entityKey: string): CoordinationLease | null;
73
+ export declare function acquireCoordinationLease(directory: string, input: CoordinationLeaseInput): {
74
+ outcome: 'acquired' | 'held' | 'stale_generation';
75
+ };
76
+ export declare function releaseCoordinationLease(directory: string, namespace: string, entityKey: string, generation: number, ownerToken: string): boolean;
77
+ export interface CoordinationImportInput {
78
+ source: string;
79
+ sourceDigest: string;
80
+ rowCount: number;
81
+ emptyNamespace: string;
82
+ }
83
+ export declare function importCoordinationOnce(directory: string, input: CoordinationImportInput, importer: () => void): 'imported' | 'already_imported' | 'state_exists';
84
+ /** Remove import markers for an operator reset of a specific authority. */
85
+ export declare function deleteCoordinationImports(directory: string, sources: readonly string[]): number;
@@ -31,10 +31,27 @@ export declare function applySynchronousForClass(db: Database, cls: 'full' | 'no
31
31
  * "the previous value" — is the correct post-condition: nothing outside the
32
32
  * foundation ever sets a different value on this connection.
33
33
  *
34
- * NESTING CAVEAT (final-critic note): nesting a normal-class helper inside an
35
- * open full-class transaction would restore NORMAL before the OUTER commit.
36
- * No production path nests these helpers today (group-commit ops never call
37
- * the qa-gate/receipt writers); if nesting is ever introduced, restore the
38
- * pre-call value instead.
34
+ * This low-level pragma helper does not own a transaction and therefore must
35
+ * not be nested. Transactional callers use `withImmediateTransaction`, whose
36
+ * owner tracking prevents a nested helper from lowering the outer commit's
37
+ * durability.
39
38
  */
40
39
  export declare function withDurabilityClass<T>(db: Database, cls: 'full' | 'normal', fn: () => T): T;
40
+ type TransactionOwner = {
41
+ readonly durability: 'full' | 'normal';
42
+ depth: number;
43
+ };
44
+ export interface ImmediateTransactionHooks {
45
+ beforeBegin?: (db: Database) => void;
46
+ beforeOuterCommit?: (db: Database) => void;
47
+ afterOuterCommit?: (db: Database) => void;
48
+ }
49
+ /**
50
+ * Run a synchronous immediate transaction without allowing a nested call to
51
+ * lower the connection durability before the real outer commit (#2481).
52
+ */
53
+ export declare function withImmediateTransaction<T>(db: Database, cls: 'full' | 'normal', fn: () => T, hooks?: ImmediateTransactionHooks): T;
54
+ export declare const _transactionInternals: {
55
+ transactionOwners: WeakMap<Database, TransactionOwner>;
56
+ };
57
+ export {};
@@ -11,6 +11,7 @@
11
11
  * (native `bun:sqlite` under Bun, a `node:sqlite` adapter under Node — issue
12
12
  * #1873). Used by `global-db`, `project-db`, and the memory SQLite provider.
13
13
  */
14
+ export { acquireCoordinationLease, type CoordinationLease, type CoordinationState, countCoordinationStates, deleteCoordinationImports, deleteCoordinationState, deleteCoordinationStateWithinTransaction, getCoordinationLease, getCoordinationState, importCoordinationOnce, listCoordinationStates, MAX_COORDINATION_STATE_LIST_ROWS, releaseCoordinationLease, transitionCoordinationState, transitionCoordinationStateWithinTransaction, withCoordinationTransaction, } from './coordination-store.js';
14
15
  export { closeGlobalDb, getGlobalDb, runGlobalMigrations, } from './global-db.js';
15
16
  export { closeAllProjectDbs, closeProjectDb, getProjectDb, projectDbExists, projectDbPath, runProjectMigrations, } from './project-db.js';
16
17
  export { computeProfileHash, DEFAULT_QA_GATES, getEffectiveGates, getOrCreateProfile, getOrCreateProfileForIdentity, getProfile, getProfileForIdentity, getProfileLookupForIdentity, hasAnyProfileWithEnabledGate, lockProfile, lockProfileForIdentity, type QaGateProfile, type QaGateProfileIdentity, QaGateProfileIdentityUnboundError, type QaGateProfileLookupForIdentity, type QaGates, type SetGatesForIdentityOptions, setGates, setGatesForIdentity, } from './qa-gate-profile.js';
@@ -39,6 +39,16 @@ export declare function projectDbPath(directory: string): string;
39
39
  * workspace just to check for a missing record.
40
40
  */
41
41
  export declare function projectDbExists(directory: string): boolean;
42
+ /**
43
+ * Best-effort WAL checkpoint before close (issue #2480 checkpoint policy).
44
+ *
45
+ * `wal_checkpoint(TRUNCATE)` reports contention through its result row
46
+ * (`busy = 1`) rather than blocking, so a contended checkpoint degrades to
47
+ * PASSIVE and then gives up — close must never hang or throw. The WAL
48
+ * sidecars surviving a contended checkpoint is safe: SQLite recovers them
49
+ * on the next open.
50
+ */
51
+ declare function checkpointWalBestEffort(db: Database): void;
42
52
  /**
43
53
  * Return the cached project database for the given directory, opening it
44
54
  * if needed. Creates `.swarm/` if absent and enables WAL + foreign keys.
@@ -68,6 +78,8 @@ export declare function closeProjectDb(directory: string): void;
68
78
  */
69
79
  export declare function closeAllProjectDbs(): void;
70
80
  export declare const _internals: {
81
+ checkpointWalBestEffort: typeof checkpointWalBestEffort;
71
82
  projectDbCount: () => number;
72
83
  projectDbAliasCount: () => number;
73
84
  };
85
+ export {};