Repository navigation
Conversation
The LLVM Coverage diff gate compares a baseline line-coverage percentage against the current one and fails the PR on a drop above 0.3 pp. Both percentages are merged from per-shard .profdata artifacts declared optional=True, and neither side was ever validated as a complete measurement. Five independent routes drop a shard while every check-run stays success: a producer merge that crashes and uploads nothing, an aggregate merge that discards a corrupt input under -failure-mode=warn, an unbounded *.profdata glob that never compares what arrived against what was expected, a run that stopped early yet still publishes a structurally valid but under-covered profile, and a zero-length .profraw, which llvm-profdata ignores silently at every --failure-mode. The defect is symmetric and the second direction is worse. A short PR side fails an unrelated PR for a regression it did not cause. A short baseline has a low total, so a real regression passes; that case produces a PASS, emits no failure row, and is therefore invisible in any failure count. Enforce one invariant: a verdict, and every number derived from it, is produced only from two complete measurements of the same artifact manifest. Each fact is produced by the component that owns it. All four merge sites become all-or-nothing via --failure-mode=any, which lets the three producer two-string corrupt-profile parsers go away. The functional and integration producers create no profile when the run did not execute what it planned; the functional fact comes from a new authoritative marker inside tests/clickhouse-test, because "All tests have finished." is also printed by a run that lost a worker (the counter tested there is the number of tests SELECTED), and the integration fact is recorded at the phase scheduler and snapshotted before the coverage block resets has_error. Zero-length raw inputs are rejected. Each shard names its profile after its own coverage artifact, so completeness is exact set equality rather than a difference, which would accept a foreign profile, and the aggregate merge receives an explicit expected-intersect-present file list instead of a glob. A llvm_coverage.meta.json sidecar rides on the existing llvm_coverage.info artifact's path list, so no new artifact name is introduced and no workflow file changes. The selector prefers a complete, manifest-matching ancestor and keeps today's first-match walk as a fallback. The consumer judges only when both sides are complete over the same manifest and otherwise reports SKIPPED with the reason, which counts as OK, withholding every comparative output including the CI DB row on the master path that later baselines read. The full HTML report is still published, labelled as a partial measurement, since it is the best artifact for identifying the missing shard. No master commit published before this carries a sidecar, so a missing sidecar means "unknown" and the fallback selector pass reproduces today's behaviour until master republishes; nothing starts failing at merge time. Not covered, and disclosed in the description: two runs can both be complete over the same artifact manifest while exercising different code, for example when a commit changes which integration suites are selected without changing the manifest. The fingerprint detects artifact-list drift only. The praktika change is one additive line giving a locally-run job its own JOB_CONFIG, mirroring _setup_env; without it a locally-run coverage shard cannot derive its profile name. It is deliberately not registered in the coverage digests, because CI never executes generate_local_run_environment.
… unit-test jobs working Two guards introduced by the previous commit did not reach the path they exist to serve. Both were found independently by review and by the automated gate. The differential coverage script was invoked unconditionally. Its own precondition exits 1 when llvm_coverage.info is absent, which is exactly the state a failed aggregate merge deliberately leaves behind: the merge writes `failed` to its marker, publishes no .info and exits 0 so the job can report SKIPPED. A non-zero command makes the sub-result FAIL, and the script dies before genhtml, so the output directory is missing and the SKIPPED override nested under that directory's existence is never evaluated. The job therefore reddened on precisely the run that four separate places in this change promise it cannot. The absent-.info condition is now evaluated before the invocation, and the invocation is skipped in that case; the result keeps the same name so the report links are unaffected. The existing override stays, because it still serves the other incomparable causes, where the script does succeed. The unit-test profile naming block sat at unconditional top level, between the gtest run and the result write. The six sanitizer Unit tests parameter sets declare no coverage artifact, so the assertion on `provides` fired there and the job died without writing its result, discarding the gtest outcome rather than mis-reporting it. The block moves back inside the existing `.profraw` guard, where the profile filename was a literal before this change: a non-instrumented binary emits no .profraw, so there is nothing to name. The assertions are unchanged; they are correct for the one job that does declare an artifact. The two cells that covered these lines only checked that a substring appeared in the job source, which is how both defects survived. They are replaced by behavioural cells that execute the real statements in their real order, and the one that matters asserts the composite job result is green rather than only the sub-result's status. Three mutations, one per behaviour, each reddening its intended cell. Co-Authored-By: Claude Opus 5 <[email protected]>
…eport an empty measurement as skipped Four defects in the completeness protocol, all in the ci/ Python. The baseline sidecar and the selected-base marker were read above the differential script, which is their only writer: the wget in generate_diff_coverage_report.sh fetches base_llvm_coverage.meta.json and the echo near its end writes selected_base_commit.txt. Both reads therefore returned nothing on every run, so comparable() took its absent-baseline branch and the gate abstained even when both sides were complete and the artifact fingerprints matched. It could not self-heal, because a download cannot be observed by a read that already happened, and it was invisible: the reason string is the same one correct behaviour emits during the first days after this lands, so the CI log of the broken state was identical to the log of the working one. The reads now sit in the branch that runs the script, after it. On the path where no coverage data was published the marker is not read at all, since nothing wrote one. With no shard profile arriving at all, the file list rendered as the empty string and the merge script's unbounded-glob guard cannot distinguish that from the variable being omitted, which is the case it exists to catch. It exited 1 before writing its status marker, so the job went red on exactly the input the protocol promises to report as a green skip. The job now recognises the empty set itself and builds the skipped sub-result directly. The script keeps its guard and is unchanged; no sentinel value is passed to it and no marker is fabricated for it. A PR side already known to be short a shard still ran the script, so the log printed a baseline percentage, a current percentage and a delta between two identical notices saying the comparison had been skipped. Every published comparative surface was already withheld, so nothing incorrect was exported, but a reader could take an abstention for a verdict, which is the confusion this gate exists to remove, and genhtml ran on a measurement already known incomparable. The four causes that depend only on this run's own sidecar now short-circuit before the script. They moved into completeness.current_side_reason, which comparable() also calls, so the short-circuit reason cannot drift from the verdict. Baseline-side causes are unchanged and still reach the later override: the script is what fetches the baseline, so they cannot be known any earlier, and a test pins that the script still runs for them. The harness for the diff gate could not observe any of this. Its stub created none of the files the real script creates, so the baseline side was unobservable under both orderings, and its synthetic sidecar omitted the schema version, so a verdict was unreachable even had a baseline existed. Both of its cells passed against the broken ordering. The stub now reproduces the real outputs using the production sidecar functions, the synthetic sidecar is a real one built over real profile files, and the healthy-path cell asserts the runtime verdict rather than a sub-result status that a later statement overrides anyway. While writing the test for the third defect I asserted that no delta line is printed and found the assertion could never fail, because the harness executed a region ending six statements before those prints. The region now covers them, a check keeps them inside it, and the healthy path demonstrates they are reachable, which is what makes the absence meaningful.
Fix round 3 of the LLVM coverage completeness protocol. The short-circuit added in the previous round correctly stops the differential script from running on a measurement already known incomparable, but two downstream blocks were never taught about the state that creates, so on exactly the paths this change exists to serve the job log contradicted itself. The differential script is the sole writer of changes.diff and current.changed.info. When the current side is known incomparable the script never runs, so both files are absent, so the uncovered-code block's own incomparable branch was unreachable and control fell through to the arm that reports "No C/C++ source files changed" - a statement about the PR's contents that was never established, on a run whose C++ files may well have changed. The diff-report line printed the same false sentence. Both now test comparability first, so the reason that was actually established is the one reported, while a genuinely comparable run that found nothing coverable still reports exactly as before. A baseline-side cause is only knowable after the script has run, so that path legitimately reaches the block that parses both lcov summaries. It printed baseline, current and delta before the abstention override was applied, putting three numbers between two identical skip notices - the reading confusion this gate exists to remove. The summary parsing and those three prints are now gated on comparability; a comparable run still prints all three, and the override stays where it is, since it is the only thing that turns the sub-result into SKIPPED on that path. The coverage marker predicate in tests/clickhouse-test had no live test: the existing cell asserted that both operand substrings appear near the marker, which still passes when the conjunction is swapped for a disjunction - and that swap admits both states the marker exists to exclude, a killed worker and a zero-test run, each of which then lets a short profile be merged. The cell now executes the real predicate over both signs of both inputs. The predicate itself is unchanged. Nine mutations, each reddening exactly its predicted cells; the operator-swap mutations are verified per row. The gate module's verdict-block extraction moved from a line range to AST nodes, because the drop assignment and the verdict chain now sit at different nesting depths; that also makes it carry all three arms, so its pass path is executed rather than merely not-failed.
Three residues of the same defect: _diff_ran was being used as a proxy for "this run produced a verdict", but it is False for three materially different reasons and only one of them - nothing coverable changed on a comparable run - licenses an OK or the "no C/C++ source files changed" sentence. The abstention override was nested inside `if _diff_ran:`. When the differential script ran, selected an incomplete baseline and then took its own no-coverable-files exit, no report directory was created, so the override never executed and the diff sub-result kept the OK it was constructed with: a green verdict for a run that did not judge. It is now an independent statement placed after the whole construct, guarded on comparability alone, where the degraded/not-degraded arm cannot clobber it either. The coverage-comment and CI-DB-row branch selected its message on _diff_ran, so a current-side cause - where the script is deliberately never invoked - printed a claim about the PR's contents immediately after the real incompleteness reason. It now tests comparability first, as the two sibling sites already do. The full-report link was appended unconditionally. The merge phase can now legitimately produce no report (it exits 0 without generating HTML when merged.profdata is absent, where the merge base exited 1 and reddened the job), so the intended green SKIPPED result advertised a URL that 404s, on master runs too. The link is now gated on the same entry point collect_html_report_files requires, so the link and the artifact cannot disagree. Tests: nine new cases, each mutation-verified. The harness slice is extended through the comment branch, without which four of them would assert on statements that never execute; a self-assert pins that reach, and shortening the slice makes all four fail loudly rather than pass vacuously. The sibling gate test selected the verdict node by requiring one `if` that was both `not _measurement_comparable` and contained `set_failed()` - a conjunction that only held while the abstention and the verdict were arms of one chain, i.e. it encoded the pre-fix structure as an invariant. Each statement is now selected on one property and the comparability guard is taken from the job's own node, so the emitted snippet cannot describe a nesting the job no longer has.
…omparable The abstention that reports "we could not compare the two coverage measurements" was hoisted out of the `if _diff_ran:` chain in the previous round so that a baseline-side cause could still reach it. Hoisting it exposed a second problem the nested form had masked: unlike the two sibling abstentions, which construct a fresh Result via `Result.create_from`, this one MUTATES the Result that `Result.from_commands_run` produced for generate_diff_coverage_report.sh. That Result is already FAIL when the script exited non-zero, and SKIPPED is inside `Result.is_ok()`, so an unguarded `set_status` turned a real tooling failure green. The two states genuinely co-occur on an ordinary post-merge run. The script writes base_llvm_coverage.meta.json and selected_base_commit.txt before several of its own later failure paths - `exit 1` on an empty GitHub compare, and under `set -euo pipefail` any failure of the two `gh api` calls, of either `lcov --extract`, or of `genhtml`. In each of those the report directory is absent, and the baseline side is incomparable for every baseline published before this change because those commits carry no sidecar. A failed report must stay RED: merge_llvm_coverage.sh states that contract verbatim. Guarding on `is_ok()` rather than `not is_failure()` also excludes ERROR, which is the conservative direction; only a result that is not already a failure may be downgraded, so a run that merely could not be compared still reports SKIPPED and keeps the job green. The new pytest case drives the mixed state through the real job source and asserts the composite is not ok. Its harness parameter forces the script's status to failure while still writing the baseline outputs the script writes before failing, because writing them first is what makes the state real. The sibling gate module's AST selector now matches a test that contains the comparability negation rather than equals it, and its Result stub delegates to the real `is_ok`, so neither can drift from production.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model, run once per revision of this branch:
Severity: blocker, major, nit. DISAGREE verdicts carry recorded evidence and are terminal Session id: cron:clickhouse-review-slot-51:20260731-221200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-51:20260731-221200 |
|
cc @alexbakharew @maxknv, could you review this? The coverage gate compared a baseline total against a PR total without checking that either side had all 21 shard profiles, so a short PR side failed unrelated PRs and a short baseline hid real regressions behind a pass; each side now publishes and validates its own completeness before any verdict, and reports SKIPPED with a reason when it cannot. |
|
Workflow [PR], commit [df79405] AI ReviewSummaryThis PR hardens the Findings
Final Verdict
|
| fi | ||
| echo "Found coverage file at ${COVERAGE_URL}" | ||
| wget --quiet "${COVERAGE_URL}" -O base_llvm_coverage.info | ||
| FIRST_BASE_COMMIT="${TEST_COMMIT}" |
There was a problem hiding this comment.
Before breaking on this candidate, the selector still needs to reject the cases that comparable() later treats as unusable: a newer schema_version and a torn info_digest/.info pair. Right now the pass-1 predicate only checks complete + manifest_fp, so the nearest ancestor can win selection here and then force the whole job to SKIPPED instead of falling through to the next older usable baseline. Please keep walking unless the candidate also passes the same schema/digest checks after download.
There was a problem hiding this comment.
Both findings reproduced against the code and are fixed in 33b26ce.
Selection predicate weaker than the usability predicate. Correct, and the
consequence is the one this PR exists to prevent: a candidate that passes the
weaker test and fails comparable won selection and then abstained the whole job
instead of falling through to the next usable ancestor. Rather than duplicating the
schema_version and info_digest checks in the selector, pass 1 now calls
comparable itself, so the two cannot drift apart again. The digest check needs the
candidate's .info bytes, so the download moves above the decision and a rejected
candidate's files are removed before the walk continues. Pass 2 is untouched and
still selects exactly as before.
Verified the fallthrough actually reaches the next older candidate: with a newer
schema_version on the nearer ancestor the selector picks the farther one, same for
a torn info_digest/.info pair, and when pass 1 rejects every candidate pass 2
still selects the nearest. In all three outcomes a non-empty
base_llvm_coverage.info and the marker are on disk for the job to read.
Metadata attributes the delta to the wrong baseline. Correct, and it was the
more corrosive of the two because the row is stored with nothing revealing the
substitution. coverage_comment.json now serializes _selected_base_commit,
falling back to base_commit_sha when no marker exists so the row never loses its
baseline key. That is the only consumer keyed on it: the hook reads this field
straight through into coverage_ci.coverage_data, and the master-side payload
writes "" by construction. Existing stored rows are not backfilled -- the
substitution was not recorded at the time, so which revision each old row actually
measured is not recoverable.
Six test rows, each verified to fail without its fix (restoring the previous
selector reddens the two walk-past rows; restoring the old payload line reddens both
metadata rows). The selector harness now imports the real completeness module
through WORKSPACE_PATH, so the predicate under test is the production function
rather than a copy -- breaking that import reddens the pass-1 rows, which is what
shows they are not vacuous.
ci/tests: 97 passed in the completeness suite, 605 passed overall. The 7 failures
in the full run reproduce identically at the pre-change commit and need a live
server on localhost:9000; they are unrelated to this change.
| f"{TEMP_DIR}/base_llvm_coverage.meta.json" | ||
| ) | ||
| _selected_base_file = Path(TEMP_DIR) / "selected_base_commit.txt" | ||
| _selected_base_commit = ( |
There was a problem hiding this comment.
We now capture the actually selected baseline here because it can differ from base_commit_sha, but the later coverage_comment.json payload still serializes base_commit_sha. Whenever generate_diff_coverage_report.sh skips the nearest ancestor and picks an older complete one, coverage_ci.coverage_data will attribute the delta to the wrong master revision. Please plumb _selected_base_commit through to the emitted metadata so the stored row matches the report that was actually generated.
There was a problem hiding this comment.
Fixed in 33b26ce. coverage_comment.json now serializes _selected_base_commit, falling back to base_commit_sha only when no marker exists. Details and the verification of both findings are in #112832 (comment).
…he one it used Two independent defects in the completeness protocol, both reported by the automated reviewer on the PR. The baseline selector's first pass tested only `complete` + `manifest_fp`, while `comparable` additionally rejects a newer `schema_version` and a torn `info_digest`/`.info` pair. A candidate that passes the weaker test and fails the stronger one therefore won selection and then forced the whole job to SKIPPED, instead of walking on to the next usable ancestor. A gate that disables itself on an avoidable input is the failure mode this protocol exists to prevent, so the selector now applies `comparable` itself rather than an approximation of it. That needs the candidate's `.info` bytes for the digest check, so the download moves above the decision; a rejected candidate's files are removed before the walk continues. Pass 2 is unchanged and still selects exactly as before, which is what keeps the change backward compatible while master has not yet republished. The emitted metadata attributed the delta to the wrong revision. The job captures the ancestor that was actually selected, but `coverage_comment.json` kept serializing `base_commit_sha`, the NEAREST master ancestor. Whenever the selector walks past it, every consumer of `coverage_ci.coverage_data` reads a delta against a revision that was never measured, with nothing in the payload revealing the substitution. It now stores the selected commit, falling back to the nearest one when no marker exists so the row never loses its baseline key. Six test rows, each verified to fail without its fix: two selector rows for the two causes `comparable` rejects after download, one reverse-direction row proving pass 1 still selects a usable candidate, and the payload rows. The selector harness now imports the real completeness module through `WORKSPACE_PATH`, so the predicate under test is the production function.
|
Closing as over-engineered for the problem it solves. The invariant it establishes (a coverage verdict only from two complete measurements) is right, and the analysis in this PR was what surfaced the failure routes - but the completeness sidecar, the manifest fingerprint, and the two-pass baseline selector can be replaced by a simpler rule: the Superseded by #115623, which implements that design (~460 added lines vs ~3200 here), keeps the per-artifact profile naming and |
…ofiles kill-safe
The `LLVM Coverage` gate compares two totals merged from 21 per-shard
`.profdata` artifacts that are `optional=True`, and nothing checked that
either side had all of them. A missing shard on the PR side fails an innocent
PR ("Coverage degraded" by 0.5 pp on a 102-line PR); a missing shard on a
master run writes a low baseline into the CI DB, so later real regressions
pass invisibly. Observed twice in 60 days, both times the same shard:
`Integration tests (amd_llvm_coverage, 4/8)` merged only 20 of 21 profiles
while every check was green.
Examples:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110186&sha=0b33f54bc8089ea3560397c589e93dc6aec92d47&name_0=PR&name_1=LLVM%20Coverage
(ClickHouse#110186)
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105844&sha=66107bb44ab45a490e839225eb096e46204e5e86&name_0=PR&name_1=LLVM%20Coverage
(ClickHouse#105844)
The invariant: a verdict comes only from two complete measurements.
- Every coverage producer (FT, IT, unit) names its profile after its own
artifact (`<artifact>.profdata`), so the filename carries the shard
identity. Producer merges use `--failure-mode=any` and skip zero-length
`.profraw` inputs: a shard with invalid data is absent, never silently
short. Artifacts stay `optional=True`, so a missing profile never reddens
a green test job.
- The `LLVM Coverage` job checks the expected set against what arrived and
merges an explicit file list (no `*.profdata` glob). On a missing or
invalid shard it reports `SKIPPED` with the shard name and withholds every
comparative output: no verdict, no GitHub comment, no `llvm_coverage.info`,
no CI DB row. Baseline completeness then needs no metadata: the diff script
already selects the first master ancestor that has an `.info`, and after
this change such an `.info` exists only for complete runs.
- Under coverage the IT sequential phase runs regardless of how many parallel
tests failed (`MAX_FAILS_BEFORE_DROP`), so a green shard cannot silently
publish a profile short by the whole sequential phase.
- Root cause of the recurring shard 4/8 loss: a `SIGKILL` during the
exit-time profile write leaves a half-written `.profraw` whose header makes
`llvm-profdata` abort with "LLVM ERROR: out of memory"
(llvm/llvm-project#50970). Coverage builds now
compile with `-mllvm -runtime-counter-relocation` and run with `%c`
(continuous mode): counters are memory-mapped into the file, which is valid
at every instant, so kills lose nothing and corrupt nothing.
Related: ClickHouse#112832
Co-Authored-By: Claude Fable 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
The
LLVM Coveragegate fails a PR when line coverage drops more than 0.3 pp below the baseline.Both percentages are merged from per-shard
.profdataartifacts that are deliberatelyoptional=True, and nothing checked that either side had all of them. Five routes drop a shardwhile every check-run stays green, from a producer merge that crashes to an aggregate merge that
discards a corrupt input under
-failure-mode=warn.Both directions are wrong. A short PR side fails an unrelated PR for a regression it did not cause
(example).
A short baseline has a low total, so a real regression passes; that case produces a PASS, emits no
failure row, and is invisible in any failure count.
Rather than raise the tolerance, which would paper over the measurement, the invariant is that a
verdict comes only from two complete measurements of the same artifact manifest. Each merge becomes all-or-nothing via
--failure-mode=any; each producer publishes no profile unless it ran what it planned; each shardnames its profile after its own coverage artifact, so completeness is exact set equality. That
fact travels beside the measurement in a sidecar riding on the existing
llvm_coverage.infoartifact, so no new artifact name and no workflow file change is needed.Otherwise the job reports
SKIPPEDwith the reason, which counts as OK, and withholds everycomparative output, including the CI DB row that later baselines read. No master commit has a
sidecar yet, so a missing one means "unknown" and the fallback selector pass reproduces today's
behaviour until master republishes.
One residual is not covered: two runs can both be complete over the same 21 artifacts yet exercise
different code, for example when a commit changes which integration suites are selected. The
fingerprint detects artifact-list drift only, and is not a claim that the measured code matched.
Why
tests/clickhouse-testgains a marker, and validationAll tests have finished.cannot carry the "this run executed what it planned" fact, because aworker that dies abnormally still reaches it: the counter tested there is the number of tests
selected. Suppressing that marker would be the tidier layer, but such a run already exits non-zero
and is already reported as a failure, so suppression would only reclassify it from
FAILtoERRORacross every functional-test job. The new line is additive and leaves
success_finishand its threeconsumers untouched. If you would rather have the suppression, that is a deliberate CI semantics
change and I would send it separately.
92 new pytest cases plus one on the existing gate test, all pure and deterministic. Each of 51
mutations, one per behaviour introduced here, reddens its intended case.
ci/tests/run per armagainst a baseline exported from this branch's merge base: 607 collected here against 514 there,
0 new failures and 0 tests deleted by set difference, and the same pre-existing host-flaky rows in
both arms. Workflow config generation succeeds, which confirms no new artifact name was introduced.
The
llvm-profdatabehaviour relied on here was measured:-failure-mode=anyon a corrupt input exits1 and writes no file, while the clean path is byte-identical to
-failure-mode=warn; a zero-lengthinput is accepted silently at both modes, which is why it is filtered explicitly.
The other three routes are an unbounded
*.profdataglob, a run that stopped early yet stillpublishes a valid but under-covered profile, and that zero-length
.profraw. When a measurement isincomplete the full report is still published, labelled
partial measurement: N of M shards, as thebest artifact for identifying the missing shard.