Skip to content

Do not report a base-branch submodule move as a bugfix-validation failure - #117948

Merged
alexey-milovidov merged 8 commits into
ClickHouse:masterfrom
groeneai:fix-bugfix-validation-base-drift-abstention
Sep 13, 2026
Merged

alexey-milovidov merged 8 commits into
ClickHouse:masterfrom
groeneai:fix-bugfix-validation-base-drift-abstention

Conversation

@groeneai

@groeneai groeneai commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #111530

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Bugfix validation (unit tests) no longer reports a failure when the only submodule difference between the merge-base and the checkout came from the base branch.

Description

The job reports ERROR when submodule state differs between merge-base and checkout, without deciding whether the PR or the base branch moved it. Only a PR-side move is the author's to fix.

praktika checks out the synthetic merge ref, so HEAD carries the base tip's pins: master's submodule motion since the split lands in that diff. Since 2026-08-04: 143 error rows, 70 pull requests, more than all other causes combined (87); latest 2026-09-03. Example: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116959&sha=40a2ee8c17b1f660a491bf088121e3cd1b428e51&name_0=PR&name_1=Bugfix%20validation%20%28unit%20tests%29

So compute the PR-side diff too. Empty means the base moved it, and the job reports SKIPPED; non-empty keeps ERROR and names the PR's paths; an uncomputable diff keeps ERROR (fail close). The sibling validators already spell a declined verdict SKIPPED: is_ok covers it (the job exits 0), is_success does not.

The praktika commit keeps that outcome out of the success cache, and every other verdict of this job with it: each one reads the merge base, the PR's labels or its changed-file set, none of which a digest hashes (job_configs.py cites PR 109229). The digest stays, because it also gates affectedness. The keyword is opt-in, so no job that omits it changes behaviour.

On #111530 you wrote that an inconclusive ERROR is honest, for a case that "should stay rare (recent merge-bases)". Drift is nonzero at one day of merge-base age, and a base refresh only postpones it (below). If you still prefer ERROR, say so and I will close this.

Alternative, your call: digest_config=None here, as on the functional and integration validators. That reaches the same place, but the digest is this job's only affectedness gate, so bugfix PRs touching none of its paths would then still schedule a large runner.

My branch has no drift, so this PR's CI cannot exercise the new arm.

How to reproduce both measurements

Paths a merge-base of a given age already differs in, against master 41b3bd68a3a31449af85a6d76eff3814db5b6b1c (2026-09-03), counted exactly as the guard counts them:

D=7; B=$(git rev-list -1 --before="$D days ago" 41b3bd68a3a3)
git diff --raw --ignore-submodules=none $B 41b3bd68a3a3 -- contrib .gitmodules \
  | awk '$1==":160000"||$2=="160000"||$NF==".gitmodules"{print $NF}' | sort -u | wc -l
merge-base age (days) 1 2 4 7 14 30
drifted paths 2 5 5 9 8 24

Not monotonic, because a pin can move and move back. The guard fires as a function of branch age rather than of anything the PR did, and merging master clears it only until the next pin moves.

The row counts are check_status = 'error' (this job leaves test_status empty, so filtering on it returns zero) with position(test_context_raw, 'Submodule state differs between the merge-base and the checkout') > 0, on play.clickhouse.com.


Workflow [PR]
Sync PR [sync-upstream/pr/117948]

Version info

  • Merged into: 26.9.1.1370 (included in 26.9 and later)

The CI cache pushes a success record whenever Result.is_ok() holds, which covers
OK, SKIPPED and XFAIL. That is right for a verdict determined by the checked-out
tree, and wrong for a job whose outcome also depends on run-time state no digest
input captures: the record is then reused on a later commit that hashes the same,
and the run that would have produced a real verdict never happens. See ClickHouse#109229,
where the functional and integration bugfix validators hit exactly this and were
made non-cacheable by dropping their digest entirely.

do_not_cache is the narrower lever for a job whose digest is load-bearing for
scheduling, and it mirrors the existing per-run do_not_block_pipeline_on_failure
flag: same Result.ext dict, same complete_job keyword, one runner consumer. It is
opt-in and appended last in the signature, so a job that does not pass it keeps
today's behaviour exactly, and nothing about digests, affectedness, changed-file
filtering or cache lookup changes.
…lure

The unit-test bugfix validator refuses to build the before-binary when submodule
state differs between the merge-base and the checkout, and reports ERROR. Its
message states a disjunction the code never decides: either the PR changes
submodule state, or the base branch moved a submodule after the branch split.

The workflow checks out GitHub's synthetic merge ref, so HEAD already carries the
base tip's pins and master's own submodule motion since the branch split lands in
that diff unaided. Any long-lived bugfix branch therefore trips the guard as a
function of its age, with nothing contributed by the PR. On every occurrence I
looked at, the merge-base to PR-head submodule diff was empty. Over the 30 days
to 2026-09-03 that is 139 rows across 70 pull requests, the largest error class
of this job, and merging master only moves the merge base, so it returns as soon
as a pin moves again.

Compute the PR-side diff too and decide. An empty PR-side diff means every
drifted path came from the base, which the author cannot influence, so report
SKIPPED: is_ok covers it, so the job exits 0 and the check is not red, while
is_success does not, so the run still never counts as a validation. That is how
the functional and integration validators of the same family already spell a
declined verdict. A non-empty PR-side diff keeps ERROR and now names the PR's own
paths instead of the disjunction. A diff that cannot be computed keeps ERROR, so
an error can never be mistaken for base motion.

The refusal itself, its predicate and its strict=True diff are unchanged, and so
is every other arm of the job. The abstention is marked non-cacheable because the
verdict depends on the merge base, which no digest input captures.
The comment introducing the submodule-drift guard still ended with
`Inconclusive (ERROR), not a pass.`, which is no longer true of every arm:
base-only motion reports `SKIPPED`, and `Result.is_ok` accepts `SKIPPED`, so the
job exits 0 and the check is not red.

Name the per-arm statuses instead, and name `Result.is_success` as the predicate
that counts neither `ERROR` nor `SKIPPED`, so the sentence a reader meets first
is true of all three arms.

Comment only, no behaviour change.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 3, 2026
@groeneai

groeneai commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (1 change, 8 declined or noted; re-review clean)

Reviewed cold against the resulting code, then a second independent pass, then adjudicated with the
recorded validation. The second pass over the fix returned no findings.

❌ Fixed: the comment introducing the guard still ended "Inconclusive (ERROR), not a pass", which
this change makes false for the base-only arm, since Result.is_ok accepts SKIPPED. It now says
which arm reports which status, and that is_success counts neither.

⚠️ Declined, with evidence: a request for regression proof of the three attribution arms and of
the cache opt-out. It exists: five throwaway git init fixtures drive the real main (base-only and
base-deletion to SKIPPED exit 0; PR-side, same-value and unattributable to ERROR exit 1), and the
cache check is read out of ci/praktika/runner.py with ast rather than restated, so reverting that
condition flips the outcome. Six single-hunk mutants were predicted before running and all six
matched, including the one that proves the explicit status= is required: dropping it yields OK,
not ERROR. A positive control (an unflagged OK exit) stayed cacheable in all seven runs. Not
committed as a test, per the repository rule that CI-script tests are throwaway.

💡 Noted, not changed: the doubled path list when the PR is the only contributor to the drift;
the em-dash carried into why_inconclusive (the file goes from 43 to 42, so this change removes one);
the "branch age" comment, kept because it justifies why base-only motion is not the author's to act
on; and two wording nits of my own, one of them in the sentence I asked for above.

The class kept firing while this was in review: re-measured just before posting, 146 error rows over
71 pull requests since 2026-08-04, latest 20:07 UTC today, against 87 for every other cause of an
error on this job.

@clickhouse-gh

clickhouse-gh Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d9b9c8c]

Summary: ✅


AI Review

Summary

Reviewed the current diff and prior discussion. The PR makes the unit-test bugfix validator return SKIPPED for base-only submodule drift, keeps PR-side or unattributable drift as ERROR, and prevents this job's merge-base/label/changed-file-dependent verdicts from being written into the CI success cache. The earlier bot-raised cacheability concern is fixed in the current head, and I did not find new correctness or reliability issues in the updated implementation.

Final Verdict

✅ No blocking or major issues found in the current head.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 3, 2026
@groeneai

groeneai commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov @maxknv, could you review this? The job now also diffs the merge-base against the PR head, so a submodule pin that the base branch moved after the branch split reports SKIPPED rather than ERROR, while a PR-side or uncomputable difference still reports ERROR. The praktika side is an opt-in do_not_cache keyword, so that abstention is not kept in the success cache.

Unlike its functional and integration siblings, `Bugfix validation (unit tests)`
keeps a `digest_config`, so an `is_ok` result is pushed to the CI cache and
reused by any later commit whose digest inputs hash the same. A job digest
hashes the checkout's files and submodule revisions (`ci/praktika/digest.py`)
and never the merge-base commit, while the verdict is computed against
`git merge-base <pr head> origin/master`, which jumps forward the moment the
author merges master into the branch. The synthetic merge ref's tree is
idempotent under that merge, so the digest can be unchanged across it: on master
for 2026-09-03, 2 of 14 one-hour windows changed none of this job's digest
paths.

Both success exits that read the merge base (the compile-attribution "nothing to
validate" `XFAIL` and the reproduced-bug `XFAIL`) were therefore reusable at a
merge base they were never computed against, which can hide a later `FAIL`, the
one verdict that blocks. They now set `do_not_cache`, like the base-only
submodule-drift arm.

The three short circuits above the merge-base resolution stay cacheable: they
read the PR labels and the changed unit-test files, and `src/**/tests/*` lives
inside the digest's `./src`. Keeping those cached is why this job marks
individual exits rather than dropping `digest_config` the way the functional and
integration validators do: it pulls the binary-builder image and populates
submodules before it can short-circuit at all.
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Sep 3, 2026
Of this job's success exits, the `Not a bugfix PR` short circuit is the one
whose verdict can change while its digest cannot. A digest hashes the
checkout's files and submodule revisions, so the PR's labels are not an input,
and a label moves without any code change.

`ci-force-all` is what makes the exit reachable: it bypasses the workflow
filter hooks that otherwise skip every `Bugfix` job on a non-bugfix PR, and it
skips only the cache lookup, so the run still pushes a success record for
(job, digest). Adding `pr-bugfix` and dropping `ci-force-all` afterwards is a
changelog category edit, which leaves the tree byte-identical, so the next
normal run reuses that `OK` and `new_tests_check` no longer sees the `FAIL` a
fresh run would report.

The two exits that stay cached read the changed-file set instead, which cannot
gain or lose a `src/**/tests/*` entry without also changing the digest.
`complete_job`'s note on the cache flag had no main clause. The submodule guard's
note said "either way" in two consecutive sentences, once about the causes of the
difference and once about the result arms.

The inconclusive-verdict message used an em-dash; plain ASCII punctuation is the
house style for user-visible text.
The two commits before this one exempted the verdicts that read the merge base and
the one that reads the PR's labels, and left the two changed-file short circuits
cacheable, on the argument that a merge cannot add a `src/**/tests/*` entry to the
changed set without also changing `./src`. That argument is wrong.

The changed set is GitHub's PR file list, the diff from the merge base to the head,
while the digest hashes the checkout, which is the base+PR merge ref. When master
changes a unit-test file AFTER a run has been cached, and the branch then merges
master while keeping its own content for that file, the merge ref's `./src` is still
the content the cached run hashed, yet the file has entered the changed set.
Measured over nine shapes in which master moves between the two runs: five reproduce
it, the producing branch actions being a restore of the branch's own content for
that file after the merge, and a merge with `-s ours`.

Every verdict of this job reads the merge base, the PR's labels or the changed-file
set, so `finalize` marks them all non-cacheable and the per-exit keyword arguments
are gone. `digest_config` stays: praktika also uses it to skip the job when the PR
touches none of its paths.
The note added beside `do_not_cache` in `complete_job` was two dependent clauses with
no main clause, both in its original form and in the first attempt at rewording it.
@alexey-milovidov alexey-milovidov self-assigned this Sep 13, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 13, 2026
Merged via the queue into ClickHouse:master with commit 50df683 Sep 13, 2026
174 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants