@cortexkit/opencode-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.
- package/dist/auto-search-worker.js +10 -7
- package/dist/{compaction-marker-candidates-dd638ypn.js → compaction-marker-candidates-a0edbqrr.js} +2 -2
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/{conflict-warning-hook-ae8nmv7c.js → conflict-warning-hook-myk5hbt9.js} +5 -5
- package/dist/{context-yg023c5r.js → context-ffr7e0g7.js} +46 -34
- package/dist/{embedding-backfill-aj488s8x.js → embedding-backfill-re16xncd.js} +6 -6
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +6 -3
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +7 -1
- package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +2 -2
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/primer-seed.d.ts +2 -0
- package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts +2 -2
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +10 -3
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-replay-document.d.ts +4 -0
- package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +7 -0
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/note-nudger.d.ts +5 -3
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +7 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/replay-committed-drops.d.ts +9 -0
- package/dist/hooks/magic-context/replay-committed-drops.d.ts.map +1 -0
- package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts +2 -2
- package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +3 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-served-raw.d.ts +29 -0
- package/dist/hooks/magic-context/rust-served-raw.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +23 -24
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +2 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +2 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/{index-m4p77myp.js → index-0gyq3djm.js} +1 -1
- package/dist/{index-jpm52v9x.js → index-37q80veb.js} +1 -1
- package/dist/{index-znzgze2v.js → index-4btknbqh.js} +9 -8
- package/dist/{index-v4bqjy56.js → index-5tbvdff4.js} +59 -28
- package/dist/{index-7jzrrxap.js → index-9yyqq3mm.js} +1 -1
- package/dist/{index-qvr78ej6.js → index-a8acx4gc.js} +2 -2
- package/dist/{index-gcdb3rqw.js → index-ax2jhztn.js} +1 -1
- package/dist/{index-2mqps3c1.js → index-ebnngykq.js} +145 -94
- package/dist/{index-41gqa557.js → index-g8qbdb03.js} +1 -1
- package/dist/{index-fst3t0d9.js → index-j58gqrn2.js} +65 -65
- package/dist/{index-xfbfrngb.js → index-j5hce1ab.js} +2 -2
- package/dist/{index-kb9nn0a0.js → index-j8epsc0g.js} +35 -14
- package/dist/{index-7zg9dvx0.js → index-n5a170gs.js} +227 -38
- package/dist/{index-fjtgekd4.js → index-n7kwfw2r.js} +4 -4
- package/dist/{index-dd18gej8.js → index-rwmpkss5.js} +3 -3
- package/dist/{index-7w18gg78.js → index-rzmjkdd6.js} +1 -1
- package/dist/{index-c0b01zrc.js → index-sf94at64.js} +3 -3
- package/dist/{index-yxawqmdd.js → index-sh91t19a.js} +1 -1
- package/dist/{index-x3y1np1h.js → index-tagss15p.js} +857 -125
- package/dist/{index-yqps2zsv.js → index-tmtty2x5.js} +1 -1
- package/dist/{index-bhk710rw.js → index-vt4sf4ep.js} +1 -1
- package/dist/{index-6m7rdv7y.js → index-w4mw92w3.js} +1 -1
- package/dist/{index-7ndnvw7a.js → index-w6bd03dc.js} +1 -1
- package/dist/{index-p2hs3rps.js → index-w6vr754t.js} +4 -4
- package/dist/{index-3wckxwfp.js → index-wq16ahsn.js} +5 -5
- package/dist/index.js +36 -36
- package/dist/{message-index-bounded-pv6ct15d.js → message-index-bounded-04rycpx4.js} +9 -9
- package/dist/{message-index-jqa7qd0s.js → message-index-rqtse28y.js} +9 -9
- package/dist/{message-time-backfill-8x06r9kx.js → message-time-backfill-a5ytnp53.js} +1 -1
- package/dist/migration-worker.js +6 -6
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/{project-embedding-registry-fcmszatg.js → project-embedding-registry-k0sd9k7v.js} +5 -5
- package/dist/raw-ordinal-warmup-worker.js +17 -15
- package/dist/{read-session-chunk-cwgjwjd0.js → read-session-chunk-h1btx938.js} +7 -5
- package/dist/{read-session-raw-z38cn0as.js → read-session-raw-vdf4wh78.js} +2 -2
- package/dist/{recomp-orchestrator-xw9wt5bm.js → recomp-orchestrator-trcgmm23.js} +20 -20
- package/dist/{search-v1t47s2q.js → search-3rbdx6hw.js} +16 -16
- package/dist/{send-session-notification-yp9m5g4p.js → send-session-notification-2tp44tfa.js} +4 -4
- package/dist/shared/processed-image-eligibility.d.ts +22 -0
- package/dist/shared/processed-image-eligibility.d.ts.map +1 -0
- package/dist/shared/recovery-reasoning-prefix.d.ts +9 -0
- package/dist/shared/recovery-reasoning-prefix.d.ts.map +1 -0
- package/dist/shared/sqlite.d.ts +1 -1
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/tag-transcript.d.ts +9 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/{sqlite-mhjkerzq.js → sqlite-j3tvg8r0.js} +1 -1
- package/dist/{storage-memory-07fx57k6.js → storage-memory-8168bgef.js} +2 -2
- package/dist/{storage-tags-0ssbmzg9.js → storage-tags-61z5j2f9.js} +2 -2
- package/dist/tools/ctx-expand/search-archive.d.ts +4 -0
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -0
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-ttra554y.js → transform-postprocess-phase-7qts7h54.js} +20 -20
- package/dist/v2/auto-search-worker.js +10 -7
- package/dist/v2/{compaction-marker-candidates-1s21e2fz.js → compaction-marker-candidates-6nypjkpf.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +2 -2
- package/dist/v2/{context-6en6a8ar.js → context-xq4rtywr.js} +1019 -233
- package/dist/v2/{embedding-backfill-9hbkfvnz.js → embedding-backfill-xd9ygzgd.js} +6 -6
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/{message-index-h8ssgq3q.js → message-index-8e5z2xx8.js} +9 -9
- package/dist/v2/{message-index-bounded-c0810p5w.js → message-index-bounded-5vh1h2g7.js} +9 -9
- package/dist/v2/{message-time-backfill-cje68egj.js → message-time-backfill-2z365239.js} +1 -1
- package/dist/v2/migration-worker.js +6 -6
- package/dist/v2/{project-embedding-registry-42th7k1z.js → project-embedding-registry-b77awytr.js} +5 -5
- package/dist/v2/raw-ordinal-warmup-worker.js +17 -15
- package/dist/v2/{read-session-chunk-n86v9xfg.js → read-session-chunk-4sat83cx.js} +7 -5
- package/dist/v2/{read-session-raw-3b3ehga4.js → read-session-raw-a3hw9jsp.js} +2 -2
- package/dist/v2/{recomp-orchestrator-krvsbnds.js → recomp-orchestrator-n11zv1f1.js} +19 -19
- package/dist/v2/{search-048v8y02.js → search-mvgqtkkz.js} +16 -16
- package/dist/v2/{send-session-notification-a4h2azxa.js → send-session-notification-ppgc8qdz.js} +4 -4
- package/dist/v2/{server-cvgn49tr.js → server-1rfgbjfn.js} +1 -1
- package/dist/v2/{server-3bc6k4k4.js → server-7srtwsa4.js} +5 -5
- package/dist/v2/{server-7jzrrxap.js → server-9yyqq3mm.js} +1 -1
- package/dist/v2/{server-2htmbqbv.js → server-brhj8qtd.js} +1 -1
- package/dist/v2/{server-3dqjhchy.js → server-dd0nja67.js} +1 -1
- package/dist/v2/{server-8wcf79fe.js → server-fpqe39as.js} +1 -1
- package/dist/v2/{server-cjz51jm2.js → server-fw31krgq.js} +3 -3
- package/dist/v2/{server-4n2tknpc.js → server-gtv9wbhq.js} +227 -38
- package/dist/v2/{server-8pqnnmf9.js → server-hcvcxzx7.js} +2 -2
- package/dist/v2/{server-kb9nn0a0.js → server-j8epsc0g.js} +35 -14
- package/dist/v2/{server-rygvffsf.js → server-jdwd03ep.js} +4 -4
- package/dist/v2/{server-q6j5dasr.js → server-kdrezdy0.js} +1 -1
- package/dist/v2/{server-e2v4m8xe.js → server-mv1w7t6z.js} +61 -30
- package/dist/v2/{server-hetyb88z.js → server-nfan6zb6.js} +65 -65
- package/dist/v2/{server-4enr7s6x.js → server-qcw43339.js} +1 -1
- package/dist/v2/{server-5zrpr764.js → server-sy4b1sra.js} +1 -1
- package/dist/v2/{server-9a6v0wth.js → server-v4fwha43.js} +9 -8
- package/dist/v2/{server-pcygfdbs.js → server-w3zeywp1.js} +1 -1
- package/dist/v2/{server-czb2rkpk.js → server-wkdgjjch.js} +1 -1
- package/dist/v2/{server-9290a1mb.js → server-x08d1xf3.js} +1 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/{sqlite-mhjkerzq.js → sqlite-j3tvg8r0.js} +1 -1
- package/dist/v2/{storage-memory-07fx57k6.js → storage-memory-8168bgef.js} +2 -2
- package/dist/v2/{storage-tags-3a4cavqb.js → storage-tags-j2fzq3sw.js} +2 -2
- package/dist/v2/{wrapup-orchestrator-r2v7kgy3.js → wrapup-orchestrator-s92ebfzv.js} +19 -19
- package/dist/{wrapup-orchestrator-z7agncp8.js → wrapup-orchestrator-df61jmz9.js} +21 -21
- package/package.json +3 -3
- package/src/shared/processed-image-eligibility.test.ts +68 -0
- package/src/shared/processed-image-eligibility.ts +41 -0
- package/src/shared/processed-image-position-review.json +20 -0
- package/src/shared/processed-image-position-review.test.ts +19 -0
- package/src/shared/recovery-reasoning-prefix.test.ts +34 -0
- package/src/shared/recovery-reasoning-prefix.ts +35 -0
- package/src/shared/sqlite-acquisition-routing.test.ts +4 -3
- package/src/shared/sqlite-foreground-wait.test.ts +140 -0
- package/src/shared/sqlite-pass-scope.test.ts +4 -4
- package/src/shared/sqlite-writer-diagnostics.test.ts +31 -0
- package/src/shared/sqlite.ts +64 -23
- package/src/shared/tag-transcript.ts +118 -0
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
buildCanonicalChunkTextFromFts,
|
|
21
21
|
loadCompartmentChunkEmbeddingsForSearch
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-ax2jhztn.js";
|
|
23
23
|
import {
|
|
24
24
|
recordEmbeddingMeasurement,
|
|
25
25
|
saveCommitEmbedding,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
enqueueShadowEmbeddingItems2,
|
|
37
37
|
getProjectEmbeddingSnapshot2,
|
|
38
38
|
embedItemsForProject2
|
|
39
|
-
} from "./index-
|
|
39
|
+
} from "./index-sf94at64.js";
|
|
40
40
|
import {
|
|
41
41
|
getProjectEmbeddings2
|
|
42
42
|
} from "./index-4dhv7mqz.js";
|
|
@@ -45,13 +45,13 @@ import {
|
|
|
45
45
|
isEmbeddingEnabled,
|
|
46
46
|
embedText,
|
|
47
47
|
ensureMemoryEmbeddings2
|
|
48
|
-
} from "./index-
|
|
48
|
+
} from "./index-w6bd03dc.js";
|
|
49
49
|
import {
|
|
50
50
|
ModuleMemoryAuthorityError2,
|
|
51
51
|
getMemoriesByProject2,
|
|
52
52
|
getMemoriesByProjects2,
|
|
53
53
|
updateMemoryRetrievalCount2
|
|
54
|
-
} from "./index-
|
|
54
|
+
} from "./index-9yyqq3mm.js";
|
|
55
55
|
import {
|
|
56
56
|
USER_FACING_FAILURES,
|
|
57
57
|
getNotes,
|
|
@@ -60,20 +60,20 @@ import {
|
|
|
60
60
|
sanitizeFtsQuery,
|
|
61
61
|
searchMemoriesFTS,
|
|
62
62
|
searchMemoriesFTSUnion
|
|
63
|
-
} from "./index-
|
|
63
|
+
} from "./index-n7kwfw2r.js";
|
|
64
64
|
import {
|
|
65
65
|
isRecord
|
|
66
|
-
} from "./index-
|
|
66
|
+
} from "./index-tmtty2x5.js";
|
|
67
67
|
import {
|
|
68
68
|
getIndexedMessageCorpusSize2
|
|
69
|
-
} from "./index-
|
|
69
|
+
} from "./index-wq16ahsn.js";
|
|
70
70
|
import {
|
|
71
71
|
resolveWorkspaceShareCategories,
|
|
72
72
|
resolveWorkspaceIdentitySet,
|
|
73
73
|
expandWorkspaceIdentitySetWithAliases,
|
|
74
74
|
resolveStoredPathWorkspaceIdentity,
|
|
75
75
|
sourceNameForMemory
|
|
76
|
-
} from "./index-
|
|
76
|
+
} from "./index-j5hce1ab.js";
|
|
77
77
|
import {
|
|
78
78
|
isKnownAutocommit
|
|
79
79
|
} from "./index-8ajstryz.js";
|
|
@@ -1257,6 +1257,61 @@ function searchGitCommitsSync(db, projectPath, query, options) {
|
|
|
1257
1257
|
});
|
|
1258
1258
|
return results.slice(0, options.limit);
|
|
1259
1259
|
}
|
|
1260
|
+
// src/features/magic-context/message-fts-session-filter.ts
|
|
1261
|
+
var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
|
|
1262
|
+
SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
|
|
1263
|
+
) AND `;
|
|
1264
|
+
var coverageCaches = new WeakMap;
|
|
1265
|
+
function getCoverageCache(db) {
|
|
1266
|
+
let cache = coverageCaches.get(db);
|
|
1267
|
+
if (!cache) {
|
|
1268
|
+
cache = {
|
|
1269
|
+
pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
|
|
1270
|
+
stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
|
|
1271
|
+
missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
|
|
1272
|
+
FROM message_history_fts WHERE rowid IN (
|
|
1273
|
+
SELECT id FROM message_history_fts_docsize
|
|
1274
|
+
EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
|
|
1275
|
+
)`)
|
|
1276
|
+
};
|
|
1277
|
+
coverageCaches.set(db, cache);
|
|
1278
|
+
}
|
|
1279
|
+
return cache;
|
|
1280
|
+
}
|
|
1281
|
+
function withMessageFtsSessionFilter(db, sessionId, read) {
|
|
1282
|
+
let cacheable = false;
|
|
1283
|
+
try {
|
|
1284
|
+
const transaction = db;
|
|
1285
|
+
cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
|
|
1286
|
+
if (!cacheable)
|
|
1287
|
+
coverageCaches.delete(db);
|
|
1288
|
+
} catch {
|
|
1289
|
+
coverageCaches.delete(db);
|
|
1290
|
+
}
|
|
1291
|
+
return db.transaction(() => {
|
|
1292
|
+
let sessionFirst = false;
|
|
1293
|
+
try {
|
|
1294
|
+
const cache = getCoverageCache(db);
|
|
1295
|
+
cache.pin.get();
|
|
1296
|
+
const stamp = cache.stamp.get();
|
|
1297
|
+
let incomplete = cache.incompleteSessions;
|
|
1298
|
+
if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
|
|
1299
|
+
const rows = cache.missing.all();
|
|
1300
|
+
incomplete = new Set(rows.map((row) => row.sessionId));
|
|
1301
|
+
if (cacheable) {
|
|
1302
|
+
cache.version = stamp.version;
|
|
1303
|
+
cache.changes = stamp.changes;
|
|
1304
|
+
cache.incompleteSessions = incomplete;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
sessionFirst = !incomplete.has(sessionId);
|
|
1308
|
+
} catch {
|
|
1309
|
+
coverageCaches.delete(db);
|
|
1310
|
+
}
|
|
1311
|
+
return read(sessionFirst);
|
|
1312
|
+
}).deferred();
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1260
1315
|
// src/features/magic-context/literal-probes.ts
|
|
1261
1316
|
var MAX_PROBES = 5;
|
|
1262
1317
|
var MIN_PROBE_LENGTH = 3;
|
|
@@ -1313,61 +1368,6 @@ function containsProbeVerbatim(text, probes) {
|
|
|
1313
1368
|
return probes.some((probe) => haystack.includes(probe.toLowerCase()));
|
|
1314
1369
|
}
|
|
1315
1370
|
|
|
1316
|
-
// src/features/magic-context/message-fts-session-filter.ts
|
|
1317
|
-
var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
|
|
1318
|
-
SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
|
|
1319
|
-
) AND `;
|
|
1320
|
-
var coverageCaches = new WeakMap;
|
|
1321
|
-
function getCoverageCache(db) {
|
|
1322
|
-
let cache = coverageCaches.get(db);
|
|
1323
|
-
if (!cache) {
|
|
1324
|
-
cache = {
|
|
1325
|
-
pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
|
|
1326
|
-
stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
|
|
1327
|
-
missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
|
|
1328
|
-
FROM message_history_fts WHERE rowid IN (
|
|
1329
|
-
SELECT id FROM message_history_fts_docsize
|
|
1330
|
-
EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
|
|
1331
|
-
)`)
|
|
1332
|
-
};
|
|
1333
|
-
coverageCaches.set(db, cache);
|
|
1334
|
-
}
|
|
1335
|
-
return cache;
|
|
1336
|
-
}
|
|
1337
|
-
function withMessageFtsSessionFilter(db, sessionId, read) {
|
|
1338
|
-
let cacheable = false;
|
|
1339
|
-
try {
|
|
1340
|
-
const transaction = db;
|
|
1341
|
-
cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
|
|
1342
|
-
if (!cacheable)
|
|
1343
|
-
coverageCaches.delete(db);
|
|
1344
|
-
} catch {
|
|
1345
|
-
coverageCaches.delete(db);
|
|
1346
|
-
}
|
|
1347
|
-
return db.transaction(() => {
|
|
1348
|
-
let sessionFirst = false;
|
|
1349
|
-
try {
|
|
1350
|
-
const cache = getCoverageCache(db);
|
|
1351
|
-
cache.pin.get();
|
|
1352
|
-
const stamp = cache.stamp.get();
|
|
1353
|
-
let incomplete = cache.incompleteSessions;
|
|
1354
|
-
if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
|
|
1355
|
-
const rows = cache.missing.all();
|
|
1356
|
-
incomplete = new Set(rows.map((row) => row.sessionId));
|
|
1357
|
-
if (cacheable) {
|
|
1358
|
-
cache.version = stamp.version;
|
|
1359
|
-
cache.changes = stamp.changes;
|
|
1360
|
-
cache.incompleteSessions = incomplete;
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
sessionFirst = !incomplete.has(sessionId);
|
|
1364
|
-
} catch {
|
|
1365
|
-
coverageCaches.delete(db);
|
|
1366
|
-
}
|
|
1367
|
-
return read(sessionFirst);
|
|
1368
|
-
}).deferred();
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
1371
|
// src/features/magic-context/search-measurement.ts
|
|
1372
1372
|
import { createHash as createHash2 } from "node:crypto";
|
|
1373
1373
|
function resultId(result) {
|
|
@@ -3242,7 +3242,7 @@ ${diagnosticLines.join(`
|
|
|
3242
3242
|
bodyParts.push(diagnosticLines.join(`
|
|
3243
3243
|
`));
|
|
3244
3244
|
if (results.some((result) => result.source === "message" || result.source === "compartment")) {
|
|
3245
|
-
bodyParts.push("Use ctx_expand(start, end) with the range from any message result above to read the
|
|
3245
|
+
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.");
|
|
3246
3246
|
}
|
|
3247
3247
|
if (results.some((result) => result.source === "note" && result.anchorOrdinal !== null && result.sourceSessionId === currentSessionId)) {
|
|
3248
3248
|
bodyParts.push(SEARCH_NOTE_EXPAND_HINT);
|
|
@@ -3254,4 +3254,4 @@ ${bodyParts.join(`
|
|
|
3254
3254
|
`)}`;
|
|
3255
3255
|
}
|
|
3256
3256
|
|
|
3257
|
-
export { renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, singleStoreMigrationRequiredFailure, projectNeedsSingleStoreMigration, STORE_AHEAD_OF_BINARY_CODE, storeAheadOfBinaryFailure, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS, transformColdStartExecuteTimeoutMs, MAX_WRAPUP_REQUEST_BUDGET_MS, getDefaultSubcConnectionFile, isModuleTransportGenerationChangedResult, SubcModuleTransport, indexCommitsForProject, embedUnembeddedCommits, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
3257
|
+
export { renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, singleStoreMigrationRequiredFailure, projectNeedsSingleStoreMigration, STORE_AHEAD_OF_BINARY_CODE, storeAheadOfBinaryFailure, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS, transformColdStartExecuteTimeoutMs, MAX_WRAPUP_REQUEST_BUDGET_MS, getDefaultSubcConnectionFile, isModuleTransportGenerationChangedResult, SubcModuleTransport, indexCommitsForProject, embedUnembeddedCommits, withMessageFtsSessionFilter, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
} from "./index-58e3y90n.js";
|
|
17
17
|
import {
|
|
18
18
|
Database2
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-j8epsc0g.js";
|
|
20
20
|
import {
|
|
21
21
|
normalizeStoredProjectPath,
|
|
22
22
|
storedPathBelongsToIdentity
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-g8qbdb03.js";
|
|
24
24
|
import {
|
|
25
25
|
logSlowWriteTransaction
|
|
26
26
|
} from "./index-4mjhqadz.js";
|
|
@@ -6,12 +6,15 @@ function registerSlowWriteReporter2(reporter) {
|
|
|
6
6
|
reportSlowPrivilegedWrite = reporter;
|
|
7
7
|
}
|
|
8
8
|
var sqliteDiagnosticSink;
|
|
9
|
-
|
|
9
|
+
var sqliteDiagnosticHost = () => "unknown";
|
|
10
|
+
function registerSqliteDiagnosticSink2(sink, host) {
|
|
10
11
|
sqliteDiagnosticSink = sink;
|
|
12
|
+
if (host)
|
|
13
|
+
sqliteDiagnosticHost = host;
|
|
11
14
|
}
|
|
12
15
|
function reportSqliteDiagnostic(message) {
|
|
13
16
|
try {
|
|
14
|
-
sqliteDiagnosticSink?.(`[magic-context] ${message}`);
|
|
17
|
+
sqliteDiagnosticSink?.(`[magic-context] ${message} pid=${process.pid} host=${sqliteDiagnosticHost()}`);
|
|
15
18
|
} catch {}
|
|
16
19
|
}
|
|
17
20
|
function detectSqliteRuntime2() {
|
|
@@ -170,10 +173,18 @@ function installTransactionRouting(db, readonly) {
|
|
|
170
173
|
assertTransformWrite2();
|
|
171
174
|
if (/^\s*BEGIN\s+(?:IMMEDIATE|EXCLUSIVE)(?:\s+TRANSACTION)?\s*;?\s*$/i.test(sql)) {
|
|
172
175
|
openWriterTransactions.delete(db);
|
|
173
|
-
if (transformPassScope.getStore()?.active || backgroundWriterScope.getStore())
|
|
176
|
+
if (transformPassScope.getStore()?.active || backgroundWriterScope.getStore()) {
|
|
174
177
|
acquireShort(db, () => nativeExec(sql), sql.trim());
|
|
175
|
-
else
|
|
178
|
+
} else {
|
|
176
179
|
nativeExec(sql);
|
|
180
|
+
openWriterTransactions.set(db, {
|
|
181
|
+
site: sql.trim(),
|
|
182
|
+
lane: "background",
|
|
183
|
+
acquireMs: 0,
|
|
184
|
+
attempts: 1,
|
|
185
|
+
acquiredAt: performance.now()
|
|
186
|
+
});
|
|
187
|
+
}
|
|
177
188
|
return db;
|
|
178
189
|
}
|
|
179
190
|
if (WRITER_TRANSACTION_END.test(sql) && openWriterTransactions.has(db))
|
|
@@ -556,9 +567,9 @@ class SqliteAcquisitionBusyError2 extends Error {
|
|
|
556
567
|
}
|
|
557
568
|
}
|
|
558
569
|
var SHORT_BUSY_TIMEOUT_MS = 25;
|
|
559
|
-
var FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS =
|
|
570
|
+
var FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS = 2000;
|
|
560
571
|
var FOREGROUND_ACQUISITION_BUDGET_MS = 16500;
|
|
561
|
-
var SLOW_WRITER_LOG_MS =
|
|
572
|
+
var SLOW_WRITER_LOG_MS = 100;
|
|
562
573
|
var WRITER_TRANSACTION_END = /^\s*(?:COMMIT|END|ROLLBACK)(?:\s+TRANSACTION)?\s*;?\s*$/i;
|
|
563
574
|
var writerAcquisitionScope = new AsyncLocalStorage;
|
|
564
575
|
var openWriterTransactions = new WeakMap;
|
|
@@ -569,22 +580,30 @@ function foregroundWaitLease() {
|
|
|
569
580
|
function withAutocommitTimeout(db, operation) {
|
|
570
581
|
assertTransformWrite2();
|
|
571
582
|
const lease = foregroundWaitLease();
|
|
572
|
-
if (isInTransaction(db)
|
|
583
|
+
if (isInTransaction(db))
|
|
573
584
|
return operation();
|
|
574
|
-
const
|
|
575
|
-
|
|
585
|
+
const scoped = lease || backgroundWriterScope.getStore();
|
|
586
|
+
const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
|
|
587
|
+
if (scoped)
|
|
588
|
+
db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
|
|
576
589
|
const started = performance.now();
|
|
590
|
+
let completed = false;
|
|
577
591
|
try {
|
|
578
|
-
|
|
592
|
+
const result = operation();
|
|
593
|
+
completed = true;
|
|
594
|
+
return result;
|
|
579
595
|
} catch (error) {
|
|
580
596
|
if (lease && isTransientSqliteError2(error))
|
|
581
597
|
throw new SqliteAcquisitionBusyError2(error, "autocommit");
|
|
582
598
|
throw error;
|
|
583
599
|
} finally {
|
|
600
|
+
const elapsed = performance.now() - started;
|
|
584
601
|
if (lease)
|
|
585
|
-
lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs -
|
|
602
|
+
lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - elapsed);
|
|
586
603
|
if (previous !== null)
|
|
587
604
|
db.exec(`PRAGMA busy_timeout=${previous}`);
|
|
605
|
+
if (elapsed >= SLOW_WRITER_LOG_MS)
|
|
606
|
+
reportSqliteDiagnostic(`sqlite writer site=autocommit lane=${lease ? "foreground" : "background"} elapsed_ms=${Math.round(elapsed)} timing=statement_including_acquisition outcome=${completed ? "completed" : "failed"} caller=${writerCaller()}`);
|
|
588
607
|
}
|
|
589
608
|
}
|
|
590
609
|
function acquireShort(db, acquire, site) {
|
|
@@ -630,24 +649,26 @@ function acquireShort(db, acquire, site) {
|
|
|
630
649
|
}
|
|
631
650
|
function endWriterTransaction(db, end, sql) {
|
|
632
651
|
let ended = false;
|
|
633
|
-
const endStarted = performance.now();
|
|
634
652
|
try {
|
|
635
653
|
const result = end();
|
|
636
654
|
ended = true;
|
|
637
655
|
return result;
|
|
638
656
|
} finally {
|
|
639
657
|
const open = openWriterTransactions.get(db);
|
|
640
|
-
const endMs = performance.now() - endStarted;
|
|
641
658
|
if (open && !isInTransaction(db)) {
|
|
642
659
|
openWriterTransactions.delete(db);
|
|
643
660
|
const holdMs = performance.now() - open.acquiredAt;
|
|
644
661
|
if (open.acquireMs >= SLOW_WRITER_LOG_MS || holdMs >= SLOW_WRITER_LOG_MS) {
|
|
645
662
|
const outcome = /^\s*ROLLBACK/i.test(sql) ? "rolled_back" : ended ? "committed" : "failed";
|
|
646
|
-
reportSqliteDiagnostic(`sqlite writer site=${open.site} lane=${open.lane} acquire_ms=${Math.round(open.acquireMs)} hold_ms=${Math.round(holdMs)}
|
|
663
|
+
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()}`);
|
|
647
664
|
}
|
|
648
665
|
}
|
|
649
666
|
}
|
|
650
667
|
}
|
|
668
|
+
function writerCaller() {
|
|
669
|
+
return new Error().stack?.split(`
|
|
670
|
+
`).find((line) => line.includes(" at ") && !/[/\\]sqlite\.[tj]s[:)]/.test(line) && !/\b(?:writerCaller|endWriterTransaction|withAutocommitTimeout|value)\b/.test(line))?.trim().replace(/\s+/g, "_") ?? "unknown";
|
|
671
|
+
}
|
|
651
672
|
async function beginSqliteWriterAsync2(db, site) {
|
|
652
673
|
const started = performance.now();
|
|
653
674
|
let attempts = 0;
|