Skip to content

refactor(core): bring core C and C++ test suite batch A to the lint and HISS standard (ADR-1142) - #1767

Merged
lusoris merged 3 commits into
masterfrom
refactor/std-core-tests-a
Oct 1, 2026
Merged

lusoris merged 3 commits into
masterfrom
refactor/std-core-tests-a

Conversation

@lusoris

@lusoris lusoris commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors 10 core C and C++ test sources under core/test (test_barten_csf.c, test_psnr_hvs_simd.c, test_propagate_metadata.c, test_thread_pool.c, test_context.c, test_predict.c, test_ciede.c, test_pic_preallocation.c, test_locale_handling.c, test_dict.cpp) to zero clang-tidy findings in the CPU lane under ADR-1142 (-182 baseline findings across these files). Functions exceeding branch, nesting, and statement thresholds were split into modular helpers satisfying HISS-04 / NASA JPL Rule 4, removing 2 recorded debt infractions from .standards-baseline.json (365 -> 363). C23 nullptr diagnostics in C files are scoped under ADR-1138 to maintain MSVC C portability, and test_dict.cpp uses anonymous namespaces and standard nullptr. All 10 tests continue to pass.

Files Touched & Findings Delta

  • core/test/test_barten_csf.c: 38 -> 0 (cpu lane), HISS-04 resolved (-1 baseline row)
  • core/test/test_psnr_hvs_simd.c: 24 -> 0 (cpu lane), HISS-04 resolved (-1 baseline row)
  • core/test/test_propagate_metadata.c: 10 -> 0 (cpu lane)
  • core/test/test_thread_pool.c: 14 -> 0 (cpu lane)
  • core/test/test_context.c: 16 -> 0 (cpu lane)
  • core/test/test_predict.c: 10 -> 0 (cpu lane)
  • core/test/test_ciede.c: 20 -> 0 (cpu lane)
  • core/test/test_pic_preallocation.c: 16 -> 0 (cpu lane)
  • core/test/test_locale_handling.c: 21 -> 0 (cpu lane)
  • core/test/test_dict.cpp: 33 -> 0 (cpu lane)

Total tidy findings reduced: 202 -> 0 across touched files.
Total HISS rows removed: 2 rows. Baseline: 365 -> 363.

Type

  • refactor — no behavior change

Checklist

  • Commits follow Conventional Commits (the commit-msg hook enforces this).
  • make format && make lint is green locally: pre-commit on every changed file; praetorctl audit passes.
  • Unit tests pass: python3 scripts/ci/run_meson_test.py -- -C build test_barten_csf test_psnr_hvs_simd test_propagate_metadata test_thread_pool test_context test_predict test_ciede test_pic_preallocation test_locale_handling test_dict.
  • If I touched any SIMD/GPU code path, I ran /cross-backend-diff: not applicable, test harness only.
  • If I touched a feature extractor with SIMD/GPU twins, I either updated every twin or listed the gap: not applicable.
  • If I added a new .c / .cpp / .cu / .h / .hpp, it has the appropriate license header: headers confirmed present.
  • If this is a breaking change, the commit message uses ! or BREAKING CHANGE:: not breaking.
  • If this PR adds an ADR, the ADR row lives in docs/adr/_index_fragments/: no ADR; applies existing ADR-1142.

Bug-status hygiene (ADR-0165)

  • no state delta: test suite standards audit batch A (ADR-1142)

Netflix golden-data gate (ADR-0024)

  • I did not modify any assertAlmostEqual(...) score in the Netflix golden Python tests.
  • If I believe a golden value must change, I have explained why below: not applicable.

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: mechanical standards refactor under ADR-1142.
  • Decision matrix — no alternatives: only-one-way fix.
  • AGENTS.md invariant note — no rebase-sensitive invariants: internal test file refactoring.
  • Reproducer / smoke-test command — python3 scripts/ci/run_meson_test.py -- -C build test_barten_csf test_psnr_hvs_simd test_propagate_metadata test_thread_pool test_context test_predict test_ciede test_pic_preallocation test_locale_handling test_dict
  • CHANGELOG fragment — changelog.d/changed/std-core-tests-a.md
  • Rebase note — no rebase impact: internal test helper extraction.

lusoris and others added 3 commits October 1, 2026 22:43
…it-identical (#1734)

* fix(cuda): compute float_adm in the CPU's arithmetic so the twin is bit-identical

float_adm_cuda matched the CPU extractor on 144 of 791 measured scores
and was up to 1.3e-5 from it (adm_scale0 at 3840x2160). An exact twin
was built first and the old constructs were put back one at a time; all
of them together give the old twin's output bit for bit. Sizes alone:

- the angle test's threshold as cos^2 * (|o|^2 * |t|^2), where
  adm_angle_flag_s() evaluates (cos^2 * |o|^2) * |t|^2 (1.3e-5);
- each row reduced per tile and the rows added in fp64, where
  adm_csf_den_scale_s() and adm_cm_s() add a row into one float and the
  rows into another (4.4e-7);
- CSF weights from a host copy of dwt_quant_step() with fp32
  intermediates, four of eight default weights 1 to 3 ulp off (2.1e-7);
- t / (o + eps), where the x86 CPU multiplies by rcp_s(), a Newton step
  on the processor's RCPSS estimate (1.3e-7);
- the masking threshold's centre taps after its neighbours, where
  adm_cm_thresh3x3_s() adds the centre fifth in one sum per band
  (9.4e-8);
- fp32 1/15 and 1/30 where the CPU's are double literals (7.2e-8,
  1.5e-10), and an fp32 gain limit (1.0e-7 at 1.2);
- the frame sums floored at 1e-2 * area / 1080p where compute_adm()
  uses 1e-10: adm2 = 1 instead of the CPU's 0 on a flat 16-bit frame
  with one raised sample and adm_noise_weight=0.

ADR-1420:

- cuda/float_adm/float_adm_device.h holds the decouple, the CSF, the
  threshold and the reduction terms of adm_tools.c operation for
  operation, with explicit round-to-nearest intrinsics on the device;
  the host compiles it for a test.
- RCPSS is specified by an error bound, so the reference's quotient
  belongs to the host processor. adm_reciprocal_model_probe() fills a
  4096-entry table from the instruction and proves the model against it
  (9.4 ms at extractor start); the decouple kernel evaluates it in
  integer arithmetic. A CPU build that divides (MSVC, ARM) makes the
  twin divide.
- float_adm_terms stores nine terms per sample of the reduced region,
  float_adm_row_sums adds each row in one thread, the host adds the
  rows.
- adm_tools.c exports its reduced region, CSF weights, angle constant
  and reciprocal estimate (adm_float_reference.h), and four of its
  reductions call the exported adm_pool_bands_s() instead of repeating
  it. CPU scores are unchanged (4 752 outputs).
- EXACT_TWINS lists float_adm / cuda: the gate cell is an equality.

Measured on an RTX 4090 at --precision max against master 5c8b9e9,
identical scores before and after: Netflix 576x324 8-bit 66/336 and
336/336, 10-, 12- and 16-bit 2/21 and 21/21, checkerboard 1 px 2/21 and
21/21, 10 px 4/21 and 21/21, BBB 3840x2160 66/350 and 350/350; 658 and
2034 of 2034 with debug=true, also with clang's CUDA driver and with
non-default gain limit, bypass, noise weight and viewing geometry. Not
identical: adm_p_norm other than 1 or 3, within 1.1e-7 (device powf).
A run of the twin alone takes 1.87 and 1.98 ms per 4K frame; its
kernels take 0.76 and 1.11 ms
(T-CUDA-FLOAT-ADM-EXACT-THROUGHPUT-2026-10-01).

Found on the way and recorded: the SYCL, HIP and Metal twins carry the
same arithmetic and floor (T-GPU-FLOAT-ADM-CPU-ARITHMETIC-2026-10-01,
T-GPU-FLOAT-ADM-FRAME-SUM-FLOOR-2026-10-01); the CPU's float ADM
depends on the processor through RCPSS
(T-FLOAT-ADM-RECIPROCAL-ESTIMATE-HOST-DEPENDENT-2026-10-01), reads
outside its bands below 17x17
(T-FLOAT-ADM-TINY-FRAME-BAND-READS-2026-10-01) and files its debug
ratio under an unsuffixed key
(T-FLOAT-ADM-DEBUG-KEY-UNSUFFIXED-2026-10-01).

Tests: test_cuda_float_adm_parity asserts equality over 15 cases, each
of which fails on the old twin; test_float_adm_device_math compares the
header with the CPU routines and the reciprocal model with the
instruction on the host; test_cuda_float_adm_exact_contract.py pins the
design.

* docs: regenerate the indexes and the citation map after rebasing
* chore(deps): Update dependency openai to >=3.22.1

* chore(deps): regenerate dev-llm lock for openai >=3.22.1

* docs: regenerate the indexes and the citation map after rebasing
…nd HISS standard (ADR-1142) (#1767)

* test(core): refactor test_barten_csf for standards and HISS compliance

* test(core): refactor test_psnr_hvs_simd for HISS modularity

* test(core): refactor test_propagate_metadata for standards compliance

* test(core): refactor test_thread_pool for standards compliance

* test(core): refactor test_context for standards compliance

* test(core): refactor test_predict for standards compliance

* test(core): refactor test_ciede for standards compliance

* test(core): refactor test_pic_preallocation for standards compliance

* test(core): refactor test_locale_handling for branch and locale hygiene

Add SPDX license identifier, wrap test TU in ADR-0141 and ADR-1138 NOLINT
brackets, extract output verification and tmpfile helpers to satisfy
branch complexity limits, and replace rewind with checked fseek.

* test(core): refactor test_dict for anonymous namespaces and branch hygiene

Add SPDX license identifier, replace NULL with nullptr, move test functions
into discrete anonymous namespaces to stay within HISS-04 60-line block budgets,
and simplify assertions into modular helpers to satisfy branch complexity limits.

* test(core): flatten inner 8x8 block loop in test_psnr_hvs_simd

Flatten nested i and j block loops into a single k loop to remain within
the nesting depth threshold 4 without altering floating-point accumulation.

* chore(ci): tighten CPU tidy and HISS debt baselines for batch A

Record updated debt ratchets for 10 core test TUs in tidy-baseline-cpu.json
and decrement active infractions by 2 in .standards-baseline.json and README.md.
Add changelog fragment for std-core-tests-a and update CHANGELOG.md.

* docs: regenerate the indexes and the citation map after rebasing
@lusoris
lusoris force-pushed the refactor/std-core-tests-a branch from bff64ac to c24d5bd Compare October 1, 2026 20:57
@lusoris
lusoris merged commit c24d5bd into master Oct 1, 2026
58 of 71 checks passed
@lusoris
lusoris deleted the refactor/std-core-tests-a branch October 1, 2026 20:57
@github-actions github-actions Bot added the type:refactor Internal refactor label Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:refactor Internal refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant