Noise-robust overview: structured-noise stripping + homogeneous-sibling collapse - #19
Merged
Conversation
…s-sibling collapse Real-world vaults often contain large imported/converted document subtrees (OCR'd PDFs, DocuSign exports, HTML conversions) that drown the overview: ID shrapnel from dashed GUIDs survives tokenization and wins TF-IDF, and hundreds of near-identical folders dominate the folder map. Two fixes, benchmarked on a corpus of real agent vaults: - stripNoise now removes GUID/dashed-hex runs, digit-mixed ID blobs, HTML tags/entities, and long hex-letter runs before tokenization. - Numerous, lexically homogeneous sibling folders collapse into one aggregate row (mean pairwise cosine over body+heading terms >= 0.15, >= 5 children, never into the vault root). overview.collapse config (default true), --no-collapse CLI flag, additive collapsedFolders field in --json output. - Warnings now go to stderr so overview --json is always parseable. On the worst benchmarked vault: 242 overview lines -> 11, noise keywords 778 -> 6, curated-keyword robustness 0.71 -> 0.82; clean vaults byte-identical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
napkin overviewexists to prime an agent with the vault's actual vocabulary so lexical search works. On vaults containing large imported/converted document subtrees (OCR'd PDFs, DocuSign exports, HTML conversions), the overview drowns:AB12CD34-5678-4EFA-…) slip past the existing[a-f0-9]{8,}filter because hyphens split them into short fragments ("dab", "bcf"). Each fragment is note-unique, so TF-IDF scores it as highly distinctive — the algorithm structurally rewards garbage.Noise keywords aren't just wasted tokens — they prime the agent to search in noise terms.
Fix
Structured-noise stripping (always on).
stripNoisenow removes GUID/dashed-hex runs, digit-mixed ID blobs, HTML tags/entities, and long hex-letter runs before tokenization. A token-level "wordness" filter was tried and rejected — it killed real vocabulary (pdf,xlsx,fee). You can't judge a 3-letter token; you can recognize a GUID in context.Homogeneous-sibling collapse (
overview.collapseconfig, defaulttrue). Parents with ≥5 children whose mean pairwise term-distribution cosine ≥ 0.15 render as one aggregate row:contracts/ (+153 similar subfolders). Similarity is computed over body+heading terms only — shared naming conventions can't fake content homogeneity — and the vault root is never a collapse target (top-level folders are the taxonomy).--no-collapserestores the full listing; JSON gains an additivecollapsedFoldersfield.Warnings → stderr. Previously a single malformed-frontmatter note corrupted
overview --jsonstdout.Results (benchmark on 8 real-world agent vaults)
* recall of the keywords the same algorithm produces when import subtrees are excluded — i.e. how well pollution is prevented from corrupting curated folders' keywords.
Interactions that shaped the design: collapse is useless without noise-stripping (ID shrapnel makes dump folders look different from each other, blocking collapse); note-level IDF was evaluated and rejected (marginal residual gain, measurable recall cost). The 0.15 threshold sits on a plateau — 0.125–0.175 produce identical collapse sets, and no curated folder collapses even at 0.10.
Notes
(+N similar subfolders)marker.--no-collapse.