ci: add clang-tidy gate and libFuzzer target - #53
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Problem - The project had no static analysis beyond clang-format and no fuzzing, so runtime evaluation paths (binding, dispatch, structural extraction) were only covered by fixed test cases. Implementation - Add .clang-tidy (bugprone/clang-analyzer/performance/portability/ concurrency, headers-only scope, warnings-as-errors) and a clang-tidy workflow running it on tests and samples. - Fix the findings it surfaced: two unsequenced double-forwards in guard/tuple evaluation (bugprone-use-after-move), missing enum underlying types (performance-enum-size), and an unconstrained forwarding constructor (bugprone-forwarding-reference-overload). - Add fuzz/ptn_fuzz_match: oracle-based libFuzzer target comparing literal, guard, structural, variant, and combinator evaluation against reference implementations, behind PTN_BUILD_FUZZ. - Add a fuzz workflow: 180s smoke on PR/push, 900s weekly deep run, crash artifacts uploaded on failure. Tests - clang-tidy is clean on all test and sample TUs (json_dispatch excluded: needs nlohmann/json). - Local fuzz run: 8.27M executions in 45s with ASan on Windows, no divergence, no sanitizer reports. - Full suite: 204/204.
sentomk
force-pushed
the
ci/tidy-and-fuzz
branch
from
August 1, 2026 18:13
db8c61b to
ce32369
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add the two missing verification layers: static analysis via clang-tidy (warnings-as-errors gate on tests + samples) and fuzzing via a libFuzzer target with oracle comparison. Adding clang-tidy immediately paid off — it surfaced two real latent bugs in the evaluation path.
Changes
.clang-tidy:bugprone-*,clang-analyzer-*,performance-*,portability-*,concurrency-*, scoped toinclude/ptn/,WarningsAsErrors: '*'. Three checks disabled with documented rationale (CRTP mixin style, metaprogramming branch clones, swappable-parameter noise)..github/workflows/clang-tidy.yml: runs the config on every test/sample TU (json_dispatch excluded — needs nlohmann/json).guard.hppeval(bin_expr)andeval.hppinvoke_from_tuple_impl: unsequenced doublestd::forwardof the same tuple (bugprone-use-after-move) — now evaluate through lvalue, which is also semantically right for read-only paths.performance-enum-size: explicitstd::uint8_tforrange_mode(shrinksrange_predicateby 3 bytes) and 8 compile-time enums; fwd declarations synced.structural.hpp:has_guarded_patternforwarding constructor constrained so it cannot hide copy/move ctors.fuzz/ptn_fuzz_match.cpp: oracle-based target — five batteries (literal dispatch, guards, structural, variant, combinators) comparing patternia against reference implementations; divergence traps.fuzz/CMakeLists.txt+PTN_BUILD_FUZZoption (Clang-only, FATAL_ERROR otherwise); Windows CRT pinning handled (MSVC_RUNTIME_LIBRARY MultiThreadedforclang_rt.fuzzer's MT_StaticRelease)..github/workflows/fuzz.yml: 180s smoke per PR/push, 900s weekly deep run, crash artifacts uploaded on failure.Testing
Follow-ups (repo settings, outside this PR)
clang-tidyandfuzzto the branch protection required checks once both workflows have proven stable on main.fuzz/corpus/once the first interesting inputs accumulate.