Pass tag confidence scores to AI assignment for weighted matching

The AI assignment path was receiving project tags as flat strings, losing
the confidence scores from AI tagging. Now both the GPT path and the
fallback algorithm weight tag matches by confidence — a 0.9 tag matters
more than a 0.5 one.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-17 09:29:46 +01:00
parent cfeef9a601
commit fbeec846a3
3 changed files with 46 additions and 10 deletions

View File

@@ -52,7 +52,7 @@ export interface AnonymizedProject {
anonymousId: string
title: string
description: string | null
tags: string[]
tags: Array<{ name: string; confidence: number }>
teamName: string | null
}
@@ -209,6 +209,7 @@ interface ProjectInput {
title: string
description?: string | null
tags: string[]
tagConfidences?: Array<{ name: string; confidence: number }>
teamName?: string | null
}
@@ -253,7 +254,9 @@ export function anonymizeForAI(
description: project.description
? truncateAndSanitize(project.description, DESCRIPTION_LIMITS.ASSIGNMENT)
: null,
tags: project.tags,
tags: project.tagConfidences && project.tagConfidences.length > 0
? project.tagConfidences
: project.tags.map((t) => ({ name: t, confidence: 1.0 })),
teamName: project.teamName ? `Team ${index + 1}` : null,
}
}
@@ -524,7 +527,7 @@ export function validateAnonymization(data: AnonymizationResult): boolean {
if (!checkText(project.title)) return false
if (!checkText(project.description)) return false
for (const tag of project.tags) {
if (!checkText(tag)) return false
if (!checkText(typeof tag === 'string' ? tag : tag.name)) return false
}
}