@cortexkit/opencode-magic-context 0.49.35 → 0.49.36
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 +1 -1
- package/dist/auto-search-worker.js +163 -160
- package/dist/chunk-embedding-write-worker.js +58 -56
- package/dist/{compaction-marker-candidates-g0p67ced.js → compaction-marker-candidates-5p1qkve9.js} +3 -1
- package/dist/compaction-marker-candidates-worker.js +24 -23
- package/dist/{compartment-chunk-embedding-y4136are.js → compartment-chunk-embedding-ypktm0tk.js} +5 -4
- package/dist/{conflict-warning-hook-hhw8z5ak.js → conflict-warning-hook-b75jn458.js} +6 -5
- package/dist/{context-fk8e3h9p.js → context-969z683s.js} +485 -91
- package/dist/{embedding-backfill-q6n72sy0.js → embedding-backfill-rma0v2ct.js} +9 -8
- package/dist/embedding-worker.js +2 -2
- package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts +5 -3
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-gate.d.ts +2 -0
- package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-state.d.ts +9 -0
- package/dist/features/magic-context/dreamer/verify-state.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/verify.d.ts +2 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/migration-worker-client.d.ts +3 -0
- package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/migration-worker.d.ts +15 -0
- package/dist/features/magic-context/migration-worker.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +2 -2
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +4 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/work-metrics-carry-storage.d.ts +10 -0
- package/dist/features/magic-context/work-metrics-carry-storage.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts +5 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/issue-423-fixture.d.ts +1 -1
- package/dist/hooks/magic-context/issue-423-fixture.d.ts.map +1 -1
- package/dist/hooks/magic-context/issue-424-fixture.d.ts +1 -1
- package/dist/hooks/magic-context/issue-424-fixture.d.ts.map +1 -1
- package/dist/hooks/magic-context/project-structural-sentinels.d.ts +25 -0
- package/dist/hooks/magic-context/project-structural-sentinels.d.ts.map +1 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +2 -0
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/release-recovery-prefix.d.ts +9 -0
- package/dist/hooks/magic-context/release-recovery-prefix.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-structural-noise.d.ts +6 -3
- package/dist/hooks/magic-context/strip-structural-noise.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +3 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +3 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-cpjk5jd2.js → index-1d042x6w.js} +16 -14
- package/dist/{index-jn0ddrhp.js → index-21fgrfrf.js} +8 -6
- package/dist/{index-pq0dpwrc.js → index-2rs7912w.js} +2 -2
- package/dist/{index-ezv6dz3y.js → index-4ks89h5a.js} +4 -4
- package/dist/{index-vzhhr1ht.js → index-4y35msh5.js} +1 -2
- package/dist/{index-f297z1n8.js → index-72czy45z.js} +5 -5
- package/dist/index-7v05d9b7.js +58 -0
- package/dist/{index-f9b3vtt1.js → index-850vthn3.js} +8 -2
- package/dist/{index-ksv0a31x.js → index-8jjjmhab.js} +12 -1
- package/dist/index-96ztjvkn.js +204 -0
- package/dist/{index-gyaa159j.js → index-9fgmkfaf.js} +6 -3
- package/dist/{index-4bgk5ztz.js → index-9tdvbdv1.js} +187 -90
- package/dist/{index-2v6nvy3k.js → index-ae1ar4v1.js} +1 -1
- package/dist/{index-faxb7mck.js → index-b1ydbp95.js} +1 -1
- package/dist/{index-nxrsns5x.js → index-c5dzns43.js} +75 -75
- package/dist/{index-zhqwda72.js → index-dcjkw41m.js} +1 -1
- package/dist/{index-x2mrq5xv.js → index-dfdg2cgg.js} +179 -49
- package/dist/{index-87ctnzz9.js → index-dz48h1wx.js} +2 -2
- package/dist/{index-b6xz3qbe.js → index-gnmhbyyc.js} +366 -83
- package/dist/{index-qx8j6kds.js → index-j105mf16.js} +2 -2
- package/dist/{index-p56dszfp.js → index-jggt5gf2.js} +1 -1
- package/dist/{index-xwwsbsd3.js → index-pp8vdn01.js} +5 -5
- package/dist/{index-dy7w6wm4.js → index-prw8apnc.js} +5 -5
- package/dist/{index-qncw9hey.js → index-r2epb000.js} +33 -3
- package/dist/{index-brg2w6qc.js → index-tn9drm1a.js} +16 -14
- package/dist/{index-pswsyf1w.js → index-ty4vhe4n.js} +3 -3
- package/dist/{index-pztqab6k.js → index-vd2ywmfe.js} +1 -1
- package/dist/{index-3j9t1v4n.js → index-wcwhhtdh.js} +10 -9
- package/dist/{index-1rhgxqs8.js → index-xd2p95m7.js} +1 -1
- package/dist/{index-0c7p8mq5.js → index-xnm0wq1r.js} +1 -1
- package/dist/{index-3d3872c6.js → index-ys7j6679.js} +4 -4
- package/dist/index.js +38 -37
- package/dist/{message-fts-rowid-map-xg7hr0mk.js → message-fts-rowid-map-t6qsyg9s.js} +4 -3
- package/dist/{message-index-bounded-narw7bnz.js → message-index-bounded-wfk6aqxk.js} +9 -8
- package/dist/migration-worker.js +45 -40
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-tdz7985n.js → project-embedding-registry-3yyegjma.js} +8 -7
- package/dist/raw-ordinal-warmup-worker.js +114 -118
- package/dist/{read-session-chunk-vmg1zjg0.js → read-session-chunk-26yrrhyz.js} +7 -6
- package/dist/{read-session-raw-mncmzbm9.js → read-session-raw-j7c9w57v.js} +3 -2
- package/dist/{recomp-orchestrator-qyyhnc9b.js → recomp-orchestrator-wk509qkp.js} +20 -19
- package/dist/{render-c5p0k846.js → render-h1qarr8a.js} +13 -12
- package/dist/{search-f6hwvcxk.js → search-5h9fydyq.js} +16 -15
- package/dist/{search-archive-0ny7p3bw.js → search-archive-q79hyqxs.js} +9 -8
- package/dist/{send-session-notification-0gwcz3fw.js → send-session-notification-14p3yje4.js} +5 -4
- package/dist/shared/model-suggestion-retry.d.ts +7 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/shared/reusable-worker-entry.d.ts +4 -0
- package/dist/shared/reusable-worker-entry.d.ts.map +1 -0
- package/dist/shared/reusable-worker.d.ts +6 -0
- package/dist/shared/reusable-worker.d.ts.map +1 -0
- package/dist/shared/reusable-worker.fixture.d.ts +2 -0
- package/dist/shared/reusable-worker.fixture.d.ts.map +1 -0
- package/dist/shared/worker-shutdown.d.ts +1 -1
- package/dist/shared/worker-shutdown.d.ts.map +1 -1
- package/dist/{storage-tags-zx1023km.js → storage-tags-vj0yj7ed.js} +1 -1
- package/dist/{store-620rjzt9.js → store-s3eykdjt.js} +1 -1
- package/dist/{transform-postprocess-phase-807ff6t2.js → transform-postprocess-phase-4gj0mtcg.js} +21 -20
- package/dist/v2/auto-search-worker.js +163 -160
- package/dist/v2/chunk-embedding-write-worker.js +59 -57
- package/dist/v2/compaction-marker-candidates-worker.js +24 -23
- package/dist/v2/{compaction-marker-candidates-t1aq6gsj.js → compaction-marker-candidates-yeb2ky46.js} +4 -2
- package/dist/v2/{compartment-chunk-embedding-ncsk0r9e.js → compartment-chunk-embedding-qfk791bd.js} +6 -5
- package/dist/v2/{context-znqfkap4.js → context-bxr039be.js} +1011 -209
- package/dist/v2/{embedding-backfill-11j425e0.js → embedding-backfill-00tw59rx.js} +10 -9
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/fold/code-mode-catalog.d.ts +3 -0
- package/dist/v2/fold/code-mode-catalog.d.ts.map +1 -0
- package/dist/v2/fold/idle.d.ts +1 -0
- package/dist/v2/fold/idle.d.ts.map +1 -1
- package/dist/v2/fold/manual-baseline.d.ts +8 -0
- package/dist/v2/fold/manual-baseline.d.ts.map +1 -0
- package/dist/v2/fold/native-replay-v3.d.ts +7 -0
- package/dist/v2/fold/native-replay-v3.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +24 -7
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/fold/summary.d.ts +4 -0
- package/dist/v2/fold/summary.d.ts.map +1 -0
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/channel2.d.ts +6 -0
- package/dist/v2/hooks/channel2.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/restore-rows.d.ts +12 -2
- package/dist/v2/hooks/restore-rows.d.ts.map +1 -1
- package/dist/v2/hooks/synthetic-admission.d.ts +7 -0
- package/dist/v2/hooks/synthetic-admission.d.ts.map +1 -0
- package/dist/v2/hooks/usage-persist.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-rmk571mb.js → message-fts-rowid-map-z86avy0n.js} +5 -4
- package/dist/v2/{message-index-bounded-620bppw7.js → message-index-bounded-w14496s9.js} +9 -8
- package/dist/v2/migration-worker.js +46 -41
- package/dist/v2/{project-embedding-registry-bm5fe1a8.js → project-embedding-registry-jqq2qeqb.js} +9 -8
- package/dist/v2/raw-ordinal-warmup-worker.js +114 -118
- package/dist/v2/{read-session-chunk-qfwv1k71.js → read-session-chunk-tqnh1ret.js} +7 -6
- package/dist/v2/{read-session-raw-q294t8xs.js → read-session-raw-qpp6x9kg.js} +4 -3
- package/dist/v2/{recomp-orchestrator-fcnjref7.js → recomp-orchestrator-9cjk6aej.js} +19 -18
- package/dist/v2/{render-98a1qv0b.js → render-5dz1knf2.js} +13 -12
- package/dist/v2/{search-z1zqzsmh.js → search-8yfet25y.js} +15 -14
- package/dist/v2/{search-archive-r0y1bafr.js → search-archive-z6z9jqwf.js} +9 -8
- package/dist/v2/{send-session-notification-fst6hkg7.js → send-session-notification-kxp47tsw.js} +4 -3
- package/dist/v2/{server-cpjk5jd2.js → server-1d042x6w.js} +16 -14
- package/dist/v2/{server-fqj6ddpr.js → server-5by3vdzs.js} +186 -89
- package/dist/v2/{server-5jp38p98.js → server-6emy0v9a.js} +1 -2
- package/dist/v2/{server-rktnzs89.js → server-6vzh6wej.js} +1 -1
- package/dist/v2/{server-qa74bj91.js → server-7094pk3w.js} +9 -8
- package/dist/v2/{server-bxpz2dcn.js → server-7acq7815.js} +8 -6
- package/dist/v2/server-7v05d9b7.js +58 -0
- package/dist/v2/{server-24g8r2d0.js → server-7zacmty5.js} +75 -75
- package/dist/v2/server-96ztjvkn.js +204 -0
- package/dist/v2/{server-hnknwaz8.js → server-a9w5f0yw.js} +3 -3
- package/dist/v2/{server-9k0mjef7.js → server-avdveykk.js} +1 -1
- package/dist/v2/{server-hsf0qsn5.js → server-cp1a03vc.js} +1 -1
- package/dist/v2/{server-r3chnxs5.js → server-dfq5vb8j.js} +2 -2
- package/dist/v2/{server-x4m6xcn4.js → server-e51xmr4d.js} +6 -6
- package/dist/v2/{server-7ccxt4nq.js → server-g3gqq4ac.js} +6 -3
- package/dist/v2/{server-kkxzwa6w.js → server-gkse1wyz.js} +3 -3
- package/dist/v2/{server-1xesqm5h.js → server-jd7vzwn4.js} +15 -13
- package/dist/v2/{server-ws5exe6q.js → server-nmyganc8.js} +1 -1
- package/dist/v2/{server-q0z2q2dx.js → server-nq3cb7be.js} +1 -1
- package/dist/v2/{server-55v5hpth.js → server-qjyp27vf.js} +2 -2
- package/dist/v2/{server-xbtw0p9t.js → server-r4430x9m.js} +9 -3
- package/dist/v2/{server-qf2kzsh2.js → server-t8y64xj7.js} +4 -4
- package/dist/v2/{server-s9xgyyj9.js → server-tnzbk64q.js} +34 -4
- package/dist/v2/{server-51779zs2.js → server-v0p37hm2.js} +4 -1
- package/dist/v2/{server-bpvsvtph.js → server-xfjjbrkt.js} +12 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-19s0ebf0.js → storage-tags-cw07ky67.js} +1 -1
- package/dist/v2/{store-vdm8v3jd.js → store-z3qe67cg.js} +1 -1
- package/dist/v2/{v2-archive-reader-t2c0eypn.js → v2-archive-reader-z7wr42ry.js} +3 -3
- package/dist/v2/{wrapup-orchestrator-aqpqsveg.js → wrapup-orchestrator-j1v62bkj.js} +19 -18
- package/dist/{v2-archive-reader-tm2eayp2.js → v2-archive-reader-028z6kck.js} +2 -2
- package/dist/{wrapup-orchestrator-k5yp19a6.js → wrapup-orchestrator-xg9avt2p.js} +21 -20
- package/package.json +1 -1
- package/src/shared/model-suggestion-retry.ts +1 -1
- package/src/shared/prompt-async-transport.test.ts +64 -3
- package/src/shared/prompt-async-transport.ts +61 -16
- package/src/shared/reusable-worker-entry.ts +58 -0
- package/src/shared/reusable-worker-reset.test.ts +108 -0
- package/src/shared/reusable-worker.fixture.ts +35 -0
- package/src/shared/reusable-worker.test.ts +253 -0
- package/src/shared/reusable-worker.ts +240 -0
- package/src/shared/worker-shutdown.ts +21 -17
|
@@ -191,7 +191,7 @@ import {
|
|
|
191
191
|
snapRangeToCompartments,
|
|
192
192
|
getActiveCompartmentRun,
|
|
193
193
|
startCompartmentAgent
|
|
194
|
-
} from "./index-
|
|
194
|
+
} from "./index-9tdvbdv1.js";
|
|
195
195
|
import {
|
|
196
196
|
hasTrustedAbsoluteWall,
|
|
197
197
|
applyProvenInputFloor,
|
|
@@ -225,6 +225,7 @@ import {
|
|
|
225
225
|
currentReclaimableToolOutputCount,
|
|
226
226
|
isRecord,
|
|
227
227
|
contentTagOwnerMessageId,
|
|
228
|
+
providerVisiblePart,
|
|
228
229
|
normalizeTodoStateJson,
|
|
229
230
|
computeSyntheticCallId,
|
|
230
231
|
CHANNEL1_SENTINEL,
|
|
@@ -253,13 +254,20 @@ import {
|
|
|
253
254
|
getTagsByNumbers2,
|
|
254
255
|
getDroppedTagsByNumbers2,
|
|
255
256
|
getMaxDroppedTagNumber2
|
|
256
|
-
} from "./index-
|
|
257
|
+
} from "./index-8jjjmhab.js";
|
|
257
258
|
import {
|
|
258
259
|
observeTemporalDecisions,
|
|
259
260
|
stableStringify
|
|
260
261
|
} from "./index-9wnbnx8f.js";
|
|
261
262
|
import {
|
|
262
263
|
withContentLanguageDirective,
|
|
264
|
+
string,
|
|
265
|
+
number,
|
|
266
|
+
boolean,
|
|
267
|
+
array,
|
|
268
|
+
object,
|
|
269
|
+
tuple,
|
|
270
|
+
literal,
|
|
263
271
|
parseCron,
|
|
264
272
|
nextOccurrence,
|
|
265
273
|
nextDueAtMs,
|
|
@@ -270,14 +278,14 @@ import {
|
|
|
270
278
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
271
279
|
DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
272
280
|
DREAM_TASK_PROMOTION_DEFAULTS
|
|
273
|
-
} from "./index-
|
|
281
|
+
} from "./index-c5dzns43.js";
|
|
274
282
|
import {
|
|
275
283
|
areRustHistorianSyntheticParts2,
|
|
276
284
|
isRawCompactionSummaryInfo2,
|
|
277
285
|
extractInMemoryMessageViews2,
|
|
278
286
|
buildInMemoryTailRawMessages2,
|
|
279
287
|
RawOrdinalsNotReady2
|
|
280
|
-
} from "./index-
|
|
288
|
+
} from "./index-r2epb000.js";
|
|
281
289
|
import {
|
|
282
290
|
openCodeDbExists,
|
|
283
291
|
withReadOnlySessionDb,
|
|
@@ -285,7 +293,7 @@ import {
|
|
|
285
293
|
latestPersistedMessageForRecovery,
|
|
286
294
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
287
295
|
findLastAssistantModelFromOpenCodeDb
|
|
288
|
-
} from "./index-
|
|
296
|
+
} from "./index-vd2ywmfe.js";
|
|
289
297
|
import {
|
|
290
298
|
askAnswerLines,
|
|
291
299
|
estimateTrueRawMessageTokens,
|
|
@@ -361,7 +369,6 @@ import {
|
|
|
361
369
|
getPendingCompactionMarkerState,
|
|
362
370
|
getCompactionMarkerHealth,
|
|
363
371
|
clearPendingCompactionMarkerStateIf,
|
|
364
|
-
setSessionWorkMetrics,
|
|
365
372
|
getObservedEpochFloor,
|
|
366
373
|
resolveEpochFloorForPass,
|
|
367
374
|
detectLatestTurnThinkingMismatch,
|
|
@@ -409,7 +416,7 @@ import {
|
|
|
409
416
|
readRawSessionMessageById2,
|
|
410
417
|
readSessionChunk2,
|
|
411
418
|
readRawSessionSeedTail2
|
|
412
|
-
} from "./index-
|
|
419
|
+
} from "./index-tn9drm1a.js";
|
|
413
420
|
import {
|
|
414
421
|
BoundedSessionMap,
|
|
415
422
|
getMeasuredToolDefinitionTokens
|
|
@@ -439,7 +446,7 @@ import {
|
|
|
439
446
|
runSqliteOptimize,
|
|
440
447
|
openDatabase,
|
|
441
448
|
openCurrentDatabase
|
|
442
|
-
} from "./index-
|
|
449
|
+
} from "./index-9fgmkfaf.js";
|
|
443
450
|
import {
|
|
444
451
|
unescapeXml,
|
|
445
452
|
resolveWorkspaceShareCategories,
|
|
@@ -548,10 +555,10 @@ import {
|
|
|
548
555
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
549
556
|
getProjectState,
|
|
550
557
|
bumpProjectUserProfileVersion
|
|
551
|
-
} from "./index-
|
|
558
|
+
} from "./index-72czy45z.js";
|
|
552
559
|
import {
|
|
553
560
|
getLastIndexedOrdinal
|
|
554
|
-
} from "./index-
|
|
561
|
+
} from "./index-2rs7912w.js";
|
|
555
562
|
import {
|
|
556
563
|
SESSION_NOTE_CONDITION_ERROR,
|
|
557
564
|
getNoteByIdInScope,
|
|
@@ -589,7 +596,7 @@ import {
|
|
|
589
596
|
getCachedLocalEmbeddingPooling,
|
|
590
597
|
preflightLocalEmbeddingPooling,
|
|
591
598
|
getLocalEmbeddingNativeMemoryStats
|
|
592
|
-
} from "./index-
|
|
599
|
+
} from "./index-xd2p95m7.js";
|
|
593
600
|
import {
|
|
594
601
|
describeShadowBackfillWriteRefusal2,
|
|
595
602
|
markProjectLoadUntrusted2,
|
|
@@ -609,7 +616,7 @@ import {
|
|
|
609
616
|
embedSessionCompartmentChunks2,
|
|
610
617
|
getEmbeddingCoverageStatus2,
|
|
611
618
|
getAutoEmbeddingSessionCoverage2
|
|
612
|
-
} from "./index-
|
|
619
|
+
} from "./index-21fgrfrf.js";
|
|
613
620
|
import {
|
|
614
621
|
saveEmbeddingIfHashMatches,
|
|
615
622
|
invalidateProject2,
|
|
@@ -617,7 +624,7 @@ import {
|
|
|
617
624
|
} from "./index-4dhv7mqz.js";
|
|
618
625
|
import {
|
|
619
626
|
cosineSimilarity
|
|
620
|
-
} from "./index-
|
|
627
|
+
} from "./index-ty4vhe4n.js";
|
|
621
628
|
import {
|
|
622
629
|
computeCueContentHash,
|
|
623
630
|
hasMuralCueColumns,
|
|
@@ -637,6 +644,7 @@ import {
|
|
|
637
644
|
getMemoryById2,
|
|
638
645
|
getMemoriesByIds2,
|
|
639
646
|
updateMemorySeenCount2,
|
|
647
|
+
updateMemoryVerification2,
|
|
640
648
|
setMemoryClassification2,
|
|
641
649
|
supersededMemory2,
|
|
642
650
|
mergeMemoryStats2,
|
|
@@ -662,7 +670,7 @@ import {
|
|
|
662
670
|
readGitFileChangeTimesSince,
|
|
663
671
|
verificationFileExists,
|
|
664
672
|
normalizeVerificationFiles
|
|
665
|
-
} from "./index-
|
|
673
|
+
} from "./index-xnm0wq1r.js";
|
|
666
674
|
import {
|
|
667
675
|
renderSingleStoreMigrationRequiredRefusal,
|
|
668
676
|
SingleStoreMigrationRequiredError,
|
|
@@ -683,23 +691,23 @@ import {
|
|
|
683
691
|
resolveMemoriesByIdsForSearch2,
|
|
684
692
|
unifiedSearch2,
|
|
685
693
|
formatSearchResults2
|
|
686
|
-
} from "./index-
|
|
694
|
+
} from "./index-wcwhhtdh.js";
|
|
687
695
|
import {
|
|
688
696
|
scheduleReconciliation,
|
|
689
697
|
scheduleIncrementalIndex,
|
|
690
698
|
getMessageIndexQueueHeapStats,
|
|
691
699
|
clearSessionTracking
|
|
692
|
-
} from "./index-
|
|
700
|
+
} from "./index-dz48h1wx.js";
|
|
693
701
|
import {
|
|
694
702
|
flushIgnoredMessages2,
|
|
695
703
|
clearIgnoredMessages2,
|
|
696
704
|
observeIgnoredNotificationEvent2,
|
|
697
705
|
sendStatusNotification2
|
|
698
|
-
} from "./index-
|
|
706
|
+
} from "./index-ae1ar4v1.js";
|
|
699
707
|
import {
|
|
700
708
|
setRecompStarting2,
|
|
701
709
|
setRecompTerminal2
|
|
702
|
-
} from "./index-
|
|
710
|
+
} from "./index-ys7j6679.js";
|
|
703
711
|
import {
|
|
704
712
|
makeToolCompositeKey,
|
|
705
713
|
searchMessageHistoryOffThread,
|
|
@@ -743,11 +751,13 @@ import {
|
|
|
743
751
|
replayCavemanCompression,
|
|
744
752
|
DegradedPassRefusalError,
|
|
745
753
|
degradedPassError,
|
|
754
|
+
isStructuralNoiseSentinel,
|
|
755
|
+
stripStructuralNoise,
|
|
756
|
+
prepareStructuralSentinelChoices,
|
|
746
757
|
renderDroppedText,
|
|
747
758
|
applyFlushedStatuses,
|
|
748
759
|
prewarmTagOwners,
|
|
749
760
|
waitForTagOwners,
|
|
750
|
-
stripStructuralNoise,
|
|
751
761
|
isLegacyForeignTextTag,
|
|
752
762
|
withTransformTimingSummary,
|
|
753
763
|
logTransformTiming,
|
|
@@ -762,7 +772,7 @@ import {
|
|
|
762
772
|
abortSessionFailClosed2,
|
|
763
773
|
evaluateEmergencyFailClosed2,
|
|
764
774
|
runPostTransformPhase2
|
|
765
|
-
} from "./index-
|
|
775
|
+
} from "./index-dfdg2cgg.js";
|
|
766
776
|
import {
|
|
767
777
|
ANNOUNCEMENT_VERSION2,
|
|
768
778
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -777,13 +787,13 @@ import {
|
|
|
777
787
|
renderMessageByOrdinal2,
|
|
778
788
|
renderVerboseRangeForTool2,
|
|
779
789
|
renderItemByTag2
|
|
780
|
-
} from "./index-
|
|
790
|
+
} from "./index-j105mf16.js";
|
|
781
791
|
import {
|
|
782
792
|
readV2ArchiveOffThread2
|
|
783
|
-
} from "./index-
|
|
793
|
+
} from "./index-prw8apnc.js";
|
|
784
794
|
import {
|
|
785
795
|
renderSearchArchiveOffThread2
|
|
786
|
-
} from "./index-
|
|
796
|
+
} from "./index-4ks89h5a.js";
|
|
787
797
|
import {
|
|
788
798
|
COMPACTION_ENABLED_PATH,
|
|
789
799
|
isDreamerRunnable,
|
|
@@ -2361,7 +2371,7 @@ function recordRetrospectiveWindowProcessed(db, projectPath, windowKey) {
|
|
|
2361
2371
|
}
|
|
2362
2372
|
|
|
2363
2373
|
// src/features/magic-context/dreamer/task-executor.ts
|
|
2364
|
-
import { createHash as
|
|
2374
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
2365
2375
|
import { existsSync as existsSync5, readFileSync as readFileSync3 } from "node:fs";
|
|
2366
2376
|
|
|
2367
2377
|
// src/features/magic-context/mural/compress-cues.ts
|
|
@@ -8399,12 +8409,17 @@ function countCompartmentsSince(db, projectPath, since) {
|
|
|
8399
8409
|
return row?.cnt ?? 0;
|
|
8400
8410
|
}
|
|
8401
8411
|
function countProjectSessionsSince(db, projectPath, since) {
|
|
8402
|
-
const
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8412
|
+
const scope = `FROM session_projects sp
|
|
8413
|
+
LEFT JOIN session_meta m ON m.session_id = sp.session_id
|
|
8414
|
+
WHERE sp.project_path = ? AND sp.harness = ?
|
|
8415
|
+
AND COALESCE(m.is_subagent, 0) = 0`;
|
|
8416
|
+
const row = since === null ? db.prepare(`SELECT COUNT(*) AS cnt ${scope}`).get(projectPath, getHarness2()) : db.prepare(`SELECT COUNT(*) AS cnt ${scope}
|
|
8417
|
+
AND COALESCE(
|
|
8418
|
+
(SELECT CAST(value AS INTEGER) FROM schema_migrations_meta
|
|
8419
|
+
WHERE key = 'retrospective_activity:' || sp.session_id),
|
|
8420
|
+
(SELECT updated_at FROM message_history_index
|
|
8421
|
+
WHERE session_id = sp.session_id AND harness = sp.harness)
|
|
8422
|
+
) > ?`).get(projectPath, getHarness2(), since);
|
|
8408
8423
|
return row?.cnt ?? 0;
|
|
8409
8424
|
}
|
|
8410
8425
|
function countMappedMemories(db, projectPath) {
|
|
@@ -8417,6 +8432,10 @@ function countMappedMemories(db, projectPath) {
|
|
|
8417
8432
|
AND v.file_path <> ''`).get(projectPath, Date.now());
|
|
8418
8433
|
return row?.cnt ?? 0;
|
|
8419
8434
|
}
|
|
8435
|
+
var CURRENT_VERIFY_SKIP_SQL = `COALESCE(CASE WHEN json_valid(m.metadata_json) THEN
|
|
8436
|
+
json_extract(m.metadata_json, '$.dreamerVerifySkip.contentHash') = m.normalized_hash
|
|
8437
|
+
AND json_type(m.metadata_json, '$.dreamerVerifySkip.fingerprint') = 'text'
|
|
8438
|
+
ELSE 0 END, 0)`;
|
|
8420
8439
|
function countUnverifiedMappedMemories(db, projectPath) {
|
|
8421
8440
|
const row = db.prepare(`SELECT COUNT(DISTINCT m.id) AS cnt
|
|
8422
8441
|
FROM memories m
|
|
@@ -8425,7 +8444,8 @@ function countUnverifiedMappedMemories(db, projectPath) {
|
|
|
8425
8444
|
AND m.status IN ('active','permanent')
|
|
8426
8445
|
AND (m.expires_at IS NULL OR m.expires_at > ?)
|
|
8427
8446
|
AND v.file_path <> ''
|
|
8428
|
-
AND v.verified_at = 0
|
|
8447
|
+
AND v.verified_at = 0
|
|
8448
|
+
AND NOT (${CURRENT_VERIFY_SKIP_SQL})`).get(projectPath, Date.now());
|
|
8429
8449
|
return row?.cnt ?? 0;
|
|
8430
8450
|
}
|
|
8431
8451
|
function countBroadCycleCandidates(db, projectPath, cycleStartAt) {
|
|
@@ -8434,6 +8454,7 @@ function countBroadCycleCandidates(db, projectPath, cycleStartAt) {
|
|
|
8434
8454
|
WHERE m.project_path = ?
|
|
8435
8455
|
AND m.status IN ('active','permanent')
|
|
8436
8456
|
AND (m.expires_at IS NULL OR m.expires_at > ?)
|
|
8457
|
+
AND NOT (${CURRENT_VERIFY_SKIP_SQL})
|
|
8437
8458
|
AND (
|
|
8438
8459
|
SELECT MAX(v.verified_at)
|
|
8439
8460
|
FROM memory_verifications v
|
|
@@ -8542,7 +8563,7 @@ function getDreamTaskBacklog(db, projectPath, task, options = {}) {
|
|
|
8542
8563
|
case "verify-broad": {
|
|
8543
8564
|
const total = countMappedMemories(db, projectPath);
|
|
8544
8565
|
const cycleStartAt = getTaskScheduleState(db, projectPath, "verify-broad")?.lastBroadRunAt;
|
|
8545
|
-
const pending =
|
|
8566
|
+
const pending = countBroadCycleCandidates(db, projectPath, cycleStartAt ?? Number.MAX_SAFE_INTEGER);
|
|
8546
8567
|
return { pending, total };
|
|
8547
8568
|
}
|
|
8548
8569
|
case "curate": {
|
|
@@ -8669,6 +8690,7 @@ function getDreamTaskBacklogs(db, projectPath, tasks = CANONICAL_DREAM_TASKS, op
|
|
|
8669
8690
|
}
|
|
8670
8691
|
const optionKey = (value) => value === undefined ? "omitted" : value === null ? "null" : `number:${value}`;
|
|
8671
8692
|
const key = JSON.stringify([
|
|
8693
|
+
getHarness2(),
|
|
8672
8694
|
projectPath,
|
|
8673
8695
|
tasks,
|
|
8674
8696
|
optionKey(options.lastRunAt),
|
|
@@ -8722,7 +8744,7 @@ function evaluateTaskGate(task, ctx) {
|
|
|
8722
8744
|
}
|
|
8723
8745
|
|
|
8724
8746
|
// src/features/magic-context/dreamer/verify.ts
|
|
8725
|
-
import { createHash as
|
|
8747
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
8726
8748
|
|
|
8727
8749
|
// src/features/magic-context/dreamer/verify-diff.ts
|
|
8728
8750
|
import { execFile as execFile3 } from "node:child_process";
|
|
@@ -8843,7 +8865,56 @@ Read only these changed line ranges if they may affect the claim.`
|
|
|
8843
8865
|
}
|
|
8844
8866
|
|
|
8845
8867
|
// src/features/magic-context/dreamer/verify-gate.ts
|
|
8868
|
+
import path5 from "node:path";
|
|
8869
|
+
|
|
8870
|
+
// src/features/magic-context/dreamer/verify-state.ts
|
|
8871
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
8872
|
+
import { readFile, realpath as realpath2 } from "node:fs/promises";
|
|
8846
8873
|
import path4 from "node:path";
|
|
8874
|
+
function verificationMetadata(memory) {
|
|
8875
|
+
try {
|
|
8876
|
+
const parsed = JSON.parse(memory.metadataJson ?? "{}");
|
|
8877
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
|
|
8878
|
+
return parsed;
|
|
8879
|
+
} catch {}
|
|
8880
|
+
return {};
|
|
8881
|
+
}
|
|
8882
|
+
async function verificationFilesFingerprint(directory, files) {
|
|
8883
|
+
const root = await resolveGitTopLevel(directory) ?? path4.resolve(directory);
|
|
8884
|
+
const hash = createHash6("sha256");
|
|
8885
|
+
for (const file of [...new Set(files)].sort()) {
|
|
8886
|
+
const absolute = path4.resolve(root, file);
|
|
8887
|
+
const withinRoot = (candidate) => {
|
|
8888
|
+
const relative = path4.relative(root, candidate);
|
|
8889
|
+
return relative !== ".." && !relative.startsWith(`..${path4.sep}`) && !path4.isAbsolute(relative);
|
|
8890
|
+
};
|
|
8891
|
+
if (!withinRoot(absolute))
|
|
8892
|
+
return null;
|
|
8893
|
+
hash.update(JSON.stringify(file));
|
|
8894
|
+
try {
|
|
8895
|
+
if (!withinRoot(await realpath2(absolute)))
|
|
8896
|
+
return null;
|
|
8897
|
+
hash.update(createHash6("sha256").update(await readFile(absolute)).digest("hex"));
|
|
8898
|
+
} catch (error) {
|
|
8899
|
+
if (error.code !== "ENOENT")
|
|
8900
|
+
return null;
|
|
8901
|
+
hash.update("missing");
|
|
8902
|
+
}
|
|
8903
|
+
}
|
|
8904
|
+
return hash.digest("hex");
|
|
8905
|
+
}
|
|
8906
|
+
function recordVerificationVerdict(db, memory, verdict, at, fingerprint = null) {
|
|
8907
|
+
const metadata = verificationMetadata(memory);
|
|
8908
|
+
delete metadata.dreamerVerifySkip;
|
|
8909
|
+
if (verdict === "skip" && fingerprint) {
|
|
8910
|
+
metadata.dreamerVerifySkip = { contentHash: memory.normalizedHash, fingerprint, at };
|
|
8911
|
+
}
|
|
8912
|
+
metadata.dreamerVerifyVerdict = verdict;
|
|
8913
|
+
metadata.dreamerVerifyAttemptedAt = at;
|
|
8914
|
+
db.prepare("UPDATE memories SET metadata_json = ? WHERE id = ?").run(JSON.stringify(metadata), memory.id);
|
|
8915
|
+
}
|
|
8916
|
+
|
|
8917
|
+
// src/features/magic-context/dreamer/verify-gate.ts
|
|
8847
8918
|
function minOf(values) {
|
|
8848
8919
|
return values.reduce((acc, v) => v < acc ? v : acc, Number.POSITIVE_INFINITY);
|
|
8849
8920
|
}
|
|
@@ -8875,7 +8946,22 @@ async function partitionVerifyScope(args) {
|
|
|
8875
8946
|
const runStartedAt = args.now ?? Date.now();
|
|
8876
8947
|
const active = getMemoriesByProject2(args.db, args.projectIdentity);
|
|
8877
8948
|
const verById = getMemoryVerifications(args.db, active.map((m) => m.id));
|
|
8878
|
-
const candidates =
|
|
8949
|
+
const candidates = [];
|
|
8950
|
+
const unchangedSkippedIds = [];
|
|
8951
|
+
const changedSkippedIds = new Set;
|
|
8952
|
+
for (const memory of active) {
|
|
8953
|
+
const files = verById.get(memory.id)?.files ?? [];
|
|
8954
|
+
if (!files.length)
|
|
8955
|
+
continue;
|
|
8956
|
+
const skip = verificationMetadata(memory).dreamerVerifySkip;
|
|
8957
|
+
if (skip && skip.contentHash === memory.normalizedHash && typeof skip.fingerprint === "string" && skip.fingerprint === await verificationFilesFingerprint(args.projectDirectory, files)) {
|
|
8958
|
+
unchangedSkippedIds.push(memory.id);
|
|
8959
|
+
} else {
|
|
8960
|
+
candidates.push(memory);
|
|
8961
|
+
if (skip)
|
|
8962
|
+
changedSkippedIds.add(memory.id);
|
|
8963
|
+
}
|
|
8964
|
+
}
|
|
8879
8965
|
const toPrompt = (m) => {
|
|
8880
8966
|
const verifiedAt = verById.get(m.id)?.verifiedAt ?? 0;
|
|
8881
8967
|
let verifiedCommit = null;
|
|
@@ -8902,7 +8988,7 @@ async function partitionVerifyScope(args) {
|
|
|
8902
8988
|
leaseKey: args.leaseKey,
|
|
8903
8989
|
runStartedAt
|
|
8904
8990
|
});
|
|
8905
|
-
const broadCandidates = candidates.filter((m) => (verById.get(m.id)?.verifiedAt ?? 0) < broadCycleStartAt).sort((a, b) => {
|
|
8991
|
+
const broadCandidates = candidates.filter((m) => changedSkippedIds.has(m.id) || (verById.get(m.id)?.verifiedAt ?? 0) < broadCycleStartAt).sort((a, b) => {
|
|
8906
8992
|
const verifiedAtA = verById.get(a.id)?.verifiedAt ?? 0;
|
|
8907
8993
|
const verifiedAtB = verById.get(b.id)?.verifiedAt ?? 0;
|
|
8908
8994
|
return verifiedAtA - verifiedAtB || a.id - b.id;
|
|
@@ -8913,7 +8999,10 @@ async function partitionVerifyScope(args) {
|
|
|
8913
8999
|
mode: "broad",
|
|
8914
9000
|
inScope: broadCandidates.map(toPrompt),
|
|
8915
9001
|
inScopeIds: broadCandidates.map((m) => m.id),
|
|
8916
|
-
skippedIds:
|
|
9002
|
+
skippedIds: [
|
|
9003
|
+
...unchangedSkippedIds,
|
|
9004
|
+
...candidates.filter((m) => !broadIds.has(m.id)).map((m) => m.id)
|
|
9005
|
+
],
|
|
8917
9006
|
broadCycleStartAt,
|
|
8918
9007
|
reason: `broad cycle (${broadCandidates.length} remain; started ${broadCycleStartAt})`
|
|
8919
9008
|
};
|
|
@@ -8924,7 +9013,7 @@ async function partitionVerifyScope(args) {
|
|
|
8924
9013
|
mode: "incremental",
|
|
8925
9014
|
inScope: [],
|
|
8926
9015
|
inScopeIds: [],
|
|
8927
|
-
skippedIds:
|
|
9016
|
+
skippedIds: unchangedSkippedIds,
|
|
8928
9017
|
reason: "no file-mapped memories in scope"
|
|
8929
9018
|
};
|
|
8930
9019
|
}
|
|
@@ -8933,11 +9022,11 @@ async function partitionVerifyScope(args) {
|
|
|
8933
9022
|
mode,
|
|
8934
9023
|
inScope: candidates.map(toPrompt),
|
|
8935
9024
|
inScopeIds: candidates.map((m) => m.id),
|
|
8936
|
-
skippedIds:
|
|
9025
|
+
skippedIds: unchangedSkippedIds,
|
|
8937
9026
|
reason
|
|
8938
9027
|
});
|
|
8939
9028
|
const resolvedGitRoot = await resolveGitTopLevel(args.projectDirectory);
|
|
8940
|
-
const gitRoot = resolvedGitRoot ??
|
|
9029
|
+
const gitRoot = resolvedGitRoot ?? path5.resolve(args.projectDirectory);
|
|
8941
9030
|
const verifiedTimes = candidates.map((m) => verById.get(m.id)?.verifiedAt ?? 0).filter((t) => t > 0);
|
|
8942
9031
|
const sinceMs = verifiedTimes.length > 0 ? minOf(verifiedTimes) : runStartedAt;
|
|
8943
9032
|
const changeTimes = await readGitFileChangeTimesSince(args.projectDirectory, sinceMs, resolvedGitRoot ?? undefined);
|
|
@@ -8947,11 +9036,11 @@ async function partitionVerifyScope(args) {
|
|
|
8947
9036
|
const head = await readGitHead(args.projectDirectory);
|
|
8948
9037
|
const uncommitted = head ? await readGitChangedFilesSince(args.projectDirectory, head, resolvedGitRoot ?? undefined) ?? new Set : new Set;
|
|
8949
9038
|
const inScope = [];
|
|
8950
|
-
const skippedIds = [];
|
|
9039
|
+
const skippedIds = [...unchangedSkippedIds];
|
|
8951
9040
|
for (const m of candidates) {
|
|
8952
9041
|
const v = verById.get(m.id);
|
|
8953
9042
|
const verifiedAt = v?.verifiedAt ?? 0;
|
|
8954
|
-
if (verifiedAt === 0) {
|
|
9043
|
+
if (verifiedAt === 0 || changedSkippedIds.has(m.id)) {
|
|
8955
9044
|
inScope.push(toPrompt(m));
|
|
8956
9045
|
continue;
|
|
8957
9046
|
}
|
|
@@ -9321,6 +9410,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
9321
9410
|
let budgetFinalized = false;
|
|
9322
9411
|
let failedCompletion;
|
|
9323
9412
|
let headAtPrompt = null;
|
|
9413
|
+
const skipSnapshots = new Map;
|
|
9324
9414
|
const onBudgetUpdate = (state) => {
|
|
9325
9415
|
budgetFinalized ||= state.finalizeFired;
|
|
9326
9416
|
args.onBudgetUpdate?.({
|
|
@@ -9337,6 +9427,11 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
9337
9427
|
});
|
|
9338
9428
|
};
|
|
9339
9429
|
try {
|
|
9430
|
+
if (!args.moduleRoute) {
|
|
9431
|
+
for (const memory of batch) {
|
|
9432
|
+
skipSnapshots.set(memory.id, await raceWithSignal(verificationFilesFingerprint(args.sessionDirectory, memory.mappedFiles), batchSignal));
|
|
9433
|
+
}
|
|
9434
|
+
}
|
|
9340
9435
|
headAtPrompt = await raceWithSignal(readGitHead(args.sessionDirectory), batchSignal);
|
|
9341
9436
|
const evidence = !args.forceBroad && batch.every((m) => m.verifiedAt) ? await raceWithSignal(buildVerifyDiffEvidence(args.sessionDirectory, batch), batchSignal) : null;
|
|
9342
9437
|
const prompt = buildVerifyPrompt(args.projectIdentity, await raceWithSignal(seedVerifyCandidates(batch, args.sessionDirectory), batchSignal), evidence);
|
|
@@ -9378,7 +9473,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
9378
9473
|
tokens: run.completion.usage
|
|
9379
9474
|
});
|
|
9380
9475
|
reportUsage(run.completion.messages ?? [], run.childSessionId, run.completion.usage.input + (run.completion.usage.cacheRead ?? 0) + (run.completion.usage.cacheWrite ?? 0));
|
|
9381
|
-
return await applyParsedVerifyManifest(args, batch, run.validated, evidence?.head ?? headAtPrompt, budgetFinalized);
|
|
9476
|
+
return await applyParsedVerifyManifest(args, batch, run.validated, evidence?.head ?? headAtPrompt, budgetFinalized, skipSnapshots);
|
|
9382
9477
|
}
|
|
9383
9478
|
const client = args.client;
|
|
9384
9479
|
if (!client)
|
|
@@ -9438,7 +9533,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
9438
9533
|
promptSettled = true;
|
|
9439
9534
|
recordInvocation4(args, startedAt, { status: "completed", messages: run.output });
|
|
9440
9535
|
reportUsage(run.output, agentSessionId);
|
|
9441
|
-
return await applyParsedVerifyManifest(args, batch, run.validated, evidence?.head ?? headAtPrompt, budgetFinalized);
|
|
9536
|
+
return await applyParsedVerifyManifest(args, batch, run.validated, evidence?.head ?? headAtPrompt, budgetFinalized, skipSnapshots);
|
|
9442
9537
|
} catch (error) {
|
|
9443
9538
|
const desc = describeError(error);
|
|
9444
9539
|
const providerFailure = error instanceof DreamerProviderOutputFailureError ? error : undefined;
|
|
@@ -9458,7 +9553,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
9458
9553
|
if (interrupted) {
|
|
9459
9554
|
const text = verifyAssistantText(messages) ?? failedCompletion?.text ?? "";
|
|
9460
9555
|
const recovered = parsePartialVerifyManifest(text, new Set(batch.map((m) => m.id)));
|
|
9461
|
-
const counts = await applyParsedVerifyManifest(args, batch, recovered, headAtPrompt, true);
|
|
9556
|
+
const counts = await applyParsedVerifyManifest(args, batch, recovered, headAtPrompt, true, skipSnapshots);
|
|
9462
9557
|
return {
|
|
9463
9558
|
...counts,
|
|
9464
9559
|
timedOut: !(error instanceof DreamTokenBudgetExceeded),
|
|
@@ -9490,7 +9585,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
9490
9585
|
signal.removeEventListener("abort", abort);
|
|
9491
9586
|
}
|
|
9492
9587
|
}
|
|
9493
|
-
async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budgetFinalized = false) {
|
|
9588
|
+
async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budgetFinalized = false, skipSnapshots) {
|
|
9494
9589
|
const batchIds = new Set(batch.map((m) => m.id));
|
|
9495
9590
|
const batchById = new Map(batch.map((memory) => [memory.id, memory]));
|
|
9496
9591
|
const valid = {
|
|
@@ -9569,6 +9664,15 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
9569
9664
|
}
|
|
9570
9665
|
writes.push({ kind: "archive", id: a.id, reason: a.reason });
|
|
9571
9666
|
}
|
|
9667
|
+
if (!args.moduleRoute) {
|
|
9668
|
+
for (const entry of valid.skipped) {
|
|
9669
|
+
const original = batchById.get(entry.id);
|
|
9670
|
+
if (!original)
|
|
9671
|
+
continue;
|
|
9672
|
+
const fingerprint = skipSnapshots ? skipSnapshots.get(entry.id) ?? null : await verificationFilesFingerprint(args.sessionDirectory, original.mappedFiles);
|
|
9673
|
+
writes.push({ kind: "skip", id: entry.id, fingerprint });
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9572
9676
|
let verified = 0;
|
|
9573
9677
|
let updated = 0;
|
|
9574
9678
|
let archived = 0;
|
|
@@ -9598,7 +9702,7 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
9598
9702
|
name: "memory.set_verification",
|
|
9599
9703
|
arguments: {
|
|
9600
9704
|
memory_project: args.projectIdentity,
|
|
9601
|
-
command_id: `${args.moduleRoute.moduleCommandId}:${
|
|
9705
|
+
command_id: `${args.moduleRoute.moduleCommandId}:${createHash7("sha256").update(rows.map((row) => row.memory_id).join(",")).digest("hex").slice(0, 16)}`,
|
|
9602
9706
|
rows
|
|
9603
9707
|
}
|
|
9604
9708
|
}
|
|
@@ -9630,9 +9734,17 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
9630
9734
|
continue;
|
|
9631
9735
|
if (w.kind === "verify") {
|
|
9632
9736
|
recordMemoryVerifications(args.db, w.id, w.files, now);
|
|
9633
|
-
|
|
9634
|
-
|
|
9737
|
+
updateMemoryVerification2(args.db, w.id, "verified");
|
|
9738
|
+
recordVerificationVerdict(args.db, memory, "verified", now);
|
|
9739
|
+
const verifiedMemory = getMemoryById2(args.db, w.id);
|
|
9740
|
+
if (verifiedHead && verifiedMemory)
|
|
9741
|
+
recordVerifiedCommit(args.db, verifiedMemory, now, verifiedHead);
|
|
9635
9742
|
verified += 1;
|
|
9743
|
+
} else if (w.kind === "skip") {
|
|
9744
|
+
if (memory.content !== batchById.get(w.id)?.content)
|
|
9745
|
+
continue;
|
|
9746
|
+
updateMemoryVerification2(args.db, w.id, "unverified");
|
|
9747
|
+
recordVerificationVerdict(args.db, memory, "skip", now, w.fingerprint);
|
|
9636
9748
|
} else if (w.kind === "update") {
|
|
9637
9749
|
const duplicate = getMemoryByHash2(args.db, memory.projectPath, memory.category, w.hash);
|
|
9638
9750
|
if (duplicate && duplicate.id !== memory.id) {
|
|
@@ -9641,6 +9753,8 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
9641
9753
|
continue;
|
|
9642
9754
|
}
|
|
9643
9755
|
rewriteMemoryContent(args.db, memory, w.content, w.hash);
|
|
9756
|
+
updateMemoryVerification2(args.db, w.id, "unverified");
|
|
9757
|
+
recordVerificationVerdict(args.db, memory, "update", now);
|
|
9644
9758
|
queueMemoryMutation(args.db, {
|
|
9645
9759
|
projectPath: args.projectIdentity,
|
|
9646
9760
|
mutationType: "update",
|
|
@@ -9651,6 +9765,8 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
9651
9765
|
updated += 1;
|
|
9652
9766
|
} else {
|
|
9653
9767
|
archiveMemory2(args.db, w.id, w.reason);
|
|
9768
|
+
updateMemoryVerification2(args.db, w.id, "stale");
|
|
9769
|
+
recordVerificationVerdict(args.db, memory, "archive", now);
|
|
9654
9770
|
queueMemoryMutation(args.db, {
|
|
9655
9771
|
projectPath: args.projectIdentity,
|
|
9656
9772
|
mutationType: "archive",
|
|
@@ -10444,7 +10560,7 @@ function parseFrictionGateVerdict(verdict) {
|
|
|
10444
10560
|
}
|
|
10445
10561
|
function computeRetrospectiveWindowKey(flagged) {
|
|
10446
10562
|
const anchors = flagged.map((message) => `${message.sessionId}:${message.ts}`).sort().join("|");
|
|
10447
|
-
return
|
|
10563
|
+
return createHash8("sha256").update(anchors).digest("hex").slice(0, 32);
|
|
10448
10564
|
}
|
|
10449
10565
|
function renderFrictionWindow(messages, flaggedOrdinals, radius = 2) {
|
|
10450
10566
|
const flagged = new Set(flaggedOrdinals);
|
|
@@ -12042,7 +12158,7 @@ function createDreamTimerModuleClient(moduleClient) {
|
|
|
12042
12158
|
import { readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
|
|
12043
12159
|
|
|
12044
12160
|
// src/plugin/embedding-bootstrap-helpers.ts
|
|
12045
|
-
import { createHash as
|
|
12161
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
12046
12162
|
var EMBEDDING_AFFECTING_KEYS = new Set([
|
|
12047
12163
|
"embedding.api_key",
|
|
12048
12164
|
"embedding.endpoint",
|
|
@@ -12090,7 +12206,7 @@ var EMBEDDING_WARNING_TERMS = [
|
|
|
12090
12206
|
];
|
|
12091
12207
|
var loggedFailureSignatures = new Map;
|
|
12092
12208
|
function sha256Prefix(value, length = 16) {
|
|
12093
|
-
return
|
|
12209
|
+
return createHash9("sha256").update(value).digest("hex").slice(0, length);
|
|
12094
12210
|
}
|
|
12095
12211
|
function warningLooksEmbeddingRelated(message) {
|
|
12096
12212
|
const lower = message.toLowerCase();
|
|
@@ -13018,6 +13134,78 @@ function computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry, gen
|
|
|
13018
13134
|
return { carry, metrics: metricsFromCarry(view) };
|
|
13019
13135
|
}
|
|
13020
13136
|
|
|
13137
|
+
// src/features/magic-context/work-metrics-carry-storage.ts
|
|
13138
|
+
var STATE_KEY = "magicContextWorkMetrics";
|
|
13139
|
+
var storedCarry = object({
|
|
13140
|
+
version: literal(1),
|
|
13141
|
+
source: string(),
|
|
13142
|
+
newWorkSum: number(),
|
|
13143
|
+
lastTimeCreated: number(),
|
|
13144
|
+
lastId: string(),
|
|
13145
|
+
perAgent: array(tuple([
|
|
13146
|
+
string(),
|
|
13147
|
+
object({
|
|
13148
|
+
prevPrompt: number(),
|
|
13149
|
+
phaseId: number(),
|
|
13150
|
+
phasePeak: number(),
|
|
13151
|
+
phaseHasQualifying: boolean(),
|
|
13152
|
+
closedPhaseSum: number(),
|
|
13153
|
+
lastOutput: number(),
|
|
13154
|
+
seen: boolean()
|
|
13155
|
+
})
|
|
13156
|
+
]))
|
|
13157
|
+
});
|
|
13158
|
+
function readState2(db, sessionId) {
|
|
13159
|
+
const row = db.prepare("SELECT deferred_execute_state, new_work_tokens, total_input_tokens FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
13160
|
+
let root = {};
|
|
13161
|
+
try {
|
|
13162
|
+
const value = JSON.parse(row?.deferred_execute_state ?? "null");
|
|
13163
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value))
|
|
13164
|
+
root = value;
|
|
13165
|
+
} catch {}
|
|
13166
|
+
return { root, newWorkTokens: row?.new_work_tokens, totalInputTokens: row?.total_input_tokens };
|
|
13167
|
+
}
|
|
13168
|
+
function matchesStoredState(state, source, carry, metrics) {
|
|
13169
|
+
const parsed = storedCarry.safeParse(state.root[STATE_KEY]);
|
|
13170
|
+
if (!parsed.success)
|
|
13171
|
+
return false;
|
|
13172
|
+
const previous = parsed.data;
|
|
13173
|
+
if (previous.source !== source || previous.newWorkSum !== carry.newWorkSum || previous.lastTimeCreated !== carry.lastTimeCreated || previous.lastId !== carry.lastId || previous.perAgent.length !== carry.perAgent.size || state.newWorkTokens !== metrics.newWorkTokens || state.totalInputTokens !== metrics.totalInputTokens)
|
|
13174
|
+
return false;
|
|
13175
|
+
return previous.perAgent.every(([key, agent]) => {
|
|
13176
|
+
const current = carry.perAgent.get(key);
|
|
13177
|
+
return current !== undefined && agent.prevPrompt === current.prevPrompt && agent.phaseId === current.phaseId && agent.phasePeak === current.phasePeak && agent.phaseHasQualifying === current.phaseHasQualifying && agent.closedPhaseSum === current.closedPhaseSum && agent.lastOutput === current.lastOutput && agent.seen === current.seen;
|
|
13178
|
+
});
|
|
13179
|
+
}
|
|
13180
|
+
function readSessionWorkMetricsCarry(db, sessionId, source) {
|
|
13181
|
+
const parsed = storedCarry.safeParse(readState2(db, sessionId).root[STATE_KEY]);
|
|
13182
|
+
if (!parsed.success || parsed.data.source !== source)
|
|
13183
|
+
return;
|
|
13184
|
+
return {
|
|
13185
|
+
perAgent: new Map(parsed.data.perAgent),
|
|
13186
|
+
newWorkSum: parsed.data.newWorkSum,
|
|
13187
|
+
lastTimeCreated: parsed.data.lastTimeCreated,
|
|
13188
|
+
lastId: parsed.data.lastId
|
|
13189
|
+
};
|
|
13190
|
+
}
|
|
13191
|
+
function setSessionWorkMetricsCarry(db, sessionId, source, carry, metrics) {
|
|
13192
|
+
const normalized = {
|
|
13193
|
+
newWorkTokens: Math.max(0, Math.floor(metrics.newWorkTokens)),
|
|
13194
|
+
totalInputTokens: Math.max(0, Math.floor(metrics.totalInputTokens))
|
|
13195
|
+
};
|
|
13196
|
+
if (matchesStoredState(readState2(db, sessionId), source, carry, normalized))
|
|
13197
|
+
return;
|
|
13198
|
+
db.transaction(() => {
|
|
13199
|
+
const state = readState2(db, sessionId);
|
|
13200
|
+
if (matchesStoredState(state, source, carry, normalized))
|
|
13201
|
+
return;
|
|
13202
|
+
ensureSessionMetaRow(db, sessionId);
|
|
13203
|
+
const { root } = state;
|
|
13204
|
+
root[STATE_KEY] = { ...carry, version: 1, source, perAgent: [...carry.perAgent] };
|
|
13205
|
+
db.prepare("UPDATE session_meta SET deferred_execute_state = ?, new_work_tokens = ?, total_input_tokens = ? WHERE session_id = ?").run(JSON.stringify(root), normalized.newWorkTokens, normalized.totalInputTokens, sessionId);
|
|
13206
|
+
}).immediate();
|
|
13207
|
+
}
|
|
13208
|
+
|
|
13021
13209
|
// src/hooks/magic-context/format-embed-failure.ts
|
|
13022
13210
|
function formatEmbedFailureSummary(embedded, remaining, failure, style = "markdown") {
|
|
13023
13211
|
const historyBlocks = `history block${embedded === 1 ? "" : "s"}`;
|
|
@@ -15288,7 +15476,6 @@ function pluginPackageVersion(moduleUrl = import.meta.url) {
|
|
|
15288
15476
|
}
|
|
15289
15477
|
|
|
15290
15478
|
// src/plugin/rpc-handlers.ts
|
|
15291
|
-
var workMetricsCarryBySession = new Map;
|
|
15292
15479
|
async function executeRustRecompRpc(moduleClient, sessionId, projectRoot) {
|
|
15293
15480
|
if (!moduleClient)
|
|
15294
15481
|
return { ok: false, error: "Rust module client is unavailable" };
|
|
@@ -15328,12 +15515,11 @@ function resolveSidebarWorkMetrics(db, sessionId, persistedNewWork, persistedTot
|
|
|
15328
15515
|
return { newWorkTokens: persistedNewWork, totalInputTokens: persistedTotalInput };
|
|
15329
15516
|
}
|
|
15330
15517
|
try {
|
|
15331
|
-
const
|
|
15332
|
-
const carry =
|
|
15518
|
+
const source = `${generation}:${resolveOpenCodeDbPath(generation).path}`;
|
|
15519
|
+
const carry = readSessionWorkMetricsCarry(db, sessionId, source) ?? emptyWorkMetricsCarry();
|
|
15333
15520
|
const { carry: nextCarry, metrics } = withReadOnlySessionDb((openCodeDb) => computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry, generation), generation);
|
|
15334
|
-
workMetricsCarryBySession.set(carryKey, nextCarry);
|
|
15335
15521
|
try {
|
|
15336
|
-
|
|
15522
|
+
setSessionWorkMetricsCarry(db, sessionId, source, nextCarry, metrics);
|
|
15337
15523
|
} catch {}
|
|
15338
15524
|
return metrics;
|
|
15339
15525
|
} catch {
|
|
@@ -16232,8 +16418,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16232
16418
|
const db = readDatabase();
|
|
16233
16419
|
if (!db)
|
|
16234
16420
|
return { ok: false, error: "db unavailable" };
|
|
16235
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16236
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
16421
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-wk509qkp.js"));
|
|
16422
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-14p3yje4.js"));
|
|
16237
16423
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16238
16424
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
16239
16425
|
return {
|
|
@@ -16317,7 +16503,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16317
16503
|
const db = readDatabase();
|
|
16318
16504
|
if (!db)
|
|
16319
16505
|
return { ok: false, error: "db unavailable" };
|
|
16320
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16506
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-xg9avt2p.js"));
|
|
16321
16507
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16322
16508
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16323
16509
|
const ctx = {
|
|
@@ -17288,6 +17474,44 @@ function createPassOutcome() {
|
|
|
17288
17474
|
};
|
|
17289
17475
|
}
|
|
17290
17476
|
|
|
17477
|
+
// src/hooks/magic-context/release-recovery-prefix.ts
|
|
17478
|
+
function groups(messages) {
|
|
17479
|
+
const result = new Map;
|
|
17480
|
+
for (const message of messages) {
|
|
17481
|
+
if (!message.info.id)
|
|
17482
|
+
continue;
|
|
17483
|
+
const group = result.get(message.info.id) ?? [];
|
|
17484
|
+
group.push(message);
|
|
17485
|
+
result.set(message.info.id, group);
|
|
17486
|
+
}
|
|
17487
|
+
return result;
|
|
17488
|
+
}
|
|
17489
|
+
function visibleGroup(group) {
|
|
17490
|
+
return JSON.stringify(group.map((message) => ({
|
|
17491
|
+
role: message.info.role,
|
|
17492
|
+
parts: message.parts.filter((part) => !isStructuralNoiseSentinel(part) && !(isRecord(part) && (part.type === "step-start" || part.type === "step-finish" || part.type === "meta"))).map(providerVisiblePart)
|
|
17493
|
+
})));
|
|
17494
|
+
}
|
|
17495
|
+
function snapshotRecoveryMessages(messages) {
|
|
17496
|
+
return new Map([...groups(messages)].map(([id, group]) => [id, visibleGroup(group)]));
|
|
17497
|
+
}
|
|
17498
|
+
function releaseRecoveryPrefix(args) {
|
|
17499
|
+
const frozen = groups(args.frozen);
|
|
17500
|
+
const rendered = groups(args.after);
|
|
17501
|
+
const emitted = new Set;
|
|
17502
|
+
return args.after.flatMap((message) => {
|
|
17503
|
+
const id = message.info.id;
|
|
17504
|
+
if (!id)
|
|
17505
|
+
return [message];
|
|
17506
|
+
if (emitted.has(id))
|
|
17507
|
+
return [];
|
|
17508
|
+
emitted.add(id);
|
|
17509
|
+
const group = rendered.get(id) ?? [message];
|
|
17510
|
+
const previous = frozen.get(id);
|
|
17511
|
+
return previous && args.before.get(id) === visibleGroup(group) ? previous : group;
|
|
17512
|
+
});
|
|
17513
|
+
}
|
|
17514
|
+
|
|
17291
17515
|
// src/hooks/magic-context/render-options.ts
|
|
17292
17516
|
function createM0RenderOptions(controls, contextUsage, modelKey, resolvedContextLimit, projectPath) {
|
|
17293
17517
|
return {
|
|
@@ -17319,7 +17543,7 @@ function resolveHistoryBudgetTokens(historyBudgetPercentage, contextUsage, execu
|
|
|
17319
17543
|
}
|
|
17320
17544
|
|
|
17321
17545
|
// src/hooks/magic-context/rust-mode-transform.ts
|
|
17322
|
-
import { createHash as
|
|
17546
|
+
import { createHash as createHash13, randomUUID as randomUUID6 } from "node:crypto";
|
|
17323
17547
|
|
|
17324
17548
|
// src/features/magic-context/memory/single-store-embedding-drain.ts
|
|
17325
17549
|
function isWatermarkRow(row) {
|
|
@@ -17383,7 +17607,7 @@ function advanceEmbeddedWatermark(db, projectPath, upTo) {
|
|
|
17383
17607
|
}
|
|
17384
17608
|
|
|
17385
17609
|
// src/features/magic-context/mural/source-revision.ts
|
|
17386
|
-
import { createHash as
|
|
17610
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
17387
17611
|
var statements = new WeakMap;
|
|
17388
17612
|
function muralSourceRevision(db, projectPath) {
|
|
17389
17613
|
let statement = statements.get(db);
|
|
@@ -17400,7 +17624,7 @@ function muralSourceRevision(db, projectPath) {
|
|
|
17400
17624
|
statements.set(db, statement);
|
|
17401
17625
|
}
|
|
17402
17626
|
const row = statement.get(projectPath, Date.now());
|
|
17403
|
-
return
|
|
17627
|
+
return createHash10("sha256").update(row.revision).digest("hex");
|
|
17404
17628
|
}
|
|
17405
17629
|
|
|
17406
17630
|
// src/features/magic-context/install-instance-id.ts
|
|
@@ -19861,7 +20085,7 @@ function noteExternalLkgReplay(participant, sessionId, inputMessages, servedMess
|
|
|
19861
20085
|
}
|
|
19862
20086
|
|
|
19863
20087
|
// src/hooks/magic-context/rust-served-raw.ts
|
|
19864
|
-
import { createHash as
|
|
20088
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
19865
20089
|
class RustServedRawConflict extends EmergencyFailClosedError {
|
|
19866
20090
|
reason;
|
|
19867
20091
|
messageIds;
|
|
@@ -19875,7 +20099,7 @@ class RustServedRawConflict extends EmergencyFailClosedError {
|
|
|
19875
20099
|
}
|
|
19876
20100
|
function partDigest(part) {
|
|
19877
20101
|
const serialized = JSON.stringify(part);
|
|
19878
|
-
return
|
|
20102
|
+
return createHash12("sha256").update(stableStringify(serialized === undefined ? undefined : JSON.parse(serialized))).digest("hex");
|
|
19879
20103
|
}
|
|
19880
20104
|
function records(doc) {
|
|
19881
20105
|
if (doc.rustServedRaw === undefined)
|
|
@@ -20109,6 +20333,32 @@ class StorageBusyRefusalError extends Error {
|
|
|
20109
20333
|
}
|
|
20110
20334
|
|
|
20111
20335
|
// src/hooks/magic-context/transform-context-state.ts
|
|
20336
|
+
var usageRefusals = new WeakMap;
|
|
20337
|
+
function recordUsageRefusal(db, sessionId, refusedAt = Date.now()) {
|
|
20338
|
+
let sessions = usageRefusals.get(db);
|
|
20339
|
+
if (!sessions) {
|
|
20340
|
+
sessions = new Map;
|
|
20341
|
+
usageRefusals.set(db, sessions);
|
|
20342
|
+
}
|
|
20343
|
+
if (!sessions.has(sessionId))
|
|
20344
|
+
sessions.set(sessionId, refusedAt);
|
|
20345
|
+
}
|
|
20346
|
+
function shouldResetRefusedUsage(db, sessionId, meta, liveReading) {
|
|
20347
|
+
const refusals = usageRefusals.get(db);
|
|
20348
|
+
const refusedAt = refusals?.get(sessionId);
|
|
20349
|
+
if (refusedAt === undefined)
|
|
20350
|
+
return false;
|
|
20351
|
+
const readingAt = liveReading?.hasUsageTokens ? liveReading.updatedAt : meta.lastResponseTime;
|
|
20352
|
+
if (readingAt > refusedAt) {
|
|
20353
|
+
refusals?.delete(sessionId);
|
|
20354
|
+
return false;
|
|
20355
|
+
}
|
|
20356
|
+
const now = Date.now();
|
|
20357
|
+
const foldedAt = meta.cachedM0MaterializedAt ?? 0;
|
|
20358
|
+
if (foldedAt > refusedAt && foldedAt <= now)
|
|
20359
|
+
return true;
|
|
20360
|
+
return !!db.prepare("SELECT 1 FROM compartments WHERE session_id = ? AND harness = ? AND created_at > ? AND created_at <= ? LIMIT 1").get(sessionId, getHarness2(), refusedAt, now);
|
|
20361
|
+
}
|
|
20112
20362
|
function loadPersistedUsageWatermark(db, sessionId) {
|
|
20113
20363
|
const result = db.prepare("SELECT last_response_time FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
20114
20364
|
if (result === null || typeof result !== "object")
|
|
@@ -20548,10 +20798,10 @@ function messageCacheSignature(message) {
|
|
|
20548
20798
|
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
20549
20799
|
const serializedParts = JSON.stringify(parts) ?? "null";
|
|
20550
20800
|
const serializedMessage = JSON.stringify(message) ?? "null";
|
|
20551
|
-
return `${messageIdOf(message) ?? ""}:${parts.length}:${Buffer.byteLength(serializedParts)}:${
|
|
20801
|
+
return `${messageIdOf(message) ?? ""}:${parts.length}:${Buffer.byteLength(serializedParts)}:${createHash13("sha256").update(serializedMessage).digest("hex")}`;
|
|
20552
20802
|
}
|
|
20553
20803
|
function advanceWireFingerprint(previous, encoded) {
|
|
20554
|
-
return
|
|
20804
|
+
return createHash13("sha256").update(previous).update("\\0").update(JSON.stringify(encoded) ?? "null").digest("hex");
|
|
20555
20805
|
}
|
|
20556
20806
|
function buildWireFingerprint(encoded) {
|
|
20557
20807
|
let fingerprint = "rust-wire-v1";
|
|
@@ -22343,7 +22593,7 @@ function createRustModeTransform(deps, options) {
|
|
|
22343
22593
|
const id = messageIdOf(message) ?? `index:${todoStart + offset}`;
|
|
22344
22594
|
const parts = message.parts?.filter((part) => isRecord3(part) && part.type === "tool" && part.tool === "todowrite");
|
|
22345
22595
|
if (parts?.length) {
|
|
22346
|
-
todoCalls.set(id,
|
|
22596
|
+
todoCalls.set(id, createHash13("sha256").update(JSON.stringify(parts)).digest("hex"));
|
|
22347
22597
|
} else {
|
|
22348
22598
|
todoCalls.delete(id);
|
|
22349
22599
|
}
|
|
@@ -24210,6 +24460,7 @@ function createTransform(deps) {
|
|
|
24210
24460
|
return;
|
|
24211
24461
|
throw degradedPassError(site, error);
|
|
24212
24462
|
};
|
|
24463
|
+
const structuralSentinelUpgradeFailed = deps.storeGeneration === "v1" && !deps.compactionOff && deps.transformMode !== "rust" && prepareStructuralSentinelChoices({ db, sessionId, messages }).structuralSentinelUpgrade === undefined;
|
|
24213
24464
|
if (deps.storeGeneration !== undefined) {
|
|
24214
24465
|
try {
|
|
24215
24466
|
if (rustModeTransform && readCoordinateGeneration(db, sessionId) !== deps.storeGeneration) {
|
|
@@ -24431,10 +24682,13 @@ function createTransform(deps) {
|
|
|
24431
24682
|
loadedSessions.add(sessionId);
|
|
24432
24683
|
const earlyStateSnapshot = loadTransformPassStateSnapshot(db, sessionId);
|
|
24433
24684
|
const historianFailureState = earlyStateSnapshot.historianFailure;
|
|
24434
|
-
|
|
24685
|
+
const liveUsageBeforeReset = deps.contextUsageMap.get(sessionId);
|
|
24686
|
+
const usageResetAfterRefusal = shouldResetRefusedUsage(db, sessionId, sessionMeta, liveUsageBeforeReset);
|
|
24687
|
+
if ((isFirstTransformPassForSession || usageResetAfterRefusal) && sessionMeta) {
|
|
24435
24688
|
const persistedPct = sessionMeta.lastContextPercentage ?? 0;
|
|
24436
|
-
if (persistedPct > 0) {
|
|
24437
|
-
|
|
24689
|
+
if (persistedPct > 0 || usageResetAfterRefusal && (sessionMeta.lastInputTokens > 0 || deps.contextUsageMap.has(sessionId))) {
|
|
24690
|
+
const resetPct = persistedPct || liveUsageBeforeReset?.usage.percentage || 0;
|
|
24691
|
+
sessionLog2(sessionId, `transform: ${isFirstTransformPassForSession ? "first pass" : "refused turn recovery"} reset — percentage=${resetPct.toFixed(1)}% — clearing stale usage state`);
|
|
24438
24692
|
updateSessionMeta(db, sessionId, {
|
|
24439
24693
|
lastContextPercentage: 0,
|
|
24440
24694
|
lastInputTokens: 0
|
|
@@ -24843,10 +25097,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24843
25097
|
let taggingSucceeded = false;
|
|
24844
25098
|
let recoveryBatch = null;
|
|
24845
25099
|
let recoveryNormalized = false;
|
|
25100
|
+
let recoveryReleased = false;
|
|
24846
25101
|
const untaggedReplayTailServed = !!recovery.prefix || untaggedReplayIds.size > 0 && messages.some((message) => untaggedReplayIds.has(message.info.id ?? ""));
|
|
25102
|
+
const releaseRecoveryReplay = untaggedReplayTailServed ? () => {
|
|
25103
|
+
recoveryReleased = true;
|
|
25104
|
+
} : undefined;
|
|
24847
25105
|
const normalizeRecoveryTail = untaggedReplayTailServed ? () => {
|
|
24848
25106
|
if (recoveryNormalized)
|
|
24849
25107
|
return;
|
|
25108
|
+
recoveryReleased = true;
|
|
24850
25109
|
const tail = messages.filter((message) => untaggedReplayIds.has(message.info.id ?? ""));
|
|
24851
25110
|
const tagged = tagMessages(sessionId, tail, deps.tagger, db, {
|
|
24852
25111
|
skipPrefixInjection: !ctxReduceCallable,
|
|
@@ -24922,6 +25181,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24922
25181
|
const targetTagNumbers = [...targets.keys()];
|
|
24923
25182
|
const targetsSliceTags = compactionOff ? [] : getDroppedTagsByNumbers2(db, sessionId, targetTagNumbers);
|
|
24924
25183
|
logTransformTiming(sessionId, "getDroppedTagsByNumbers", t1b, `targets=${targetTagNumbers.length} fetched=${targetsSliceTags.length}`);
|
|
25184
|
+
const recoveryBeforePostprocess = recovery.prefix ? snapshotRecoveryMessages(messages) : undefined;
|
|
24925
25185
|
let didMutateFromFlushedStatuses = false;
|
|
24926
25186
|
if (taggingSucceeded) {
|
|
24927
25187
|
try {
|
|
@@ -25066,7 +25326,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25066
25326
|
let contextUsageFromEstimate = hostOverWindow;
|
|
25067
25327
|
if (contextUsage.inputTokens <= 0 && protectionCacheBustingPass) {
|
|
25068
25328
|
const overflowRecoveryPass = usagePercentageSynthetic || emergencyRecoveryArmed;
|
|
25069
|
-
const savedProviderReading = overflowRecoveryPass ? null : savedProviderReadingForPass({
|
|
25329
|
+
const savedProviderReading = overflowRecoveryPass || usageResetAfterRefusal ? null : savedProviderReadingForPass({
|
|
25070
25330
|
persisted: persistedUsageBeforeResets,
|
|
25071
25331
|
currentModelKey: currentModelKeyForBoundary ?? (hardModelKey || undefined),
|
|
25072
25332
|
contextLimit: resolvedContextLimit,
|
|
@@ -25133,7 +25393,10 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25133
25393
|
const tPostProcess = performance.now();
|
|
25134
25394
|
dropProjectionEmergency = contextUsage.percentage >= 95;
|
|
25135
25395
|
const postTransformResult = await runPostTransformPhase2({
|
|
25396
|
+
opencode1: deps.storeGeneration === "v1",
|
|
25136
25397
|
opencode2: deps.storeGeneration === "v2",
|
|
25398
|
+
structuralSentinelUpgradeFailed,
|
|
25399
|
+
releaseRecoveryPrefix: releaseRecoveryReplay,
|
|
25137
25400
|
normalizeRecoveryTail,
|
|
25138
25401
|
compactionMarkerStrategy: deps.compactionMarkerStrategy ?? defaultCompactionMarkerStrategy2,
|
|
25139
25402
|
sessionId,
|
|
@@ -25228,7 +25491,17 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25228
25491
|
}
|
|
25229
25492
|
});
|
|
25230
25493
|
compactionModeTransitionPending.delete(sessionId);
|
|
25231
|
-
if (recovery.prefix && !recoveryNormalized) {
|
|
25494
|
+
if (recovery.prefix && recoveryReleased && !recoveryNormalized) {
|
|
25495
|
+
if (!recoveryBeforePostprocess)
|
|
25496
|
+
throw new Error("Cannot release recovery without its pre-edit snapshot");
|
|
25497
|
+
const released = releaseRecoveryPrefix({
|
|
25498
|
+
frozen: JSON.parse(recovery.prefix.json),
|
|
25499
|
+
before: recoveryBeforePostprocess,
|
|
25500
|
+
after: messages
|
|
25501
|
+
});
|
|
25502
|
+
messages.splice(0, messages.length, ...released);
|
|
25503
|
+
}
|
|
25504
|
+
if (recovery.prefix && !recoveryReleased) {
|
|
25232
25505
|
const renderedById = new Map;
|
|
25233
25506
|
for (const message of messages) {
|
|
25234
25507
|
if (!message.info.id)
|
|
@@ -25240,7 +25513,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25240
25513
|
const suffix = recoveryTailSources.flatMap(({ identity, pristineSystem }) => pristineSystem ? [pristineSystem] : renderedById.get(identity) ?? []);
|
|
25241
25514
|
messages.splice(0, messages.length, ...JSON.parse(recovery.prefix.json), ...suffix);
|
|
25242
25515
|
}
|
|
25243
|
-
const recoveryReleaseReason = recovery.rebuildReason ?? (recoveryNormalized ? "recovery_tail_normalized" : undefined);
|
|
25516
|
+
const recoveryReleaseReason = recovery.rebuildReason ?? (recoveryNormalized ? "recovery_tail_normalized" : recoveryReleased ? "recovery_prefix_released" : undefined);
|
|
25244
25517
|
if (recoveryReleaseReason)
|
|
25245
25518
|
postTransformResult.bustedThisPass = true;
|
|
25246
25519
|
passOutcome.markFinalized();
|
|
@@ -25375,6 +25648,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25375
25648
|
}
|
|
25376
25649
|
try {
|
|
25377
25650
|
await host.hostRefuse(deps.client, sessionId);
|
|
25651
|
+
recordUsageRefusal(db, sessionId);
|
|
25378
25652
|
} catch (error) {
|
|
25379
25653
|
sessionLog2(sessionId, "transform: emergency fail-closed abort failed; refusing to return a sendable prompt:", getErrorMessage(error));
|
|
25380
25654
|
throw new EmergencyFailClosedError("Emergency recovery abort failed", {
|
|
@@ -25622,7 +25896,16 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25622
25896
|
});
|
|
25623
25897
|
deps.onPassPermission?.(sessionId, postTransformResult.prefixMutationPermitted);
|
|
25624
25898
|
};
|
|
25625
|
-
const timedTransform = (input, output) => withTransformTimingSummary(() =>
|
|
25899
|
+
const timedTransform = (input, output) => withTransformTimingSummary(async () => {
|
|
25900
|
+
const sessionId = findSessionId(output.messages);
|
|
25901
|
+
try {
|
|
25902
|
+
await transform(input, output);
|
|
25903
|
+
} catch (error) {
|
|
25904
|
+
if (sessionId && !deps.compactionOff && error instanceof EmergencyFailClosedError)
|
|
25905
|
+
recordUsageRefusal(deps.db, sessionId);
|
|
25906
|
+
throw error;
|
|
25907
|
+
}
|
|
25908
|
+
});
|
|
25626
25909
|
return Object.assign(timedTransform, {
|
|
25627
25910
|
clearSessionLogState,
|
|
25628
25911
|
invalidateRustWireState(sessionId) {
|
|
@@ -25845,12 +26128,12 @@ function systemPromptDates(prompt, sticky) {
|
|
|
25845
26128
|
}
|
|
25846
26129
|
|
|
25847
26130
|
// src/hooks/magic-context/system-prompt-diagnostics.ts
|
|
25848
|
-
import { createHash as
|
|
26131
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
25849
26132
|
function snapshotSystemPrompt(system, preset) {
|
|
25850
26133
|
return { elements: system.map((element) => Buffer.from(element)), preset };
|
|
25851
26134
|
}
|
|
25852
26135
|
function describeSystemPromptChange(previous, current) {
|
|
25853
|
-
const metadata = (element) => element === undefined ? "absent" : `bytes=${element.length},md5=${
|
|
26136
|
+
const metadata = (element) => element === undefined ? "absent" : `bytes=${element.length},md5=${createHash14("md5").update(element).digest("hex")}`;
|
|
25854
26137
|
const elements = [];
|
|
25855
26138
|
for (let index = 0;index < Math.max(previous?.elements.length ?? 0, current.elements.length); index++) {
|
|
25856
26139
|
const before = previous?.elements[index];
|
|
@@ -27681,7 +27964,7 @@ import { existsSync as existsSync8 } from "node:fs";
|
|
|
27681
27964
|
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
27682
27965
|
|
|
27683
27966
|
// ../retina-local-fs/src/path-fence.ts
|
|
27684
|
-
import { lstat as lstat2, realpath as
|
|
27967
|
+
import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
|
|
27685
27968
|
import { homedir } from "node:os";
|
|
27686
27969
|
import { basename, dirname as dirname2, isAbsolute, join as join6, relative, resolve, sep } from "node:path";
|
|
27687
27970
|
|
|
@@ -27711,7 +27994,7 @@ async function resolveFenceRoots(options) {
|
|
|
27711
27994
|
const configuredHomePath = resolve(options.homeDirectory ?? process.env.HOME ?? homedir());
|
|
27712
27995
|
let home;
|
|
27713
27996
|
try {
|
|
27714
|
-
home = await
|
|
27997
|
+
home = await realpath3(configuredHomePath);
|
|
27715
27998
|
} catch (error) {
|
|
27716
27999
|
throw fsError(configuredHomePath, error);
|
|
27717
28000
|
}
|
|
@@ -27741,7 +28024,7 @@ function fenceCandidates(canonical, aliases) {
|
|
|
27741
28024
|
}
|
|
27742
28025
|
async function canonicalPath(path, allowMissing) {
|
|
27743
28026
|
try {
|
|
27744
|
-
return await
|
|
28027
|
+
return await realpath3(path);
|
|
27745
28028
|
} catch (error) {
|
|
27746
28029
|
if (!allowMissing || !isMissingError(error)) {
|
|
27747
28030
|
throw fsError(path, error);
|
|
@@ -27766,7 +28049,7 @@ async function canonicalPath(path, allowMissing) {
|
|
|
27766
28049
|
suffix.unshift(basename(candidate));
|
|
27767
28050
|
candidate = parent;
|
|
27768
28051
|
try {
|
|
27769
|
-
return join6(await
|
|
28052
|
+
return join6(await realpath3(candidate), ...suffix);
|
|
27770
28053
|
} catch (parentError) {
|
|
27771
28054
|
if (!isMissingError(parentError)) {
|
|
27772
28055
|
throw fsError(path, parentError);
|
|
@@ -28456,7 +28739,7 @@ function formatCtxReduceReply(stampedCount, selfStampCount = 0) {
|
|
|
28456
28739
|
return parts.join(" ");
|
|
28457
28740
|
}
|
|
28458
28741
|
// src/tools/ctx-reduce/tools.ts
|
|
28459
|
-
import { createHash as
|
|
28742
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
28460
28743
|
import { tool as tool4 } from "@opencode-ai/plugin";
|
|
28461
28744
|
|
|
28462
28745
|
// src/features/magic-context/range-parser.ts
|
|
@@ -28520,11 +28803,11 @@ function createCtxReduceTool(deps) {
|
|
|
28520
28803
|
const stableId = `oc-${sessionId}-${callId}`;
|
|
28521
28804
|
if (Buffer.byteLength(stableId) <= 128)
|
|
28522
28805
|
return stableId;
|
|
28523
|
-
return `oc-${
|
|
28806
|
+
return `oc-${createHash15("sha256").update(stableId).digest("hex")}`;
|
|
28524
28807
|
}
|
|
28525
28808
|
fallbackCommandSequence += 1;
|
|
28526
28809
|
const monotonicId = `oc-${sessionId}-${fallbackCommandSequence}`;
|
|
28527
|
-
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${
|
|
28810
|
+
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${createHash15("sha256").update(monotonicId).digest("hex")}`;
|
|
28528
28811
|
};
|
|
28529
28812
|
return tool4({
|
|
28530
28813
|
description: CTX_REDUCE_DESCRIPTION,
|