The design language that makes your AI harness better at design.
JavaScript
serve-question: refuse a comp-led surface round that declares no decision comps (#960)
Paul Bakaus0fd148c49724
diff --git a/crates/context/src/concept_seed.rs b/crates/context/src/concept_seed.rsindex 4894eed55..66aefa5e0 100644--- a/crates/context/src/concept_seed.rs+++ b/crates/context/src/concept_seed.rs@@ -623,6 +623,10 @@ pub fn run(args: &[String], io: &mut Io) -> i32 {};match render_concept_seed(&env, &cwd, &mut budget, &seed) {Ok(text) => {+ // A valid roll: the scope and re-roll round passed validation.+ // serve-question reads the record to know a surface round when+ // it serves one (`record_roll`).+ crate::serve_question::record_roll(&cwd, seed.scope.as_deref().unwrap_or("surface"), &seed.key, seed.reroll as usize);io.out(&text);0}@@ -889,4 +893,26 @@ mod tests {let (_, out) = seed(&proj, &skill, true, &["--kind", "assigned", "--from", "k1", "--scope", "direction"]);assert!(!out.contains("PRESENTATION"), "{out}");}++ #[test]+ fn every_roll_records_its_scope_for_serve_question() {+ let (proj, skill) = fixture("roll-record", &[]);+ let record = proj.join(".impeccable/questions/roll.json");+ let read = || serde_json::from_str::<Value>(&std::fs::read_to_string(&record).unwrap()).unwrap();+ // Invalid arguments and telemetry pings are not rolls.+ let (code, _) = seed(&proj, &skill, true, &["--scope", "world", "--from", "k1"]);+ assert_eq!(code, 1);+ seed(&proj, &skill, true, &["--chosen", "x", "--kind", "assigned", "--from", "k1", "--scope", "surface"]);+ assert!(!record.exists());+ // A surface roll, then a direction re-roll replacing it.+ let (code, _) = seed(&proj, &skill, true, &["--scope", "surface", "--mode", "operate", "--from", "k1"]);+ assert_eq!(code, 0);+ let r = read();+ assert_eq!((r["scope"].as_str(), r["key"].as_str(), r["reroll"].as_u64()), (Some("surface"), Some("k1"), Some(0)));+ assert!(r["at"].as_f64().is_some_and(|at| (crate::util::now_ms() - at).abs() < 60_000.0), "{r}");+ let (code, _) = seed(&proj, &skill, false, &["--scope", "direction", "--from", "k2", "--reroll", "1"]);+ assert_eq!(code, 0);+ let r = read();+ assert_eq!((r["scope"].as_str(), r["key"].as_str(), r["reroll"].as_u64()), (Some("direction"), Some("k2"), Some(1)));+ }}diff --git a/crates/context/src/seed_text.rs b/crates/context/src/seed_text.rsindex 7ce41736d..d0f918a72 100644--- a/crates/context/src/seed_text.rs+++ b/crates/context/src/seed_text.rs@@ -26,7 +26,7 @@ pub const DEGRADED_SAFER: &str = "@@DEGRADEDHEADER@@\nSAFER REGISTER (user-requepub const DEGRADED_BOLDER: &str = "BOLDER REGISTER UNAVAILABLE: bolder deals foreign forms, and this roll ran\n degraded with no catalog and no roll service, so there is nothing bold to\n deal. Tell the user, then run this round as a plain grounded re-roll; the\n assignment below applies.\n";-pub const DEGRADED_BODY: &str = "@@DEGRADEDHEADER@@\n@@DEGRADEDREGISTER@@@@ASSIGNED_OR_DEALT@@\n @@PROMOTEDINSTRUCTION@@\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nnothing is written. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\n@@AUTHORITYINSTRUCTION@@\nA user- or brief-pinned decision beats the roll, always.\n@@RESTATED_ASSIGNED_OR_DEALT@@\n";+pub const DEGRADED_BODY: &str = "@@DEGRADEDHEADER@@\n@@DEGRADEDREGISTER@@@@ASSIGNED_OR_DEALT@@\n @@PROMOTEDINSTRUCTION@@\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nthe only file written is the local roll record .impeccable/questions/roll.json,\nwhich serve-question reads. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\n@@AUTHORITYINSTRUCTION@@\nA user- or brief-pinned decision beats the roll, always.\n@@RESTATED_ASSIGNED_OR_DEALT@@\n";pub const GRAIN_NONE_AVAIL: &str = "\nNONE of these sit at the requested @@MATCH_GRAIN@@ grain, because the catalog holds no @@MATCH_GRAIN@@-grain composition yet. Derive that structure yourself and borrow only their sequence and attention laws.";diff --git a/crates/context/src/serve_question.rs b/crates/context/src/serve_question.rsindex 19113db18..14ad1a87c 100644--- a/crates/context/src/serve_question.rs+++ b/crates/context/src/serve_question.rs@@ -185,52 +185,172 @@ fn declared_comps(payload: &Value) -> Vec<String> {out}+/// Whether a card declares a decision comp: a truthy `comp`, or the legacy+/// `sketch` (a URL counts).+fn card_has_comp(card: &Value) -> bool {+ 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)+}++/// The options that owe a comp and declare none, declined challengers+/// excepted, by id (`options[<n>]` for a card with no id), in card order.+fn options_missing_comps(payload: &Value) -> Vec<String> {+ let options = payload.get("options").and_then(Value::as_array).map(Vec::as_slice).unwrap_or(&[]);+ options+ .iter()+ .enumerate()+ .filter(|(_, o)| o.get("verdict").and_then(Value::as_str) != Some("declined") && !card_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()+}++/// A full comp-led hand with image generation: `buildPath` `{"value":+/// "comp", "toggle": true}` (a code-led round's slots are a flip reserve,+/// and no toggle means no image generation) and at least two options (a+/// degraded roll's single card is text-only).+fn comp_led_full_hand(payload: &Value) -> bool {+ 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 options = payload.get("options").and_then(Value::as_array).map(Vec::len).unwrap_or(0);+ comp_led && toggle && options >= 2+}++/// Whether a payload carries the canon exit, a truthy `canon` or an object+/// `canonCard`: direction rounds only; surface rounds and the comp round+/// never carry it.+fn has_canon_exit(payload: &Value) -> bool {+ payload.get("canonCard").is_some_and(Value::is_object) || payload.get("canon").map(crate::staleness::js_truthy).unwrap_or(false)+}+/// 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.+/// challengers excepted, only when it is a direction round (it carries the+/// canon exit) and a comp-led full hand with image generation+/// (`comp_led_full_hand`). 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 {+ if !has_canon_exit(payload) || !comp_led_full_hand(payload) {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)) {+ let mut missing = options_missing_comps(payload);+ if payload.get("canonCard").filter(|c| c.is_object()).is_some_and(|c| !card_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 {+/// The cards a comp-led surface round leaves without a decision comp. The+/// payload alone cannot tell a surface round from the comp round, so the+/// caller decides that from concept-seed's roll record+/// (`surface_roll_pending`); given that, the round owes a comp on every+/// dealt card when it carries no canon exit and is a comp-led full hand with+/// image generation.+fn missing_surface_comps(payload: &Value) -> Vec<String> {+ if has_canon_exit(payload) || !comp_led_full_hand(payload) {+ return Vec::new();+ }+ options_missing_comps(payload)+}++/// Which round a missing-comp refusal names.+#[derive(Clone, Copy, Debug, PartialEq)]+enum CompRound {+ Direction,+ Surface,+}++/// The missing-comp gate `--start` and `--update` share: a direction round+/// (known by its canon exit), else a surface round when concept-seed's+/// latest roll in this project is a surface roll no decision page has taken+/// yet (`roll` is the record as `read_roll` returned it). `None` when the+/// payload owes nothing or declares every comp it owes.+fn missing_comps(roll: Option<&str>, payload: &Value) -> Option<(CompRound, Vec<String>)> {+ let direction = missing_direction_comps(payload);+ if !direction.is_empty() {+ return Some((CompRound::Direction, direction));+ }+ if !surface_roll_pending(roll) {+ return None;+ }+ let surface = missing_surface_comps(payload);+ (!surface.is_empty()).then_some((CompRound::Surface, surface))+}++/// The refusal `--start` and `--update` print for a comp-led direction or+/// surface round that declares no comp on some card. `rerun` names the+/// command to repeat.+fn missing_comps_message(round: CompRound, missing: &[String], rerun: &str, outcome: &str) -> String {+ let (owed, canon_note) = match round {+ CompRound::Direction => (+ "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 canon card's goes inside canonCard)",+ ),+ CompRound::Surface => (+ "this surface round (concept-seed's latest roll here was --scope surface) is comp-led with image generation (buildPath value \"comp\", toggle true), so every dealt card declares a decision comp",+ "",+ ),+ };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",+ "serve-question: {}; {}. Missing a \"comp\": {}. Give each of those cards \"comp\": \".impeccable/mocks/decision/<card id>.png\"{}, then {}; the comps are generated after the page serves, as its NEXT line says.\n",+ owed,outcome,missing.join(", "),+ canon_note,rerun)}+/// How long a roll stays bound to the next decision page. A roll is+/// presented within minutes; an older record belongs to work long gone.+const ROLL_WINDOW_MS: f64 = 60.0 * 60.0 * 1000.0;++/// `.impeccable/questions/roll.json`: concept-seed's latest roll in this+/// project, `{"scope", "key", "reroll", "at"}` (`at` in epoch ms). Every+/// roll replaces it; a decision page (a payload carrying `buildPath`) that+/// `--start` serves or `--update` delivers removes it, so a roll binds to+/// the one page that presents it.+fn roll_file(qdir: &str) -> String {+ jsp::join(&[qdir, "roll.json"])+}++/// Records a concept-seed roll for the next decision page. Best effort: a+/// roll never fails because its record could not be written.+pub fn record_roll(cwd: &str, scope: &str, key: &str, reroll: usize) {+ let qdir = jsp::join(&[cwd, ".impeccable", "questions"]);+ let record = json!({ "scope": scope, "key": key, "reroll": reroll, "at": now_ms() as u64 });+ let _ = std::fs::create_dir_all(&qdir).and_then(|_| write_atomic(&roll_file(&qdir), &json_compact(&record)));+}++/// The roll record as `--start` / `--update` read it once, before the gate:+/// the same text decides the gate and names the record `take_roll` may+/// remove.+fn read_roll(qdir: &str) -> Option<String> {+ safe_read(&roll_file(qdir))+}++/// Whether a roll record (as `read_roll` returned it) is a surface roll made+/// within `ROLL_WINDOW_MS` that no decision page has taken yet.+fn surface_roll_pending(roll: Option<&str>) -> bool {+ let Some(record) = roll.and_then(|t| serde_json::from_str::<Value>(t).ok()) else {+ return false;+ };+ let fresh = record.get("at").and_then(Value::as_f64).is_some_and(|at| now_ms() - at < ROLL_WINDOW_MS);+ fresh && record.get("scope").and_then(Value::as_str) == Some("surface")+}++/// A decision page took the roll it was gated against: the payload carries+/// `buildPath`, which only direction and surface rounds do. Removes the+/// record only while it still holds that roll (`read` is the text read+/// before the gate), so a newer roll another session recorded in between+/// stays bound to its own page.+fn take_roll(qdir: &str, read: Option<&str>, payload: &Value) {+ let Some(read) = read else { return };+ if payload.get("buildPath").is_some_and(|b| !b.is_null()) && read_roll(qdir).as_deref() == Some(read) {+ let _ = std::fs::remove_file(roll_file(qdir));+ }+}+/// 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).@@ -786,9 +906,9 @@ 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"));+ let roll = read_roll(&qdir);+ if let Some((round, missing)) = missing_comps(roll.as_deref(), &next_round) {+ io.err(&missing_comps_message(round, &missing, "rerun --update on the same key", "nothing was delivered"));return 1;}if !is_alive(&qdir, &key) {@@ -803,6 +923,7 @@ pub fn run(argv: &[String], io: &mut Io) -> i32 {io.err(&format!("serve-question: could not record the hand ({}); nothing was delivered. Make .impeccable/questions/ writable and rerun --update on the same key.\n", e));return 1;}+ take_roll(&qdir, roll.as_deref(), &next_round);let delivered = next_file(&qdir, &key);let _ = std::fs::copy(jsp::resolve(&cwd, &[&pp]), &delivered);touch_now(&delivered);@@ -825,9 +946,9 @@ 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"));+ let roll = read_roll(&qdir);+ if let Some((round, missing)) = missing_comps(roll.as_deref(), &start_payload) {+ io.err(&missing_comps_message(round, &missing, "rerun --start", "the page was not served"));return 1;}let _ = std::fs::create_dir_all(&qdir);@@ -839,6 +960,7 @@ pub fn run(argv: &[String], io: &mut Io) -> i32 {return 1;}};+ take_roll(&qdir, roll.as_deref(), &start_payload);// The old state goes either way, so the wait below sees the new// server's state, not the dead one's; its pid is never signalled,// since a dead server's pid may have been reused.@@ -2178,6 +2300,154 @@ mod tests {let _ = std::fs::remove_dir_all(&dir);}+ /// A comp-led surface round: three dealt structures as full cards, no+ /// canon, no pick card.+ fn surface_round(comps: bool) -> Value {+ let mut p = json!({+ "title": "Choose the structure",+ "options": [+ { "id": "ledger", "kicker": "THE ROLL", "thesis": "One." },+ { "id": "rail", "thesis": "Two." },+ { "id": "field", "thesis": "Three." }+ ],+ "reroll": true,+ "buildPath": { "value": "comp", "toggle": true }+ });+ if comps {+ for (i, id) in ["ledger", "rail", "field"].iter().enumerate() {+ p["options"][i]["comp"] = json!(format!(".impeccable/mocks/decision/{id}.png"));+ }+ }+ p+ }++ fn write_roll(dir: &std::path::Path, scope: &str, at: f64) {+ std::fs::write(dir.join(".impeccable/questions/roll.json"), json!({ "scope": scope, "key": "k", "reroll": 0, "at": at as u64 }).to_string()).unwrap();+ }++ #[test]+ fn missing_surface_comps_names_dealt_cards_and_leaves_other_rounds_alone() {+ assert_eq!(missing_surface_comps(&surface_round(false)), vec!["ledger", "rail", "field"]);+ assert!(missing_surface_comps(&surface_round(true)).is_empty());+ let with = |f: &dyn Fn(&mut Value)| {+ let mut p = surface_round(false);+ f(&mut p);+ missing_surface_comps(&p)+ };+ // One card short, and a card with no id named by its index.+ assert_eq!(+ with(&|p| {+ *p = surface_round(true);+ p["options"][1].as_object_mut().unwrap().remove("comp");+ p["options"][2].as_object_mut().unwrap().remove("id");+ p["options"][2].as_object_mut().unwrap().remove("comp");+ }),+ vec!["rail", "options[2]"]+ );+ // Code-led, no toggle, no buildPath: nothing owed.+ assert!(with(&|p| p["buildPath"]["value"] = json!("code")).is_empty());+ assert!(with(&|p| p["buildPath"]["toggle"] = json!(false)).is_empty());+ assert!(with(&|p| { p.as_object_mut().unwrap().remove("buildPath"); }).is_empty());+ // A single card owes nothing; a payload with the canon exit is a+ // direction round, which the direction gate owns.+ assert!(with(&|p| { p["options"] = json!([{ "id": "ledger", "thesis": "One." }]); }).is_empty());+ assert!(with(&|p| p["canon"] = json!(true)).is_empty());+ }++ #[test]+ fn surface_gate_applies_only_while_a_fresh_surface_roll_is_pending() {+ let dir = temp_project("surface-roll");+ let qdir = jsp::join(&[&dir.to_string_lossy(), ".impeccable", "questions"]);+ let bare = surface_round(false);+ let gate = |p: &Value| missing_comps(read_roll(&qdir).as_deref(), p);+ let pending = || surface_roll_pending(read_roll(&qdir).as_deref());+ // No roll recorded: the payload cannot be told from the comp round.+ assert_eq!(gate(&bare), None);+ // A fresh surface roll binds the next decision page.+ write_roll(&dir, "surface", now_ms());+ assert_eq!(gate(&bare), Some((CompRound::Surface, vec!["ledger".into(), "rail".into(), "field".into()])));+ assert_eq!(gate(&surface_round(true)), None);+ // A later direction roll replaces it; a stale one has expired.+ write_roll(&dir, "direction", now_ms());+ assert_eq!(gate(&bare), None);+ write_roll(&dir, "surface", now_ms() - ROLL_WINDOW_MS - 1000.0);+ assert_eq!(gate(&bare), None);+ // An unreadable record gates nothing.+ std::fs::write(dir.join(".impeccable/questions/roll.json"), "{not json").unwrap();+ assert_eq!(gate(&bare), None);+ // A direction round is still the direction gate's, roll or not.+ write_roll(&dir, "surface", now_ms());+ assert_eq!(gate(&direction_round(false)).map(|(r, _)| r), Some(CompRound::Direction));+ // Only a decision page (a payload with buildPath) takes the roll.+ let read = read_roll(&qdir);+ take_roll(&qdir, read.as_deref(), &json!({ "options": [{ "id": "a" }, { "id": "b" }] }));+ assert!(pending());+ // A newer roll recorded after this page read the record (another+ // session's) is not this page's to take.+ write_roll(&dir, "surface", now_ms() + 1.0);+ take_roll(&qdir, read.as_deref(), &surface_round(true));+ assert!(pending());+ // The roll the page was gated against is.+ let read = read_roll(&qdir);+ take_roll(&qdir, read.as_deref(), &surface_round(true));+ assert!(!pending());+ // No record read, nothing to take.+ take_roll(&qdir, None, &surface_round(true));+ let _ = std::fs::remove_dir_all(&dir);+ }++ #[test]+ fn start_and_update_refuse_a_comp_led_surface_round_after_a_surface_roll() {+ let dir = temp_project("surface-missing-comps");+ let qdir = jsp::join(&[&dir.to_string_lossy(), ".impeccable", "questions"]);+ let roll = dir.join(".impeccable/questions/roll.json");+ // Recorded the way concept-seed records a roll.+ record_roll(&dir.to_string_lossy(), "surface", "seed-1", 0);+ assert!(surface_roll_pending(read_roll(&qdir).as_deref()));+ std::fs::write(dir.join("p.json"), surface_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.starts_with("serve-question: this surface round (concept-seed's latest roll here was --scope surface) is comp-led with image generation"), "{err}");+ assert!(err.contains("so every dealt card declares a decision comp; the page was not served."), "{err}");+ assert!(err.contains("Missing a \"comp\": ledger, rail, field."), "{err}");+ assert!(err.contains("\".impeccable/mocks/decision/<card id>.png\", then rerun --start;") && !err.contains("canonCard"), "{err}");+ // Refused before anything was recorded or spawned; the roll stays bound.+ assert!(!std::path::Path::new(&hand_file(&qdir, "k1")).exists());+ assert!(!std::path::Path::new(&state_file(&qdir, "k1")).exists());+ assert!(roll.exists());++ // A surface re-roll delivered by --update is gated the same way.+ 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!(roll.exists());++ // With every comp declared, --update delivers and takes the roll, so+ // a later page on this project (the comp round) is not gated by it.+ std::fs::write(dir.join("p.json"), surface_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}");+ assert!(!roll.exists());+ std::fs::write(dir.join("p.json"), surface_round(false).to_string()).unwrap();+ let (code, _, err) = run_err(&["--update", "--key", "k1", "--payload", "p.json"]);+ assert_eq!(code, 0, "{err}");+ 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.mdindex e4ad9e9d5..23795f548 100644--- a/docs/CLI-CONTRACT.md+++ b/docs/CLI-CONTRACT.md@@ -427,6 +427,7 @@ retain their local-development trust behavior. See [bundle signing](BUNDLE-SIGNI````${mode}` is the mode as given (`experience` stays `experience`). When the file cannot be read, or either section is missing or empty, the block is the single line `MODE RULES unavailable: read ${path} before writing directions or comps.` and the roll still succeeds. Without `--mode` nothing is printed. The richness instruction is mode-neutral; the per-mode guidance on committing to an interface language lives in the mode files.- **Presentation** (binary only; every successful roll, direction or surface, full or degraded, every re-roll and both registers; never on validation errors, the PRODUCT.md gate, or telemetry pings): after the last line of the roll, a `PRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):` header and five `- ` lines, in order: how to serve the hand (round 0: `<self> serve-question --schema`, `--start --payload <file>`, open the URL; re-roll: `--update --key <same key> --payload <file>` while a page is open, never a second `--start`, and `--start` when no page opened yet); the comp line (direction: every card declares a comp under `.impeccable/mocks/decision/`, canon included, declined excepted, generated after serving in reading order with its `a.png.json` sidecar; degraded direction other than the safer register: one text-only card, no comp; surface: comps or wireframes, no pick or canon card; a recorded `code` default turns either scope's line into the code-led flip-reserve variant); `<self> serve-question --wait --key <key>`, led by `After the last comp lands (at once when this round generates none),` or, on a code-led round or a single degraded card, `Right after serving, with no comp to generate first,`, with the session-polling rule (rerun only after exit 3); the build-path line (`recorded default <comp|code> (from .impeccable/config.json|.impeccable/config.local.json)`, resolved exactly like `context`'s `BUILD_PATH_DEFAULT`, or `none recorded ...` with the comp default and the one-time offer after a flip); and the structured-tool fallback (`--start` exit 2, `--wait` exit 4, or a harness that cannot hold a blocking `--wait`). Text in `crates/context/src/seed_text.rs`; `reference/new-work.md` is its source and names the block.+- **Roll record** (binary only; every successful roll, the same set that prints the presentation block): writes `.impeccable/questions/roll.json` atomically (temp file, then rename), creating the directory, as `{"scope":"surface"|"direction","key":<key>,"reroll":<n>,"at":<epoch ms>}`, replacing the previous record. Best effort: a write failure is silent and never fails the roll. Validation errors, the PRODUCT.md gate, and telemetry pings write nothing. `serve-question` reads it for the surface-round comp gate and removes it when a decision page takes the roll (**Missing decision comps**).- **Telemetry ping** (`--chosen` and/or `--kind` present; never gated by PRODUCT.md): `pingChosen({chosenId, key, scope, mode, kind, register})`: skipped (returns false) when `IMPECCABLE_NO_TELEMETRY` or `DO_NOT_TRACK` set, `kind` not in `{assigned,pick,challenger,canon}`, `register` not `safer|bolder`, neither chosenId nor kind, or kind challenger/absent without chosenId. Else `POST ${API_BASE}/chosen` with `Content-Type: application/json`, body `JSON.stringify({ [chosenId], key, scope, mode, [kind], [register] })` (undefined values omitted by JSON.stringify), abort at budget. stdout `choice recorded\n` on success else `choice ping skipped\n`; always exit 0.- **Exit**: destroys undici global dispatcher then `process.exit(exitCode ?? 0)`.- Tests: `tests/concept-seed.test.mjs` (scopes reproducibility, degraded seed, register, ratings/breadth/mode/grain/platform, init gate, `pingChosen` validation & opt-out, API roll path + dispatcher destroy).@@ -441,10 +442,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); 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)`.+ - `--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 and surface gate (**Missing decision comps** below; stderr, exit 1, `nothing was delivered`, before the liveness check, `<key>.next.json`, the hand file, or the roll record 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); writes a new hand to `<key>.hand.json`, removes the roll record when the payload carries `buildPath`, copies payload to `<key>.next.json`, touches mtime, `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 or surface round that leaves a card without a decision comp (**Missing decision comps** below; stderr, exit 1, before the hand is recorded, the roll record removed, the old state removed, or anything spawned), decides the hand and writes `<key>.hand.json` when it is new (**Decision comps**), removes the roll record when the payload carries `buildPath`, 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.+- **Missing decision comps** (engine addition, not in the JS): `--start` and `--update` refuse a payload that is a comp-led direction round (or, per **Surface rounds** below, surface 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`. **Surface rounds**: the payload alone cannot tell a surface round (three dealt structures as full cards, no canon, no pick card) from the comp round or any other canon-less page, so the engine links it to concept-seed's roll record (`.impeccable/questions/roll.json`, **Roll record** under concept-seed). When the payload owes no direction comps and the record exists, parses, has `scope` `"surface"`, and its `at` is less than one hour old, a payload with no canon exit that is comp-led with image generation and carries at least two options owes a comp on every option whose `verdict` is not `"declined"`, named as above. Message: `serve-question: this surface round (concept-seed's latest roll here was --scope surface) is comp-led with image generation (buildPath value "comp", toggle true), so every dealt card declares a decision comp; ${outcome}. Missing a "comp": ${ids joined by ", "}. Give each of those cards "comp": ".impeccable/mocks/decision/<card id>.png", then ${rerun}; the comps are generated after the page serves, as its NEXT line says.` with the same `${outcome}`/`${rerun}` pairs. The record binds a roll to the one page that presents it: a refusal leaves it in place, and a `--start` that records its hand, or an `--update` that records its hand, removes it when the payload carries a non-null `buildPath` (only direction and surface rounds do), whatever the round's build path. The record is read once, before the gate, and removed only while the file still holds that same text: a newer roll another session recorded in between stays for its own page. So a later page in the same project (the comp round, a page after a direction roll, anything after the surface round was served) is not gated by it, and a page without `buildPath` (an unrelated question) neither takes nor is gated by it. 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/DELTAS.md b/tests/oracle/DELTAS.mdindex 503282ebb..c82238bbd 100644--- a/tests/oracle/DELTAS.md+++ b/tests/oracle/DELTAS.md@@ -390,3 +390,15 @@ New cases, recorded from the binary and reviewed by hand:- `build-phase-decision-comp-option-one`: `--decision-comp` with `--comp` and with a missing file exit 1; `start --direction seed --decision-comp` prints the option-one NEXT; the first `advance` fails with `1 comp (the chosen decision comp ... as option one, the others directly under .impeccable/mocks)` and no approval, although an unrelated decision comp carries `"approved": true`; after two comps land in `.impeccable/mocks/` and the decision comp's sidecar is approved, `advance` closes on it (`3 comps, 1 approved`), and the snapshotted state and `approved-comp.json` name the decision path.- `question-wait-answer-decision-comp-in-round`: with a build state in the `comps` phase recording `decisionComp` and a page that also serves a comp directly in `.impeccable/mocks/`, a pick of that path prints `APPROVED COMP`, not `CHOSEN COMP`.++## Recorded 2026-10-05: surface rounds owe their decision comps too++`serve-question --start` and `--update` refused only comp-led direction rounds with missing decision comps, because a surface round's payload carries no canon and looks like the comp round. Every successful `concept-seed` roll now writes `.impeccable/questions/roll.json` (`scope`, `key`, `reroll`, `at`), and while the latest roll is a surface roll under an hour old that no decision page has taken, a comp-led surface hand that leaves a dealt card without a comp is refused with the same message helper (exit 1, before any state is written). The degraded roll's approval guidance said `nothing is written`; it now names the record.++- `seed-degraded-direction`, `seed-degraded-surface`, `seed-degraded-bolder`: in the no-network paragraph, `and\nnothing is written.` became `and\nthe only file written is the local roll record .impeccable/questions/roll.json,\nwhich serve-question reads.`. Nothing else moved; exit status and stderr are unchanged, and the cases snapshot no files.++New cases, recorded from the binary and reviewed by hand:++- `question-start-surface-missing-comps`: a degraded surface roll, then `--start` of a comp-led three-card surface hand with no comps exits 1 naming `ledger, rail, field`; no hand is recorded and `roll.json` stays.+- `question-update-surface-missing-comps`: a surface re-roll, then `--update` of the same hand with only `ledger` declared exits 1 naming `rail, field`; nothing is delivered and `roll.json` stays.+- `question-update-surface-shape-after-direction-roll`: after a direction roll the same comp-less hand is delivered, and the page takes the roll (`roll.json` is gone).diff --git a/tests/oracle/cases/context.mjs b/tests/oracle/cases/context.mjsindex 9eb5d53ae..8a8df824f 100644--- a/tests/oracle/cases/context.mjs+++ b/tests/oracle/cases/context.mjs@@ -188,6 +188,17 @@ const DIRECTION_NO_COMPS = {canon: true,canonCard: { label: 'The category standard', thesis: 'Five.' },};+// A surface round on an established world: three dealt structures as full cards, comp-led with image generation, no canon, no comps.+const SURFACE_NO_COMPS = {+ title: 'Choose the structure',+ options: [+ { id: 'ledger', label: 'Ledger', kicker: 'THE ROLL', thesis: 'One.' },+ { id: 'rail', label: 'Rail', thesis: 'Two.' },+ { id: 'field', label: 'Field', thesis: 'Three.' },+ ],+ reroll: true,+ buildPath: { value: 'comp', toggle: true },+};const QUESTION_PAYLOAD = { title: 'Pick', options: [{ id: 'a', label: 'A', thesis: 'One.' }, { id: 'b', label: 'B', thesis: 'Two.' }] };const cases = [@@ -768,6 +779,29 @@ const cases = [// 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/**'] },+ // A surface round carries no canon, so the payload alone cannot tell it from the comp round; concept-seed records every roll in .impeccable/questions/roll.json, and while the latest is a surface roll no decision page has taken, --start and --update refuse a comp-led surface hand that leaves a dealt card without a comp. The refusal leaves the roll record in place for the corrected rerun.+ {+ id: 'question-start-surface-missing-comps', verb: 'serve-question', workspace: 'ctx-product-only', setup: (ws) => write(ws, 'payload.json', JSON.stringify(SURFACE_NO_COMPS)), env: env(), files: ['.impeccable/questions/**'],+ steps: [+ { verb: 'concept-seed', args: ['--scope', 'surface', '--mode', 'operate', '--from', 'oracle-key-1'], env: degradedEnv() },+ { args: ['--start', '--no-open', '--key', 'k1', '--payload', 'payload.json'] },+ ],+ },+ {+ id: 'question-update-surface-missing-comps', verb: 'serve-question', workspace: 'ctx-product-only', 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({ ...SURFACE_NO_COMPS, options: SURFACE_NO_COMPS.options.map((o) => (o.id === 'ledger' ? { ...o, comp: '.impeccable/mocks/decision/ledger.png' } : o)) })); }, env: env(), files: ['.impeccable/questions/**'],+ steps: [+ { verb: 'concept-seed', args: ['--scope', 'surface', '--mode', 'operate', '--from', 'oracle-key-1', '--reroll', '1'], env: degradedEnv() },+ { args: ['--update', '--key', 'k1', '--payload', 'payload.json'] },+ ],+ },+ // After a direction roll the same comp-less, canon-less hand is not a surface round (the comp round looks like this): --update delivers it, and the decision page takes the roll record.+ {+ id: 'question-update-surface-shape-after-direction-roll', verb: 'serve-question', workspace: 'ctx-product-only', 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(SURFACE_NO_COMPS)); }, env: env(), files: ['.impeccable/questions/roll.json', '.impeccable/questions/k1.next.json'],+ steps: [+ { verb: 'concept-seed', args: ['--scope', 'direction', '--mode', 'persuade', '--from', 'oracle-key-1'], env: degradedEnv() },+ { args: ['--update', '--key', 'k1', '--payload', 'payload.json'] },+ ],+ },{ 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-surface-missing-comps.json b/tests/oracle/golden/question-start-surface-missing-comps.jsonnew file mode 100644index 000000000..f39ec5d95--- /dev/null+++ b/tests/oracle/golden/question-start-surface-missing-comps.json@@ -0,0 +1,19 @@+{+ "steps": [+ {+ "stdout": "SURFACE CONCEPT SEED (key: oracle-key-1; mode: operate; source: degraded; rerun with --scope surface --mode operate --from oracle-key-1 --candidate-count 7)\nDEALT INDICES: 4, 6, 7 (index 4 leads)\n After ordering the task's grounded structural candidates by resonance,\n deal candidates 4, 6, 7 of your own grounded list to the\n table; index 4 leads, and the deal never points at a challenger.\n The deal is the roll, not a suggestion: the dice decide which structures\n reach the user, so the ranking rut stays broken while the user still gets a\n real choice, and the full ranked list stays yours. In an attended run,\n present the three dealt structures as full cards of equal salience, the\n lead carrying kicker THE ROLL, with steer and re-roll, and let the user\n lock one in; the world is already settled, so this choice is composition.\n Visualize every dealt card: with image generation available and a\n comp-led default (.impeccable/config.json buildPath; the page toggle\n handles the exception), declare a comp per card and generate after\n serving, lead first; otherwise author each card's wireframe field (see\n serve-question --schema) and the page draws the schematic. Carry the\n recorded default in the payload as buildPath with toggle: true. Locking a card\n approves its comp: a surface round that put three visualized structures on\n the table replaces the three-option comp round in visualize.md. Re-roll\n yourself only when every dealt structure fails audience identification or\n product clarity on named factual grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nthe only file written is the local roll record .impeccable/questions/roll.json,\nwhich serve-question reads. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and DESIGN.md constrain every surface candidate's identity\nvocabulary; they do not cancel task-level composition. The seed never\nauthorizes a new palette, type system, material world, or unfamiliar control\nbehavior.\nMODE RULES (operate, from <REPO>/tests/fixtures/mode-rules-skill/reference/mode-operate.md). They govern this surface's directions and every comp you write or judge for it, the decision comps included; where shared guidance conflicts, these win.\nDIRECTIONS\n- OPERATE DIRECTION RULE.\n\n### Nested heading stays in the body\n\n- OPERATE DIRECTION SUB RULE.\nCOMPS\n- OPERATE COMP RULE.\nA user- or brief-pinned decision beats the roll, always.\nDEALT INDICES (restated for truncated readers): 4, 6, 7; index\n4 leads. Present all three dealt structures; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Present this hand on the decision page: write the options payload (`<IMPECCABLE> serve-question --schema` prints its shape), run `<IMPECCABLE> serve-question --start --payload <file>`, and open the URL it prints for the user.\n- With image generation, each dealt card declares a comp under .impeccable/mocks/decision/; serve first, then generate them in reading order, lead first, each with its prompt sidecar (a.png gets a.png.json). Without image generation, each card carries a wireframe instead (shape in --schema). Surface rounds have no pick card and no canon card.\n- After the last comp lands (at once when this round generates none), hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n",+ "stderr": "",+ "exit": 0,+ "signal": null+ },+ {+ "stdout": "",+ "stderr": "serve-question: this surface round (concept-seed's latest roll here was --scope surface) is comp-led with image generation (buildPath value \"comp\", toggle true), so every dealt card declares a decision comp; the page was not served. Missing a \"comp\": ledger, rail, field. Give each of those cards \"comp\": \".impeccable/mocks/decision/<card id>.png\", then rerun --start; the comps are generated after the page serves, as its NEXT line says.\n",+ "exit": 1,+ "signal": null+ }+ ],+ "files": {+ ".impeccable/questions/roll.json": "{\"scope\":\"surface\",\"key\":\"oracle-key-1\",\"reroll\":0,\"at\": <EPOCH>}"+ }+}diff --git a/tests/oracle/golden/question-update-surface-missing-comps.json b/tests/oracle/golden/question-update-surface-missing-comps.jsonnew file mode 100644index 000000000..407b2fc18--- /dev/null+++ b/tests/oracle/golden/question-update-surface-missing-comps.json@@ -0,0 +1,20 @@+{+ "steps": [+ {+ "stdout": "SURFACE CONCEPT SEED (key: oracle-key-1; mode: operate; source: degraded; rerun with --scope surface --mode operate --from oracle-key-1 --reroll 1 --candidate-count 7)\nDEALT INDICES: 5, 4, 2 (index 5 leads)\n After ordering the task's grounded structural candidates by resonance,\n deal candidates 5, 4, 2 of your own grounded list to the\n table; index 5 leads, and the deal never points at a challenger.\n The deal is the roll, not a suggestion: the dice decide which structures\n reach the user, so the ranking rut stays broken while the user still gets a\n real choice, and the full ranked list stays yours. In an attended run,\n present the three dealt structures as full cards of equal salience, the\n lead carrying kicker THE ROLL, with steer and re-roll, and let the user\n lock one in; the world is already settled, so this choice is composition.\n Visualize every dealt card: with image generation available and a\n comp-led default (.impeccable/config.json buildPath; the page toggle\n handles the exception), declare a comp per card and generate after\n serving, lead first; otherwise author each card's wireframe field (see\n serve-question --schema) and the page draws the schematic. Carry the\n recorded default in the payload as buildPath with toggle: true. Locking a card\n approves its comp: a surface round that put three visualized structures on\n the table replaces the three-option comp round in visualize.md. Re-roll\n yourself only when every dealt structure fails audience identification or\n product clarity on named factual grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nthe only file written is the local roll record .impeccable/questions/roll.json,\nwhich serve-question reads. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and DESIGN.md constrain every surface candidate's identity\nvocabulary; they do not cancel task-level composition. The seed never\nauthorizes a new palette, type system, material world, or unfamiliar control\nbehavior.\nMODE RULES (operate, from <REPO>/tests/fixtures/mode-rules-skill/reference/mode-operate.md). They govern this surface's directions and every comp you write or judge for it, the decision comps included; where shared guidance conflicts, these win.\nDIRECTIONS\n- OPERATE DIRECTION RULE.\n\n### Nested heading stays in the body\n\n- OPERATE DIRECTION SUB RULE.\nCOMPS\n- OPERATE COMP RULE.\nA user- or brief-pinned decision beats the roll, always.\nDEALT INDICES (restated for truncated readers): 5, 4, 2; index\n5 leads. Present all three dealt structures; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Re-roll round: while the page is open on a key, deliver this hand to it with `<IMPECCABLE> serve-question --update --key <same key> --payload <file>` and never --start a second server. A re-roll made before any page opened starts one with `<IMPECCABLE> serve-question --start --payload <file>`; a round already on the structured-tool fallback stays there.\n- With image generation, each dealt card declares a comp under .impeccable/mocks/decision/; serve first, then generate them in reading order, lead first, each with its prompt sidecar (a.png gets a.png.json). Without image generation, each card carries a wireframe instead (shape in --schema). Surface rounds have no pick card and no canon card.\n- After the last comp lands (at once when this round generates none), hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n",+ "stderr": "",+ "exit": 0,+ "signal": null+ },+ {+ "stdout": "",+ "stderr": "serve-question: this surface round (concept-seed's latest roll here was --scope surface) is comp-led with image generation (buildPath value \"comp\", toggle true), so every dealt card declares a decision comp; nothing was delivered. Missing a \"comp\": rail, field. Give each of those cards \"comp\": \".impeccable/mocks/decision/<card id>.png\", 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/\"}",+ ".impeccable/questions/roll.json": "{\"scope\":\"surface\",\"key\":\"oracle-key-1\",\"reroll\":1,\"at\": <EPOCH>}"+ }+}diff --git a/tests/oracle/golden/question-update-surface-shape-after-direction-roll.json b/tests/oracle/golden/question-update-surface-shape-after-direction-roll.jsonnew file mode 100644index 000000000..8b9e3a3e5--- /dev/null+++ b/tests/oracle/golden/question-update-surface-shape-after-direction-roll.json@@ -0,0 +1,19 @@+{+ "steps": [+ {+ "stdout": "DIRECTION CONCEPT SEED (key: oracle-key-1; mode: persuade; source: degraded; rerun with --scope direction --mode persuade --from oracle-key-1 --candidate-count 7)\nASSIGNED INDEX: 6\n After ordering the grounded directions by resonance, build candidate\n 6 of your own grounded list; the assignment never points at a\n challenger. The assignment is the roll, not a suggestion: your top-ranked\n direction is what every run would ship, so the script decides which grounded\n direction gets built. Each direction joins a durable visual system to a\n concrete expression for the requested first surface, decided as one. It must\n survive the current task plus navigation, quiet and dense content,\n interaction and state, and a substantially different future surface. In an\n attended run, present the assigned direction fully committed and offer\n re-roll. You may add ONE card for your top-ranked grounded candidate when\n it is not the assigned direction, kicker IMPECCABLE’S PICK, with an honest risk line\n naming its familiarity; one pick card, never a ranked lineup, and the pick\n never takes the lead position. When the assignment IS your top candidate,\n there is no pick card. Re-roll yourself only\n on named factual grounds, when the assignment cannot carry the product's\n truth or task; taste is never grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nthe only file written is the local roll record .impeccable/questions/roll.json,\nwhich serve-question reads. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and explicit incumbent brand commitments constrain every direction.\nThe seed never chooses exact colors, fonts, tokens, or a user preference, and\nit never permits the world and first surface to be selected independently.\nMODE RULES (persuade, from <REPO>/tests/fixtures/mode-rules-skill/reference/mode-persuade.md). They govern this surface's directions and every comp you write or judge for it, the decision comps included; where shared guidance conflicts, these win.\nDIRECTIONS\n- PERSUADE DIRECTION RULE ONE.\n- PERSUADE DIRECTION RULE TWO.\nCOMPS\n- PERSUADE COMP RULE.\nA user- or brief-pinned decision beats the roll, always.\nASSIGNED INDEX (restated for truncated readers): 6. Build candidate\n6 of your own grounded list; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Present this hand on the decision page: write the options payload (`<IMPECCABLE> serve-question --schema` prints its shape), run `<IMPECCABLE> serve-question --start --payload <file>`, and open the URL it prints for the user.\n- This degraded hand goes on the page as a single text-only card with re-roll; it declares no comp.\n- Right after serving, with no comp to generate first, hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n",+ "stderr": "",+ "exit": 0,+ "signal": null+ },+ {+ "stdout": "next round delivered; the page reloads itself\n",+ "stderr": "",+ "exit": 0,+ "signal": null+ }+ ],+ "files": {+ ".impeccable/questions/k1.next.json": "{\"title\":\"Choose the structure\",\"options\":[{\"id\":\"ledger\",\"label\":\"Ledger\",\"kicker\":\"THE ROLL\",\"thesis\":\"One.\"},{\"id\":\"rail\",\"label\":\"Rail\",\"thesis\":\"Two.\"},{\"id\":\"field\",\"label\":\"Field\",\"thesis\":\"Three.\"}],\"reroll\":true,\"buildPath\":{\"value\":\"comp\",\"toggle\":true}}"+ }+}diff --git a/tests/oracle/golden/seed-degraded-bolder.json b/tests/oracle/golden/seed-degraded-bolder.jsonindex 29edbaa0b..4faaa49b3 100644--- a/tests/oracle/golden/seed-degraded-bolder.json+++ b/tests/oracle/golden/seed-degraded-bolder.json@@ -1,5 +1,5 @@{- "stdout": "DIRECTION CONCEPT SEED (key: oracle-key-1; mode: unscoped; source: degraded; rerun with --scope direction --from oracle-key-1 --reroll 1 --register bolder --candidate-count 7)\nBOLDER REGISTER UNAVAILABLE: bolder deals foreign forms, and this roll ran\n degraded with no catalog and no roll service, so there is nothing bold to\n deal. Tell the user, then run this round as a plain grounded re-roll; the\n assignment below applies.\nASSIGNED INDEX: 3\n After ordering the grounded directions by resonance, build candidate\n 3 of your own grounded list; the assignment never points at a\n challenger. The assignment is the roll, not a suggestion: your top-ranked\n direction is what every run would ship, so the script decides which grounded\n direction gets built. Each direction joins a durable visual system to a\n concrete expression for the requested first surface, decided as one. It must\n survive the current task plus navigation, quiet and dense content,\n interaction and state, and a substantially different future surface. In an\n attended run, present the assigned direction fully committed and offer\n re-roll. You may add ONE card for your top-ranked grounded candidate when\n it is not the assigned direction, kicker IMPECCABLE’S PICK, with an honest risk line\n naming its familiarity; one pick card, never a ranked lineup, and the pick\n never takes the lead position. When the assignment IS your top candidate,\n there is no pick card. Re-roll yourself only\n on named factual grounds, when the assignment cannot carry the product's\n truth or task; taste is never grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nnothing is written. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and explicit incumbent brand commitments constrain every direction.\nThe seed never chooses exact colors, fonts, tokens, or a user preference, and\nit never permits the world and first surface to be selected independently.\nA user- or brief-pinned decision beats the roll, always.\nASSIGNED INDEX (restated for truncated readers): 3. Build candidate\n3 of your own grounded list; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Re-roll round: while the page is open on a key, deliver this hand to it with `<IMPECCABLE> serve-question --update --key <same key> --payload <file>` and never --start a second server. A re-roll made before any page opened starts one with `<IMPECCABLE> serve-question --start --payload <file>`; a round already on the structured-tool fallback stays there.\n- This degraded hand goes on the page as a single text-only card with re-roll; it declares no comp.\n- Right after serving, with no comp to generate first, hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n",+ "stdout": "DIRECTION CONCEPT SEED (key: oracle-key-1; mode: unscoped; source: degraded; rerun with --scope direction --from oracle-key-1 --reroll 1 --register bolder --candidate-count 7)\nBOLDER REGISTER UNAVAILABLE: bolder deals foreign forms, and this roll ran\n degraded with no catalog and no roll service, so there is nothing bold to\n deal. Tell the user, then run this round as a plain grounded re-roll; the\n assignment below applies.\nASSIGNED INDEX: 3\n After ordering the grounded directions by resonance, build candidate\n 3 of your own grounded list; the assignment never points at a\n challenger. The assignment is the roll, not a suggestion: your top-ranked\n direction is what every run would ship, so the script decides which grounded\n direction gets built. Each direction joins a durable visual system to a\n concrete expression for the requested first surface, decided as one. It must\n survive the current task plus navigation, quiet and dense content,\n interaction and state, and a substantially different future surface. In an\n attended run, present the assigned direction fully committed and offer\n re-roll. You may add ONE card for your top-ranked grounded candidate when\n it is not the assigned direction, kicker IMPECCABLE’S PICK, with an honest risk line\n naming its familiarity; one pick card, never a ranked lineup, and the pick\n never takes the lead position. When the assignment IS your top candidate,\n there is no pick card. Re-roll yourself only\n on named factual grounds, when the assignment cannot carry the product's\n truth or task; taste is never grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nthe only file written is the local roll record .impeccable/questions/roll.json,\nwhich serve-question reads. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and explicit incumbent brand commitments constrain every direction.\nThe seed never chooses exact colors, fonts, tokens, or a user preference, and\nit never permits the world and first surface to be selected independently.\nA user- or brief-pinned decision beats the roll, always.\nASSIGNED INDEX (restated for truncated readers): 3. Build candidate\n3 of your own grounded list; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Re-roll round: while the page is open on a key, deliver this hand to it with `<IMPECCABLE> serve-question --update --key <same key> --payload <file>` and never --start a second server. A re-roll made before any page opened starts one with `<IMPECCABLE> serve-question --start --payload <file>`; a round already on the structured-tool fallback stays there.\n- This degraded hand goes on the page as a single text-only card with re-roll; it declares no comp.\n- Right after serving, with no comp to generate first, hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n","stderr": "","exit": 0,"signal": null,diff --git a/tests/oracle/golden/seed-degraded-direction.json b/tests/oracle/golden/seed-degraded-direction.jsonindex e0bdfcd5f..6d5108357 100644--- a/tests/oracle/golden/seed-degraded-direction.json+++ b/tests/oracle/golden/seed-degraded-direction.json@@ -1,5 +1,5 @@{- "stdout": "DIRECTION CONCEPT SEED (key: oracle-key-1; mode: persuade; source: degraded; rerun with --scope direction --mode persuade --from oracle-key-1 --candidate-count 7)\nASSIGNED INDEX: 6\n After ordering the grounded directions by resonance, build candidate\n 6 of your own grounded list; the assignment never points at a\n challenger. The assignment is the roll, not a suggestion: your top-ranked\n direction is what every run would ship, so the script decides which grounded\n direction gets built. Each direction joins a durable visual system to a\n concrete expression for the requested first surface, decided as one. It must\n survive the current task plus navigation, quiet and dense content,\n interaction and state, and a substantially different future surface. In an\n attended run, present the assigned direction fully committed and offer\n re-roll. You may add ONE card for your top-ranked grounded candidate when\n it is not the assigned direction, kicker IMPECCABLE’S PICK, with an honest risk line\n naming its familiarity; one pick card, never a ranked lineup, and the pick\n never takes the lead position. When the assignment IS your top candidate,\n there is no pick card. Re-roll yourself only\n on named factual grounds, when the assignment cannot carry the product's\n truth or task; taste is never grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nnothing is written. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and explicit incumbent brand commitments constrain every direction.\nThe seed never chooses exact colors, fonts, tokens, or a user preference, and\nit never permits the world and first surface to be selected independently.\nMODE RULES (persuade, from <REPO>/tests/fixtures/mode-rules-skill/reference/mode-persuade.md). They govern this surface's directions and every comp you write or judge for it, the decision comps included; where shared guidance conflicts, these win.\nDIRECTIONS\n- PERSUADE DIRECTION RULE ONE.\n- PERSUADE DIRECTION RULE TWO.\nCOMPS\n- PERSUADE COMP RULE.\nA user- or brief-pinned decision beats the roll, always.\nASSIGNED INDEX (restated for truncated readers): 6. Build candidate\n6 of your own grounded list; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Present this hand on the decision page: write the options payload (`<IMPECCABLE> serve-question --schema` prints its shape), run `<IMPECCABLE> serve-question --start --payload <file>`, and open the URL it prints for the user.\n- This degraded hand goes on the page as a single text-only card with re-roll; it declares no comp.\n- Right after serving, with no comp to generate first, hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n",+ "stdout": "DIRECTION CONCEPT SEED (key: oracle-key-1; mode: persuade; source: degraded; rerun with --scope direction --mode persuade --from oracle-key-1 --candidate-count 7)\nASSIGNED INDEX: 6\n After ordering the grounded directions by resonance, build candidate\n 6 of your own grounded list; the assignment never points at a\n challenger. The assignment is the roll, not a suggestion: your top-ranked\n direction is what every run would ship, so the script decides which grounded\n direction gets built. Each direction joins a durable visual system to a\n concrete expression for the requested first surface, decided as one. It must\n survive the current task plus navigation, quiet and dense content,\n interaction and state, and a substantially different future surface. In an\n attended run, present the assigned direction fully committed and offer\n re-roll. You may add ONE card for your top-ranked grounded candidate when\n it is not the assigned direction, kicker IMPECCABLE’S PICK, with an honest risk line\n naming its familiarity; one pick card, never a ranked lineup, and the pick\n never takes the lead position. When the assignment IS your top candidate,\n there is no pick card. Re-roll yourself only\n on named factual grounds, when the assignment cannot carry the product's\n truth or task; taste is never grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nthe only file written is the local roll record .impeccable/questions/roll.json,\nwhich serve-question reads. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and explicit incumbent brand commitments constrain every direction.\nThe seed never chooses exact colors, fonts, tokens, or a user preference, and\nit never permits the world and first surface to be selected independently.\nMODE RULES (persuade, from <REPO>/tests/fixtures/mode-rules-skill/reference/mode-persuade.md). They govern this surface's directions and every comp you write or judge for it, the decision comps included; where shared guidance conflicts, these win.\nDIRECTIONS\n- PERSUADE DIRECTION RULE ONE.\n- PERSUADE DIRECTION RULE TWO.\nCOMPS\n- PERSUADE COMP RULE.\nA user- or brief-pinned decision beats the roll, always.\nASSIGNED INDEX (restated for truncated readers): 6. Build candidate\n6 of your own grounded list; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Present this hand on the decision page: write the options payload (`<IMPECCABLE> serve-question --schema` prints its shape), run `<IMPECCABLE> serve-question --start --payload <file>`, and open the URL it prints for the user.\n- This degraded hand goes on the page as a single text-only card with re-roll; it declares no comp.\n- Right after serving, with no comp to generate first, hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n","stderr": "","exit": 0,"signal": null,diff --git a/tests/oracle/golden/seed-degraded-surface.json b/tests/oracle/golden/seed-degraded-surface.jsonindex a86fc45d4..efdf40199 100644--- a/tests/oracle/golden/seed-degraded-surface.json+++ b/tests/oracle/golden/seed-degraded-surface.json@@ -1,5 +1,5 @@{- "stdout": "SURFACE CONCEPT SEED (key: oracle-key-1; mode: operate; source: degraded; rerun with --scope surface --mode operate --from oracle-key-1 --candidate-count 7)\nDEALT INDICES: 4, 6, 7 (index 4 leads)\n After ordering the task's grounded structural candidates by resonance,\n deal candidates 4, 6, 7 of your own grounded list to the\n table; index 4 leads, and the deal never points at a challenger.\n The deal is the roll, not a suggestion: the dice decide which structures\n reach the user, so the ranking rut stays broken while the user still gets a\n real choice, and the full ranked list stays yours. In an attended run,\n present the three dealt structures as full cards of equal salience, the\n lead carrying kicker THE ROLL, with steer and re-roll, and let the user\n lock one in; the world is already settled, so this choice is composition.\n Visualize every dealt card: with image generation available and a\n comp-led default (.impeccable/config.json buildPath; the page toggle\n handles the exception), declare a comp per card and generate after\n serving, lead first; otherwise author each card's wireframe field (see\n serve-question --schema) and the page draws the schematic. Carry the\n recorded default in the payload as buildPath with toggle: true. Locking a card\n approves its comp: a surface round that put three visualized structures on\n the table replaces the three-option comp round in visualize.md. Re-roll\n yourself only when every dealt structure fails audience identification or\n product clarity on named factual grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nnothing is written. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and DESIGN.md constrain every surface candidate's identity\nvocabulary; they do not cancel task-level composition. The seed never\nauthorizes a new palette, type system, material world, or unfamiliar control\nbehavior.\nMODE RULES (operate, from <REPO>/tests/fixtures/mode-rules-skill/reference/mode-operate.md). They govern this surface's directions and every comp you write or judge for it, the decision comps included; where shared guidance conflicts, these win.\nDIRECTIONS\n- OPERATE DIRECTION RULE.\n\n### Nested heading stays in the body\n\n- OPERATE DIRECTION SUB RULE.\nCOMPS\n- OPERATE COMP RULE.\nA user- or brief-pinned decision beats the roll, always.\nDEALT INDICES (restated for truncated readers): 4, 6, 7; index\n4 leads. Present all three dealt structures; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Present this hand on the decision page: write the options payload (`<IMPECCABLE> serve-question --schema` prints its shape), run `<IMPECCABLE> serve-question --start --payload <file>`, and open the URL it prints for the user.\n- With image generation, each dealt card declares a comp under .impeccable/mocks/decision/; serve first, then generate them in reading order, lead first, each with its prompt sidecar (a.png gets a.png.json). Without image generation, each card carries a wireframe instead (shape in --schema). Surface rounds have no pick card and no canon card.\n- After the last comp lands (at once when this round generates none), hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n",+ "stdout": "SURFACE CONCEPT SEED (key: oracle-key-1; mode: operate; source: degraded; rerun with --scope surface --mode operate --from oracle-key-1 --candidate-count 7)\nDEALT INDICES: 4, 6, 7 (index 4 leads)\n After ordering the task's grounded structural candidates by resonance,\n deal candidates 4, 6, 7 of your own grounded list to the\n table; index 4 leads, and the deal never points at a challenger.\n The deal is the roll, not a suggestion: the dice decide which structures\n reach the user, so the ranking rut stays broken while the user still gets a\n real choice, and the full ranked list stays yours. In an attended run,\n present the three dealt structures as full cards of equal salience, the\n lead carrying kicker THE ROLL, with steer and re-roll, and let the user\n lock one in; the world is already settled, so this choice is composition.\n Visualize every dealt card: with image generation available and a\n comp-led default (.impeccable/config.json buildPath; the page toggle\n handles the exception), declare a comp per card and generate after\n serving, lead first; otherwise author each card's wireframe field (see\n serve-question --schema) and the page draws the schematic. Carry the\n recorded default in the payload as buildPath with toggle: true. Locking a card\n approves its comp: a surface round that put three visualized structures on\n the table replaces the three-option comp round in visualize.md. Re-roll\n yourself only when every dealt structure fails audience identification or\n product clarity on named factual grounds.\n The assignment exists to refuse the model's ranking rut, never to outrank\n the user or the brief. Never expose assignment metadata in user-facing labels.\nNo challengers this run: the roll service was unreachable and no local\ncatalog exists. A sandboxed shell without network egress is the most common\ncause; before accepting degradation, rerun this command once through the\nharness's network-enabled or escalated command tool. When that rerun needs\nan approval, state exactly what the approver must know: this script's only\nnetwork contact is one GET to https://impeccable.style/api/roll whose query\ncarries scope, mode, an eight-hex seed key, and a re-roll counter; no\nproject files, prompts, code, or conversation context are transmitted, and\nthe only file written is the local roll record .impeccable/questions/roll.json,\nwhich serve-question reads. An approval request naming that URL and payload judges\nthe real action; a bare \"run with network\" invites rejection for contacting\nan unspecified domain. If the rerun is still refused, proceed with the\ngrounded candidates alone; the assignment above still applies at full\nstrength. Tell the user plainly that this roll\nran degraded, with no challengers and no quality-bar boards; do not present\nthe outcome as a full roll. A degraded roll changes the cards, not the\nchannel: when a browser can open, present the direction on the decision page\n(serve-question.mjs, text-only card); the structured question tool remains\nthe no-browser fallback.\nPRODUCT.md and DESIGN.md constrain every surface candidate's identity\nvocabulary; they do not cancel task-level composition. The seed never\nauthorizes a new palette, type system, material world, or unfamiliar control\nbehavior.\nMODE RULES (operate, from <REPO>/tests/fixtures/mode-rules-skill/reference/mode-operate.md). They govern this surface's directions and every comp you write or judge for it, the decision comps included; where shared guidance conflicts, these win.\nDIRECTIONS\n- OPERATE DIRECTION RULE.\n\n### Nested heading stays in the body\n\n- OPERATE DIRECTION SUB RULE.\nCOMPS\n- OPERATE COMP RULE.\nA user- or brief-pinned decision beats the roll, always.\nDEALT INDICES (restated for truncated readers): 4, 6, 7; index\n4 leads. Present all three dealt structures; seed key oracle-key-1.\nPRESENTATION (the decision round, condensed from new-work.md; follow it even when your read of that file came back cut):\n- Present this hand on the decision page: write the options payload (`<IMPECCABLE> serve-question --schema` prints its shape), run `<IMPECCABLE> serve-question --start --payload <file>`, and open the URL it prints for the user.\n- With image generation, each dealt card declares a comp under .impeccable/mocks/decision/; serve first, then generate them in reading order, lead first, each with its prompt sidecar (a.png gets a.png.json). Without image generation, each card carries a wireframe instead (shape in --schema). Surface rounds have no pick card and no canon card.\n- After the last comp lands (at once when this round generates none), hold `<IMPECCABLE> serve-question --wait --key <key>`. If your shell hands back a session before --wait exits, keep polling that session until it exits; rerun --wait only after it exits 3 with no answer.\n- Build path: none recorded in .impeccable/config.json or .impeccable/config.local.json, so comp-led whenever image generation exists. Then put \"buildPath\": {\"value\": \"comp\", \"toggle\": true} in the payload; without image generation there is no toggle and the build is code-led. Never ask about the build path during the round; only when the ANSWER returns buildPathFlipped: true, offer once afterwards to keep the flipped value as the default.\n- The structured question tool is the fallback, never the first channel: take it when --start exits 2, when --wait exits 4 after the page closed unanswered, or when your harness cannot hold a blocking --wait at all (say so in your first reply). It carries the same options and asks nothing about the build path.\n","stderr": "","exit": 0,"signal": null,