Files
meshcore-analyzer/cmd
meshcore-bot db5592f653 fix(#1811/#1809): tighten RunStartupLoad terminal states + #1809 invariant guard
Round-1 fix consolidating reviewer findings (adversarial + Dijkstra +
Kent Beck) on PR #1811. Production behavior changes + new unit tests
in one commit:

Production fixes (chunked_load.go, main.go, store.go):
  * RunStartupLoad: inline the LoadChunked call (drop superfluous
    goroutine + channel — direct call is equivalent).
  * RunStartupLoad: on LoadChunked error, set backgroundLoadFailed=true
    with a captured error string. Pre-fix: undefined (done=false,
    failed=false) terminal state.
  * RunStartupLoad: when hotStartupHours==0 set backgroundLoadDone=true
    immediately (no bg work needed). Pre-fix: /api/healthz +
    backgroundLoadComplete stayed false forever on this branch.
  * RunStartupLoad: log an INFO line between LoadChunked completion
    and bg-loader start (the post-mortem of #1809 needed this signal).
  * main.go: stop logging 'background load will start' on the
    hotStartupHours==0 branch where it was a lie. Branch the log
    message based on the actual path taken.
  * loadBackgroundChunks: runtime assertion — panic if oldestLoaded
    is '' while packets are present. Future refactors that
    re-introduce the #1809 parallel spawn race fail loudly instead
    of silently shipping the same coverage-gate regression.
  * hotStartupHours: documented as immutable post-construction (no
    locks needed on readers).

Tests (runstartup_load_test.go) — codify the new contracts:
  * TestRunStartupLoad_HotStartupHoursZero_SetsDoneImmediately (B3)
  * TestRunStartupLoad_LoadChunkedError_SetsFailedTerminal (B2)
  * TestRunStartupLoad_EmptyDB_SetsDoneTerminal (B4)
  * TestRunStartupLoad_BgLoaderRunsAfterLoadChunkedSets_OldestLoaded
    (B5/B6 — behavior-describing name, no issue number in fn name)
  * TestLoadBackgroundChunks_PanicsOnOldestLoadedEmpty_Invariant (A7)

The original TDD red→green chain (c9c782b → f532d08) is preserved
intact.

Refs #1809, PR #1811.
2026-06-30 14:28:47 -07:00
..