Repository navigation
census: send an HF token when one is in the environment - #633
Conversation
engine#619's five UNVERIFIABLE rows are gated (auto-access) repos: HF answers the listing without `config`, so the architecture is unknowable and the class is never seen. The watcher sent no credentials at all, so no token could ever resolve those rows however many were installed. HF_TOKEN (or HUGGING_FACE_HUB_TOKEN, the name huggingface_hub writes) is now sent as a Bearer header on every HF request. With none in the environment the request is byte-identical to what the watcher always sent. A rejected token (401) turns the header off for the rest of the run and the page is retried anonymously, so a stale token costs a warning instead of the whole sweep, and the UNVERIFIABLE line then says the token was already sent rather than advising a token at a run that sent one. Tests: tests/census_watch_test.py pins the header for both variable names, the report text with and without a token, and the 401 fallback through a stubbed urlopen (no network). Not verified here: that HF exposes `config` for a gated repo to a valid token. The token on this box is revoked (401 on whoami-v2), so that half waits for a working one. Refs: #619
PR Reviewer Guide 🔍(Review updated until commit 0aaa829)Here are some key observations to aid the review process:
|
…ne costs The 'Unverifiable: gated configs' section still claimed the watcher sends no `Authorization` header on purpose and that a token "needs [to be] in the watcher"; that is false as of the parent commit. Describe the code: `hf_token()` reads HF_TOKEN, then HUGGING_FACE_HUB_TOKEN (no token *file* is read, so the standard ~/.cache/huggingface/token changes nothing), `request_headers()` adds the Bearer header on the architecture walk's listing pages only (FastFlowLM's `get_json` fetches still send the UA alone), with no token the request is byte-identical and a gated row stays unverifiable - reported once, remembered, no alert - and a 401 sets _AUTH_REJECTED and retries anonymously instead of ending the run. HF answers the listing 200 even with an invalid Bearer (measured: /api/models 200, only /api/whoami-v2 401), so that fallback is a guard, not a path the watcher exercises, and the section now says so. The `cestaristudio/granite-switch-4.1-3b-preview` example is corrected: without a token it stays unverifiable and does not alert (it was never `!! UNCOVERED`), and a token granted access to it would classify it like any other row. Docs only - tools/census_watch.py and its test are untouched.
|
Persistent review updated to latest commit 7fc8536 |
main now reviews Granite-Switch in the same section, so the gated-listing note keeps both halves: the row stays unverifiable without a token, and the class it would have named is already reviewed.
|
Persistent review updated to latest commit 0aaa829 |
Half of
#619is blocked on something the watcher cannot do at all: it never sent credentials.The five
UNVERIFIABLErows are gated (auto-access) repos — HF answers the listing withoutconfig, soarchitectures_of()returns''and the class is never seen. The advice printed next to them ("gated repos need a token") was therefore unfollowable: installing a token changed nothing.Change
HF_TOKEN, orHUGGING_FACE_HUB_TOKEN(the namehuggingface_hubwrites), is sent asAuthorization: Bearer …byrequest_headers()on the architecture walk's listing requests (hf_get_page). With no token in the environment the request is byte-identical to what the watcher always sent. No token file is read:hf_token()looks only at those two variables, so the standard~/.cache/huggingface/tokenchanges nothing.401inhf_get_pagesets_AUTH_REJECTED, printsthe token was rejected (401); continuing without itand retries the page anonymously, so a token some endpoint rejects costs a warning rather than the sweep. (That path is a guard, not one the watcher exercises — see the correction below.)UNVERIFIABLEline now says whether a token was already sent ((HF_TOKEN sent, still no config)), so it stops advising a token at a run that sent one.docs/arch-gaps.md, section Unverifiable: gated configs (which this PR previously left stale, still claiming the watcher "sends noAuthorizationheader on purpose"): now names the two variables the code reads and the fact that no token file is read, says what happens with no token (unverifiable row: reported once, remembered, no alert, exit code unmoved), says a rejected token is not fatal, notes that the header goes on the architecture walk only (the FastFlowLM org/detail/release fetches inget_json()still sendUser-Agent: 1bit-census-watchalone), and corrects thecestaristudio/granite-switch-4.1-3b-previewexample: with no token it stays unverifiable and does not alert — it was never!! UNCOVERED— and a token granted access to it would classify it like any other row.Correction: a dead token does not empty the sweep
An earlier revision of this body said one dead token "silently emptied the sweep", and the 401 fallback was justified that way. That claim is wrong, and the code cannot detect a dead token the way it implied. Measured today with
Authorization: Bearer hf_invalid_probe_token:hf_get_page()puts the header on the listing route, and HF answers that route200even with an invalid Bearer — no 401 arrives there, the page comes back with models and inline configs, and the sweep is neither emptied nor degraded. The only endpoint observed to reject the token is/api/whoami-v2, which the watcher never calls; so no, the code does not probe an endpoint that distinguishes a good token from a bad one. The401branch inhf_get_pageis therefore a guard for an endpoint that does reject it, pinned only against a stubbedurlopenintests/census_watch_test.py(check 17), not against observed HF behaviour. I did not add awhoamiprobe: it would be an extra unverified request per run feeding a diagnosis nothing consumes.Verification
python3 tests/census_watch_test.py— header construction for both variable names, report text with and without a token, and the 401 fallback through a stubbedurlopen(no network):The same file fails on the base commit (
5c2aee2): run against an extracted5c2aee2tree it dies at check 16 withAttributeError: module 'census_watch' has no attribute 'TOKEN_VARS', so the new checks pin this commit's code and not the old behavior.python3 tools/registry_build.py --check-gaps— clean (none of the 27 reviewed significant classes is mapped without a reason).python3 tools/registry_build.py --check-pins— clean (registry/architectures.json records the committed pins). (--check-gaps/--check-pinslive ontools/registry_build.py;tools/census_watch.pytakes--limit/--state/--fullonly.)python3 tools/copyright.py --check— clean.python3 tools/census_watch.py --limit 5still runs and still exits 1 on the real FastFlowLM alerts (!! NEW FLM FastFlowLM/LFM3-1.7B-NPU2,.../MiniCPM-V-4.7-1B-NPU2,.../smolvla-NPU2).What this does NOT claim
That HF returns
configfor a gated repo to a valid token — unverified, because the token on this box is revoked (401onwhoami-v2), and I will not write that claim without a working one. Nothing here was run with a valid token. It also does not touch the four public classes in#619(LiveMemForCausalLM,CDMMoELMPoincare,GraniteSwitchForCausalLM,Senryu2ForCausalLM); those need the reviewed-not-an-alias writeup indocs/arch-gaps.md.Refs #619.