@cortexkit/opencode-magic-context 0.49.97 → 0.49.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{announcement-8nj2jd87.js → announcement-p2xjv6cp.js} +4 -5
- package/dist/auto-search-worker.js +5 -5
- package/dist/chunk-embedding-write-worker.js +15 -16
- package/dist/{compaction-marker-candidates-a4b0anvv.js → compaction-marker-candidates-2apg7ewt.js} +2 -3
- package/dist/compaction-marker-candidates-worker.js +1 -1
- package/dist/{compartment-chunk-embedding-re2cw7y3.js → compartment-chunk-embedding-gnemmf79.js} +7 -8
- package/dist/{conflict-warning-hook-wcq55y61.js → conflict-warning-hook-x1ynwzwz.js} +7 -8
- package/dist/{context-br04s0b6.js → context-z77a2jpx.js} +377 -60
- package/dist/{derive-budgets-g1sy72e8.js → derive-budgets-vbv0fwsd.js} +4 -5
- package/dist/embedding-backfill-79br4kk6.js +28 -0
- package/dist/embedding-worker-process.js +1 -2
- package/dist/embedding-worker.js +6 -7
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-probe.d.ts +10 -9
- package/dist/features/magic-context/memory/embedding-probe.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-response-slots.d.ts +13 -0
- package/dist/features/magic-context/memory/embedding-response-slots.d.ts.map +1 -0
- package/dist/features/magic-context/storage-native-replay.d.ts +2 -0
- package/dist/features/magic-context/storage-native-replay.d.ts.map +1 -1
- package/dist/{history-owner-74826t4n.js → history-owner-8dj31nyf.js} +2 -3
- package/dist/hooks/magic-context/apply-operations.d.ts +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-flush.d.ts +1 -1
- package/dist/hooks/magic-context/execute-flush.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +2 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-tbdy1hk0.js → index-0wj3jr8n.js} +6 -6
- package/dist/{index-j4dcjb8t.js → index-1vv1ka4a.js} +4 -4
- package/dist/{index-zfx7mtqa.js → index-2m3t73wk.js} +1 -1
- package/dist/{index-3fhb0j32.js → index-34xvre52.js} +223 -5
- package/dist/{index-pkxkeezb.js → index-4qc8d9by.js} +17 -17
- package/dist/{index-mmf6e740.js → index-507a56zb.js} +7 -7
- package/dist/{index-qdjxrbnr.js → index-5nf2a14a.js} +52 -45
- package/dist/{index-w9hxgntq.js → index-5xrj3zp4.js} +5 -5
- package/dist/{index-kj4bprep.js → index-61a853ky.js} +4 -4
- package/dist/{index-zmgp0tr6.js → index-74w347am.js} +3 -3
- package/dist/{index-hp46xe93.js → index-8hhmv0ff.js} +6 -6
- package/dist/{index-c205x7xd.js → index-8k9qpyjf.js} +1 -1
- package/dist/{index-tqtpgnhr.js → index-9awtk18w.js} +1 -1
- package/dist/{index-h7kta6cn.js → index-9eqt7755.js} +3 -3
- package/dist/{index-x49x59ar.js → index-9q7wzca8.js} +23 -25
- package/dist/{index-880a24vd.js → index-ab86c21b.js} +1 -1
- package/dist/{index-3n4j5rqc.js → index-abhmtj00.js} +1 -1
- package/dist/{index-tr4ep2ej.js → index-ajmy0v5j.js} +31 -0
- package/dist/{index-dj64gzg5.js → index-cayqdwf9.js} +2 -2
- package/dist/{index-0sqhg9nf.js → index-dnxnj42p.js} +12 -12
- package/dist/{index-0bjj9yf3.js → index-e6s2jpr8.js} +2 -2
- package/dist/{index-8v1brm5n.js → index-em72jhc0.js} +11 -11
- package/dist/{index-910gahfb.js → index-esym6cw4.js} +6 -8
- package/dist/{index-7sdns2ww.js → index-fd3hkyk1.js} +2 -2
- package/dist/{index-fgw241hh.js → index-gcf2x04k.js} +2 -2
- package/dist/{index-89xg64wb.js → index-geph2sa6.js} +2 -2
- package/dist/{index-45qgkg8j.js → index-h1qh9n8b.js} +2 -2
- package/dist/{index-9jvxq5rt.js → index-h1xvt8fw.js} +4 -4
- package/dist/{index-0ve29s6f.js → index-hbqxxb2n.js} +1 -1
- package/dist/{index-dnpcv1rg.js → index-hyvxmz3e.js} +4 -4
- package/dist/{index-hedgz8an.js → index-jsbgw33b.js} +1 -1
- package/dist/{index-mgy7g740.js → index-kjdys7e2.js} +1 -1
- package/dist/{index-e6ay1gez.js → index-mfx7hzyc.js} +2 -2
- package/dist/{index-7m2tnk8q.js → index-mhdavdd4.js} +31 -28
- package/dist/{index-r1d45dsr.js → index-nyjztqyj.js} +3 -3
- package/dist/{index-azkfw78y.js → index-qxzk5s30.js} +1 -1
- package/dist/{index-6mryx739.js → index-t7st85f5.js} +1 -1
- package/dist/{index-89bkkgcn.js → index-tyjx0dwz.js} +4 -4
- package/dist/{index-k34hc455.js → index-vdzd98ry.js} +2 -2
- package/dist/{index-hj78hvhm.js → index-vegw385y.js} +2 -2
- package/dist/{index-w7n7qkpf.js → index-w6kcwhhj.js} +4 -4
- package/dist/{index-xcej5kpt.js → index-xbna9akt.js} +5 -5
- package/dist/{index-cpbr0xvk.js → index-xtv4d4hv.js} +2 -2
- package/dist/{index-zkjx8gq3.js → index-xw608ytx.js} +11 -11
- package/dist/{index-jzrvdqb8.js → index-y5f5yg5a.js} +1 -1
- package/dist/index.js +55 -56
- package/dist/{logger-nmb2508f.js → logger-dgtrf43g.js} +1 -2
- package/dist/{message-fts-rowid-map-vcatdan0.js → message-fts-rowid-map-cfq59g6g.js} +4 -5
- package/dist/{message-index-bounded-abhwe610.js → message-index-bounded-6y7p974x.js} +10 -11
- package/dist/{message-time-backfill-zc5rsvhv.js → message-time-backfill-av870n4c.js} +2 -3
- package/dist/migration-worker.js +12 -13
- package/dist/plugin/rpc-handlers.d.ts +1 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-e566q4bg.js → project-embedding-registry-xy8dcdys.js} +13 -14
- package/dist/raw-ordinal-warmup-worker.js +8 -8
- package/dist/{read-session-chunk-sde0wym3.js → read-session-chunk-9ejnbe07.js} +8 -9
- package/dist/{read-session-raw-trhdgc9z.js → read-session-raw-pgc9gxtn.js} +2 -3
- package/dist/{recomp-orchestrator-dapm3e4v.js → recomp-orchestrator-9k91tkyx.js} +32 -33
- package/dist/render-9712q3gp.js +42 -0
- package/dist/{safe-notification-target-54ns7dv9.js → safe-notification-target-01j8km9e.js} +2 -3
- package/dist/{search-archive-4bbn3ztv.js → search-archive-5jr011gc.js} +11 -12
- package/dist/{search-11aw8wpq.js → search-yhaxy3e6.js} +25 -26
- package/dist/{send-session-notification-gxrj4w1r.js → send-session-notification-tfhs4dbc.js} +5 -6
- package/dist/shared/rpc-types.d.ts +5 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/status-view-check.d.ts.map +1 -1
- package/dist/shared/status-view.d.ts +8 -0
- package/dist/shared/status-view.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +1 -1
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/{storage-tags-jq0c0zsn.js → storage-tags-vd3sgd4s.js} +5 -6
- package/dist/{store-29ksp6vy.js → store-235fjtsn.js} +6 -4
- package/dist/{store-reader-dgh3ssxx.js → store-reader-01e8t5j0.js} +4 -1
- package/dist/{transform-postprocess-phase-1xrjg6be.js → transform-postprocess-phase-mf5js6cs.js} +33 -34
- package/dist/v2/auto-search-worker.js +5 -5
- package/dist/v2/checkpoint-instruction-status.d.ts +13 -0
- package/dist/v2/checkpoint-instruction-status.d.ts.map +1 -0
- package/dist/v2/chunk-embedding-write-worker.js +15 -16
- package/dist/v2/{compaction-marker-candidates-6nypmsr3.js → compaction-marker-candidates-3rxg3f1e.js} +2 -3
- package/dist/v2/compaction-marker-candidates-worker.js +1 -1
- package/dist/v2/{compartment-chunk-embedding-jthtfhcd.js → compartment-chunk-embedding-6v74y2r3.js} +7 -8
- package/dist/v2/{context-43r0mzkp.js → context-4fej2dzv.js} +390 -69
- package/dist/v2/{derive-budgets-wj0q7s7d.js → derive-budgets-9237wmq5.js} +5 -6
- package/dist/v2/embedding-backfill-nhgp8znm.js +28 -0
- package/dist/v2/embedding-worker-process.js +1 -2
- package/dist/v2/embedding-worker.js +6 -7
- package/dist/v2/fold/idle.d.ts +11 -1
- package/dist/v2/fold/idle.d.ts.map +1 -1
- package/dist/v2/fold/instruction-supersession.d.ts +22 -1
- package/dist/v2/fold/instruction-supersession.d.ts.map +1 -1
- package/dist/v2/fold/native-replay-v3.d.ts +1 -0
- package/dist/v2/fold/native-replay-v3.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +73 -0
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/{history-owner-8pd5ax3n.js → history-owner-k4gx50a0.js} +2 -3
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{logger-58jfese9.js → logger-0ys28353.js} +1 -2
- package/dist/v2/{message-fts-rowid-map-ax4vk78j.js → message-fts-rowid-map-88x2zbyj.js} +4 -5
- package/dist/v2/{message-index-bounded-qh794qxx.js → message-index-bounded-wj5rs9az.js} +10 -11
- package/dist/v2/{message-time-backfill-yj773saf.js → message-time-backfill-5p4vwd79.js} +2 -3
- package/dist/v2/migration-worker.js +12 -13
- package/dist/v2/{project-embedding-registry-z05xvckg.js → project-embedding-registry-qz9x79kn.js} +13 -14
- package/dist/v2/raw-ordinal-warmup-worker.js +8 -8
- package/dist/v2/{read-session-chunk-8tn2dbn1.js → read-session-chunk-89ep8br4.js} +8 -9
- package/dist/v2/{read-session-raw-ywebck9q.js → read-session-raw-seh1kcvp.js} +2 -3
- package/dist/v2/recomp-orchestrator-9wap1z1d.js +68 -0
- package/dist/v2/render-bzzypsgy.js +42 -0
- package/dist/v2/{safe-notification-target-zrwbh6k7.js → safe-notification-target-3e2rq2ys.js} +2 -3
- package/dist/v2/{search-archive-8zqsf9e6.js → search-archive-4yr4hw2m.js} +11 -12
- package/dist/v2/{search-35cz80x0.js → search-ymm2crs3.js} +24 -25
- package/dist/v2/{send-session-notification-8x146x5y.js → send-session-notification-vtnk598k.js} +5 -6
- package/dist/v2/{server-vj0xbbrc.js → server-0b3ms151.js} +2 -2
- package/dist/v2/{server-r3h4fy4k.js → server-1bks09js.js} +5 -5
- package/dist/v2/{server-nnh81jqy.js → server-2ek9exbe.js} +6 -8
- package/dist/v2/{server-63ree5ns.js → server-2xng77ch.js} +1 -1
- package/dist/v2/{server-2sare4qg.js → server-3mb205v9.js} +4 -4
- package/dist/v2/{server-n34vzyfm.js → server-3qeqa3b6.js} +1 -1
- package/dist/v2/{server-av3p9c8k.js → server-54nc921b.js} +1 -1
- package/dist/v2/{server-2qvnr3t7.js → server-5zx51pm4.js} +1 -1
- package/dist/v2/{server-vsx9tsks.js → server-62t1852h.js} +11 -11
- package/dist/v2/{server-svccj9rd.js → server-6mq43ear.js} +4 -4
- package/dist/v2/{server-1fnsfm3a.js → server-6r3b0re0.js} +24 -26
- package/dist/v2/{server-db91dxwc.js → server-7861dnm3.js} +6 -6
- package/dist/v2/{server-6qax5pds.js → server-7c5p0bh1.js} +2 -2
- package/dist/v2/{server-z5cv5wm5.js → server-7wpw3wc6.js} +31 -28
- package/dist/v2/{server-11ra1pmx.js → server-8xgs110k.js} +4 -4
- package/dist/v2/{server-40vdz8sf.js → server-98xd6j4r.js} +2 -2
- package/dist/v2/{server-k3ntgf6n.js → server-b5eg9ct6.js} +2 -2
- package/dist/v2/{server-2cq3e1c1.js → server-b65sqz7y.js} +4 -4
- package/dist/v2/{server-ganavh75.js → server-bhr92yb4.js} +2 -2
- package/dist/v2/{server-4yrvbnnm.js → server-bzebqckc.js} +2 -2
- package/dist/v2/{server-rt8t6s2a.js → server-cc58mckk.js} +2 -2
- package/dist/v2/{server-xekyjy4w.js → server-d0h1gjz2.js} +6 -6
- package/dist/v2/{server-73bqw5c0.js → server-d46xewmt.js} +1 -1
- package/dist/v2/{server-rr5c0xcg.js → server-d4h86y7v.js} +2 -2
- package/dist/v2/{server-7tj8yzrv.js → server-e14d7ebh.js} +2 -2
- package/dist/v2/{server-gh2w75fn.js → server-e8ybwfv8.js} +3 -3
- package/dist/v2/{server-zemnpv92.js → server-ghk96d57.js} +4 -4
- package/dist/v2/{server-j1gxs1gj.js → server-h95cdc30.js} +1 -1
- package/dist/v2/{server-5t4nzfpt.js → server-j09jx1n9.js} +1 -1
- package/dist/v2/{server-n33hyq9t.js → server-jrs4gny6.js} +2 -2
- package/dist/v2/{server-7h4gwphm.js → server-pqgnjf38.js} +3 -3
- package/dist/v2/{server-379fd3n7.js → server-rbxtp4sm.js} +1 -1
- package/dist/v2/{server-2wz6y46g.js → server-sfffm587.js} +1 -1
- package/dist/v2/{server-bx5k66qc.js → server-vgy98kcd.js} +1 -1
- package/dist/v2/{server-kzrrdjp5.js → server-xc7t2r4k.js} +223 -5
- package/dist/v2/{server-z2nv8jdv.js → server-xn7fpv2b.js} +12 -12
- package/dist/v2/{server-tq523gj6.js → server-yacpgq4s.js} +1 -1
- package/dist/v2/{server-vtkbxzw1.js → server-ysg14rv1.js} +31 -0
- package/dist/v2/{server-qjjky07w.js → server-zedjjdc5.js} +11 -11
- package/dist/v2/server.js +8 -9
- package/dist/v2/{storage-tags-pcenytad.js → storage-tags-8kktww54.js} +5 -6
- package/dist/v2/{store-gx19qc3a.js → store-0kjfynwp.js} +6 -4
- package/dist/v2/{store-reader-qt2msa8z.js → store-reader-w0srb18d.js} +4 -1
- package/dist/v2/store-reader.d.ts +1 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/tui/index.d.ts +1 -1
- package/dist/v2/tui/index.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-hvdyz30c.js → v2-archive-reader-veyqp15a.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-0d4ceff3.js → wrapup-orchestrator-89cg7p41.js} +33 -34
- package/dist/{v2-archive-reader-qs24chs6.js → v2-archive-reader-3s332fn7.js} +1 -1
- package/dist/wrapup-orchestrator-41rt7etq.js +55 -0
- package/package.json +2 -2
- package/src/shared/rpc-types.ts +6 -0
- package/src/shared/status-view-check.ts +11 -0
- package/src/shared/status-view.ts +24 -1
- package/src/shared/tag-transcript.ts +5 -4
- package/src/shared/test-preload-leak-scan.test.ts +56 -0
- package/src/shared/transcript.ts +1 -1
- package/src/v2/tui/index.ts +8 -1
- package/src/v2/tui/status-dialog-fallback.test.ts +21 -0
- package/dist/embedding-backfill-pdymqbnh.js +0 -29
- package/dist/index-dt7cyqfe.js +0 -223
- package/dist/render-6vmqzcem.js +0 -43
- package/dist/v2/embedding-backfill-16b16m38.js +0 -29
- package/dist/v2/recomp-orchestrator-vzygyqwn.js +0 -69
- package/dist/v2/render-9b5dxp9e.js +0 -43
- package/dist/v2/server-dt7cyqfe.js +0 -223
- package/dist/wrapup-orchestrator-v1mhjw55.js +0 -56
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
resolveLegacyConfigSources,
|
|
8
8
|
getProtectedTokensTierOverrides,
|
|
9
9
|
loadPluginConfigDetailed
|
|
10
|
-
} from "./server-
|
|
10
|
+
} from "./server-0b3ms151.js";
|
|
11
11
|
import {
|
|
12
12
|
getHarness2,
|
|
13
13
|
harnessOwnsOpenCodeStore2
|
|
@@ -16,30 +16,28 @@ import {
|
|
|
16
16
|
getDataDir,
|
|
17
17
|
ensureCortexKitArtifactGitignore,
|
|
18
18
|
getMagicContextStorageDir,
|
|
19
|
+
sanitizeDiagnosticText,
|
|
20
|
+
hasShareabilitySensitiveText,
|
|
19
21
|
classifyStalePluginBuild,
|
|
20
22
|
importPluginModule,
|
|
21
23
|
log2,
|
|
22
24
|
sessionLog2,
|
|
23
25
|
getLoggerDiagnostics2
|
|
24
|
-
} from "./server-
|
|
25
|
-
import {
|
|
26
|
-
sanitizeDiagnosticText,
|
|
27
|
-
hasShareabilitySensitiveText
|
|
28
|
-
} from "./server-dt7cyqfe.js";
|
|
26
|
+
} from "./server-xc7t2r4k.js";
|
|
29
27
|
import {
|
|
30
28
|
registerOwnRpcServerInstance,
|
|
31
29
|
rpcPortDir,
|
|
32
30
|
rpcPortFilePath,
|
|
33
31
|
parseRpcPortFile,
|
|
34
32
|
inspectProcessesAsync
|
|
35
|
-
} from "./server-
|
|
33
|
+
} from "./server-sfffm587.js";
|
|
36
34
|
import {
|
|
37
35
|
shouldEnforcePrivateStoragePermissions,
|
|
38
36
|
ensureStorageDirectorySync,
|
|
39
37
|
writeStorageFileAtomicSync,
|
|
40
38
|
writeStorageFileAsync,
|
|
41
39
|
createStorageWriteStream
|
|
42
|
-
} from "./server-
|
|
40
|
+
} from "./server-3qeqa3b6.js";
|
|
43
41
|
import {
|
|
44
42
|
hasTrustedAbsoluteWall,
|
|
45
43
|
applyProvenInputFloor,
|
|
@@ -52,7 +50,7 @@ import {
|
|
|
52
50
|
getSdkContextLimit,
|
|
53
51
|
getSdkOutputLimit,
|
|
54
52
|
getModelsDevCacheState
|
|
55
|
-
} from "./server-
|
|
53
|
+
} from "./server-d4h86y7v.js";
|
|
56
54
|
import {
|
|
57
55
|
COMPACTION_ENABLED_PATH,
|
|
58
56
|
isDreamerRunnable,
|
|
@@ -249,7 +247,7 @@ import {
|
|
|
249
247
|
startCompartmentAgent,
|
|
250
248
|
setRecompStarting2,
|
|
251
249
|
setRecompTerminal2
|
|
252
|
-
} from "./server-
|
|
250
|
+
} from "./server-6r3b0re0.js";
|
|
253
251
|
import {
|
|
254
252
|
embedPauseBySession,
|
|
255
253
|
embedRunStateBySession,
|
|
@@ -272,7 +270,7 @@ import {
|
|
|
272
270
|
estimateTokens,
|
|
273
271
|
estimateFixedPromptTokens,
|
|
274
272
|
normalizeText
|
|
275
|
-
} from "./server-
|
|
273
|
+
} from "./server-d46xewmt.js";
|
|
276
274
|
import {
|
|
277
275
|
SubcClient,
|
|
278
276
|
connectionFileExists,
|
|
@@ -280,7 +278,7 @@ import {
|
|
|
280
278
|
toSynapseLaneDescriptor,
|
|
281
279
|
formatSynapseLaneDescriptor,
|
|
282
280
|
SynapseEmbeddingProvider
|
|
283
|
-
} from "./server-
|
|
281
|
+
} from "./server-b5eg9ct6.js";
|
|
284
282
|
import {
|
|
285
283
|
inRootAsyncContext2,
|
|
286
284
|
detectSqliteRuntime2,
|
|
@@ -310,11 +308,11 @@ import {
|
|
|
310
308
|
buildInMemoryTailRawMessages2,
|
|
311
309
|
RawOrdinalsNotReady2,
|
|
312
310
|
runSessionWarmupWorker
|
|
313
|
-
} from "./server-
|
|
314
|
-
import"./server-
|
|
311
|
+
} from "./server-54nc921b.js";
|
|
312
|
+
import"./server-98xd6j4r.js";
|
|
315
313
|
import {
|
|
316
314
|
deleteChunkEmbedBackoffForSession2
|
|
317
|
-
} from "./server-
|
|
315
|
+
} from "./server-ghk96d57.js";
|
|
318
316
|
import {
|
|
319
317
|
acquireCompartmentLease,
|
|
320
318
|
releaseCompartmentLeaseBestEffort,
|
|
@@ -440,12 +438,12 @@ import {
|
|
|
440
438
|
saveSourceContent,
|
|
441
439
|
replaceSourceContent,
|
|
442
440
|
getSourceContents
|
|
443
|
-
} from "./server-
|
|
441
|
+
} from "./server-zedjjdc5.js";
|
|
444
442
|
import {
|
|
445
443
|
cleanSearchText,
|
|
446
444
|
matchedSearchSnippet,
|
|
447
445
|
getLastIndexedOrdinal
|
|
448
|
-
} from "./server-
|
|
446
|
+
} from "./server-6mq43ear.js";
|
|
449
447
|
import {
|
|
450
448
|
ensureSessionMetaRow,
|
|
451
449
|
clearCachedM0M1,
|
|
@@ -704,7 +702,7 @@ import {
|
|
|
704
702
|
adoptNullOwnerToolTag2,
|
|
705
703
|
getCandidateToolOwners2,
|
|
706
704
|
pickNearestPriorOwner2
|
|
707
|
-
} from "./server-
|
|
705
|
+
} from "./server-8xgs110k.js";
|
|
708
706
|
import {
|
|
709
707
|
BoundedSessionMap,
|
|
710
708
|
getTableColumnNames,
|
|
@@ -718,7 +716,7 @@ import {
|
|
|
718
716
|
freezeTemporalDecisions,
|
|
719
717
|
tagRevisionKey,
|
|
720
718
|
tagIdentityRevisionKey
|
|
721
|
-
} from "./server-
|
|
719
|
+
} from "./server-bzebqckc.js";
|
|
722
720
|
import {
|
|
723
721
|
resolveHistorianModel2
|
|
724
722
|
} from "./server-5kym00ag.js";
|
|
@@ -736,7 +734,7 @@ import {
|
|
|
736
734
|
shouldBypassFailClosedBlock,
|
|
737
735
|
resolveAgentNameFromMessages,
|
|
738
736
|
createFailClosedController
|
|
739
|
-
} from "./server-
|
|
737
|
+
} from "./server-5zx51pm4.js";
|
|
740
738
|
import {
|
|
741
739
|
pruneMissingProjectIdentities,
|
|
742
740
|
setHomeProjectPermission,
|
|
@@ -754,7 +752,7 @@ import {
|
|
|
754
752
|
storedPathBelongsToIdentity,
|
|
755
753
|
beginBootQuietPeriod,
|
|
756
754
|
scheduleAfterBootQuiet
|
|
757
|
-
} from "./server-
|
|
755
|
+
} from "./server-jrs4gny6.js";
|
|
758
756
|
import {
|
|
759
757
|
resolveModelCalibration,
|
|
760
758
|
calibrateBuckets,
|
|
@@ -775,7 +773,7 @@ import {
|
|
|
775
773
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
776
774
|
getMessageTimesFromOpenCodeDb,
|
|
777
775
|
findLastAssistantModelFromOpenCodeDb
|
|
778
|
-
} from "./server-
|
|
776
|
+
} from "./server-vgy98kcd.js";
|
|
779
777
|
import {
|
|
780
778
|
askAnswerLines,
|
|
781
779
|
estimateTrueRawMessageTokens,
|
|
@@ -818,7 +816,7 @@ import {
|
|
|
818
816
|
readRawSessionMessageOrdinalById2,
|
|
819
817
|
readSessionChunk2,
|
|
820
818
|
readRawSessionSeedTail2
|
|
821
|
-
} from "./server-
|
|
819
|
+
} from "./server-7861dnm3.js";
|
|
822
820
|
import {
|
|
823
821
|
getMessageIndexEpoch,
|
|
824
822
|
isMessageIndexSearchable,
|
|
@@ -844,7 +842,7 @@ import {
|
|
|
844
842
|
resolveMemoriesByIdsForSearch2,
|
|
845
843
|
unifiedSearch2,
|
|
846
844
|
formatSearchResults2
|
|
847
|
-
} from "./server-
|
|
845
|
+
} from "./server-xn7fpv2b.js";
|
|
848
846
|
import {
|
|
849
847
|
startBootDeadline,
|
|
850
848
|
getUnconfirmedMigrationHolders,
|
|
@@ -860,7 +858,7 @@ import {
|
|
|
860
858
|
openDatabaseAsync,
|
|
861
859
|
isDatabasePersisted,
|
|
862
860
|
getDatabasePersistenceError
|
|
863
|
-
} from "./server-
|
|
861
|
+
} from "./server-62t1852h.js";
|
|
864
862
|
import {
|
|
865
863
|
V2_MEMORY_CATEGORIES,
|
|
866
864
|
CATEGORY_PRIORITY
|
|
@@ -873,13 +871,13 @@ import {
|
|
|
873
871
|
resolveStoredPathWorkspaceIdentity,
|
|
874
872
|
storedPathBelongsToWorkspace,
|
|
875
873
|
computeWorkspaceEpochFingerprint
|
|
876
|
-
} from "./server-
|
|
874
|
+
} from "./server-3mb205v9.js";
|
|
877
875
|
import {
|
|
878
876
|
gaDatabasePath2,
|
|
879
877
|
RAW_MESSAGE_TYPES2,
|
|
880
878
|
V2StoreReaderPool2,
|
|
881
879
|
V2StoreReader2
|
|
882
|
-
} from "./server-
|
|
880
|
+
} from "./server-ysg14rv1.js";
|
|
883
881
|
import {
|
|
884
882
|
configureContextDatabasePragmas2
|
|
885
883
|
} from "./server-fb3zxn06.js";
|
|
@@ -908,15 +906,15 @@ import {
|
|
|
908
906
|
createPrimer,
|
|
909
907
|
updatePrimerSupport,
|
|
910
908
|
updatePrimerAnswer
|
|
911
|
-
} from "./server-
|
|
909
|
+
} from "./server-j09jx1n9.js";
|
|
912
910
|
import {
|
|
913
911
|
deriveTriggerBudget2,
|
|
914
912
|
deriveHistorianChunkTokens2,
|
|
915
913
|
resolveKnownHistorianContextLimit2,
|
|
916
914
|
resolveHistorianProducerLimits2,
|
|
917
915
|
resolveHistorianContextLimit2
|
|
918
|
-
} from "./server-
|
|
919
|
-
import"./server-
|
|
916
|
+
} from "./server-cc58mckk.js";
|
|
917
|
+
import"./server-rbxtp4sm.js";
|
|
920
918
|
import {
|
|
921
919
|
isEmbeddingHostBusy2
|
|
922
920
|
} from "./server-qt1qqasc.js";
|
|
@@ -942,7 +940,7 @@ import {
|
|
|
942
940
|
embedSessionCompartmentChunks2,
|
|
943
941
|
getEmbeddingCoverageStatus2,
|
|
944
942
|
getAutoEmbeddingSessionCoverage2
|
|
945
|
-
} from "./server-
|
|
943
|
+
} from "./server-7wpw3wc6.js";
|
|
946
944
|
import {
|
|
947
945
|
GIT_SWEEP_LEASE_RENEWAL_MS,
|
|
948
946
|
acquireGitSweepLease,
|
|
@@ -952,7 +950,7 @@ import {
|
|
|
952
950
|
releaseGitSweepLease,
|
|
953
951
|
recordSessionProjectIdentity,
|
|
954
952
|
hasRecordedSessionProjectIdentity
|
|
955
|
-
} from "./server-
|
|
953
|
+
} from "./server-7c5p0bh1.js";
|
|
956
954
|
import {
|
|
957
955
|
saveEmbeddingIfHashMatches,
|
|
958
956
|
invalidateProject2,
|
|
@@ -962,7 +960,7 @@ import {
|
|
|
962
960
|
getCachedLocalEmbeddingPooling,
|
|
963
961
|
preflightLocalEmbeddingPooling,
|
|
964
962
|
getLocalEmbeddingNativeMemoryStats
|
|
965
|
-
} from "./server-
|
|
963
|
+
} from "./server-pqgnjf38.js";
|
|
966
964
|
import {
|
|
967
965
|
renderUserFacingFailure,
|
|
968
966
|
userFacingFailureCode,
|
|
@@ -982,8 +980,8 @@ import {
|
|
|
982
980
|
readGitFileChangeTimesSince,
|
|
983
981
|
verificationFileExists,
|
|
984
982
|
normalizeVerificationFiles
|
|
985
|
-
} from "./server-
|
|
986
|
-
import"./server-
|
|
983
|
+
} from "./server-2ek9exbe.js";
|
|
984
|
+
import"./server-bhr92yb4.js";
|
|
987
985
|
import {
|
|
988
986
|
computeCueContentHash,
|
|
989
987
|
hasMuralCueColumns,
|
|
@@ -1019,11 +1017,11 @@ import {
|
|
|
1019
1017
|
drainNotifications2,
|
|
1020
1018
|
isTuiConnected2
|
|
1021
1019
|
} from "./server-y14pawe1.js";
|
|
1022
|
-
import"./server-
|
|
1020
|
+
import"./server-2xng77ch.js";
|
|
1023
1021
|
import {
|
|
1024
1022
|
flushIgnoredMessages2,
|
|
1025
1023
|
sendStatusNotification2
|
|
1026
|
-
} from "./server-
|
|
1024
|
+
} from "./server-b65sqz7y.js";
|
|
1027
1025
|
import {
|
|
1028
1026
|
rememberHostMedia,
|
|
1029
1027
|
hostMediaAsset,
|
|
@@ -1049,7 +1047,7 @@ import {
|
|
|
1049
1047
|
readV2RawMessagePagesForConversion2,
|
|
1050
1048
|
createV2RawMessageReader2,
|
|
1051
1049
|
createV2RawMessageProvider2
|
|
1052
|
-
} from "./server-
|
|
1050
|
+
} from "./server-e14d7ebh.js";
|
|
1053
1051
|
import {
|
|
1054
1052
|
resolvePromptContext2
|
|
1055
1053
|
} from "./server-fmsr7v69.js";
|
|
@@ -1057,15 +1055,15 @@ import {
|
|
|
1057
1055
|
renderMessageByOrdinal2,
|
|
1058
1056
|
renderVerboseRangeForTool2,
|
|
1059
1057
|
renderItemByTag2
|
|
1060
|
-
} from "./server-
|
|
1061
|
-
import"./server-
|
|
1058
|
+
} from "./server-e8ybwfv8.js";
|
|
1059
|
+
import"./server-h95cdc30.js";
|
|
1062
1060
|
import {
|
|
1063
1061
|
readV2ArchiveOffThread2
|
|
1064
|
-
} from "./server-
|
|
1062
|
+
} from "./server-1bks09js.js";
|
|
1065
1063
|
import {
|
|
1066
1064
|
unresolvedLiveTailRefusal2,
|
|
1067
1065
|
renderSearchArchiveOffThread2
|
|
1068
|
-
} from "./server-
|
|
1066
|
+
} from "./server-d0h1gjz2.js";
|
|
1069
1067
|
import {
|
|
1070
1068
|
markHostInstructionRow,
|
|
1071
1069
|
hostInstructionRow,
|
|
@@ -1101,7 +1099,7 @@ import {
|
|
|
1101
1099
|
} from "./server-8ajstryz.js";
|
|
1102
1100
|
import {
|
|
1103
1101
|
logSlowWriteTransaction
|
|
1104
|
-
} from "./server-
|
|
1102
|
+
} from "./server-yacpgq4s.js";
|
|
1105
1103
|
import {
|
|
1106
1104
|
sameProjectDirectory,
|
|
1107
1105
|
canonicalProjectDirectory
|
|
@@ -6183,20 +6181,24 @@ function resolveTailHygieneStatus(tsBaseline, rustBaseline) {
|
|
|
6183
6181
|
}
|
|
6184
6182
|
|
|
6185
6183
|
// src/hooks/magic-context/execute-flush.ts
|
|
6186
|
-
function executeFlush(db, sessionId) {
|
|
6184
|
+
function executeFlush(db, sessionId, onToolDrops) {
|
|
6187
6185
|
try {
|
|
6188
6186
|
const pendingOps = getPendingOps(db, sessionId);
|
|
6189
6187
|
if (pendingOps.length === 0) {
|
|
6190
6188
|
return "No pending operations to flush.";
|
|
6191
6189
|
}
|
|
6192
6190
|
let dropped = 0;
|
|
6193
|
-
db.transaction(() => {
|
|
6191
|
+
const toolDrops = db.transaction(() => {
|
|
6192
|
+
const toolDrops = onToolDrops ? getTagsByNumbers2(db, sessionId, pendingOps.map((op) => op.tagId)).filter((tag) => tag.type === "tool" && tag.status === "active").map((tag) => tag.tagNumber) : [];
|
|
6194
6193
|
for (const op of pendingOps) {
|
|
6195
6194
|
updateTagStatus2(db, sessionId, op.tagId, "dropped");
|
|
6196
6195
|
removePendingOp(db, sessionId, op.tagId);
|
|
6197
6196
|
dropped++;
|
|
6198
6197
|
}
|
|
6198
|
+
return toolDrops;
|
|
6199
6199
|
}).immediate();
|
|
6200
|
+
if (toolDrops.length > 0)
|
|
6201
|
+
onToolDrops?.(toolDrops);
|
|
6200
6202
|
const parts = [];
|
|
6201
6203
|
if (dropped > 0)
|
|
6202
6204
|
parts.push(`${dropped} dropped`);
|
|
@@ -8667,7 +8669,7 @@ function applyPendingOperations(sessionId, db, targets, protectedTagIds, preload
|
|
|
8667
8669
|
}
|
|
8668
8670
|
return didMutateMessage;
|
|
8669
8671
|
}
|
|
8670
|
-
function applyFlushedStatuses(sessionId, db, targets, preloadedTags) {
|
|
8672
|
+
function applyFlushedStatuses(sessionId, db, targets, preloadedTags, keepRealArgumentsFor) {
|
|
8671
8673
|
let didMutateMessage = false;
|
|
8672
8674
|
const tags = preloadedTags ?? getDroppedTagsByNumbers2(db, sessionId, [...targets.keys()]);
|
|
8673
8675
|
for (const tag of tags) {
|
|
@@ -8698,7 +8700,7 @@ function applyFlushedStatuses(sessionId, db, targets, preloadedTags) {
|
|
|
8698
8700
|
didMutateMessage = true;
|
|
8699
8701
|
}
|
|
8700
8702
|
} else {
|
|
8701
|
-
const dropResult = target?.drop?.() ?? "absent";
|
|
8703
|
+
const dropResult = target?.drop?.(keepRealArgumentsFor?.has(tag.tagNumber)) ?? "absent";
|
|
8702
8704
|
if (dropResult === "removed" || dropResult === "truncated") {
|
|
8703
8705
|
didMutateMessage = true;
|
|
8704
8706
|
}
|
|
@@ -21939,6 +21941,7 @@ function createTransform(deps) {
|
|
|
21939
21941
|
onCompartmentStatePublished: (sid) => {
|
|
21940
21942
|
deferredHistoryRefreshSessions.add(sid);
|
|
21941
21943
|
deferredMaterializationSessions.add(sid);
|
|
21944
|
+
deps.onHistoryPublished?.(sid);
|
|
21942
21945
|
}
|
|
21943
21946
|
}, undefined, urgent ? undefined : prepareRecoveryBoundary);
|
|
21944
21947
|
return true;
|
|
@@ -22314,6 +22317,7 @@ ${notice}`, notificationParams));
|
|
|
22314
22317
|
onCompartmentStatePublished: (sid) => {
|
|
22315
22318
|
deferredHistoryRefreshSessions.add(sid);
|
|
22316
22319
|
deferredMaterializationSessions.add(sid);
|
|
22320
|
+
deps.onHistoryPublished?.(sid);
|
|
22317
22321
|
}
|
|
22318
22322
|
});
|
|
22319
22323
|
pendingCompartmentInjection = compartmentPhase.pendingCompartmentInjection;
|
|
@@ -26552,6 +26556,9 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
26552
26556
|
const detail = buildStatusDetail(db, sessionId, dir, modelKey, rawConfig, liveSessionState, injectionBudgetTokens, moduleStatus, compactionEnabled);
|
|
26553
26557
|
if (showForkHistoryGap(db, sessionId))
|
|
26554
26558
|
detail.forkHistoryGap = true;
|
|
26559
|
+
const checkpointInstructions = args.readCheckpointInstructions?.(sessionId);
|
|
26560
|
+
if (checkpointInstructions?.tokens)
|
|
26561
|
+
detail.checkpointInstructions = checkpointInstructions;
|
|
26555
26562
|
if (args.hiddenCompletionExecutor?.capabilities.tools === false) {
|
|
26556
26563
|
detail.dreamerUnsupportedTasks = toolLoopDreamTasks();
|
|
26557
26564
|
}
|
|
@@ -26595,7 +26602,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
26595
26602
|
return { count: buildCompartmentCount(db, sessionId, moduleStatus) };
|
|
26596
26603
|
});
|
|
26597
26604
|
const buildManagedCtx = async (db) => {
|
|
26598
|
-
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-
|
|
26605
|
+
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-9237wmq5.js"));
|
|
26599
26606
|
const { resolveHistorianModel } = await importPluginModule(() => import("./model-resolution-280gmqvd.js"));
|
|
26600
26607
|
const { userObservationCollectionEnabled, userObservationsRequested } = await importPluginModule(() => import("./task-config-4nqq2s0w.js"));
|
|
26601
26608
|
const DEFAULT_HISTORIAN_TIMEOUT_MS = 10 * 60 * 1000;
|
|
@@ -26628,7 +26635,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
26628
26635
|
return { ok: false, error: "no session" };
|
|
26629
26636
|
const readDirectory = args.readSessionDirectory;
|
|
26630
26637
|
if (readDirectory) {
|
|
26631
|
-
const { handoffHistoryWork } = await import("./history-owner-
|
|
26638
|
+
const { handoffHistoryWork } = await import("./history-owner-k4gx50a0.js");
|
|
26632
26639
|
const handed = await handoffHistoryWork({
|
|
26633
26640
|
storageDir: args.storageDir ?? getMagicContextStorageDir(),
|
|
26634
26641
|
directory,
|
|
@@ -26647,8 +26654,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
26647
26654
|
const db = readDatabase();
|
|
26648
26655
|
if (!db)
|
|
26649
26656
|
return { ok: false, error: "db unavailable" };
|
|
26650
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
26651
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
26657
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-9wap1z1d.js"));
|
|
26658
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-vtnk598k.js"));
|
|
26652
26659
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
26653
26660
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
26654
26661
|
return {
|
|
@@ -26706,7 +26713,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
26706
26713
|
rpcServer.handle("wrapup", async (params) => {
|
|
26707
26714
|
const readDirectory = args.readSessionDirectory;
|
|
26708
26715
|
if (readDirectory && params.sessionId) {
|
|
26709
|
-
const { handoffHistoryWork } = await import("./history-owner-
|
|
26716
|
+
const { handoffHistoryWork } = await import("./history-owner-k4gx50a0.js");
|
|
26710
26717
|
const sessionId = String(params.sessionId);
|
|
26711
26718
|
const handed = await handoffHistoryWork({
|
|
26712
26719
|
storageDir: args.storageDir ?? getMagicContextStorageDir(),
|
|
@@ -26732,7 +26739,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
26732
26739
|
const db = readDatabase();
|
|
26733
26740
|
if (!db)
|
|
26734
26741
|
return { ok: false, error: "db unavailable" };
|
|
26735
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
26742
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-89cg7p41.js"));
|
|
26736
26743
|
const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
|
|
26737
26744
|
const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
|
|
26738
26745
|
if (!window)
|
|
@@ -27711,12 +27718,24 @@ function trimToRecordedBoundary(db, sessionId, messages) {
|
|
|
27711
27718
|
}
|
|
27712
27719
|
|
|
27713
27720
|
// src/v2/fold/idle.ts
|
|
27721
|
+
function publishedHistoryCanRide({
|
|
27722
|
+
directoryResolved,
|
|
27723
|
+
percentage,
|
|
27724
|
+
executeThreshold,
|
|
27725
|
+
publishedEnd,
|
|
27726
|
+
servedEnd
|
|
27727
|
+
}) {
|
|
27728
|
+
return directoryResolved && percentage >= executeThreshold && publishedEnd !== null && publishedEnd !== servedEnd;
|
|
27729
|
+
}
|
|
27730
|
+
|
|
27714
27731
|
class HostFoldIdle {
|
|
27715
27732
|
fold;
|
|
27716
27733
|
now;
|
|
27717
27734
|
timers;
|
|
27718
27735
|
windows = new Map;
|
|
27719
27736
|
attempted = new Map;
|
|
27737
|
+
publicationWindows = new BoundedSessionMap(1000);
|
|
27738
|
+
publicationAttempts = new BoundedSessionMap(1000);
|
|
27720
27739
|
constructor(fold, now = Date.now, timers = { setTimeout, clearTimeout }) {
|
|
27721
27740
|
this.fold = fold;
|
|
27722
27741
|
this.now = now;
|
|
@@ -27727,8 +27746,10 @@ class HostFoldIdle {
|
|
|
27727
27746
|
if (window?.timer)
|
|
27728
27747
|
this.timers.clearTimeout(window.timer);
|
|
27729
27748
|
this.windows.delete(sessionID);
|
|
27749
|
+
this.publicationWindows.delete(sessionID);
|
|
27730
27750
|
}
|
|
27731
27751
|
idle(sessionID, cacheTtl, lastResponseTime) {
|
|
27752
|
+
const previousPublication = this.publicationWindows.peek(sessionID);
|
|
27732
27753
|
this.active(sessionID);
|
|
27733
27754
|
let ttl;
|
|
27734
27755
|
try {
|
|
@@ -27736,8 +27757,12 @@ class HostFoldIdle {
|
|
|
27736
27757
|
} catch {
|
|
27737
27758
|
ttl = 5 * 60 * 1000;
|
|
27738
27759
|
}
|
|
27739
|
-
if (
|
|
27760
|
+
if (lastResponseTime <= 0)
|
|
27740
27761
|
return;
|
|
27762
|
+
if (!Number.isFinite(ttl)) {
|
|
27763
|
+
this.publicationWindows.set(sessionID, previousPublication?.responseTime === lastResponseTime ? previousPublication : { responseTime: lastResponseTime });
|
|
27764
|
+
return;
|
|
27765
|
+
}
|
|
27741
27766
|
const attempted = this.attempted.get(sessionID);
|
|
27742
27767
|
if (attempted?.cacheTtl === cacheTtl && attempted.lastResponseTime === lastResponseTime)
|
|
27743
27768
|
return;
|
|
@@ -27763,10 +27788,24 @@ class HostFoldIdle {
|
|
|
27763
27788
|
};
|
|
27764
27789
|
wake();
|
|
27765
27790
|
}
|
|
27791
|
+
published(sessionID, ready) {
|
|
27792
|
+
const window = this.publicationWindows.get(sessionID);
|
|
27793
|
+
if (!window || this.publicationAttempts.get(sessionID) === window.responseTime)
|
|
27794
|
+
return;
|
|
27795
|
+
const eligible = () => this.publicationWindows.peek(sessionID) === window && ready();
|
|
27796
|
+
if (!eligible())
|
|
27797
|
+
return;
|
|
27798
|
+
this.publicationAttempts.set(sessionID, window.responseTime);
|
|
27799
|
+
this.fold(sessionID, eligible).catch(() => {
|
|
27800
|
+
return;
|
|
27801
|
+
});
|
|
27802
|
+
}
|
|
27766
27803
|
dispose() {
|
|
27767
27804
|
for (const sessionID of this.windows.keys())
|
|
27768
27805
|
this.active(sessionID);
|
|
27769
27806
|
this.attempted.clear();
|
|
27807
|
+
this.publicationWindows.clear();
|
|
27808
|
+
this.publicationAttempts.clear();
|
|
27770
27809
|
}
|
|
27771
27810
|
}
|
|
27772
27811
|
|
|
@@ -27985,8 +28024,58 @@ function retiredLiveInstructionIDs(db, sessionID) {
|
|
|
27985
28024
|
function coveredInstructionSupersessionOn(db, sessionID) {
|
|
27986
28025
|
return coveredOn(readReplayEnvelope(db, sessionID)[coveredNamespace]);
|
|
27987
28026
|
}
|
|
28027
|
+
var leftOutNamespace = "legacyCheckpointInstructionsLeftOut";
|
|
28028
|
+
function decodeLeftOut(value) {
|
|
28029
|
+
if (typeof value !== "object" || value === null)
|
|
28030
|
+
return;
|
|
28031
|
+
const { through, ids } = value;
|
|
28032
|
+
if (typeof through !== "number" || !Number.isSafeInteger(through) || through < -1 || !Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0))
|
|
28033
|
+
return;
|
|
28034
|
+
return { through, ids: [...ids] };
|
|
28035
|
+
}
|
|
28036
|
+
function instructionsLeftOut(db, sessionID) {
|
|
28037
|
+
let doc;
|
|
28038
|
+
try {
|
|
28039
|
+
doc = readReplayEnvelope(db, sessionID, "read");
|
|
28040
|
+
} catch {
|
|
28041
|
+
return;
|
|
28042
|
+
}
|
|
28043
|
+
return decodeLeftOut(doc[leftOutNamespace]);
|
|
28044
|
+
}
|
|
28045
|
+
function mergeInstructionsLeftOut(a, b) {
|
|
28046
|
+
return {
|
|
28047
|
+
through: Math.max(a?.through ?? -1, b.through),
|
|
28048
|
+
ids: [...new Set([...a?.ids ?? [], ...b.ids])]
|
|
28049
|
+
};
|
|
28050
|
+
}
|
|
28051
|
+
function raisesInstructionsLeftOut(current, next) {
|
|
28052
|
+
if (!current)
|
|
28053
|
+
return true;
|
|
28054
|
+
const ids = new Set(current.ids);
|
|
28055
|
+
return next.through > current.through || next.ids.some((id) => !ids.has(id));
|
|
28056
|
+
}
|
|
28057
|
+
function recordInstructionsLeftOut(db, sessionID, value) {
|
|
28058
|
+
return updateReplayDocument(db, sessionID, (doc) => {
|
|
28059
|
+
const current = decodeLeftOut(doc[leftOutNamespace]);
|
|
28060
|
+
if (current && !raisesInstructionsLeftOut(current, value))
|
|
28061
|
+
return false;
|
|
28062
|
+
doc.version = 2;
|
|
28063
|
+
doc[leftOutNamespace] = mergeInstructionsLeftOut(current, value);
|
|
28064
|
+
return true;
|
|
28065
|
+
});
|
|
28066
|
+
}
|
|
28067
|
+
function isLeftOutInstruction(leftOut, row) {
|
|
28068
|
+
return !!leftOut && row.type === "system" && (row.seq <= leftOut.through || leftOut.ids.includes(row.id));
|
|
28069
|
+
}
|
|
27988
28070
|
var coveredSupersessionEnabled = true;
|
|
27989
|
-
function
|
|
28071
|
+
function isMarkedInstructionUpdate(row) {
|
|
28072
|
+
const metadata = row.data.metadata;
|
|
28073
|
+
if (typeof metadata !== "object" || metadata === null || !("instructionSources" in metadata))
|
|
28074
|
+
return false;
|
|
28075
|
+
const sources = metadata.instructionSources;
|
|
28076
|
+
return row.type === "system" && "notice" in metadata && metadata.notice === "instructions" && Array.isArray(sources) && sources.length > 0 && sources.every((source) => typeof source === "string" && source.length > 0);
|
|
28077
|
+
}
|
|
28078
|
+
function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new Set, covered = [], checkpointSequence, checkpointCoveredThrough) {
|
|
27990
28079
|
const instructionRows = (list) => list.flatMap((message) => {
|
|
27991
28080
|
const row = hostInstructionRow(message.info);
|
|
27992
28081
|
return row ? [{ message, row }] : [];
|
|
@@ -27998,6 +28087,12 @@ function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new
|
|
|
27998
28087
|
const coveredFollowed = rows.length > 0 && (coveredRows.length > 0 || permitted) && coveredInstructionSupersessionOn(db, sessionID);
|
|
27999
28088
|
const switchCovered = permitted && rows.length > 0 && !coveredFollowed && coveredSupersessionEnabled;
|
|
28000
28089
|
const selected = permitted ? supersededInstructionIDs(rows.map(({ row }) => row)) : new Set;
|
|
28090
|
+
if (permitted && checkpointSequence !== undefined) {
|
|
28091
|
+
for (const { row } of rows) {
|
|
28092
|
+
if (row.seq < checkpointSequence && (isMarkedInstructionUpdate(row) || checkpointCoveredThrough !== undefined && row.seq <= checkpointCoveredThrough))
|
|
28093
|
+
selected.add(row.id);
|
|
28094
|
+
}
|
|
28095
|
+
}
|
|
28001
28096
|
const newlyRetired = new Set([...selected].filter((id) => !retired.has(id)));
|
|
28002
28097
|
const omitted = new Set([...retired, ...newlyRetired]);
|
|
28003
28098
|
const omits = (message, id) => omitted.has(id) && (!coveredMessages.has(message) || coveredFollowed || switchCovered);
|
|
@@ -29022,12 +29117,13 @@ function validReplayState(value) {
|
|
|
29022
29117
|
"upgrade",
|
|
29023
29118
|
"withoutRecentContext",
|
|
29024
29119
|
"retiredInstructionThrough",
|
|
29025
|
-
"retiredInstructionIDs"
|
|
29120
|
+
"retiredInstructionIDs",
|
|
29121
|
+
"reclaimCoveredInstructionsThrough"
|
|
29026
29122
|
]))
|
|
29027
29123
|
return false;
|
|
29028
29124
|
const floor = value.floor;
|
|
29029
29125
|
const upgrade = value.upgrade;
|
|
29030
|
-
return object2(floor) && keys(floor, ["kind", "id", "seq", "after", "digest"]) && ["start", "summary", "checkpoint", "host-checkpoint"].includes(floor.kind) && identity(floor.id) && typeof floor.seq === "number" && typeof floor.after === "number" && Number.isSafeInteger(floor.seq) && Number.isSafeInteger(floor.after) && floor.after === (floor.kind === "start" || floor.kind === "host-checkpoint" ? floor.seq - 1 : floor.seq) && digest(floor.digest) && validControls(value.controls) && (value.blocked === undefined || typeof value.blocked === "boolean") && (value.withoutRecentContext === undefined || typeof value.withoutRecentContext === "boolean") && (value.retiredInstructionThrough === undefined || Number.isSafeInteger(value.retiredInstructionThrough) && value.retiredInstructionThrough >= 0) && (value.retiredInstructionIDs === undefined || Array.isArray(value.retiredInstructionIDs) && value.retiredInstructionIDs.every(identity)) && (upgrade === undefined || object2(upgrade) && keys(upgrade, ["admissionID", "mode"]) && identity(upgrade.admissionID) && ["bounded", "host-checkpoint", "source-repair"].includes(upgrade.mode));
|
|
29126
|
+
return object2(floor) && keys(floor, ["kind", "id", "seq", "after", "digest"]) && ["start", "summary", "checkpoint", "host-checkpoint"].includes(floor.kind) && identity(floor.id) && typeof floor.seq === "number" && typeof floor.after === "number" && Number.isSafeInteger(floor.seq) && Number.isSafeInteger(floor.after) && floor.after === (floor.kind === "start" || floor.kind === "host-checkpoint" ? floor.seq - 1 : floor.seq) && digest(floor.digest) && validControls(value.controls) && (value.blocked === undefined || typeof value.blocked === "boolean") && (value.withoutRecentContext === undefined || typeof value.withoutRecentContext === "boolean") && (value.retiredInstructionThrough === undefined || Number.isSafeInteger(value.retiredInstructionThrough) && value.retiredInstructionThrough >= 0) && (value.retiredInstructionIDs === undefined || Array.isArray(value.retiredInstructionIDs) && value.retiredInstructionIDs.every(identity)) && (value.reclaimCoveredInstructionsThrough === undefined || Number.isSafeInteger(value.reclaimCoveredInstructionsThrough) && value.reclaimCoveredInstructionsThrough >= 0) && (upgrade === undefined || object2(upgrade) && keys(upgrade, ["admissionID", "mode"]) && identity(upgrade.admissionID) && ["bounded", "host-checkpoint", "source-repair"].includes(upgrade.mode));
|
|
29031
29127
|
}
|
|
29032
29128
|
function instructionRetirement(replay) {
|
|
29033
29129
|
const ids = new Set(replay?.retiredInstructionIDs);
|
|
@@ -29281,6 +29377,17 @@ async function forgetNativeFoldProvenance(storage, sessionID, legacyOnly = false
|
|
|
29281
29377
|
after = page.next;
|
|
29282
29378
|
} while (after);
|
|
29283
29379
|
}
|
|
29380
|
+
function legacyLeftOut(record) {
|
|
29381
|
+
const replay = record.replay;
|
|
29382
|
+
if (replay.reclaimCoveredInstructionsThrough !== undefined || replay.floor.after < 0)
|
|
29383
|
+
return;
|
|
29384
|
+
const through = replay.retiredInstructionThrough ?? -1;
|
|
29385
|
+
const ids = [...replay.retiredInstructionIDs ?? []];
|
|
29386
|
+
return {
|
|
29387
|
+
native: { through: Math.max(replay.floor.after, through), ids },
|
|
29388
|
+
fallback: { through, ids }
|
|
29389
|
+
};
|
|
29390
|
+
}
|
|
29284
29391
|
|
|
29285
29392
|
class NativeFoldReplay {
|
|
29286
29393
|
storage;
|
|
@@ -29303,6 +29410,8 @@ class NativeFoldReplay {
|
|
|
29303
29410
|
reportedForeignRefreshes = new Set;
|
|
29304
29411
|
editedAdmissions = new Map;
|
|
29305
29412
|
legacyUpgrades = new Map;
|
|
29413
|
+
passRecords = new Map;
|
|
29414
|
+
passLeftOut = new Map;
|
|
29306
29415
|
constructor(storage, openReader, admissions, options = {}) {
|
|
29307
29416
|
this.storage = storage;
|
|
29308
29417
|
this.openReader = openReader;
|
|
@@ -29359,6 +29468,103 @@ class NativeFoldReplay {
|
|
|
29359
29468
|
return instructionRetirement();
|
|
29360
29469
|
return instructionRetirement(await this.floorState(sessionID, reader));
|
|
29361
29470
|
}
|
|
29471
|
+
async coveredInstructionReclaimBoundary(sessionID, cut, reader) {
|
|
29472
|
+
if (!this.options.deferCoveredInstructionRetirement?.())
|
|
29473
|
+
return;
|
|
29474
|
+
const admission = await this.passRecord(sessionID, reader);
|
|
29475
|
+
if (admission?.proof.admissionID !== cut.id || admission.proof.sourceDigest !== foldDigest(reader.hostIdentity()) || admission.proof.summaryDigest !== foldDigest(cut.data.summary ?? "") || admission.replay.reclaimCoveredInstructionsThrough === undefined)
|
|
29476
|
+
return;
|
|
29477
|
+
const coverage = this.historyCoverage(sessionID, reader);
|
|
29478
|
+
return coverage && this.floorCovered(sessionID, admission.replay.floor, coverage, admission.replay) ? admission.replay.reclaimCoveredInstructionsThrough : undefined;
|
|
29479
|
+
}
|
|
29480
|
+
async admittedInstructionRetirement(sessionID, reader) {
|
|
29481
|
+
return instructionRetirement((await this.passRecord(sessionID, reader))?.replay);
|
|
29482
|
+
}
|
|
29483
|
+
async leftOutForPass(sessionID, cut, reader, served) {
|
|
29484
|
+
const stored = instructionsLeftOut(this.storage.db, sessionID);
|
|
29485
|
+
const record = await this.passRecord(sessionID, reader);
|
|
29486
|
+
if (!record || record.proof.sourceDigest !== foldDigest(reader.hostIdentity()) || stored && served === "fallback")
|
|
29487
|
+
return { leftOut: stored };
|
|
29488
|
+
const legacy = legacyLeftOut(record);
|
|
29489
|
+
if (!legacy || !raisesInstructionsLeftOut(stored, legacy.native))
|
|
29490
|
+
return { leftOut: stored };
|
|
29491
|
+
const path = this.legacyPath(sessionID, record, cut, reader, served);
|
|
29492
|
+
const value = mergeInstructionsLeftOut(stored, legacy[path]);
|
|
29493
|
+
if (raisesInstructionsLeftOut(stored, legacy[path]))
|
|
29494
|
+
this.passLeftOut.set(sessionID, value);
|
|
29495
|
+
if (served !== "native" || path !== "fallback")
|
|
29496
|
+
return { leftOut: value };
|
|
29497
|
+
return {
|
|
29498
|
+
leftOut: value,
|
|
29499
|
+
restoreCoveredThrough: record.replay.floor.after,
|
|
29500
|
+
stageRetirement: () => this.passLeftOut.set(sessionID, mergeInstructionsLeftOut(value, legacy.native))
|
|
29501
|
+
};
|
|
29502
|
+
}
|
|
29503
|
+
legacyPath(sessionID, record, cut, reader, served) {
|
|
29504
|
+
const carried = this.savedRequestCarriedCovered(sessionID, record, reader);
|
|
29505
|
+
if (carried !== undefined)
|
|
29506
|
+
return carried ? "fallback" : "native";
|
|
29507
|
+
if (served === "native" || served === undefined && cut && this.oldReleaseAdmits(sessionID, record, cut, reader))
|
|
29508
|
+
return "native";
|
|
29509
|
+
return "fallback";
|
|
29510
|
+
}
|
|
29511
|
+
oldReleaseAdmits(sessionID, record, cut, reader) {
|
|
29512
|
+
return isLocalCheckpoint(cut) && record.proof.admissionID === cut.id && record.proof.sourceDigest === foldDigest(reader.hostIdentity()) && record.proof.summaryDigest === foldDigest(cut.data.summary ?? "") && validFloor(reader, sessionID, record.replay.floor) && this.floorCovered(sessionID, record.replay.floor, this.historyCoverage(sessionID, reader), record.replay) && record.proof.historyDigest === historyDigest(reader, sessionID, cut.seq - 1, record.replay.floor.after);
|
|
29513
|
+
}
|
|
29514
|
+
savedRequestCarriedCovered(sessionID, record, reader) {
|
|
29515
|
+
let slot;
|
|
29516
|
+
try {
|
|
29517
|
+
slot = getSlot(sessionID) ?? loadPersistedLkgSlot(this.storage.db, sessionID);
|
|
29518
|
+
} catch {
|
|
29519
|
+
return;
|
|
29520
|
+
}
|
|
29521
|
+
if (!slot)
|
|
29522
|
+
return;
|
|
29523
|
+
const first = slot.inputIdSeq.findIndex((id) => !id.startsWith("\x00"));
|
|
29524
|
+
if (first < 0 || !slot.inputIdSeq.slice(0, first).every((id) => id.startsWith("\x00mc-system:")))
|
|
29525
|
+
return;
|
|
29526
|
+
const firstID = slot.inputIdSeq[first];
|
|
29527
|
+
const seq = firstID === undefined ? undefined : reader.sequenceForId(sessionID, firstID);
|
|
29528
|
+
const floor = record.replay.floor.after;
|
|
29529
|
+
if (seq === undefined || seq <= floor)
|
|
29530
|
+
return;
|
|
29531
|
+
const retired = instructionRetirement(record.replay);
|
|
29532
|
+
const between = reader.instructionRowsThrough(sessionID, seq - 1).filter((row) => row.seq > floor && !retired(row)).length;
|
|
29533
|
+
if (first === between)
|
|
29534
|
+
return false;
|
|
29535
|
+
return first > between ? true : undefined;
|
|
29536
|
+
}
|
|
29537
|
+
commitPassLeftOut(sessionID) {
|
|
29538
|
+
const value = this.passLeftOut.get(sessionID);
|
|
29539
|
+
this.passLeftOut.delete(sessionID);
|
|
29540
|
+
return !value || recordInstructionsLeftOut(this.storage.db, sessionID, value);
|
|
29541
|
+
}
|
|
29542
|
+
cancelPassLeftOut(sessionID) {
|
|
29543
|
+
this.passLeftOut.delete(sessionID);
|
|
29544
|
+
this.passRecords.delete(sessionID);
|
|
29545
|
+
}
|
|
29546
|
+
async passRecord(sessionID, reader) {
|
|
29547
|
+
const seen = this.passRecords.get(sessionID);
|
|
29548
|
+
if (seen?.reader === reader)
|
|
29549
|
+
return seen.record;
|
|
29550
|
+
const record = await this.readV3(sessionID);
|
|
29551
|
+
this.passRecords.set(sessionID, { reader, record });
|
|
29552
|
+
return record;
|
|
29553
|
+
}
|
|
29554
|
+
rememberLegacyLeftOut(sessionID, previous, reader) {
|
|
29555
|
+
if (!previous || previous.proof.sourceDigest !== foldDigest(reader.hostIdentity()))
|
|
29556
|
+
return true;
|
|
29557
|
+
if (instructionsLeftOut(this.storage.db, sessionID))
|
|
29558
|
+
return true;
|
|
29559
|
+
const leftOut = this.passLeftOut.get(sessionID) ?? legacyLeftOut(previous)?.[this.legacyPath(sessionID, previous, reader.latestCompaction(sessionID), reader)];
|
|
29560
|
+
if (!leftOut)
|
|
29561
|
+
return true;
|
|
29562
|
+
try {
|
|
29563
|
+
return recordInstructionsLeftOut(this.storage.db, sessionID, leftOut);
|
|
29564
|
+
} catch {
|
|
29565
|
+
return false;
|
|
29566
|
+
}
|
|
29567
|
+
}
|
|
29362
29568
|
async prepareManualFold(sessionID, reader, boundaryID, summary) {
|
|
29363
29569
|
const running = reader.latestRunningCompaction(sessionID);
|
|
29364
29570
|
if (!running || this.options.protocol !== 3)
|
|
@@ -29382,10 +29588,11 @@ class NativeFoldReplay {
|
|
|
29382
29588
|
if (instruction.seq > floor.after && (liveRetired.has(instruction.id) || superseded.has(instruction.id) || text.length > 0 && summary.includes(text)))
|
|
29383
29589
|
retiredInstructionIDs.push(instruction.id);
|
|
29384
29590
|
}
|
|
29591
|
+
const retiredThrough = this.options.deferCoveredInstructionRetirement?.() ? previous?.retiredInstructionThrough : floor.after;
|
|
29385
29592
|
return {
|
|
29386
29593
|
floor,
|
|
29387
29594
|
controls: previous?.controls ?? [],
|
|
29388
|
-
...
|
|
29595
|
+
...retiredThrough !== undefined && retiredThrough >= 0 ? { retiredInstructionThrough: retiredThrough } : {},
|
|
29389
29596
|
retiredInstructionIDs
|
|
29390
29597
|
};
|
|
29391
29598
|
}
|
|
@@ -29708,6 +29915,7 @@ ${cached}
|
|
|
29708
29915
|
}
|
|
29709
29916
|
};
|
|
29710
29917
|
const payload = encodeAdmissionV3(value);
|
|
29918
|
+
this.passRecords.delete(sessionID);
|
|
29711
29919
|
await admissions.set(this.admissionKey(sessionID), {
|
|
29712
29920
|
payload,
|
|
29713
29921
|
digest: foldDigest(payload)
|
|
@@ -29746,6 +29954,7 @@ ${cached}
|
|
|
29746
29954
|
return;
|
|
29747
29955
|
value.replay.withoutRecentContext = true;
|
|
29748
29956
|
const payload = encodeAdmissionV3(value);
|
|
29957
|
+
this.passRecords.delete(sessionID);
|
|
29749
29958
|
if (!pending)
|
|
29750
29959
|
await admissions.set(this.admissionKey(sessionID), {
|
|
29751
29960
|
payload,
|
|
@@ -29767,7 +29976,7 @@ ${cached}
|
|
|
29767
29976
|
}
|
|
29768
29977
|
async admits(sessionID, cut, reader) {
|
|
29769
29978
|
if (this.options.protocol === 3) {
|
|
29770
|
-
const saved = await this.
|
|
29979
|
+
const saved = await this.passRecord(sessionID, reader);
|
|
29771
29980
|
if (!saved || !isLocalCheckpoint(cut) || cut.session_id !== sessionID)
|
|
29772
29981
|
return false;
|
|
29773
29982
|
const proof = saved.proof;
|
|
@@ -29826,6 +30035,7 @@ ${cached}
|
|
|
29826
30035
|
if (snapshot.historyDigest !== historyDigest(reader, sessionID, cut.seq - 1)) {
|
|
29827
30036
|
this.staleHeads.add(sessionID);
|
|
29828
30037
|
this.invalidate(sessionID);
|
|
30038
|
+
this.passRecords.delete(sessionID);
|
|
29829
30039
|
await this.removeAdmission(this.admissionKey(sessionID));
|
|
29830
30040
|
return false;
|
|
29831
30041
|
}
|
|
@@ -29868,6 +30078,7 @@ ${cached}
|
|
|
29868
30078
|
}
|
|
29869
30079
|
};
|
|
29870
30080
|
const payload = encodeAdmissionV3(value);
|
|
30081
|
+
this.passRecords.delete(sessionID);
|
|
29871
30082
|
await admissions.set(this.admissionKey(sessionID), {
|
|
29872
30083
|
payload,
|
|
29873
30084
|
digest: foldDigest(payload)
|
|
@@ -29883,7 +30094,7 @@ ${cached}
|
|
|
29883
30094
|
}
|
|
29884
30095
|
async replayAdmission(sessionID, cut, reader) {
|
|
29885
30096
|
if (this.options.protocol === 3) {
|
|
29886
|
-
const saved = await this.
|
|
30097
|
+
const saved = await this.passRecord(sessionID, reader);
|
|
29887
30098
|
if (!saved)
|
|
29888
30099
|
return "legacy";
|
|
29889
30100
|
if (saved.proof.admissionID !== cut.id)
|
|
@@ -30162,10 +30373,12 @@ ${cached}
|
|
|
30162
30373
|
this.reportOnce(draft.sessionID, this.reportedForeignRefreshes, "v3 host fold: admission refresh skipped: admission belongs to a different host database file");
|
|
30163
30374
|
return;
|
|
30164
30375
|
}
|
|
30376
|
+
const coveredThrough = Math.min(replay.floor.after, cut.seq - 1);
|
|
30165
30377
|
const value = {
|
|
30166
30378
|
...saved,
|
|
30167
30379
|
replay: {
|
|
30168
30380
|
...replay,
|
|
30381
|
+
...this.options.deferCoveredInstructionRetirement?.() && coveredThrough >= 0 ? { reclaimCoveredInstructionsThrough: coveredThrough } : {},
|
|
30169
30382
|
controls: controlsThrough(replay.controls, reader, draft.sessionID, cut.seq - 1)
|
|
30170
30383
|
},
|
|
30171
30384
|
proof: {
|
|
@@ -30174,6 +30387,11 @@ ${cached}
|
|
|
30174
30387
|
}
|
|
30175
30388
|
};
|
|
30176
30389
|
const payload = encodeAdmissionV3(value);
|
|
30390
|
+
if (!this.rememberLegacyLeftOut(draft.sessionID, saved, reader)) {
|
|
30391
|
+
this.report(draft.sessionID, "admission refresh skipped: the instruction rows an older checkpoint record left out could not be recorded");
|
|
30392
|
+
return;
|
|
30393
|
+
}
|
|
30394
|
+
this.passRecords.delete(draft.sessionID);
|
|
30177
30395
|
await this.admissions?.set(this.admissionKey(draft.sessionID), {
|
|
30178
30396
|
payload,
|
|
30179
30397
|
digest: foldDigest(payload)
|
|
@@ -30217,6 +30435,12 @@ ${cached}
|
|
|
30217
30435
|
this.report(draft.sessionID, "fold refused: no usable host checkpoint boundary");
|
|
30218
30436
|
return false;
|
|
30219
30437
|
}
|
|
30438
|
+
if (this.options.deferCoveredInstructionRetirement?.() && replay.floor.after >= 0) {
|
|
30439
|
+
replay = {
|
|
30440
|
+
...replay,
|
|
30441
|
+
reclaimCoveredInstructionsThrough: Math.min(replay.floor.after, running.seq - 1)
|
|
30442
|
+
};
|
|
30443
|
+
}
|
|
30220
30444
|
const liveRetired = retiredLiveInstructionIDs(this.storage.db, draft.sessionID);
|
|
30221
30445
|
const absentRetired = liveRetired.size === 0 ? [] : reader.instructionRowsThrough(draft.sessionID, reader.latestSequence(draft.sessionID)).filter((row) => liveRetired.has(row.id) && !draft.messages.some((message) => nativeRowID(message) === row.id || message.role === "system" && !nativeRowID(message) && message.content.map((part) => part.text ?? "").join("") === row.data.text)).map((row) => row.id);
|
|
30222
30446
|
if (absentRetired.length > 0)
|
|
@@ -30226,6 +30450,10 @@ ${cached}
|
|
|
30226
30450
|
...new Set([...replay.retiredInstructionIDs ?? [], ...absentRetired])
|
|
30227
30451
|
]
|
|
30228
30452
|
};
|
|
30453
|
+
if (!this.rememberLegacyLeftOut(draft.sessionID, await this.readV3(draft.sessionID), reader)) {
|
|
30454
|
+
this.report(draft.sessionID, "fold refused: the instruction rows an older checkpoint record left out could not be recorded");
|
|
30455
|
+
return false;
|
|
30456
|
+
}
|
|
30229
30457
|
const model = `${draft.model.providerID}/${draft.model.id}`;
|
|
30230
30458
|
if (!args.manual && this.tail(draft.sessionID)?.model !== model)
|
|
30231
30459
|
this.storage.replaceRows(draft.sessionID, reader.latestSequence(draft.sessionID), []);
|
|
@@ -30265,6 +30493,7 @@ ${cached}
|
|
|
30265
30493
|
};
|
|
30266
30494
|
const capturedPayload = JSON.stringify(capture);
|
|
30267
30495
|
let written = 0;
|
|
30496
|
+
this.passRecords.delete(draft.sessionID);
|
|
30268
30497
|
try {
|
|
30269
30498
|
for (const [index, key] of keys.entries()) {
|
|
30270
30499
|
const data = index === 0 ? capturedPayload : payload;
|
|
@@ -30301,6 +30530,7 @@ ${cached}
|
|
|
30301
30530
|
}));
|
|
30302
30531
|
return true;
|
|
30303
30532
|
}
|
|
30533
|
+
this.passRecords.delete(draft.sessionID);
|
|
30304
30534
|
await this.admissions?.set(this.admissionKey(draft.sessionID), {
|
|
30305
30535
|
payload,
|
|
30306
30536
|
digest: foldDigest(payload)
|
|
@@ -30346,6 +30576,7 @@ ${cached}
|
|
|
30346
30576
|
historyDigest: historyDigest(reader, draft.sessionID, (running?.seq ?? through) - 1)
|
|
30347
30577
|
};
|
|
30348
30578
|
const payload = JSON.stringify(provenance);
|
|
30579
|
+
this.passRecords.delete(draft.sessionID);
|
|
30349
30580
|
await this.admissions.set(this.admissionKey(draft.sessionID), {
|
|
30350
30581
|
payload,
|
|
30351
30582
|
digest: foldDigest(payload)
|
|
@@ -30517,6 +30748,7 @@ ${cached}
|
|
|
30517
30748
|
this.dirty.delete(sessionID);
|
|
30518
30749
|
this.changed.delete(sessionID);
|
|
30519
30750
|
this.staleHeads.delete(sessionID);
|
|
30751
|
+
this.passRecords.delete(sessionID);
|
|
30520
30752
|
}
|
|
30521
30753
|
async forget(sessionID) {
|
|
30522
30754
|
if (this.stampMRU?.sessionID === sessionID)
|
|
@@ -30526,6 +30758,7 @@ ${cached}
|
|
|
30526
30758
|
this.reportedForeignRefreshes.delete(sessionID);
|
|
30527
30759
|
this.cancelLegacyUpgrade(sessionID);
|
|
30528
30760
|
this.cancelEditedAdmission(sessionID);
|
|
30761
|
+
this.cancelPassLeftOut(sessionID);
|
|
30529
30762
|
if (this.admissions)
|
|
30530
30763
|
await forgetNativeFoldProvenance(this.admissions, sessionID);
|
|
30531
30764
|
await this.storage.forget(sessionID);
|
|
@@ -58462,6 +58695,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
58462
58695
|
const nativeFoldReplay = nativeFoldMemory ? new NativeFoldReplay(nativeFoldMemory, () => openStoreReader(), context.storage, {
|
|
58463
58696
|
protocol: 3,
|
|
58464
58697
|
log: sessionLog2,
|
|
58698
|
+
deferCoveredInstructionRetirement: () => !rustModeModuleClient,
|
|
58465
58699
|
rendersHistory: (sessionID) => {
|
|
58466
58700
|
if (rustModeModuleClient)
|
|
58467
58701
|
return false;
|
|
@@ -59062,6 +59296,33 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59062
59296
|
log: sessionLog2
|
|
59063
59297
|
}) : undefined;
|
|
59064
59298
|
const hostFoldIdle = hostFolds ? new HostFoldIdle((sessionID, eligible) => hostFolds.idle(sessionID, eligible)) : undefined;
|
|
59299
|
+
const considerPublishedHostFold = (sessionID) => {
|
|
59300
|
+
if (rustModeModuleClient)
|
|
59301
|
+
return;
|
|
59302
|
+
hostFoldIdle?.published(sessionID, () => {
|
|
59303
|
+
if (!db)
|
|
59304
|
+
return false;
|
|
59305
|
+
try {
|
|
59306
|
+
const reading = loadPersistedUsage(db, sessionID);
|
|
59307
|
+
if (!reading)
|
|
59308
|
+
return false;
|
|
59309
|
+
const threshold = resolveExecuteThresholdDetail(config.execute_threshold_percentage, reading.lastObservedModelKey ?? undefined, 65, {
|
|
59310
|
+
tokensConfig: config.execute_threshold_tokens,
|
|
59311
|
+
contextLimit: reading.lastUsageContextLimit,
|
|
59312
|
+
sessionId: sessionID
|
|
59313
|
+
});
|
|
59314
|
+
return publishedHistoryCanRide({
|
|
59315
|
+
directoryResolved: sessionDirectories.has(sessionID),
|
|
59316
|
+
percentage: reading.usage.percentage,
|
|
59317
|
+
executeThreshold: threshold.percentage,
|
|
59318
|
+
publishedEnd: getLastCompartmentEndMessageId(db, sessionID),
|
|
59319
|
+
servedEnd: readSessionMeta(db, sessionID).cachedM0TrimBoundaryId ?? null
|
|
59320
|
+
});
|
|
59321
|
+
} catch {
|
|
59322
|
+
return false;
|
|
59323
|
+
}
|
|
59324
|
+
});
|
|
59325
|
+
};
|
|
59065
59326
|
cleanup.idle = () => {
|
|
59066
59327
|
messageTimesCache.clear();
|
|
59067
59328
|
recoveredInstructions.clear();
|
|
@@ -59254,6 +59515,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59254
59515
|
if (db) {
|
|
59255
59516
|
const meta = getOrCreateSessionMeta(db, sessionID);
|
|
59256
59517
|
hostFoldIdle?.idle(sessionID, meta.cacheTtl, meta.lastResponseTime);
|
|
59518
|
+
considerPublishedHostFold(sessionID);
|
|
59257
59519
|
}
|
|
59258
59520
|
}
|
|
59259
59521
|
}
|
|
@@ -59411,17 +59673,18 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59411
59673
|
const temporalTimes = config.temporal_awareness === true;
|
|
59412
59674
|
const anchorTimesOnly = !temporalTimes && !rustModeModuleClient;
|
|
59413
59675
|
const foldedInstructionIDs = new Map;
|
|
59414
|
-
const retireInstructionMessages = async (sessionID, reader, messages) => {
|
|
59415
|
-
const
|
|
59416
|
-
if (!
|
|
59676
|
+
const retireInstructionMessages = async (sessionID, reader, messages, leftOut) => {
|
|
59677
|
+
const recorded = await nativeFoldReplay?.instructionRetirement(sessionID, reader);
|
|
59678
|
+
if (!recorded)
|
|
59417
59679
|
return messages;
|
|
59418
59680
|
if (db) {
|
|
59419
|
-
foldedInstructionIDs.set(sessionID, new Set([...retiredLiveInstructionIDs(db, sessionID)].filter((id) =>
|
|
59681
|
+
foldedInstructionIDs.set(sessionID, new Set([...retiredLiveInstructionIDs(db, sessionID)].filter((id) => recorded({
|
|
59420
59682
|
type: "system",
|
|
59421
59683
|
id,
|
|
59422
59684
|
seq: reader.sequenceForId(sessionID, id) ?? Infinity
|
|
59423
59685
|
}))));
|
|
59424
59686
|
}
|
|
59687
|
+
const retired = (row) => recorded(row) || isLeftOutInstruction(leftOut, row);
|
|
59425
59688
|
return messages.filter((message) => {
|
|
59426
59689
|
const id = nativeRowID(message);
|
|
59427
59690
|
return message.role !== "system" || !id || !retired({
|
|
@@ -59484,6 +59747,17 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59484
59747
|
...args.messages.filter((message) => message !== args.incoming)
|
|
59485
59748
|
];
|
|
59486
59749
|
};
|
|
59750
|
+
const restoreAdmittedCheckpoint = async (draft, messages, incoming, restored, reader, coveredThrough) => {
|
|
59751
|
+
const merged = restoreNativeCheckpointInput(messages, incoming, restored, reader, draft.sessionID);
|
|
59752
|
+
if (coveredThrough === undefined)
|
|
59753
|
+
return merged;
|
|
59754
|
+
const present = new Set(merged.map(nativeRowID));
|
|
59755
|
+
const retired = await nativeFoldReplay?.admittedInstructionRetirement(draft.sessionID, reader);
|
|
59756
|
+
return [
|
|
59757
|
+
...coveredInstructionRows(reader, draft.sessionID, coveredThrough, draft.model, (row) => present.has(row.id) || retired?.(row) === true),
|
|
59758
|
+
...merged
|
|
59759
|
+
];
|
|
59760
|
+
};
|
|
59487
59761
|
const checkpointPassPermissions = new Map;
|
|
59488
59762
|
const checkpointInputEstimates = new Map;
|
|
59489
59763
|
const admissionRebuildPasses = new Set;
|
|
@@ -59507,7 +59781,13 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59507
59781
|
onPassPermission: (sessionID, permission) => {
|
|
59508
59782
|
checkpointPassPermissions.set(sessionID, permission);
|
|
59509
59783
|
},
|
|
59510
|
-
|
|
59784
|
+
onHistoryPublished: considerPublishedHostFold,
|
|
59785
|
+
reclaimHostRows: (sessionID, messages, permitted, covered) => {
|
|
59786
|
+
const pass = contextPass.getStore();
|
|
59787
|
+
if (pass)
|
|
59788
|
+
pass.legacyCoveredReclaimPermitted = permitted;
|
|
59789
|
+
return reclaimInstructionRows(database, sessionID, messages, permitted, foldedInstructionIDs.get(sessionID), covered, pass?.checkpointSequence, pass?.checkpointCoveredThrough);
|
|
59790
|
+
},
|
|
59511
59791
|
compactionOff,
|
|
59512
59792
|
storeGeneration: "v2",
|
|
59513
59793
|
normalizeRestoredAssistantText: (text, providerID) => stripCopiedTagNotation(text, providerID === "anthropic"),
|
|
@@ -59712,6 +59992,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59712
59992
|
if (!rustModeModuleClient) {
|
|
59713
59993
|
syntheticIDs = await readSyntheticProvenance(reader, messages);
|
|
59714
59994
|
const replayDb = db ?? storage.current();
|
|
59995
|
+
let leftOut;
|
|
59715
59996
|
if (!compactionOff && localCut && incoming && replayDb) {
|
|
59716
59997
|
const admission = nativeFoldReplay ? await nativeFoldReplay.replayAdmission(draft.sessionID, localCut, reader) : "legacy";
|
|
59717
59998
|
if (admission === undefined)
|
|
@@ -59726,7 +60007,9 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59726
60007
|
});
|
|
59727
60008
|
if (!restored)
|
|
59728
60009
|
return;
|
|
59729
|
-
|
|
60010
|
+
const legacy = await nativeFoldReplay.leftOutForPass(draft.sessionID, localCut, reader, "native");
|
|
60011
|
+
leftOut = legacy?.leftOut;
|
|
60012
|
+
messages = await restoreAdmittedCheckpoint(draft, messages, incoming, restored, reader, legacy?.restoreCoveredThrough ?? await nativeFoldReplay.coveredInstructionReclaimBoundary(draft.sessionID, localCut, reader));
|
|
59730
60013
|
} else {
|
|
59731
60014
|
messages = await restoreAfterCheckpoint({
|
|
59732
60015
|
db: replayDb,
|
|
@@ -59736,10 +60019,11 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59736
60019
|
cut: localCut,
|
|
59737
60020
|
incoming
|
|
59738
60021
|
});
|
|
60022
|
+
leftOut = (await nativeFoldReplay?.leftOutForPass(draft.sessionID, localCut, reader, "fallback"))?.leftOut;
|
|
59739
60023
|
}
|
|
59740
60024
|
} else if (localCut)
|
|
59741
60025
|
return;
|
|
59742
|
-
messages = await retireInstructionMessages(draft.sessionID, reader, messages);
|
|
60026
|
+
messages = await retireInstructionMessages(draft.sessionID, reader, messages, leftOut);
|
|
59743
60027
|
times = readTimes(reader, messages);
|
|
59744
60028
|
}
|
|
59745
60029
|
} finally {
|
|
@@ -59893,6 +60177,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59893
60177
|
let syntheticIDs;
|
|
59894
60178
|
let messageTimes;
|
|
59895
60179
|
let instructionRows = new Map;
|
|
60180
|
+
let legacyInstructions;
|
|
59896
60181
|
const reader = openStoreReader();
|
|
59897
60182
|
let checkpoint;
|
|
59898
60183
|
let submitted;
|
|
@@ -59903,6 +60188,8 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59903
60188
|
try {
|
|
59904
60189
|
syntheticIDs = await readSyntheticProvenance(reader, draft.messages);
|
|
59905
60190
|
const cut = reader.latestCompaction(draft.sessionID);
|
|
60191
|
+
if (!rustModeModuleClient)
|
|
60192
|
+
pass.checkpointSequence = cut?.seq;
|
|
59906
60193
|
if (nativeFoldReplay)
|
|
59907
60194
|
draftSourceIdentity = await nativeFoldReplay.observeSource(draft.sessionID, reader);
|
|
59908
60195
|
const boundaryRepair = !rustModeModuleClient && db && !compactionOff ? revertMessageCleanup.retireProvenHistory(db, draft.sessionID, reader) ?? checkHistoryBoundary(db, reader, draft.sessionID) : undefined;
|
|
@@ -59968,9 +60255,15 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59968
60255
|
historyRefreshSessions.add(draft.sessionID);
|
|
59969
60256
|
requestPendingMaterialization(pendingMaterializationSessions, draft.sessionID, "host_history_change");
|
|
59970
60257
|
}
|
|
60258
|
+
if (!rustModeModuleClient && cut)
|
|
60259
|
+
pass.checkpointCoveredThrough = await nativeFoldReplay?.coveredInstructionReclaimBoundary(draft.sessionID, cut, reader);
|
|
59971
60260
|
if (cut && incoming && nativeRestored) {
|
|
59972
60261
|
pass.restoredAfterSummaryId = nativeRestoredAfterSummaryId;
|
|
59973
|
-
|
|
60262
|
+
if (!rustModeModuleClient) {
|
|
60263
|
+
legacyInstructions = await nativeFoldReplay?.leftOutForPass(draft.sessionID, cut, reader, "native");
|
|
60264
|
+
pass.checkpointCoveredThrough ??= legacyInstructions?.restoreCoveredThrough;
|
|
60265
|
+
}
|
|
60266
|
+
draft.messages.splice(0, draft.messages.length, ...await restoreAdmittedCheckpoint(draft, draft.messages, incoming, nativeRestored, reader, pass.checkpointCoveredThrough));
|
|
59974
60267
|
} else if (!compactionOff && localCut && cut && incoming) {
|
|
59975
60268
|
const legacy = await folds.read(draft.sessionID);
|
|
59976
60269
|
if (legacy?.cutSeq === cut.seq && legacy.submittedSha === foldDigest(cut.data.summary ?? "")) {
|
|
@@ -60005,9 +60298,11 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60005
60298
|
restoredFirstRow = id;
|
|
60006
60299
|
}
|
|
60007
60300
|
}));
|
|
60301
|
+
if (!rustModeModuleClient)
|
|
60302
|
+
legacyInstructions = await nativeFoldReplay?.leftOutForPass(draft.sessionID, cut, reader, "fallback");
|
|
60008
60303
|
}
|
|
60009
60304
|
instructionRows = new Map(bindKeptInstructionCoordinates(draft.messages, incoming || undefined, reader, draft.sessionID).map((row) => [row.id, row]));
|
|
60010
|
-
draft.messages = await retireInstructionMessages(draft.sessionID, reader, draft.messages);
|
|
60305
|
+
draft.messages = await retireInstructionMessages(draft.sessionID, reader, draft.messages, legacyInstructions?.leftOut);
|
|
60011
60306
|
messageTimes = readTimes(reader, draft.messages);
|
|
60012
60307
|
} finally {
|
|
60013
60308
|
reader.close();
|
|
@@ -60056,6 +60351,8 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60056
60351
|
rustReplayParticipant: () => transform?.getRustReplayParticipant() ?? null
|
|
60057
60352
|
})({}, mapped);
|
|
60058
60353
|
mapped.commit();
|
|
60354
|
+
if (pass.legacyCoveredReclaimPermitted && replayHead === undefined)
|
|
60355
|
+
pass.stageLegacyRetirement = legacyInstructions?.stageRetirement;
|
|
60059
60356
|
if (replayHead === undefined && (pass.recoveredCheckpointID || previousRecovery && pass.nativeReplayCheckpointID === previousRecovery.checkpointID)) {
|
|
60060
60357
|
let coveredAfterRestore;
|
|
60061
60358
|
if (pass.recoveredCheckpointID && restoredFirstRow) {
|
|
@@ -60275,11 +60572,23 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60275
60572
|
hostFoldIdle.idle(draft.sessionID, meta.cacheTtl, meta.lastResponseTime);
|
|
60276
60573
|
}
|
|
60277
60574
|
}
|
|
60575
|
+
if (!deletedSessions.has(draft.sessionID)) {
|
|
60576
|
+
let recorded = false;
|
|
60577
|
+
try {
|
|
60578
|
+
pass.stageLegacyRetirement?.();
|
|
60579
|
+
recorded = nativeFoldReplay?.commitPassLeftOut(draft.sessionID) ?? true;
|
|
60580
|
+
} catch {
|
|
60581
|
+
recorded = false;
|
|
60582
|
+
}
|
|
60583
|
+
if (!recorded)
|
|
60584
|
+
sessionLog2(draft.sessionID, "v2 host fold: instruction rows an older checkpoint record left out were not recorded; the next pass leaves them out again");
|
|
60585
|
+
}
|
|
60278
60586
|
returned = true;
|
|
60279
60587
|
} finally {
|
|
60280
60588
|
admissionRebuildPasses.delete(draft.sessionID);
|
|
60281
60589
|
nativeFoldReplay?.cancelLegacyUpgrade(draft.sessionID);
|
|
60282
60590
|
nativeFoldReplay?.cancelEditedAdmission(draft.sessionID);
|
|
60591
|
+
nativeFoldReplay?.cancelPassLeftOut(draft.sessionID);
|
|
60283
60592
|
checkpointInputEstimates.delete(draft.sessionID);
|
|
60284
60593
|
checkpointPassPermissions.delete(draft.sessionID);
|
|
60285
60594
|
foldedInstructionIDs.delete(draft.sessionID);
|
|
@@ -60353,6 +60662,18 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60353
60662
|
compactionMarkerStrategy: v2CompactionMarkerStrategy,
|
|
60354
60663
|
prepareHistorySession,
|
|
60355
60664
|
readForkHistoryGap: (database, sessionID) => readForkHistoryGap(database, openStoreReader, sessionID),
|
|
60665
|
+
readCheckpointInstructions: (sessionID) => {
|
|
60666
|
+
try {
|
|
60667
|
+
const reader = openStoreReader();
|
|
60668
|
+
try {
|
|
60669
|
+
return reader.checkpointInstructionEstimate(sessionID);
|
|
60670
|
+
} finally {
|
|
60671
|
+
reader.close();
|
|
60672
|
+
}
|
|
60673
|
+
} catch {
|
|
60674
|
+
return;
|
|
60675
|
+
}
|
|
60676
|
+
},
|
|
60356
60677
|
readSessionDirectory: async (sessionID) => {
|
|
60357
60678
|
try {
|
|
60358
60679
|
return (await context.session.get({ sessionID })).location?.directory ?? null;
|