fix: stop failing the build on a page that says it has no events
Infinity Nikki's wiki prints "There are no Events in this category" between versions, and the refresh runner has honoured that since 2026-09-03 — it stores the empty parse as the source's real answer rather than letting a quiet lane reach the broken tier. The feed build never asked, so the same page arrived at CI as parsedCount 0, indistinguishable from a parser that has stopped reading a redesigned page, and brokenSources failed every build while every refresh stayed green. The runner's verdict cannot travel on its own: only a parser has seen the page, and by the time brokenSources runs there is nothing left but the feed. So the fact rides on SourceHealth, defaulted so an older feed the service worker cached keeps validating and reads as the strict answer. Both ends now ask it the same way — of an empty parse only, from the page's own words only — because a redesign yields zero rows too, and excusing that is the silently emptied calendar the gate exists for. The rule sits in a module rather than in build-feed.ts, which writes public/ and so runs a build if a test imports it. That is how the two ends drifted apart with nothing to catch it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
e51585f2b2
commit
1156c358a7
+11
-32
@@ -10,6 +10,7 @@
|
||||
* bun run build:feed
|
||||
*/
|
||||
import { ADAPTERS } from "../src/ingest/adapters/index.ts";
|
||||
import { sourceHealth } from "../src/ingest/health.ts";
|
||||
import { mergeEvents } from "../src/ingest/merge.ts";
|
||||
import { SnapshotStore, freshnessAt } from "../src/ingest/snapshots.ts";
|
||||
import { EventFeed, SCHEMA_VERSION, type SourceHealth } from "../src/shared/feed.ts";
|
||||
@@ -69,44 +70,22 @@ for (const adapter of ADAPTERS) {
|
||||
game: adapter.game,
|
||||
});
|
||||
|
||||
// Parsed a second time as of the document's own capture date, when nothing
|
||||
// in it had expired yet. That figure is what separates "this parser has
|
||||
// stopped reading the page" from "this page's events have all finished
|
||||
// since it was captured" — the two are the same zero once expiry has been
|
||||
// applied, and only the first means our code is wrong.
|
||||
// Null when we do not know when these bytes were current: there is no date
|
||||
// to parse "as of", and inventing one would manufacture a figure the check
|
||||
// then trusts. Unknown is a real answer here, and `brokenSources` declines
|
||||
// to fail a build on it.
|
||||
const parsedCount =
|
||||
at === null
|
||||
? null
|
||||
: adapter.parse(html, {
|
||||
now: at,
|
||||
sourceUrl: adapter.url,
|
||||
sourceId: adapter.id,
|
||||
game: adapter.game,
|
||||
}).length;
|
||||
// Which of the three empties this is, decided in a module a test can reach
|
||||
// rather than here — see `src/ingest/health.ts` for why that matters.
|
||||
const health = sourceHealth(adapter, html, at, events.length);
|
||||
const { parsedCount } = health;
|
||||
|
||||
const groups = byGame.get(adapter.game) ?? [];
|
||||
groups.push(events);
|
||||
byGame.set(adapter.game, groups);
|
||||
|
||||
sources.push({
|
||||
sourceId: adapter.id,
|
||||
game: adapter.game,
|
||||
url: adapter.url,
|
||||
// When the bytes were last confirmed live; a fixture's capture date when
|
||||
// this source has never been refreshed.
|
||||
lastSuccessAt: at,
|
||||
eventCount: events.length,
|
||||
parsedCount,
|
||||
});
|
||||
sources.push(health);
|
||||
|
||||
// A source that parsed events and then lost them all to the calendar says
|
||||
// so on the build log, because a bare "0 events" reads as a fault.
|
||||
const note =
|
||||
events.length === 0 && parsedCount !== null && parsedCount > 0
|
||||
// A source that came back with nothing says which nothing it was, because a
|
||||
// bare "0 events" reads as a fault and two of the three are not one.
|
||||
const note = health.statesNoEvents
|
||||
? " (the page states it currently lists none)"
|
||||
: events.length === 0 && parsedCount !== null && parsedCount > 0
|
||||
? ` (all ${parsedCount} have ended — stale page)`
|
||||
: "";
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user