diff options
| author | Scott Gasch <[email protected]> | 2026-10-15 14:43:17 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-10-15 14:43:17 -0700 |
| commit | ac7572166bd24868fcaf5980a91bb82fe61ba677 (patch) | |
| tree | 8c583c3c631690e752d62bff674733358b48d1e2 /src/precommit_check.sh | |
| parent | 993b6eeb2a9ac7b659c473b6883fa53af1ad3a0b (diff) | |
NNUE accumulator struct scaffolding; fix 3 bugs found by DEBUG+TEST; add that gate
Partial checkpoint on the nnue-accumulator-plumbing branch, before the
MakeMove/UnmakeMove hookup itself:
- chess.h: NNUE_ACCUMULATOR struct (256 floats, pre-activation, float32
for now -- quantization to int16 deliberately deferred until a real
quantization-aware export pass exists, per docs/NNUE.md). Added the
live, always-current SEARCHER_THREAD_CONTEXT.sNnueAccum[2] (one per
color) and PLY_INFO.sNnueAccumBackup (the king-move full-recompute
backup slot, DEBUG-only color tag declared for a later ASSERT).
LIGHTWEIGHT_SEARCHER_CONTEXT also mirrors sNnueAccum[2] at the same
relative position -- omitting that broke its byte-compatible-prefix
contract with the full context the moment MakeMove/UnmakeMove will
start touching it unconditionally (caught by this session's own
TestSan self-test failure).
- Combining DEBUG=1 and TEST=1 for the first time (apparently ever)
while chasing that failure immediately turned up three more real,
pre-existing bugs, all in self-test-only code whose assert-guarded
invariants had never been checked with asserts actually compiled in:
- board.c: IsBoardLegal now rejects an en passant square whose rank
doesn't match the side to move (and verifies the double-moved
pawn/empty origin square), closing a gap VALID_EP_SQUARE alone
can't catch.
- testgenerate.c: TestCapturesAndPromotionsGenerator's fixture table
had a self-contradictory FEN this new IsBoardLegal check would
have caught; replaced with a genuine Black-to-move en passant
position.
- testgenerate.c: TestFindUnblockedSquaresSpeed called
_GenerateAllMoves directly instead of the GenerateMoves wrapper,
skipping the DEBUG-only pStack->board[uPly] snapshot
WouldGiveCheck's own ASSERT checks against.
- precommit_check.sh / CLAUDE.md: added the DEBUG=1 TEST=1 combination
as a permanent third pre-commit gate, given what its first-ever run
turned up. Real cost (~235s of ~266s total, unoptimized build
dominates), judged worth it.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/precommit_check.sh')
| -rwxr-xr-x | src/precommit_check.sh | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/precommit_check.sh b/src/precommit_check.sh index c2d7d41..0525765 100755 --- a/src/precommit_check.sh +++ b/src/precommit_check.sh @@ -1,5 +1,6 @@ #!/bin/sh -# Pre-commit build/test gate: TEST=1 self-test suite + DEBUG=1 random-sample +# Pre-commit build/test gate: TEST=1 self-test suite + a combined +# DEBUG=1 TEST=1 self-test (asserts live) + DEBUG=1 random-sample # smoke test (debug_smoke_test.sh). Restores a normal release build # afterward so the working directory isn't left with a TEST/DEBUG-flavored # binary as a side effect of running this. @@ -16,7 +17,7 @@ mkdir -p "$LOGDIR" FAIL=0 TOTAL_START=$(date +%s) -echo "=== [1/3] Self-test build (gmake TEST=1) ===" +echo "=== [1/4] Self-test build (gmake TEST=1) ===" STEP_START=$(date +%s) gmake clean > "$LOGDIR/clean_test.log" 2>&1 gmake -j5 TEST=1 GENETIC=1 SIXTYFOUR=1 > "$LOGDIR/build_test.log" 2>&1 @@ -36,7 +37,35 @@ fi STEP_END=$(date +%s) echo " [$((STEP_END - STEP_START))s]" -echo "=== [2/3] DEBUG smoke test (10 random ECM positions, sd 4) ===" +# 2026-10-15: added after combining DEBUG=1 and TEST=1 for the first +# time (ever, as far as anyone could tell) turned up three real, +# previously-undiscovered bugs in a single run -- none in production +# code, all in self-test-only harnesses whose assert-guarded invariants +# had apparently never been checked with asserts actually compiled in +# (plain TEST=1 has no DEBUG, so ASSERT is a no-op; DEBUG=1 alone never +# links the self-test .o files at all). Unoptimized, so this step is +# the slow one -- budget a couple of minutes, not seconds. +echo "=== [2/4] Combined self-test build (gmake DEBUG=1 TEST=1) ===" +STEP_START=$(date +%s) +gmake clean > "$LOGDIR/clean_debugtest.log" 2>&1 +gmake -j5 DEBUG=1 TEST=1 GENETIC=1 > "$LOGDIR/build_debugtest.log" 2>&1 +if [ $? -ne 0 ]; then + echo " BUILD FAILED -- see $LOGDIR/build_debugtest.log" + FAIL=1 +else + ./_typhoon --batch --command "" > "$LOGDIR/test_run_debugtest.log" 2>&1 + STATUS=$? + if [ "$STATUS" -ne 0 ] || grep -qi "assertion failure\|PANIC" "$LOGDIR/test_run_debugtest.log"; then + echo " SELF-TEST FAILED (exit=$STATUS) -- see $LOGDIR/test_run_debugtest.log" + FAIL=1 + else + echo " self-test passed" + fi +fi +STEP_END=$(date +%s) +echo " [$((STEP_END - STEP_START))s]" + +echo "=== [3/4] DEBUG smoke test (10 random ECM positions, sd 4) ===" STEP_START=$(date +%s) gmake clean > "$LOGDIR/clean_debug.log" 2>&1 gmake -j5 GENETIC=1 DEBUG=1 MP=1 SIXTYFOUR=1 > "$LOGDIR/build_debug.log" 2>&1 @@ -50,7 +79,7 @@ fi STEP_END=$(date +%s) echo " [$((STEP_END - STEP_START))s]" -echo "=== [3/3] Restoring normal release build (GENETIC=1 PERF_COUNTERS=1 MP=1 SIXTYFOUR=1) ===" +echo "=== [4/4] Restoring normal release build (GENETIC=1 PERF_COUNTERS=1 MP=1 SIXTYFOUR=1) ===" STEP_START=$(date +%s) gmake clean > "$LOGDIR/clean_release.log" 2>&1 gmake -j5 GENETIC=1 PERF_COUNTERS=1 MP=1 SIXTYFOUR=1 > "$LOGDIR/build_release.log" 2>&1 |
