Skip to content

Generate the fuzzer dictionary from a release binary instead of committing it - #115307

Merged
alexey-milovidov merged 34 commits into
ClickHouse:masterfrom
groeneai:groeneai/reland-fuzzer-dict-from-binary
Sep 19, 2026
Merged

alexey-milovidov merged 34 commits into
ClickHouse:masterfrom
groeneai:groeneai/reland-fuzzer-dict-from-binary

Conversation

@groeneai

@groeneai groeneai commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

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):

...

Description

Do not merge this until NightlyFuzzers is green on this branch. Dispatching it needs
admin rights, so I am asking for a manual run first.

Re-land of #111025, reverted in #113649 after the nightly libFuzzer tests job went red for
a week. The mechanism is unchanged: the dictionary comes from the release binary's own
registries instead of a committed snapshot that drifts. Four defects are fixed; the first two
made the job red, the rest are collateral damage from dropping all.dict.

  1. The coverage check ran comm under en_US.UTF-8 on LC_ALL=C-sorted input, so it
    exited 1 and set -e killed the script.
  2. The release binary was staged executable beside the fuzzer targets, so runner.py
    ran it as one.
  3. The all.dict fallback came only from a POST_BUILD step of the fuzzers target,
    which OSS-Fuzz never reaches, so cp tests/fuzz/*.dict aborted under bash -eu.
  4. NightlyFuzzers claimed a cache hit on MasterCI's release build but declared its artifacts
    untagged and injected a different docker graph, so the digests differed and it rebuilt the
    binary nightly. The shared build is the AMD one since CI: move libFuzzer test to amd64 #105118 moved the job.

Against a real binary, update_dict.sh aborts under a UTF-8 locale before the fix and succeeds
after. ci/tests covers the four fixes and the dependency and digest invariants, each with a
mutation arm (PYTHONPATH=./ci:. pytest ci/tests/test_fuzzer_dict_*.py ci/tests/test_nightly_fuzzers_build_sharing.py, 93 tests, 92 pass here; test_unpinned_comm_aborts needs a host whose default collation makes comm reject LC_ALL=C-sorted input, which this worker's en_US.utf8 does not). Since 8ff3720644b2 removed the
CI Tests job with ci/tests, nothing in CI runs them, so they are a local harness rather
than a standing guard.

Residuals. runner.py still infers "fuzzer target" from the execute bit, and the fallback is
generated at configure time, so a scanned-carrier edit needs a reconfigure to refresh it while
pinning all 1819 carriers would cost one per edit. _publish_latest_docker_manifest matches
branches literally though the field admits patterns, so a workflow tagging latest from a
patterned set would not publish, and the regex and glob readings of the live patterns disagree
both ways, so the field's meaning is a praktika-wide call. A local -DFUZZER=1 configure against
a genuinely read-only checkout fails at the generation step; it is not moved under
${CMAKE_BINARY_DIR} because OSS-Fuzz copies $SRC/ClickHouse/tests/fuzz/*.dict under
bash -eu and there is no flag that distinguishes its configure from our own Build (amd_fuzzers)
one, so the build-tree form would abort the official build instead of degrading. The earlier dispatch showed defects
1 and 2 only; I cannot rule out more without a run.

cc @yakov-olkhovskiy @maxknv @leshikus


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

…tting it

Re-land of ClickHouse#111025, which was reverted wholesale in ClickHouse#113649 because the nightly
libFuzzer job went red on defects introduced alongside it. The mechanism itself
was never in question: a committed all.dict silently drifts from the real
grammar, so the dictionary is now derived from the release binary's own
registries at job time, with a source-derived fallback for build-time consumers
and a curated old.dict for names that are composed at compile time.

This commit restores the reverted tree verbatim. Two files drifted while the
revert was in place, and the resolution keeps both sides of each:

  - ci/praktika/job.py. Master added run_on_upstream_failure and
    checkout_persist_credentials (with the __post_init__ assert tying the latter
    to enable_gh_auth); ClickHouse#111025 added set_digest_config, which this change uses.
    All three are kept.
  - ci/defs/job_configs.py. Master added unrelated job definitions, so the
    fuzzers-digest block is added to master's list rather than replacing it.

The two defects that made the job red are fixed in the following commits.

Related: ClickHouse#111025
Related: ClickHouse#113649
The check sorts both dictionaries with LC_ALL=C but ran comm under the job
container's LC_ALL=en_US.UTF-8. comm merges its inputs assuming they are sorted
the way it itself would sort them, and quoted multi-word keywords order
differently under the two collations ('"ADD INDEX"' sorts before '"ADD"' in C
and after it in en_US), so comm diagnosed its own C-sorted inputs as disordered
and exited 1. That sat inside a command substitution under set -e, so the script
died before the coverage verdict was ever evaluated: the nightly libFuzzer job
aborted with a bare CalledProcessError and produced zero test rows.

Two changes, both needed:

comm now runs with LC_ALL=C, matching the collation its inputs were sorted with,
and is wrapped in `if !` so a genuine comparison failure reports itself instead
of killing the script. A non-zero comm no longer means "no diff".

The two sorts now write files as plain commands rather than running inside
process substitutions. set -e does not observe a process substitution's exit
status, so an unreadable all.dict used to yield an empty diff and the check
reported success with the gate disarmed, while an unreadable source.dict
reported every token as missing.

The regression test extracts the check verbatim between the BEGIN/END markers
and runs it against synthetic dictionaries under a UTF-8 collating locale. It
covers the three outcomes the check must keep apart (covered, gap, comparison
broken), reproduces the original abort from the pre-change command, and pins
both process-substitution failure modes. The locale is chosen by measuring that
it actually inverts the token pair, so C.utf8 (a UTF-8 locale that collates by
byte value) cannot make the arms vacuous.
The libFuzzer job stages the release binary next to the fuzzer targets and
chmods it +x so update_dict.sh can generate all.dict from it. That directory is
then mounted at /fuzzers and becomes the runner's working directory, and
tests/fuzz/runner.py enumerates fuzzers as every executable file in it. The
binary matched, so the runner invoked

    ./clickhouse -artifact_prefix=<dir> corpus/clickhouse

which the server rejects with UNRECOGNIZED_ARGUMENTS. The nightly job reported a
`clickhouse` failure next to 20 passing *_fuzzer targets.

The binary is only executable because of that chmod: artifacts are downloaded
with `aws s3 cp`, a content copy that carries no POSIX mode, so a 755 source
lands as 644 under the job's umask, which is also why the *_fuzzer files are
chmod-ed explicitly. Nothing needs the binary executable after generation, so
restoring the mode it arrived with removes the trigger at its source rather than
teaching the runner to skip it, and leaves the directory in its pre-generation
state. The restore runs in a finally block, so a failed generation cannot leak
the bit into a later step either.

The regression test pins the whole 0644 -> 0755 -> 0644 cycle, since the binary
does have to be executable while the generator runs, and covers the failure
path. It imports generate_dictionary rather than reimplementing it, so it cannot
drift from the code.

tests/fuzz/runner.py is deliberately unchanged: it still treats the execute bit
as meaning "fuzzer target", which is a contract the producer is now respecting.
…ilding

The .options files shipped to fuzzer consumers reference all.dict, which is no
longer committed. Its fallback was generated by tests/fuzz/build.sh, wired only
as a POST_BUILD step of the `fuzzers` aggregate target.

OSS-Fuzz (google/oss-fuzz projects/clickhouse/build.sh) never reaches that
target: it configures with -DENABLE_FUZZING=1, builds each fuzzer individually
with `ninja -j N $FUZZER_TARGET`, and then copies the dictionary out of the
source tree with `cp $SRC/ClickHouse/tests/fuzz/*.dict $OUT/`. That script runs
under `#!/bin/bash -eu`, so the unmatched glob aborted the official OSS-Fuzz
build rather than merely degrading a dictionary. Verified in the ninja graph:
tests/fuzz/build.sh appears only on CMakeFiles/fuzzers.util, and
`ninja -t deps select_parser_fuzzer` contains no reference to it.

Generate the source-derived dictionary during the fuzzing configure step
instead, into the source tree, where both a single-target build and the
OSS-Fuzz copy find it. build.sh now copies whichever dictionary is current
rather than generating a second one, so the nightly libFuzzer job's
binary-derived all.dict (tests/fuzz/update_dict.sh) still wins. The generated
file is ignored, so a fuzzing configure leaves the working tree clean.

Related: ClickHouse#111025
Related: ClickHouse#113649
NightlyFuzzers needs the release binary to generate the fuzzer dictionary and
claimed to get it as a cache hit against the same commit built in MasterCI. The
claim was false, and the workflow paid a full ARM release build every night.

MasterCI takes JobConfigs.release_build_jobs_with_examples, which appends
--build-examples and CLICKHOUSE_EXAMPLES to the ARM release job; NightlyFuzzers
took the plain release_build_jobs. Both `command` and the `provides` artifact
configs are part of the job digest (ci/praktika/digest.py drops only requires,
enable_commit_status, allow_failure, force_success and digest_config), so the
two variants hashed differently. Measured: config digests 8383 for nightly
against ab29 for master.

Independently, CH_ARM_RELEASE is in BINARIES_WITH_LONG_RETENTION and MasterCI
tags it {"retention": "long"}, while NightlyFuzzers listed the binaries
untagged. The upload path is keyed by branch and commit, so a nightly upload
could replace MasterCI's long-retention object with a default-retention one --
and since the tags live in the artifact configs the digest hashes, the missing
tags also blocked the cache hit on their own.

Take the same job variant and apply the same tags, which makes the digests
equal (ab29 both sides) and the comment true. The tagging loop was already
duplicated between MasterCI and ReleaseBranchCI, so factor it into
with_long_retention_tags() next to the list it reads instead of adding a third
copy.

Related: ClickHouse#111025
Related: ClickHouse#113649
Two mechanisms this branch introduces enumerate their carriers incompletely.

The CI Tests job digest gates whether ci/tests/ runs at all, so an input
outside include_paths leaves its guard unable to run on the commit that
breaks it. The OSS-Fuzz contract suite reads the root CMakeLists.txt,
tests/fuzz/build.sh, tests/fuzz/generate_source_dict.sh, .gitignore,
dictionaries/old.dict and the .options files; only update_dict.sh was
listed. Measured with the job's own traverse_paths: deleting the
generate_source_dict.sh block from the if (FUZZER) block, and making
build.sh regenerate its own dictionary, both left the digest at
1f75cc3b895e -- so both would have taken a cache hit from an older green
run. After the widening the same two mutations move it to 617e8249873f
and cdaeacf833c3, while touching an unrelated src/ comment does not, and
no commit in the last 300 master merges newly invalidates the job.

with_long_retention_tags documents that every workflow uploading these
binaries must apply the same tags, then tagged three of five. NightlyJepsen
and NightlySQLancer are also branches=['master'], so they resolve to the
same REFs/master/<sha>/<job> key and replaced MasterCI's long-retention
object with a default-retention one; the tags also feed the job digest, so
the two could not share MasterCI's build cache either (a7227e97 vs
1e39a9e7, 920dd7d8 vs 1d561c46). Both match after the change. Workflows
under the PR and merge-queue key spaces cannot collide and are left alone.

Each half gets a completeness arm, so a sixth carrier or a seventh suite
input is caught rather than silently uncovered.
…ately

Three statements the code did not hold.

The codegen_fuzzer dependency glob claimed to be in sync with the trees
generate_source_dict.sh scans, but matched only *.h and *.cpp while the
generator greps those trees with no suffix filter. 28 of the 1804 files in
the five trees were excluded, one of them real C++ (src/Functions/stl.hpp).
Appending a registerAlias call to an excluded file moves the generator's
output (md5 0f418b14 -> 50a7c55f) without invalidating codegen.dict, so a
token could be added or removed and the dictionary would not rebuild.
Globbing the trees whole makes the dependency set equal the scan set. The
aggregate all.dict stays a configure-time product: OSS-Fuzz builds
individual *_fuzzer targets and never reaches an aggregate build step.

TestSuiteInputsAreInTheJobDigest enumerates the suite's direct reads, which
reads as total coverage of the dictionary path. The generator's scanned trees
are deliberately outside the CI Tests digest; the FATAL_ERROR in the root
CMakeLists' if (FUZZER) block is what catches a failing generator, re-run by
Build (arm_fuzzers) because its digest covers ./src.

with_long_retention_tags said every workflow uploading these artifacts has to
apply the same tags, which the PR's own test_every_colliding_workflow_tags_them
excludes PULL_REQUEST and MERGE_QUEUE from: their uploads land in a different
keyspace. Scoped to the workflows that can collide on the same object key.

No compiled code changes. ci/tests: 750 passed, the 2 pre-existing
test_max_failures_exit_code parallel-limit failures unchanged.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

An independent review pass over this branch across several rounds: a cold read of the
resulting code, then a second-model review of the full diff, then adjudication of every
finding against measured evidence. Findings I agreed with were fixed before this was
published; findings I rejected are listed with the measurement that refutes them.

Fixed before publication

❌ The re-land broke the official OSS-Fuzz build. tests/fuzz/build.sh was wired only
as a POST_BUILD command of the aggregate fuzzers target, but OSS-Fuzz builds individual
*_fuzzer targets, so the source-derived fallback was never generated and its own
cp $SRC/ClickHouse/tests/fuzz/*.dict $OUT/ aborted under bash -eu on an unmatched glob.
Reproduced by running that exact command against the tree (rc=1; the glob is non-empty
before the change and empty after). Now generated at fuzzing-configure time, with
FATAL_ERROR on failure.

⚠️ A false cache-hit claim and a retention downgrade in the nightly workflow. The
comment claimed the ARM release build cache-hits MasterCI's, but MasterCI uses the
--build-examples variant and praktika hashes both command and provides, so the digests
differed. Separately CH_ARM_RELEASE is in BINARIES_WITH_LONG_RETENTION and the nightly
upload carried no retention tag, so it could replace MasterCI's long-retention object. Both
digests now match (recomputed with Digest().calc_job_digest), and two sibling nightly
workflows that had the same gap were fixed with it.

⚠️ CI Tests cache-hit past its own inputs. The new contract suite reads
CMakeLists.txt, build.sh, generate_source_dict.sh, .gitignore, old.dict and the
.options files, none of which were in that job's digest, so a commit breaking the OSS-Fuzz
wiring would have taken a cache hit and never run the suite protecting it. Two mutations
left the digest unmoved before the fix; a positive control moves it after.

⚠️ A stated dependency invariant that the code did not hold. The codegen dependency glob
claimed to be in sync with the trees the generator scans, but matched only *.h/*.cpp
while the generator greps those trees with no suffix filter, so 28 of 1804 files were
excluded. Appending a registerAlias call to an excluded file moved the generator's output
(md5 0f418b14 -> 50a7c55f) without invalidating the dictionary; a negative control
containing an incidental registerFunction string left it unchanged. The trees are now
globbed whole, and I re-evaluated the real glob with cmake -P: 1804 files, equal to the
scan set, a strict superset of the old glob, 0 paths outside the five trees.

⚠️ Two docstrings that overstated their invariant. The retention helper said every
workflow uploading these binaries must tag them, which this PR's own new test excludes
pull-request and merge-queue workflows from; and the digest-coverage arm read as total
coverage when it enumerates direct reads only. Both reworded, and the commit message
attribution of the merge-drift resolution was corrected in an earlier round.

Raised and rejected, with evidence

⚠️ "The replacement dictionaries silently drop four compound SQL tokens
(DATA INNER UUID, METRICS INNER UUID, TAGS INNER UUID, SET TIME ZONE)."
Every fact
here reproduces, and the true loss set versus the deleted file is nine tokens, not four. But
the comparison is against the committed snapshot this PR removes because it drifts: that
snapshot was last regenerated in March 2026, and all four cited keywords were deleted from
src/Parsers/CommonParsers.h on 2026-04-11 in
6ddf0b92f42f9d7
(DATA_INNER_UUID and siblings collapsed into a single INNER_UUID), which predates this
branch's base. getAllKeyWords() is built solely from the MR_MACROS lists and
system.keywords reads exactly that, so no binary built since April can emit them; checked
live, all nine are absent from system.keywords, system.functions,
system.data_type_families and system.table_functions. The decisive control is the base
mechanism rather than the base file: running the old script's own queries against the
same binary yields 6283 tokens versus this branch's 6374, so 0 tokens lost and 91
gained
; against the stale snapshot it is +1380/-9. The prescribed remedy would re-create
the drift by hand, pinning four keywords the parser has not accepted as single tokens since
April, and would break old.dict's role (compile-time-composed names; 53 of its 54
multi-word entries are still live keywords). The syntax itself remains covered:
SET TIME ZONE 'UTC' still works and parses as SET + TIME ZONE, and both components,
plus INNER UUID, DATA, METRICS and TAGS, are present in the new dictionary.

⚠️ "Model all.dict as a build output with the generator inputs as dependencies."
Rejected because it reintroduces the OSS-Fuzz blocker above: all.dict is generated at
configure time precisely because OSS-Fuzz builds individual *_fuzzer targets and never
reaches an aggregate build step. The CI-facing reach is also refuted, since every nightly
job's prepare step removes the build directory, so no fuzzers build dir survives a run. The
residual was a purely local incremental rebuild, which is the glob half fixed above.

⚠️ "The libFuzzer job's cache key omits the manually run Docker image." Accurate as a
mechanism but not widened here: before this change the job already invoked docker run
directly, already had no run_in_docker, and already had exactly one include path. This
change only adds include paths. Closing it needs a praktika change of its own.

⚠️ "No test proves the binary-derived dictionary replaces the staged fallback." Refuted
end to end against a real binary: the fixed update_dict.sh writes all.dict at rc=0 under
LC_ALL=en_US.UTF-8, where the pre-change form exits 1 with
comm: input is not in sorted order.

⚠️ "Provide a green manual NightlyFuzzers run." Correct that the evidence is missing,
but not obtainable by me: dispatching the workflow returns 403 (needs repository admin) and
a fork run is not a substitute since every job is self-hosted. This is why the description
asks for a manual run and states the change must not be merged until it is green.

💡 Three notes recorded and deliberately not raised as defects: tests/fuzz/runner.py still
infers "fuzzer target" from the execute bit (the fix here is producer-side, so nothing
reaches that inference any more); the widened ./tests/fuzz/ digest entry walks the working
tree and so would include a locally generated all.dict, which cannot affect CI because the
digest is computed in a fresh checkout; and the reworded retention scope is less precise
than the test it documents, since merge-queue runs also take the REFs/ path and are
excluded by their branch value rather than by the keyspace shape. No follow-ups proposed.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)

Four defects. A = coverage check aborts under a UTF-8 locale.
B = release binary left executable in the runner's workdir. C = all.dict generated only
by a POST_BUILD step OSS-Fuzz never reaches. D = NightlyFuzzers took a different build
variant with untagged artifacts.

# Question Answer
a Deterministic repro? Yes, all four, no CI run needed. A: LC_ALL=en_US.UTF-8 CLICKHOUSE_BIN=<bin> OUTPUT_DIR=<dir> bash tests/fuzz/update_dict.sh aborts comm: input is not in sorted order, rc=1. B: <bin> -artifact_prefix=/tmp/x/ /tmp/nonexistent gives Code: 552. UNRECOGNIZED_ARGUMENTS, rc=40, which is what the runner invoked. C: bash -eu -c 'cp <dir>/*.dict $OUT/' on a directory with no dictionary, rc!=0. D: recomputing the job digest the way hook_cache.py does gives different values for NightlyFuzzers and MasterCI on the same Build (arm_release).
b Root cause explained? Yes, four independent causes. A: both dictionaries are sorted with LC_ALL=C, but comm ran under the container's en_US.UTF-8; the collations disagree on quoted multi-word keywords, so comm diagnosed its own input as disordered and exited 1 inside a command substitution under set -e, killing the script before the coverage verdict. B: generate_dictionary chmods the release binary +x and never restores it; that directory is the runner's workdir, and the runner enumerates targets as every executable file in it. C: OSS-Fuzz builds fuzzer targets individually, so a POST_BUILD step of the fuzzers aggregate target never fires, and its cp tests/fuzz/*.dict then aborts on an unmatched glob under -eu. D: the digest covers command and the provides artifact configs, so a different job variant and untagged artifacts both break the cache hit, and the untagged upload also replaces MasterCI's long-retention object at the same branch-and-commit key.
c Fix matches root cause? Yes, each at its source. A pins comm to the collation its inputs were sorted with and captures its status. B restores the mode in the producer that set it. C moves generation to configure time via execute_process, writing into the source tree where both a per-target build and the OSS-Fuzz glob find it, and makes a failure FATAL_ERROR rather than surfacing far away. D takes the same job variant and applies the shared with_long_retention_tags helper. No symptom guard, no widened bound, no disabled check.
d Test intent preserved / new tests added? Both. 35 new arms across 4 files: 6 in test_fuzzer_dict_coverage_check_locale.py (extracts the check verbatim between markers; covered/gap/comparison-broken plus both process-substitution failure modes), 5 in test_fuzzer_dict_binary_mode.py (the 0644 to 0755 to 0644 cycle, the failure path, fuzzer targets stay executable), 15 in test_fuzzer_dict_ossfuzz_contract.py (configure-time generation, source-tree output, fatal on failure, build.sh consumes rather than regenerates, the generator run for real, the OSS-Fuzz cp end to end, and the job-digest coverage of the suite's own inputs), 9 in test_nightly_fuzzers_build_sharing.py (digest equality with MasterCI, the variant and artifact declarations, retention tags across all five uploading workflows, and a completeness arm over ci/workflows/). No test removed or weakened; the coverage check itself gets stricter, since it can no longer pass with an unreadable input.
e Both directions demonstrated? Yes, every arm has a mutation twin. A, end to end on a real binary: pre-change form rc=1 with comm: input is not in sorted order, fixed form rc=0 with a 6374-token all.dict. B: with the finally restore stripped, test_binary_mode_is_restored and the failure-path arm fail (0755 vs 0644); unmutated all 5 pass. C: the same OSS-Fuzz cp succeeds with the dictionary present and aborts without it. D: reverting each of the five workflows to untagged makes the parametrized arm and the completeness arm fail, naming the workflow. The digest-coverage arm: narrowing include_paths back makes it fail naming the 23 of its 25 inputs that then go uncovered; deleting the execute_process block or making build.sh regenerate moves the digest under the new config and does not move it under the old one, while an unrelated src/ edit moves neither.
f Fix is general across code paths? Yes, carrier sets enumerated rather than assumed. B: the only other chmod in the job touches *_fuzzer files exclusively and the ARM_FUZZERS glob is suffix-scoped, so the release binary was the sole non-fuzzer candidate; finally covers the exception path. A: both halves of the abort are fixed, the collation mismatch and the process substitutions that hid a failing sort. C: build.sh was checked for a second generation path and no longer has one. D: all 13 workflows declaring clickhouse_binaries were enumerated; the 5 that upload a long-retention binary under REFs/<branch> are now tagged, the 3 under PRs/<n> cannot collide, and 5 declare without providing. A completeness arm over ci/workflows/ closes the set so a sixth carrier cannot ship untagged.
g Fix generalizes across inputs? N/A for type wrappers (CI shell, Python and CMake; no ClickHouse data types). The input dimensions that exist are covered: A, three verdict outcomes plus unreadable inputs on either side, with the test measuring that its chosen locale actually inverts the token pair so a byte-collating UTF-8 locale (C.utf8) cannot make the arms vacuous; B, both paths and any starting mode, since the original is captured rather than assumed; C, dictionary present and absent, and the generator's real output checked for libFuzzer's one-quoted-token-per-line format; D, all 11 names in BINARIES_WITH_LONG_RETENTION across all 5 carriers, 24 (workflow, binary) pairs examined.
h Backward compatible? Yes. No setting, no serialization format, no user-visible behavior. The re-landed change deletes the committed dictionaries, and the compatibility story is intact: tests/fuzz/dictionaries/old.dict plus the source-derived fallback in generate_source_dict.sh, now generated at configure time, which is what the coverage check guards. The digest widening costs no extra CI: over the last 300 first-parent master merges, 0 touch a newly-added path without already touching an old one.
i Invariants and contracts preserved? Yes. The coverage check fails closed: a comparison failure is distinguished from a coverage gap and neither is silently swallowed. Only fuzzer targets are executable in the runner's workdir, including when generation throws, so runner.py's "executable means fuzzer target" contract is respected by the producer. tests/fuzz/*.dict is non-empty before any fuzzer target is built, so OSS-Fuzz's cp under -eu cannot abort. One artifact key holds one retention class, since every workflow uploading it agrees on the tags. with_long_retention_tags copies rather than mutating the shared module-level ArtifactConfigs, verified with five call sites.

Residual, disclosed and unchanged: runner.py still infers "fuzzer target" from the
execute bit rather than the filename.

Session id: cron:clickhouse-impl-slot-6:20260817-220002

@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e17fa86]

Summary: ✅


AI Review

Summary

This PR replaces the committed fuzzer dictionaries with generation from a release binary, adds a source-derived fallback for build-time/direct consumers, and rewires NightlyFuzzers to share the release build. The main direction makes sense, but three existing concerns still hold on the current head: the direct-consumer fallback still depends on a writable checkout, it can still drift after incremental source edits, and the new regression harness still has no executor in CI. Those points are already tracked in open inline threads, so I did not post duplicate inline comments.

Missing context / blind spots
  • ⚠️ I do not see a green human-dispatched NightlyFuzzers run on commit e17fa868c947. Since the PR's contract is specifically about the real self-hosted nightly fuzzing path, that end-to-end run is the evidence that would close the remaining validation gap.
Findings

⚠️ Majors

  • [CMakeLists.txt:796] [dismissed by author -- https://github.com/Generate the fuzzer dictionary from a release binary instead of committing it #115307#discussion_r4052171210] The source-derived fallback is still generated by writing tests/fuzz/all.dict into the checkout during configure. That makes local -DENABLE_FUZZING=1 / -DFUZZER=1 configures fail against a read-only checkout before any target is built, which is a real regression for hermetic/out-of-source fuzzing builds. Suggested fix: make the direct-consumer fallback a build artifact instead of a configure-time write into the source tree, and stage it into tests/fuzz/ only in the path that truly requires a source-tree *.dict.
  • [CMakeLists.txt:796] [dismissed by author -- https://github.com/Generate the fuzzer dictionary from a release binary instead of committing it #115307#discussion_r3852576261] The same fallback is still generated only at configure time, so after editing a scanned carrier and rebuilding a fuzzer target the direct-consumer path can keep packaging a stale dictionary until the user reruns CMake manually. The nightly job overwrites all.dict later, but the local/OSS-Fuzz-style consumer path this block exists for is still unguarded against source drift. Suggested fix: tie the fallback to explicit build or reconfigure dependencies for the scanned carriers, or regenerate it in the packaging path that consumes it.
  • [ci/tests/test_fuzzer_dict_ossfuzz_contract.py:1] [dismissed by author -- https://github.com/Generate the fuzzer dictionary from a release binary instead of committing it #115307#discussion_r3968074230] The new regression suites are still dead code in CI: nothing under .github/workflows, ci/defs, or ci/workflows executes these ci/tests modules on the current head. That leaves the cache/dictionary invariants unguarded after merge, so a future regression can pass required checks unless it happens to break some unrelated surface. Suggested fix: wire the suites into an executed workflow again, or move the assertions into a test surface that CI already runs.
Final Verdict

⚠️ Not ready to approve. No new inline comments were needed because the remaining concerns are already covered by existing open review threads.

LLVM Coverage Report

Measured on commit e17fa86.

Metric Baseline Current Δ
Lines 88.40% 88.40% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 80.60% 80.60% +0.00%

Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage).

Newly covered: +171 lines in 50 files (-104 lines lost coverage) · Details

Full report

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 18, 2026
@groeneai groeneai added the groeneai-origin-request PR origin: a maintainer pinged or directed groeneai label Aug 19, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 20, 2026
@alexey-milovidov alexey-milovidov self-assigned this Aug 20, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 20, 2026
Comment thread CMakeLists.txt
# before any target is built. The nightly libFuzzer job overwrites it with
# the authoritative binary-derived one (tests/fuzz/update_dict.sh).
execute_process(
COMMAND "${CMAKE_SOURCE_DIR}/tests/fuzz/generate_source_dict.sh" "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/tests/fuzz/all.dict"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This writes all.dict into ${CMAKE_SOURCE_DIR} during configure, so -DFUZZER=1 now requires a writable checkout. That regresses hermetic / read-only out-of-source fuzzing builds: configure fails before any target is built even though the file is only consumed later by packaging/copy steps. Can we keep the generated dictionary under ${CMAKE_BINARY_DIR} and only stage it into the source-tree location in the specific OSS-Fuzz path that still expects tests/fuzz/*.dict?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵 The mechanism is right - configure writes ${CMAKE_SOURCE_DIR}/tests/fuzz/all.dict, and on a read-only checkout -DFUZZER=1 fails there. I am not moving it, and the reason is what the one consumer that needs the source-tree location actually does. Measured against google/oss-fuzz projects/clickhouse/build.sh as it stands today:

  • It reads the dictionary only from the source tree: cp $SRC/ClickHouse/tests/fuzz/*.dict $OUT/, under #!/bin/bash -eu. A dictionary that lives only under ${CMAKE_BINARY_DIR} leaves that glob unmatched, so the official build aborts at the copy rather than shipping a worse dictionary. That is the failure direction this file's comment is about.
  • There is no in-tree signal that says "this is the OSS-Fuzz path" at configure time. It configures with -DENABLE_FUZZING=1, exactly what our own Build (amd_fuzzers) passes (ci/jobs/build_clickhouse.py). The only flag unique to it is -DLIB_FUZZING_ENGINE:STRING=$LIB_FUZZING_ENGINE, which nothing in ClickHouse's CMake reads - grep over CMakeLists.txt and cmake/ outside contrib returns nothing. Gating the staging on a variable the tree otherwise ignores means the official build silently loses its dictionary the day OSS-Fuzz stops passing it, and we do not run that build, so we would not see it.
  • The hermetic premise does not survive contact with that same consumer either. Before it configures anything it runs sed -i twice over $SRC/ClickHouse/CMakeLists.txt, then mkdir -p $SRC/ClickHouse/tests/fuzz/*_fuzzer.in/ and copies tests/queries/0_stateless/*.sql and tests/queries/1_stateful/*.sql into the source tree. A read-only checkout cannot run that path no matter where the dictionary is generated.

Making the dictionary a per-target build edge instead is the other direction, and it is the shape #111025 was reverted for: OSS-Fuzz builds targets individually with ninja -j N $FUZZER_TARGET, so a step hanging off the fuzzers aggregate target is never reached. TestConfigureTimeGeneration in ci/tests/test_fuzzer_dict_ossfuzz_contract.py pins that, with mutation arms.

What is left over is the case your finding names minus the OSS-Fuzz path: a local -DFUZZER=1 configure against a checkout that is genuinely read-only. That one is real and unaddressed, and I have added it to the Residuals paragraph of the description rather than leaving it implicit here.

Three of the added assertions could stay green while the wiring they
describe regressed. Each is replaced by the property it was standing in
for, and each mutation was confirmed to redden.

build.sh: asserting it does not mention generate_source_dict.sh still
allowed regenerating the dictionary via update_dict.sh or an inlined
query, which overwrites the binary-derived dictionary before the
artifact is consumed. Assert instead that the only line naming a
dictionary or a generator is the copy into $OUT, with a mutation arm per
regeneration route.

Build (arm_fuzzers): nothing covered the widened digest, so dropping
./tests/fuzz/ and ./tests/queries/0_stateless/ from that job left every
test green while a dictionary or corpus change could cache-hit a stale
ARM_FUZZERS artifact. Assert the include paths, that the shared build
digest does not already carry them (otherwise the assertion is
vacuous), that with_git_submodules survives the digest replacement, and
that only the fuzzers build is widened.

libFuzzer tests: the shared-build coverage was producer-side only.
Assert the consumer edge too - the job requires CH_ARM_RELEASE, the
workflow provides everything the job requires, and the dictionary
inputs are in the consumer digest.

Mutation arms verified: build.sh regenerating via update_dict.sh or an
inlined write, the arm_fuzzers widening removed, with_git_submodules
dropped, CH_ARM_RELEASE removed from requires, and update_dict.sh
removed from the consumer digest. All six redden; the intact tree
passes 50 of 50 in these modules.
The build-sharing assertion compared the imported workflow objects, but
praktika hashes the mangled ones. Mangle appends the injected docker job
names to every job's run_after, and run_after is part of the job digest,
so the comparison could not see a difference that decides the real cache
key.

It was hiding one. MasterCI sets enable_dockers_manifest_merge, so its
graph gains a multiplatform manifest job; NightlyFuzzers' did not.
Measured post-mangle config digests for Build (arm_release): 6efd for
MasterCI against b765 for NightlyFuzzers, with run_after the only
differing field. So the release build was still rebuilt from scratch
every night despite the job variant and artifact tags already agreeing.

Enable the same manifest merge on NightlyFuzzers, which makes the two
graphs and the digests identical, and compare post-mangle so the
assertion tracks the key praktika actually computes. A negative control
asserts run_after is populated and that the two graphs agree, since an
empty run_after would make the pre- and post-mangle comparisons
indistinguishable.

Verified by removing the alignment again: the post-mangle assertion
fails, while the previous pre-mangle comparison passes on that same tree
(ab29 both sides), which is what it was blind to.
Two more assertions could not see the shape they described.

The POST_BUILD guard filtered the if (FUZZER) block to lines containing
the generator name, then checked those lines for add_custom_command and
POST_BUILD. In a normal multi-line add_custom_command those tokens are on
a different line from the generator, so they were never in the strings
being checked. Measured: adding a POST_BUILD regeneration of all.dict
beside the configure-time one left all 22 tests green. Parse whole
parenthesis-balanced statements instead, require exactly one generator
invocation and that it is the execute_process, with mutation arms for the
single- and multi-line aggregate-target forms.

Aligning the docker graph for the cache also made the injected manifest
job cache-identical to MasterCI's while the two workflows disagreed on
set_latest_for_docker_merged_manifest, which the job digest does not
cover. Measured identical manifest config digests (659a) with
set_latest True for MasterCI and False here, so whichever ran first would
decide whether the `latest` manifests are published. Set the flag to
match and pin the invariant over the workflows that share the job.

Both fixes verified by reverting them: the statement parser reddens on
the POST_BUILD mutation the line filter passed, and the manifest guard
reddens on the flag mutation.
The generator runs from configure and needs mapfile and GNU grep -z.
Stock macOS provides neither, and the failure mode was silent: the
extraction just yields fewer tokens, which is not a configure error and
would surface much later as the nightly coverage check.

Resolve bash through PATH instead of pinning /bin/bash, which is 3.2 on
macOS and shadows an installed newer bash, and check both prerequisites
before their first use so an unsupported environment says which tool is
missing.

Output-neutral: the generated dictionary is byte-identical before and
after (md5 0f418b14408c9809dda69b0595d4dc19, 6384 lines). Verified by
substituting a grep that rejects -z, which now aborts with the GNU grep
message and writes no output file, and by exercising the version
comparison at majors 3, 4 and 5. shellcheck -S warning is clean.

Also drop the exact new-test count from the description, which went stale
as rounds were added.
@groeneai

Copy link
Copy Markdown
Collaborator Author

All four findings verified by mutation rather than by reading, and all four were right. Head 12c8138a088c2361dc3bfae6a7d40546addcadf0.

1. build.sh negative check too weak - agreed. Adding bash $SRC/tests/fuzz/update_dict.sh before the copy left all 15 tests in that module green. Replaced with the positive contract: the only non-comment line naming a dictionary or a generator is cp $SRC/tests/fuzz/*.dict $OUT/, with a mutation arm per regeneration route (binary-derived, source-derived, inlined query).

2. arm_fuzzers include paths unguarded - agreed. Deleting the whole widening from special_build_jobs left all 39 tests green. Added assertions on that job's include_paths, that with_git_submodules survives the digest replacement, and that only the fuzzers build is widened, plus a negative control asserting the shared build digest does not already carry those paths (otherwise the assertion is vacuous).

3. consumer edge unasserted - agreed. Dropping CH_ARM_RELEASE from libfuzzer_job.requires left everything green. Added assertions that the job config requires it, that the workflow instance does, that the workflow provides everything the job requires, and that the dictionary inputs are in the consumer digest.

4. configure-time write into CMAKE_SOURCE_DIR - the mechanism reproduces (Permission denied, rc=1 with a read-only destination), but not the conclusion, so I did not move the output. cp $SRC/ClickHouse/tests/fuzz/*.dict $OUT/ in OSS-Fuzz's own build.sh reads the source tree, so a CMAKE_BINARY_DIR dictionary leaves that glob unmatched, and under -eu that aborts the build. The staging path you suggest is also unreachable there: fuzzers is an aggregate target and OSS-Fuzz builds ninja -j N $FUZZER_TARGET per target, so its POST_BUILD never runs. And the read-only premise does not hold for that consumer regardless: the same script runs sed -i on $SRC/ClickHouse/CMakeLists.txt twice and mkdir -p $SRC/ClickHouse/tests/fuzz/*_fuzzer.in/ five times before and after cmake. On a genuinely read-only checkout those fail first (measured: sed rc=4, mkdir rc=1). The file is gitignored so a fuzzing configure does not dirty the tree.

What finding 4 did surface is a real portability gap one level down, now fixed: the generator needs mapfile and GNU grep -z, and its /bin/bash shebang pinned macOS's 3.2 even when a newer bash is ahead on PATH. It now resolves bash through PATH and checks both prerequisites before first use, so an unsupported environment names the missing tool instead of silently emitting a short dictionary. Output-neutral, verified byte-identical (md5 0f418b14408c9809dda69b0595d4dc19, 6384 lines).

Two further defects of the same class as 1-3, found while verifying them:

  • The build-sharing digest was compared on the imported workflow objects, but praktika hashes the mangled ones, and mangle appends the injected docker job names to run_after, which is hashed. Measured Build (arm_release) config digests: 6efd for MasterCI against b765 here, run_after the only differing field, because MasterCI sets enable_dockers_manifest_merge and this workflow did not. So the release build was still rebuilt nightly. Fixed, and the comparison now runs post-mangle: reverting the alignment reddens it while the old pre-mangle comparison passes on that same tree (ab29 both sides).
  • Aligning that graph made the manifest job cache-identical to MasterCI's (659a) while the two workflows disagreed on set_latest_for_docker_merged_manifest, which the job digest does not cover, so whichever ran first would decide whether latest is published. Aligned and pinned.

On the aggregate-target guard you did not flag: it filtered the if (FUZZER) block to lines containing the generator name, then checked those lines for POST_BUILD, which in a multi-line add_custom_command is a different line. Adding a POST_BUILD regeneration beside the configure-time one left all 22 tests green. It now parses parenthesis-balanced statements and requires exactly one generator invocation, in the execute_process.

The CI graph did change here, so a NightlyFuzzers dispatch on an earlier head no longer covers this one. The body's merge condition still stands: it needs a green NightlyFuzzers on 12c8138a088c2361dc3bfae6a7d40546addcadf0, which needs admin rights to trigger.

ci/tests goes from 750 to 768 passing; the 2 failures in test_max_failures_exit_code.py are pre-existing on the merge-base and unrelated. ruff clean, shellcheck -S warning clean on the generator.

Aligning NightlyFuzzers' docker graph with MasterCI's set
enable_dockers_manifest_merge on the workflow definition, which adds a
"Dockers Build (multiplatform manifest)" job and puts it in the run_after
of every job downstream of the docker builds. The generated YAML was not
regenerated in that commit, so the committed file still described the old
graph and the Config Workflow check reported it as outdated.

Regenerated with 'PYTHONPATH=.:./ci python3 -m praktika yaml'. Only
nightly_fuzzers.yml changes: the other workflow definitions this branch
touches were refactored to build their long-retention artifact list
through a helper, and artifact retention tags are not represented in the
generated YAML, so those files come out byte-identical.
The generated codegen.dict is derived by grepping source trees with no suffix
filter, so every file under a scanned tree is an input. Nothing asserted that
the CMake dependency set for the codegen.dict command still equals that scan
set, so narrowing the glob back to *.h / *.cpp left the whole ci/tests suite
green while src/Functions/stl.hpp - a real carrier of an extracted name -
stopped triggering a regeneration, leaving codegen_select_fuzzer with a stale
grammar after an incremental build.

Compare the two sets as resolved file paths rather than as pattern lists, since
the lists can agree while their expansions do not. Six arms narrow one side and
require the disagreement to be seen: the glob reverted to suffixes, a scanned
tree dropped, the individually listed files dropped, a scan root added only to
the generator, a suffix filter added to the generator, and the digest entry
removed. A further pair runs the generator against a copy of the trees and
measures that a name added to that carrier reaches the dictionary, with a
control arm that must not carry it.

The resolution expands the globs in Python because cmake is not installed in
the CI Tests image; where cmake is available it is pinned against cmake itself,
on the intact list and on a narrowed one.

CI Tests is cache-gated, and the codegen CMakeLists was outside its digest, so
a commit that only narrowed the dependency list would have taken a cache hit
and never run these assertions. Add it to the include paths.
Comparing the dependency set against the generator's scan set says nothing
about whether any command consumes the variable. All of those assertions hold
with ${CODEGEN_DICT_SCANNED_SOURCES} absent from the codegen.dict command's
DEPENDS, with the generator script absent from it, or with codegen.dict absent
from the clickhouse.g command's DEPENDS - each of which leaves an edited carrier
regenerating nothing.

Parse the add_custom_command statements per argument section, so OUTPUT is not
read as far as COMMAND, and assert every edge of the chain from the scanned
sources through codegen.dict and clickhouse.g to the generated source, plus that
the grammar is built from the generated dictionary rather than the
binary-derived all.dict that does not exist at build time. Each edge carries an
arm that removes it and requires the assertion to fail.

The check that the reads outside the scanned trees are dependencies now reads
the DEPENDS section rather than the whole statement: naming a file in COMMAND
does not make a change to it trigger a rebuild.
…puts

A custom command only reruns for a file named in its DEPENDS, so editing
update.sh or clickhouse-template.g left clickhouse.g as it was, and editing
gen.py left out.cpp and out.proto stale. Reproduced on a two-arm project: the
command whose DEPENDS omits its generator keeps the output from the previous
build, while the one naming it regenerates.

The three scripts are configure_file'd into the binary directory and the
commands run there, so DEPENDS names the copies, which is what the build
compares timestamps against. Verified on the same shape end to end: a gen.py
edit regenerates out.cpp, an update.sh edit regenerates clickhouse.g and then
out.cpp.

Each edge carries an arm that removes it, plus one that points a dependency at
the source path instead of the copy.
@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing e17fa868c with master 8b9e2dc98 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of a09e4850d; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

Agreed, measured rather than read: reverting CODEGEN_DICT_SCANNED_SOURCES to the old
*.h / *.cpp form left all 57 tests in the four fuzzer-dictionary modules green. 28 of
the 1804 files under the scanned trees match neither pattern, and appending a
static constexpr auto name to src/Functions/stl.hpp does change the generated
dictionary, so the consequence holds too.

Added ci/tests/test_fuzzer_dict_codegen_deps.py, taking your second suggestion. It
compares the two sets as resolved file paths rather than as pattern lists, since the lists
can agree while their expansions do not, and it runs the generator against a copy of the
trees to measure that a name added to that carrier reaches the dictionary, with a control
arm that must not carry it. Nine arms narrow one side and require the disagreement to be
seen. The globs are expanded in Python because cmake is absent from the CI Tests image;
where it exists the resolution is pinned against cmake itself.

Two things this led to that were not in the finding:

CI Tests is cache-gated and src/Parsers/fuzzers/codegen_fuzzer/CMakeLists.txt was
outside its digest, so narrowing the list would have taken a cache hit and never run these
assertions. It is in include_paths now.

The same question asked of the rest of the chain found a defect predating this PR:
update.sh, clickhouse-template.g and gen.py were in no DEPENDS, so editing one left
its output stale. Reproduced on a two-arm project and fixed, depending on the
configure_file copies the commands run against.

88 tests pass. Head is fec450608c84e52cb41ae4c524f10d635e50c4f6; since this changes the
build graph, the manual NightlyFuzzers run needs to be against that SHA. I have not
re-triggered anything.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Two things the master merge in 4c737a6 surfaced that are yours to decide, both independent of the generator fix I just pushed.

The five suites this PR adds no longer have an executor. 8ff3720644b2 removed the CI Tests job together with ci/tests, and nothing under ci/defs, ci/workflows or .github/workflows references either now. Two of the classes asserted that job's digest, so they raised AttributeError: run together, the five suites gave 4 failed, 84 passed. I removed those two classes in 6f56e4a, since the job they pin is gone and they have no subject rather than a repairable assertion, and the suites are 84 passed again. The other 84 assertions still never execute in CI. Re-adding an executor would reinstate the surface you just removed, and deleting 1650 lines of the suites is a larger call than a bot round, so I have left them in place and am flagging it instead of choosing.

NightlyFuzzers publishes latest from whatever ref runs it. This PR sets set_latest_for_docker_merged_manifest=True so the manifest job's digest matches MasterCI and the shared arm_release build is a cache hit here. add_latest reaches Docker.merge_manifest with no event or branch guard (native_jobs.py:203, then docker.py:151). master.py carries the same flag today, so the missing guard is not something this PR introduces, but MasterCI only runs on master whereas NightlyFuzzers is dispatchable on any ref. So if the manifest job cache-misses during the branch dispatch this PR is waiting on, that run would retag every configured image latest from this branch. On a cache hit, which is the intended path and the reason the flag is set, nothing is retagged. Worth knowing before the dispatch; gating publication to the default branch would be a change to the shared praktika path rather than to this PR.

I have not squashed, and will not: the branch carries five of your commits including the head, so a squash would mean force-pushing over them.

Conflicts:
- `tests/fuzz/all.dict`, `tests/fuzz/dictionaries/functions.dict`,
  `tests/fuzz/dictionaries/keywords.dict`: master updated the committed
  dictionaries while this branch deletes them (they are now generated from a
  release binary). Kept the deletions.
- `.github/workflows/nightly_fuzzers.yml`: master moved `finish_workflow` to
  the `arm-tiny` runner label while this branch widened its `needs` with
  `build_arm_release` and `dockers_build_multiplatform_manifest`. Kept both;
  `python3 -m ci.praktika yaml` reproduces the result with no diff.
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Refreshed against master (head d4860885c95d). The branch was CONFLICTING; it is MERGEABLE again.

Conflicts resolved:

  • tests/fuzz/all.dict, tests/fuzz/dictionaries/functions.dict, tests/fuzz/dictionaries/keywords.dict — master updated the committed dictionaries while this branch deletes them (that is the point of the change). Kept the deletions.
  • .github/workflows/nightly_fuzzers.yml — master moved finish_workflow onto the arm-tiny runner label, this branch widened its needs with build_arm_release and dockers_build_multiplatform_manifest. Both sides only change different things, so both are kept; python3 -m ci.praktika yaml reproduces the committed file with no diff.

Verified locally on the merged tree: tests/fuzz/generate_source_dict.sh runs clean and emits 6417 tokens, and the five fuzzer suites give 83 passed / 1 failed — the failure is the known host-locale case test_unpinned_comm_aborts, where this worker's en_US.utf8 collation does not make comm reject the LC_ALL=C-sorted input, so the mutation arm never sees "not in sorted order". It is green in the CI container.

CH Inc sync: the private sync branch sync-upstream/pr/115307 was re-merged by hand with private master and with this new head, pushed as a28a3ed98ea. The private master merge hit the same shape as here — ci/defs/job_configs.py where master removes the ci_tests job that this branch had extended with dictionary include paths; master's removal wins, matching the public side. The sync PR is MERGEABLE again.

The AI Review Major about empty-match handling in generate_source_dict.sh predates 46d6552bc59a, which fixed it; the verdict has not been re-run since. The merge condition in the description is unchanged: a green human-dispatched NightlyFuzzers run on the current head, which needs admin rights to dispatch.

Comment thread ci/workflows/nightly_fuzzers.py Resolved
@@ -0,0 +1,425 @@
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new regression suites currently have no executor in the tree they are being merged into.

A repo-wide search across .github/workflows, ci/defs, and ci/workflows finds no job that still runs ci/tests/test_fuzzer_dict_* or ci/tests/test_nightly_fuzzers_build_sharing.py after the CI Tests job removal, so the PR's “fixed and covered” contract has no CI evidence behind it on current HEAD. Because these tests are the only proof for the cache/dictionary wiring, future regressions will pass CI unless they happen to break some other surface accidentally.

Please either wire these suites into an executed workflow again, or move the assertions into a test surface that CI already runs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact is right, and it is the same one I recorded on this PR on 2026-08-30: nothing has run these suites since 8ff3720644b2 removed the CI Tests job together with ci/tests. That round also dropped the two suites whose subject had genuinely disappeared.

Neither remedy is mine to choose. Wiring an executor back in reinstates the surface that removal deleted, and 5e8bf203b1409d2 ("Remove ci/tests (attempt 3)") states the standard for the other direction: nothing runs it, so it is dead code, and removing it finishes the removal rather than re-opening the decision. There is also no surface to move the assertions to: the style job runs mypy, pylint and ruff, master schedules no Python test job at all, and the ci/tests/test_e2e.py restored to master yesterday has no executor either.

So keeping them as a locally runnable harness or deleting them is a maintainer decision, and I have not pre-empted it. What I did fix this round is a real weakness in the new arms: they asserted the decision functions rather than the production call path, so restoring either static call would have left them green.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵 Adopting the third remedy of the three you list, since it is the only one that is mine to make: the PR body no longer claims these suites as standing coverage. It now states plainly that nothing in CI has executed them since 8ff3720644b2 removed the CI Tests job together with ci/tests, gives the command that runs them locally, and records the result (94 passed on the current head). Reinstating an executor or deleting the suites both remain maintainer decisions, and there is still no already-executed Python test surface on master to move the assertions to — the style job runs mypy, pylint and ruff, and the ci/tests/test_e2e.py restored to master has no executor either.

Also in this round, the two TestLatestTagIsBaseBranchOnly wiring arms added last time were aborting before they reached Docker.merge_manifest: _build_dockers refuses to run when platform.processor cannot name the host CPU, and that value is uname -p, which is unknown on some hosts. The architecture is not their subject, so it is now pinned rather than read from the host, and the arms are verified load-bearing — restoring the static workflow.set_latest_for_docker_merged_manifest at the call site still reddens test_the_merge_gets_no_tag_on_another_branch.

groeneai and others added 3 commits September 1, 2026 03:05
`Dockers Build (multiplatform manifest)` passed
`Workflow.set_latest_for_docker_merged_manifest` straight into
`Docker.merge_manifest`, which turns it into `docker buildx imagetools create
--tag <image>:latest`, with no branch or event guard. Two workflows set the flag:
MasterCI, which only runs on `master`, and NightlyFuzzers, whose generated
workflow also exposes `workflow_dispatch` and is therefore dispatchable on any
ref. A manifest-job cache miss during a branch dispatch would retag every merged
image `latest` from that branch.

Turning the flag off for NightlyFuzzers is not the fix. The manifest job's digest
does not cover the flag, so the two workflows share its cache entry, and a
disagreement there would make master's `latest` tagging depend on which workflow
filled the entry first.

Gate the tag on the branch the run is on instead. Both flag holders declare
`branches=[BASE_BRANCH]`, so scheduled and push runs keep tagging `latest` and
only an off-base dispatch loses the retag.

Reported by the AI reviewer in
ClickHouse#115307 (comment)

Co-Authored-By: Claude Opus 5 <[email protected]>
`libfuzzer_test_check.py` also backs `libFuzzer corpus minimization`, which
`WeeklyFuzzersCorpus` runs with `--minimize-only`. `main` called
`generate_dictionary` before branching on that flag, and the generator asserts the
release binary is staged next to the fuzzer targets. That job requires only
`ARM_FUZZERS` and `FUZZERS_CORPUS`, and its workflow provides no release build at
all, so every weekly run would have failed with "ClickHouse release binary not
found" before reaching the runner.

Nothing is lost by skipping it: `tests/fuzz/runner.py` builds the merge command
from `allowed_merge_libfuzzer_options`, which has no `dict` entry, and returns
before the fuzzing block that would add `-dict=`. Measured on the guard: with
`--minimize-only` the run now reaches the runner, without the guard it raises the
assert, and a run without the flag still generates the dictionary.

The added test pins the config half of the pairing, which is what makes the
requirement unsatisfiable rather than merely absent.

Co-Authored-By: Claude Opus 5 <[email protected]>
Review of the previous two commits found that each guard was pinned by asserting
the decision, never the value the production call site passes on. Restoring the
static workflow flag in `_build_dockers`, or the unconditional
`generate_dictionary` call, left every assertion green.

Both arms now drive the real code path: `_build_dockers` with
`Docker.merge_manifest` captured, and `main` up to the runner invocation with
generation counted. Each has the opposite arm as its control, and each of the two
mutations above reddens exactly one of them.

Also corrects the mechanism named in the mode docstring: praktika downloads
artifacts through the boto3 client, not `aws s3 cp`. The conclusion is unchanged,
since S3 carries object content and no POSIX mode either way.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

Round 6

Two AI-reviewer findings, and one blocker my own review of the first fix turned up.

latest from a branch dispatch (35a8bc4): agreed, fixed, reasoning in the thread. The flag stays on, because the manifest job's digest does not cover it and both cache sharers have to agree; the tag itself is now gated on the run's branch, which leaves scheduled and push runs unchanged.

This PR broke the weekly corpus-minimization job (9908976): libfuzzer_test_check.py also backs libFuzzer corpus minimization, and main called generate_dictionary before branching on --minimize-only. That job requires only ARM_FUZZERS and FUZZERS_CORPUS, and WeeklyFuzzersCorpus provides no release build, so every Sunday run would have failed with "ClickHouse release binary not found" before reaching the runner. Skipping generation there loses nothing: runner.py builds the merge command from allowed_merge_libfuzzer_options, which has no dict entry. Measured three arms: with the guard the minimization run reaches the runner, without it it raises the assert, and a run without the flag still generates the dictionary.

Guard wiring (7295403): both new guards were pinned by asserting their decision, so restoring either static call site would have left every assertion green. Both arms now drive the real path, _build_dockers with Docker.merge_manifest captured and main up to the runner with generation counted, each with the opposite arm as its control.

Two findings I agree with and deliberately did not act on:

  • The suites still have no CI executor. Both offered remedies either reinstate the surface the ci/tests removal deleted or have no target surface, so this stays a maintainer decision.
  • if grep -qE in generate_source_dict.sh cannot distinguish exit 2 from "no match". Third raising, still declining: reaching it needs a file to become unreadable between two greps microseconds apart, and it is not silent where it matters, since update_dict.sh compares the binary-derived dictionary against the source-derived one and exits 1 listing the difference, and the binary-derived dictionary carries 10 __-prefixed tokens.

Five fuzzer suites pass locally (95 cases), ruff is clean, and python3 -m ci.praktika yaml reproduces the committed workflow with no diff. No rebase, no master merge, no force push: the three commits fast-forward d4860885, and every maintainer commit on this branch is still reachable. Not squashed, since the branch carries maintainer commits including the base of mine.

The merge precondition is unchanged and I have not re-pinged for it.

@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 72954032f60ed63de7c93218fe9ceacd8ebfe319

Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link I
will post here when it opens.

Check / test Reason Owner / fixing PR
Docs examples / Documentation examples, Function/toYYYYMM#0 the example in src/Functions/toYYYYMM.cpp documents SELECT toYYYYMM(now(), 'US/Eastern') as 202608, so it began returning 202609 when the month rolled over in that zone at 2026-09-01 04:00 UTC. Time triggered and trunk-wide: 47 rows over 46 unrelated PRs since that boundary, against 0 rows in the preceding 10 days #117459 (mine, open)
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) job-level container-memory abort with no failing test assertion: the shard's nested containers breach the /docker cgroup leaf. 633 rows over 301 unrelated PRs in the last 24h. #117202 is already an ancestor of this head (compare returns status=ahead, behind_by=0) and the shard failed anyway, so it is not the owner #117411 / #117412 (both open)

This branch changes ci/, so I checked causation rather than assuming: the diff touches no integration
test job or config file and no memory, cgroup or /docker budget knob, and the toYYYYMM example is
outside it entirely.

Session id: cron:our-pr-ci-monitor:20260901-083000

@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 4, 2026
alexey-milovidov and others added 2 commits September 9, 2026 11:35
…zer-dict-from-binary

# Conflicts:
#	ci/defs/job_configs.py
#	ci/jobs/libfuzzer_test_check.py
#	ci/workflows/master.py
#	ci/workflows/release_branches.py
`_build_dockers` refuses to run when `platform.processor` cannot name the
host CPU, and that value is `uname -p`, which is `unknown` on some hosts.
Both `TestLatestTagIsBaseBranchOnly` wiring arms therefore aborted before
reaching `Docker.merge_manifest`, so they could not observe the `add_latest`
argument they exist to pin. The architecture is not their subject, so it is
pinned rather than read from the host.

Verified load-bearing: restoring the static
`workflow.set_latest_for_docker_merged_manifest` at the call site still fails
`test_the_merge_gets_no_tag_on_another_branch`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Comment thread ci/praktika/native_jobs.py Resolved
alexey-milovidov and others added 2 commits September 9, 2026 12:23
`_publish_latest_docker_manifest` confines publication of the mutable
`latest` docker alias to the workflow's own branch, but a workflow that
declares no branches fell back to publishing. Moving a public mutable tag
is a consequential action, so the undecidable case now refuses instead.

Every workflow that tags `latest` declares a branch on both the public and
the private side today (`MasterCI` and `NightlyFuzzers`, both `master`), so
this changes no live behaviour; the arm that pins that invariant is kept as
well, because a silent never-publish would be as wrong as a silent publish.

Verified load-bearing: restoring the `return True` fallback reddens
`test_a_workflow_without_branches_refuses_to_publish`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…zer-dict-from-binary

Master moved the fuzzers build and the libFuzzer jobs from arm to amd, which this
branch's additions were keyed to. The dictionary is generated by running the
release binary, so it must be the binary for the arch the job runs on: the extra
requirement becomes `CH_AMD_RELEASE` and the workflow provides `amd_release`.

Two of those re-keyings are in hunks that merged cleanly and would have gone
wrong silently - the `special_build_jobs` digest hook still tested
`BuildTypes.ARM_FUZZERS` (so it would never have applied), and
`ci/workflows/nightly_fuzzers.py` still selected the arm release build while the
job required the amd artifact. `praktika yaml` refuses to generate in the latter
case, which is how it surfaced.

`.github/workflows/nightly_fuzzers.yml` is generated, so it is regenerated with
`python3 -m ci.praktika yaml` rather than hand-merged; it is the only generated
workflow the regeneration changes.
@clickhouse-gh
clickhouse-gh Bot requested review from leshikus and maxknv September 12, 2026 22:06
ClickHouse#105118 moved the libFuzzer job to amd64 and the master merge brought it here:
the fuzzers build is `BuildTypes.AMD_FUZZERS`, NightlyFuzzers selects
`Build (amd_release)`, and the consumer edge is `CH_AMD_RELEASE`. Two modules
still named the arm jobs, so on this head one class raised `AttributeError`
before asserting anything and the build-sharing module could not find the job
whose digest it compares: 11 of the 96 arms were red and the invariants they
stand for were not exercised at all.

The examples wiring is appended to the arm release job only, so the two arms
that described the shared build in those terms lost their subject. They are
replaced by what the sharing rests on instead: that the wiring does not reach
the amd job, so both release job lists agree on it, and that every artifact
the shared build provides is declared by the workflow.

`test_an_untagged_upload_would_not_match` was also passing for an incidental
reason. It compared a hand-built workflow holding the shared `ArtifactConfigs`
singletons against MasterCI's import-time copies, and mangle stamps
`_provided_by` onto the singletons, so the two digests differed whether the
long-retention tags were there or not. It now derives both sides from this
workflow's own artifact configs and flips only the tagging, which reddens in an
isolated and in a full-module run when the tags are equalized.
The claim it rested on does not hold. Praktika uploads under
`REFs/<branch>/<sha>/<workflow>/<job>` (`_environment.py`
`get_s3_prefix_static` and `runner.py`, on master since `633ec9e571ae8`), so two
workflows uploading the same artifact name for one commit cannot overwrite each
other, and NightlyJepsen and NightlySQLancer could never downgrade MasterCI's
retention. The digest half of the rule does not reach them either: their
post-mangle build configs are cache-incompatible with MasterCI's, because their
docker graph carries no manifest job. What remains there is a retention policy
decision about two workflows this PR is not about, so it is reverted and the
helper docstring states the invariant that does hold.

NightlyFuzzers keeps the tags. It does share MasterCI's release build, and the
digest is measurably sensitive to them: dropping the helper there reddens
`test_digest_matches_master`.

The census arm that enumerated every non-PR workflow for the same collision goes
with the claim. The parametrized arm keeps the three call sites that apply the
helper.
return False
if not workflow.branches:
return False
return branch in workflow.branches

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflow.Config.branches is documented and already used as "branch names or patterns" (see ci/praktika/workflow.py and the shared matcher in ci/praktika/orchestrator/__init__.py). This helper narrows that contract to literal list membership, so the first workflow that enables set_latest_for_docker_merged_manifest on a patterned branch set will silently never publish latest even when the branch should match.

Please reuse the same exact-or-regex branch matcher here instead of branch in workflow.branches, so latest tagging follows the same branch semantics as workflow selection.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, and patterns are live rather than hypothetical: ReleaseBranchCI declares branches = ["2[1-9].[1-9][0-9]", "2[1-9].[1-9]"] (ci/workflows/release_branches.py:26), and yaml_generator.py:481 emits those strings verbatim into on: push: branches:. So the field does carry patterns and this helper accepts only literal names.

I am not reusing _branch_matches here, because it is not the semantics that selects any workflow able to carry this flag, and the divergence runs the dangerous way. Measured on this head:

  • find_workflows_for_event skips Workflow.Engine.GH_ACTIONS (orchestrator/__init__.py:62), and every push or pull_request workflow in the tree is GHActions (MasterCI, ReleaseBranchCI, PR, BackportPR); the only non-GHActions workflow is CreateReleaseBranch, a dispatch with branches = []. _branch_matches therefore cannot fire on branches today: what selects those four is GitHub's evaluation of the generated yaml, whose filter patterns are globs, not re.fullmatch.
  • The two readings disagree in both directions on real inputs. re.fullmatch("2[1-9].[1-9][0-9]", "26x10") matches, because the dot is a metacharacter, and the glob does not; so the swap would let a run move latest from a branch the workflow is not configured for. Conversely feature/* and 26.? match as globs and fail re.fullmatch.
  • re.fullmatch("releases/**", "releases/26.3") raises re.error: multiple repeat, so a branch set written in GitHub's own syntax would fail the manifest job rather than skip the tag.

For a shared mutable alias, publishing too eagerly is the harmful direction, which is why the undecidable case refuses. A faithful pattern-aware form has to follow whichever engine selects the workflow, and branches is documented "for push trigger only" while NightlyFuzzers is a schedule workflow, so for its ref there is no selection semantics to inherit at all. That is a praktika-wide decision about what the field means, and _branch_matches is where both paths should converge if you want it; it needs glob-shaped entries handled before it can claim the documented contract.

Worth knowing if pattern support does land: test_the_declared_branches_still_publish feeds each entry of workflow.branches in as the branch, so on a patterned entry it would assert only that the pattern text round-trips and would stay green while real runs published nothing. Not vacuous today, since both flag-carrying workflows declare the literal master, but it has to change with the semantics. I have recorded the narrowing as a declined residual in the PR body.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Refreshed against master (head e17fa868c947, 3368 commits merged, no conflicts this round - the four recurring conflict shapes in ci/defs/job_configs.py, ci/jobs/libfuzzer_test_check.py, ci/workflows/master.py and ci/workflows/release_branches.py all merged cleanly).

Verified on the merged tree:

  • python3 -m ci.praktika yaml reproduces the committed workflows with no diff.
  • tests/fuzz/generate_source_dict.sh runs clean and emits 6747 tokens (6696 before the merge; the difference is the functions master added).
  • The five suites give 92 passed / 1 failed, the failure being the known host-locale case test_unpinned_comm_aborts - this worker's en_US.utf8 default collation does not make comm reject the LC_ALL=C-sorted input, so the mutation arm never observes "not in sorted order".

CH Inc sync: the private branch sync-upstream/pr/115307 was re-merged by hand with private master and with this new head, pushed as 80035e3c3d5; the sync pull request is MERGEABLE / CLEAN. Private master's conflict was the same shape as before, libfuzzer_job in ci/defs/job_configs.py, where private master still carries requires=[AMD_FUZZERS, FUZZERS_CORPUS] and this branch adds the release binary - both kept, matching this head's [AMD_FUZZERS, FUZZERS_CORPUS, CH_AMD_RELEASE]. .github/public_workflows/nightly_fuzzers.yml is a mirror of the public file rather than a generated one there (verified: the private generator does not rewrite it), so it takes this branch's version verbatim.

The only red on the previous head was Fast test (arm_darwin), reported as DROPPED rather than as a failing test; the new run decides it.

The remaining AI-review Major on CMakeLists.txt (configure writes into the source tree) is answered in #115307 (comment) with the OSS-Fuzz build script as evidence, and the part of it that survives that evidence is now named in the Residuals paragraph of the description.

The merge condition in the description is unchanged: this still needs one human-dispatched green NightlyFuzzers run on the current head, which requires admin rights.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 19, 2026
Merged via the queue into ClickHouse:master with commit 8837959 Sep 19, 2026
177 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 19, 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-request PR origin: a maintainer pinged or directed groeneai 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