Audit script (audit-rust-consts.sh) scans Rust src/examples for numeric
literals mirroring structural kernel-side consts (N_ACTIONS, Q_N_ATOMS,
HIDDEN_DIM, MAX_UNITS, BOOK_LEVELS). Closes the layer-3 gap noted in
feedback_use_consts_not_literals_for_structural_dims:
Layer 1: kernel `#define` allowlist → audit-isv
Layer 2: Rust `pub const` canonical → exists (e.g. N_ACTIONS in rl/common.rs)
Layer 3: Rust literals mirroring (2) → audit-rust-consts (this commit)
Honors `// audit-ignore: <SYMBOL>` per-line markers and skips `[u8; N]`
byte-buffer patterns (high false-positive class — almost always I/O
scratch, not structural dims).
Cleanup driven by first run (19 real flags, no grandfathering):
* New canonical: `BOOK_LEVELS` in `ml-alpha/src/cfc/snap_features.rs`
(10 book levels = same place as `Mbp10RawInput` struct)
* `ml-backtesting/src/lob/mod.rs`: redefine as `pub use` re-export from
ml-alpha (single source of truth; ml-backtesting depends on ml-alpha
via `Mbp10RawInput` already)
* 19 sites switched literal `10` → `BOOK_LEVELS`:
- snap_features.rs:44-47 (struct fields)
- data/loader.rs:872-876, 960 (Mbp10Snapshot → Mbp10RawInput convert)
- data/aggregation.rs:161 (level-wise aggregation loop)
- trainer/perception.rs:2750-2756, 6272-6278, 6686-6690, 7247-7253
(snapshot → batch staging loops)
- tests/lob_sim_fuzz.rs:21, lob_sim_integrated_fuzz.rs:22 (duplicate
const → use ml_backtesting::lob::BOOK_LEVELS)
* 5 sites marked `// audit-ignore: BOOK_LEVELS — <reason>`:
- harness.rs:572,574,594 (conviction-bucket histograms, 10 ≠ depth)
- multi_horizon_labels.rs:489,557,564 (10-element test price vecs)
Re-run after fixes: 0 suspect literals flagged. PASS.
Audit manifest
Tracks names of newly-added artifacts so the three audit scripts
(scripts/audit-isv.sh, scripts/audit-wiring.sh,
scripts/audit-diag.sh) can verify ISV-residency, wiring, and
diagnostic exposure on every commit.
These manifests are SP-agnostic — they hold the cumulative set of "things introduced by the active development line" that downstream ship gates audit. SP20 starts the convention; future SPs extend it.
Files
kernels.txt— one new .cu kernel basename per line (e.g.rl_trail_mutate)slots.txt— one new RL_*_INDEX constant name per line (e.g.RL_TRAIL_ADJUST_RATE_INDEX)heads.txt— one new head module name per line (e.g.frd)actions.txt— one new Action enum entry per line (e.g.HalfFlatLong)diag-fields.txt— one new diag JSONL field path per line, jq-syntax (e.g..units.unit_count,.trail.fired_count_step)
Workflow per phase commit
- Implement the phase (new kernel / slot / head / action / diag field)
- Append the names to relevant manifest files
- Run
scripts/audit-isv.sh— must report 0 violations - Run
scripts/audit-wiring.sh— must report 0 violations - Run
scripts/audit-diag.sh— must report 0 missing fields - Commit (the manifest append + the code in the same commit)
Failures are immediately actionable — no "iterate within scope" softness. Per SP20 spec §0.4.