vestige/benchmarks/silent-rotation/harness/run-sync.sh
Sam Valladares 9bdb9a5668 benchmarks: add Silent Rotation, a fleet-convergence memory benchmark
Three agents fix one failing test concurrently. The fix needs a signing key id
that is randomized per trial from a 50-key keyring and appears in no file the
agents can read. It exists only in the memory layer. Seven arms: a no-memory
control, dense cosine RAG, Vestige, mem0, supermemory, hindsight, Zep/Graphiti.

The measured result is about the first retrieval, not the final score. Across
5 models and 22 trials, a query-based arm's FIRST memory call surfaced the
correct key 6 times out of 87. Vestige, which takes no query argument, did it
56 out of 56. Every downstream number follows from that.

Ships the raw evidence rather than a summary: all agent transcripts, the
harness, and tests/bm25_baseline.py, which reproduces the ranking table offline
with no API key. Two arms were contaminated by a flush bug in this harness that
served them a previous trial's facts; both were fixed and re-run, and the
contaminated cells are withheld rather than published.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 21:24:03 +07:00

132 lines
5.3 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# run-sync.sh -- PHASE 2 of the multi-agent flagship demo (the VESTIGE group).
#
# Runs the SAME fleet of N agents on the SAME torture-v2 bug, but this time they
# share ONE Vestige DB as a coordination hub. Before editing, each agent reaches
# BACKWARD from the failure (vestige_backfill) to the 4-day-old identity-service
# canonical-order decision via the canonical_digest join, learns the DIRECTION
# (identity is source of truth; the ledger must adapt), and publishes it to the
# shared memory (vestige_log) so the fleet converges on the SAME fix. The merge
# is clean and the integrated repo goes green. Emits MEASURED fleet numbers to
# results/sync.json.
#
# Nothing is scripted to win. If a required key/binary is missing this ERRORS.
#
# Required env:
# PROVIDER=anthropic (default) -> ANTHROPIC_API_KEY (or `ant auth login`)
# PROVIDER=openai -> OPENAI_API_KEY (GPT-5.6 Sol)
# VESTIGE_BIN -> path to the vestige CLI (auto-resolved below)
# Optional env (see README.md):
# FLEET_SIZE (default 3), MODEL, COST_PER_MTOK_INPUT/OUTPUT, MAX_ITERATIONS,
# MAX_TOKENS, TEST_CMD, TORTURE_REPO, VESTIGE_DATA_DIR, PYTHON
#
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO="${TORTURE_REPO:-$HERE/../torture-v2}"
OUT="$HERE/results/sync.json"
PY="${PYTHON:-python3}"
# Resolve the vestige CLI to an absolute path (the seed subshell may not inherit
# an interactive PATH), preferring an explicit VESTIGE_BIN, then the release
# binary, then PATH.
if [ -z "${VESTIGE_BIN:-}" ]; then
if [ -x "$HOME/vestige/target/release/vestige" ]; then
VESTIGE_BIN="$HOME/vestige/target/release/vestige"
elif command -v vestige >/dev/null 2>&1; then
VESTIGE_BIN="$(command -v vestige)"
else
VESTIGE_BIN="vestige"
fi
fi
export VESTIGE_BIN
# The shared coordination bus DB. Reuse the repo's isolated demo dir so the fleet
# recalls over the same seeded history the demo narrates.
export VESTIGE_DATA_DIR="${VESTIGE_DATA_DIR:-$REPO/.vestige-demo-db}"
PROVIDER="${PROVIDER:-anthropic}"
# Provider-aware key guard. Never fabricate.
if [ "$PROVIDER" = "mock" ]; then
: # $0 scripted provider for wiring verification -- no key needed.
elif [ "$PROVIDER" = "deepseek" ]; then
if [ -z "${DEEPSEEK_API_KEY:-}" ]; then
echo "ERROR: PROVIDER=deepseek but DEEPSEEK_API_KEY is not set. Refusing to fabricate numbers." >&2
echo " Set DEEPSEEK_API_KEY (DeepSeek direct api.deepseek.com, for deepseek-v4-pro)." >&2
exit 2
fi
elif [ "$PROVIDER" = "openai" ]; then
if [ -z "${OPENAI_API_KEY:-}" ]; then
echo "ERROR: PROVIDER=openai but OPENAI_API_KEY is not set." >&2
echo " Set OPENAI_API_KEY (for gpt-5.6-sol). Refusing to fabricate numbers." >&2
exit 2
fi
elif [ "$PROVIDER" = "openrouter" ]; then
if [ -z "${OPENROUTER_API_KEY:-}" ]; then
echo "ERROR: PROVIDER=openrouter but OPENROUTER_API_KEY is not set. Refusing to fabricate numbers." >&2
echo " Set OPENROUTER_API_KEY (for moonshotai/kimi-k2.7-code)." >&2
exit 2
fi
elif [ "$PROVIDER" = "moonshot" ]; then
if [ -z "${MOONSHOT_API_KEY:-}" ]; then
echo "ERROR: PROVIDER=moonshot but MOONSHOT_API_KEY is not set. Refusing to fabricate numbers." >&2
echo " Set MOONSHOT_API_KEY (Moonshot direct api.moonshot.ai/v1, for kimi-k3)." >&2
exit 2
fi
elif [ "$PROVIDER" = "anthropic" ]; then
if [ -z "${ANTHROPIC_API_KEY:-}" ] && ! (command -v ant >/dev/null 2>&1 && ant auth status >/dev/null 2>&1); then
echo "ERROR: ANTHROPIC_API_KEY is not set and no 'ant' auth profile is active." >&2
echo " Set ANTHROPIC_API_KEY or run 'ant auth login'. Refusing to fabricate numbers." >&2
exit 2
fi
else
echo "ERROR: unknown PROVIDER '$PROVIDER'. Use 'anthropic', 'openai', 'openrouter', or 'moonshot'." >&2
exit 2
fi
if ! command -v "$VESTIGE_BIN" >/dev/null 2>&1 && [ ! -x "$VESTIGE_BIN" ]; then
echo "ERROR: vestige CLI not found at '$VESTIGE_BIN'. Set VESTIGE_BIN." >&2
exit 2
fi
if [ ! -d "$REPO" ]; then
echo "ERROR: torture repo not found at $REPO (set TORTURE_REPO)." >&2
exit 2
fi
mkdir -p "$HERE/results"
echo "== SYNC fleet run (Phase 2: Vestige shared hub) =="
echo "repo: $REPO"
echo "provider: $PROVIDER"
echo "model: ${MODEL:-$([ "$PROVIDER" = openai ] && echo gpt-5.6-sol || { [ "$PROVIDER" = openrouter ] && echo moonshotai/kimi-k2.7-code || echo claude-opus-4-8; })}"
echo "fleet size: ${FLEET_SIZE:-3}"
echo "vestige: $VESTIGE_BIN (shared bus: $VESTIGE_DATA_DIR)"
echo "out: $OUT"
echo
# Seed the SHARED coordination memory with the real project history via the
# repo's own canonical seed (cause + noise + lookalike distractor + failure).
SEED="$REPO/.vestige-seed.sh"
if [ -f "$SEED" ]; then
echo "seeding shared bus via repo canonical seed: $SEED"
VESTIGE_BIN="$VESTIGE_BIN" VESTIGE_DATA_DIR="$VESTIGE_DATA_DIR" bash "$SEED" >/dev/null
echo "seed complete ($VESTIGE_DATA_DIR)"
echo
else
echo "ERROR: repo seed script not found at $SEED." >&2
exit 2
fi
# Ensure deps present once, then reset base repo to pristine broken + snapshot.
if [ ! -d "$REPO/node_modules" ]; then
echo "installing repo deps (npm install)..."
(cd "$REPO" && npm install >/dev/null 2>&1) || {
echo "ERROR: npm install failed in $REPO" >&2; exit 2; }
fi
TORTURE_REPO="$REPO" bash "$HERE/reset-repo.sh"
echo
exec "$PY" "$HERE/agent/fleet_runner.py" --mode sync --repo "$REPO" --out "$OUT"