Skip to content

2026.08.16 - Implement Residual DCP Metadata Stripping - #54

Merged
lanhhoang merged 9 commits into
masterfrom
20260816-strip-residual-metadata
Aug 16, 2026
Merged

2026.08.16 - Implement Residual DCP Metadata Stripping#54
lanhhoang merged 9 commits into
masterfrom
20260816-strip-residual-metadata

Conversation

@lanhhoang

Copy link
Copy Markdown
Contributor

Implement the plan in #53.

  • Add DCP_RESIDUAL_INLINE regex (src/messages/strip.ts) to strip prefix-less -dcp-message-id> and dcp-system-reminder> residual fragments. Documented false positive: dcp-message-id foo>barbar.
  • Extend stripHallucinationsFromString signature with optional knownRefs?: ReadonlySet<string>; add private stripKnownRefsFromString helper that strips bare m#### refs from the injected session set, sorted longest-first with word-boundary anchors.
  • Wire the known-refs snapshot into the message_end handler in src/index.ts: notify "info" when the sanitizer changes the message, notify "warning" (defense-in-depth) when the sanitizer is a no-op but a residual pattern remains in the visible text.
  • Add 8 + 8 + 4 tests covering the residual regex, the known-refs helper, and the notify branches. Existing 9 strip tests still pass.
  • Add [Unreleased] changelog entry.

End-of-line residual regex (a separate DCP_RESIDUAL_EOL) was deliberately dropped per docs/07-addendum-residual-regex.md: a general EOL regex cannot distinguish truncated residuals from prose that mentions the namespace phrase. That case is covered by the looksLikeUnproductiveTurn-style warning notify instead.

@lanhhoang
lanhhoang merged commit f3eae4a into master Aug 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant