Merge ghostlight-verse/dungeon-playtest-harness: unattended playtest runner, model critic and per-world reports (cut-dungeon-playtest-harness r1, report h1; ruling dungeon-playtest-harness)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
9f22513b83
7 changed files with 1505 additions and 81 deletions
79
crates/ghostlight-dungeon/playtest/plan.json
Normal file
79
crates/ghostlight-dungeon/playtest/plan.json
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"turns_per_character": 12,
|
||||
"wall_minutes": 240,
|
||||
"turn_timeout_minutes": 15,
|
||||
"character_model": "claude-sonnet-5-5",
|
||||
"critic_model": "claude-opus-5-5",
|
||||
"prices": {
|
||||
"opus": { "input": 4.0, "output": 20.0, "cache_read": 0.2 },
|
||||
"sonnet": { "input": 2.0, "output": 10.0, "cache_read": 0.1 },
|
||||
"haiku": { "input": 0.1, "output": 0.5 }
|
||||
},
|
||||
"temperaments": {
|
||||
"diplomat": {
|
||||
"goal": "Make allies and brokered deals; leave every room better disposed toward you than you found it.",
|
||||
"manner": "Talks first and listens closely. Offers trades, introductions and face-saving ways out. Never draws a weapon unless cornered.",
|
||||
"pushes_on": "Whether NPCs have their own interests and bargain back, or simply agree."
|
||||
},
|
||||
"murderhobo": {
|
||||
"goal": "Take what you want and answer slights with steel.",
|
||||
"manner": "Quick to anger, blunt, armed. Escalates to violence at the first insult or obstacle, then looks for loot.",
|
||||
"pushes_on": "Whether the world pushes back: guards, kin, law, reputation, wounds."
|
||||
},
|
||||
"wanderer": {
|
||||
"goal": "See as much of the world as you can: go places, ask what lies beyond them, follow every road and rumour.",
|
||||
"manner": "Curious and restless. Moves on whenever somewhere is explored. Asks locals about the next place and about their own history.",
|
||||
"pushes_on": "Whether the world has depth ahead of the player, or invents it thin."
|
||||
},
|
||||
"schemer": {
|
||||
"goal": "Gain power by playing factions against one another.",
|
||||
"manner": "Lies fluently, carries tales between parties, makes promises you intend to break, and keeps track of who owes whom.",
|
||||
"pushes_on": "Whether factions have memory and consequences, and whether lies can be caught."
|
||||
},
|
||||
"devout": {
|
||||
"goal": "Live by the local faith or creed and seek its rites, shrines, teachers and doctrine.",
|
||||
"manner": "Earnest and respectful. Asks what is believed, what is forbidden, what is owed to the powers. Takes part in observances.",
|
||||
"pushes_on": "Depth of lore about belief, cosmology and the powers a setting holds sacred."
|
||||
},
|
||||
"grifter": {
|
||||
"goal": "Come out ahead through theft, cheating and unpaid debts.",
|
||||
"manner": "Charming and shifty. Picks pockets, short-changes, forges, runs cons, skips out on what is owed.",
|
||||
"pushes_on": "Whether ledgers, debts, law and watchfulness exist and bite."
|
||||
},
|
||||
"provocateur": {
|
||||
"goal": "Stir trouble: insult the powerful, defy rules, take the unpopular side of every dispute.",
|
||||
"manner": "Loud, contrarian, theatrical. Says what nobody wants said and refuses to back down.",
|
||||
"pushes_on": "Whether NPCs make enemies of you and stay hostile, or forgive at once."
|
||||
},
|
||||
"charmer": {
|
||||
"goal": "Win hearts: flirt, seduce, court and be courted.",
|
||||
"manner": "Warm, flattering, bold about desire. Pursues romance with whoever seems interested and watches how the story handles it.",
|
||||
"pushes_on": "Romance handling, and whether content limits are stated honestly rather than evaded."
|
||||
}
|
||||
},
|
||||
"worlds": [
|
||||
{ "id": "delvehold-diplomat", "vault": "delvehold", "era": "present", "name": "Ilsa Brandt", "temperament": "diplomat" },
|
||||
{ "id": "delvehold-murderhobo", "vault": "delvehold", "era": "present", "name": "Korr Skullsplitter", "temperament": "murderhobo" },
|
||||
{ "id": "delvehold-grifter", "vault": "delvehold", "era": "present", "name": "Pip Tallowcandle", "temperament": "grifter" },
|
||||
{
|
||||
"id": "aetheria-pre-schemer", "vault": "aetheria", "era": "pre-elysium", "name": "Vesper Quill", "temperament": "schemer",
|
||||
"lenses": { "weighted": { "charter": 3, "veil": 3, "hearth": 3 }, "rest": 1 }
|
||||
},
|
||||
{
|
||||
"id": "aetheria-pre-devout", "vault": "aetheria", "era": "pre-elysium", "name": "Sister Anwen Roe", "temperament": "devout",
|
||||
"lenses": { "weighted": { "charter": 3, "veil": 3, "hearth": 3 }, "rest": 1 }
|
||||
},
|
||||
{
|
||||
"id": "aetheria-pre-provocateur", "vault": "aetheria", "era": "pre-elysium", "name": "Dax Marlowe", "temperament": "provocateur",
|
||||
"lenses": { "weighted": { "charter": 3, "veil": 3, "hearth": 3 }, "rest": 1 }
|
||||
},
|
||||
{
|
||||
"id": "aetheria-post-wanderer", "vault": "aetheria", "era": "post-elysium", "name": "Tamsin Ode", "temperament": "wanderer",
|
||||
"lenses": { "weighted": { "numen": 3, "veil": 3, "tangle": 3 }, "rest": 1 }
|
||||
},
|
||||
{
|
||||
"id": "aetheria-post-charmer", "vault": "aetheria", "era": "post-elysium", "name": "Lucan Vey", "temperament": "charmer",
|
||||
"lenses": { "weighted": { "numen": 3, "veil": 3, "tangle": 3 }, "rest": 1 }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -812,7 +812,6 @@ async fn auth_logout(headers: HeaderMap, State(state): State<AppState>) -> Respo
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
app_session::AppSessionOwner,
|
||||
begin::tests::{Rig, author, deferred_rig, eventually, one_vault, principal, rig},
|
||||
heimdall::{
|
||||
AccountSummary, AuthBeginReceipt, AuthCompletionReceipt, AuthNavigation, AuthProvider,
|
||||
|
|
@ -953,41 +952,16 @@ mod tests {
|
|||
}
|
||||
|
||||
async fn app_over(rig: Rig, accounts: &[&str]) -> App {
|
||||
let key = rig.directory.path().join("session.key");
|
||||
std::fs::write(&key, [17_u8; 32]).unwrap();
|
||||
let mut sessions =
|
||||
AppSessionOwner::open(rig.directory.path().join("service/app-sessions-v2.cc"), &key)
|
||||
.unwrap();
|
||||
let cookies = accounts
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, account)| {
|
||||
sessions
|
||||
.create_session(VerifiedSessionAdmission::fixture(
|
||||
*account,
|
||||
format!("heimdall-session-{index}"),
|
||||
1,
|
||||
Utc::now() + chrono::Duration::hours(1),
|
||||
Utc::now() + chrono::Duration::days(1),
|
||||
"fixture-refresh",
|
||||
))
|
||||
.unwrap()
|
||||
})
|
||||
.collect();
|
||||
let heimdall = Arc::new(FakeHeimdall::default());
|
||||
let (fatal, fatal_events) = tokio::sync::mpsc::unbounded_channel();
|
||||
let state = AppState {
|
||||
catalog: rig.catalog.clone(),
|
||||
timelines: rig.timelines.clone(),
|
||||
vaults: one_vault(),
|
||||
scale: rig.scale.clone(),
|
||||
sessions: Arc::new(Mutex::new(sessions)),
|
||||
heimdall: heimdall.clone(),
|
||||
auth: Arc::default(),
|
||||
runtime_id: "ghostlight-test".into(),
|
||||
runtime_health: None,
|
||||
fatal,
|
||||
};
|
||||
let (state, cookies, fatal_events) = crate::test_support::assemble(
|
||||
rig.directory.path(),
|
||||
rig.catalog.clone(),
|
||||
rig.timelines.clone(),
|
||||
rig.scale.clone(),
|
||||
one_vault(),
|
||||
heimdall.clone(),
|
||||
accounts,
|
||||
);
|
||||
App {
|
||||
router: service_router(state.clone()),
|
||||
state,
|
||||
|
|
|
|||
|
|
@ -7,11 +7,15 @@ mod heimdall;
|
|||
mod idunn_health;
|
||||
mod invite;
|
||||
mod page;
|
||||
#[cfg(test)]
|
||||
mod playtest;
|
||||
mod play;
|
||||
mod run_ahead;
|
||||
mod runtime;
|
||||
mod session_refresh;
|
||||
mod state_layout;
|
||||
#[cfg(test)]
|
||||
mod test_support;
|
||||
mod timelines;
|
||||
mod turn_log;
|
||||
mod vaults;
|
||||
|
|
|
|||
1145
crates/ghostlight-dungeon/src/playtest.rs
Normal file
1145
crates/ghostlight-dungeon/src/playtest.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -129,7 +129,7 @@ fn lane_models_from(read: impl Fn(&str) -> Option<String>) -> (ControllerModels,
|
|||
}
|
||||
|
||||
/// The one routed inference port every timeline and lane shares.
|
||||
fn open_shared() -> anyhow::Result<Shared> {
|
||||
pub(crate) fn open_shared() -> anyhow::Result<Shared> {
|
||||
let (models, play_model) = lane_models();
|
||||
let mut all: Vec<&str> = models.each().to_vec();
|
||||
all.push(&play_model);
|
||||
|
|
@ -599,37 +599,6 @@ fn require_no_runtime_custody_failure(
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Counts every call and the usage the connector reports, around the real
|
||||
/// port, for the live check.
|
||||
struct CountingPort {
|
||||
inner: Arc<dyn InferencePort>,
|
||||
calls: std::sync::atomic::AtomicU64,
|
||||
usage: std::sync::Mutex<(u64, u64)>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InferencePort for CountingPort {
|
||||
fn prepare(
|
||||
&self,
|
||||
request: ghostlight::InferenceRequest,
|
||||
) -> Result<ghostlight::PreparedInference, ghostlight::InferenceFault> {
|
||||
self.inner.prepare(request)
|
||||
}
|
||||
|
||||
async fn infer(
|
||||
&self,
|
||||
request: ghostlight::PreparedInference,
|
||||
) -> Result<ghostlight::InferenceOutput, ghostlight::InferenceFault> {
|
||||
self.calls.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
||||
let output = self.inner.infer(request).await?;
|
||||
let seen = serde_json::to_value(&output).unwrap_or_default();
|
||||
let mut usage = self.usage.lock().unwrap();
|
||||
usage.0 += seen["usage"]["prompt"].as_u64().unwrap_or(0);
|
||||
usage.1 += seen["usage"]["completion"].as_u64().unwrap_or(0);
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
|
||||
/// Live: Begin on an imported snapshot through the real connector.
|
||||
/// `GHOSTLIGHT_LIVE_STATE_ROOT` holds `snapshots/` from `import-vault`,
|
||||
/// `GHOSTLIGHT_LIVE_PROFILE` names the profile, and the connector address
|
||||
|
|
@ -648,11 +617,7 @@ mod tests {
|
|||
let profile = std::env::var("GHOSTLIGHT_LIVE_PROFILE").unwrap();
|
||||
prepare_admitted_state_layout(&root).unwrap();
|
||||
let shared = open_shared().unwrap();
|
||||
let counting = Arc::new(CountingPort {
|
||||
inner: shared.inference.clone(),
|
||||
calls: Default::default(),
|
||||
usage: Default::default(),
|
||||
});
|
||||
let counting = crate::test_support::CountingPort::new(shared.inference.clone());
|
||||
let shared = Shared { inference: counting.clone(), ..shared };
|
||||
let (fatal, _fatal_events) = mpsc::unbounded_channel();
|
||||
let timelines = Timelines::new(root.clone(), shared, fatal);
|
||||
|
|
@ -691,8 +656,8 @@ mod tests {
|
|||
Some(SeedStatus::Seeding) => tokio::time::sleep(Duration::from_secs(2)).await,
|
||||
}
|
||||
};
|
||||
let (calls, usage) = (counting.calls.load(std::sync::atomic::Ordering::SeqCst), *counting.usage.lock().unwrap());
|
||||
println!("LIVE ready after {ready:?}; calls={calls} prompt_tokens={} completion_tokens={}", usage.0, usage.1);
|
||||
let used = counting.totals();
|
||||
println!("LIVE ready after {ready:?}; calls={} prompt_tokens={} completion_tokens={}", used.calls, used.prompt, used.completion);
|
||||
let host = timelines.host(&begun.timeline).await.unwrap();
|
||||
// A position is not public on the snapshot; the Debug text names it by
|
||||
// the same entity id a place carries.
|
||||
|
|
@ -726,13 +691,8 @@ mod tests {
|
|||
while host.sweeping.try_lock().is_err() && sweep_started.elapsed() < Duration::from_secs(1800) {
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
}
|
||||
let (calls, usage) = (counting.calls.load(std::sync::atomic::Ordering::SeqCst), *counting.usage.lock().unwrap());
|
||||
println!(
|
||||
"LIVE after run-ahead at {:?}: calls={calls} prompt_tokens={} completion_tokens={}",
|
||||
started.elapsed(),
|
||||
usage.0,
|
||||
usage.1
|
||||
);
|
||||
let used = counting.totals();
|
||||
println!("LIVE after run-ahead at {:?}: calls={} prompt_tokens={} completion_tokens={}", started.elapsed(), used.calls, used.prompt, used.completion);
|
||||
report("after run-ahead", &host.world.snapshot().await.unwrap());
|
||||
}
|
||||
|
||||
|
|
|
|||
173
crates/ghostlight-dungeon/src/test_support.rs
Normal file
173
crates/ghostlight-dungeon/src/test_support.rs
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
//! Test support the API tests, the live runtime check and the playtest
|
||||
//! harness share: a counting port that keeps usage per model, and the one
|
||||
//! assembly of an `AppState` with signed-in test sessions.
|
||||
|
||||
use crate::{
|
||||
app_session::AppSessionOwner,
|
||||
begin::{Scale, Vaults},
|
||||
catalog::Catalog,
|
||||
heimdall::{HeimdallPort, VerifiedSessionAdmission},
|
||||
runtime::AppState,
|
||||
timelines::Timelines,
|
||||
};
|
||||
use chrono::Utc;
|
||||
use ghostlight::{
|
||||
InferenceFault, InferenceOutput, InferencePort, InferenceRequest, PreparedInference,
|
||||
};
|
||||
use serde_json::Value;
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
path::Path,
|
||||
sync::{Arc, Mutex as StdMutex},
|
||||
};
|
||||
use tokio::sync::{Mutex, mpsc};
|
||||
|
||||
/// What one model was asked and what the provider says it spent.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub(crate) struct ModelUsage {
|
||||
pub(crate) calls: u64,
|
||||
pub(crate) prompt: u64,
|
||||
pub(crate) cached_prompt: u64,
|
||||
pub(crate) completion: u64,
|
||||
}
|
||||
|
||||
/// Counts every call and the usage the connector reports, per model, around
|
||||
/// the real port.
|
||||
pub(crate) struct CountingPort {
|
||||
inner: Arc<dyn InferencePort>,
|
||||
usage: StdMutex<BTreeMap<String, ModelUsage>>,
|
||||
}
|
||||
|
||||
impl CountingPort {
|
||||
pub(crate) fn new(inner: Arc<dyn InferencePort>) -> Arc<Self> {
|
||||
Arc::new(Self { inner, usage: StdMutex::new(BTreeMap::new()) })
|
||||
}
|
||||
|
||||
pub(crate) fn by_model(&self) -> BTreeMap<String, ModelUsage> {
|
||||
self.usage.lock().unwrap().clone()
|
||||
}
|
||||
|
||||
pub(crate) fn totals(&self) -> ModelUsage {
|
||||
self.by_model().values().fold(ModelUsage::default(), |sum, each| ModelUsage {
|
||||
calls: sum.calls + each.calls,
|
||||
prompt: sum.prompt + each.prompt,
|
||||
cached_prompt: sum.cached_prompt + each.cached_prompt,
|
||||
completion: sum.completion + each.completion,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// The model a prepared request names: the `model` key wherever the request's
|
||||
/// serialization keeps it, including inside a string that holds JSON.
|
||||
fn model_of(value: &Value) -> Option<String> {
|
||||
match value {
|
||||
Value::Object(map) => map
|
||||
.get("model")
|
||||
.and_then(Value::as_str)
|
||||
.map(str::to_owned)
|
||||
.or_else(|| map.values().find_map(model_of)),
|
||||
Value::Array(items) => items.iter().find_map(model_of),
|
||||
Value::String(text) if text.starts_with('{') => {
|
||||
serde_json::from_str::<Value>(text).ok().and_then(|inner| model_of(&inner))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InferencePort for CountingPort {
|
||||
fn prepare(&self, request: InferenceRequest) -> Result<PreparedInference, InferenceFault> {
|
||||
self.inner.prepare(request)
|
||||
}
|
||||
|
||||
async fn infer(&self, request: PreparedInference) -> Result<InferenceOutput, InferenceFault> {
|
||||
let model = serde_json::to_value(&request)
|
||||
.ok()
|
||||
.and_then(|seen| model_of(&seen))
|
||||
.unwrap_or_else(|| "unknown".into());
|
||||
let output = self.inner.infer(request).await?;
|
||||
let usage = output.usage();
|
||||
let mut table = self.usage.lock().unwrap();
|
||||
let row = table.entry(model).or_default();
|
||||
row.calls += 1;
|
||||
if let Some(usage) = usage {
|
||||
row.prompt += usage.prompt;
|
||||
row.cached_prompt += usage.cached_prompt.unwrap_or(0);
|
||||
row.completion += usage.completion;
|
||||
}
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
|
||||
/// An `AppState` over the given pieces with one signed-in session per entry of
|
||||
/// `accounts` (the same account twice is the same player on two devices), the
|
||||
/// session cookies in order, and the receiver of the fatal signals. Session
|
||||
/// custody lives under `directory`.
|
||||
pub(crate) fn assemble(
|
||||
directory: &Path,
|
||||
catalog: Arc<Mutex<Catalog>>,
|
||||
timelines: Arc<Timelines>,
|
||||
scale: Arc<Scale>,
|
||||
vaults: Arc<dyn Vaults>,
|
||||
heimdall: Arc<dyn HeimdallPort>,
|
||||
accounts: &[&str],
|
||||
) -> (AppState, Vec<String>, mpsc::UnboundedReceiver<String>) {
|
||||
let key = directory.join("session.key");
|
||||
std::fs::write(&key, [17_u8; 32]).unwrap();
|
||||
let mut sessions =
|
||||
AppSessionOwner::open(directory.join("service/app-sessions-v2.cc"), &key).unwrap();
|
||||
let cookies = accounts
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, account)| {
|
||||
sessions
|
||||
.create_session(VerifiedSessionAdmission::fixture(
|
||||
*account,
|
||||
format!("heimdall-session-{index}"),
|
||||
1,
|
||||
Utc::now() + chrono::Duration::hours(1),
|
||||
Utc::now() + chrono::Duration::days(1),
|
||||
"fixture-refresh",
|
||||
))
|
||||
.unwrap()
|
||||
})
|
||||
.collect();
|
||||
let (fatal, fatal_events) = mpsc::unbounded_channel();
|
||||
let state = AppState {
|
||||
catalog,
|
||||
timelines,
|
||||
vaults,
|
||||
scale,
|
||||
sessions: Arc::new(Mutex::new(sessions)),
|
||||
heimdall,
|
||||
auth: Arc::default(),
|
||||
runtime_id: "ghostlight-test".into(),
|
||||
runtime_health: None,
|
||||
fatal,
|
||||
};
|
||||
(state, cookies, fatal_events)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::play::tests::ScriptedPort;
|
||||
|
||||
#[test]
|
||||
fn a_prepared_request_names_its_model() {
|
||||
let port = ScriptedPort::new(vec![]);
|
||||
let request = InferenceRequest::play(
|
||||
ghostlight::CommandId::new(),
|
||||
0,
|
||||
"claude-opus-5-5",
|
||||
"be brief",
|
||||
vec![],
|
||||
vec![],
|
||||
100,
|
||||
)
|
||||
.unwrap();
|
||||
let prepared = port.prepare(request).unwrap();
|
||||
let seen = serde_json::to_value(&prepared).unwrap();
|
||||
assert_eq!(model_of(&seen).as_deref(), Some("claude-opus-5-5"));
|
||||
}
|
||||
}
|
||||
89
scripts/playtest-yggdrasil.sh
Normal file
89
scripts/playtest-yggdrasil.sh
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/env bash
|
||||
# Run the Dungeon playtest on Yggdrasil: build the test binary once, then run it
|
||||
# detached under a transient systemd unit that loads the Ghostlight connector key.
|
||||
#
|
||||
# scripts/playtest-yggdrasil.sh [--turns N] [--worlds id,id] [--wall-minutes M]
|
||||
# [--out DIR] [--rev REV]
|
||||
#
|
||||
# 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
|
||||
# Eureka skill's ygg-verify.sh reachable as $YGG_VERIFY (default
|
||||
# ~/.claude/skills/eureka/tools/stopgap/ygg-verify.sh). The launcher clones REV on
|
||||
# Yggdrasil, builds there, and exits once the unit is running; the unit keeps going.
|
||||
# Vault copies live under $VAULT_BASE (default ~/ghostlight-playtest/vaults, holding
|
||||
# AetheriaLore/Aetheria and Delvehold/Delvehold); output goes under $OUT_BASE.
|
||||
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=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--turns) turns=$2; shift 2 ;;
|
||||
--worlds) worlds=$2; shift 2 ;;
|
||||
--wall-minutes) wall=$2; shift 2 ;;
|
||||
--out) out=$2; shift 2 ;;
|
||||
--rev) rev=$2; shift 2 ;;
|
||||
--on-host) on_host=1; shift ;;
|
||||
--stamp) stamp=$2; shift 2 ;;
|
||||
*) echo "unknown argument $1" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$on_host" = 0 ]; then
|
||||
here=$(cd "$(dirname "$0")/.." && pwd)
|
||||
rev=${rev:-$(git -C "$here" rev-parse --short HEAD)}
|
||||
stamp=$(date -u +%Y-%m-%dT%H%MZ)
|
||||
verify=${YGG_VERIFY:-$HOME/.claude/skills/eureka/tools/stopgap/ygg-verify.sh}
|
||||
args="--on-host --rev $rev --stamp $stamp"
|
||||
[ -n "$turns" ] && args="$args --turns $turns"
|
||||
[ -n "$worlds" ] && args="$args --worlds $worlds"
|
||||
[ -n "$wall" ] && args="$args --wall-minutes $wall"
|
||||
[ -n "$out" ] && args="$args --out $out"
|
||||
RUN_ON_HOST=1 TIMEOUT=3000 bash "$verify" "$here" "$rev" "$IMAGE" "bash scripts/playtest-yggdrasil.sh $args"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# On the Yggdrasil host, inside the clone of REV.
|
||||
base=${PLAYTEST_BASE:-$HOME/ghostlight-playtest}
|
||||
out=${out:-$base/out}
|
||||
bin_dir=$base/bin
|
||||
mkdir -p "$bin_dir" "$out"
|
||||
bin=$bin_dir/ghostlight-dungeon-$rev
|
||||
if [ ! -x "$bin" ]; then
|
||||
sudo docker run --rm --cpus=4 --memory=6g \
|
||||
-v "$PWD:/src" -v eureka-cargo-home:/cargo-home -e CARGO_HOME=/cargo-home \
|
||||
-v /etc/machine-id:/etc/machine-id:ro -e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0='*' \
|
||||
-e GHOSTLIGHT_BUILD_COMMIT="$rev" -v "$bin_dir:/out" -w /src "$IMAGE" bash -c '
|
||||
set -euo pipefail
|
||||
exe=$(cargo test --locked -p ghostlight-dungeon --no-run --message-format=json 2>/out/build.log \
|
||||
| grep "\"test\":true" | grep "\"executable\":\"[^\"]*/ghostlight_dungeon-" \
|
||||
| sed "s/.*\"executable\":\"\([^\"]*\)\".*/\1/" | tail -1)
|
||||
test -n "$exe"
|
||||
cp "$exe" /out/ghostlight-dungeon-'"$rev"'
|
||||
'
|
||||
fi
|
||||
test -x "$bin"
|
||||
|
||||
unit=ghostlight-playtest-$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")
|
||||
[ -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")
|
||||
[ -n "${GHOSTLIGHT_CONTROLLER_MAX_CONCURRENT:-}" ] && env_args+=(--setenv=GHOSTLIGHT_CONTROLLER_MAX_CONCURRENT="$GHOSTLIGHT_CONTROLLER_MAX_CONCURRENT")
|
||||
|
||||
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
|
||||
|
||||
echo "unit: $unit"
|
||||
echo "output: $out/$stamp"
|
||||
echo "run log: $out/$stamp.run.log"
|
||||
echo "progress: tail -f $out/$stamp/progress.log"
|
||||
echo "status: systemctl status $unit"
|
||||
Loading…
Reference in a new issue