fix(collision): treat case/whitespace-variant identities as one person

Vision reports a display name ("Karti") while the git watcher reports a handle ("karti"); the detectors compared engineerId case-sensitively, so the same human collided with themselves. Canonicalize identity at the decision point in both the file and research detectors, keeping the display-cased name for the card.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kartikeya
2026-06-28 10:34:16 -07:00
parent d8eaf8d2e2
commit 79620bccaa
2 changed files with 25 additions and 3 deletions
+7 -1
View File
@@ -24,6 +24,12 @@ function stripGitPrefix(raw: string): string {
return raw.trim().replace(/^(\?\?|[MADRCU!]{1,2})\s+/, '');
}
/** Case/whitespace-insensitive identity so vision "Karti" and git "karti" are
* recognized as the same person and never flagged researching-vs-editing self. */
function canonicalName(raw: string): string {
return raw.trim().toLowerCase();
}
function fileStem(raw: string): string {
const base = stripGitPrefix(raw).split(/[\\/]/).pop()?.trim().toLowerCase() ?? '';
return base.replace(/\.[^.]+$/, '');
@@ -104,7 +110,7 @@ export async function detectResearchOverlaps(
const researchText = [topic, source].filter(Boolean).join(' ');
for (const editor of editorFiles) {
if (editor.engineerId === researcher.engineerId) continue;
if (canonicalName(editor.engineerId) === canonicalName(researcher.engineerId)) continue;
const stem = fileStem(editor.file);
if (!stem) continue;