Skip to content

Commit 4b2c566

Browse files
committed
fix: close 3 Oracle-identified gaps in cache-bust fixes
- Wire clearInjectionCache into session lifecycle via onSessionCacheInvalidated (compaction + deletion now clear stale cache) - Gate catch-path nudgePlacements.clear behind isCacheBustingPass (defer-pass exceptions no longer trigger re-anchoring)
1 parent 34d95dc commit 4b2c566

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/hooks/magic-context/hook.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { getErrorMessage } from "../../shared/error-message";
2525
import { log } from "../../shared/logger";
2626
import { createMagicContextCommandHandler } from "./command-handler";
2727
import { createEventHandler } from "./event-handler";
28+
import { clearInjectionCache } from "./inject-compartments";
2829
import { createNudger } from "./nudger";
2930
import { createTextCompleteHandler } from "./text-complete";
3031
import { createNudgePlacementStore, createTransform } from "./transform";
@@ -188,7 +189,10 @@ export function createMagicContextHook(deps: MagicContextDeps) {
188189
tagger: deps.tagger,
189190
db,
190191
nudgePlacements,
191-
onSessionCacheInvalidated: deps.onSessionCacheInvalidated,
192+
onSessionCacheInvalidated: (sessionId: string) => {
193+
clearInjectionCache(sessionId);
194+
deps.onSessionCacheInvalidated?.(sessionId);
195+
},
192196
});
193197

194198
const runDreamQueueInBackground = (): void => {

src/hooks/magic-context/transform-postprocess-phase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ export function runPostTransformPhase(args: RunPostTransformPhaseArgs): void {
229229
} catch (error) {
230230
sessionLog(args.sessionId, "transform failed applying pending operations:", error);
231231
updateSessionMeta(args.db, args.sessionId, { lastTransformError: getErrorMessage(error) });
232-
args.nudgePlacements.clear(args.sessionId);
232+
// Only clear on cache-busting passes to avoid re-anchor on next defer.
233+
if (isCacheBustingPass) args.nudgePlacements.clear(args.sessionId);
233234
}
234235
// Only clear nudge placements on cache-busting passes. Clearing on defer would
235236
// cause the next pass to re-anchor the nudge on a cached assistant message (Finding 2).

0 commit comments

Comments
 (0)