AM-4: gate scenario YAML, retarget on audited source, re-measure
Some checks failed
ci / check (push) Failing after 3s

Adopts both remediations from CB-EV-0001 §4 (maintainer decision).

Option A — serde_yaml is now optional behind cb-game-runtime's
`scenarios` feature. The scenario module, the ScenarioGame impl and the
string parsers behind it are cfg-gated; cb-sim opts in explicitly. Both
configurations compile and lint clean under -D warnings.

A trap worth recording: `default-features = false` on a *member*
dependency is silently ignored when the workspace dependency does not
specify it. The first attempt gated nothing while looking correct — the
build succeeded and cargo tree still showed all six YAML crates. Fixed
by setting it on the workspace dependency. This is the positive-control
failure mode in miniature: success was not evidence the change applied.

Retarget — AM-4 now measures third-party source under audit, split by
build configuration, replacing a crate count that was unreachable
without undoing K5/K7 and that does not compare across ecosystems.

Re-measured via the new `make dep-weight`, whose own positive control
refuses to report when any crate's source cannot be located:

  shipped runtime   23 crates   246,250 lines   target <=250,000  met
  dev toolchain     29 crates   317,021 lines   target <=350,000  met
  own source                      3,408 lines

Scenario tooling costs 70,771 lines a shipped game never compiles —
the split the single number was hiding.

Targets are set at current measurement plus headroom, so they bind on
future growth rather than retroactively passing what had failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tegwick 2026-07-31 03:35:41 +02:00
parent 8e11fc412e
commit 4be6e020ea
12 changed files with 271 additions and 43 deletions

View file

@ -2,6 +2,7 @@
//! GameKernel K15K16). Every rule realized here names its GR-id in a doc
//! comment, giving a greppable rule→code→scenario chain.
#[cfg(feature = "scenarios")]
use cb_game_runtime::{parse_actor, CommandStep, ScenarioGame, Setup};
use cb_kernel::{Actor, Aggregate, ChaChaRng, KernelRng, PlayerId, Rejection, Seed};
use serde::{Deserialize, Serialize};
@ -235,6 +236,7 @@ impl GroundChoice {
}
}
#[cfg(feature = "scenarios")]
fn parse(raw: &str, arg: Option<u64>) -> Result<Self, String> {
let need = |what: &str| {
arg.ok_or_else(|| format!("GROUND choice {raw:?} needs a {what} argument"))
@ -275,6 +277,7 @@ pub enum SupportResponse {
}
impl SupportResponse {
#[cfg(feature = "scenarios")]
fn parse(raw: &str) -> Result<Self, String> {
match raw {
"accept_bond" => Ok(SupportResponse::AcceptBond),
@ -287,6 +290,7 @@ impl SupportResponse {
}
impl GroundMode {
#[cfg(feature = "scenarios")]
fn parse(raw: &str) -> Result<Self, String> {
match raw {
"GR" => Ok(GroundMode::Gr),
@ -329,6 +333,7 @@ pub enum Action {
}
impl Action {
#[cfg(feature = "scenarios")]
fn parse(raw: &str) -> Result<Self, String> {
match raw {
"INVESTIGATE" => Ok(Action::Investigate),
@ -1741,6 +1746,7 @@ impl GroundState {
}
/// GR-S01: hidden-Problem priorities admitted per player count.
#[cfg(feature = "scenarios")]
fn problem_priorities(players: u8) -> Result<u8, String> {
match players {
2 => Ok(2),
@ -1752,6 +1758,7 @@ fn problem_priorities(players: u8) -> Result<u8, String> {
/// 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<SolutionCard> {
[Suit::Clarify, Suit::Repair, Suit::Boundary, Suit::Change]
.into_iter()
@ -1759,6 +1766,7 @@ fn core_solution_deck() -> Vec<SolutionCard> {
.collect()
}
#[cfg(feature = "scenarios")]
impl ScenarioGame for GroundState {
/// GR-S01..S04. The `standard-Np` presets differ only in seat count;
/// Problem content is scenario data, so the preset uses the canonical