@cortexkit/opencode-magic-context 0.49.81 → 0.49.82

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 (156) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +4 -4
  3. package/dist/{conflict-warning-hook-8s8r0c0v.js → conflict-warning-hook-a0wrnzch.js} +2 -2
  4. package/dist/{context-359s1ncq.js → context-00f1hdz2.js} +251 -29
  5. package/dist/{embedding-backfill-0tvprmrn.js → embedding-backfill-k994xdas.js} +4 -4
  6. package/dist/features/magic-context/memory/identity-merge-command.d.ts +4 -0
  7. package/dist/features/magic-context/memory/identity-merge-command.d.ts.map +1 -0
  8. package/dist/features/magic-context/memory/project-binding-notice.d.ts +5 -0
  9. package/dist/features/magic-context/memory/project-binding-notice.d.ts.map +1 -0
  10. package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
  11. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  12. package/dist/features/magic-context/storage-clone.d.ts +17 -0
  13. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  14. package/dist/features/magic-context/store-generation-rebase.d.ts +13 -0
  15. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -7
  17. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/stored-compartment-gaps.d.ts +16 -0
  21. package/dist/hooks/magic-context/stored-compartment-gaps.d.ts.map +1 -0
  22. package/dist/hooks/magic-context/transform.d.ts +1 -0
  23. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  24. package/dist/{index-m4q6ptgz.js → index-2xhzmwf6.js} +4 -4
  25. package/dist/{index-jhhkb4jv.js → index-2ygw6q5s.js} +1 -1
  26. package/dist/{index-v0epndb8.js → index-93rezfvc.js} +22 -2
  27. package/dist/{index-1rx9bfrk.js → index-b2787fk6.js} +111 -40
  28. package/dist/{index-tebcx987.js → index-bd34njzg.js} +1 -1
  29. package/dist/{index-zpd4pxnp.js → index-dg5jvh9r.js} +6 -6
  30. package/dist/{index-6athgjba.js → index-e21n48yd.js} +34 -2
  31. package/dist/{index-726b5jh5.js → index-eptthgkw.js} +5 -5
  32. package/dist/{index-9554nr2q.js → index-fgy6hnr3.js} +6 -1
  33. package/dist/{index-tzy5h4x6.js → index-fpqdbb67.js} +1 -1
  34. package/dist/{v2/server-x8a7jmkh.js → index-fzgyvsb1.js} +15 -4
  35. package/dist/{index-1sq1krqw.js → index-g6hfh4h4.js} +4 -4
  36. package/dist/{index-wwzamy3j.js → index-hz1xdb15.js} +3 -3
  37. package/dist/{index-6sckwxjj.js → index-jvr9ba9y.js} +151 -37
  38. package/dist/{index-m6rkq3t4.js → index-rnyaa7cj.js} +1 -1
  39. package/dist/{index-yfn52pb6.js → index-shpyv8gq.js} +2 -2
  40. package/dist/{index-7jefmy0g.js → index-stx8zd81.js} +2 -2
  41. package/dist/{index-jg7sbt3v.js → index-vpw46557.js} +1 -1
  42. package/dist/{index-xx05vta0.js → index-w2wpx7t5.js} +1 -1
  43. package/dist/{index-177yv84k.js → index-w8dcjt7f.js} +1 -1
  44. package/dist/{index-ma258g0g.js → index-wxxcfpxh.js} +5 -5
  45. package/dist/{index-xsdaz3mq.js → index-x8qgqnym.js} +30 -11
  46. package/dist/{index-aawwdt26.js → index-zvane1rq.js} +2 -2
  47. package/dist/index.js +31 -31
  48. package/dist/migration-worker.js +3 -3
  49. package/dist/plugin/rpc-handlers.d.ts +2 -0
  50. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  51. package/dist/{project-embedding-registry-sw4z2ptg.js → project-embedding-registry-y3z36mjy.js} +3 -3
  52. package/dist/raw-ordinal-warmup-worker.js +2 -2
  53. package/dist/{recomp-orchestrator-ar3xw3f4.js → recomp-orchestrator-fjdp3t1d.js} +14 -14
  54. package/dist/{render-bjxgkrk6.js → render-c9fjwrad.js} +6 -6
  55. package/dist/{rpc-notifications-3hed126v.js → rpc-notifications-t9q0ynq7.js} +3 -1
  56. package/dist/{search-z56487n8.js → search-1jejx5cx.js} +9 -9
  57. package/dist/{search-archive-p3jhx9wc.js → search-archive-s2jas2jb.js} +2 -2
  58. package/dist/{send-session-notification-ykvt5k2s.js → send-session-notification-7x518gew.js} +1 -1
  59. package/dist/shared/prompt-surface-runtime.d.ts +1 -1
  60. package/dist/shared/rpc-notifications.d.ts +8 -3
  61. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  62. package/dist/shared/rpc-types.d.ts +4 -0
  63. package/dist/shared/rpc-types.d.ts.map +1 -1
  64. package/dist/shared/status-summary.d.ts +2 -0
  65. package/dist/shared/status-summary.d.ts.map +1 -1
  66. package/dist/shared/status-view-check.d.ts.map +1 -1
  67. package/dist/shared/status-view.d.ts +1 -0
  68. package/dist/shared/status-view.d.ts.map +1 -1
  69. package/dist/shared/user-facing-codes.d.ts +5 -0
  70. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  71. package/dist/{store-8trkpmtx.js → store-ggrq9e14.js} +6 -2
  72. package/dist/{store-reader-3eh1s1m8.js → store-reader-tr64nxyy.js} +1 -1
  73. package/dist/tools/ctx-memory/constants.d.ts +1 -1
  74. package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
  75. package/dist/tools/light-descriptions.d.ts +1 -1
  76. package/dist/tools/light-descriptions.d.ts.map +1 -1
  77. package/dist/tools/parameter-descriptions.d.ts +6 -6
  78. package/dist/tools/parameter-descriptions.d.ts.map +1 -1
  79. package/dist/{transform-postprocess-phase-6kyqctnq.js → transform-postprocess-phase-p2egg02g.js} +15 -15
  80. package/dist/v2/auto-search-worker.js +3 -3
  81. package/dist/v2/chunk-embedding-write-worker.js +4 -4
  82. package/dist/v2/{context-dpe94zcx.js → context-gwkgh0wd.js} +368 -43
  83. package/dist/v2/{embedding-backfill-qnaswpmb.js → embedding-backfill-hjvjxp7d.js} +4 -4
  84. package/dist/v2/fork-inheritance.d.ts +25 -17
  85. package/dist/v2/fork-inheritance.d.ts.map +1 -1
  86. package/dist/v2/hidden-child-native.d.ts +6 -6
  87. package/dist/v2/hidden-child-native.d.ts.map +1 -1
  88. package/dist/v2/hidden-child-record.d.ts +21 -3
  89. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  90. package/dist/v2/hidden-child-sweep.d.ts +1 -1
  91. package/dist/v2/hidden-child-sweep.d.ts.map +1 -1
  92. package/dist/v2/hidden-completion.d.ts +1 -0
  93. package/dist/v2/hidden-completion.d.ts.map +1 -1
  94. package/dist/v2/hidden-run-holder.d.ts +16 -0
  95. package/dist/v2/hidden-run-holder.d.ts.map +1 -0
  96. package/dist/v2/hooks/context.d.ts.map +1 -1
  97. package/dist/v2/hooks/dream-timer.d.ts +5 -7
  98. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  99. package/dist/v2/hooks/fork-history-status.d.ts +10 -0
  100. package/dist/v2/hooks/fork-history-status.d.ts.map +1 -0
  101. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  102. package/dist/v2/hooks/store.d.ts +4 -0
  103. package/dist/v2/hooks/store.d.ts.map +1 -1
  104. package/dist/v2/hooks/types.d.ts +5 -26
  105. package/dist/v2/hooks/types.d.ts.map +1 -1
  106. package/dist/v2/migration-worker.js +3 -3
  107. package/dist/v2/{project-embedding-registry-52f2jept.js → project-embedding-registry-mzsvyads.js} +3 -3
  108. package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
  109. package/dist/v2/{recomp-orchestrator-7t6fkpbb.js → recomp-orchestrator-jn39mxh0.js} +13 -13
  110. package/dist/v2/{render-hwqk0d8t.js → render-q2aj9bgy.js} +6 -6
  111. package/dist/v2/{rpc-notifications-3hed126v.js → rpc-notifications-t9q0ynq7.js} +3 -1
  112. package/dist/v2/{search-eftsvbg7.js → search-9xn6ds9x.js} +8 -8
  113. package/dist/v2/{search-archive-mdxzvgpm.js → search-archive-fj59gjv1.js} +2 -2
  114. package/dist/v2/{send-session-notification-8g4r97bp.js → send-session-notification-p52rhjzy.js} +1 -1
  115. package/dist/v2/{server-ma9jwnas.js → server-1cn3kryt.js} +4 -4
  116. package/dist/v2/{server-34pvhvxt.js → server-1efjj215.js} +22 -2
  117. package/dist/v2/{server-jn4pktdk.js → server-2ktxmtbd.js} +1 -1
  118. package/dist/v2/{server-zw1e3wq5.js → server-2w1rdttn.js} +1 -1
  119. package/dist/v2/{server-jtq03rkb.js → server-4z964n1c.js} +1 -1
  120. package/dist/v2/{server-pxdpwycq.js → server-53n8hv5q.js} +6 -6
  121. package/dist/v2/{server-rbtx6q5v.js → server-569he5mh.js} +1 -1
  122. package/dist/v2/{server-rthnpmbp.js → server-5yfq912a.js} +34 -2
  123. package/dist/v2/{server-mhrgymcs.js → server-68q80y27.js} +2 -2
  124. package/dist/v2/{server-afsz3cmx.js → server-bt546axy.js} +1 -1
  125. package/dist/v2/{server-dhdn8mwq.js → server-c8mqs0v5.js} +30 -11
  126. package/dist/{index-x8a7jmkh.js → v2/server-fzgyvsb1.js} +15 -4
  127. package/dist/v2/{server-76v5y7zm.js → server-g1a0nhtk.js} +2 -2
  128. package/dist/v2/{server-25qtxt4d.js → server-gx1s06dx.js} +6 -1
  129. package/dist/v2/{server-x8ksqcw7.js → server-pejjj0nv.js} +1 -1
  130. package/dist/v2/{server-a1zp7exh.js → server-vt6nj2hn.js} +106 -35
  131. package/dist/v2/{server-qjff96a6.js → server-wdq85mxj.js} +4 -4
  132. package/dist/v2/server.js +3 -3
  133. package/dist/v2/{store-m3zny7q2.js → store-qdgzd38f.js} +6 -2
  134. package/dist/v2/{store-reader-yaxtdy6f.js → store-reader-83tka051.js} +1 -1
  135. package/dist/v2/store-reader.d.ts +15 -8
  136. package/dist/v2/store-reader.d.ts.map +1 -1
  137. package/dist/v2/tui/index.d.ts +1 -1
  138. package/dist/v2/tui/index.d.ts.map +1 -1
  139. package/dist/v2/{v2-archive-reader-p89x05hj.js → v2-archive-reader-9z8z97db.js} +1 -1
  140. package/dist/v2/{wrapup-orchestrator-c0bwb0wa.js → wrapup-orchestrator-vd5zfp3v.js} +13 -13
  141. package/dist/{v2-archive-reader-vzmzb245.js → v2-archive-reader-r0xpxsb1.js} +1 -1
  142. package/dist/{wrapup-orchestrator-548q5y55.js → wrapup-orchestrator-k29zqfp9.js} +15 -15
  143. package/package.json +1 -1
  144. package/src/agents/smart-notes-dreamer-gate.golden.json +169 -169
  145. package/src/shared/prompt-surface-a1-golden.md +8 -7
  146. package/src/shared/rpc-notifications.test.ts +29 -0
  147. package/src/shared/rpc-notifications.ts +24 -5
  148. package/src/shared/rpc-types.ts +4 -0
  149. package/src/shared/status-summary.ts +9 -1
  150. package/src/shared/status-view-check.ts +2 -0
  151. package/src/shared/status-view.test.ts +9 -0
  152. package/src/shared/status-view.ts +4 -0
  153. package/src/shared/user-facing-codes.ts +5 -0
  154. package/src/tui/slots/sidebar-content.tsx +11 -5
  155. package/src/tui-compiled/slots/sidebar-content.tsx +191 -176
  156. package/src/v2/tui/index.ts +7 -2
@@ -60,6 +60,7 @@ import {
60
60
  pruneMissingProjectIdentities,
61
61
  shouldSkipHomeProjectMemory,
62
62
  ProjectIdentityError,
63
+ directoryFallback,
63
64
  takeDubiousOwnershipProjectIdentityWarning,
64
65
  isUserHomeDirectory,
65
66
  resolveProjectIdentity,
@@ -71,7 +72,7 @@ import {
71
72
  storedPathBelongsToIdentity,
72
73
  beginBootQuietPeriod,
73
74
  scheduleAfterBootQuiet
74
- } from "./index-tzy5h4x6.js";
75
+ } from "./index-fpqdbb67.js";
75
76
  import {
76
77
  recordSessionProjectIdentity,
77
78
  hasRecordedSessionProjectIdentity,
@@ -81,7 +82,7 @@ import {
81
82
  markGitSweepSuccessAndRelease,
82
83
  parkGitSweepNonIndexable,
83
84
  releaseGitSweepLease
84
- } from "./index-jg7sbt3v.js";
85
+ } from "./index-vpw46557.js";
85
86
  import {
86
87
  getMagicContextBuiltinCommands,
87
88
  formatConfigParseStatusLine,
@@ -196,7 +197,7 @@ import {
196
197
  snapRangeToCompartments,
197
198
  getActiveCompartmentRun,
198
199
  startCompartmentAgent
199
- } from "./index-1rx9bfrk.js";
200
+ } from "./index-b2787fk6.js";
200
201
  import {
201
202
  hasTrustedAbsoluteWall,
202
203
  applyProvenInputFloor,
@@ -453,7 +454,7 @@ import {
453
454
  runSqliteOptimize,
454
455
  openDatabase,
455
456
  openCurrentDatabase
456
- } from "./index-aawwdt26.js";
457
+ } from "./index-zvane1rq.js";
457
458
  import {
458
459
  unescapeXml,
459
460
  resolveWorkspaceShareCategories,
@@ -462,7 +463,7 @@ import {
462
463
  resolveStoredPathWorkspaceIdentity,
463
464
  storedPathBelongsToWorkspace,
464
465
  computeWorkspaceEpochFingerprint
465
- } from "./index-xx05vta0.js";
466
+ } from "./index-w2wpx7t5.js";
466
467
  import {
467
468
  V2_MEMORY_CATEGORIES,
468
469
  CATEGORY_PRIORITY
@@ -569,7 +570,7 @@ import {
569
570
  GLOBAL_USER_PROFILE_PROJECT_PATH,
570
571
  getProjectState,
571
572
  bumpProjectUserProfileVersion
572
- } from "./index-xsdaz3mq.js";
573
+ } from "./index-x8qgqnym.js";
573
574
  import {
574
575
  getLastIndexedOrdinal
575
576
  } from "./index-zzvd4a9z.js";
