Skip to content

The design language that makes your AI harness better at design.

JavaScript

serve-question: refuse a comp-led direction round that declares no decision comps (#959)

Paul Bakaus62f461d629d9
diff --git a/crates/context/src/serve_question.rs b/crates/context/src/serve_question.rs
index e5742f119..19113db18 100644
--- a/crates/context/src/serve_question.rs
+++ b/crates/context/src/serve_question.rs
@@ -185,6 +185,52 @@ fn declared_comps(payload: &Value) -> Vec<String> {
out
}
+/// The cards a comp-led direction round leaves without a decision comp, by
+/// id (`canonCard` for the canon card, `options[<n>]` for a card with no
+/// id). The round owes a comp on every card, canon included and declined
+/// challengers excepted, only when all three hold: it is a direction round
+/// (it carries the canon exit, `canon` or `canonCard`, which surface rounds
+/// and the comp round never do), it has image generation and a comp-led
+/// default (`buildPath` `{"value": "comp", "toggle": true}`; a code-led
+/// round's slots are a flip reserve, and no toggle means no image
+/// generation), and it is a full hand (a degraded roll's single card is
+/// text-only). Empty when the round owes nothing or every card declares one.
+fn missing_direction_comps(payload: &Value) -> Vec<String> {
+ let comp_led = payload.pointer("/buildPath/value").and_then(Value::as_str) == Some("comp");
+ let toggle = payload.pointer("/buildPath/toggle") == Some(&Value::Bool(true));
+ let canon_card = payload.get("canonCard").filter(|c| c.is_object());
+ let direction = canon_card.is_some() || payload.get("canon").map(crate::staleness::js_truthy).unwrap_or(false);
+ let options = payload.get("options").and_then(Value::as_array).map(Vec::as_slice).unwrap_or(&[]);
+ if !comp_led || !toggle || !direction || options.len() < 2 {
+ return Vec::new();
+ }
+ let has_comp = |card: &Value| {
+ let comp = card.get("comp").filter(|v| !v.is_null()).or_else(|| card.get("sketch").filter(|v| !v.is_null()));
+ comp.map(crate::staleness::js_truthy).unwrap_or(false)
+ };
+ let mut missing: Vec<String> = options
+ .iter()
+ .enumerate()
+ .filter(|(_, o)| o.get("verdict").and_then(Value::as_str) != Some("declined") && !has_comp(o))
+ .map(|(i, o)| o.get("id").and_then(Value::as_str).filter(|s| !s.is_empty()).map(str::to_string).unwrap_or_else(|| format!("options[{}]", i)))
+ .collect();
+ if canon_card.is_some_and(|c| !has_comp(c)) {
+ missing.push("canonCard".into());
+ }
+ missing
+}
+
+/// The refusal `--start` and `--update` print for a comp-led direction round
+/// that declares no comp on some card. `rerun` names the command to repeat.
+fn missing_comps_message(missing: &[String], rerun: &str, outcome: &str) -> String {
+ format!(
+ "serve-question: this direction round is comp-led with image generation (buildPath value \"comp\", toggle true), so every card declares a decision comp, canon included, declined challengers excepted; {}. Missing a \"comp\": {}. Give each of those cards \"comp\": \".impeccable/mocks/decision/<card id>.png\" (the canon card's goes inside canonCard), then {}; the comps are generated after the page serves, as its NEXT line says.\n",
+ outcome,
+ missing.join(", "),
+ rerun
+ )
+}
+
/// Provenance of a hand lives in `<key>.hand.json`, written atomically by
/// `--start` and `--update` only, never by the server (whose heartbeat and
/// claim writes rewrite `<key>.state.json` and would race a shared field).
@@ -740,6 +786,11 @@ pub fn run(argv: &[String], io: &mut Io) -> i32 {
io.err("serve-question: --update payload needs an options array; nothing was delivered. Fix the payload and rerun --update on the same key.\n");
return 1;
}
+ let missing = missing_direction_comps(&next_round);
+ if !missing.is_empty() {
+ io.err(&missing_comps_message(&missing, "rerun --update on the same key", "nothing was delivered"));
+ return 1;
+ }
if !is_alive(&qdir, &key) {
io.err("serve-question: no live question server for that key; the page it served is gone too. Re-present the round with --start and a fresh key, or fall back to the structured question tool.\n");
return 2;
@@ -774,6 +825,11 @@ pub fn run(argv: &[String], io: &mut Io) -> i32 {
return 1;
}
};
+ let missing = missing_direction_comps(&start_payload);
+ if !missing.is_empty() {
+ io.err(&missing_comps_message(&missing, "rerun --start", "the page was not served"));
+ return 1;
+ }
let _ = std::fs::create_dir_all(&qdir);
let key = a.arg("key").unwrap_or_else(random_key);
let hand = match start_hand(&qdir, &key, &cwd, &start_payload) {
@@ -2008,6 +2064,120 @@ mod tests {
let _ = std::fs::remove_dir_all(&dir);
}
+ /// A comp-led direction round: the assigned card, the pick, a competitive
+ /// and a declined challenger, and the canon card.
+ fn direction_round(comps: bool) -> Value {
+ let comp = |id: &str| if comps { json!(format!(".impeccable/mocks/decision/{id}.png")) } else { Value::Null };
+ let mut p = json!({
+ "title": "Choose the visual world",
+ "options": [
+ { "id": "assigned", "kicker": "THE ROLL", "thesis": "One." },
+ { "id": "model-pick", "kicker": "IMPECCABLE’S PICK", "thesis": "Two." },
+ { "id": "challenger-a", "verdict": "competitive", "thesis": "Three.", "hero": "https://x/a-hero.webp" },
+ { "id": "challenger-b", "verdict": "declined", "thesis": "Four.", "hero": "https://x/b-hero.webp" }
+ ],
+ "reroll": { "registers": ["safer", "bolder"] },
+ "buildPath": { "value": "comp", "toggle": true },
+ "canon": true,
+ "canonCard": { "label": "The category standard", "thesis": "Five." }
+ });
+ if comps {
+ for (i, id) in ["assigned", "model-pick", "challenger-a"].iter().enumerate() {
+ p["options"][i]["comp"] = comp(id);
+ }
+ p["canonCard"]["comp"] = comp("canon");
+ }
+ p
+ }
+
+ #[test]
+ fn missing_direction_comps_names_every_eligible_card_without_one() {
+ let bare = direction_round(false);
+ assert_eq!(missing_direction_comps(&bare), vec!["assigned", "model-pick", "challenger-a", "canonCard"]);
+ // Declared everywhere it is owed: nothing missing; the declined
+ // challenger never owes one.
+ assert!(missing_direction_comps(&direction_round(true)).is_empty());
+ // One card short is enough, and the legacy sketch key counts.
+ let mut partial = direction_round(true);
+ partial["options"][1].as_object_mut().unwrap().remove("comp");
+ partial["options"][2]["sketch"] = partial["options"][2]["comp"].take();
+ partial["options"][2].as_object_mut().unwrap().remove("comp");
+ assert_eq!(missing_direction_comps(&partial), vec!["model-pick"]);
+ let mut no_canon_comp = direction_round(true);
+ no_canon_comp["canonCard"].as_object_mut().unwrap().remove("comp");
+ assert_eq!(missing_direction_comps(&no_canon_comp), vec!["canonCard"]);
+ // A card with no id is named by its index.
+ let mut no_id = direction_round(true);
+ no_id["options"][0].as_object_mut().unwrap().remove("id");
+ no_id["options"][0].as_object_mut().unwrap().remove("comp");
+ assert_eq!(missing_direction_comps(&no_id), vec!["options[0]"]);
+ // canon: true without a canonCard is a footer action, not a card.
+ let mut footer = bare.clone();
+ footer.as_object_mut().unwrap().remove("canonCard");
+ assert_eq!(missing_direction_comps(&footer), vec!["assigned", "model-pick", "challenger-a"]);
+ }
+
+ #[test]
+ fn missing_direction_comps_leaves_rounds_that_owe_none_alone() {
+ let with = |f: &dyn Fn(&mut Value)| {
+ let mut p = direction_round(false);
+ f(&mut p);
+ missing_direction_comps(&p)
+ };
+ // Code-led: the slots are a flip reserve.
+ assert!(with(&|p| p["buildPath"]["value"] = json!("code")).is_empty());
+ // No toggle, or no buildPath at all: no image generation this round.
+ assert!(with(&|p| p["buildPath"]["toggle"] = json!(false)).is_empty());
+ assert!(with(&|p| { p["buildPath"].as_object_mut().unwrap().remove("toggle"); }).is_empty());
+ assert!(with(&|p| { p.as_object_mut().unwrap().remove("buildPath"); }).is_empty());
+ // A surface round (no canon exit) and the comp round carry no canon.
+ assert!(with(&|p| { p.as_object_mut().unwrap().remove("canon"); p.as_object_mut().unwrap().remove("canonCard"); }).is_empty());
+ assert!(with(&|p| { p["canon"] = json!(false); p.as_object_mut().unwrap().remove("canonCard"); }).is_empty());
+ // A degraded roll's single text-only card.
+ assert!(with(&|p| { p["options"] = json!([{ "id": "assigned", "thesis": "One." }]); }).is_empty());
+ }
+
+ #[test]
+ fn start_and_update_refuse_a_comp_led_direction_round_without_comps() {
+ let dir = temp_project("missing-comps");
+ let qdir = jsp::join(&[&dir.to_string_lossy(), ".impeccable", "questions"]);
+ std::fs::write(dir.join("p.json"), direction_round(false).to_string()).unwrap();
+ let run_err = |args: &[&str]| {
+ let env = Env::from([("IMPECCABLE_SKILL_DIR".into(), "/skill".into())]);
+ let (mut io, cap) = Io::captured("", dir.clone(), env);
+ let argv: Vec<String> = args.iter().map(|s| s.to_string()).collect();
+ let code = run(&argv, &mut io);
+ let out = String::from_utf8(cap.stdout.borrow().clone()).unwrap();
+ let err = String::from_utf8(cap.stderr.borrow().clone()).unwrap();
+ (code, out, err)
+ };
+ let (code, out, err) = run_err(&["--start", "--no-open", "--key", "k1", "--payload", "p.json"]);
+ assert_eq!(code, 1, "{err}");
+ assert!(out.is_empty(), "{out}");
+ assert!(err.contains("the page was not served"), "{err}");
+ assert!(err.contains("Missing a \"comp\": assigned, model-pick, challenger-a, canonCard."), "{err}");
+ assert!(err.contains(".impeccable/mocks/decision/<card id>.png") && err.contains("then rerun --start;"), "{err}");
+ // Refused before anything was recorded or spawned.
+ assert!(!std::path::Path::new(&hand_file(&qdir, "k1")).exists());
+ assert!(!std::path::Path::new(&state_file(&qdir, "k1")).exists());
+
+ // --update refuses the same round with the page left on its hand.
+ write_state(&dir, &json!({ "pid": std::process::id(), "port": 1, "url": "http://127.0.0.1:1/" }));
+ let (code, out, err) = run_err(&["--update", "--key", "k1", "--payload", "p.json"]);
+ assert_eq!(code, 1, "{err}");
+ assert!(out.is_empty(), "{out}");
+ assert!(err.contains("nothing was delivered") && err.contains("then rerun --update on the same key;"), "{err}");
+ assert!(!std::path::Path::new(&next_file(&qdir, "k1")).exists());
+ assert!(!std::path::Path::new(&hand_file(&qdir, "k1")).exists());
+
+ // With every comp declared, --update delivers and prints NEXT.
+ std::fs::write(dir.join("p.json"), direction_round(true).to_string()).unwrap();
+ let (code, out, err) = run_err(&["--update", "--key", "k1", "--payload", "p.json"]);
+ assert_eq!(code, 0, "{err}");
+ assert!(out.contains("next round delivered") && out.contains("NEXT read "), "{out}");
+ let _ = std::fs::remove_dir_all(&dir);
+ }
+
#[test]
fn markers_survive_a_failed_hand_write_and_leave_with_the_question() {
let dir = temp_project("markers");
diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.md
index f4fac192d..890c83570 100644
--- a/docs/CLI-CONTRACT.md
+++ b/docs/CLI-CONTRACT.md
@@ -436,9 +436,10 @@ retain their local-development trust behavior. See [bundle signing](BUNDLE-SIGNI
- `--schema`: prints canonical payload JSON (2-space) then a long explanatory paragraph; exit 0. (Copy verbatim from source lines 210-232.)
- `--wait --key K [--poll N]`: loops up to N s (1 s ticks): answer file → break; flip file exists → delete it, `stdout> BUILD PATH FLIPPED: comp (for this session only; never write it to settings). The table is still open and the page shows shimmer where the images will land: generate each open card’s comp into its declared path now, lead first, then collect the answer with --wait again. A card whose comp already exists needs nothing.` followed by the `NEXT` visualize line (**Decision comps**), exit 0; server dead (no fresh `lastBeat` <12 s and `process.kill(pid,0)` fails with non-EPERM) → `stdout> serve-question: the question server is gone with no answer. This is a server failure, not a user decision: restart it with --start --key ${K} and the same payload, reopen the URL for the user, and wait again. Never proceed without their choice while their browser session is open.` exit 2; `lastBeat` older than 15 s and not mid-delivery (next.json mtime <10 s or `claimedAt` <10 s) → `PAGE CLOSED: the question page went away without an answer; re-present, reopen the URL, or fall back to the structured question tool` exit 4; no answer after poll → `WAITING: no answer yet after ${N}s; run --wait --key ${K} again` exit 3; answer → `printAnswer`, delete answer file, delete state and hand files unless optionId `reroll` or `followup:true`; exit 0. Missing `--key` → `stderr> serve-question: --wait needs --key` exit 1.
- `--stop --key K`: kill pid from state, remove answer/state/hand, `stdout> stopped`, exit 0.
- - `--update --key K --payload F`: payload must have non-empty `options` (else stderr `serve-question: --update payload needs an options array; nothing was delivered. Fix the payload and rerun --update on the same key.` exit 1); server liveness like wait (dead → stderr `serve-question: no live question server for that key; the page it served is gone too. Re-present the round with --start and a fresh key, or fall back to the structured question tool.` exit 2); copies payload to `<key>.next.json`, touches mtime, writes a new hand to `<key>.hand.json`, `stdout> next round delivered; the page reloads itself`, then the `NEXT` visualize line when the new round's comps are due (**Decision comps**), exit 0.
- - `--start --payload F [--key K] [--open] [--timeout] [--idle-grace]`: validates JSON, decides the hand and writes `<key>.hand.json` when it is new (**Decision comps**), removes the key's previous state file without signalling its pid, spawns detached child `node serve-question.mjs --payload F --detached-serve --key K --timeout T [--idle-grace G] [--no-open unless --open]` with stdio to `<key>.log`; waits ≤8 s for state file; failure → stderr `serve-question: server failed to start` + last 4 log lines + `serve-question: log at <rel>. A sandboxed exec that cannot listen on localhost causes exactly this; rerun this command once through the harness's network-enabled or unsandboxed command tool before falling back.` exit 1; success stdout: `QUESTION URL: ${url}`, `QUESTION KEY: ${key}`, `Open the URL for the user now: in-app browser when the harness has one, otherwise the system opener (macOS \`open\`, Linux \`xdg-open\`), otherwise show the URL.`, the `NEXT` visualize line when the payload's comps are due (**Decision comps**), `Then collect the answer with: node <abs script> --wait --key ${key}`; exit 0. Key default `Math.random().toString(16).slice(2,10)`.
+ - `--update --key K --payload F`: payload must have non-empty `options` (else stderr `serve-question: --update payload needs an options array; nothing was delivered. Fix the payload and rerun --update on the same key.` exit 1); then the comp-led direction gate (**Missing decision comps** below; stderr, exit 1, `nothing was delivered`, before the liveness check, `<key>.next.json`, or the hand file are touched); server liveness like wait (dead → stderr `serve-question: no live question server for that key; the page it served is gone too. Re-present the round with --start and a fresh key, or fall back to the structured question tool.` exit 2); copies payload to `<key>.next.json`, touches mtime, writes a new hand to `<key>.hand.json`, `stdout> next round delivered; the page reloads itself`, then the `NEXT` visualize line when the new round's comps are due (**Decision comps**), exit 0.
+ - `--start --payload F [--key K] [--open] [--timeout] [--idle-grace]`: validates JSON, refuses a comp-led direction round that leaves a card without a decision comp (**Missing decision comps** below; stderr, exit 1, before the hand is recorded, the old state removed, or anything spawned), decides the hand and writes `<key>.hand.json` when it is new (**Decision comps**), removes the key's previous state file without signalling its pid, spawns detached child `node serve-question.mjs --payload F --detached-serve --key K --timeout T [--idle-grace G] [--no-open unless --open]` with stdio to `<key>.log`; waits ≤8 s for state file; failure → stderr `serve-question: server failed to start` + last 4 log lines + `serve-question: log at <rel>. A sandboxed exec that cannot listen on localhost causes exactly this; rerun this command once through the harness's network-enabled or unsandboxed command tool before falling back.` exit 1; success stdout: `QUESTION URL: ${url}`, `QUESTION KEY: ${key}`, `Open the URL for the user now: in-app browser when the harness has one, otherwise the system opener (macOS \`open\`, Linux \`xdg-open\`), otherwise show the URL.`, the `NEXT` visualize line when the payload's comps are due (**Decision comps**), `Then collect the answer with: node <abs script> --wait --key ${key}`; exit 0. Key default `Math.random().toString(16).slice(2,10)`.
- default (blocking): loads payload (error → stderr `serve-question: payload needs an options array` exit 1), listens on `127.0.0.1:${port}`, `stdout> QUESTION URL: http://127.0.0.1:${port}/` and `Waiting for the user to choose in the browser (Ctrl-C aborts)...`, opens browser unless `--no-open`; on answer prints via `printAnswer` and exits 0 after 150 ms. Detached mode writes state instead of printing.
+- **Missing decision comps** (engine addition, not in the JS): `--start` and `--update` refuse a payload that is a comp-led direction round with image generation while some card that owes a decision comp declares none. The round owes them when all of these hold: `buildPath.value` is `"comp"` and `buildPath.toggle` is `true` (the toggle is only offered where image generation exists; a code-led round's slots are a flip reserve); the payload carries the canon exit, a truthy `canon` or an object `canonCard` (direction rounds only: surface rounds and the comp round never carry it); and `options` has at least two entries (a degraded roll's single text-only card declares no comp). The cards that owe one are every option whose `verdict` is not `"declined"`, plus `canonCard` when present; a card declares one with a truthy `comp` or legacy `sketch` (a URL counts). Missing cards are named by `id` (`options[<n>]` when the option has none, `canonCard` for the canon card), in card order. Message on stderr, exit 1 (exit 2 keeps its fallback meaning): `serve-question: this direction round is comp-led with image generation (buildPath value "comp", toggle true), so every card declares a decision comp, canon included, declined challengers excepted; ${outcome}. Missing a "comp": ${ids joined by ", "}. Give each of those cards "comp": ".impeccable/mocks/decision/<card id>.png" (the canon card's goes inside canonCard), then ${rerun}; the comps are generated after the page serves, as its NEXT line says.` with `${outcome}`/`${rerun}` = `the page was not served`/`rerun --start` for `--start` and `nothing was delivered`/`rerun --update on the same key` for `--update`. Checked after the JSON parse (and, for `--update`, the options check) and before anything else; the env and headless gates run first, so a session that falls back to the structured tool never sees it. The blocking (non-`--start`) server does not check.
- **Decision comps** (engine addition, not in the JS): a round's declared comps are the local paths in each option's `comp` (or legacy `sketch`) and `canonCard.comp`, in card order, deduplicated; URLs are left out. The detached server writes them to the state file as `comps` (omitted when empty) and rewrites them when it claims a `--update` round.
- **Hands and provenance.** Each served hand's provenance lives in `<key>.hand.json`, `{"id": "<per-hand id>", "digest": "<first 16 hex of sha256 over the compact JSON of the whole payload>", "comps": [<declared comps>], "pre": {"<slot>": "<sha256 hex of the file bytes>"}}`. Only `--start` and `--update` write it, atomically (a temp file beside it, then a rename), and a failed write fails the command: `--start` prints `serve-question: could not record the hand (<file>: <error>); the page was not served. Make .impeccable/questions/ writable and rerun --start.` on stderr and exits 1 before spawning the server or touching the old state; `--update` prints `serve-question: could not record the hand (<file>: <error>); nothing was delivered. Make .impeccable/questions/ writable and rerun --update on the same key.` and exits 1 before copying `<key>.next.json`, so the page keeps the previous round with its hand file intact; the server never does, so its heartbeat and claim rewrites of the state file cannot drop a hand. `--update` always starts a new hand. `--start` keeps the recorded hand when the key's hand file carries the same digest (a restart) and otherwise starts a new one. A new hand fingerprints every declared slot that already holds a file into `pre`. The digest covers the whole payload, not only the slot paths, because a re-roll often reuses the previous hand's paths. `impeccable generate-image`, after writing `--out`, scans `.impeccable/questions/*.hand.json` for a hand that declares that path (resolved against the cwd; compared case-insensitively on Windows) and marks it generated during that hand with a marker file `<key>.generated/<16 hex of sha256 over the JSON string of the slot>-<hand tag>.json` = `{"slot", "hand"}` (the hand's `id`), written atomically. The hand tag is the hand's `id` (a hand file without an `id` uses its `digest`) when that is 1 to 64 characters of `[a-z0-9_]`, else the first 16 hex of sha256 over its JSON string (lowercase only, so ids that differ in case never share a path on a case-insensitive file system). Markers are one file per slot rather than a list inside the hand file because parallel generators (one subagent per card) would race a shared read-modify-write, and the tag in the name keeps one hand's markers off every path another hand writes. A marker counts only while its name carries the hand file's tag, so a re-roll that repeats a payload never inherits the previous hand's markers. Writing a new hand writes the hand file first and only then prunes, deciding from the file name alone: it deletes only markers (and their temp files) tagged with another hand, so a failed write leaves the live hand and its markers intact and a parallel generation's marker for the new hand is never touched, even when it regenerates a reused slot while the prune runs (#886). A legacy untagged marker `<16 hex>.json` (written before names carried the hand) counts, and survives a prune, only while its content's `hand` (else `digest`) matches the hand's `id` (else `digest`); the engine never writes that name again. `--stop` and a closing answer remove `<key>.generated/` with the hand file. A failed marker write prints `generate-image: could not mark <out> as generated for its decision page (<file>: <error>); a --wait may report it stale` on stderr and leaves the exit at 0, since the image itself was written. Readers merge the valid markers into the hand as `generated: [<slot>, ...]`. A declared comp is **this hand's** when its file exists and its slot is in `generated`, has no `pre` entry, or its current bytes hash differently from `pre`; timestamps play no part, so an old file rewritten unchanged in the same second is still not this hand's, while a deterministic generator's identical regeneration still counts through `generated`. Rewriting a comp's prompt sidecar never counts on its own: only new bytes or an engine generation do. Two exceptions: a comp directly in `.impeccable/mocks/` is the comp round's, generated before that round serves, and counts whenever it exists; with no hand file, existence decides. `--wait` judges the hand file's `comps`, else the state's. A declared comp that exists but is not this hand's is **stale**. The page itself still shows whatever file sits at a slot; hiding stale files there is out of scope.
- Four directives follow:
diff --git a/tests/oracle/README.md b/tests/oracle/README.md
index 9be4a1198..344317ec8 100644
--- a/tests/oracle/README.md
+++ b/tests/oracle/README.md
@@ -69,7 +69,8 @@ machine-dependent fragments. Each is targeted at one script's output:
Not covered on purpose: `palette` with no `--id` / `--from` / env seed (random),
`concept-seed` against the live roll API, `generate-image` real mode,
-`serve-question --start` / blocking mode (opens a browser and binds a port),
+`serve-question --start` / blocking mode (opens a browser and binds a port;
+`--start` refusals that exit before spawning are covered),
and unhandled-exception paths whose stack traces carry Node line numbers.
## Live-mode cases (`cases/live-*.mjs`, workspaces `live-*`)
diff --git a/tests/oracle/cases/context.mjs b/tests/oracle/cases/context.mjs
index 92edf5ced..9eb5d53ae 100644
--- a/tests/oracle/cases/context.mjs
+++ b/tests/oracle/cases/context.mjs
@@ -174,6 +174,20 @@ const MODE_RULES_SKILL = `${REPO}/tests/fixtures/mode-rules-skill`;
const seedEnv = (extra = {}) => env({ IMPECCABLE_SKILL_DIR: MODE_RULES_SKILL, IMPECCABLE_CATALOG_DIR: CATALOG, IMPECCABLE_API_URL: 'http://127.0.0.1:9/api', IMPECCABLE_API_TIMEOUT: '300', ...extra });
const degradedEnv = (extra = {}) => env({ IMPECCABLE_SKILL_DIR: MODE_RULES_SKILL, IMPECCABLE_CATALOG_DIR: `${WS}/no-such-catalog`, IMPECCABLE_API_URL: 'http://127.0.0.1:9/api', IMPECCABLE_API_TIMEOUT: '300', ...extra });
+// A direction round as the eval run wrote it: comp-led with image generation, canon card, no comps.
+const DIRECTION_NO_COMPS = {
+ title: 'Choose the visual world',
+ options: [
+ { id: 'assigned', label: 'Ledger', kicker: 'THE ROLL', thesis: 'One.' },
+ { id: 'model-pick', label: 'Folio', kicker: 'IMPECCABLE’S PICK', thesis: 'Two.' },
+ { id: 'challenger-a', label: 'Rail', verdict: 'competitive', thesis: 'Three.', hero: 'https://x/a-hero.webp' },
+ { id: 'challenger-b', label: 'Field', verdict: 'declined', thesis: 'Four.', hero: 'https://x/b-hero.webp' },
+ ],
+ reroll: { registers: ['safer', 'bolder'] },
+ buildPath: { value: 'comp', toggle: true },
+ canon: true,
+ canonCard: { label: 'The category standard', thesis: 'Five.' },
+};
const QUESTION_PAYLOAD = { title: 'Pick', options: [{ id: 'a', label: 'A', thesis: 'One.' }, { id: 'b', label: 'B', thesis: 'Two.' }] };
const cases = [
@@ -751,6 +765,9 @@ const cases = [
{ id: 'question-update-no-key', verb: 'serve-question', workspace: 'ctx-empty', setup: (ws) => write(ws, 'payload.json', JSON.stringify(QUESTION_PAYLOAD)), args: ['--update', '--payload', 'payload.json'], env: env() },
{ id: 'question-update-empty-options', verb: 'serve-question', workspace: 'ctx-empty', setup: (ws) => write(ws, 'payload.json', JSON.stringify({ options: [] })), args: ['--update', '--key', 'k1', '--payload', 'payload.json'], env: env(), files: ['.impeccable/questions/**'] },
{ id: 'question-update-no-server', verb: 'serve-question', workspace: 'ctx-empty', setup: (ws) => write(ws, 'payload.json', JSON.stringify(QUESTION_PAYLOAD)), args: ['--update', '--key', 'k1', '--payload', 'payload.json'], env: env(), files: ['.impeccable/questions/**'] },
+ // A comp-led direction round with image generation (buildPath comp + toggle, canon exit present) owes a decision comp on every card, canon included, declined challengers excepted: --start refuses one that declares none before recording a hand or spawning a server, and --update refuses it before delivery.
+ { id: 'question-start-direction-missing-comps', verb: 'serve-question', workspace: 'ctx-empty', setup: (ws) => write(ws, 'payload.json', JSON.stringify(DIRECTION_NO_COMPS)), args: ['--start', '--no-open', '--key', 'k1', '--payload', 'payload.json'], env: env(), files: ['.impeccable/questions/**'] },
+ { id: 'question-update-direction-missing-comps', verb: 'serve-question', workspace: 'ctx-empty', setup: (ws) => { write(ws, '.impeccable/questions/k1.state.json', JSON.stringify({ pid: 1, port: 1, url: 'http://127.0.0.1:1/' })); write(ws, 'payload.json', JSON.stringify({ ...DIRECTION_NO_COMPS, options: DIRECTION_NO_COMPS.options.map((o) => (o.id === 'assigned' ? { ...o, comp: '.impeccable/mocks/decision/assigned.png' } : o)) })); }, args: ['--update', '--key', 'k1', '--payload', 'payload.json'], env: env(), files: ['.impeccable/questions/**'] },
{ id: 'question-payload-no-options', verb: 'serve-question', workspace: 'ctx-empty', setup: (ws) => write(ws, 'payload.json', JSON.stringify({ title: 'no options' })), args: ['--payload', 'payload.json', '--no-open'], env: env(), files: ['.impeccable/questions/**'] },
];
diff --git a/tests/oracle/golden/question-start-direction-missing-comps.json b/tests/oracle/golden/question-start-direction-missing-comps.json
new file mode 100644
index 000000000..d78240037
--- /dev/null
+++ b/tests/oracle/golden/question-start-direction-missing-comps.json
@@ -0,0 +1,7 @@
+{
+ "stdout": "",
+ "stderr": "serve-question: this direction round is comp-led with image generation (buildPath value \"comp\", toggle true), so every card declares a decision comp, canon included, declined challengers excepted; the page was not served. Missing a \"comp\": assigned, model-pick, challenger-a, canonCard. Give each of those cards \"comp\": \".impeccable/mocks/decision/<card id>.png\" (the canon card's goes inside canonCard), then rerun --start; the comps are generated after the page serves, as its NEXT line says.\n",
+ "exit": 1,
+ "signal": null,
+ "files": {}
+}
diff --git a/tests/oracle/golden/question-update-direction-missing-comps.json b/tests/oracle/golden/question-update-direction-missing-comps.json
new file mode 100644
index 000000000..a7d2307d1
--- /dev/null
+++ b/tests/oracle/golden/question-update-direction-missing-comps.json
@@ -0,0 +1,9 @@
+{
+ "stdout": "",
+ "stderr": "serve-question: this direction round is comp-led with image generation (buildPath value \"comp\", toggle true), so every card declares a decision comp, canon included, declined challengers excepted; nothing was delivered. Missing a \"comp\": model-pick, challenger-a, canonCard. Give each of those cards \"comp\": \".impeccable/mocks/decision/<card id>.png\" (the canon card's goes inside canonCard), then rerun --update on the same key; the comps are generated after the page serves, as its NEXT line says.\n",
+ "exit": 1,
+ "signal": null,
+ "files": {
+ ".impeccable/questions/k1.state.json": "{\"pid\":<PID>,\"port\":1,\"url\":\"http://127.0.0.1:1/\"}"
+ }
+}