#22375: fix(audit): use human-readable labels for RegExp patterns in post-compaction audit
size: XS
trusted-contributor
Cluster:
Error Handling Improvements
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
#22494: fix(post-compaction-audit): show readable label for missing regex r...
by Phineas1500 · 2026-02-21
91.8%
#22711: fix: post-compaction audit skips non-existent required files
by taw0002 · 2026-02-21
79.2%
#21285: fix(auto-reply): parse toolCall read paths in post-compaction audit
by Jackten · 2026-02-19
72.9%
#22124: fix(agents): remove non-existent WORKFLOW_AUTO.md from post-compact...
by lailoo · 2026-02-20
72.8%
#21140: test(security): add regression test for claude-opus-4-6 audit
by dinakars777 · 2026-02-19
70.5%
#20465: fix: remove WORKFLOW_AUTO.md from default post-compaction audit reads
by aldoeliacim · 2026-02-19
70.2%
#20241: fix(memory-lancedb): consolidate preference keyword/category detect...
by ciberponk · 2026-02-18
69.9%
#19115: fix(logging): improved redaction for config objects and unquoted keys
by Clawborn · 2026-02-17
68.7%
#18107: fix(security): prevent ReDoS in session filter patterns (CWE-1333)
by brandonwise · 2026-02-16
68.4%
#17244: fix: strip TTS tags from agent replies before delivery (#14652)
by robbyczgw-cla · 2026-02-15
68.0%