From c534b8ea831165f3eab130a94200a221fe55b21f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 14:41:14 -0800 Subject: [PATCH] Type: Kinsoku Shori sets refuse a null field type.kinsokuSets.set read a null value as a key left out, so `cannotStart: null` cleared that category and `from: null` made a renamed set look new to the paragraphs using it. A null value now fails the call and changes nothing. --- crates/engine/src/cmd/kinsokusets.rs | 4 ++++ crates/engine/src/cmd/kinsokusets/tests.rs | 6 +++++- docs/mcp.md | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/kinsokusets.rs b/crates/engine/src/cmd/kinsokusets.rs index e8fb7b5404..8a62c4d8b0 100644 --- a/crates/engine/src/cmd/kinsokusets.rs +++ b/crates/engine/src/cmd/kinsokusets.rs @@ -174,6 +174,10 @@ fn parse_set(v: &Value, c: &str) -> Result<(KinsokuSet, Option)> { if let Some(k) = o.keys().find(|k| !SET_KEYS.contains(&k.as_str())) { return Err(bad(c, format!("unknown key `{k}`; a set takes {}", SET_KEYS.join(", ")))); } + // A null value is refused rather than read as a key left out. + if let Some(k) = o.iter().find_map(|(k, v)| v.is_null().then_some(k)) { + return Err(bad(c, format!("`{k}` can't be null; leave it out instead"))); + } let raw = o.get("name").and_then(Value::as_str).ok_or_else(|| bad(c, "each set needs a name"))?; let name = KinsokuSet::clean_name(raw).ok_or_else(|| { bad(c, format!("`{raw}` can't name a Kinsoku set (1 to {KINSOKU_NAME_MAX} characters, no control characters, not None, Hard or Soft)")) diff --git a/crates/engine/src/cmd/kinsokusets/tests.rs b/crates/engine/src/cmd/kinsokusets/tests.rs index 290738aa26..1d1c8980c0 100644 --- a/crates/engine/src/cmd/kinsokusets/tests.rs +++ b/crates/engine/src/cmd/kinsokusets/tests.rs @@ -62,7 +62,8 @@ fn kinsoku_sets_are_set_as_one_undo_step_and_saved() { /// The sets are checked before anything changes: a built-in name, a blank or too-long name, two /// sets of one name in any case, an unknown key, a sequence of one character or with a space, a -/// control character, a `from` the document has no set of, and more than 256 sets all fail. +/// control character, a `from` the document has no set of, a null value, and more than 256 sets +/// all fail. #[test] fn kinsoku_sets_refuse_what_a_set_cannot_hold() { let mut s = session(); @@ -83,6 +84,9 @@ fn kinsoku_sets_refuse_what_a_set_cannot_hold() { json!([{"name": "A", "cannotStart": ["あ"]}]), json!([{"name": "A", "from": "Missing"}]), json!([{"name": "A", "from": "Tight"}, {"name": "B", "from": "tight"}]), + json!([{"name": "Tight", "from": "Tight", "cannotStart": null}]), + json!([{"name": "Tight", "from": null}]), + json!([{"name": "A", "inseparable": null}]), json!((0..257).map(|i| json!({"name": format!("S{i}")})).collect::>()), ] { assert!(s.execute("type.kinsokuSets.set", &json!({"sets": bad})).is_err(), "{bad}"); diff --git a/docs/mcp.md b/docs/mcp.md index b960c65333..c033a46904 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -8705,8 +8705,8 @@ sequence counts each of its characters); a control or space character in a categ case and never None, Hard or Soft; a document holds at most 256 sets. These limits are VectorCraft's own. A set with the name of a set the document has (any case) and no `from` edits that set; `from` names the set it renames. Every paragraph and paragraph style using an edited set takes its new characters and name, and those using a set left out -take Hard. An unknown key, a name used twice, a `from` the document has no set of and a sequence of one character fail -the call and change nothing. The built-in None, Hard and Soft are not stored and can't be changed. → `{sets}`. +take Hard. An unknown key, a null value, a name used twice, a `from` the document has no set of and a sequence of one +character fail the call and change nothing. The built-in None, Hard and Soft are not stored and can't be changed. → `{sets}`. `type.kinsokuSets.list` returns the sets with how many paragraphs (`paragraphs`), paragraph styles (`styles`) and graphs (`graphs`, in the paragraph attributes a graph keeps for its labels) use each. `type.kinsokuSets.base {base: "hard"|"soft"|"none"|name, name?}` returns the categories a new set based on a