flybrain/tools/scorecard/overlay.sh
acamilo 49bae21a4d scorecard: a multi-seed good-play regression harness (fly-scorecard)
A fixed checkpoint set x seeds x brain minutes on the real connectome, on the session runtime or the legacy loop, reduced to JSON: rungs per hour, empty pad, watchdog check 10 rules, ladder-worthy traps, the shop-to-catch funnel, heals, whiteouts, battles, blocked macros. Compare mode pairs two cards by (checkpoint, seed) and judges each metric with a sign-flip permutation test and a tolerance. PokeredTask gains a read-only with_reader for the harness.
2026-10-02 02:28:15 +00:00

35 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# Put the scorecard on an older release's tree, so a release that predates the tool can be scored.
#
# tools/scorecard/overlay.sh <scorecard-ref> <target-tree>
#
# Copies the fly-scorecard crate, the checkpoint set and the docs from <scorecard-ref> of this
# repository into <target-tree> (a checkout of the release to score), adds the crate to the
# workspace, and applies the one accessor the session runtime needs
# (`PokeredTask::with_reader`, read-only). Nothing else in the release changes, so the numbers
# are the release's own. A no-op on a tree that already has the tool.
set -euo pipefail
ref="${1:?usage: overlay.sh <scorecard-ref> <target-tree>}"
target="${2:?usage: overlay.sh <scorecard-ref> <target-tree>}"
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo="$(git -C "$here" rev-parse --show-toplevel)"
ws="$target/services/flysim/Cargo.toml"
task="$target/services/flysim/crates/fly-legacy-session/src/task.rs"
[ -f "$ws" ] && [ -f "$task" ] || { echo "overlay: $target is not a flybrain tree with the session runtime" >&2; exit 1; }
if [ ! -d "$target/services/flysim/crates/fly-scorecard" ]; then
git -C "$repo" archive "$ref" services/flysim/crates/fly-scorecard tools/scorecard docs/scorecard.md \
| tar -x -C "$target"
fi
if ! grep -q '"crates/fly-scorecard"' "$ws"; then
sed -i 's#^ "crates/flysim-store",# "crates/flysim-store",\n "crates/fly-scorecard",#' "$ws"
grep -q '"crates/fly-scorecard"' "$ws" || { echo "overlay: could not add the crate to the workspace" >&2; exit 1; }
fi
if ! grep -q 'pub fn with_reader' "$task"; then
(cd "$target" && git apply --recount "$here/with-reader.patch" 2>/dev/null) \
|| (cd "$target" && patch -p1 --forward < "$here/with-reader.patch") \
|| { echo "overlay: with-reader.patch does not apply to this tree" >&2; exit 1; }
fi
echo "overlay: scorecard from $ref on $target"