refactor(dnn,psnr): clear the dnn + psnr clang-tidy buckets to zero (ADR-1142 wave 2) - #1323
Draft
lusoris wants to merge 11 commits into
Draft
refactor(dnn,psnr): clear the dnn + psnr clang-tidy buckets to zero (ADR-1142 wave 2)#1323lusoris wants to merge 11 commits into
lusoris wants to merge 11 commits into
Conversation
lusoris
force-pushed
the
refactor/tidy-wave2-dnn-psnr
branch
2 times, most recently
from
September 6, 2026 03:00
66edbbb to
7eba02c
Compare
lusoris
pushed a commit
that referenced
this pull request
Sep 6, 2026
The wave-2 tidy pass rewrote 90 `NULL`s to the C23 `nullptr` keyword
across seven C translation units (`core/src/dnn/{dnn_api,
dnn_attach_api,model_loader,onnx_scan,op_allowlist}.c`,
`core/src/feature/{float_psnr,integer_psnr}.c`). ADR-1138 settled that
question for C: `Build — Windows MSVC + CUDA (build only)` is a required
status check and compiles these TUs with cl.exe, whose documented
/std:clatest C23 feature set does not include `nullptr`. PR #1192 had to
revert exactly this rewrite after all three Windows legs failed with
"use of undeclared identifier nullptr", which is why the ADR exists.
Restore `NULL` everywhere and give each of the seven files the
file-scoped `NOLINTBEGIN(modernize-use-nullptr)` … `NOLINTEND` bracket
the ADR prescribes, worded as in `core/src/dnn/ort_backend.c` and
`core/src/feature/integer_adm.c`. `psnr_tools.cpp` is C++ and keeps
`nullptr` — ADR-0915's ratchet still covers it in full.
The revert re-opened one finding the keyword rewrite had masked:
`vmaf_dnn_session_open()` is 114 lines against the 60-line
readability-function-size budget. Split it into `resolve_load_path()`
(the ADR-0174 int8 sibling lookup and its fp32 fallback) and
`setup_luma_fast_path()` (the NCHW [1,1,H,W] shape check and scratch
allocation), which also retires the `goto fail` ladder. Behaviour is
unchanged: the same validation order, the same ownership on every error
path, the same -ENAMETOOLONG / -ENOMEM / -ENOTSUP contracts.
Also record the invariant in `core/src/dnn/AGENTS.md` and
`core/src/feature/AGENTS.md`, correct the `docs/rebase-notes.md` bullet
that told a future rebaser to convert upstream `NULL`s to the keyword,
cite `PR #1323` rather than the branch name in the `docs/state.md` row,
and refresh the changelog fragment.
Verified: ninja 0 warnings; `meson test -C bt` 129/129 Ok, 0 Fail
(all 7 dnn tests included); clang-tidy -p bt reports 0 findings on all
nine touched sources; pre-commit clean on every touched file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
refactor/tidy-wave2-dnn-psnr
branch
from
September 6, 2026 09:50
7eba02c to
35ec49c
Compare
lusoris
pushed a commit
that referenced
this pull request
Sep 6, 2026
The wave-2 tidy pass rewrote 90 `NULL`s to the C23 `nullptr` keyword
across seven C translation units (`core/src/dnn/{dnn_api,
dnn_attach_api,model_loader,onnx_scan,op_allowlist}.c`,
`core/src/feature/{float_psnr,integer_psnr}.c`). ADR-1138 settled that
question for C: `Build — Windows MSVC + CUDA (build only)` is a required
status check and compiles these TUs with cl.exe, whose documented
/std:clatest C23 feature set does not include `nullptr`. PR #1192 had to
revert exactly this rewrite after all three Windows legs failed with
"use of undeclared identifier nullptr", which is why the ADR exists.
Restore `NULL` everywhere and give each of the seven files the
file-scoped `NOLINTBEGIN(modernize-use-nullptr)` … `NOLINTEND` bracket
the ADR prescribes, worded as in `core/src/dnn/ort_backend.c` and
`core/src/feature/integer_adm.c`. `psnr_tools.cpp` is C++ and keeps
`nullptr` — ADR-0915's ratchet still covers it in full.
The revert re-opened one finding the keyword rewrite had masked:
`vmaf_dnn_session_open()` is 114 lines against the 60-line
readability-function-size budget. Split it into `resolve_load_path()`
(the ADR-0174 int8 sibling lookup and its fp32 fallback) and
`setup_luma_fast_path()` (the NCHW [1,1,H,W] shape check and scratch
allocation), which also retires the `goto fail` ladder. Behaviour is
unchanged: the same validation order, the same ownership on every error
path, the same -ENAMETOOLONG / -ENOMEM / -ENOTSUP contracts.
Also record the invariant in `core/src/dnn/AGENTS.md` and
`core/src/feature/AGENTS.md`, correct the `docs/rebase-notes.md` bullet
that told a future rebaser to convert upstream `NULL`s to the keyword,
cite `PR #1323` rather than the branch name in the `docs/state.md` row,
and refresh the changelog fragment.
Verified: ninja 0 warnings; `meson test -C bt` 129/129 Ok, 0 Fail
(all 7 dnn tests included); clang-tidy -p bt reports 0 findings on all
nine touched sources; pre-commit clean on every touched file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
refactor/tidy-wave2-dnn-psnr
branch
from
September 6, 2026 18:26
35ec49c to
ffc7cb8
Compare
…ions Clean the psnr bucket of core to the ADR-1142 whole-tree clang-tidy ratchet: - psnr_tools.cpp: designated initialisers for the format table (modernize-use-designated-initializers, 24 warnings). - integer_psnr.c / float_psnr.c: nullptr sentinels; the cross-TU feature-extractor registry symbols carry the ADR-0278 NOLINT citation already used by cambi.c and float_ssim.c. - psnr.c: include its own psnr.h so compute_psnr()'s external linkage is declared, not inferred. Numerically inert: the format table keeps identical peak / psnr_max values and no arithmetic changed.
… presets Clean core/src/dnn/model_loader.c to the ADR-1142 whole-tree clang-tidy ratchet (29 baseline warnings): - vmaf_dnn_sidecar_load (202 lines / 167 statements / 37 branches) is split into sidecar_json_path(), slurp_sidecar_json() and one parse_sidecar_*() helper per sidecar field group. - vmaf_dnn_verify_signature (130 lines / 18 branches) is split into default_registry_path(), resolve_bundle_abs() and run_cosign_verify(). - codec_block_preset_ordinal (105 lines / 127 statements / 40 branches) becomes a table of (encoder family -> preset ordinal) rows; libsvtav1 keeps its numeric parse in svtav1_preset_ordinal(). - vmaf_dnn_codec_block_fill loses a nesting level via lower_copy() and codec_vocab_index(). - extract_string_array / extract_float_array share json_array_begin(). - str_to_lower calls (tolower) parenthesised: glibc's five-level <ctype.h> macro was the only source of the nesting-depth finding. - NULL -> nullptr throughout; the two getenv() call sites carry the ADR-0461 caller-contract NOLINT already used by gpu_dispatch_env.cpp and mcp/compute_vmaf.c. Behaviour-preserving: every helper keeps the original control flow, error codes and float arithmetic (ordinal / 9.0f) of the code it replaces.
…ocation The probe ran `vmaf --tiny-model /dev/null` and looked for the "built without DNN support" diagnostic. That command never reaches the check: configure_tiny_model() in core/tools/vmaf.cpp runs after argument validation and after the inputs are opened, so the bare probe dies on "Reference .y4m or .yuv (-r/--reference) is required". On any -Denable_dnn=disabled build — what the CI CPU/tidy lanes configure, and what 'auto' resolves to without ONNX Runtime — the script therefore continued as if DNN were available and the ADR-0524 NR block exited 1 instead of meson-skipping. The probe now issues an otherwise-valid invocation (--no-reference with the src01_hrc01 fixture as --distorted, --tiny-model /dev/null), which reaches the availability check. DIST_YUV moves up to be the single definition of the fixture path. Verified: VMAF_BIN=core/build/tools/vmaf bash core/test/dnn/test_cli.sh -> "libvmaf built without DNN support; skipping DNN CLI smoke", rc=77 (was rc=1). Closes T-DNN-TESTCLI-PROBE-NEVER-SKIPS-2026-09-05.
extract_string_array() was still 10 lines over the ADR-1142 budget; the per-element parse moves into json_dup_string_elem(). The quote check still runs before the `cnt >= max` check so a malformed element past the cap keeps returning -EINVAL rather than -ERANGE. vmaf_dnn_verify_signature() was still 18 branches; the registry lookup (default path, slurp, bundle lookup, path resolution) moves into lookup_bundle_abs(), leaving the function as bundle -> stat -> cosign. core/src/dnn/model_loader.c now measures 0 clang-tidy warnings.
- changelog.d/changed/tidy-wave2-dnn-psnr.md + regenerated CHANGELOG.md Unreleased block. - docs/rebase-notes.md: the psnr bucket is upstream-mirrored; record the designated-initialiser table, the psnr.h self-include and the nullptr / ADR-0278 NOLINT shape so a future port-upstream-commit does not silently revert them. - core/src/feature/AGENTS.md: same invariants, next to the existing ssim / ms_ssim cross-TU NOLINT note.
scripts/ci/assertion-density.sh flagged the post-split vmaf_dnn_sidecar_load: at 30 lines it is still over the 20-line bar but its precondition asserts had moved into the helpers. Re-assert the two input pointers plus the two intermediate postconditions (non-empty sidecar path, non-null slurped buffer) that the helpers guarantee. scripts/ci/assertion-density.sh: PASS — every fork-added function >=20 lines has >=1 assert (252 asserts / 151 functions, avg 1.67).
The wave-2 tidy pass rewrote 90 `NULL`s to the C23 `nullptr` keyword
across seven C translation units (`core/src/dnn/{dnn_api,
dnn_attach_api,model_loader,onnx_scan,op_allowlist}.c`,
`core/src/feature/{float_psnr,integer_psnr}.c`). ADR-1138 settled that
question for C: `Build — Windows MSVC + CUDA (build only)` is a required
status check and compiles these TUs with cl.exe, whose documented
/std:clatest C23 feature set does not include `nullptr`. PR #1192 had to
revert exactly this rewrite after all three Windows legs failed with
"use of undeclared identifier nullptr", which is why the ADR exists.
Restore `NULL` everywhere and give each of the seven files the
file-scoped `NOLINTBEGIN(modernize-use-nullptr)` … `NOLINTEND` bracket
the ADR prescribes, worded as in `core/src/dnn/ort_backend.c` and
`core/src/feature/integer_adm.c`. `psnr_tools.cpp` is C++ and keeps
`nullptr` — ADR-0915's ratchet still covers it in full.
The revert re-opened one finding the keyword rewrite had masked:
`vmaf_dnn_session_open()` is 114 lines against the 60-line
readability-function-size budget. Split it into `resolve_load_path()`
(the ADR-0174 int8 sibling lookup and its fp32 fallback) and
`setup_luma_fast_path()` (the NCHW [1,1,H,W] shape check and scratch
allocation), which also retires the `goto fail` ladder. Behaviour is
unchanged: the same validation order, the same ownership on every error
path, the same -ENAMETOOLONG / -ENOMEM / -ENOTSUP contracts.
Also record the invariant in `core/src/dnn/AGENTS.md` and
`core/src/feature/AGENTS.md`, correct the `docs/rebase-notes.md` bullet
that told a future rebaser to convert upstream `NULL`s to the keyword,
cite `PR #1323` rather than the branch name in the `docs/state.md` row,
and refresh the changelog fragment.
Verified: ninja 0 warnings; `meson test -C bt` 129/129 Ok, 0 Fail
(all 7 dnn tests included); clang-tidy -p bt reports 0 findings on all
nine touched sources; pre-commit clean on every touched file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
refactor/tidy-wave2-dnn-psnr
branch
from
September 7, 2026 06:57
ffc7cb8 to
55dece8
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
Wave-2 of the epic #1237 ADR-1142 whole-tree clang-tidy ratchet, covering the
core/src/dnn/andcore/src/feature/*psnr*buckets. Nine sources go from 60 measured warnings to 0:model_loader.c29 → 0 (four oversized functions split into named helpers, the per-encoder preset ladder replaced by a lookup table, two ADR-0461-citedgetenvNOLINTs),psnr_tools.cpp24 → 0 (designated initialisers),integer_psnr.c3 → 0,dnn_api.c/onnx_scan.c/float_psnr.c2 → 0 each,dnn_attach_api.c/op_allowlist.c/psnr.c1 → 0 each. Every finding is fixed by refactoring; the only new suppressions reuse an established in-tree citation (ADR-0278 cross-TU registry linkage on the two feature-extractor symbols, ADR-0461 caller-contract on the twogetenvsites, ADR-1138 file-scopedmodernize-use-nullptrbrackets on the seven touched C TUs). Numeric paths are proven inert:--feature psnr --precision=maxon thesrc01_hrc00/src01_hrc01pair is byte-identical before and after once thefpsandversionmetadata lines are excluded, and the Netflix golden gate stays at 271 passed / 12 skipped / 0 failed. The pass also surfaced a real defect:core/test/dnn/test_cli.sh's DNN-availability probe never reached the check it was probing for, so the test failed instead of skipping on every-Denable_dnn=disabledbuild — fixed here and recorded indocs/state.mdasT-DNN-TESTCLI-PROBE-NEVER-SKIPS-2026-09-05.scripts/ci/tidy-baseline-cpu.jsonis deliberately NOT updated here — see the "Baseline" note below. Deferred:core/src/feature/third_party/xiph/psnr_hvs.c(2modernize-use-nullptr) is vendored Xiph code outside the brief'score/src/feature/*psnr*.cscope and is left for the vendored-code wave; the psnr test files (test_psnr_hvs_coverage.c32,test_integer_psnr_coverage.c31, …) belong to the test-tree bucket of the same epic.C translation units keep
NULL(ADR-1138)The first revision of this branch rewrote 90
NULLs to the C23nullptrkeyword across the seven touched.cfiles. That is exactly the rewrite ADR-1138 forbids:Build — Windows MSVC + CUDA (build only)is a required status check, it compiles these translation units withcl.exe, and MSVC's documented/std:clatestC23 feature set does not includenullptr— PR #1192 had to revert the identical rewrite after all three Windows legs failed with "use of undeclared identifier nullptr". Commit35ec49cfcrestoresNULLeverywhere and gives each of the seven files the file-scoped/* NOLINTBEGIN(modernize-use-nullptr) … ADR-1138. */…/* NOLINTEND */bracket the ADR prescribes, worded as incore/src/dnn/ort_backend.candcore/src/feature/integer_adm.c.psnr_tools.cppis C++ and keepsnullptr; ADR-0915's ratchet still covers it in full.The revert re-opened one finding the keyword rewrite had masked —
vmaf_dnn_session_open()at 114 lines against the 60-linereadability-function-sizebudget. It is split intoresolve_load_path()(the ADR-0174 int8-sibling lookup plus its fp32 fallback) andsetup_luma_fast_path()(the NCHW[1,1,H,W]shape check and scratch allocation), which also retires the function'sgoto failladder. Behaviour is unchanged: same validation order, same ownership on every error path, same-ENAMETOOLONG/-ENOMEM/-ENOTSUPcontracts, and all sevendnnmeson tests (includingtest_dnn_session_apiandtest_model_loader) stay green.Baseline — must be tightened from the CI artifact
The 60-warning drop needs
scripts/ci/tidy-baseline-cpu.jsontightened in this PR (ADR-1142 exit 3). That baseline cannot be produced on this workstation:.github/workflows/lint-and-format.ymlmeasures withCC=gcc-14 CXX=g++-14 meson setup build core(build dirbuild/at the repo root), and this machine has no gcc-14 (gcc 16.2.1 / gcc-15 only). A local--writerun therefore produces two classes of false delta on top of the real ones: every generated model TU moves to a different build-dir path, and several C++ TUs the diff never touches drift upward purely from the newer libstdc++ headers. Committing that would encode paths CI never emits and would silently raise the ceiling on untouched files, so the local write is discarded and master's baseline is unchanged. ADR-1142 also forbids hand-editing a baseline.The
Tidy Ratchetjob is expected to exit 3 on the first non-draft run and upload the correct measurement as thetidy-ratchet-cpu.jsonartifact — that file is the baseline to commit, exactly as the workflow step "Upload measurement (commit it as the new baseline when the ratchet asks)" describes, and exactly the flow PR #1192 used. All nine touched files measure 0 locally with clang-tidy 22.1.8 (the version the baseline records), so the CI measurement should show 0 for each of them and no increase anywhere else.Type
refactor— lint-debt cleanup of the dnn + psnr buckets, plus one test-harness bug fix.Checklist
make format-checkgreen;pre-commit run --filesgreen on every touched file (clang-format, markdownlint-cli2, shellcheck, semgrep, copyright, state.md-id and ADR guards).meson test -C bt→ Ok 129 / Fail 0 on a CPU-only-Denable_cuda=false -Denable_sycl=false -Db_lto=falsebuild, andmake VENV=… test-netflix-golden(271 passed / 12 skipped / 0 failed).core/test/dnn/test_cli.shnow correctly reports meson-skip (77) on a DNN-disabled build instead of failing.meson_options.txtentry, feature extractor, backend or output-schema change. The maintainer-facing notes land in the twoAGENTS.mdfiles anddocs/rebase-notes.md.Bug-status hygiene (ADR-0165)
docs/state.md— one new Recently closed row,T-DNN-TESTCLI-PROBE-NEVER-SKIPS-2026-09-05, covering thetest_cli.shprobe defect, its root cause inconfigure_tiny_model()'s position incore/tools/vmaf.cpp, the fix and the rc=77 verification, citingPR #1323.Netflix golden-data gate (ADR-0024)
assertAlmostEqual(...)score in the Netflix golden Python tests.Deep-dive deliverables (ADR-0108)
AGENTS.mdinvariant note —core/src/dnn/AGENTS.md(model_loader lint shape, the ADR-1138NULLbracket, and the test_cli.sh probe contract) andcore/src/feature/AGENTS.md(psnr bucket lint shape + ADR-1138 bracket).changelog.d/changed/tidy-wave2-dnn-psnr.mddocs/rebase-notes.mdentry "core/src/feature/psnr_tools.cpp,psnr.c,integer_psnr.c,float_psnr.c— ADR-1142 tidy ratchet"Reproducer
🤖 Generated with Claude Code