@cortexkit/opencode-magic-context 0.49.2 → 0.49.3

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 (114) hide show
  1. package/README.md +2 -38
  2. package/dist/auto-search-worker.js +3 -3
  3. package/dist/compaction-marker-candidates-dd638ypn.js +19 -0
  4. package/dist/compaction-marker-candidates-worker.js +24 -0
  5. package/dist/{conflict-warning-hook-asnt6hfc.js → conflict-warning-hook-ae8nmv7c.js} +5 -4
  6. package/dist/{context-tfyhtdcs.js → context-9tbxh883.js} +63 -29
  7. package/dist/{embedding-backfill-wyc3ykyf.js → embedding-backfill-aj488s8x.js} +5 -5
  8. package/dist/features/magic-context/compaction-marker-candidates-worker.d.ts +2 -0
  9. package/dist/features/magic-context/compaction-marker-candidates-worker.d.ts.map +1 -0
  10. package/dist/features/magic-context/compaction-marker-candidates.d.ts +47 -0
  11. package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -0
  12. package/dist/features/magic-context/compaction-marker.d.ts +12 -0
  13. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  14. package/dist/features/magic-context/memory/project-identity.d.ts +5 -1
  15. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  16. package/dist/features/magic-context/message-index-async.d.ts +3 -0
  17. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  18. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  19. package/dist/features/magic-context/storage-clone.d.ts +2 -0
  20. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  21. package/dist/features/magic-context/storage-tags.d.ts +1 -1
  22. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +3 -0
  24. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/history-boundary-repair.d.ts +11 -2
  27. package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +4 -3
  29. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +10 -0
  31. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  35. package/dist/{index-sfhndpcb.js → index-3wckxwfp.js} +39 -39
  36. package/dist/{index-gzky5rva.js → index-41gqa557.js} +4 -2
  37. package/dist/{index-r2zcs71c.js → index-7ndnvw7a.js} +1 -1
  38. package/dist/{index-sv0bb7vg.js → index-7zg9dvx0.js} +35 -4
  39. package/dist/{index-xgrwmj82.js → index-bhk710rw.js} +1 -1
  40. package/dist/{index-fg00p1cg.js → index-c0b01zrc.js} +2 -2
  41. package/dist/{index-rafsaxac.js → index-fjtgekd4.js} +2 -2
  42. package/dist/{index-fdtkt5r1.js → index-fst3t0d9.js} +9 -9
  43. package/dist/{index-6tfxmc4n.js → index-je2na55n.js} +4 -4
  44. package/dist/{index-h5zfkjyk.js → index-jpm52v9x.js} +6 -24
  45. package/dist/{index-s7fc0fkn.js → index-m4p77myp.js} +1 -1
  46. package/dist/{index-xnanvj3w.js → index-mgy5dwcw.js} +607 -579
  47. package/dist/{index-0pjvpfkf.js → index-qvr78ej6.js} +1 -1
  48. package/dist/{index-zfzdpeq2.js → index-s4ztdn8v.js} +1311 -1271
  49. package/dist/index-v0p37hm2.js +22 -0
  50. package/dist/{index-eypn4ba6.js → index-w9pe0nx1.js} +3 -3
  51. package/dist/{index-p0n5ryq8.js → index-ws3gcy5m.js} +19 -9
  52. package/dist/{index-att4bfan.js → index-xfbfrngb.js} +1 -1
  53. package/dist/{index-nydv6g8r.js → index-yqps2zsv.js} +44 -6
  54. package/dist/index-yxawqmdd.js +212 -0
  55. package/dist/{index-zg8yq4ya.js → index-znzgze2v.js} +3 -3
  56. package/dist/index.js +38 -35
  57. package/dist/{message-index-bounded-hqktkhdy.js → message-index-bounded-pv6ct15d.js} +18 -17
  58. package/dist/message-index-jqa7qd0s.js +60 -0
  59. package/dist/migration-worker.js +3 -3
  60. package/dist/{project-embedding-registry-0gv3h6y8.js → project-embedding-registry-fcmszatg.js} +4 -4
  61. package/dist/raw-ordinal-warmup-worker.js +22 -5
  62. package/dist/{read-session-chunk-5mh0bh8y.js → read-session-chunk-cwgjwjd0.js} +7 -6
  63. package/dist/{read-session-raw-8sjbc9h0.js → read-session-raw-z38cn0as.js} +2 -1
  64. package/dist/{recomp-orchestrator-kpkhkjhq.js → recomp-orchestrator-txcc802e.js} +19 -17
  65. package/dist/{search-p9w39qv4.js → search-v1t47s2q.js} +14 -13
  66. package/dist/{send-session-notification-xffh3bbe.js → send-session-notification-yp9m5g4p.js} +4 -3
  67. package/dist/shared/tag-owner-id.d.ts +1 -0
  68. package/dist/shared/tag-owner-id.d.ts.map +1 -1
  69. package/dist/{storage-tags-k0pda32s.js → storage-tags-0ssbmzg9.js} +2 -2
  70. package/dist/{transform-postprocess-phase-481j5a7z.js → transform-postprocess-phase-113rwew1.js} +19 -17
  71. package/dist/v2/auto-search-worker.js +3 -3
  72. package/dist/v2/compaction-marker-candidates-1s21e2fz.js +18 -0
  73. package/dist/v2/compaction-marker-candidates-worker.js +24 -0
  74. package/dist/v2/{context-gsdtha5v.js → context-p1xf3w5q.js} +115 -44
  75. package/dist/v2/{embedding-backfill-dbvjbcmm.js → embedding-backfill-9hbkfvnz.js} +5 -5
  76. package/dist/v2/{message-index-bounded-p6v0n8qh.js → message-index-bounded-c0810p5w.js} +17 -16
  77. package/dist/v2/message-index-h8ssgq3q.js +59 -0
  78. package/dist/v2/migration-worker.js +3 -3
  79. package/dist/v2/{project-embedding-registry-nyq7z8y6.js → project-embedding-registry-42th7k1z.js} +4 -4
  80. package/dist/v2/raw-ordinal-warmup-worker.js +22 -5
  81. package/dist/v2/{read-session-chunk-fhyfe4qa.js → read-session-chunk-n86v9xfg.js} +6 -5
  82. package/dist/v2/{read-session-raw-j8dvp7f4.js → read-session-raw-3b3ehga4.js} +2 -1
  83. package/dist/v2/{recomp-orchestrator-5xy7w136.js → recomp-orchestrator-v168jwgg.js} +16 -14
  84. package/dist/v2/{search-j7bakcwa.js → search-048v8y02.js} +13 -12
  85. package/dist/v2/{send-session-notification-f6v698r5.js → send-session-notification-a4h2azxa.js} +2 -1
  86. package/dist/v2/{server-bgzy0phk.js → server-3bc6k4k4.js} +62 -33
  87. package/dist/v2/{server-7h861yms.js → server-3dqjhchy.js} +5 -18
  88. package/dist/v2/{server-c7n2ftng.js → server-4n2tknpc.js} +34 -3
  89. package/dist/v2/server-51779zs2.js +19 -0
  90. package/dist/v2/{server-kh958yj8.js → server-5zrpr764.js} +1 -1
  91. package/dist/v2/{server-6tcrjfw8.js → server-8pqnnmf9.js} +1 -1
  92. package/dist/v2/server-9290a1mb.js +212 -0
  93. package/dist/v2/{server-7vkj6zhb.js → server-9a6v0wth.js} +3 -3
  94. package/dist/v2/{server-1fszbabv.js → server-cjz51jm2.js} +2 -2
  95. package/dist/v2/{server-7spkq1y6.js → server-cxxjb33r.js} +2286 -2246
  96. package/dist/v2/{server-mqvtz7wz.js → server-hetyb88z.js} +9 -9
  97. package/dist/v2/{server-4c7jt8gq.js → server-pcygfdbs.js} +44 -6
  98. package/dist/v2/{server-8xmq9h3f.js → server-q6j5dasr.js} +4 -2
  99. package/dist/v2/{server-zbxjj2mz.js → server-rygvffsf.js} +2 -2
  100. package/dist/v2/server.js +4 -4
  101. package/dist/v2/{storage-tags-5yxrvkaf.js → storage-tags-3a4cavqb.js} +2 -2
  102. package/dist/v2/{wrapup-orchestrator-yem5422s.js → wrapup-orchestrator-zcyf8ymw.js} +14 -12
  103. package/dist/{wrapup-orchestrator-xvrr27ws.js → wrapup-orchestrator-5aa2q4v3.js} +20 -18
  104. package/package.json +3 -3
  105. package/src/config/latch-permanence-guard.test.ts +6 -1
  106. package/src/shared/sqlite-writer-diagnostics.test.ts +21 -10
  107. package/src/shared/tag-owner-id.ts +13 -0
  108. package/src/shared/tag-transcript.test.ts +6 -1
  109. package/src/shared/tag-transcript.ts +2 -1
  110. package/src/shared/windows-hidden-spawns.test.ts +60 -4
  111. /package/dist/{index-69vas84q.js → index-e6xnpach.js} +0 -0
  112. /package/dist/{index-p1hnwfd8.js → index-gcdb3rqw.js} +0 -0
  113. /package/dist/v2/{index-69vas84q.js → index-e6xnpach.js} +0 -0
  114. /package/dist/v2/{server-s2st631p.js → server-8wcf79fe.js} +0 -0
@@ -8,11 +8,12 @@ import {
8
8
  clearIgnoredMessages2,
9
9
  observeIgnoredNotificationEvent2,
10
10
  sendStatusNotification2
11
- } from "./index-xgrwmj82.js";
11
+ } from "./index-bhk710rw.js";
12
12
  import"./index-qt1qqasc.js";
13
13
  import"./index-tqf7yg27.js";
14
- import"./index-0pjvpfkf.js";
15
- import"./index-h5zfkjyk.js";
14
+ import"./index-qvr78ej6.js";
15
+ import"./index-jpm52v9x.js";
16
+ import"./index-v0p37hm2.js";
16
17
  import"./index-58e3y90n.js";
17
18
  import"./index-kb9nn0a0.js";
18
19
  import"./index-nsjyysj0.js";
@@ -11,6 +11,7 @@
11
11
  * tag is treated as belonging to a message that does not exist.
12
12
  */
13
13
  export declare const TEXT_TAG_IDENTITY_MARKER = ":mc-text-v1:";
14
+ export declare const PI_FALLBACK_PREFIXES_JSON: string;
14
15
  /**
15
16
  * The owning message id of a content tag id. An id with neither suffix is
16
17
  * returned unchanged: it already is the message id.
@@ -1 +1 @@
1
- {"version":3,"file":"tag-owner-id.d.ts","sourceRoot":"","sources":["../../src/shared/tag-owner-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AAKvD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMlE"}
1
+ {"version":3,"file":"tag-owner-id.d.ts","sourceRoot":"","sources":["../../src/shared/tag-owner-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AAKvD,eAAO,MAAM,yBAAyB,QAQrC,CAAC;AAKF;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMlE"}
@@ -60,11 +60,11 @@ import {
60
60
  adoptNullOwnerToolTag2,
61
61
  getCandidateToolOwners2,
62
62
  pickNearestPriorOwner2
63
- } from "./index-nydv6g8r.js";
63
+ } from "./index-yqps2zsv.js";
64
64
  import"./index-1zx87sdm.js";
65
65
  import"./index-1bt88epp.js";
66
- import"./index-qx53vezw.js";
67
66
  import"./index-kb9nn0a0.js";
67
+ import"./index-qx53vezw.js";
68
68
  import"./index-nsjyysj0.js";
69
69
  import"./index-0sahzkwr.js";
70
70
  import"./index-pavzsdc6.js";
@@ -18,42 +18,44 @@ import {
18
18
  finalizeMessageRepresentation2,
19
19
  runPostTransformPhase2,
20
20
  checkM0MutationDriftAndSignal2
21
- } from "./index-p0n5ryq8.js";
22
- import"./index-zfzdpeq2.js";
23
- import"./index-rafsaxac.js";
24
- import"./index-sfhndpcb.js";
25
- import"./index-r2zcs71c.js";
21
+ } from "./index-ws3gcy5m.js";
22
+ import"./index-s4ztdn8v.js";
23
+ import"./index-yxawqmdd.js";
24
+ import"./index-sd3egckz.js";
25
+ import"./index-fjtgekd4.js";
26
+ import"./index-3wckxwfp.js";
27
+ import"./index-7ndnvw7a.js";
26
28
  import"./index-7jzrrxap.js";
27
- import"./index-fg00p1cg.js";
28
- import"./index-p1hnwfd8.js";
29
+ import"./index-c0b01zrc.js";
30
+ import"./index-gcdb3rqw.js";
29
31
  import"./index-4dhv7mqz.js";
30
32
  import"./index-w23dh319.js";
31
- import"./index-sd3egckz.js";
32
- import"./index-xgrwmj82.js";
33
+ import"./index-bhk710rw.js";
33
34
  import"./index-qt1qqasc.js";
34
35
  import"./index-x8a7jmkh.js";
35
36
  import"./index-tqf7yg27.js";
36
37
  import"./index-gbmqa9x9.js";
37
38
  import"./index-vkbqdnkj.js";
38
- import"./index-zg8yq4ya.js";
39
+ import"./index-znzgze2v.js";
39
40
  import"./index-fb3zxn06.js";
40
- import"./index-att4bfan.js";
41
+ import"./index-xfbfrngb.js";
41
42
  import"./index-6m7rdv7y.js";
42
43
  import"./index-fr0wbhdn.js";
43
- import"./index-gzky5rva.js";
44
+ import"./index-41gqa557.js";
44
45
  import"./index-7w18gg78.js";
45
- import"./index-sv0bb7vg.js";
46
- import"./index-nydv6g8r.js";
46
+ import"./index-7zg9dvx0.js";
47
+ import"./index-yqps2zsv.js";
47
48
  import"./index-1zx87sdm.js";
48
- import"./index-0pjvpfkf.js";
49
- import"./index-h5zfkjyk.js";
49
+ import"./index-qvr78ej6.js";
50
+ import"./index-jpm52v9x.js";
51
+ import"./index-v0p37hm2.js";
50
52
  import"./index-k6xvbj2e.js";
51
53
  import"./index-h2wc01qk.js";
52
54
  import"./index-1bt88epp.js";
53
55
  import"./index-58e3y90n.js";
54
- import"./index-qx53vezw.js";
55
56
  import"./index-4mjhqadz.js";
56
57
  import"./index-kb9nn0a0.js";
58
+ import"./index-qx53vezw.js";
57
59
  import"./index-nsjyysj0.js";
58
60
  import"./index-0sahzkwr.js";
59
61
  import"./index-pavzsdc6.js";
@@ -17,11 +17,11 @@ var [
17
17
  { setHarness },
18
18
  { Database }
19
19
  ] = await Promise.all([
20
- import("./embedding-backfill-dbvjbcmm.js"),
20
+ import("./embedding-backfill-9hbkfvnz.js"),
21
21
  import("./embedding-cache-mgyr73ef.js"),
22
22
  import("./storage-memory-07fx57k6.js"),
23
- import("./project-embedding-registry-nyq7z8y6.js"),
24
- import("./search-j7bakcwa.js"),
23
+ import("./project-embedding-registry-42th7k1z.js"),
24
+ import("./search-048v8y02.js"),
25
25
  import("./embedding-activity-g1dhes6g.js"),
26
26
  import("./harness-e4avh192.js"),
27
27
  import("./sqlite-mhjkerzq.js")
@@ -0,0 +1,18 @@
1
+ import {
2
+ isMarkerCandidateBasisCurrent2,
3
+ invalidateMarkerCandidateBasis2,
4
+ readMarkerCandidateBasis2,
5
+ prepareMarkerCandidateBasis2,
6
+ scanMarkerCandidateSnapshot2
7
+ } from "./server-9290a1mb.js";
8
+ import"./server-51779zs2.js";
9
+ import"./server-kb9nn0a0.js";
10
+ import"./server-t4k4qexw.js";
11
+ import"./server-pavzsdc6.js";
12
+ export {
13
+ invalidateMarkerCandidateBasis2 as invalidateMarkerCandidateBasis,
14
+ isMarkerCandidateBasisCurrent2 as isMarkerCandidateBasisCurrent,
15
+ prepareMarkerCandidateBasis2 as prepareMarkerCandidateBasis,
16
+ readMarkerCandidateBasis2 as readMarkerCandidateBasis,
17
+ scanMarkerCandidateSnapshot2 as scanMarkerCandidateSnapshot
18
+ };
@@ -0,0 +1,24 @@
1
+ // src/features/magic-context/compaction-marker-candidates-worker.ts
2
+ import { parentPort, workerData } from "node:worker_threads";
3
+ var port = parentPort;
4
+ if (!port)
5
+ throw new Error("marker candidate worker requires a parent port");
6
+ port.postMessage({ kind: "accepted" });
7
+ var [{ Database }, { scanMarkerCandidateSnapshot }] = await Promise.all([
8
+ import("./sqlite-mhjkerzq.js"),
9
+ import("./compaction-marker-candidates-1s21e2fz.js")
10
+ ]);
11
+ var input = workerData;
12
+ var db;
13
+ var reply;
14
+ try {
15
+ db = new Database(input.path, { readonly: true });
16
+ db.exec("PRAGMA busy_timeout=250");
17
+ reply = { kind: "candidates", snapshot: scanMarkerCandidateSnapshot(db, input.sessionId) };
18
+ } catch (error) {
19
+ reply = { kind: "error", error: error instanceof Error ? error.message : String(error) };
20
+ } finally {
21
+ db?.close();
22
+ }
23
+ port.postMessage(reply);
24
+ port.close();
@@ -151,6 +151,10 @@ import {
151
151
  readCoordinateGeneration,
152
152
  rebaseSessionCoordinatesAsync,
153
153
  HiddenCompletionRefusal,
154
+ getOpenCodeDbPath,
155
+ compareOpenCodeMessagesByCanonicalOrder,
156
+ prepareCompactionMarkerCandidates,
157
+ removeMcOwnedCompactionMarkers,
154
158
  getCompartmentEvents,
155
159
  USER_MEMORY_CANDIDATE_TTL_MS,
156
160
  insertUserMemoryCandidates,
@@ -198,9 +202,6 @@ import {
198
202
  promptSurfaceHashMaterial,
199
203
  createPromptSurfaceRuntime,
200
204
  createPromptSurfaceGuidanceEpochCache,
201
- getOpenCodeDbPath,
202
- compareOpenCodeMessagesByCanonicalOrder,
203
- removeMcOwnedCompactionMarkers,
204
205
  MARKER_SUMMARY_TEXT,
205
206
  markerUpdateDefinitelyDidNotCut,
206
207
  applyDeferredCompactionMarker,
@@ -262,7 +263,7 @@ import {
262
263
  startCompartmentAgent,
263
264
  setRecompStarting2,
264
265
  setRecompTerminal2
265
- } from "./server-7spkq1y6.js";
266
+ } from "./server-cxxjb33r.js";
266
267
  import {
267
268
  CANONICAL_DREAM_TASKS,
268
269
  DREAM_TASK_CAPABILITIES,
@@ -300,7 +301,7 @@ import {
300
301
  openDatabaseAsync,
301
302
  isDatabasePersisted,
302
303
  getDatabasePersistenceError
303
- } from "./server-7vkj6zhb.js";
304
+ } from "./server-9a6v0wth.js";
304
305
  import {
305
306
  setHomeProjectPermission,
306
307
  shouldSkipHomeProjectMemory,
@@ -316,7 +317,7 @@ import {
316
317
  storedPathBelongsToIdentity,
317
318
  beginBootQuietPeriod,
318
319
  scheduleAfterBootQuiet
319
- } from "./server-8xmq9h3f.js";
320
+ } from "./server-q6j5dasr.js";
320
321
  import {
321
322
  detectLatestTurnThinkingMismatch,
322
323
  isPrefixBoundThinkingModel,
@@ -421,6 +422,8 @@ import {
421
422
  setPendingCompactionMarkerState,
422
423
  replacePendingCompactionMarkerStateIf,
423
424
  clearPendingCompactionMarkerStateIf,
425
+ getPendingPiCompactionMarkerState,
426
+ clearPendingPiCompactionMarkerStateIf,
424
427
  setSessionWorkMetrics,
425
428
  getObservedEpochFloor,
426
429
  resolveEpochFloorForPass,
@@ -492,7 +495,7 @@ import {
492
495
  readRawSessionMessageById2,
493
496
  readSessionChunk2,
494
497
  readRawSessionSeedTail2
495
- } from "./server-c7n2ftng.js";
498
+ } from "./server-4n2tknpc.js";
496
499
  import {
497
500
  textMentionsRecentCommit,
498
501
  hasMeaningfulUserText2,
@@ -531,7 +534,7 @@ import {
531
534
  } from "./server-2htmbqbv.js";
532
535
  import {
533
536
  deleteChunkEmbedBackoffForSession
534
- } from "./server-s2st631p.js";
537
+ } from "./server-8wcf79fe.js";
535
538
  import {
536
539
  registerOwnRpcServerInstance,
537
540
  rpcPortDir,
@@ -552,12 +555,12 @@ import {
552
555
  markLkgRecoveryDirty,
553
556
  advanceSessionActivity,
554
557
  backfillSessionActivity,
555
- getLastIndexedOrdinal,
556
- getMessageIndexReconciliationStartOrdinal,
557
- isMessageIndexReconciledThrough,
558
- indexMessagesAfterOrdinal,
559
- sweepOrphanedOpenCodeMessageIndexes
560
- } from "./server-bgzy0phk.js";
558
+ getLastIndexedOrdinal2,
559
+ getMessageIndexReconciliationStartOrdinal2,
560
+ isMessageIndexReconciledThrough2,
561
+ indexMessagesAfterOrdinal2,
562
+ sweepOrphanedOpenCodeMessageIndexes2
563
+ } from "./server-3bc6k4k4.js";
561
564
  import {
562
565
  stableStringify,
563
566
  getTemporalDecisions,
@@ -656,13 +659,14 @@ import {
656
659
  adoptNullOwnerToolTag2,
657
660
  getCandidateToolOwners2,
658
661
  pickNearestPriorOwner2
659
- } from "./server-4c7jt8gq.js";
662
+ } from "./server-pcygfdbs.js";
663
+ import"./server-51779zs2.js";
660
664
  import {
661
665
  isRawCompactionSummaryInfo2,
662
666
  extractInMemoryMessageViews2,
663
667
  buildInMemoryTailRawMessages2,
664
668
  runSessionWarmupWorker
665
- } from "./server-7h861yms.js";
669
+ } from "./server-3dqjhchy.js";
666
670
  import {
667
671
  resolveOpenCodeDbPath,
668
672
  assertOpenCodeStoreGeneration,
@@ -696,7 +700,7 @@ import {
696
700
  resolveStoredPathWorkspaceIdentity,
697
701
  storedPathBelongsToWorkspace,
698
702
  computeWorkspaceEpochFingerprint
699
- } from "./server-6tcrjfw8.js";
703
+ } from "./server-8pqnnmf9.js";
700
704
  import {
701
705
  GIT_SWEEP_LEASE_RENEWAL_MS,
702
706
  acquireGitSweepLease,
@@ -723,7 +727,7 @@ import {
723
727
  drainCommitBacklogForProject2,
724
728
  embedSessionCompartmentChunks2,
725
729
  getEmbeddingCoverageStatus2
726
- } from "./server-1fszbabv.js";
730
+ } from "./server-cjz51jm2.js";
727
731
  import"./server-fb3zxn06.js";
728
732
  import {
729
733
  SESSION_NOTE_CONDITION_ERROR,
@@ -767,7 +771,7 @@ import {
767
771
  readGitFileChangeTimesSince,
768
772
  verificationFileExists,
769
773
  normalizeVerificationFiles
770
- } from "./server-zbxjj2mz.js";
774
+ } from "./server-rygvffsf.js";
771
775
  import {
772
776
  deriveTriggerBudget2,
773
777
  deriveHistorianChunkTokens2,
@@ -775,6 +779,7 @@ import {
775
779
  resolveHistorianProducerLimits2,
776
780
  resolveHistorianContextLimit2
777
781
  } from "./server-t528t8qm.js";
782
+ import"./server-9290a1mb.js";
778
783
  import {
779
784
  isEmbeddingHostBusy2
780
785
  } from "./server-qt1qqasc.js";
@@ -788,7 +793,7 @@ import {
788
793
  } from "./server-ras2sxnc.js";
789
794
  import {
790
795
  cosineSimilarity
791
- } from "./server-kh958yj8.js";
796
+ } from "./server-5zrpr764.js";
792
797
  import {
793
798
  computeCueContentHash,
794
799
  hasMuralCueColumns,
@@ -845,7 +850,7 @@ import {
845
850
  resolveMemoriesByIdsForSearch2,
846
851
  unifiedSearch2,
847
852
  formatSearchResults2
848
- } from "./server-mqvtz7wz.js";
853
+ } from "./server-hetyb88z.js";
849
854
  import {
850
855
  resolvePromptContext2
851
856
  } from "./server-fmsr7v69.js";
@@ -2774,7 +2779,7 @@ function forgetCachedPrefix(sessionId) {
2774
2779
  clearInjectionCache(sessionId);
2775
2780
  resetPrefixTrimFallbackState(sessionId);
2776
2781
  }
2777
- function dropCompartmentsAfter(db, sessionId, anchor, holderId) {
2782
+ function dropCompartmentsAfter(db, sessionId, anchor, holderId, activeBranch = false, onRetire) {
2778
2783
  db.exec("BEGIN IMMEDIATE");
2779
2784
  let finished = false;
2780
2785
  try {
@@ -2783,12 +2788,19 @@ function dropCompartmentsAfter(db, sessionId, anchor, holderId) {
2783
2788
  finished = true;
2784
2789
  return null;
2785
2790
  }
2786
- const dropped = db.prepare("SELECT id, sequence FROM compartments WHERE session_id = ? AND sequence > ? ORDER BY sequence").all(sessionId, anchor.sequence);
2791
+ const dropped = db.prepare("SELECT id, sequence FROM compartments WHERE session_id = ? AND sequence > ? ORDER BY sequence").all(sessionId, anchor?.sequence ?? -1);
2792
+ onRetire?.();
2787
2793
  const deleteEmbeddings = db.prepare("DELETE FROM compartment_chunk_embeddings WHERE compartment_id = ?");
2788
2794
  for (const row of dropped)
2789
2795
  deleteEmbeddings.run(row.id);
2790
- db.prepare("DELETE FROM compartments WHERE session_id = ? AND sequence > ?").run(sessionId, anchor.sequence);
2791
- db.prepare("DELETE FROM compression_depth WHERE session_id = ? AND message_ordinal > ?").run(sessionId, anchor.endMessage);
2796
+ db.prepare("DELETE FROM compartments WHERE session_id = ? AND sequence > ?").run(sessionId, anchor?.sequence ?? -1);
2797
+ db.prepare("DELETE FROM compression_depth WHERE session_id = ? AND message_ordinal > ?").run(sessionId, anchor?.endMessage ?? 0);
2798
+ if (activeBranch) {
2799
+ db.prepare("UPDATE session_meta SET prior_boundary_ordinal = ? WHERE session_id = ?").run((anchor?.endMessage ?? 0) + 1, sessionId);
2800
+ const marker = getPendingPiCompactionMarkerState(db, sessionId);
2801
+ if (marker)
2802
+ clearPendingPiCompactionMarkerStateIf(db, sessionId, marker);
2803
+ }
2792
2804
  deleteChunkEmbedBackoffForSession(db, sessionId);
2793
2805
  queueM0Mutation(db, { sessionId, mutationType: "recomp_boundary_change" });
2794
2806
  clearCachedM0M1(db, sessionId);
@@ -2804,24 +2816,38 @@ function dropCompartmentsAfter(db, sessionId, anchor, holderId) {
2804
2816
  }
2805
2817
  }
2806
2818
  function repairMissingHistoryBoundary(args) {
2807
- const { db, sessionId, isInHostStore } = args;
2808
- const compartments = getCompartments(db, sessionId);
2819
+ const { db, sessionId, isInHostStore, scope = "store" } = args;
2820
+ const compartments = scope === "active-branch" ? db.prepare("SELECT sequence, COALESCE(end_message_id, '') AS endMessageId FROM compartments WHERE session_id = ? ORDER BY sequence").all(sessionId) : getCompartments(db, sessionId);
2809
2821
  let latestIndex = compartments.length - 1;
2810
2822
  while (latestIndex >= 0 && !compartments[latestIndex]?.endMessageId)
2811
2823
  latestIndex -= 1;
2812
2824
  if (latestIndex < 0)
2813
2825
  return { kind: "intact" };
2826
+ if (scope === "active-branch") {
2827
+ for (let index = 0;index <= latestIndex; index += 1) {
2828
+ const endId = compartments[index]?.endMessageId;
2829
+ if (!endId)
2830
+ continue;
2831
+ const present = isInHostStore(endId);
2832
+ if (present === null)
2833
+ return { kind: "unknown" };
2834
+ if (!present) {
2835
+ latestIndex = index;
2836
+ break;
2837
+ }
2838
+ }
2839
+ }
2814
2840
  const latestEnd = compartments[latestIndex].endMessageId;
2815
2841
  const latestPresent = isInHostStore(latestEnd);
2816
2842
  if (latestPresent === null)
2817
2843
  return { kind: "unknown" };
2818
2844
  if (!latestPresent) {
2819
2845
  const missing = latestEnd;
2820
- const problem = `newest compartment end ${latestEnd} is not in the host store`;
2846
+ const problem = `compartment end ${latestEnd} is not in ${scope === "active-branch" ? "the active host branch" : "the host store"}`;
2821
2847
  const anchor = findAnchor(compartments, latestIndex, isInHostStore);
2822
2848
  if (anchor === "unknown")
2823
2849
  return { kind: "unknown" };
2824
- if (anchor === null) {
2850
+ if (anchor === null && scope === "store") {
2825
2851
  sessionLog2(sessionId, `history boundary unresolved: ${problem} and no older compartment end is in the host store; nothing to re-anchor on`);
2826
2852
  return { kind: "unresolved", reason: "no-anchor", missingEndMessageId: missing };
2827
2853
  }
@@ -2833,8 +2859,15 @@ function repairMissingHistoryBoundary(args) {
2833
2859
  return { kind: "unresolved", reason: "busy", missingEndMessageId: missing };
2834
2860
  }
2835
2861
  let dropped;
2862
+ let anchorForDrop = anchor;
2836
2863
  try {
2837
- dropped = dropCompartmentsAfter(db, sessionId, anchor, holderId);
2864
+ if (scope === "active-branch" && anchor) {
2865
+ const row = db.prepare("SELECT end_message AS endMessage FROM compartments WHERE session_id = ? AND sequence = ?").get(sessionId, anchor.sequence);
2866
+ if (!row)
2867
+ return { kind: "unresolved", reason: "busy", missingEndMessageId: missing };
2868
+ anchorForDrop = { ...anchor, endMessage: row.endMessage };
2869
+ }
2870
+ dropped = dropCompartmentsAfter(db, sessionId, anchorForDrop, holderId, scope === "active-branch", () => args.onRetire?.(compartments.slice(latestIndex), anchor));
2838
2871
  } finally {
2839
2872
  releaseCompartmentLeaseBestEffort(db, sessionId, holderId);
2840
2873
  }
@@ -2844,14 +2877,16 @@ function repairMissingHistoryBoundary(args) {
2844
2877
  invalidateAutoEmbedSession(sessionId);
2845
2878
  forgetCachedPrefix(sessionId);
2846
2879
  const range = dropped.length === 0 ? "none" : `${dropped[0]}-${dropped[dropped.length - 1]} (${dropped.length})`;
2847
- sessionLog2(sessionId, `history boundary repair: ${problem}; re-anchored on compartment ${anchor.sequence} ending at ${anchor.endMessageId} (ordinal ${anchor.endMessage}); removed compartments ${range} for the historian to rebuild; the cached prefix is rebuilt on this pass`);
2880
+ sessionLog2(sessionId, `history boundary repair: ${problem}; re-anchored on ${anchorForDrop ? `compartment ${anchorForDrop.sequence} ending at ${anchorForDrop.endMessageId} (ordinal ${anchorForDrop.endMessage})` : "the start of history"}; removed compartments ${range} for the historian to rebuild; the cached prefix is rebuilt on this pass`);
2848
2881
  return {
2849
2882
  kind: "repaired",
2850
2883
  missingEndMessageId: missing,
2851
- anchorEndMessageId: anchor.endMessageId,
2884
+ anchorEndMessageId: anchor?.endMessageId ?? "",
2852
2885
  droppedSequences: dropped
2853
2886
  };
2854
2887
  }
2888
+ if (scope === "active-branch")
2889
+ return { kind: "intact" };
2855
2890
  const baseline = readBaseline(db, sessionId);
2856
2891
  if (!baseline.hasCachedM0 || baseline.boundary === null || baseline.boundary === latestEnd) {
2857
2892
  return { kind: "intact" };
@@ -2971,15 +3006,15 @@ async function reconcileSessionIndex(db, sessionId, readMessages) {
2971
3006
  try {
2972
3007
  const fullReader = typeof readMessages === "function" ? readMessages : null;
2973
3008
  const finalWatermark = readMessages.getCount ? readMessages.getCount(sessionId) : (fallbackSnapshot = fullReader?.(sessionId) ?? []).length;
2974
- let cursor = getMessageIndexReconciliationStartOrdinal(db, sessionId);
3009
+ let cursor = getMessageIndexReconciliationStartOrdinal2(db, sessionId);
2975
3010
  let after;
2976
3011
  while (cursor < finalWatermark) {
2977
3012
  const pageEnd = Math.min(finalWatermark, cursor + RECONCILIATION_BATCH_SIZE);
2978
3013
  const messages = readMessages.readPage ? readMessages.readPage(sessionId, cursor, RECONCILIATION_BATCH_SIZE, finalWatermark, after) : (fallbackSnapshot ?? []).filter((message) => message.ordinal > cursor && message.ordinal <= pageEnd);
2979
3014
  const retainedMessages = fallbackSnapshot ?? messages;
2980
3015
  heapHolder.activeReconcilerBuffers.set(sessionId, retainedMessages);
2981
- withSqliteBackgroundWriter2(() => indexMessagesAfterOrdinal(db, sessionId, messages, cursor, pageEnd));
2982
- const nextCursor = getMessageIndexReconciliationStartOrdinal(db, sessionId);
3016
+ withSqliteBackgroundWriter2(() => indexMessagesAfterOrdinal2(db, sessionId, messages, cursor, pageEnd));
3017
+ const nextCursor = getMessageIndexReconciliationStartOrdinal2(db, sessionId);
2983
3018
  if (nextCursor <= cursor)
2984
3019
  break;
2985
3020
  cursor = nextCursor;
@@ -2989,7 +3024,7 @@ async function reconcileSessionIndex(db, sessionId, readMessages) {
2989
3024
  await yieldToEventLoop();
2990
3025
  }
2991
3026
  }
2992
- if (isMessageIndexReconciledThrough(db, sessionId, finalWatermark)) {
3027
+ if (isMessageIndexReconciledThrough2(db, sessionId, finalWatermark)) {
2993
3028
  heapHolder.reconciledSessions.add(sessionId);
2994
3029
  }
2995
3030
  } finally {
@@ -3022,6 +3057,32 @@ function scheduleReconciliation(db, sessionId, readMessages) {
3022
3057
  });
3023
3058
  });
3024
3059
  }
3060
+ async function sweepOrphanedOpenCodeMessageIndexesOffThread(db, openSource, options = {}) {
3061
+ const path = getSqliteDatabasePath2(db);
3062
+ if (!path || getHarness2() !== "opencode")
3063
+ return sweepOrphanedOpenCodeMessageIndexes2(db, openSource, options);
3064
+ let source = null;
3065
+ let sourcePath = null;
3066
+ try {
3067
+ source = openSource();
3068
+ if (source)
3069
+ sourcePath = getSqliteDatabasePath2(source);
3070
+ } catch {} finally {
3071
+ if (sourcePath)
3072
+ source?.close();
3073
+ }
3074
+ if (!sourcePath)
3075
+ return sweepOrphanedOpenCodeMessageIndexes2(db, () => source, options);
3076
+ const reply = await runSessionWarmupWorker({
3077
+ path,
3078
+ sessionId: "",
3079
+ harness: getHarness2(),
3080
+ orphanSweep: { sourcePath, options }
3081
+ }, {});
3082
+ if (!("orphanSweep" in reply))
3083
+ throw new Error("message history orphan sweep worker failed");
3084
+ return reply.orphanSweep;
3085
+ }
3025
3086
  function getMessageIndexQueueHeapStats() {
3026
3087
  return {
3027
3088
  queueLength: heapHolder.reconciliationScheduledSessions.size + heapHolder.incrementalTimers.size + heapHolder.pendingIncrementalKeys.size,
@@ -8629,6 +8690,9 @@ function applyRustModeDeferredCompactionMarker(args) {
8629
8690
  const outcome = (args.applyDeferred ?? applyDeferredCompactionMarker)(args.db, args.sessionId, pending, args.sessionDirectory, trustedBoundary);
8630
8691
  args.afterApply?.(outcome);
8631
8692
  switch (outcome.kind) {
8693
+ case "deferred":
8694
+ sessionLog2(args.sessionId, "rust compaction-marker drain: candidate preparation deferred; pending target retained");
8695
+ break;
8632
8696
  case "applied":
8633
8697
  case "already-current":
8634
8698
  case "stale-skip":
@@ -9839,9 +9903,15 @@ async function runPostTransformPhase(args) {
9839
9903
  sessionLog2(args.sessionId, `compaction-marker drain: refusing ordinal ${pending.ordinal} because prefix trim through ${args.pendingCompartmentInjection?.compartmentEndMessageId ?? "<none>"} was not proven; preserving deferred history refresh signal`);
9840
9904
  } else {
9841
9905
  const tMarkerDrain = performance.now();
9842
- const outcome = (args.compactionMarkerStrategy ?? defaultCompactionMarkerStrategy).applyDeferred(args.db, args.sessionId, pending, args.sessionDirectory);
9906
+ const strategy = args.compactionMarkerStrategy ?? defaultCompactionMarkerStrategy;
9907
+ const candidatesReady = strategy.applyDeferred !== applyDeferredCompactionMarker || await prepareCompactionMarkerCandidates(args.sessionId);
9908
+ const outcome = candidatesReady ? strategy.applyDeferred(args.db, args.sessionId, pending, args.sessionDirectory) : { kind: "deferred", reason: "candidate-preparation" };
9843
9909
  logTransformTiming(args.sessionId, "pp.markerDrain", tMarkerDrain, `outcome=${outcome.kind}`);
9844
9910
  switch (outcome.kind) {
9911
+ case "deferred":
9912
+ suppressV12HistoryDrain = true;
9913
+ sessionLog2(args.sessionId, "compaction-marker drain: candidate preparation deferred; preserving deferred history refresh signal");
9914
+ break;
9845
9915
  case "applied":
9846
9916
  case "already-current":
9847
9917
  case "stale-skip":
@@ -16123,7 +16193,8 @@ function createRustModeTransform(deps, options) {
16123
16193
  }
16124
16194
  pendingWireCache.nativeOutput = moduleMessages;
16125
16195
  if (!replayedFrozenRepresentation) {
16126
- if (materializedBoundary && !deps.compactionOff) {
16196
+ if ((materializedBoundary || getPendingCompactionMarkerState(deps.db, sessionId) !== null) && !deps.compactionOff) {
16197
+ await prepareCompactionMarkerCandidates(sessionId);
16127
16198
  try {
16128
16199
  await withAsyncPrivilegedWriter2(deps.db, () => {
16129
16200
  return;
@@ -19530,7 +19601,7 @@ function getAsyncModule() {
19530
19601
  await beforeModuleLoad();
19531
19602
  const [{ default: singlefileAsyncifyVariant }, { newQuickJSAsyncWASMModuleFromVariant }] = await importPluginModule(() => Promise.all([
19532
19603
  import("./index-6e4mwffh.js").then((m)=>__toESM(m.default,1)),
19533
- import("./index-69vas84q.js")
19604
+ import("./index-e6xnpach.js")
19534
19605
  ]));
19535
19606
  const module = await newQuickJSAsyncWASMModuleFromVariant(singlefileAsyncifyVariant);
19536
19607
  return module;
@@ -21591,8 +21662,8 @@ function registerRpcHandlers(rpcServer, args) {
21591
21662
  const db = readDatabase();
21592
21663
  if (!db)
21593
21664
  return { ok: false, error: "db unavailable" };
21594
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-5xy7w136.js"));
21595
- const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-f6v698r5.js"));
21665
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-v168jwgg.js"));
21666
+ const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-a4h2azxa.js"));
21596
21667
  log2(`[rpc] recomp requested for session ${sessionId}`);
21597
21668
  if (!args.client && !args.hiddenCompletionExecutor) {
21598
21669
  return {
@@ -21661,7 +21732,7 @@ function registerRpcHandlers(rpcServer, args) {
21661
21732
  const db = readDatabase();
21662
21733
  if (!db)
21663
21734
  return { ok: false, error: "db unavailable" };
21664
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-yem5422s.js"));
21735
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-zcyf8ymw.js"));
21665
21736
  const model = liveSessionState.liveModelBySession.get(sessionId);
21666
21737
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
21667
21738
  const ctx = {
@@ -33659,7 +33730,7 @@ async function runMessageHistoryMaintenance(db) {
33659
33730
  log2(`[message-index] pending Rust session cleanup: cleared=${rustCleanup.cleared} failed=${rustCleanup.failedSessionIds.length}`);
33660
33731
  }
33661
33732
  }
33662
- const sweep = sweepOrphanedOpenCodeMessageIndexes(db, openOpenCodeDb);
33733
+ const sweep = await sweepOrphanedOpenCodeMessageIndexesOffThread(db, openOpenCodeDb);
33663
33734
  if (sweep.reason)
33664
33735
  log2(`[message-index] orphan sweep parked: ${sweep.reason}`);
33665
33736
  if (sweep.deleted > 0) {
@@ -48429,7 +48500,7 @@ function singleLine(value) {
48429
48500
  // src/tools/ctx-note/tools.ts
48430
48501
  function captureAnchorOrdinal(db, sessionId) {
48431
48502
  try {
48432
- const ordinal = getLastIndexedOrdinal(db, sessionId);
48503
+ const ordinal = getLastIndexedOrdinal2(db, sessionId);
48433
48504
  return ordinal > 0 ? ordinal : null;
48434
48505
  } catch {
48435
48506
  return null;
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./server-kh958yj8.js";
4
- import"./server-1fszbabv.js";
5
- import"./server-s2st631p.js";
3
+ } from "./server-5zrpr764.js";
4
+ import"./server-cjz51jm2.js";
5
+ import"./server-8wcf79fe.js";
6
6
  import"./server-4dhv7mqz.js";
7
7
  import"./server-qt1qqasc.js";
8
8
  import"./server-ras2sxnc.js";
9
9
  import"./server-hb6xhh9q.js";
10
- import"./server-8xmq9h3f.js";
10
+ import"./server-q6j5dasr.js";
11
11
  import"./server-2htmbqbv.js";
12
12
  import"./server-cw6521wn.js";
13
- import"./server-kzns2hbz.js";
14
13
  import"./server-3t0q2cqx.js";
15
14
  import"./server-kb9nn0a0.js";
15
+ import"./server-kzns2hbz.js";
16
16
  import"./server-t4k4qexw.js";
17
17
  import"./server-pavzsdc6.js";
18
18
  export {