startup: add bounded per-reason refusal census per pipeline key #2293
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2301"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T10:55:48Z.
Summary
Refs #2274 (Part B: Per-reason refusal census).
Adds a standalone, lock-protected per-
(key, reason)refusal census insrc/startup_stubs/per_reason_refusal_census.hso multiple refusal reasons on the same pipeline key are counted independently rather than overwriting earlier reasons with the last refusal.PerReasonRefusalCensus: bounded table (max_entries = 128, sanitized 64-byte reason buffer,detail_entries = 8first-seen hint, overflow accounting past the cap) usingstd::mutex.report(emit, only_if_changed)): skips unchanged periodic reports, prints only changed(key, reason)entries on periodic ticks, and keeps delta tracking intact across forced reports.tests/startup_per_reason_refusal_census_check.cpp+ CMake/CTest registration: tests interleaved multi-reason counts on two keys, reason normalization/sanitization, detail/overflow limits, periodic deltas, and twoWILL_FAILcontrols compiled against the realPerReasonRefusalCensusclass (-DX2W_CENSUS_KEEP_LASTand-DX2W_CENSUS_KEEP_FIRST) that print both expected reasons with their counts on mismatch.docs/startup-runtime.md: documents the standalone header, its limits, and its test command.Ready to wire directly into runtime refusal callers (such as slot-67 compute dispatch and binding) once the preceding Part B dispatch PRs land.
Verification
Commit
55ab0dec4d016604f3525354ad5a64e3dbe5a26con Windows 11 (26200.9974, MSVC19.44.35228.0):devCTest (startup_memory_srv_census,startup_per_reason_refusal_census,startup_per_reason_refusal_census_keep-last_control,startup_per_reason_refusal_census_keep-first_control): 4/4 passed.release(/O2) CTest: 4/4 passed.docs_links_check.py: passed (18 Markdown files, 437 links).bidi_controls_check.py: passed (1586 tracked files).form_coverage_check.py: passed.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:58:20Z.
Review: COMMENTED
Review of head
d1be384d0dff79b18c6f71a1a3a10dc976f1b4ce(4 files, +366).Verdict: logic is correct; one test-quality P2 and a few nits. No P1.
Commands executed locally (Linux, g++ -std=c++17 -Wall -Wextra):
g++ -std=c++17 -Wall -Wextra -Isrc tests/startup_per_reason_refusal_census_check.cpp-> no warnings; run printsPASS (distinct keys=2, pairs=4, detail=8, max=128).--mutate keep-last-> exit 1 (FAIL key2 keeps interleaved missing_root with calls=1, 5 checks); controls fail as intended.git checkout -- .:reported_ = total_made unconditional (forced report eats the periodic delta) -> killed (forced report does not hide next periodic delta).++distinct_keys_-> killed (summary line mismatch).python3 tests/docs_links_check.py-> pass (18 files, 437 links).python3 tests/bidi_controls_check.py-> pass.git diff --check origin/main...HEAD-> clean.Windows jobs were still pending at review time. This is header-only and device-free, so I did not queue a WARP/GPU run.
P2
tests/startup_per_reason_refusal_census_check.cpp:~70-105: thekeep-last/keep-firstcontrols do not exercisePerReasonRefusalCensus. They rebuild a fake single-slot table in the test and overwriteobserved, so they would fail whatever the header does. They prove the assertions are strict, but not that the header regresses visibly. The real-header mutations above are killed by the main run, so coverage is fine. Either say in the CMake comment and docs that the controls are simulated, or drop them in favor of a compile-time-DX2W_CENSUS_KEEP_LASTstyle mutation of the real class.Nits
2.
per_reason_refusal_census.h:50:memcpy(entry.reason, reason, sizeof(reason))copies uninitialized bytes after the NUL. Usestrcpyor zero-initreason[] = {}(valgrind/MSan noise only).3. Header is not included by any production code yet; the PR text says wiring follows. Fine, but the doc section may be read as "wired".
4.
note()linear scan is O(128) under the mutex per refusal; fine for a refusal path, worth a comment if it ever lands on a hot path.5. PR body has stray escape glitches (
\report,\tests, a leading BOM, unfencedpowershell). Cosmetic.6. Title and body are neutral; clean-room and MIT constraints look fine; mergeable.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T11:04:29Z.
Addressed the P2 and nits in
55ab0dec4d016604f3525354ad5a64e3dbe5a26c:tests/startup_per_reason_refusal_census_check.cppand added compile-timeX2W_CENSUS_KEEP_LAST/X2W_CENSUS_KEEP_FIRSTcontrol targets inCMakeLists.txtso bothWILL_FAILcontrols exercisePerReasonRefusalCensusdirectly (keep-lastfails 7 checks,keep-firstfails 6 checks, each printing both expectedkey1reasons with counts alongside the observed output).char reason[max_reason_bytes] = {};innote()beforecopy_sanitized()somemcpynever copies uninitialized tail bytes.docs/startup-runtime.mdthatPerReasonRefusalCensusis currently a standalone header/check not yet wired intod3d12_xs_device.cppor the five-second report.mutex_.Re-verified on Windows 11 (
devandrelease/O2presets: 4/4 CTest cases passed;docs_links_check.py,bidi_controls_check.py, andform_coverage_check.pypassed).