diff --git a/Makefile b/Makefile index e0ddc1d..d7f70ab 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ TOOLS := $(REPO)/tools # Every cargo recipe runs at the repo root; the shell does not persist cd. IN_REPO := cd $(REPO) && -.PHONY: check test sim bench bench-test coverage dep-weight cost cost-test cost-pin cost-budget shape-budget cost-mix loop-lint self-tests env-test task-done status facts-check facts-gen mutation-check size-metrics runtime-metrics build-time am6 am7 am8 replay-test loc play gate-review all +.PHONY: check test sim bench bench-test coverage dep-weight cost cost-test cost-pin cost-budget shape-budget cost-mix loop-lint self-tests env-test task-done status facts-check facts-gen mutation-check size-metrics runtime-metrics build-time am6 am7 am8 edition-check replay-test loc play gate-review all ## fmt + clippy (deny warnings) + HashMap deny-lint check: @@ -63,6 +63,11 @@ am6: $(IN_REPO) $(CARGO) test --release -p games-ground --all-features \ am6_throughput -- --ignored --nocapture --test-threads=1 +# ADR-0011 D2: is the vendored edition still what ground-game published? +# Reports "upstream not checked out" as its own outcome, never a pass. +edition-check: + $(PY) $(TOOLS)/edition-check.py + # AM-8 N=10 determinism gate. One scenario, ten same-seed replays, all # compared to the first. Not all 25: `make sim` already runs K8's double- # run over every scenario, and repeating that eight more times costs 47 s @@ -120,6 +125,7 @@ self-tests: $(PY) $(TOOLS)/runtime-metrics.py --self-test $(PY) $(TOOLS)/replay-test.py --self-test $(PY) $(TOOLS)/design-baseline.py --self-test + $(PY) $(TOOLS)/edition-check.py --self-test # T01 positive control: prove the environment fix, do not assume it. Runs # every tool from a foreign working directory with a PATH that has no @@ -204,4 +210,4 @@ loc: printf '%-28s %s\n' $$d "$$(find $$d/src -name '*.rs' | xargs cat | grep -vcE '^\s*(//|$$)')"; \ done -all: check test sim coverage size-metrics runtime-metrics am6 am7 am8 replay-test dep-weight self-tests env-test facts-check loop-lint bench-test +all: check test sim coverage size-metrics runtime-metrics am6 am7 am8 edition-check replay-test dep-weight self-tests env-test facts-check loop-lint bench-test diff --git a/decisions/ADR-0011-vendor-the-edition.md b/decisions/ADR-0011-vendor-the-edition.md new file mode 100644 index 0000000..6e6ed50 --- /dev/null +++ b/decisions/ADR-0011-vendor-the-edition.md @@ -0,0 +1,118 @@ +# ADR-0011: vendor the edition, read it by hand, and let the hashes move + +status: accepted +date: 2026-08-04 +decided by: agent, under the standing loop authorization +tier: M (structural M — adds or refuses an external dependency and changes +how a game is set up; chaos d8=7 → no override). Tier M merges survey and +decision into one document, which this is. +references: [CB-WP-0021](../workplans/CB-WP-0021-import-the-edition.md), +[ADR-0007](ADR-0007-render-html-not-a-port.md) D3 (the acquisition rule), +GROUND-WP-0002 T01 and GROUND-WP-0004 (ground-game's rulings) + +## Context + +`editions/ground-darvo-r0/Problems.csv` is authoritative (ground-game, +2026-08-03) and the engine has been inventing Problem values and suits. +GR-S01's deal was then ruled (2026-08-04): **Surface always ∪ hidden +`1..k`**, k = 2/3/4, giving available points **6 / 9 / 12** — which holds +*only* with the real values. + +## Correction: the constraint was measured against the wrong budget + +**CB-WP-0021's declaration said a CSV crate costs 21,613 lines against +AM-4a's 3,798 of headroom — "5.7× over, settled by measurement rather +than preference."** + +`setup` and `problem_priorities` are `#[cfg(feature = "scenarios")]`. +**They are not in the shipped runtime at all**, so AM-4a never sees them +and never would have. The budget that applies is AM-4b, and measured +against *its* graph: + +| | lines | +|---|---:| +| AM-4b headroom (745,000 − 725,258) | **19,742** | +| `csv` marginal cost (`csv` + `csv-core`; `ryu`, `itoa`, `memchr` already present via `serde_json`) | **17,651** | + +**It fits, with 2,091 lines to spare.** The declaration's confident +"settled by measurement" was measurement of the wrong thing — the third +premise this pass has had to correct, and the second where a real number +was computed against a mis-chosen denominator. + +## Decision 1 — refuse `csv`, on proportion rather than impossibility + +It fits and it is still refused, and the distinction matters because the +argument has to survive someone re-running the numbers. + +**17,651 lines is 89% of everything AM-4b has left, to read 20 rows.** The +next dependency after it would have 2,091 lines to live in. A hand-rolled +reader for this grammar is ~50 lines we own. + +INTENT's rule is *"assimilate the implementation"* — but that is about +**mature optimized libraries** for hard problems. Splitting quoted CSV +fields is not one, and `Problems.csv` is 20 rows read once at setup. +Taking a general parser here would spend the budget's remaining capacity +on the easiest problem we have. + +**If the data grows into something a hand reader should not own — nested +quoting, embedded newlines, multiple files with differing dialects — this +decision is wrong and `csv` is the answer.** That is the condition to +revisit under, stated now rather than left to taste. + +## Decision 2 — vendor the file, with a checked provenance + +`ground-game` is a separate repository. Two options: + +| | cost | +|---|---| +| **sibling checkout** | the build depends on a path that may not exist. CI runs `rust:1.97` with this repo only, so `make all` would fail or silently skip — and a silent skip is the class this project has found seven times | +| **vendor a copy** | clay-borg carries content it does not own, and a stale copy is worse than no copy | + +**Vendored**, at `editions/ground-darvo-r0/Problems.csv`, with a +`PROVENANCE` note naming the upstream repo, path and revision. + +The staleness answer is a **committed digest of the upstream file**. A +check compares it when `../ground-game` is present, and reports +**`upstream not checked out`** as a distinct outcome when it is not — never +a pass. That is the shape ADR-0009 used for `node`: an absent thing is +reported absent, not treated as satisfied. + +**Acquisition rule (ADR-0007 D3):** this is content the build causes to be +present, and it is ours now. It is not third-party *code* and does not +enter AM-4, but the provenance note is what stops it becoming +unattributed. + +## Decision 3 — the hashes move, and nothing pins them + +Problem values and suits enter `GroundState`, which is hashed (K7). The +declaration called this *"the reason the ADR exists."* Measured: + +| | | +|---|---| +| scenario files pinning a state hash | **0** | +| replay bundles committed | **0** | +| scenarios asserting on `problems.N.*` | **10 of 25** | + +**So the feared blast radius is not there.** K8's double-run compares two +runs of the same build; AM-7's probe compares segments within one run; +`replay-test` generates its bundle at run time. All are self-consistent +and survive a content change by construction. + +What breaks is **scenario expectations** — which is exactly what *should* +break when the content changes, and is why they are written as `expect` +blocks rather than hashes. + +**No hash is grandfathered and none is recorded as "was".** A recorded +hash that outlives the content it describes is a lie with a timestamp. + +## Consequences + +- The deal fix and the import land **together**. The ruled 6/9/12 holds + only with real values; the same deal with the stand-in gives 6/10/15, a + game nobody ruled on. +- `gd0001` is **inverted, not deleted** — it is the record of why the game + became winnable. +- If ground-game revises `r0` in place, the digest check fails loudly. + Per GROUND-WP-0002 T01's proposed contract, `point_value` and + `required_solution` may not change within a revision; this is the + mechanism that notices if they do. diff --git a/editions/ground-darvo-r0/PROVENANCE.md b/editions/ground-darvo-r0/PROVENANCE.md new file mode 100644 index 0000000..f0158bb --- /dev/null +++ b/editions/ground-darvo-r0/PROVENANCE.md @@ -0,0 +1,33 @@ +# Vendored edition data — provenance + +**Not ours.** This directory holds a copy of content owned by the +`ground-game` repository, vendored under ADR-0011 Decision 2 because the +build must not depend on a sibling checkout that CI does not have. + +| | | +|---|---| +| upstream repo | `ground-game` | +| upstream path | `editions/ground-darvo-r0/Problems.csv` | +| upstream revision | `9fd27a51f427a0a3dbeba04bc44c2e2eae894b3e` | +| vendored | 2026-08-04 | +| authoritative? | **yes** — ruled by ground-game, GROUND-WP-0002 T01 | + +## Digest + +``` +sha256 0a04830c93b62dcb2f4411a9fbde576368a7427fe9e63c5015e606e4d42d23a0 Problems.csv +``` + +`make edition-check` compares this against `../ground-game` when that +repository is present, and reports **`upstream not checked out`** as a +distinct outcome when it is not — never a pass. An absent check is +reported absent, not treated as satisfied (the shape ADR-0009 used for +`node`). + +## What may not change under this revision + +Per GROUND-WP-0002 T01's contract: `point_value` and +`required_solution` are **authoritative and frozen within `r0`**. The +engine hashes game state and both values are *in* that state, so a silent +change would rot every recorded scenario expectation. A change to either +is a new revision (`-r1`), and this digest is what notices. diff --git a/editions/ground-darvo-r0/Problems.csv b/editions/ground-darvo-r0/Problems.csv new file mode 100644 index 0000000..b19d202 --- /dev/null +++ b/editions/ground-darvo-r0/Problems.csv @@ -0,0 +1,21 @@ +problem_id,scenario_id,visibility,hidden_priority,title,problem_text,required_solution,symbol_id,point_value,front_rules,reveal_effect,unresolved_effect,back_design_id +PRB_01_S,SCN_01,Surface,0,Deadline Missed,A promised result was not delivered when expected.,Repair,SYM_REPAIR,2,Resolve with Repair. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM_SURFACE +PRB_01_1,SCN_01,Hidden,1,Unclear Ownership,Responsibility for the commitment and the work was never made explicit.,Clarify,SYM_CLARIFY,2,Resolve with Clarify. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_01_2,SCN_01,Hidden,2,Unspoken Overload,The work required more capacity than someone could safely or fairly provide.,Boundary,SYM_BOUNDARY,2,Resolve with Boundary. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_01_3,SCN_01,Hidden,3,Bad News Was Delayed,A warning was withheld until the remaining options became worse.,Repair,SYM_REPAIR,3,Resolve with Repair. Value: 3.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_01_4,SCN_01,Hidden,4,No Checkpoint Process,The group had no reliable moment for testing progress and changing course.,Change,SYM_CHANGE,3,Resolve with Change. Value: 3.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_02_S,SCN_02,Surface,0,Shared Task Left Undone,"A recurring responsibility was not completed, and others absorbed the impact.",Repair,SYM_REPAIR,2,Resolve with Repair. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM_SURFACE +PRB_02_1,SCN_02,Hidden,1,Different Standards,"Players were using different definitions of complete, timely, or fair.",Clarify,SYM_CLARIFY,2,Resolve with Clarify. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_02_2,SCN_02,Hidden,2,Invisible Workload,Some contributions and constraints were not visible to the group.,Boundary,SYM_BOUNDARY,2,Resolve with Boundary. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_02_3,SCN_02,Hidden,3,Resentment Never Raised,Frustration accumulated without a direct request or acknowledgement.,Repair,SYM_REPAIR,3,Resolve with Repair. Value: 3.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_02_4,SCN_02,Hidden,4,No Ownership Routine,The group relied on goodwill instead of a dependable allocation method.,Change,SYM_CHANGE,3,Resolve with Change. Value: 3.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_03_S,SCN_03,Surface,0,Decision Announced as Settled,A group-affecting choice was presented as final before meaningful agreement.,Boundary,SYM_BOUNDARY,2,Resolve with Boundary. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM_SURFACE +PRB_03_1,SCN_03,Hidden,1,Mandate Was Ambiguous,"It was unclear who could decide, advise, consent, or veto.",Clarify,SYM_CLARIFY,2,Resolve with Clarify. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_03_2,SCN_03,Hidden,2,Contributions Were Dismissed,Relevant input was ignored or treated as less legitimate.,Repair,SYM_REPAIR,2,Resolve with Repair. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_03_3,SCN_03,Hidden,3,One Voice Spoke for Others,A player claimed authority to represent people who had not agreed.,Boundary,SYM_BOUNDARY,3,Resolve with Boundary. Value: 3.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_03_4,SCN_03,Hidden,4,No Decision Rule,The group had no shared method for turning discussion into a legitimate choice.,Change,SYM_CHANGE,3,Resolve with Change. Value: 3.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_04_S,SCN_04,Surface,0,Private Information Spread,Information moved beyond the circle in which it was originally shared.,Repair,SYM_REPAIR,2,Resolve with Repair. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM_SURFACE +PRB_04_1,SCN_04,Hidden,1,Confidentiality Was Assumed,The players never made the scope of confidentiality explicit.,Clarify,SYM_CLARIFY,2,Resolve with Clarify. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_04_2,SCN_04,Hidden,2,Exposure Caused Harm,"The sharing changed another player's safety, reputation, or freedom to choose.",Repair,SYM_REPAIR,2,Resolve with Repair. Value: 2.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_04_3,SCN_04,Hidden,3,Consent Boundary Was Ignored,A clear or reasonably expected limit on sharing was crossed.,Boundary,SYM_BOUNDARY,3,Resolve with Boundary. Value: 3.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM +PRB_04_4,SCN_04,Hidden,4,No Sharing Protocol,"The group lacked a repeatable rule for consent, need-to-know, and escalation.",Change,SYM_CHANGE,3,Resolve with Change. Value: 3.,None in the core set.,No card-specific effect; it simply remains unsolved.,BACK_PROBLEM diff --git a/games/ground/src/bot.rs b/games/ground/src/bot.rs index bedfe2c..9e4fd3f 100644 --- a/games/ground/src/bot.rs +++ b/games/ground/src/bot.rs @@ -1077,42 +1077,12 @@ mod tests { } } - /// **A recorded finding, not a desired property.** With the standard - /// preset's placeholder Problem values (value = priority), the total - /// a game can possibly reach is below GR-E01's threshold at 2, 3 and - /// 4 players — group success is unreachable regardless of play. Only - /// 5–6p can clear its 9. - /// - /// This test pins the arithmetic so the gap cannot close silently. - /// **It is expected to fail** when Problem values become scenario - /// data (GR-S01 calls the current fixture a stand-in); the failure is - /// the signal to delete it, not to re-tune it. - #[test] - fn the_standard_preset_cannot_reach_the_threshold_below_five_seats() { - let mut report = Vec::new(); - for players in 2..=6u8 { - let initial = setup(players, 42); - let best: u32 = initial.problems.values().map(|p| u32::from(p.value)).sum(); - let threshold = play(initial, &mut policies("greedy", players, 42)) - .expect("game") - .state - .outcome - .expect("outcome") - .threshold; - report.push(format!("{players}p best {best} vs threshold {threshold}")); - if players < 5 { - assert!( - best < threshold, - "{players}p: best {best} now reaches threshold {threshold} — \ - the fixture changed, delete this test" - ); - } else { - assert!( - best >= threshold, - "{players}p: best {best} cannot reach threshold {threshold}" - ); - } - } - println!("GR-E01 reachability: {}", report.join(", ")); - } + // `the_standard_preset_cannot_reach_the_threshold_below_five_seats` + // lived here and was deleted 2026-08-04, on its own instruction: it + // said "the failure is the signal to delete it, not to re-tune it". + // ground-game ruled GR-S01's deal and the game became winnable. + // + // The record did not go with it. `gd0001_group_success_is_reachable_at + // _every_seat_count` in lib.rs is the same arithmetic, inverted rather + // than removed, and carries why the numbers changed. } diff --git a/games/ground/src/edition.rs b/games/ground/src/edition.rs new file mode 100644 index 0000000..39b5649 --- /dev/null +++ b/games/ground/src/edition.rs @@ -0,0 +1,150 @@ +//! The edition dataset, vendored and read by hand (ADR-0011). +//! +//! `Problems.csv` is authoritative (ground-game, GROUND-WP-0002 T01). The +//! engine used to invent Problem values and suits; it reads them now. +//! +//! **Why not the `csv` crate.** It fits — 17,651 marginal lines against +//! AM-4b's 19,742 of headroom — and is refused anyway, because that is +//! 89% of everything the budget has left to read 20 rows, and the next +//! dependency would have 2,091 lines to live in. If this data ever grows +//! nested quoting, embedded newlines, or multiple dialects, that decision +//! is wrong and `csv` is the answer (ADR-0011 D1). + +use crate::{SolutionCard, Suit}; + +/// One Problem as the edition prints it. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct EditionProblem { + /// `hidden_priority`: 0 is the Surface Problem. + pub priority: u8, + pub value: u8, + pub suit: Suit, + /// `visibility == "Surface"` — dealt face up (GR-S01). + pub surface: bool, +} + +const CSV: &str = include_str!("../../../editions/ground-darvo-r0/Problems.csv"); + +/// Split one CSV record, honouring `"…"` quoting. +/// +/// `problem_text` contains commas, which is the only reason this is not a +/// `split(',')`. Doubled quotes inside a quoted field are not handled and +/// do not occur; if they ever do, this returns the wrong field count and +/// `problems_of` fails loudly rather than mis-parsing. +fn fields(line: &str) -> Vec { + let mut out = Vec::new(); + let mut cur = String::new(); + let mut quoted = false; + for c in line.chars() { + match c { + '"' => quoted = !quoted, + ',' if !quoted => out.push(std::mem::take(&mut cur)), + c => cur.push(c), + } + } + out.push(cur); + out +} + +fn suit_of(s: &str) -> Option { + match s.trim() { + "Clarify" => Some(Suit::Clarify), + "Repair" => Some(Suit::Repair), + "Boundary" => Some(Suit::Boundary), + "Change" => Some(Suit::Change), + _ => None, + } +} + +/// Every Problem of one scenario, ordered by `hidden_priority`. +/// +/// Returns `Err` rather than an empty list when the data does not parse: +/// a loader that silently reads nothing would hand `setup` a game with no +/// Problems and look like a rules bug. +pub fn problems_of(scenario_id: &str) -> Result, String> { + let mut lines = CSV.lines(); + let header = lines.next().ok_or("edition data is empty")?; + let cols: Vec = fields(header) + .into_iter() + .map(|c| c.trim_start_matches('\u{feff}').trim().to_string()) + .collect(); + let at = |name: &str| -> Result { + cols.iter() + .position(|c| c == name) + .ok_or_else(|| format!("edition data has no column {name:?}")) + }; + let (c_scn, c_pri, c_val, c_sol, c_vis) = ( + at("scenario_id")?, + at("hidden_priority")?, + at("point_value")?, + at("required_solution")?, + at("visibility")?, + ); + + let mut out = Vec::new(); + for line in lines.filter(|l| !l.trim().is_empty()) { + let f = fields(line); + if f.len() != cols.len() { + return Err(format!( + "edition row has {} fields, header has {}: {line}", + f.len(), + cols.len() + )); + } + if f[c_scn].trim() != scenario_id { + continue; + } + out.push(EditionProblem { + priority: f[c_pri] + .trim() + .parse() + .map_err(|_| format!("hidden_priority {:?} is not a number", f[c_pri]))?, + value: f[c_val] + .trim() + .parse() + .map_err(|_| format!("point_value {:?} is not a number", f[c_val]))?, + suit: suit_of(&f[c_sol]) + .ok_or_else(|| format!("required_solution {:?} is not a suit", f[c_sol]))?, + surface: f[c_vis].trim() == "Surface", + }); + } + if out.is_empty() { + return Err(format!("edition data has no Problems for {scenario_id}")); + } + out.sort_by_key(|p| p.priority); + Ok(out) +} + +/// GR-S01 as ruled by ground-game 2026-08-04: **Surface always, plus +/// hidden priorities `1..=k`**, with k by seat band. Surface is never one +/// of the hidden slots. +/// +/// Available points are therefore 6 / 9 / 12 with this edition's values — +/// the numbers ground-game ruled the thresholds 5 / 7 / 9 against. +pub fn hidden_depth(players: u8) -> Result { + match players { + 2 => Ok(2), + 3..=4 => Ok(3), + 5..=6 => Ok(4), + other => Err(format!("GR-S01: unsupported player count {other}")), + } +} + +/// The Problems dealt at `players` seats, Surface first. +pub fn deal(scenario_id: &str, players: u8) -> Result, String> { + let k = hidden_depth(players)?; + let all = problems_of(scenario_id)?; + let dealt: Vec = all + .into_iter() + .filter(|p| p.surface || (p.priority >= 1 && p.priority <= k)) + .collect(); + Ok(dealt) +} + +/// The core Solution deck, 6 per suit in canonical order (GR-S04). +pub fn solution_deck() -> Vec { + [Suit::Clarify, Suit::Repair, Suit::Boundary, Suit::Change] + .into_iter() + .flat_map(|suit| std::iter::repeat_n(SolutionCard { suit }, 6)) + .collect() +} diff --git a/games/ground/src/lib.rs b/games/ground/src/lib.rs index 4fbe666..551c5a5 100644 --- a/games/ground/src/lib.rs +++ b/games/ground/src/lib.rs @@ -7,6 +7,8 @@ /// aggregate. That its tests do need `scenarios` is a real seam — setup /// presets currently live behind that feature (see `bot.rs`). pub mod bot; +#[cfg(feature = "scenarios")] +pub mod edition; /// K13's per-player projection (CB-WP-0008 T02) — the trait's first /// implementor. Needs the runtime's `Project`, which the game already @@ -1788,26 +1790,12 @@ impl GroundState { } } -/// GR-S01: hidden-Problem priorities admitted per player count. -#[cfg(feature = "scenarios")] -fn problem_priorities(players: u8) -> Result { - match players { - 2 => Ok(2), - 3..=4 => Ok(3), - 5..=6 => Ok(4), - other => Err(format!("GR-S01: unsupported player count {other}")), - } -} +// GR-S01's deal now lives in `edition::hidden_depth` (ADR-0011): the +// ruled shape is Surface + hidden 1..=k, and k belongs beside the data +// it indexes into. -/// GR-S04: the 24 core Solution cards, 6 per suit, in canonical order -/// before the seeded shuffle. -#[cfg(feature = "scenarios")] -fn core_solution_deck() -> Vec { - [Suit::Clarify, Suit::Repair, Suit::Boundary, Suit::Change] - .into_iter() - .flat_map(|suit| std::iter::repeat_n(SolutionCard { suit }, 6)) - .collect() -} +// GR-S04's deck now lives in `edition::solution_deck` (ADR-0011), +// beside the Problem data it is dealt against. #[cfg(feature = "scenarios")] impl ScenarioGame for GroundState { @@ -1824,11 +1812,14 @@ impl ScenarioGame for GroundState { setup.preset )); } - let priorities = problem_priorities(seats)?; + // GR-S01 as ruled 2026-08-04: Surface always, plus hidden + // priorities 1..=k. The values and suits come from the edition + // (ADR-0011); the engine used to invent both. + let dealt = crate::edition::deal("SCN_01", seats)?; let mut rng = ChaChaRng::from_seed(Seed(seed)); // GR-S04: shuffle first, then deal, so the deal is seed-derived. - let mut deck = core_solution_deck(); + let mut deck = crate::edition::solution_deck(); rng.shuffle(&mut deck); // GR-S02: Stress 2, Freedom READY, DARVO OFF, two Solution cards. @@ -1849,17 +1840,18 @@ impl ScenarioGame for GroundState { ); } - // GR-S01: priority 1 is the Surface Problem, face up; the rest - // start face down. - let suits = [Suit::Clarify, Suit::Repair, Suit::Boundary, Suit::Change]; - let problems = (1..=u32::from(priorities)) - .map(|priority| { + // Surface is dealt face up; hidden Problems face down (GR-S01). + // Keyed by 1-based position so scenario dot-paths stay stable. + let problems: BTreeMap = dealt + .iter() + .enumerate() + .map(|(i, p)| { ( - priority, + (i + 1) as u32, ProblemState { - suit: suits[(priority as usize - 1) % suits.len()], - value: priority as u8, - face_up: priority == 1, + suit: p.suit, + value: p.value, + face_up: p.surface, denied: false, claimed_by: None, protected_this_round: false, @@ -2041,10 +2033,26 @@ mod tests { assert_eq!(player.hand.len(), 2); } assert_eq!(state.solution_deck.len(), 24 - 6); - // GR-S01: 3 players → priorities 1–3, priority 1 face up. - assert_eq!(state.problems.len(), 3); - assert!(state.problems[&1].face_up); - assert!(!state.problems[&2].face_up); + // GR-S01 as ruled 2026-08-04: Surface always, plus hidden + // priorities 1..=k. At 3 players k = 3, so FOUR Problems are + // dealt — Surface face up, the three hidden ones face down. The + // engine used to deal Surface + (k-1), which is what made the + // group unable to reach GR-E01's threshold. + assert_eq!( + state.problems.len(), + 4, + "GR-S01 deals Surface + hidden 1..=3" + ); + assert!(state.problems[&1].face_up, "the Surface Problem is face up"); + for slot in 2..=4 { + assert!( + !state.problems[&slot].face_up, + "hidden Problem {slot} is face up" + ); + } + // The edition's values, not the stand-in's `value = priority`. + let dealt: Vec = (1..=4).map(|n| state.problems[&n].value).collect(); + assert_eq!(dealt, vec![2, 2, 2, 3], "edition point_value not loaded"); } /// GR-S03/S04: the same seed reproduces setup exactly; a different @@ -2476,25 +2484,28 @@ mod replay_probe { } } - /// **GD-0001: group success is arithmetically unreachable below 5 - /// seats**, and this is the reproduction rather than an argument. + /// **GD-0001, INVERTED 2026-08-04.** Group success is reachable at + /// every seat count. /// - /// The maintainer played several 3-player games on 2026-08-03 and - /// could not win any of them. This says why: claim *every* Problem - /// the deal puts in play, concede nothing, and the total still falls - /// short of GR-E01's threshold at 2, 3 and 4 seats. + /// This test used to assert the opposite, and it was right to: the + /// maintainer played several 3-player games on 2026-08-03 and could + /// not win any of them, because GR-S01 dealt 2/3/4 Problems worth + /// 3/6/10 against thresholds of 5/7/9. /// - /// It reads both numbers out of the engine — `problem_priorities` - /// (GR-S01's deal) and `threshold` (GR-E01) — so it cannot drift from - /// the rules it is testing, and it holds for **either dataset**: the - /// stand-in gives 3/6/10 and `Problems.csv` gives 4/6/9, against the - /// same 5/7/9. + /// ground-game ruled the deal on 2026-08-04 — **Surface always, plus + /// hidden priorities 1..=k** — which with this edition's values gives + /// **6 / 9 / 12**. The ruling said to invert this test rather than + /// retire it, and that is why it is still here: a reader learns the + /// game *became* winnable, not that a test quietly vanished. /// - /// **This test asserts the defect.** It is expected to keep passing - /// until ground-game rules, and to be inverted when it does — either - /// the deal count rises or the thresholds fall. + /// It reads both numbers out of the engine — the deal and + /// `threshold` — so it cannot drift from the rules it tests. + /// + /// **The 2p case is the one to watch.** 2+2+2 against a threshold of + /// 5 means a full clear: any two Problems sum to 4. Reachable is not + /// forgiving, and ground-game kept that deliberately. #[test] - fn gd0001_group_success_is_unreachable_below_five_seats() { + fn gd0001_group_success_is_reachable_at_every_seat_count() { let mut verdicts = Vec::new(); for seats in 2..=6u8 { let state = fresh_n(seats); @@ -2516,18 +2527,24 @@ mod replay_probe { .filter(|(_, _, _, _, ok)| !ok) .map(|(s, _, _, _, _)| *s) .collect(); - // Positive control: a run where everything is reachable would - // report a clean sheet and prove nothing. assert!( - !verdicts.is_empty() && verdicts.iter().any(|(_, _, _, _, ok)| *ok), - "no seat count was reachable; the harness measured nothing useful" + unreachable.is_empty(), + "group success is unreachable at {unreachable:?} seats — the \ + ruled deal (Surface + hidden 1..=k) is not what the engine \ + deals, or the edition values changed" ); + // The ruled numbers, asserted rather than implied: 6/9/12 against + // 5/7/9. A deal that was reachable for the wrong reason — more + // Problems, or richer ones — would pass the check above. + let available: Vec = verdicts.iter().map(|(_, _, b, _, _)| *b).collect(); assert_eq!( - unreachable, - vec![2, 3, 4], - "GD-0001 has changed: ground-game may have ruled. Re-read the \ - finding before editing this test." + available, + vec![6, 9, 9, 12, 12], + "available points are not the 6/9/12 ground-game ruled against" ); + // Positive control: a harness that measured nothing would report + // an empty `unreachable` and pass. + assert_eq!(verdicts.len(), 5, "the sweep did not cover 2..=6 seats"); } /// AM-7 scaling floor from GameKernel §5: fold throughput at 100k diff --git a/gates.toml b/gates.toml index 5a804c9..a806b36 100644 --- a/gates.toml +++ b/gates.toml @@ -19,7 +19,7 @@ # `loop-lint` fails when a target is in neither list. not_control_gates = [ "check", "test", "sim", "bench-test", "size-metrics", "runtime-metrics", - "am6", "am7", "am8", "replay-test", "dep-weight", "self-tests", "env-test", + "am6", "am7", "am8", "edition-check", "replay-test", "dep-weight", "self-tests", "env-test", ] [[gate]] diff --git a/scenarios/ground/gr-a02-solve.yaml b/scenarios/ground/gr-a02-solve.yaml index 86874f3..333ea67 100644 --- a/scenarios/ground/gr-a02-solve.yaml +++ b/scenarios/ground/gr-a02-solve.yaml @@ -11,8 +11,8 @@ setup: preset: standard-3p patch: "lead": 0 - "players.0.hand": [{ suit: Clarify }] - "players.1.hand": [{ suit: Clarify }] + "players.0.hand": [{ suit: Repair }] + "players.1.hand": [{ suit: Repair }] commands: - actor: P1 cmd: select_action @@ -39,5 +39,5 @@ expect: "problems.1.claimed_by": 0 "players.0.hand": [] # GR-A02: P2 resolved second, so its Solution is not spent. - "players.1.hand": [{ suit: Clarify }] + "players.1.hand": [{ suit: Repair }] rejects: [] diff --git a/scenarios/ground/gr-e01-threshold-reachable-2p.yaml b/scenarios/ground/gr-e01-threshold-reachable-2p.yaml new file mode 100644 index 0000000..f8afaea --- /dev/null +++ b/scenarios/ground/gr-e01-threshold-reachable-2p.yaml @@ -0,0 +1,66 @@ +scenario: ground/gr-e01-threshold-reachable-2p +description: > + GR-E01's threshold against the EDITION's Problem values, at the + 2-player boundary — the tightest band. Rewritten from + `gr-e01-threshold-unreachable-2p` on ground-game's ruling of + 2026-08-04, which called the old gap "not a design gap" and asked for + "a non-provisional import/fixture check: for every seat band, + sum(point_value of dealt Problems) >= threshold". + + The old scenario recorded a real defect: the engine dealt Surface + + (N-1) hidden, worth 3/6/10 against thresholds of 5/7/9, and a + maintainer could not win a 3-player game. GR-S01 was then ruled as + Surface + hidden 1..=k, giving 6/9/12. It is renamed rather than + deleted, because the record of why the numbers changed is worth more + than a clean directory. + + At 2p the deal is Surface(Repair,2) + hidden 1(Clarify,2) + + hidden 2(Boundary,2) = 6 against a threshold of 5. Reachable, and + ground-game kept it unforgiving on purpose: any TWO Problems sum to 4, + so success needs a full clear. +covers: [GR-E01, GR-E02, GR-O01] +provisional: false +seed: 42 +setup: + players: 2 + preset: standard-2p + patch: + "round": 5 + "mode": SharedGround + # A full clear: all three dealt Problems claimed. Anything less than + # all three cannot reach 5, which is the point of the band. + "problems.1.claimed_by": 0 + "problems.2.claimed_by": 1 + "problems.2.face_up": true + "problems.3.claimed_by": 0 + "problems.3.face_up": true +commands: + - actor: P1 + cmd: select_action + args: { action: GROUND } + - actor: P2 + cmd: select_action + args: { action: GROUND } + - actor: SYSTEM + cmd: reveal + - actor: P1 + cmd: choose_ground_mode + args: { mode: GR } + - actor: P2 + cmd: choose_ground_mode + args: { mode: GR } + - actor: SYSTEM + cmd: resolve + - actor: SYSTEM + cmd: end_round +expect: + events: + - kind: GameEnded + state: + # 2 + 2 + 2 = 6, the maximum a 2-player game can score, against 5. + "outcome.total": 6 + "outcome.threshold": 5 + "outcome.group_success": true + "round": 5 + "step": End + rejects: [] diff --git a/scenarios/ground/gr-e01-threshold-unreachable-2p.yaml b/scenarios/ground/gr-e01-threshold-unreachable-2p.yaml deleted file mode 100644 index 1a7ad5d..0000000 --- a/scenarios/ground/gr-e01-threshold-unreachable-2p.yaml +++ /dev/null @@ -1,53 +0,0 @@ -scenario: ground/gr-e01-threshold-unreachable-2p -description: > - GR-E01's threshold against the standard preset's Problem values, at the - 2-player boundary. Both Problems are claimed — the best case available - — and the total is 3 against a threshold of 5. With the placeholder - fixture (value = priority) group success is unreachable at 2, 3 and 4 - players; only 5–6p can reach its 9. Recorded here so the gap has a - failing-in-fact scenario rather than a paragraph, and marked provisional - because the fixture is explicitly a stand-in for scenario Problem data. -covers: [GR-E01, GR-E02, GR-O01] -provisional: true -provisional_owner: ground-game -provisional_raised: 2026-08-01 -seed: 42 -setup: - players: 2 - preset: standard-2p - patch: - "round": 5 - "mode": SharedGround - "problems.1.claimed_by": 0 - "problems.2.claimed_by": 1 - "problems.2.face_up": true -commands: - - actor: P1 - cmd: select_action - args: { action: GROUND } - - actor: P2 - cmd: select_action - args: { action: GROUND } - - actor: SYSTEM - cmd: reveal - - actor: P1 - cmd: choose_ground_mode - args: { mode: GR } - - actor: P2 - cmd: choose_ground_mode - args: { mode: GR } - - actor: SYSTEM - cmd: resolve - - actor: SYSTEM - cmd: end_round -expect: - events: - - kind: GameEnded - state: - # 1 + 2 = 3, the maximum any 2-player game of this preset can score. - "outcome.total": 3 - "outcome.threshold": 5 - "outcome.group_success": false - "round": 5 - "step": End - rejects: [] diff --git a/scenarios/ground/gr-e03-common-problem.yaml b/scenarios/ground/gr-e03-common-problem.yaml index ddf7a08..81ecd69 100644 --- a/scenarios/ground/gr-e03-common-problem.yaml +++ b/scenarios/ground/gr-e03-common-problem.yaml @@ -15,11 +15,15 @@ setup: patch: "round": 5 "mode": CommonProblem - # Every Problem claimed: 1+2+3+4 = 10, over the 5-6p threshold of 9. + # Four of the five dealt Problems claimed: 2+2+3+2 = 9, exactly the + # 5-6p threshold. P3 takes the 3-value Problem so the personal edge + # this scenario exists to test has a unique winner — with the edition + # values (2,2,2,3,3) an even spread would tie three ways and the test + # would assert nothing about GR-E03. "problems.1.claimed_by": 0 "problems.2.claimed_by": 1 - "problems.3.claimed_by": 2 - "problems.4.claimed_by": 3 + "problems.4.claimed_by": 2 + "problems.3.claimed_by": 3 "problems.2.face_up": true "problems.3.face_up": true "problems.4.face_up": true @@ -66,11 +70,11 @@ expect: events: - kind: GameEnded state: - "outcome.total": 10 + "outcome.total": 9 "outcome.threshold": 9 "outcome.group_success": true # GR-E03: claimed value −1 per Blame held. - "outcome.personal.3": 2 + "outcome.personal.3": 0 "outcome.personal.2": 3 # P4 claimed 4 and still loses: the Blame is load-bearing here. "outcome.winners": [2] diff --git a/scenarios/ground/gr-e04-coalitions.yaml b/scenarios/ground/gr-e04-coalitions.yaml index dd9f16d..663138d 100644 --- a/scenarios/ground/gr-e04-coalitions.yaml +++ b/scenarios/ground/gr-e04-coalitions.yaml @@ -15,7 +15,8 @@ setup: "lead": 0 "round": 5 "mode": BondedCoalitions - # Values 1+2+3 = 6 claimed; 3p threshold is 7, so no group success. + # Edition values 2+2+2 = 6 claimed; 3p threshold is 7, so still no + # group success — the band this scenario needs is unchanged. "problems.1.claimed_by": 0 "problems.2.claimed_by": 1 "problems.3.claimed_by": 2 @@ -45,12 +46,12 @@ expect: "outcome.total": 6 "outcome.group_success": false # P1 claimed value 1 less one Blame; P2 value 2; P3 value 3. - "outcome.personal.0": 0 + "outcome.personal.0": 1 "outcome.personal.1": 2 - "outcome.personal.2": 3 + "outcome.personal.2": 2 # GR-E04: P1+P2 are Bonded; the Rivalry leaves P3 solo. "outcome.coalitions.0.members": [0, 1] - "outcome.coalitions.0.score": 2 + "outcome.coalitions.0.score": 3 "outcome.coalitions.1.members": [2] - "outcome.coalitions.1.score": 3 + "outcome.coalitions.1.score": 2 rejects: [] diff --git a/scenarios/ground/gr-f02-no-gate.yaml b/scenarios/ground/gr-f02-no-gate.yaml index 105a368..4a05e0b 100644 --- a/scenarios/ground/gr-f02-no-gate.yaml +++ b/scenarios/ground/gr-f02-no-gate.yaml @@ -12,8 +12,8 @@ setup: "lead": 0 "players.0.stress": 3 "players.1.stress": 4 - "players.0.hand": [{ suit: Clarify }] - "players.1.hand": [{ suit: Clarify }] + "players.0.hand": [{ suit: Repair }] + "players.1.hand": [{ suit: Repair }] commands: # GR-F02: Stress 3 is below the gate, so SOLVE is available. - actor: P1 diff --git a/scenarios/ground/gr-p05-solve-legality.yaml b/scenarios/ground/gr-p05-solve-legality.yaml index 42e35b1..f8187ff 100644 --- a/scenarios/ground/gr-p05-solve-legality.yaml +++ b/scenarios/ground/gr-p05-solve-legality.yaml @@ -22,7 +22,7 @@ setup: patch: "lead": 1 "players.0.hand": [{ suit: Change }] - "players.1.hand": [{ suit: Clarify }] + "players.1.hand": [{ suit: Repair }] commands: # 0 — P1 holds no Clarify: refused. - actor: P1 diff --git a/tools/edition-check.py b/tools/edition-check.py new file mode 100755 index 0000000..8caffe6 --- /dev/null +++ b/tools/edition-check.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +"""Is the vendored edition still what ground-game published? (ADR-0011 D2) + +`editions/ground-darvo-r0/` is a copy of content owned by another repo. +A stale copy is worse than no copy, so the digest is committed and this +compares it. + +**An absent upstream is reported absent, never as a pass.** That is the +shape ADR-0009 used for `node`: a check that cannot run says so, because +a silent skip is the class this project has found seven times. +""" +import hashlib +import os +import re +import sys + +from repo import ROOT, enter_root + +VENDORED = "editions/ground-darvo-r0/Problems.csv" +PROVENANCE = "editions/ground-darvo-r0/PROVENANCE.md" +UPSTREAM = os.path.join(os.path.dirname(ROOT), "ground-game", VENDORED) + + +def digest(path): + return hashlib.sha256(open(path, "rb").read()).hexdigest() + + +def recorded(): + text = open(os.path.join(ROOT, PROVENANCE)).read() + m = re.search(r"sha256\s+([0-9a-f]{64})", text) + if not m: + raise ValueError(f"{PROVENANCE} records no sha256 digest") + return m.group(1) + + +def check(): + have = digest(os.path.join(ROOT, VENDORED)) + want = recorded() + print("edition-check — vendored data against its provenance") + if have != want: + print(f" [FAIL] {VENDORED} does not match its recorded digest") + print(f" recorded {want}\n actual {have}") + return 1 + print(f" [ok ] vendored copy matches its recorded digest") + + if not os.path.exists(UPSTREAM): + # NOT a pass and NOT a failure: the question could not be asked. + print(" [----] upstream not checked out — freshness UNVERIFIED") + print(f" expected {UPSTREAM}") + return 0 + up = digest(UPSTREAM) + if up != have: + print(" [FAIL] upstream has changed since this copy was vendored") + print(f" upstream {up}\n vendored {have}") + print(" ground-game froze point_value and required_solution") + print(" within r0 — a change here is a new revision, or a") + print(" contract violation worth raising.") + return 1 + print(" [ok ] vendored copy is current with ../ground-game") + return 0 + + +def self_test(): + """A checker that cannot detect a mismatch is decoration.""" + results = [] + + def chk(name, ok, detail=""): + results.append((name, ok, detail)) + + chk("the vendored file exists", os.path.exists(os.path.join(ROOT, VENDORED))) + chk("provenance records a digest", len(recorded()) == 64) + chk("digest of the real file matches provenance", + digest(os.path.join(ROOT, VENDORED)) == recorded()) + # The control that matters: a changed byte must be detected. + import tempfile + with tempfile.NamedTemporaryFile("wb", delete=False) as fh: + fh.write(open(os.path.join(ROOT, VENDORED), "rb").read() + b"\n#tamper\n") + tampered = fh.name + chk("a tampered copy has a different digest", + digest(tampered) != recorded(), "otherwise the check is decoration") + os.unlink(tampered) + + print("edition-check self-test (positive control)") + ok = True + for name, passed, det in results: + print(f" [{'ok ' if passed else 'FAIL'}] {name}" + (f" — {det}" if det else "")) + ok &= passed + return 0 if ok else 1 + + +if __name__ == "__main__": + enter_root() + raise SystemExit(self_test() if "--self-test" in sys.argv else check())