@@ -598,14 +599,14 @@ import {
598
599
  createPrimer,
599
600
  updatePrimerSupport,
600
601
  updatePrimerAnswer
601
- } from "./index-tebcx987.js";
602
+ } from "./index-bd34njzg.js";
602
603
  import {
603
604
  registerNotificationSink2,
604
605
  pushNotification2,
605
606
  acknowledgeNotifications2,
606
607
  drainNotifications2,
607
608
  isTuiConnected2
608
- } from "./index-x8a7jmkh.js";
609
+ } from "./index-fzgyvsb1.js";
609
610
  import {
610
611
  getCachedLocalEmbeddingPooling,
611
612
  preflightLocalEmbeddingPooling,
@@ -631,7 +632,7 @@ import {
631
632
  embedSessionCompartmentChunks2,
632
633
  getEmbeddingCoverageStatus2,
633
634
  getAutoEmbeddingSessionCoverage2
634
- } from "./index-yfn52pb6.js";
635
+ } from "./index-shpyv8gq.js";
635
636
  import {
636
637
  saveEmbeddingIfHashMatches,
637
638
  invalidateProject2,
@@ -657,7 +658,7 @@ import {
657
658
  readGitFileChangeTimesSince,
658
659
  verificationFileExists,
659
660
  normalizeVerificationFiles
660
- } from "./index-9554nr2q.js";
661
+ } from "./index-fgy6hnr3.js";
661
662
  import {
662
663
  computeCueContentHash,
663
664
  hasMuralCueColumns,
@@ -682,6 +683,7 @@ import {
682
683
  supersededMemory2,
683
684
  mergeMemoryStats2,
684
685
  archiveMemory2,
686
+ getMemoryCount2,
685
687
  getMemoryCountsByStatus2
686
688
  } from "./index-jjvbk92s.js";
687
689
  import {
@@ -704,23 +706,23 @@ import {
704
706
  resolveMemoriesByIdsForSearch2,
705
707
  unifiedSearch2,
706
708
  formatSearchResults2
707
- } from "./index-zpd4pxnp.js";
709
+ } from "./index-dg5jvh9r.js";
708
710
  import {
709
711
  scheduleReconciliation,
710
712
  scheduleIncrementalIndex,
711
713
  getMessageIndexQueueHeapStats,
712
714
  clearSessionTracking
713
- } from "./index-m6rkq3t4.js";
715
+ } from "./index-rnyaa7cj.js";
714
716
  import {
715
717
  flushIgnoredMessages2,
716
718
  clearIgnoredMessages2,
717
719
  observeIgnoredNotificationEvent2,
718
720
  sendStatusNotification2
719
- } from "./index-1sq1krqw.js";
721
+ } from "./index-g6hfh4h4.js";
720
722
  import {
721
723
  setRecompStarting2,
722
724
  setRecompTerminal2
723
- } from "./index-wwzamy3j.js";
725
+ } from "./index-hz1xdb15.js";
724
726
  import {
725
727
  makeToolCompositeKey,
726
728
  searchMessageHistoryOffThread,
@@ -805,7 +807,7 @@ import {
805
807
  abortSessionFailClosed2,
806
808
  evaluateEmergencyFailClosed2,
807
809
  runPostTransformPhase2
808
- } from "./index-ma258g0g.js";
810
+ } from "./index-wxxcfpxh.js";
809
811
  import {
810
812
  ANNOUNCEMENT_VERSION2,
811
813
  ANNOUNCEMENT_FEATURES2,
@@ -823,10 +825,10 @@ import {
823
825
  } from "./index-twmeey4h.js";
824
826
  import {
825
827
  readV2ArchiveOffThread2
826
- } from "./index-m4q6ptgz.js";
828
+ } from "./index-2xhzmwf6.js";
827
829
  import {
828
830
  renderSearchArchiveOffThread2
829
- } from "./index-jhhkb4jv.js";
831
+ } from "./index-2ygw6q5s.js";
830
832
  import {
831
833
  COMPACTION_ENABLED_PATH,
832
834
  isDreamerRunnable,
@@ -13140,6 +13142,79 @@ function getActiveMemoryImportanceHistogram(db, projectPath) {
13140
13142
  };
13141
13143
  }
13142
13144
 
13145
+ // src/features/magic-context/memory/identity-merge-command.ts
13146
+ var IDENTITY_MERGE_COMMAND = "npx @cortexkit/magic-context@latest doctor merge-identities";
13147
+ var IDENTITY_MERGE_PREVIEW_HINT = "It shows what would move. Add --apply to move them.";
13148
+ function shellArg(value, platform) {
13149
+ if (/^[\w.:/-]+$/.test(value))
13150
+ return value;
13151
+ return platform === "win32" ? `"${value}"` : `'${value.replaceAll("'", "'\\''")}'`;
13152
+ }
13153
+ function identityMergeCommand(from, to, platform = process.platform) {
13154
+ return `${IDENTITY_MERGE_COMMAND} --from ${shellArg(from, platform)} --to ${to ? shellArg(to, platform) : '"DESTINATION_IDENTITY"'}`;
13155
+ }
13156
+
13157
+ // src/features/magic-context/memory/project-binding-notice.ts
13158
+ var observedBindings = new WeakMap;
13159
+ function bindingLog(harness, directory, old, identity, memories) {
13160
+ return `project binding changed harness=${harness} cwd=${directory || "unknown"} old=${old ?? "none"} new=${identity} memories=${memories}`;
13161
+ }
13162
+ function observeSessionProjectBinding(db, sessionId, identity, directory, notify) {
13163
+ const change = recordSessionProjectIdentity(db, sessionId, identity);
13164
+ const harness = getHarness2();
13165
+ let observations = observedBindings.get(db);
13166
+ if (!observations) {
13167
+ observations = new BoundedSessionMap(1000);
13168
+ observedBindings.set(db, observations);
13169
+ }
13170
+ const key = `${harness}\x00${sessionId}`;
13171
+ const last = observations.get(key);
13172
+ const noticed = last?.noticed ?? new Set;
13173
+ const observation = {
13174
+ directory,
13175
+ noticed,
13176
+ warning: change ? undefined : last?.warning
13177
+ };
13178
+ observations.set(key, observation);
13179
+ const old = change?.previousProjectPath;
13180
+ if (!change || !old && harness !== "pi" && harness !== "omp")
13181
+ return;
13182
+ const memories = old ? getMemoryCount2(db, old) : 0;
13183
+ const binding = bindingLog(harness, directory, old, identity, memories);
13184
+ if (!old || !memories) {
13185
+ sessionLog2(sessionId, binding);
13186
+ return;
13187
+ }
13188
+ const oldDirectory = [last?.directory, directory].find((path) => path && directoryFallback(path) === old);
13189
+ const location = oldDirectory ? `the old folder (${oldDirectory})` : `the old project (${old})`;
13190
+ let guidance;
13191
+ if (old.startsWith("dir:") && /^(dir|git):/.test(identity)) {
13192
+ guidance = `Review the merge first:
13193
+ ${identityMergeCommand(oldDirectory ?? old, identity)}
13194
+ ${IDENTITY_MERGE_PREVIEW_HINT}`;
13195
+ } else if (old.startsWith("git:") && identity.startsWith("dir:")) {
13196
+ guidance = "A repository's memories cannot be merged into a folder project.";
13197
+ } else {
13198
+ guidance = "Run `npx @cortexkit/magic-context@latest doctor` to see how these memories can be merged.";
13199
+ }
13200
+ const count = `${memories} ${memories === 1 ? "memory" : "memories"}`;
13201
+ observation.warning = `${count} stayed under this session's previous project. Nothing was moved.
13202
+ ${guidance}`;
13203
+ if (noticed.has(old)) {
13204
+ sessionLog2(sessionId, binding);
13205
+ return;
13206
+ }
13207
+ noticed.add(old);
13208
+ const notice = `This session changed projects. ${count} stayed with ${location}; nothing moved. ${guidance}`;
13209
+ sessionLog2(sessionId, `${binding} notice=${JSON.stringify(notice)}`);
13210
+ try {
13211
+ notify?.(notice);
13212
+ } catch {}
13213
+ }
13214
+ function getProjectBindingWarning(db, sessionId) {
13215
+ return observedBindings.get(db)?.peek(`${getHarness2()}\x00${sessionId}`)?.warning;
13216
+ }
13217
+
13143
13218
  // src/features/magic-context/session-cache-ttl.ts
13144
13219
  function readSessionCacheTtl(db, sessionId) {
13145
13220
  const saved = readReplayEnvelope(db, sessionId).cacheTtlPolicy;
@@ -13807,7 +13882,9 @@ function statusWarningsFromDetail(detail) {
13807
13882
  const warnings = [];
13808
13883
  if (detail.lastTransformError)
13809
13884
  warnings.push("transform_update_failed");
13810
- if ((detail.historianFailureCount ?? 0) > 0)
13885
+ if (detail.forkHistoryGap)
13886
+ warnings.push("fork_history_gap");
13887
+ else if ((detail.historianFailureCount ?? 0) > 0)
13811
13888
  warnings.push("historian_unavailable");
13812
13889
  if ((detail.configParseFailures?.length ?? 0) > 0)
13813
13890
  warnings.push("configuration_warning");
@@ -13862,6 +13939,7 @@ function statusSummaryFromDetail(detail) {
13862
13939
  compactionMarker: detail.compactionMarker,
13863
13940
  warnings: statusWarningsFromDetail(detail),
13864
13941
  hiddenVariantWarnings: detail.hiddenVariantWarnings ?? [],
13942
+ projectBindingWarning: detail.projectBindingWarning,
13865
13943
  dreamerSkipped: detail.dreamerSkipped,
13866
13944
  hiddenModelSkips: detail.hiddenModelSkips,
13867
13945
  dreamerQuotas: [
@@ -13966,6 +14044,10 @@ function renderUserStatusSummary(summary, style) {
13966
14044
  for (const warning of summary.hiddenVariantWarnings ?? []) {
13967
14045
  lines.push(style === "markdown" ? `- **Warning:** ${warning}` : `Warning: ${warning}`);
13968
14046
  }
14047
+ if (summary.projectBindingWarning) {
14048
+ const label = style === "markdown" ? "- **Warning:**" : "Warning:";
14049
+ lines.push(`${label} ${summary.projectBindingWarning}`);
14050
+ }
13969
14051
  for (const warning of summary.warnings) {
13970
14052
  lines.push(style === "markdown" ? `- **Warning:** ${renderUserFacingFailure(warning)}` : `Warning: ${renderUserFacingFailure(warning)}`);
13971
14053
  }
@@ -14616,7 +14698,11 @@ ${c.content}
14616
14698
  const rebaseNotice = readCoordinateRebaseNotice(db, sessionId);
14617
14699
  const rebaseNoticeLine = rebaseNotice ? formatCoordinateRebaseNotice(rebaseNotice) : null;
14618
14700
  if (rebaseNotice && rebaseNoticeLine) {
14619
- lines.push("", "### Store Conversion", `- The host changed how it stores this conversation (${rebaseNotice.previousGeneration ?? "unrecorded"} → ${rebaseNotice.generation}); saved positions were re-derived from message ids.`, `- ${rebaseNoticeLine}.`);
14701
+ if (rebaseNotice.inheritedGaps !== undefined) {
14702
+ lines.push("", "### Saved History Recovery", `- ${rebaseNoticeLine}.`);
14703
+ } else {
14704
+ lines.push("", "### Store Conversion", `- The host changed how it stores this conversation (${rebaseNotice.previousGeneration ?? "unrecorded"} → ${rebaseNotice.generation}); saved positions were re-derived from message ids.`, `- ${rebaseNoticeLine}.`);
14705
+ }
14620
14706
  }
14621
14707
  lines.push("", "### History Compression", `- Compartments: ${compartments.length}`, ...rebaseNotice && rebaseNotice.unresolvedCompartments > 0 ? [
14622
14708
  `- Excluded from range recovery: ${rebaseNotice.unresolvedCompartments} (endpoint message no longer in this host's history)`
@@ -15962,6 +16048,7 @@ function buildSidebarSnapshot(db, sessionId, directory, liveSessionState, inject
15962
16048
  readySmartNoteCount,
15963
16049
  cacheTtl,
15964
16050
  lastTransformError: meta?.last_transform_error ? String(meta.last_transform_error) : null,
16051
+ projectBindingWarning: getProjectBindingWarning(db, sessionId),
15965
16052
  lastDreamerRunAt,
15966
16053
  projectIdentity,
15967
16054
  dreamerBacklog,
@@ -16466,6 +16553,15 @@ function registerRpcHandlers(rpcServer, args) {
16466
16553
  const rawConfig = config;
16467
16554
  const getNotificationParams = (sessionId) => getLiveNotificationParams(sessionId, liveSessionState.liveModelBySession, liveSessionState.variantBySession, liveSessionState.agentBySession, currentPluginConfigReader(directory)?.poll().effective.toast_duration_ms ?? config.toast_duration_ms);
16468
16555
  const injectionBudgetTokens = config.memory?.injection_budget_tokens;
16556
+ const showForkHistoryGap = (db, sessionId) => {
16557
+ if (!compactionEnabled || config.transform_mode === "rust")
16558
+ return false;
16559
+ try {
16560
+ return args.readForkHistoryGap?.(db, sessionId) === true;
16561
+ } catch {
16562
+ return false;
16563
+ }
16564
+ };
16469
16565
  if (isDebugRpcEnabled(config)) {
16470
16566
  const readMemory = () => buildDebugMemoryUsage(args.getDebugMemoryHolders?.());
16471
16567
  rpcServer.handle("debug.memoryUsage", async () => ({ ...readMemory() }));
@@ -16486,7 +16582,10 @@ function registerRpcHandlers(rpcServer, args) {
16486
16582
  error: "Rust module status unavailable; canonical session state was not read"
16487
16583
  };
16488
16584
  }
16489
- return buildSidebarSnapshotRpcResponse(db, sessionId, dir, liveSessionState, injectionBudgetTokens, rawConfig, moduleStatus, compactionEnabled);
16585
+ const snapshot = buildSidebarSnapshotRpcResponse(db, sessionId, dir, liveSessionState, injectionBudgetTokens, rawConfig, moduleStatus, compactionEnabled);
16586
+ if (!snapshot.error && snapshot.disabled !== true && showForkHistoryGap(db, sessionId))
16587
+ snapshot.forkHistoryGap = true;
16588
+ return snapshot;
16490
16589
  });
16491
16590
  rpcServer.handle("session-owner", async (params) => {
16492
16591
  const sessionId = String(params.sessionId ?? "");
@@ -16520,6 +16619,8 @@ function registerRpcHandlers(rpcServer, args) {
16520
16619
  };
16521
16620
  }
16522
16621
  const detail = buildStatusDetail(db, sessionId, dir, modelKey, rawConfig, liveSessionState, injectionBudgetTokens, moduleStatus, compactionEnabled);
16622
+ if (showForkHistoryGap(db, sessionId))
16623
+ detail.forkHistoryGap = true;
16523
16624
  if (args.hiddenCompletionExecutor?.capabilities.tools === false) {
16524
16625
  detail.dreamerUnsupportedTasks = toolLoopDreamTasks();
16525
16626
  }
@@ -16615,8 +16716,8 @@ function registerRpcHandlers(rpcServer, args) {
16615
16716
  const db = readDatabase();
16616
16717
  if (!db)
16617
16718
  return { ok: false, error: "db unavailable" };
16618
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-ar3xw3f4.js"));
16619
- const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-ykvt5k2s.js"));
16719
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-fjdp3t1d.js"));
16720
+ const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-7x518gew.js"));
16620
16721
  log2(`[rpc] recomp requested for session ${sessionId}`);
16621
16722
  if (!args.client && !args.hiddenCompletionExecutor) {
16622
16723
  return {
@@ -16700,7 +16801,7 @@ function registerRpcHandlers(rpcServer, args) {
16700
16801
  const db = readDatabase();
16701
16802
  if (!db)
16702
16803
  return { ok: false, error: "db unavailable" };
16703
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-548q5y55.js"));
16804
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-k29zqfp9.js"));
16704
16805
  const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
16705
16806
  const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
16706
16807
  if (!window)
@@ -22935,7 +23036,11 @@ function createRustModeTransform(deps, options) {
22935
23036
  const sessionProjectIdentity = (options.sessionProjectIdentityResolverForTests ?? resolveProjectIdentityForSession)(directory, deps.allowHomeProject);
22936
23037
  if (sessionProjectIdentity) {
22937
23038
  if (state.recordedSessionProjectIdentity !== sessionProjectIdentity) {
22938
- recordSessionProjectIdentity(deps.db, sessionId, sessionProjectIdentity);
23039
+ observeSessionProjectBinding(deps.db, sessionId, sessionProjectIdentity, directory, (notice) => {
23040
+ withoutSqliteTransformPass2(() => sendStatusNotification2(deps.client, sessionId, `## Project memory warning
23041
+
23042
+ ${notice}`, {}));
23043
+ });
22939
23044
  }
22940
23045
  state.recordedSessionProjectIdentity = sessionProjectIdentity;
22941
23046
  state.recordedSessionDirectory = directory;
@@ -25743,7 +25848,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25743
25848
  const authorityProjectPath = (deps.memoryConfig?.enabled ? projectIdentity : undefined) ?? deps.projectPath ?? sessionProjectIdentity;
25744
25849
  if (authorityProjectPath) {}
25745
25850
  if (sessionIdentityForBinding && sessionDirectoryResolvedFromHost && recordedSessionProjectIdentity.get(sessionId) !== sessionIdentityForBinding) {
25746
- recordSessionProjectIdentity(db, sessionId, sessionIdentityForBinding);
25851
+ observeSessionProjectBinding(db, sessionId, sessionIdentityForBinding, sessionDirectory, (notice) => {
25852
+ if (deps.hostProjectBindingNotice)
25853
+ deps.hostProjectBindingNotice(sessionId, notice);
25854
+ else {
25855
+ withoutSqliteTransformPass2(() => sendStatusNotification2(deps.client, sessionId, `## Project memory warning
25856
+
25857
+ ${notice}`, notificationParams));
25858
+ }
25859
+ });
25747
25860
  recordedSessionProjectIdentity.set(sessionId, sessionIdentityForBinding);
25748
25861
  }
25749
25862
  const taggerFloor = compactionOff ? 0 : deriveTaggerLoadFloor(messages, sessionId, db);
@@ -28405,10 +28518,11 @@ Your active memories are already in <project-memory> as \`#id: fact\` lines. Wri
28405
28518
 
28406
28519
  Actions:
28407
28520
  - write: new memory (content + category).
28408
- - update: rewrite one memory whose fact changed (ids: [one], content; category optional to recategorize).
28521
+ - update: rewrite one memory whose fact changed (ids: [one], content; category: the current one to keep, a new one to recategorize).
28409
28522
  - archive: retire wrong or obsolete memories (ids: [one or more], optional reason).
28410
- - merge: collapse duplicates into one (ids: [two or more], content).
28523
+ - merge: collapse duplicates into one (ids: [two or more distinct ids of memories in the same category], content).
28411
28524
  - get: fetch by id (ids: 1–20), readable in every status.
28525
+ The call form that works on every host sends action, content, category and ids every time: argument-dropping providers only emit required fields. For get and archive pass content="" and any valid category; for write pass ids=[].
28412
28526
  Examples: category="CONFIG_VALUES", content="OpenCode source is at ~/Work/OSS/opencode" · category="CONSTRAINTS", content="Dashboard Tauri build needs RGBA PNGs, not grayscale"`;
28413
28527
  var DEFAULT_SEARCH_LIMIT = 10;
28414
28528
  // src/tools/ctx-memory/tools.ts
@@ -28668,13 +28782,13 @@ function updateMemoryContentInCurrentTransaction(db, memory, content, normalized
28668
28782
  }
28669
28783
  var ctxMemoryArgsShape = {
28670
28784
  action: tool2.schema.enum([...CTX_MEMORY_ACTIONS]).describe("write | update | archive | merge | get"),
28671
- content: tool2.schema.string().describe("The memory text — one standalone fact (write, update, merge)."),
28672
- category: tool2.schema.enum([...V2_MEMORY_CATEGORIES]).describe("Kind of fact (required for write; on update/merge, pass the memory's current category to keep it)."),
28673
- ids: tool2.schema.array(tool2.schema.number()).describe("Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get."),
28785
+ content: tool2.schema.string().describe("Send on every call — the memory text for write, update and merge; pass an empty string for archive and get."),
28786
+ category: tool2.schema.enum([...V2_MEMORY_CATEGORIES]).describe("Send on every call — the fact's kind for write; on update/merge, the memory's current category to keep it; archive and get ignore it, so pass any valid category."),
28787
+ ids: tool2.schema.array(tool2.schema.number()).describe("Send on every call — one id for update, one or more for archive, two or more distinct ids of memories in the same category for merge, 1–20 for get; write takes an empty list."),
28674
28788
  reason: tool2.schema.string().optional().describe("Why it is being archived (optional).")
28675
28789
  };
28676
28790
  var ctxMemoryListArgsShape = {
28677
- category: tool2.schema.enum([...V2_MEMORY_CATEGORIES]).optional().describe("Kind of fact (required for write; on update/merge optional, omitted keeps the current category)."),
28791
+ category: tool2.schema.enum([...V2_MEMORY_CATEGORIES]).optional().describe("Filter listed memories to this category (optional)."),
28678
28792
  limit: tool2.schema.number().optional().describe("Max results for list (default 10).")
28679
28793
  };
28680
28794
  var ctxMemoryArgsSchema = tool2.schema.object({
@@ -30273,9 +30387,9 @@ var FULL_PARAMETER_DESCRIPTIONS = {
30273
30387
  },
30274
30388
  ctx_memory: {
30275
30389
  action: "write | update | archive | merge | get",
30276
- content: "The memory text — one standalone fact (write, update, merge). Archive and get take an empty string.",
30277
- category: "Kind of fact: the new fact's kind for write; on update/merge, the memory's current category to keep it. Archive and get ignore it.",
30278
- ids: "Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get. Write takes an empty list.",
30390
+ content: "Send on every call — the memory text for write, update and merge; pass an empty string for archive and get.",
30391
+ category: "Send on every call — the fact's kind for write; on update/merge, the memory's current category to keep it; archive and get ignore it, so pass any valid category.",
30392
+ ids: "Send on every call — one id for update, one or more for archive, two or more distinct ids of memories in the same category for merge, 1–20 for get; write takes an empty list.",
30279
30393
  reason: "Why it is being archived (optional)."
30280
30394
  },
30281
30395
  ctx_search: {
@@ -30308,9 +30422,9 @@ var LIGHT_PARAMETER_DESCRIPTIONS = {
30308
30422
  },
30309
30423
  ctx_memory: {
30310
30424
  action: "write | update | archive | merge | get",
30311
- content: "One standalone fact (write, update, merge). Archive and get: empty string.",
30312
- category: "Kind of fact (write; on update/merge pass the current category to keep it). Archive and get ignore it.",
30313
- ids: "Ids from <project-memory>: one for update, 1+ for archive, 2+ for merge, 1–20 for get. Write: empty list.",
30425
+ content: "Send on every call: the fact (write, update, merge); empty string for archive/get.",
30426
+ category: "Send on every call: kind for write; current category for update/merge; any category for archive/get (ignored).",
30427
+ ids: "Send on every call: one id for update, 1+ for archive, 2+ distinct same-category ids for merge, 1–20 for get; write: empty list.",
30314
30428
  reason: "Why it is archived (optional)."
30315
30429
  },
30316
30430
  ctx_search: {
@@ -16,7 +16,7 @@ import {
16
16
  } from "./index-q7q6qp1f.js";
17
17
  import {
18
18
  scheduleAfterBootQuiet
19
- } from "./index-tzy5h4x6.js";
19
+ } from "./index-fpqdbb67.js";
20
20
  import {
21
21
  cleanSearchText,
22
22
  hintKeywordRelevance,
@@ -67,7 +67,7 @@ import {
67
67
  } from "./index-2amn2s73.js";
68
68
  import {
69
69
  setBootQuietPeriodForTests
70
- } from "./index-tzy5h4x6.js";
70
+ } from "./index-fpqdbb67.js";
71
71
  import {
72
72
  isEmbeddingHostBusy2
73
73
  } from "./index-qt1qqasc.js";
@@ -78,7 +78,7 @@ import {
78
78
  acquireGitSweepLease,
79
79
  renewGitSweepLease,
80
80
  releaseGitSweepLease
81
- } from "./index-jg7sbt3v.js";
81
+ } from "./index-vpw46557.js";
82
82
  import {
83
83
  saveEmbeddingIfHashMatches,
84
84
  getMemoryEmbedCoverage,
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-ywrz4wy2.js";
5
5
  import {
6
6
  sendStatusNotification2
7
- } from "./index-1sq1krqw.js";
7
+ } from "./index-g6hfh4h4.js";
8
8
  import {
9
9
  formatConflictShort
10
10
  } from "./index-nxxzeq4y.js";
@@ -235,7 +235,7 @@ async function sendStartupAnnouncement2(client, directory, version, features, fo
235
235
  if (!sessionId) {
236
236
  return;
237
237
  }
238
- const { isTuiConnected } = await importPluginModule(() => import("./rpc-notifications-3hed126v.js"));
238
+ const { isTuiConnected } = await importPluginModule(() => import("./rpc-notifications-t9q0ynq7.js"));
239
239
  if (isTuiConnected(sessionId) || isTuiConnected())
240
240
  return;
241
241
  const bullets = features.map((line) => ` • ${line}`).join(`
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-pavzsdc6.js";
4
4
  import {
5
5
  isUserHomeDirectory
6
- } from "./index-tzy5h4x6.js";
6
+ } from "./index-fpqdbb67.js";
7
7
  import {
8
8
  logSlowWriteTransaction
9
9
  } from "./index-m0pwswv9.js";
@@ -20,7 +20,7 @@ import {
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./index-tzy5h4x6.js";
23
+ } from "./index-fpqdbb67.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
26
  } from "./index-m0pwswv9.js";
@@ -10,7 +10,7 @@ import {
10
10
  readSearchBackfillCursor2,
11
11
  writeSearchBackfillCursor2,
12
12
  embedItemsWindowBounded2
13
- } from "./index-yfn52pb6.js";
13
+ } from "./index-shpyv8gq.js";
14
14
  import {
15
15
  saveEmbeddingIfHashMatches
16
16
  } from "./index-4dhv7mqz.js";
@@ -225,7 +225,7 @@ import {
225
225
  saveSourceContent,
226
226
  replaceSourceContent,
227
227
  getSourceContents
228
- } from "./index-xsdaz3mq.js";
228
+ } from "./index-x8qgqnym.js";
229
229
  import {
230
230
  cleanSearchText,
231
231
  matchedSearchSnippet
@@ -234,18 +234,18 @@ import {
234
234
  getProjectEmbeddingSnapshot2,
235
235
  embedTextForProject2,
236
236
  embedBatchForProject2
237
- } from "./index-yfn52pb6.js";
237
+ } from "./index-shpyv8gq.js";
238
238
  import {
239
239
  isEmbeddingHostBusy2
240
240
  } from "./index-qt1qqasc.js";
241
241
  import {
242
242
  userFacingFailureCode
243
- } from "./index-9554nr2q.js";
243
+ } from "./index-fgy6hnr3.js";
244
244
  import {
245
245
  getMessageIndexEpoch,
246
246
  isMessageIndexSearchable,
247
247
  createAutoSearchDiagnostics
248
- } from "./index-m6rkq3t4.js";
248
+ } from "./index-rnyaa7cj.js";
249
249
  import {
250
250
  openCodeDbExists,
251
251
  withReadOnlySessionDb,
@@ -285,7 +285,7 @@ import {
285
285
  peekNoteNudgeText,
286
286
  markNoteNudgeDelivered,
287
287
  getActiveCompartmentRun
288
- } from "./index-1rx9bfrk.js";
288
+ } from "./index-b2787fk6.js";
289
289
  import {
290
290
  getErrorMessage
291
291
  } from "./index-y8v6yerm.js";
@@ -75,11 +75,11 @@ import {
75
75
  import {
76
76
  layoutLkgPrefix,
77
77
  assembleLkgPrefix
78
- } from "./index-xx05vta0.js";
78
+ } from "./index-w2wpx7t5.js";
79
79
  import {
80
80
  gaDatabasePath2,
81
81
  V2StoreReader2
82
- } from "./index-6athgjba.js";
82
+ } from "./index-e21n48yd.js";
83
83
  import {
84
84
  markHostInstructionRow,
85
85
  hostInstructionRowID,
@@ -4692,9 +4692,10 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4692
4692
  const compartmentColumns = db.prepare("PRAGMA table_info(compartments)").all();
4693
4693
  const hasBlockIndices = ["start_block_index", "end_block_index"].every((name) => compartmentColumns.some((column) => column.name === name));
4694
4694
  const blockProjection = hasBlockIndices ? "start_block_index, end_block_index" : "NULL AS start_block_index, NULL AS end_block_index";
4695
+ const rebaseProjection = compartmentColumns.some(({ name }) => name === "rebase_status") ? "rebase_status" : "NULL AS rebase_status";
4695
4696
  const sourceCompartments = db.prepare(`SELECT sequence, start_message, end_message, start_message_id, end_message_id,
4696
4697
  title, content, p1, p2, p3, p4, importance, episode_type, legacy,
4697
- created_at, harness, ${blockProjection}
4698
+ created_at, harness, ${blockProjection}, ${rebaseProjection}
4698
4699
  FROM compartments WHERE session_id = ? ORDER BY sequence ASC`).all(sourceSessionId);
4699
4700
  const insertCompartment = db.prepare(`INSERT INTO compartments
4700
4701
  (session_id, sequence, start_message, end_message, start_message_id,
@@ -4702,18 +4703,31 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4702
4703
  episode_type, legacy, created_at, harness${hasBlockIndices ? ", start_block_index, end_block_index" : ""})
4703
4704
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?${hasBlockIndices ? ", ?, ?" : ""})`);
4704
4705
  const copiedCompartments = [];
4706
+ const selected = filter.selectCompartments?.(sourceCompartments.map((row) => ({
4707
+ sequence: row.sequence,
4708
+ startMessage: row.start_message,
4709
+ endMessage: row.end_message,
4710
+ startMessageId: row.start_message_id,
4711
+ endMessageId: row.end_message_id,
4712
+ rebaseStatus: row.rebase_status
4713
+ })));
4705
4714
  for (const row of sourceCompartments) {
4706
- const startMessage = filter.resolveBoundaryOrdinal(row.start_message_id);
4707
- const endMessage = filter.resolveBoundaryOrdinal(row.end_message_id);
4715
+ const mapped = selected?.get(row.sequence);
4716
+ if (selected && !mapped)
4717
+ continue;
4718
+ const startMessage = mapped?.startMessage ?? filter.resolveBoundaryOrdinal(row.start_message_id);
4719
+ const endMessage = mapped?.endMessage ?? filter.resolveBoundaryOrdinal(row.end_message_id);
4708
4720
  if (startMessage === undefined || endMessage === undefined)
4709
4721
  continue;
4710
- insertCompartment.run(destinationSessionId, row.sequence, startMessage, endMessage, mapMessageId(filter, row.start_message_id), mapMessageId(filter, row.end_message_id), row.title, row.content, row.p1, row.p2, row.p3, row.p4, row.importance, row.episode_type, row.legacy, row.created_at, row.harness, ...hasBlockIndices ? [row.start_block_index, row.end_block_index] : []);
4722
+ const startMessageId = mapped?.startMessageId ?? mapMessageId(filter, row.start_message_id);
4723
+ const endMessageId = mapped?.endMessageId ?? mapMessageId(filter, row.end_message_id);
4724
+ insertCompartment.run(destinationSessionId, row.sequence, startMessage, endMessage, startMessageId, endMessageId, row.title, row.content, row.p1, row.p2, row.p3, row.p4, row.importance, row.episode_type, row.legacy, row.created_at, row.harness, ...hasBlockIndices ? [row.start_block_index, row.end_block_index] : []);
4711
4725
  copiedCompartments.push({
4712
4726
  sequence: row.sequence,
4713
4727
  startMessage,
4714
4728
  endMessage,
4715
- startMessageId: mapMessageId(filter, row.start_message_id) ?? row.start_message_id,
4716
- endMessageId: mapMessageId(filter, row.end_message_id) ?? row.end_message_id
4729
+ startMessageId: startMessageId ?? row.start_message_id,
4730
+ endMessageId: endMessageId ?? row.end_message_id
4717
4731
  });
4718
4732
  }
4719
4733
  const sourceTags = db.prepare(`SELECT id, message_id, type, status, byte_size, tag_number, harness,
@@ -4791,7 +4805,8 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4791
4805
  if (pendingMarker === null)
4792
4806
  clearedMarker = getPendingPiCompactionMarkerState(db, destinationSessionId);
4793
4807
  const todoAnchor = meta?.todo_synthetic_anchor_message_id ?? "";
4794
- const migrateTodo = todoAnchor.length > 0 && filter.includeMessageId(todoAnchor);
4808
+ const replayFilter = filter.includeReplayMessageId ? { ...filter, includeMessageId: filter.includeReplayMessageId } : filter;
4809
+ const migrateTodo = todoAnchor.length > 0 && replayFilter.includeMessageId(todoAnchor);
4795
4810
  db.prepare(`INSERT INTO session_meta
4796
4811
  (session_id, harness, counter, cleared_reasoning_through_tag,
4797
4812
  tool_reclaim_watermark, pi_stable_id_scheme, stripped_placeholder_ids,
@@ -4816,11 +4831,15 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4816
4831
  todo_synthetic_anchor_message_id = excluded.todo_synthetic_anchor_message_id,
4817
4832
  todo_synthetic_state_json = excluded.todo_synthetic_state_json,
4818
4833
  cached_m0_bytes = NULL,
4819
- cached_m1_bytes = NULL`).run(destinationSessionId, getHarness2(), maxCopiedTag, clampWatermark(meta?.cleared_reasoning_through_tag ?? null, maxCopiedTag), clampWatermark(meta?.tool_reclaim_watermark ?? null, maxCopiedTag), typeof meta?.pi_stable_id_scheme === "number" && Number.isFinite(meta.pi_stable_id_scheme) ? meta.pi_stable_id_scheme : null, filterStrippedPlaceholderBlob(meta?.stripped_placeholder_ids ?? null, filter), filterIdBlob(meta?.stale_reduce_stripped_ids ?? null, filter), filterProcessedImageBlob(meta?.processed_image_stripped_ids ?? null, filter), clonePiContentDecisions(meta?.merged_reasoning_stripped_ids ?? null, filter), pendingMarker, migrateTodo ? meta?.last_todo_state ?? "" : "", migrateTodo ? meta?.todo_synthetic_call_id ?? "" : "", migrateTodo ? mapMessageId(filter, todoAnchor) ?? "" : "", migrateTodo ? meta?.todo_synthetic_state_json ?? "" : "");
4834
+ cached_m1_bytes = NULL`).run(destinationSessionId, getHarness2(), maxCopiedTag, clampWatermark(meta?.cleared_reasoning_through_tag ?? null, maxCopiedTag), clampWatermark(meta?.tool_reclaim_watermark ?? null, maxCopiedTag), typeof meta?.pi_stable_id_scheme === "number" && Number.isFinite(meta.pi_stable_id_scheme) ? meta.pi_stable_id_scheme : null, filterStrippedPlaceholderBlob(meta?.stripped_placeholder_ids ?? null, replayFilter), filterIdBlob(meta?.stale_reduce_stripped_ids ?? null, replayFilter), filterProcessedImageBlob(meta?.processed_image_stripped_ids ?? null, replayFilter), clonePiContentDecisions(meta?.merged_reasoning_stripped_ids ?? null, replayFilter), pendingMarker, migrateTodo ? meta?.last_todo_state ?? "" : "", migrateTodo ? meta?.todo_synthetic_call_id ?? "" : "", migrateTodo ? mapMessageId(filter, todoAnchor) ?? "" : "", migrateTodo ? meta?.todo_synthetic_state_json ?? "" : "");
4835
+ const inheritedGaps = filter.inheritedCoordinateGaps?.() ?? [];
4836
+ if (inheritedGaps.length > 0) {
4837
+ db.prepare("UPDATE session_meta SET coordinate_rebase_notice = ? WHERE session_id = ?").run(JSON.stringify({ generation: "v2", inheritedGaps }), destinationSessionId);
4838
+ }
4820
4839
  const metaColumnRows = db.prepare("PRAGMA table_info(session_meta)").all();
4821
4840
  const metaColumns = new Set(metaColumnRows.map((column) => column.name));
4822
4841
  if (metaColumns.has("trailing_blank_decisions")) {
4823
- const replayDocument = cloneReplayDocument(db, sourceSessionId, copiedToolCallIds, filter);
4842
+ const replayDocument = cloneReplayDocument(db, sourceSessionId, copiedToolCallIds, replayFilter);
4824
4843
  writeReplayDocument(db, destinationSessionId, replayDocument);
4825
4844
  }
4826
4845
  const pendingOpsRow = db.prepare("SELECT COUNT(*) AS count FROM pending_ops WHERE session_id = ?").get(destinationSessionId);
@@ -13,7 +13,7 @@ import {
13
13
  } from "./index-gzy5w8ya.js";
14
14
  import {
15
15
  scheduleAfterBootQuiet
16
- } from "./index-tzy5h4x6.js";
16
+ } from "./index-fpqdbb67.js";
17
17
  import {
18
18
  getHarness2,
19
19
  harnessOwnsOpenCodeStore2
@@ -57,7 +57,7 @@ import {
57
57
  hasPendingMigrations,
58
58
  getMainThreadMigrationBodyCount,
59
59
  runMigrations
60
- } from "./index-xx05vta0.js";
60
+ } from "./index-w2wpx7t5.js";
61
61
  import {
62
62
  installTagIdentityRevisionTrigger,
63
63
  ensureColumn,