Skip to content

fix(refs): the WarmUp prefetch honors the persisted latest_tags fallback (the #108 warm-up-hang regression) - #109

Merged
atrawog merged 1 commit into
mainfrom
fix/warmup-persisted-prefetch
Sep 7, 2026
Merged

atrawog merged 1 commit into
mainfrom
fix/warmup-persisted-prefetch

Conversation

@atrawog

@atrawog atrawog commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

refs.GitClient.WarmUp (the startup prefetch behind "charly: fetching git metadata for N repo(s) (first run)") regressed in #108: the offline-fallback cutover correctly moved the persisted latest_tags entries from fresh-data-with-TTL to OFFLINE-FALLBACK-ONLY, but WarmUp's cold-check kept consulting only the IN-PROCESS maps - which start empty in every fresh process. Result: every project load re-probed the entire collected corpus over the network.

Measured live on the opencharly umbrella host: a project whose persisted cache already held 316 latest_tags + 279 default_branches entries printed "fetching git metadata for 193 repo(s) (first run)" on every fresh process and ran 193 repos x 2 git ls-remote ops (~23 s healthy, uncontended). The pre-#108 model served the persisted entry as fresh, so the prefetch found ~1 cold repo and returned instantly - which is exactly why the same bed passed at run 2026.249.2233 ("fetching git metadata for 1 repo(s)" in its deploy-add log) and hung at run 2026.250.0131.

Under concurrent bed runs (the CC-1 wave: multiple charly processes x 10 warm-up workers each), the aggregate ls-remote fanout trips GitHub's throttling threshold (the documented 152-concurrent-ls-remote storm this layer was built to prevent); every throttled fetch then burns its 30 s-deadline x 3 bounded retries, stretching the 23 s warm-up into tens of minutes per process - the observed deterministic hang of two independent binaries at the identical line.

The fix restores WarmUp to a UX batch, never a resolution: a repo whose PERSISTED latest_tags fallback carries an entry is prefetch-warm. The #108 freshness contract is untouched - the on-demand LatestTag path still re-probes the network in every fresh process (guarded by the existing offline-fallback tests), and a repo pinned at immutable tags never resolves a latest tag at all, so for those repos the probe was pure waste. A genuinely cold repo (no persisted entry) still prefetches, unit-pinned.

How tested

  • New unit test TestWarmUpSkipsPrefetchWhenPersistedFallbackExists: a FRESH client over a persisted-cache file (written through the real save() path) must not invoke the gitLatestTagFetch seam for a repo the fallback knows, and must invoke it exactly once for a genuinely cold repo. Fails without the change (fetch count 1 != 0).
  • Full go test ./refs/ ./spec/ -count=1 -> ok (refs 11.5 s includes the live-network offline-fallback suite).
  • gofmt -l refs/ clean; go vet ./... clean.
  • End-to-end A/B against the distro-fedora project (193-repo corpus), same command:
    • pre-fix binary: charly box list boxes -> "fetching git metadata for 193 repo(s) (first run - may take a moment)... git metadata cached." - 23.2 s (cold deploy config, uncontended).
    • post-fix binary (charly built with "replace github.com/opencharly/spec => "): same command -> no warm-up message, 0.74 s.
  • Reproduction evidence retained: /tmp/cc1-warmup-cold.log (pre-fix 193-repo probe + timing), /tmp/cc1-warmfix.log (post-fix, silent + fast).

Rulebook compliance

  • R0 - loaded /charly-internals:git-workflow + /charly-internals:root-cause-analyzer (the R1 trigger) before acting; this PR is the root-cause fix, not a workaround.
  • R1 - full RCA: expected (persisted cache makes the prefetch instant), actual (193-repo network probe every process), mechanism (fix(refs): the persisted latest_tags cache is an offline fallback, never fresh data #108 moved persisted tags to the fallback map; WarmUp never consulted it), missed control (no unit test covered WarmUp's cold-check against a persisted cache), blast radius (every charly command that loads a project with remote refs - beds, deploys, features; the entire CC-1 wave), root fix (this patch).
  • R2 - the whole cutover is this one seam: WarmUp is the only consumer of the prefetch cold-check; the on-demand paths keep their contract by design and by existing tests. No same-mechanism sibling exists (grep-verified: WarmUp has one caller, sdk loaderkit refs_collect).
  • R3 - one canonical implementation: the persisted-awareness lives in the GitClient (the single git layer), not at any call site.
  • R4 - no sleeps/retries/suppressions; the bounded-retry machinery is pre-existing and untouched. The fix REMOVES redundant network work instead of masking it.
  • R4a - product fixed first; no documentation edited to match the defect.
  • R5 - no legacy path added or kept; the pre-fix(refs): the persisted latest_tags cache is an offline fallback, never fresh data #108 fresh-serving model is NOT restored (the fallback semantics stay).
  • R6 - branch + PR only; no force-push, no hook bypass, no main push.
  • R7 - the new test fails without the change (asserted: fetch-count 1 without the fix); the changed path ran live end-to-end with retained outputs.
  • R8 - no emitted artifacts touched (the cache section's on-disk shape is unchanged; the patch only reads it).
  • R9/R10 - spec is a pure contract module (Go + CUE only, no charly.yml, no check beds - the disposition fix(refs): the persisted latest_tags cache is an offline fallback, never fresh data #108's own changelog recorded); the gate is the unit suite + the live consumer exercise above. The consumer re-pin (charly go.mod -> this spec tag) lands in the in-flight CC-1 charly PR, whose bed R10 matrix then proves the affected disposable:true targets on fresh runs.

Change classification

  • Change class: feature (spec/refs mechanism - the git-layer prefetch policy).
  • Verification gate: unit suite + the live A/B exercise above; the consumer exercise (bed R10s) lands with the charly re-pin PR.
  • Attribution tier: fully tested and validated (changed path executed live with retained output; full unit gate passed).

Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (fully tested and validated)

…ack (the #108 warm-up-hang regression)

#108 (the offline-fallback cutover) moved the persisted latest_tags entries
from fresh-data-with-TTL to OFFLINE-FALLBACK-ONLY — correctly, fixing the
stale-latest-tag bug — but WarmUp's cold-check kept consulting ONLY the
in-process maps. Those start empty in every fresh process, so every project
load re-probed the ENTIRE collected corpus (measured live: 193-194 repos x 2
ls-remote ops per process, on a host whose persisted cache already held 316
latest_tags + 279 default_branches entries). The pre-#108 model served the
persisted entry as fresh, so the prefetch found ~1 cold repo and returned
instantly — which is why the old runs passed.

Under concurrent bed runs the re-probe fanout (10 warm-up workers x N
processes) trips GitHub's documented throttling threshold (the 152-concurrent-
ls-remote storm this very layer was built to prevent), and every throttled
fetch then burns its 30s-deadline x 3 bounded retries — a 23s warm-up
(measured, healthy network) stretching into tens of minutes per process: the
observed deterministic hang at 'fetching git metadata for 194 repo(s)'.

The fix restores the prefetch to a UX batch, never a resolution: a repo whose
PERSISTED latest_tags fallback has an entry is prefetch-warm. The freshness
contract is untouched — the on-demand LatestTag path still re-probes the
network in every fresh process (the offline-fallback tests keep guarding it);
a repo pinned at immutable tags never resolves a latest tag at all, so for
those repos the probe was pure waste. A genuinely cold repo (no persisted
entry) still prefetches, unit-pinned.
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 0ec3606f0eb5 (branch: feat branch of PR #109)

Security screen: PASS — no secrets, no egress, no scope mismatch (description matches the diff exactly), no new deps, no guardrail weakening. The change reduces network fanout rather than adding it.

Checklist: All applicable rules PASS or NA.

  • A1/A2/A3 — Body is complete (Summary, How tested with pasted output, rulebook compliance, change classification, exact *Assisted-by:* footer). Change class is a Go mechanism fix in the spec contract module; gate is the unit suite + live A/B consumer exercise, which is the correct disposition for a spec module (no beds exist there; consumer bed R10s land with the charly re-pin PR). "fully tested and validated" is justified: the changed path executed live against a fresh rebuild (post-fix binary: no warm-up message, 0.74 s vs 23.2 s pre-fix) and the new unit test fails without the change.
  • B5/R1 — Full RCA provided (expected vs actual, mechanism, missed control, blast radius, root fix); no forbidden framing, no surviving warnings.
  • B6/R2 — No out-of-scope split; the cutover is this one seam, no parking.
  • B7/R3, B8/R4, B9/R4a, B10/R5 — Single canonical implementation in GitClient; no sleeps/retries added (removes redundant network work); product fixed first, no docs edited; no legacy path restored.
  • B12/R10 — Ships a test that fails without the change (verified: fresh client has empty in-process maps, so the old condition marks the repo cold and fires the fetch seam → fetch count 1 ≠ 0). Test is internally consistent: it self-verifies the persisted entry round-trips through the real save() path before asserting the fetch seam stays un-called, and the genuinely-cold repo drives the injected seam exactly once.
  • B16 placement — CORRECT: the persisted-awareness lives in the git layer (refs/git_client.go), the single owner of git metadata, not at a call site.
  • B13/B14/B15/B17/B18 — No candy/CUE changes (ADE/SDD NA); concurrency failure root-caused and fixed, not dismissed; one atomic commit; no autonomous destroy/rebuild (A/B is a read-only charly box list boxes); diff is gofmt-clean with no visible lint issues.

No comments on the thread to adjudicate.

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 7, 2026 01:58
@atrawog
atrawog merged commit 840f1cb into main Sep 7, 2026
2 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 7, 2026
@aitrawog
aitrawog deleted the fix/warmup-persisted-prefetch branch September 25, 2026 19:10
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