Files
Sylpheed/docker/port/bin/build-reference-cli
MechaCat02 9fbb352ef0 monorepo: one repository for the decoders, the port and the corpus
Merges the Godot port into the reverse-engineering repository, preserving both
histories -- 1019 commits of corpus plus the port's 31, brought in by subtree
merge and then moved into place so git can follow each file across the rename.

The reason is not tidiness. The two-repo split forced the exporter to depend on
the decoders by pinned revision, and that created a whole class of failure that
now disappears: a sha reachable only from a topic branch, orphaned by a
squash-merge, breaking a fresh checkout silently at build time. It also forced a
live read-only mount of one agent's working tree into another's container, which
is why a contract file could move mid-iteration. With a path dependency, a
decoder change and the exporter change it requires land in the same commit or
not at all.

Canary stays separate: it is a fork tracking upstream.

New structure for the long term:

  docs/game/     how the game is NAVIGATED -- menus, modals, prompts, alerts,
                 and in-game flight. Written so nobody rediscovers it. Mostly
                 open questions on purpose; the in-game tutorials are the
                 resource for the flight half.
  docs/port/MODDING.md
                 modding as a constraint on the exporter TODAY, not a later
                 feature: one logical asset in one file (the disc splits nearly
                 everything, and resolving that is the exporter's job), names a
                 person recognises, PNG/OGG/OGV/JSON only, base-and-overrides so
                 re-exporting is always safe, provenance in every file.
  data/base + data/mods
                 generated tree and drop-in overrides, both gitignored
  exchange/      transient inter-agent files, deliberately outside history
  docs/agents/   the team protocol

Both the README and the navigation doc lead with the correction that cost the
most: the oracle is the real game under Xenia Canary. Reborn's renderer is a
hypothesis under test, it has been wrong, and treating it as ground truth
propagated into three documents and both agents before a human caught it.

Scripted modding stays possible without being built: no screen name is hardcoded
in GDScript and there is no native code in port/, which is what Godot Mod Loader
needs to be able to substitute behaviour later.
2026-08-29 11:34:46 +02:00

81 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build `sylpheed-cli` from the SAME revision of sylpheed-formats the exporter
# is pinned to, and put it on the persistent target volume.
#
# build-reference-cli -> $CARGO_TARGET_DIR/release/sylpheed-cli
#
# Why not just use /reborn/target/release/sylpheed-cli: that binary is built
# from whatever /reborn's working tree is at, which is a LIVE mount of the other
# agent's checkout and moves under you mid-iteration. `sylpheed-cli screen
# render` is the reference the Godot port is diffed against, so if it runs
# different decoders than the exporter, a pixel disagreement has a free variable
# in it and proves nothing about the port.
#
# The pinned source lives in CARGO_HOME, which is on the container overlay and
# does not survive a fresh container -- cargo re-fetches it. The BINARY goes to
# CARGO_TARGET_DIR, which is a volume, so this is a one-off per image.
#
# Jobs are capped for the same reason as build-export.
set -euo pipefail
cd "${PROJECT_DIR:-/work}"
export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-3}"
rev=$(sed -n 's/.*Syplheed-Reborn\.git", rev = "\([0-9a-f]*\)".*/\1/p' \
crates/sylpheed-export/Cargo.toml | head -1)
[ -n "$rev" ] || { echo "build-reference-cli: no rev pin found in Cargo.toml" >&2; exit 1; }
# The checkout only exists once cargo has fetched it; a fresh container has not.
find_checkout() {
find "${CARGO_HOME:?}/git/checkouts" -maxdepth 2 -type d -name "${rev}*" 2>/dev/null | head -1
}
src=$(find_checkout)
if [ -z "$src" ]; then
echo "build-reference-cli: fetching the pinned decoders ($rev)"
cargo fetch
src=$(find_checkout)
fi
[ -n "$src" ] || { echo "build-reference-cli: no checkout for rev $rev" >&2; exit 1; }
# Build into a target directory KEYED BY THE REVISION.
#
# This is not tidiness. Sharing one target dir across pins silently served a
# stale binary: after the pin moved 8b6dbcf -> 5414db3, cargo reported
# "Finished in 0.13s" and left in place a `sylpheed-cli` built from the OLD
# decoders. `screen list` still worked, so the old check passed, and the
# reference renderer this whole project verifies against was a revision behind
# for three consecutive diff runs. A per-rev tree cannot do that: a new pin has
# no artifacts to reuse.
echo "build-reference-cli: building sylpheed-cli from $rev"
tree="$CARGO_TARGET_DIR/reference-cli/$rev"
CARGO_TARGET_DIR="$tree" cargo build --release --manifest-path "$src/Cargo.toml" -p sylpheed-cli
stable="$CARGO_TARGET_DIR/reference-cli/sylpheed-cli"
mkdir -p "$(dirname "$stable")"
cp -f "$tree/release/sylpheed-cli" "$stable"
"$stable" screen list "${SYLPHEED_DISC:-/disc}/dat/GP_TITLE.pak" >/dev/null \
|| { echo "build-reference-cli: built, but 'screen list' failed" >&2; exit 1; }
# And check the binary is actually the pinned code, not merely a working one.
# `screen info` prints each element's resting placement, which is decoder
# output; if this disagrees with what the exporter wrote from the same pin, the
# two halves of the verification are not the same revision and every diff below
# is meaningless. Compare rather than assert a value, so this stays true when
# the pin moves again.
if [ -f "${PROJECT_DIR:-/work}/export/screens/title/main_menu.json" ]; then
cli_rest=$("$stable" screen info "${SYLPHEED_DISC:-/disc}/dat/GP_TITLE.pak" --build 5 \
| sed -n 's/.*ptframe1\.t32.*rest (\([0-9]*\),\([0-9]*\)).*/\1,\2/p')
exp_rest=$(python3 -c '
import json,sys
d=json.load(open(sys.argv[1]))
e=next(e for e in d["elements"] if e["id"]=="ptframe1")
print("%d,%d" % tuple(e["rest"]["pos"]))' "${PROJECT_DIR:-/work}/export/screens/title/main_menu.json")
if [ "$cli_rest" != "$exp_rest" ]; then
echo "build-reference-cli: STALE OR MISMATCHED BINARY" >&2
echo " the CLI resolves ptframe1 rest to ($cli_rest) but export/ says ($exp_rest)." >&2
echo " Both should come from rev $rev. Delete $tree and rebuild." >&2
exit 1
fi
fi
echo "build-reference-cli: $stable (rev $rev, agrees with export/ on ptframe1)"