opencode-swarm 7.171.2 → 7.172.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +5 -0
  2. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  3. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  4. package/dist/background/delegation-lifecycle.d.ts +21 -5
  5. package/dist/background/pending-delegations.d.ts +118 -6
  6. package/dist/cli/ast-diff-f2a1y02y.js +13 -0
  7. package/dist/cli/{coder-settlement-9e696204.js → coder-settlement-0k46xqk2.js} +14 -14
  8. package/dist/cli/{config-doctor-zr748h4m.js → config-doctor-x41bxjp6.js} +6 -6
  9. package/dist/cli/{core-aa3jmzcs.js → core-3spww0at.js} +5 -5
  10. package/dist/cli/{curation-policy-fakrpw5t.js → curation-policy-92qhvewe.js} +7 -7
  11. package/dist/cli/{curator-drift-r9r8gepb.js → curator-drift-fqvxe2zw.js} +8 -8
  12. package/dist/cli/{curator-xgpxtaf1.js → curator-eyz6gg74.js} +45 -45
  13. package/dist/cli/curator-llm-factory-jnsjqq99.js +72 -0
  14. package/dist/cli/{dispatch-hwwj3qrb.js → dispatch-9yqqqfr6.js} +2 -2
  15. package/dist/cli/{evidence-summary-service-5e2323zr.js → evidence-summary-service-kf0vb1hf.js} +22 -22
  16. package/dist/cli/{gate-evidence-5htpsr5y.js → gate-evidence-89wvxgs9.js} +9 -9
  17. package/dist/cli/guardrail-explain-rz4kaqyp.js +73 -0
  18. package/dist/cli/guardrail-log-kfjk62sz.js +23 -0
  19. package/dist/cli/{guardrail-reset-rdqxeqy0.js → guardrail-reset-d8m1h5sz.js} +45 -45
  20. package/dist/cli/hive-promoter-0ekf5zp1.js +87 -0
  21. package/dist/cli/{index-qcy7eg6z.js → index-0y2ygy5f.js} +154 -37
  22. package/dist/cli/{index-aa2eyfvr.js → index-12w05bxk.js} +2 -2
  23. package/dist/cli/{index-95e3a9en.js → index-1s3t3jdc.js} +1 -1
  24. package/dist/cli/{index-f1rj1j8t.js → index-1vsmh63p.js} +2713 -1429
  25. package/dist/cli/{index-gq2zdxep.js → index-25fa4krx.js} +8 -8
  26. package/dist/cli/{index-qdy4a48x.js → index-29j9sjbw.js} +3 -3
  27. package/dist/cli/{index-wfh89qct.js → index-2rdj9mdh.js} +4 -4
  28. package/dist/cli/{index-dsgc303n.js → index-328eg2bb.js} +4 -4
  29. package/dist/cli/{index-nyn01yrz.js → index-34jdempk.js} +2 -2
  30. package/dist/cli/{index-9txyxbqc.js → index-39x78qk0.js} +8 -8
  31. package/dist/cli/{index-5a8q4qr5.js → index-3kqzzwvd.js} +2 -2
  32. package/dist/cli/{index-r60cw2jt.js → index-53ges0rk.js} +7 -7
  33. package/dist/cli/{index-2ryy0cwt.js → index-5hambjmn.js} +6 -6
  34. package/dist/cli/{index-vqb65csb.js → index-63t4m2t5.js} +16 -16
  35. package/dist/cli/{index-0caqxnby.js → index-677gzqmd.js} +1 -1
  36. package/dist/cli/{index-b3pmzbh1.js → index-6fb3y9pm.js} +2 -2
  37. package/dist/cli/{index-e7yv4xw1.js → index-6jshhpjw.js} +3 -3
  38. package/dist/cli/{index-j6rq132j.js → index-7q1m8rsw.js} +7 -7
  39. package/dist/cli/{index-rrc08h4q.js → index-8k09fkqj.js} +5 -5
  40. package/dist/cli/{index-mazy938h.js → index-8wnjcav5.js} +4 -4
  41. package/dist/cli/{index-nbdmdyke.js → index-a2kv054j.js} +1 -1
  42. package/dist/cli/{index-9dz2ee2g.js → index-br3r0y73.js} +67 -47
  43. package/dist/cli/{index-ee6ydtfe.js → index-c1ggtmpm.js} +1 -1
  44. package/dist/cli/{index-evxd1art.js → index-dga9j6s1.js} +2 -2
  45. package/dist/cli/{index-nfs78aqj.js → index-dpb1xs5m.js} +2 -2
  46. package/dist/cli/{index-sxt7fgcw.js → index-ecaws78e.js} +1 -1
  47. package/dist/cli/{index-yqbnsmmv.js → index-efkckdaw.js} +1 -1
  48. package/dist/cli/{index-cw912re7.js → index-fpbcxykc.js} +1 -1
  49. package/dist/cli/{index-3qf1vxtb.js → index-frcemc0b.js} +1 -1
  50. package/dist/cli/{index-bpmtbmy9.js → index-gknz3bv1.js} +1 -1
  51. package/dist/cli/{index-11gz0few.js → index-gmw8a1qa.js} +1 -1
  52. package/dist/cli/{index-5400m33a.js → index-hnvmj9wx.js} +1 -1
  53. package/dist/cli/{index-ph94evsh.js → index-jvg7hvjp.js} +7 -7
  54. package/dist/cli/{index-g6nen3gt.js → index-k441jgzk.js} +1 -1
  55. package/dist/cli/{index-6k5aq7b9.js → index-mj07x42s.js} +2 -2
  56. package/dist/cli/{index-kb66he4e.js → index-nqbmk4b9.js} +1 -1
  57. package/dist/cli/{index-er6sk4e6.js → index-nyrhz1h1.js} +2 -2
  58. package/dist/cli/{index-b43rt5ph.js → index-pt7h91zc.js} +19 -1
  59. package/dist/cli/{ast-diff-b0esr2kf.js → index-qss1s93b.js} +3 -6
  60. package/dist/cli/{index-04ph4jp2.js → index-r08tgb71.js} +2 -2
  61. package/dist/cli/{index-3jcp3zb6.js → index-s723hx7z.js} +2 -2
  62. package/dist/cli/{index-jr6pypmj.js → index-tfmb620d.js} +45 -45
  63. package/dist/cli/{index-7qqwx64h.js → index-v2fge66b.js} +8 -8
  64. package/dist/cli/{index-fhh02gwx.js → index-v6msnkz2.js} +2 -2
  65. package/dist/cli/{index-7hnjs7tf.js → index-w1d5nsdc.js} +2 -2
  66. package/dist/cli/{index-n832052r.js → index-wrt875kh.js} +1 -1
  67. package/dist/cli/{index-9vfp6g53.js → index-xn9tm7sr.js} +47 -47
  68. package/dist/cli/{index-d79q2f8z.js → index-y8y2bjsy.js} +4 -4
  69. package/dist/cli/{semantic-classifier-ygqk0me1.js → index-ykamkw55.js} +2 -5
  70. package/dist/cli/{index-9br68j86.js → index-z2deqhpp.js} +1 -1
  71. package/dist/cli/{index-0yffa3np.js → index-z81mxyhm.js} +5 -5
  72. package/dist/cli/{index-q2yk70rs.js → index-zbw6h4xn.js} +4 -3
  73. package/dist/cli/index.js +53 -47
  74. package/dist/cli/{knowledge-escalator-kn74r5w8.js → knowledge-escalator-qtz01ffw.js} +17 -17
  75. package/dist/cli/{knowledge-events-7gpw741m.js → knowledge-events-8w0mvkzc.js} +15 -15
  76. package/dist/cli/{knowledge-link-vh9pfnb9.js → knowledge-link-3xp7h4xn.js} +6 -6
  77. package/dist/cli/{knowledge-store-3f9kke7z.js → knowledge-store-p5ps09qg.js} +7 -7
  78. package/dist/cli/{knowledge-validator-c2z68v8v.js → knowledge-validator-rc63wfkp.js} +9 -9
  79. package/dist/cli/mcp-pmfg7wpk.js +78 -0
  80. package/dist/cli/mcp.d.ts +27 -0
  81. package/dist/cli/{model-preflight-1ycat9jz.js → model-preflight-2mvdbj0c.js} +1 -1
  82. package/dist/cli/{pending-delegations-d5c07rb7.js → pending-delegations-1sg6g7et.js} +21 -13
  83. package/dist/cli/{pr-subscriptions-krv0jvds.js → pr-subscriptions-yd804apk.js} +13 -13
  84. package/dist/cli/{pr-workflow-gate-hmdht1he.js → pr-workflow-gate-pf3ssffq.js} +45 -45
  85. package/dist/cli/{runner-8m8qhngm.js → runner-rry4z6j2.js} +7 -7
  86. package/dist/cli/{scan-cursor-b57xxs3q.js → scan-cursor-j93ek248.js} +8 -8
  87. package/dist/cli/{schema-r8tv8dqm.js → schema-hvptm5hf.js} +3 -3
  88. package/dist/cli/{scope-persistence-0sc90mpj.js → scope-persistence-3tfvswtk.js} +17 -17
  89. package/dist/cli/semantic-classifier-bjsez0v5.js +8 -0
  90. package/dist/cli/server-rbvx63t6.js +18129 -0
  91. package/dist/cli/{skill-generator-syxa1mxm.js → skill-generator-r9wc6xt1.js} +19 -19
  92. package/dist/cli/snapshot-coordination-init-7w5em40w.js +86 -0
  93. package/dist/cli/{telemetry-0mz37v3h.js → telemetry-vw919tfm.js} +3 -3
  94. package/dist/cli/{workspace-snapshot-hkz2wt1c.js → workspace-snapshot-x54wxr6a.js} +4 -4
  95. package/dist/cli/{worktree-collision-ownership-1tzw8qzp.js → worktree-collision-ownership-yetwf2ch.js} +14 -14
  96. package/dist/cli/{worktree-isolation-ez0e48v3.js → worktree-isolation-sxfj78hv.js} +45 -45
  97. package/dist/hooks/pr-workflow-gate.d.ts +14 -2
  98. package/dist/hooks/pr-workflow-session-resolver.d.ts +45 -0
  99. package/dist/hooks/search-knowledge.d.ts +7 -0
  100. package/dist/index.js +102 -102
  101. package/dist/mcp/adapters/knowledge-memory.d.ts +16 -0
  102. package/dist/mcp/adapters/scope-repo.d.ts +14 -0
  103. package/dist/mcp/adapters/verification.d.ts +20 -0
  104. package/dist/mcp/pipeline.d.ts +25 -0
  105. package/dist/mcp/registry.d.ts +47 -0
  106. package/dist/mcp/server.d.ts +35 -0
  107. package/dist/memory/gateway.d.ts +9 -1
  108. package/dist/observability/catalog.d.ts +4 -3
  109. package/dist/pr-review/completion.d.ts +12 -0
  110. package/dist/telemetry.d.ts +11 -1
  111. package/dist/tools/dispatch-lanes.d.ts +5 -1
  112. package/dist/tools/placeholder-scan.d.ts +10 -0
  113. package/dist/tools/pr-workflow-status.d.ts +6 -0
  114. package/dist/tools/quality-budget.d.ts +10 -0
  115. package/dist/tools/repo-map.d.ts +5 -0
  116. package/dist/tools/sast-scan.d.ts +11 -0
  117. package/dist/tools/swarm-memory-recall.d.ts +12 -0
  118. package/dist/tools/syntax-check.d.ts +12 -1
  119. package/package.json +2 -1
  120. package/dist/cli/curator-llm-factory-nshzhgs4.js +0 -72
  121. package/dist/cli/guardrail-explain-d0h0p73g.js +0 -73
  122. package/dist/cli/guardrail-log-heejmjce.js +0 -23
  123. package/dist/cli/hive-promoter-n262tkm3.js +0 -87
  124. package/dist/cli/snapshot-coordination-init-x18mwxyv.js +0 -86
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-b3pmzbh1.js";
4
+ } from "./index-6fb3y9pm.js";
5
5
  import {
6
6
  bunWrite
7
7
  } from "./index-2s7dvzff.js";
