T08 iter 1: scenario runner executes; GROUND setup and Select step
Replaces the RunOutcome::Unimplemented stub with a real runner: - ScenarioGame trait: games own setup presets and the command vocabulary, the runner owns execution, assertions, and determinism. - K8 double-run: every scenario runs twice on the same seed and fails on state-hash divergence. - K4/K11: applied events go through Envelope into EventLog, so seq monotonicity is enforced on the real path, not just in unit tests. - setup.patch was parsed and silently dropped; the runner now applies it generically and errors on a path that does not exist, so a typo in a scenario can never pass as a no-op. - Assertions: dot-path state lookup over objects and arrays, ordered event subsequence matching by field subset, exact rejects-set match. GROUND rules realized: GR-S01..S04 setup (seeded shuffle, deal, Lead, Surface Problem face up), GR-R02 Select commit, GR-R03 stress gate and Freedom spend, GR-A13 targeting legality. cb-sim dispatches by the scenario's game prefix and reports rule coverage. 3 scenarios pass, 7 rules covered; fmt/clippy/tests green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
be52250850
commit
a09d76f370
7 changed files with 848 additions and 47 deletions
|
|
@ -1,9 +1,10 @@
|
|||
//! cb-sim — scenario runner binary (GameKernel K17; precursor of `cb sim`).
|
||||
//! T07 scope: parse and validate scenario files, report coverage tags.
|
||||
//! T08 wires execution. Exit codes: 0 all passed, 1 failures, 2 not yet
|
||||
//! executable (parse-only), 64 usage error.
|
||||
//! Parses scenario files, dispatches each to its game by the `<game>/`
|
||||
//! prefix of its `scenario` field, and executes it. Exit codes: 0 all
|
||||
//! passed, 1 failures, 2 unknown game, 64 usage error.
|
||||
|
||||
use cb_game_runtime::{scenario, RunOutcome, ScenarioFile};
|
||||
use games_ground::GroundState;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
|
|
@ -12,8 +13,10 @@ fn main() {
|
|||
std::process::exit(64);
|
||||
}
|
||||
|
||||
let mut unimplemented = false;
|
||||
let mut unknown_game = false;
|
||||
let mut failed = false;
|
||||
let mut passed = 0usize;
|
||||
let mut covered: Vec<String> = Vec::new();
|
||||
|
||||
for path in &args {
|
||||
let text = match std::fs::read_to_string(path) {
|
||||
|
|
@ -24,36 +27,50 @@ fn main() {
|
|||
continue;
|
||||
}
|
||||
};
|
||||
match ScenarioFile::from_yaml(&text) {
|
||||
let sc = match ScenarioFile::from_yaml(&text) {
|
||||
Err(e) => {
|
||||
eprintln!("{path}: parse error: {e}");
|
||||
failed = true;
|
||||
continue;
|
||||
}
|
||||
Ok(sc) => sc,
|
||||
};
|
||||
|
||||
let outcome = match sc.scenario.split('/').next() {
|
||||
Some("ground") => scenario::run::<GroundState>(&sc),
|
||||
_ => {
|
||||
println!("SKIP {} — no game registered for this prefix", sc.scenario);
|
||||
unknown_game = true;
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
match outcome {
|
||||
RunOutcome::Passed { covers } => {
|
||||
println!(
|
||||
"PASS {} covers={}{}",
|
||||
sc.scenario,
|
||||
covers.join(","),
|
||||
if sc.provisional { " provisional" } else { "" }
|
||||
);
|
||||
covered.extend(covers);
|
||||
passed += 1;
|
||||
}
|
||||
RunOutcome::Failed { reason } => {
|
||||
println!("FAIL {} — {reason}", sc.scenario);
|
||||
failed = true;
|
||||
}
|
||||
Ok(sc) => match scenario::run(&sc) {
|
||||
RunOutcome::Passed { covers } => {
|
||||
println!("PASS {} covers={}", sc.scenario, covers.join(","));
|
||||
}
|
||||
RunOutcome::Failed { reason } => {
|
||||
println!("FAIL {} — {reason}", sc.scenario);
|
||||
failed = true;
|
||||
}
|
||||
RunOutcome::Unimplemented => {
|
||||
println!(
|
||||
"PARSED {} covers={}{} (runner not yet implemented — T08)",
|
||||
sc.scenario,
|
||||
sc.covers.join(","),
|
||||
if sc.provisional { " provisional" } else { "" }
|
||||
);
|
||||
unimplemented = true;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
covered.sort();
|
||||
covered.dedup();
|
||||
println!("{passed} passed, {} rules covered", covered.len());
|
||||
|
||||
if failed {
|
||||
std::process::exit(1);
|
||||
}
|
||||
if unimplemented {
|
||||
if unknown_game {
|
||||
std::process::exit(2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue