Repository navigation
fix(mirror): keep the shard version and re-hash same-size replacements (#1825) - #1845
Merged
Merged
Conversation
#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.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 1, 2026
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.
Follow-up to the #1815 review (#1825), generator items only.
--versionno longer silently resets to"1"--version's help said "default: keep the existing one" butmain()didargs.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 (mostcommon value;
names-*shards are ignored because they are generated from thesame 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.31writes2026.10.31, not1.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 S3quoting; multipart
-<n>suffixes are preserved as-is).size<TAB>etag<TAB>sha256<TAB>keyinsite/.mirror-hashes.tsv-- beside the published tree, never inside it,and git-ignored.
--checkpointstill overrides the path, and the oldthree-column format is still read.
is_stale()is the one rule used by both--checkandhash_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 ETagnormalization, 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.ymlandci/local_gate.py-- a test module no workflow executes is a decorative guard.ruff check(both files) clean,ci/check_python_complexity.pyclean,ci/render_workflows.py --checkclean,ci/check_workflow_concurrency.pyOK.No Rust was touched, so
bash testwas not re-run.Not in this PR (deliberately)
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-publishedbenchmark-statsbranch and sharesthe benchmark's concurrency group -- a design change worth its own PR (and
its own review), not a YAML move.
maintainer-created secrets, per the issue.
(
fbuild-packages-fetch), not generator.Closes nothing on its own -- #1825 still tracks items 1, 2 and 4.