Skip to content

sdk%feat(lint): add clang-{format,tidy} 20, instrument with lint_clang.py, validate against cert-{c,cpp}-coding-standards and cpp-security-and-quality suites, fetch per-platform CodeQL - #111

Merged
kwvg merged 11 commits into
dashpay:developfrom
kwvg:lint_cxx
Nov 3, 2026

Conversation

@kwvg

@kwvg kwvg commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

As described in base-sdk#101, we will be introducing C/C++ sources for generating corpora (and later for FFIs for our libraries),

Additional Information

  • This pull request makes just lint a very expensive step as it will be running CodeQL thrice, reformulating workflows to parallelise this step and readjusting just verbs to make just comb more resource-economic will be addressed in a future pull request to avoid reworking CI until FFIs have been committed in tree.

  • During local platform validation we identified that aarch64 Linux CodeQL broke again and now that all-platform bundles have been deprecated by GitHub (source) we're going back to managing CodeQL ourselves to repair aarch64 Linux though the fixes are a lot less invasive than prior iterations so the maintenance burden will be limited.

How Has This Been Tested?

just lint

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional tests
  • I have made corresponding changes to the documentation
  • I did not use agentic assistance (i.e. LLMs, AI) except as disclosed and can answer questions, comments and concerns without said assistance. I assume authorship of the code submitted.
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

Agent disclosure

Code generated with Claude Code using Opus 5.5, medium effort. Reviewed with Codex using GPT-6.1-Sol, medium effort as adversarial review and Claude Code using Fable 5.1, medium effort.

@kwvg kwvg added this to the 0.3 milestone Nov 2, 2026
@kwvg kwvg self-assigned this Nov 2, 2026
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between e2a0ae8 and 901e651.

Files ignored due to path filters: 2
  • contrib/nix/flake.lock is excluded by !**/*.lock, !**/*.lock
  • uv.lock is excluded by !**/*.lock, !**/*.lock
Files selected for processing: 26
  • .github/workflows/build_stable.yml
  • AGENTS.md
  • Justfile
  • contrib/nix/flake.nix
  • contrib/nix/mods/codeql.nix
  • contrib/nix/mods/fhs.nix
  • contrib/nix/mods/nixpkgs.nix
  • contrib/nix/shell/common.nix
  • contrib/probes/free.c
  • contrib/probes/hello.c
  • contrib/probes/hello.cpp
  • fuzz/pow/src/shim.c
  • maint/.clang-format
  • maint/.clang-tidy
  • maint/README.md
  • maint/codeql/c/codeql-pack.lock.yml
  • maint/codeql/c/qlpack.yml
  • maint/codeql/c/suppressions.toml
  • maint/codeql/cpp/codeql-pack.lock.yml
  • maint/codeql/cpp/qlpack.yml
  • maint/common.py
  • maint/lint/lint_clang.py
  • maint/lint/lint_codeql.py
  • maint/lint/lint_semgrep.py
  • maint/semgrep/cxx/style.yml
  • pyproject.toml

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0119f58 and e2a0ae8.

Files ignored due to path filters: 2
  • contrib/nix/flake.lock is excluded by !**/*.lock, !**/*.lock
  • uv.lock is excluded by !**/*.lock, !**/*.lock
Files selected for processing: 3
  • contrib/nix/mods/codeql.nix
  • contrib/nix/mods/fhs.nix
  • contrib/nix/shell/common.nix

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Integer addition now returns 0 when the result would overflow.
    • The greeting example now exits with an error if an exception occurs.
  • Chores
    • Automated checks now cover C and C++ code in addition to Rust, including formatting, static analysis, and security-and-quality queries.
    • Development tooling now includes consistent C/C++ formatting and documentation-comment checks.
    • The development environment now uses a single CodeQL version across supported platforms and includes C/C++ compiler tools.
    • The lint workflow now checks out Git submodules.

The repository adds C and C++ linting with clang-format, clang-tidy, Semgrep, and CodeQL. Shared configuration defines source extensions, compiler standards, flags, and environment handling. CodeQL packs and suppressions support C and C++ analysis. Nix provisions CodeQL and clang-tools, and the lint target runs C and C++ CodeQL suites. Probe sources receive formatting changes, overflow handling in the C addition probe, and exception handling in the C++ entry point.

Sequence Diagram(s)

