Skip to content

fix(mirror): keep the shard version and re-hash same-size replacements (#1825) - #1845

Merged
zackees merged 1 commit into
mainfrom
agent/mirror-manifest-1825
Nov 1, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/mirror-manifest-1825

Conversation

@zackees

@zackees zackees commented Nov 1, 2026

Copy link
Copy Markdown
Member

Follow-up to the #1815 review (#1825), generator items only.

--version no longer silently resets to "1"

--version's help said "default: keep the existing one" but main() did
args.version or "1", so a bare re-run would rewrite every shard's version.

Now existing_version() reads the version the shards on disk carry (most
common value; names-* shards are ignored because they are generated from the
same run) and falls back to "1" only when there is nothing to keep.
Verified end-to-end: a bare re-run over shards at 2026.10.31 writes
2026.10.31, not 1.

Same-size replacement is re-hashed

The change check compared size only, so an object replaced with same-size bytes
was never re-hashed and its committed SHA-256 went stale.

  • list_bucket() now keeps the listing's ETag (etag_value() strips the S3
    quoting; multipart -<n> suffixes are preserved as-is).
  • Each hashed object is recorded as size<TAB>etag<TAB>sha256<TAB>key in
    site/.mirror-hashes.tsv -- beside the published tree, never inside it,
    and git-ignored. --checkpoint still overrides the path, and the old
    three-column format is still read.
  • is_stale() is the one rule used by both --check and hash_missing():
    size change ⇒ stale; equal sizes with two known, different ETags ⇒ stale.
    A record read from a committed shard has no ETag, so the first run after
    this change compares by size only and does not re-download the mirror.

E2E with a fake bucket (no network): run 1 hashes 2 objects; changing one
object's bytes and ETag at the same size re-hashes exactly that 1 and leaves
the other's SHA reused; deleting the state file restores size-only behaviour.

Also fixed

The state/checkpoint log file was opened and never closed (ResourceWarning);
hash failures are now collected by a helper and the handle is closed in a
finally.

Tests

ci/test_gen_mirror_manifest.py, 17 tests: registry-key listing and ETag
normalization, the staleness rule (new / resized / same-size replacement /
unchanged / shard-without-ETag / no listing ETag), both state-file formats, the
version fallback, and an incremental re-hash run that asserts the new SHA and
the recorded ETag line.

Registered in .github/workflows/ci-workflow-drift.yml and
ci/local_gate.py -- a test module no workflow executes is a decorative guard.

uv run --with pyyaml --no-project python -m unittest ci.test_setup_action \
  ci.test_fractional_workflows ci.test_local_gate ci.test_local_dylint_gate \
  ci.test_local_lint_gate ci.test_publish_quota ci.test_gen_mirror_manifest
Ran 73 tests ... OK

ruff check (both files) clean, ci/check_python_complexity.py clean,
ci/render_workflows.py --check clean, ci/check_workflow_concurrency.py OK.
No Rust was touched, so bash test was not re-run.

Not in this PR (deliberately)

  • Item 1, decouple the Pages deploy from the benchmark build. A Pages
    deploy replaces the whole site, so a mirror-only deploy job in the same
    workflow either races the benchmark deploy or wipes the benchmark stats.
    Doing it correctly means a separate workflow that composes
    site/mirror/ with the already-published benchmark-stats branch and shares
    the benchmark's concurrency group -- a design change worth its own PR (and
    its own review), not a YAML move.
  • Item 2, scheduled incremental hashing with bucket credentials. Needs
    maintainer-created secrets, per the issue.
  • Item 4, vendor-before-unverified ordering is client-side
    (fbuild-packages-fetch), not generator.

Closes nothing on its own -- #1825 still tracks items 1, 2 and 4.

#1825)

Three generator defects from the #1815 review:

- `--version` claimed to keep the existing version but wrote "1", so a
  bare re-run would rewrite every shard's version. It now reads the
  version the shards on disk carry (most common), falling back to "1"
  only when there are none.
- The incremental change check compared size only, so an object
  replaced with same-size bytes was never re-hashed and its committed
  SHA-256 went stale. The listing's ETag is now normalized and
  recorded per object in `site/.mirror-hashes.tsv` (git-ignored, beside
  the published tree, never inside it; `--checkpoint` overrides it).
  Comparison is size + ETag, and only when both sides know an ETag --
  a record read from a committed shard has none, so upgrading does not
  re-download the whole mirror.
- The state log file was never closed; hash failures are now collected
  by a helper whose file handle is closed in a `finally`.

`ci/test_gen_mirror_manifest.py` (17 tests) covers the listing, the
staleness rule including the same-size replacement, both state-file
formats, the version fallback and the incremental re-hash. It was
registered in `ci-workflow-drift.yml` and `ci/local_gate.py` -- a test
module no workflow runs is a decorative guard.
@coderabbitai

coderabbitai Bot commented Nov 1, 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 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 1, 2026
@zackees
zackees added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit 2a0fda0 Nov 1, 2026
29 checks passed
@zackees
zackees deleted the agent/mirror-manifest-1825 branch November 1, 2026 21:38
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 2, 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