Tell a broken source apart from a stale one

CI failed on Infinity Nikki yielding no events, and was wrong to. Its
snapshot parses to six events; every one of them had ended by the morning
the build ran. The parser is fine — `--now 2026-08-14` gives six, today
gives none — and the page simply has nothing current left on it.

eventCount is counted after expired events are dropped, so "this parser has
stopped reading a redesigned page" and "this page's events have all
finished" arrived as the same zero. Only the first means our code is wrong,
and only the first should redden a build. So the feed now records what each
document yields parsed as of its own capture date, before expiry, and the
check fails on that instead.

Nikki cannot refresh itself out of this, either: docs/SOURCES.md records
that Fandom refuses the Actions runner. A lane with an empty calendar is a
real problem, but it is a refresh problem, so it is reported on the build
log and left visible rather than thrown.

parsedCount is nullable and defaulted, never required: the client validates
the whole feed with safeParse and the service worker serves the last feed it
downloaded, so a required field would have made every cached feed fail
validation and taken the offline promise with it. Null also covers a source
whose bytes were never confirmed live — there is no date to parse "as of",
and a build is not failed on missing information.

The rule moved to shared/feed.ts. A test did pin the old one, by grepping
the workflow for the string — which proved the check existed, never that it
was right.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Lucas Winther
2026-08-28 05:54:17 +02:00
co-authored by Claude Opus 5
parent 96d5230f29
commit ef109f224b
8 changed files with 177 additions and 15 deletions
+18 -7
View File
@@ -72,14 +72,25 @@ jobs:
}
// Per source, not just in total: nine healthy sources hide a tenth
// that has gone to zero, and the total stays comfortably over the
// floor while one game shows an empty calendar. A live snapshot
// that parsed to nothing is refused upstream and never stored, so
// zero here means the fixture stopped parsing — a regression in our
// code, not a quiet week for that game.
const empty = feed.sources.filter((s) => s.eventCount === 0);
if (empty.length > 0) {
// floor while one game shows an empty calendar.
//
// Which zero it is decides whether this build should fail, and
// the rule lives in shared/feed.ts rather than here. It was
// inline, and a test did pin it — by grepping this file for the
// string. That proved the check existed, never that it was right,
// and it was not: it read eventCount, which is counted after
// expiry, so a page whose events had all simply ended reddened the
// build. Behaviour belongs where behaviour can be exercised.
const { brokenSources, staleSources } = await import("./src/shared/feed.ts");
for (const s of staleSources(feed.sources)) {
console.log(
` note: ${s.sourceId} parsed ${s.parsedCount} events, all of them ended — stale page, not a fault`,
);
}
const broken = brokenSources(feed.sources);
if (broken.length > 0) {
throw new Error(
`sources yielding no events: ${empty.map((s) => s.sourceId).join(", ")}`,
`sources parsing to nothing: ${broken.map((s) => s.sourceId).join(", ")}`,
);
}
'