@cortexkit/opencode-magic-context 0.49.43 → 0.49.44
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/{compaction-marker-candidates-5c44h1m9.js → compaction-marker-candidates-dkfp1q9j.js} +12 -2
- package/dist/compaction-marker-candidates-worker.js +5 -2
- package/dist/{context-zf1yj1g0.js → context-ws6gbyrr.js} +19 -19
- package/dist/{embedding-backfill-rma0v2ct.js → embedding-backfill-zxj35jkq.js} +4 -4
- package/dist/embedding-worker.js +2 -2
- package/dist/features/magic-context/compaction-marker-candidates.d.ts +57 -4
- package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts +18 -3
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/scheduler.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +5 -4
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +4 -4
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +7 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +7 -2
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/local-wire-reading.d.ts +54 -0
- package/dist/hooks/magic-context/local-wire-reading.d.ts.map +1 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-date-refresh.d.ts +1 -2
- package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +38 -6
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +5 -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/{index-zqsp3z0d.js → index-1j8m4ad0.js} +1 -1
- package/dist/{index-5m2azs6v.js → index-24y47287.js} +4 -4
- package/dist/{index-c5dzns43.js → index-4dpvnp8k.js} +1 -1
- package/dist/{index-ty4vhe4n.js → index-66qexmjw.js} +3 -3
- package/dist/{index-kfsqk1q7.js → index-6qnhaaa0.js} +1 -1
- package/dist/{index-n8bsqg7b.js → index-7y8c2n52.js} +3 -3
- package/dist/{index-ayk4we2k.js → index-8w3y6pxc.js} +36 -26
- package/dist/{index-p2e7j9p1.js → index-91y4xvx6.js} +1 -1
- package/dist/{index-rdx17j04.js → index-dasvhxwg.js} +1 -1
- package/dist/{index-z6v8086q.js → index-g0mjm7e4.js} +2 -2
- package/dist/{index-1zv08avf.js → index-g7rrfjkq.js} +4 -4
- package/dist/{index-3w1pbn85.js → index-gn6gfz4y.js} +64 -12
- package/dist/{index-xnm0wq1r.js → index-kgk64zyx.js} +1 -1
- package/dist/{index-xjw9rres.js → index-knnscj54.js} +1 -1
- package/dist/{index-gsqz39wk.js → index-m1mttf6y.js} +1 -1
- package/dist/{index-adt3jghq.js → index-ntssp0dt.js} +159 -49
- package/dist/{index-xd2p95m7.js → index-p6gs3xpx.js} +1 -1
- package/dist/{index-21fgrfrf.js → index-rhcwddn9.js} +2 -2
- package/dist/{index-fas76dft.js → index-v64se1t6.js} +5 -5
- package/dist/{index-xmqj3cf5.js → index-wapyeb06.js} +129 -56
- package/dist/index.js +23 -23
- package/dist/{message-index-bounded-5mj8p6nq.js → message-index-bounded-dmq6ne7d.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/{project-embedding-registry-3yyegjma.js → project-embedding-registry-m47vg1ce.js} +3 -3
- package/dist/raw-ordinal-warmup-worker.js +3 -3
- package/dist/{read-session-chunk-k70bhfjm.js → read-session-chunk-3m7z9v3t.js} +2 -2
- package/dist/{recomp-orchestrator-2q4rmerf.js → recomp-orchestrator-9wtcpd7d.js} +12 -12
- package/dist/{render-36fvvwz6.js → render-esw55s0k.js} +6 -6
- package/dist/{search-6v2na3af.js → search-3b4kbhtw.js} +9 -9
- package/dist/{search-archive-jwb2ctnq.js → search-archive-wna5basn.js} +4 -4
- package/dist/shared/status-view.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-0ms3ga4h.js → transform-postprocess-phase-1y6p9ccc.js} +13 -13
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/compaction-marker-candidates-worker.js +5 -2
- package/dist/v2/{compaction-marker-candidates-jy65jt49.js → compaction-marker-candidates-y737qb1v.js} +12 -2
- package/dist/v2/{context-2xr6vbt2.js → context-sfgk72cj.js} +184 -64
- package/dist/v2/{embedding-backfill-00tw59rx.js → embedding-backfill-ahwzfc7v.js} +4 -4
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-5341qsqd.js → message-index-bounded-mapha2ag.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-jqq2qeqb.js → project-embedding-registry-mn403rp5.js} +3 -3
- package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
- package/dist/v2/{read-session-chunk-dgmq3ntm.js → read-session-chunk-svcthp0n.js} +2 -2
- package/dist/v2/{recomp-orchestrator-2vmyhtst.js → recomp-orchestrator-2bkv46am.js} +12 -12
- package/dist/v2/{render-kz0f40ws.js → render-315tv10c.js} +6 -6
- package/dist/v2/{search-archive-wajxd01m.js → search-archive-hnx40ts0.js} +4 -4
- package/dist/v2/{search-a9hwy1sw.js → search-bhrr075t.js} +8 -8
- package/dist/v2/{server-7qc9tk6z.js → server-1c720m9s.js} +1 -1
- package/dist/v2/{server-qehn6btp.js → server-1yx5455s.js} +2 -2
- package/dist/v2/{server-p78wdf43.js → server-63cz4w5t.js} +1 -1
- package/dist/v2/{server-kqrpt2ht.js → server-78mc9sxx.js} +1 -1
- package/dist/v2/{server-7acq7815.js → server-86sk7h34.js} +2 -2
- package/dist/v2/{server-6vzh6wej.js → server-8xdnk7vz.js} +1 -1
- package/dist/v2/{server-gkse1wyz.js → server-aqgg41wb.js} +3 -3
- package/dist/v2/{server-3m7p4g9w.js → server-g8xvnxcf.js} +1 -1
- package/dist/v2/{server-dwpgzm0t.js → server-gwxys0d0.js} +64 -12
- package/dist/v2/{server-5ydn39x3.js → server-ngdrh7rv.js} +130 -57
- package/dist/v2/{server-7zacmty5.js → server-p9s40wfa.js} +1 -1
- package/dist/v2/{server-dqs8e4yt.js → server-qs0mdpc1.js} +4 -4
- package/dist/v2/{server-sfcp13bn.js → server-rqypazrp.js} +3 -3
- package/dist/v2/{server-09td1wgc.js → server-t5gxvcc3.js} +1 -1
- package/dist/v2/{server-avdveykk.js → server-vjhk8v41.js} +1 -1
- package/dist/v2/{server-nq3cb7be.js → server-xnz3nrt2.js} +1 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/{v2-archive-reader-ag6sk771.js → v2-archive-reader-qwn0me88.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-2a077zew.js → wrapup-orchestrator-ts0sqwp3.js} +12 -12
- package/dist/{v2-archive-reader-chk95syc.js → v2-archive-reader-vqqjkeaq.js} +1 -1
- package/dist/{wrapup-orchestrator-rhs675kj.js → wrapup-orchestrator-qxvbvr4r.js} +13 -13
- package/package.json +1 -1
- package/src/config/schema/magic-context.ts +1 -1
- package/src/shared/status-view.ts +3 -5
- package/src/tui/dialogs/status-dialog-render.test.ts +1 -1
|
@@ -120,11 +120,11 @@ import {
|
|
|
120
120
|
saveSourceContent,
|
|
121
121
|
replaceSourceContent,
|
|
122
122
|
getSourceContents
|
|
123
|
-
} from "./index-
|
|
123
|
+
} from "./index-dasvhxwg.js";
|
|
124
124
|
import {
|
|
125
125
|
cleanSearchText,
|
|
126
126
|
matchedSearchSnippet
|
|
127
|
-
} from "./index-
|
|
127
|
+
} from "./index-m1mttf6y.js";
|
|
128
128
|
import {
|
|
129
129
|
stripSystemInjection,
|
|
130
130
|
isTextPart,
|
|
@@ -222,15 +222,15 @@ import {
|
|
|
222
222
|
extractToolCallObservation,
|
|
223
223
|
ToolMutationBatch,
|
|
224
224
|
createToolDropTarget
|
|
225
|
-
} from "./index-
|
|
225
|
+
} from "./index-1j8m4ad0.js";
|
|
226
226
|
import {
|
|
227
227
|
isValidLanguageCode
|
|
228
|
-
} from "./index-
|
|
228
|
+
} from "./index-4dpvnp8k.js";
|
|
229
229
|
import {
|
|
230
230
|
getProjectEmbeddingSnapshot2,
|
|
231
231
|
embedTextForProject2,
|
|
232
232
|
embedBatchForProject2
|
|
233
|
-
} from "./index-
|
|
233
|
+
} from "./index-rhcwddn9.js";
|
|
234
234
|
import {
|
|
235
235
|
isEmbeddingHostBusy2
|
|
236
236
|
} from "./index-qt1qqasc.js";
|
|
@@ -238,7 +238,7 @@ import {
|
|
|
238
238
|
getMessageIndexEpoch,
|
|
239
239
|
isMessageIndexSearchable,
|
|
240
240
|
createAutoSearchDiagnostics
|
|
241
|
-
} from "./index-
|
|
241
|
+
} from "./index-91y4xvx6.js";
|
|
242
242
|
import {
|
|
243
243
|
openCodeDbExists,
|
|
244
244
|
withReadOnlySessionDb,
|
|
@@ -249,7 +249,7 @@ import {
|
|
|
249
249
|
} from "./index-jkanybgq.js";
|
|
250
250
|
import {
|
|
251
251
|
compareOpenCodeMessagesByCanonicalOrder,
|
|
252
|
-
|
|
252
|
+
startCompactionMarkerCandidatePreparation,
|
|
253
253
|
MARKER_SUMMARY_TEXT,
|
|
254
254
|
applyDeferredCompactionMarker,
|
|
255
255
|
injectTemporalMarkers,
|
|
@@ -266,10 +266,10 @@ import {
|
|
|
266
266
|
peekNoteNudgeText,
|
|
267
267
|
markNoteNudgeDelivered,
|
|
268
268
|
getActiveCompartmentRun
|
|
269
|
-
} from "./index-
|
|
269
|
+
} from "./index-wapyeb06.js";
|
|
270
270
|
import {
|
|
271
271
|
userFacingFailureCode
|
|
272
|
-
} from "./index-
|
|
272
|
+
} from "./index-kgk64zyx.js";
|
|
273
273
|
import {
|
|
274
274
|
normalizeProtectedToolName,
|
|
275
275
|
mergeProtectedTools
|
|
@@ -2496,7 +2496,7 @@ function hasReclaimRide(signals) {
|
|
|
2496
2496
|
return signals.hardFold || signals.force || signals.explicitFlush || signals.publishedHistory || signals.subagentExecute === true || signals.executeReclaim === true || signals.servedShapeRepair === true;
|
|
2497
2497
|
}
|
|
2498
2498
|
function prefixMutationPermitted(gate) {
|
|
2499
|
-
return !gate.signedThinkingHold || gate.firstRender || gate.
|
|
2499
|
+
return !gate.signedThinkingHold || gate.firstRender || gate.emergency;
|
|
2500
2500
|
}
|
|
2501
2501
|
function reclaimRidePermitted(signals, gate) {
|
|
2502
2502
|
return prefixMutationPermitted(gate) && hasReclaimRide(signals);
|
|
@@ -3582,7 +3582,6 @@ var CACHE_LOSING_FOLD_REASONS = new Set([
|
|
|
3582
3582
|
"model_change",
|
|
3583
3583
|
"system_hash",
|
|
3584
3584
|
"tool_definitions",
|
|
3585
|
-
"ttl_idle",
|
|
3586
3585
|
"host_compaction"
|
|
3587
3586
|
]);
|
|
3588
3587
|
function sameBytes(left, right) {
|
|
@@ -5859,6 +5858,16 @@ function applyRustModeDeferredCompactionMarker2(args) {
|
|
|
5859
5858
|
ordinal: boundary.ordinal,
|
|
5860
5859
|
endMessageId: boundary.endMessageId
|
|
5861
5860
|
} : undefined;
|
|
5861
|
+
if ((args.applyDeferred ?? applyDeferredCompactionMarker) === applyDeferredCompactionMarker && startCompactionMarkerCandidatePreparation(args.sessionId) === "preparing") {
|
|
5862
|
+
const settled = applyDeferredCompactionMarker(args.db, args.sessionId, pending, args.sessionDirectory, trustedBoundary, { validateOnly: true });
|
|
5863
|
+
if (settled.kind === "stale-skip" || settled.kind === "already-current") {
|
|
5864
|
+
if (!clearPendingCompactionMarkerStateIf(args.db, args.sessionId, pending))
|
|
5865
|
+
sessionLog2(args.sessionId, `rust compaction-marker drain: CAS lost${boundary ? ` after module row ${boundary.rowVersion}` : ""}; newer pending target retained`);
|
|
5866
|
+
return;
|
|
5867
|
+
}
|
|
5868
|
+
sessionLog2(args.sessionId, "rust compaction-marker drain: candidate preparation deferred; pending target retained");
|
|
5869
|
+
return;
|
|
5870
|
+
}
|
|
5862
5871
|
args.beforeApply?.();
|
|
5863
5872
|
const outcome = (args.applyDeferred ?? applyDeferredCompactionMarker)(args.db, args.sessionId, pending, args.sessionDirectory, trustedBoundary);
|
|
5864
5873
|
args.afterApply?.(outcome);
|
|
@@ -6288,6 +6297,8 @@ async function runPostTransformPhase2(args) {
|
|
|
6288
6297
|
const alreadyRanThisTurn = args.currentTurnId !== null && args.lastHeuristicsTurnId.get(args.sessionId) === args.currentTurnId;
|
|
6289
6298
|
const forceMaterialization = args.fullFeatureMode && !compactionOff && args.contextUsage.percentage >= args.forceMaterializationPercentage;
|
|
6290
6299
|
const emergencyDropEligible = !compactionOff && args.contextUsage.percentage >= args.forceMaterializationPercentage;
|
|
6300
|
+
const forceRideWaitsOnLocalCount = args.contextUsageFromEstimate === true && args.contextUsage.percentage < 95;
|
|
6301
|
+
const forceBandConfirmed = emergencyDropEligible && !forceRideWaitsOnLocalCount;
|
|
6291
6302
|
const executePressureEligible = args.schedulerDecision === "execute" || emergencyDropEligible;
|
|
6292
6303
|
if (!executePressureEligible) {
|
|
6293
6304
|
routinePressureAppliedBySession.delete(args.sessionId);
|
|
@@ -6527,13 +6538,11 @@ async function runPostTransformPhase2(args) {
|
|
|
6527
6538
|
const depth = getPendingOpsCount(args.db, args.sessionId);
|
|
6528
6539
|
return depth === null ? "not loaded (deferred pass)" : String(depth);
|
|
6529
6540
|
};
|
|
6530
|
-
const heldIdleExpiryRebuild = activeThinkingPrefixHold && args.m0M1?.hardSignals?.cacheExpired === true;
|
|
6531
|
-
const idleExpiryRebuild = (!freezeM0M1 || activeThinkingPrefixHold) && args.m0M1?.hardSignals?.cacheExpired === true;
|
|
6532
6541
|
const rideSignals = {
|
|
6533
6542
|
servedShapeRepair: servedShapeRepair.needsRebuild,
|
|
6534
6543
|
executeReclaim: false,
|
|
6535
6544
|
subagentExecute: !args.fullFeatureMode && args.schedulerDecision === "execute",
|
|
6536
|
-
hardFold: rewritingSignedPrefix || foldBustsServedPrefixThisPass || firstRenderBust
|
|
6545
|
+
hardFold: rewritingSignedPrefix || foldBustsServedPrefixThisPass || firstRenderBust,
|
|
6537
6546
|
force: emergencyDropEligible && (args.contextUsage.percentage >= 95 || args.contextUsageFromEstimate !== true && getEmergencyInputSample(args.db, args.sessionId) === 0),
|
|
6538
6547
|
explicitFlush: isExplicitFlush && hasPendingMaterializationOrigin(args.pendingMaterializationSessions, args.sessionId, "user_flush"),
|
|
6539
6548
|
publishedHistory: !prefixPreflightFailed && (publishedM1RefreshedThisPass || !m0M1EnabledForFold && (args.pendingCompartmentInjection?.compartmentCount ?? 0) > 0 && legacyPublishedHeadChanged(args))
|
|
@@ -6542,7 +6551,7 @@ async function runPostTransformPhase2(args) {
|
|
|
6542
6551
|
rideSignals.executeReclaim = !compactionOff && originateExecuteReclaim({
|
|
6543
6552
|
db: args.db,
|
|
6544
6553
|
sessionId: args.sessionId,
|
|
6545
|
-
primaryExecute: args.fullFeatureMode && args.schedulerDecision === "execute" && args.contextUsage.percentage < args.forceMaterializationPercentage,
|
|
6554
|
+
primaryExecute: args.fullFeatureMode && args.schedulerDecision === "execute" && (args.contextUsage.percentage < args.forceMaterializationPercentage || forceRideWaitsOnLocalCount),
|
|
6546
6555
|
alreadyBusting: Object.values(rideSignals).some(Boolean) || args.historyRebuiltThisPass,
|
|
6547
6556
|
summaryCanCome: compartmentRunning || args.sessionMeta.compartmentInProgress || (prefixPreflightFailed || freezeM0M1 || activeThinkingPrefixHold) && (args.deferredHistoryRefreshSessions.has(args.sessionId) || args.deferredMaterializationSessions.has(args.sessionId) || args.historyRefreshSessions?.has(args.sessionId) === true) || readExecuteReclaimState(args.db, args.sessionId).floorOrdinal !== null,
|
|
6548
6557
|
reclaimableTokens: estimateExecuteReclaimTokens({
|
|
@@ -6558,11 +6567,10 @@ async function runPostTransformPhase2(args) {
|
|
|
6558
6567
|
const publishedWorkDrainAllowed = (!compactionOff || servedShapeRepair.needsRebuild) && reclaimRidePermitted(rideSignals, {
|
|
6559
6568
|
signedThinkingHold: activeThinkingPrefixHold,
|
|
6560
6569
|
firstRender: firstRenderBust,
|
|
6561
|
-
|
|
6562
|
-
emergency: emergencyDropEligible
|
|
6570
|
+
emergency: forceBandConfirmed
|
|
6563
6571
|
});
|
|
6564
6572
|
const shouldApplyPendingOps = !compactionOff && publishedWorkDrainAllowed;
|
|
6565
|
-
const shouldRunHeuristics = !compactionOff && publishedWorkDrainAllowed && (rideSignals.publishedHistory || rideSignals.executeReclaim || rideSignals.servedShapeRepair || materializationRequested || forceMaterialization || foldBustsServedPrefixThisPass || firstRenderBust ||
|
|
6573
|
+
const shouldRunHeuristics = !compactionOff && publishedWorkDrainAllowed && (rideSignals.publishedHistory || rideSignals.executeReclaim || rideSignals.servedShapeRepair || materializationRequested || forceMaterialization || foldBustsServedPrefixThisPass || firstRenderBust || emergencyDropEligible || args.schedulerDecision === "execute" && (!alreadyRanThisTurn || !args.fullFeatureMode));
|
|
6566
6574
|
const isCacheBustingPass = publishedWorkDrainAllowed;
|
|
6567
6575
|
if (servedShapeRepair.needsRebuild && !isCacheBustingPass)
|
|
6568
6576
|
throw new Error("Served-shape repair requires a rebuilding pass");
|
|
@@ -6583,7 +6591,7 @@ async function runPostTransformPhase2(args) {
|
|
|
6583
6591
|
const recoveryHeadlessRebuild = !recoveryHasHistoryHead && (args.schedulerDecision === "execute" || isExplicitFlush || forceMaterialization || emergencyDropEligible);
|
|
6584
6592
|
const recoveredShapeRewriteProof = recoveryHeadChangedThisPass ? "head_bytes" : recoveryExternalFoldCause ?? (recoveryHeadlessRebuild ? "headless_rebuild" : null);
|
|
6585
6593
|
const canNormalizeRecoveredShape = isCacheBustingPass && !activeThinkingPrefixHold && recoveredShapeRewriteProof !== null;
|
|
6586
|
-
sessionLog2(args.sessionId, `rewrite permission: allowed=${isCacheBustingPass} ${reclaimRideLabel(rideSignals)} served_shape_repair=${servedShapeRepair.needsRebuild} signed_prefix_release=${rewritingSignedPrefix} fold_prefix_loss=${foldBustsServedPrefixThisPass} first_render=${firstRenderBust}
|
|
6594
|
+
sessionLog2(args.sessionId, `rewrite permission: allowed=${isCacheBustingPass} ${reclaimRideLabel(rideSignals)} served_shape_repair=${servedShapeRepair.needsRebuild} signed_prefix_release=${rewritingSignedPrefix} fold_prefix_loss=${foldBustsServedPrefixThisPass} first_render=${firstRenderBust} cache_expired=${args.m0M1?.hardSignals?.cacheExpired === true} thinking_hold=${activeThinkingPrefixHold} recovery_has_head=${recoveryHasHistoryHead} recovery_head_changed=${recoveryHeadChangedThisPass} recovery_headless_rebuild=${recoveryHeadlessRebuild} proven_external_fold=${recoveryExternalFoldCause ?? "none"} recovered_shape_proof=${recoveredShapeRewriteProof ?? "none"}`);
|
|
6587
6595
|
let recoveryTailNormalizedThisPass = false;
|
|
6588
6596
|
if (args.normalizeRecoveryTail && canNormalizeRecoveredShape) {
|
|
6589
6597
|
args.normalizeRecoveryTail();
|
|
@@ -6772,16 +6780,16 @@ async function runPostTransformPhase2(args) {
|
|
|
6772
6780
|
wordRules: args.cavemanTextCompression.wordRules
|
|
6773
6781
|
} : undefined;
|
|
6774
6782
|
const heuristicTags = shouldApplyPendingOps ? getActiveTagsBySession2(args.db, args.sessionId) : args.tags;
|
|
6775
|
-
const emergencyRewriteAlreadyPriced = pendingOpsDidMutate || foldBustsServedPrefixThisPass || firstRenderBust ||
|
|
6776
|
-
if (
|
|
6783
|
+
const emergencyRewriteAlreadyPriced = pendingOpsDidMutate || foldBustsServedPrefixThisPass || firstRenderBust || args.historyRebuiltThisPass || args.compartmentInjectionRebuiltFromDb || args.rebuiltHistoryFromInitialPrepare;
|
|
6784
|
+
if (forceBandConfirmed && emergencyRewriteAlreadyPriced && getEmergencyInputSample(args.db, args.sessionId) > 0) {
|
|
6777
6785
|
clearEmergencyDropSample(args.db, args.sessionId);
|
|
6778
6786
|
}
|
|
6779
|
-
let routineCleanupApplied = (
|
|
6787
|
+
let routineCleanupApplied = (forceBandConfirmed ? args.contextUsage.percentage >= 95 || getEmergencyInputSample(args.db, args.sessionId) === 0 : !args.fullFeatureMode || !routinePressureAlreadyApplied) || materializationRequested || emergencyRewriteAlreadyPriced;
|
|
6780
6788
|
let cleanup = applyHeuristicCleanup(args.sessionId, args.db, newTargets, args.messageTagNumbers, {
|
|
6781
6789
|
protectedTagNumbers: args.protectedTagNumbers,
|
|
6782
6790
|
protectedCutoff: args.protectedCutoff,
|
|
6783
6791
|
protectedToolTags,
|
|
6784
|
-
emergency:
|
|
6792
|
+
emergency: forceBandConfirmed && args.emergencyCeilingTokens !== undefined && args.emergencyCeilingTokens > 0 ? {
|
|
6785
6793
|
currentTotalInputTokens: args.contextUsage.inputTokens,
|
|
6786
6794
|
ceilingTokens: args.emergencyCeilingTokens,
|
|
6787
6795
|
usagePercentage: args.contextUsage.percentage,
|
|
@@ -6917,7 +6925,7 @@ async function runPostTransformPhase2(args) {
|
|
|
6917
6925
|
args.lastHeuristicsTurnId.set(args.sessionId, args.currentTurnId);
|
|
6918
6926
|
}
|
|
6919
6927
|
}
|
|
6920
|
-
if (
|
|
6928
|
+
if (forceBandConfirmed && (pendingOpsDidMutate || heuristicOrReasoningDidMutate)) {
|
|
6921
6929
|
setEmergencyDropSample(args.db, args.sessionId, args.contextUsage.inputTokens);
|
|
6922
6930
|
}
|
|
6923
6931
|
const toolReclaimApplicationOpportunity = isCacheBustingPass;
|
|
@@ -7235,6 +7243,8 @@ async function runPostTransformPhase2(args) {
|
|
|
7235
7243
|
const historyWasConsumedThisPass = (!m0M1Enabled || deliveredPrefix?.injected === true && !deliveredPrefix.materializationContentionRetryExhausted) && args.historyRebuiltThisPass && (args.canConsumeDeferredLate || args.phaseJustAwaitedPublication || explicitRebuildHappened) && materializationSatisfied;
|
|
7236
7244
|
let suppressV12HistoryDrain = false;
|
|
7237
7245
|
let persistedCompactionMarkerState = replaySnapshot?.compactionMarker ?? null;
|
|
7246
|
+
if (replaySnapshot?.pendingCompactionMarker && (args.compactionMarkerStrategy ?? defaultCompactionMarkerStrategy2).applyDeferred === applyDeferredCompactionMarker)
|
|
7247
|
+
startCompactionMarkerCandidatePreparation(args.sessionId);
|
|
7238
7248
|
if (historyWasConsumedThisPass && args.deferredHistoryWasPendingAtPassStart) {
|
|
7239
7249
|
const pending = replaySnapshot?.pendingCompactionMarker ?? null;
|
|
7240
7250
|
if (pending) {
|
|
@@ -7249,7 +7259,7 @@ async function runPostTransformPhase2(args) {
|
|
|
7249
7259
|
} else {
|
|
7250
7260
|
const tMarkerDrain = performance.now();
|
|
7251
7261
|
const strategy = args.compactionMarkerStrategy ?? defaultCompactionMarkerStrategy2;
|
|
7252
|
-
const candidatesReady = strategy.applyDeferred !== applyDeferredCompactionMarker ||
|
|
7262
|
+
const candidatesReady = strategy.applyDeferred !== applyDeferredCompactionMarker || startCompactionMarkerCandidatePreparation(args.sessionId) === "ready";
|
|
7253
7263
|
const outcome = candidatesReady ? strategy.applyDeferred(args.db, args.sessionId, pending, args.sessionDirectory) : { kind: "deferred", reason: "candidate-preparation" };
|
|
7254
7264
|
logTransformTiming(args.sessionId, "pp.markerDrain", tMarkerDrain, `outcome=${outcome.kind}`);
|
|
7255
7265
|
switch (outcome.kind) {
|
|
@@ -7647,7 +7657,7 @@ async function runPostTransformPhase2(args) {
|
|
|
7647
7657
|
}
|
|
7648
7658
|
}
|
|
7649
7659
|
}
|
|
7650
|
-
const prefixEditBesidesReasoningTrim = firstRenderBust ||
|
|
7660
|
+
const prefixEditBesidesReasoningTrim = firstRenderBust || materializationRequested || explicitMaterializedSuccessfully || deferredMaterializedSuccessfully || foldBustsServedPrefixThisPass || publishedM1RefreshedThisPass || m0RematerializedThisPass || m0M1InjectedThisPass && historyWasConsumedThisPass || historyWasConsumedThisPass || pendingOpsDidMutate || heuristicOrReasoningEditBesidesTrim || emergency || autoReclaimDidMutateThisPass || convertedToolSkeletonsDidMutate || deferredClearedMarkerRetires || noteNudgeAppendedThisPass || todoAnchorMovedThisPass || autoSearchHintAppendedThisPass || dropModeSwitchesThisPass || recoveryTailNormalizedThisPass || firstApplicationEdits.beforeNewerThinking;
|
|
7651
7661
|
let proactiveThinkingStrip = null;
|
|
7652
7662
|
if (!compactionOff && args.thinkingBindingRecoveryEnabledForModel === true && proactiveThinkingStripPermitted && prefixEditBesidesReasoningTrim) {
|
|
7653
7663
|
const outcome = freezeReasoningOnBustingPass2({
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
rawMessageWorkerSource2,
|
|
20
20
|
rawMessageOffThreadRangeReader2,
|
|
21
21
|
readRawSessionMessageIdOrdinalsForRange2
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-1j8m4ad0.js";
|
|
23
23
|
import {
|
|
24
24
|
readV2ArchiveOffThread2
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-7y8c2n52.js";
|
|
26
26
|
|
|
27
27
|
// src/tools/ctx-expand/search-archive.ts
|
|
28
28
|
var archiveReadsOnThisThread = 0;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
releaseCompartmentLeaseBestEffort,
|
|
9
9
|
getCompartments,
|
|
10
10
|
getLastCompartmentEndMessage
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-dasvhxwg.js";
|
|
12
12
|
import {
|
|
13
13
|
inRootAsyncContext2
|
|
14
14
|
} from "./index-gzy5w8ya.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
getHistorianFailureState,
|
|
21
21
|
clearEmergencyRecovery,
|
|
22
22
|
prepareRawSessionOrdinals2
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-1j8m4ad0.js";
|
|
24
24
|
import {
|
|
25
25
|
pushNotification2
|
|
26
26
|
} from "./index-x8a7jmkh.js";
|
|
@@ -32,14 +32,14 @@ import {
|
|
|
32
32
|
getActiveCompartmentRun,
|
|
33
33
|
markActiveCompartmentRunPublished,
|
|
34
34
|
registerActiveCompartmentRun
|
|
35
|
-
} from "./index-
|
|
35
|
+
} from "./index-wapyeb06.js";
|
|
36
36
|
import {
|
|
37
37
|
sendStatusNotification2
|
|
38
38
|
} from "./index-ae1ar4v1.js";
|
|
39
39
|
import {
|
|
40
40
|
setRecompStarting2,
|
|
41
41
|
setRecompTerminal2
|
|
42
|
-
} from "./index-
|
|
42
|
+
} from "./index-24y47287.js";
|
|
43
43
|
|
|
44
44
|
// src/hooks/magic-context/wrapup-orchestrator.ts
|
|
45
45
|
import * as crypto from "node:crypto";
|
|
@@ -26,9 +26,10 @@ var missingWorkerWarnings = new Set;
|
|
|
26
26
|
var ownWriteRevisions = new Map;
|
|
27
27
|
var exitRegistered = false;
|
|
28
28
|
function reportWorkerUnavailable(entry, detail) {
|
|
29
|
-
|
|
29
|
+
const key = `${entry.href}\x00${detail}`;
|
|
30
|
+
if (missingWorkerWarnings.has(key))
|
|
30
31
|
return;
|
|
31
|
-
missingWorkerWarnings.add(
|
|
32
|
+
missingWorkerWarnings.add(key);
|
|
32
33
|
const path = entry.protocol === "file:" ? fileURLToPath(entry) : entry.href;
|
|
33
34
|
log2(`[magic-context] [ERROR] compaction-marker: candidate worker unavailable ${path}: ${detail}; marker unchanged, advancement deferred`);
|
|
34
35
|
}
|
|
@@ -64,6 +65,9 @@ function invalidateMarkerCandidateBasis2(db, sessionId) {
|
|
|
64
65
|
if (revision !== undefined)
|
|
65
66
|
ownWriteRevisions.set(key, revision + 1);
|
|
66
67
|
}
|
|
68
|
+
function discardMarkerCandidateBasis2(db, sessionId) {
|
|
69
|
+
candidates.get(db)?.delete(sessionId);
|
|
70
|
+
}
|
|
67
71
|
function readMarkerCandidateBasis2(db, sessionId, readConnection = db) {
|
|
68
72
|
const basis = candidates.get(db)?.get(sessionId);
|
|
69
73
|
if (basis) {
|
|
@@ -94,7 +98,7 @@ function prepareMarkerCandidateBasis2(db, sessionId, options = {}) {
|
|
|
94
98
|
reportWorkerUnavailable(entry, "file missing");
|
|
95
99
|
return Promise.resolve(false);
|
|
96
100
|
}
|
|
97
|
-
const preparation = runCandidateWorker(path, sessionId, options).then((snapshot) => {
|
|
101
|
+
const preparation = runCandidateWorker(path, sessionId, options.references !== false, options).then((snapshot) => {
|
|
98
102
|
if (!snapshot)
|
|
99
103
|
return false;
|
|
100
104
|
const basis = {
|
|
@@ -124,7 +128,7 @@ function prepareMarkerCandidateBasis2(db, sessionId, options = {}) {
|
|
|
124
128
|
function markerWorkerEntry() {
|
|
125
129
|
return new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./compaction-marker-candidates-worker.ts" : "./compaction-marker-candidates-worker.js", import.meta.url);
|
|
126
130
|
}
|
|
127
|
-
function runCandidateWorker(path, sessionId, options) {
|
|
131
|
+
function runCandidateWorker(path, sessionId, references, options) {
|
|
128
132
|
if (!exitRegistered) {
|
|
129
133
|
exitRegistered = true;
|
|
130
134
|
const controller = new AbortController;
|
|
@@ -164,10 +168,14 @@ function runCandidateWorker(path, sessionId, options) {
|
|
|
164
168
|
timer.unref?.();
|
|
165
169
|
};
|
|
166
170
|
try {
|
|
167
|
-
|
|
171
|
+
const pooled = !options.entry || options.shareWorker === true;
|
|
172
|
+
worker = inRootAsyncContext2(() => pooled ? reuseWorker(entry, { workerData: { path, sessionId, references } }) : new Worker(entry, { workerData: { path, sessionId, references } }));
|
|
168
173
|
workers.add(worker);
|
|
169
174
|
worker.unref();
|
|
170
|
-
|
|
175
|
+
if (pooled)
|
|
176
|
+
worker.once("online", () => deadline(options.acceptMs ?? 2000));
|
|
177
|
+
else
|
|
178
|
+
deadline(options.acceptMs ?? 2000);
|
|
171
179
|
worker.on("message", (reply) => {
|
|
172
180
|
if (reply.kind === "accepted")
|
|
173
181
|
deadline(options.resultMs ?? 600000);
|
|
@@ -205,20 +213,64 @@ function scanMarkerSummaryCandidates(db, sessionId) {
|
|
|
205
213
|
db.exec("ROLLBACK");
|
|
206
214
|
}
|
|
207
215
|
}
|
|
208
|
-
function scanMarkerCandidateSnapshot2(db, sessionId) {
|
|
216
|
+
function scanMarkerCandidateSnapshot2(db, sessionId, references = true) {
|
|
209
217
|
const ownsSnapshot = !db.inTransaction;
|
|
210
218
|
if (ownsSnapshot)
|
|
211
219
|
db.exec("BEGIN");
|
|
212
220
|
try {
|
|
213
221
|
const ids = scanMarkerSummaryCandidates(db, sessionId);
|
|
214
|
-
const frontier = db
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
return {
|
|
222
|
+
const frontier = readMarkerFrontier(db, "message");
|
|
223
|
+
if (!references)
|
|
224
|
+
return { ids, frontier };
|
|
225
|
+
return {
|
|
226
|
+
ids,
|
|
227
|
+
frontier,
|
|
228
|
+
references: {
|
|
229
|
+
partIds: readMarkerReferenceRows2(db, sessionId, "part").map((row) => row.id),
|
|
230
|
+
partFrontiers: readMarkerFrontiers2(db, "part")
|
|
231
|
+
}
|
|
232
|
+
};
|
|
218
233
|
} finally {
|
|
219
234
|
if (ownsSnapshot)
|
|
220
235
|
db.exec("ROLLBACK");
|
|
221
236
|
}
|
|
222
237
|
}
|
|
238
|
+
function readMarkerFrontier(db, table) {
|
|
239
|
+
const frontier = db.prepare(`SELECT rowid,id FROM ${table} ORDER BY rowid DESC LIMIT 1`).all()[0] ?? null;
|
|
240
|
+
if (frontier && !Number.isSafeInteger(frontier.rowid))
|
|
241
|
+
throw new Error(`marker ${table} frontier rowid is not a safe integer`);
|
|
242
|
+
return frontier;
|
|
243
|
+
}
|
|
244
|
+
var MARKER_FRONTIER_CANDIDATES = 3;
|
|
245
|
+
function readMarkerFrontiers2(db, table, count = MARKER_FRONTIER_CANDIDATES) {
|
|
246
|
+
const frontiers = db.prepare(`SELECT rowid,id FROM ${table} ORDER BY rowid DESC LIMIT ?`).all(count);
|
|
247
|
+
if (frontiers.some((frontier) => !Number.isSafeInteger(frontier.rowid)))
|
|
248
|
+
throw new Error(`marker ${table} frontier rowid is not a safe integer`);
|
|
249
|
+
return frontiers;
|
|
250
|
+
}
|
|
251
|
+
var MARKER_REFERENCE_FRONTIER_SQL = (table) => `SELECT rowid FROM ${table} WHERE id = ?`;
|
|
252
|
+
function certifiedMarkerReferenceFloor2(db, table, frontiers) {
|
|
253
|
+
if (frontiers.length === 0)
|
|
254
|
+
return 0;
|
|
255
|
+
const probe = db.prepare(MARKER_REFERENCE_FRONTIER_SQL(table));
|
|
256
|
+
for (const frontier of [...frontiers].sort((a, b) => b.rowid - a.rowid)) {
|
|
257
|
+
const current = probe.all(frontier.id);
|
|
258
|
+
if (current[0]?.rowid === frontier.rowid)
|
|
259
|
+
return frontier.rowid;
|
|
260
|
+
}
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
var MARKER_TAIL_REFERENCE_COLUMNS = `id,
|
|
264
|
+
CASE WHEN data LIKE '%tail_start_id%' THEN json_extract(data, '$.tail_start_id') END AS direct,
|
|
265
|
+
CASE WHEN data LIKE '%tail_start_id%' THEN json_extract(data, '$.compaction.tail_start_id') END AS nested`;
|
|
266
|
+
function readMarkerReferenceRows2(db, sessionId, table, afterRowid) {
|
|
267
|
+
return db.prepare(`SELECT ${MARKER_TAIL_REFERENCE_COLUMNS} FROM ${table}
|
|
268
|
+
WHERE ${afterRowid === undefined ? "session_id = ?" : "rowid > ? AND +session_id = ?"}
|
|
269
|
+
AND ${table === "part" ? "data LIKE '%compaction%' AND json_valid(data) AND json_extract(data, '$.type') = 'compaction'" : "(data LIKE '%compaction%' OR data LIKE '%tail_start_id%') AND json_valid(data) AND (json_type(data, '$.compaction') IS NOT NULL OR json_type(data, '$.tail_start_id') IS NOT NULL)"}`).all(...afterRowid === undefined ? [sessionId] : [afterRowid, sessionId]);
|
|
270
|
+
}
|
|
271
|
+
function readKnownMarkerReferenceRows2(db, sessionId, table, ids) {
|
|
272
|
+
const byId = db.prepare(`SELECT ${MARKER_TAIL_REFERENCE_COLUMNS} FROM ${table} WHERE id = ? AND session_id = ?`);
|
|
273
|
+
return ids.flatMap((id) => byId.all(id, sessionId));
|
|
274
|
+
}
|
|
223
275
|
|
|
224
|
-
export { isMarkerCandidateBasisCurrent2, invalidateMarkerCandidateBasis2, readMarkerCandidateBasis2, prepareMarkerCandidateBasis2, scanMarkerCandidateSnapshot2 };
|
|
276
|
+
export { isMarkerCandidateBasisCurrent2, invalidateMarkerCandidateBasis2, discardMarkerCandidateBasis2, readMarkerCandidateBasis2, prepareMarkerCandidateBasis2, scanMarkerCandidateSnapshot2, readMarkerFrontiers2, certifiedMarkerReferenceFloor2, readMarkerReferenceRows2, readKnownMarkerReferenceRows2 };
|