Files
Sylpheed/tools/port/check-capture-controls
MechaCat02 c3758e3850 port: land the play-tested work, and only that
Takes the port branch up to 77320d5e -- the state the human play-tested on
2026-09-02 -- for SOURCE paths only. Not a branch merge: `auto/port-p6-audio`
is 366 commits and 938 files, and most of that must not land.

WHAT COMES IN (76 files, all human-confirmed working):
  * the logo splash animation. 08ed3dd1 found it: `pose_at` ASSIGNED the settle
    instant instead of clamping to it, so the splash never animated at all --
    and the same bug manufactured a passing harness result, because the harness
    photographed t past the settle. Confirmed by play-test: "cannot notice any
    obvious difference from the actual game."
  * gamepad input -- (A)/(B) bound additively (`ui_accept` ships with NO joypad
    binding), stick latched with hysteresis at the game's own 61% digitise
    threshold. This is what made (A), video-skip and Extras work at all.
  * menu navigation and flow, menu audio, the exporter, the authored
    declarations, and 23 verification tools under tools/port/.

WHAT IS DELIBERATELY LEFT ON THE BRANCH:
  * everything after c0ae460a -- the F5/F6 title-timing investigation, whose own
    tip commit calls itself a "hand-off for one-minute human checks". Unchecked
    by definition; it goes through the new review gate like anything else.
  * the OPTIONS menu work of 2026-09-03. Real, probably good, NOT play-tested.
  * the F1 repeat mechanism, which its own commit calls "deliberately inert".

WHAT MUST NOT LAND, AND WHY THE .gitignore CHANGED:
  545 MB of extracted game content was committed on that branch -- 850 sprite,
  audio and transcoded video files under `export-probe/` and `export-probe2/`,
  plus 246 MB of loose .wav and .tsv at the repo root. This repository's own
  rule, in this file, is "never game content".

  The rule was not missing. It was written, and it was tightened on that very
  branch, with a careful comment explaining why BOTH `export/` and `data/base/`
  had to be listed -- while the exporter was writing to a third name that
  nobody had thought to list. Enumerating names is the thing that failed. So
  the ignore rules now describe the SHAPE: any top-level `export*/`, game media
  by extension, and loose capture output at the root. Verified both ways -- it
  catches all four offenders and ignores nothing currently tracked.

Verified: `cargo check --workspace` clean; all nine GDScript files parse in
project context, with a positive control (an injected syntax error is detected,
3 lines) so the clean result means something. `tools/port/check-all` was NOT
run -- it needs the container, the export tree and a display.
2026-09-04 16:17:14 +02:00