sequenceDiagram
  participant Justfile
  participant lint_codeql.py
  participant common.py
  participant CodeQL
  Justfile->>lint_codeql.py: Run C or C++ CodeQL suite
  lint_codeql.py->>common.py: Get compiler flags and environment
  common.py-->>lint_codeql.py: Return flags and environment
  lint_codeql.py->>CodeQL: Resolve suites and create analysis database
  CodeQL-->>lint_codeql.py: Return analysis findings
  lint_codeql.py->>lint_codeql.py: Filter findings by ownership and suppressions
Loading

Suggested reviewers: thepastaclaw

Merge Risk: Minimal · previous review e2a0a

Linux CodeQL now runs inside the required FHS environment. No concrete merge-blocking risk remains.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title names the main change: adding clang-format and clang-tidy 20 linting, a lint_clang.py driver, CERT and security-and-quality CodeQL suites, and per-platform CodeQL fetching. The changeset mat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description directly relates to the changes. It explains the planned C/C++ support, CodeQL platform bundles, lint changes, testing, and motivation.
Full details: Title check

Explanation

The title names the main change: adding clang-format and clang-tidy 20 linting, a lint_clang.py driver, CERT and security-and-quality CodeQL suites, and per-platform CodeQL fetching. The changeset matches each of these. The title is long (192 characters, 16 words) and packs many items into one line, but it is related to the main change and is not vague or off-topic.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Note

This pull request has no conflicts! 🎊 🎉 🎊

@kwvg kwvg moved this to Build/CI in base-sdk v0.3 Nov 2, 2026
@github-actions github-actions Bot added the topic:Build/CI Pull requests associated with work on the build system and maintenance. label Nov 2, 2026
@thepastaclaw

thepastaclaw commented Nov 2, 2026 •

Copy link
Copy Markdown

✅ Final review complete — no blockers (commit 901e651) · triage: normal

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread contrib/nix/mods/codeql.nix Resolved

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

Verified the supplied findings against head 0119f58 and the base-to-head source changes. No blocking defect was confirmed; the diagnostic-filtering regression-test suggestion is valid and in scope. Current CI checks, including Lint, pass, and the lint log confirms the new C/C++ gates executed; local validation was static only.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This cross-cutting lint and build-tooling change adds substantial orchestration and platform-specific CodeQL packaging without changing any critical runtime surface.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `maint/lint/lint_codeql.py`:
- [SUGGESTION] maint/lint/lint_codeql.py:239-245: Add regression fixtures for diagnostic filtering and suppressions
  The new ownership filter controls which diagnostics contribute to the failure count, including findings from the existing Rust security queries. Neither this filtering nor the new TOML suppression loader has accompanying regression tests. The passing lint run verifies integration on the current sources, but does not establish that an unsuppressed owned-file diagnostic still fails the gate. Add small CSV/TOML fixture tests covering an owned finding being counted, an external-header finding being excluded, exact path-and-message suppression without suppressing a different file or message, and malformed CSV rows or suppression records being rejected. These helpers can be tested without invoking CodeQL.

Comment thread maint/lint/lint_codeql.py Resolved
@kwvg
kwvg marked this pull request as ready for review November 2, 2026 16:24

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

Independently inspected the complete base-to-head diff at 901e651 and found no verified blocking defect; the regression-coverage suggestion remains valid. Current CI reports successful lint, stable-platform builds, and cross-builds, with MSRV and additional platform checks still pending and no failed checks reported. Validation was static only; no builds or tests were executed locally.

🟡 1 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a cross-cutting lint and build-tooling change with platform-specific CodeQL packaging and new analysis orchestration, but it does not change a critical runtime surface.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `maint/lint/lint_codeql.py`:
- [SUGGESTION] maint/lint/lint_codeql.py:239-245: Add regression fixtures for diagnostic filtering and suppressions
  (existing thread: https://github.com/dashpay/base-sdk/pull/111#discussion_r4444226145)
  The ownership filter and per-language suppressions determine which diagnostics can fail the lint gate, but neither `_print_csv_diagnostics` nor `_load_suppressions` has regression coverage in the current tree. Passing analysis does not prove that an owned, unsuppressed violation survives filtering or that a suppression matches only its exact path/message pair. In particular, the two configured suppressions target `__builtin_available` in the macOS-only branch of `contrib/probes/hello.c`, while the CI lint job runs on Ubuntu. Add lightweight CSV/TOML fixtures covering an owned unsuppressed result, an unowned dependency result, an exact suppression, path/message near-matches, newline normalization, and malformed rows or suppression entries; assert both emitted diagnostics and the returned count. These tests can exercise the Python helpers without invoking CodeQL.

@kwvg
kwvg merged commit 9e2df7c into dashpay:develop Nov 3, 2026
34 checks passed
kwvg added a commit that referenced this pull request Nov 3, 2026
* [e8ce915] pkc%test(bls): add the reference implementation as a submodule (pasta)
* [76704ec] sdk%build(nix): add `corpora.nix` with CMake, Boost and GMP (pasta)
* [4feb192] pkc%test(bls): add programs that write the BLS corpora (pasta)
* [5e0c21a] sdk%ci(gha): build the corpus generators weekly (pasta)

Description:

`````
## Motivation

The BLS corpora in `pkgs/pkc/corpus` are written from the reference implementation, but the programs that wrote them are not in the repository. This pull request adds them, with `regen.py` to write every corpus again from a pinned release, so a corpus can be checked or extended later. It is split out of #101, which adds one more program on top of it.

## Additional Information

| Description | Notes |
| ----------- | ----- |
| Add the reference implementation as a submodule | `pkgs/pkc/contrib/dash`, pinned at v24.0.0-rc.5 (8163290aa0), shallow and with `update = none`, so a clone, `git submodule update` and CI checkouts skip it. Only `regen.py` checks it out. Bazel, CodeQL and the crate package skip it, as its tree carries build files of its own. |
| Add programs that write the BLS corpora | Each `gen_*.cpp` links the release's BLS library (dashbls, with relic), plus a few of the release's own sources where a corpus needs them, and prints one corpus. `regen.py` extracts the release's `src`, builds the library, compiles and runs every program, and writes the corpora only when all of them succeed. The nine corpora come out byte-identical, so this changes no corpus. `pkgs/pkc/contrib/README.md` has the recipe. |
| Add autotools and GMP to the dev shell | `contrib/nix/shell/dev.nix` gains autoconf, automake, libtool, pkg-config and GMP for `regen.py`. The CI shell is unchanged. |

Bazel has no build for the library, and the release's copy of the library builds with autotools only, as the reference implementation stopped tracking relic's CMake configuration template. So `regen.py` runs that build, which needs a POSIX shell, and GMP is required.

When these programs were added, the corpora were also checked equal at v23.1.8 (728f505583).

The C++ here is as it was in #101 and predates the clang-format style in #111. As discussed in #101, this branch is open for the C++ lint and static analysis commits. Whichever of this and #111 lands second will adapt.

## Breaking Changes

None. No library code changes.

## How Has This Been Tested?

- `regen.py` writes the nine corpora byte-identical to the committed ones, with GCC 15 and with clang 21 building both the library and the programs, from a fresh clone that fetches the submodule and from an existing build.
- A failed library build, a submodule checked out at another commit and an invalid option each stop the run with nothing written.
- Only Linux x86_64 was run. macOS and Windows are untested, and the dev shell change has not been run in a Nix shell.
- `cargo test -p dash-pkc --all-features` passes, and the lint suite is clean with the submodule checked out.
- CI (`just test lint fuzz::test`, CodeQL included) is green on each commit.

## Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional tests
- [x] I have made corresponding changes to the documentation
- [ ] I did not use agentic assistance (i.e. LLMs, AI) except as [disclosed](#agent-disclosure) and can answer questions,
      comments and concerns without said assistance. I assume authorship of the code submitted.
- [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

### Agent disclosure

Code, commit messages and this description were generated with Claude Code using Claude Opus 5.5, running autonomously as an agent on behalf of the author. The agent also built the pinned release's BLS library and wrote the corpora with it. The change was reviewed by a Claude Code agent using Opus 5.5.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
`````
PastaPastaPasta added a commit to PastaPastaPasta/base-sdk that referenced this pull request Nov 4, 2026
Takes dashpay#100 dashpay#88 dashpay#108 dashpay#107 dashpay#111 dashpay#110 dashpay#112 dashpay#115 dashpay#114 dashpay#101. ChainSetup keeps
the DEC-1043 policy fields; the BS11 BLS wrappers, i64 TxOut values and
MAX_SER_SIZE payload bound stay for Core parity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:Build/CI Pull requests associated with work on the build system and maintenance.

Projects

Status: Build/CI

Development

Successfully merging this pull request may close these issues.

2 participants