fix(reference): select verified station deterministically

This commit is contained in:
jb
2026-09-19 09:57:48 -04:00
parent 18515efbdf
commit 0c03a59b02
3 changed files with 16 additions and 9 deletions
+4 -2
View File
@@ -27,8 +27,10 @@ try {
assert(verifiedStations > 0);
const joinedStations = Number((db.query<{ n: number }, []>('SELECT COUNT(*) AS n FROM stations st JOIN systems s ON s.system_id = st.system_id JOIN constellations c ON c.constellation_id = s.constellation_id JOIN regions r ON r.region_id = c.region_id').get() as { n: number }).n);
assert.equal(joinedStations, counts.stations, 'every station must join through system, constellation, and region');
const verifiedStation = (await repository.stations({ limit: 1 })).find((station) => station.sourceVerified);
assert(verifiedStation, 'reader must expose a verified station row');
const verifiedStationId = db.query<{ station_id: number }, []>('SELECT station_id FROM stations WHERE source_verified = 1 ORDER BY station_id LIMIT 1').get()?.station_id;
assert(verifiedStationId !== undefined, 'published artifact must contain a verified station row');
const verifiedStation = (await repository.stations([verifiedStationId]))[0];
assert(verifiedStation?.sourceVerified, 'reader must expose the selected verified station row');
assert.deepEqual(await repository.stations([Number.MAX_SAFE_INTEGER]), [], 'unknown station IDs must remain absent rather than fabricated');
const integrity = db.query<{ integrity_check: string }, []>('PRAGMA integrity_check').all();
assert.deepEqual(integrity.map(row => row.integrity_check), ['ok']);