Behavioral digest hardening (PR #84, @ynaamane)
The behavioral digest was extracting junk rules from Claude Code's synthetic messages. A production store had 572 rules (cap is 20), most were garbage like "Do not <local-command-caveat>...". This release fixes 9 ship-blocker bugs:
- Noise filter:
_is_system_noise()catches<local-command-caveat>,<teammate-message>,/initprompts, and 15+ other CC synthetic patterns before they reach the correction extractor - Prohibition hardening: rejects oversize (>200 char), multi-paragraph, and structural input
- Promotion gate: all rules start "pending", need 2 occurrences to activate (prevents one-shot noise)
- Retroactive purge: loading a pre-polluted store auto-demotes noise rules and persists the cleanup to disk
- Duplicate detection: now requires scope + priority + bigram overlap (catches order-inverted pairs)
- Injection cap:
build_injection_textcapped atMAX_ACTIVE_RULES(20) - CLAUDE_CONFIG_DIR:
_get_memdirhonors the env var for non-default profiles
Follow-up fixes
- Retroactive purge now persists to disk (was in-memory only — re-scanned on every load)
- Boundary tests for
_to_prohibition(exactly 200 chars, exactly 2 newlines) - README documents the 2-occurrence promotion contract
542 tests passing (up from 464). ~6.6B tokens saved, ~19.5K tracked installs, 282 stars.