Files
shinyobjectz bbd7369548 One loop, raea goal: every rule in TypeScript, held at edit, render, publish and done; raea make is the asset tools
The rules are raea/goal's (sdk/goal), run by `raea goal check` at four moments: the hook after a save, every
render's end, raea cloud's publish, and the Stop hook. Rust's cut and goal gates and the box's word, sound, frame and
place checks are packs (MK30-MK39); runtime/cut-plan, runtime/goal-plan, raea make status and the box's check code
are gone with no alias (MK41).

brief.ts is the one registered root (MK43): raea runs it, and every file that imports raea must be reached from it
(the registered check, an error at publish and done). Its tasks are its `plan` (MK44), read from its run and written
back where each is written by `raea goal tasks`, the one path for the app, agents and the box. Its `goal` is one
goal or a workflow of several (MK46), each with its step, after and rules, checked and reported alone. Taste lines
and signed asks run inside the loop (MK47).

`raea goal check|tasks|seen|judge|gates|next` is the loop; `raea make clothes|motion|solid|wear|splat|physics|bake|
sao|tokensynth|sounds|component|blockout|...` the asset tools (MK45). Old names are refused with where they went.
docs/make.feature is docs/goal.feature; tools/legacy-names.sh holds the old names out.

raea's Node mode on JavaScriptCore now gives a CommonJS package's names as named exports (React's jsx), loads a
file a tool imports by URL, keeps process.exit's code from a promise callback, and reads stdin as fd 0, so the goal
runner runs on the shipped binary.
2026-11-29 16:02:31 -08:00

79 lines
5.4 KiB
Bash
Executable File

#!/bin/sh
# Render equals play, and the bake's time (the no-V8 goal's gate 2): each timeline baked and played from its bake (no
# JS while it plays), snapshots taken at frames across it, the same frames rendered (React, RGB readback), each pair
# compared (SSIM >= 0.999 passes); the bake's time comes from the playtest's open.
# sdk/react/bench/timelines/check.sh [TIMELINE...] (default: titles)
# Build first: lane build -- cargo build --release -p raea-cli.
set -e
cd "$(dirname "$0")/../.."
# pixel checks: no Content Credentials or TrustMark id in the frames (a still's mark moves its pixels: 0.997 for 1.0)
export RAEA_SIGN=0 RAEA_MARK=0
OUT=${TMPDIR:-/tmp}/raea-timelines-check
mkdir -p "$OUT"
# the smaller of two SSIMs, as the worst so far is printed: the first unless the second is lower (an empty one is 0),
# trailing zeros dropped (ffmpeg's 0.990000 is 0.99, its 1.000000 is 1.0)
minf() { awk -v w="$1" -v v="${2:-0}" 'BEGIN { if (v + 0 < w + 0) { if (index(v, ".")) { sub(/0+$/, "", v); if (v ~ /\.$/) v = v "0" } print v } else print w }'; }
# PASS when an SSIM is at least 0.999 (and $2, when given, is true: 1)
passf() { awk -v w="$1" -v c="${2:-1}" 'BEGIN { print (w + 0 >= 0.999 && c == 1) ? "PASS" : "FAIL" }'; }
# a frame's time in seconds
at() { awk -v f="$1" -v fps="$fps" 'BEGIN { printf "%.17g", f / fps }'; }
status=0
for t in ${*:-titles}; do
edit="bench/timelines/$t/edit.tsx"
fps=$(grep -o 'fps={[A-Z0-9]*}' "$edit" | head -1 | grep -o '[0-9]*' || true)
[ -n "$fps" ] || fps=$(grep -o 'const FPS = [0-9]*' "$edit" | grep -o '[0-9]*$')
frames="0 45 120 300 450 599"
snaps=""
for f in $frames; do snaps="$snaps --snapshot $(at $f) $OUT/$t-play-$f.png"; done
last=$(awk -v fps="$fps" 'BEGIN { printf "%.17g", 599 / fps + 0.2 }')
RAEA_AUDIO_MUTE=1 target/release/raea play "$edit" --baked --offscreen --seconds "$last" --json "$OUT/$t.json" $snaps > "$OUT/$t.log" 2>&1 || { echo "$t: the baked play failed (see $OUT/$t.log)"; status=1; continue; }
worst=1
line=""
for f in $frames; do
RAEA_READBACK=rgba target/release/raea render "$edit" -o "$OUT/$t-render-$f.png" --frame "$f" > /dev/null 2>&1
s=$(ffmpeg -v error -i "$OUT/$t-render-$f.png" -i "$OUT/$t-play-$f.png" -filter_complex "[0]format=rgb24[a];[1]format=rgb24[b];[a][b]ssim=stats_file=-" -f null - 2>&1 | grep -o 'All:[0-9.]*' | tail -1 | cut -d: -f2)
line="$line $f:$s"
worst=$(minf "$worst" "$s")
done
# seeks: the same frames reached by jumping (the keyframe before each, then the frames after it), last frame first so
# every jump goes backwards or far, compared with the same renders
seeks=""
for f in $(echo $frames | tr ' ' '\n' | sort -rn); do seeks="$seeks --seek $f $OUT/$t-seek-$f.png"; done
RAEA_AUDIO_MUTE=1 target/release/raea play "$edit" --baked --offscreen $seeks > "$OUT/$t-seek.log" 2>&1 || { echo "$t: the seeks failed (see $OUT/$t-seek.log)"; status=1; continue; }
sline=""
for f in $frames; do
s=$(ffmpeg -v error -i "$OUT/$t-render-$f.png" -i "$OUT/$t-seek-$f.png" -filter_complex "[0]format=rgb24[a];[1]format=rgb24[b];[a][b]ssim=stats_file=-" -f null - 2>&1 | grep -o 'All:[0-9.]*' | tail -1 | cut -d: -f2)
sline="$sline $f:$s"
worst=$(minf "$worst" "$s")
done
bake=$(jq -r '.open_ms // 0' "$OUT/$t.json" | awk '{ printf "%.0f", $1 }')
ok=$(passf "$worst")
[ "$ok" = PASS ] || status=1
echo "$t: $ok render vs baked play, SSIM by frame:$line; seeks:$sline (worst $worst); opened and baked in $bake ms"
# an edit baked from the bake before it (bake_incremental): the fixture's last spring (its cards) retuned in a copy, the copy
# baked from the original (only the frames where the changed component renders are stepped), played, and compared
# with renders of the copy; a scrub of the incremental bake (seeks across its re-stepped runs) must play through
first=$(grep -n "damping: [0-9]*" "$edit" | tail -1 | cut -d: -f1)
if [ -n "$first" ]; then
mkdir -p "$OUT/$t-edit"
sed "${first}s/damping: [0-9]*/damping: 5/" "$edit" > "$OUT/$t-edit/edit.tsx"
esnaps=""
for f in $frames; do esnaps="$esnaps --snapshot $(at $f) $OUT/$t-eplay-$f.png"; done
RAEA_BAKE_FROM="$PWD/$edit" RAEA_AUDIO_MUTE=1 target/release/raea play "$OUT/$t-edit/edit.tsx" --baked --offscreen --seconds "$last" $esnaps > "$OUT/$t-edit.log" 2>&1 || { echo "$t: the incremental play failed (see $OUT/$t-edit.log)"; status=1; continue; }
inc=$(grep -o "raea make bake: incremental, [0-9]* of [0-9]* frames stepped, [0-9]* ms" "$OUT/$t-edit.log" | sed "s/raea make bake: incremental, //")
eworst=1
eline=""
for f in $frames; do
RAEA_READBACK=rgba target/release/raea render "$OUT/$t-edit/edit.tsx" -o "$OUT/$t-erender-$f.png" --frame "$f" > /dev/null 2>&1
s=$(ffmpeg -v error -i "$OUT/$t-erender-$f.png" -i "$OUT/$t-eplay-$f.png" -filter_complex "[0]format=rgb24[a];[1]format=rgb24[b];[a][b]ssim=stats_file=-" -f null - 2>&1 | grep -o 'All:[0-9.]*' | tail -1 | cut -d: -f2)
eline="$eline $f:$s"
eworst=$(minf "$eworst" "$s")
done
RAEA_BAKE_FROM="$PWD/$edit" RAEA_AUDIO_MUTE=1 target/release/raea play "$OUT/$t-edit/edit.tsx" --baked --offscreen --scrub 60 > "$OUT/$t-escrub.log" 2>&1 && scrub=ok || scrub=failed
eok=$(passf "$eworst" "$([ "$scrub" = ok ] && [ -n "$inc" ] && echo 1)")
[ "$eok" = PASS ] || status=1
echo "$t, edited: $eok baked from the bake before ($inc), render vs play:$eline (worst $eworst); scrub $scrub"
fi
done
exit $status