@cortexkit/opencode-magic-context 0.49.100 → 0.49.103
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/agents/dreamer.d.ts +3 -2
- package/dist/agents/dreamer.d.ts.map +1 -1
- package/dist/agents/permissions.d.ts +2 -0
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +3 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -1
- package/dist/auto-search-worker.js +5 -5
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-k2tdh146.js → context-jk7bgc3s.js} +227 -43
- package/dist/{embedding-backfill-79br4kk6.js → embedding-backfill-anty7zdf.js} +3 -3
- package/dist/{embedding-cache-zn4r1c31.js → embedding-cache-dveynq4m.js} +1 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +1 -0
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +7 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +2 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +5 -2
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +7 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-zyb7tndy.js → index-3nxhxeeg.js} +5 -5
- package/dist/{index-esym6cw4.js → index-42fg6tzz.js} +3 -3
- package/dist/{index-z1hc2g06.js → index-4536jdzj.js} +2 -2
- package/dist/{index-mfx7hzyc.js → index-4dywj733.js} +1 -1
- package/dist/{index-63kp05sy.js → index-4v50y0jr.js} +1 -1
- package/dist/{index-zg5r2syy.js → index-6gd9akdt.js} +1 -1
- package/dist/{index-0tqhr9zs.js → index-6t6v8prs.js} +5 -5
- package/dist/{index-0eyxarpb.js → index-7jvc0rhh.js} +100 -28
- package/dist/{index-kjhgxkdx.js → index-9jqaha1g.js} +1 -1
- package/dist/{index-634cww4x.js → index-9mxkvdtp.js} +9 -9
- package/dist/{index-3cgh0ght.js → index-f455a0g3.js} +1 -1
- package/dist/{index-6hjbeeth.js → index-jg5whyrd.js} +4 -4
- package/dist/{index-qjcye18f.js → index-jjxpmypb.js} +3 -3
- package/dist/{index-e6s2jpr8.js → index-jyj9jg9f.js} +2 -2
- package/dist/{index-ajmy0v5j.js → index-ke0mkz7g.js} +13 -0
- package/dist/{index-txthzqrm.js → index-mes48s7a.js} +152 -75
- package/dist/{index-jjy4shhy.js → index-p8nc9axh.js} +1 -1
- package/dist/{index-9emdjcb5.js → index-pw1f07vg.js} +1 -1
- package/dist/{v2/server-qjwpqvnf.js → index-qbydvfev.js} +4 -3
- package/dist/{index-rjxg7a7m.js → index-qzfz2tvk.js} +5 -1
- package/dist/{index-n3tebmah.js → index-t2h3484a.js} +8 -8
- package/dist/{index-mhdavdd4.js → index-vhx6yph7.js} +11 -8
- package/dist/{index-rakm1eay.js → index-zh683xh2.js} +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -42
- package/dist/{message-index-bounded-289186ah.js → message-index-bounded-8s8sx40x.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{project-embedding-registry-xy8dcdys.js → project-embedding-registry-4cv7n37m.js} +2 -2
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-frnwxnjg.js → read-session-chunk-wwg20mte.js} +2 -2
- package/dist/{recomp-orchestrator-e7n124g0.js → recomp-orchestrator-vg4cxyp7.js} +13 -13
- package/dist/{render-argap54x.js → render-f32trg2t.js} +7 -7
- package/dist/{search-archive-ads5mh9s.js → search-archive-yh6xtvrx.js} +5 -5
- package/dist/{search-fxtb4844.js → search-ygtyb91s.js} +11 -11
- package/dist/{storage-memory-hhrvfw0x.js → storage-memory-p91f7b5h.js} +2 -2
- package/dist/{storage-tags-2d2ba8e9.js → storage-tags-5nke1bdt.js} +1 -1
- package/dist/{store-reader-01e8t5j0.js → store-reader-c5fwa9qx.js} +1 -1
- package/dist/{store-235fjtsn.js → store-wpx314rk.js} +2 -2
- package/dist/tools/ctx-memory/constants.d.ts +2 -0
- package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts +1 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-2y0st4gk.js → transform-postprocess-phase-958fmjs5.js} +14 -14
- package/dist/v2/auto-search-worker.js +5 -5
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-v56v40cx.js → context-3g3jvxg8.js} +347 -88
- package/dist/v2/{embedding-backfill-nhgp8znm.js → embedding-backfill-ra9gbbs4.js} +3 -3
- package/dist/v2/{embedding-cache-zn4r1c31.js → embedding-cache-dveynq4m.js} +1 -1
- package/dist/v2/fold/instruction-supersession.d.ts +18 -1
- package/dist/v2/fold/instruction-supersession.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +2 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/revert-message-state.d.ts +6 -0
- package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-p69v4wpy.js → message-index-bounded-j1sxtefe.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-qz9x79kn.js → project-embedding-registry-gdaqb7h0.js} +2 -2
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-qzw3vedr.js → read-session-chunk-p6z3kmdj.js} +2 -2
- package/dist/v2/{recomp-orchestrator-5gkzamy2.js → recomp-orchestrator-29m3cc5b.js} +12 -12
- package/dist/v2/{render-atxj9eaf.js → render-jpj43axy.js} +7 -7
- package/dist/v2/{search-archive-vgwnvdx2.js → search-archive-wbhxp0p1.js} +5 -5
- package/dist/v2/{search-51qr14ed.js → search-ybyc7vmx.js} +10 -10
- package/dist/v2/{server-bhr92yb4.js → server-1qxdyz4p.js} +2 -2
- package/dist/v2/{server-8vby30m5.js → server-8f92sd2r.js} +2 -2
- package/dist/v2/{server-08jh9wew.js → server-8m5wk6aq.js} +5 -5
- package/dist/v2/{server-606mnrv4.js → server-9ms9b75c.js} +5 -1
- package/dist/v2/{server-s3m2y97h.js → server-b01a7dhj.js} +1 -1
- package/dist/v2/{server-rwdp3hw6.js → server-df5scn4q.js} +71 -11
- package/dist/v2/{server-7wpw3wc6.js → server-fagcnt6j.js} +11 -8
- package/dist/v2/{server-b25nvm9c.js → server-ga6y57vh.js} +1 -1
- package/dist/v2/{server-2ek9exbe.js → server-kx5egpt7.js} +3 -3
- package/dist/v2/{server-e14d7ebh.js → server-mc5t7k8v.js} +1 -1
- package/dist/v2/{server-9emdjcb5.js → server-pw1f07vg.js} +1 -1
- package/dist/{index-qjwpqvnf.js → v2/server-qbydvfev.js} +4 -3
- package/dist/v2/{server-c1vcbszm.js → server-qdpd8h27.js} +1 -1
- package/dist/v2/{server-ysg14rv1.js → server-qg8jyfxa.js} +13 -0
- package/dist/v2/{server-d2a639dg.js → server-r851hxn5.js} +8 -8
- package/dist/v2/{server-p2wxmjc3.js → server-t45hgcsg.js} +2 -2
- package/dist/v2/{server-awth2wsg.js → server-x22jtpna.js} +1 -1
- package/dist/v2/{server-wdmcqhv6.js → server-xpy46ddq.js} +3 -3
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-memory-hhrvfw0x.js → storage-memory-p91f7b5h.js} +2 -2
- package/dist/v2/{storage-tags-4t9fb4ch.js → storage-tags-s7nvvyg8.js} +1 -1
- package/dist/v2/{store-0kjfynwp.js → store-mba47sxn.js} +2 -2
- package/dist/v2/{store-reader-w0srb18d.js → store-reader-w7w8vfsy.js} +1 -1
- package/dist/v2/store-reader.d.ts +7 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-1wc5wb1a.js → v2-archive-reader-5njmg3a3.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-ksdn2emb.js → wrapup-orchestrator-ahkq8a61.js} +12 -12
- package/dist/{v2-archive-reader-4pk46nc1.js → v2-archive-reader-y38khjax.js} +1 -1
- package/dist/{wrapup-orchestrator-sc2fsfct.js → wrapup-orchestrator-gjqaac65.js} +14 -14
- package/package.json +1 -1
- package/src/agents/dreamer.ts +3 -2
- package/src/agents/hidden-agent-registrations.ts +2 -2
- package/src/agents/permissions.test.ts +89 -3
- package/src/agents/permissions.ts +32 -0
- package/src/agents/smart-notes-dreamer-gate.fixture.ts +27 -4
- package/src/agents/smart-notes-dreamer-gate.test.ts +5 -1
|
@@ -127,6 +127,13 @@ import {
|
|
|
127
127
|
DREAMER_CLASSIFIER_AGENT,
|
|
128
128
|
DREAMER_DOCS_AGENT,
|
|
129
129
|
DREAMER_REVIEWER_AGENT,
|
|
130
|
+
CTX_MEMORY_TOOL_NAME,
|
|
131
|
+
CTX_MEMORY_LIST_TOOL_NAME,
|
|
132
|
+
CTX_MEMORY_CURATE_TOOL_NAME,
|
|
133
|
+
DREAMER_ONLY_MEMORY_TOOL_NAMES,
|
|
134
|
+
CTX_MEMORY_LIST_DESCRIPTION,
|
|
135
|
+
CTX_MEMORY_DESCRIPTION,
|
|
136
|
+
DEFAULT_SEARCH_LIMIT,
|
|
130
137
|
keptUnderRetention,
|
|
131
138
|
roleTitle,
|
|
132
139
|
childCreateInput,
|
|
@@ -247,7 +254,7 @@ import {
|
|
|
247
254
|
startCompartmentAgent,
|
|
248
255
|
setRecompStarting2,
|
|
249
256
|
setRecompTerminal2
|
|
250
|
-
} from "./server-
|
|
257
|
+
} from "./server-df5scn4q.js";
|
|
251
258
|
import {
|
|
252
259
|
embedPauseBySession,
|
|
253
260
|
embedRunStateBySession,
|
|
@@ -438,12 +445,12 @@ import {
|
|
|
438
445
|
saveSourceContent,
|
|
439
446
|
replaceSourceContent,
|
|
440
447
|
getSourceContents
|
|
441
|
-
} from "./server-
|
|
448
|
+
} from "./server-8f92sd2r.js";
|
|
442
449
|
import {
|
|
443
450
|
cleanSearchText,
|
|
444
451
|
matchedSearchSnippet,
|
|
445
452
|
getLastIndexedOrdinal
|
|
446
|
-
} from "./server-
|
|
453
|
+
} from "./server-qdpd8h27.js";
|
|
447
454
|
import {
|
|
448
455
|
ensureSessionMetaRow,
|
|
449
456
|
clearCachedM0M1,
|
|
@@ -707,7 +714,7 @@ import {
|
|
|
707
714
|
adoptNullOwnerToolTag2,
|
|
708
715
|
getCandidateToolOwners2,
|
|
709
716
|
pickNearestPriorOwner2
|
|
710
|
-
} from "./server-
|
|
717
|
+
} from "./server-9ms9b75c.js";
|
|
711
718
|
import {
|
|
712
719
|
BoundedSessionMap,
|
|
713
720
|
getTableColumnNames,
|
|
@@ -821,7 +828,7 @@ import {
|
|
|
821
828
|
readRawSessionMessageOrdinalById2,
|
|
822
829
|
readSessionChunk2,
|
|
823
830
|
readRawSessionSeedTail2
|
|
824
|
-
} from "./server-
|
|
831
|
+
} from "./server-x22jtpna.js";
|
|
825
832
|
import {
|
|
826
833
|
getMessageIndexEpoch,
|
|
827
834
|
isMessageIndexSearchable,
|
|
@@ -847,7 +854,7 @@ import {
|
|
|
847
854
|
resolveMemoriesByIdsForSearch2,
|
|
848
855
|
unifiedSearch2,
|
|
849
856
|
formatSearchResults2
|
|
850
|
-
} from "./server-
|
|
857
|
+
} from "./server-r851hxn5.js";
|
|
851
858
|
import {
|
|
852
859
|
startBootDeadline,
|
|
853
860
|
getUnconfirmedMigrationHolders,
|
|
@@ -863,7 +870,7 @@ import {
|
|
|
863
870
|
openDatabaseAsync,
|
|
864
871
|
isDatabasePersisted,
|
|
865
872
|
getDatabasePersistenceError
|
|
866
|
-
} from "./server-
|
|
873
|
+
} from "./server-ga6y57vh.js";
|
|
867
874
|
import {
|
|
868
875
|
V2_MEMORY_CATEGORIES,
|
|
869
876
|
CATEGORY_PRIORITY
|
|
@@ -882,7 +889,7 @@ import {
|
|
|
882
889
|
RAW_MESSAGE_TYPES2,
|
|
883
890
|
V2StoreReaderPool2,
|
|
884
891
|
V2StoreReader2
|
|
885
|
-
} from "./server-
|
|
892
|
+
} from "./server-qg8jyfxa.js";
|
|
886
893
|
import {
|
|
887
894
|
configureContextDatabasePragmas2
|
|
888
895
|
} from "./server-fb3zxn06.js";
|
|
@@ -939,13 +946,12 @@ import {
|
|
|
939
946
|
embedTextForProject2,
|
|
940
947
|
embedBatchForProject2,
|
|
941
948
|
countUnembeddedMemoriesForProject2,
|
|
942
|
-
embedUnembeddedMemoriesForProject2,
|
|
943
949
|
embedUnembeddedMemoriesForProjectOutcome2,
|
|
944
950
|
drainCommitBacklogForProject2,
|
|
945
951
|
embedSessionCompartmentChunks2,
|
|
946
952
|
getEmbeddingCoverageStatus2,
|
|
947
953
|
getAutoEmbeddingSessionCoverage2
|
|
948
|
-
} from "./server-
|
|
954
|
+
} from "./server-fagcnt6j.js";
|
|
949
955
|
import {
|
|
950
956
|
GIT_SWEEP_LEASE_RENEWAL_MS,
|
|
951
957
|
acquireGitSweepLease,
|
|
@@ -960,7 +966,7 @@ import {
|
|
|
960
966
|
saveEmbeddingIfHashMatches,
|
|
961
967
|
invalidateProject2,
|
|
962
968
|
invalidateMemory2
|
|
963
|
-
} from "./server-
|
|
969
|
+
} from "./server-qbydvfev.js";
|
|
964
970
|
import {
|
|
965
971
|
getCachedLocalEmbeddingPooling,
|
|
966
972
|
preflightLocalEmbeddingPooling,
|
|
@@ -985,8 +991,8 @@ import {
|
|
|
985
991
|
readGitFileChangeTimesSince,
|
|
986
992
|
verificationFileExists,
|
|
987
993
|
normalizeVerificationFiles
|
|
988
|
-
} from "./server-
|
|
989
|
-
import"./server-
|
|
994
|
+
} from "./server-kx5egpt7.js";
|
|
995
|
+
import"./server-1qxdyz4p.js";
|
|
990
996
|
import {
|
|
991
997
|
computeCueContentHash,
|
|
992
998
|
hasMuralCueColumns,
|
|
@@ -1013,7 +1019,7 @@ import {
|
|
|
1013
1019
|
archiveMemory2,
|
|
1014
1020
|
getMemoryCount2,
|
|
1015
1021
|
getMemoryCountsByStatus2
|
|
1016
|
-
} from "./server-
|
|
1022
|
+
} from "./server-pw1f07vg.js";
|
|
1017
1023
|
import {
|
|
1018
1024
|
registerNotificationSink2,
|
|
1019
1025
|
pushLiveNotification2,
|
|
@@ -1052,7 +1058,7 @@ import {
|
|
|
1052
1058
|
readV2RawMessagePagesForConversion2,
|
|
1053
1059
|
createV2RawMessageReader2,
|
|
1054
1060
|
createV2RawMessageProvider2
|
|
1055
|
-
} from "./server-
|
|
1061
|
+
} from "./server-mc5t7k8v.js";
|
|
1056
1062
|
import {
|
|
1057
1063
|
resolvePromptContext2
|
|
1058
1064
|
} from "./server-fmsr7v69.js";
|
|
@@ -1060,15 +1066,15 @@ import {
|
|
|
1060
1066
|
renderMessageByOrdinal2,
|
|
1061
1067
|
renderVerboseRangeForTool2,
|
|
1062
1068
|
renderItemByTag2
|
|
1063
|
-
} from "./server-
|
|
1064
|
-
import"./server-
|
|
1069
|
+
} from "./server-t45hgcsg.js";
|
|
1070
|
+
import"./server-b01a7dhj.js";
|
|
1065
1071
|
import {
|
|
1066
1072
|
readV2ArchiveOffThread2
|
|
1067
|
-
} from "./server-
|
|
1073
|
+
} from "./server-8m5wk6aq.js";
|
|
1068
1074
|
import {
|
|
1069
1075
|
unresolvedLiveTailRefusal2,
|
|
1070
1076
|
renderSearchArchiveOffThread2
|
|
1071
|
-
} from "./server-
|
|
1077
|
+
} from "./server-xpy46ddq.js";
|
|
1072
1078
|
import {
|
|
1073
1079
|
markHostInstructionRow,
|
|
1074
1080
|
hostInstructionRow,
|
|
@@ -23272,6 +23278,7 @@ ${notice}`, notificationParams));
|
|
|
23272
23278
|
}
|
|
23273
23279
|
}
|
|
23274
23280
|
reclaim?.markRetired();
|
|
23281
|
+
reclaim?.settle?.();
|
|
23275
23282
|
const signedThinkingServed = isPrefixBoundThinkingModel(modelForBudget?.providerID, modelForBudget?.modelID) && servesThinkingBlock(messages, modelForBudget?.providerID, modelForBudget?.modelID);
|
|
23276
23283
|
finishSystemDateRefresh(deps.historyRefreshSessions, dateRequest, postTransformResult.bustedThisPass && !activeThinkingPrefixHold && !signedThinkingServed || postTransformResult.thinkingReleasedForFit === true, signedThinkingServed);
|
|
23277
23284
|
if (activeThinkingPrefixHold && !postTransformResult.thinkingReleasedForFit && sessionMeta.cachedM0Bytes != null && sessionMeta.cachedM1Bytes != null) {
|
|
@@ -26911,7 +26918,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
26911
26918
|
const db = readDatabase();
|
|
26912
26919
|
if (!db)
|
|
26913
26920
|
return { ok: false, error: "db unavailable" };
|
|
26914
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
26921
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-29m3cc5b.js"));
|
|
26915
26922
|
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-vtnk598k.js"));
|
|
26916
26923
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
26917
26924
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
@@ -26996,7 +27003,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
26996
27003
|
const db = readDatabase();
|
|
26997
27004
|
if (!db)
|
|
26998
27005
|
return { ok: false, error: "db unavailable" };
|
|
26999
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
27006
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-ahkq8a61.js"));
|
|
27000
27007
|
const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
|
|
27001
27008
|
const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
|
|
27002
27009
|
if (!window)
|
|
@@ -27074,7 +27081,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
27074
27081
|
}
|
|
27075
27082
|
|
|
27076
27083
|
// src/plugin/subagent-tool-policy.ts
|
|
27077
|
-
var PRIMARY_ONLY_TOOLS = new Set(["ctx_memory", "ctx_note"]);
|
|
27084
|
+
var PRIMARY_ONLY_TOOLS = new Set(["ctx_memory", "ctx_note", CTX_MEMORY_CURATE_TOOL_NAME]);
|
|
27078
27085
|
function subagentToolRefusal(db, toolId, sessionId, isInternalChild = () => false) {
|
|
27079
27086
|
if (PRIMARY_ONLY_TOOLS.has(toolId) && !isInternalChild(sessionId) && getOrCreateSessionMeta(db, sessionId).isSubagent) {
|
|
27080
27087
|
return `Error: ${toolId} is unavailable in subagent sessions. Use the primary session instead.`;
|
|
@@ -28278,6 +28285,82 @@ var coveredOn = (value) => typeof value === "object" && value !== null && value.
|
|
|
28278
28285
|
function retiredLiveInstructionIDs(db, sessionID) {
|
|
28279
28286
|
return decode(readReplayEnvelope(db, sessionID)[namespace]);
|
|
28280
28287
|
}
|
|
28288
|
+
var throughNamespace = "instructionSupersessionThrough";
|
|
28289
|
+
function decodeThrough(value, sessionID) {
|
|
28290
|
+
if (value === undefined)
|
|
28291
|
+
return { kind: "absent" };
|
|
28292
|
+
const { session, through } = value ?? {};
|
|
28293
|
+
if (typeof session !== "string" || session.length === 0 || typeof through !== "number" || !Number.isSafeInteger(through) || through < -1)
|
|
28294
|
+
throw new Error("Invalid instruction supersession replay state");
|
|
28295
|
+
return session === sessionID ? { kind: "own", through } : { kind: "foreign" };
|
|
28296
|
+
}
|
|
28297
|
+
var pendingLowerings = new WeakMap;
|
|
28298
|
+
function pendingLowering(db, sessionID) {
|
|
28299
|
+
return pendingLowerings.get(db)?.get(sessionID);
|
|
28300
|
+
}
|
|
28301
|
+
function setPendingLowering(db, sessionID, through) {
|
|
28302
|
+
let sessions = pendingLowerings.get(db);
|
|
28303
|
+
if (!sessions)
|
|
28304
|
+
pendingLowerings.set(db, sessions = new Map);
|
|
28305
|
+
sessions.set(sessionID, { through });
|
|
28306
|
+
}
|
|
28307
|
+
function clearPendingLowering(db, sessionID, pending) {
|
|
28308
|
+
const sessions = pendingLowerings.get(db);
|
|
28309
|
+
if (sessions?.get(sessionID) === pending)
|
|
28310
|
+
sessions.delete(sessionID);
|
|
28311
|
+
}
|
|
28312
|
+
function readThrough(db, sessionID) {
|
|
28313
|
+
const stored = decodeThrough(readReplayEnvelope(db, sessionID)[throughNamespace], sessionID);
|
|
28314
|
+
const pending = pendingLowering(db, sessionID);
|
|
28315
|
+
return stored.kind === "own" && pending && pending.through < stored.through ? { kind: "own", through: pending.through } : stored;
|
|
28316
|
+
}
|
|
28317
|
+
function isRetiredThrough(row, through) {
|
|
28318
|
+
return row.seq <= through && isMarkedInstructionUpdate(row);
|
|
28319
|
+
}
|
|
28320
|
+
var revertCounts = new WeakMap;
|
|
28321
|
+
function revertCount(db, sessionID) {
|
|
28322
|
+
return revertCounts.get(db)?.get(sessionID) ?? 0;
|
|
28323
|
+
}
|
|
28324
|
+
function lowerRetiredInstructionThrough(db, sessionID, before) {
|
|
28325
|
+
let sessions = revertCounts.get(db);
|
|
28326
|
+
if (!sessions)
|
|
28327
|
+
revertCounts.set(db, sessions = new Map);
|
|
28328
|
+
sessions.set(sessionID, revertCount(db, sessionID) + 1);
|
|
28329
|
+
return saveLowering(db, sessionID, before);
|
|
28330
|
+
}
|
|
28331
|
+
function saveLowering(db, sessionID, before) {
|
|
28332
|
+
const pending = pendingLowering(db, sessionID);
|
|
28333
|
+
const limit = Math.min(before ?? -1, pending?.through ?? Number.POSITIVE_INFINITY);
|
|
28334
|
+
let failure = "the replay document could not be written";
|
|
28335
|
+
let saved = false;
|
|
28336
|
+
try {
|
|
28337
|
+
saved = updateReplayDocument(db, sessionID, (doc) => {
|
|
28338
|
+
const current = decodeThrough(doc[throughNamespace], sessionID);
|
|
28339
|
+
if (current.kind !== "own" || current.through <= limit)
|
|
28340
|
+
return false;
|
|
28341
|
+
doc.version = 2;
|
|
28342
|
+
doc[throughNamespace] = { session: sessionID, through: limit };
|
|
28343
|
+
return true;
|
|
28344
|
+
});
|
|
28345
|
+
} catch (error) {
|
|
28346
|
+
failure = error;
|
|
28347
|
+
}
|
|
28348
|
+
if (saved) {
|
|
28349
|
+
if (pending)
|
|
28350
|
+
clearPendingLowering(db, sessionID, pending);
|
|
28351
|
+
return true;
|
|
28352
|
+
}
|
|
28353
|
+
if (pending?.through !== limit) {
|
|
28354
|
+
setPendingLowering(db, sessionID, limit);
|
|
28355
|
+
sessionLog2(sessionID, "committed revert: retired instruction rows kept lowered in memory until saved:", failure);
|
|
28356
|
+
}
|
|
28357
|
+
return false;
|
|
28358
|
+
}
|
|
28359
|
+
function retryRetiredInstructionLowering(db, sessionID) {
|
|
28360
|
+
const pending = pendingLowering(db, sessionID);
|
|
28361
|
+
if (pending)
|
|
28362
|
+
saveLowering(db, sessionID, pending.through);
|
|
28363
|
+
}
|
|
28281
28364
|
function coveredInstructionSupersessionOn(db, sessionID) {
|
|
28282
28365
|
return coveredOn(readReplayEnvelope(db, sessionID)[coveredNamespace]);
|
|
28283
28366
|
}
|
|
@@ -28332,7 +28415,8 @@ function isMarkedInstructionUpdate(row) {
|
|
|
28332
28415
|
const sources = metadata.instructionSources;
|
|
28333
28416
|
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);
|
|
28334
28417
|
}
|
|
28335
|
-
function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new
|
|
28418
|
+
function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new Map, covered = [], checkpointSequence, checkpointCoveredThrough, localCheckpointSequence) {
|
|
28419
|
+
const builtAfterReverts = revertCount(db, sessionID);
|
|
28336
28420
|
const instructionRows = (list) => list.flatMap((message) => {
|
|
28337
28421
|
const row = hostInstructionRow(message.info);
|
|
28338
28422
|
return row ? [{ message, row }] : [];
|
|
@@ -28340,7 +28424,19 @@ function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new
|
|
|
28340
28424
|
const coveredRows = coveredSupersessionEnabled ? instructionRows(covered) : [];
|
|
28341
28425
|
const rows = [...coveredRows, ...instructionRows(messages)];
|
|
28342
28426
|
const coveredMessages = new Set(coveredRows.map(({ message }) => message));
|
|
28343
|
-
const retired = rows.length ? retiredLiveInstructionIDs(db, sessionID) :
|
|
28427
|
+
const retired = new Set(rows.length ? retiredLiveInstructionIDs(db, sessionID) : []);
|
|
28428
|
+
let stored = { kind: "foreign" };
|
|
28429
|
+
if (rows.length)
|
|
28430
|
+
stored = readThrough(db, sessionID);
|
|
28431
|
+
else if (checkpointSequence !== undefined) {
|
|
28432
|
+
try {
|
|
28433
|
+
stored = readThrough(db, sessionID);
|
|
28434
|
+
} catch {}
|
|
28435
|
+
}
|
|
28436
|
+
const through = stored.kind === "own" ? stored.through : -1;
|
|
28437
|
+
for (const { row } of rows)
|
|
28438
|
+
if (isRetiredThrough(row, through))
|
|
28439
|
+
retired.add(row.id);
|
|
28344
28440
|
const coveredFollowed = rows.length > 0 && (coveredRows.length > 0 || permitted) && coveredInstructionSupersessionOn(db, sessionID);
|
|
28345
28441
|
const switchCovered = permitted && rows.length > 0 && !coveredFollowed && coveredSupersessionEnabled;
|
|
28346
28442
|
const selected = permitted ? supersededInstructionIDs(rows.map(({ row }) => row)) : new Set;
|
|
@@ -28353,6 +28449,13 @@ function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new
|
|
|
28353
28449
|
const newlyRetired = new Set([...selected].filter((id) => !retired.has(id)));
|
|
28354
28450
|
const omitted = new Set([...retired, ...newlyRetired]);
|
|
28355
28451
|
const omits = (message, id) => omitted.has(id) && (!coveredMessages.has(message) || coveredFollowed || switchCovered);
|
|
28452
|
+
let servedFrom = Number.POSITIVE_INFINITY;
|
|
28453
|
+
for (const { message, row } of rows) {
|
|
28454
|
+
if (isMarkedInstructionUpdate(row) && !omits(message, row.id))
|
|
28455
|
+
servedFrom = Math.min(servedFrom, row.seq);
|
|
28456
|
+
}
|
|
28457
|
+
const coverable = (seq) => Math.min(seq, servedFrom - 1);
|
|
28458
|
+
const initialThrough = stored.kind === "absent" && localCheckpointSequence !== undefined ? Math.max(-1, coverable(localCheckpointSequence - 1)) : undefined;
|
|
28356
28459
|
const edits = [];
|
|
28357
28460
|
for (const { message, row } of rows) {
|
|
28358
28461
|
if (!omits(message, row.id))
|
|
@@ -28362,33 +28465,81 @@ function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new
|
|
|
28362
28465
|
edits.push(message);
|
|
28363
28466
|
message.parts = [];
|
|
28364
28467
|
}
|
|
28468
|
+
const decisions = newlyRetired.size > 0 || switchCovered;
|
|
28469
|
+
const pending = pendingLowering(db, sessionID);
|
|
28470
|
+
let wrote;
|
|
28365
28471
|
return {
|
|
28366
28472
|
edits,
|
|
28367
|
-
hasDecisions:
|
|
28473
|
+
hasDecisions: decisions,
|
|
28368
28474
|
record(doc) {
|
|
28369
|
-
if (
|
|
28475
|
+
if (!decisions)
|
|
28370
28476
|
return false;
|
|
28371
28477
|
const current = decode(doc[namespace]);
|
|
28372
28478
|
if ([...newlyRetired].every((id) => current.has(id)) && (!switchCovered || coveredOn(doc[coveredNamespace])))
|
|
28373
28479
|
return false;
|
|
28374
|
-
|
|
28375
|
-
|
|
28480
|
+
const storedNow = decodeThrough(doc[throughNamespace], sessionID);
|
|
28481
|
+
let nextThrough = storedNow.kind === "own" ? Math.min(storedNow.through, pending?.through ?? Number.POSITIVE_INFINITY) : undefined;
|
|
28482
|
+
let dropped = -1;
|
|
28483
|
+
if (revertCount(db, sessionID) === builtAfterReverts) {
|
|
28484
|
+
for (const [id, seq] of folded) {
|
|
28485
|
+
if (current.delete(id) && Number.isFinite(seq))
|
|
28486
|
+
dropped = Math.max(dropped, seq);
|
|
28487
|
+
}
|
|
28488
|
+
}
|
|
28376
28489
|
for (const id of newlyRetired)
|
|
28377
28490
|
current.add(id);
|
|
28491
|
+
if (coverable(dropped) >= 0)
|
|
28492
|
+
nextThrough = Math.max(nextThrough ?? -1, coverable(dropped));
|
|
28378
28493
|
doc.version = 2;
|
|
28379
28494
|
doc[namespace] = [...current];
|
|
28380
28495
|
if (switchCovered)
|
|
28381
28496
|
doc[coveredNamespace] = { on: true };
|
|
28497
|
+
wrote = undefined;
|
|
28498
|
+
if (nextThrough !== undefined && (storedNow.kind !== "own" || nextThrough !== storedNow.through)) {
|
|
28499
|
+
doc[throughNamespace] = { session: sessionID, through: nextThrough };
|
|
28500
|
+
wrote = nextThrough;
|
|
28501
|
+
}
|
|
28382
28502
|
return true;
|
|
28383
28503
|
},
|
|
28384
28504
|
markRetired() {
|
|
28505
|
+
if (pending && wrote !== undefined)
|
|
28506
|
+
clearPendingLowering(db, sessionID, pending);
|
|
28385
28507
|
for (const { message, row } of rows) {
|
|
28386
28508
|
if (omits(message, row.id))
|
|
28387
28509
|
markRetiredInstructionRow(message.info);
|
|
28388
28510
|
}
|
|
28511
|
+
},
|
|
28512
|
+
settle() {
|
|
28513
|
+
if (initialThrough === undefined || revertCount(db, sessionID) !== builtAfterReverts)
|
|
28514
|
+
return;
|
|
28515
|
+
const initial = initialThrough;
|
|
28516
|
+
let failure = "the replay document could not be written";
|
|
28517
|
+
try {
|
|
28518
|
+
const saved = updateReplayDocument(db, sessionID, (doc) => {
|
|
28519
|
+
const now = decodeThrough(doc[throughNamespace], sessionID);
|
|
28520
|
+
const raisable = now.kind === "absent" || now.kind === "own" && wrote !== undefined && now.through === wrote && wrote < initial;
|
|
28521
|
+
if (!raisable)
|
|
28522
|
+
return false;
|
|
28523
|
+
doc.version = 2;
|
|
28524
|
+
doc[throughNamespace] = { session: sessionID, through: initial };
|
|
28525
|
+
return true;
|
|
28526
|
+
});
|
|
28527
|
+
if (saved)
|
|
28528
|
+
return;
|
|
28529
|
+
} catch (error) {
|
|
28530
|
+
failure = error;
|
|
28531
|
+
}
|
|
28532
|
+
let logged = initialFailuresLogged.get(db);
|
|
28533
|
+
if (!logged)
|
|
28534
|
+
initialFailuresLogged.set(db, logged = new Set);
|
|
28535
|
+
if (logged.has(sessionID))
|
|
28536
|
+
return;
|
|
28537
|
+
logged.add(sessionID);
|
|
28538
|
+
sessionLog2(sessionID, "retired instruction rows: value from the checkpoint not saved; a later pass tries again:", failure);
|
|
28389
28539
|
}
|
|
28390
28540
|
};
|
|
28391
28541
|
}
|
|
28542
|
+
var initialFailuresLogged = new WeakMap;
|
|
28392
28543
|
|
|
28393
28544
|
// src/v2/fold/manual-baseline.ts
|
|
28394
28545
|
var text = (value) => value == null ? null : typeof value === "string" ? value : Buffer.from(value).toString("utf8");
|
|
@@ -34163,14 +34314,16 @@ Project memory uses exactly 5 categories. Every memory belongs to one:
|
|
|
34163
34314
|
- **NAMING** — naming conventions and canonical names. Not inventories.
|
|
34164
34315
|
|
|
34165
34316
|
**Legacy categories during transition:** older memories may still carry pre-v2 category names. When you touch one, map it to its 5-category home with \`action="update"\` (or \`merge\`): WORKFLOW_RULES→PROJECT_RULES, ARCHITECTURE_DECISIONS→ARCHITECTURE, CONFIG_DEFAULTS→CONFIG_VALUES, ENVIRONMENT→CONFIG_VALUES (paths) or CONSTRAINTS, KNOWN_ISSUES→CONSTRAINTS only if it's an external-system limit. USER_DIRECTIVES / USER_PREFERENCES are NOT project categories. Do not compare project memories with the global user profile or use it to justify an archive.`;
|
|
34166
|
-
|
|
34317
|
+
function buildCurateSystemPrompt(memoryTool) {
|
|
34318
|
+
const example = (args) => memoryTool === CTX_MEMORY_TOOL_NAME ? args : `${memoryTool}(${args})`;
|
|
34319
|
+
return `You are a memory-pool curator for the magic-context system. You run during a scheduled dream window to keep a project's cross-session memory store lean and well-formed.
|
|
34167
34320
|
|
|
34168
34321
|
## Memory operations
|
|
34169
34322
|
- The scoped category snapshot arrives in the first message. Do not list or get it again; track mutation deltas.
|
|
34170
|
-
-
|
|
34171
|
-
-
|
|
34172
|
-
-
|
|
34173
|
-
-
|
|
34323
|
+
- \`${example('action="merge", ids=[N,M,...], content="...", category="..."')}\` — consolidate duplicates into one canonical memory
|
|
34324
|
+
- \`${example('action="update", ids=[N], content="...", superseded_by=M')}\` — rewrite content; name where removed detail survives when cutting more than half
|
|
34325
|
+
- \`${example('action="write", category="...", content="..."')}\` — create a memory (SPLITS ONLY — never mint new facts)
|
|
34326
|
+
- \`${example('action="archive", ids=[N], superseded_by=M, reason="..."')}\` — consolidate a redundant memory into the named active same-category survivor
|
|
34174
34327
|
|
|
34175
34328
|
## Rules
|
|
34176
34329
|
1. **Assume the pool is accurate.** A separate verify task checks memories against code. You handle QUALITY only — duplicates, wording, low-value entries — never correctness, and you do NOT read the codebase.
|
|
@@ -34181,6 +34334,8 @@ var CURATE_SYSTEM_PROMPT = `You are a memory-pool curator for the magic-context
|
|
|
34181
34334
|
6. **Never mint new facts** — that is the historian's job. \`write\` is for splitting a compound memory only.
|
|
34182
34335
|
|
|
34183
34336
|
${PROJECT_MEMORY_TAXONOMY}`;
|
|
34337
|
+
}
|
|
34338
|
+
var CURATE_SYSTEM_PROMPT = buildCurateSystemPrompt(CTX_MEMORY_CURATE_TOOL_NAME);
|
|
34184
34339
|
var MAINTAIN_DOCS_SYSTEM_PROMPT = `You are a read-only documentation investigator for the magic-context system. Use read, grep, glob and navigation tools to verify source. Never edit any file or run commands. Return only a proposed change to the project's ARCHITECTURE.md and STRUCTURE.md, not a change log. The protected regions between <!-- mc:protected START ... --> and <!-- mc:protected END --> must remain byte-identical. If the docs are accurate, return [].`;
|
|
34185
34340
|
var REVIEW_USER_MEMORIES_SYSTEM_PROMPT = `You are a user-profile reviewer for the magic-context system. You run during a scheduled dream window to decide which recurring behavioral observations about the human user are real, persistent patterns worth keeping in their global user profile.
|
|
34186
34341
|
|
|
@@ -34215,7 +34370,7 @@ The memories below are assumed ACCURATE (a separate verify task keeps them true)
|
|
|
34215
34370
|
Work ALL THREE phases below in order (A → B → C) over this category. Do NOT stop after consolidating — a run that only merges and never improves or archives is incomplete.
|
|
34216
34371
|
|
|
34217
34372
|
### Phase A — Consolidate duplicates
|
|
34218
|
-
Group by category, then merge near-identical / superset-subset / same-fact-different-angle clusters into one canonical memory with
|
|
34373
|
+
Group by category, then merge near-identical / superset-subset / same-fact-different-angle clusters into one canonical memory with \`${args.memoryTool ?? CTX_MEMORY_CURATE_TOOL_NAME}(action="merge", ids=[...], content="...", category="...")\`. Preserve every unique detail; terse present tense; paths/keys verbatim. Every id in a merge MUST share the same category — the system rejects cross-category merges. If two similar memories sit in different categories they are NOT duplicates; do not archive either as a consolidation. One fact per memory.
|
|
34219
34374
|
|
|
34220
34375
|
### Phase B — Improve wording
|
|
34221
34376
|
Rewrite narrative/historical → operational present tense ("X uses Y because Z", not "we switched to Y"); drop session-local context and commit hashes (unless the hash is the point); add specifics where vague. A rewrite that removes more than half the content must name the active same-category memory preserving that detail with \`superseded_by\`. \`write\` is for SPLITS ONLY (update the original down to its first fact, write the second) — a healthy run is net-neutral or net-shrinking, never net-adds facts.
|
|
@@ -34344,7 +34499,8 @@ function buildDreamTaskPrompt(task, args) {
|
|
|
34344
34499
|
projectPath: args.projectPath,
|
|
34345
34500
|
category: args.curate?.category ?? "PROJECT_RULES",
|
|
34346
34501
|
memories: args.curate?.memories ?? [],
|
|
34347
|
-
crossChunkCandidates: args.curate?.crossChunkCandidates
|
|
34502
|
+
crossChunkCandidates: args.curate?.crossChunkCandidates,
|
|
34503
|
+
memoryTool: args.curate?.memoryTool
|
|
34348
34504
|
});
|
|
34349
34505
|
case "maintain-docs":
|
|
34350
34506
|
return buildMaintainDocsPrompt(args.projectPath, args.docsChangeSet ?? "", args.existingDocs ?? { architecture: false, structure: false }, args.docsBudget, args.docsCurrentTokens, args.docsContents);
|
|
@@ -35279,7 +35435,8 @@ var refusalReasons = new Set(CURATE_SAFETY_REFUSAL_REASONS);
|
|
|
35279
35435
|
function parseCurateSafetyRefusal(action, output) {
|
|
35280
35436
|
if (action !== "archive" && action !== "update")
|
|
35281
35437
|
return null;
|
|
35282
|
-
const refusal = /^Skipped (archive|update) for memory \[ID: -?\d+(?:, -?\d+)*\]: curate safety refusal \(([a-z,-]+)\); refused=[1-9]\d*\.$/.exec(output
|
|
35438
|
+
const refusal = /^Skipped (archive|update) for memory \[ID: -?\d+(?:, -?\d+)*\]: curate safety refusal \(([a-z,-]+)\); refused=[1-9]\d*\.$/.exec(output.split(`
|
|
35439
|
+
`, 1)[0] ?? "");
|
|
35283
35440
|
if (refusal?.[1] !== action || !refusal[2])
|
|
35284
35441
|
return null;
|
|
35285
35442
|
const reasons = [...new Set(refusal[2].split(","))];
|
|
@@ -35330,14 +35487,20 @@ function assessCurateMutationSafety(args) {
|
|
|
35330
35487
|
return null;
|
|
35331
35488
|
}
|
|
35332
35489
|
function recordCurateSafetyRefusal(sessionId, refusal) {
|
|
35333
|
-
const
|
|
35334
|
-
|
|
35490
|
+
const counts = refusalCountsBySession.get(sessionId) ?? { total: 0, byMemory: new Map };
|
|
35491
|
+
const forMemory = (counts.byMemory.get(refusal.memoryId) ?? 0) + 1;
|
|
35492
|
+
counts.byMemory.set(refusal.memoryId, forMemory);
|
|
35493
|
+
const count = ++counts.total;
|
|
35494
|
+
refusalCountsBySession.set(sessionId, counts);
|
|
35335
35495
|
const lengths = refusal.originalChars === undefined ? "" : ` original_chars=${refusal.originalChars} replacement_chars=${refusal.replacementChars ?? 0}`;
|
|
35336
35496
|
log2(`[dreamer] curate safety refusal: session_id=${sessionId} memory_id=${refusal.memoryId} verdict=${refusal.verdict} reason=${refusal.reason}${lengths} refused=${count}`);
|
|
35337
35497
|
return count;
|
|
35338
35498
|
}
|
|
35499
|
+
function curateSafetyRefusalsForMemory(sessionId, memoryId) {
|
|
35500
|
+
return refusalCountsBySession.get(sessionId)?.byMemory.get(memoryId) ?? 0;
|
|
35501
|
+
}
|
|
35339
35502
|
function takeCurateSafetyRefusalCount(sessionId) {
|
|
35340
|
-
const count = refusalCountsBySession.get(sessionId) ?? 0;
|
|
35503
|
+
const count = refusalCountsBySession.get(sessionId)?.total ?? 0;
|
|
35341
35504
|
refusalCountsBySession.delete(sessionId);
|
|
35342
35505
|
return count;
|
|
35343
35506
|
}
|
|
@@ -40321,7 +40484,7 @@ function inspectCurateMemoryOperations(messages) {
|
|
|
40321
40484
|
if (!isRecord(part) || part.type !== "tool")
|
|
40322
40485
|
continue;
|
|
40323
40486
|
const toolName = part.tool ?? part.name;
|
|
40324
|
-
if (toolName !==
|
|
40487
|
+
if (toolName !== CTX_MEMORY_TOOL_NAME && toolName !== CTX_MEMORY_CURATE_TOOL_NAME)
|
|
40325
40488
|
continue;
|
|
40326
40489
|
const state = isRecord(part.state) ? part.state : null;
|
|
40327
40490
|
const input = isRecord(state?.input) ? state.input : null;
|
|
@@ -41493,6 +41656,9 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
41493
41656
|
const curateChunks = curateMemories ? chunkCurateMemories(curateMemories, Math.max(4000, Math.floor(resolveRetrospectiveUsableInputTokens(config, deps) * 2))) : [];
|
|
41494
41657
|
const batches = task === "curate" ? curateChunks : [{ memories: [], crossChunkCandidates: [] }];
|
|
41495
41658
|
const curateOperations = emptyCurateMemoryOperations();
|
|
41659
|
+
const harness = getHarness2();
|
|
41660
|
+
const curateMemoryTool = harness === "pi" || harness === "omp" ? CTX_MEMORY_TOOL_NAME : CTX_MEMORY_CURATE_TOOL_NAME;
|
|
41661
|
+
const taskSystemPrompt = task === "maintain-docs" ? MAINTAIN_DOCS_SYSTEM_PROMPT : buildCurateSystemPrompt(curateMemoryTool);
|
|
41496
41662
|
let curateRefused = 0;
|
|
41497
41663
|
let run = {
|
|
41498
41664
|
output: [],
|
|
@@ -41513,7 +41679,8 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
41513
41679
|
curate: curateMemories && curateCategory ? {
|
|
41514
41680
|
category: curateCategory,
|
|
41515
41681
|
memories: batch.memories,
|
|
41516
|
-
crossChunkCandidates: batch.crossChunkCandidates
|
|
41682
|
+
crossChunkCandidates: batch.crossChunkCandidates,
|
|
41683
|
+
memoryTool: curateMemoryTool
|
|
41517
41684
|
} : undefined
|
|
41518
41685
|
});
|
|
41519
41686
|
if (deps.hiddenCompletionExecutor) {
|
|
@@ -41522,7 +41689,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
41522
41689
|
parentSessionId: parent ?? undefined,
|
|
41523
41690
|
sessionDirectory: docsDir,
|
|
41524
41691
|
agent: task === "maintain-docs" ? DREAMER_DOCS_AGENT : DREAMER_AGENT,
|
|
41525
|
-
system:
|
|
41692
|
+
system: taskSystemPrompt,
|
|
41526
41693
|
prompt: taskPrompt,
|
|
41527
41694
|
title: `magic-context-dream-${task}`,
|
|
41528
41695
|
callContext: `dreamer:${task}`,
|
|
@@ -41569,7 +41736,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
41569
41736
|
query: { directory: docsDir },
|
|
41570
41737
|
body: {
|
|
41571
41738
|
agent: task === "maintain-docs" ? DREAMER_DOCS_AGENT : DREAMER_AGENT,
|
|
41572
|
-
system: task === "maintain-docs" ?
|
|
41739
|
+
system: task === "maintain-docs" ? taskSystemPrompt : withContentLanguageDirective(taskSystemPrompt, config.language ?? deps.language),
|
|
41573
41740
|
...modelBodyField(config.model),
|
|
41574
41741
|
parts: [{ type: "text", text: taskPrompt, synthetic: true }]
|
|
41575
41742
|
}
|
|
@@ -42384,6 +42551,7 @@ function logEmptyIdentityRefusalOnce(directory) {
|
|
|
42384
42551
|
log2(`[dreamer] not registering ${directory}: it has no project identity, so no project-scoped work runs for it`);
|
|
42385
42552
|
}
|
|
42386
42553
|
var registeredProjects = new Map;
|
|
42554
|
+
var lastMemoryEmbeddingSkip = new WeakMap;
|
|
42387
42555
|
function stopDreamScheduleTimerIfIdle() {
|
|
42388
42556
|
if (registeredProjects.size !== 0)
|
|
42389
42557
|
return;
|
|
@@ -42423,6 +42591,8 @@ async function startDreamScheduleTimer(args) {
|
|
|
42423
42591
|
}
|
|
42424
42592
|
}
|
|
42425
42593
|
registeredProjects.set(args.directory, args);
|
|
42594
|
+
if (previousRegistration !== args)
|
|
42595
|
+
lastMemoryEmbeddingSkip.delete(args);
|
|
42426
42596
|
if (isNewRegistration) {
|
|
42427
42597
|
log2(`[dreamer] registered project ${args.projectIdentity} (dreaming=${dreamingEnabled} embeddings=${embeddingSweepEnabled} commits=${commitIndexingEnabled}; total=${registeredProjects.size})`);
|
|
42428
42598
|
}
|
|
@@ -42574,17 +42744,51 @@ async function runProjectMaintenance(reg, origin, db) {
|
|
|
42574
42744
|
const sampled = reg.sampleDreamRun?.();
|
|
42575
42745
|
const current = sampled ? { ...reg, ...sampled } : reg;
|
|
42576
42746
|
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true || current.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
|
|
42577
|
-
if (!projectMaintenanceEnabled)
|
|
42747
|
+
if (!projectMaintenanceEnabled) {
|
|
42748
|
+
logMemoryEmbeddingOutcome(reg, { kind: "disabled" });
|
|
42578
42749
|
return;
|
|
42750
|
+
}
|
|
42579
42751
|
await reg.ensureRegistered(reg.directory, db);
|
|
42580
42752
|
const memorySnapshot = getProjectEmbeddingSnapshot2(reg.projectIdentity);
|
|
42581
|
-
|
|
42582
|
-
|
|
42583
|
-
|
|
42584
|
-
|
|
42753
|
+
const outcome = memorySnapshot?.enabled ? await embedUnembeddedMemoriesForProjectOutcome2(db, reg.projectIdentity) : { kind: "disabled" };
|
|
42754
|
+
logMemoryEmbeddingOutcome(reg, outcome);
|
|
42755
|
+
await sweepProject(current, origin, db, current.gitCommitIndexing?.enabled === true);
|
|
42756
|
+
}
|
|
42757
|
+
function logMemoryEmbeddingOutcome(reg, outcome) {
|
|
42758
|
+
let reason;
|
|
42759
|
+
let missingCount;
|
|
42760
|
+
switch (outcome.kind) {
|
|
42761
|
+
case "done":
|
|
42762
|
+
reason = "nothing missing";
|
|
42763
|
+
break;
|
|
42764
|
+
case "disabled":
|
|
42765
|
+
reason = "embedding disabled";
|
|
42766
|
+
break;
|
|
42767
|
+
case "unavailable":
|
|
42768
|
+
reason = outcome.reason === "busy" ? "a session is busy" : "provider unavailable";
|
|
42769
|
+
missingCount = outcome.missingCount;
|
|
42770
|
+
break;
|
|
42771
|
+
case "embedded": {
|
|
42772
|
+
const { count } = outcome;
|
|
42773
|
+
if (count > 0) {
|
|
42774
|
+
lastMemoryEmbeddingSkip.delete(reg);
|
|
42775
|
+
log2(`[magic-context] proactively embedded ${count} ${count === 1 ? "memory" : "memories"} for project ${reg.projectIdentity}`);
|
|
42776
|
+
return;
|
|
42777
|
+
}
|
|
42778
|
+
reason = "no vectors saved";
|
|
42779
|
+
missingCount = outcome.missingCount;
|
|
42780
|
+
break;
|
|
42585
42781
|
}
|
|
42782
|
+
case "failed":
|
|
42783
|
+
lastMemoryEmbeddingSkip.delete(reg);
|
|
42784
|
+
return;
|
|
42586
42785
|
}
|
|
42587
|
-
|
|
42786
|
+
const missing = missingCount === undefined ? "" : ` (${missingCount} missing at check)`;
|
|
42787
|
+
const line = `[magic-context] proactive memory embedding skipped for project ${reg.projectIdentity}: ${reason}${missing}`;
|
|
42788
|
+
if (line === lastMemoryEmbeddingSkip.get(reg))
|
|
42789
|
+
return;
|
|
42790
|
+
log2(line);
|
|
42791
|
+
lastMemoryEmbeddingSkip.set(reg, line);
|
|
42588
42792
|
}
|
|
42589
42793
|
async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
42590
42794
|
if (!directoryStillExists(reg.directory)) {
|
|
@@ -43767,8 +43971,10 @@ class V2RevertMessageCleanup {
|
|
|
43767
43971
|
const reader = this.openStoreReader();
|
|
43768
43972
|
try {
|
|
43769
43973
|
const suffix = reader.revertSuffix(sessionID, cutoff, MAX_STAGED_SUFFIX_ROWS);
|
|
43770
|
-
|
|
43974
|
+
const before = suffix ? suffix.predecessor.seq : reader.sequenceBefore(sessionID, cutoff);
|
|
43975
|
+
this.staged.set(sessionID, suffix ? { cutoff, host: reader.hostIdentity(), suffix, before } : {
|
|
43771
43976
|
cutoff,
|
|
43977
|
+
before,
|
|
43772
43978
|
unavailable: "stage did not prove a bounded suffix and retained predecessor"
|
|
43773
43979
|
});
|
|
43774
43980
|
} finally {
|
|
@@ -43778,6 +43984,10 @@ class V2RevertMessageCleanup {
|
|
|
43778
43984
|
this.staged.set(sessionID, { cutoff, unavailable: "host store read failed at stage" });
|
|
43779
43985
|
}
|
|
43780
43986
|
}
|
|
43987
|
+
stagedPredecessor(sessionID, to) {
|
|
43988
|
+
const staged = this.staged.peek(sessionID);
|
|
43989
|
+
return staged && staged.cutoff === to ? staged.before : undefined;
|
|
43990
|
+
}
|
|
43781
43991
|
discardStageProof(sessionID) {
|
|
43782
43992
|
this.staged.delete(sessionID);
|
|
43783
43993
|
}
|
|
@@ -56436,23 +56646,6 @@ function createCtxExpandTools(deps) {
|
|
|
56436
56646
|
ctx_expand: createCtxExpandTool(deps)
|
|
56437
56647
|
};
|
|
56438
56648
|
}
|
|
56439
|
-
// src/tools/ctx-memory/constants.ts
|
|
56440
|
-
var CTX_MEMORY_TOOL_NAME = "ctx_memory";
|
|
56441
|
-
var CTX_MEMORY_LIST_TOOL_NAME = "ctx_memory_list";
|
|
56442
|
-
var CTX_MEMORY_LIST_DESCRIPTION = "Browse active memories, optionally filter by category.";
|
|
56443
|
-
var CTX_MEMORY_DESCRIPTION = `Durable facts about this project, shared with every agent working on it and kept for the months this work lasts.
|
|
56444
|
-
|
|
56445
|
-
Your active memories are already in <project-memory> as \`#id: fact\` lines. Write one when you learn something that must not have to be found again — a project rule, an architectural fact, a hard-won constraint, a config value, a naming convention — and especially when it cost you turns to find. One standalone fact per memory, phrased to make sense on its own. A pending intention with its evidence ("do X later, here is what we know") is ctx_note, not memory.
|
|
56446
|
-
|
|
56447
|
-
Actions:
|
|
56448
|
-
- write: new memory (content + category).
|
|
56449
|
-
- update: rewrite one memory whose fact changed (ids: [one], content; category: the current one to keep, a new one to recategorize).
|
|
56450
|
-
- archive: retire wrong or obsolete memories (ids: [one or more], optional reason).
|
|
56451
|
-
- merge: collapse duplicates into one (ids: [two or more distinct ids of memories in the same category], content).
|
|
56452
|
-
- get: fetch by id (ids: 1–20), readable in every status.
|
|
56453
|
-
The call form that works on every host sends action, content, category and ids every time: argument-dropping providers only emit required fields. For get and archive pass content="" and any valid category; for write pass ids=[].
|
|
56454
|
-
Examples: category="CONFIG_VALUES", content="OpenCode source is at ~/Work/OSS/opencode" · category="CONSTRAINTS", content="Dashboard Tauri build needs RGBA PNGs, not grayscale"`;
|
|
56455
|
-
var DEFAULT_SEARCH_LIMIT = 10;
|
|
56456
56649
|
// src/features/magic-context/memory/memory-visibility.ts
|
|
56457
56650
|
function createMemoryVisibilityPolicy(db, projectIdentity) {
|
|
56458
56651
|
const identitySet = resolveWorkspaceIdentitySet(db, projectIdentity);
|
|
@@ -56666,13 +56859,28 @@ function preflightCurateMutation(args) {
|
|
|
56666
56859
|
if (refusals.length === 0)
|
|
56667
56860
|
return { skip: null, successor };
|
|
56668
56861
|
let refused = 0;
|
|
56862
|
+
let steer = false;
|
|
56863
|
+
const leaveAlone = [];
|
|
56669
56864
|
for (const refusal of refusals) {
|
|
56670
56865
|
refused = recordCurateSafetyRefusal(args.sessionId, refusal);
|
|
56866
|
+
if (curateSafetyRefusalsForMemory(args.sessionId, refusal.memoryId) >= 3) {
|
|
56867
|
+
leaveAlone.push(refusal.memoryId);
|
|
56868
|
+
} else if (args.toolName === CTX_MEMORY_TOOL_NAME && params.superseded_by === undefined && (refusal.reason === "missing-active-same-category-successor" || refusal.reason === "content-loss")) {
|
|
56869
|
+
steer = true;
|
|
56870
|
+
}
|
|
56671
56871
|
}
|
|
56672
56872
|
const memoryIds = refusals.map((refusal) => refusal.memoryId).join(", ");
|
|
56673
56873
|
const reasons = [...new Set(refusals.map((refusal) => refusal.reason))].join(",");
|
|
56874
|
+
const guidance = [
|
|
56875
|
+
...steer ? [`Use ${CTX_MEMORY_CURATE_TOOL_NAME} to name the survivor with superseded_by.`] : [],
|
|
56876
|
+
...leaveAlone.map((id) => `Memory [ID: ${id}] is left as it is for this run. Do not try it again.`)
|
|
56877
|
+
];
|
|
56674
56878
|
return {
|
|
56675
|
-
skip:
|
|
56879
|
+
skip: [
|
|
56880
|
+
`Skipped ${params.action} for memory [ID: ${memoryIds}]: curate safety refusal (${reasons}); refused=${refused}.`,
|
|
56881
|
+
...guidance
|
|
56882
|
+
].join(`
|
|
56883
|
+
`),
|
|
56676
56884
|
successor
|
|
56677
56885
|
};
|
|
56678
56886
|
}
|
|
@@ -56716,12 +56924,16 @@ var ctxMemoryListArgsShape = {
|
|
|
56716
56924
|
category: tool.schema.enum([...V2_MEMORY_CATEGORIES]).optional().describe("Filter listed memories to this category (optional)."),
|
|
56717
56925
|
limit: tool.schema.number().optional().describe("Max results for list (default 10).")
|
|
56718
56926
|
};
|
|
56927
|
+
var ctxMemoryCurateArgsShape = {
|
|
56928
|
+
...ctxMemoryArgsShape,
|
|
56929
|
+
superseded_by: tool.schema.number().optional().describe("ID of the active memory in the same project and category that keeps the information.")
|
|
56930
|
+
};
|
|
56719
56931
|
var ctxMemoryArgsSchema = tool.schema.object({
|
|
56720
56932
|
...ctxMemoryArgsShape,
|
|
56721
|
-
superseded_by:
|
|
56933
|
+
superseded_by: ctxMemoryCurateArgsShape.superseded_by,
|
|
56722
56934
|
limit: tool.schema.number().optional()
|
|
56723
56935
|
}).passthrough();
|
|
56724
|
-
function createCtxMemoryTool(deps) {
|
|
56936
|
+
function createCtxMemoryTool(deps, toolName = CTX_MEMORY_TOOL_NAME) {
|
|
56725
56937
|
const allowedActions = getAllowedActions(deps);
|
|
56726
56938
|
return tool({
|
|
56727
56939
|
description: CTX_MEMORY_DESCRIPTION,
|
|
@@ -56770,7 +56982,8 @@ function createCtxMemoryTool(deps) {
|
|
|
56770
56982
|
const curatePreflight = toolContext.agent === DREAMER_AGENT ? preflightCurateMutation({
|
|
56771
56983
|
db: deps.db,
|
|
56772
56984
|
params: args,
|
|
56773
|
-
sessionId: toolContext.sessionID
|
|
56985
|
+
sessionId: toolContext.sessionID,
|
|
56986
|
+
toolName
|
|
56774
56987
|
}) : { skip: null, successor: null };
|
|
56775
56988
|
if (curatePreflight.skip)
|
|
56776
56989
|
return curatePreflight.skip;
|
|
@@ -57098,6 +57311,22 @@ function createCtxMemoryListTools(deps) {
|
|
|
57098
57311
|
[CTX_MEMORY_LIST_TOOL_NAME]: createCtxMemoryListTool(deps)
|
|
57099
57312
|
};
|
|
57100
57313
|
}
|
|
57314
|
+
function createDreamerMemoryTools(deps) {
|
|
57315
|
+
const memoryTool = createCtxMemoryTool(deps, CTX_MEMORY_CURATE_TOOL_NAME);
|
|
57316
|
+
return {
|
|
57317
|
+
...createCtxMemoryListTools(deps),
|
|
57318
|
+
[CTX_MEMORY_CURATE_TOOL_NAME]: tool({
|
|
57319
|
+
description: "Maintain the project memory pool during Curate.",
|
|
57320
|
+
args: ctxMemoryCurateArgsShape,
|
|
57321
|
+
async execute(args, toolContext) {
|
|
57322
|
+
if (toolContext.agent !== DREAMER_AGENT) {
|
|
57323
|
+
return `Error: ${CTX_MEMORY_CURATE_TOOL_NAME} is only available to the dreamer agent.`;
|
|
57324
|
+
}
|
|
57325
|
+
return memoryTool.execute(args, toolContext);
|
|
57326
|
+
}
|
|
57327
|
+
})
|
|
57328
|
+
};
|
|
57329
|
+
}
|
|
57101
57330
|
// src/features/magic-context/smart-notes/condition-compiler.ts
|
|
57102
57331
|
import { existsSync as existsSync9 } from "node:fs";
|
|
57103
57332
|
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
@@ -57868,14 +58097,13 @@ Keep: user messages (never stamp one for its directive), your own conversation t
|
|
|
57868
58097
|
|
|
57869
58098
|
Look at each tag before stamping it; never blanket-stamp a range like "1-50". Many small targeted stamps beat one sweep. \`drop\` accepts "3-5", "1,2,9", "1-5,8,12-15".`;
|
|
57870
58099
|
function formatCtxReduceReply(stampedCount, selfStampCount = 0) {
|
|
57871
|
-
const parts = [];
|
|
57872
58100
|
if (stampedCount > 0) {
|
|
57873
|
-
|
|
58101
|
+
return `${stampedCount} tag${stampedCount === 1 ? "" : "s"} stamped.`;
|
|
57874
58102
|
}
|
|
57875
58103
|
if (selfStampCount > 0) {
|
|
57876
|
-
|
|
58104
|
+
return "Nothing stamped: ctx_reduce calls are cleaned up automatically.";
|
|
57877
58105
|
}
|
|
57878
|
-
return
|
|
58106
|
+
return "";
|
|
57879
58107
|
}
|
|
57880
58108
|
// src/tools/ctx-reduce/tools.ts
|
|
57881
58109
|
import { createHash as createHash21 } from "node:crypto";
|
|
@@ -58296,7 +58524,7 @@ async function registerTools(context, db, config, rustToolBackends, isInternalCh
|
|
|
58296
58524
|
...project,
|
|
58297
58525
|
...rustToolBackends ? { rustToolBackends } : {}
|
|
58298
58526
|
}),
|
|
58299
|
-
...
|
|
58527
|
+
...createDreamerMemoryTools({
|
|
58300
58528
|
...project,
|
|
58301
58529
|
...rustToolBackends ? { rustToolBackends } : {}
|
|
58302
58530
|
})
|
|
@@ -58314,7 +58542,7 @@ async function registerTools(context, db, config, rustToolBackends, isInternalCh
|
|
|
58314
58542
|
const refusal = subagentToolRefusal(db, name, call.sessionID, isInternalChild);
|
|
58315
58543
|
if (refusal)
|
|
58316
58544
|
return { content: refusal };
|
|
58317
|
-
if (name === "ctx_memory" || name === "ctx_note" || name === "ctx_reduce")
|
|
58545
|
+
if (name === "ctx_memory" || name === "ctx_note" || name === "ctx_reduce" || name === CTX_MEMORY_CURATE_TOOL_NAME && call.agent === DREAMER_AGENT)
|
|
58318
58546
|
await withAsyncPrivilegedWriter2(db, () => {
|
|
58319
58547
|
return;
|
|
58320
58548
|
});
|
|
@@ -59002,9 +59230,11 @@ function catalogModels(listed, draftModel) {
|
|
|
59002
59230
|
}
|
|
59003
59231
|
return models;
|
|
59004
59232
|
}
|
|
59005
|
-
function removeDreamerOnlyTools(draft) {
|
|
59006
|
-
if (draft.tools)
|
|
59007
|
-
|
|
59233
|
+
function removeDreamerOnlyTools(draft, ids = DREAMER_ONLY_MEMORY_TOOL_NAMES) {
|
|
59234
|
+
if (!draft.tools)
|
|
59235
|
+
return;
|
|
59236
|
+
for (const id of ids)
|
|
59237
|
+
delete draft.tools[id];
|
|
59008
59238
|
}
|
|
59009
59239
|
function applyV2PromptSurfaceTools(draft, runtime, config, smartNotesEnabled = true) {
|
|
59010
59240
|
if (!draft.tools)
|
|
@@ -59848,6 +60078,27 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59848
60078
|
}
|
|
59849
60079
|
};
|
|
59850
60080
|
const usageController = new AbortController;
|
|
60081
|
+
const lowerRetiredInstructionsOnRevert = (database, sessionID, event) => {
|
|
60082
|
+
try {
|
|
60083
|
+
let before = revertMessageCleanup.stagedPredecessor(sessionID, event.data?.to);
|
|
60084
|
+
const commitSeq = event.durable?.seq;
|
|
60085
|
+
if (before === undefined && event.durable?.aggregateID === sessionID && typeof commitSeq === "number" && Number.isSafeInteger(commitSeq)) {
|
|
60086
|
+
const reader = openStoreReader();
|
|
60087
|
+
try {
|
|
60088
|
+
before = reader.highestSequenceBelow(sessionID, commitSeq);
|
|
60089
|
+
} finally {
|
|
60090
|
+
reader.close();
|
|
60091
|
+
}
|
|
60092
|
+
}
|
|
60093
|
+
if (before === undefined) {
|
|
60094
|
+
sessionLog2(sessionID, "committed revert: last kept row unknown; retired instruction rows left as they are");
|
|
60095
|
+
return;
|
|
60096
|
+
}
|
|
60097
|
+
lowerRetiredInstructionThrough(database, sessionID, before);
|
|
60098
|
+
} catch (error) {
|
|
60099
|
+
sessionLog2(sessionID, "committed revert: retired instruction rows not updated:", error);
|
|
60100
|
+
}
|
|
60101
|
+
};
|
|
59851
60102
|
cleanup.abortUsage = () => {
|
|
59852
60103
|
usageController.abort();
|
|
59853
60104
|
httpRefusalCounts.dispose();
|
|
@@ -59910,6 +60161,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
59910
60161
|
const indexDb = db;
|
|
59911
60162
|
withoutSqliteTransformPass2(() => {
|
|
59912
60163
|
scheduleClearAndReindex(indexDb, sessionID, pagedRead);
|
|
60164
|
+
lowerRetiredInstructionsOnRevert(indexDb, sessionID, event);
|
|
59913
60165
|
try {
|
|
59914
60166
|
if (revertMessageCleanup.pruneOnCommit(indexDb, sessionID, event.data?.to, !compactionOff && !rustModeModuleClient)) {
|
|
59915
60167
|
tagger.cleanup(sessionID);
|
|
@@ -60085,8 +60337,10 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60085
60337
|
draft.result = { summary: hiddenSummary, metadata: { keepID: undefined } };
|
|
60086
60338
|
return;
|
|
60087
60339
|
}
|
|
60088
|
-
if (compactionOff)
|
|
60340
|
+
if (compactionOff) {
|
|
60341
|
+
removeDreamerOnlyTools(draft, [CTX_MEMORY_CURATE_TOOL_NAME]);
|
|
60089
60342
|
return;
|
|
60343
|
+
}
|
|
60090
60344
|
if (nativeFoldReplay)
|
|
60091
60345
|
rememberHostMedia(draft.messages);
|
|
60092
60346
|
const reader = openStoreReader();
|
|
@@ -60178,11 +60432,13 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60178
60432
|
if (!recorded)
|
|
60179
60433
|
return messages;
|
|
60180
60434
|
if (db) {
|
|
60181
|
-
|
|
60182
|
-
|
|
60183
|
-
id
|
|
60184
|
-
|
|
60185
|
-
|
|
60435
|
+
const folded = new Map;
|
|
60436
|
+
for (const id of retiredLiveInstructionIDs(db, sessionID)) {
|
|
60437
|
+
const seq = reader.sequenceForId(sessionID, id) ?? Infinity;
|
|
60438
|
+
if (recorded({ type: "system", id, seq }))
|
|
60439
|
+
folded.set(id, seq);
|
|
60440
|
+
}
|
|
60441
|
+
foldedInstructionIDs.set(sessionID, folded);
|
|
60186
60442
|
}
|
|
60187
60443
|
const retired = (row) => recorded(row) || isLeftOutInstruction(leftOut, row);
|
|
60188
60444
|
return messages.filter((message) => {
|
|
@@ -60286,7 +60542,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60286
60542
|
const pass = contextPass.getStore();
|
|
60287
60543
|
if (pass)
|
|
60288
60544
|
pass.legacyCoveredReclaimPermitted = permitted;
|
|
60289
|
-
return reclaimInstructionRows(database, sessionID, messages, permitted, foldedInstructionIDs.get(sessionID), covered, pass?.checkpointSequence, pass?.checkpointCoveredThrough);
|
|
60545
|
+
return reclaimInstructionRows(database, sessionID, messages, permitted, foldedInstructionIDs.get(sessionID), covered, pass?.checkpointSequence, pass?.checkpointCoveredThrough, pass?.localCheckpointSequence);
|
|
60290
60546
|
},
|
|
60291
60547
|
compactionOff,
|
|
60292
60548
|
storeGeneration: "v2",
|
|
@@ -60678,6 +60934,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60678
60934
|
let messageTimes;
|
|
60679
60935
|
let instructionRows = new Map;
|
|
60680
60936
|
let legacyInstructions;
|
|
60937
|
+
retryRetiredInstructionLowering(db, draft.sessionID);
|
|
60681
60938
|
const reader = openStoreReader();
|
|
60682
60939
|
let checkpoint;
|
|
60683
60940
|
let submitted;
|
|
@@ -60688,8 +60945,10 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
|
|
|
60688
60945
|
try {
|
|
60689
60946
|
syntheticIDs = await readSyntheticProvenance(reader, draft.messages);
|
|
60690
60947
|
const cut = reader.latestCompaction(draft.sessionID);
|
|
60691
|
-
if (!rustModeModuleClient)
|
|
60948
|
+
if (!rustModeModuleClient) {
|
|
60692
60949
|
pass.checkpointSequence = cut?.seq;
|
|
60950
|
+
pass.localCheckpointSequence = cut && isLocalCheckpoint(cut) ? cut.seq : undefined;
|
|
60951
|
+
}
|
|
60693
60952
|
if (nativeFoldReplay)
|
|
60694
60953
|
draftSourceIdentity = await nativeFoldReplay.observeSource(draft.sessionID, reader);
|
|
60695
60954
|
const boundaryRepair = !rustModeModuleClient && db && !compactionOff ? revertMessageCleanup.retireProvenHistory(db, draft.sessionID, reader) ?? checkHistoryBoundary(db, reader, draft.sessionID) : undefined;
|