feat(DIS-102): sanitizeForDiscord strips paths and tokens before Discord send #46

Merged
dev merged 4 commits from phase-1/sanitize-for-discord into main 2026-04-10 08:05:44 +00:00
Owner

Summary

  • Add sanitizeForDiscord() in src/runtime/sanitize.ts that replaces absolute paths (repoRoot, home) and sensitive tokens (Discord bot tokens, Anthropic API keys) before text reaches Discord
  • Apply sanitizer in src/router.ts to all channel.send() calls and the error message path
  • Add 8 unit tests covering all replacement cases, ordering guarantees, and false-positive safety

Test plan

  • vitest run tests/unit/sanitize-for-discord.test.ts � all 8 tests pass
  • TypeScript compiles cleanly (tsc --noEmit)
  • Verify no path/token appears in a Discord channel during manual smoke test
## Summary - Add `sanitizeForDiscord()` in `src/runtime/sanitize.ts` that replaces absolute paths (repoRoot, home) and sensitive tokens (Discord bot tokens, Anthropic API keys) before text reaches Discord - Apply sanitizer in `src/router.ts` to all `channel.send()` calls and the error message path - Add 8 unit tests covering all replacement cases, ordering guarantees, and false-positive safety ## Test plan - [x] `vitest run tests/unit/sanitize-for-discord.test.ts` � all 8 tests pass - [x] TypeScript compiles cleanly (`tsc --noEmit`) - [ ] Verify no path/token appears in a Discord channel during manual smoke test
dev added 1 commit 2026-04-09 15:48:39 +00:00
feat(DIS-102): sanitizeForDiscord strips paths and tokens before Discord send
Some checks failed
CI / build-and-test (ubuntu-latest) (pull_request) Has been cancelled
CI / build-and-test (windows-latest) (pull_request) Has been cancelled
CI / lint (pull_request) Has been cancelled
7ddc22dc0f
Add sanitizeForDiscord() in src/runtime/sanitize.ts.
Router applies sanitizer to all channel.send() calls.
Prevents path/token leaks into Discord channels.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev force-pushed phase-1/sanitize-for-discord from 7ddc22dc0f to 90f96bdbf4 2026-04-10 07:51:19 +00:00 Compare
dev added 1 commit 2026-04-10 07:58:38 +00:00
fix(DIS-102): handle both slash styles for Windows path sanitization
Some checks failed
CI / build-and-test (ubuntu-latest) (pull_request) Has been cancelled
CI / build-and-test (windows-latest) (pull_request) Has been cancelled
CI / lint (pull_request) Has been cancelled
5869c15f9d
os.homedir() returns backslashes on Windows but Claude Code outputs
paths with forward slashes. Replace both C:\Users\x and C:/Users/x
variants so home and repoRoot are always redacted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev added 1 commit 2026-04-10 08:02:25 +00:00
fix(DIS-102): sanitize response before DB storage to break path feedback loop
Some checks failed
CI / build-and-test (ubuntu-latest) (pull_request) Has been cancelled
CI / build-and-test (windows-latest) (pull_request) Has been cancelled
CI / lint (pull_request) Has been cancelled
714e0c01e5
The root cause was twofold:
1. Raw (unsanitized) agent responses were stored in the conversation
   history DB. On subsequent calls, these paths were fed back to the
   agent as context, causing it to reproduce full paths regardless of
   Discord-side sanitization.
2. repoRoot (workspace_path) was not passed to sanitizeForDiscord,
   so workspace-specific paths were only partially masked via the
   home directory fallback.

Fix: sanitize the full response once before both sending to Discord
and storing in the DB. Pass workspace_path as repoRoot for precise
path replacement. Add Windows path tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev merged commit ce54b4c824 into main 2026-04-10 08:05:44 +00:00
dev deleted branch phase-1/sanitize-for-discord 2026-04-10 08:05:48 +00:00
Sign in to join this conversation.
No description provided.