@cortexkit/opencode-magic-context 0.49.93 → 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-jpxthqxg.js → context-h9x9m2p3.js} +176 -61
- package/dist/{embedding-backfill-6wzc4p2n.js → embedding-backfill-wdrqkw09.js} +5 -5
- package/dist/embedding-worker.js +2 -2
- 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-synapse.d.ts +18 -5
- package/dist/features/magic-context/memory/embedding-synapse.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/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-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 +3 -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-za1yx1m4.js → index-2gewejcz.js} +17 -8
- package/dist/{index-hee64h6k.js → index-2v9qpmb3.js} +5 -5
- package/dist/{index-g5c67kay.js → index-3tmbvn0z.js} +8 -8
- package/dist/{index-5zrzg8r1.js → index-3ywyr4zx.js} +1 -1
- package/dist/{index-kty5k23y.js → index-47hst5me.js} +1 -1
- package/dist/{index-g6y2wk32.js → index-7dzaamqg.js} +6 -6
- package/dist/{index-dr6bd4c8.js → index-7r11k4xr.js} +1 -1
- package/dist/{index-g9qtxv87.js → index-7skgrbsg.js} +100 -52
- package/dist/{index-gqfy38m9.js → index-c81tggen.js} +1 -1
- package/dist/{index-0twg41mh.js → index-ejgp0z9p.js} +1 -1
- package/dist/{index-pnawfv4e.js → index-esacb9d0.js} +1 -1
- package/dist/{index-1kem0xxx.js → index-ewta5h87.js} +4 -4
- package/dist/{index-6r99v53h.js → index-j7n64sg4.js} +162 -60
- package/dist/{index-y2vshk67.js → index-jm62g83a.js} +177 -59
- package/dist/{index-yqha238s.js → index-pc49a7zt.js} +119 -9
- package/dist/{index-ttdk2w0z.js → index-qmm8xpbc.js} +3 -3
- package/dist/{index-n9kd68vc.js → index-tedck05r.js} +3 -3
- package/dist/{index-j2w79s9r.js → index-tm799pq7.js} +1 -1
- package/dist/{index-01h7tqe3.js → index-tr4ep2ej.js} +21 -6
- package/dist/{index-rz47hf2m.js → index-wqwjawer.js} +27 -11
- package/dist/index-xe34pwb6.js +119 -0
- package/dist/{index-hes3k87g.js → index-xjaf9g90.js} +1 -1
- package/dist/{index-fpjnjxyx.js → index-yzzxb5e1.js} +2 -2
- package/dist/{index-xr1t0fxb.js → index-zk6gtf43.js} +44 -8
- package/dist/index.js +26 -26
- package/dist/{message-index-bounded-vjrnptar.js → message-index-bounded-d3x8rhpz.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/{project-embedding-registry-m8zcmrsg.js → project-embedding-registry-az68q792.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +5 -5
- package/dist/{read-session-chunk-zkzdc0e5.js → read-session-chunk-70r1snq3.js} +2 -2
- package/dist/{recomp-orchestrator-qb2hymj5.js → recomp-orchestrator-cn4r2gz6.js} +14 -14
- package/dist/{render-34p0kek8.js → render-g45k3gts.js} +9 -9
- package/dist/{search-archive-08ppk0q5.js → search-archive-s9t3exc1.js} +8 -6
- package/dist/{search-e9bb9hpx.js → search-b0cb342r.js} +12 -12
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/{storage-tags-gk7gjkqt.js → storage-tags-xvbje7jm.js} +1 -1
- 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-neds90e3.js → transform-postprocess-phase-r1xhsjrh.js} +15 -15
- 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-ctsd80vc.js → context-2hssw26q.js} +332 -99
- package/dist/v2/{embedding-backfill-40g0anxh.js → embedding-backfill-gveter8p.js} +5 -5
- package/dist/v2/embedding-worker.js +2 -2
- 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-1vew9c37.js → message-index-bounded-tbwrff24.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-je5jam7y.js → project-embedding-registry-2zeycxek.js} +4 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +5 -5
- package/dist/v2/{read-session-chunk-09sre4xv.js → read-session-chunk-cvgsfsgr.js} +2 -2
- package/dist/v2/{recomp-orchestrator-mgcty3we.js → recomp-orchestrator-k4cj62f2.js} +13 -13
- package/dist/v2/{render-ygcmyn9x.js → render-ys7a3zks.js} +9 -9
- package/dist/v2/{search-archive-nrsqqmk5.js → search-archive-k2yh0jj3.js} +8 -6
- package/dist/v2/{search-gmye6n25.js → search-x1cac8t6.js} +11 -11
- 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-pcarsvj2.js → server-6aj72z52.js} +3 -3
- package/dist/v2/{server-cvp9w5gs.js → server-6nh36020.js} +68 -59
- package/dist/v2/{server-btgnkr9z.js → server-88pjnecb.js} +1 -1
- package/dist/v2/{server-myp4pc6x.js → server-bfct1yvb.js} +99 -51
- package/dist/v2/{server-4ecpanyn.js → server-cd93xyyx.js} +119 -9
- package/dist/v2/{server-6x40bnb7.js → server-cvm1qrqc.js} +2 -2
- package/dist/v2/{server-z9czv2vb.js → server-gj259dqy.js} +44 -8
- package/dist/v2/{server-vc5fta6s.js → server-prrx17q3.js} +3 -3
- package/dist/v2/{server-6chcnnhq.js → server-qy58c11s.js} +1 -1
- package/dist/v2/{server-dgsjamm4.js → server-s81b3nct.js} +1 -1
- package/dist/v2/{server-g53asaqt.js → server-s8mk882p.js} +27 -11
- package/dist/v2/{server-2xm0gxke.js → server-srtq37nh.js} +1 -1
- package/dist/v2/{server-bnkc9kph.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-k1xc2bw1.js → server-zc8s06gx.js} +1 -1
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-tags-nccqr0kr.js → storage-tags-y20j3jdp.js} +1 -1
- 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-7vmng8q7.js → v2-archive-reader-q92kwkr5.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-7r4y0bf6.js → wrapup-orchestrator-ydqkxkhj.js} +13 -13
- package/dist/{v2-archive-reader-7s90gfax.js → v2-archive-reader-x62hsr4c.js} +1 -1
- package/dist/{wrapup-orchestrator-m2p89973.js → wrapup-orchestrator-kt81d6et.js} +15 -15
- package/package.json +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
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
getRawSessionTagKeysThrough2,
|
|
36
36
|
getLegacyProtectedTailStartOrdinal2,
|
|
37
37
|
readSessionChunk2
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-7r11k4xr.js";
|
|
39
39
|
import {
|
|
40
40
|
getHarness2,
|
|
41
41
|
harnessOwnsOpenCodeStore2
|
|
@@ -123,7 +123,7 @@ import {
|
|
|
123
123
|
LATEST_SUPPORTED_VERSION,
|
|
124
124
|
getPersistedSchemaVersion,
|
|
125
125
|
openDatabase
|
|
126
|
-
} from "./index-
|
|
126
|
+
} from "./index-c81tggen.js";
|
|
127
127
|
import {
|
|
128
128
|
areRustHistorianSyntheticParts2,
|
|
129
129
|
isStrictGapHealingMessage2,
|
|
@@ -167,7 +167,7 @@ import {
|
|
|
167
167
|
replaceCompartmentChunkEmbeddings2,
|
|
168
168
|
deleteChunkEmbedBackoffForSession2,
|
|
169
169
|
chunkWindowSourceKey2
|
|
170
|
-
} from "./index-
|
|
170
|
+
} from "./index-ejgp0z9p.js";
|
|
171
171
|
import {
|
|
172
172
|
COMPARTMENT_LEASE_RENEWAL_MS,
|
|
173
173
|
getCompartmentLeaseBlocker,
|
|
@@ -176,6 +176,9 @@ import {
|
|
|
176
176
|
releaseCompartmentLease,
|
|
177
177
|
releaseCompartmentLeaseBestEffort,
|
|
178
178
|
isCompartmentLeaseHeld,
|
|
179
|
+
readSummaryCoverage,
|
|
180
|
+
markHistoryGapAfterCoverageChange,
|
|
181
|
+
settleHistoryGapAfterReplacement,
|
|
179
182
|
isNoContentCompartment,
|
|
180
183
|
queueM0Mutation,
|
|
181
184
|
getMaxM0MutationId,
|
|
@@ -212,14 +215,14 @@ import {
|
|
|
212
215
|
getProjectState,
|
|
213
216
|
recordSubagentInvocation,
|
|
214
217
|
getLatestHistorianInvocationId
|
|
215
|
-
} from "./index-
|
|
218
|
+
} from "./index-pc49a7zt.js";
|
|
216
219
|
import {
|
|
217
220
|
clearCompressionDepth,
|
|
218
221
|
clearCompressionDepthRange,
|
|
219
222
|
toMessageIndexSource,
|
|
220
223
|
clearIndexedMessagesInTransaction,
|
|
221
224
|
indexSourcesAfterOrdinal
|
|
222
|
-
} from "./index-
|
|
225
|
+
} from "./index-esacb9d0.js";
|
|
223
226
|
import {
|
|
224
227
|
stripWellFormedLeadingTagPrefix,
|
|
225
228
|
peelLeadingMcTagNotation,
|
|
@@ -270,7 +273,7 @@ import {
|
|
|
270
273
|
foldShrunkPartTags2,
|
|
271
274
|
getTagNumberByMessageId2,
|
|
272
275
|
getActiveTagsBySession2
|
|
273
|
-
} from "./index-
|
|
276
|
+
} from "./index-zk6gtf43.js";
|
|
274
277
|
import {
|
|
275
278
|
openCodeDbExists,
|
|
276
279
|
withReadOnlySessionDb,
|
|
@@ -298,13 +301,13 @@ import {
|
|
|
298
301
|
getProjectChunkEmbeddingModelId2,
|
|
299
302
|
getProjectEmbeddingMaxInputTokens2,
|
|
300
303
|
embedItemsWindowBounded2
|
|
301
|
-
} from "./index-
|
|
304
|
+
} from "./index-tedck05r.js";
|
|
302
305
|
import {
|
|
303
306
|
renderUserFacingFailure,
|
|
304
307
|
userFacingFailureCode,
|
|
305
308
|
promoteSessionFactsDurable,
|
|
306
309
|
embedPromotedFacts
|
|
307
|
-
} from "./index-
|
|
310
|
+
} from "./index-qmm8xpbc.js";
|
|
308
311
|
import {
|
|
309
312
|
isMarkerCandidateBasisCurrent2,
|
|
310
313
|
invalidateMarkerCandidateBasis2,
|
|
@@ -16062,6 +16065,7 @@ function* rebaseSteps(args) {
|
|
|
16062
16065
|
outcome.partTagsFolded = fold.foldedTagNumbers.length;
|
|
16063
16066
|
outcome.partTagsRekeyed = fold.rekeyedTagNumbers.length;
|
|
16064
16067
|
outcome.queuedReductionsDiscarded = fold.discardedDropTagNumbers.length;
|
|
16068
|
+
const previousCoverage = readSummaryCoverage(db, sessionId);
|
|
16065
16069
|
const updateCompartment = {
|
|
16066
16070
|
compartments: db.prepare("UPDATE compartments SET start_message = ?, end_message = ?, rebase_status = ?, title = ?, content = ?, p1 = ?, p2 = ?, p3 = ?, p4 = ? WHERE id = ?"),
|
|
16067
16071
|
recomp_compartments: db.prepare("UPDATE recomp_compartments SET start_message = ?, end_message = ?, rebase_status = ?, title = ?, content = ?, p1 = ?, p2 = ?, p3 = ?, p4 = ? WHERE id = ?")
|
|
@@ -16103,6 +16107,7 @@ function* rebaseSteps(args) {
|
|
|
16103
16107
|
outcome.recompCompartmentsUnresolved += unresolved;
|
|
16104
16108
|
}
|
|
16105
16109
|
}
|
|
16110
|
+
markHistoryGapAfterCoverageChange(db, sessionId, previousCoverage, true);
|
|
16106
16111
|
const updateNote = db.prepare("UPDATE notes SET anchor_ordinal = ? WHERE id = ? AND session_id = ?");
|
|
16107
16112
|
for (const plan of movedNotes) {
|
|
16108
16113
|
updateNote.run(plan.ordinal, plan.id, sessionId);
|
|
@@ -16190,9 +16195,11 @@ function recoverUnresolvedCompartments(args) {
|
|
|
16190
16195
|
db.exec("BEGIN IMMEDIATE");
|
|
16191
16196
|
let committed = false;
|
|
16192
16197
|
try {
|
|
16198
|
+
const previousCoverage = readSummaryCoverage(db, sessionId);
|
|
16193
16199
|
for (const plan of changed) {
|
|
16194
16200
|
db.prepare("UPDATE compartments SET start_message = ?, end_message = ?, rebase_status = ? WHERE id = ?").run(plan.start, plan.end, plan.status, plan.id);
|
|
16195
16201
|
}
|
|
16202
|
+
markHistoryGapAfterCoverageChange(db, sessionId, previousCoverage);
|
|
16196
16203
|
const previous = readCoordinateRebaseNotice(db, sessionId);
|
|
16197
16204
|
const generation = previous?.generation ?? readCoordinateGeneration(db, sessionId);
|
|
16198
16205
|
if (generation !== null) {
|
|
@@ -18764,10 +18771,12 @@ function promoteRecompStaging(db, sessionId, holderId, stopped, carriedRows) {
|
|
|
18764
18771
|
}
|
|
18765
18772
|
}
|
|
18766
18773
|
const compartments = carried ? [...staging.compartments, ...carried.compartments] : staging.compartments;
|
|
18774
|
+
const previousCoverage = readSummaryCoverage(db, sessionId);
|
|
18767
18775
|
deleteChunkEmbedBackoffForSession2(db, sessionId);
|
|
18768
18776
|
db.prepare("DELETE FROM compartments WHERE session_id = ?").run(sessionId);
|
|
18769
18777
|
db.prepare("DELETE FROM session_facts WHERE session_id = ?").run(sessionId);
|
|
18770
18778
|
insertRecompCompartmentRows(db, sessionId, compartments, now, carried?.rows ?? carriedRows);
|
|
18779
|
+
settleHistoryGapAfterReplacement(db, sessionId, previousCoverage, staging.compartments.some((row) => !isNoContentCompartment(row)));
|
|
18771
18780
|
queueM0Mutation(db, {
|
|
18772
18781
|
sessionId,
|
|
18773
18782
|
mutationType: "recomp_boundary_change",
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getCompartments,
|
|
10
10
|
getLastCompartmentEndMessage,
|
|
11
11
|
requestPendingMaterialization
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-pc49a7zt.js";
|
|
13
13
|
import {
|
|
14
14
|
inRootAsyncContext2
|
|
15
15
|
} from "./index-gzy5w8ya.js";
|
|
@@ -20,10 +20,10 @@ import {
|
|
|
20
20
|
releaseWrapupInProgress,
|
|
21
21
|
getHistorianFailureState,
|
|
22
22
|
clearEmergencyRecovery
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-zk6gtf43.js";
|
|
24
24
|
import {
|
|
25
25
|
prepareRawSessionOrdinals2
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-7r11k4xr.js";
|
|
27
27
|
import {
|
|
28
28
|
pushNotification2
|
|
29
29
|
} from "./index-y14pawe1.js";
|
|
@@ -35,14 +35,14 @@ import {
|
|
|
35
35
|
getActiveCompartmentRun,
|
|
36
36
|
markActiveCompartmentRunPublished,
|
|
37
37
|
registerActiveCompartmentRun
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-2gewejcz.js";
|
|
39
39
|
import {
|
|
40
40
|
sendStatusNotification2
|
|
41
41
|
} from "./index-9ffntwyr.js";
|
|
42
42
|
import {
|
|
43
43
|
setRecompStarting2,
|
|
44
44
|
setRecompTerminal2
|
|
45
|
-
} from "./index-
|
|
45
|
+
} from "./index-ewta5h87.js";
|
|
46
46
|
|
|
47
47
|
// src/hooks/magic-context/wrapup-orchestrator.ts
|
|
48
48
|
import * as crypto from "node:crypto";
|
|
@@ -164,7 +164,7 @@ import {
|
|
|
164
164
|
adoptNullOwnerToolTag2,
|
|
165
165
|
getCandidateToolOwners2,
|
|
166
166
|
pickNearestPriorOwner2
|
|
167
|
-
} from "./index-
|
|
167
|
+
} from "./index-zk6gtf43.js";
|
|
168
168
|
import {
|
|
169
169
|
getHarness2
|
|
170
170
|
} from "./index-pavzsdc6.js";
|
|
@@ -218,11 +218,11 @@ import {
|
|
|
218
218
|
saveSourceContent,
|
|
219
219
|
replaceSourceContent,
|
|
220
220
|
getSourceContents
|
|
221
|
-
} from "./index-
|
|
221
|
+
} from "./index-pc49a7zt.js";
|
|
222
222
|
import {
|
|
223
223
|
cleanSearchText,
|
|
224
224
|
matchedSearchSnippet
|
|
225
|
-
} from "./index-
|
|
225
|
+
} from "./index-esacb9d0.js";
|
|
226
226
|
import {
|
|
227
227
|
BoundedSessionMap,
|
|
228
228
|
tagRevisionKey,
|
|
@@ -255,7 +255,7 @@ import {
|
|
|
255
255
|
extractToolCallObservation,
|
|
256
256
|
ToolMutationBatch,
|
|
257
257
|
createToolDropTarget
|
|
258
|
-
} from "./index-
|
|
258
|
+
} from "./index-7r11k4xr.js";
|
|
259
259
|
import {
|
|
260
260
|
hasTrustedAbsoluteWall,
|
|
261
261
|
applyProvenInputFloor,
|
|
@@ -267,18 +267,18 @@ import {
|
|
|
267
267
|
getProjectEmbeddingSnapshot2,
|
|
268
268
|
embedTextForProject2,
|
|
269
269
|
embedBatchForProject2
|
|
270
|
-
} from "./index-
|
|
270
|
+
} from "./index-tedck05r.js";
|
|
271
271
|
import {
|
|
272
272
|
isEmbeddingHostBusy2
|
|
273
273
|
} from "./index-qt1qqasc.js";
|
|
274
274
|
import {
|
|
275
275
|
userFacingFailureCode
|
|
276
|
-
} from "./index-
|
|
276
|
+
} from "./index-qmm8xpbc.js";
|
|
277
277
|
import {
|
|
278
278
|
getMessageIndexEpoch,
|
|
279
279
|
isMessageIndexSearchable,
|
|
280
280
|
createAutoSearchDiagnostics
|
|
281
|
-
} from "./index-
|
|
281
|
+
} from "./index-47hst5me.js";
|
|
282
282
|
import {
|
|
283
283
|
compareOpenCodeMessagesByCanonicalOrder,
|
|
284
284
|
startCompactionMarkerCandidatePreparation,
|
|
@@ -300,7 +300,7 @@ import {
|
|
|
300
300
|
peekNoteNudgeText,
|
|
301
301
|
markNoteNudgeDelivered,
|
|
302
302
|
getActiveCompartmentRun
|
|
303
|
-
} from "./index-
|
|
303
|
+
} from "./index-2gewejcz.js";
|
|
304
304
|
import {
|
|
305
305
|
canonicalModelIdentity,
|
|
306
306
|
piModelRefToCanonical,
|
|
@@ -137,11 +137,11 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
137
137
|
{ createV2RecoveryAttachments }
|
|
138
138
|
] = await Promise.all([
|
|
139
139
|
import("./sqlite-zdgm52sv.js"),
|
|
140
|
-
import("./store-reader-
|
|
141
|
-
import("./store-
|
|
142
|
-
import("./read-session-chunk-
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
140
|
+
import("./store-reader-dgh3ssxx.js"),
|
|
141
|
+
import("./store-91kawq9a.js"),
|
|
142
|
+
import("./read-session-chunk-70r1snq3.js"),
|
|
143
|
+
import("./render-g45k3gts.js"),
|
|
144
|
+
import("./search-archive-s9t3exc1.js"),
|
|
145
145
|
import("./expand-attachments-h33jbgyz.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -169,7 +169,7 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
169
169
|
} else {
|
|
170
170
|
const start = read.kind === "message" ? read.message : read.start;
|
|
171
171
|
const end = read.kind === "message" ? read.message : read.end;
|
|
172
|
-
text = renderSearchArchive(db, request.sessionId, start, end, read.tokenBudget, read.kind === "archive" && read.archiveOnly, () => reader.ordinalMapForRange(request.sessionId, start, end));
|
|
172
|
+
text = renderSearchArchive(db, request.sessionId, start, end, read.tokenBudget, read.kind === "archive" && read.archiveOnly, () => reader.ordinalMapForRange(request.sessionId, start, end), read.kind === "message" ? undefined : read.liveTailAfter);
|
|
173
173
|
if (text === null && read.kind === "message") {
|
|
174
174
|
text = renderMessageByOrdinal(request.sessionId, read.message, attachments);
|
|
175
175
|
} else if (text === null && read.kind === "verbose") {
|
|
@@ -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";
|