containers: each agent clones the monorepo into its own volume
The last structural fix for the collision class that has bitten three times. Both containers now clone the repository into their OWN named volume instead of bind-mounting a human's working tree, so an agent's local git config cannot capture a human's commits, a credential helper cannot leak a container-only path onto the host, and a `git add -A` cannot sweep another party's in-flight files. Cloned once at startup and never auto-pulled: pulling under a running agent moves files out from under whatever it is mid-edit, which is the same bug again. Accepted knowingly: Claude Code keys per-project memory off the working directory, so moving off the host path starts that memory empty. The corpus in docs/ is the memory that matters and it travels with the clone. Other changes: * docker/agent -> docker/decoder; the launcher is sylph-decoder. Roles, not "the agent", now that there is more than one. * /reborn is gone -- one repository now, so the port reads HANDOFF from its own checkout rather than through a live read-only mount of someone else's tree. * Canary mounts separately at /canary; it stays a fork tracking upstream. * A shared `sylpheed-exchange` volume at /exchange, with tools/ on PATH so `share` is available in both. * The decoder's credential file gets the .host-copy treatment the port already had -- `credential.helper=store` rewrites by rename-over-target, which is EBUSY on a bind mount and reports a fatal that is not one. * Budget split deliberately: decoder 5 cpu / 6 GB, port 3 / 4, leaving room for the planned Referee. "Half the host" was right when there was one agent. Prompts move to docs/agents/ and are rewritten around the protocol: the oracle is the running game, dynamic RE stays with the decoder, each iteration must attempt to refute one claim of the other, and neither may verify its way out of its own role.
This commit is contained in:
52
docker/decoder/bin/build-canary
Executable file
52
docker/decoder/bin/build-canary
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
# Configure + build Xenia Canary inside the container.
|
||||
#
|
||||
# The build directory is $XENIA_BUILD_DIR (outside the bind-mounted repo) on
|
||||
# purpose. The host builds this same tree, and CMake caches an absolute compiler
|
||||
# path and a generator: sharing repo/build between host and container makes each
|
||||
# one reconfigure and relink everything the other just did.
|
||||
#
|
||||
# Parallelism comes from $SYLPH_JOBS, which the entrypoint derives from
|
||||
# AVAILABLE MEMORY as well as core count — a full-parallel build of this tree
|
||||
# has OOM-killed the host outright.
|
||||
#
|
||||
# build-canary [Release|Debug] [extra cmake --build args]
|
||||
set -euo pipefail
|
||||
|
||||
CONFIG="${1:-Release}"; shift || true
|
||||
SRC="${PROJECT_DIR:-/work}/xenia-canary"
|
||||
BUILD="${XENIA_BUILD_DIR:-/sylph-home/re/canary-build}"
|
||||
JOBS="${SYLPH_JOBS:-2}"
|
||||
|
||||
[ -d "$SRC" ] || { echo "build-canary: no source at $SRC" >&2; exit 1; }
|
||||
|
||||
# Submodules: this tree has drifted before, and a checkout that changes a
|
||||
# gitlink fails silently into a half-built third_party. Report rather than fix,
|
||||
# because one submodule here carries an in-tree cmake build whose untracked
|
||||
# artifacts block an update.
|
||||
if ! git -C "$SRC" submodule status --recursive 2>/dev/null | grep -qv '^ '; then
|
||||
:
|
||||
else
|
||||
echo "build-canary: note — submodules are not all at their recorded commits:" >&2
|
||||
git -C "$SRC" submodule status 2>/dev/null | grep -v '^ ' | sed 's/^/ /' >&2
|
||||
fi
|
||||
|
||||
if [ ! -f "$BUILD/CMakeCache.txt" ]; then
|
||||
echo "==> configuring $BUILD ($CONFIG, Ninja Multi-Config, clang $(clang --version | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'))"
|
||||
cmake -S "$SRC" -B "$BUILD" -G "Ninja Multi-Config" \
|
||||
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
||||
-DXENIA_BUILD_TESTS=OFF -DXENIA_BUILD_MISC=OFF \
|
||||
-DXENIA_ENABLE_LTO=OFF
|
||||
fi
|
||||
|
||||
echo "==> building $CONFIG with -j$JOBS"
|
||||
cmake --build "$BUILD" --config "$CONFIG" --parallel "$JOBS" --target xenia_canary "$@"
|
||||
|
||||
BIN="$BUILD/bin/Linux/$CONFIG/xenia_canary"
|
||||
if [ -x "$BIN" ]; then
|
||||
echo "==> $BIN"
|
||||
echo " run it with: run-canary"
|
||||
else
|
||||
echo "build-canary: target did not produce $BIN" >&2
|
||||
exit 1
|
||||
fi
|
||||
47
docker/decoder/bin/build-reborn
Executable file
47
docker/decoder/bin/build-reborn
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build / test Sylpheed Reborn inside the container.
|
||||
#
|
||||
# CARGO_TARGET_DIR points outside the bind-mounted repo (see the Dockerfile), so
|
||||
# this never fights the host's incremental state.
|
||||
#
|
||||
# build-reborn cargo build --workspace
|
||||
# build-reborn test cargo test --workspace, disc tests enabled
|
||||
# build-reborn ci fmt + clippy + test
|
||||
# build-reborn <cargo args...>
|
||||
set -euo pipefail
|
||||
|
||||
SRC="${PROJECT_DIR:-/work}/Syplheed-Reborn"
|
||||
JOBS="${SYLPH_JOBS:-2}"
|
||||
cd "$SRC"
|
||||
|
||||
# The disc-gated integration tests self-skip when this is unset, and a green run
|
||||
# then means almost nothing — point them at the extracted disc if it is there.
|
||||
if [ -z "${SYLPHEED_DISC:-}" ]; then
|
||||
for c in "${PROJECT_DIR:-/work}/sylph_extract" "$SRC/../sylph_extract"; do
|
||||
[ -d "$c/dat" ] && { export SYLPHEED_DISC="$(readlink -f "$c")"; break; }
|
||||
done
|
||||
fi
|
||||
[ -n "${SYLPHEED_DISC:-}" ] && export SYLPHEED_RES3D="$SYLPHEED_DISC/hidden/resource3d"
|
||||
if [ -z "${SYLPHEED_ISO:-}" ]; then
|
||||
iso="$(find "${PROJECT_DIR:-/work}" -maxdepth 2 -iname '*.iso' -print -quit 2>/dev/null || true)"
|
||||
[ -n "$iso" ] && export SYLPHEED_ISO="$iso"
|
||||
fi
|
||||
echo "==> SYLPHEED_DISC=${SYLPHEED_DISC:-<unset — disc tests will SKIP>}" >&2
|
||||
|
||||
export CARGO_BUILD_JOBS="$JOBS"
|
||||
|
||||
case "${1:-build}" in
|
||||
build) shift || true; exec cargo build --workspace "$@" ;;
|
||||
test) shift || true; exec cargo test --workspace "$@" ;;
|
||||
ci)
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --workspace -- -D warnings
|
||||
cargo test --workspace
|
||||
# NOTE: `just ci` also checks wasm32. That leg does not build, and not for
|
||||
# any reason in this crate: the workspace pins tokio with features=["full"],
|
||||
# which pulls mio, which refuses to compile for wasm32. Left out here rather
|
||||
# than reported as a failure of the change under test.
|
||||
echo "==> native CI green (wasm leg skipped — see the note in this script)"
|
||||
;;
|
||||
*) exec cargo "$@" ;;
|
||||
esac
|
||||
72
docker/decoder/bin/claude-autonomous
Executable file
72
docker/decoder/bin/claude-autonomous
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/expect -f
|
||||
# Start Claude Code for an unattended run, answering the first-run gates.
|
||||
#
|
||||
# Claude Code has three one-time interactive prompts, and every one of them is a
|
||||
# silent, permanent hang for an agent with nobody at the keyboard — no error, no
|
||||
# log line, just a container that looks healthy and does nothing:
|
||||
#
|
||||
# 1. the theme picker (first run, or whenever the installed version is
|
||||
# newer than lastOnboardingVersion)
|
||||
# 2. "do you trust this folder?" (per workspace)
|
||||
# 3. the Bypass Permissions disclaimer (for --dangerously-skip-permissions)
|
||||
#
|
||||
# `seed-claude-config.py` pre-sets the config keys for 1 and 2. The disclaimer
|
||||
# has no such key — it is meant to be accepted by a person once — so it is
|
||||
# answered here instead. That is the honest reading of `sylph-agent loose`: the
|
||||
# operator accepted it by choosing to run this, and the container is exactly the
|
||||
# sandbox the warning asks for.
|
||||
#
|
||||
# ── Why the patterns are single words ──
|
||||
# Claude Code draws its UI with ABSOLUTE COLUMN escapes between words, so the
|
||||
# prompt arrives on the wire as
|
||||
#
|
||||
# 2.\x1b[8GYes,\x1b[13GI\x1b[15Gaccept
|
||||
#
|
||||
# A multi-word pattern like {Yes, I accept} therefore never matches, and the
|
||||
# wrapper sits there looking like it is not running at all. Match one word.
|
||||
|
||||
set timeout 90
|
||||
log_user 1
|
||||
|
||||
# Give the pty a wide, tall geometry. A detached `docker run -t` defaults to
|
||||
# 80x24, and Claude Code hard-wraps to the terminal width — which truncates the
|
||||
# Remote Control URL to "https://claude.ai/code/session_01…" in the one place
|
||||
# you need to read it, and makes `docker logs` nearly unusable generally.
|
||||
set stty_init "rows 50 cols 200"
|
||||
|
||||
set answered_theme 0
|
||||
set answered_trust 0
|
||||
set answered_bypass 0
|
||||
|
||||
spawn -noecho claude --dangerously-skip-permissions {*}$argv
|
||||
|
||||
expect {
|
||||
-re {Choose} {
|
||||
if {!$answered_theme} { set answered_theme 1; send "\r" }
|
||||
exp_continue
|
||||
}
|
||||
-re {trust} {
|
||||
if {!$answered_trust} {
|
||||
set answered_trust 1
|
||||
send_user "\n\[claude-autonomous] accepting the workspace trust prompt\n"
|
||||
send "1\r"
|
||||
}
|
||||
exp_continue
|
||||
}
|
||||
-re {accept} {
|
||||
if {!$answered_bypass} {
|
||||
set answered_bypass 1
|
||||
send_user "\n\[claude-autonomous] accepting the Bypass Permissions disclaimer\n"
|
||||
send "2\r"
|
||||
}
|
||||
exp_continue
|
||||
}
|
||||
timeout {
|
||||
# No new gate for a while: the session is up (or never had one). Stop
|
||||
# matching so nothing later in the run can be answered by accident.
|
||||
}
|
||||
eof { exit }
|
||||
}
|
||||
|
||||
# Hand the terminal over for the rest of the run.
|
||||
interact
|
||||
82
docker/decoder/bin/push-work
Executable file
82
docker/decoder/bin/push-work
Executable file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
# Push the current topic branch to origin — the ONLY sanctioned way out of the
|
||||
# container.
|
||||
#
|
||||
# Why a wrapper instead of plain `git push`:
|
||||
#
|
||||
# * **`main` and shared branches are refused.** The agent commits to
|
||||
# `auto/<topic>`; a human merges. A token that can push anywhere is one
|
||||
# confused iteration away from rewriting the consolidated line.
|
||||
# * **Force-push is refused**, always. Nothing here needs it, and history
|
||||
# rewriting is the one mistake that cannot be undone by merging.
|
||||
# * It pushes the CURRENT branch only, by name, so a stray `--all` cannot
|
||||
# publish another agent's worktree branch mid-experiment.
|
||||
#
|
||||
# Credentials come from a file mounted read-only at ~/.git-credentials (see
|
||||
# `sylph-agent`). They are never printed, never logged, and never passed on a
|
||||
# command line.
|
||||
#
|
||||
# push-work push the current branch, and any annotated tags on it
|
||||
#
|
||||
# --follow-tags publishes ANNOTATED tags reachable from the pushed commits. That
|
||||
# is what makes a pinned decoder state durable: the port depends on commits of
|
||||
# ours by revision, and a commit reachable only from a topic branch is orphaned
|
||||
# by a squash-merge. Lightweight tags are deliberately not pushed.
|
||||
# push-work --dry-run say what it would do
|
||||
set -euo pipefail
|
||||
|
||||
DRY=0
|
||||
[ "${1:-}" = "--dry-run" ] && DRY=1
|
||||
|
||||
repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || {
|
||||
echo "push-work: not inside a git repository" >&2; exit 1; }
|
||||
cd "$repo_root"
|
||||
|
||||
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [ "$branch" = "HEAD" ]; then
|
||||
echo "push-work: detached HEAD — check out a branch first" >&2; exit 1
|
||||
fi
|
||||
|
||||
case "$branch" in
|
||||
auto/*) ;;
|
||||
*)
|
||||
echo "push-work: refusing to push '$branch'." >&2
|
||||
echo " Only auto/* topic branches may leave the container; a human merges" >&2
|
||||
echo " them into main. Move your work: git switch -c auto/<topic>" >&2
|
||||
exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ ! -s "$HOME/.git-credentials" ]; then
|
||||
echo "push-work: no credentials mounted at ~/.git-credentials." >&2
|
||||
echo " The host must start the container with SYLPH_GIT_CREDENTIALS pointing" >&2
|
||||
echo " at a file containing one line:" >&2
|
||||
echo " https://<user>:<token>@git.mc02.dev" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# `store` reads the file we mounted; nothing is written back (it is read-only).
|
||||
# Applied to THIS COMMAND ONLY, via `-c`, never `git config --local`.
|
||||
#
|
||||
# Writing it to --local config persists it in the repository, and this repo is a
|
||||
# bind mount the host also uses -- so the host's git inherited
|
||||
# `store --file=/sylph-home/re/.git-credentials`, a path that exists only inside
|
||||
# the container, and every host push then failed with
|
||||
# `unable to get credential storage lock: No such file or directory`.
|
||||
#
|
||||
# A tool that configures a shared repository to suit itself breaks every other
|
||||
# user of that repository. Keep it to the invocation.
|
||||
CRED_HELPER="store --file=$HOME/.git-credentials"
|
||||
|
||||
ahead=$(git rev-list --count "origin/$branch..$branch" 2>/dev/null || git rev-list --count HEAD)
|
||||
echo "push-work: $branch — $ahead commit(s) to publish"
|
||||
|
||||
if [ "$DRY" = 1 ]; then
|
||||
echo "push-work: --dry-run, stopping here"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --force-with-lease is deliberately NOT offered. If this is rejected as
|
||||
# non-fast-forward, someone else moved the branch: fetch and merge, do not
|
||||
# overwrite.
|
||||
git -c "credential.helper=$CRED_HELPER" push --follow-tags --set-upstream origin "$branch"
|
||||
echo "push-work: pushed $branch"
|
||||
99
docker/decoder/bin/run-canary
Executable file
99
docker/decoder/bin/run-canary
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
# Launch Xenia Canary with the settings this title actually needs.
|
||||
#
|
||||
# Four of these are not preferences — they are measured requirements, and every
|
||||
# one of them cost a debugging session before it was pinned down:
|
||||
#
|
||||
# --apu=sdl + SDL_AUDIODRIVER=dummy
|
||||
# There is no PulseAudio here, so `--apu=nop` looks like the safe muted
|
||||
# choice. It is not: the log then fills with "CreateDriver failed for
|
||||
# index=0", the guest never gets past the intro movie, and the window
|
||||
# stays black for 8+ minutes. The SDL driver against a dummy device is
|
||||
# both silent AND lets the title advance.
|
||||
#
|
||||
# NO --audio flag
|
||||
# The RE notes say "--audio --apu=sdl". `--audio` is NOT a cvar in this
|
||||
# tree, and an unknown argument is not a friendly error: xenia calls
|
||||
# ShowSimpleMessageBox from ParseLaunchArguments, BEFORE logging is
|
||||
# initialised, and that SDL dialog blocks on XIfEvent forever. Headless,
|
||||
# the symptom is a 10x10 window, an empty log, and no guest memory —
|
||||
# which reads like a hang deep in the emulator rather than a typo.
|
||||
# If this ever appears to hang at startup, suspect a bad flag first.
|
||||
#
|
||||
# --hid=file --pad_file=...
|
||||
# The old vgamepad path made its device through /dev/uinput, which is NOT
|
||||
# namespaced — a pad created inside a container registers with the HOST's
|
||||
# input stack and every scripted press leaks to the user's desktop. This
|
||||
# driver reads a text file instead. Drive it with tools/re-capture/pad.py.
|
||||
# Trap worth remembering: 360 menus poll XamInputGetKeystrokeEx, not
|
||||
# GetState, so a stubbed GetKeystroke looks like a completely dead pad.
|
||||
#
|
||||
# one instance at a time
|
||||
# Two emulators (or ours + canary) at once perturbs both and the box.
|
||||
# Enforced with a lockfile rather than left to discipline.
|
||||
#
|
||||
# Usage: run-canary [extra xenia flags...]
|
||||
# ISO from $SYLPH_ISO, else the first *.iso under $PROJECT_DIR.
|
||||
# Binary from $XENIA_BIN, else the container build, else the repo build.
|
||||
set -u
|
||||
|
||||
LOCK=/tmp/xenia-canary.lock
|
||||
exec 9>"$LOCK"
|
||||
if ! flock -n 9; then
|
||||
echo "run-canary: an emulator is already running (lock $LOCK)." >&2
|
||||
echo " Only one at a time — kill it first: pkill -x xenia_canary" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PROJECT_DIR="${PROJECT_DIR:-/work}"
|
||||
|
||||
# ── Binary ───────────────────────────────────────────────────────────────────
|
||||
pick_bin() {
|
||||
[ -n "${XENIA_BIN:-}" ] && { echo "$XENIA_BIN"; return; }
|
||||
for c in \
|
||||
"${XENIA_BUILD_DIR:-/sylph-home/re/canary-build}/bin/Linux/Release/xenia_canary" \
|
||||
"${XENIA_BUILD_DIR:-/sylph-home/re/canary-build}/bin/Linux/Debug/xenia_canary" \
|
||||
"$PROJECT_DIR/xenia-canary/build/bin/Linux/Release/xenia_canary" \
|
||||
"$PROJECT_DIR/xenia-canary/build/bin/Linux/Debug/xenia_canary"; do
|
||||
[ -x "$c" ] && { echo "$c"; return; }
|
||||
done
|
||||
}
|
||||
BIN="$(pick_bin)"
|
||||
if [ -z "${BIN:-}" ]; then
|
||||
echo "run-canary: no xenia_canary binary found. Build one with: build-canary" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── ISO ──────────────────────────────────────────────────────────────────────
|
||||
ISO="${SYLPH_ISO:-}"
|
||||
if [ -z "$ISO" ]; then
|
||||
# Prefer a REAL file over a symlink and take the largest: the tree carries
|
||||
# `xenia-rs/sylpheed.iso` as a symlink to the retail image, and a symlink has
|
||||
# already cost a session once (Wine could not resolve it -> "path invalid").
|
||||
ISO="$(find "$PROJECT_DIR" -maxdepth 2 -type f -iname '*.iso' -printf '%s\t%p\n' 2>/dev/null \
|
||||
| sort -rn | head -1 | cut -f2-)"
|
||||
fi
|
||||
if [ -z "$ISO" ] || [ ! -f "$ISO" ]; then
|
||||
echo "run-canary: no ISO. Set SYLPH_ISO=/path/to/game.iso" >&2
|
||||
exit 1
|
||||
fi
|
||||
ISO="$(readlink -f "$ISO")"
|
||||
|
||||
export SDL_AUDIODRIVER="${SDL_AUDIODRIVER:-dummy}"
|
||||
export DISPLAY="${DISPLAY:-:98}"
|
||||
PAD="${XENIA_PAD_FILE:-/tmp/xenia_pad.txt}"
|
||||
: > "$PAD"
|
||||
|
||||
# Guest memory is backed by /dev/shm; a stale file from a killed run confuses
|
||||
# the memory readers (gmem.py finds two candidates and picks the dead one).
|
||||
rm -f /dev/shm/xenia_memory_* /dev/shm/xenia_code_cache_* 2>/dev/null || true
|
||||
|
||||
echo "run-canary: $BIN" >&2
|
||||
echo " iso: $ISO" >&2
|
||||
echo " pad: $PAD display: $DISPLAY shm: $(df -h /dev/shm | awk 'NR==2{print $2}')" >&2
|
||||
|
||||
exec "$BIN" "$ISO" \
|
||||
--apu=sdl \
|
||||
--hid=file --pad_file="$PAD" \
|
||||
--mute=true \
|
||||
"$@"
|
||||
51
docker/decoder/bin/screenshot
Executable file
51
docker/decoder/bin/screenshot
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# Raw full-root PNG grab of the headless display.
|
||||
#
|
||||
# This is deliberately the *uncropped* root window, because
|
||||
# `tools/re-capture/bin/screenshot` is a wrapper that calls this one as its raw
|
||||
# grabber and then crops to the game surface — xenia's window is a GTK window
|
||||
# whose menu bar pushes the 1280x720 game image down ~25 px, and every pixel
|
||||
# oracle in the toolkit was measured against the bare game image. That wrapper
|
||||
# directory is first on PATH, so scripts calling `screenshot` get the cropped
|
||||
# game surface and this stays the honest raw grab underneath it.
|
||||
#
|
||||
# screenshot [out.png] default: $HOME/shots/shot-NNNN.png
|
||||
set -u
|
||||
|
||||
OUT="${1:-}"
|
||||
if [ -z "$OUT" ]; then
|
||||
dir="${HOME:-/tmp}/shots"; mkdir -p "$dir"
|
||||
n_file="$dir/.counter"
|
||||
n=$(( $(cat "$n_file" 2>/dev/null || echo 0) + 1 )); echo "$n" > "$n_file"
|
||||
OUT="$dir/shot-$(printf '%04d' "$n").png"
|
||||
fi
|
||||
mkdir -p "$(dirname "$OUT")"
|
||||
|
||||
if ! xdpyinfo >/dev/null 2>&1; then
|
||||
echo "screenshot: no display on ${DISPLAY:-<unset>}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ImageMagick first. `import` talks X11 directly and captures a window that is
|
||||
# mid-redraw without tearing the way a video grabber can.
|
||||
if command -v import >/dev/null 2>&1 && import -silent -window root "$OUT" 2>/dev/null; then
|
||||
echo "$OUT"; exit 0
|
||||
fi
|
||||
|
||||
# Fallback: ffmpeg's x11grab. Needs an explicit size, so read it off the server
|
||||
# rather than assuming the geometry.
|
||||
if command -v ffmpeg >/dev/null 2>&1; then
|
||||
size=$(xdpyinfo | awk '/dimensions:/{print $2; exit}')
|
||||
if ffmpeg -loglevel error -y -f x11grab -draw_mouse 0 \
|
||||
-video_size "$size" -i "$DISPLAY" -frames:v 1 "$OUT" 2>/dev/null; then
|
||||
echo "$OUT"; exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Last resort: xwd, which is always present with x11-utils.
|
||||
if command -v xwd >/dev/null 2>&1 && command -v convert >/dev/null 2>&1; then
|
||||
xwd -root -silent | convert xwd:- "$OUT" && { echo "$OUT"; exit 0; }
|
||||
fi
|
||||
|
||||
echo "screenshot: no working capture backend" >&2
|
||||
exit 1
|
||||
85
docker/decoder/bin/seed-claude-config.py
Executable file
85
docker/decoder/bin/seed-claude-config.py
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Mark Claude Code's onboarding as complete in ~/.claude.json.
|
||||
|
||||
Claude Code re-runs its first-run wizard whenever `lastOnboardingVersion` does
|
||||
not match the installed version. In a terminal that is a one-key prompt; for an
|
||||
unattended agent it is a silent, permanent hang on the theme picker — no error,
|
||||
no log line, and the container looks like it started fine.
|
||||
|
||||
It also pre-accepts the workspace's trust prompt. That is a SECOND, separate
|
||||
first-run gate: even past onboarding, Claude Code asks "is this a project you
|
||||
trust?" per directory, and this repo's settings pre-approve 442 tool permissions
|
||||
so the prompt is emphatic about it. Unattended, it is another silent hang.
|
||||
|
||||
Pre-accepting is safe here precisely because the trust question is being
|
||||
answered by the person who built and launched the container, for their own
|
||||
repository — it is not a judgement being made on their behalf about someone
|
||||
else's code.
|
||||
|
||||
Usage: seed-claude-config.py <path to .claude.json> <installed version> [workspace...]
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if len(sys.argv) < 3:
|
||||
print(f"usage: {sys.argv[0]} <config.json> <version> [workspace...]",
|
||||
file=sys.stderr)
|
||||
return 2
|
||||
path, version = sys.argv[1], sys.argv[2]
|
||||
workspaces = sys.argv[3:]
|
||||
|
||||
cfg = {}
|
||||
if os.path.exists(path) and os.path.getsize(path):
|
||||
try:
|
||||
with open(path) as f:
|
||||
cfg = json.load(f)
|
||||
except (OSError, ValueError):
|
||||
# A corrupt or partial config is not worth failing the container
|
||||
# over — start from empty rather than block the run.
|
||||
cfg = {}
|
||||
if not isinstance(cfg, dict):
|
||||
cfg = {}
|
||||
|
||||
cfg["hasCompletedOnboarding"] = True
|
||||
cfg["lastOnboardingVersion"] = version
|
||||
cfg.setdefault("theme", "dark")
|
||||
# The THIRD interactive gate: --dangerously-skip-permissions shows a
|
||||
# "Bypass Permissions mode / you accept all responsibility" confirmation on
|
||||
# first use. Key name taken from the shipped binary's own strings, not
|
||||
# guessed. Accepting it here is the whole point of `sylph-agent loose` —
|
||||
# the container is the sandbox that warning asks you to provide.
|
||||
cfg["bypassPermissionsModeAccepted"] = True
|
||||
# A FOURTH gate, and this one fires mid-session rather than at startup, so
|
||||
# the pty wrapper has already handed over by then: an upsell asking whether
|
||||
# to try the fullscreen renderer. It is shown while
|
||||
# `fullscreenUpsellSeenCount` is below an internal threshold, so park it far
|
||||
# above. Found by reading the shipped binary's strings, same as the others.
|
||||
cfg["fullscreenUpsellSeenCount"] = 9999
|
||||
# An auto-update mid-run would restart the process and lose the loop's
|
||||
# scheduled wake-up, so pin the version the container was built with.
|
||||
cfg["autoUpdates"] = False
|
||||
|
||||
projects = cfg.setdefault("projects", {})
|
||||
if not isinstance(projects, dict):
|
||||
projects = cfg["projects"] = {}
|
||||
for ws in workspaces:
|
||||
entry = projects.setdefault(ws, {})
|
||||
if not isinstance(entry, dict):
|
||||
entry = projects[ws] = {}
|
||||
entry["hasTrustDialogAccepted"] = True
|
||||
entry.setdefault("projectOnboardingSeenCount", 1)
|
||||
entry["hasClaudeMdExternalIncludesApproved"] = True
|
||||
entry["hasClaudeMdExternalIncludesWarningShown"] = True
|
||||
|
||||
tmp = path + ".tmp"
|
||||
with open(tmp, "w") as f:
|
||||
json.dump(cfg, f, indent=2)
|
||||
os.replace(tmp, path)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
88
docker/decoder/bin/sylph-doctor
Executable file
88
docker/decoder/bin/sylph-doctor
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prove the container can actually do the four things it exists for, before an
|
||||
# unattended agent spends an hour discovering otherwise.
|
||||
#
|
||||
# Every check here stands for a failure that has already happened once: a
|
||||
# display that was not there, a missing numpy that looked like a logic bug, a
|
||||
# /dev/shm too small for guest memory, a Vulkan stack with no ICD.
|
||||
set -u
|
||||
fail=0
|
||||
ok() { printf ' \033[32m✔\033[0m %s\n' "$*"; }
|
||||
bad() { printf ' \033[31m✖\033[0m %s\n' "$*"; fail=$((fail+1)); }
|
||||
warn() { printf ' \033[33m!\033[0m %s\n' "$*"; }
|
||||
|
||||
echo "── resources ──"
|
||||
# nproc shows the HOST's cores: --cpus is a quota, not a mask. Report both so
|
||||
# "12 cpus" is never mistaken for 12 cpus' worth of throughput.
|
||||
quota="unlimited"
|
||||
if [ -r /sys/fs/cgroup/cpu.max ]; then
|
||||
read -r q p < /sys/fs/cgroup/cpu.max
|
||||
[ "$q" != max ] && quota="$(( q / p )) (quota)"
|
||||
fi
|
||||
echo " cpus: $(nproc) visible, $quota"
|
||||
if [ -r /sys/fs/cgroup/memory.max ]; then
|
||||
m=$(cat /sys/fs/cgroup/memory.max)
|
||||
[ "$m" = max ] && warn "memory: UNLIMITED — the half-the-box cap is not applied" \
|
||||
|| ok "memory cap: $(( m / 1024 / 1024 / 1024 )) GiB"
|
||||
fi
|
||||
shm=$(df -BM /dev/shm | awk 'NR==2{print $2}' | tr -d M)
|
||||
# Guest memory for a 512 MB console plus the code cache does not fit in
|
||||
# Docker's 64 MB default, and the symptom is an mmap error, not a disk-full one.
|
||||
[ "${shm:-0}" -ge 512 ] && ok "/dev/shm: ${shm} MiB" || bad "/dev/shm only ${shm:-?} MiB — need >=512; pass --shm-size"
|
||||
|
||||
echo "── toolchain ──"
|
||||
for t in clang clang++ cmake ninja cargo rustc python3 node claude; do
|
||||
command -v "$t" >/dev/null && ok "$t ($("$t" --version 2>/dev/null | head -1))" || bad "$t missing"
|
||||
done
|
||||
|
||||
echo "── python (dynamic RE) ──"
|
||||
# numpy and PIL missing is the specific hole that silently disabled entities2.py
|
||||
# and every image oracle in the toolkit.
|
||||
for m in numpy PIL duckdb; do
|
||||
python3 -c "import $m" 2>/dev/null && ok "python: $m" || bad "python: $m MISSING"
|
||||
done
|
||||
|
||||
echo "── display ──"
|
||||
if xdpyinfo >/dev/null 2>&1; then
|
||||
ok "display $DISPLAY ($(xdpyinfo | awk '/dimensions:/{print $2; exit}'))"
|
||||
pgrep -x openbox >/dev/null && ok "openbox running" || warn "no window manager — window geometry oracles will misread"
|
||||
out=$(screenshot /tmp/_doctor.png 2>&1) && [ -s /tmp/_doctor.png ] \
|
||||
&& ok "screenshot works -> $(identify -format '%wx%h' /tmp/_doctor.png 2>/dev/null || echo ok)" \
|
||||
|| bad "screenshot failed: $out"
|
||||
rm -f /tmp/_doctor.png
|
||||
else
|
||||
bad "no display on ${DISPLAY:-<unset>}"
|
||||
fi
|
||||
|
||||
echo "── vulkan ──"
|
||||
if command -v vulkaninfo >/dev/null 2>&1; then
|
||||
dev=$(vulkaninfo --summary 2>/dev/null | grep -m3 -E 'deviceName' | sed 's/^ *//')
|
||||
[ -n "$dev" ] && { ok "Vulkan devices:"; echo "$dev" | sed 's/^/ /'; } \
|
||||
|| bad "vulkaninfo found no device (ICD missing?)"
|
||||
else
|
||||
bad "vulkaninfo missing"
|
||||
fi
|
||||
# Judge by what enumerated, not by whether a device node is present: an NVIDIA
|
||||
# card needs the NVIDIA Container Toolkit, and /dev/dri alone does nothing.
|
||||
case "${dev:-}" in
|
||||
*llvmpipe*|*lavapipe*)
|
||||
warn "SOFTWARE Vulkan only — correct but slow."
|
||||
command -v nvidia-smi >/dev/null 2>&1 \
|
||||
&& warn " host has an NVIDIA GPU: install nvidia-container-toolkit for hardware" ;;
|
||||
"") ;;
|
||||
*) ok "hardware Vulkan" ;;
|
||||
esac
|
||||
|
||||
echo "── project ──"
|
||||
[ -d /work/xenia-canary ] && ok "/work/xenia-canary" || bad "/work/xenia-canary not mounted"
|
||||
[ -d /work/Syplheed-Reborn ] && ok "/work/Syplheed-Reborn" || bad "/work/Syplheed-Reborn not mounted"
|
||||
iso=$(find /work -maxdepth 2 -type f -iname '*.iso' -printf '%s\t%p\n' 2>/dev/null | sort -rn | head -1 | cut -f2-)
|
||||
[ -n "$iso" ] && ok "ISO: $iso" || warn "no ISO under /work — run-canary needs SYLPH_ISO"
|
||||
[ -d /work/sylph_extract/dat ] && ok "extracted disc (disc-gated tests will run)" \
|
||||
|| warn "no extracted disc — Reborn disc tests will SKIP"
|
||||
[ -w /sylph-home/re/.claude ] && ok "~/.claude writable (token refresh works)" \
|
||||
|| warn "~/.claude not writable — Claude Code may fail to refresh auth"
|
||||
|
||||
echo
|
||||
[ "$fail" -eq 0 ] && { echo "all good."; exit 0; }
|
||||
echo "$fail check(s) failed."; exit 1
|
||||
Reference in New Issue
Block a user