@cortexkit/opencode-magic-context 0.49.6 → 0.49.7

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 (153) hide show
  1. package/dist/auto-search-worker.js +10 -7
  2. package/dist/{compaction-marker-candidates-cz72pm1t.js → compaction-marker-candidates-a0edbqrr.js} +2 -2
  3. package/dist/compaction-marker-candidates-worker.js +2 -2
  4. package/dist/{conflict-warning-hook-1jq1rxx7.js → conflict-warning-hook-myk5hbt9.js} +5 -5
  5. package/dist/{context-ae3gxdye.js → context-ffr7e0g7.js} +46 -34
  6. package/dist/{embedding-backfill-dtjmyktb.js → embedding-backfill-re16xncd.js} +6 -6
  7. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  8. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +6 -3
  9. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  10. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +7 -1
  11. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
  12. package/dist/features/magic-context/dreamer/map-memories.d.ts +2 -2
  13. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/primer-seed.d.ts +2 -0
  15. package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/refresh-primers.d.ts +2 -2
  17. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  18. package/dist/features/magic-context/storage-meta-persisted.d.ts +10 -3
  19. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  20. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  21. package/dist/features/magic-context/storage-replay-document.d.ts +4 -0
  22. package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/apply-operations.d.ts +7 -0
  24. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/note-nudger.d.ts +5 -3
  29. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/read-session-chunk.d.ts +7 -0
  32. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/replay-committed-drops.d.ts +9 -0
  34. package/dist/hooks/magic-context/replay-committed-drops.d.ts.map +1 -0
  35. package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts +2 -2
  36. package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/rust-mode-transform.d.ts +3 -0
  38. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/rust-served-raw.d.ts +29 -0
  40. package/dist/hooks/magic-context/rust-served-raw.d.ts.map +1 -0
  41. package/dist/hooks/magic-context/strip-content.d.ts +23 -24
  42. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/tag-messages.d.ts +2 -0
  44. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/tool-drop-target.d.ts +2 -0
  46. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  48. package/dist/{index-6q5h70h2.js → index-0gyq3djm.js} +1 -1
  49. package/dist/{index-vnjhmkwk.js → index-37q80veb.js} +1 -1
  50. package/dist/{index-besxhcsh.js → index-4btknbqh.js} +9 -8
  51. package/dist/{index-vh3e2mvr.js → index-5tbvdff4.js} +59 -28
  52. package/dist/{index-cm4hmxyk.js → index-9yyqq3mm.js} +1 -1
  53. package/dist/{index-ab3bgm2m.js → index-a8acx4gc.js} +2 -2
  54. package/dist/{index-j55vn694.js → index-ax2jhztn.js} +1 -1
  55. package/dist/{index-zgzdm6dg.js → index-ebnngykq.js} +145 -94
  56. package/dist/{index-g9exahnx.js → index-g8qbdb03.js} +1 -1
  57. package/dist/{index-ch08qwgd.js → index-j58gqrn2.js} +65 -65
  58. package/dist/{index-xqyj5c85.js → index-j5hce1ab.js} +2 -2
  59. package/dist/{index-0nnd4bry.js → index-j8epsc0g.js} +34 -13
  60. package/dist/{index-vztbgcdk.js → index-n5a170gs.js} +227 -38
  61. package/dist/{index-s0gsmthp.js → index-n7kwfw2r.js} +4 -4
  62. package/dist/{index-ck6y3td2.js → index-rwmpkss5.js} +3 -3
  63. package/dist/{index-bg5qqene.js → index-rzmjkdd6.js} +1 -1
  64. package/dist/{index-9s58tq95.js → index-sf94at64.js} +3 -3
  65. package/dist/{index-f3dnvnw6.js → index-sh91t19a.js} +1 -1
  66. package/dist/{index-mj1fgfrk.js → index-tagss15p.js} +857 -125
  67. package/dist/{index-1j8jcjpa.js → index-tmtty2x5.js} +1 -1
  68. package/dist/{index-hr64sth2.js → index-vt4sf4ep.js} +1 -1
  69. package/dist/{index-9m7bn21d.js → index-w4mw92w3.js} +1 -1
  70. package/dist/{index-7q1m1qjk.js → index-w6bd03dc.js} +1 -1
  71. package/dist/{index-a796ct3s.js → index-w6vr754t.js} +4 -4
  72. package/dist/{index-1xaw2pq8.js → index-wq16ahsn.js} +5 -5
  73. package/dist/index.js +36 -36
  74. package/dist/{message-index-bounded-630j53ps.js → message-index-bounded-04rycpx4.js} +9 -9
  75. package/dist/{message-index-c84wm2g0.js → message-index-rqtse28y.js} +9 -9
  76. package/dist/{message-time-backfill-8kj57qe3.js → message-time-backfill-a5ytnp53.js} +1 -1
  77. package/dist/migration-worker.js +6 -6
  78. package/dist/plugin/messages-transform.d.ts.map +1 -1
  79. package/dist/{project-embedding-registry-vv59t7ah.js → project-embedding-registry-k0sd9k7v.js} +5 -5
  80. package/dist/raw-ordinal-warmup-worker.js +17 -15
  81. package/dist/{read-session-chunk-t3vjd0h0.js → read-session-chunk-h1btx938.js} +7 -5
  82. package/dist/{read-session-raw-gf7eytnm.js → read-session-raw-vdf4wh78.js} +2 -2
  83. package/dist/{recomp-orchestrator-1d08g57a.js → recomp-orchestrator-trcgmm23.js} +20 -20
  84. package/dist/{search-kth2p6cc.js → search-3rbdx6hw.js} +16 -16
  85. package/dist/{send-session-notification-3j6krd4w.js → send-session-notification-2tp44tfa.js} +4 -4
  86. package/dist/shared/processed-image-eligibility.d.ts +22 -0
  87. package/dist/shared/processed-image-eligibility.d.ts.map +1 -0
  88. package/dist/shared/recovery-reasoning-prefix.d.ts +9 -0
  89. package/dist/shared/recovery-reasoning-prefix.d.ts.map +1 -0
  90. package/dist/shared/sqlite.d.ts +1 -1
  91. package/dist/shared/sqlite.d.ts.map +1 -1
  92. package/dist/shared/tag-transcript.d.ts +9 -0
  93. package/dist/shared/tag-transcript.d.ts.map +1 -1
  94. package/dist/{sqlite-d7edbk1s.js → sqlite-j3tvg8r0.js} +1 -1
  95. package/dist/{storage-memory-af5zdz98.js → storage-memory-8168bgef.js} +2 -2
  96. package/dist/{storage-tags-dyj7mmbq.js → storage-tags-61z5j2f9.js} +2 -2
  97. package/dist/tools/ctx-expand/search-archive.d.ts +4 -0
  98. package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -0
  99. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  100. package/dist/{transform-postprocess-phase-bv3kb5s1.js → transform-postprocess-phase-7qts7h54.js} +20 -20
  101. package/dist/v2/auto-search-worker.js +10 -7
  102. package/dist/v2/{compaction-marker-candidates-6gqp5wrc.js → compaction-marker-candidates-6nypjkpf.js} +2 -2
  103. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  104. package/dist/v2/{context-p8f2shp1.js → context-xq4rtywr.js} +1019 -233
  105. package/dist/v2/{embedding-backfill-cg4rv90f.js → embedding-backfill-xd9ygzgd.js} +6 -6
  106. package/dist/v2/hooks/payload.d.ts.map +1 -1
  107. package/dist/v2/{message-index-3ws17x1g.js → message-index-8e5z2xx8.js} +9 -9
  108. package/dist/v2/{message-index-bounded-yzxmf6vp.js → message-index-bounded-5vh1h2g7.js} +9 -9
  109. package/dist/v2/{message-time-backfill-5nf10c65.js → message-time-backfill-2z365239.js} +1 -1
  110. package/dist/v2/migration-worker.js +6 -6
  111. package/dist/v2/{project-embedding-registry-rsnf2263.js → project-embedding-registry-b77awytr.js} +5 -5
  112. package/dist/v2/raw-ordinal-warmup-worker.js +17 -15
  113. package/dist/v2/{read-session-chunk-vtb0w2kd.js → read-session-chunk-4sat83cx.js} +7 -5
  114. package/dist/v2/{read-session-raw-gpcddemt.js → read-session-raw-a3hw9jsp.js} +2 -2
  115. package/dist/v2/{recomp-orchestrator-v64r4s4r.js → recomp-orchestrator-n11zv1f1.js} +19 -19
  116. package/dist/v2/{search-bpa4fxq1.js → search-mvgqtkkz.js} +16 -16
  117. package/dist/v2/{send-session-notification-5aj2j7vf.js → send-session-notification-ppgc8qdz.js} +4 -4
  118. package/dist/v2/{server-wrem2nmz.js → server-1rfgbjfn.js} +1 -1
  119. package/dist/v2/{server-qn23p4h7.js → server-7srtwsa4.js} +5 -5
  120. package/dist/v2/{server-cm4hmxyk.js → server-9yyqq3mm.js} +1 -1
  121. package/dist/v2/{server-yezz0cp2.js → server-brhj8qtd.js} +1 -1
  122. package/dist/v2/{server-387vkhjq.js → server-dd0nja67.js} +1 -1
  123. package/dist/v2/{server-keswwkvv.js → server-fpqe39as.js} +1 -1
  124. package/dist/v2/{server-158ehmk2.js → server-fw31krgq.js} +3 -3
  125. package/dist/v2/{server-fby0cxbq.js → server-gtv9wbhq.js} +227 -38
  126. package/dist/v2/{server-ww9nr8pe.js → server-hcvcxzx7.js} +2 -2
  127. package/dist/v2/{server-0nnd4bry.js → server-j8epsc0g.js} +34 -13
  128. package/dist/v2/{server-x2r63c0x.js → server-jdwd03ep.js} +4 -4
  129. package/dist/v2/{server-btgnsv7w.js → server-kdrezdy0.js} +1 -1
  130. package/dist/v2/{server-7skbfb81.js → server-mv1w7t6z.js} +61 -30
  131. package/dist/v2/{server-aa9w15cs.js → server-nfan6zb6.js} +65 -65
  132. package/dist/v2/{server-9zqewm6g.js → server-qcw43339.js} +1 -1
  133. package/dist/v2/{server-f9py7s7a.js → server-sy4b1sra.js} +1 -1
  134. package/dist/v2/{server-09g9pkvx.js → server-v4fwha43.js} +9 -8
  135. package/dist/v2/{server-yd01snxq.js → server-w3zeywp1.js} +1 -1
  136. package/dist/v2/{server-4tn95znb.js → server-wkdgjjch.js} +1 -1
  137. package/dist/v2/{server-6a9mxnb2.js → server-x08d1xf3.js} +1 -1
  138. package/dist/v2/server.js +4 -4
  139. package/dist/v2/{sqlite-d7edbk1s.js → sqlite-j3tvg8r0.js} +1 -1
  140. package/dist/v2/{storage-memory-af5zdz98.js → storage-memory-8168bgef.js} +2 -2
  141. package/dist/v2/{storage-tags-d47bpaqa.js → storage-tags-j2fzq3sw.js} +2 -2
  142. package/dist/v2/{wrapup-orchestrator-cahk37n7.js → wrapup-orchestrator-s92ebfzv.js} +19 -19
  143. package/dist/{wrapup-orchestrator-mqp0v195.js → wrapup-orchestrator-df61jmz9.js} +21 -21
  144. package/package.json +3 -3
  145. package/src/shared/processed-image-eligibility.test.ts +68 -0
  146. package/src/shared/processed-image-eligibility.ts +41 -0
  147. package/src/shared/processed-image-position-review.json +20 -0
  148. package/src/shared/processed-image-position-review.test.ts +19 -0
  149. package/src/shared/recovery-reasoning-prefix.test.ts +34 -0
  150. package/src/shared/recovery-reasoning-prefix.ts +35 -0
  151. package/src/shared/sqlite-writer-diagnostics.test.ts +31 -0
  152. package/src/shared/sqlite.ts +63 -22
  153. package/src/shared/tag-transcript.ts +118 -0
