Skip to content

ops: re-seed installs cache + add runbook#522

Merged
amavashev merged 2 commits intomainfrom
ops/reseed-installs-cache
May 1, 2026
Merged

ops: re-seed installs cache + add runbook#522
amavashev merged 2 commits intomainfrom
ops/reseed-installs-cache

Conversation

@amavashev
Copy link
Copy Markdown
Contributor

Brings the homepage clones counter back. Two changes:

  1. Re-seed .vitepress/theme/installs-cache.json — the committed cache had regressed to the pre-PR-installs counter: add GitHub clones + GitHub Packages, label 'installs + clones' #515 schema (no clones field, ghcr:0 placeholder still present). Effect: HomeSocialProof.vue was reading data.clones0 → the v-if="showClones" check hid the entire stat. Only the installs counter rendered.

  2. Add .outreach/installs-cache-runbook.md — documents why this cache is committed (PyPI and GitHub clones APIs are rolling-window only; the cache holds the historical peak), the required CI env (GITHUB_TOKEN), a schema-regression detector, and what to do if this happens again.

Before / after

Before After
Cache file shape Pre-PR-#515 (ghcr:0, no clones) Current schema (16-repo clonesByRepo, all fields)
Homepage installs 4,049+ package installs 8,109+ package installs
Homepage clones (hidden — clones=0) 35,587 repo clones
Total accumulator state Lost Restored

Root cause hypothesis

The cache file is committed at every build that produces new HWMs. Somewhere along the way a stale or hand-edited cache file (with the old schema and a total: 44156 from after PR #515 baked in — a frankenstate) got committed to main. That broke the homepage second stat starting from the next deploy build, because every deploy from then on read this regressed cache and propagated it.

How this stays fixed

The runbook flags an open prevention item:

CI deploy pipeline likely needs GITHUB_TOKEN added if it does not have one already. Without a token in CI, every deploy build re-reads the committed cache without updating it — so the displayed numbers go stale instead of growing.

Verify Vercel / Netlify / Cloudflare Pages / GH Actions config exposes GITHUB_TOKEN (or GH_TOKEN) with repo scope to the build environment. If yes: builds will keep the cache fresh on deploy. If no: the cache only refreshes when manually re-seeded (the play we just executed).

Test plan

  • npm run build locally — verified, produces [installs] clones+35587(cache:35587) log line
  • Cache file passes schema-regression check: jq 'has("clones")' .vitepress/theme/installs-cache.json returns true
  • After merge + deploy, homepage shows both stats: 8,109+ package installs · 35,587 repo clones
  • If the homepage still shows only one stat post-merge, confirm GITHUB_TOKEN is wired into the deploy pipeline (it's not optional — see runbook)

amavashev added 2 commits May 1, 2026 09:54
ROOT CAUSE: the committed installs-cache.json on main had regressed
to the pre-PR-#515 schema:

  before: {"npm":4049,"pypi":1339,"crates":49,"ghcr":0,
           "maven":0,"total":44156,"fetchedAt":"..."}

The 'ghcr:0' field, missing 'clones' / 'clonesByRepo' /
'releases' / 'ghPackages' fields are all symptoms of an old-schema
cache file getting committed (likely from a stale local checkout
or hand-edit during an unrelated session).

EFFECT: HomeSocialProof.vue reads data.clones, gets 0 by default
(field missing from cache), <span v-if=showClones> evaluates false,
the entire 'repo clones' stat hides. Only the installs counter
renders. Result: clones counter 'disappeared' from the homepage.

FIX: re-ran 'npm run build' locally with GITHUB_TOKEN set
(gh auth token) so the clones fetcher could populate per-repo
day-cursor accumulators. New cache shape:

  after: {"npm":4049,"pypi":1339,"crates":49,
          "clones":35587,
          "clonesByRepo":{ /* 16 repos with count + lastSeenDay */ },
          "releases":0,"releasesByRepo":{...},
          "ghPackages":2672,"maven":0,"total":8109,
          "fetchedAt":"..."}

Homepage will now render '8,109+ package installs · 35,587 repo clones'.

PREVENTION: added .outreach/installs-cache-runbook.md documenting:
  - why the cache is committed (PyPI / clones APIs are rolling-window;
    cache holds the historical peak)
  - required env at build time (GITHUB_TOKEN with repo scope)
  - schema-regression detector (jq query to verify clones field exists)
  - CI checklist for the deploy pipeline
  - what to do if the clones counter disappears again

The runbook lives in .outreach/ which is excluded from the published
site (srcExclude in config.ts). Internal-facing only.

OPEN QUESTION (for follow-up): the deploy pipeline likely needs
GITHUB_TOKEN added if it does not have one already. Without a token
in CI, every deploy build re-reads this committed cache without
updating it — so the displayed numbers go stale instead of growing.
The runbook flags this in the CI checklist.
The previous re-seed (commit 7aa7765) started the clones accumulator
from an empty clonesByRepo because the committed cache on main had
been wiped twice (commits 8fb04d5 and f3e8b24 wrote the old-schema
{ghcr:0} cache that loses all accumulator state).

A fresh seed from empty only captures the current 14-day API window,
missing all activity from days that have rolled off. That's why the
re-seed produced 35,587 — about 470 short of the historical peak of
36,057 from commit 35cd32b.

Recovery: restored .vitepress/theme/installs-cache.json from git
content of 35cd32b (the last cache that had clones=36057 with the
full per-repo accumulator state, lastSeenDay=2026-04-29). Then ran
npm run build with GITHUB_TOKEN; the day-cursor accumulator only
added days strictly AFTER 2026-04-29 (i.e., one new day, 2026-04-30)
on top of the 36,057 floor.

Result:
  clones: 36,057 (restored peak) + 1,644 (Apr 30 new days) = 37,701
  total:  8,109 (defensible, unchanged)

Why the new total is GREATER than the original 36,057: between when
35cd32b was committed and the wipe, multiple build-time updates were
LOST. The restoration only recovers the snapshot state from that
specific commit; everything that should have accumulated in the days
since (and was wiped) is gone permanently. Today's build adds Apr 30
on top of that snapshot. May 1 will accumulate on the next build.

This is the best recovery possible without those lost intermediate
states. Going forward, CI needs GITHUB_TOKEN AND the schema-regression
detector from the runbook should run pre-commit to prevent another
wipe.
@amavashev amavashev merged commit edacd8a into main May 1, 2026
5 checks passed
@amavashev amavashev deleted the ops/reseed-installs-cache branch May 1, 2026 15:14
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