Commit fdcf185a by PLN (Algolia)

test(boot): check-boot now RUNS the helpers against an empty control map (#55)

PLN asked what tooling would have caught tonight's mute-bomb. Honest answer:
nothing we had, and not tidal-ears — it analyses audio, and this bug produced
SILENCE. Silence is indistinguishable from silence no matter how well measured.
The defect was symbolic: a pattern emitting zero events.

Typechecking could not catch it either. `gF1 $ sound "bd"` is perfectly
well-typed while producing NO EVENTS, because an untouched "^NN" yields nothing
and `#` cannot emit without a right-hand value. Pass 1 of this script was green
throughout the entire outage.

The missing capability was the ability to ask one question mechanically:
"what does this helper do with an EMPTY control map?" — i.e. on a fresh boot,
before any knob has moved. That is now pass 3: it extracts the helper block,
appends assertions, compiles, and RUNS them, checking that each of gF1/gF2/gF3,
gMask, gMute1-3, gM1-3, gPanic, midiGdef and a composed gF1.gM2 stack all emit
events with `State (Arc 0 1) M.empty`.

It is a real execution rather than a typecheck, but pure pattern evaluation
only: no stream, no scsynth, no MIDI, no port binding. Safe to run mid-set.

Verified in BOTH directions, which is the whole point:
  - current BootTidal.hs        -> 13/13 audible, exit 0
  - orDef guards stripped out
    (i.e. the pre-3685c743 code) -> 11 FAILs naming each silent helper, exit 1

That negative test also confirmed something useful about the shape of the bug:
gPanic and midiGdef stayed audible even with the guards stripped, because they
route through `range`/arithmetic that survives an empty map differently from
`#`. So a partial fix would have looked partially fine — exactly the kind of
half-green result that lets a bug like this hide for months.

Turns the ad-hoc Haskell probe written during the incident into a permanent
regression test. This bug class has now bitten three times (#21 djfbus, #48's
one-directional filters, #55's untouched-control silence); pass 3 is the first
thing that would have caught any of them before a boot.
parent 3685c743
......@@ -97,6 +97,82 @@ if [ -n "$SEED_START" ]; then
exit 1
fi
echo "check-boot: OK — #55 control-seed block typechecks."
# --- Pass 3: RUN the helpers against an EMPTY control map (#55) ----------
# The regression test that tonight's bug needed and nobody had. Typechecking
# cannot catch it: `gF1 $ sound "bd"` is perfectly well-typed while emitting
# ZERO events, because an untouched "^NN" yields nothing and `#` cannot emit
# without a right-hand value. The only mechanical check is to QUERY the
# pattern with no controls set and assert events come out.
#
# This is a real execution, not a typecheck — but it is pure pattern
# evaluation: no stream, no scsynth, no MIDI, no ports. Safe mid-set.
{
echo '{-# LANGUAGE OverloadedStrings #-}'
echo '{-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing -Wno-type-defaults #-}'
echo 'module Main where'
echo 'import Sound.Tidal.Context'
echo 'import qualified Data.Map.Strict as M'
echo 'import System.Exit (exitFailure)'
echo 'import Data.IORef'
echo 'p :: Int -> ControlPattern -> IO ()'
echo 'p = undefined'
echo 'setI :: String -> Pattern Int -> IO ()'
echo 'setI = undefined'
sed -n "${START},${END}p" "$BOOT" | sed -e '1s/^let //' -e 's/^ //'
cat <<'HS'
-- Query with a DELIBERATELY EMPTY controls map: the state of a fresh boot
-- before any knob has been moved.
audible :: String -> ControlPattern -> IORef Bool -> IO ()
audible label pat failed = do
let evs = query pat (State (Arc 0 1) M.empty)
if null evs
then do putStrLn (" FAIL " ++ label ++ " -> SILENT with an empty control map")
writeIORef failed True
else putStrLn (" ok " ++ label ++ " -> " ++ show (length evs) ++ " event(s)")
main :: IO ()
main = do
failed <- newIORef False
putStrLn " (untouched-control audibility, #55)"
mapM_ (\(l, f) -> audible l (f (sound "bd")) failed)
[ ("gF1 ", gF1), ("gF2 ", gF2), ("gF3 ", gF3)
, ("gMask ", gMask)
, ("gMute1", gMute1), ("gMute2", gMute2), ("gMute3", gMute3)
, ("gM1 ", gM1), ("gM2 ", gM2), ("gM3 ", gM3)
, ("gPanic", gPanic)
]
-- Gain paths: silent here means the global fader zeroes the whole rig.
audible "midiGdef" (sound "bd" # midiGdef) failed
-- A composed stack is the realistic shape a track actually uses.
audible "gF1.gM2 " (gF1 (gM2 (sound "bd"))) failed
bad <- readIORef failed
if bad then exitFailure else return ()
HS
} > "$WORK/RunCheck.hs"
set +e
ROUT="$(ghc -package tidal -package containers -o "$WORK/runcheck" \
-outputdir "$WORK/out" "$WORK/RunCheck.hs" 2>&1)"
RRC=$?
set -e
if [ "$RRC" -ne 0 ]; then
echo "" >&2
printf '%s\n' "$ROUT" | sed "s#$WORK/RunCheck.hs#<run-check>#" >&2
echo "check-boot: FAIL — could not build the untouched-control test." >&2
exit 1
fi
set +e
"$WORK/runcheck"
RUNRC=$?
set -e
if [ "$RUNRC" -ne 0 ]; then
echo "check-boot: FAIL — helpers go SILENT with an untouched controller." >&2
echo " This is the #55 mute-bomb. Streams will have no sound on" >&2
echo " a fresh boot until every knob is physically moved." >&2
exit 1
fi
echo "check-boot: OK — all g* helpers audible with an untouched controller."
else
echo "check-boot: WARN — no #55 control-seed block found (untouched knobs" >&2
echo " will silence their streams; see BootTidal.hs history)." >&2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment