← Back to PRs

#22375: fix(audit): use human-readable labels for RegExp patterns in post-compaction audit

by aldoeliacim open 2026-02-21 03:04 View on GitHub →
size: XS trusted-contributor
Fixes #22339 ## Problem Post-compaction audit warnings display raw `.source` output for RegExp entries: ``` memory\/\d{4}-\d{2}-\d{2}\.md ``` This is confusing and has been mistaken for prompt injection. ## Fix - Add `RequiredReadEntry` type supporting `{ pattern: RegExp, label: string }` objects alongside plain strings and RegExp - `DEFAULT_REQUIRED_READS` now uses a labeled entry for the daily memory pattern → displays `memory/YYYY-MM-DD.md` - Plain `RegExp` entries still fall back to `.source` for backward compatibility - Added tests verifying labeled display and plain RegExp fallback ## Testing - All 17 tests pass (`vitest run post-compaction-audit.test.ts`) - 2 new tests: labeled entry display + plain RegExp fallback AI-assisted (Claude) <!-- greptile_comment --> <h3>Greptile Summary</h3> Replaced raw regex `.source` output with human-readable labels for post-compaction audit warnings. The daily memory pattern now displays as `memory/YYYY-MM-DD.md` instead of the confusing escaped regex `memory\/\d{4}-\d{2}-\d{2}\.md`. Implementation adds a new `RequiredReadEntry` union type supporting labeled patterns while maintaining backward compatibility with plain RegExp entries. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - Simple, well-tested change that improves UX without altering core logic. Type-safe implementation with backward compatibility and comprehensive test coverage (2 new tests verify both labeled and plain RegExp behavior). - No files require special attention <sub>Last reviewed commit: 12a6bf7</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs