Skip to content

PHA-1410: instrumentation tick iterates liveEvents(now), not single currentEventId() - #192

Open
phattbeats wants to merge 1 commit into
mainfrom
pha-1410/live-events-iterate
Open

PHA-1410: instrumentation tick iterates liveEvents(now), not single currentEventId()#192
phattbeats wants to merge 1 commit into
mainfrom
pha-1410/live-events-iterate

Conversation

@phattbeats

Copy link
Copy Markdown
Owner

What

One-line semantic change in src/instrumentation.ts: the background live-results tick now iterates liveEvents(now) (mirroring prelock-reminders's registry-driven pattern) instead of calling refreshLiveResultsTick(currentEventId()) for a single event.

Why

Per PHA-950 review: on-read drivers/watchers iterate live events, not a constant. The background tick was the last holdout using the single-id pattern.

The bug: during the (explicitly-supported) overlap window where one Major is archiving on GF-resolve while the next has gone live, the newly-live event's outcomes would not be background-crawled until the older event archives and currentEventId() advances. Under that gap, served pages track currentEvent (handled by the page-side liveEvents derivation), but the BACKGROUND crawler misses the new event entirely.

Current schedule impact: LOW. Cologne archived, Singapore Nov 25 — no overlap. But the next event sequence could hit this.

How

-    const { currentEventId } = await import("@/lib/events-core");
+    const { liveEvents } = await import("@/lib/events-core");
     ...
-        const r = await refreshLiveResultsTick(currentEventId());
-        if (r.ingested > 0 || r.resolved > 0 || r.stale > 0) { ... }
+        const events = liveEvents();
+        for (const ev of events) {
+          const r = await refreshLiveResultsTick(ev.id);
+          if (r.ingested > 0 || r.resolved > 0 || r.stale > 0) { ... }
+        }

Empty list is a valid state between Majors (when no event is currently in its live window) — no-op, no error.

The single-id API refresh routes (standings/refresh, team-stats/refresh, outcomes/ingest) are deliberately untouched — they serve the one active event by request, not by background tick. The route name encodes the scope; currentEventId is the right call there.

Verification

  • TypeScript syntax: the import swap is 1:1 (currentEventId(now): numberliveEvents(now): EventConfig[]); the loop is a plain for..of with the same body. Path alias @/lib/events-core already in tsconfig.json.
  • No test infrastructure (no vitest/jest config in the repo). Manual smoke: deploy to a multi-Major schedule and verify [live-tick] event N: ingested … lines fire for every live event, not just one. Will be covered by the next multi-Major cutover (PHA-1327 follow-up).

Scope

Single file (src/instrumentation.ts), 18 insertions / 7 deletions. No config, no schema, no API changes.

Routing note

This is the first Van Dam wake correctly routed into Van Dam's session since the wake-routing fix (PHA-1490) landed today. The repo (phattbeats/phatt-picks) was reachable locally, the fix was a 1-line semantic swap, and the branch is pushed.

— Claude Van Dam, 2026-07-23

…urrentEventId()

Mirror prelock-reminders' registry-driven pattern. The background live-results
tick previously called refreshLiveResultsTick(currentEventId()), which only
covered the single active event. During the explicit overlap window where
one Major is archiving on GF-resolve while the next has gone live, the
newly-live event's outcomes would not be background-crawled until the older
event archives and currentEventId() advances.

Per PHA-950 intent: on-read drivers/watchers iterate live events, not a constant.

The single-id API refresh routes (standings/refresh, team-stats/refresh,
outcomes/ingest) are untouched — they serve the one active event by request,
not the background tick.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant