mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 02:42:24 +03:00
Fix round 1 (adversarial review) of #12150 P1b. Two findings: CRITICAL: applyVideoBridgeLogRedaction matched the video-bridge redaction map by positional {messageIndex, partIndex}, but those positions are computed by the guardrail's preCall while injectSystemPrompt (prepends a system message when none exists), context-relay handoff injection, and reasoning-rule body rewrites all run afterward and can prepend/splice the message array before persistAttemptLogs serializes the log -- silently invalidating the map. A stale index either misses the video part (transcript logged unredacted) or, worse, overwrites an unrelated legitimate message while the transcript still leaks. Fixed by switching to content-address matching: videoBridge.ts's VideoBridgeLogRedactionEntry now carries fullText (the exact unredacted text placed into the part), and applyVideoBridgeLogRedaction scans every part in the named container for an exact text+type match instead of trusting position. messageIndex/partIndex are kept as advisory/debugging metadata only. New "Scenario A" regression test in video-bridge-log-redaction.test.ts reproduces the real injectSystemPrompt shape and proves both the leak and the corruption are fixed. Important: an observed request's response-derived text (the model's own reply, which received the full unredacted transcript) could still populate durable Memory -- only the request-derived text was gated. Extracted the shared decision + extraction wiring into runMemoryExtractionGate (memoryExtraction.ts), which gates both request- and response-derived extractFacts calls behind one shouldExtractMemory() check; chatCore.ts's two call sites (non-streaming, streaming) now each collapse to a single call. video-bridge-memory-suppression.test.ts's hand-mirrored stub was replaced with tests against the real runMemoryExtractionGate, including one isolating the response-derived path specifically. Refs #12150