fix: add structural noise filtering for system traces and raw blobs#149
fix: add structural noise filtering for system traces and raw blobs#149eisen0419 wants to merge 1 commit intoCortexReach:masterfrom
Conversation
Add STRUCTURAL_NOISE_PATTERNS to noise-filter.ts covering: - System: prefixed runtime messages - Compaction/model-switch/session-management traces - OpenClaw (untrusted metadata) wrapper remnants - Pure JSON objects and XML-wrapped content - Multi-line blockquote blobs (>= 3 quoted lines) New filterStructuralNoise option (default: true) in NoiseFilterOptions. Closes CortexReach#127
CI failure noteThe CI failure is a pre-existing issue on The This version mismatch exists on the current |
Review: fix: add structural noise filtering for system traces and raw blobsVerdict: Fix-then-merge — two pattern-level issues need addressing before this is safe to ship. ✅ What's working
🔴 Blocking1. 2. XML/HTML pattern is not anchored and will false-positive on real user content
For the intended use case (filtering OpenClaw's /^<(relevant-memories|memory-context|system-context)>[\s\S]*<\/\1>/iOr anchor to the full string ( 🟡 Suggested before merge3.
Suggested fix: /\bmodel\s+(switched?|changed|swapped?)\b/i
/\bsession\s+(reset|restarted?|started?|ended?)\b/i4. No negative test cases for the three risky patterns — especially important here given the false positive surface. The |
|
Correction to my previous comment — the suggested regex fix was wrong on two counts:
The correct minimal fix is to add /\bmodel\s+(switch|switched|changed|swap)\b/i
/\bsession\s+(reset|restart|start|end)\b/iWith this:
One remaining limitation: |
Summary
noise-filter.tspreviously only filtered surface-level noise (greetings, denials, meta-questions), but missed structural memory contamination: runtime traces, raw conversation blobs, and metadata wrappers that silently degrade memory corpus quality over time.Changes
src/noise-filter.ts: AddedSTRUCTURAL_NOISE_PATTERNSarray covering:System:prefixed runtime messages(untrusted metadata):wrapper remnants{...})<tag>...</tag>)filterStructuralNoiseoption inNoiseFilterOptions(default:true)test/noise-filter-structural.test.mjs: 10 test cases covering all new patterns + opt-out behaviorTest plan
isNoise()behavior preserved (new patterns are additive)filterStructuralNoise: falsedisables the new filtersCloses #127