// Zieht eine feste Zufallsstichprobe aus den automatisch bestätigten Gemeindeseiten für die Prüfung durch Agents. // Der Startwert steht fest, die Auswahl ist damit wiederholbar. Ergebnis: daten/audit/stichprobe-.json import { createHash } from 'node:crypto'; import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const hier = dirname(fileURLToPath(import.meta.url)); const pfad = (d) => join(hier, 'daten', d); const UMFANG = 150; const TEILE = 3; const wert = (s) => createHash('sha256').update(`audit-2026-11-21:${s}`).digest('hex'); const zeilen = readFileSync(pfad('gemeinden-hosting.jsonl'), 'utf8').trim().split('\n').map((z) => JSON.parse(z)).filter((z) => z.inhalt === 'bestaetigt'); const auswahl = zeilen.sort((a, b) => wert(a.ags).localeCompare(wert(b.ags))).slice(0, UMFANG) .map((z) => ({ ags: z.ags, kreis: z.ags.slice(0, 5), gemeinde: z.name, adresse: `https://${z.ziel}/` })); mkdirSync(pfad('audit'), { recursive: true }); for (let t = 0; t < TEILE; t++) writeFileSync(pfad(`audit/stichprobe-${t + 1}.json`), JSON.stringify(auswahl.filter((_, i) => i % TEILE === t), null, 1)); console.log(JSON.stringify({ grundgesamtheit: zeilen.length, stichprobe: auswahl.length }));