opencode-swarm 7.200.13 → 7.200.14

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 (73) 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/{attest-task-pvwft49v.js → attest-task-1bhnpxsr.js} +26 -26
  4. package/dist/cli/{auto-checkpoint-d42tskyk.js → auto-checkpoint-v0k01dwk.js} +4 -4
  5. package/dist/cli/{checkpoint-ga9vbvb1.js → checkpoint-w9fkn2v6.js} +8 -8
  6. package/dist/cli/{coder-settlement-rbhdzxs0.js → coder-settlement-4t577hx9.js} +4 -4
  7. package/dist/cli/{config-doctor-qh3aba3c.js → config-doctor-m4c4f4j3.js} +7 -7
  8. package/dist/cli/{core-vx7fxf4y.js → core-pqpsbekk.js} +1 -1
  9. package/dist/cli/{curator-drift-4e5nsjec.js → curator-drift-yb05q3a8.js} +5 -5
  10. package/dist/cli/{curator-llm-factory-cn47pa0k.js → curator-llm-factory-r2rsrmz4.js} +26 -26
  11. package/dist/cli/{curator-0nv1asjc.js → curator-sxq06cgw.js} +26 -26
  12. package/dist/cli/{doctor-knowledge-receipt-phase-id-5qs5w6jz.js → doctor-knowledge-receipt-phase-id-7z98yg2z.js} +4 -4
  13. package/dist/cli/{evidence-summary-service-fbhdnww1.js → evidence-summary-service-y3g4tg5y.js} +10 -10
  14. package/dist/cli/{gate-evidence-44bzkpnp.js → gate-evidence-7nasr4dk.js} +3 -3
  15. package/dist/cli/{guardrail-explain-ga6m57w3.js → guardrail-explain-zhq6djgr.js} +27 -27
  16. package/dist/cli/{guardrail-log-aekacstp.js → guardrail-log-enq4hp9f.js} +3 -3
  17. package/dist/cli/{guardrail-reset-ezjd8vtv.js → guardrail-reset-3k2x5vsr.js} +26 -26
  18. package/dist/cli/{hive-promoter-r8z673jn.js → hive-promoter-sstdct9j.js} +26 -26
  19. package/dist/cli/{index-cc2vkpg7.js → index-11aqm3bt.js} +1 -1
  20. package/dist/cli/{index-h8ta8mva.js → index-1520thw9.js} +1 -1
  21. package/dist/cli/{index-sx4fm1d2.js → index-25v6n1t3.js} +1 -1
  22. package/dist/cli/{index-v4g6rm68.js → index-39v48pf0.js} +3 -3
  23. package/dist/cli/{index-6kdyc1s7.js → index-5mbyavx0.js} +1 -1
  24. package/dist/cli/{index-8az4qgz7.js → index-6cnppnh7.js} +2 -2
  25. package/dist/cli/{index-6tpmpc0f.js → index-93xekq7n.js} +1 -1
  26. package/dist/cli/{index-x9gyt21k.js → index-9p3phwap.js} +2 -2
  27. package/dist/cli/{index-7811ftfy.js → index-b7y19187.js} +5 -5
  28. package/dist/cli/{index-nfjwshs6.js → index-fhrcyexn.js} +1 -1
  29. package/dist/cli/{index-dkg8meb8.js → index-g3mrxex7.js} +3 -3
  30. package/dist/cli/{index-qg38v82w.js → index-gsyv2s9g.js} +4 -4
  31. package/dist/cli/{index-6xaft4r3.js → index-gx2a1xgp.js} +1 -1
  32. package/dist/cli/{index-ffz00br0.js → index-h91a4abf.js} +3 -3
  33. package/dist/cli/{index-pxf512yn.js → index-j3me99q7.js} +3 -3
  34. package/dist/cli/{index-krrn8eg3.js → index-mem1hrkw.js} +1 -1
  35. package/dist/cli/{index-xfdx40ba.js → index-ne0s5g10.js} +5 -5
  36. package/dist/cli/{index-hs96g7xz.js → index-pdaycg02.js} +1 -1
  37. package/dist/cli/{index-h59n1rx5.js → index-phdf1pjq.js} +2 -2
  38. package/dist/cli/{index-1w9mc5ck.js → index-r160hfq9.js} +26 -26
  39. package/dist/cli/{index-a01knv2b.js → index-sm64f3fc.js} +542 -126
  40. package/dist/cli/{index-fh22ndnh.js → index-sxna6jn9.js} +1 -1
  41. package/dist/cli/{index-q0gtj1px.js → index-szwa4tek.js} +2 -2
  42. package/dist/cli/{index-165v1k07.js → index-szwmgbm4.js} +3 -3
  43. package/dist/cli/{index-9zw7mh20.js → index-t6dkmt0c.js} +3 -3
  44. package/dist/cli/{index-fxnj2qd5.js → index-vjdwrd9r.js} +1 -1
  45. package/dist/cli/{index-9v10n049.js → index-vqxvdx7n.js} +2 -2
  46. package/dist/cli/{index-1nnrz6yd.js → index-vv9k85h0.js} +6 -6
  47. package/dist/cli/{index-3jewj7q3.js → index-wj3a023e.js} +1 -1
  48. package/dist/cli/{index-8kta0a96.js → index-yc5e6yr5.js} +2 -2
  49. package/dist/cli/{index-0g2nvyn9.js → index-ztezaknp.js} +28 -28
  50. package/dist/cli/index.js +27 -27
  51. package/dist/cli/{knowledge-escalator-t29wynav.js → knowledge-escalator-h8j3v62j.js} +7 -7
  52. package/dist/cli/{knowledge-events-pqn56zk8.js → knowledge-events-f80mxhjd.js} +5 -5
  53. package/dist/cli/{knowledge-store-tset38av.js → knowledge-store-z0eb6xk5.js} +1 -1
  54. package/dist/cli/{knowledge-validator-6p132rab.js → knowledge-validator-k0jn2w06.js} +2 -2
  55. package/dist/cli/{mcp-j2zpg3pg.js → mcp-zg75c3e4.js} +1 -1
  56. package/dist/cli/{model-preflight-0n10a18z.js → model-preflight-2592b0fv.js} +26 -26
  57. package/dist/cli/{pending-delegations-qsvc60qb.js → pending-delegations-ek7600es.js} +2 -2
  58. package/dist/cli/{pr-subscriptions-zx205zj2.js → pr-subscriptions-wmzs42h3.js} +1 -1
  59. package/dist/cli/{pr-workflow-gate-04ypha5r.js → pr-workflow-gate-regg66xa.js} +26 -26
  60. package/dist/cli/{scan-cursor-6zb8bjmp.js → scan-cursor-rxpkxhj3.js} +2 -2
  61. package/dist/cli/{schema-9spe6r4w.js → schema-art9xdhq.js} +1 -1
  62. package/dist/cli/{scope-persistence-7b330a4k.js → scope-persistence-7ny8a0gk.js} +5 -5
  63. package/dist/cli/{server-q54h8edd.js → server-b4nczew1.js} +26 -26
  64. package/dist/cli/{skill-generator-k6gtr0fh.js → skill-generator-bbzwn7ny.js} +8 -8
  65. package/dist/cli/{snapshot-coordination-init-namz3ae3.js → snapshot-coordination-init-1v237k29.js} +26 -26
  66. package/dist/cli/{speckit-checkoff-40evtzf3.js → speckit-checkoff-tc2pswse.js} +3 -3
  67. package/dist/cli/{workflow-wal-file-qjez91sg.js → workflow-wal-file-4vh413p1.js} +2 -2
  68. package/dist/cli/{worktree-collision-ownership-k471ygv7.js → worktree-collision-ownership-vt740r91.js} +2 -2
  69. package/dist/cli/{worktree-isolation-5tbcb2j9.js → worktree-isolation-yqfqvtex.js} +26 -26
  70. package/dist/index.js +32 -15
  71. package/dist/memory/memory-family-migration.d.ts +57 -3
  72. package/dist/utils/ephemeral-session-teardown.d.ts +24 -5
  73. package/package.json +1 -1
@@ -17,14 +17,14 @@ import {
17
17
  protectedRoots,
18
18
  redactDecisionLineForArchive,
19
19
  stableCanonicalStringify
20
- } from "./index-fh22ndnh.js";
20
+ } from "./index-sxna6jn9.js";
21
21
  import {
22
22
  detectStraySwarmDirs,
23
23
  readDoctorArtifact,
24
24
  removeStraySwarmDir,
25
25
  resolvePlanParallelizationFlag,
26
26
  runConfigDoctor
27
- } from "./index-pxf512yn.js";
27
+ } from "./index-j3me99q7.js";
28
28
  import {
29
29
  archiveEvidence,
30
30
  checkRequirementCoverage,
@@ -36,7 +36,7 @@ import {
36
36
  sanitizeTaskId,
37
37
  saveEvidence,
38
38
  validateProjectRoot
39
- } from "./index-nfjwshs6.js";
39
+ } from "./index-fhrcyexn.js";
40
40
  import {
41
41
  EvaluationTaskV1Schema,
42
42
  GateAuditManifestV1Schema,
@@ -107,16 +107,16 @@ import {
107
107
  skillContractDigest,
108
108
  splitSkillFrontmatter,
109
109
  syncBundledProjectSkillsIfMissingAsync
110
- } from "./index-v4g6rm68.js";
110
+ } from "./index-39v48pf0.js";
111
111
  import {
112
112
  buildEscalationBriefing,
113
113
  readRecentEscalations
114
- } from "./index-1nnrz6yd.js";
114
+ } from "./index-vv9k85h0.js";
115
115
  import {
116
116
  alreadyCuratedThisGeneration,
117
117
  claimNextScanBatch,
118
118
  resolveCohortId
119
- } from "./index-6xaft4r3.js";
119
+ } from "./index-gx2a1xgp.js";
120
120
  import {
121
121
  CURATOR_CONSOLIDATION_PROMPT,
122
122
  CURATOR_INIT_PROMPT,
@@ -135,13 +135,13 @@ import {
135
135
  getGroupCommitWriter,
136
136
  importLegacyJsonl,
137
137
  readPriorDriftReports
138
- } from "./index-hs96g7xz.js";
138
+ } from "./index-pdaycg02.js";
139
139
  import {
140
140
  assertNoUnsettledCoderDispatch,
141
141
  listCoderSettlementWalStates,
142
142
  recoverCoderSettlement,
143
143
  recoverStaleCoderSettlements
144
- } from "./index-7811ftfy.js";
144
+ } from "./index-b7y19187.js";
145
145
  import {
146
146
  TASK_WORKFLOW_SCHEMA_MARKER,
147
147
  compareTaskWorkflowStateRank,
@@ -155,7 +155,7 @@ import {
155
155
  readTaskEvidenceState,
156
156
  transitionTaskWorkflowEvidenceWithStatus,
157
157
  withTaskEvidenceTransaction
158
- } from "./index-h8ta8mva.js";
158
+ } from "./index-1520thw9.js";
159
159
  import {
160
160
  fastForwardToRefAsync,
161
161
  parsePorcelainV2Snapshot,
@@ -289,7 +289,7 @@ import {
289
289
  writeAtomicJson,
290
290
  writePrWorkflowAtomicJson,
291
291
  writeStateWhileLocked
292
- } from "./index-9zw7mh20.js";
292
+ } from "./index-t6dkmt0c.js";
293
293
  import {
294
294
  MAX_PENDING_SCOPE_BINDINGS,
295
295
  canonicalWorkspaceIdentity,
@@ -298,7 +298,7 @@ import {
298
298
  clearScopeBindings,
299
299
  readAuthoritativeScopeBindingSet,
300
300
  readDeclaredScopeFilesFromBindings
301
- } from "./index-sx4fm1d2.js";
301
+ } from "./index-25v6n1t3.js";
302
302
  import {
303
303
  DEFAULT_QA_GATES,
304
304
  computeProfileHash,
@@ -349,7 +349,7 @@ import {
349
349
  swarmOverwriteCandidates,
350
350
  trackedDirtyCandidates,
351
351
  transientBackoff
352
- } from "./index-dkg8meb8.js";
352
+ } from "./index-g3mrxex7.js";
353
353
  import {
354
354
  EPIC_MODE_CONFIG_DISABLED_MESSAGE,
355
355
  PlanRecoverySupersededError,
@@ -381,7 +381,7 @@ import {
381
381
  updateEpicRecord,
382
382
  updateTaskStatus,
383
383
  withPlanLifecycleLock
384
- } from "./index-xfdx40ba.js";
384
+ } from "./index-ne0s5g10.js";
385
385
  import {
386
386
  containsControlChars,
387
387
  containsPathTraversal,
@@ -398,7 +398,7 @@ import {
398
398
  resolveSpeckitProjection,
399
399
  validateSpeckit,
400
400
  writeProjectedSpecSync
401
- } from "./index-165v1k07.js";
401
+ } from "./index-szwmgbm4.js";
402
402
  import {
403
403
  clearWorktreeMergeStatus,
404
404
  getAllWorktreeMergeFailures,
@@ -421,7 +421,7 @@ import {
421
421
  replayFromLedgerWithStatus,
422
422
  resolvePlanningProfile,
423
423
  takeSnapshotEvent
424
- } from "./index-h59n1rx5.js";
424
+ } from "./index-phdf1pjq.js";
425
425
  import {
426
426
  MAX_COORDINATION_STATE_LIST_ROWS,
427
427
  deleteCoordinationImports,
@@ -485,7 +485,7 @@ import {
485
485
  recordHiveKnowledgeEvent,
486
486
  recordKnowledgeEvent,
487
487
  resolveKnowledgeEventsPath
488
- } from "./index-9v10n049.js";
488
+ } from "./index-vqxvdx7n.js";
489
489
  import {
490
490
  commitDisplayedMembership,
491
491
  commitEmptyRetrieval,
@@ -498,7 +498,7 @@ import {
498
498
  queryLiveMemberships,
499
499
  reconcilePhaseClose,
500
500
  recordPhaseCloseIntent
501
- } from "./index-8kta0a96.js";
501
+ } from "./index-yc5e6yr5.js";
502
502
  import {
503
503
  sanitizeContextText
504
504
  } from "./index-m9zzj4ee.js";
@@ -519,7 +519,7 @@ import {
519
519
  validateActionableFields,
520
520
  validateLesson,
521
521
  validateSkillPath
522
- } from "./index-3jewj7q3.js";
522
+ } from "./index-wj3a023e.js";
523
523
  import {
524
524
  MAX_CURATION_PROPOSALS,
525
525
  authorizeCuration,
@@ -558,7 +558,7 @@ import {
558
558
  transactFile,
559
559
  transactKnowledge,
560
560
  wordBigrams
561
- } from "./index-qg38v82w.js";
561
+ } from "./index-gsyv2s9g.js";
562
562
  import {
563
563
  readTailJsonl,
564
564
  readTailJsonlDetailed,
@@ -582,7 +582,7 @@ import {
582
582
  } from "./index-erp7fk72.js";
583
583
  import {
584
584
  resolveWorktreeIsolationConfig
585
- } from "./index-8az4qgz7.js";
585
+ } from "./index-6cnppnh7.js";
586
586
  import {
587
587
  RetrospectiveEvidenceSchema
588
588
  } from "./index-g22dps7x.js";
@@ -603,7 +603,7 @@ import {
603
603
  loadPluginConfig,
604
604
  loadPluginConfigWithMeta,
605
605
  resolveEpicConfig
606
- } from "./index-6kdyc1s7.js";
606
+ } from "./index-5mbyavx0.js";
607
607
  import {
608
608
  DEFAULT_HARNESS_EVOLUTION_CONFIG,
609
609
  DEFAULT_HARNESS_OPT_CONFIG,
@@ -625,7 +625,7 @@ import {
625
625
  resolveContextWindow,
626
626
  resolveGeneratedAgentRole,
627
627
  stripKnownSwarmPrefix
628
- } from "./index-cc2vkpg7.js";
628
+ } from "./index-11aqm3bt.js";
629
629
  import {
630
630
  KNOWLEDGE_SCHEMA_VERSION,
631
631
  OUTCOME_BLOCK_THRESHOLD,
@@ -647,7 +647,7 @@ import {
647
647
  recoveryReadErrored,
648
648
  startupOrphanRecovery,
649
649
  writeWorkflowWalFile
650
- } from "./index-krrn8eg3.js";
650
+ } from "./index-mem1hrkw.js";
651
651
  import {
652
652
  assertSettlementArtifactsRemovable,
653
653
  isPathUnderSwarmWorktreeBase,
@@ -658,7 +658,7 @@ import {
658
658
  removeWorktree,
659
659
  resolveWorktreeBaseDir,
660
660
  withSettlementArtifactLifecycle
661
- } from "./index-q0gtj1px.js";
661
+ } from "./index-szwa4tek.js";
662
662
  import {
663
663
  estimateCharsForTokens,
664
664
  estimateTokens,
@@ -1716,6 +1716,83 @@ var SidecarCandidateSchema = exports_external.discriminatedUnion("row_format_fam
1716
1716
  invariant_violated: exports_external.string().min(1)
1717
1717
  }).strict()
1718
1718
  ]);
1719
+ var BIDI_RANGES = [
1720
+ [8234, 8238],
1721
+ [8294, 8297]
1722
+ ];
1723
+ function isBidiCodePoint(code) {
1724
+ for (let i = 0;i < BIDI_RANGES.length; i++) {
1725
+ const [lo, hi] = BIDI_RANGES[i];
1726
+ if (code >= lo && code <= hi)
1727
+ return true;
1728
+ }
1729
+ return false;
1730
+ }
1731
+ function sanitizeString(value) {
1732
+ let result = "";
1733
+ for (let i = 0;i < value.length; i++) {
1734
+ const code = value.codePointAt(i) ?? 0;
1735
+ if (code > 65535) {
1736
+ result += value[i];
1737
+ i++;
1738
+ result += value[i];
1739
+ } else if (code === 0) {
1740
+ result += "\\u0000";
1741
+ } else if (code === 27) {
1742
+ if (i + 1 < value.length && value[i + 1] === "[") {
1743
+ i++;
1744
+ while (i + 1 < value.length) {
1745
+ const next = value.charCodeAt(i + 1);
1746
+ if (next >= 48 && next <= 63) {
1747
+ i++;
1748
+ } else if (next >= 32 && next <= 47) {
1749
+ i++;
1750
+ } else if (next >= 64 && next <= 126) {
1751
+ i++;
1752
+ break;
1753
+ } else {
1754
+ break;
1755
+ }
1756
+ }
1757
+ } else if (i + 1 < value.length && value[i + 1] === "]") {
1758
+ i++;
1759
+ while (i + 1 < value.length) {
1760
+ const next = value.charCodeAt(i + 1);
1761
+ if (next === 7) {
1762
+ i++;
1763
+ break;
1764
+ } else if (next === 27 && i + 2 < value.length && value[i + 2] === "\\") {
1765
+ i += 2;
1766
+ break;
1767
+ } else {
1768
+ i++;
1769
+ }
1770
+ }
1771
+ } else if (i + 1 < value.length) {
1772
+ const next = value.charCodeAt(i + 1);
1773
+ if (next >= 32 && next <= 47) {
1774
+ i++;
1775
+ while (i + 1 < value.length) {
1776
+ const b = value.charCodeAt(i + 1);
1777
+ if (b >= 48 && b <= 126) {
1778
+ i++;
1779
+ break;
1780
+ } else if (b >= 32 && b <= 47) {
1781
+ i++;
1782
+ } else {
1783
+ break;
1784
+ }
1785
+ }
1786
+ } else if (next >= 48 && next <= 126) {
1787
+ i++;
1788
+ }
1789
+ }
1790
+ } else if (isBidiCodePoint(code)) {} else {
1791
+ result += value[i];
1792
+ }
1793
+ }
1794
+ return result;
1795
+ }
1719
1796
 
1720
1797
  // src/background/candidate-parser.ts
