Repository navigation
feat(scripts): delete chats that carry Russian, after archiving them (CLEAN-169) - #143
Merged
Merged
Conversation
…(CLEAN-169) The customer-facing dashboard must show no Russian. This removes the chats themselves; the rollup cleanup and the Rancher exclusion live in the fork, where the analytics slice is. Selection is Cyrillic in the transcript, not ChatSession.insights.language. That field is written by the summarizer, which only runs on chats with three or more user messages, so a two-message "привет" never gets one — and the parser keeps whatever string the model returned, defaulting to 'en'. A rule that decides what gets deleted has to be a rule, not a judgment. Cyrillic in the bot reply counts too: the chat list preview renders the last message whatever its role, so a Russian answer to an English question is just as visible to the customer. The dry run is the default here, the inverse of the other scripts, and --delete without --archive is refused: the archive is the only thing that makes this reversible. It is written inside the pod and copied off with kubectl cp, so no copy is left behind on prod. Per chat the row goes first and the S3 object second — the reverse of the CLEAN-168 copy. A row pointing at a missing transcript opens as an empty chat; an object with no row is invisible, and failures are reported by key for a manual sweep. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011B9tuWEQvYg5YQY9SQZN2u
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CLEAN-169
The customer-facing analytics dashboard shows Russian text. This PR removes the chats themselves. The rollup cleanup and dropping Rancher from the dashboard are the other half, and they can only live in the customer fork — the
analyticsslice does not exist here.Why not
insights.languageThat looked like the obvious key and it is the wrong one.
ChatInsightServiceonly summarizes chats with at least three user messages (gate.minUserMessages: 3), so a two-message "привет" has noinsightsat all. Most of the offending chats are two messages long.en(chatInsight.service.ts:273). It is unvalidated LLM output.A rule that decides what gets deleted has to be a rule. This one is: Cyrillic in the transcript,
/[\u0400-\u04FF]/.Cyrillic in the bot reply counts too — the chat list preview renders the last message whatever its role, so a Russian answer to an English question is just as visible to the customer. The dry run prints per-chat counts split by side, so the borderline case (one Russian word in an English conversation) is visible before anything is deleted.
Cyrillic is wider than Russian; Ukrainian and Bulgarian would match. Accepted for this installation, and
detect.tsis the one place to narrow it.Safety
--deleteis required to act, and--deletewithout--archiveis refused: the archive is the only thing that makes this reversible.kubectl cp. No copy stays on prod.ChatSessionrow, then the S3 object. This is the reverse of the CLEAN-168 copy and deliberately so — a row pointing at a missing transcript opens as an empty chat, while an object with no row is invisible. A failed object delete is reported by key for a manual sweep.ChatFeedbackfollows the row byonDelete: Cascade.Leadis untouched: it is installation-wide and the same person may also have English chats.Runbook
Twin consoles
Nothing to check: this touches
api/src/scripts/only, no slice inadmin/orapp/.Gates
bunx jest src/scripts— 18 pass, 2 suites (written first, watched fail, then implemented)bunx jest— 2154 pass, 1 fail:slices/bridle/domain/documentText.extractor.spec.ts:363(PDF text extraction). Pre-existing onorigin/main— verified by stashing this branch and re-running that spec, which fails identically. Not touched by this change.bun run build— clean (needsprisma-import --force+prisma generatefirst after a branch switch, or the stale client reports 133 phantom errors)bunx eslint src/scripts— 0 real findings; the 508 errors are allDelete ␍CRLF noise, the known repo-wide line-ending issue--archive <path> is required with --deleteandunknown flag --nope, both before any DB connection🤖 Generated with Claude Code
https://claude.ai/code/session_011B9tuWEQvYg5YQY9SQZN2u