@cortexkit/pi-magic-context 0.49.5 → 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 (35) hide show
  1. package/dist/auto-search-worker.js +10 -7
  2. package/dist/{compaction-marker-candidates-cd17s4ys.js → compaction-marker-candidates-tqcq5n00.js} +2 -2
  3. package/dist/compaction-marker-candidates-worker.js +2 -2
  4. package/dist/{embedding-backfill-r7n7dj50.js → embedding-backfill-vygvr2x4.js} +6 -6
  5. package/dist/{index-g1csz24n.js → index-0d8zqccx.js} +3 -3
  6. package/dist/{index-mzn6t38b.js → index-0eg59y8d.js} +2 -2
  7. package/dist/{index-9ygacw4e.js → index-0ww9cgfd.js} +4 -4
  8. package/dist/{index-4gfq5t09.js → index-34zacc0h.js} +1 -1
  9. package/dist/{index-a1jmtv6r.js → index-6q5mx0cz.js} +8 -7
  10. package/dist/{index-9n88gmpf.js → index-6vjj0555.js} +1 -1
  11. package/dist/{index-2apf1afe.js → index-7mm27xdc.js} +1 -1
  12. package/dist/{index-3cgbv47m.js → index-7ptxvfc5.js} +35 -14
  13. package/dist/{index-57njcjax.js → index-8jpqq2yk.js} +64 -64
  14. package/dist/{index-27jh224p.js → index-8ye22z7k.js} +1 -1
  15. package/dist/{index-xvm5cdyn.js → index-a7fj661j.js} +1 -1
  16. package/dist/{index-xjqheg7a.js → index-dj784nyr.js} +1 -1
  17. package/dist/{index-g3600tpw.js → index-dj8hpkz7.js} +1 -1
  18. package/dist/{index-590pwxvr.js → index-fhv6ydkq.js} +98 -19
  19. package/dist/{index-g7984a4r.js → index-gqsfhksw.js} +1 -1
  20. package/dist/{index-gxk9hcd1.js → index-mrsarsbh.js} +160 -25
  21. package/dist/index.js +979 -321
  22. package/dist/{message-index-2damq13v.js → message-index-8rxj3cxh.js} +7 -7
  23. package/dist/{message-index-bounded-0qa5eacp.js → message-index-bounded-e5bv8gzm.js} +7 -7
  24. package/dist/{message-time-backfill-05ppypkz.js → message-time-backfill-hmekd2jj.js} +1 -1
  25. package/dist/migration-worker.js +5 -5
  26. package/dist/{project-embedding-registry-fzc4eb29.js → project-embedding-registry-z5m4eh3d.js} +5 -5
  27. package/dist/raw-ordinal-warmup-worker.js +17 -15
  28. package/dist/{read-session-chunk-q05ztqg5.js → read-session-chunk-sp5adk01.js} +6 -4
  29. package/dist/{read-session-raw-527m0yxx.js → read-session-raw-s14c7nf3.js} +2 -2
  30. package/dist/{search-5m0jjf29.js → search-hgfaqytc.js} +13 -13
  31. package/dist/{sqlite-3yye76ht.js → sqlite-f8kh2n10.js} +1 -1
  32. package/dist/{storage-memory-1z20y55x.js → storage-memory-yf7r98vz.js} +2 -2
  33. package/dist/{storage-tags-1b2w0wst.js → storage-tags-0xk95neb.js} +2 -2
  34. package/dist/subagent-entry.js +16 -16
  35. package/package.json +1 -1
@@ -14,19 +14,22 @@ var [
14
14
  { installProjectEmbeddingSearchBridge },
15
15
  { searchMessageHistory, unifiedSearch },
16
16
  { setEmbeddingSessionBusy },
17
- { setHarness },
18
- { Database }
17
+ { getHarness, setHarness },
18
+ { Database, registerSqliteDiagnosticSink },
19
+ { log }
19
20
  ] = await Promise.all([
20
- import("./embedding-backfill-r7n7dj50.js"),
21
+ import("./embedding-backfill-vygvr2x4.js"),
21
22
  import("./embedding-cache-7rp4gqzr.js"),
22
- import("./storage-memory-1z20y55x.js"),
23
- import("./project-embedding-registry-fzc4eb29.js"),
24
- import("./search-5m0jjf29.js"),
23
+ import("./storage-memory-yf7r98vz.js"),
24
+ import("./project-embedding-registry-z5m4eh3d.js"),
25
+ import("./search-hgfaqytc.js"),
25
26
  import("./embedding-activity-ew6dshfd.js"),
26
27
  import("./harness-9872e0ym.js"),
27
- import("./sqlite-3yye76ht.js")
28
+ import("./sqlite-f8kh2n10.js"),
29
+ import("./logger-j6tecd1h.js")
28
30
  ]);
29
31
  setHarness(input.harness);
32
+ registerSqliteDiagnosticSink(log, getHarness);
30
33
  setEmbeddingSessionBusy(input.sessionId, input.embeddingHostBusy === true);
31
34
  var nextId = 0;
32
35
  var pending = new Map;
@@ -4,9 +4,9 @@ import {
4
4
  readMarkerCandidateBasis2,
5
5
  prepareMarkerCandidateBasis2,
6
6
  scanMarkerCandidateSnapshot2
7
- } from "./index-g3600tpw.js";
7
+ } from "./index-dj8hpkz7.js";
8
8
  import"./index-399p688g.js";
9
- import"./index-3cgbv47m.js";
9
+ import"./index-7ptxvfc5.js";
10
10
  import"./index-x3dcnxh0.js";
11
11
  import"./index-0h2mkab2.js";
12
12
  export {
@@ -5,8 +5,8 @@ if (!port)
5
5
  throw new Error("marker candidate worker requires a parent port");
6
6
  port.postMessage({ kind: "accepted" });
7
7
  var [{ Database }, { scanMarkerCandidateSnapshot }] = await Promise.all([
8
- import("./sqlite-3yye76ht.js"),
9
- import("./compaction-marker-candidates-cd17s4ys.js")
8
+ import("./sqlite-f8kh2n10.js"),
9
+ import("./compaction-marker-candidates-tqcq5n00.js")
10
10
  ]);
11
11
  var input = workerData;
12
12
  var db;
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./index-xvm5cdyn.js";
4
- import"./index-g1csz24n.js";
3
+ } from "./index-a7fj661j.js";
4
+ import"./index-0d8zqccx.js";
5
5
  import"./index-9p40dgkm.js";
6
- import"./index-27jh224p.js";
6
+ import"./index-8ye22z7k.js";
7
7
  import"./index-yhzhdp3m.js";
8
8
  import"./index-gc2749rx.js";
9
9
  import"./index-21v1kfs7.js";
10
10
  import"./index-cyrnv16r.js";
11
- import"./index-g7984a4r.js";
12
- import"./index-4gfq5t09.js";
11
+ import"./index-gqsfhksw.js";
12
+ import"./index-34zacc0h.js";
13
13
  import"./index-0vrkp1jq.js";
14
- import"./index-3cgbv47m.js";
14
+ import"./index-7ptxvfc5.js";
15
15
  import"./index-r56xgha8.js";
16
16
  import"./index-x3dcnxh0.js";
17
17
  import"./index-0h2mkab2.js";
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  isUserHomeDirectory,
10
10
  setBootQuietPeriodForTests
11
- } from "./index-g7984a4r.js";
11
+ } from "./index-gqsfhksw.js";
12
12
  import {
13
13
  withSqliteBackgroundWriter2,
14
14
  withoutSqliteTransformPass2,
15
15
  isTransientSqliteError2
16
- } from "./index-3cgbv47m.js";
16
+ } from "./index-7ptxvfc5.js";
17
17
  import {
18
18
  estimateTokens
19
19
  } from "./index-r56xgha8.js";
@@ -39,7 +39,7 @@ import {
39
39
  countSessionCompartmentEmbedCoverage,
40
40
  countSessionCompartmentEmbedCoveragePolite,
41
41
  countUnembeddedSessionCompartmentsPolite
42
- } from "./index-27jh224p.js";
42
+ } from "./index-8ye22z7k.js";
43
43
  import {
44
44
  DEFAULT_LOCAL_EMBEDDING_MODEL
45
45
  } from "./index-cyrnv16r.js";
@@ -16,11 +16,11 @@ import {
16
16
  } from "./index-8976mezv.js";
17
17
  import {
18
18
  Database2
19
- } from "./index-3cgbv47m.js";
19
+ } from "./index-7ptxvfc5.js";
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./index-g7984a4r.js";
23
+ } from "./index-gqsfhksw.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
26
  } from "./index-0vrkp1jq.js";
@@ -16,16 +16,16 @@ import {
16
16
  import {
17
17
  withSqliteBackgroundWriter2,
18
18
  withoutSqliteTransformPass2
19
- } from "./index-3cgbv47m.js";
19
+ } from "./index-7ptxvfc5.js";
20
20
  import {
21
21
  recordMessageFtsRowid,
22
22
  recordIndexedMessageTime,
23
23
  messageFtsOrdinalRangeIsMapped,
24
24
  deleteUnmappedMessageFtsRows
25
- } from "./index-4gfq5t09.js";
25
+ } from "./index-34zacc0h.js";
26
26
  import {
27
27
  deleteChunkEmbedBackoffForSession
28
- } from "./index-27jh224p.js";
28
+ } from "./index-8ye22z7k.js";
29
29
  import {
30
30
  closeQuietly,
31
31
  TAG_TOMBSTONE_OWNER_PREFIX,
@@ -37,7 +37,7 @@ import {
37
37
  } from "./index-mcgehvgw.js";
38
38
  import {
39
39
  cleanUserText2
40
- } from "./index-590pwxvr.js";
40
+ } from "./index-fhv6ydkq.js";
41
41
  import {
42
42
  logSlowWriteTransaction
43
43
  } from "./index-0vrkp1jq.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  withSqliteBackgroundWriter2,
3
3
  withoutSqliteTransformPass2
4
- } from "./index-3cgbv47m.js";
4
+ } from "./index-7ptxvfc5.js";
5
5
  import {
6
6
  logSlowWriteTransaction
7
7
  } from "./index-0vrkp1jq.js";
@@ -15,8 +15,9 @@ import {
15
15
  withoutSqliteTransformPass2,
16
16
  isTransientSqliteError2,
17
17
  withPrivilegedWriter2
18
- } from "./index-3cgbv47m.js";
18
+ } from "./index-7ptxvfc5.js";
19
19
  import {
20
+ getHarness2,
20
21
  harnessOwnsOpenCodeStore2
21
22
  } from "./index-0h2mkab2.js";
22
23
  import {
@@ -35,7 +36,7 @@ import {
35
36
  } from "./index-fapenpch.js";
36
37
  import {
37
38
  startMessageFtsRowidMapBackfill
38
- } from "./index-4gfq5t09.js";
39
+ } from "./index-34zacc0h.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 "./index-mzn6t38b.js";
49
+ } from "./index-0eg59y8d.js";
49
50
  import {
50
51
  closeQuietly,
51
52
  ensureColumn,
@@ -61,7 +62,7 @@ import {
61
62
  import {
62
63
  bootQuietRemainingMs,
63
64
  scheduleAfterBootQuiet
64
- } from "./index-g7984a4r.js";
65
+ } from "./index-gqsfhksw.js";
65
66
  import {
66
67
  logSlowWriteTransaction
67
68
  } from "./index-0vrkp1jq.js";
@@ -838,7 +839,7 @@ function backfillToolOwnersInChunks(db, result) {
838
839
 
839
840
  // ../plugin/src/features/magic-context/storage-db.ts
840
841
  registerSlowWriteReporter2(logSlowWriteTransaction);
841
- registerSqliteDiagnosticSink2((message) => log2(message));
842
+ registerSqliteDiagnosticSink2((message) => log2(message), getHarness2);
842
843
  var databases = new Map;
843
844
  var pendingAsyncOpens = new Map;
844
845
  var persistenceByDatabase = new WeakMap;
@@ -1287,8 +1288,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1287
1288
  startMessageFtsRowidMapBackfill(db).then(async () => {
1288
1289
  if (!readsOpenCodeStore)
1289
1290
  return;
1290
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-q05ztqg5.js"));
1291
- const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-05ppypkz.js"));
1291
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-sp5adk01.js"));
1292
+ const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-hmekd2jj.js"));
1292
1293
  await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
1293
1294
  readPage: readRawSessionMessagePage
1294
1295
  }));
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  getTagIdentityWriteGeneration2,
12
12
  getSqliteDatabasePath2
13
- } from "./index-3cgbv47m.js";
13
+ } from "./index-7ptxvfc5.js";
14
14
  import {
15
15
  tagOrderConstraintIndex,
16
16
  tagIdentityRevisionKey
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getSqliteDatabasePath2,
3
3
  releaseIndexOwner2
4
- } from "./index-3cgbv47m.js";
4
+ } from "./index-7ptxvfc5.js";
5
5
  import {
6
6
  registerExitAbort
7
7
  } from "./index-399p688g.js";
