Repository navigation
Fix unit-test bugfix validation: force submodule checkout so the before-binary configures - #111530
Merged
Merged
Conversation
…fore-binary configures The "Bugfix validation (unit tests)" job builds a "before" binary from the merge-base sources (with only the PR's unit-test files overlaid) and checks that the new test fails without the fix. It populates the before-worktree's submodule working trees by hardlinking them from the primary checkout, whose submodules are in turn checked out by `ensure_primary_submodules`. That checkout used `git submodule update --depth 1 --single-branch`. When the runner restores the submodule S3 cache, each submodule's `.git/modules` data is present with `HEAD` already at the recorded gitlink, but the working tree is empty. In that state `git submodule update` (without `--force`) sees `HEAD == recorded commit`, considers the submodule up-to-date, and leaves the working tree empty. The hardlink loop then found `contrib/abseil-cpp` empty in the primary checkout, silently `continue`d past it, and `cmake` later failed with a misleading `Cannot find source file ... throw_delegate.cc / borrowed_fixup_buffer.cc` — an infrastructure problem reported as a red job that never actually validated anything. Fixes: - `ensure_primary_submodules`: add `--force` so `git submodule update` runs `git checkout --force` unconditionally and repopulates a submodule whose `HEAD` already matches but whose working tree is empty. Verified in isolation: with the `.git` link and module `HEAD` present at the recorded commit but the files removed, plain `update` leaves the working tree empty while `--force` restores it. - `prepare_before_worktree`: run `ensure_primary_submodules` before creating the worktree; check the `cp -al` exit status and that the destination ended up non-empty; treat a submodule that is empty in the primary checkout as a hard failure instead of silently skipping it. Any failure now fails close with a precise per-submodule message and the job reports an infrastructure ERROR rather than a spurious cmake source-file error. Surfaced by the "Bugfix validation (unit tests)" job on https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110833&sha=1fd7b845e718f6d4ce0f2dbffb5a44b20d43eb9e&name_0=PR&name_1=Bugfix%20validation%20%28unit%20tests%29 Related: #110833 Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
|
Workflow [PR], commit [3e5e777] Summary: ✅ AI ReviewSummaryThis PR hardens the Final Verdict
|
The before-worktree's submodules are hardlinked from the primary checkout, which is at the PR-head revisions. If the PR changes any submodule gitlink or `.gitmodules`, the "before" binary would be built against PR-head submodule content (or miss a merge-base-only submodule), and the validator could report a false reproduction or refutation. Detect submodule state changes between the merge-base and the PR head via `git diff --raw --ignore-submodules=none` (the override matters: a `diff.ignoreSubmodules=all` config would otherwise hide every gitlink change) and report an infrastructure `ERROR` instead of validating against the wrong code. Co-Authored-By: Claude Fable 5 <[email protected]>
The AI review requested focused tests for the submodule-state guard added in the previous commit. Cover, with a mocked `Shell.get_output`: a gitlink bump, added/removed gitlinks (mode 160000 on one side only), a `.gitmodules`-only edit, a clean diff, an empty diff, and malformed/noise lines. Also assert the command passes `--ignore-submodules=none` and diffs the merge-base against the PR head. Co-Authored-By: Claude Fable 5 <[email protected]>
…not the PR head The fail-close guard `get_submodule_state_changes` diffed the merge-base against the PR head, but `prepare_before_worktree` hardlinks submodule working trees from the primary checkout, whose submodules are checked out at `HEAD`'s recorded revisions — normally GitHub's synthetic base+PR merge ref. A base-only submodule bump after the branch split therefore escaped the guard: the PR's own diff shows no gitlink change, yet `ensure_primary_submodules` checks out the base-tip revision and the hardlink step copies it into the merge-base worktree, so the before-binary would build merge-base sources against base-tip contrib content and could produce a false reproduction or refutation. Compare the merge-base against `git rev-parse HEAD` instead — the commit whose submodule trees are actually copied — which catches both PR-side gitlink/`.gitmodules` edits and base-side drift. Add a focused wiring test that `main` passes the checkout `HEAD` (not the PR head) to the guard. Co-Authored-By: Claude Fable 5 <[email protected]>
…dule worktrees Two fail-close gaps from the AI review: - `get_submodule_state_changes` now runs the `git diff --raw` with `strict=True`: without it, `Shell.get_output` swallows a non-zero git exit (missing object in the shallow checkout, transient error) into an empty string, and the drift guard would silently disable itself. - `prepare_before_worktree` now uses `submodule_worktree_populated`, which ignores the bookkeeping `.git` entry, for both the source submodule and the hardlinked destination: a plain `git submodule update` can exit 0 leaving exactly `['.git']` in the working tree, which a bare `os.listdir` non-empty check would accept, propagating a sourceless tree into the before-worktree and reintroducing the misleading cmake "cannot find source file" failure. Covered by new unit tests (strict flag asserted, diff failure propagates, `.git`-only and empty directories rejected, real content accepted). Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Jul 26, 2026
Closed
This was referenced Aug 12, 2026
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…-submodules Fix unit-test bugfix validation: force submodule checkout so the before-binary configures
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix the
Bugfix validation (unit tests)job failing to configure the "before" binary.Description
The
Bugfix validation (unit tests)job builds a "before" binary from the merge-base sources (with only the PR's unit-test files overlaid) and checks that the new test fails without the fix. It populates the before-worktree's submodule working trees by hardlinking them from the primary checkout, whose submodules are checked out byensure_primary_submoduleswithgit submodule update --depth 1 --single-branch.When the runner restores the submodule S3 cache, each submodule's
.git/modulesdata is present withHEADalready at the recorded gitlink, but the working tree is empty. In that stategit submodule update(without--force) seesHEAD== the recorded commit, considers the submodule up to date, and leaves the working tree empty. The hardlink loop then foundcontrib/abseil-cppempty in the primary checkout, silentlycontinued past it, andcmakelater failed with a misleadingCannot find source file ... throw_delegate.cc / borrowed_fixup_buffer.cc. This is an infrastructure problem that surfaced as a red job which never actually validated the bugfix.Fixes:
ensure_primary_submodules: add--forcesogit submodule updaterunsgit checkout --forceunconditionally and repopulates a submodule whoseHEADalready matches but whose working tree is empty. Verified in isolation: with the.gitlink and moduleHEADpresent at the recorded commit but the files removed, plainupdateleaves the working tree empty while--forcerestores it.prepare_before_worktree: runensure_primary_submodulesbefore creating the worktree; check thecp -alexit status and that the destination ended up with real content (a directory holding only the bookkeeping.gitentry counts as empty); treat a submodule that is empty in the primary checkout as a hard failure instead of silently skipping it. Any failure now fails close with a precise per-submodule message and the job reports an infrastructureERRORrather than a spuriouscmakesource-file error..gitmodules) differs between the merge-base and the checkoutHEAD(normally GitHub's synthetic base+PR merge ref, whose submodule working trees are what gets hardlinked): whether the PR edits submodule state or the base branch moved a submodule after the branch split, the before-binary would otherwise silently build merge-base sources against the wrong submodule content and could report a false reproduction/refutation. The job reports an infrastructureERROR(inconclusive) instead. The guard'sgit diffis strict: a failed diff raises instead of silently disabling the guard. Covered by focused unit tests inci/tests/test_unit_tests_bugfix_validation.py.Surfaced by the
Bugfix validation (unit tests)job on https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110833&sha=1fd7b845e718f6d4ce0f2dbffb5a44b20d43eb9e&name_0=PR&name_1=Bugfix%20validation%20%28unit%20tests%29 (PR #110833).Documentation entry for user-facing changes
🤖 Generated with Claude Code
Version info
26.8.1.129(included in26.8and later)