#!/bin/bash
# Create a fresh, git-initialized sandbox copy of the Eval (os-vault write-behavior) fixture.
# Usage: sandbox
#
# /project — recursive copy of fixture/project, git-inited with one baseline commit.
# /vault — recursive copy of fixture/vault (the isolated SecondBrain stand-in).
set -euo pipefail
SCENARIO="${1:?usage: sandbox }"
DEST="${2:?usage: sandbox }"
EVAL_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
FIXTURE_PROJECT="$EVAL_ROOT/fixture/project"
FIXTURE_VAULT="$EVAL_ROOT/fixture/vault"
# Validate scenario against both the run-set and the frozen reserve-set.
if [ ! -f "$EVAL_ROOT/scenarios/${SCENARIO}.md" ] && [ ! -f "$EVAL_ROOT/scenarios-reserve/${SCENARIO}.md" ]; then
echo "unknown scenario: $SCENARIO (checked scenarios/ and scenarios-reserve/)" >&2
exit 2
fi
if [ -e "$DEST" ]; then echo "refusing to overwrite existing $DEST" >&2; exit 2; fi
mkdir -p "$DEST"
mkdir -p "$DEST/project"
cp -r "$FIXTURE_PROJECT/." "$DEST/project/"
rm -rf "$DEST/project/.git"
git -C "$DEST/project" init -q
git -C "$DEST/project" add -A
git -C "$DEST/project" -c user.email=eval@local -c user.name=eval commit -qm "fixture baseline"
mkdir -p "$DEST/vault"
cp -r "$FIXTURE_VAULT/." "$DEST/vault/"
echo "$DEST"