@cortexkit/opencode-magic-context 0.49.23 → 0.49.25
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/README.md +0 -26
- package/dist/agents/permissions.d.ts +8 -3
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +5 -5
- package/dist/{compartment-chunk-embedding-he60aaa2.js → compartment-chunk-embedding-eypvn607.js} +3 -3
- package/dist/{conflict-warning-hook-2r32hyx6.js → conflict-warning-hook-a27bhggg.js} +4 -4
- package/dist/{context-j7hp43a0.js → context-keb00be8.js} +30 -24
- package/dist/{embedding-backfill-dtke6tck.js → embedding-backfill-vddgmem3.js} +5 -5
- package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
- package/dist/features/magic-context/tool-definition-tokens.d.ts +113 -57
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/ask-answer-notice.d.ts +25 -0
- package/dist/hooks/magic-context/ask-answer-notice.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +10 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts +42 -0
- package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-y76rhsnr.js → index-0s8454t2.js} +50 -31
- package/dist/{index-1gtfne2c.js → index-2haxh8h3.js} +1 -1
- package/dist/{index-m32esgmj.js → index-3d5wnkq7.js} +1 -1
- package/dist/{index-jfem3dgz.js → index-7tdtpqrg.js} +5 -1
- package/dist/{index-mnnkgq0q.js → index-awcftgmx.js} +7 -49
- package/dist/{index-1kbznkft.js → index-axjgxeww.js} +10 -8
- package/dist/{index-j32jj2t8.js → index-bhyksfyy.js} +3 -3
- package/dist/{index-ksq50rg0.js → index-c9zrgcnt.js} +1 -1
- package/dist/index-cfaet9cg.js +405 -0
- package/dist/{index-jmq8kfe7.js → index-ebsvmc5s.js} +4 -4
- package/dist/{index-66eby7hx.js → index-jcr6pe7z.js} +1 -1
- package/dist/{index-syaazvy2.js → index-n18sch77.js} +5 -5
- package/dist/{index-a9zvn5fe.js → index-q7ywt6xt.js} +3 -3
- package/dist/{index-x6cbrv9h.js → index-szf8r0ba.js} +1 -1
- package/dist/{index-rxqr723x.js → index-t6j3qxnd.js} +1 -1
- package/dist/{index-11gzxvf4.js → index-y6xpzjzr.js} +98 -48
- package/dist/{index-mnhcdfxg.js → index-yrrsp47d.js} +91 -17
- package/dist/{index-zy67whjr.js → index-z05n7702.js} +1 -1
- package/dist/{index-3svaejkh.js → index-z928hmnp.js} +1 -1
- package/dist/{index-ffzhwfzy.js → index-zzrzjnx5.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -38
- package/dist/{message-fts-rowid-map-e79b7b6x.js → message-fts-rowid-map-9e1getgs.js} +2 -2
- package/dist/{message-index-4q8ek2fc.js → message-index-3g966xn7.js} +7 -7
- package/dist/{message-index-bounded-rydsg9r5.js → message-index-bounded-vaeqhp9w.js} +7 -7
- package/dist/migration-worker.js +4 -4
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-hn529988.js → project-embedding-registry-rstzmb60.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +6 -6
- package/dist/{read-session-chunk-t039f0m5.js → read-session-chunk-z5gnc0zb.js} +4 -4
- package/dist/{read-session-raw-aw6jgvwg.js → read-session-raw-s4amywnh.js} +3 -1
- package/dist/{recomp-orchestrator-hbm53jj5.js → recomp-orchestrator-qwqeskhq.js} +14 -14
- package/dist/{search-hea079d7.js → search-84zfqeky.js} +11 -11
- package/dist/{search-archive-weh164mh.js → search-archive-mfabzyn2.js} +5 -5
- package/dist/{send-session-notification-gqzkz7da.js → send-session-notification-ygj4mja0.js} +3 -3
- package/dist/shared/slow-test.d.ts +7 -0
- package/dist/shared/slow-test.d.ts.map +1 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/parameter-descriptions.d.ts +6 -6
- package/dist/tools/parameter-descriptions.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-0b04tm1p.js → transform-postprocess-phase-hr1ntmjj.js} +14 -14
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +5 -5
- package/dist/v2/{compartment-chunk-embedding-8jjmcgeg.js → compartment-chunk-embedding-tk6g4q80.js} +3 -3
- package/dist/v2/{context-ea3x7smm.js → context-y7wfvdve.js} +106 -50
- package/dist/v2/{embedding-backfill-5e74ae0m.js → embedding-backfill-w5qp7t28.js} +5 -5
- package/dist/v2/hooks/context.d.ts +4 -0
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-n8fdg2ja.js → message-fts-rowid-map-pqk3a55v.js} +2 -2
- package/dist/v2/{message-index-bounded-8rcd7qq9.js → message-index-bounded-te303atj.js} +6 -6
- package/dist/v2/{message-index-qz9wdp82.js → message-index-fz6b4jeh.js} +6 -6
- package/dist/v2/migration-worker.js +4 -4
- package/dist/v2/{project-embedding-registry-v38q4xd5.js → project-embedding-registry-e7zftfvj.js} +4 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
- package/dist/v2/{read-session-chunk-wazfyxcg.js → read-session-chunk-knvkq1hf.js} +3 -3
- package/dist/v2/{read-session-raw-b70cpwzj.js → read-session-raw-ppjxnqk4.js} +3 -1
- package/dist/v2/{recomp-orchestrator-b12zaptj.js → recomp-orchestrator-e8a4jpvr.js} +11 -11
- package/dist/v2/{search-archive-x64rtz1z.js → search-archive-vrwgxv6z.js} +4 -4
- package/dist/v2/{search-hza9x72a.js → search-hav4dggf.js} +10 -10
- package/dist/v2/{send-session-notification-8eqe259v.js → send-session-notification-f8scq6ae.js} +1 -1
- package/dist/v2/{server-m4bfaevz.js → server-5brp2rfn.js} +90 -16
- package/dist/v2/{server-ppcd1qxh.js → server-6a8pxpxg.js} +7 -49
- package/dist/v2/server-7d6m1p2b.js +361 -0
- package/dist/v2/{server-zg5y109h.js → server-7weh65vd.js} +45 -27
- package/dist/v2/{server-qteg2kt9.js → server-8j2e7t31.js} +1 -1
- package/dist/v2/{server-d48x3m4x.js → server-9xbbaekh.js} +1 -1
- package/dist/v2/{server-j8h7bsca.js → server-e75vag9d.js} +3 -3
- package/dist/v2/{server-132h8twc.js → server-m6yyn961.js} +2 -2
- package/dist/v2/{server-62g58aaz.js → server-pw21ypwb.js} +1 -1
- package/dist/v2/{server-ad18djzs.js → server-q5z0gag0.js} +1 -1
- package/dist/v2/{server-4kjmrjn4.js → server-swvhxhxz.js} +5 -1
- package/dist/v2/{server-33nqbqkw.js → server-tfawsj08.js} +5 -5
- package/dist/v2/{server-dtp8hcjh.js → server-wxrdher8.js} +1 -1
- package/dist/v2/server.js +5 -5
- package/dist/v2/{wrapup-orchestrator-3ssd5yy1.js → wrapup-orchestrator-ycs8y6n4.js} +11 -11
- package/dist/{wrapup-orchestrator-5vpcd1zx.js → wrapup-orchestrator-f642w8n3.js} +15 -15
- package/package.json +4 -4
- package/src/agents/permissions.ts +22 -6
- package/src/agents/smart-notes-dreamer-gate.golden.json +241 -241
- package/src/agents/smart-notes-on.golden.json +4 -4
- package/src/config/compaction-accessor-guard.test.ts +0 -5
- package/src/config/removed-config-keys.test.ts +12 -26
- package/src/shared/announcement.test.ts +55 -59
- package/src/shared/prompt-surface-a1-golden.md +6 -7
- package/src/shared/slow-test.ts +24 -0
- package/src/shared/stable-json-linear.test.ts +18 -10
- package/dist/index-j76ah6d7.js +0 -120
- package/dist/v2/server-d1dzgvwd.js +0 -120
- package/src/config/latch-permanence-guard.test.ts +0 -258
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import {
|
|
2
|
+
estimateTokens
|
|
3
|
+
} from "./server-3mz2qh5a.js";
|
|
4
|
+
import {
|
|
5
|
+
stableStringify
|
|
6
|
+
} from "./server-rqebawx1.js";
|
|
7
|
+
|
|
8
|
+
// src/features/magic-context/tool-definition-tokens.ts
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
|
|
11
|
+
// src/shared/bounded-session-map.ts
|
|
12
|
+
class BoundedSessionMap {
|
|
13
|
+
maxEntries;
|
|
14
|
+
store = new Map;
|
|
15
|
+
constructor(maxEntries) {
|
|
16
|
+
if (!Number.isFinite(maxEntries) || maxEntries < 1) {
|
|
17
|
+
throw new Error(`BoundedSessionMap: maxEntries must be >= 1, got ${maxEntries}`);
|
|
18
|
+
}
|
|
19
|
+
this.maxEntries = maxEntries;
|
|
20
|
+
}
|
|
21
|
+
get(sessionId) {
|
|
22
|
+
const value = this.store.get(sessionId);
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
return;
|
|
25
|
+
this.store.delete(sessionId);
|
|
26
|
+
this.store.set(sessionId, value);
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
peek(sessionId) {
|
|
30
|
+
return this.store.get(sessionId);
|
|
31
|
+
}
|
|
32
|
+
has(sessionId) {
|
|
33
|
+
return this.store.has(sessionId);
|
|
34
|
+
}
|
|
35
|
+
set(sessionId, value) {
|
|
36
|
+
if (this.store.has(sessionId)) {
|
|
37
|
+
this.store.delete(sessionId);
|
|
38
|
+
} else if (this.store.size >= this.maxEntries) {
|
|
39
|
+
const oldest = this.store.keys().next().value;
|
|
40
|
+
if (oldest !== undefined)
|
|
41
|
+
this.store.delete(oldest);
|
|
42
|
+
}
|
|
43
|
+
this.store.set(sessionId, value);
|
|
44
|
+
}
|
|
45
|
+
delete(sessionId) {
|
|
46
|
+
return this.store.delete(sessionId);
|
|
47
|
+
}
|
|
48
|
+
clear() {
|
|
49
|
+
this.store.clear();
|
|
50
|
+
}
|
|
51
|
+
get size() {
|
|
52
|
+
return this.store.size;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/features/magic-context/tool-definition-tokens.ts
|
|
57
|
+
var ACTIVITY_WINDOW_MS = 10 * 60000;
|
|
58
|
+
var MAX_ACTIVITY_GAP_MS = 60000;
|
|
59
|
+
var RETIRED_CACHE_LIMIT = 64;
|
|
60
|
+
var WRITE_RETRY_MS = 5000;
|
|
61
|
+
var WINDOWED_SINCE_KEY = "tool_definition_measurements:windowed_since";
|
|
62
|
+
var routes = new Map;
|
|
63
|
+
var sessionFlights = new BoundedSessionMap(1000);
|
|
64
|
+
var persistenceDb = null;
|
|
65
|
+
var windowedSince;
|
|
66
|
+
var boundAt = 0;
|
|
67
|
+
var cachedInsertStmt = null;
|
|
68
|
+
var cachedDeleteStmt = null;
|
|
69
|
+
function agentKey(agentName) {
|
|
70
|
+
return agentName && agentName.length > 0 ? agentName : "default";
|
|
71
|
+
}
|
|
72
|
+
function keyFor(providerID, modelID, agentName) {
|
|
73
|
+
return `${providerID}/${modelID}/${agentKey(agentName)}`;
|
|
74
|
+
}
|
|
75
|
+
function fingerprintFor(description, parameters) {
|
|
76
|
+
return createHash("sha256").update(description).update("\x00").update(stableStringify(parameters)).digest("hex");
|
|
77
|
+
}
|
|
78
|
+
function measure(description, parameters) {
|
|
79
|
+
let paramsText = "";
|
|
80
|
+
try {
|
|
81
|
+
paramsText = parameters === undefined ? "" : JSON.stringify(parameters);
|
|
82
|
+
} catch {
|
|
83
|
+
paramsText = "";
|
|
84
|
+
}
|
|
85
|
+
return estimateTokens(description) + estimateTokens(paramsText);
|
|
86
|
+
}
|
|
87
|
+
function routeFor(providerID, modelID, agentName) {
|
|
88
|
+
const key = keyFor(providerID, modelID, agentName);
|
|
89
|
+
let route = routes.get(key);
|
|
90
|
+
if (!route) {
|
|
91
|
+
route = {
|
|
92
|
+
providerID,
|
|
93
|
+
modelID,
|
|
94
|
+
agentName: agentKey(agentName),
|
|
95
|
+
tools: new Map,
|
|
96
|
+
live: false,
|
|
97
|
+
clock: 0,
|
|
98
|
+
lastWallAt: Date.now(),
|
|
99
|
+
oldestFireAt: Number.POSITIVE_INFINITY,
|
|
100
|
+
retired: new Map,
|
|
101
|
+
legacyRows: new Set
|
|
102
|
+
};
|
|
103
|
+
routes.set(key, route);
|
|
104
|
+
}
|
|
105
|
+
return { key, route };
|
|
106
|
+
}
|
|
107
|
+
function advanceClock(route) {
|
|
108
|
+
const now = Date.now();
|
|
109
|
+
const gap = Math.min(Math.max(now - route.lastWallAt, 0), MAX_ACTIVITY_GAP_MS);
|
|
110
|
+
route.clock += gap;
|
|
111
|
+
route.lastWallAt = Math.max(route.lastWallAt, now);
|
|
112
|
+
return route.clock;
|
|
113
|
+
}
|
|
114
|
+
function counts(route, slot) {
|
|
115
|
+
if (!route.live)
|
|
116
|
+
return true;
|
|
117
|
+
if (slot.legacy)
|
|
118
|
+
return false;
|
|
119
|
+
return slot.lastFireAt >= route.clock - ACTIVITY_WINDOW_MS;
|
|
120
|
+
}
|
|
121
|
+
function currentTools(route) {
|
|
122
|
+
return [...route.tools.entries()].filter(([, slot]) => counts(route, slot));
|
|
123
|
+
}
|
|
124
|
+
function summarize(entries, live) {
|
|
125
|
+
let total = 0;
|
|
126
|
+
for (const [, slot] of entries)
|
|
127
|
+
total += slot.tokens;
|
|
128
|
+
const ids = entries.map(([id]) => id).sort();
|
|
129
|
+
const fingerprints = new Map(entries.map(([id, slot]) => [
|
|
130
|
+
id,
|
|
131
|
+
slot.fingerprint ?? (live ? `stored:${slot.tokens}` : undefined)
|
|
132
|
+
]));
|
|
133
|
+
const complete = ids.every((id) => fingerprints.get(id) !== undefined);
|
|
134
|
+
return {
|
|
135
|
+
total,
|
|
136
|
+
signature: complete ? createHash("sha256").update(JSON.stringify(ids.map((id) => [id, fingerprints.get(id)]))).digest("hex") : undefined,
|
|
137
|
+
hash: ids.length === 0 ? "" : createHash("sha256").update(ids.join("\x00")).digest("hex")
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function resolve(providerID, modelID, agentName, sessionId) {
|
|
141
|
+
if (!providerID || !modelID)
|
|
142
|
+
return;
|
|
143
|
+
const key = keyFor(providerID, modelID, agentName);
|
|
144
|
+
if (sessionId) {
|
|
145
|
+
const flight = sessionFlights.peek(sessionId);
|
|
146
|
+
if (flight?.key === key && flight.exact)
|
|
147
|
+
return flight.exact;
|
|
148
|
+
}
|
|
149
|
+
const route = routes.get(key);
|
|
150
|
+
if (!route)
|
|
151
|
+
return;
|
|
152
|
+
const entries = currentTools(route);
|
|
153
|
+
if (!route.live && entries.length === 0)
|
|
154
|
+
return;
|
|
155
|
+
return summarize(entries, route.live);
|
|
156
|
+
}
|
|
157
|
+
function readWindowedSince(db) {
|
|
158
|
+
try {
|
|
159
|
+
const row = db.prepare("SELECT value FROM schema_migrations_meta WHERE key = ?").get(WINDOWED_SINCE_KEY);
|
|
160
|
+
if (!row)
|
|
161
|
+
return;
|
|
162
|
+
const value = Number(row.value);
|
|
163
|
+
return Number.isFinite(value) ? value : undefined;
|
|
164
|
+
} catch {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function markWindowed() {
|
|
169
|
+
if (windowedSince !== undefined || !persistenceDb)
|
|
170
|
+
return;
|
|
171
|
+
try {
|
|
172
|
+
persistenceDb.prepare("INSERT OR IGNORE INTO schema_migrations_meta (key, value) VALUES (?, ?)").run(WINDOWED_SINCE_KEY, String(boundAt));
|
|
173
|
+
windowedSince = readWindowedSince(persistenceDb);
|
|
174
|
+
} catch {}
|
|
175
|
+
}
|
|
176
|
+
function persistInsert(route, toolID, tokens) {
|
|
177
|
+
if (!persistenceDb)
|
|
178
|
+
return false;
|
|
179
|
+
try {
|
|
180
|
+
cachedInsertStmt ??= persistenceDb.prepare(`INSERT OR REPLACE INTO tool_definition_measurements
|
|
181
|
+
(provider_id, model_id, agent_name, tool_id, token_count, recorded_at)
|
|
182
|
+
VALUES (?, ?, ?, ?, ?, ?)`);
|
|
183
|
+
cachedInsertStmt.run(route.providerID, route.modelID, route.agentName, toolID, tokens, Date.now());
|
|
184
|
+
} catch {
|
|
185
|
+
cachedInsertStmt = null;
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
if (route.legacyRows.delete(toolID) && route.legacyRows.size === 0)
|
|
189
|
+
markWindowed();
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
function persistDelete(route, toolIDs) {
|
|
193
|
+
if (!persistenceDb)
|
|
194
|
+
return false;
|
|
195
|
+
try {
|
|
196
|
+
cachedDeleteStmt ??= persistenceDb.prepare(`DELETE FROM tool_definition_measurements
|
|
197
|
+
WHERE provider_id = ? AND model_id = ? AND agent_name = ?
|
|
198
|
+
AND tool_id IN (SELECT value FROM json_each(?))`);
|
|
199
|
+
cachedDeleteStmt.run(route.providerID, route.modelID, route.agentName, JSON.stringify(toolIDs));
|
|
200
|
+
} catch {
|
|
201
|
+
cachedDeleteStmt = null;
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
for (const id of toolIDs)
|
|
205
|
+
route.legacyRows.delete(id);
|
|
206
|
+
markWindowed();
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
function writeSlot(route, toolID, slot) {
|
|
210
|
+
if (slot.persisted || !persistenceDb)
|
|
211
|
+
return;
|
|
212
|
+
const now = Date.now();
|
|
213
|
+
if (slot.writeFailedAt !== undefined && now - slot.writeFailedAt < WRITE_RETRY_MS)
|
|
214
|
+
return;
|
|
215
|
+
if (persistInsert(route, toolID, slot.tokens)) {
|
|
216
|
+
slot.persisted = true;
|
|
217
|
+
slot.writeFailedAt = undefined;
|
|
218
|
+
} else {
|
|
219
|
+
slot.writeFailedAt = now;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function retire(route, toolID, slot, rowDeleted) {
|
|
223
|
+
if (slot.fingerprint === undefined)
|
|
224
|
+
return;
|
|
225
|
+
route.retired.delete(toolID);
|
|
226
|
+
route.retired.set(toolID, {
|
|
227
|
+
fingerprint: slot.fingerprint,
|
|
228
|
+
tokens: slot.tokens,
|
|
229
|
+
rowKept: slot.persisted && !rowDeleted
|
|
230
|
+
});
|
|
231
|
+
if (route.retired.size > RETIRED_CACHE_LIMIT) {
|
|
232
|
+
const oldest = route.retired.keys().next().value;
|
|
233
|
+
if (oldest !== undefined)
|
|
234
|
+
route.retired.delete(oldest);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function freshSlot(route, toolID, description, parameters, fingerprint, now) {
|
|
238
|
+
const retired = route.retired.get(toolID);
|
|
239
|
+
if (retired)
|
|
240
|
+
route.retired.delete(toolID);
|
|
241
|
+
const reuse = retired?.fingerprint === fingerprint ? retired : undefined;
|
|
242
|
+
return {
|
|
243
|
+
tokens: reuse ? reuse.tokens : measure(description, parameters),
|
|
244
|
+
fingerprint,
|
|
245
|
+
lastFireAt: now,
|
|
246
|
+
legacy: false,
|
|
247
|
+
persisted: reuse?.rowKept === true
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function setDatabase(db) {
|
|
251
|
+
const rebound = persistenceDb !== null && persistenceDb !== db;
|
|
252
|
+
persistenceDb = db;
|
|
253
|
+
boundAt = Date.now();
|
|
254
|
+
cachedInsertStmt = null;
|
|
255
|
+
cachedDeleteStmt = null;
|
|
256
|
+
if (rebound) {
|
|
257
|
+
for (const route of routes.values()) {
|
|
258
|
+
for (const slot of route.tools.values()) {
|
|
259
|
+
slot.persisted = false;
|
|
260
|
+
slot.writeFailedAt = undefined;
|
|
261
|
+
}
|
|
262
|
+
for (const retired of route.retired.values())
|
|
263
|
+
retired.rowKept = false;
|
|
264
|
+
route.legacyRows.clear();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
windowedSince = readWindowedSince(db);
|
|
268
|
+
if (windowedSince !== undefined)
|
|
269
|
+
return;
|
|
270
|
+
try {
|
|
271
|
+
if (!db.prepare("SELECT 1 FROM tool_definition_measurements LIMIT 1").get())
|
|
272
|
+
markWindowed();
|
|
273
|
+
} catch {}
|
|
274
|
+
}
|
|
275
|
+
function loadToolDefinitionMeasurements(db) {
|
|
276
|
+
let rows = [];
|
|
277
|
+
try {
|
|
278
|
+
rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count, recorded_at FROM tool_definition_measurements").all();
|
|
279
|
+
} catch {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const since = readWindowedSince(db);
|
|
283
|
+
const loadedAt = new Map;
|
|
284
|
+
for (const row of rows) {
|
|
285
|
+
const { route } = routeFor(row.provider_id, row.model_id, row.agent_name);
|
|
286
|
+
if (route.live)
|
|
287
|
+
continue;
|
|
288
|
+
let now = loadedAt.get(route);
|
|
289
|
+
if (now === undefined) {
|
|
290
|
+
now = advanceClock(route);
|
|
291
|
+
loadedAt.set(route, now);
|
|
292
|
+
}
|
|
293
|
+
const legacy = since === undefined || !(Number(row.recorded_at) >= since);
|
|
294
|
+
route.tools.set(row.tool_id, {
|
|
295
|
+
tokens: row.token_count,
|
|
296
|
+
fingerprint: undefined,
|
|
297
|
+
lastFireAt: now,
|
|
298
|
+
legacy,
|
|
299
|
+
persisted: !legacy
|
|
300
|
+
});
|
|
301
|
+
route.oldestFireAt = Math.min(route.oldestFireAt, now);
|
|
302
|
+
if (legacy)
|
|
303
|
+
route.legacyRows.add(row.tool_id);
|
|
304
|
+
else
|
|
305
|
+
route.legacyRows.delete(row.tool_id);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function recordToolDefinitionSet(providerID, modelID, agentName, tools, sessionId) {
|
|
309
|
+
if (!providerID || !modelID)
|
|
310
|
+
return;
|
|
311
|
+
const { key, route } = routeFor(providerID, modelID, agentName);
|
|
312
|
+
const now = advanceClock(route);
|
|
313
|
+
route.live = true;
|
|
314
|
+
const next = new Map;
|
|
315
|
+
for (const tool of tools) {
|
|
316
|
+
if (!tool.id)
|
|
317
|
+
continue;
|
|
318
|
+
const fingerprint = fingerprintFor(tool.description ?? "", tool.parameters);
|
|
319
|
+
const previous = route.tools.get(tool.id);
|
|
320
|
+
if (previous && previous.fingerprint === fingerprint) {
|
|
321
|
+
previous.lastFireAt = now;
|
|
322
|
+
next.set(tool.id, previous);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
next.set(tool.id, freshSlot(route, tool.id, tool.description ?? "", tool.parameters, fingerprint, now));
|
|
326
|
+
}
|
|
327
|
+
const removed = [...route.tools].filter(([id]) => !next.has(id));
|
|
328
|
+
route.tools = next;
|
|
329
|
+
route.oldestFireAt = now;
|
|
330
|
+
if (removed.length > 0) {
|
|
331
|
+
const deleted = persistDelete(route, removed.map(([id]) => id));
|
|
332
|
+
for (const [id, slot] of removed)
|
|
333
|
+
retire(route, id, slot, deleted);
|
|
334
|
+
}
|
|
335
|
+
for (const [toolID, slot] of next)
|
|
336
|
+
writeSlot(route, toolID, slot);
|
|
337
|
+
if (sessionId)
|
|
338
|
+
sessionFlights.set(sessionId, { key, exact: summarize([...next.entries()], true) });
|
|
339
|
+
}
|
|
340
|
+
function getCurrentToolSetHash(providerID, modelID, agentName, sessionId) {
|
|
341
|
+
return resolve(providerID, modelID, agentName, sessionId)?.hash ?? "";
|
|
342
|
+
}
|
|
343
|
+
function getToolDefinitionMeasurementSignature(providerID, modelID, agentName, sessionId) {
|
|
344
|
+
return resolve(providerID, modelID, agentName, sessionId)?.signature;
|
|
345
|
+
}
|
|
346
|
+
function getMeasuredToolDefinitionTokens(providerID, modelID, agentName, sessionId) {
|
|
347
|
+
return resolve(providerID, modelID, agentName, sessionId)?.total;
|
|
348
|
+
}
|
|
349
|
+
function getSessionToolDefinitionTokens(sessionId) {
|
|
350
|
+
if (!sessionId)
|
|
351
|
+
return;
|
|
352
|
+
const flight = sessionFlights.peek(sessionId);
|
|
353
|
+
if (!flight)
|
|
354
|
+
return;
|
|
355
|
+
if (flight.exact)
|
|
356
|
+
return flight.exact.total;
|
|
357
|
+
const route = routes.get(flight.key);
|
|
358
|
+
return route ? summarize(currentTools(route), route.live).total : undefined;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export { BoundedSessionMap, setDatabase, loadToolDefinitionMeasurements, recordToolDefinitionSet, getCurrentToolSetHash, getToolDefinitionMeasurementSignature, getMeasuredToolDefinitionTokens, getSessionToolDefinitionTokens };
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
getProjectChunkEmbeddingModelId2,
|
|
41
41
|
getProjectEmbeddingMaxInputTokens2,
|
|
42
42
|
embedItemsForProject2
|
|
43
|
-
} from "./server-
|
|
43
|
+
} from "./server-q5z0gag0.js";
|
|
44
44
|
import {
|
|
45
45
|
hasMeaningfulUserText2,
|
|
46
46
|
estimateTokens,
|
|
@@ -55,11 +55,12 @@ import {
|
|
|
55
55
|
beginSqliteWriterAsync2
|
|
56
56
|
} from "./server-gzy5w8ya.js";
|
|
57
57
|
import {
|
|
58
|
+
areRustHistorianSyntheticParts2,
|
|
58
59
|
isStrictGapHealingMessage2,
|
|
59
60
|
noteRawSessionSummaryRowWritten2,
|
|
60
61
|
RawOrdinalsNotReady2,
|
|
61
62
|
runSessionWarmupWorker
|
|
62
|
-
} from "./server-
|
|
63
|
+
} from "./server-swvhxhxz.js";
|
|
63
64
|
import {
|
|
64
65
|
buildCanonicalChunkTextFromFts2,
|
|
65
66
|
buildCompartmentSummaryFallbackText2,
|
|
@@ -69,12 +70,11 @@ import {
|
|
|
69
70
|
replaceCompartmentChunkEmbeddings2,
|
|
70
71
|
deleteChunkEmbedBackoffForSession2,
|
|
71
72
|
chunkWindowSourceKey2
|
|
72
|
-
} from "./server-
|
|
73
|
+
} from "./server-pw21ypwb.js";
|
|
73
74
|
import {
|
|
74
75
|
isPidAlive
|
|
75
76
|
} from "./server-k3t06fxr.js";
|
|
76
77
|
import {
|
|
77
|
-
BoundedSessionMap,
|
|
78
78
|
clearLkgFenceProcessState,
|
|
79
79
|
lkgFenceRequiresRebuild,
|
|
80
80
|
lkgRecoveryFenceUnclean,
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
toMessageIndexSource2,
|
|
90
90
|
clearIndexedMessagesInTransaction2,
|
|
91
91
|
indexSourcesAfterOrdinal2
|
|
92
|
-
} from "./server-
|
|
92
|
+
} from "./server-6a8pxpxg.js";
|
|
93
93
|
import {
|
|
94
94
|
retreatPastHostUnservedRows,
|
|
95
95
|
snapTerminalCompartmentToServedRow,
|
|
@@ -187,7 +187,7 @@ import {
|
|
|
187
187
|
getRawSessionTagKeysThrough2,
|
|
188
188
|
getLegacyProtectedTailStartOrdinal2,
|
|
189
189
|
readSessionChunk2
|
|
190
|
-
} from "./server-
|
|
190
|
+
} from "./server-5brp2rfn.js";
|
|
191
191
|
import {
|
|
192
192
|
getTableColumnNames
|
|
193
193
|
} from "./server-rqebawx1.js";
|
|
@@ -197,7 +197,7 @@ import {
|
|
|
197
197
|
LATEST_SUPPORTED_VERSION,
|
|
198
198
|
getPersistedSchemaVersion,
|
|
199
199
|
openDatabase
|
|
200
|
-
} from "./server-
|
|
200
|
+
} from "./server-e75vag9d.js";
|
|
201
201
|
import {
|
|
202
202
|
providerMass,
|
|
203
203
|
calibrationForModelKey,
|
|
@@ -228,8 +228,9 @@ import {
|
|
|
228
228
|
getMessageTimesFromOpenCodeDb
|
|
229
229
|
} from "./server-3vhxy2k5.js";
|
|
230
230
|
import {
|
|
231
|
+
BoundedSessionMap,
|
|
231
232
|
getMeasuredToolDefinitionTokens
|
|
232
|
-
} from "./server-
|
|
233
|
+
} from "./server-7d6m1p2b.js";
|
|
233
234
|
import {
|
|
234
235
|
V2_MEMORY_CATEGORIES,
|
|
235
236
|
CATEGORY_PRIORITY,
|
|
@@ -258,7 +259,7 @@ import {
|
|
|
258
259
|
userFacingFailureCode,
|
|
259
260
|
promoteSessionFactsDurable,
|
|
260
261
|
embedPromotedFacts
|
|
261
|
-
} from "./server-
|
|
262
|
+
} from "./server-9xbbaekh.js";
|
|
262
263
|
import {
|
|
263
264
|
isMarkerCandidateBasisCurrent2,
|
|
264
265
|
invalidateMarkerCandidateBasis2,
|
|
@@ -1488,13 +1489,13 @@ function identity(slot) {
|
|
|
1488
1489
|
slot.inputContentDigests
|
|
1489
1490
|
])).update(slot.jsonPrefix).digest("hex");
|
|
1490
1491
|
}
|
|
1491
|
-
function envelope(modelKey, systemPromptTokens, agentName) {
|
|
1492
|
+
function envelope(modelKey, systemPromptTokens, agentName, sessionId) {
|
|
1492
1493
|
const slash = modelKey.indexOf("/");
|
|
1493
1494
|
return JSON.stringify([
|
|
1494
1495
|
modelKey,
|
|
1495
1496
|
systemPromptTokens,
|
|
1496
1497
|
agentName,
|
|
1497
|
-
getMeasuredToolDefinitionTokens(modelKey.slice(0, slash), modelKey.slice(slash + 1), agentName)
|
|
1498
|
+
getMeasuredToolDefinitionTokens(modelKey.slice(0, slash), modelKey.slice(slash + 1), agentName, sessionId)
|
|
1498
1499
|
]);
|
|
1499
1500
|
}
|
|
1500
1501
|
function beginV2LkgRequest(sessionId, modelKey, previousResponseId, responseAfterSequence) {
|
|
@@ -1526,7 +1527,7 @@ function noteCapturedLkgRequest(args) {
|
|
|
1526
1527
|
request,
|
|
1527
1528
|
slot: identity(args.slot),
|
|
1528
1529
|
prefixCount: JSON.parse(args.slot.jsonPrefix).length,
|
|
1529
|
-
envelope: envelope(request.modelKey, args.systemPromptTokens, args.agentName)
|
|
1530
|
+
envelope: envelope(request.modelKey, args.systemPromptTokens, args.agentName, args.sessionId)
|
|
1530
1531
|
});
|
|
1531
1532
|
}
|
|
1532
1533
|
function noteLkgProviderResponse(args) {
|
|
@@ -1557,7 +1558,7 @@ function noteLkgProviderResponse(args) {
|
|
|
1557
1558
|
}
|
|
1558
1559
|
function measuredLkgPrefix(args) {
|
|
1559
1560
|
const capture = captures.get(args.sessionId);
|
|
1560
|
-
if (!capture?.usage || !args.slot || capture.slot !== identity(args.slot) || capture.request.modelKey !== args.modelKey || capture.envelope !== envelope(args.modelKey, args.systemPromptTokens, args.agentName))
|
|
1561
|
+
if (!capture?.usage || !args.slot || capture.slot !== identity(args.slot) || capture.request.modelKey !== args.modelKey || capture.envelope !== envelope(args.modelKey, args.systemPromptTokens, args.agentName, args.sessionId))
|
|
1561
1562
|
return;
|
|
1562
1563
|
const appendedMessages = args.messages.slice(capture.prefixCount);
|
|
1563
1564
|
if (appendedMessages[0]?.info.id !== capture.usage.responseId || appendedMessages[0]?.info.role !== "assistant" || JSON.stringify(args.messages.slice(0, capture.prefixCount)) !== args.slot.jsonPrefix)
|
|
@@ -16783,6 +16784,7 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
16783
16784
|
priorBoundaryOrdinal: ctx.priorBoundaryOrdinal,
|
|
16784
16785
|
migrationFloorActive: ctx.migrationFloorActive,
|
|
16785
16786
|
emergencyTailScale: ctx.emergencyTailScale,
|
|
16787
|
+
liftLivePromptFloor: ctx.liftLivePromptFloor === true ? true : undefined,
|
|
16786
16788
|
providerShapeVersion: ctx.providerShapeVersion,
|
|
16787
16789
|
cacheNamespace: ctx.cacheNamespace,
|
|
16788
16790
|
createdAt,
|
|
@@ -17210,28 +17212,37 @@ function logInconsistentProducerWindowOnce(sessionId, model, window, reserve) {
|
|
|
17210
17212
|
sessionLog2(sessionId, `producer window inconsistent for ${model}: window=${window} reserve=${reserve}; sending unguarded`);
|
|
17211
17213
|
}
|
|
17212
17214
|
var HISTORIAN_ALERT_COOLDOWN_MS = 60 * 1000;
|
|
17213
|
-
function
|
|
17214
|
-
|
|
17215
|
-
return [];
|
|
17215
|
+
function nonNarrativeStoredGapRanges(db, sessionId, compartments) {
|
|
17216
|
+
const rebasedToV2 = readCoordinateRebaseNotice(db, sessionId)?.generation === "v2";
|
|
17216
17217
|
const safeRanges = [];
|
|
17217
|
-
for (let index =
|
|
17218
|
+
for (let index = 0;index < compartments.length; index += 1) {
|
|
17218
17219
|
const previous = compartments[index - 1];
|
|
17219
17220
|
const current = compartments[index];
|
|
17220
|
-
if (!
|
|
17221
|
+
if (!current)
|
|
17221
17222
|
continue;
|
|
17222
|
-
const start = previous.endMessage + 1;
|
|
17223
|
+
const start = previous ? previous.endMessage + 1 : 1;
|
|
17223
17224
|
const end = current.startMessage - 1;
|
|
17224
17225
|
if (end < start)
|
|
17225
17226
|
continue;
|
|
17226
17227
|
const messages = readRawSessionMessageRange2(sessionId, start, end);
|
|
17227
17228
|
const ordinals = new Set(messages.map((message) => message.ordinal));
|
|
17228
|
-
const complete = ordinals.size === end - start + 1 && messages.every((message) => isStrictGapHealingMessage2(message));
|
|
17229
|
+
const complete = ordinals.size === end - start + 1 && messages.every((message) => message.ordinal >= start && message.ordinal <= end && (areRustHistorianSyntheticParts2(message.parts) || index > 0 && rebasedToV2 && isStrictGapHealingMessage2(message)));
|
|
17229
17230
|
if (complete)
|
|
17230
17231
|
safeRanges.push({ start, end });
|
|
17231
17232
|
}
|
|
17232
17233
|
return safeRanges;
|
|
17233
17234
|
}
|
|
17234
17235
|
var lastHistorianAlertBySession = new Map;
|
|
17236
|
+
var loggedStoredValidationFailures = new Map;
|
|
17237
|
+
function logStoredValidationFailureOnce(sessionId, error) {
|
|
17238
|
+
const failureClass = error.split(" ", 2).join(" ");
|
|
17239
|
+
const logged = loggedStoredValidationFailures.get(sessionId) ?? new Set;
|
|
17240
|
+
if (logged.has(failureClass))
|
|
17241
|
+
return;
|
|
17242
|
+
logged.add(failureClass);
|
|
17243
|
+
loggedStoredValidationFailures.set(sessionId, logged);
|
|
17244
|
+
sessionLog2(sessionId, `historian failure: source=existing-validation reason="${error}"`);
|
|
17245
|
+
}
|
|
17235
17246
|
var STORED_COMPARTMENT_FAILURE_BACKOFF_MS = 30 * 60 * 1000;
|
|
17236
17247
|
function storedCompartmentFailureBackingOff(db, sessionId, validationError, now = Date.now()) {
|
|
17237
17248
|
if (getHistorianFailureState(db, sessionId).lastError !== validationError)
|
|
@@ -17376,10 +17387,12 @@ async function runCompartmentAgent(deps) {
|
|
|
17376
17387
|
return;
|
|
17377
17388
|
}
|
|
17378
17389
|
let priorCompartments = getCompartments(db, sessionId);
|
|
17379
|
-
let existingValidationError = validateStoredCompartments(priorCompartments,
|
|
17390
|
+
let existingValidationError = validateStoredCompartments(priorCompartments, nonNarrativeStoredGapRanges(db, sessionId, priorCompartments));
|
|
17380
17391
|
const unresolvedInvolved = existingValidationError !== null && priorCompartments.some((compartment) => compartment.rebaseStatus === "unresolved");
|
|
17381
|
-
if (
|
|
17382
|
-
|
|
17392
|
+
if (existingValidationError && storedCompartmentFailureBackingOff(db, sessionId, existingValidationError)) {
|
|
17393
|
+
if (unresolvedInvolved) {
|
|
17394
|
+
sessionLog2(sessionId, `historian no-op: stored compartments still invalid ("${existingValidationError}"); backing off`);
|
|
17395
|
+
}
|
|
17383
17396
|
telemetry.status = "noop";
|
|
17384
17397
|
telemetry.failureReason = `existing-validation backoff: ${existingValidationError}`;
|
|
17385
17398
|
return;
|
|
@@ -17393,15 +17406,19 @@ async function runCompartmentAgent(deps) {
|
|
|
17393
17406
|
});
|
|
17394
17407
|
if (recovery.rowsRewritten > 0) {
|
|
17395
17408
|
priorCompartments = getCompartments(db, sessionId);
|
|
17396
|
-
existingValidationError = validateStoredCompartments(priorCompartments,
|
|
17409
|
+
existingValidationError = validateStoredCompartments(priorCompartments, nonNarrativeStoredGapRanges(db, sessionId, priorCompartments));
|
|
17397
17410
|
}
|
|
17398
17411
|
}
|
|
17399
17412
|
if (existingValidationError) {
|
|
17400
|
-
|
|
17413
|
+
if (unresolvedInvolved) {
|
|
17414
|
+
sessionLog2(sessionId, `historian failure: source=existing-validation reason="${existingValidationError}"`);
|
|
17415
|
+
} else {
|
|
17416
|
+
logStoredValidationFailureOnce(sessionId, existingValidationError);
|
|
17417
|
+
}
|
|
17401
17418
|
const failCount = incrementHistorianFailure(db, sessionId, existingValidationError);
|
|
17402
17419
|
telemetry.failureReason = `existing-validation: ${existingValidationError}`;
|
|
17420
|
+
retainDrainReservationForRetryThrottle = true;
|
|
17403
17421
|
if (unresolvedInvolved) {
|
|
17404
|
-
retainDrainReservationForRetryThrottle = true;
|
|
17405
17422
|
await notifyHistorianIssue(buildStoredCompartmentsInvalidNotice());
|
|
17406
17423
|
} else {
|
|
17407
17424
|
await notifyHistorianIssue(buildHistorianFailureNotice(failCount, existingValidationError));
|
|
@@ -17441,7 +17458,8 @@ async function runCompartmentAgent(deps) {
|
|
|
17441
17458
|
inputTokens: boundarySnapshot.usageInputTokens
|
|
17442
17459
|
},
|
|
17443
17460
|
usageSource: boundarySnapshot.usageSource,
|
|
17444
|
-
emergencyTailScale: boundarySnapshot.emergencyTailScale
|
|
17461
|
+
emergencyTailScale: boundarySnapshot.emergencyTailScale,
|
|
17462
|
+
liftLivePromptFloor: boundarySnapshot.liftLivePromptFloor === true
|
|
17445
17463
|
});
|
|
17446
17464
|
if (refreshed && hasRunnableCompartmentWindow(refreshed)) {
|
|
17447
17465
|
sessionLog2(sessionId, `historian: refreshed stale protected-tail snapshot at run time (was: ${validation.detail ?? "stale"}) — eligible head ${refreshed.offset}-${refreshed.eligibleEndOrdinal - 1}`);
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
} from "./server-fb3zxn06.js";
|
|
43
43
|
import {
|
|
44
44
|
startMessageFtsRowidMapBackfill2
|
|
45
|
-
} from "./server-
|
|
45
|
+
} from "./server-wxrdher8.js";
|
|
46
46
|
import {
|
|
47
47
|
LKG_SLOT_CHUNKS_DDL,
|
|
48
48
|
SESSION_REPLAY_DECISIONS_DDL,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
import {
|
|
66
66
|
setDatabase,
|
|
67
67
|
loadToolDefinitionMeasurements
|
|
68
|
-
} from "./server-
|
|
68
|
+
} from "./server-7d6m1p2b.js";
|
|
69
69
|
import {
|
|
70
70
|
getErrorMessage
|
|
71
71
|
} from "./server-y8v6yerm.js";
|
|
@@ -1221,7 +1221,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1221
1221
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1222
1222
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1223
1223
|
return;
|
|
1224
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1224
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-knvkq1hf.js"));
|
|
1225
1225
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-zvthw6xb.js"));
|
|
1226
1226
|
if (signal.aborted)
|
|
1227
1227
|
return;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./server-gzy5w8ya.js";
|
|
7
7
|
import {
|
|
8
8
|
runSessionWarmupWorker
|
|
9
|
-
} from "./server-
|
|
9
|
+
} from "./server-swvhxhxz.js";
|
|
10
10
|
import {
|
|
11
11
|
estimateTokens
|
|
12
12
|
} from "./server-3mz2qh5a.js";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
hasRawMessageProvider2,
|
|
19
19
|
readRawSessionMessageIdOrdinalsForRange2
|
|
20
|
-
} from "./server-
|
|
20
|
+
} from "./server-5brp2rfn.js";
|
|
21
21
|
|
|
22
22
|
// src/tools/ctx-expand/search-archive.ts
|
|
23
23
|
var archiveReadsOnThisThread = 0;
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./server-ab1g0wn9.js";
|
|
14
14
|
import {
|
|
15
15
|
messageFtsOrdinalRangeIsMapped2
|
|
16
|
-
} from "./server-
|
|
16
|
+
} from "./server-wxrdher8.js";
|
|
17
17
|
|
|
18
18
|
// src/features/magic-context/compartment-chunk-embedding.ts
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
countSessionCompartmentEmbedCoverage2,
|
|
51
51
|
countSessionCompartmentEmbedCoveragePolite2,
|
|
52
52
|
countUnembeddedSessionCompartmentsPolite2
|
|
53
|
-
} from "./server-
|
|
53
|
+
} from "./server-pw21ypwb.js";
|
|
54
54
|
import {
|
|
55
55
|
acquireGitSweepLease,
|
|
56
56
|
renewGitSweepLease,
|
|
@@ -18,6 +18,10 @@ import { Worker } from "node:worker_threads";
|
|
|
18
18
|
|
|
19
19
|
// src/hooks/magic-context/read-session-raw.ts
|
|
20
20
|
import { isMainThread } from "node:worker_threads";
|
|
21
|
+
function areRustHistorianSyntheticParts2(parts) {
|
|
22
|
+
const contentParts = parts.filter((part) => part === null || typeof part !== "object" || part.type !== "compaction");
|
|
23
|
+
return contentParts.length > 0 && contentParts.every((part) => part !== null && typeof part === "object" && (part.synthetic === true || part.syntheticTodoMarker === true));
|
|
24
|
+
}
|
|
21
25
|
function isStrictGapHealingMessage2(message) {
|
|
22
26
|
if (message.storeType === "synthetic")
|
|
23
27
|
return true;
|
|
@@ -1293,4 +1297,4 @@ function recordFailure(key, sessionId, failure, detail) {
|
|
|
1293
1297
|
log2(`[magic-context] WARN canonical ordinal warm-up failed for ${sessionId} (${failure}: ${detail}); counts remain bounded and callers must defer or retry`);
|
|
1294
1298
|
}
|
|
1295
1299
|
|
|
1296
|
-
export { isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
|
|
1300
|
+
export { areRustHistorianSyntheticParts2, isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
|