@@ -5,12 +5,15 @@ function registerSlowWriteReporter2(reporter) {
5
5
  reportSlowPrivilegedWrite = reporter;
6
6
  }
7
7
  var sqliteDiagnosticSink;
8
- function registerSqliteDiagnosticSink2(sink) {
8
+ var sqliteDiagnosticHost = () => "unknown";
9
+ function registerSqliteDiagnosticSink2(sink, host) {
9
10
  sqliteDiagnosticSink = sink;
11
+ if (host)
12
+ sqliteDiagnosticHost = host;
10
13
  }
11
14
  function reportSqliteDiagnostic(message) {
12
15
  try {
13
- sqliteDiagnosticSink?.(`[magic-context] ${message}`);
16
+ sqliteDiagnosticSink?.(`[magic-context] ${message} pid=${process.pid} host=${sqliteDiagnosticHost()}`);
14
17
  } catch {}
15
18
  }
16
19
  function detectSqliteRuntime2() {
@@ -169,10 +172,18 @@ function installTransactionRouting(db, readonly) {
169
172
  assertTransformWrite2();
170
173
  if (/^\s*BEGIN\s+(?:IMMEDIATE|EXCLUSIVE)(?:\s+TRANSACTION)?\s*;?\s*$/i.test(sql)) {
171
174
  openWriterTransactions.delete(db);
172
- if (transformPassScope.getStore()?.active || backgroundWriterScope.getStore())
175
+ if (transformPassScope.getStore()?.active || backgroundWriterScope.getStore()) {
173
176
  acquireShort(db, () => nativeExec(sql), sql.trim());
174
- else
177
+ } else {
175
178
  nativeExec(sql);
179
+ openWriterTransactions.set(db, {
180
+ site: sql.trim(),
181
+ lane: "background",
182
+ acquireMs: 0,
183
+ attempts: 1,
184
+ acquiredAt: performance.now()
185
+ });
186
+ }
176
187
  return db;
177
188
  }
178
189
  if (WRITER_TRANSACTION_END.test(sql) && openWriterTransactions.has(db))
@@ -495,9 +506,9 @@ class SqliteAcquisitionBusyError extends Error {
495
506
  }
496
507
  }
497
508
  var SHORT_BUSY_TIMEOUT_MS = 25;
498
- var FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS = 250;
509
+ var FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS = 2000;
499
510
  var FOREGROUND_ACQUISITION_BUDGET_MS = 16500;
500
- var SLOW_WRITER_LOG_MS = 250;
511
+ var SLOW_WRITER_LOG_MS = 100;
501
512
  var WRITER_TRANSACTION_END = /^\s*(?:COMMIT|END|ROLLBACK)(?:\s+TRANSACTION)?\s*;?\s*$/i;
502
513
  var writerAcquisitionScope = new AsyncLocalStorage;
503
514
  var openWriterTransactions = new WeakMap;
@@ -508,22 +519,30 @@ function foregroundWaitLease() {
508
519
  function withAutocommitTimeout(db, operation) {
509
520
  assertTransformWrite2();
510
521
  const lease = foregroundWaitLease();
511
- if (isInTransaction(db) || !lease && !backgroundWriterScope.getStore())
522
+ if (isInTransaction(db))
512
523
  return operation();
513
- const previous = pragmaNumber(db, "busy_timeout");
514
- db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(lease.remainingWaitMs) : SHORT_BUSY_TIMEOUT_MS}`);
524
+ const scoped = lease || backgroundWriterScope.getStore();
525
+ const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
526
+ if (scoped)
527
+ db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
515
528
  const started = performance.now();
529
+ let completed = false;
516
530
  try {
517
- return operation();
531
+ const result = operation();
532
+ completed = true;
533
+ return result;
518
534
  } catch (error) {
519
535
  if (lease && isTransientSqliteError2(error))
520
536
  throw new SqliteAcquisitionBusyError(error, "autocommit");
521
537
  throw error;
522
538
  } finally {
539
+ const elapsed = performance.now() - started;
523
540
  if (lease)
524
- lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - started));
541
+ lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - elapsed);
525
542
  if (previous !== null)
526
543
  db.exec(`PRAGMA busy_timeout=${previous}`);
544
+ if (elapsed >= SLOW_WRITER_LOG_MS)
545
+ reportSqliteDiagnostic(`sqlite writer site=autocommit lane=${lease ? "foreground" : "background"} elapsed_ms=${Math.round(elapsed)} timing=statement_including_acquisition outcome=${completed ? "completed" : "failed"} caller=${writerCaller()}`);
527
546
  }
528
547
  }
529
548
  function acquireShort(db, acquire, site) {
@@ -569,24 +588,26 @@ function acquireShort(db, acquire, site) {
569
588
  }
570
589
  function endWriterTransaction(db, end, sql) {
571
590
  let ended = false;
572
- const endStarted = performance.now();
573
591
  try {
574
592
  const result = end();
575
593
  ended = true;
576
594
  return result;
577
595
  } finally {
578
596
  const open = openWriterTransactions.get(db);
579
- const endMs = performance.now() - endStarted;
580
597
  if (open && !isInTransaction(db)) {
581
598
  openWriterTransactions.delete(db);
582
599
  const holdMs = performance.now() - open.acquiredAt;
583
600
  if (open.acquireMs >= SLOW_WRITER_LOG_MS || holdMs >= SLOW_WRITER_LOG_MS) {
584
601
  const outcome = /^\s*ROLLBACK/i.test(sql) ? "rolled_back" : ended ? "committed" : "failed";
585
- reportSqliteDiagnostic(`sqlite writer site=${open.site} lane=${open.lane} acquire_ms=${Math.round(open.acquireMs)} hold_ms=${Math.round(holdMs)} end_ms=${Math.round(endMs)} attempts=${open.attempts} outcome=${outcome}`);
602
+ reportSqliteDiagnostic(`sqlite writer site=${open.site} lane=${open.lane} acquire_ms=${Math.round(open.acquireMs)} hold_ms=${Math.round(holdMs)} attempts=${open.attempts} outcome=${outcome} timing=through_commit_upper_bound caller=${writerCaller()}`);
586
603
  }
587
604
  }
588
605
  }
589
606
  }
607
+ function writerCaller() {
608
+ return new Error().stack?.split(`
609
+ `).find((line) => line.includes(" at ") && !/[/\\]sqlite\.[tj]s[:)]/.test(line) && !/\b(?:writerCaller|endWriterTransaction|withAutocommitTimeout|value)\b/.test(line))?.trim().replace(/\s+/g, "_") ?? "unknown";
610
+ }
590
611
  async function beginSqliteWriterAsync2(db, site) {
591
612
  const started = performance.now();
592
613
  let attempts = 0;
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-0h2mkab2.js";
4
4
  import {
5
5
  isTransientSqliteError2
6
- } from "./index-3cgbv47m.js";
6
+ } from "./index-7ptxvfc5.js";
7
7
  import {
8
8
  PROMOTABLE_CATEGORIES,
9
9
  CATEGORY_DEFAULT_TTL
@@ -21,7 +21,7 @@ import {
21
21
  resolveStoredPathWorkspaceIdentity,
22
22
  sourceNameForMemory,
23
23
  managedAuthorityNoteRow
24
- } from "./index-mzn6t38b.js";
24
+ } from "./index-0eg59y8d.js";
25
25
  import {
26
26
  isKnownAutocommit
27
27
  } from "./index-mcgehvgw.js";
@@ -31,7 +31,7 @@ import {
31
31
  import {
32
32
  buildCanonicalChunkTextFromFts,
33
33
  loadCompartmentChunkEmbeddingsForSearch
34
- } from "./index-27jh224p.js";
34
+ } from "./index-8ye22z7k.js";
35
35
  import {
36
36
  recordEmbeddingMeasurement,
37
37
  saveCommitEmbedding,
@@ -49,7 +49,7 @@ import {
49
49
  getProjectEmbeddingSnapshot2,
50
50
  embedTextForProject2,
51
51
  embedItemsForProject2
52
- } from "./index-g1csz24n.js";
52
+ } from "./index-0d8zqccx.js";
53
53
  import {
54
54
  saveEmbeddingIfHashMatches,
55
55
  getProjectEmbeddings2
@@ -59,7 +59,7 @@ import {
59
59
  isEmbeddingEnabled,
60
60
  embedText,
61
61
  ensureMemoryEmbeddings2
62
- } from "./index-xvm5cdyn.js";
62
+ } from "./index-a7fj661j.js";
63
63
  import {
64
64
  getMemorySelectColumns2,
65
65
  isMemoryRow2,
@@ -73,10 +73,10 @@ import {
73
73
  getMemoryById2,
74
74
  updateMemorySeenCount2,
75
75
  updateMemoryRetrievalCount2
76
- } from "./index-xjqheg7a.js";
76
+ } from "./index-dj784nyr.js";
77
77
  import {
78
78
  getIndexedMessageCorpusSize2
79
- } from "./index-9ygacw4e.js";
79
+ } from "./index-0ww9cgfd.js";
80
80
  import {
81
81
  computeNormalizedHash
82
82
  } from "./index-9x1f96r8.js";
@@ -1792,6 +1792,61 @@ function searchGitCommitsSync(db, projectPath, query, options) {
1792
1792
  });
1793
1793
  return results.slice(0, options.limit);
1794
1794
  }
1795
+ // ../plugin/src/features/magic-context/message-fts-session-filter.ts
1796
+ var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
1797
+ SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
1798
+ ) AND `;
1799
+ var coverageCaches = new WeakMap;
1800
+ function getCoverageCache(db) {
1801
+ let cache = coverageCaches.get(db);
1802
+ if (!cache) {
1803
+ cache = {
1804
+ pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
1805
+ stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
1806
+ missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
1807
+ FROM message_history_fts WHERE rowid IN (
1808
+ SELECT id FROM message_history_fts_docsize
1809
+ EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
1810
+ )`)
1811
+ };
1812
+ coverageCaches.set(db, cache);
1813
+ }
1814
+ return cache;
1815
+ }
1816
+ function withMessageFtsSessionFilter(db, sessionId, read) {
1817
+ let cacheable = false;
1818
+ try {
1819
+ const transaction = db;
1820
+ cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
1821
+ if (!cacheable)
1822
+ coverageCaches.delete(db);
1823
+ } catch {
1824
+ coverageCaches.delete(db);
1825
+ }
1826
+ return db.transaction(() => {
1827
+ let sessionFirst = false;
1828
+ try {
1829
+ const cache = getCoverageCache(db);
1830
+ cache.pin.get();
1831
+ const stamp = cache.stamp.get();
1832
+ let incomplete = cache.incompleteSessions;
1833
+ if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
1834
+ const rows = cache.missing.all();
1835
+ incomplete = new Set(rows.map((row) => row.sessionId));
1836
+ if (cacheable) {
1837
+ cache.version = stamp.version;
1838
+ cache.changes = stamp.changes;
1839
+ cache.incompleteSessions = incomplete;
1840
+ }
1841
+ }
1842
+ sessionFirst = !incomplete.has(sessionId);
1843
+ } catch {
1844
+ coverageCaches.delete(db);
1845
+ }
1846
+ return read(sessionFirst);
1847
+ }).deferred();
1848
+ }
1849
+
1795
1850
  // ../plugin/src/features/magic-context/literal-probes.ts
1796
1851
  var MAX_PROBES = 5;
1797
1852
  var MIN_PROBE_LENGTH = 3;
@@ -1848,61 +1903,6 @@ function containsProbeVerbatim(text, probes) {
1848
1903
  return probes.some((probe) => haystack.includes(probe.toLowerCase()));
1849
1904
  }
1850
1905
 
1851
- // ../plugin/src/features/magic-context/message-fts-session-filter.ts
1852
- var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
1853
- SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
1854
- ) AND `;
1855
- var coverageCaches = new WeakMap;
1856
- function getCoverageCache(db) {
1857
- let cache = coverageCaches.get(db);
1858
- if (!cache) {
1859
- cache = {
1860
- pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
1861
- stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
1862
- missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
1863
- FROM message_history_fts WHERE rowid IN (
1864
- SELECT id FROM message_history_fts_docsize
1865
- EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
1866
- )`)
1867
- };
1868
- coverageCaches.set(db, cache);
1869
- }
1870
- return cache;
1871
- }
1872
- function withMessageFtsSessionFilter(db, sessionId, read) {
1873
- let cacheable = false;
1874
- try {
1875
- const transaction = db;
1876
- cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
1877
- if (!cacheable)
1878
- coverageCaches.delete(db);
1879
- } catch {
1880
- coverageCaches.delete(db);
1881
- }
1882
- return db.transaction(() => {
1883
- let sessionFirst = false;
1884
- try {
1885
- const cache = getCoverageCache(db);
1886
- cache.pin.get();
1887
- const stamp = cache.stamp.get();
1888
- let incomplete = cache.incompleteSessions;
1889
- if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
1890
- const rows = cache.missing.all();
1891
- incomplete = new Set(rows.map((row) => row.sessionId));
1892
- if (cacheable) {
1893
- cache.version = stamp.version;
1894
- cache.changes = stamp.changes;
1895
- cache.incompleteSessions = incomplete;
1896
- }
1897
- }
1898
- sessionFirst = !incomplete.has(sessionId);
1899
- } catch {
1900
- coverageCaches.delete(db);
1901
- }
1902
- return read(sessionFirst);
1903
- }).deferred();
1904
- }
1905
-
1906
1906
  // ../plugin/src/features/magic-context/search-measurement.ts
1907
1907
  import { createHash } from "node:crypto";
1908
1908
  function resultId(result) {
@@ -3789,7 +3789,7 @@ ${diagnosticLines.join(`
3789
3789
  bodyParts.push(diagnosticLines.join(`
3790
3790
  `));
3791
3791
  if (results.some((result) => result.source === "message" || result.source === "compartment")) {
3792
- bodyParts.push("Use ctx_expand(start, end) with the range from any message result above to read the full conversation context.");
3792
+ 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.");
3793
3793
  }
3794
3794
  if (results.some((result) => result.source === "note" && result.anchorOrdinal !== null && result.sourceSessionId === currentSessionId)) {
3795
3795
  bodyParts.push(SEARCH_NOTE_EXPAND_HINT);
@@ -3801,4 +3801,4 @@ ${bodyParts.join(`
3801
3801
  `)}`;
3802
3802
  }
3803
3803
 
3804
- export { getNoteByIdInScope, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, projectNeedsSingleStoreMigration, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, indexCommitsForProject, embedUnembeddedCommits, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
3804
+ export { getNoteByIdInScope, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, projectNeedsSingleStoreMigration, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, indexCommitsForProject, embedUnembeddedCommits, withMessageFtsSessionFilter, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
@@ -13,7 +13,7 @@ import {
13
13
  } from "./index-21v1kfs7.js";
14
14
  import {
15
15
  messageFtsOrdinalRangeIsMapped
16
- } from "./index-4gfq5t09.js";
16
+ } from "./index-34zacc0h.js";
17
17
 
18
18
  // ../plugin/src/features/magic-context/compartment-chunk-embedding.ts
19
19
  import { createHash } from "node:crypto";
@@ -15,7 +15,7 @@ import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./index-g1csz24n.js";
18
+ } from "./index-0d8zqccx.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./index-9p40dgkm.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withPrivilegedWriter2
3
- } from "./index-3cgbv47m.js";
3
+ } from "./index-7ptxvfc5.js";
4
4
  import {
5
5
  MEMORY_CATEGORY_ORDER_SQL
6
6
  } from "./index-135e8hvg.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-x3dcnxh0.js";
7
7
  import {
8
8
  getSqliteDatabasePath2
9
- } from "./index-3cgbv47m.js";
9
+ } from "./index-7ptxvfc5.js";
10
10
 
11
11
  // ../plugin/src/features/magic-context/compaction-marker-candidates.ts
12
12
  import { existsSync, realpathSync } from "node:fs";