@@ -18,18 +18,21 @@ import {
18
18
  releaseCoordinationLease,
19
19
  transitionCoordinationState,
20
20
  withCoordinationTransaction
21
- } from "./index-g6nen3gt.js";
21
+ } from "./index-k441jgzk.js";
22
22
  import {
23
23
  getProjectDb,
24
24
  projectDbExists
25
- } from "./index-yqbnsmmv.js";
25
+ } from "./index-efkckdaw.js";
26
26
  import {
27
27
  observeDelegationLedgerPressure
28
- } from "./index-nfs78aqj.js";
28
+ } from "./index-dpb1xs5m.js";
29
29
  import {
30
30
  EvidenceLockTimeoutError,
31
31
  withEvidenceLock
32
- } from "./index-evxd1art.js";
32
+ } from "./index-dga9j6s1.js";
33
+ import {
34
+ telemetry
35
+ } from "./index-br3r0y73.js";
33
36
  import {
34
37
  canonicalRootKeyFresh,
35
38
  sameProjectRoot
@@ -37,7 +40,7 @@ import {
37
40
  import {
38
41
  exports_external,
39
42
  init_zod
40
- } from "./index-bpmtbmy9.js";
43
+ } from "./index-gknz3bv1.js";
41
44
  import {
42
45
  criticalWarn,
43
46
  init_logger,
@@ -1620,6 +1623,14 @@ var ManifestSchema = exports_external.object({
1620
1623
  updatedAt: exports_external.number().int().nonnegative()
1621
1624
  }).strict();
1622
1625
  var WRITER_ID = `w-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
1626
+ function portableSyncSleep(ms) {
1627
+ try {
1628
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
1629
+ } catch {
1630
+ const start = Date.now();
1631
+ while (Date.now() - start < ms) {}
1632
+ }
1633
+ }
1623
1634
  var _checkpointInternals = {
1624
1635
  renameWithRetry: (from, to) => {
1625
1636
  let lastError;
@@ -1641,14 +1652,7 @@ var _checkpointInternals = {
1641
1652
  renameOnce: (from, to) => {
1642
1653
  fs2.renameSync(from, to);
1643
1654
  },
1644
- syncSleep: (ms) => {
1645
- try {
1646
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
1647
- } catch {
1648
- const start = Date.now();
1649
- while (Date.now() - start < ms) {}
1650
- }
1651
- }
1655
+ syncSleep: portableSyncSleep
1652
1656
  };
1653
1657
  function writeDurableFileSync(target, contents) {
1654
1658
  const tmp = `${target}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
@@ -2541,22 +2545,100 @@ function maybeCompactDelegationsLocked(directory) {
2541
2545
  function ensureSwarmDir(directory) {
2542
2546
  fs2.mkdirSync(path2.resolve(directory, ".swarm"), { recursive: true });
2543
2547
  }
2544
- function readDelegations(directory) {
2548
+ var DELEGATION_READ_RETRY_DELAY_MS = 25;
2549
+ var MAX_TRACKED_DELEGATION_READ_UNCERTAIN_ROOTS = 32;
2550
+ var DELEGATION_READ_UNCERTAIN_EMIT_COOLDOWN_MS = 60000;
2551
+ var delegationReadUncertainEmitAtByRoot = new Map;
2552
+ var delegationReadUncertainEmitOrder = [];
2553
+ var DELEGATION_READ_REASON_MAX_CHARS = 200;
2554
+ function readDelegationLoadAttempt(directory) {
2545
2555
  const importState = ensureDelegationCoordinationImported(directory, false);
2546
- if (importState === "uncertain")
2547
- return [];
2556
+ if (importState === "uncertain") {
2557
+ return {
2558
+ status: "uncertain",
2559
+ reason: "background delegation coordination state is uncertain",
2560
+ source: "coordination-import",
2561
+ attempts: 1
2562
+ };
2563
+ }
2548
2564
  if (importState === "ready") {
2549
2565
  const coordination = coordinationRowsToDelegations(directory);
2550
- if (coordination !== null)
2551
- return coordination;
2552
- return [];
2566
+ if (coordination !== null) {
2567
+ return { status: "ok", records: coordination, source: "coordination" };
2568
+ }
2569
+ return {
2570
+ status: "uncertain",
2571
+ reason: "background delegation coordination state is unreadable or over-bound",
2572
+ source: "coordination-read",
2573
+ attempts: 1
2574
+ };
2553
2575
  }
2554
2576
  const load = loadFoldedState(directory, { strict: false });
2555
2577
  if (load.status === "uncertain") {
2556
- warn(`[background] readDelegations: authoritative state uncertain (${load.reason}); returning empty`);
2557
- return [];
2578
+ return {
2579
+ status: "uncertain",
2580
+ reason: `background delegation store is unreadable: ${load.reason.slice(0, DELEGATION_READ_REASON_MAX_CHARS)}`,
2581
+ source: "fold",
2582
+ attempts: 1,
2583
+ ...load.repairHint ? { repairHint: load.repairHint } : {}
2584
+ };
2558
2585
  }
2559
- return [...load.records.values()];
2586
+ const loadSource = load.mode === "legacy" ? "legacy-ledger" : load.mode;
2587
+ return {
2588
+ status: "ok",
2589
+ records: [...load.records.values()],
2590
+ source: loadSource
2591
+ };
2592
+ }
2593
+ function emitDelegationReadUncertainBounded(directory, outcome) {
2594
+ try {
2595
+ const rootKey = canonicalRootKeyFresh(directory);
2596
+ const now = Date.now();
2597
+ const last = delegationReadUncertainEmitAtByRoot.get(rootKey);
2598
+ if (last !== undefined && now - last < _internals.delegationReadUncertainEmitCooldownMs) {
2599
+ return;
2600
+ }
2601
+ delegationReadUncertainEmitAtByRoot.delete(rootKey);
2602
+ delegationReadUncertainEmitAtByRoot.set(rootKey, now);
2603
+ const priorOccurrence = delegationReadUncertainEmitOrder.indexOf(rootKey);
2604
+ if (priorOccurrence >= 0) {
2605
+ delegationReadUncertainEmitOrder.splice(priorOccurrence, 1);
2606
+ }
2607
+ delegationReadUncertainEmitOrder.push(rootKey);
2608
+ while (delegationReadUncertainEmitOrder.length > 0) {
2609
+ if (delegationReadUncertainEmitOrder.length <= MAX_TRACKED_DELEGATION_READ_UNCERTAIN_ROOTS) {
2610
+ break;
2611
+ }
2612
+ const evicted = delegationReadUncertainEmitOrder.shift();
2613
+ if (evicted === undefined)
2614
+ break;
2615
+ delegationReadUncertainEmitAtByRoot.delete(evicted);
2616
+ }
2617
+ const reasonCode = outcome.reason.split("(")[0].trim().split(/\s+/).slice(0, 6).join("_").slice(0, 64);
2618
+ telemetry.delegationReadUncertain({
2619
+ attempt: outcome.attempts,
2620
+ reasonCode,
2621
+ source: outcome.source
2622
+ });
2623
+ } catch {}
2624
+ }
2625
+ function readDelegationsDetailed(directory) {
2626
+ const first = readDelegationLoadAttempt(directory);
2627
+ if (first.status === "ok")
2628
+ return first;
2629
+ portableSyncSleep(_internals.readRetryDelayMs);
2630
+ const second = readDelegationLoadAttempt(directory);
2631
+ if (second.status === "ok")
2632
+ return second;
2633
+ const finalOutcome = { ...second, attempts: 2 };
2634
+ recordLedgerUncertainty(directory, finalOutcome.reason, `advisory-${finalOutcome.source}`, finalOutcome.repairHint);
2635
+ emitDelegationReadUncertainBounded(directory, finalOutcome);
2636
+ warn(`[background] readDelegationsDetailed: authoritative state uncertain after retry (${finalOutcome.reason}); treating the store as unknown, not empty`);
2637
+ return finalOutcome;
2638
+ }
2639
+ function readDelegations(directory) {
2640
+ const outcome = readDelegationsDetailed(directory);
2641
+ return outcome.status === "ok" ? outcome.records : [];
2560
2642
  }
2561
2643
  function scanDelegationsForRecovery(directory) {
2562
2644
  const importState = ensureDelegationCoordinationImported(directory, false);
@@ -2595,14 +2677,22 @@ function scanDelegationsForRecovery(directory) {
2595
2677
  const source = load.mode === "legacy" ? "legacy-ledger" : load.mode;
2596
2678
  return { status: "ok", owners: [...load.records.values()], source };
2597
2679
  }
2598
- function findByCorrelationId(directory, correlationId) {
2680
+ function findByCorrelationIdDetailed(directory, correlationId) {
2599
2681
  if (!correlationId)
2600
- return null;
2601
- for (const record of readDelegations(directory)) {
2602
- if (record.correlationId === correlationId)
2603
- return record;
2682
+ return { status: "ok", value: null };
2683
+ const read = readDelegationsDetailed(directory);
2684
+ if (read.status === "uncertain")
2685
+ return read;
2686
+ for (const record of read.records) {
2687
+ if (record.correlationId === correlationId) {
2688
+ return { status: "ok", value: record };
2689
+ }
2604
2690
  }
2605
- return null;
2691
+ return { status: "ok", value: null };
2692
+ }
2693
+ function findByCorrelationId(directory, correlationId) {
2694
+ const outcome = findByCorrelationIdDetailed(directory, correlationId);
2695
+ return outcome.status === "ok" ? outcome.value : null;
2606
2696
  }
2607
2697
  function appendRecord(directory, record) {
2608
2698
  const importState = ensureDelegationCoordinationImported(directory, true);
@@ -3251,6 +3341,16 @@ function getLegacyCoderSettlementReconciler(directory) {
3251
3341
  return legacyCoderSettlementReconcilers.get(canonicalRootKeyFresh(directory));
3252
3342
  }
3253
3343
  var _internals = {
3344
+ readRetryDelayMs: DELEGATION_READ_RETRY_DELAY_MS,
3345
+ delegationReadUncertainEmitCooldownMs: DELEGATION_READ_UNCERTAIN_EMIT_COOLDOWN_MS,
3346
+ resetDelegationReadUncertainRegistry: () => {
3347
+ delegationReadUncertainEmitAtByRoot.clear();
3348
+ delegationReadUncertainEmitOrder.length = 0;
3349
+ },
3350
+ delegationReadUncertainEmitOrderSnapshot: () => [
3351
+ ...delegationReadUncertainEmitOrder
3352
+ ],
3353
+ delegationReadUncertainCooldownsSnapshot: () => new Map(delegationReadUncertainEmitAtByRoot),
3254
3354
  getLegacyCoderSettlementReconciler,
3255
3355
  readFallbackDirectory,
3256
3356
  getLegacyCoderSettlementReconcilerOrder: () => [
@@ -3642,10 +3742,20 @@ async function acknowledgeObservedBackgroundAdvisories(directory, parentSessionI
3642
3742
  async function releasePreparedBackgroundAdvisories(directory, parentSessionId, preparationId, eventIds) {
3643
3743
  return releaseBackgroundAdvisoryPreparation(directory, parentSessionId, preparationId, eventIds);
3644
3744
  }
3645
- function findByBatchId(directory, batchId, opts) {
3745
+ function findByBatchIdDetailed(directory, batchId, opts) {
3646
3746
  if (!batchId)
3647
- return [];
3648
- return readDelegations(directory).filter((record) => record.batchId === batchId && (opts?.parentSessionId === undefined || record.parentSessionId === opts.parentSessionId));
3747
+ return { status: "ok", value: [] };
3748
+ const read = readDelegationsDetailed(directory);
3749
+ if (read.status === "uncertain")
3750
+ return read;
3751
+ return {
3752
+ status: "ok",
3753
+ value: read.records.filter((record) => record.batchId === batchId && (opts?.parentSessionId === undefined || record.parentSessionId === opts.parentSessionId))
3754
+ };
3755
+ }
3756
+ function findByBatchId(directory, batchId, opts) {
3757
+ const outcome = findByBatchIdDetailed(directory, batchId, opts);
3758
+ return outcome.status === "ok" ? outcome.value : [];
3649
3759
  }
3650
3760
  function findOpenAsyncLaneBatches(directory) {
3651
3761
  return readDelegations(directory).filter((record) => record.batchId !== undefined && (record.status === "pending" || record.status === "running"));
@@ -3899,9 +4009,16 @@ async function removeDelegationFallback(directory, correlationId) {
3899
4009
  async function findDelegationForCompletion(directory, correlationId) {
3900
4010
  if (!correlationId)
3901
4011
  return null;
3902
- const primary = findByCorrelationId(directory, correlationId);
3903
- if (primary)
3904
- return { source: "primary", record: primary };
4012
+ const primary = findByCorrelationIdDetailed(directory, correlationId);
4013
+ if (primary.status === "uncertain") {
4014
+ return {
4015
+ source: "uncertain",
4016
+ record: null,
4017
+ uncertain: `delegation store unreadable after ${primary.attempts} attempts (${primary.reason})`
4018
+ };
4019
+ }
4020
+ if (primary.value)
4021
+ return { source: "primary", record: primary.value };
3905
4022
  const fallback = await readDelegationFallback(directory, correlationId);
3906
4023
  return fallback ? { source: "fallback", record: fallback.record, fallback } : null;
3907
4024
  }
@@ -4524,7 +4641,7 @@ async function reconcileLegacyCoderSettlements(directory, maxRecords, onReconcil
4524
4641
  const candidates = readDelegations(directory).filter((record) => record.normalizedAgent === "coder" && Boolean(record.legacyCoderSettlementTransfer) && Boolean(record.terminalResult)).slice(0, maxRecords);
4525
4642
  if (candidates.length === 0)
4526
4643
  return 0;
4527
- const { transferCoderSettlementToBackground } = await import("./coder-settlement-9e696204.js");
4644
+ const { transferCoderSettlementToBackground } = await import("./coder-settlement-0k46xqk2.js");
4528
4645
  let transferred = 0;
4529
4646
  for (const record of candidates) {
4530
4647
  try {
@@ -4881,4 +4998,4 @@ async function maintainBackgroundDelegations(directory, options = {}) {
4881
4998
  return emitObservation("ok");
4882
4999
  }
4883
5000
 
4884
- export { prReviewFindingRequiresCritic, PR_REVIEW_BASE_DIMENSION_IDS, PR_REVIEW_RISK_IMPACTS, PR_REVIEW_RISK_TAGS, prReviewLegacyTranscriptCompatibilityEnabled, PrReviewLaneResultEnvelopeSchema, decodePrReviewWorkflowBinding, prReviewLaneResultEnvelopeDigest, PrReviewResultReceiptSchema, PR_REVIEW_FINDINGS_MAX_BYTES, PR_REVIEW_HANDOFF_MAX_BYTES, PR_REVIEW_DISCARDED_EXAMPLE_ITEM_ID, PrReviewRunIdSchema, parsePrReviewRiskTagsField, PrReviewReviewerVerdictFieldsSchema, PrReviewCriticVerdictFieldsSchema, parsePrReviewVerdictRow, generatePrReviewRunId, MAX_RECOVERY_LEDGER_BYTES, readDelegationHealthArtifact, collectDelegationLedgerHealth, MAX_PR_REVIEW_COLLECTION_RECEIPT_ITEM_IDS, BACKGROUND_DELEGATIONS_FILE, BACKGROUND_DELEGATION_FALLBACK_DIR, BACKGROUND_CODER_RESERVATIONS_FILE, BACKGROUND_DELEGATIONS_CHECKPOINT_FILE, BACKGROUND_DELEGATIONS_MANIFEST_FILE, MAX_LIVE_BACKGROUND_FALLBACKS, MAX_LIVE_BACKGROUND_CODER_RESERVATIONS, MAX_BACKGROUND_OBSERVED_FILES, MAX_BACKGROUND_ADVISORY_CHARS, LEGACY_CODER_SETTLEMENT_PENDING_ADVISORY_MARKER, DELEGATION_COMPACTION_LOW_WATER_BYTES, DELEGATION_COMPACTION_HIGH_WATER_BYTES, MAX_CHECKPOINT_BYTES, MAX_CHECKPOINT_RECORDS, TOMBSTONE_MIN_AGE_MS, BACKGROUND_INGESTION_LEASE_MS, BACKGROUND_CODER_RESERVATION_LEASE_MS, BACKGROUND_CODER_RESERVATION_LEASE_MAX_MS, BACKGROUND_CODER_RESERVATION_LEASE_MIN_MS, DEFAULT_STALE_DELEGATION_TIMEOUT_MS, DEFAULT_SWEEPABLE_DELEGATION_STATUSES, _checkpointInternals, isUnsettledWorktreeOwner, compactBackgroundDelegations, readDelegations, scanDelegationsForRecovery, findByCorrelationId, recordPendingDelegationDetailed, recordPendingDelegation, buildPromptSnapshot, appendDelegationTransition, publishPrReviewResultReceipt, buildBackgroundCompletionEventId, claimTerminalResult, claimCoderSettlement, normalizeBackgroundObservedFiles, updateCoderSettlement, registerLegacyCoderSettlementReconciler, _internals, markLegacyCoderSettlementTransferPending, clearLegacyCoderSettlementTransferPending, claimDelegationIngestion, recordDelegationIngestionResult, putPendingBackgroundAdvisory, replacePendingBackgroundAdvisory, preparePendingBackgroundAdvisories, acknowledgeObservedBackgroundAdvisories, releasePreparedBackgroundAdvisories, findByBatchId, findOpenAsyncLaneBatches, isTerminalDelegationStatus, registerStaleSweepObserver, sweepStaleDelegations, readDelegationFallback, listDelegationFallbacks, scanDelegationFallbacksForRecovery, writeDelegationFallback, removeDelegationFallback, findDelegationForCompletion, promoteDelegationFallback, buildBackgroundCoderReservationId, scanBackgroundCoderReservationsForAdmission, reserveBackgroundCoderSlot, bindBackgroundCoderReservation, releaseBackgroundCoderReservation, maintainBackgroundDelegations };
5001
+ export { prReviewFindingRequiresCritic, PR_REVIEW_BASE_DIMENSION_IDS, PR_REVIEW_RISK_IMPACTS, PR_REVIEW_RISK_TAGS, prReviewLegacyTranscriptCompatibilityEnabled, PrReviewLaneResultEnvelopeSchema, decodePrReviewWorkflowBinding, prReviewLaneResultEnvelopeDigest, PrReviewResultReceiptSchema, PR_REVIEW_FINDINGS_MAX_BYTES, PR_REVIEW_HANDOFF_MAX_BYTES, PR_REVIEW_DISCARDED_EXAMPLE_ITEM_ID, PrReviewRunIdSchema, parsePrReviewRiskTagsField, PrReviewReviewerVerdictFieldsSchema, PrReviewCriticVerdictFieldsSchema, parsePrReviewVerdictRow, generatePrReviewRunId, MAX_RECOVERY_LEDGER_BYTES, readDelegationHealthArtifact, collectDelegationLedgerHealth, MAX_PR_REVIEW_COLLECTION_RECEIPT_ITEM_IDS, BACKGROUND_DELEGATIONS_FILE, BACKGROUND_DELEGATION_FALLBACK_DIR, BACKGROUND_CODER_RESERVATIONS_FILE, BACKGROUND_DELEGATIONS_CHECKPOINT_FILE, BACKGROUND_DELEGATIONS_MANIFEST_FILE, MAX_LIVE_BACKGROUND_FALLBACKS, MAX_LIVE_BACKGROUND_CODER_RESERVATIONS, MAX_BACKGROUND_OBSERVED_FILES, MAX_BACKGROUND_ADVISORY_CHARS, LEGACY_CODER_SETTLEMENT_PENDING_ADVISORY_MARKER, DELEGATION_COMPACTION_LOW_WATER_BYTES, DELEGATION_COMPACTION_HIGH_WATER_BYTES, MAX_CHECKPOINT_BYTES, MAX_CHECKPOINT_RECORDS, TOMBSTONE_MIN_AGE_MS, BACKGROUND_INGESTION_LEASE_MS, BACKGROUND_CODER_RESERVATION_LEASE_MS, BACKGROUND_CODER_RESERVATION_LEASE_MAX_MS, BACKGROUND_CODER_RESERVATION_LEASE_MIN_MS, DEFAULT_STALE_DELEGATION_TIMEOUT_MS, DEFAULT_SWEEPABLE_DELEGATION_STATUSES, _checkpointInternals, isUnsettledWorktreeOwner, compactBackgroundDelegations, DELEGATION_READ_RETRY_DELAY_MS, readDelegationsDetailed, readDelegations, scanDelegationsForRecovery, findByCorrelationIdDetailed, findByCorrelationId, recordPendingDelegationDetailed, recordPendingDelegation, buildPromptSnapshot, appendDelegationTransition, publishPrReviewResultReceipt, buildBackgroundCompletionEventId, claimTerminalResult, claimCoderSettlement, normalizeBackgroundObservedFiles, updateCoderSettlement, registerLegacyCoderSettlementReconciler, _internals, markLegacyCoderSettlementTransferPending, clearLegacyCoderSettlementTransferPending, claimDelegationIngestion, recordDelegationIngestionResult, putPendingBackgroundAdvisory, replacePendingBackgroundAdvisory, preparePendingBackgroundAdvisories, acknowledgeObservedBackgroundAdvisories, releasePreparedBackgroundAdvisories, findByBatchIdDetailed, findByBatchId, findOpenAsyncLaneBatches, isTerminalDelegationStatus, registerStaleSweepObserver, sweepStaleDelegations, readDelegationFallback, listDelegationFallbacks, scanDelegationFallbacksForRecovery, writeDelegationFallback, removeDelegationFallback, findDelegationForCompletion, promoteDelegationFallback, buildBackgroundCoderReservationId, scanBackgroundCoderReservationsForAdmission, reserveBackgroundCoderSlot, bindBackgroundCoderReservation, releaseBackgroundCoderReservation, maintainBackgroundDelegations };
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  derivePlanId,
4
4
  derivePlanIdentityHash
5
- } from "./index-g6nen3gt.js";
5
+ } from "./index-k441jgzk.js";
6
6
  import {
7
7
  DURABILITY_CLASSES,
8
8
  getProjectDb,
9
9
  projectDbExists,
10
10
  withImmediateTransaction
11
- } from "./index-yqbnsmmv.js";
11
+ } from "./index-efkckdaw.js";
12
12
  import {
13
13
  init_logger,
14
14
  warn
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  atomicWriteFile
4
- } from "./index-evxd1art.js";
4
+ } from "./index-dga9j6s1.js";
5
5
  import {
6
6
  canonicalRootKeyFresh
7
7
  } from "./index-1xnse449.js";