@cortexkit/opencode-magic-context 0.49.87 → 0.49.90
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.
- package/dist/{announcement-fnyxaahs.js → announcement-4ynkaf0d.js} +2 -2
- package/dist/auto-search-worker.js +3 -3
- package/dist/chunk-embedding-write-worker.js +5 -5
- package/dist/{context-gnk68pyy.js → context-cdds0gjj.js} +219 -41
- package/dist/{derive-budgets-90869322.js → derive-budgets-hzzq71rm.js} +2 -2
- package/dist/{embedding-backfill-9khxv6a9.js → embedding-backfill-qjkaee9s.js} +6 -6
- package/dist/embedding-worker.js +2 -2
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp-carry.d.ts +4 -0
- package/dist/hooks/magic-context/compartment-runner-recomp-carry.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts +8 -2
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +2 -0
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -5
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/{index-watde7a1.js → index-2pdgy88n.js} +3 -3
- package/dist/{index-c1s40xmj.js → index-39rzef89.js} +7 -5
- package/dist/{index-c5tmzym6.js → index-5df2fw5b.js} +108 -13
- package/dist/{index-7svecf3m.js → index-5pgyqgmx.js} +1 -1
- package/dist/{index-k50xhjw1.js → index-60x5d68t.js} +1 -1
- package/dist/{index-jka4y6mv.js → index-61knrt52.js} +1 -1
- package/dist/{index-74sh122g.js → index-9d3qgwq0.js} +1 -1
- package/dist/{index-2kf73btc.js → index-cr483vx6.js} +1 -1
- package/dist/{index-5nmqgvz2.js → index-dk3hy2a2.js} +6 -6
- package/dist/{index-awyqqnd8.js → index-g0mb2kb4.js} +6 -6
- package/dist/{index-kmrv1fw3.js → index-h9hybzr5.js} +2 -2
- package/dist/{index-vyfrgwhk.js → index-jzfsnbmm.js} +2 -2
- package/dist/{index-rvf1726x.js → index-mrjat4eq.js} +75 -12
- package/dist/{index-b364vr04.js → index-n1ty0vd3.js} +22 -22
- package/dist/{index-csztadkj.js → index-q7msfgwz.js} +272 -101
- package/dist/{index-pmcvg3k1.js → index-qfcjrnpe.js} +6 -5
- package/dist/{index-3dtzyred.js → index-r4y0dczp.js} +1 -1
- package/dist/{index-bxrfq3mv.js → index-tt0vs4x5.js} +1 -1
- package/dist/{index-3x4qvp29.js → index-w51n3576.js} +1 -1
- package/dist/{index-3jgzd7nz.js → index-wmb2mcdw.js} +3 -3
- package/dist/{index-zmqx48vt.js → index-xsqw8kbd.js} +1 -1
- package/dist/{index-hdyfvdag.js → index-zxhev8ze.js} +1 -1
- package/dist/index.js +26 -26
- package/dist/migration-worker.js +4 -4
- package/dist/{project-embedding-registry-8t0gwf59.js → project-embedding-registry-m3fp1pa4.js} +5 -5
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{recomp-orchestrator-2ztmtxt2.js → recomp-orchestrator-dgyb394j.js} +14 -14
- package/dist/{render-d6q6h9hy.js → render-d014e603.js} +6 -6
- package/dist/{search-d5aajhs3.js → search-9gceftb9.js} +11 -11
- package/dist/{search-archive-g96jn6p0.js → search-archive-gybn6q7s.js} +2 -2
- package/dist/shared/recomp-outcome.d.ts +4 -0
- package/dist/shared/recomp-outcome.d.ts.map +1 -0
- package/dist/shared/storage-permissions.d.ts +16 -2
- package/dist/shared/storage-permissions.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +4 -1
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-b2yjw8by.js → transform-postprocess-phase-34k1zwsy.js} +15 -15
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +5 -5
- package/dist/v2/{context-s86114yy.js → context-satgm752.js} +218 -41
- package/dist/v2/{derive-budgets-ecjy1aqh.js → derive-budgets-hr4qqrnv.js} +3 -3
- package/dist/v2/{embedding-backfill-tazkbpyg.js → embedding-backfill-0ar1bm97.js} +6 -6
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/fold/native-replay.d.ts +11 -2
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/revert-message-state.d.ts +19 -1
- package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
- package/dist/v2/migration-worker.js +4 -4
- package/dist/v2/{project-embedding-registry-ah3gsg48.js → project-embedding-registry-gx2waee8.js} +5 -5
- package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
- package/dist/v2/{recomp-orchestrator-kc62xgb9.js → recomp-orchestrator-wq7gbkqa.js} +15 -15
- package/dist/v2/{render-j05per51.js → render-2dan17xc.js} +6 -6
- package/dist/v2/{search-archive-b4ptw02k.js → search-archive-89hdy0a2.js} +2 -2
- package/dist/v2/{search-kg31ad2s.js → search-nyqykx7q.js} +10 -10
- package/dist/v2/{server-ct0gs8fc.js → server-09h2vyvs.js} +2 -2
- package/dist/v2/{server-r2es6zt7.js → server-0tv6kytx.js} +108 -13
- package/dist/v2/{server-rz4snd3x.js → server-1rrmxhd1.js} +1 -1
- package/dist/v2/{server-xa8fefhw.js → server-96nm9vk4.js} +1 -1
- package/dist/v2/{server-2p0qayr1.js → server-a85j3kam.js} +1 -1
- package/dist/v2/{server-gwhj0362.js → server-add0j5n3.js} +7 -5
- package/dist/v2/{server-ff5wcfy4.js → server-b0a9h3ds.js} +2 -2
- package/dist/v2/{server-xn7zqs4j.js → server-dgjqvpgd.js} +3 -3
- package/dist/v2/{server-2r9btf0g.js → server-dtcwkdqj.js} +274 -103
- package/dist/v2/{server-axdmkvd5.js → server-f7tzvmzs.js} +1 -1
- package/dist/v2/{server-yh2z4gg2.js → server-fb5hvvfc.js} +75 -12
- package/dist/v2/{server-pbp58w5x.js → server-fn4ky6mn.js} +1 -1
- package/dist/v2/{server-3p6b0qya.js → server-gqkdfdvw.js} +1 -1
- package/dist/v2/{server-cwtehwbb.js → server-j4jjtdc5.js} +1 -1
- package/dist/v2/{server-b93f0bqh.js → server-pjk9spbf.js} +1 -1
- package/dist/v2/{server-gqrw0br5.js → server-ta4h0fch.js} +6 -6
- package/dist/v2/{server-e2k9mt86.js → server-tj65pgvg.js} +1 -1
- package/dist/v2/{server-6vnbz81n.js → server-vy0beygw.js} +1 -1
- package/dist/v2/server.js +5 -5
- package/dist/v2/{v2-archive-reader-2ayz16s4.js → v2-archive-reader-gh1jghf7.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-e20sjbdz.js → wrapup-orchestrator-2h7ayss9.js} +15 -15
- package/dist/{v2-archive-reader-x39mzvwn.js → v2-archive-reader-8158kyfd.js} +1 -1
- package/dist/{wrapup-orchestrator-h3s905vs.js → wrapup-orchestrator-ct59br0c.js} +15 -15
- package/package.json +1 -1
- package/src/shared/recomp-outcome.ts +8 -0
- package/src/shared/storage-permissions-startup.test.ts +296 -6
- package/src/shared/storage-permissions.ts +143 -18
- package/src/shared/user-facing-codes.ts +5 -2
- package/src/tui/dialogs/status-dialog.tsx +3 -0
- package/src/tui/slots/sidebar-content.tsx +6 -2
- package/src/tui-compiled/dialogs/status-dialog.tsx +12 -0
- package/src/tui-compiled/slots/sidebar-content.tsx +7 -2
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
readLastAnnouncedVersion2,
|
|
6
6
|
markAnnouncementSeen2,
|
|
7
7
|
shouldShowAnnouncement2
|
|
8
|
-
} from "./index-
|
|
9
|
-
import"./index-
|
|
8
|
+
} from "./index-cr483vx6.js";
|
|
9
|
+
import"./index-5df2fw5b.js";
|
|
10
10
|
import"./index-gqf8r04r.js";
|
|
11
11
|
import"./index-ywrz4wy2.js";
|
|
12
12
|
import"./index-pavzsdc6.js";
|
|
@@ -27,11 +27,11 @@ serveWorkerJobs(async (initial, port) => {
|
|
|
27
27
|
{ Database, registerSqliteDiagnosticSink },
|
|
28
28
|
{ log }
|
|
29
29
|
] = await Promise.all([
|
|
30
|
-
import("./embedding-backfill-
|
|
30
|
+
import("./embedding-backfill-qjkaee9s.js"),
|
|
31
31
|
import("./embedding-cache-zn4r1c31.js"),
|
|
32
32
|
import("./storage-memory-hhrvfw0x.js"),
|
|
33
|
-
import("./project-embedding-registry-
|
|
34
|
-
import("./search-
|
|
33
|
+
import("./project-embedding-registry-m3fp1pa4.js"),
|
|
34
|
+
import("./search-9gceftb9.js"),
|
|
35
35
|
import("./compartment-chunk-embedding-fey2bsyf.js"),
|
|
36
36
|
import("./embedding-activity-g1dhes6g.js"),
|
|
37
37
|
import("./harness-e4avh192.js"),
|
|
@@ -30,16 +30,16 @@ import {
|
|
|
30
30
|
acquireGitSweepLease,
|
|
31
31
|
renewGitSweepLease,
|
|
32
32
|
releaseGitSweepLease
|
|
33
|
-
} from "./index-
|
|
33
|
+
} from "./index-r4y0dczp.js";
|
|
34
34
|
import"./index-gqf8r04r.js";
|
|
35
|
-
import"./index-
|
|
36
|
-
import"./index-
|
|
35
|
+
import"./index-5df2fw5b.js";
|
|
36
|
+
import"./index-5pgyqgmx.js";
|
|
37
37
|
import {
|
|
38
38
|
LATEST_SUPPORTED_VERSION,
|
|
39
39
|
enforceSchemaFence
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-mrjat4eq.js";
|
|
41
41
|
import"./index-wh9fxds5.js";
|
|
42
|
-
import"./index-
|
|
42
|
+
import"./index-tt0vs4x5.js";
|
|
43
43
|
import"./index-m6dnydf8.js";
|
|
44
44
|
import"./index-fr0wbhdn.js";
|
|
45
45
|
import"./index-58e3y90n.js";
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
resolveOpenCodeProtectedTailBoundary,
|
|
45
45
|
nonNarrativeStoredGapRanges,
|
|
46
46
|
getActiveCompartmentRun
|
|
47
|
-
} from "./index-
|
|
47
|
+
} from "./index-q7msfgwz.js";
|
|
48
48
|
import"./index-sd3egckz.js";
|
|
49
49
|
import {
|
|
50
50
|
getHarness2
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
} from "./index-ywrz4wy2.js";
|
|
58
58
|
import"./index-z4p0ry94.js";
|
|
59
59
|
import"./index-gqf8r04r.js";
|
|
60
|
-
import"./index-
|
|
60
|
+
import"./index-5df2fw5b.js";
|
|
61
61
|
import {
|
|
62
62
|
isSaneLimit,
|
|
63
63
|
setOutputReserveConfig,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
deriveHistorianChunkTokens2,
|
|
69
69
|
resolveKnownHistorianContextLimit2,
|
|
70
70
|
resolveHistorianContextLimit2
|
|
71
|
-
} from "./index-
|
|
71
|
+
} from "./index-xsqw8kbd.js";
|
|
72
72
|
import"./index-6nqz8hsz.js";
|
|
73
73
|
import {
|
|
74
74
|
CANONICAL_DREAM_TASKS,
|
|
@@ -136,7 +136,7 @@ import {
|
|
|
136
136
|
applyJsonSchemaParameterDescriptions,
|
|
137
137
|
MagicContextRpcServer,
|
|
138
138
|
subagentTemperature
|
|
139
|
-
} from "./index-
|
|
139
|
+
} from "./index-n1ty0vd3.js";
|
|
140
140
|
import {
|
|
141
141
|
invalidateAutoEmbedSession,
|
|
142
142
|
clearEmbedSessionState
|
|
@@ -169,6 +169,7 @@ import {
|
|
|
169
169
|
releaseCompartmentLeaseBestEffort,
|
|
170
170
|
isCompartmentLeaseHeld,
|
|
171
171
|
queueM0Mutation,
|
|
172
|
+
getLastCompartmentEndMessageId,
|
|
172
173
|
clearRecompStaging,
|
|
173
174
|
getUncoveredCompartmentEndsThrough,
|
|
174
175
|
readServerFallbackUsage,
|
|
@@ -198,7 +199,7 @@ import {
|
|
|
198
199
|
getSlot,
|
|
199
200
|
dropSlot,
|
|
200
201
|
copySessionStateForClone
|
|
201
|
-
} from "./index-
|
|
202
|
+
} from "./index-h9hybzr5.js";
|
|
202
203
|
import"./index-chpzb6xy.js";
|
|
203
204
|
import {
|
|
204
205
|
stripPersistedAssistantText,
|
|
@@ -263,7 +264,7 @@ import {
|
|
|
263
264
|
setHomeProjectPermission,
|
|
264
265
|
resolveProjectIdentityForSession,
|
|
265
266
|
scheduleAfterBootQuiet
|
|
266
|
-
} from "./index-
|
|
267
|
+
} from "./index-5pgyqgmx.js";
|
|
267
268
|
import"./index-1zx87sdm.js";
|
|
268
269
|
import"./index-58e3y90n.js";
|
|
269
270
|
import"./index-x40zr813.js";
|
|
@@ -282,7 +283,7 @@ import {
|
|
|
282
283
|
} from "./index-2qsca7h7.js";
|
|
283
284
|
import {
|
|
284
285
|
scheduleClearAndReindex
|
|
285
|
-
} from "./index-
|
|
286
|
+
} from "./index-zxhev8ze.js";
|
|
286
287
|
import {
|
|
287
288
|
startBootDeadline,
|
|
288
289
|
getSchemaFenceRejection,
|
|
@@ -292,9 +293,9 @@ import {
|
|
|
292
293
|
openDatabaseAsync,
|
|
293
294
|
isDatabasePersisted,
|
|
294
295
|
getDatabasePersistenceError
|
|
295
|
-
} from "./index-
|
|
296
|
+
} from "./index-mrjat4eq.js";
|
|
296
297
|
import"./index-fr0wbhdn.js";
|
|
297
|
-
import"./index-
|
|
298
|
+
import"./index-tt0vs4x5.js";
|
|
298
299
|
import {
|
|
299
300
|
gaDatabasePath2,
|
|
300
301
|
RAW_MESSAGE_TYPES2,
|
|
@@ -302,7 +303,7 @@ import {
|
|
|
302
303
|
V2StoreReader2
|
|
303
304
|
} from "./index-1y4y98r1.js";
|
|
304
305
|
import"./index-fb3zxn06.js";
|
|
305
|
-
import"./index-
|
|
306
|
+
import"./index-61knrt52.js";
|
|
306
307
|
import {
|
|
307
308
|
resolveContextLimit,
|
|
308
309
|
resolveModelKey,
|
|
@@ -320,20 +321,20 @@ import {
|
|
|
320
321
|
servedHeadChanged,
|
|
321
322
|
noteHostCheckpointCommit,
|
|
322
323
|
isSyntheticHeadMessage2
|
|
323
|
-
} from "./index-
|
|
324
|
+
} from "./index-g0mb2kb4.js";
|
|
324
325
|
import"./index-832w615x.js";
|
|
325
326
|
import"./index-qt1qqasc.js";
|
|
326
327
|
import {
|
|
327
328
|
retainProjectEmbedding2
|
|
328
|
-
} from "./index-
|
|
329
|
-
import"./index-
|
|
329
|
+
} from "./index-2pdgy88n.js";
|
|
330
|
+
import"./index-r4y0dczp.js";
|
|
330
331
|
import"./index-qjwpqvnf.js";
|
|
331
|
-
import"./index-
|
|
332
|
+
import"./index-60x5d68t.js";
|
|
332
333
|
import {
|
|
333
334
|
renderUserFacingFailure,
|
|
334
335
|
userFacingFailureCode
|
|
335
|
-
} from "./index-
|
|
336
|
-
import"./index-
|
|
336
|
+
} from "./index-39rzef89.js";
|
|
337
|
+
import"./index-w51n3576.js";
|
|
337
338
|
import"./index-9emdjcb5.js";
|
|
338
339
|
import {
|
|
339
340
|
pushLiveNotification2,
|
|
@@ -342,9 +343,9 @@ import {
|
|
|
342
343
|
} from "./index-y14pawe1.js";
|
|
343
344
|
import"./index-e6ncz7a6.js";
|
|
344
345
|
import"./index-6zewd2n5.js";
|
|
345
|
-
import"./index-
|
|
346
|
-
import"./index-
|
|
347
|
-
import"./index-
|
|
346
|
+
import"./index-dk3hy2a2.js";
|
|
347
|
+
import"./index-qfcjrnpe.js";
|
|
348
|
+
import"./index-cr483vx6.js";
|
|
348
349
|
import {
|
|
349
350
|
detectConflicts
|
|
350
351
|
} from "./index-nxxzeq4y.js";
|
|
@@ -377,8 +378,8 @@ import {
|
|
|
377
378
|
import"./index-fmsr7v69.js";
|
|
378
379
|
import"./index-78t37mcq.js";
|
|
379
380
|
import"./index-52x68mj4.js";
|
|
380
|
-
import"./index-
|
|
381
|
-
import"./index-
|
|
381
|
+
import"./index-jzfsnbmm.js";
|
|
382
|
+
import"./index-9d3qgwq0.js";
|
|
382
383
|
import {
|
|
383
384
|
isDreamerRunnable,
|
|
384
385
|
isSmartNoteSurfaceAvailable,
|
|
@@ -494,6 +495,49 @@ function dropCompartmentsAfter(db, sessionId, anchor, holderId, activeBranch = f
|
|
|
494
495
|
}
|
|
495
496
|
function repairMissingHistoryBoundary(args) {
|
|
496
497
|
const { db, sessionId, isInHostStore, scope = "store" } = args;
|
|
498
|
+
const removed = args.removedByCommittedRevert;
|
|
499
|
+
if (removed) {
|
|
500
|
+
const firstRemoved = removed.values().next().value;
|
|
501
|
+
if (firstRemoved === undefined)
|
|
502
|
+
return { kind: "intact" };
|
|
503
|
+
const busy = {
|
|
504
|
+
kind: "unresolved",
|
|
505
|
+
reason: "busy",
|
|
506
|
+
missingEndMessageId: firstRemoved
|
|
507
|
+
};
|
|
508
|
+
const holderId = crypto.randomUUID();
|
|
509
|
+
if (getActiveCompartmentRun(sessionId) || !acquireCompartmentLease(db, sessionId, holderId))
|
|
510
|
+
return busy;
|
|
511
|
+
try {
|
|
512
|
+
const boundaries = readStoreBoundaries(db, sessionId);
|
|
513
|
+
const first = boundaries.findIndex(({ endMessageId }) => removed.has(endMessageId));
|
|
514
|
+
const affected = boundaries[first];
|
|
515
|
+
if (!affected)
|
|
516
|
+
return { kind: "intact" };
|
|
517
|
+
const previous = boundaries[first - 1];
|
|
518
|
+
let anchor = null;
|
|
519
|
+
if (previous) {
|
|
520
|
+
const row = db.prepare("SELECT end_message AS endMessage FROM compartments WHERE session_id = ? AND sequence = ?").get(sessionId, previous.sequence);
|
|
521
|
+
if (!row)
|
|
522
|
+
return busy;
|
|
523
|
+
anchor = { ...previous, endMessage: row.endMessage };
|
|
524
|
+
}
|
|
525
|
+
const dropped = dropCompartmentsAfter(db, sessionId, anchor, holderId, false, () => args.onRetire?.(boundaries.slice(first), anchor));
|
|
526
|
+
if (dropped === null)
|
|
527
|
+
return busy;
|
|
528
|
+
invalidateAutoEmbedSession(sessionId);
|
|
529
|
+
forgetCachedPrefix(sessionId);
|
|
530
|
+
sessionLog2(sessionId, `committed revert history repair: removed compartments ${dropped.join(",")} and cleared the cached history; removed boundary ${affected.endMessageId}`);
|
|
531
|
+
return {
|
|
532
|
+
kind: "repaired",
|
|
533
|
+
missingEndMessageId: affected.endMessageId,
|
|
534
|
+
anchorEndMessageId: anchor?.endMessageId ?? "",
|
|
535
|
+
droppedSequences: dropped
|
|
536
|
+
};
|
|
537
|
+
} finally {
|
|
538
|
+
releaseCompartmentLeaseBestEffort(db, sessionId, holderId);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
497
541
|
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) : readStoreBoundaries(db, sessionId);
|
|
498
542
|
let latestIndex = compartments.length - 1;
|
|
499
543
|
while (latestIndex >= 0 && !compartments[latestIndex]?.endMessageId)
|
|
@@ -2401,15 +2445,33 @@ class NativeFoldReplay {
|
|
|
2401
2445
|
this.options.log?.(sessionID, `v3 host fold: ${reason}`);
|
|
2402
2446
|
} catch {}
|
|
2403
2447
|
}
|
|
2448
|
+
historyCoverage(sessionID, reader) {
|
|
2449
|
+
if (!this.options.rendersHistory?.(sessionID))
|
|
2450
|
+
return;
|
|
2451
|
+
const db = this.storage.db;
|
|
2452
|
+
const cached = db.prepare("SELECT cached_m0_last_baseline_end_message_id AS id, cached_m0_bytes IS NOT NULL AS hasBytes FROM session_meta WHERE session_id=?").get(sessionID);
|
|
2453
|
+
const id = cached?.hasBytes ? cached.id : getLastCompartmentEndMessageId(db, sessionID);
|
|
2454
|
+
const after = id ? reader.sequenceForId(sessionID, id) : (reader.earliestSequence(sessionID) ?? 0) - 1;
|
|
2455
|
+
return after === undefined ? undefined : { id, after };
|
|
2456
|
+
}
|
|
2457
|
+
floorCovered(sessionID, floor, coverage, record) {
|
|
2458
|
+
if (!coverage || floor.kind === "start" || floor.kind === "host-checkpoint" && !record?.withoutRecentContext && this.options.servesHostCheckpoint?.(sessionID, floor.id) || floor.after <= coverage.after)
|
|
2459
|
+
return true;
|
|
2460
|
+
this.options.onUncoveredFloor?.(sessionID, floor, coverage);
|
|
2461
|
+
return false;
|
|
2462
|
+
}
|
|
2404
2463
|
async floorState(sessionID, reader, boundary, served, preferCapture = false) {
|
|
2464
|
+
const coverage = this.historyCoverage(sessionID, reader);
|
|
2405
2465
|
const retained = this.tail(sessionID)?.replay;
|
|
2406
2466
|
const controlsKnown = (replay) => replay.controls.every((control) => !control.after || reader.sequenceForId(sessionID, control.after) !== undefined);
|
|
2407
|
-
const memory = retained && validReplayState(retained) && controlsKnown(retained) && validFloor(reader, sessionID, retained.floor) ? retained : undefined;
|
|
2467
|
+
const memory = retained && validReplayState(retained) && controlsKnown(retained) && validFloor(reader, sessionID, retained.floor) && this.floorCovered(sessionID, retained.floor, coverage, retained) ? retained : undefined;
|
|
2408
2468
|
const cut = reader.latestCompaction(sessionID);
|
|
2409
2469
|
const saved = await this.readV3(sessionID);
|
|
2410
|
-
const durable = saved && saved.proof.sourceDigest === foldDigest(reader.hostIdentity()) && (!cut || saved.proof.admissionID === cut.id) && controlsKnown(saved.replay) && validFloor(reader, sessionID, saved.replay.floor) ? saved.replay : undefined;
|
|
2411
|
-
const
|
|
2412
|
-
const
|
|
2470
|
+
const durable = saved && saved.proof.sourceDigest === foldDigest(reader.hostIdentity()) && (!cut || saved.proof.admissionID === cut.id) && controlsKnown(saved.replay) && validFloor(reader, sessionID, saved.replay.floor) && this.floorCovered(sessionID, saved.replay.floor, coverage, saved.replay) ? saved.replay : undefined;
|
|
2471
|
+
const marker = importedFloor(reader, sessionID, cut?.seq);
|
|
2472
|
+
const imported = marker && this.floorCovered(sessionID, marker, coverage) ? marker : undefined;
|
|
2473
|
+
const capturedRecord = await this.readCapturedReplay(sessionID, reader);
|
|
2474
|
+
const captured = capturedRecord && this.floorCovered(sessionID, capturedRecord.floor, coverage, capturedRecord) ? capturedRecord : undefined;
|
|
2413
2475
|
const existing = preferCapture ? captured ?? memory ?? durable : memory ?? durable ?? captured;
|
|
2414
2476
|
if (preferCapture && !existing && !served)
|
|
2415
2477
|
return;
|
|
@@ -2716,6 +2778,8 @@ ${cached}
|
|
|
2716
2778
|
await this.retainReplay(sessionID, replay, this.tail(sessionID)?.model ?? "", cut.seq - 1);
|
|
2717
2779
|
return false;
|
|
2718
2780
|
}
|
|
2781
|
+
if (!this.floorCovered(sessionID, replay.floor, this.historyCoverage(sessionID, reader), replay))
|
|
2782
|
+
return false;
|
|
2719
2783
|
await this.retainReplay(sessionID, saved.replay, this.tail(sessionID)?.model ?? "", cut.seq - 1);
|
|
2720
2784
|
if (proof.historyDigest !== historyDigest(reader, sessionID, cut.seq - 1, saved.replay.floor.after)) {
|
|
2721
2785
|
this.staleHeads.add(sessionID);
|
|
@@ -2810,7 +2874,7 @@ ${cached}
|
|
|
2810
2874
|
return "legacy";
|
|
2811
2875
|
if (saved.proof.admissionID !== cut.id)
|
|
2812
2876
|
return "legacy";
|
|
2813
|
-
return saved.proof.sourceDigest === foldDigest(reader.hostIdentity()) && saved.proof.summaryDigest === foldDigest(cut.data.summary ?? "") && validFloor(reader, sessionID, saved.replay.floor) && saved.proof.historyDigest === historyDigest(reader, sessionID, cut.seq - 1, saved.replay.floor.after) ? "native" : undefined;
|
|
2877
|
+
return saved.proof.sourceDigest === foldDigest(reader.hostIdentity()) && saved.proof.summaryDigest === foldDigest(cut.data.summary ?? "") && validFloor(reader, sessionID, saved.replay.floor) && this.floorCovered(sessionID, saved.replay.floor, this.historyCoverage(sessionID, reader), saved.replay) && saved.proof.historyDigest === historyDigest(reader, sessionID, cut.seq - 1, saved.replay.floor.after) ? "native" : undefined;
|
|
2814
2878
|
}
|
|
2815
2879
|
if (!isLocalCheckpoint(cut) || cut.session_id !== sessionID)
|
|
2816
2880
|
return;
|
|
@@ -2977,7 +3041,7 @@ ${cached}
|
|
|
2977
3041
|
}
|
|
2978
3042
|
return [...grouped].map(([row, messages]) => this.record(row, messages));
|
|
2979
3043
|
}
|
|
2980
|
-
async capture(draft, native, boundary) {
|
|
3044
|
+
async capture(draft, native, boundary, restoredFirstRow) {
|
|
2981
3045
|
const release = this.storage.hold(draft.sessionID);
|
|
2982
3046
|
let replay;
|
|
2983
3047
|
let sourceSeq = -1;
|
|
@@ -2987,6 +3051,11 @@ ${cached}
|
|
|
2987
3051
|
try {
|
|
2988
3052
|
if (this.options.protocol === 3) {
|
|
2989
3053
|
replay = await this.floorState(draft.sessionID, reader, boundary, draft);
|
|
3054
|
+
if (!replay && restoredFirstRow) {
|
|
3055
|
+
const first = reader.page(draft.sessionID, { limit: 1 }).rows[0];
|
|
3056
|
+
if (first?.id === restoredFirstRow)
|
|
3057
|
+
replay = { floor: floorFor(first, "start"), controls: [] };
|
|
3058
|
+
}
|
|
2990
3059
|
if (!replay)
|
|
2991
3060
|
throw new NativeReplayUnavailable("No usable host replay boundary");
|
|
2992
3061
|
replay = { ...replay, blocked: false };
|
|
@@ -3054,7 +3123,7 @@ ${cached}
|
|
|
3054
3123
|
await this.saveCapturedReplay(draft.sessionID, replay, reader);
|
|
3055
3124
|
const saved = await this.readV3(draft.sessionID);
|
|
3056
3125
|
const cut = reader.latestCompaction(draft.sessionID);
|
|
3057
|
-
if (saved && !this.editedAdmissions.has(draft.sessionID) && cut?.id === saved.proof.admissionID && replay.floor.after > saved.replay.floor.after && boundary && this.servedBaseline(draft) === boundary.summary) {
|
|
3126
|
+
if (saved && !this.editedAdmissions.has(draft.sessionID) && cut?.id === saved.proof.admissionID && (replay.floor.after > saved.replay.floor.after || !this.floorCovered(draft.sessionID, saved.replay.floor, this.historyCoverage(draft.sessionID, reader), saved.replay)) && (boundary && this.servedBaseline(draft) === boundary.summary || replay.floor.kind === "start" && restoredFirstRow === replay.floor.id)) {
|
|
3058
3127
|
const value = {
|
|
3059
3128
|
...saved,
|
|
3060
3129
|
replay: {
|
|
@@ -3305,11 +3374,12 @@ ${cached}
|
|
|
3305
3374
|
}
|
|
3306
3375
|
const through = cut.seq - 1;
|
|
3307
3376
|
let metadata = this.metadata.get(sessionID);
|
|
3308
|
-
if (!metadata || (this.metadataThrough.get(sessionID) ?? -1) < through) {
|
|
3377
|
+
if (!metadata || (this.metadataThrough.get(sessionID) ?? -1) < through || this.options.protocol === 3 && this.options.rendersHistory?.(sessionID) && (this.metadataAfter.get(sessionID) ?? -1) > after) {
|
|
3309
3378
|
reader ??= this.openReader(sessionID);
|
|
3310
3379
|
metadata = reader.rowStampsThrough(sessionID, through, this.options.protocol === 3 ? after : undefined).filter(conversational);
|
|
3311
3380
|
this.metadata.set(sessionID, metadata);
|
|
3312
3381
|
this.metadataThrough.set(sessionID, through);
|
|
3382
|
+
this.metadataAfter.set(sessionID, this.options.protocol === 3 ? after : undefined);
|
|
3313
3383
|
}
|
|
3314
3384
|
const required = metadata.filter((row) => row.seq > after && row.seq <= through);
|
|
3315
3385
|
if (this.dirty.has(sessionID) || !tail || (this.loaded.get(sessionID) ?? -1) < through && !this.storage.admission(sessionID, cut.id) || !this.storage.containsRows(sessionID, required.map((row) => row.id))) {
|
|
@@ -6238,6 +6308,7 @@ var MAX_STAGED_SUFFIX_ROWS = 1e4;
|
|
|
6238
6308
|
class V2RevertMessageCleanup {
|
|
6239
6309
|
openStoreReader;
|
|
6240
6310
|
staged = new BoundedSessionMap(MAX_STAGED_REVERTS);
|
|
6311
|
+
pendingHistory = [];
|
|
6241
6312
|
constructor(openStoreReader) {
|
|
6242
6313
|
this.openStoreReader = openStoreReader;
|
|
6243
6314
|
}
|
|
@@ -6266,7 +6337,11 @@ class V2RevertMessageCleanup {
|
|
|
6266
6337
|
discardAllStageProofs() {
|
|
6267
6338
|
this.staged.clear();
|
|
6268
6339
|
}
|
|
6269
|
-
|
|
6340
|
+
forgetSession(sessionID) {
|
|
6341
|
+
this.discardStageProof(sessionID);
|
|
6342
|
+
this.pendingHistory = this.pendingHistory.filter((proof) => proof.sessionID !== sessionID);
|
|
6343
|
+
}
|
|
6344
|
+
pruneOnCommit(db, sessionID, to, retireHistory) {
|
|
6270
6345
|
const staged = this.staged.peek(sessionID);
|
|
6271
6346
|
this.discardStageProof(sessionID);
|
|
6272
6347
|
const noteSkippedCleanup = (reason) => {
|
|
@@ -6296,9 +6371,45 @@ class V2RevertMessageCleanup {
|
|
|
6296
6371
|
return noteSkippedCleanup("retained predecessor is not visible at commit");
|
|
6297
6372
|
if (!removed.size)
|
|
6298
6373
|
return noteSkippedCleanup("all staged rows still exist");
|
|
6374
|
+
if (retireHistory) {
|
|
6375
|
+
if (this.pendingHistory.length === MAX_STAGED_REVERTS)
|
|
6376
|
+
this.pendingHistory.shift();
|
|
6377
|
+
this.pendingHistory.push({ sessionID, host: staged.host, removed });
|
|
6378
|
+
}
|
|
6299
6379
|
pruneMessages(db, sessionID, removed);
|
|
6300
6380
|
return true;
|
|
6301
6381
|
}
|
|
6382
|
+
retireProvenHistory(db, sessionID, reader) {
|
|
6383
|
+
const ownProofs = this.pendingHistory.filter((proof) => proof.sessionID === sessionID);
|
|
6384
|
+
if (ownProofs.length === 0)
|
|
6385
|
+
return;
|
|
6386
|
+
const source = reader ?? this.openStoreReader();
|
|
6387
|
+
try {
|
|
6388
|
+
const host = source.hostIdentity();
|
|
6389
|
+
const current = ownProofs.filter((proof) => proof.host === host);
|
|
6390
|
+
this.pendingHistory = this.pendingHistory.filter((proof) => proof.sessionID !== sessionID || proof.host === host);
|
|
6391
|
+
if (current.length === 0)
|
|
6392
|
+
return;
|
|
6393
|
+
const removed = new Set;
|
|
6394
|
+
for (const proof of current)
|
|
6395
|
+
for (const id of proof.removed)
|
|
6396
|
+
removed.add(id);
|
|
6397
|
+
const result = repairMissingHistoryBoundary({
|
|
6398
|
+
db,
|
|
6399
|
+
sessionId: sessionID,
|
|
6400
|
+
isInHostStore: (id) => source.sequenceForId(sessionID, id) !== undefined,
|
|
6401
|
+
removedByCommittedRevert: removed,
|
|
6402
|
+
onRetire: () => clearRecompStaging(db, sessionID)
|
|
6403
|
+
});
|
|
6404
|
+
if (result.kind !== "unresolved") {
|
|
6405
|
+
this.pendingHistory = this.pendingHistory.filter((proof) => proof.sessionID !== sessionID);
|
|
6406
|
+
}
|
|
6407
|
+
return result.kind === "intact" ? undefined : result;
|
|
6408
|
+
} finally {
|
|
6409
|
+
if (!reader)
|
|
6410
|
+
source.close();
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6302
6413
|
}
|
|
6303
6414
|
function pruneMessages(db, sessionID, removed) {
|
|
6304
6415
|
db.transaction(() => {
|
|
@@ -6965,12 +7076,16 @@ function checkHistoryBoundary(db, reader, sessionID) {
|
|
|
6965
7076
|
}
|
|
6966
7077
|
}
|
|
6967
7078
|
function newBaselineStartAfter(db, reader, sessionID, cached, compactionOff) {
|
|
6968
|
-
if (cached?.id != null
|
|
7079
|
+
if (cached?.id != null)
|
|
6969
7080
|
return;
|
|
6970
7081
|
const isSubagent = storedSubagentMode(db, sessionID);
|
|
6971
7082
|
if (isSubagent === undefined || !rendersCompartmentHistory(isSubagent, compactionOff))
|
|
6972
7083
|
return;
|
|
7084
|
+
if (cached?.hasBytes)
|
|
7085
|
+
return reader.earliestSequence(sessionID) === undefined ? undefined : null;
|
|
6973
7086
|
const newest = db.prepare("SELECT end_message_id AS id, rebase_status AS status FROM compartments WHERE session_id = ? ORDER BY sequence DESC LIMIT 1").get(sessionID);
|
|
7087
|
+
if (!newest && reader.earliestSequence(sessionID) !== undefined)
|
|
7088
|
+
return null;
|
|
6974
7089
|
if (newest?.id && newest.status !== "unresolved" && reader.sequenceForId(sessionID, newest.id) !== undefined)
|
|
6975
7090
|
return newest.id;
|
|
6976
7091
|
return;
|
|
@@ -6988,6 +7103,12 @@ async function cacheV2SessionDirectory(session, sessionID, directories) {
|
|
|
6988
7103
|
}
|
|
6989
7104
|
}
|
|
6990
7105
|
var contextPass = new AsyncLocalStorage;
|
|
7106
|
+
function noteCheckpointWithoutTail(sessionID, cut, incoming, messageCount) {
|
|
7107
|
+
const pass = contextPass.getStore();
|
|
7108
|
+
if (pass?.sessionID !== sessionID)
|
|
7109
|
+
return;
|
|
7110
|
+
pass.checkpointWithoutTail = cut && incoming && messageCount === 1 && !isCheckpointNote(cut.data.summary) ? cut.id : undefined;
|
|
7111
|
+
}
|
|
6991
7112
|
function withV2ContextPass(sessionID, run) {
|
|
6992
7113
|
const pass = { sessionID, refused: false };
|
|
6993
7114
|
return withSqliteTransformPass2(() => contextPass.run(pass, () => run(pass)));
|
|
@@ -7204,9 +7325,34 @@ async function registerContext(context) {
|
|
|
7204
7325
|
const embeddings = createV2EmbeddingScope(resolveProjectIdentityForSession(directory, config.allow_home_project));
|
|
7205
7326
|
const folds = new FoldOwner(context.storage);
|
|
7206
7327
|
const nativeFoldMemory = compactionOff ? undefined : nativeFoldCache(() => storage.require());
|
|
7328
|
+
const loggedUncoveredCheckpoints = new BoundedSessionMap(1000);
|
|
7207
7329
|
const nativeFoldReplay = nativeFoldMemory ? new NativeFoldReplay(nativeFoldMemory, () => openStoreReader(), context.storage, {
|
|
7208
7330
|
protocol: 3,
|
|
7209
|
-
log: sessionLog2
|
|
7331
|
+
log: sessionLog2,
|
|
7332
|
+
rendersHistory: (sessionID) => {
|
|
7333
|
+
if (rustModeModuleClient)
|
|
7334
|
+
return false;
|
|
7335
|
+
const mode = storedSubagentMode(storage.require(), sessionID);
|
|
7336
|
+
return mode !== undefined && rendersCompartmentHistory(mode, compactionOff);
|
|
7337
|
+
},
|
|
7338
|
+
servesHostCheckpoint: (sessionID, checkpointID) => {
|
|
7339
|
+
const pass = contextPass.getStore();
|
|
7340
|
+
return pass?.sessionID === sessionID && pass.checkpointWithoutTail === checkpointID;
|
|
7341
|
+
},
|
|
7342
|
+
onUncoveredFloor: (sessionID, floor, coverage) => {
|
|
7343
|
+
const pass = contextPass.getStore();
|
|
7344
|
+
if (pass?.sessionID === sessionID && pass.loggedUncoveredFloor)
|
|
7345
|
+
return;
|
|
7346
|
+
if (floor.kind === "checkpoint") {
|
|
7347
|
+
const key = JSON.stringify([sessionID, floor.id]);
|
|
7348
|
+
if (loggedUncoveredCheckpoints.get(key))
|
|
7349
|
+
return;
|
|
7350
|
+
loggedUncoveredCheckpoints.set(key, true);
|
|
7351
|
+
}
|
|
7352
|
+
if (pass?.sessionID === sessionID)
|
|
7353
|
+
pass.loggedUncoveredFloor = true;
|
|
7354
|
+
sessionLog2(sessionID, `v2 restore: ignored ${floor.kind} floor ${floor.id} at seq=${floor.after}; rendered coverage ${coverage.id ?? "none"} ends at seq=${coverage.after}`);
|
|
7355
|
+
}
|
|
7210
7356
|
}) : undefined;
|
|
7211
7357
|
setOutputReserveConfig(config.output_reserve);
|
|
7212
7358
|
const queriedModels = new Set;
|
|
@@ -7811,9 +7957,11 @@ async function registerContext(context) {
|
|
|
7811
7957
|
if (event.type === "session.revert.staged" && db) {
|
|
7812
7958
|
revertMessageCleanup.captureStageProof(sessionID, event.data.revert?.messageID);
|
|
7813
7959
|
}
|
|
7814
|
-
if (event.type === "session.revert.cleared"
|
|
7960
|
+
if (event.type === "session.revert.cleared") {
|
|
7815
7961
|
revertMessageCleanup.discardStageProof(sessionID);
|
|
7816
7962
|
}
|
|
7963
|
+
if (event.type === "session.deleted")
|
|
7964
|
+
revertMessageCleanup.forgetSession(sessionID);
|
|
7817
7965
|
if (event.type === "session.revert.committed") {
|
|
7818
7966
|
dropServedRecord(sessionID, "host_edit");
|
|
7819
7967
|
if (db) {
|
|
@@ -7821,9 +7969,10 @@ async function registerContext(context) {
|
|
|
7821
7969
|
withoutSqliteTransformPass2(() => {
|
|
7822
7970
|
scheduleClearAndReindex(indexDb, sessionID, pagedRead);
|
|
7823
7971
|
try {
|
|
7824
|
-
if (revertMessageCleanup.pruneOnCommit(indexDb, sessionID, event.data?.to)) {
|
|
7972
|
+
if (revertMessageCleanup.pruneOnCommit(indexDb, sessionID, event.data?.to, !compactionOff && !rustModeModuleClient)) {
|
|
7825
7973
|
tagger.cleanup(sessionID);
|
|
7826
7974
|
transform?.invalidateRustWireState(sessionID);
|
|
7975
|
+
revertMessageCleanup.retireProvenHistory(indexDb, sessionID);
|
|
7827
7976
|
}
|
|
7828
7977
|
} catch (error) {
|
|
7829
7978
|
sessionLog2(sessionID, "committed revert message cleanup failed:", error);
|
|
@@ -8121,7 +8270,7 @@ async function registerContext(context) {
|
|
|
8121
8270
|
const nativeFloor = await nativeFoldReplay?.restorationFloor(draft.sessionID, cut, reader, {
|
|
8122
8271
|
allowMissingFloor: newStart !== undefined
|
|
8123
8272
|
});
|
|
8124
|
-
if (newStart && nativeFloor === undefined) {
|
|
8273
|
+
if (newStart !== undefined && nativeFloor === undefined) {
|
|
8125
8274
|
const pass = contextPass.getStore();
|
|
8126
8275
|
if (pass)
|
|
8127
8276
|
pass.recoveredCheckpointID = cut.id;
|
|
@@ -8130,6 +8279,12 @@ async function registerContext(context) {
|
|
|
8130
8279
|
const servedBoundary = boundaryID ? servedBoundaryRow2(reader, draft.sessionID, boundaryID) : null;
|
|
8131
8280
|
const retiredInstructions = await nativeFoldReplay?.instructionRetirement(draft.sessionID, reader) ?? (() => false);
|
|
8132
8281
|
const floor = Math.max(nativeFloor ?? -Infinity, (nativeFoldReplay?.sourceChanged(draft.sessionID) && !rustModeModuleClient ? (reader.earliestSequence(draft.sessionID) ?? 0) - 1 : undefined) ?? (moduleBoundarySeq !== undefined ? moduleBoundarySeq - 1 : undefined) ?? servedBoundary?.seq ?? reader.sequenceForId(draft.sessionID, boundaryID) ?? (reader.earliestSequence(draft.sessionID) ?? 0) - 1);
|
|
8282
|
+
if (nativeFloor === undefined && newStart === null) {
|
|
8283
|
+
const first = reader.page(draft.sessionID, { limit: 1 }).rows[0];
|
|
8284
|
+
if (first?.seq === floor + 1)
|
|
8285
|
+
args.onStartAtFirstRow?.(first.id);
|
|
8286
|
+
sessionLog2(draft.sessionID, `v2 restore: no rendered history boundary; starting at stored row seq=${floor + 1}`);
|
|
8287
|
+
}
|
|
8133
8288
|
const floorRow = !rustModeModuleClient && Number.isFinite(floor) ? reader.range(draft.sessionID, floor - 1, floor).find((row) => row.seq === floor) : undefined;
|
|
8134
8289
|
const boundary = floorRow && hasUnsummarizedBlocks(db, reader, draft.sessionID, floorRow.id) ? floor - 1 : floor;
|
|
8135
8290
|
if (moduleBoundarySeq !== undefined)
|
|
@@ -8358,6 +8513,7 @@ async function registerContext(context) {
|
|
|
8358
8513
|
const incoming = localCut && messages.find((message) => message.id === localCut.id);
|
|
8359
8514
|
if (localCut && !incoming)
|
|
8360
8515
|
return;
|
|
8516
|
+
noteCheckpointWithoutTail(draft.sessionID, localCut, incoming, messages.length);
|
|
8361
8517
|
checkpointAtEntry = incoming || null;
|
|
8362
8518
|
const modeDb = db ?? storage.current();
|
|
8363
8519
|
const subagent = modeDb ? storedSubagentMode(modeDb, draft.sessionID) : undefined;
|
|
@@ -8554,18 +8710,20 @@ async function registerContext(context) {
|
|
|
8554
8710
|
let submitted;
|
|
8555
8711
|
let recordedHead;
|
|
8556
8712
|
let upgradeCheckpointSequence;
|
|
8713
|
+
let restoredFirstRow;
|
|
8557
8714
|
try {
|
|
8558
8715
|
syntheticIDs = await readSyntheticProvenance(reader, draft.messages);
|
|
8559
8716
|
const cut = reader.latestCompaction(draft.sessionID);
|
|
8560
8717
|
if (nativeFoldReplay)
|
|
8561
8718
|
await nativeFoldReplay.observeSource(draft.sessionID, reader);
|
|
8562
|
-
const boundaryRepair = !rustModeModuleClient && db && !compactionOff ? checkHistoryBoundary(db, reader, draft.sessionID) : undefined;
|
|
8719
|
+
const boundaryRepair = !rustModeModuleClient && db && !compactionOff ? revertMessageCleanup.retireProvenHistory(db, draft.sessionID, reader) ?? checkHistoryBoundary(db, reader, draft.sessionID) : undefined;
|
|
8563
8720
|
if (boundaryRepair?.kind === "repaired" || boundaryRepair?.kind === "baseline-reset") {
|
|
8564
8721
|
historyRefreshSessions.add(draft.sessionID);
|
|
8565
8722
|
requestPendingMaterialization(pendingMaterializationSessions, draft.sessionID, "boundary_repair");
|
|
8566
8723
|
}
|
|
8567
8724
|
const localCut = cut && isLocalCheckpoint(cut) ? cut : undefined;
|
|
8568
8725
|
const incoming = localCut && draft.messages.find((message) => message.id === localCut.id);
|
|
8726
|
+
noteCheckpointWithoutTail(draft.sessionID, localCut, incoming, draft.messages.length);
|
|
8569
8727
|
if (!compactionOff && localCut && !incoming)
|
|
8570
8728
|
throw new Error("The host checkpoint disappeared from the context draft");
|
|
8571
8729
|
checkpointAtEntry = incoming || null;
|
|
@@ -8647,7 +8805,10 @@ async function registerContext(context) {
|
|
|
8647
8805
|
messages: draft.messages,
|
|
8648
8806
|
cut: localCut,
|
|
8649
8807
|
incoming,
|
|
8650
|
-
canRebuild: true
|
|
8808
|
+
canRebuild: true,
|
|
8809
|
+
onStartAtFirstRow: (id) => {
|
|
8810
|
+
restoredFirstRow = id;
|
|
8811
|
+
}
|
|
8651
8812
|
}));
|
|
8652
8813
|
}
|
|
8653
8814
|
instructionRows = new Map(bindKeptInstructionCoordinates(draft.messages, incoming || undefined, reader, draft.sessionID).map((row) => [row.id, row]));
|
|
@@ -8701,14 +8862,30 @@ async function registerContext(context) {
|
|
|
8701
8862
|
})({}, mapped);
|
|
8702
8863
|
mapped.commit();
|
|
8703
8864
|
if (replayHead === undefined && (pass.recoveredCheckpointID || previousRecovery && pass.nativeReplayCheckpointID === previousRecovery.checkpointID)) {
|
|
8865
|
+
let coveredAfterRestore;
|
|
8866
|
+
if (pass.recoveredCheckpointID && restoredFirstRow) {
|
|
8867
|
+
try {
|
|
8868
|
+
const end = db.prepare("SELECT cached_m0_last_baseline_end_message_id AS id FROM session_meta WHERE session_id=?").get(draft.sessionID);
|
|
8869
|
+
if (end?.id) {
|
|
8870
|
+
const source = openStoreReader();
|
|
8871
|
+
try {
|
|
8872
|
+
const seq = source.sequenceForId(draft.sessionID, end.id);
|
|
8873
|
+
if (seq !== undefined)
|
|
8874
|
+
coveredAfterRestore = new Set(source.instructionRowsThrough(draft.sessionID, seq).map(({ id }) => id));
|
|
8875
|
+
} finally {
|
|
8876
|
+
source.close();
|
|
8877
|
+
}
|
|
8878
|
+
}
|
|
8879
|
+
} catch {}
|
|
8880
|
+
}
|
|
8704
8881
|
pass.servedInstructionIDs = new Set(mapped.messages.flatMap(({ info, parts }) => {
|
|
8705
|
-
|
|
8882
|
+
const id = hostInstructionRowID(info);
|
|
8883
|
+
if (!id || info.role !== "system" || pass.recoveredCheckpointID && !isCoveredInstructionRow(info) && !coveredAfterRestore?.has(id) || !parts.some((value) => {
|
|
8706
8884
|
const part = value;
|
|
8707
8885
|
return part?.type === "text" && typeof part.text === "string" && part.text.length > 0;
|
|
8708
8886
|
}))
|
|
8709
8887
|
return [];
|
|
8710
|
-
|
|
8711
|
-
return id ? [id] : [];
|
|
8888
|
+
return [id];
|
|
8712
8889
|
}));
|
|
8713
8890
|
}
|
|
8714
8891
|
const checkpointPermission = checkpointPassPermissions.get(draft.sessionID);
|
|
@@ -8756,7 +8933,7 @@ async function registerContext(context) {
|
|
|
8756
8933
|
try {
|
|
8757
8934
|
const state = db && getOrCreateSessionMeta(db, draft.sessionID);
|
|
8758
8935
|
const boundary = db?.prepare("SELECT cached_m0_last_baseline_end_message_id AS id FROM session_meta WHERE session_id=?").get(draft.sessionID);
|
|
8759
|
-
await nativeFoldReplay?.capture(draft, nativeMessages, boundary?.id && state?.cachedM0Bytes ? { id: boundary.id, summary: state.cachedM0Bytes.toString("utf8") } : undefined);
|
|
8936
|
+
await nativeFoldReplay?.capture(draft, nativeMessages, boundary?.id && state?.cachedM0Bytes ? { id: boundary.id, summary: state.cachedM0Bytes.toString("utf8") } : undefined, restoredFirstRow);
|
|
8760
8937
|
} catch (error) {
|
|
8761
8938
|
nativeFoldReplay?.invalidate(draft.sessionID, true);
|
|
8762
8939
|
sessionLog2(draft.sessionID, "v2 host fold: optional capture unavailable", error);
|
|
@@ -9073,6 +9250,7 @@ async function registerContext(context) {
|
|
|
9073
9250
|
await hiddenChildSweep.dispose();
|
|
9074
9251
|
messageTimesCache.clear();
|
|
9075
9252
|
recoveredInstructions.clear();
|
|
9253
|
+
loggedUncoveredCheckpoints.clear();
|
|
9076
9254
|
hostFoldIdle?.dispose();
|
|
9077
9255
|
usageController.abort();
|
|
9078
9256
|
await hiddenCompletionExecutor?.dispose();
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
resolveHistorianProducerLimits2,
|
|
6
6
|
resolveHistorianContextLimit2,
|
|
7
7
|
producerSourceLocalBudget2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-xsqw8kbd.js";
|
|
9
9
|
import"./index-1zx87sdm.js";
|
|
10
|
-
import"./index-
|
|
10
|
+
import"./index-5df2fw5b.js";
|
|
11
11
|
import"./index-gqf8r04r.js";
|
|
12
12
|
import"./index-ywrz4wy2.js";
|
|
13
13
|
import"./index-pavzsdc6.js";
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureMemoryEmbeddings2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
3
|
+
} from "./index-w51n3576.js";
|
|
4
|
+
import"./index-2pdgy88n.js";
|
|
5
5
|
import"./index-qjwpqvnf.js";
|
|
6
6
|
import"./index-2amn2s73.js";
|
|
7
7
|
import"./index-qt1qqasc.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-60x5d68t.js";
|
|
9
9
|
import"./index-6nqz8hsz.js";
|
|
10
|
-
import"./index-
|
|
10
|
+
import"./index-r4y0dczp.js";
|
|
11
11
|
import"./index-3pdknr07.js";
|
|
12
12
|
import"./index-pxnzyvjc.js";
|
|
13
|
-
import"./index-
|
|
13
|
+
import"./index-5pgyqgmx.js";
|
|
14
14
|
import"./index-s32f8y67.js";
|
|
15
15
|
import"./index-q7q6qp1f.js";
|
|
16
16
|
import"./index-96ztjvkn.js";
|
|
17
17
|
import"./index-v0p37hm2.js";
|
|
18
18
|
import"./index-m0pwswv9.js";
|
|
19
|
-
import"./index-
|
|
19
|
+
import"./index-5df2fw5b.js";
|
|
20
20
|
import"./index-gqf8r04r.js";
|
|
21
21
|
import"./index-5vsk2cpp.js";
|
|
22
22
|
import"./index-gzy5w8ya.js";
|