Skip to content

fix(mirror): keep other tools' index entries when regenerating - #2056

Merged
zackees merged 3 commits into
mainfrom
fix/mirror-manifest-preserve-2040
Nov 17, 2026
Merged

zackees merged 3 commits into
mainfrom
fix/mirror-manifest-preserve-2040

Conversation

@zackees

@zackees zackees commented Nov 17, 2026

Copy link
Copy Markdown
Member

Part of #2040 (item 2). Items 1, 3 and 4 are untouched.

Root cause

site/mirror/ has three writers. Only one of them knew about the others.

Index entry Shard Written by
owners, @names-* shards/<id>.json, shards/names-*.json ci/gen_mirror_manifest.py
@esp-libs shards/esp-libs.json (version 2026.11.04) ci/publish_esp_slices.py (upserts one component per run; 072ee66 ... 66c4e04, 2026-11-04)
@esp-toolchain shards/esp-toolchain.json (version 1) ci/publish_toolchain_slices.py (c5c7227 ... ff3cdf0, 2026-11-07/08)

The generator rebuilt the whole Index from the bucket listing and the state DB, then deleted every shard file it had not written. So:

  • esp-toolchain.json and @esp-toolchain were deleted.
  • esp-libs.json was either deleted or, with --prebuilt, rewritten wholesale. It was stamped with the generator's single shard version, the majority version of the 8040 registry shards (2026.10.31). That is the rewind from 2026.11.04.
  • The generator emitted @esp-libs before @names-*, but the publishers append after them. That is the reorder.

The committed index is not newer data the generator failed to fetch. Two of its entries come from other tools that the generator never reads.

Fix: option (a), keep what it doesn't own

  • gen_mirror_manifest.py now owns only the registry owners and @names-*. Every other @ key belongs to another tool. That namespace is already reserved, because @ is escaped in owner keys.
  • Foreign entries are carried over from the committed manifest.json verbatim, after the generated entries, in committed order. Their shard files are never pruned or rewritten.
  • Fail loud: if a foreign entry's shard is missing, or no longer hashes to its descriptor, ForeignShardError is raised before any file is written. If a foreign key collides with a generated one, it also raises.
  • Foreign shards no longer feed load_existing. Before, --check counted their component ids (for example toolchain-xtensa-esp-elf/...) as removed bucket objects and always failed. They also no longer feed the shard-version vote.
  • --prebuilt is removed. It was a second writer for @esp-libs that replaced the shard wholesale (dropping components missing from FILE) and restamped its version. No committed shard was ever produced by it.

Why not (b) or (c):

  • (b), teaching the generator to produce these shards, would duplicate the two publishers. Their inputs (vendor metadata, slicer output, upload results) are not in the bucket listing or the state DB.
  • (c), refusing to write unless --allow-removal is passed, would make every routine regeneration need a flag to get past entries it was never meant to touch.

Commits

  1. refactor: extract write_site from main. Behaviour-preserving; the existing tests stay green.
  2. fix: the behaviour change plus tests and docs.
  3. style: ruff format of the two touched Python files. Formatting only; both were unformatted on main.

Tests (ci/test_gen_mirror_manifest.py, TestCommittedIndex, tempdirs, no network)

I ran these RED against commit 1, and they fail there for behavioural reasons:

  • Regenerating keeps the esp-toolchain shard bytes and its @esp-toolchain entry.
  • The registry version 2026.10.31 does not rewind esp-libs.json from 2026.11.04.
  • With unchanged inputs, the whole tree is rewritten byte for byte, so there is no reorder.
  • A new registry owner sorts in, and foreign entries stay last in committed order.
  • A missing foreign shard raises ForeignShardError and writes nothing.
  • A foreign shard that no longer matches its descriptor raises.
  • load_existing (used by --check) ignores foreign components.
  • existing_version ignores foreign shards.

Validation

  • uv run --with pyyaml --with zstandard --no-project python -m unittest ci.test_gen_mirror_manifest ci.test_publish_toolchain_slices ci.test_local_suites: 60 tests OK.
  • Real-data round trip, with no bucket access. I fed a scratch copy of the committed site/mirror/ back through write_site, using its own shards as the hashed inputs and their provides as systems. The result was 29300 objects, 8040 owner shards and 16 names shards, and diff -r against site/mirror/ is identical, including esp-libs.json, esp-toolchain.json and the Index order.
  • publish_toolchain_slices.py --check still passes against the committed tree.
  • ruff check and ci/check_python_complexity.py (C901 <= 10) pass.
  • No workflow runs the generator. CI only runs its unit tests, via ci-workflow-drift.yml and ci/local_suites.py, and that module list is unchanged.

Behaviour-preserving: write_site builds the documents, prunes unlisted
shards and writes the tree, so the write path can be tested without a
bucket (#2040).
gen_mirror_manifest.py rebuilt the whole Index from the bucket, so a
regeneration deleted shards/esp-toolchain.json and @esp-toolchain (written
by publish_toolchain_slices.py), and either deleted @esp-libs (written by
publish_esp_slices.py) or, via --prebuilt, rewrote it wholesale stamped
with the registry shards' version (2026.11.04 -> 2026.10.31) and moved it
ahead of @names-*.

The generator now owns only the registry owners and @names-*. Every other
@ entry is carried over verbatim after the generated entries in committed
order, its shard is never pruned, and one whose shard is missing or no
longer hashes to its descriptor raises ForeignShardError before anything
is written. Foreign shards no longer feed load_existing (so --check no
longer reports their components as removed bucket objects) or the shard
version vote. --prebuilt is removed: it was a second writer for
@esp-libs, never used for a committed shard.

Part of #2040 (item 2).
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees
zackees added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit bf798aa Nov 17, 2026
29 checks passed
@zackees
zackees deleted the fix/mirror-manifest-preserve-2040 branch November 17, 2026 13:36
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant