You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mirror: state db drift, generator drops esp-toolchain, rejected UA, no release tracking #2040
Registry mirror tooling gaps found while mirroring FastLED 3.10.9 (#2019, PR #2034)
The bucket's state DB is out of date.
ci/gen_mirror_manifest.py requires every bucket object to be listed in the bucket's _state/manifest.db.
FastLED 3.10.9 was uploaded and indexed using a local copy of that DB with an extra row. The bucket's own DB was never updated.
Until a mirror pass records the new object, or the patched DB is uploaded, regenerating the index from the bucket fails with "objects have no system in the state db".
The generator damages the committed index.
It deletes site/mirror/shards/esp-toolchain.json and the @esp-toolchain index entry, because it doesn't produce that shard.
It rewinds esp-libs.json from 2026.11.04 to 2026.10.31 and reorders the index.
dl.registry.platformio.org now returns 403 "This download method is not supported" for PlatformIO/6.1.16 (fbuild-mirror; ...).
fbuild's production UA (crates/fbuild-core/src/http.rs:49) still gets 200.
The next full pass will probably need FBUILD_MIRROR_UA set.
Nothing picks up new registry releases.
~/dev/fbuild-mirror/mirror.py and rotate.py aren't in any repo, and nothing runs them on a schedule.
The last pass ended 2026-10-30, so every owner's releases since then are missing. FastLED 3.10.9 is the case that was reported.
Proposal: put the tool under version control. Add an incremental mode that diffs the registry against the shards and mirrors only new versions; that is what chore(mirror): index FastLED 3.10.9 (#2019) #2034 did by hand. Then schedule it.
Claimed by the fbuild-74 coordinator (meta #2035). A sub-agent is starting on item 2 (the generator damaging the committed index), which is in this repo. Items 1, 3 and 4 involve writing to the bucket, an out-of-repo tool, and scheduling; those wait for the maintainer to decide.
The generator rebuilt the whole Index from the bucket and the state DB, then pruned every shard file it had not written. With --prebuilt it also rewrote esp-libs.json stamped with the registry shards' version (2026.10.31), and put it before @names-*.
What changed. The generator now owns only the registry owners and @names-*. Any other @ entry is kept verbatim, after the generated entries, in committed order, and its shard is never pruned. If such a shard is missing or no longer matches its descriptor, the run raises ForeignShardError before writing anything. --prebuilt is removed. --check no longer counts foreign components as removed bucket objects.
Validation. Feeding the committed site/mirror/ back through the generator offline reproduces it byte for byte: 29300 objects, the Index order, and both esp shards.
Items 1, 3 and 4 are untouched. This fix does not change the state-DB requirement: a regeneration still stops with "objects have no system in the state db" until the bucket's _state/manifest.db records FastLED 3.10.9.
Item 1 (the bucket's state DB is out of date) is resolved. This was a data fix in the bucket. No code in this repo changed.
Diagnosis
I downloaded _state/manifest.db from the bucket. It was last modified 2026-10-30 13:36 UTC, sha256 43c2fa92…6711. Its integrity check passes. It has 29302 files rows: 29299 done and 3 gone. It is byte-identical to ~/dev/fbuild-mirror/local-state/manifest.db.
I compared it with the bucket listing. Of the 29300 registry objects, exactly one has no done row: fastled/library/FastLED/3.10.9/FastLED-3.10.9.tar.gz. No done row points at a missing object.
I reproduced the failure. A regeneration into a scratch copy of site/mirror/ stopped with ValueError: 1 objects have no system in the state db, e.g. ['fastled/library/FastLED/3.10.9/FastLED-3.10.9.tar.gz']. --check exited 0 against the same bucket. It never reads the state DB, so it cannot detect this drift.
Strategies considered
(a) Upload a corrected DB. Take the bucket's current DB, add only the missing row in mirror.py's schema, back up, upload.
Correct: the DB then describes what the bucket actually holds.
Low risk: one row, checked by a full diff of the dump.
Reversible: server-side and local backups.
Small effort.
(b) Make the generator tolerate objects with no row. It would treat them as any-host or infer them from shards.
This hides real drift. A missing row is exactly the signal that an object was uploaded outside the mirror tool.
"Unknown" would silently become system: [] (any host), which is wrong for platform-specific toolchains.
Inferring from the committed shards is circular: the shard would become the source for itself.
Rejected.
(c) Leave it for the next full mirror pass. There is no schedule (item 4), and the pass is blocked on the UA 403 (item 3). The bucket would also stay unregenerable indefinitely. Rejected.
(d) Upload the patched local DB from chore(mirror): index FastLED 3.10.9 (#2019) #2034 wholesale. This yields the same end state as (a). It is weaker because it trusts an old scratch file, not the current bucket copy, and it can't be ETag-guarded against a concurrent writer. Rejected in favour of (a).
(e) Add a state-DB coverage check to --check. This could be useful later. It does not fix the data, and the regeneration already fails loudly. Not done here.
Chosen: (a). It fixes the actual inconsistency, keeps the generator's fail-loud contract, and can be undone by copying the backup back.
What was done
Built the new DB locally. I copied the downloaded DB and inserted one files row with the column set mirror.py writes:
state='done', attempts=1, last_error=NULL, updated_at=1794890138, which is the object's LastModified
Metadata comes from the registry API for fastled/library/FastLED 3.10.9, the same source mirror.py catalog uses.
url is the table's primary key. A later catalog pass does insert or ignore, so it will keep this row and not re-queue the file.
The packages row already existed and is unchanged.
Checked the new DB before uploading.
pragma integrity_check returns ok.
files went from 29302 to 29303 rows.
In a full iterdump diff against the original, 0 lines were removed and 1 line was added (the row above).
A regeneration with --state-db <new db> into a scratch copy of site/mirror/ exited 0. diff -r against the committed site/mirror/ showed no differences.
Backed up the original.
Server-side: _state/manifest.db.bak-2026-11-17. It is private, made with CopySourceIfMatch on the original ETag, then downloaded again; its sha256 matches the original.
Locally: ~/dev/fbuild-mirror/state-backups/manifest.db.bucket-2026-10-30T133624Z, sha256 43c2fa92…6711. The patched DB is beside it (sha256 b3c91702…626d).
Uploaded the new _state/manifest.db. The upload was guarded on the original ETag still being current. It is private and binary/octet-stream, as before. Nothing else was written and nothing was deleted.
Verification (after upload)
I downloaded _state/manifest.db again. Its sha256 is b3c91702…626d, the same as the local patched DB.
Integrity check: ok. files has 29303 rows, the old 29302 plus 1: 29300 done and 3 gone. The 3.10.9 row is present as above.
Bucket listing against done rows: 0 objects without a row, and 0 rows without an object.
I ran ci/gen_mirror_manifest.py against the bucket with no --state-db, into a scratch copy of site/mirror/:
Item 3 (rejected UA) and the tool's location: PR #2060. It is not merged yet. Its CI summary fails only on ESP32 Dev / build, an unrelated esptool 5.6.0 provisioning 404 that is breaking every ESP32 build in CI today (#2061), so the merge queue rejects it.
Where the tool lives: strategies
(a) ci/mirror/ in this repo, next to gen_mirror_manifest.py (chosen).
mirror.py writes the state DB (files.key/system/state) that gen_mirror_manifest.py reads, so both are now reviewed and tested together.
A test builds a DB from mirror.SCHEMA and reads it through gen.load_systems.
Another test pins the shared bucket name, _state/manifest.db key and registry prefix.
The scripts are covered by the repo's ruff C901 ratchet and the drift unittest job.
Secrets are not affected: credentials stay in ~/.config/do-spaces/credentials.json.
(b) A new repo. Rejected:
The schema coupling would cross a repo boundary.
It would need its own CI.
It is less discoverable than a directory beside the generator.
Nothing about it needs separate access control.
(c) Stay local, patched only. Rejected:
There is no review and no tests.
The stale-DB hazard from item 1 came from exactly this: unversioned operator state and code in one directory.
UA findings (2026-11-17)
I sent 9 requests in total: GETs of a 7.5 KB package (platformio/platform/native/1.2.1) and one registry API GET.
The 403 body is This download method is not supported. Please use PlatformIO Core to install packages.
The PlatformIO version and the +https:// comment make no difference. The fbuild-mirror token alone decides it.
The same UA worked on 2026-10-30 (rotation.log). The token looks like it was refused specifically after the ~102 GB full pass. That may be a deliberate decision by PlatformIO, and the maintainer should weigh that before the next large pass.
api.registry.platformio.org/v3/packages/... returns 200 to the new default.
Scripts moved.ci/mirror/mirror.py and ci/mirror/rotate.py, code only.
The DO SSH key id and the personal paths are now env config: FBUILD_MIRROR_SSH_KEY_ID (required), FBUILD_MIRROR_SSH_KEY, FBUILD_MIRROR_WORKDIR (default ~/.local/state/fbuild-mirror) and FBUILD_MIRROR_CREDS.
UA.
The default is fbuild's production format, PlatformIO/6.2.0 (fbuild/<Cargo.toml version>). A test compares it with registry_user_agent() in crates/fbuild-core/src/http.rs.
FBUILD_MIRROR_UA overrides it.
A UA without the PlatformIO/ prefix, or one unsafe in a systemd Environment= line, is refused before any request.
rotate.py writes the UA into the droplet unit. rotate.py --print-user-agent shows it.
Stale-DB guard.
A fresh droplet is always restored from the bucket's _state/manifest.db, never from the local rotation-work/manifest.db.
A local copy that is ahead of the bucket copy in rows, done rows or newest updated_at stops the run before a droplet is created.
A droplet snapshot that is behind the bucket copy is never uploaded.
Row count alone is not enough. The stale local copy and the pre-fix bucket copy both have 29302 rows; they differ in done (29085 vs 29299).
A failed bucket download used to read as "first run, start empty". Now only a 404 does.
Checked read-only against the real copies: the stale local copy (29302/29085) is ignored in favour of the bucket copy (29303/29300), and uploading it as a snapshot is refused.
Complexity refactor.catalog, fetch_one and rotate's main were split, behaviour-preserving, to meet C901 ≤ 10. The fetch_one tests pass against the original too.
Tests.ci/test_mirror_tool.py (29 tests, no network) is registered in ci/local_suites.py and ci-workflow-drift.yml.
Old directory.~/dev/fbuild-mirror/ is untouched apart from a new MOVED.md.
No mirror pass was run, no droplet was started, and nothing was written to the bucket.
Item 4 (nothing picks up new registry releases): PR #2066.
Strategies considered
Incremental mode
(a) Re-read versions of every known package each pass. Correct, but it costs ~18,800 API requests per pass to find a few dozen changes. That is the same request volume that preceded the fbuild-mirror block. Rejected.
(b) The registry's "updated" ordering (chosen).GET /v3/search?query=*&sort=updated works and returns packages newest-updated first, each with updated_at. I checked this against the live API on 2026-11-17. A pass pages down to a stored watermark and re-reads versions only for packages updated since. A 16 h window was one search page plus 26 version requests.
(c) A watch list of owners. It misses everything outside the list, and the mirror's job is the whole registry. Kept only as a spot tool: --package owner/type/name refreshes named packages, which is the FastLED 3.10.9 case from chore(mirror): index FastLED 3.10.9 (#2019) #2034.
(d) Diff the committed shards against the registry. That needs the same per-package version reads as (a), and the shards are an output, not the mirror's state. Rejected.
Shard version stamping
(i) Restamp all shards: an 8040-file diff for one release. Rejected.
(ii) Keep the old version via --version: the changed shard's version then says nothing. Rejected.
(iii) Per shard (chosen). An unchanged shard keeps its text and version. A new or changed shard gets --version, which defaults to today's UTC date. The client ignores the field (downloader_mirror_manifest.rs checks only schema_version). Regenerating the committed site/mirror/ with a different stamp is byte-identical.
It pages the search with sort=updated down to a watermark, stored in a new meta table (registry_updated_since), less a 6 h overlap.
Every package updated since then is queued for a version re-read. insert or ignore queues only the files the DB lacks.
A scan records a new watermark only if it covered everything since the old one:
a full scan of an empty DB;
an incremental scan that started at or before the stored watermark;
with no watermark stored, an explicit --since.
A full scan of a DB with no watermark does not set one. It logs a warning that releases of known packages are not picked up.
The meta table is additive. gen_mirror_manifest.py ignores it, and a test pins that.
ci/mirror/update.py (new) runs the incremental pass from one machine, with no droplet. New releases are far below the ~36 GB/IP/day cap. Steps:
Download the bucket DB and its ETag in one GET.
Catalog, or --package.
Print the exact queue. --dry-run stops here.
Refuse a queue over --max-bytes (default 5 GB; bigger is rotate.py's job).
Back up the DB server-side with CopySourceIfMatch, transfer, and upload the DB with If-Match. The upload happens even if the transfer dies.
403 fail-fast (item 3's finding)
Any registry 403 (download, search or versions) raises RegistryRefused, and it is not retried.
The chunk's other downloads are cancelled (TaskGroup), so their rows stay pending and are not recorded as errors.
A registry_refused marker with the 403 body is written and the pass exits 3.
mirror.py run will not start while the marker exists, and the droplet unit has RestartPreventExitStatus=3.
rotate.py sees the marker, snapshots the DB, destroys the droplet and exits 3 instead of rotating, because a new IP will not help.
ETag-conditional snapshot (item 3's finding)
rotate.py uploads with If-Match on the ETag read, or If-None-Match: * when there was no DB. A 412 raises ManifestConflict.
DO Spaces enforces it. A PUT of _state/manifest.db with a wrong If-Match returned 412 PreconditionFailed, and the ETag was unchanged afterwards.
gen_mirror_manifest.py --check now also fails when an object has no done row, or a done row has no object (item 3's finding).
Tests are in ci/test_mirror_tool.py and ci/test_gen_mirror_manifest.py. All 554 tests in the drift job pass locally.
What was uploaded
Dry run against the real registry.--since 2026-11-17T12:00Z queued 65 files (166 MB) across 26 packages, all versions the mirror lacks. I did not publish this run: a recent --since on a DB without a watermark records one, and that would have hidden the 10-30 → 11-17 window.
Dry run first: exactly 2 files, 6321283 bytes. An authenticated listing showed both absent.
Backup: _state/manifest.db.bak-20261117T214822Z, sha256 b3c91702…626d, which is the previous DB.
Transfer: done=2, error=0.
DB upload: If-Match on "399ebee1…-3".
Verification.
The new DB passes its integrity check and has 29305 rows (29302 done).
Its dump differs from the previous copy only by the 2 files rows and the empty meta table. The packages table is unchanged, and the DB is still private.
gen_mirror_manifest.py hashed 2 of 29302 objects. Only those two owner shards (restamped 2026.11.17) and their Index descriptors changed; @esp-* was untouched.
--check exits 0, and both public objects re-download with the registry's sha256.
Scheduling: recommendation
(a) By hand: the interim, until (b) exists.
(b) A new scheduled workflow (recommended, not added). The global rule forbids new workflow files unless the maintainer asks for one. Weekly is enough. It would:
Run uv run --no-project --script ci/mirror/update.py --max-bytes <cap>.
Run gen_mirror_manifest.py --credentials <file> and then --check.
Open a PR with the site/mirror/ changes.
It needs:
Repo secrets for a DO Spaces key with read/write on bucket fbuild, e.g. FBUILD_MIRROR_SPACES_ACCESS_KEY / FBUILD_MIRROR_SPACES_SECRET_KEY, written to a temp JSON file for FBUILD_MIRROR_CREDS / --credentials. No secrets were added.
contents: write and pull-requests: write. A PR opened with GITHUB_TOKEN does not trigger CI, so it also needs a PAT or GitHub App token if the PR should run CI and enter the merge queue.
(c) A cron job or systemd timer on the maintainer's machine works: the credentials are already there. It depends on that machine being up, and it still needs a git/gh step for the PR.
(d) Reusing an existing scheduled workflow: none fits. nightly-platforms, hw-ci, audit-ignored-tests and the others are build or audit jobs, and adding bucket-write secrets to them would widen their blast radius. Not done.
Needs the maintainer
First catch-up run. The bucket DB has no watermark yet, so the first scan needs --since at or before the first full pass. 2026-10-01 is safe. The log only reaches back to 2026-10-30, and every done row is dated 2026-10-30.
Start with update.py --since 2026-10-01 --dry-run.
16 h held 166 MB, so the backlog since 10-30 is probably a few GB. That is above my 500 MB limit.
Later runs need no flag.
The User-Agent the mirror traffic uses. Since item 3 it is fbuild's production UA, PlatformIO/6.2.0 (fbuild/<version>). If PlatformIO blocks that string the way it blocked fbuild-mirror, real fbuild clients' registry fallback breaks too. Small weekly deltas are far from the 102 GB pass, but decide that before scheduling. FBUILD_MIRROR_UA overrides it.
The schedule and its secrets, as above.
Backups. Each publishing run leaves a dated _state/manifest.db.bak-*, about 20 MB each. Prune them by hand.
#2066 merged (5eaf469). Item 4's code is done. The four maintainer items in the comment above are still open: the first --since 2026-10-01 catch-up run, the User-Agent decision, the schedule and its secrets, and pruning backups. So #2040 stays open.
Re-ran the tools against the real bucket today (read-only) rather than trusting the November notes.
Item 1 — bucket state DB drift: closed, and it is now self-detecting.
uv run --no-project --with boto3 python ci/gen_mirror_manifest.py --credentials ~/.config/do-spaces/credentials.json --check → exit 0 against today's bucket.
The exact failure that opened this issue is now a check rather than a surprise: state_db_drift() in ci/gen_mirror_manifest.py reports objects with no done row and done rows with no object, and --check fails on either (2d5b877, covered by ci/test_gen_mirror_manifest.py). The 2026-11-17 data fix plus this check means "objects have no system in the state db" cannot come back silently.
Item 2 — generator damaging the committed index: closed by #2056. Foreign @esp-* entries are kept verbatim after the generated ones, their shards are never pruned, a missing or mismatched one raises ForeignShardError before any write, --prebuilt is gone, and --check no longer counts foreign components as removed objects. A test regenerates the committed site/mirror/ offline and compares byte for byte.
Item 3 — User-Agent 403: closed by #2060. Default UA is now fbuild's production PlatformIO/6.2.0 (fbuild/<version>), FBUILD_MIRROR_UA overrides it, an unsafe or prefix-less UA is refused before any request, and a 403 stops the pass with exit 3 instead of retrying 6 times per file.
Item 4 — new registry releases: tool and incremental mode delivered; the schedule is the one open cell.
mirror.py, rotate.py and update.py are in ci/mirror/ with ci/test_mirror_tool.py registered in the drift workflow. rotate.py always restores a droplet from the bucket copy and refuses a local copy that is ahead in rows, done rows or newest updated_at — the stale-local-DB hazard noted here on 2026-11-17 is closed in-repo.
Real incremental run, nothing written: uv run --no-project --script ci/mirror/update.py --since 2026-10-01 --dry-run → exit 0 queued: 806 files (~1.41 GB), after scanning 18997 registry packages newest-first down to the watermark and refreshing version metadata for 1072 of them, in about four minutes from one machine. FastLED itself queues nothing, so chore(mirror): index FastLED 3.10.9 (#2019) #2034's case stays fixed; the other 806 are everyone else's releases since 2026-10-30.
Still open: nothing runs this on a schedule. This is a maintainer decision, not a code gap, and I did not make it:
There is no DigitalOcean Spaces credential in this repo — gh secret list shows AZURE_*, PROJECT_APP_PRIVATE_KEY and SOLDR_S3_CACHE_* only. Any workflow would need a new secret.
The pass writes the production bucket; afterwards site/mirror/ has to be regenerated, checked and committed, and a commit to main cannot bypass this repo's merge queue.
Two shapes are worth choosing between, both small once the credential location is decided:
(a) scheduled workflow: update.py → gen_mirror_manifest.py → --check → open a PR carrying the regenerated site/mirror/ (merge queue applies as usual).
(b) systemd timer on a host that already holds ~/.config/do-spaces/credentials.json, pushing the same branch and PR.
Worth pairing with either: prune the dated _state/manifest.db.bak-* copies, which are currently removed by hand.
No bucket writes were made by this run: --check only reads, --dry-run writes nothing.
Closeout 2026-11-21: decisions on the four maintainer items
Code changes: #2127 (merged). Nothing was uploaded to or deleted from the bucket. No droplets were started and no full pass was run.
1. User-Agent for mirror traffic: decided, implemented in #2127
Strategies considered:
(a) Keep the status quo. All tools default to the production UA PlatformIO/6.2.0 (fbuild/<version>), with FBUILD_MIRROR_UA as an override. Simple, but the next ~100 GB full pass would then run under the string real fbuild clients depend on. The fbuild-mirror token was refused right after the last bulk pass. If the production string is refused the same way, every user's registry fallback breaks.
(b) A separate mirror-only default token (e.g. ...; mirror). It isolates the blast radius, but a token marked as a mirror is the one the CDN already refused, so it would very likely be refused again. Rejected.
(c) No default at all; always require FBUILD_MIRROR_UA. Safe, but it adds friction to the small weekly pass. Those deltas are client-sized: today's backlog is 1.5 GB over three weeks, and the default --max-bytes cap is 5 GB.
(d) Tiered (chosen).update.py, the incremental pass capped by --max-bytes, keeps the production default. rotate.py, the bulk pass, stops before creating a droplet unless FBUILD_MIRROR_UA is set explicitly. The traffic pattern that preceded the last refusal can then never go out under the production string by accident.
Implemented with TDD: 4 tests written first and seen failing, then passing. rotate.py --print-user-agent still prints the default.
Caveat for the maintainer: the 403 body ("Please use PlatformIO Core to install packages") may reflect a deliberate PlatformIO policy about mirroring, not a bug. Before any further full pass, it is worth asking PlatformIO for a sanctioned arrangement rather than just picking another UA string.
2. Catch-up run --since 2026-10-01: dry run done, upload NOT done (over the 500 MB limit)
uv run --no-project --script ci/mirror/update.py --since 2026-10-01 --dry-run exited 0:
Bucket DB read: 29305 rows, 29302 done, ETag 88d1e898…8f24.
Scanned 19022 registry packages newest-updated first, and re-read versions for 1108 of them.
884 library files (1.04 GB) across many owners. The largest owners by file count are alash-electronics (45), johboh (32) and endurodave (23).
12 platformio/tool files (0.48 GB). The largest are framework-arduinoststm32 4.30100.0 (79 MB), framework-zephyr 3.40500.261117 (74 MB), and framework-arduinoespressif32 4.30312.261116 and .261113 (49 MB each).
FastLED 3.10.10 (36 MB) is also missing.
This is above the 500 MB limit approved for this task, so nothing was published. The server-side DB backup was not needed, because no write happened.
The backlog grew from 806 files / 1.41 GB on 11-18 to 896 / 1.52 GB today.
Needs maintainer approval: run the same command without --dry-run (1.52 GB, under the 5 GB --max-bytes default). It backs up the DB server-side, transfers the files and uploads the DB with If-Match. Then regenerate and --checksite/mirror/. A smaller alternative is update.py --package fastled/library/FastLED (~36 MB) to get FastLED 3.10.10 in now. It does not set the watermark, so the catch-up is still needed afterwards.
Total: 2 backups, 39 MB. The live _state/manifest.db is 19,570,688 bytes, last modified 2026-11-17 21:48:51.
Strategies considered:
(a) Keep pruning by hand. Error-prone, and it means raw s3 rm commands near the live DB key.
(b) Bucket lifecycle rule (expire .bak-* after N days). It needs no code. But age-based expiry can delete every backup after a quiet period, which leaves none when the next run needs one.
(c) Keep the newest N, as an opt-in tool flag (chosen).update.py --prune-backups KEEP lists every backup and marks the ones beyond the newest KEEP. It deletes only with --delete. It always keeps at least one, refuses any key that is not a .bak- copy, and never runs a pass.
(d) Auto-prune at the end of each publishing run. Rejected for now: deletion was not approved, and it should stay an explicit act.
Recommended policy: keep the newest 5 (~100 MB at today's size). With a weekly schedule that is about a month of rollback points. Today --prune-backups 5 would delete nothing. The dry run with --prune-backups 1 would delete only bak-2026-11-17. That was not run with --delete.
4. Scheduled workflow: recommendation only (no workflow file added)
No workflow was added: the maintainer's global rule forbids new .github/workflows/*.yml files unless requested. Strategies:
(a) Scheduled GitHub workflow (recommended once requested). Run weekly:
Open a PR with site/mirror/ through the merge queue.
It needs new repo secrets for a DO Spaces key scoped to bucket fbuild (there are none today), contents: write and pull-requests: write, and a GitHub App token (PROJECT_APP_PRIVATE_KEY exists) so the PR triggers CI. Its 403 exit code 3 should fail the job loudly.
(b) systemd timer or cron on a machine that already holds ~/.config/do-spaces/credentials.json. It needs no new secrets, but it depends on that machine being up and still needs a gh step for the PR.
(c) Manual runs. This is the interim until (a) or (b) exists.
(d) Piggy-back on an existing scheduled workflow. Rejected, because it would add bucket-write secrets to unrelated build and audit jobs.
Recommendation: (a), first run after the catch-up in item 2 is approved and published, so its first delta is small.
No code work that I can do without approval is left in this issue.
Waiting on the maintainer — not done, and not mine to do:
Catch-up upload: update.py --since 2026-10-01 without --dry-run (896 files, ~1.52 GB at the last dry run), then regenerate and --checksite/mirror/ and merge that PR. Read-only probe today: fastled/library/FastLED/3.10.10/FastLED-3.10.10.tar.gz still answers 403 on the bucket (3.10.9 answers 200), so the backlog is unchanged.
A schedule: a new .github/workflows/*.yml plus DO Spaces secrets (none exist in the repo), or a timer on a host that holds the credentials. New workflow files need an explicit request.
Backup deletion: update.py --prune-backups 5 --delete. Two backups exist (39 MB); nothing has been deleted.
Before any further full pass: the 403 body suggests a deliberate PlatformIO policy — worth asking them rather than choosing another UA.
Decision — close or keep open. (a) Close now and move the three approvals to a new issue: loses the context and the dry-run receipts that sit here. (b) Close as "code complete": wrong, because item 4's own acceptance — new releases actually reach the mirror — is not met while 3.10.10 is missing. (c) Keep open, approval-gated (chosen): the remaining acts are exactly this issue's items 1 and 4, and each is one command once approved.
Activity
zackees commentedon Nov 17, 2026
Claimed by the fbuild-74 coordinator (meta #2035). A sub-agent is starting on item 2 (the generator damaging the committed index), which is in this repo. Items 1, 3 and 4 involve writing to the bucket, an out-of-repo tool, and scheduling; those wait for the maintainer to decide.
zackees commentedon Nov 17, 2026
Item 2 is fixed by #2056 (merged).
Root cause.
site/mirror/has three writers:ci/gen_mirror_manifest.pywrites the owner shards and@names-*.ci/publish_esp_slices.pywrites@esp-libs, version2026.11.04.ci/publish_toolchain_slices.pywrites@esp-toolchain.The generator rebuilt the whole Index from the bucket and the state DB, then pruned every shard file it had not written. With
--prebuiltit also rewroteesp-libs.jsonstamped with the registry shards' version (2026.10.31), and put it before@names-*.What changed. The generator now owns only the registry owners and
@names-*. Any other@entry is kept verbatim, after the generated entries, in committed order, and its shard is never pruned. If such a shard is missing or no longer matches its descriptor, the run raisesForeignShardErrorbefore writing anything.--prebuiltis removed.--checkno longer counts foreign components as removed bucket objects.Validation. Feeding the committed
site/mirror/back through the generator offline reproduces it byte for byte: 29300 objects, the Index order, and both esp shards.Items 1, 3 and 4 are untouched. This fix does not change the state-DB requirement: a regeneration still stops with "objects have no system in the state db" until the bucket's
_state/manifest.dbrecords FastLED 3.10.9.zackees commentedon Nov 17, 2026
Item 1 (the bucket's state DB is out of date) is resolved. This was a data fix in the bucket. No code in this repo changed.
Diagnosis
I downloaded
_state/manifest.dbfrom the bucket. It was last modified 2026-10-30 13:36 UTC, sha25643c2fa92…6711. Its integrity check passes. It has 29302filesrows: 29299doneand 3gone. It is byte-identical to~/dev/fbuild-mirror/local-state/manifest.db.I compared it with the bucket listing. Of the 29300 registry objects, exactly one has no
donerow:fastled/library/FastLED/3.10.9/FastLED-3.10.9.tar.gz. Nodonerow points at a missing object.I reproduced the failure. A regeneration into a scratch copy of
site/mirror/stopped withValueError: 1 objects have no system in the state db, e.g. ['fastled/library/FastLED/3.10.9/FastLED-3.10.9.tar.gz'].--checkexited 0 against the same bucket. It never reads the state DB, so it cannot detect this drift.Strategies considered
mirror.py's schema, back up, upload.system: [](any host), which is wrong for platform-specific toolchains.--check. This could be useful later. It does not fix the data, and the regeneration already fails loudly. Not done here.Chosen: (a). It fixes the actual inconsistency, keeps the generator's fail-loud contract, and can be undone by copying the backup back.
What was done
filesrow with the column setmirror.pywrites:url=https://dl.registry.platformio.org/download/fastled/library/FastLED/3.10.9/FastLED-3.10.9.tar.gz,owner=fastled,type=library,package=FastLED,version=3.10.9,filename=FastLED-3.10.9.tar.gzsystem='*',size=35733120,sha256=8b6af0f3…f751,key=fastled/library/FastLED/3.10.9/FastLED-3.10.9.tar.gzstate='done',attempts=1,last_error=NULL,updated_at=1794890138, which is the object's LastModifiedfastled/library/FastLED3.10.9, the same sourcemirror.py cataloguses.urlis the table's primary key. A latercatalogpass doesinsert or ignore, so it will keep this row and not re-queue the file.packagesrow already existed and is unchanged.pragma integrity_checkreturns ok.fileswent from 29302 to 29303 rows.iterdumpdiff against the original, 0 lines were removed and 1 line was added (the row above).--state-db <new db>into a scratch copy ofsite/mirror/exited 0.diff -ragainst the committedsite/mirror/showed no differences._state/manifest.db.bak-2026-11-17. It is private, made withCopySourceIfMatchon the original ETag, then downloaded again; its sha256 matches the original.~/dev/fbuild-mirror/state-backups/manifest.db.bucket-2026-10-30T133624Z, sha25643c2fa92…6711. The patched DB is beside it (sha256b3c91702…626d)._state/manifest.db. The upload was guarded on the original ETag still being current. It is private andbinary/octet-stream, as before. Nothing else was written and nothing was deleted.Verification (after upload)
_state/manifest.dbagain. Its sha256 isb3c91702…626d, the same as the local patched DB.fileshas 29303 rows, the old 29302 plus 1: 29300doneand 3gone. The 3.10.9 row is present as above.donerows: 0 objects without a row, and 0 rows without an object.ci/gen_mirror_manifest.pyagainst the bucket with no--state-db, into a scratch copy ofsite/mirror/:0 of 29300 objects need hashingwrote 8040 shards covering 29300 objectsdiff -ragainst the committedsite/mirror/: identical, including@esp-libsand@esp-toolchain, thanks to fix(mirror): keep other tools' index entries when regenerating #2056.--checkagainst the bucket: exit 0._state/manifest.dband of the backup both return 403, so neither is public.Left open (not item 1)
~/dev/fbuild-mirror/rotation-work/manifest.dbis an older snapshot: 29085done, 214pending.rotate.py'srestore_manifest()uses that local file in preference to the bucket copy whenever it exists.rotate.pyrun from that directory would restore the stale DB to the droplet. Its next snapshot would then overwrite the corrected bucket DB.zackees commentedon Nov 17, 2026
Item 3 (rejected UA) and the tool's location: PR #2060. It is not merged yet. Its
CI summaryfails only onESP32 Dev / build, an unrelated esptool 5.6.0 provisioning 404 that is breaking every ESP32 build in CI today (#2061), so the merge queue rejects it.Where the tool lives: strategies
ci/mirror/in this repo, next togen_mirror_manifest.py(chosen).mirror.pywrites the state DB (files.key/system/state) thatgen_mirror_manifest.pyreads, so both are now reviewed and tested together.mirror.SCHEMAand reads it throughgen.load_systems._state/manifest.dbkey and registry prefix.~/.config/do-spaces/credentials.json.UA findings (2026-11-17)
I sent 9 requests in total: GETs of a 7.5 KB package (
platformio/platform/native/1.2.1) and one registry API GET.PlatformIO/6.1.16 (fbuild-mirror; +https://github.com/FastLED/fbuild)(old default)PlatformIO/6.2.0 (fbuild-mirror; +https://github.com/FastLED/fbuild)PlatformIO/6.2.0 (fbuild-mirror)PlatformIO/6.2.0 (fbuild/2.2.40)PlatformIO/6.1.16 (fbuild/2.5.52)PlatformIO/6.2.0 (fbuild/2.5.52; +https://github.com/FastLED/fbuild)PlatformIO/6.2.0 (fbuild/2.5.52)(new default)This download method is not supported. Please use PlatformIO Core to install packages.+https://comment make no difference. Thefbuild-mirrortoken alone decides it.rotation.log). The token looks like it was refused specifically after the ~102 GB full pass. That may be a deliberate decision by PlatformIO, and the maintainer should weigh that before the next large pass.api.registry.platformio.org/v3/packages/...returns 200 to the new default.What changed (#2060)
ci/mirror/mirror.pyandci/mirror/rotate.py, code only.FBUILD_MIRROR_SSH_KEY_ID(required),FBUILD_MIRROR_SSH_KEY,FBUILD_MIRROR_WORKDIR(default~/.local/state/fbuild-mirror) andFBUILD_MIRROR_CREDS.PlatformIO/6.2.0 (fbuild/<Cargo.toml version>). A test compares it withregistry_user_agent()incrates/fbuild-core/src/http.rs.FBUILD_MIRROR_UAoverrides it.PlatformIO/prefix, or one unsafe in a systemdEnvironment=line, is refused before any request.rotate.pywrites the UA into the droplet unit.rotate.py --print-user-agentshows it._state/manifest.db, never from the localrotation-work/manifest.db.updated_atstops the run before a droplet is created.done(29085 vs 29299).catalog,fetch_oneand rotate'smainwere split, behaviour-preserving, to meet C901 ≤ 10. Thefetch_onetests pass against the original too.ci/test_mirror_tool.py(29 tests, no network) is registered inci/local_suites.pyandci-workflow-drift.yml.~/dev/fbuild-mirror/is untouched apart from a newMOVED.md.No mirror pass was run, no droplet was started, and nothing was written to the bucket.
zackees commentedon Nov 17, 2026
Item 4 (nothing picks up new registry releases): PR #2066.
Strategies considered
Incremental mode
fbuild-mirrorblock. Rejected.GET /v3/search?query=*&sort=updatedworks and returns packages newest-updated first, each withupdated_at. I checked this against the live API on 2026-11-17. A pass pages down to a stored watermark and re-reads versions only for packages updated since. A 16 h window was one search page plus 26 version requests.--package owner/type/namerefreshes named packages, which is the FastLED 3.10.9 case from chore(mirror): index FastLED 3.10.9 (#2019) #2034.Shard version stamping
--version: the changed shard's version then says nothing. Rejected.--version, which defaults to today's UTC date. The client ignores the field (downloader_mirror_manifest.rschecks onlyschema_version). Regenerating the committedsite/mirror/with a different stamp is byte-identical.Chosen design (#2066)
mirror.py catalogsort=updateddown to a watermark, stored in a newmetatable (registry_updated_since), less a 6 h overlap.insert or ignorequeues only the files the DB lacks.--since.metatable is additive.gen_mirror_manifest.pyignores it, and a test pins that.ci/mirror/update.py(new) runs the incremental pass from one machine, with no droplet. New releases are far below the ~36 GB/IP/day cap. Steps:--package.--dry-runstops here.--max-bytes(default 5 GB; bigger isrotate.py's job).CopySourceIfMatch, transfer, and upload the DB withIf-Match. The upload happens even if the transfer dies.403 fail-fast (item 3's finding)
RegistryRefused, and it is not retried.pendingand are not recorded as errors.registry_refusedmarker with the 403 body is written and the pass exits 3.mirror.py runwill not start while the marker exists, and the droplet unit hasRestartPreventExitStatus=3.rotate.pysees the marker, snapshots the DB, destroys the droplet and exits 3 instead of rotating, because a new IP will not help.ETag-conditional snapshot (item 3's finding)
rotate.pyuploads withIf-Matchon the ETag read, orIf-None-Match: *when there was no DB. A 412 raisesManifestConflict._state/manifest.dbwith a wrongIf-Matchreturned412 PreconditionFailed, and the ETag was unchanged afterwards.gen_mirror_manifest.py --checknow also fails when an object has nodonerow, or adonerow has no object (item 3's finding).Tests are in
ci/test_mirror_tool.pyandci/test_gen_mirror_manifest.py. All 554 tests in the drift job pass locally.What was uploaded
--since 2026-11-17T12:00Zqueued 65 files (166 MB) across 26 packages, all versions the mirror lacks. I did not publish this run: a recent--sinceon a DB without a watermark records one, and that would have hidden the 10-30 → 11-17 window.update.py --package earlephilhower/library/ESP8266Audio --package xylopyrographer/library/LiteLED._state/manifest.db.bak-20261117T214822Z, sha256b3c91702…626d, which is the previous DB."399ebee1…-3".filesrows and the emptymetatable. Thepackagestable is unchanged, and the DB is still private.gen_mirror_manifest.pyhashed 2 of 29302 objects. Only those two owner shards (restamped2026.11.17) and their Index descriptors changed;@esp-*was untouched.--checkexits 0, and both public objects re-download with the registry's sha256.Scheduling: recommendation
(a) By hand: the interim, until (b) exists.
(b) A new scheduled workflow (recommended, not added). The global rule forbids new workflow files unless the maintainer asks for one. Weekly is enough. It would:
uv run --no-project --script ci/mirror/update.py --max-bytes <cap>.gen_mirror_manifest.py --credentials <file>and then--check.site/mirror/changes.It needs:
fbuild, e.g.FBUILD_MIRROR_SPACES_ACCESS_KEY/FBUILD_MIRROR_SPACES_SECRET_KEY, written to a temp JSON file forFBUILD_MIRROR_CREDS/--credentials. No secrets were added.contents: writeandpull-requests: write. A PR opened withGITHUB_TOKENdoes not trigger CI, so it also needs a PAT or GitHub App token if the PR should run CI and enter the merge queue.(c) A cron job or systemd timer on the maintainer's machine works: the credentials are already there. It depends on that machine being up, and it still needs a git/gh step for the PR.
(d) Reusing an existing scheduled workflow: none fits.
nightly-platforms,hw-ci,audit-ignored-testsand the others are build or audit jobs, and adding bucket-write secrets to them would widen their blast radius. Not done.Needs the maintainer
--sinceat or before the first full pass. 2026-10-01 is safe. The log only reaches back to 2026-10-30, and everydonerow is dated 2026-10-30.update.py --since 2026-10-01 --dry-run.PlatformIO/6.2.0 (fbuild/<version>). If PlatformIO blocks that string the way it blockedfbuild-mirror, real fbuild clients' registry fallback breaks too. Small weekly deltas are far from the 102 GB pass, but decide that before scheduling.FBUILD_MIRROR_UAoverrides it._state/manifest.db.bak-*, about 20 MB each. Prune them by hand.zackees commentedon Nov 17, 2026
#2066 merged (5eaf469). Item 4's code is done. The four maintainer items in the comment above are still open: the first
--since 2026-10-01catch-up run, the User-Agent decision, the schedule and its secrets, and pruning backups. So #2040 stays open.zackees commentedon Nov 18, 2026
Steward triage 2026-11-18 — items 1–3 verified delivered; one cell remains (scheduling)
Re-ran the tools against the real bucket today (read-only) rather than trusting the November notes.
Item 1 — bucket state DB drift: closed, and it is now self-detecting.
uv run --no-project --with boto3 python ci/gen_mirror_manifest.py --credentials ~/.config/do-spaces/credentials.json --check→ exit 0 against today's bucket.state_db_drift()inci/gen_mirror_manifest.pyreports objects with nodonerow anddonerows with no object, and--checkfails on either (2d5b877, covered byci/test_gen_mirror_manifest.py). The 2026-11-17 data fix plus this check means "objects have no system in the state db" cannot come back silently.Item 2 — generator damaging the committed index: closed by #2056. Foreign
@esp-*entries are kept verbatim after the generated ones, their shards are never pruned, a missing or mismatched one raisesForeignShardErrorbefore any write,--prebuiltis gone, and--checkno longer counts foreign components as removed objects. A test regenerates the committedsite/mirror/offline and compares byte for byte.Item 3 — User-Agent 403: closed by #2060. Default UA is now fbuild's production
PlatformIO/6.2.0 (fbuild/<version>),FBUILD_MIRROR_UAoverrides it, an unsafe or prefix-less UA is refused before any request, and a 403 stops the pass with exit 3 instead of retrying 6 times per file.Item 4 — new registry releases: tool and incremental mode delivered; the schedule is the one open cell.
mirror.py,rotate.pyandupdate.pyare inci/mirror/withci/test_mirror_tool.pyregistered in the drift workflow.rotate.pyalways restores a droplet from the bucket copy and refuses a local copy that is ahead in rows,donerows or newestupdated_at— the stale-local-DB hazard noted here on 2026-11-17 is closed in-repo.uv run --no-project --script ci/mirror/update.py --since 2026-10-01 --dry-run→ exit 0queued: 806 files(~1.41 GB), after scanning 18997 registry packages newest-first down to the watermark and refreshing version metadata for 1072 of them, in about four minutes from one machine. FastLED itself queues nothing, so chore(mirror): index FastLED 3.10.9 (#2019) #2034's case stays fixed; the other 806 are everyone else's releases since 2026-10-30.gh secret listshows AZURE_*,PROJECT_APP_PRIVATE_KEYandSOLDR_S3_CACHE_*only. Any workflow would need a new secret.site/mirror/has to be regenerated, checked and committed, and a commit tomaincannot bypass this repo's merge queue.Two shapes are worth choosing between, both small once the credential location is decided:
update.py→gen_mirror_manifest.py→--check→ open a PR carrying the regeneratedsite/mirror/(merge queue applies as usual).~/.config/do-spaces/credentials.json, pushing the same branch and PR.Worth pairing with either: prune the dated
_state/manifest.db.bak-*copies, which are currently removed by hand.No bucket writes were made by this run:
--checkonly reads,--dry-runwrites nothing.zackees commentedon Nov 21, 2026
Closeout 2026-11-21: decisions on the four maintainer items
Code changes: #2127 (merged). Nothing was uploaded to or deleted from the bucket. No droplets were started and no full pass was run.
1. User-Agent for mirror traffic: decided, implemented in #2127
Strategies considered:
PlatformIO/6.2.0 (fbuild/<version>), withFBUILD_MIRROR_UAas an override. Simple, but the next ~100 GB full pass would then run under the string real fbuild clients depend on. Thefbuild-mirrortoken was refused right after the last bulk pass. If the production string is refused the same way, every user's registry fallback breaks....; mirror). It isolates the blast radius, but a token marked as a mirror is the one the CDN already refused, so it would very likely be refused again. Rejected.FBUILD_MIRROR_UA. Safe, but it adds friction to the small weekly pass. Those deltas are client-sized: today's backlog is 1.5 GB over three weeks, and the default--max-bytescap is 5 GB.update.py, the incremental pass capped by--max-bytes, keeps the production default.rotate.py, the bulk pass, stops before creating a droplet unlessFBUILD_MIRROR_UAis set explicitly. The traffic pattern that preceded the last refusal can then never go out under the production string by accident.Implemented with TDD: 4 tests written first and seen failing, then passing.
rotate.py --print-user-agentstill prints the default.Caveat for the maintainer: the 403 body ("Please use PlatformIO Core to install packages") may reflect a deliberate PlatformIO policy about mirroring, not a bug. Before any further full pass, it is worth asking PlatformIO for a sanctioned arrangement rather than just picking another UA string.
2. Catch-up run
--since 2026-10-01: dry run done, upload NOT done (over the 500 MB limit)uv run --no-project --script ci/mirror/update.py --since 2026-10-01 --dry-runexited 0:done, ETag88d1e898…8f24.platformio/toolfiles (0.48 GB). The largest are framework-arduinoststm32 4.30100.0 (79 MB), framework-zephyr 3.40500.261117 (74 MB), and framework-arduinoespressif32 4.30312.261116 and .261113 (49 MB each).Needs maintainer approval: run the same command without
--dry-run(1.52 GB, under the 5 GB--max-bytesdefault). It backs up the DB server-side, transfers the files and uploads the DB with If-Match. Then regenerate and--checksite/mirror/. A smaller alternative isupdate.py --package fastled/library/FastLED(~36 MB) to get FastLED 3.10.10 in now. It does not set the watermark, so the catch-up is still needed afterwards.3.
_state/manifest.db.bak-*backups: listed, nothing deleted, opt-in pruning added in #2127_state/manifest.db.bak-2026-11-17_state/manifest.db.bak-20261117T214822ZTotal: 2 backups, 39 MB. The live
_state/manifest.dbis 19,570,688 bytes, last modified 2026-11-17 21:48:51.Strategies considered:
s3 rmcommands near the live DB key..bak-*after N days). It needs no code. But age-based expiry can delete every backup after a quiet period, which leaves none when the next run needs one.update.py --prune-backups KEEPlists every backup and marks the ones beyond the newest KEEP. It deletes only with--delete. It always keeps at least one, refuses any key that is not a.bak-copy, and never runs a pass.Recommended policy: keep the newest 5 (~100 MB at today's size). With a weekly schedule that is about a month of rollback points. Today
--prune-backups 5would delete nothing. The dry run with--prune-backups 1would delete onlybak-2026-11-17. That was not run with--delete.4. Scheduled workflow: recommendation only (no workflow file added)
No workflow was added: the maintainer's global rule forbids new
.github/workflows/*.ymlfiles unless requested. Strategies:(a) Scheduled GitHub workflow (recommended once requested). Run weekly:
update.py(production UA;--max-bytes 2000000000).gen_mirror_manifest.py --credentialsand--check.update.py --prune-backups 5 --delete.site/mirror/through the merge queue.It needs new repo secrets for a DO Spaces key scoped to bucket
fbuild(there are none today),contents: writeandpull-requests: write, and a GitHub App token (PROJECT_APP_PRIVATE_KEYexists) so the PR triggers CI. Its 403 exit code 3 should fail the job loudly.(b) systemd timer or cron on a machine that already holds
~/.config/do-spaces/credentials.json. It needs no new secrets, but it depends on that machine being up and still needs aghstep for the PR.(c) Manual runs. This is the interim until (a) or (b) exists.
(d) Piggy-back on an existing scheduled workflow. Rejected, because it would add bucket-write secrets to unrelated build and audit jobs.
Recommendation: (a), first run after the catch-up in item 2 is approved and published, so its first delta is small.
Status
Leaving this issue open for those.
zackees commentedon Nov 21, 2026
Status check (meta #2035 closeout): open, waiting only on maintainer approval
Re-verified on
maincee21122. No bucket write, no pass, no droplet.Done — all four items have their code on
main:--checknow fails on drift (#2066)@esp-toolchain/ rewound@esp-libsrotate.pyrefuses a full pass unlessFBUILD_MIRROR_UAis set —ci/mirror/rotate.py:704)ci/mirror/), #2066 (update.pyincremental pass), #2127 (update.py --prune-backups KEEP [--delete])No code work that I can do without approval is left in this issue.
Waiting on the maintainer — not done, and not mine to do:
update.py --since 2026-10-01without--dry-run(896 files, ~1.52 GB at the last dry run), then regenerate and--checksite/mirror/and merge that PR. Read-only probe today:fastled/library/FastLED/3.10.10/FastLED-3.10.10.tar.gzstill answers403on the bucket (3.10.9 answers200), so the backlog is unchanged..github/workflows/*.ymlplus DO Spaces secrets (none exist in the repo), or a timer on a host that holds the credentials. New workflow files need an explicit request.update.py --prune-backups 5 --delete. Two backups exist (39 MB); nothing has been deleted.Decision — close or keep open. (a) Close now and move the three approvals to a new issue: loses the context and the dry-run receipts that sit here. (b) Close as "code complete": wrong, because item 4's own acceptance — new releases actually reach the mirror — is not met while 3.10.10 is missing. (c) Keep open, approval-gated (chosen): the remaining acts are exactly this issue's items 1 and 4, and each is one command once approved.