8000 fix(autoindex): split diverged identical files into two groups by ege-arhan · Pull Request #3832 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(autoindex): split diverged identical files into two groups - #3832

Open
ege-arhan wants to merge 1 commit into
xerj-org:mainfrom
ege-arhan:fix/diverged-identical-pair
Open

ege-arhan wants to merge 1 commit into
xerj-org:mainfrom
ege-arhan:fix/diverged-identical-pair

Conversation

@ege-arhan
@ege-arhan ege-arhan commented Dec 2, 2026 •
Copy link
Copy Markdown

What this changes, and why

Fixes #3831.

The second autoindex pass aborts with error: group claimed twice when two byte-identical files have diverged between passes.

reconcile_groups picks the new group id in this order: known content id, then path ownership, then a derived id. When the content changed, no content id matches, so the decision falls to path_owners. A predecessor group that held both identical copies owns both paths. Both new desired groups therefore get that one predecessor group_id, and the second claimed.insert(group_id) returns false:

anyhow::ensure!(claimed.insert(group_id.clone()), "group claimed twice");

The first group keeps the predecessor id; later groups that would collide now get a derived axg1-… id instead of aborting the pass. Re-running on the result is a no-op, so the next pass sees two independent groups and stops there.

Nothing else changes: content ids, digests, canonical path selection, and the existing "changed file can join surviving content group" path are untouched.

Evidence

New test diverged_identical_pair_does_not_claim_one_group_twice builds one predecessor group with paths 61 and 62, then reconciles two desired groups with different content ids and one path each.

Parent commit cc6aee8:

test sync::tests::diverged_identical_pair_does_not_claim_one_group_twice ... FAILED
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2124 filtered out

With the change:

test sync::tests::diverged_identical_pair_does_not_claim_one_group_twice ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2124 filtered out

Full xerj-autoindex lib suite with the change:

cargo test -p xerj-autoindex --lib
test result: FAILED. 2122 passed; 1 failed; 2 ignored; 0 measured; 0 filtered out; finished in 46.68s

The single failure is xc::tests::xerj_code_on_an_empty_ledger_names_catalog_prefixes (assertion left == right failed: a non-empty ledger must not probe the catalog, left 3, right 2). It fails the same way on parent commit cc6aee8 with my change stashed, so it is not from this diff.

Checks

  • cargo fmt --all — cargo fmt -p xerj-autoindex -- --check exits 0
  • Scoped release build: cargo build --release -j 8 -p xerj-autoindex -> Finished \release` profile [optimized] target(s) in 2m 45s`
  • cargo test -p xerj-autoindex passes — 2122 passed, 1 pre-existing failure named above
  • ES-YAML conformance suite — not run
  • New ES-compatible behaviour has a matching YAML case — not applicable, this is an autoindex/group-reconciliation fix, no query behaviour
  • Docs updated — not applicable, no user-visible option or output format changed
  • Applicable audit in docs/CONTRIBUTION_REVIEW.md — recovery/stateful read: the change only widens group-id derivation, and the new test asserts the second pass over the result is idempotent

Not run: ES-YAML suite (this change touches neither the query path nor ES compatibility, so the suite would not exercise it). cargo clippy -D warnings fails in crates/xerj-common/src/packed_f32.rs:55 on chunks_exact → as_chunks with rustc 1.100.0 — that file is untouched by this diff and the lint fires on parent commit too.

Provenance

  • Written by: AI agent (Claude, run by @ege-arhan who reviewed the diff and the test output)
  • Verified (commands run, output observed): the test above fails on cc6aee8 and passes with the change; cargo test -p xerj-autoindex --lib 2122 passed / 1 pre-existing failure; cargo fmt -p xerj-autoindex -- --check exit 0; cargo build --release -j 8 -p xerj-autoindex finished in 2m45s; xc::tests::xerj_code_on_an_empty_ledger_names_catalog_prefixes fails identically on the parent commit.
  • Assumed (not tested, and what would falsify it): I did not run the end-to-end xerj autoindex script from the issue against a built release binary, so I have not watched the CLI print success on the second pass. The unit test asserts the same reconcile_groups contract that the CLI path calls through sync_executor::reconcile. If the CLI failure came from a different call site that reimplements group claiming, this patch would not fix it; the binary repro would show the error still present.

`reconcile_groups` derives the new group id from path ownership when the
content id is unknown. A predecessor group that held two byte-identical
paths gives both new desired groups that same owner, so the second
`claimed.insert` returns false and the pass aborts with "group claimed
twice" (xerj-org#3831). The files were identical on the first pass and diverged
between the two passes, so no content id matches and every new group
falls through to the path-owner branch.

Keep the predecessor id for the first group, as before, and derive a new
`axg1-...` id for later ones that would collide. The second pass writes
both files instead of failing, and re-running on the result is a no-op.

Test: `diverged_identical_pair_does_not_claim_one_group_twice` fails on
the parent commit and passes with the change; full `xerj-autoindex` lib
suite is 2123 passed, with `xc::tests::xerj_code_on_an_empty_ledger_names_catalog_prefixes`
failing on the parent commit too.
@cla-bot
cla-bot Bot commented Dec 2, 2026
Copy link
Copy Markdown

Thanks for this contribution — we'd like to merge it.

Before we can, we need a signed Contributor License Agreement from: @ege-arhan

It is a one-time thing per contributor, not per pull request. Read CLA.md, then open a small pull request adding your GitHub username to .contributors — that pull request is your signature, since it is made from your own account.

Once it is merged, comment @cla-bot check here and this check will go green. If you believe you are already covered, comment @cla-bot check and it will re-verify.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: autoindex fails when two identical files diverge

1 participant

0