@cortexkit/opencode-magic-context 0.49.51 → 0.49.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-search-worker.js +3 -3
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-r77d4fdy.js → context-p6r0bk7a.js} +90 -51
- package/dist/{embedding-backfill-3wdjzrvs.js → embedding-backfill-qes2kf1c.js} +2 -2
- package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-session-filter.d.ts +1 -1
- package/dist/features/magic-context/message-fts-session-filter.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +8 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts +10 -3
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +20 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +1 -1
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/active-anthropic-turn.d.ts +6 -0
- package/dist/hooks/magic-context/active-anthropic-turn.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +2 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-recovery.d.ts +15 -0
- package/dist/hooks/magic-context/history-boundary-recovery.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +12 -2
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +21 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/latest-assistant-turn.d.ts +43 -0
- package/dist/hooks/magic-context/latest-assistant-turn.d.ts.map +1 -1
- package/dist/hooks/magic-context/latest-thinking-recovery.d.ts +102 -26
- package/dist/hooks/magic-context/latest-thinking-recovery.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +18 -2
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/pending-marker-rearm.d.ts +20 -0
- package/dist/hooks/magic-context/pending-marker-rearm.d.ts.map +1 -0
- package/dist/hooks/magic-context/persist-filtered-noise.d.ts +1 -1
- package/dist/hooks/magic-context/persist-filtered-noise.d.ts.map +1 -1
- package/dist/hooks/magic-context/priced-pass-sizing.d.ts +7 -0
- package/dist/hooks/magic-context/priced-pass-sizing.d.ts.map +1 -1
- package/dist/hooks/magic-context/routine-cleanup-decision.d.ts +11 -1
- package/dist/hooks/magic-context/routine-cleanup-decision.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/served-check.d.ts +127 -0
- package/dist/hooks/magic-context/served-check.d.ts.map +1 -0
- package/dist/hooks/magic-context/signed-thinking-hold.d.ts +32 -4
- package/dist/hooks/magic-context/signed-thinking-hold.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +37 -2
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +21 -2
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -1
- package/dist/{index-n0twfvah.js → index-2ctn7q09.js} +531 -17
- package/dist/{index-bamnjp2t.js → index-2m54t4g1.js} +9 -5
- package/dist/{index-30sf7e5k.js → index-3b5k5vma.js} +27 -16
- package/dist/{index-ct3ettqt.js → index-3h0wyv22.js} +3 -3
- package/dist/{index-hkveze74.js → index-3hhq18q0.js} +1 -1
- package/dist/{index-kaqs6h31.js → index-52x68mj4.js} +1 -1
- package/dist/{index-wr2t8zb0.js → index-5684dzbv.js} +648 -69
- package/dist/{index-s131svmx.js → index-7wasafnb.js} +1 -1
- package/dist/{index-8d7gkgjs.js → index-85chg6fw.js} +1 -1
- package/dist/{index-z4832qfe.js → index-a6bxwv4a.js} +1 -1
- package/dist/{index-h8g08nxs.js → index-chjsdqg6.js} +104 -62
- package/dist/{index-5dptmnvd.js → index-esm4farg.js} +8 -7
- package/dist/{index-97bjd14c.js → index-fbs0f5ch.js} +4 -4
- package/dist/{index-cwj6qhmf.js → index-kwpweqzs.js} +8 -3
- package/dist/{index-07rp6xcn.js → index-n3rxwtwt.js} +48 -15
- package/dist/{index-gv7dwx5b.js → index-p7ssfv6p.js} +503 -395
- package/dist/{index-v4a1pnny.js → index-pgbmbtdq.js} +4 -4
- package/dist/{index-mjh63zvw.js → index-wpab17w4.js} +1 -1
- package/dist/index.js +53 -32
- package/dist/{message-index-bounded-k0ebpy3y.js → message-index-bounded-7p3064st.js} +2 -2
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts +6 -0
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/{project-embedding-registry-5dwh5zfn.js → project-embedding-registry-m8t547fb.js} +3 -1
- package/dist/raw-ordinal-warmup-worker.js +3 -3
- package/dist/{read-session-chunk-6712p893.js → read-session-chunk-cyks9yx4.js} +1 -1
- package/dist/{recomp-orchestrator-8ebydg5j.js → recomp-orchestrator-d4nks9da.js} +9 -9
- package/dist/{render-dtc4qkq4.js → render-gc1fn4nz.js} +5 -5
- package/dist/{search-75bj2430.js → search-1bjy7yhc.js} +8 -8
- package/dist/{search-archive-f6hjbnsa.js → search-archive-hdrfjgv8.js} +4 -4
- package/dist/shared/test-open-files.d.ts +17 -0
- package/dist/shared/test-open-files.d.ts.map +1 -0
- package/dist/shared/user-facing-codes.d.ts +7 -2
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-1bg25094.js → transform-postprocess-phase-9e53b1dr.js} +10 -10
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-cpbhpxks.js → context-1p22880w.js} +1084 -370
- package/dist/v2/{embedding-backfill-x1zpc04f.js → embedding-backfill-bwcmw1te.js} +2 -2
- package/dist/v2/fold/instruction-supersession.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-a36rw93p.js → message-index-bounded-mjpxz7wp.js} +2 -2
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-v2fxrs8b.js → project-embedding-registry-7qcs8c61.js} +3 -1
- package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
- package/dist/v2/{read-session-chunk-hzhxvhyv.js → read-session-chunk-cxk2kssy.js} +1 -1
- package/dist/v2/{recomp-orchestrator-yzr49pd0.js → recomp-orchestrator-e560ryjm.js} +8 -8
- package/dist/v2/{render-rhaevxv1.js → render-rk17pvy0.js} +5 -5
- package/dist/v2/{search-archive-9924fyk8.js → search-archive-a51g9sp7.js} +4 -4
- package/dist/v2/{search-3yrdpr38.js → search-kvzyj2mf.js} +7 -7
- package/dist/v2/{server-scp3y4dh.js → server-28g1b00j.js} +1 -1
- package/dist/v2/{server-kaqs6h31.js → server-52x68mj4.js} +1 -1
- package/dist/v2/{server-0k586y7d.js → server-71bg2psk.js} +3 -3
- package/dist/v2/{server-3bfc26r7.js → server-77rvx3wn.js} +34 -15
- package/dist/v2/{server-jxrqsn84.js → server-ah1j996f.js} +1 -1
- package/dist/v2/{server-sgn61hht.js → server-bjsmb6zs.js} +8 -3
- package/dist/v2/{server-16kfxcxj.js → server-bzh1fkvd.js} +1 -1
- package/dist/v2/{server-vjadwb3j.js → server-d5zgah57.js} +1 -1
- package/dist/v2/{server-q93jdtz8.js → server-e37d2zt4.js} +8 -7
- package/dist/v2/{server-016a1whm.js → server-fh6dhx8c.js} +104 -62
- package/dist/v2/{server-eznem83k.js → server-jmrd7vwc.js} +26 -15
- package/dist/v2/{server-4h4acntc.js → server-k3vtc89v.js} +9 -5
- package/dist/v2/{server-88yvx6r9.js → server-zq704789.js} +531 -17
- package/dist/v2/server.js +2 -2
- package/dist/v2/{v2-archive-reader-5ggewg8q.js → v2-archive-reader-hsvddme0.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-36c5wyvq.js → wrapup-orchestrator-ckpj1yvj.js} +8 -8
- package/dist/{v2-archive-reader-gx5ke1d7.js → v2-archive-reader-qgqrxgrq.js} +1 -1
- package/dist/{wrapup-orchestrator-ya31knav.js → wrapup-orchestrator-6189f37j.js} +10 -10
- package/package.json +1 -1
- package/src/shared/escalation-bands.test.ts +16 -1
- package/src/shared/sqlite-placeholders.test.ts +103 -0
- package/src/shared/storage-file-mutex-review.test.ts +5 -7
- package/src/shared/test-open-files.test.ts +194 -0
- package/src/shared/test-open-files.ts +71 -0
- package/src/shared/user-facing-codes.ts +8 -2
|
@@ -52,8 +52,9 @@ import {
|
|
|
52
52
|
parseProcessedImageMarkers,
|
|
53
53
|
serializeProcessedImageMarkers,
|
|
54
54
|
getPendingPiCompactionMarkerState,
|
|
55
|
-
logPiCompactionMarkerClear
|
|
56
|
-
|
|
55
|
+
logPiCompactionMarkerClear,
|
|
56
|
+
isPrefixBoundThinkingModel
|
|
57
|
+
} from "./server-77rvx3wn.js";
|
|
57
58
|
import {
|
|
58
59
|
getTableColumnNames,
|
|
59
60
|
tagTombstoneOwnerRange,
|
|
@@ -442,7 +443,7 @@ function getUncoveredCompartmentEndsThrough(db, sessionId, endOrdinal = Number.M
|
|
|
442
443
|
const rows = db.prepare(`SELECT k.end_message_id, k.end_message,
|
|
443
444
|
n.start_message_id AS successor_id, n.start_message AS successor_start FROM compartments k
|
|
444
445
|
LEFT JOIN compartments n ON n.session_id = k.session_id AND n.sequence = k.sequence + 1
|
|
445
|
-
WHERE k.session_id = ?
|
|
446
|
+
WHERE k.session_id = ? AND k.end_message <= ? AND k.end_message > ? AND k.end_block_index IS NOT NULL
|
|
446
447
|
AND NOT COALESCE(n.sequence IS NOT NULL AND (
|
|
447
448
|
(n.start_message_id = k.end_message_id AND n.start_block_index > k.end_block_index)
|
|
448
449
|
OR n.start_message = k.end_message + 1), 0)
|
|
@@ -583,7 +584,7 @@ function readProjectDocsCanonical(projectDirectory) {
|
|
|
583
584
|
return { renderedBlock, canonicalHash };
|
|
584
585
|
}
|
|
585
586
|
// src/hooks/magic-context/lkg-slot.ts
|
|
586
|
-
import { createHash as
|
|
587
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
587
588
|
|
|
588
589
|
// src/hooks/magic-context/lkg-measured-request.ts
|
|
589
590
|
import { createHash as createHash4 } from "node:crypto";
|
|
@@ -2798,6 +2799,7 @@ function coldStartUncapturedReplay(args) {
|
|
|
2798
2799
|
|
|
2799
2800
|
// src/hooks/magic-context/lkg-recovery-prefix.ts
|
|
2800
2801
|
var sessions = new BoundedSessionMap(1000);
|
|
2802
|
+
var restartHeadChecked = new BoundedSessionMap(1000);
|
|
2801
2803
|
function noteUncertifiedNormalLkg(sessionId, revision) {
|
|
2802
2804
|
sessions.set(sessionId, {
|
|
2803
2805
|
...sessions.get(sessionId),
|
|
@@ -2816,6 +2818,7 @@ function rememberLkgDirtyRevision(sessionId, revision) {
|
|
|
2816
2818
|
}
|
|
2817
2819
|
function clearLkgRecoverySession(sessionId) {
|
|
2818
2820
|
sessions.delete(sessionId);
|
|
2821
|
+
restartHeadChecked.delete(sessionId);
|
|
2819
2822
|
clearLkgFenceProcessState(sessionId);
|
|
2820
2823
|
}
|
|
2821
2824
|
function noteLkgCapturedPrefix(sessionId) {
|
|
@@ -2831,13 +2834,14 @@ function readPersistedLkgUntaggedInputIds(db, sessionId) {
|
|
|
2831
2834
|
return [];
|
|
2832
2835
|
}
|
|
2833
2836
|
}
|
|
2834
|
-
function persistLkgUntaggedInputIds(db, sessionId, ids) {
|
|
2835
|
-
const next = [...new Set(ids)].sort();
|
|
2837
|
+
function persistLkgUntaggedInputIds(db, sessionId, ids, alsoRecord) {
|
|
2838
|
+
const next = ids === undefined ? undefined : [...new Set(ids)].sort();
|
|
2836
2839
|
try {
|
|
2837
2840
|
return updateReplayDocument(db, sessionId, (doc) => {
|
|
2841
|
+
const recorded = alsoRecord?.(doc) ?? false;
|
|
2838
2842
|
const saved = Array.isArray(doc.lkgUntaggedInputIds) ? doc.lkgUntaggedInputIds : [];
|
|
2839
|
-
if (JSON.stringify(saved) === JSON.stringify(next))
|
|
2840
|
-
return
|
|
2843
|
+
if (next === undefined || JSON.stringify(saved) === JSON.stringify(next))
|
|
2844
|
+
return recorded;
|
|
2841
2845
|
doc.version = 2;
|
|
2842
2846
|
if (next.length > 0)
|
|
2843
2847
|
doc.lkgUntaggedInputIds = next;
|
|
@@ -2851,10 +2855,7 @@ function persistLkgUntaggedInputIds(db, sessionId, ids) {
|
|
|
2851
2855
|
}
|
|
2852
2856
|
}
|
|
2853
2857
|
function noteLkgRecoveryPrefix(args) {
|
|
2854
|
-
const digests = [
|
|
2855
|
-
...args.entry.entryContentDigests,
|
|
2856
|
-
...args.entry.pristineTail.map(lkgContentDigest)
|
|
2857
|
-
];
|
|
2858
|
+
const digests = [...args.entry.entryContentDigests, ...args.hostTailDigests];
|
|
2858
2859
|
if (digests.length !== args.entry.entryInputIds.length || digests.some((value) => !value))
|
|
2859
2860
|
return false;
|
|
2860
2861
|
const ids = args.entry.entryInputIds;
|
|
@@ -2891,8 +2892,15 @@ function readRecoveryIdentityPrefix(sessionId, inputs, messages, db) {
|
|
|
2891
2892
|
const prefix = state?.prefix;
|
|
2892
2893
|
if (!prefix && state?.uncertifiedNormal && ownsLkgDirtyFence(sessionId, state.fenceRevision))
|
|
2893
2894
|
return {};
|
|
2894
|
-
if (!prefix)
|
|
2895
|
-
|
|
2895
|
+
if (!prefix) {
|
|
2896
|
+
let restartedSlotJson;
|
|
2897
|
+
if (!state && slot && !restartHeadChecked.has(sessionId)) {
|
|
2898
|
+
restartHeadChecked.set(sessionId, true);
|
|
2899
|
+
restartedSlotJson = slot.jsonPrefix;
|
|
2900
|
+
}
|
|
2901
|
+
const restarted = restartedSlotJson === undefined ? {} : { restartedSlotJson };
|
|
2902
|
+
return !state && lkgRecoveryFenceUnclean(sessionId) || slot && lkgFenceRequiresRebuild(sessionId, slot, !!state) ? { rebuildReason: "lkg_restart_rebuild", ...restarted } : restarted;
|
|
2903
|
+
}
|
|
2896
2904
|
const keys = resolveLkgModelKeys(messages);
|
|
2897
2905
|
if (state?.fenceRevision !== undefined && (!slot || !ownsLkgDirtyFence(sessionId, state.fenceRevision)) || prefix.modelKey !== keys.modelKey || prefix.providerKey !== keys.providerKey || inputs.length < prefix.inputs.length || prefix.inputs.some((input, index) => input.id !== inputs[index]?.id || input.digest !== inputs[index]?.contentDigest?.()))
|
|
2898
2906
|
return { rebuildReason: "lkg_recovery_input_rebuild" };
|
|
@@ -2927,6 +2935,512 @@ function lkgRecoveryEntryUnproven(sessionId, entry, messages) {
|
|
|
2927
2935
|
return !!readRecoveryIdentityPrefix(sessionId, inputs, messages).rebuildReason;
|
|
2928
2936
|
}
|
|
2929
2937
|
|
|
2938
|
+
// src/hooks/magic-context/served-check.ts
|
|
2939
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
2940
|
+
var RECORD_SESSIONS = 256;
|
|
2941
|
+
var records = new BoundedSessionMap(RECORD_SESSIONS);
|
|
2942
|
+
var pending4 = new BoundedSessionMap(1000);
|
|
2943
|
+
var counters = new BoundedSessionMap(1000);
|
|
2944
|
+
var SERVED_FULL_CHECK_INTERVAL = 100;
|
|
2945
|
+
var COUNT_LOG_INTERVAL = 100;
|
|
2946
|
+
var HEAD_MIN = 2;
|
|
2947
|
+
var HEAD_MAX = 4;
|
|
2948
|
+
var lastWork = { fingerprinted: 0, digested: 0, full: false, ms: 0, shapeMs: 0 };
|
|
2949
|
+
function emptyCounters() {
|
|
2950
|
+
return {
|
|
2951
|
+
commits: 0,
|
|
2952
|
+
compared: 0,
|
|
2953
|
+
unknown: 0,
|
|
2954
|
+
refused: 0,
|
|
2955
|
+
appendOnly: 0,
|
|
2956
|
+
changed: 0,
|
|
2957
|
+
shorter: 0,
|
|
2958
|
+
modelChanged: 0,
|
|
2959
|
+
unpermittedChange: 0,
|
|
2960
|
+
mixedReplay: 0,
|
|
2961
|
+
thinkingPrefixChange: 0,
|
|
2962
|
+
sameShapeChange: 0,
|
|
2963
|
+
fullChecks: 0
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
function countersFor(sessionId) {
|
|
2967
|
+
let value = counters.get(sessionId);
|
|
2968
|
+
if (!value) {
|
|
2969
|
+
value = emptyCounters();
|
|
2970
|
+
counters.set(sessionId, value);
|
|
2971
|
+
}
|
|
2972
|
+
return value;
|
|
2973
|
+
}
|
|
2974
|
+
function pendingFor(sessionId) {
|
|
2975
|
+
let value = pending4.get(sessionId);
|
|
2976
|
+
if (!value) {
|
|
2977
|
+
value = {};
|
|
2978
|
+
pending4.set(sessionId, value);
|
|
2979
|
+
}
|
|
2980
|
+
return value;
|
|
2981
|
+
}
|
|
2982
|
+
function beginServedRequest(sessionId) {
|
|
2983
|
+
pending4.delete(sessionId);
|
|
2984
|
+
}
|
|
2985
|
+
function noteServedPassPermission(sessionId, permission) {
|
|
2986
|
+
pendingFor(sessionId).permission = permission;
|
|
2987
|
+
}
|
|
2988
|
+
function noteServedModel(sessionId, model) {
|
|
2989
|
+
if (model)
|
|
2990
|
+
pendingFor(sessionId).model = model;
|
|
2991
|
+
}
|
|
2992
|
+
function noteServedReplay(sessionId) {
|
|
2993
|
+
pendingFor(sessionId).replay = true;
|
|
2994
|
+
}
|
|
2995
|
+
function noteServedHostInput(sessionId) {
|
|
2996
|
+
pendingFor(sessionId).input = true;
|
|
2997
|
+
}
|
|
2998
|
+
function noteServedRefusal(sessionId) {
|
|
2999
|
+
pendingFor(sessionId).refused = true;
|
|
3000
|
+
}
|
|
3001
|
+
function countServedRefusal(sessionId) {
|
|
3002
|
+
try {
|
|
3003
|
+
pending4.delete(sessionId);
|
|
3004
|
+
countersFor(sessionId).refused += 1;
|
|
3005
|
+
} catch {}
|
|
3006
|
+
}
|
|
3007
|
+
function dropServedRecord(sessionId, reason) {
|
|
3008
|
+
try {
|
|
3009
|
+
const value = counters.peek(sessionId);
|
|
3010
|
+
if (value && value.commits + value.refused > 0)
|
|
3011
|
+
logCounts(sessionId, value, reason);
|
|
3012
|
+
if (records.has(sessionId))
|
|
3013
|
+
sessionLog2(sessionId, `served check: record dropped reason=${reason}; the next request is not compared`);
|
|
3014
|
+
} catch {}
|
|
3015
|
+
records.delete(sessionId);
|
|
3016
|
+
pending4.delete(sessionId);
|
|
3017
|
+
counters.delete(sessionId);
|
|
3018
|
+
}
|
|
3019
|
+
function forgetServedRecord(sessionId) {
|
|
3020
|
+
records.delete(sessionId);
|
|
3021
|
+
pending4.delete(sessionId);
|
|
3022
|
+
}
|
|
3023
|
+
function logCounts(sessionId, value, reason) {
|
|
3024
|
+
sessionLog2(sessionId, `served check counts: compared=${value.compared} unknown=${value.unknown} refused=${value.refused} append_only=${value.appendOnly} changed=${value.changed} shorter=${value.shorter} model_changed=${value.modelChanged} unpermitted_change=${value.unpermittedChange} mixed_replay=${value.mixedReplay} thinking_prefix_change=${value.thinkingPrefixChange} same_shape_change=${value.sameShapeChange} full_checks=${value.fullChecks} reason=${reason}`);
|
|
3025
|
+
}
|
|
3026
|
+
function mix(hash, value) {
|
|
3027
|
+
return Math.imul(hash ^ (value | 0), 16777619);
|
|
3028
|
+
}
|
|
3029
|
+
function mixName(hash, value) {
|
|
3030
|
+
if (typeof value !== "string")
|
|
3031
|
+
return mix(hash, value === undefined ? -1 : -2);
|
|
3032
|
+
const length = value.length;
|
|
3033
|
+
const h = mix(hash, length);
|
|
3034
|
+
return length === 0 ? h : mix(h, value.charCodeAt(length - 1) << 16 | value.charCodeAt(length >> 1));
|
|
3035
|
+
}
|
|
3036
|
+
function mixId(hash, value) {
|
|
3037
|
+
if (typeof value !== "string")
|
|
3038
|
+
return mix(hash, value === undefined ? -1 : -2);
|
|
3039
|
+
const length = value.length;
|
|
3040
|
+
let h = mix(hash, length);
|
|
3041
|
+
const stop = length > 8 ? length - 8 : 0;
|
|
3042
|
+
let index = length - 1;
|
|
3043
|
+
for (;index > stop; index -= 2)
|
|
3044
|
+
h = mix(h, value.charCodeAt(index) << 16 | value.charCodeAt(index - 1));
|
|
3045
|
+
if (index === stop && length > 0)
|
|
3046
|
+
h = mix(h, value.charCodeAt(index));
|
|
3047
|
+
return h;
|
|
3048
|
+
}
|
|
3049
|
+
function mixNumber(hash, value) {
|
|
3050
|
+
const whole = Math.trunc(value);
|
|
3051
|
+
return mix(mix(mix(hash, whole), whole / 4294967296), Math.round((value - whole) * 1e6));
|
|
3052
|
+
}
|
|
3053
|
+
function mixLength(hash, value) {
|
|
3054
|
+
return typeof value === "string" ? mix(hash, value.length) : mix(hash, value === undefined ? -1 : -2);
|
|
3055
|
+
}
|
|
3056
|
+
function mixShallow(hash, value) {
|
|
3057
|
+
switch (typeof value) {
|
|
3058
|
+
case "string":
|
|
3059
|
+
return mix(mix(hash, 1), value.length);
|
|
3060
|
+
case "number":
|
|
3061
|
+
return mixNumber(mix(hash, 2), value);
|
|
3062
|
+
case "boolean":
|
|
3063
|
+
return mix(hash, value ? 5 : 4);
|
|
3064
|
+
case "undefined":
|
|
3065
|
+
return mix(hash, -1);
|
|
3066
|
+
case "object":
|
|
3067
|
+
if (value === null)
|
|
3068
|
+
return mix(hash, 3);
|
|
3069
|
+
if (Array.isArray(value))
|
|
3070
|
+
return mix(mix(hash, 9), value.length);
|
|
3071
|
+
{
|
|
3072
|
+
const size = value.byteLength;
|
|
3073
|
+
return typeof size === "number" ? mix(mix(hash, 7), size) : mix(hash, 10);
|
|
3074
|
+
}
|
|
3075
|
+
default:
|
|
3076
|
+
return mix(hash, 6);
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
function mixToolState(hash, state) {
|
|
3080
|
+
let h = mixName(hash, state.status);
|
|
3081
|
+
h = mixShallow(h, state.input);
|
|
3082
|
+
h = mixShallow(h, state.output);
|
|
3083
|
+
if (state.error !== undefined)
|
|
3084
|
+
h = mixShallow(h, state.error);
|
|
3085
|
+
if (state.attachments !== undefined)
|
|
3086
|
+
h = mixShallow(h, state.attachments);
|
|
3087
|
+
if (state.content !== undefined)
|
|
3088
|
+
h = mixShallow(h, state.content);
|
|
3089
|
+
const time = state.time;
|
|
3090
|
+
h = mix(h, time && typeof time === "object" && time.compacted !== undefined ? 1 : 0);
|
|
3091
|
+
if (state.status === "error") {
|
|
3092
|
+
const metadata = state.metadata;
|
|
3093
|
+
if (metadata && typeof metadata === "object" && metadata.interrupted === true)
|
|
3094
|
+
h = mixShallow(h, metadata.output);
|
|
3095
|
+
}
|
|
3096
|
+
return h;
|
|
3097
|
+
}
|
|
3098
|
+
function isThinkingType(type) {
|
|
3099
|
+
return type === "reasoning" || type === "thinking" || type === "redacted_thinking";
|
|
3100
|
+
}
|
|
3101
|
+
function isKeptThinkingPart(part) {
|
|
3102
|
+
if (!isThinkingType(part.type) || part.ignored === true)
|
|
3103
|
+
return false;
|
|
3104
|
+
if (part.type === "redacted_thinking" || part.redacted === true)
|
|
3105
|
+
return true;
|
|
3106
|
+
if (typeof part.text === "string" && part.text !== "")
|
|
3107
|
+
return true;
|
|
3108
|
+
if (typeof part.thinking === "string" && part.thinking !== "")
|
|
3109
|
+
return true;
|
|
3110
|
+
const metadata = part.metadata;
|
|
3111
|
+
if (metadata && typeof metadata === "object") {
|
|
3112
|
+
for (const record of Object.values(metadata))
|
|
3113
|
+
if (record && typeof record === "object" && "redactedData" in record)
|
|
3114
|
+
return true;
|
|
3115
|
+
}
|
|
3116
|
+
return false;
|
|
3117
|
+
}
|
|
3118
|
+
var PART_FIELDS = [
|
|
3119
|
+
"text",
|
|
3120
|
+
"thinking",
|
|
3121
|
+
"thinkingSignature",
|
|
3122
|
+
"signature",
|
|
3123
|
+
"redacted",
|
|
3124
|
+
"data",
|
|
3125
|
+
"url",
|
|
3126
|
+
"mime",
|
|
3127
|
+
"mimeType",
|
|
3128
|
+
"mediaType",
|
|
3129
|
+
"filename",
|
|
3130
|
+
"name",
|
|
3131
|
+
"tool",
|
|
3132
|
+
"callID",
|
|
3133
|
+
"toolCallId",
|
|
3134
|
+
"input",
|
|
3135
|
+
"arguments",
|
|
3136
|
+
"output",
|
|
3137
|
+
"error",
|
|
3138
|
+
"isError",
|
|
3139
|
+
"providerExecuted",
|
|
3140
|
+
"synthetic",
|
|
3141
|
+
"ignored"
|
|
3142
|
+
];
|
|
3143
|
+
var walkOut = { partThinking: false, messageThinking: false, messageHead: false };
|
|
3144
|
+
function mixPart(hash, rawPart) {
|
|
3145
|
+
walkOut.partThinking = false;
|
|
3146
|
+
if (!rawPart || typeof rawPart !== "object")
|
|
3147
|
+
return mix(hash, 11);
|
|
3148
|
+
const part = rawPart;
|
|
3149
|
+
const type = part.type;
|
|
3150
|
+
let h = mixId(mixName(hash, type), part.id);
|
|
3151
|
+
if (type === "text") {
|
|
3152
|
+
h = mixLength(h, part.text);
|
|
3153
|
+
return mix(h, (part.synthetic === true ? 1 : 0) | (part.ignored === true ? 2 : 0));
|
|
3154
|
+
}
|
|
3155
|
+
if (type === "tool" && part.state && typeof part.state === "object")
|
|
3156
|
+
return mixToolState(mixId(mixName(h, part.tool), part.callID), part.state);
|
|
3157
|
+
for (let index = 0;index < PART_FIELDS.length; index += 1) {
|
|
3158
|
+
const value = part[PART_FIELDS[index]];
|
|
3159
|
+
if (value !== undefined)
|
|
3160
|
+
h = mixShallow(mix(h, index), value);
|
|
3161
|
+
}
|
|
3162
|
+
const result = part.result;
|
|
3163
|
+
if (result && typeof result === "object") {
|
|
3164
|
+
h = mixName(h, result.type);
|
|
3165
|
+
h = mixShallow(h, result.value);
|
|
3166
|
+
}
|
|
3167
|
+
if (isThinkingType(type)) {
|
|
3168
|
+
walkOut.partThinking = isKeptThinkingPart(part);
|
|
3169
|
+
const metadata = part.metadata;
|
|
3170
|
+
const anthropic = metadata && typeof metadata === "object" ? metadata.anthropic : undefined;
|
|
3171
|
+
if (anthropic && typeof anthropic === "object") {
|
|
3172
|
+
h = mixShallow(h, anthropic.signature);
|
|
3173
|
+
h = mixShallow(h, anthropic.redactedData);
|
|
3174
|
+
} else
|
|
3175
|
+
h = mix(h, metadata && typeof metadata === "object" ? 17 : 18);
|
|
3176
|
+
}
|
|
3177
|
+
return h;
|
|
3178
|
+
}
|
|
3179
|
+
function messageShape(message) {
|
|
3180
|
+
const record = message && typeof message === "object" ? message : {};
|
|
3181
|
+
const info = record.info && typeof record.info === "object" ? record.info : record;
|
|
3182
|
+
const parts = Array.isArray(record.parts) ? record.parts : record.content;
|
|
3183
|
+
const role = info.role;
|
|
3184
|
+
let hash = mixId(2166136261, info.id);
|
|
3185
|
+
hash = mixName(hash, role);
|
|
3186
|
+
if (typeof record.timestamp === "number")
|
|
3187
|
+
hash = mixNumber(hash, record.timestamp);
|
|
3188
|
+
if (typeof record.toolCallId === "string")
|
|
3189
|
+
hash = mixId(hash, record.toolCallId);
|
|
3190
|
+
if (record.isError === true)
|
|
3191
|
+
hash = mix(hash, 12);
|
|
3192
|
+
if (info.summary === true)
|
|
3193
|
+
hash = mix(hash, 13);
|
|
3194
|
+
let thinking = false;
|
|
3195
|
+
let synthetic = info.synthetic === true || info.summary === true;
|
|
3196
|
+
if (typeof parts === "string") {
|
|
3197
|
+
hash = mix(mix(hash, 14), parts.length);
|
|
3198
|
+
} else if (Array.isArray(parts)) {
|
|
3199
|
+
hash = mix(mix(hash, 15), parts.length);
|
|
3200
|
+
let allSynthetic = parts.length > 0;
|
|
3201
|
+
for (const part of parts) {
|
|
3202
|
+
hash = mixPart(hash, part);
|
|
3203
|
+
if (walkOut.partThinking)
|
|
3204
|
+
thinking = true;
|
|
3205
|
+
if (allSynthetic && part?.synthetic !== true)
|
|
3206
|
+
allSynthetic = false;
|
|
3207
|
+
}
|
|
3208
|
+
if (allSynthetic)
|
|
3209
|
+
synthetic = true;
|
|
3210
|
+
} else {
|
|
3211
|
+
hash = mix(hash, 16);
|
|
3212
|
+
}
|
|
3213
|
+
walkOut.messageThinking = thinking && role === "assistant";
|
|
3214
|
+
walkOut.messageHead = synthetic || role === "system" || role === "compactionSummary" || role === "branchSummary";
|
|
3215
|
+
return hash >>> 0;
|
|
3216
|
+
}
|
|
3217
|
+
function digestInto(message, out, index) {
|
|
3218
|
+
let json;
|
|
3219
|
+
try {
|
|
3220
|
+
json = JSON.stringify(contentSnapshotValue(message));
|
|
3221
|
+
} catch {
|
|
3222
|
+
json = undefined;
|
|
3223
|
+
}
|
|
3224
|
+
if (json === undefined) {
|
|
3225
|
+
out[2 * index] = 0;
|
|
3226
|
+
out[2 * index + 1] = 0;
|
|
3227
|
+
return;
|
|
3228
|
+
}
|
|
3229
|
+
const digest = createHash6("sha256").update(json).digest();
|
|
3230
|
+
out[2 * index] = digest.readUInt32LE(0);
|
|
3231
|
+
out[2 * index + 1] = digest.readUInt32LE(4);
|
|
3232
|
+
}
|
|
3233
|
+
function digestsDiffer(a, ai, b, bi) {
|
|
3234
|
+
const a0 = a[2 * ai];
|
|
3235
|
+
const a1 = a[2 * ai + 1];
|
|
3236
|
+
const b0 = b[2 * bi];
|
|
3237
|
+
const b1 = b[2 * bi + 1];
|
|
3238
|
+
if (a0 === 0 && a1 === 0 || b0 === 0 && b1 === 0)
|
|
3239
|
+
return false;
|
|
3240
|
+
return a0 !== b0 || a1 !== b1;
|
|
3241
|
+
}
|
|
3242
|
+
function permittedLabel(permitted) {
|
|
3243
|
+
return permitted === null ? "unknown" : String(permitted);
|
|
3244
|
+
}
|
|
3245
|
+
function commitServedRequest(args) {
|
|
3246
|
+
try {
|
|
3247
|
+
return commit(args);
|
|
3248
|
+
} catch (error) {
|
|
3249
|
+
try {
|
|
3250
|
+
records.delete(args.sessionId);
|
|
3251
|
+
sessionLog2(args.sessionId, "served check failed; the record is unknown again:", error);
|
|
3252
|
+
} catch {}
|
|
3253
|
+
return null;
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
function commit(args) {
|
|
3257
|
+
const { sessionId, messages, host } = args;
|
|
3258
|
+
const startedAt = performance.now();
|
|
3259
|
+
const note = pending4.peek(sessionId) ?? {};
|
|
3260
|
+
pending4.delete(sessionId);
|
|
3261
|
+
const count = countersFor(sessionId);
|
|
3262
|
+
const kind = note.replay ? "replay" : note.input ? "input" : "pass";
|
|
3263
|
+
const permission = note.permission;
|
|
3264
|
+
const permitted = permission?.permitted ?? (args.compactionOff ? false : kind === "input" ? false : null);
|
|
3265
|
+
const prior = records.get(sessionId);
|
|
3266
|
+
if (note.refused) {
|
|
3267
|
+
count.refused += 1;
|
|
3268
|
+
return {
|
|
3269
|
+
class: "refused",
|
|
3270
|
+
kind,
|
|
3271
|
+
firstIndex: null,
|
|
3272
|
+
recorded: prior?.count ?? 0,
|
|
3273
|
+
served: messages.length,
|
|
3274
|
+
seenBy: null,
|
|
3275
|
+
keptThinkingIndex: -1,
|
|
3276
|
+
recordedThinkingIndex: prior?.keptThinkingIndex ?? -1,
|
|
3277
|
+
permitted,
|
|
3278
|
+
events: []
|
|
3279
|
+
};
|
|
3280
|
+
}
|
|
3281
|
+
count.commits += 1;
|
|
3282
|
+
const m = messages.length;
|
|
3283
|
+
const providerID = note.model?.providerID ?? args.providerID;
|
|
3284
|
+
const modelID = note.model?.modelID ?? args.modelID;
|
|
3285
|
+
const prefixBound = isPrefixBoundThinkingModel(providerID, modelID);
|
|
3286
|
+
const modelKey = modelID ? `${providerID ?? ""}/${modelID}` : null;
|
|
3287
|
+
const shapes = new Uint32Array(m);
|
|
3288
|
+
let keptThinkingIndex = -1;
|
|
3289
|
+
let headCount = Math.min(HEAD_MIN, m);
|
|
3290
|
+
let leading = true;
|
|
3291
|
+
for (let index = 0;index < m; index += 1) {
|
|
3292
|
+
shapes[index] = messageShape(messages[index]);
|
|
3293
|
+
if (prefixBound && keptThinkingIndex < 0 && walkOut.messageThinking)
|
|
3294
|
+
keptThinkingIndex = index;
|
|
3295
|
+
if (leading && index >= HEAD_MIN) {
|
|
3296
|
+
if (walkOut.messageHead && index < HEAD_MAX)
|
|
3297
|
+
headCount = index + 1;
|
|
3298
|
+
else
|
|
3299
|
+
leading = false;
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
const shapeMs = performance.now() - startedAt;
|
|
3303
|
+
const digests = new Uint32Array(2 * m);
|
|
3304
|
+
const computed = new Uint8Array(m);
|
|
3305
|
+
let digested = 0;
|
|
3306
|
+
const digest = (index) => {
|
|
3307
|
+
if (index < 0 || index >= m || computed[index])
|
|
3308
|
+
return;
|
|
3309
|
+
computed[index] = 1;
|
|
3310
|
+
digested += 1;
|
|
3311
|
+
digestInto(messages[index], digests, index);
|
|
3312
|
+
};
|
|
3313
|
+
const finish = (comparison, full, passesSinceFull) => {
|
|
3314
|
+
records.set(sessionId, {
|
|
3315
|
+
count: m,
|
|
3316
|
+
shapes,
|
|
3317
|
+
digests,
|
|
3318
|
+
modelKey: modelKey ?? prior?.modelKey ?? null,
|
|
3319
|
+
kind,
|
|
3320
|
+
keptThinkingIndex,
|
|
3321
|
+
passesSinceFull
|
|
3322
|
+
});
|
|
3323
|
+
lastWork = { fingerprinted: m, digested, full, ms: 0, shapeMs };
|
|
3324
|
+
if (count.commits % COUNT_LOG_INTERVAL === 0)
|
|
3325
|
+
logCounts(sessionId, count, "periodic");
|
|
3326
|
+
lastWork.ms = performance.now() - startedAt;
|
|
3327
|
+
return { ...comparison, kind, permitted, served: m };
|
|
3328
|
+
};
|
|
3329
|
+
const modelChanged = prior !== undefined && prior.modelKey !== null && modelKey !== null && prior.modelKey !== modelKey;
|
|
3330
|
+
if (!prior || modelChanged) {
|
|
3331
|
+
for (let index = 0;index < m; index += 1)
|
|
3332
|
+
digest(index);
|
|
3333
|
+
if (prior)
|
|
3334
|
+
count.modelChanged += 1;
|
|
3335
|
+
else
|
|
3336
|
+
count.unknown += 1;
|
|
3337
|
+
return finish({
|
|
3338
|
+
class: prior ? "model_change" : "unknown",
|
|
3339
|
+
firstIndex: null,
|
|
3340
|
+
recorded: prior?.count ?? 0,
|
|
3341
|
+
seenBy: null,
|
|
3342
|
+
keptThinkingIndex,
|
|
3343
|
+
recordedThinkingIndex: prior?.keptThinkingIndex ?? -1,
|
|
3344
|
+
events: []
|
|
3345
|
+
}, true, 0);
|
|
3346
|
+
}
|
|
3347
|
+
count.compared += 1;
|
|
3348
|
+
const n = prior.count;
|
|
3349
|
+
const overlap = Math.min(n, m);
|
|
3350
|
+
let shapeDiff = -1;
|
|
3351
|
+
for (let index = 0;index < overlap; index += 1)
|
|
3352
|
+
if (shapes[index] !== prior.shapes[index]) {
|
|
3353
|
+
shapeDiff = index;
|
|
3354
|
+
break;
|
|
3355
|
+
}
|
|
3356
|
+
for (let index = 0;index < headCount; index += 1)
|
|
3357
|
+
digest(index);
|
|
3358
|
+
digest(n - 1);
|
|
3359
|
+
digest(prior.keptThinkingIndex);
|
|
3360
|
+
digest(keptThinkingIndex);
|
|
3361
|
+
for (let index = n;index < m; index += 1)
|
|
3362
|
+
digest(index);
|
|
3363
|
+
let handfulDiff = -1;
|
|
3364
|
+
for (let index = 0;index < overlap; index += 1)
|
|
3365
|
+
if (computed[index] && digestsDiffer(digests, index, prior.digests, index)) {
|
|
3366
|
+
handfulDiff = index;
|
|
3367
|
+
break;
|
|
3368
|
+
}
|
|
3369
|
+
const full = kind === "replay" || prior.kind === "replay" || shapeDiff >= 0 || handfulDiff >= 0 || m < n || prior.passesSinceFull + 1 >= SERVED_FULL_CHECK_INTERVAL;
|
|
3370
|
+
let contentDiff = handfulDiff;
|
|
3371
|
+
if (full) {
|
|
3372
|
+
count.fullChecks += 1;
|
|
3373
|
+
for (let index = 0;index < m; index += 1)
|
|
3374
|
+
digest(index);
|
|
3375
|
+
contentDiff = -1;
|
|
3376
|
+
for (let index = 0;index < overlap; index += 1)
|
|
3377
|
+
if (digestsDiffer(digests, index, prior.digests, index)) {
|
|
3378
|
+
contentDiff = index;
|
|
3379
|
+
break;
|
|
3380
|
+
}
|
|
3381
|
+
} else {
|
|
3382
|
+
for (let index = 0;index < overlap; index += 1)
|
|
3383
|
+
if (!computed[index]) {
|
|
3384
|
+
digests[2 * index] = prior.digests[2 * index];
|
|
3385
|
+
digests[2 * index + 1] = prior.digests[2 * index + 1];
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
const candidates = [shapeDiff, contentDiff].filter((value) => value >= 0);
|
|
3389
|
+
const firstIndex = candidates.length > 0 ? Math.min(...candidates) : -1;
|
|
3390
|
+
let comparisonClass;
|
|
3391
|
+
let seenBy = null;
|
|
3392
|
+
if (firstIndex >= 0) {
|
|
3393
|
+
comparisonClass = "changed";
|
|
3394
|
+
count.changed += 1;
|
|
3395
|
+
seenBy = shapeDiff >= 0 && shapeDiff === firstIndex ? "shape" : handfulDiff === firstIndex ? "digest" : "full";
|
|
3396
|
+
} else if (m < n) {
|
|
3397
|
+
comparisonClass = "shorter";
|
|
3398
|
+
count.shorter += 1;
|
|
3399
|
+
seenBy = "length";
|
|
3400
|
+
} else {
|
|
3401
|
+
comparisonClass = "append_only";
|
|
3402
|
+
count.appendOnly += 1;
|
|
3403
|
+
}
|
|
3404
|
+
const reportedIndex = firstIndex >= 0 ? firstIndex : comparisonClass === "shorter" ? m : null;
|
|
3405
|
+
const events = [];
|
|
3406
|
+
const permissionInputs = permission ? `decision=${permission.schedulerDecision} ${permission.rides} thinking_hold=${permission.signedThinkingHold} first_render=${permission.firstRender} host_checkpoint_head=${permission.hostCheckpointHead} emergency=${permission.emergency}` : "decision=unknown ride=unknown";
|
|
3407
|
+
if (reportedIndex !== null) {
|
|
3408
|
+
const after = n - reportedIndex;
|
|
3409
|
+
if (kind === "replay") {
|
|
3410
|
+
events.push("mixed_replay");
|
|
3411
|
+
count.mixedReplay += 1;
|
|
3412
|
+
sessionLog2(sessionId, `served check: a replay differed from the request served before it first_index=${reportedIndex} recorded=${n} after_first=${after} served=${m} class=${comparisonClass} seen_by=${seenBy} refused_pass_permitted=${permittedLabel(permitted)} host=${host}`);
|
|
3413
|
+
} else if (permitted !== true) {
|
|
3414
|
+
events.push("unpermitted_change");
|
|
3415
|
+
count.unpermittedChange += 1;
|
|
3416
|
+
sessionLog2(sessionId, `served check: a pass without rebuild permission changed served messages first_index=${reportedIndex} recorded=${n} after_first=${after} served=${m} class=${comparisonClass} seen_by=${seenBy} kind=${kind} permitted=${permittedLabel(permitted)} ${permissionInputs} previous_kind=${prior.kind} host=${host}`);
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
if (firstIndex >= 0 && shapeDiff !== firstIndex) {
|
|
3420
|
+
events.push("same_shape_change");
|
|
3421
|
+
count.sameShapeChange += 1;
|
|
3422
|
+
sessionLog2(sessionId, `served check: content changed with the same shape first_index=${firstIndex} seen_by=${seenBy} kind=${kind} permitted=${permittedLabel(permitted)} host=${host}`);
|
|
3423
|
+
}
|
|
3424
|
+
if (prefixBound && firstIndex >= 0) {
|
|
3425
|
+
const unstripped = keptThinkingIndex >= 0 && firstIndex <= keptThinkingIndex;
|
|
3426
|
+
const stripped = !unstripped && prior.keptThinkingIndex >= 0 && firstIndex <= prior.keptThinkingIndex;
|
|
3427
|
+
if (unstripped || stripped && permitted !== true) {
|
|
3428
|
+
events.push("thinking_prefix_change");
|
|
3429
|
+
count.thinkingPrefixChange += 1;
|
|
3430
|
+
sessionLog2(sessionId, `served check: a change in front of kept signed thinking on a prefix-bound model first_index=${firstIndex} kept_thinking_index=${keptThinkingIndex} recorded_thinking_index=${prior.keptThinkingIndex} thinking_stripped=${stripped} kind=${kind} permitted=${permittedLabel(permitted)} seen_by=${seenBy} host=${host}`);
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
return finish({
|
|
3434
|
+
class: comparisonClass,
|
|
3435
|
+
firstIndex: reportedIndex,
|
|
3436
|
+
recorded: n,
|
|
3437
|
+
seenBy,
|
|
3438
|
+
keptThinkingIndex,
|
|
3439
|
+
recordedThinkingIndex: prior.keptThinkingIndex,
|
|
3440
|
+
events
|
|
3441
|
+
}, full, full ? 0 : prior.passesSinceFull + 1);
|
|
3442
|
+
}
|
|
3443
|
+
|
|
2930
3444
|
// src/hooks/magic-context/lkg-slot.ts
|
|
2931
3445
|
var POSITIONAL_SYSTEM_KEY = "\x00mc-system:";
|
|
2932
3446
|
function lkgInputIdentity(id, role, index) {
|
|
@@ -3136,7 +3650,7 @@ var DIGEST_CHUNK_BYTES = 64 * 1024;
|
|
|
3136
3650
|
var digestChunk;
|
|
3137
3651
|
function lkgContentDigestFromFields(fields) {
|
|
3138
3652
|
lkgDigestsComputed += 1;
|
|
3139
|
-
const hash =
|
|
3653
|
+
const hash = createHash7("sha256");
|
|
3140
3654
|
digestChunk ??= Buffer.allocUnsafe(DIGEST_CHUNK_BYTES);
|
|
3141
3655
|
const chunk = digestChunk;
|
|
3142
3656
|
let offset = 0;
|
|
@@ -3199,7 +3713,7 @@ function legacyLkgDigestFromFields(fields) {
|
|
|
3199
3713
|
const value = typeof field === "symbol" ? field.description ?? "" : String(field);
|
|
3200
3714
|
key += `${typeof field}:${value.length}:${value}\x00`;
|
|
3201
3715
|
}
|
|
3202
|
-
return
|
|
3716
|
+
return createHash7("sha256").update(key).digest("base64url");
|
|
3203
3717
|
}
|
|
3204
3718
|
function legacyLkgContentDigest(message) {
|
|
3205
3719
|
const fields = flattenContentFields(withoutEmptyUserDiffSummary(message));
|
|
@@ -4602,4 +5116,4 @@ var ERROR_CLASSES = new Set([
|
|
|
4602
5116
|
"permission_denied",
|
|
4603
5117
|
"unknown"
|
|
4604
5118
|
]);
|
|
4605
|
-
export { COMPARTMENT_LEASE_RENEWAL_MS, getCompartmentLeaseBlocker, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, buildCompartmentBlock, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndsThrough, isPartialCompartmentEnd, readProjectDocsCanonical, readServerFallbackUsage, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, advanceSessionActivity, backfillSessionActivity, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, clearPendingMaterializationOrigin, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, lkgInputIdentity, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, externalHistorianFailureReason, recordHistorianRun, summarizeImportance, tallyFactsByCategory, MEMORY_VISIBILITY_MUTATION_CATEGORY, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId };
|
|
5119
|
+
export { COMPARTMENT_LEASE_RENEWAL_MS, getCompartmentLeaseBlocker, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, buildCompartmentBlock, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndsThrough, isPartialCompartmentEnd, readProjectDocsCanonical, readServerFallbackUsage, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, advanceSessionActivity, backfillSessionActivity, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, clearPendingMaterializationOrigin, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, beginServedRequest, noteServedPassPermission, noteServedModel, noteServedReplay, noteServedHostInput, noteServedRefusal, countServedRefusal, dropServedRecord, forgetServedRecord, commitServedRequest, lkgInputIdentity, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, externalHistorianFailureReason, recordHistorianRun, summarizeImportance, tallyFactsByCategory, MEMORY_VISIBILITY_MUTATION_CATEGORY, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId };
|
package/dist/v2/server.js
CHANGED
|
@@ -7875,7 +7875,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
7875
7875
|
// package.json
|
|
7876
7876
|
var package_default = {
|
|
7877
7877
|
name: "@cortexkit/opencode-magic-context",
|
|
7878
|
-
version: "0.49.
|
|
7878
|
+
version: "0.49.53",
|
|
7879
7879
|
type: "module",
|
|
7880
7880
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
7881
7881
|
main: "dist/index.js",
|
|
@@ -8196,7 +8196,7 @@ async function setup(context) {
|
|
|
8196
8196
|
if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
|
|
8197
8197
|
log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
8198
8198
|
}
|
|
8199
|
-
const { registerContext } = await import("./context-
|
|
8199
|
+
const { registerContext } = await import("./context-1p22880w.js");
|
|
8200
8200
|
setHarness2("opencode2");
|
|
8201
8201
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
8202
8202
|
const duties = await registerContext(context);
|