@cortexkit/opencode-magic-context 0.49.92 → 0.49.95
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 +4 -4
- package/dist/chunk-embedding-write-worker.js +3 -3
- package/dist/{compartment-chunk-embedding-rp4asvk0.js → compartment-chunk-embedding-4nn3hsw2.js} +2 -2
- package/dist/{context-e8qd2v00.js → context-h9x9m2p3.js} +192 -68
- package/dist/{embedding-backfill-w0yq71q2.js → embedding-backfill-wdrqkw09.js} +6 -6
- package/dist/embedding-worker.js +3 -3
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +5 -2
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
- package/dist/features/magic-context/history-gap-recovery.d.ts +42 -0
- package/dist/features/magic-context/history-gap-recovery.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts +18 -5
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts +3 -0
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/message-visibility.d.ts +10 -0
- package/dist/features/magic-context/message-visibility.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts +4 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +2 -2
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts +3 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts +4 -0
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +1 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts +4 -0
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +2 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-stage-logger.d.ts +6 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
- package/dist/{index-3f3d548g.js → index-2gewejcz.js} +18 -9
- package/dist/{index-n71006wq.js → index-2v9qpmb3.js} +5 -5
- package/dist/{index-zzhcshdk.js → index-3tmbvn0z.js} +9 -9
- package/dist/{index-f25ha337.js → index-3ywyr4zx.js} +1 -1
- package/dist/{index-hbn5g7rt.js → index-47hst5me.js} +1 -1
- package/dist/{index-xg1zjht5.js → index-7dzaamqg.js} +6 -6
- package/dist/{index-5y9w2ax7.js → index-7r11k4xr.js} +2 -2
- package/dist/{index-5pmf4jpj.js → index-7skgrbsg.js} +100 -52
- package/dist/{index-6rk44cer.js → index-c81tggen.js} +1 -1
- package/dist/{index-0twg41mh.js → index-ejgp0z9p.js} +1 -1
- package/dist/{index-hre29c1a.js → index-esacb9d0.js} +1 -1
- package/dist/{index-5a9kwapd.js → index-ewta5h87.js} +4 -4
- package/dist/{index-6r99v53h.js → index-j7n64sg4.js} +162 -60
- package/dist/{index-r3tdqqtq.js → index-jm62g83a.js} +180 -64
- package/dist/{index-anwy2mfb.js → index-pc49a7zt.js} +162 -31
- package/dist/{index-ydhymf0b.js → index-qmm8xpbc.js} +4 -4
- package/dist/{index-3n376ann.js → index-tedck05r.js} +4 -4
- package/dist/{index-j2w79s9r.js → index-tm799pq7.js} +1 -1
- package/dist/{index-01h7tqe3.js → index-tr4ep2ej.js} +21 -6
- package/dist/{index-wvbg9m0h.js → index-wqwjawer.js} +27 -11
- package/dist/index-xe34pwb6.js +119 -0
- package/dist/{index-xn9efn18.js → index-xjaf9g90.js} +13 -6
- package/dist/{index-6nqz8hsz.js → index-y915t3ey.js} +1 -1
- package/dist/{index-41bma6qs.js → index-yzzxb5e1.js} +2 -2
- package/dist/{index-901exj0f.js → index-zk6gtf43.js} +45 -9
- package/dist/index.js +27 -27
- package/dist/{message-index-bounded-f6fc00ze.js → message-index-bounded-d3x8rhpz.js} +4 -4
- package/dist/migration-worker.js +1 -1
- package/dist/{project-embedding-registry-8je0xg18.js → project-embedding-registry-az68q792.js} +5 -5
- package/dist/raw-ordinal-warmup-worker.js +5 -5
- package/dist/{read-session-chunk-y2ew3630.js → read-session-chunk-70r1snq3.js} +3 -3
- package/dist/{recomp-orchestrator-ggtcvb9g.js → recomp-orchestrator-cn4r2gz6.js} +15 -15
- package/dist/{render-q8c6wrq9.js → render-g45k3gts.js} +10 -10
- package/dist/{search-archive-pz1jf655.js → search-archive-s9t3exc1.js} +9 -7
- package/dist/{search-gjyrwapc.js → search-b0cb342r.js} +13 -13
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/{storage-tags-7raphcw6.js → storage-tags-xvbje7jm.js} +2 -2
- package/dist/{store-yr443ye8.js → store-91kawq9a.js} +2 -2
- package/dist/{store-reader-qbq6q4v0.js → store-reader-dgh3ssxx.js} +1 -1
- package/dist/tools/ctx-expand/search-archive.d.ts +3 -2
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-expand/v2-archive-reader.d.ts +2 -0
- package/dist/tools/ctx-expand/v2-archive-reader.d.ts.map +1 -1
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-pmzdd3s2.js → transform-postprocess-phase-r1xhsjrh.js} +16 -16
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +3 -3
- package/dist/v2/{compartment-chunk-embedding-w7ht0t9v.js → compartment-chunk-embedding-a7ddvz7v.js} +2 -2
- package/dist/v2/{context-qqbpzk1q.js → context-2hssw26q.js} +351 -111
- package/dist/v2/{embedding-backfill-95m72gxa.js → embedding-backfill-gveter8p.js} +6 -6
- package/dist/v2/embedding-worker.js +3 -3
- package/dist/v2/fold/memory-cache.d.ts +2 -0
- package/dist/v2/fold/memory-cache.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +22 -5
- 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.map +1 -1
- package/dist/v2/hooks/session-project-backfill.d.ts +2 -1
- package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-70g28hyg.js → message-index-bounded-tbwrff24.js} +4 -4
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-fcxf4qht.js → project-embedding-registry-2zeycxek.js} +5 -5
- package/dist/v2/raw-ordinal-warmup-worker.js +5 -5
- package/dist/v2/{read-session-chunk-9rf0n9e6.js → read-session-chunk-cvgsfsgr.js} +3 -3
- package/dist/v2/{recomp-orchestrator-cwghhjc9.js → recomp-orchestrator-k4cj62f2.js} +15 -15
- package/dist/v2/{render-e852zmxz.js → render-ys7a3zks.js} +10 -10
- package/dist/v2/{search-archive-tmn6b5w8.js → search-archive-k2yh0jj3.js} +9 -7
- package/dist/v2/{search-jd3vczhn.js → search-x1cac8t6.js} +12 -12
- package/dist/v2/{server-vsqmkvxc.js → server-00adcfjd.js} +1 -1
- package/dist/v2/{server-rkj44mez.js → server-476anw1w.js} +1 -1
- package/dist/v2/{server-barj0mjz.js → server-5016ccyn.js} +1 -1
- package/dist/v2/{server-72k2r3kt.js → server-6aj72z52.js} +4 -4
- package/dist/v2/{server-7x5a46hf.js → server-6nh36020.js} +70 -61
- package/dist/v2/{server-fj3pekz2.js → server-88pjnecb.js} +1 -1
- package/dist/v2/{server-js2v309w.js → server-bfct1yvb.js} +99 -51
- package/dist/v2/{server-6t3asmx8.js → server-cd93xyyx.js} +162 -31
- package/dist/v2/{server-ysjjcatk.js → server-cvm1qrqc.js} +2 -2
- package/dist/v2/{server-rz6g5xne.js → server-e6xneh68.js} +1 -1
- package/dist/v2/{server-d4trxrj3.js → server-gj259dqy.js} +45 -9
- package/dist/v2/{server-8ps3717t.js → server-prrx17q3.js} +4 -4
- package/dist/v2/{server-7e89a2kf.js → server-qy58c11s.js} +13 -6
- package/dist/v2/{server-9011eteb.js → server-s81b3nct.js} +2 -2
- package/dist/v2/{server-p4g021y5.js → server-s8mk882p.js} +27 -11
- package/dist/v2/{server-mgxqfprb.js → server-srtq37nh.js} +1 -1
- package/dist/v2/{server-bvr9xs8h.js → server-vbr1rdkg.js} +6 -6
- package/dist/v2/{server-vtgeyhq6.js → server-vtkbxzw1.js} +21 -6
- package/dist/v2/{server-ps6zrzwj.js → server-xepfjgv5.js} +162 -60
- package/dist/v2/server-y0pd600x.js +119 -0
- package/dist/v2/{server-b4efn08m.js → server-zc8s06gx.js} +1 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-wgsemtw1.js → storage-tags-y20j3jdp.js} +2 -2
- package/dist/v2/{store-enef5jcn.js → store-b95snz31.js} +2 -2
- package/dist/v2/{store-reader-jbaqv1yp.js → store-reader-qt2msa8z.js} +1 -1
- package/dist/v2/store-reader.d.ts +1 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-dm1aeqk2.js → v2-archive-reader-q92kwkr5.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-cke368np.js → wrapup-orchestrator-ydqkxkhj.js} +15 -15
- package/dist/{v2-archive-reader-39ye0d3b.js → v2-archive-reader-x62hsr4c.js} +1 -1
- package/dist/{wrapup-orchestrator-ggnk0r4r.js → wrapup-orchestrator-kt81d6et.js} +16 -16
- package/package.json +1 -1
- package/src/config/schema/magic-context.ts +1 -1
- package/src/shared/storage-file-mutex-review.test.ts +110 -0
- package/src/shared/storage-file-mutex.ts +12 -0
- package/dist/index-52x68mj4.js +0 -58
- package/dist/v2/server-52x68mj4.js +0 -58
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
StaleRouteHandleError,
|
|
7
7
|
SubcClient,
|
|
8
8
|
isConsumerReconnectTransient
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-j7n64sg4.js";
|
|
10
10
|
import {
|
|
11
11
|
getHarness2
|
|
12
12
|
} from "./index-pavzsdc6.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
trackCompartmentChunkSearchPool2,
|
|
24
24
|
peekCompartmentChunkSearchPool2,
|
|
25
25
|
warmCompartmentChunkSearchPool2
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-ejgp0z9p.js";
|
|
27
27
|
import {
|
|
28
28
|
saveCommitEmbedding,
|
|
29
29
|
loadProjectCommitEmbeddings,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
enqueueShadowEmbeddingItems2,
|
|
40
40
|
getProjectEmbeddingSnapshot2,
|
|
41
41
|
embedItemsForProject2
|
|
42
|
-
} from "./index-
|
|
42
|
+
} from "./index-tedck05r.js";
|
|
43
43
|
import {
|
|
44
44
|
recordEmbeddingMeasurement
|
|
45
45
|
} from "./index-2amn2s73.js";
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
sanitizeFtsQuery,
|
|
56
56
|
searchMemoriesFTS,
|
|
57
57
|
searchMemoriesFTSUnion
|
|
58
|
-
} from "./index-
|
|
58
|
+
} from "./index-qmm8xpbc.js";
|
|
59
59
|
import {
|
|
60
60
|
ModuleMemoryAuthorityError2,
|
|
61
61
|
getMemoriesByProject2,
|
|
@@ -65,24 +65,25 @@ import {
|
|
|
65
65
|
import {
|
|
66
66
|
matchedSearchSnippet,
|
|
67
67
|
getIndexedMessageCorpusSize
|
|
68
|
-
} from "./index-
|
|
68
|
+
} from "./index-esacb9d0.js";
|
|
69
69
|
import {
|
|
70
70
|
getMessageIndexEpoch,
|
|
71
71
|
isMessageIndexSearchable,
|
|
72
72
|
withMemoryHintContent,
|
|
73
73
|
autoSearchRelevance,
|
|
74
74
|
recordAutoSearchLane
|
|
75
|
-
} from "./index-
|
|
75
|
+
} from "./index-47hst5me.js";
|
|
76
76
|
import {
|
|
77
77
|
ensureMemoryEmbeddings2
|
|
78
|
-
} from "./index-
|
|
78
|
+
} from "./index-3ywyr4zx.js";
|
|
79
79
|
import {
|
|
80
80
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
81
|
-
withMessageFtsSessionFilter
|
|
82
|
-
|
|
81
|
+
withMessageFtsSessionFilter,
|
|
82
|
+
messageTextVisibleInRequestSql
|
|
83
|
+
} from "./index-xe34pwb6.js";
|
|
83
84
|
import {
|
|
84
85
|
isRecord
|
|
85
|
-
} from "./index-
|
|
86
|
+
} from "./index-zk6gtf43.js";
|
|
86
87
|
import {
|
|
87
88
|
resolveWorkspaceShareCategories,
|
|
88
89
|
resolveWorkspaceIdentitySet,
|
|
@@ -1815,6 +1816,7 @@ var messageSearchDiagnosticStatements = new WeakMap;
|
|
|
1815
1816
|
var sessionFirstMessageSearchDiagnosticStatements = new WeakMap;
|
|
1816
1817
|
var messageSearchDiagnosticStatementsWithDateRange = new WeakMap;
|
|
1817
1818
|
var batchedMessageSearchStatements = new WeakMap;
|
|
1819
|
+
var visibilityFtsStatements = new WeakMap;
|
|
1818
1820
|
var batchedFtsCountStatements = new WeakMap;
|
|
1819
1821
|
function createUnifiedSearchDiagnostics2() {
|
|
1820
1822
|
return {
|
|
@@ -1834,6 +1836,7 @@ function searchMessageHistory2(db, request) {
|
|
|
1834
1836
|
query: request.query,
|
|
1835
1837
|
limit: request.limit,
|
|
1836
1838
|
maxOrdinal: request.maxOrdinal,
|
|
1839
|
+
includeDroppedTailMessages: request.includeDroppedTailMessages,
|
|
1837
1840
|
probes: request.probes,
|
|
1838
1841
|
relaxedRecall: request.relaxedRecall,
|
|
1839
1842
|
diagnostics,
|
|
@@ -2073,6 +2076,46 @@ function getMessageSearchDiagnosticStatementWithDateRange(db) {
|
|
|
2073
2076
|
}
|
|
2074
2077
|
return statement;
|
|
2075
2078
|
}
|
|
2079
|
+
var MESSAGE_FTS_VISIBLE = messageTextVisibleInRequestSql("message_history_fts.session_id", "message_history_fts.message_id", "CAST(message_history_fts.message_ordinal AS INTEGER)", "?");
|
|
2080
|
+
function getVisibilityFtsStatement(db, sessionFirst, dated, diagnostics) {
|
|
2081
|
+
let statements = visibilityFtsStatements.get(db);
|
|
2082
|
+
if (!statements) {
|
|
2083
|
+
statements = new Map;
|
|
2084
|
+
visibilityFtsStatements.set(db, statements);
|
|
2085
|
+
}
|
|
2086
|
+
const key = `${sessionFirst}:${dated}:${diagnostics}`;
|
|
2087
|
+
let statement = statements.get(key);
|
|
2088
|
+
if (statement)
|
|
2089
|
+
return statement;
|
|
2090
|
+
const from = `FROM message_history_fts${dated ? `
|
|
2091
|
+
JOIN message_fts_rowid_map AS map
|
|
2092
|
+
ON map.session_id = message_history_fts.session_id
|
|
2093
|
+
AND map.fts_rowid = message_history_fts.rowid` : ""}
|
|
2094
|
+
WHERE ${sessionFirst || dated ? MESSAGE_FTS_SESSION_FILTER_SQL : ""}message_history_fts.session_id = ?
|
|
2095
|
+
AND message_history_fts MATCH ?${dated ? " AND map.message_time_ms BETWEEN ? AND ?" : ""}`;
|
|
2096
|
+
const columns = `message_history_fts.message_ordinal AS messageOrdinal,
|
|
2097
|
+
message_history_fts.message_id AS messageId, message_history_fts.role AS role,
|
|
2098
|
+
message_history_fts.content AS content, bm25(message_history_fts) AS ftsRank`;
|
|
2099
|
+
statement = db.prepare(diagnostics ? `
|
|
2100
|
+
WITH matches AS MATERIALIZED (
|
|
2101
|
+
SELECT ${columns}, ${MESSAGE_FTS_VISIBLE} AS visible ${from}
|
|
2102
|
+
), eligible AS (
|
|
2103
|
+
SELECT * FROM matches WHERE NOT visible
|
|
2104
|
+
ORDER BY ftsRank, CAST(messageOrdinal AS INTEGER) LIMIT ?
|
|
2105
|
+
), summary AS (
|
|
2106
|
+
SELECT COUNT(*) AS suppressedCount FROM matches WHERE visible
|
|
2107
|
+
)
|
|
2108
|
+
SELECT messageOrdinal, messageId, role, content, ftsRank, suppressedCount, 0 AS summaryOnly
|
|
2109
|
+
FROM eligible CROSS JOIN summary
|
|
2110
|
+
UNION ALL
|
|
2111
|
+
SELECT NULL, NULL, NULL, NULL, NULL, suppressedCount, 1 FROM summary
|
|
2112
|
+
WHERE NOT EXISTS (SELECT 1 FROM eligible)
|
|
2113
|
+
ORDER BY summaryOnly, ftsRank, messageOrdinal
|
|
2114
|
+
` : `SELECT ${columns} ${from} AND NOT (${MESSAGE_FTS_VISIBLE})
|
|
2115
|
+
ORDER BY ftsRank, CAST(messageOrdinal AS INTEGER) LIMIT ?`);
|
|
2116
|
+
statements.set(key, statement);
|
|
2117
|
+
return statement;
|
|
2118
|
+
}
|
|
2076
2119
|
function getBatchedFtsCountStatement(db, queryCount, cutoff, dateRange, sessionFirst) {
|
|
2077
2120
|
let statements = batchedFtsCountStatements.get(db);
|
|
2078
2121
|
if (!statements) {
|
|
@@ -2225,11 +2268,12 @@ function selectSemanticCandidates(args) {
|
|
|
2225
2268
|
function mergeMemoryResults(args) {
|
|
2226
2269
|
const memoryById = new Map(args.memories.map((memory) => [memory.id, memory]));
|
|
2227
2270
|
const candidateIds = new Set([...args.semanticScores.keys(), ...args.ftsScores.keys()]);
|
|
2228
|
-
const
|
|
2229
|
-
const
|
|
2271
|
+
const ranked = [];
|
|
2272
|
+
const suppressionLimit = args.suppressionLimit ?? 0;
|
|
2273
|
+
const isVisible = (id) => args.visibleMemoryIds?.has(id) ?? false;
|
|
2230
2274
|
for (const id of candidateIds) {
|
|
2231
2275
|
const memory = memoryById.get(id);
|
|
2232
|
-
if (!memory) {
|
|
2276
|
+
if (!memory || suppressionLimit === 0 && isVisible(id)) {
|
|
2233
2277
|
continue;
|
|
2234
2278
|
}
|
|
2235
2279
|
const semanticScore = args.semanticScores.get(id);
|
|
@@ -2249,11 +2293,13 @@ function mergeMemoryResults(args) {
|
|
|
2249
2293
|
if (score <= 0) {
|
|
2250
2294
|
continue;
|
|
2251
2295
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2296
|
+
ranked.push({ memory, score, matchType });
|
|
2297
|
+
}
|
|
2298
|
+
ranked.sort((left, right) => right.score !== left.score ? right.score - left.score : left.memory.id - right.memory.id);
|
|
2299
|
+
const suppressedVisibleIds = ranked.slice(0, suppressionLimit).map(({ memory }) => memory.id).filter(isVisible);
|
|
2300
|
+
const hidden = suppressionLimit === 0 ? ranked : ranked.filter(({ memory }) => !isVisible(memory.id));
|
|
2301
|
+
return {
|
|
2302
|
+
results: hidden.slice(0, args.limit).map(({ memory, score, matchType }) => withMemoryHintContent({
|
|
2257
2303
|
source: "memory",
|
|
2258
2304
|
content: previewText(memory.content),
|
|
2259
2305
|
score,
|
|
@@ -2261,16 +2307,8 @@ function mergeMemoryResults(args) {
|
|
|
2261
2307
|
category: memory.category,
|
|
2262
2308
|
matchType,
|
|
2263
2309
|
sourceName: args.sourceNameByMemoryId?.get(memory.id)
|
|
2264
|
-
}, memory.content))
|
|
2265
|
-
|
|
2266
|
-
return {
|
|
2267
|
-
results: results.sort((left, right) => {
|
|
2268
|
-
if (right.score !== left.score) {
|
|
2269
|
-
return right.score - left.score;
|
|
2270
|
-
}
|
|
2271
|
-
return left.memoryId - right.memoryId;
|
|
2272
|
-
}).slice(0, args.limit),
|
|
2273
|
-
suppressedVisibleIds: suppressedVisibleIds.sort((left, right) => left - right)
|
|
2310
|
+
}, memory.content)),
|
|
2311
|
+
suppressedVisibleIds
|
|
2274
2312
|
};
|
|
2275
2313
|
}
|
|
2276
2314
|
async function searchMemories(args) {
|
|
@@ -2346,6 +2384,7 @@ async function searchMemories(args) {
|
|
|
2346
2384
|
semanticScores,
|
|
2347
2385
|
ftsScores,
|
|
2348
2386
|
limit: args.limit,
|
|
2387
|
+
suppressionLimit: args.suppressionLimit,
|
|
2349
2388
|
visibleMemoryIds: args.visibleMemoryIds,
|
|
2350
2389
|
sourceNameByMemoryId
|
|
2351
2390
|
});
|
|
@@ -2355,12 +2394,12 @@ function linearDecayScore(rank, total) {
|
|
|
2355
2394
|
return 0;
|
|
2356
2395
|
return Math.max(0, 1 - rank / total);
|
|
2357
2396
|
}
|
|
2358
|
-
function normalizeMessageSearchRow(row, cutoff) {
|
|
2397
|
+
function normalizeMessageSearchRow(row, cutoff, includeDroppedTailMessages = false) {
|
|
2359
2398
|
const messageOrdinal = getMessageOrdinal(row.messageOrdinal);
|
|
2360
2399
|
if (messageOrdinal === null || typeof row.messageId !== "string" || typeof row.role !== "string" || typeof row.content !== "string") {
|
|
2361
2400
|
return null;
|
|
2362
2401
|
}
|
|
2363
|
-
if (cutoff !== null && messageOrdinal > cutoff)
|
|
2402
|
+
if (cutoff !== null && messageOrdinal > cutoff && !includeDroppedTailMessages)
|
|
2364
2403
|
return null;
|
|
2365
2404
|
return {
|
|
2366
2405
|
messageOrdinal,
|
|
@@ -2369,12 +2408,14 @@ function normalizeMessageSearchRow(row, cutoff) {
|
|
|
2369
2408
|
content: row.content
|
|
2370
2409
|
};
|
|
2371
2410
|
}
|
|
2372
|
-
function runMessageFtsQuery(db, sessionId, ftsQuery, fetchLimit, cutoff, dateRange, sessionFirst) {
|
|
2411
|
+
function runMessageFtsQuery(db, sessionId, ftsQuery, fetchLimit, cutoff, dateRange, sessionFirst, includeDroppedTailMessages) {
|
|
2373
2412
|
if (ftsQuery.length === 0)
|
|
2374
2413
|
return [];
|
|
2375
2414
|
let rawRows;
|
|
2376
2415
|
const matchQuery = contentOnlyMessageQuery(ftsQuery);
|
|
2377
|
-
if (
|
|
2416
|
+
if (cutoff !== null && includeDroppedTailMessages) {
|
|
2417
|
+
rawRows = getVisibilityFtsStatement(db, sessionFirst, dateRange !== null, false).all(...sessionFirst || dateRange !== null ? [sessionId, sessionId] : [sessionId], matchQuery, ...dateRange ? [dateRange.from, dateRange.to] : [], cutoff, fetchLimit);
|
|
2418
|
+
} else if (dateRange !== null) {
|
|
2378
2419
|
const bindings = [
|
|
2379
2420
|
sessionId,
|
|
2380
2421
|
sessionId,
|
|
@@ -2393,7 +2434,7 @@ function runMessageFtsQuery(db, sessionId, ftsQuery, fetchLimit, cutoff, dateRan
|
|
|
2393
2434
|
const rows = rawRows.map((row) => row);
|
|
2394
2435
|
const result = [];
|
|
2395
2436
|
for (const row of rows) {
|
|
2396
|
-
const normalized = normalizeMessageSearchRow(row, cutoff);
|
|
2437
|
+
const normalized = normalizeMessageSearchRow(row, cutoff, includeDroppedTailMessages);
|
|
2397
2438
|
if (normalized)
|
|
2398
2439
|
result.push(normalized);
|
|
2399
2440
|
}
|
|
@@ -2403,28 +2444,28 @@ function runMessageFtsQueryWithDiagnostics(args) {
|
|
|
2403
2444
|
if (args.ftsQuery.length === 0)
|
|
2404
2445
|
return { rows: [], suppressedCount: 0 };
|
|
2405
2446
|
const matchQuery = contentOnlyMessageQuery(args.ftsQuery);
|
|
2406
|
-
const rawRows = (args.dateRange === null ? getMessageSearchDiagnosticStatement(args.db, args.sessionFirst).all(...args.sessionFirst ? [args.sessionId, args.sessionId] : [args.sessionId], matchQuery, args.cutoff, args.fetchLimit, args.cutoff) : getMessageSearchDiagnosticStatementWithDateRange(args.db).all(args.sessionId, args.sessionId, matchQuery, args.dateRange.from, args.dateRange.to, args.cutoff, args.fetchLimit, args.cutoff)).map((row) => row);
|
|
2447
|
+
const rawRows = (args.includeDroppedTailMessages ? getVisibilityFtsStatement(args.db, args.sessionFirst, args.dateRange !== null, true).all(args.cutoff, ...args.sessionFirst || args.dateRange !== null ? [args.sessionId, args.sessionId] : [args.sessionId], matchQuery, ...args.dateRange ? [args.dateRange.from, args.dateRange.to] : [], args.fetchLimit) : args.dateRange === null ? getMessageSearchDiagnosticStatement(args.db, args.sessionFirst).all(...args.sessionFirst ? [args.sessionId, args.sessionId] : [args.sessionId], matchQuery, args.cutoff, args.fetchLimit, args.cutoff) : getMessageSearchDiagnosticStatementWithDateRange(args.db).all(args.sessionId, args.sessionId, matchQuery, args.dateRange.from, args.dateRange.to, args.cutoff, args.fetchLimit, args.cutoff)).map((row) => row);
|
|
2407
2448
|
const suppressedCount = rawRows[0]?.suppressedCount ?? 0;
|
|
2408
2449
|
const rows = [];
|
|
2409
2450
|
for (const row of rawRows) {
|
|
2410
2451
|
if (row.summaryOnly === 1)
|
|
2411
2452
|
continue;
|
|
2412
|
-
const normalized = normalizeMessageSearchRow(row, args.cutoff);
|
|
2453
|
+
const normalized = normalizeMessageSearchRow(row, args.cutoff, args.includeDroppedTailMessages);
|
|
2413
2454
|
if (normalized)
|
|
2414
2455
|
rows.push(normalized);
|
|
2415
2456
|
}
|
|
2416
2457
|
return { rows, suppressedCount };
|
|
2417
2458
|
}
|
|
2418
|
-
function getBatchedMessageSearchStatement(db, queryCount, cutoff, dateRange, sessionFirst) {
|
|
2459
|
+
function getBatchedMessageSearchStatement(db, queryCount, cutoff, dateRange, sessionFirst, includeDroppedTailMessages) {
|
|
2419
2460
|
let statements = batchedMessageSearchStatements.get(db);
|
|
2420
2461
|
if (!statements) {
|
|
2421
2462
|
statements = new Map;
|
|
2422
2463
|
batchedMessageSearchStatements.set(db, statements);
|
|
2423
2464
|
}
|
|
2424
|
-
const key = `${queryCount}:${cutoff === null ? "all" : "cutoff"}:${dateRange === null ? "all-dates" : "dated"}:${sessionFirst}`;
|
|
2465
|
+
const key = `${queryCount}:${cutoff === null ? "all" : "cutoff"}:${dateRange === null ? "all-dates" : "dated"}:${sessionFirst}:${includeDroppedTailMessages}`;
|
|
2425
2466
|
let statement = statements.get(key);
|
|
2426
2467
|
if (!statement) {
|
|
2427
|
-
const cutoffSql = cutoff === null ? "" : " AND CAST(message_history_fts.message_ordinal AS INTEGER) <= ?";
|
|
2468
|
+
const cutoffSql = cutoff === null ? "" : includeDroppedTailMessages ? ` AND NOT (${MESSAGE_FTS_VISIBLE})` : " AND CAST(message_history_fts.message_ordinal AS INTEGER) <= ?";
|
|
2428
2469
|
const joinSql = dateRange === null ? "" : ` JOIN message_fts_rowid_map AS map
|
|
2429
2470
|
ON map.session_id = message_history_fts.session_id
|
|
2430
2471
|
AND map.fts_rowid = message_history_fts.rowid`;
|
|
@@ -2450,7 +2491,7 @@ ORDER BY queryIndex ASC, ftsRank ASC`);
|
|
|
2450
2491
|
}
|
|
2451
2492
|
return statement;
|
|
2452
2493
|
}
|
|
2453
|
-
function runMessageFtsQueriesBatch(db, sessionId, ftsQueries, fetchLimit, cutoff, dateRange, sessionFirst) {
|
|
2494
|
+
function runMessageFtsQueriesBatch(db, sessionId, ftsQueries, fetchLimit, cutoff, dateRange, sessionFirst, includeDroppedTailMessages) {
|
|
2454
2495
|
if (ftsQueries.length === 0)
|
|
2455
2496
|
return [];
|
|
2456
2497
|
const bindings = [];
|
|
@@ -2464,13 +2505,13 @@ function runMessageFtsQueriesBatch(db, sessionId, ftsQueries, fetchLimit, cutoff
|
|
|
2464
2505
|
bindings.push(cutoff);
|
|
2465
2506
|
bindings.push(fetchLimit);
|
|
2466
2507
|
}
|
|
2467
|
-
const rows = getBatchedMessageSearchStatement(db, ftsQueries.length, cutoff, dateRange, sessionFirst).all(...bindings);
|
|
2508
|
+
const rows = getBatchedMessageSearchStatement(db, ftsQueries.length, cutoff, dateRange, sessionFirst, includeDroppedTailMessages).all(...bindings);
|
|
2468
2509
|
const result = Array.from({ length: ftsQueries.length }, () => []);
|
|
2469
2510
|
for (const row of rows) {
|
|
2470
2511
|
if (typeof row.queryIndex !== "number" || row.queryIndex < 0 || row.queryIndex >= result.length) {
|
|
2471
2512
|
continue;
|
|
2472
2513
|
}
|
|
2473
|
-
const normalized = normalizeMessageSearchRow(row, cutoff);
|
|
2514
|
+
const normalized = normalizeMessageSearchRow(row, cutoff, includeDroppedTailMessages);
|
|
2474
2515
|
if (normalized)
|
|
2475
2516
|
result[row.queryIndex].push(normalized);
|
|
2476
2517
|
}
|
|
@@ -2489,6 +2530,7 @@ function searchMessages(args) {
|
|
|
2489
2530
|
}
|
|
2490
2531
|
function searchMessagesInSnapshot(args, sessionFirst) {
|
|
2491
2532
|
const cutoff = args.maxOrdinal != null && args.maxOrdinal >= 0 ? args.maxOrdinal : null;
|
|
2533
|
+
const includeDroppedTailMessages = args.includeDroppedTailMessages === true;
|
|
2492
2534
|
const baselineFetchLimit = cutoff !== null ? args.limit * 3 : args.limit;
|
|
2493
2535
|
const captureFetchLimit = args.capture ? cutoff !== null ? args.capture.limit * 3 : args.capture.limit : 0;
|
|
2494
2536
|
const fetchLimit = Math.max(baselineFetchLimit, captureFetchLimit);
|
|
@@ -2502,15 +2544,16 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2502
2544
|
fetchLimit,
|
|
2503
2545
|
cutoff,
|
|
2504
2546
|
dateRange: args.dateRange,
|
|
2505
|
-
sessionFirst
|
|
2547
|
+
sessionFirst,
|
|
2548
|
+
includeDroppedTailMessages
|
|
2506
2549
|
}) : {
|
|
2507
|
-
rows: runMessageFtsQuery(args.db, args.sessionId, baseQuery, fetchLimit, cutoff, args.dateRange, sessionFirst),
|
|
2550
|
+
rows: runMessageFtsQuery(args.db, args.sessionId, baseQuery, fetchLimit, cutoff, args.dateRange, sessionFirst, includeDroppedTailMessages),
|
|
2508
2551
|
suppressedCount: 0
|
|
2509
2552
|
};
|
|
2510
2553
|
if (args.diagnostics) {
|
|
2511
2554
|
args.diagnostics.suppressedLiveMessageMatches = outcome.suppressedCount;
|
|
2512
2555
|
}
|
|
2513
|
-
const rows = outcome.rows.length > 0 || !args.relaxedRecall ? outcome.rows : runMessageFtsQuery(args.db, args.sessionId, relaxedFtsQuery(args.query), fetchLimit, cutoff, args.dateRange, sessionFirst);
|
|
2556
|
+
const rows = outcome.rows.length > 0 || !args.relaxedRecall ? outcome.rows : runMessageFtsQuery(args.db, args.sessionId, relaxedFtsQuery(args.query), fetchLimit, cutoff, args.dateRange, sessionFirst, includeDroppedTailMessages);
|
|
2514
2557
|
const renderRows = (limit) => {
|
|
2515
2558
|
const filtered = rows.slice(0, limit);
|
|
2516
2559
|
return filtered.map((row, rank) => ({
|
|
@@ -2519,7 +2562,8 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2519
2562
|
score: linearDecayScore(rank, filtered.length),
|
|
2520
2563
|
messageOrdinal: row.messageOrdinal,
|
|
2521
2564
|
messageId: row.messageId,
|
|
2522
|
-
role: row.role
|
|
2565
|
+
role: row.role,
|
|
2566
|
+
...includeDroppedTailMessages && cutoff !== null && row.messageOrdinal > cutoff ? { droppedFromContext: true } : {}
|
|
2523
2567
|
}));
|
|
2524
2568
|
};
|
|
2525
2569
|
if (args.capture)
|
|
@@ -2537,7 +2581,8 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2537
2581
|
fetchLimit,
|
|
2538
2582
|
cutoff,
|
|
2539
2583
|
dateRange: args.dateRange,
|
|
2540
|
-
sessionFirst
|
|
2584
|
+
sessionFirst,
|
|
2585
|
+
includeDroppedTailMessages
|
|
2541
2586
|
}) : null;
|
|
2542
2587
|
if (args.diagnostics) {
|
|
2543
2588
|
args.diagnostics.suppressedLiveMessageMatches = baseOutcome?.suppressedCount ?? 0;
|
|
@@ -2546,7 +2591,7 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2546
2591
|
...!collectBaseDiagnostics && baseQuery.length > 0 ? [baseQuery] : [],
|
|
2547
2592
|
...sanitizedProbes.map((entry) => entry.query)
|
|
2548
2593
|
];
|
|
2549
|
-
const rowsByQuery = runMessageFtsQueriesBatch(args.db, args.sessionId, searchQueries, fetchLimit, cutoff, args.dateRange, sessionFirst);
|
|
2594
|
+
const rowsByQuery = runMessageFtsQueriesBatch(args.db, args.sessionId, searchQueries, fetchLimit, cutoff, args.dateRange, sessionFirst, includeDroppedTailMessages);
|
|
2550
2595
|
const queryLists = [];
|
|
2551
2596
|
let queryIndex = 0;
|
|
2552
2597
|
if (baseQuery.length > 0) {
|
|
@@ -2596,7 +2641,8 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2596
2641
|
score: linearDecayScore(rank, ranked.length),
|
|
2597
2642
|
messageOrdinal: entry.row.messageOrdinal,
|
|
2598
2643
|
messageId: entry.row.messageId,
|
|
2599
|
-
role: entry.row.role
|
|
2644
|
+
role: entry.row.role,
|
|
2645
|
+
...includeDroppedTailMessages && cutoff !== null && entry.row.messageOrdinal > cutoff ? { droppedFromContext: true } : {}
|
|
2600
2646
|
}));
|
|
2601
2647
|
};
|
|
2602
2648
|
if (args.capture)
|
|
@@ -3136,6 +3182,7 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3136
3182
|
limit: tierLimit,
|
|
3137
3183
|
captureLimit: lanes ? 75 : undefined,
|
|
3138
3184
|
maxOrdinal: options.maxMessageOrdinal,
|
|
3185
|
+
includeDroppedTailMessages: options.includeDroppedTailMessages,
|
|
3139
3186
|
probes: messageProbes,
|
|
3140
3187
|
relaxedRecall: options.explicitSearch,
|
|
3141
3188
|
collectDiagnostics: options.diagnostics !== undefined,
|
|
@@ -3218,6 +3265,7 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3218
3265
|
queryGeneration: queryContract?.generation ?? embeddingSnapshot?.generation,
|
|
3219
3266
|
workspace,
|
|
3220
3267
|
visibleMemoryIds: options.visibleMemoryIds,
|
|
3268
|
+
suppressionLimit: options.diagnostics && options.visibleMemoryIds?.size ? limit : undefined,
|
|
3221
3269
|
backfillMemoryEmbeddings: options.backfillMemoryEmbeddings,
|
|
3222
3270
|
lanes,
|
|
3223
3271
|
dateRange
|
|
@@ -3387,10 +3435,10 @@ function formatUnifiedSearchResult(result, index, currentSessionId) {
|
|
|
3387
3435
|
].join(`
|
|
3388
3436
|
`);
|
|
3389
3437
|
}
|
|
3390
|
-
const expandStart = Math.max(1, result.messageOrdinal - 3);
|
|
3391
|
-
const expandEnd = result.messageOrdinal + 3;
|
|
3438
|
+
const expandStart = result.droppedFromContext ? result.messageOrdinal : Math.max(1, result.messageOrdinal - 3);
|
|
3439
|
+
const expandEnd = result.droppedFromContext ? result.messageOrdinal : result.messageOrdinal + 3;
|
|
3392
3440
|
return [
|
|
3393
|
-
`[${index}] [message] score=${result.score.toFixed(2)} ordinal=${result.messageOrdinal} range=${expandStart}-${expandEnd} role=${result.role}`,
|
|
3441
|
+
`[${index}] [message] score=${result.score.toFixed(2)} ordinal=${result.messageOrdinal} range=${expandStart}-${expandEnd} role=${result.role}${result.droppedFromContext ? ` (dropped from context; recover with ctx_expand(message=${result.messageOrdinal}))` : ""}`,
|
|
3394
3442
|
result.content
|
|
3395
3443
|
].join(`
|
|
3396
3444
|
`);
|
|
@@ -3399,7 +3447,7 @@ function formatSearchDiagnosticLines(results, diagnostics) {
|
|
|
3399
3447
|
if (!diagnostics)
|
|
3400
3448
|
return [];
|
|
3401
3449
|
const lines = [];
|
|
3402
|
-
const visibleIds =
|
|
3450
|
+
const visibleIds = diagnostics.suppressedVisibleMemoryIds;
|
|
3403
3451
|
if (visibleIds.length > 0) {
|
|
3404
3452
|
const count = visibleIds.length;
|
|
3405
3453
|
const noun = count === 1 ? "match" : "matches";
|
|
@@ -1084,7 +1084,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1084
1084
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1085
1085
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1086
1086
|
return;
|
|
1087
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1087
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-70r1snq3.js"));
|
|
1088
1088
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-pz5981mf.js"));
|
|
1089
1089
|
if (signal.aborted)
|
|
1090
1090
|
return;
|
|
@@ -3,19 +3,19 @@ import {
|
|
|
3
3
|
} from "./index-ywrz4wy2.js";
|
|
4
4
|
import {
|
|
5
5
|
clearEmergencyRecovery
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-zk6gtf43.js";
|
|
7
7
|
import {
|
|
8
8
|
requestPendingMaterialization,
|
|
9
9
|
dropSlot
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-pc49a7zt.js";
|
|
11
11
|
import {
|
|
12
12
|
pausedRecompReason,
|
|
13
13
|
executeContextRecomp
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-2gewejcz.js";
|
|
15
15
|
import {
|
|
16
16
|
renderUserFacingFailure,
|
|
17
17
|
userFacingFailureCode
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-qmm8xpbc.js";
|
|
19
19
|
|
|
20
20
|
// src/hooks/magic-context/recomp-orchestrator.ts
|
|
21
21
|
function resolveLiveModelKey(liveSessionState, sessionId) {
|