1721
1798
  var ArtifactInputSchema = exports_external.object({
@@ -7723,17 +7800,47 @@ async function teardownEphemeralSession(session, sessionId, options = {}) {
7723
7800
  }
7724
7801
  var DEFAULT_EPHEMERAL_VERIFY_TIMEOUT_MS = 2000;
7725
7802
  var DEFAULT_EPHEMERAL_MAX_DELETE_ATTEMPTS = 3;
7803
+ var TRANSIENT_TRANSPORT_ERROR_CODES = new Set([
7804
+ "ECONNRESET",
7805
+ "ECONNREFUSED",
7806
+ "EAI_AGAIN",
7807
+ "ETIMEDOUT",
7808
+ "ENOTFOUND",
7809
+ "EPIPE",
7810
+ "UND_ERR_SOCKET"
7811
+ ]);
7812
+ function isTransientTransportError(err) {
7813
+ if (typeof err !== "object" || err === null)
7814
+ return false;
7815
+ if (err instanceof TypeError)
7816
+ return true;
7817
+ const coded = err;
7818
+ if (typeof coded.code === "string" && TRANSIENT_TRANSPORT_ERROR_CODES.has(coded.code)) {
7819
+ return true;
7820
+ }
7821
+ return coded.name === "AbortError";
7822
+ }
7726
7823
  async function sessionExists(session, sessionId, verifyTimeoutMs) {
7727
7824
  if (typeof session.get !== "function")
7728
- return true;
7825
+ return "alive";
7826
+ const verifyTimeoutError = new Error(`ephemeral session verify timed out after ${verifyTimeoutMs}ms`);
7729
7827
  try {
7730
- const result = await withTimeout(session.get({ path: { id: sessionId } }), verifyTimeoutMs, new Error(`ephemeral session verify timed out after ${verifyTimeoutMs}ms`));
7828
+ const result = await withTimeout(session.get({ path: { id: sessionId } }), verifyTimeoutMs, verifyTimeoutError);
7731
7829
  const body = result?.data;
7732
- if (body === undefined || body === null)
7733
- return false;
7734
- return true;
7735
- } catch {
7736
- return false;
7830
+ if (body === undefined || body === null) {
7831
+ const envelopeError = result?.error;
7832
+ if (envelopeError !== undefined && envelopeError !== null && isTransientTransportError(envelopeError)) {
7833
+ return "unreadable";
7834
+ }
7835
+ return "gone";
7836
+ }
7837
+ return "alive";
7838
+ } catch (err) {
7839
+ if (err === verifyTimeoutError)
7840
+ return "unreadable";
7841
+ if (isTransientTransportError(err))
7842
+ return "unreadable";
7843
+ return "gone";
7737
7844
  }
7738
7845
  }
7739
7846
  async function teardownEphemeralSessionVerified(session, sessionId, options = {}) {
@@ -7756,9 +7863,19 @@ async function teardownEphemeralSessionVerified(session, sessionId, options = {}
7756
7863
  skipAbort: deleteAttempts > 0 ? true : options.skipAbort
7757
7864
  });
7758
7865
  deleteAttempts += 1;
7759
- const alive = await _internals18.sessionExists(session, sessionId, verifyTimeoutMs);
7760
- if (!alive)
7866
+ const existence = await _internals18.sessionExists(session, sessionId, verifyTimeoutMs);
7867
+ if (existence === "gone") {
7761
7868
  return { ok: true, sessionId, attempts: deleteAttempts };
7869
+ }
7870
+ if (existence === "unreadable") {
7871
+ return {
7872
+ ok: false,
7873
+ sessionId,
7874
+ attempts: deleteAttempts,
7875
+ kind: "ephemeral-session-teardown-unverified",
7876
+ reason: "verify-unreadable"
7877
+ };
7878
+ }
7762
7879
  if (deleteAttempts >= attempts) {
7763
7880
  return {
7764
7881
  ok: false,
@@ -7775,6 +7892,7 @@ var _internals18 = {
7775
7892
  boundedAbort: boundedAbortEphemeralSession,
7776
7893
  boundedDelete: boundedDeleteEphemeralSession,
7777
7894
  sessionExists,
7895
+ isTransientTransportError,
7778
7896
  log
7779
7897
  };
7780
7898
 
@@ -9675,7 +9793,7 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
9675
9793
  return extracted === expectedSessionId;
9676
9794
  }
9677
9795
  async function inspectStandardWorktreeCollisionOwnership(identity) {
9678
- const collisionOwnership = await import("./worktree-collision-ownership-k471ygv7.js");
9796
+ const collisionOwnership = await import("./worktree-collision-ownership-vt740r91.js");
9679
9797
  return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
9680
9798
  }
9681
9799
  async function runRecoveryGit(directory, args, timeoutMs = 15000) {
@@ -9878,7 +9996,7 @@ async function precreateStandardWorktreeSession(args) {
9878
9996
  if (lateChildSessionId) {
9879
9997
  const verification = await teardownEphemeralSessionVerified(client.session, lateChildSessionId);
9880
9998
  if (!verification.ok) {
9881
- pushAdvisory(ensureAgentSession(args.parentSessionID), `WORKTREE_RECOVERY_CHILD_SESSION_LEAKED: recovery child session ${lateChildSessionId} survived verified teardown (${verification.reason}); it holds the lane swarm.db at ${collision.worktreePath}. Retry the dispatch or restart the host to release it.`);
9999
+ pushAdvisory(ensureAgentSession(args.parentSessionID), `WORKTREE_RECOVERY_CHILD_SESSION_LEAKED: recovery child session ${lateChildSessionId} was not confirmed deleted by verified teardown (${verification.reason}); it holds the lane swarm.db at ${collision.worktreePath}. Retry the dispatch or restart the host to release it.`);
9882
10000
  }
9883
10001
  }
9884
10002
  }, resolveSessionCreateTimeoutMs(args));
@@ -9928,7 +10046,7 @@ async function precreateStandardWorktreeSession(args) {
9928
10046
  if (recoveredChildSessionId) {
9929
10047
  const verification = await teardownEphemeralSessionVerified(client.session, recoveredChildSessionId);
9930
10048
  if (!verification.ok) {
9931
- pushAdvisory(ensureAgentSession(args.parentSessionID), `WORKTREE_RECOVERY_CHILD_SESSION_LEAKED: recovery child session ${recoveredChildSessionId} survived verified teardown (${verification.reason}); it holds the lane swarm.db at ${collision.worktreePath}. Retry the dispatch or restart the host to release it.`);
10049
+ pushAdvisory(ensureAgentSession(args.parentSessionID), `WORKTREE_RECOVERY_CHILD_SESSION_LEAKED: recovery child session ${recoveredChildSessionId} was not confirmed deleted by verified teardown (${verification.reason}); it holds the lane swarm.db at ${collision.worktreePath}. Retry the dispatch or restart the host to release it.`);
9932
10050
  }
9933
10051
  }
9934
10052
  hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_RECOVERY_SESSION_CREATE_FAILED: ${error2 instanceof Error ? error2.message : String(error2)}. The PREPARED claim was rolled back and recovery re-dispatch was blocked.`);
@@ -10103,7 +10221,7 @@ async function precreateStandardWorktreeSession(args) {
10103
10221
  const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, handle.worktreePath);
10104
10222
  if (laneProfile) {
10105
10223
  try {
10106
- const { writeLaneProfileToDiskReal } = await import("./core-vx7fxf4y.js");
10224
+ const { writeLaneProfileToDiskReal } = await import("./core-pqpsbekk.js");
10107
10225
  await writeLaneProfileToDiskReal(handle.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
10108
10226
  } catch {}
10109
10227
  }
@@ -10136,7 +10254,7 @@ async function precreateStandardWorktreeSession(args) {
10136
10254
  lanePath: handle.worktreePath,
10137
10255
  branchName: handle.branchName,
10138
10256
  taskId: args.taskId,
10139
- reason: `late child session ${lateChildSessionId} survived verified teardown (${verification.reason})`
10257
+ reason: `late child session ${lateChildSessionId} was not confirmed deleted by verified teardown (${verification.reason})`
10140
10258
  });
10141
10259
  }
10142
10260
  }
@@ -11103,7 +11221,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
11103
11221
  }
11104
11222
  clearWorktreeMergeStatus(statusKey);
11105
11223
  try {
11106
- const { removeLaneProfileFromDiskReal } = await import("./core-vx7fxf4y.js");
11224
+ const { removeLaneProfileFromDiskReal } = await import("./core-pqpsbekk.js");
11107
11225
  await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
11108
11226
  } catch {}
11109
11227
  const state = serializationStateBySessionID.get(dispatch.parentSessionID);
@@ -17471,7 +17589,7 @@ var INJECTION_PATTERNS = [
17471
17589
  /\bDAN\s*MODE/gi,
17472
17590
  /\bBYPASS/gi
17473
17591
  ];
17474
- function sanitizeString(input) {
17592
+ function sanitizeString2(input) {
17475
17593
  if (!input || typeof input !== "string") {
17476
17594
  return "";
17477
17595
  }
@@ -17532,9 +17650,9 @@ function detectRepetitionLoop(trajectory, config) {
17532
17650
  severity: severity2,
17533
17651
  category: "coordination_error",
17534
17652
  stepRange: [data.startStep, data.endStep],
17535
- description: `Agent "${sanitizeString(agent)}" performed "${sanitizeString(action2)}" on "${sanitizeString(target)}" ${data.count} times within ${windowSize} steps`,
17536
- affectedAgents: [sanitizeString(agent)],
17537
- affectedTargets: [sanitizeString(target)],
17653
+ description: `Agent "${sanitizeString2(agent)}" performed "${sanitizeString2(action2)}" on "${sanitizeString2(target)}" ${data.count} times within ${windowSize} steps`,
17654
+ affectedAgents: [sanitizeString2(agent)],
17655
+ affectedTargets: [sanitizeString2(target)],
17538
17656
  occurrenceCount: data.count
17539
17657
  });
17540
17658
  }
@@ -17582,12 +17700,12 @@ function detectPingPong(trajectory, config) {
17582
17700
  severity: "high",
17583
17701
  category: "coordination_error",
17584
17702
  stepRange: [delegateEntries[i].step, delegateEntries[endIndex].step],
17585
- description: `Ping-pong delegation detected: "${sanitizeString(firstAgent)}" and "${sanitizeString(secondAgent)}" alternating on "${sanitizeString(target)}"`,
17703
+ description: `Ping-pong delegation detected: "${sanitizeString2(firstAgent)}" and "${sanitizeString2(secondAgent)}" alternating on "${sanitizeString2(target)}"`,
17586
17704
  affectedAgents: [
17587
- sanitizeString(firstAgent),
17588
- sanitizeString(secondAgent)
17705
+ sanitizeString2(firstAgent),
17706
+ sanitizeString2(secondAgent)
17589
17707
  ],
17590
- affectedTargets: [sanitizeString(target)],
17708
+ affectedTargets: [sanitizeString2(target)],
17591
17709
  occurrenceCount: roundTrips
17592
17710
  });
17593
17711
  }
@@ -17624,9 +17742,9 @@ function detectExpansionDrift(trajectory, config) {
17624
17742
  ],
17625
17743
  description: `Scope expansion detected: ${previousTargets.size} unique targets \u2192 ${recentTargets.size} unique targets (${expansionRatio.toFixed(1)}x increase)`,
17626
17744
  affectedAgents: [
17627
- ...new Set(recentWindow.map((e) => sanitizeString(e.agent)))
17745
+ ...new Set(recentWindow.map((e) => sanitizeString2(e.agent)))
17628
17746
  ],
17629
- affectedTargets: [...recentTargets].map((t) => sanitizeString(t)),
17747
+ affectedTargets: [...recentTargets].map((t) => sanitizeString2(t)),
17630
17748
  occurrenceCount: Math.floor(expansionRatio * 10) / 10
17631
17749
  });
17632
17750
  }
@@ -17695,9 +17813,9 @@ function detectStuckOnTest(trajectory, config) {
17695
17813
  severity: "high",
17696
17814
  category: "reasoning_error",
17697
17815
  stepRange: [cycleStart, cycleEnd],
17698
- description: `Stuck on test detected: ${cycleCount} edit-test cycles on "${sanitizeString(file)}"`,
17699
- affectedAgents: data.agents.map((a) => sanitizeString(a)),
17700
- affectedTargets: [sanitizeString(file)],
17816
+ description: `Stuck on test detected: ${cycleCount} edit-test cycles on "${sanitizeString2(file)}"`,
17817
+ affectedAgents: data.agents.map((a) => sanitizeString2(a)),
17818
+ affectedTargets: [sanitizeString2(file)],
17701
17819
  occurrenceCount: cycleCount
17702
17820
  });
17703
17821
  }
@@ -17735,10 +17853,10 @@ function detectContextThrash(trajectory, config) {
17735
17853
  stepRange: [trajectory[runStart].step, trajectory[runEnd].step],
17736
17854
  description: `Context thrash detected: unique targets grew monotonically from ${priorCount} to ${finalCount} over ${runLength} steps`,
17737
17855
  affectedAgents: [
17738
- ...new Set(trajectory.slice(runStart, runEnd + 1).map((e) => sanitizeString(e.agent)))
17856
+ ...new Set(trajectory.slice(runStart, runEnd + 1).map((e) => sanitizeString2(e.agent)))
17739
17857
  ],
17740
17858
  affectedTargets: [
17741
- ...new Set(trajectory.slice(runStart, runEnd + 1).map((e) => sanitizeString(e.target)))
17859
+ ...new Set(trajectory.slice(runStart, runEnd + 1).map((e) => sanitizeString2(e.target)))
17742
17860
  ],
17743
17861
  occurrenceCount: runLength
17744
17862
  });
@@ -29653,7 +29771,7 @@ function clearCriticalShownIds(sessionID) {
29653
29771
  async function rehydratePrSubscriptions(sessionID, directory) {
29654
29772
  const map = new Map;
29655
29773
  try {
29656
- const { listActive: listActive2 } = await import("./pr-subscriptions-zx205zj2.js");
29774
+ const { listActive: listActive2 } = await import("./pr-subscriptions-wmzs42h3.js");
29657
29775
  const records = await listActive2(directory);
29658
29776
  for (const record of records) {
29659
29777
  if (record.sessionID !== sessionID)
@@ -40294,7 +40412,7 @@ async function handleAttestCommand(directory, args, sessionID) {
40294
40412
  `);
40295
40413
  }
40296
40414
  const taskId = args[0];
40297
- const { executeAttestTask } = await import("./attest-task-pvwft49v.js");
40415
+ const { executeAttestTask } = await import("./attest-task-1bhnpxsr.js");
40298
40416
  const result = await executeAttestTask({
40299
40417
  task_id: taskId,
40300
40418
  working_directory: directory,
@@ -47486,9 +47604,9 @@ function hashContent(content) {
47486
47604
  return createHash28("sha1").update(content).digest("hex");
47487
47605
  }
47488
47606
  async function loadConfigForPolicyCurator(directory) {
47489
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-9spe6r4w.js");
47607
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-art9xdhq.js");
47490
47608
  try {
47491
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ffz00br0.js");
47609
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-h91a4abf.js");
47492
47610
  const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
47493
47611
  return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
47494
47612
  } catch {
@@ -50546,7 +50664,7 @@ async function resolveCuratorLLMDelegate(directory, mode, sessionId) {
50546
50664
  const seam = _internals49.createCuratorLLMDelegate;
50547
50665
  if (seam)
50548
50666
  return seam(directory, mode, sessionId);
50549
- const { createCuratorLLMDelegate } = await import("./curator-llm-factory-cn47pa0k.js");
50667
+ const { createCuratorLLMDelegate } = await import("./curator-llm-factory-r2rsrmz4.js");
50550
50668
  return createCuratorLLMDelegate(directory, mode, sessionId);
50551
50669
  }
50552
50670
  async function reconcileCloseTerminalStateForPlan(directory, targetPlan, options) {
@@ -50941,7 +51059,7 @@ async function runFinalizeStage(ctx) {
50941
51059
  }
50942
51060
  }
50943
51061
  try {
50944
- const { CuratorConfigSchema: CCS } = await import("./schema-9spe6r4w.js");
51062
+ const { CuratorConfigSchema: CCS } = await import("./schema-art9xdhq.js");
50945
51063
  const { config: pmLoadedConfig } = _internals49.loadPluginConfigWithMeta(ctx.directory);
50946
51064
  const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
50947
51065
  if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
@@ -55014,7 +55132,7 @@ function adviseClosingStop(directory) {
55014
55132
  }
55015
55133
  async function writeSnapshot(directory, state) {
55016
55134
  try {
55017
- const { ensureSnapshotCoordinationReady } = await import("./snapshot-coordination-init-namz3ae3.js");
55135
+ const { ensureSnapshotCoordinationReady } = await import("./snapshot-coordination-init-1v237k29.js");
55018
55136
  await ensureSnapshotCoordinationReady(directory);
55019
55137
  if (closingStopAdvisedRoots.size > 0) {
55020
55138
  closingStopAdvisedRoots.delete(canonicalProjectKey(directory));
@@ -58243,7 +58361,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
58243
58361
  };
58244
58362
  }
58245
58363
  async function sweepActiveNearDuplicates(directory, options = {}) {
58246
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ffz00br0.js");
58364
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-h91a4abf.js");
58247
58365
  const { config } = loadPluginConfigWithMeta2(directory);
58248
58366
  const sweepConfig = config.learning?.dedup_sweep;
58249
58367
  if (sweepConfig?.enabled === false)
@@ -59367,7 +59485,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
59367
59485
  }
59368
59486
  if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
59369
59487
  try {
59370
- const skillModule = await import("./skill-generator-k6gtr0fh.js");
59488
+ const skillModule = await import("./skill-generator-bbzwn7ny.js");
59371
59489
  for (const cand of skillCandidates) {
59372
59490
  if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
59373
59491
  continue;
@@ -59839,7 +59957,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
59839
59957
  } catch {}
59840
59958
  }
59841
59959
  if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
59842
- const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-t29wynav.js");
59960
+ const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-h8j3v62j.js");
59843
59961
  for (const { id } of contradictedEntries) {
59844
59962
  try {
59845
59963
  await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
@@ -60671,7 +60789,7 @@ async function runCuratorPostMortem(directory, options = {}) {
60671
60789
  warnings.push("Failed to collect knowledge summary.");
60672
60790
  }
60673
60791
  try {
60674
- const { getScanStatus } = await import("./scan-cursor-6zb8bjmp.js");
60792
+ const { getScanStatus } = await import("./scan-cursor-rxpkxhj3.js");
60675
60793
  const scanStatus = await getScanStatus(directory);
60676
60794
  if (scanStatus.remaining_estimate > 0) {
60677
60795
  warnings.push(`Fair scan: reviewed ${knowledgeSummary.length} entries this sweep (generation ${scanStatus.generation}); ${scanStatus.remaining_estimate} more eligible entries will be visited in future curation sweeps.`);
@@ -60843,9 +60961,9 @@ var _internals71 = {
60843
60961
  verifyPostMortemKnowledgeActions,
60844
60962
  repairPostMortemActions,
60845
60963
  loadDefaultKnowledgeConfig: async (directory) => {
60846
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-9spe6r4w.js");
60964
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-art9xdhq.js");
60847
60965
  try {
60848
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ffz00br0.js");
60966
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-h91a4abf.js");
60849
60967
  const loaded = loadPluginConfigWithMeta2(directory);
60850
60968
  return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
60851
60969
  } catch {
@@ -60853,11 +60971,11 @@ var _internals71 = {
60853
60971
  }
60854
60972
  },
60855
60973
  applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
60856
- const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-0nv1asjc.js");
60974
+ const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-sxq06cgw.js");
60857
60975
  return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
60858
60976
  },
60859
60977
  checkHivePromotions: async (entries2, knowledgeConfig, directory) => {
60860
- const { checkHivePromotions } = await import("./hive-promoter-r8z673jn.js");
60978
+ const { checkHivePromotions } = await import("./hive-promoter-sstdct9j.js");
60861
60979
  return checkHivePromotions(entries2, knowledgeConfig, directory);
60862
60980
  },
60863
60981
  applyProposalTriage: async (directory, triage) => {
@@ -60866,7 +60984,7 @@ var _internals71 = {
60866
60984
  activateProposal,
60867
60985
  listSkills: listSkills2,
60868
60986
  sanitizeSlug
60869
- } = await import("./skill-generator-k6gtr0fh.js");
60987
+ } = await import("./skill-generator-bbzwn7ny.js");
60870
60988
  const result = {
60871
60989
  approved: [],
60872
60990
  rejected: [],
@@ -60908,7 +61026,7 @@ var _internals71 = {
60908
61026
  return result;
60909
61027
  },
60910
61028
  readPriorDriftReports: async (directory) => {
60911
- const { readPriorDriftReports: readPriorDriftReports2 } = await import("./curator-drift-4e5nsjec.js");
61029
+ const { readPriorDriftReports: readPriorDriftReports2 } = await import("./curator-drift-yb05q3a8.js");
60912
61030
  return readPriorDriftReports2(directory);
60913
61031
  },
60914
61032
  readSwarmKnowledge: (directory) => readKnowledge(resolveSwarmKnowledgePath(directory))
@@ -71179,9 +71297,9 @@ var _internals79 = {
71179
71297
  loadPluginConfigWithMeta,
71180
71298
  loadCuratorDeps: async () => {
71181
71299
  const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate }] = await Promise.all([
71182
- import("./schema-9spe6r4w.js"),
71183
- import("./curator-0nv1asjc.js"),
71184
- import("./curator-llm-factory-cn47pa0k.js")
71300
+ import("./schema-art9xdhq.js"),
71301
+ import("./curator-sxq06cgw.js"),
71302
+ import("./curator-llm-factory-r2rsrmz4.js")
71185
71303
  ]);
71186
71304
  return { CuratorConfigSchema, curator, createCuratorLLMDelegate };
71187
71305
  }
@@ -73629,7 +73747,7 @@ async function computeCurationDiagnostics(directory, entries2) {
73629
73747
  let scanCompleted = false;
73630
73748
  let scanRemaining = 0;
73631
73749
  try {
73632
- const { getScanStatus } = await import("./scan-cursor-6zb8bjmp.js");
73750
+ const { getScanStatus } = await import("./scan-cursor-rxpkxhj3.js");
73633
73751
  const status = await getScanStatus(directory);
73634
73752
  scanGeneration = status.generation;
73635
73753
  scanCompleted = status.completed;
@@ -73639,10 +73757,10 @@ async function computeCurationDiagnostics(directory, entries2) {
73639
73757
  try {
73640
73758
  const { isLinked: isLinked2 } = await import("./knowledge-link-r7e2t5c1.js");
73641
73759
  if (isLinked2(directory)) {
73642
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-9spe6r4w.js");
73760
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-art9xdhq.js");
73643
73761
  let config;
73644
73762
  try {
73645
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ffz00br0.js");
73763
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-h91a4abf.js");
73646
73764
  const loaded = loadPluginConfigWithMeta2(directory);
73647
73765
  config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
73648
73766
  } catch {
@@ -75122,7 +75240,7 @@ async function handleDoctorCommand(directory, args) {
75122
75240
  const result = runConfigDoctor(config, directory, planParallelizationEnabled);
75123
75241
  let output;
75124
75242
  if (enableAutoFix && result.hasAutoFixableIssues) {
75125
- const { runConfigDoctorWithFixes } = await import("./config-doctor-qh3aba3c.js");
75243
+ const { runConfigDoctorWithFixes } = await import("./config-doctor-m4c4f4j3.js");
75126
75244
  const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
75127
75245
  applyLossy: true
75128
75246
  });
@@ -75160,7 +75278,7 @@ async function handleDoctorCommand(directory, args) {
75160
75278
  `;
75161
75279
  }
75162
75280
  try {
75163
- const { runModelPreflight } = await import("./model-preflight-0n10a18z.js");
75281
+ const { runModelPreflight } = await import("./model-preflight-2592b0fv.js");
75164
75282
  const preflight = await runModelPreflight(config, swarmState.opencodeClient, { generatedAgentNames: swarmState.generatedAgentNames });
75165
75283
  const missingSelection = preflight.resolutions.filter((resolution) => resolution.status === "missing-selection");
75166
75284
  const unresolved = preflight.catalogAvailable ? preflight.resolutions.filter((resolution) => resolution.status === "unresolved") : [];
@@ -75194,7 +75312,7 @@ async function handleDoctorCommand(directory, args) {
75194
75312
  }
75195
75313
  } catch {}
75196
75314
  try {
75197
- const { renderKnowledgeReceiptPhaseIdSection } = await import("./doctor-knowledge-receipt-phase-id-5qs5w6jz.js");
75315
+ const { renderKnowledgeReceiptPhaseIdSection } = await import("./doctor-knowledge-receipt-phase-id-7z98yg2z.js");
75198
75316
  output += await renderKnowledgeReceiptPhaseIdSection(directory, enableAutoFix);
75199
75317
  } catch {}
75200
75318
  const strayDirs = detectStraySwarmDirs(directory);
@@ -77211,7 +77329,7 @@ async function handleEvidenceCommand(directory, args) {
77211
77329
  return formatTaskEvidenceMarkdown(evidenceData);
77212
77330
  }
77213
77331
  async function handleEvidenceSummaryCommand(directory) {
77214
- const { buildEvidenceSummary } = await import("./evidence-summary-service-fbhdnww1.js");
77332
+ const { buildEvidenceSummary } = await import("./evidence-summary-service-y3g4tg5y.js");
77215
77333
  const artifact = await buildEvidenceSummary(directory);
77216
77334
  if (!artifact) {
77217
77335
  return "No plan found. Run `/swarm plan` to check plan status.";
@@ -84519,7 +84637,7 @@ var MAX_INCOMPLETE_TASKS = 20;
84519
84637
  function escapeHtml(str) {
84520
84638
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
84521
84639
  }
84522
- function sanitizeString2(str, maxLength) {
84640
+ function sanitizeString3(str, maxLength) {
84523
84641
  if (!str)
84524
84642
  return "";
84525
84643
  const sanitized = String(str).replace(RTL_OVERRIDE_PATTERN, "");
@@ -84561,11 +84679,11 @@ function extractCurrentPhaseFromPlan2(plan) {
84561
84679
  for (const phase of plan.phases) {
84562
84680
  for (const task of phase.tasks) {
84563
84681
  if (task.status === "in_progress") {
84564
- currentTask = sanitizeString2(task.id, MAX_TASK_ID_LENGTH);
84682
+ currentTask = sanitizeString3(task.id, MAX_TASK_ID_LENGTH);
84565
84683
  }
84566
84684
  if (task.status !== "completed") {
84567
84685
  if (incompleteTasks.length < MAX_INCOMPLETE_TASKS) {
84568
- incompleteTasks.push(sanitizeString2(task.id, MAX_TASK_ID_LENGTH));
84686
+ incompleteTasks.push(sanitizeString3(task.id, MAX_TASK_ID_LENGTH));
84569
84687
  }
84570
84688
  }
84571
84689
  }
@@ -84584,7 +84702,7 @@ function parseSessionState(content) {
84584
84702
  if (state.activeAgent && typeof state.activeAgent === "object") {
84585
84703
  const entries2 = Object.entries(state.activeAgent);
84586
84704
  if (entries2.length > 0) {
84587
- activeAgent = sanitizeString2(entries2[entries2.length - 1][1], MAX_TASK_ID_LENGTH);
84705
+ activeAgent = sanitizeString3(entries2[entries2.length - 1][1], MAX_TASK_ID_LENGTH);
84588
84706
  }
84589
84707
  }
84590
84708
  let delegationState = null;
@@ -84594,7 +84712,7 @@ function parseSessionState(content) {
84594
84712
  let maxDepth = 0;
84595
84713
  for (const [, chain] of chains) {
84596
84714
  if (Array.isArray(chain) && chain.length > 0) {
84597
- const sanitizedChain = chain.map((e) => `${sanitizeString2(e.from, MAX_TASK_ID_LENGTH)}->${sanitizeString2(e.to, MAX_TASK_ID_LENGTH)}`).join(" | ");
84715
+ const sanitizedChain = chain.map((e) => `${sanitizeString3(e.from, MAX_TASK_ID_LENGTH)}->${sanitizeString3(e.to, MAX_TASK_ID_LENGTH)}`).join(" | ");
84598
84716
  activeChains.push(sanitizedChain);
84599
84717
  maxDepth = Math.max(maxDepth, chain.length);
84600
84718
  }
@@ -84613,8 +84731,8 @@ function parseSessionState(content) {
84613
84731
  const sess = session;
84614
84732
  if (sess.lastGateFailure && sess.currentTaskId) {
84615
84733
  pendingQA = {
84616
- taskId: sanitizeString2(sess.lastGateFailure.taskId, MAX_TASK_ID_LENGTH),
84617
- lastFailure: sanitizeString2(sess.lastGateFailure.tool, MAX_TASK_ID_LENGTH)
84734
+ taskId: sanitizeString3(sess.lastGateFailure.taskId, MAX_TASK_ID_LENGTH),
84735
+ lastFailure: sanitizeString3(sess.lastGateFailure.tool, MAX_TASK_ID_LENGTH)
84618
84736
  };
84619
84737
  break;
84620
84738
  }
@@ -84635,7 +84753,7 @@ function extractDecisions(content) {
84635
84753
  for (const decision of extractContextDecisions(content)) {
84636
84754
  const cleaned = decision.text.replace(/\u2705/g, "").trim();
84637
84755
  if (cleaned) {
84638
- const sanitized = sanitizeString2(cleaned, MAX_DECISION_LENGTH);
84756
+ const sanitized = sanitizeString3(cleaned, MAX_DECISION_LENGTH);
84639
84757
  if (sanitized) {
84640
84758
  decisions.push(sanitized);
84641
84759
  }
@@ -84686,11 +84804,11 @@ async function getHandoffData(directory) {
84686
84804
  const phaseMatch = planMdContent.match(/^## Phase (\d+):?\s*(.+)?$/m);
84687
84805
  const taskMatch = planMdContent.match(/^- \[ \] (\d+\.\d+)/g);
84688
84806
  if (phaseMatch) {
84689
- planInfo.currentPhase = sanitizeString2(`Phase ${phaseMatch[1]}${phaseMatch[2] ? `: ${phaseMatch[2]}` : ""}`, MAX_TASK_ID_LENGTH);
84807
+ planInfo.currentPhase = sanitizeString3(`Phase ${phaseMatch[1]}${phaseMatch[2] ? `: ${phaseMatch[2]}` : ""}`, MAX_TASK_ID_LENGTH);
84690
84808
  }
84691
84809
  if (taskMatch) {
84692
84810
  const rawTasks = taskMatch.map((t) => t.replace("- [ ] ", ""));
84693
- planInfo.incompleteTasks = rawTasks.map((t) => sanitizeString2(t, MAX_TASK_ID_LENGTH)).slice(0, MAX_INCOMPLETE_TASKS);
84811
+ planInfo.incompleteTasks = rawTasks.map((t) => sanitizeString3(t, MAX_TASK_ID_LENGTH)).slice(0, MAX_INCOMPLETE_TASKS);
84694
84812
  if (!planInfo.currentTask && planInfo.incompleteTasks.length > 0) {
84695
84813
  planInfo.currentTask = planInfo.incompleteTasks[0];
84696
84814
  }
@@ -84700,7 +84818,7 @@ async function getHandoffData(directory) {
84700
84818
  const contextContent = await readSwarmFileAsync(directory, "context.md");
84701
84819
  const recentDecisions = _internals97.extractDecisions(contextContent);
84702
84820
  const rawPhaseMetrics = _internals97.extractPhaseMetrics(contextContent);
84703
- const phaseMetrics = sanitizeString2(rawPhaseMetrics, 1000);
84821
+ const phaseMetrics = sanitizeString3(rawPhaseMetrics, 1000);
84704
84822
  let delegationState = null;
84705
84823
  if (sessionState?.delegationState) {
84706
84824
  delegationState = {
@@ -84873,7 +84991,7 @@ var _internals97 = {
84873
84991
  formatHandoffMarkdown,
84874
84992
  formatContinuationPrompt,
84875
84993
  escapeHtml,
84876
- sanitizeString: sanitizeString2,
84994
+ sanitizeString: sanitizeString3,
84877
84995
  validatePlanPhases,
84878
84996
  extractCurrentPhaseFromPlan: extractCurrentPhaseFromPlan2,
84879
84997
  parseSessionState,
@@ -95108,6 +95226,36 @@ function makeAdmissionError(cause) {
95108
95226
  return new MemoryMigrationLockError("storage", `memory-family-migration: destination lock acquisition failed${code ? ` (${code})` : ""}`, cause);
95109
95227
  }
95110
95228
  var MAX_BACKUPS = 5;
95229
+ var MEMBER_RECENCY_KEYS = {
95230
+ "memories.jsonl": ["updatedAt", "updated_at"],
95231
+ "proposals.jsonl": ["reviewedAt"]
95232
+ };
95233
+ function rowRecency(row, keys) {
95234
+ if (typeof row !== "object" || row === null)
95235
+ return;
95236
+ const o = row;
95237
+ for (const key of keys) {
95238
+ const value = o[key];
95239
+ if (typeof value === "string") {
95240
+ const ms2 = Date.parse(value);
95241
+ if (!Number.isNaN(ms2))
95242
+ return ms2;
95243
+ }
95244
+ }
95245
+ return;
95246
+ }
95247
+ function rowId(row) {
95248
+ if (typeof row !== "object" || row === null)
95249
+ return null;
95250
+ const o = row;
95251
+ return typeof o.id === "string" ? o.id : null;
95252
+ }
95253
+ function rowIsTombstone(row) {
95254
+ if (typeof row !== "object" || row === null)
95255
+ return false;
95256
+ const metadata = row.metadata;
95257
+ return typeof metadata === "object" && metadata !== null && metadata.deleted === true;
95258
+ }
95111
95259
  function readJsonl3(filePath) {
95112
95260
  if (!existsSync64(filePath))
95113
95261
  return [];
@@ -95128,26 +95276,96 @@ function readJsonl3(filePath) {
95128
95276
  return [];
95129
95277
  }
95130
95278
  }
95131
- function appendUnionById2(destination, source) {
95279
+ function appendUnionById2(destination, source, options = {}) {
95280
+ const memberFilename = options.memberFilename ?? "memories.jsonl";
95281
+ const recencyKeys = MEMBER_RECENCY_KEYS[memberFilename] ?? [];
95132
95282
  const result = [...destination];
95133
- const seen = new Set(result.map((r) => {
95134
- const o = r;
95135
- return typeof o.id === "string" ? o.id : JSON.stringify(r);
95136
- }));
95283
+ const effectiveLast = new Map;
95284
+ const seenRowJson = new Set;
95285
+ for (const row of destination) {
95286
+ const id = rowId(row);
95287
+ if (id !== null)
95288
+ effectiveLast.set(id, row);
95289
+ seenRowJson.add(JSON.stringify(row));
95290
+ }
95137
95291
  let added = 0;
95138
95292
  let skipped = 0;
95293
+ let superseded = 0;
95294
+ const unresolvedCollisions = [];
95295
+ const resurrectedIds = [];
95139
95296
  for (const src of source) {
95140
- const o = src;
95141
- const id = typeof o.id === "string" ? o.id : JSON.stringify(src);
95142
- if (seen.has(id)) {
95297
+ const id = rowId(src);
95298
+ if (id === null) {
95299
+ const json = JSON.stringify(src);
95300
+ if (seenRowJson.has(json)) {
95301
+ skipped++;
95302
+ continue;
95303
+ }
95304
+ result.push(src);
95305
+ seenRowJson.add(json);
95306
+ added++;
95307
+ continue;
95308
+ }
95309
+ const destRow = effectiveLast.get(id);
95310
+ if (destRow === undefined) {
95311
+ result.push(src);
95312
+ effectiveLast.set(id, src);
95313
+ added++;
95314
+ continue;
95315
+ }
95316
+ if (JSON.stringify(destRow) === JSON.stringify(src)) {
95317
+ skipped++;
95318
+ continue;
95319
+ }
95320
+ if (recencyKeys.length === 0) {
95321
+ unresolvedCollisions.push(id);
95143
95322
  skipped++;
95144
95323
  continue;
95145
95324
  }
95325
+ const destRecency = rowRecency(destRow, recencyKeys);
95326
+ const srcRecency = rowRecency(src, recencyKeys);
95327
+ let sourceWins;
95328
+ if (memberFilename === "proposals.jsonl") {
95329
+ if (destRecency === undefined && srcRecency === undefined) {
95330
+ unresolvedCollisions.push(id);
95331
+ skipped++;
95332
+ continue;
95333
+ }
95334
+ sourceWins = destRecency === undefined ? true : srcRecency === undefined ? false : srcRecency > destRecency;
95335
+ } else {
95336
+ if (destRecency === undefined || srcRecency === undefined) {
95337
+ unresolvedCollisions.push(id);
95338
+ skipped++;
95339
+ continue;
95340
+ }
95341
+ sourceWins = srcRecency > destRecency;
95342
+ }
95343
+ if (!sourceWins) {
95344
+ if (rowIsTombstone(destRow) && !rowIsTombstone(src)) {
95345
+ superseded++;
95346
+ } else {
95347
+ skipped++;
95348
+ }
95349
+ continue;
95350
+ }
95351
+ if (rowIsTombstone(destRow) && !rowIsTombstone(src)) {
95352
+ resurrectedIds.push(id);
95353
+ result.push(src);
95354
+ effectiveLast.set(id, src);
95355
+ continue;
95356
+ }
95146
95357
  result.push(src);
95147
- seen.add(id);
95148
- added++;
95358
+ effectiveLast.set(id, src);
95359
+ superseded++;
95149
95360
  }
95150
- return { merged: result, added, skipped };
95361
+ return {
95362
+ merged: result,
95363
+ added,
95364
+ skipped,
95365
+ superseded,
95366
+ unresolvedCollisions,
95367
+ resurrectedIds
95368
+ };
95151
95369
  }
95152
95370
  function appendUnionOutcomeEvents(destination, source) {
95153
95371
  const result = destination.map(validateOutcomeEvent);
@@ -95219,9 +95437,84 @@ async function mergeStagedSqlite(destStoragePath, stagedPath) {
95219
95437
  } catch {}
95220
95438
  }
95221
95439
  }
95222
- return { merged: await countRowsSafe(destDbPath), skipped: 0 };
95440
+ return {
95441
+ merged: await countRowsSafe(destDbPath),
95442
+ skipped: 0,
95443
+ audit: {
95444
+ filename: "memory.db",
95445
+ resurrectedIds: [],
95446
+ supersededCount: 0,
95447
+ unresolvedCollisions: []
95448
+ }
95449
+ };
95223
95450
  }
95224
95451
  try {
95452
+ let tableColumns = function(schema, table) {
95453
+ try {
95454
+ const rows = db.query(`PRAGMA ${schema}.table_info(${table})`).all();
95455
+ return rows.map((r) => r.name);
95456
+ } catch {
95457
+ return [];
95458
+ }
95459
+ }, mergeMemoryItemsRecency = function() {
95460
+ const destCols = tableColumns("main", "memory_items");
95461
+ const stagedCols = tableColumns("staged", "memory_items");
95462
+ const shared = destCols.filter((c) => stagedCols.includes(c));
95463
+ const shapesMatch = destCols.length > 0 && destCols.length === stagedCols.length && shared.length === destCols.length;
95464
+ if (!shapesMatch || !shared.includes("updated_at")) {
95465
+ const result2 = db.run("INSERT OR IGNORE INTO memory_items SELECT * FROM staged.memory_items;");
95466
+ return {
95467
+ merged: result2.changes ?? 0,
95468
+ skipped: 0,
95469
+ resurrectedIds: [],
95470
+ supersededCount: 0
95471
+ };
95472
+ }
95473
+ const overlaps = db.query(`SELECT destination.id AS id,
95474
+ destination.deleted AS dest_deleted,
95475
+ source.deleted AS src_deleted,
95476
+ destination.updated_at AS dest_at,
95477
+ source.updated_at AS src_at
95478
+ FROM memory_items AS destination
95479
+ JOIN staged.memory_items AS source ON source.id = destination.id`).all();
95480
+ const resurrectedIds = [];
95481
+ let supersededCount = 0;
95482
+ for (const row of overlaps) {
95483
+ const srcNewer = row.src_at > row.dest_at;
95484
+ if (row.dest_deleted === 1 && row.src_deleted === 0 && srcNewer) {
95485
+ resurrectedIds.push(row.id);
95486
+ } else if (srcNewer) {
95487
+ supersededCount++;
95488
+ } else if (row.dest_deleted === 1 && row.src_deleted === 0) {
95489
+ supersededCount++;
95490
+ }
95491
+ }
95492
+ const colList = shared.join(", ");
95493
+ const plainSet = shared.filter((c) => c !== "id" && c !== "valid_from" && c !== "supersedes_reason");
95494
+ const setList = plainSet.map((c) => `${c} = excluded.${c}`).join(`,
95495
+ `);
95496
+ const validFromClause = shared.includes("valid_from") ? `,
95497
+ valid_from = memory_items.valid_from` : "";
95498
+ const supersedesClause = shared.includes("supersedes_reason") ? `,
95499
+ supersedes_reason = COALESCE(excluded.supersedes_reason, memory_items.supersedes_reason)` : "";
95500
+ const result = db.run(`INSERT INTO memory_items (${colList})
95501
+ SELECT ${colList} FROM staged.memory_items WHERE true
95502
+ ON CONFLICT(id) DO UPDATE SET
95503
+ ${setList}${validFromClause}${supersedesClause}
95504
+ WHERE excluded.updated_at > memory_items.updated_at;`);
95505
+ const merged = result.changes ?? 0;
95506
+ const stagedCount = db.query("SELECT COUNT(*) AS n FROM staged.memory_items").get()?.n ?? 0;
95507
+ const newIds = Math.max(0, stagedCount - overlaps.length);
95508
+ const updated = Math.min(Math.max(0, merged - newIds), overlaps.length);
95509
+ const skipped = Math.max(0, overlaps.length - updated);
95510
+ if (updated > 0) {
95511
+ const ftsTable = db.query("SELECT COUNT(*) AS n FROM sqlite_master WHERE type='table' AND name='memory_items_fts'").get()?.n ?? 0;
95512
+ if (ftsTable > 0) {
95513
+ db.run("DELETE FROM memory_items_fts;");
95514
+ }
95515
+ }
95516
+ return { merged, skipped, resurrectedIds, supersededCount };
95517
+ };
95225
95518
  const { loadDatabaseCtor: loadDatabaseCtor2 } = await import("./sqlite-loader-amp9z7ty.js");
95226
95519
  const Db = loadDatabaseCtor2();
95227
95520
  const db = new Db(destDbPath);
@@ -95251,13 +95544,32 @@ async function mergeStagedSqlite(destStoragePath, stagedPath) {
95251
95544
  "memory_outcomes"
95252
95545
  ];
95253
95546
  let merged = 0;
95547
+ let skippedCollisions = 0;
95254
95548
  let skippedDueToError = 0;
95255
95549
  const failedTables = [];
95550
+ const unresolvedCollisions = [];
95551
+ let resurrectedIds = [];
95552
+ let supersededCount = 0;
95256
95553
  for (const table of tables) {
95257
95554
  try {
95258
95555
  const stashed = db.query(`SELECT COUNT(*) AS n FROM staged.sqlite_master WHERE type='table' AND name='${table}'`).get();
95259
95556
  if (!stashed || stashed.n === 0)
95260
95557
  continue;
95558
+ if (table === "memory_items") {
95559
+ const outcome = mergeMemoryItemsRecency();
95560
+ merged += outcome.merged;
95561
+ skippedCollisions += outcome.skipped;
95562
+ resurrectedIds = outcome.resurrectedIds;
95563
+ supersededCount = outcome.supersededCount;
95564
+ continue;
95565
+ }
95566
+ if (table === "memory_proposals") {
95567
+ const collided = db.query(`SELECT destination.id AS id
95568
+ FROM memory_proposals AS destination
95569
+ JOIN staged.memory_proposals AS source ON source.id = destination.id`).all();
95570
+ for (const row of collided)
95571
+ unresolvedCollisions.push(row.id);
95572
+ }
95261
95573
  if (table === "memory_outcomes") {
95262
95574
  const overlaps = db.query(`SELECT destination.id,
95263
95575
  destination.event_json AS destination_json,
@@ -95288,7 +95600,16 @@ async function mergeStagedSqlite(destStoragePath, stagedPath) {
95288
95600
  if (failedTables.length > 0) {
95289
95601
  warn(`[memory-family-migration] ${failedTables.length} table(s) skipped during SQLite ATTACH merge: ${failedTables.join(", ")}`);
95290
95602
  }
95291
- return { merged, skipped: skippedDueToError };
95603
+ return {
95604
+ merged,
95605
+ skipped: skippedDueToError + skippedCollisions,
95606
+ audit: {
95607
+ filename: "memory.db",
95608
+ resurrectedIds,
95609
+ supersededCount,
95610
+ unresolvedCollisions
95611
+ }
95612
+ };
95292
95613
  } catch (error2) {
95293
95614
  if (transactionActive) {
95294
95615
  try {
@@ -95347,6 +95668,7 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
95347
95668
  throw makeAdmissionError(error2);
95348
95669
  }
95349
95670
  const perMember = [];
95671
+ const auditEntries = [];
95350
95672
  try {
95351
95673
  for (const member of MEMORY_FAMILY) {
95352
95674
  if (member.mergeStrategy === "skip")
@@ -95355,32 +95677,92 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
95355
95677
  const destPath = path126.join(destStoragePath, member.filename);
95356
95678
  if (member.mergeStrategy === "sqlite-file-copy") {
95357
95679
  if (!existsSync64(srcPath)) {
95358
- perMember.push({ filename: member.filename, merged: 0, skipped: 0 });
95680
+ perMember.push({
95681
+ filename: member.filename,
95682
+ merged: 0,
95683
+ skipped: 0,
95684
+ superseded: 0
95685
+ });
95359
95686
  continue;
95360
95687
  }
95361
95688
  const staged = stageSqliteDb(sourceStoragePath, destStoragePath);
95362
95689
  if (!staged) {
95363
- perMember.push({ filename: member.filename, merged: 0, skipped: 0 });
95690
+ perMember.push({
95691
+ filename: member.filename,
95692
+ merged: 0,
95693
+ skipped: 0,
95694
+ superseded: 0
95695
+ });
95364
95696
  continue;
95365
95697
  }
95366
- const { merged, skipped } = await mergeStagedSqlite(destStoragePath, staged.stagedPath);
95367
- perMember.push({ filename: member.filename, merged, skipped });
95698
+ const { merged, skipped, audit } = await mergeStagedSqlite(destStoragePath, staged.stagedPath);
95699
+ perMember.push({
95700
+ filename: member.filename,
95701
+ merged,
95702
+ skipped,
95703
+ superseded: audit.supersededCount
95704
+ });
95705
+ if (audit.resurrectedIds.length > 0 || audit.supersededCount > 0 || audit.unresolvedCollisions.length > 0) {
95706
+ auditEntries.push(audit);
95707
+ }
95368
95708
  continue;
95369
95709
  }
95370
95710
  if (member.mergeStrategy === "append-union") {
95371
95711
  if (!existsSync64(srcPath)) {
95372
- perMember.push({ filename: member.filename, merged: 0, skipped: 0 });
95712
+ perMember.push({
95713
+ filename: member.filename,
95714
+ merged: 0,
95715
+ skipped: 0,
95716
+ superseded: 0
95717
+ });
95373
95718
  continue;
95374
95719
  }
95375
95720
  const srcData = readJsonl3(srcPath);
95376
95721
  const destData = readJsonl3(destPath);
95377
- const { merged, added, skipped } = member.filename === "outcome-events.jsonl" ? appendUnionOutcomeEvents(destData, srcData) : appendUnionById2(destData, srcData);
95722
+ if (member.filename === "outcome-events.jsonl") {
95723
+ const { merged: merged2, added: added2, skipped: skipped2 } = appendUnionOutcomeEvents(destData, srcData);
95724
+ const serialized2 = serializeJsonl(merged2);
95725
+ if (!validateSerializedJsonl(serialized2)) {
95726
+ throw new Error(`memory-family-migration: validation failed for ${member.filename}; aborting before commit`);
95727
+ }
95728
+ await atomicWriteFile(destPath, serialized2);
95729
+ perMember.push({
95730
+ filename: member.filename,
95731
+ merged: added2,
95732
+ skipped: skipped2,
95733
+ superseded: 0
95734
+ });
95735
+ continue;
95736
+ }
95737
+ const {
95738
+ merged,
95739
+ added,
95740
+ skipped,
95741
+ superseded,
95742
+ unresolvedCollisions,
95743
+ resurrectedIds
95744
+ } = appendUnionById2(destData, srcData, {
95745
+ memberFilename: member.filename
95746
+ });
95378
95747
  const serialized = serializeJsonl(merged);
95379
95748
  if (!validateSerializedJsonl(serialized)) {
95380
95749
  throw new Error(`memory-family-migration: validation failed for ${member.filename}; aborting before commit`);
95381
95750
  }
95382
95751
  await atomicWriteFile(destPath, serialized);
95383
- perMember.push({ filename: member.filename, merged: added, skipped });
95752
+ perMember.push({
95753
+ filename: member.filename,
95754
+ merged: added,
95755
+ skipped,
95756
+ superseded
95757
+ });
95758
+ if (resurrectedIds.length > 0 || superseded > 0 || unresolvedCollisions.length > 0) {
95759
+ auditEntries.push({
95760
+ filename: member.filename,
95761
+ resurrectedIds,
95762
+ supersededCount: superseded,
95763
+ unresolvedCollisions
95764
+ });
95765
+ }
95384
95766
  }
95385
95767
  }
95386
95768
  if (isCohortRoot(sourceRoot)) {
@@ -95410,7 +95792,7 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
95410
95792
  } catch {}
95411
95793
  }
95412
95794
  }
95413
- return { perMember };
95795
+ return { perMember, audit: auditEntries };
95414
95796
  }
95415
95797
  var _internals104 = {
95416
95798
  appendUnionById: appendUnionById2,
@@ -101322,15 +101704,19 @@ ${formatStatus2(directory)}`;
101322
101704
  evictAndCloseForRoot(localRoot);
101323
101705
  let totalMerged = 0;
101324
101706
  let totalSkipped = 0;
101707
+ let totalSuperseded = 0;
101325
101708
  let familySummary = "";
101709
+ let familyAuditNote = "";
101326
101710
  try {
101327
101711
  const result = await migrateMemoryFamily(cohortRoot, localRoot);
101328
101712
  for (const m of result.perMember) {
101329
101713
  totalMerged += m.merged;
101330
101714
  totalSkipped += m.skipped;
101715
+ totalSuperseded += m.superseded;
101331
101716
  }
101332
- familySummary = result.perMember.filter((m) => m.merged > 0 || m.skipped > 0).map((m) => ` ${m.filename}: ${m.merged} merged, ${m.skipped} kept`).join(`
101717
+ familySummary = result.perMember.filter((m) => m.merged > 0 || m.skipped > 0 || m.superseded > 0).map((m) => ` ${m.filename}: ${m.merged} merged, ${m.skipped} kept${m.superseded > 0 ? `, ${m.superseded} recency-resolved` : ""}`).join(`
101333
101718
  `);
101719
+ familyAuditNote = formatFamilyAuditNote(result.audit);
101334
101720
  } catch (error2) {
101335
101721
  return `\u274C Failed to migrate the memory family into the cohort store: ${error2 instanceof Error ? error2.message : String(error2)}`;
101336
101722
  }
@@ -101364,20 +101750,48 @@ ${formatStatus2(directory)}`;
101364
101750
  (Re-linked from previous memory link "${existing.linkId}".)` : "";
101365
101751
  const familyNote = familySummary ? `
101366
101752
  ${familySummary}` : "";
101753
+ const auditNote = familyAuditNote ? `
101754
+ ${familyAuditNote}` : "";
101367
101755
  return [
101368
101756
  `\uD83D\uDD17 Linked this worktree's memory to shared cohort store "${linkId}".`,
101369
- ` migrated the memory family (${totalMerged} new, ${totalSkipped} already present).`,
101757
+ ` migrated the memory family (${totalMerged} new, ${totalSkipped} already present${totalSuperseded > 0 ? `, ${totalSuperseded} resolved by recency` : ""}).`,
101370
101758
  ` shared at: ${cohortRoot.cohortRoot}`,
101371
- "All worktrees linked to this id now read and write the same memory." + relinkNote + familyNote
101759
+ "All worktrees linked to this id now read and write the same memory." + relinkNote + familyNote + auditNote
101372
101760
  ].join(`
101373
101761
  `);
101374
101762
  }
101763
+ function formatFamilyAuditNote(audit) {
101764
+ const resurrected = [...new Set(audit.flatMap((m) => m.resurrectedIds))];
101765
+ const unresolved = [...new Set(audit.flatMap((m) => m.unresolvedCollisions))];
101766
+ const totalSuperseded = audit.reduce((sum, m) => sum + m.supersededCount, 0);
101767
+ const fmtIds = (ids) => {
101768
+ const shown = ids.slice(0, 5).map((raw) => {
101769
+ const id = sanitizeString(raw);
101770
+ return id.length > 40 ? `${id.slice(0, 39)}\u2026` : id;
101771
+ });
101772
+ const more = ids.length > 5 ? ` +${ids.length - 5} more` : "";
101773
+ return `ids: ${shown.join(", ")}${more}`;
101774
+ };
101775
+ const lines = [];
101776
+ if (resurrected.length > 0) {
101777
+ lines.push(`\u26A0 ${resurrected.length} record(s) deleted in one store were re-added from the other (${fmtIds(resurrected)}).`);
101778
+ }
101779
+ if (totalSuperseded > 0) {
101780
+ lines.push(`\u2139 ${totalSuperseded} record collision(s) resolved by recency \u2014 the newer state won.`);
101781
+ }
101782
+ if (unresolved.length > 0) {
101783
+ lines.push(`\u26A0 ${unresolved.length} collision(s) had no recency signal; the pre-existing version was kept (${fmtIds(unresolved)}).`);
101784
+ }
101785
+ return lines.join(`
101786
+ `);
101787
+ }
101375
101788
  async function handleMemoryUnlinkCommand(directory, args) {
101376
101789
  const noCopy = args.includes("--no-copy");
101377
101790
  const pointer = readMemoryLinkPointer(directory);
101378
101791
  if (!pointer) {
101379
101792
  return "\u2139\uFE0F Memory is not linked. Nothing to unlink.";
101380
101793
  }
101794
+ let unlinkAuditNote = "";
101381
101795
  const cohortDir = resolveLinkDir(pointer.linkId);
101382
101796
  const localRoot = wrapLocalRoot(directory);
101383
101797
  const cohortRoot = {
@@ -101392,7 +101806,8 @@ async function handleMemoryUnlinkCommand(directory, args) {
101392
101806
  evictAndCloseForRoot(cohortRoot);
101393
101807
  if (!noCopy) {
101394
101808
  try {
101395
- await migrateMemoryFamily(localRoot, cohortRoot);
101809
+ const result = await migrateMemoryFamily(localRoot, cohortRoot);
101810
+ unlinkAuditNote = formatFamilyAuditNote(result.audit);
101396
101811
  } catch (error2) {
101397
101812
  return `\u274C Failed to copy the cohort memory family back to local storage: ${error2 instanceof Error ? error2.message : String(error2)}`;
101398
101813
  }
@@ -101406,7 +101821,8 @@ async function handleMemoryUnlinkCommand(directory, args) {
101406
101821
  return [
101407
101822
  `\uD83D\uDD13 Unlinked memory. ${copyNote}`,
101408
101823
  ` The shared cohort store at ${cohortRoot.cohortRoot} is NOT deleted`,
101409
- " (other worktrees may still be linked to it)."
101824
+ " (other worktrees may still be linked to it).",
101825
+ ...unlinkAuditNote ? [unlinkAuditNote] : []
101410
101826
  ].join(`
101411
101827
  `);
101412
101828
  }
@@ -101649,7 +102065,7 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
101649
102065
  }
101650
102066
  const sdkOpts = signal ? { signal } : {};
101651
102067
  try {
101652
- const { getSwarmAgents: getSwarmAgents2, resolveFallbackModel: resolveFallbackModel2 } = await import("./index-1w9mc5ck.js");
102068
+ const { getSwarmAgents: getSwarmAgents2, resolveFallbackModel: resolveFallbackModel2 } = await import("./index-r160hfq9.js");
101653
102069
  const createResult = await client.session.create({
101654
102070
  ...sessionId ? {
101655
102071
  body: {
@@ -103748,7 +104164,7 @@ async function cancelPrFeedbackLoopUnlocked(directory, sessionID, reason) {
103748
104164
  clearedEvents: []
103749
104165
  };
103750
104166
  try {
103751
- const { cancelPrFeedbackPublication: cancelPrFeedbackPublication2 } = await import("./pr-workflow-gate-04ypha5r.js");
104167
+ const { cancelPrFeedbackPublication: cancelPrFeedbackPublication2 } = await import("./pr-workflow-gate-regg66xa.js");
103752
104168
  await cancelPrFeedbackPublication2(directory, sessionID, reason);
103753
104169
  } catch (err) {
103754
104170
  warn(`[pr-feedback-loop] cancelPrFeedbackPublication failed (fail-open): ${err instanceof Error ? err.message : String(err)}`);
@@ -120388,7 +120804,7 @@ function buildDetailedHelp(commandName, entry) {
120388
120804
  async function handleHelpCommand(ctx) {
120389
120805
  const targetCommand = ctx.args.join(" ");
120390
120806
  if (!targetCommand) {
120391
- const { buildHelpText } = await import("./index-0g2nvyn9.js");
120807
+ const { buildHelpText } = await import("./index-ztezaknp.js");
120392
120808
  return buildHelpText();
120393
120809
  }
120394
120810
  const tokens = targetCommand.split(/\s+/);
@@ -120402,7 +120818,7 @@ async function handleHelpCommand(ctx) {
120402
120818
  > Note: \`/swarm ${resolved.key}\` is a deprecated alias for \`/swarm ${aliasTarget}\`.` : detailed;
120403
120819
  }
120404
120820
  const similar = _internals38.findSimilarCommands(targetCommand);
120405
- const { buildHelpText: fullHelp } = await import("./index-0g2nvyn9.js");
120821
+ const { buildHelpText: fullHelp } = await import("./index-ztezaknp.js");
120406
120822
  if (similar.length > 0) {
120407
120823
  return `Command '/swarm ${targetCommand}' not found.
120408
120824
 
@@ -120730,7 +121146,7 @@ var COMMAND_REGISTRY = {
120730
121146
  },
120731
121147
  "guardrail explain": {
120732
121148
  handler: async (ctx) => {
120733
- const { handleGuardrailExplain } = await import("./guardrail-explain-ga6m57w3.js");
121149
+ const { handleGuardrailExplain } = await import("./guardrail-explain-zhq6djgr.js");
120734
121150
  return handleGuardrailExplain(ctx.directory, ctx.args);
120735
121151
  },
120736
121152
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -120740,7 +121156,7 @@ var COMMAND_REGISTRY = {
120740
121156
  },
120741
121157
  "guardrail reset": {
120742
121158
  handler: async (ctx) => {
120743
- const { handleGuardrailReset } = await import("./guardrail-reset-ezjd8vtv.js");
121159
+ const { handleGuardrailReset } = await import("./guardrail-reset-3k2x5vsr.js");
120744
121160
  return handleGuardrailReset(ctx.args, ctx.sessionID);
120745
121161
  },
120746
121162
  description: "Reset one exact active invocation/action circuit after repair",
@@ -120761,7 +121177,7 @@ var COMMAND_REGISTRY = {
120761
121177
  },
120762
121178
  "guardrail-log": {
120763
121179
  handler: async (ctx) => {
120764
- const { handleGuardrailLog } = await import("./guardrail-log-aekacstp.js");
121180
+ const { handleGuardrailLog } = await import("./guardrail-log-enq4hp9f.js");
120765
121181
  return handleGuardrailLog(ctx.directory, ctx.args);
120766
121182
  },
120767
121183
  description: "Read the guardrail decision log (use --blocks-only for blocks)",