Skip to content

fix(analytics): recompute cached snapshots after the complete startup load #116

Description

@dborup

Upstream source

Evaluate and adapt Kpa-clawbot/CoreScope#2025: refresh analytics once the entire startup load, including background fill, has terminated.

Current fork evidence

HTTP can bind after the hot chunk. StartAnalyticsRecomputers computes snapshots immediately, then waits roughly five minutes. The RF/topology/channels gate uses LoadComplete, but this becomes true before loadBackgroundChunks fills the retention window. Analytics can therefore serve apparently valid but partial snapshots until the next interval. A lazy distance-index rebuild can create a similar stale snapshot.

Fork-specific adaptation

Enumerate only recomputers that actually exist in this fork. Separate “startup loading terminated” from the existing successful-coverage health meaning of backgroundLoadDone; a failure must wake recomputers without being reported as successful loading.

Acceptance criteria

  • A one-shot terminal signal fires exactly once for all startup-load exit paths.
  • Every current default-shape analytics recomputer runs once after that signal.
  • Manual recomputation runs on each loop and resets its ticker to avoid an immediate duplicate pass.
  • Gated endpoints cannot open based on a pass that began before the terminal signal; force-open partial results are replaced promptly.
  • Ungated endpoints retain current availability; no new 503 behavior.
  • Invalidate dependent caches/throttles before recompute where needed.
  • Distance snapshots refresh before the index reports ready.
  • Existing background-load health/coverage semantics remain unchanged.

Verification

Deterministically cover success/failure/empty/disabled paths, controlled hot/background loads, recompute ordering, ticker reset, and distance 202 → ready; run full server tests under -race, static checks, and timestamp/snapshot comparisons on an isolated large database copy.

No deploy or live-environment mutation is part of this issue.

Activity

  1. dborup commented on Sep 29, 2026

    @dborup
    OwnerAuthor

    Draft PR #145 klar til review: CI grøn (Go Build & Test, Playwright E2E, Docker build). Et engangssignal (StartupLoadDone) affyres på alle udgange af startup-loadet, og derefter genberegnes alle ni analytics-snapshots én gang i rækkefølge. Warm-up-gaten åbner kun på et pass, der startede efter signalet, og distance-snapshottet opdateres, før indekset melder klar. På en lokal fixture viser RF 499 transmissioner lige efter loadet; master viser 213 indtil næste 5-minutters tick. Måling på en stor databasekopi mangler.


    Generated by Claude Code

  2. dborup commented on Oct 1, 2026

    @dborup
    OwnerAuthor

    Fixed by #145 (merged as be35eefb), on top of #151. Follow-ups: the 503 warm-up window now spans the whole background load (still capped by the 60 s force-open) while the frontend retries for about 30 s, tracked in #150; mutant M11 and an extra post-load recompute pass were noted in review as non-blocking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions