fix(260907-efh): Fingerabdruck auf Vergabestelle/Titel/Frist verengen

Die dritte Dedup-Stufe hashte bisher fuenf Segmente, darunter CPV-Division
und geschaetzten Wert — beide werden von Nicht-DOE-Quellen systematisch
nie geliefert, wodurch dieselbe Ausschreibung aus DOE und aus einem
Scraper nie denselben Fingerabdruck ergab (WINDOWS.md #11).

- tenderFingerprint() nimmt nur noch buyerName, title, deadlineAt entgegen
- Versionsmarke FINGERPRINT_VERSION_PREFIX ("v2:") vor dem Hash, damit
  Task 3 veraltete Zeilen erkennen kann
- valueBucketsContradict() als eigene, exportierte Funktion fuer den
  Wert-Veto in Task 2 — kein Hash-Bestandteil mehr
- backfill-tender-source.ts an die neue Signatur angepasst
- Testsuite auf das neue Verhalten umgeschrieben inkl. Goldwert-Test

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K5jtbGzC5Sf9npJ3JCjKhq
This commit is contained in:
2026-09-07 10:36:21 +02:00
parent 4502664fb2
commit cb23e3bc78
3 changed files with 156 additions and 82 deletions
+8 -10
View File
@@ -16,8 +16,15 @@
*
* Idempotent: recomputes and overwrites fingerprint for every row it reads,
* so re-running is safe (same deterministic output for unchanged inputs).
*
* This script remains the manual, force-recompute-everything path. As of
* Task 3 of the WINDOWS.md #11 fix, the automatic path for ordinary
* startup is TenderFingerprintBackfillService, which recomputes only rows
* whose stored fingerprint doesn't yet carry FINGERPRINT_VERSION_PREFIX —
* this script stays useful for a deliberate full recompute (e.g. after a
* formula change) or ad-hoc verification.
*/
import { PrismaClient, Prisma } from '@prisma/client';
import { PrismaClient } from '@prisma/client';
import { tenderFingerprint } from './tender-fingerprint';
async function main(): Promise<void> {
@@ -28,9 +35,7 @@ async function main(): Promise<void> {
id: true,
title: true,
buyerName: true,
cpvDivisions: true,
deadlineAt: true,
estimatedValue: true,
},
});
@@ -39,10 +44,7 @@ async function main(): Promise<void> {
const fingerprint = tenderFingerprint({
buyerName: t.buyerName,
title: t.title,
cpvDivisions: t.cpvDivisions,
deadlineAt: t.deadlineAt,
// estimatedValue is Decimal? — convert to number|null before bucketing (T-13-01-03).
estimatedValue: decimalToNumberOrNull(t.estimatedValue),
});
await prisma.tender.update({
where: { id: t.id },
@@ -57,10 +59,6 @@ async function main(): Promise<void> {
}
}
function decimalToNumberOrNull(v: Prisma.Decimal | null): number | null {
return v === null ? null : Number(v);
}
main().catch((err) => {
console.error('backfill-tender-source failed:', err);
process.exitCode = 1;