playtest: elaboration-only atlas run (sweeps over the whole world, no player) and a Markdown world atlas from the omniscient view
open_harness factors the state, counting port and sessions both runs stand on; the atlas module seeds one world through Begin at parameterised scale, sweeps the Active elaborator breadth-first at a concurrency ceiling and a cost cap, and renders places, institutions, people, populations, facts and commitments with the sweep, lens and vault notes each entry came from. scripts/playtest-yggdrasil.sh --atlas launches it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
98f5214010
commit
bce498a848
3 changed files with 1446 additions and 29 deletions
|
|
@ -42,6 +42,8 @@ use std::{
|
|||
use tokio::sync::{Mutex, mpsc};
|
||||
use tower::ServiceExt;
|
||||
|
||||
mod atlas;
|
||||
|
||||
const PLAN_JSON: &str = include_str!("../playtest/plan.json");
|
||||
const HISTORY_IN_PROMPT: usize = 12;
|
||||
const CRITIC_CHUNK: usize = 10;
|
||||
|
|
@ -1152,6 +1154,56 @@ fn render_index(plan: &Plan, outcomes: &[WorldOutcome], total: &BTreeMap<String,
|
|||
|
||||
/// Plays the selected worlds in parallel, writes every report and the index,
|
||||
/// and returns the dated output directory.
|
||||
/// What every harness run stands on: the imported vault snapshots, the one
|
||||
/// counting port over the connector, and the signed-in test sessions.
|
||||
pub(super) struct Harness {
|
||||
pub(super) global: Arc<CountingPort>,
|
||||
pub(super) state: AppState,
|
||||
pub(super) router: Router,
|
||||
pub(super) cookies: Vec<String>,
|
||||
/// What each vault import reported, one line per profile.
|
||||
pub(super) imports: Vec<String>,
|
||||
}
|
||||
|
||||
/// Opens a run's state under `root/state`: imports `vaults`, counts every
|
||||
/// inference the lanes make, and signs in one session per account. `wrap`
|
||||
/// decorates the counted port before the lanes see it.
|
||||
pub(super) fn open_harness(
|
||||
root: &Path,
|
||||
vaults: &[&str],
|
||||
scale: Scale,
|
||||
accounts: &[String],
|
||||
wrap: impl FnOnce(Arc<dyn InferencePort>) -> Arc<dyn InferencePort>,
|
||||
) -> anyhow::Result<Harness> {
|
||||
let state_root = root.join("state");
|
||||
std::fs::create_dir_all(&state_root)?;
|
||||
prepare_admitted_state_layout(&state_root)?;
|
||||
let mut imports = Vec::new();
|
||||
for vault in vaults {
|
||||
let line = crate::vaults::import(&state_root, vault)?;
|
||||
println!("import {line}");
|
||||
imports.push(line);
|
||||
}
|
||||
let shared = open_shared()?;
|
||||
let global = CountingPort::new(shared.inference.clone());
|
||||
let shared = Shared { inference: wrap(global.clone()), ..shared };
|
||||
let (fatal, _fatal_events) = mpsc::unbounded_channel();
|
||||
let timelines = Arc::new(Timelines::new(state_root.clone(), shared, fatal));
|
||||
let catalog = Arc::new(Mutex::new(Catalog::open(state_root.join("catalog.cc"))?));
|
||||
let account_refs: Vec<&str> = accounts.iter().map(String::as_str).collect();
|
||||
let (state, cookies, _assembled_fatal) = assemble(
|
||||
&state_root,
|
||||
catalog,
|
||||
timelines,
|
||||
Arc::new(scale),
|
||||
Arc::new(SnapshotVaults::new(&state_root)),
|
||||
Arc::new(HeimdallClient::fixture()),
|
||||
&account_refs,
|
||||
);
|
||||
let router = service_router(state.clone());
|
||||
Ok(Harness { global, state, router, cookies, imports })
|
||||
}
|
||||
|
||||
pub(crate) async fn run(options: Options) -> anyhow::Result<PathBuf> {
|
||||
let mut plan = match &options.plan {
|
||||
Some(path) => serde_json::from_slice(&std::fs::read(path)?).context("the plan file did not parse")?,
|
||||
|
|
@ -1170,33 +1222,12 @@ pub(crate) async fn run(options: Options) -> anyhow::Result<PathBuf> {
|
|||
let wall = Duration::from_secs(options.wall_minutes.unwrap_or(plan.wall_minutes) * 60);
|
||||
let stamp = options.stamp.clone().unwrap_or_else(|| Utc::now().format("%Y-%m-%dT%H%MZ").to_string());
|
||||
let root = options.out.join(stamp);
|
||||
std::fs::create_dir_all(root.join("state"))?;
|
||||
std::fs::create_dir_all(&root)?;
|
||||
let root = std::fs::canonicalize(&root)?;
|
||||
let state_root = root.join("state");
|
||||
prepare_admitted_state_layout(&state_root)?;
|
||||
let vaults: BTreeSet<&str> = plan.worlds.iter().map(|world| world.vault.as_str()).collect();
|
||||
for vault in vaults {
|
||||
println!("import {}", crate::vaults::import(&state_root, vault)?);
|
||||
}
|
||||
|
||||
let shared = open_shared()?;
|
||||
let global = CountingPort::new(shared.inference.clone());
|
||||
let shared = Shared { inference: global.clone(), ..shared };
|
||||
let (fatal, _fatal_events) = mpsc::unbounded_channel();
|
||||
let timelines = Arc::new(Timelines::new(state_root.clone(), shared, fatal));
|
||||
let catalog = Arc::new(Mutex::new(Catalog::open(state_root.join("catalog.cc"))?));
|
||||
let accounts: Vec<String> = plan.worlds.iter().map(|world| format!("playtest-{}", world.id)).collect();
|
||||
let account_refs: Vec<&str> = accounts.iter().map(String::as_str).collect();
|
||||
let (state, cookies, _assembled_fatal) = assemble(
|
||||
&state_root,
|
||||
catalog,
|
||||
timelines,
|
||||
Arc::new(Scale::from_env()),
|
||||
Arc::new(SnapshotVaults::new(&state_root)),
|
||||
Arc::new(HeimdallClient::fixture()),
|
||||
&account_refs,
|
||||
);
|
||||
let router = service_router(state.clone());
|
||||
let vaults: BTreeSet<&str> = plan.worlds.iter().map(|world| world.vault.as_str()).collect();
|
||||
let vaults: Vec<&str> = vaults.into_iter().collect();
|
||||
let Harness { global, state, router, cookies, .. } = open_harness(&root, &vaults, Scale::from_env(), &accounts, |port| port)?;
|
||||
let run = Arc::new(Run {
|
||||
plan: plan.clone(),
|
||||
turns,
|
||||
|
|
|
|||
1373
crates/ghostlight-dungeon/src/playtest/atlas.rs
Normal file
1373
crates/ghostlight-dungeon/src/playtest/atlas.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -4,6 +4,13 @@
|
|||
#
|
||||
# scripts/playtest-yggdrasil.sh [--turns N] [--worlds id,id] [--wall-minutes M]
|
||||
# [--out DIR] [--rev REV]
|
||||
# scripts/playtest-yggdrasil.sh --atlas [--set NAME=VALUE ...] [--rev REV]
|
||||
#
|
||||
# --atlas runs the elaboration-only world atlas (playtest::atlas::live_atlas) instead of
|
||||
# the play-through; each --set becomes an environment variable of the unit. The atlas knobs
|
||||
# are GHOSTLIGHT_ATLAS_{VAULT,ERA,PERSONS,INSTITUTIONS,POPULATIONS,SWEEPS,SWEEP_SESSIONS,
|
||||
# SEED_SESSIONS,COST_CAP,CONCURRENCY}; set GHOSTLIGHT_CONTROLLER_MAX_CONCURRENT (the pool Begin
|
||||
# seeds under) to the same concurrency, or the run refuses to start.
|
||||
#
|
||||
# Defaults: every world in crates/ghostlight-dungeon/playtest/plan.json, 12 turns
|
||||
# per character, 240 minutes of wall time. Run it from a worktree with the
|
||||
|
|
@ -17,7 +24,7 @@ set -euo pipefail
|
|||
IMAGE=${IMAGE:-eureka-verify-rust:b99d30ec441e}
|
||||
KEY=${KEY:-/etc/gamecult/claude-connector/connection-ghostlight.key}
|
||||
CONNECTOR_ADDR=${CONNECTOR_ADDR:-127.0.0.1:4110}
|
||||
turns=""; worlds=""; wall=""; out=""; rev=""; on_host=0; stamp=""
|
||||
turns=""; worlds=""; wall=""; out=""; rev=""; on_host=0; stamp=""; atlas=0; sets=()
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--turns) turns=$2; shift 2 ;;
|
||||
|
|
@ -27,6 +34,8 @@ while [ $# -gt 0 ]; do
|
|||
--rev) rev=$2; shift 2 ;;
|
||||
--on-host) on_host=1; shift ;;
|
||||
--stamp) stamp=$2; shift 2 ;;
|
||||
--atlas) atlas=1; shift ;;
|
||||
--set) sets+=("$2"); shift 2 ;;
|
||||
*) echo "unknown argument $1" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
|
@ -41,6 +50,8 @@ if [ "$on_host" = 0 ]; then
|
|||
[ -n "$worlds" ] && args="$args --worlds $worlds"
|
||||
[ -n "$wall" ] && args="$args --wall-minutes $wall"
|
||||
[ -n "$out" ] && args="$args --out $out"
|
||||
[ "$atlas" = 1 ] && args="$args --atlas"
|
||||
for kv in "${sets[@]}"; do args="$args --set $kv"; done
|
||||
RUN_ON_HOST=1 TIMEOUT=3000 bash "$verify" "$here" "$rev" "$IMAGE" "bash scripts/playtest-yggdrasil.sh $args"
|
||||
exit $?
|
||||
fi
|
||||
|
|
@ -66,11 +77,13 @@ if [ ! -x "$bin" ]; then
|
|||
fi
|
||||
test -x "$bin"
|
||||
|
||||
unit=ghostlight-playtest-$stamp
|
||||
if [ "$atlas" = 1 ]; then kind=atlas; test_name=playtest::atlas::live_atlas; else kind=playtest; test_name=playtest::live_playtest; fi
|
||||
unit=ghostlight-$kind-$stamp
|
||||
env_args=(--setenv=GHOSTLIGHT_CONNECTOR_ADDR="$CONNECTOR_ADDR"
|
||||
--setenv=GHOSTLIGHT_CONNECTOR_KEY_FILE="/run/credentials/$unit.service/connector-key"
|
||||
--setenv=GHOSTLIGHT_VAULT_BASE="${VAULT_BASE:-$base/vaults}"
|
||||
--setenv=GHOSTLIGHT_PLAYTEST_OUT="$out" --setenv=GHOSTLIGHT_PLAYTEST_STAMP="$stamp")
|
||||
--setenv=GHOSTLIGHT_PLAYTEST_OUT="$out" --setenv=GHOSTLIGHT_PLAYTEST_STAMP="$stamp" --setenv=GHOSTLIGHT_ATLAS_STAMP="$stamp")
|
||||
for kv in "${sets[@]}"; do env_args+=(--setenv="$kv"); done
|
||||
[ -n "$turns" ] && env_args+=(--setenv=GHOSTLIGHT_PLAYTEST_TURNS="$turns")
|
||||
[ -n "$worlds" ] && env_args+=(--setenv=GHOSTLIGHT_PLAYTEST_WORLDS="$worlds")
|
||||
[ -n "$wall" ] && env_args+=(--setenv=GHOSTLIGHT_PLAYTEST_WALL_MINUTES="$wall")
|
||||
|
|
@ -80,7 +93,7 @@ sudo systemd-run --unit "$unit" --collect --quiet \
|
|||
-p User="$(id -un)" -p LoadCredential=connector-key:"$KEY" \
|
||||
-p StandardOutput=append:"$out/$stamp.run.log" -p StandardError=append:"$out/$stamp.run.log" \
|
||||
"${env_args[@]}" \
|
||||
"$bin" --ignored --exact playtest::live_playtest --nocapture --test-threads=1
|
||||
"$bin" --ignored --exact "$test_name" --nocapture --test-threads=1
|
||||
|
||||
echo "unit: $unit"
|
||||
echo "output: $out/$stamp"
|
||||
|
|
|
|||
Loading…
Reference in a new issue