Repository navigation
fix(adoption-wall): write adopter state back to the orphan branch so lastScan can advance - #398
Merged
Merged
Conversation
The state file was read and never written. No workflow wrote it, this script had no write path, and `lastScan` was stamped by hand once when the orphan branch was seeded. MAX_STATE_AGE_DAYS was therefore a FUSE, not a guard: every run green until the seed aged past 21 days, then NEEDS-REVIEW and a review PR every Monday forever, over a wall nothing had changed. The run now writes the state it read, gated on the scan and on nothing else. A fresh `lastScan` is a claim that this run resolved the whole adopter list, so it is withheld whenever the run reached no verdict: a repo that answered without the facts the ranking needs, or an avatar probe that timed out or was throttled. A definitely-dead logo is the opposite and does not withhold it — that is a finding, and a run that established one scanned fine. Rate-limited metadata never gets here at all; both fetch paths already throw and exit 1. `missedRuns` keeps its meaning: 0 for a repo that came back, +1 for one the API definitively does not have, and UNCHANGED for one this run never looked at. Nothing is ever deleted, and `isFork` is carried through verbatim so the fork disagreement report is not quietly self-cancelling. The scan is also seeded from ADOPTER_DISPLAY. The branch was seeded by parsing the live wall, which can only contain repos already rendering, so a curated adopter below the cut -- cacheplane/dawnai -- was absent from the file and, because the file is the candidate list, could never climb back onto the wall.
…ta branch The generator's write is only half a producer: without this the refreshed file is rewritten in the runner's checkout and thrown away with it, and `lastScan` never moves. Pushes to refs/heads/adoption-data and nothing else. It runs inside the orphan-branch checkout, stages one named file rather than `git add -A`, and names the destination ref in full, so it cannot reach the default branch and cannot carry repo files onto a branch that holds nothing but adopters.json. Gated on the generator's own ADOPTION_STATE_WRITTEN flag, not on the verdict: a NEEDS-REVIEW run that resolved the whole list still refreshes state. Placed before the docs/ steps so a failed state push stops the job with nothing landed half-done. No retry, no rebase, no force -- this job is the branch's only writer and `concurrency` serialises it against itself, so a rejected push means someone else wrote there and re-applying over it would delete their work. Slack says so when a run did not refresh the state, because the verdict, the diff and the logo count can all look ordinary while `lastScan` stops moving.
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fuse
adopters.jsonon the orphanadoption-databranch was read and never written. This script had no write path, and none of the sixteen workflows wrote it either — the only branch-touching steps were agit ls-remoteprobe and a sparse read-only checkout.lastScanwas stamped by hand once, when the branch was seeded (cd1a474, 22 repos parsed off the live wall), and nothing advanced it.MAX_STATE_AGE_DAYS = 21. So the feature was correct today and self-destructing on ~2026-09-22: from that Monday on, every weekly run flips to NEEDS-REVIEW and opens a review PR, forever, over a wall that has not changed.MAX_STATE_AGE_DAYSwas a fuse, not a guard.RED — observed on the real surface
The real generator, run as a real child process against a sandbox repo root (stubbed
fetch, no network),origin/main@32be6ecunmodified:And the defect itself — a fully successful run leaves the file untouched:
Run twice over one sandbox on unmodified
main, the stale state never recovers:FIRST exit=20 … EXIT CODE: 20, lastScan ADVANCED: false.GREEN — same harness, this branch
and the recovery, twice over one sandbox:
The second run is CLEAN, so nothing is written to
docs/and the workflow has nothing to commit tomain.A failed scan must not stamp freshness
This is the property the whole change turns on: if a run that could not resolve the list stamps
lastScananyway, the staleness guard stops measuring how recently the DATA was confirmed and starts measuring how recently the JOB RAN — which it can already tell. Both failure shapes, on the real surface:A rate-limited metadata pass never reaches the write at all: both fetch paths already throw on 403/429/5xx and
main()exits 1.Design, and why
Written on all three verdicts (0 / 10 / 20), gated on the SCAN and never on the status.
lastScanrecords that the adopter list was resolved, which is a different question from whether a human should look at the result. A dead avatar, a vanished adopter, a wall under its floor — those are things the run FOUND OUT, and a run that found something out scanned fine. Gating onstatuswould be actively harmful: the first dead logo freezeslastScan, and three weeks later every run carries a second, invented staleness reason on top of the real one — and the workflow only carries three reasons into Slack, so the invented one displaces the real cause from the one line a human reads. The runs that must not stamp are the ones that did not learn the answer, and that is exactly whatscanIsConclusivetests. A corrupt or missing state file never reaches the write path at all.missedRunskeeps the semantics the reader already relies on (> 0⇒ not a candidate):0, unconditionally (a repo that comes back is back)NOT_FOUND, REST 404/451) →previous + 1missedRuns > 0, which are filtered out before the API is asked and so were never looked at; and entries whoserepois notowner/name. Incrementing a repo nobody looked at manufactures evidence of a disappearance, and three of those in a row drops an adopter off a public page for no reason.That distinction did not exist before:
fetchRepoMetayielded no meta for both a 404 and a reply missingfork, and the two were indistinguishable downstream. They are now split (MetaResolution.indeterminate), which is what makes "could not tell" safe.Entries absent from the latest scan are never deleted. They keep their row, their
firstSeenand a rising counter, so a repo that reappears is recognised as the same repo.isFork,channelsandfirstSeenare carried through verbatim — overwritingisForkwith the API's answer would make the fork-disagreement report self-cancelling, erasing the very evidence it exists to surface. Entries are sorted by repo so the orphan branch's weekly diff is the delta, not a reshuffle.Writing state pushes nothing to
main. The new workflow step runs inside the orphan-branch checkout, stages one named file (nevergit add -A), and pushes torefs/heads/adoption-datanamed in full.adoption-datastays a true orphan: it is a checkout of that branch in its own gitignored directory, so no repo history and no repo files can reach it.Guard adoption-data namingis untouched and still passes (verified locally). No retry, no rebase, no force — this job is the branch's only writer andconcurrencyserialises it against itself, so a rejected push means someone else wrote there; it fails loudly andlastScansimply does not advance that week, which is the safe direction and leaves three weeks of budget.cacheplane/dawnaiRoot cause: the branch was seeded by parsing the live wall, which can only ever contain repos that were already rendering.
cacheplane/dawnaiis a curated adopter sitting below the wall's cut, so the parse could not see it — and because the file is also the candidate list, a repo missing from it could never climb back on.missingFromStatereported the gap every week and nothing could close it.The producer's state now derives from the scan:
withKnownAdoptersseeds everyADOPTER_DISPLAYkey the incoming file does not mention into the scan itself, so they are resolved from the API, ranked on their real numbers, and written back with whatever the scan actually found.missedRuns: 0there is an INPUT meaning "ask about this one", not an assertion —buildNextStateoverwrites it with the scan's answer, and if the scan was inconclusive nothing is persisted.missingFromStatestill reports against the incoming file, so it keeps describing what the upstream producer failed to discover instead of answering "none" every time.Tests
25 new cases. Each was observed FAILING under a targeted mutation and passing with the fix restored (script byte-identical after restore, verified with
cmp):withKnownAdopterscases and the curated write-backGates (raw exit codes)
prettier --check .npx eslint .npx tsc --noEmitnpx vitest runactionlint .github/workflows/update-adoption-wall.ymlnpx commitlint --from origin/main --to HEAD🤖 Generated with Claude Code
https://claude.ai/code/session_01AvkmhXVLqSSEW6FvPQHSu5