132 lines
7.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run `check-capture` against its own documented control sweep.
#
# tools/port/check-capture-controls
#
# `AUDIO-VERIFICATION.md` calls that sweep **"the tool's real specification"**
# and prints it as a table. Nothing executed it. So the specification was prose:
# if `check-capture` regressed, or if a threshold drifted, no run would have said
# so -- and this is a tool whose own history is two invented thresholds that were
# both wrong and were caught only by controls.
#
# 🔴 The same document states the principle this violates: **"A control that does
# not execute is not a control."** It was written about a mono file that skipped
# its own check. The sweep as a whole was in exactly that condition.
#
# ⚠️ One control CANNOT be rebuilt: the starved capture itself was a transient
# artifact and is gone. It is reported as MISSING rather than omitted, because a
# sweep that quietly drops a control is the defect it exists to catch.
set -euo pipefail
cd "${PROJECT_DIR:-/work}"
W="${TMPDIR:-/tmp}/capture-controls"; mkdir -p "$W"
CC=tools/port/check-capture
fail=0
# `check-capture` emits TWO verdicts -- one for channel provenance, one for
# starvation -- and `AUDIO-VERIFICATION.md`'s table compresses them into a word.
# That is fine for a summary and wrong for an assertion: the voice control is
# `PASS` on channels and `UNJUDGED` on starvation *by design*, and a sweep that
# collapsed those could not tell "passed" from "declined to judge". So both are
# reported, and a control names the pair it expects.
verdict() { # file -> "<channels>/<starvation>"
local out ch st
out=$("$CC" "$1" 2>&1 || true)
if grep -q '^PARTIAL' <<<"$out"; then echo "PARTIAL/PARTIAL"; return; fi
# A starved file SHORT-CIRCUITS: the tool reports the starvation and never
# reaches the channel check, which is right -- channel provenance is moot in a
# recording with holes punched through it. Reported as `n/a`, not as a failure:
# "the check did not run" and "the check failed" are different facts, and
# collapsing them is how a sweep starts asserting things it never observed.
if grep -qi 'no duplicated channels' <<<"$out"; then ch=PASS
elif grep -qi 'BYTE-IDENTICAL' <<<"$out"; then ch=FAIL
else ch=n/a; fi
if grep -q 'UNJUDGED' <<<"$out"; then st=UNJUDGED
elif grep -qi 'starv\|holes\|FAIL' <<<"$out"; then st=FAIL
else st=PASS; fi
echo "$ch/$st"
}
expect() { # name, file, wanted
local got; got=$(verdict "$2")
if [ "$got" = "$3" ]; then printf ' %-42s %-8s ok\n' "$1" "$got"
else printf ' %-42s %-8s 🔴 EXPECTED %s\n' "$1" "$got" "$3"; fail=1; fi
}
# Six distinct tones -- the duplicate-channel control. Frequencies chosen so no
# two channels share one, which is what the provenance check looks for.
ffmpeg -v error -y -f lavfi -i "sine=frequency=400:duration=6" \
-f lavfi -i "sine=frequency=800:duration=6" -f lavfi -i "sine=frequency=200:duration=6" \
-f lavfi -i "sine=frequency=1600:duration=6" -f lavfi -i "sine=frequency=3200:duration=6" \
-f lavfi -i "sine=frequency=6400:duration=6" \
-filter_complex "[0:a][1:a][2:a][3:a][4:a][5:a]join=inputs=6:channel_layout=5.1[a]" \
-map "[a]" -c:a pcm_s16le "$W/tones.wav"
ffmpeg -v error -y -i "$W/tones.wav" -c:a pcm_f32le "$W/tones_f32.wav"
# A real music+SFX bed: six channels of REAL material, one per channel.
#
# 🔴 The first version of this control was `-ac 6` from the stereo bed, and it
# FAILED -- correctly. An upmix leaves channels 2-5 silent and byte-identical,
# which is exactly what the provenance check exists to catch, so the control was
# a broken capture wearing a control's name. The tool was right and the control
# was wrong, which is the outcome a sweep must be able to tell from its opposite.
#
# Six NON-OVERLAPPING spans of real audio, one per channel, all continuous. A
# second attempt used `aloop=-1` to stretch the short UI cues into full-length
# channels and hung ffmpeg indefinitely; spans of the long assets need no looping.
# 🔴 THIS FFMPEG COMPLETES ITS WORK AND THEN NEVER EXITS, AND IT WEDGED THE
# WHOLE SUITE FOR AN HOUR.
#
# `check-all` sat on two lines of output for over an hour; the cause was this
# call. Diagnosed rather than guessed at: the output file reaches **4 604 262
# bytes = exactly 8.0 s of 5.1ch/16-bit/48 kHz**, the full intended length, and
# ffmpeg then hangs with the artifact already correct on disk.
#
# Three formulations were tried and all three hang, all three producing
# BYTE-IDENTICAL output: the original, one with `-t 8` bounding the output, and
# one with explicit `asplit` feeding each `atrim` (the textbook fix for
# multi-use of a single input). So it is not the split, not the output stage,
# and the artifact is not in doubt.
#
# ⚠️ Worse than the hang: it LEAKS. An orphaned ffmpeg from this script's earlier
# `aloop` form was found still running after **9.5 hours**, burning CPU across
# runs nobody was watching. `boot.gd`'s own header already names this failure
# shape -- "it does not fail, it waits, and a job that waits forever reads as a
# job still working".
#
# So: bounded, and the ARTIFACT is checked rather than the exit code. That is
# the better test regardless of the hang -- an exit code says ffmpeg thought it
# was done, the file says what it actually wrote.
timeout 90 ffmpeg -v error -y -i export/audio/bgm/main_menu.ogg \
-i export/audio/voice/ADV.ogg -i export/audio/voice/S00A.ogg \
-filter_complex "[0:a]atrim=2:10,asetpts=N/SR/TB,aformat=channel_layouts=mono[a0]; \
[0:a]atrim=20:28,asetpts=N/SR/TB,aformat=channel_layouts=mono[a1]; \
[1:a]atrim=15:23,asetpts=N/SR/TB,aformat=channel_layouts=mono[a2]; \
[1:a]atrim=40:48,asetpts=N/SR/TB,aformat=channel_layouts=mono[a3]; \
[2:a]atrim=12:20,asetpts=N/SR/TB,aformat=channel_layouts=mono[a4]; \
[2:a]atrim=35:43,asetpts=N/SR/TB,aformat=channel_layouts=mono[a5]; \
[a0][a1][a2][a3][a4][a5]join=inputs=6:channel_layout=5.1[a]" \
-map "[a]" -c:a pcm_s16le "$W/bed.wav" </dev/null || true
bed_dur=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$W/bed.wav" 2>/dev/null || echo 0)
if ! awk "BEGIN{exit !($bed_dur > 7.9 && $bed_dur < 8.1)}"; then
echo "🔴 the 5.1 bed is $bed_dur s, not the 8 s this sweep is built on -- refusing to score it" >&2
exit 2
fi
# The same bed with 350 ms holes punched through it, every second.
ffmpeg -v error -y -i "$W/bed.wav" \
-af "volume=enable='lt(mod(t,1),0.35)':volume=0" -c:a pcm_s16le "$W/holes.wav"
# A voice track: mono, with the real pauses of speech.
ffmpeg -v error -y -i export/audio/voice/ADV.ogg -t 60 -ac 1 -c:a pcm_s16le "$W/voice.wav"
echo "check-capture against its documented control sweep:"
expect "six distinct tones (PCM)" "$W/tones.wav" PASS/PASS
expect "the same tones as float32" "$W/tones_f32.wav" PARTIAL/PARTIAL
expect "real music bed" "$W/bed.wav" PASS/PASS
expect "bed with 350 ms holes punched in" "$W/holes.wav" n/a/FAIL
expect "voice track, mono, real pauses" "$W/voice.wav" PASS/UNJUDGED
printf ' %-42s %-8s the artifact is gone; not synthesised, because\n' "the starved capture" "MISSING"
printf ' %-42s %-8s fitting one to its published statistics would be\n' "" ""
printf ' %-42s %-8s a control shaped to the answer it must give\n' "" ""
echo
[ $fail -eq 0 ] && echo "the sweep matches the specification" || echo "🔴 check-capture no longer matches AUDIO-VERIFICATION.md"
exit $fail