@@ -41,10 +41,10 @@ import {
41
41
  withSqliteBackgroundWriter2,
42
42
  withoutSqliteTransformPass2,
43
43
  beginSqliteWriterAsync2
44
- } from "./server-0nnd4bry.js";
44
+ } from "./server-j8epsc0g.js";
45
45
  import {
46
46
  sameProjectDirectory
47
- } from "./server-yezz0cp2.js";
47
+ } from "./server-brhj8qtd.js";
48
48
  import {
49
49
  buildCanonicalChunkTextFromFts,
50
50
  buildCompartmentSummaryFallbackText,
@@ -54,10 +54,10 @@ import {
54
54
  replaceCompartmentChunkEmbeddings,
55
55
  deleteChunkEmbedBackoffForSession,
56
56
  chunkWindowSourceKey
57
- } from "./server-keswwkvv.js";
57
+ } from "./server-fpqe39as.js";
58
58
  import {
59
59
  isPidAlive
60
- } from "./server-wrem2nmz.js";
60
+ } from "./server-1rfgbjfn.js";
61
61
  import {
62
62
  BoundedSessionMap,
63
63
  clearCompressionDepth,
@@ -72,7 +72,7 @@ import {
72
72
  toMessageIndexSource2,
73
73
  clearIndexedMessagesInTransaction2,
74
74
  indexSourcesAfterOrdinal2
75
- } from "./server-qn23p4h7.js";
75
+ } from "./server-7srtwsa4.js";
76
76
  import {
77
77
  detectOverflow,
78
78
  SESSION_META_SELECT_COLUMNS,
@@ -138,9 +138,13 @@ import {
138
138
  THINKING_BINDING_STRIP_ORDER_END_MARKER,
139
139
  getMergedReasoningStrippedIds,
140
140
  addMergedReasoningStrippedIds,
141
+ parseProcessedImageMarkers,
142
+ serializeProcessedImageMarkers,
141
143
  getPendingCompactionMarkerState,
142
144
  setPendingCompactionMarkerState,
143
145
  clearPendingCompactionMarkerStateIf,
146
+ getPendingPiCompactionMarkerState,
147
+ logPiCompactionMarkerClear,
144
148
  resolveHostServedBoundaryId2,
145
149
  hasRawMessageProvider2,
146
150
  withRawSessionMessageCache2,
@@ -157,7 +161,7 @@ import {
157
161
  getRawSessionTagKeysThrough2,
158
162
  getLegacyProtectedTailStartOrdinal2,
159
163
  readSessionChunk2
160
- } from "./server-fby0cxbq.js";
164
+ } from "./server-gtv9wbhq.js";
161
165
  import {
162
166
  getTableColumnNames
163
167
  } from "./server-6byqfbqf.js";
@@ -167,7 +171,7 @@ import {
167
171
  LATEST_SUPPORTED_VERSION,
168
172
  getPersistedSchemaVersion,
169
173
  openDatabase
170
- } from "./server-09g9pkvx.js";
174
+ } from "./server-v4fwha43.js";
171
175
  import {
172
176
  providerMass,
173
177
  calibrationForModelKey,
@@ -185,11 +189,11 @@ import {
185
189
  foldShrunkPartTags2,
186
190
  getTagNumberByMessageId2,
187
191
  getActiveTagsBySession2
188
- } from "./server-yd01snxq.js";
192
+ } from "./server-w3zeywp1.js";
189
193
  import {
190
194
  isStrictGapHealingMessage2,
191
195
  noteRawSessionSummaryRowWritten2
192
- } from "./server-387vkhjq.js";
196
+ } from "./server-dd0nja67.js";
193
197
  import {
194
198
  resolveOpenCodeDbPath,
195
199
  assertOpenCodeStoreGeneration,
@@ -199,7 +203,7 @@ import {
199
203
  import {
200
204
  withReadOnlySessionDb,
201
205
  getMessageTimesFromOpenCodeDb
202
- } from "./server-4tn95znb.js";
206
+ } from "./server-wkdgjjch.js";
203
207
  import {
204
208
  getMeasuredToolDefinitionTokens
205
209
  } from "./server-7ekna9zs.js";
@@ -218,11 +222,11 @@ import {
218
222
  resolveStoredPathWorkspaceIdentity,
219
223
  sourceNameForMemory,
220
224
  computeWorkspaceEpochFingerprint
221
- } from "./server-ww9nr8pe.js";
225
+ } from "./server-hcvcxzx7.js";
222
226
  import {
223
227
  shouldSkipHomeProjectMemory,
224
228
  resolveProjectIdentity
225
- } from "./server-btgnsv7w.js";
229
+ } from "./server-kdrezdy0.js";
226
230
  import {
227
231
  drainBackgroundBatches,
228
232
  contentSha2562,
@@ -230,7 +234,7 @@ import {
230
234
  getProjectChunkEmbeddingModelId2,
231
235
  getProjectEmbeddingMaxInputTokens2,
232
236
  embedItemsForProject2
233
- } from "./server-158ehmk2.js";
237
+ } from "./server-fw31krgq.js";
234
238
  import {
235
239
  getSessionNotes,
236
240
  getReadySmartNotes,
@@ -239,13 +243,13 @@ import {
239
243
  userFacingFailureCode,
240
244
  promoteSessionFactsDurable,
241
245
  embedPromotedFacts
242
- } from "./server-x2r63c0x.js";
246
+ } from "./server-jdwd03ep.js";
243
247
  import {
244
248
  isMarkerCandidateBasisCurrent2,
245
249
  invalidateMarkerCandidateBasis2,
246
250
  readMarkerCandidateBasis2,
247
251
  prepareMarkerCandidateBasis2
248
- } from "./server-6a9mxnb2.js";
252
+ } from "./server-x08d1xf3.js";
249
253
  import {
250
254
  computeCueContentHash,
251
255
  getMuralCueState,
@@ -253,7 +257,7 @@ import {
253
257
  getMemoriesByProject2,
254
258
  getMemoriesByProjects2,
255
259
  getMaxMemoryIdForProjects2
256
- } from "./server-cm4hmxyk.js";
260
+ } from "./server-9yyqq3mm.js";
257
261
  import {
258
262
  pushNotification2
259
263
  } from "./server-x8a7jmkh.js";
@@ -264,7 +268,7 @@ import {
264
268
  } from "./server-t528t8qm.js";
265
269
  import {
266
270
  sendStatusNotification2
267
- } from "./server-9zqewm6g.js";
271
+ } from "./server-qcw43339.js";
268
272
  import {
269
273
  getErrorMessage,
270
274
  describeError
@@ -1882,13 +1886,17 @@ async function retryPendingRustSessionCleanupsForProject(db, projectPath, delete
1882
1886
  function clearSession(db, sessionId, rustModuleCleanupAcknowledged = false, permanentlyDeleted = false) {
1883
1887
  cancelAutoSearchWork(sessionId);
1884
1888
  let transactionStartedAt = 0;
1889
+ let clearedMarker = null;
1885
1890
  withoutSqliteTransformPass2(() => withSqliteBackgroundWriter2(() => db.transaction(() => {
1886
1891
  transactionStartedAt = performance.now();
1892
+ clearedMarker = getPendingPiCompactionMarkerState(db, sessionId);
1887
1893
  deleteSessionScopedRows(db, [sessionId], undefined, {
1888
1894
  rustModuleCleanupAcknowledged,
1889
1895
  preserveTagRevisionTombstones: !permanentlyDeleted
1890
1896
  });
1891
1897
  }).immediate()));
1898
+ if (clearedMarker)
1899
+ logPiCompactionMarkerClear(sessionId, clearedMarker, "session-reset");
1892
1900
  clearUnpublishedAutoSearchNoHints(sessionId);
1893
1901
  logSlowWriteTransaction("clear-session", transactionStartedAt);
1894
1902
  }
@@ -2278,6 +2286,9 @@ function persistLkgSlot(db, sessionId, slot, publishMetadata) {
2278
2286
  }
2279
2287
  const layout = layoutLkgPrefix(slot.jsonPrefix);
2280
2288
  try {
2289
+ const inputIdSeq = JSON.stringify(slot.piOutputEntryIds ? { version: 1, inputIds: slot.inputIdSeq, piOutputEntryIds: slot.piOutputEntryIds } : slot.inputIdSeq);
2290
+ const inputContentDigests = JSON.stringify(slot.inputContentDigests);
2291
+ const inputContentSignatures = slot.inputContentSignatures ? JSON.stringify(slot.inputContentSignatures) : null;
2281
2292
  db.transaction(() => {
2282
2293
  const storedHashes = new Map;
2283
2294
  for (const row of db.prepare("SELECT chunk, hash FROM lkg_slot_chunks WHERE session_id = ?").all(sessionId)) {
@@ -2309,11 +2320,7 @@ function persistLkgSlot(db, sessionId, slot, publishMetadata) {
2309
2320
  provider_key = excluded.provider_key,
2310
2321
  captured_at = excluded.captured_at,
2311
2322
  row_version = excluded.row_version,
2312
- capture_sequence = excluded.capture_sequence`).run(sessionId, layout.chars, layout.chunks.length, layout.hash, JSON.stringify(slot.piOutputEntryIds ? {
2313
- version: 1,
2314
- inputIds: slot.inputIdSeq,
2315
- piOutputEntryIds: slot.piOutputEntryIds
2316
- } : slot.inputIdSeq), JSON.stringify(slot.inputContentDigests), slot.inputContentSignatures ? JSON.stringify(slot.inputContentSignatures) : null, slot.lastInputMessageId, slot.modelKey, slot.providerKey, slot.capturedAt, slot.rowVersion ?? null, slot.captureSequence ?? null);
2323
+ capture_sequence = excluded.capture_sequence`).run(sessionId, layout.chars, layout.chunks.length, layout.hash, inputIdSeq, inputContentDigests, inputContentSignatures, slot.lastInputMessageId, slot.modelKey, slot.providerKey, slot.capturedAt, slot.rowVersion ?? null, slot.captureSequence ?? null);
2317
2324
  publishMetadata?.();
2318
2325
  }).immediate();
2319
2326
  rememberFingerprint(db, sessionId, fingerprint);
@@ -4227,6 +4234,9 @@ function filterIdBlob(raw, filter) {
4227
4234
  return "";
4228
4235
  }
4229
4236
  }
4237
+ function filterProcessedImageBlob(raw, filter) {
4238
+ return serializeProcessedImageMarkers(new Map([...parseProcessedImageMarkers(raw)].filter(([id]) => filter.includeMessageId(id)).map(([id, marker]) => [mapMessageId(filter, id) ?? id, marker])));
4239
+ }
4230
4240
  function filterStrippedPlaceholderBlob(raw, filter) {
4231
4241
  const state = parseStrippedPlaceholderState(raw);
4232
4242
  const keep = (ids) => ids.filter((id) => filter.includeMessageId(id)).map((id) => mapMessageId(filter, id) ?? id);
@@ -4308,7 +4318,8 @@ function clampWatermark(value, maxCopiedTag) {
4308
4318
  return Math.min(Math.floor(value), maxCopiedTag);
4309
4319
  }
4310
4320
  function copySessionStateForClone(db, sourceSessionId, destinationSessionId, filter) {
4311
- return runImmediate(db, () => {
4321
+ let clearedMarker = null;
4322
+ const result = runImmediate(db, () => {
4312
4323
  const hasTemporalDecisions = tableExists(db, "temporal_decisions");
4313
4324
  if (filter.requireEmptyDestinationMeta === true && countRows(db, "session_meta", destinationSessionId) > 0 || countRows(db, "compartments", destinationSessionId) > 0 || countRows(db, "tags", destinationSessionId) > 0 || hasTemporalDecisions && countRows(db, "temporal_decisions", destinationSessionId) > 0 || filter.copySessionNotesAndFacts === true && (tableExists(db, "notes") && countRows(db, "notes", destinationSessionId) > 0 || tableExists(db, "session_facts") && countRows(db, "session_facts", destinationSessionId) > 0)) {
4314
4325
  return {
@@ -4420,6 +4431,8 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4420
4431
  FROM session_meta WHERE session_id = ?`).get(sourceSessionId);
4421
4432
  const maxCopiedTag = copiedTagNumbers.reduce((max, value) => Math.max(max, value), 0);
4422
4433
  const pendingMarker = filter.selectPendingPiMarker(meta?.pending_pi_compaction_marker_state ?? null, copiedCompartments);
4434
+ if (pendingMarker === null)
4435
+ clearedMarker = getPendingPiCompactionMarkerState(db, destinationSessionId);
4423
4436
  const todoAnchor = meta?.todo_synthetic_anchor_message_id ?? "";
4424
4437
  const migrateTodo = todoAnchor.length > 0 && filter.includeMessageId(todoAnchor);
4425
4438
  db.prepare(`INSERT INTO session_meta
@@ -4446,7 +4459,7 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4446
4459
  todo_synthetic_anchor_message_id = excluded.todo_synthetic_anchor_message_id,
4447
4460
  todo_synthetic_state_json = excluded.todo_synthetic_state_json,
4448
4461
  cached_m0_bytes = NULL,
4449
- 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), filterIdBlob(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 ?? "" : "");
4462
+ 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 ?? "" : "");
4450
4463
  const metaColumnRows = db.prepare("PRAGMA table_info(session_meta)").all();
4451
4464
  const metaColumns = new Set(metaColumnRows.map((column) => column.name));
4452
4465
  if (metaColumns.has("trailing_blank_decisions")) {
@@ -4464,6 +4477,9 @@ function copySessionStateForClone(db, sourceSessionId, destinationSessionId, fil
4464
4477
  pendingMarkerMigrated: pendingMarker !== null
4465
4478
  };
4466
4479
  });
4480
+ if (clearedMarker)
4481
+ logPiCompactionMarkerClear(destinationSessionId, clearedMarker, "clone-replaced");
4482
+ return result;
4467
4483
  }
4468
4484
  // src/features/magic-context/historian-failure-reason.ts
4469
4485
  var MAX_HISTORIAN_FAILURE_REASON_LENGTH = 512;
@@ -5507,7 +5523,7 @@ class HiddenCompletionRefusal extends Error {
5507
5523
 
5508
5524
  // src/features/magic-context/compaction-marker.ts
5509
5525
  import { createHash as createHash7 } from "node:crypto";
5510
- import { existsSync } from "node:fs";
5526
+ import { existsSync, statSync as statSync4 } from "node:fs";
5511
5527
  var BASE62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
5512
5528
  var ID_PREFIX_HEX_LENGTH = 12;
5513
5529
  var ID_SUFFIX_LENGTH = 14;
@@ -5545,6 +5561,7 @@ function runMarkerRemovalTransaction(db, operation) {
5545
5561
  function runMarkerWriteTransaction(db, site, operation) {
5546
5562
  if (db.inTransaction)
5547
5563
  return db.transaction(operation).immediate();
5564
+ const walBefore = markerWalPages(db);
5548
5565
  const startedAt = performance.now();
5549
5566
  let acquiredAt;
5550
5567
  let workFinishedAt;
@@ -5568,9 +5585,22 @@ function runMarkerWriteTransaction(db, site, operation) {
5568
5585
  const endMs = workFinishedAt === undefined ? 0 : finishedAt - workFinishedAt;
5569
5586
  try {
5570
5587
  log2(`[magic-context] sqlite writer site=${site} db=opencode acquire_ms=${Math.round(acquireMs)} hold_ms=${Math.round(holdMs)} work_ms=${Math.round(workMs)} end_ms=${Math.round(endMs)} outcome=${acquiredAt === undefined ? "not_acquired" : committed ? "committed" : "failed"}`);
5588
+ if (finishedAt - startedAt > 100) {
5589
+ const autoCheckpoint = db.prepare("PRAGMA wal_autocheckpoint").get();
5590
+ log2(`[magic-context] compaction-marker slow writer site=${site} acquire_ms=${acquireMs.toFixed(1)} statements_ms=${workMs.toFixed(1)} ${committed ? "commit" : "rollback"}_ms=${endMs.toFixed(1)} wal_autocheckpoint=${autoCheckpoint.wal_autocheckpoint} wal_pages_before=${walBefore ?? "unknown"} wal_pages_after=${markerWalPages(db) ?? "unknown"}`);
5591
+ }
5571
5592
  } catch {}
5572
5593
  }
5573
5594
  }
5595
+ function markerWalPages(db) {
5596
+ try {
5597
+ const row = db.prepare("PRAGMA page_size").get();
5598
+ const bytes = statSync4(`${getOpenCodeDbPath()}-wal`).size;
5599
+ return Math.max(0, Math.floor((bytes - 32) / (row.page_size + 24)));
5600
+ } catch {
5601
+ return null;
5602
+ }
5603
+ }
5574
5604
  var REQUIRED_MESSAGE_COLUMNS = ["id", "session_id", "time_created", "time_updated", "data"];
5575
5605
  var REQUIRED_PART_COLUMNS = [
5576
5606
  "id",
@@ -5631,6 +5661,7 @@ function getWritableOpenCodeDb(purpose = "publication") {
5631
5661
  const timeoutMs = purpose === "removal" ? MARKER_REMOVAL_BUSY_TIMEOUT_MS : MARKER_BUSY_TIMEOUT_MS;
5632
5662
  db.exec(`PRAGMA busy_timeout=${timeoutMs}`);
5633
5663
  db.exec("PRAGMA journal_mode=WAL");
5664
+ db.exec("PRAGMA wal_autocheckpoint=0");
5634
5665
  if (purpose === "removal")
5635
5666
  cachedRemovalDb = { path: dbPath, db };
5636
5667
  else
@@ -7837,7 +7868,7 @@ async function promptAsyncAndWaitForIdle(client, request, options = {}) {
7837
7868
  }
7838
7869
  }
7839
7870
  // src/shared/prompt-surface-runtime.ts
7840
- import { existsSync as existsSync2, readFileSync as readFileSync3, statSync as statSync4 } from "node:fs";
7871
+ import { existsSync as existsSync2, readFileSync as readFileSync3, statSync as statSync5 } from "node:fs";
7841
7872
  import { dirname, isAbsolute, resolve as resolve2 } from "node:path";
7842
7873
 
7843
7874
  // src/tools/light-descriptions.ts
@@ -7901,7 +7932,7 @@ function createPromptSurfaceRuntime(options) {
7901
7932
  const path = isAbsolute(configuredPath) ? configuredPath : resolve2(userConfigDirectory, configuredPath);
7902
7933
  let content;
7903
7934
  try {
7904
- if (!statSync4(path).isFile()) {
7935
+ if (!statSync5(path).isFile()) {
7905
7936
  warnOnce(`guidance-not-file:${path}`, `prompt_surface.guidance_override_path (${path}) is not a file; using built-in guidance.`);
7906
7937
  return;
7907
7938
  }
@@ -16071,7 +16102,7 @@ function observeNoteNudgeServe(args) {
16071
16102
  sessions.set(args.sessionId, seen);
16072
16103
  return {
16073
16104
  isFirstServe: warm && args.isLiveTail && firstServe,
16074
- isCacheBustingPass: args.anchorMessageId !== null && args.isCacheBustingPass
16105
+ prefixRewriteCoversAnchor: args.anchorMessageId !== null && args.prefixRewriteCoversAnchor
16075
16106
  };
16076
16107
  }
16077
16108
  var NOTE_NUDGE_COOLDOWN_MS = 15 * 60 * 1000;
@@ -16110,7 +16141,7 @@ function peekNoteNudgeText(db, sessionId, currentUserMessageId, projectIdentity,
16110
16141
  const state = getPersistedNoteNudge(db, sessionId);
16111
16142
  if (!state.triggerPending)
16112
16143
  return null;
16113
- if (eligibility && !eligibility.isFirstServe && !eligibility.isCacheBustingPass) {
16144
+ if (eligibility && !eligibility.isFirstServe && !eligibility.prefixRewriteCoversAnchor) {
16114
16145
  sessionLog2(sessionId, "note-nudge: deferring — user already served or first serve unproven");
16115
16146
  return null;
16116
16147
  }
@@ -18798,4 +18829,4 @@ ${failure}`;
18798
18829
  }
18799
18830
  }
18800
18831
 
18801
- export { historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, embedPauseBySession, embedRunStateBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, readCoordinateGeneration, rebaseSessionCoordinatesAsync, HiddenCompletionRefusal, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, getCompartmentEvents, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, recordChildInvocation, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, teardownChildSession, runTokenLog, formatRunTokenLog, createChildSessionWithFence, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, isRecompFailure2, isRecompSkip2, extractRecompReason2, setRecompStarting2, setRecompNote2, setRecompTerminal2, buildRecompDeps2, runManagedRecomp2 };
18832
+ export { historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, embedPauseBySession, embedRunStateBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, readCoordinateGeneration, rebaseSessionCoordinatesAsync, HiddenCompletionRefusal, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, getCompartmentEvents, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, recordChildInvocation, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, teardownChildSession, runTokenLog, formatRunTokenLog, createChildSessionWithFence, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, isRecompFailure2, isRecompSkip2, extractRecompReason2, setRecompStarting2, setRecompNote2, setRecompTerminal2, buildRecompDeps2, runManagedRecomp2 };
@@ -17,7 +17,7 @@ import {
17
17
  import {
18
18
  buildCanonicalChunkTextFromFts,
19
19
  loadCompartmentChunkEmbeddingsForSearch
20
- } from "./server-keswwkvv.js";
20
+ } from "./server-fpqe39as.js";
21
21
  import {
22
22
  recordEmbeddingMeasurement,
23
23
  saveCommitEmbedding,
@@ -34,7 +34,7 @@ import {
34
34
  enqueueShadowEmbeddingItems2,
35
35
  getProjectEmbeddingSnapshot2,
36
36
  embedItemsForProject2
37
- } from "./server-158ehmk2.js";
37
+ } from "./server-fw31krgq.js";
38
38
  import {
39
39
  getProjectEmbeddings2
40
40
  } from "./server-4dhv7mqz.js";
@@ -43,13 +43,13 @@ import {
43
43
  isEmbeddingEnabled,
44
44
  embedText,
45
45
  ensureMemoryEmbeddings2
46
- } from "./server-f9py7s7a.js";
46
+ } from "./server-sy4b1sra.js";
47
47
  import {
48
48
  ModuleMemoryAuthorityError2,
49
49
  getMemoriesByProject2,
50
50
  getMemoriesByProjects2,
51
51
  updateMemoryRetrievalCount2
52
- } from "./server-cm4hmxyk.js";
52
+ } from "./server-9yyqq3mm.js";
53
53
  import {
54
54
  getNotes,
55
55
  getActivePrimers,
@@ -58,20 +58,20 @@ import {
58
58
  sanitizeFtsQuery,
59
59
  searchMemoriesFTS,
60
60
  searchMemoriesFTSUnion
61
- } from "./server-x2r63c0x.js";
61
+ } from "./server-jdwd03ep.js";
62
62
  import {
63
63
  isRecord
64
- } from "./server-yd01snxq.js";
64
+ } from "./server-w3zeywp1.js";
65
65
  import {
66
66
  getIndexedMessageCorpusSize2
67
- } from "./server-qn23p4h7.js";
67
+ } from "./server-7srtwsa4.js";
68
68
  import {
69
69
  resolveWorkspaceShareCategories,
70
70
  resolveWorkspaceIdentitySet,
71
71
  expandWorkspaceIdentitySetWithAliases,
72
72
  resolveStoredPathWorkspaceIdentity,
73
73
  sourceNameForMemory
74
- } from "./server-ww9nr8pe.js";
74
+ } from "./server-hcvcxzx7.js";
75
75
  import {
76
76
  isKnownAutocommit
77
77
  } from "./server-8ajstryz.js";
@@ -1255,6 +1255,61 @@ function searchGitCommitsSync(db, projectPath, query, options) {
1255
1255
  });
1256
1256
  return results.slice(0, options.limit);
1257
1257
  }
1258
+ // src/features/magic-context/message-fts-session-filter.ts
1259
+ var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
1260
+ SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
1261
+ ) AND `;
1262
+ var coverageCaches = new WeakMap;
1263
+ function getCoverageCache(db) {
1264
+ let cache = coverageCaches.get(db);
1265
+ if (!cache) {
1266
+ cache = {
1267
+ pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
1268
+ stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
1269
+ missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
1270
+ FROM message_history_fts WHERE rowid IN (
1271
+ SELECT id FROM message_history_fts_docsize
1272
+ EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
1273
+ )`)
1274
+ };
1275
+ coverageCaches.set(db, cache);
1276
+ }
1277
+ return cache;
1278
+ }
1279
+ function withMessageFtsSessionFilter(db, sessionId, read) {
1280
+ let cacheable = false;
1281
+ try {
1282
+ const transaction = db;
1283
+ cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
1284
+ if (!cacheable)
1285
+ coverageCaches.delete(db);
1286
+ } catch {
1287
+ coverageCaches.delete(db);
1288
+ }
1289
+ return db.transaction(() => {
1290
+ let sessionFirst = false;
1291
+ try {
1292
+ const cache = getCoverageCache(db);
1293
+ cache.pin.get();
1294
+ const stamp = cache.stamp.get();
1295
+ let incomplete = cache.incompleteSessions;
1296
+ if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
1297
+ const rows = cache.missing.all();
1298
+ incomplete = new Set(rows.map((row) => row.sessionId));
1299
+ if (cacheable) {
1300
+ cache.version = stamp.version;
1301
+ cache.changes = stamp.changes;
1302
+ cache.incompleteSessions = incomplete;
1303
+ }
1304
+ }
1305
+ sessionFirst = !incomplete.has(sessionId);
1306
+ } catch {
1307
+ coverageCaches.delete(db);
1308
+ }
1309
+ return read(sessionFirst);
1310
+ }).deferred();
1311
+ }
1312
+
1258
1313
  // src/features/magic-context/literal-probes.ts
1259
1314
  var MAX_PROBES = 5;
1260
1315
  var MIN_PROBE_LENGTH = 3;
@@ -1311,61 +1366,6 @@ function containsProbeVerbatim(text, probes) {
1311
1366
  return probes.some((probe) => haystack.includes(probe.toLowerCase()));
1312
1367
  }
1313
1368
 
1314
- // src/features/magic-context/message-fts-session-filter.ts
1315
- var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
1316
- SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
1317
- ) AND `;
1318
- var coverageCaches = new WeakMap;
1319
- function getCoverageCache(db) {
1320
- let cache = coverageCaches.get(db);
1321
- if (!cache) {
1322
- cache = {
1323
- pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
1324
- stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
1325
- missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
1326
- FROM message_history_fts WHERE rowid IN (
1327
- SELECT id FROM message_history_fts_docsize
1328
- EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
1329
- )`)
1330
- };
1331
- coverageCaches.set(db, cache);
1332
- }
1333
- return cache;
1334
- }
1335
- function withMessageFtsSessionFilter(db, sessionId, read) {
1336
- let cacheable = false;
1337
- try {
1338
- const transaction = db;
1339
- cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
1340
- if (!cacheable)
1341
- coverageCaches.delete(db);
1342
- } catch {
1343
- coverageCaches.delete(db);
1344
- }
1345
- return db.transaction(() => {
1346
- let sessionFirst = false;
1347
- try {
1348
- const cache = getCoverageCache(db);
1349
- cache.pin.get();
1350
- const stamp = cache.stamp.get();
1351
- let incomplete = cache.incompleteSessions;
1352
- if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
1353
- const rows = cache.missing.all();
1354
- incomplete = new Set(rows.map((row) => row.sessionId));
1355
- if (cacheable) {
1356
- cache.version = stamp.version;
1357
- cache.changes = stamp.changes;
1358
- cache.incompleteSessions = incomplete;
1359
- }
1360
- }
1361
- sessionFirst = !incomplete.has(sessionId);
1362
- } catch {
1363
- coverageCaches.delete(db);
1364
- }
1365
- return read(sessionFirst);
1366
- }).deferred();
1367
- }
1368
-
1369
1369
  // src/features/magic-context/search-measurement.ts
1370
1370
  import { createHash as createHash2 } from "node:crypto";
1371
1371
  function resultId(result) {
@@ -3240,7 +3240,7 @@ ${diagnosticLines.join(`
3240
3240
  bodyParts.push(diagnosticLines.join(`
3241
3241
  `));
3242
3242
  if (results.some((result) => result.source === "message" || result.source === "compartment")) {
3243
- bodyParts.push("Use ctx_expand(start, end) with the range from any message result above to read the full conversation context.");
3243
+ bodyParts.push("Use ctx_expand(start, end) with the range from any message result above to read the conversation context. If the host no longer holds those messages, ctx_expand returns indexed text from the search archive only, with no surrounding messages or tool output.");
3244
3244
  }
3245
3245
  if (results.some((result) => result.source === "note" && result.anchorOrdinal !== null && result.sourceSessionId === currentSessionId)) {
3246
3246
  bodyParts.push(SEARCH_NOTE_EXPAND_HINT);
@@ -3252,4 +3252,4 @@ ${bodyParts.join(`
3252
3252
  `)}`;
3253
3253
  }
3254
3254
 
3255
- export { renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, singleStoreMigrationRequiredFailure, projectNeedsSingleStoreMigration, STORE_AHEAD_OF_BINARY_CODE, storeAheadOfBinaryFailure, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS, transformColdStartExecuteTimeoutMs, getDefaultSubcConnectionFile, isModuleTransportGenerationChangedResult, SubcModuleTransport, indexCommitsForProject, embedUnembeddedCommits, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
3255
+ export { renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, singleStoreMigrationRequiredFailure, projectNeedsSingleStoreMigration, STORE_AHEAD_OF_BINARY_CODE, storeAheadOfBinaryFailure, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS, transformColdStartExecuteTimeoutMs, getDefaultSubcConnectionFile, isModuleTransportGenerationChangedResult, SubcModuleTransport, indexCommitsForProject, embedUnembeddedCommits, withMessageFtsSessionFilter, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
@@ -10,7 +10,7 @@ import {
10
10
  } from "./server-676xw7at.js";
11
11
  import {
12
12
  shouldHoldIgnoredNotification
13
- } from "./server-4tn95znb.js";
13
+ } from "./server-wkdgjjch.js";
14
14
  import {
15
15
  getErrorMessage
16
16
  } from "./server-y8v6yerm.js";
@@ -15,7 +15,7 @@ import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./server-158ehmk2.js";
18
+ } from "./server-fw31krgq.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./server-qt1qqasc.js";
@@ -1,4 +1,5 @@
1
1
  import {
2
+ getHarness2,
2
3
  harnessOwnsOpenCodeStore2
3
4
  } from "./server-pavzsdc6.js";
4
5
  import {
@@ -19,7 +20,7 @@ import {
19
20
  parseRpcPortFile,
20
21
  inspectProcessesAsync,
21
22
  inspectWindowsProcessesSync
22
- } from "./server-wrem2nmz.js";
23
+ } from "./server-1rfgbjfn.js";
23
24
  import {
24
25
  registerSlowWriteReporter2,
25
26
  registerSqliteDiagnosticSink2,
@@ -29,13 +30,13 @@ import {
29
30
  withoutSqliteTransformPass2,
30
31
  isTransientSqliteError2,
31
32
  withPrivilegedWriter2
32
- } from "./server-0nnd4bry.js";
33
+ } from "./server-j8epsc0g.js";
33
34
  import {
34
35
  configureContextDatabasePragmas2
35
36
  } from "./server-fb3zxn06.js";
36
37
  import {
37
38
  startMessageFtsRowidMapBackfill
38
- } from "./server-yezz0cp2.js";
39
+ } from "./server-brhj8qtd.js";
39
40
  import {
40
41
  LKG_SLOT_CHUNKS_DDL,
41
42
  SESSION_REPLAY_DECISIONS_DDL,
@@ -45,7 +46,7 @@ import {
45
46
  hasPendingMigrations,
46
47
  getMainThreadMigrationBodyCount,
47
48
  runMigrations
48
- } from "./server-ww9nr8pe.js";
49
+ } from "./server-hcvcxzx7.js";
49
50
  import {
50
51
  ensureColumn,
51
52
  installV95PerfSchema,
@@ -58,7 +59,7 @@ import {
58
59
  import {
59
60
  bootQuietRemainingMs,
60
61
  scheduleAfterBootQuiet
61
- } from "./server-btgnsv7w.js";
62
+ } from "./server-kdrezdy0.js";
62
63
  import {
63
64
  setDatabase,
64
65
  loadToolDefinitionMeasurements
@@ -749,7 +750,7 @@ function backfillToolOwnersInChunks(db, result) {
749
750
 
750
751
  // src/features/magic-context/storage-db.ts
751
752
  registerSlowWriteReporter2(logSlowWriteTransaction);
752
- registerSqliteDiagnosticSink2((message) => log2(message));
753
+ registerSqliteDiagnosticSink2((message) => log2(message), getHarness2);
753
754
  var databases = new Map;
754
755
  var pendingAsyncOpens = new Map;
755
756
  var persistenceByDatabase = new WeakMap;
@@ -1198,8 +1199,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1198
1199
  startMessageFtsRowidMapBackfill(db).then(async () => {
1199
1200
  if (!readsOpenCodeStore)
1200
1201
  return;
1201
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-vtb0w2kd.js"));
1202
- const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-5nf10c65.js"));
1202
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-4sat83cx.js"));
1203
+ const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-2z365239.js"));
1203
1204
  await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
1204
1205
  readPage: readRawSessionMessagePage
1205
1206
  }));
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  getTagIdentityWriteGeneration2,
16
16
  getSqliteDatabasePath2
17
- } from "./server-0nnd4bry.js";
17
+ } from "./server-j8epsc0g.js";
18
18
  import {
19
19
  stableStringify,
20
20
  tagOrderConstraintIndex,
@@ -14,7 +14,7 @@ import {
14
14
  } from "./server-2ra6pwf3.js";
15
15
  import {
16
16
  Database2
17
- } from "./server-0nnd4bry.js";
17
+ } from "./server-j8epsc0g.js";
18
18
  import {
19
19
  closeQuietly
20
20
  } from "./server-8ajstryz.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./server-t4k4qexw.js";
7
7
  import {
8
8
  getSqliteDatabasePath2
9
- } from "./server-0nnd4bry.js";
9
+ } from "./server-j8epsc0g.js";
10
10
 
11
11
  // src/features/magic-context/compaction-marker-candidates.ts
12
12
  import { existsSync, realpathSync } from "node:fs";