//! The rule against the vectors the Worker answers too, and over the whole//! personal kit. Synthetic tables only in the vectors.use serde_json::{json, Value};usesuper::*;fn vectors() -> Value {let path = cotton_store::manifest_dir().join("../cotton-conformance/vectors/seal/default.json"); serde_json::from_str(&std::fs::read_to_string(&path).unwrap_or_else(|error| panic!("{}: {error}", path.display()))).expect("the vectors read")}/// RULE (e2e rulings R1): the default answers every vector as the Worker's/// `defaultSeal` does.#[test]fn the_default_answers_every_vector() {for case in vectors()["cases"].as_array().expect("cases") {let said = default_seal(&case["table"]).map(|seal| json!({ "clear": seal.clear })); assert_eq!(said.unwrap_or(Value::Null), case["seal"], "{}", case["name"]); }}/// RULE (e2e rulings R1): every personal kit table is sealed unless the rule/// names it, every name is a kit table, and ruling twice changes nothing.#[test]fn every_personal_kit_table_is_sealed_unless_named() {letmut open = Vec::new();letmut held = std::collections::BTreeSet::new();let dir = cotton_store::manifest_dir().join("../cotton-core/kits/personal/tables");for entry in std::fs::read_dir(&dir).expect("the personal kit's tables") {let path = entry.expect("an entry").path();let name = path.display().to_string();let definition: Value = serde_json::from_str(&std::fs::read_to_string(&path).expect("a table file")).unwrap_or_else(|error| panic!("{name}: {error}"));let id = definition["id"].as_str().expect("an id").to_string(); held.insert(id.clone());let ruled = ruled(&definition); assert_eq!(super::ruled(&ruled), ruled, "{id}: ruling twice changes nothing");if ruled.get("seal").is_none() { open.push(id); } }let named: Vec<String> = rule().open.keys().chain(rule().pending.keys()).cloned().collect();for table in &named { assert!(held.contains(table), "{table} is a personal kit table"); }letmut expected = named; expected.sort(); open.sort(); assert_eq!(open, expected, "open only where the rule names it");}/// The owner's sign-off that memory may be sealed: set it to the date and words/// of the owner's ruling, only when the owner has given one.const OWNER_APPROVED_SEALING_MEMORY: Option<&str> = None;/// RULING (owner, 16 Nov 2026): memory stays open, so every assistant the person/// connects is briefed with it (assets/design/LAUNCH.md §3; a 22 Nov instruction/// to seal it was withdrawn the same day). Memory is never in the sealed set, by/// the kit's own `seal` block or by leaving the rule's open and pending lists,/// unless `OWNER_APPROVED_SEALING_MEMORY` names the owner's approval. The sealing/// path is held for that day in apps/business/test/window.test.ts MEMORY_SEALED.////// Since 23 Nov 2026 (owner-approved, relayed by the coordinator): memory is/// sealed one account at a time, by the Worker's memory lock/// (apps/business/src/memory_lock.ts, assets/design/shared/MEMORY-LOCK.md),/// never by the kit or the rule. So this guard still holds as written: the/// kit and the rule leave memory open, and only the switch, behind its two/// gates, lays the seal block on one object.#[test]fn memory_stays_open_by_the_owners_ruling_of_16_nov() {let path = cotton_store::manifest_dir().join("../cotton-core/kits/personal/tables/memory.json");let definition: Value = serde_json::from_str(&std::fs::read_to_string(&path).expect("memory.json")).expect("memory.json is JSON");let sealed = ruled(&definition).get("seal").is_some_and(Value::is_object);if OWNER_APPROVED_SEALING_MEMORY.is_none() { assert!(definition.get("seal").is_none(), "memory.json carries a seal block, but the owner ruled on 16 Nov 2026 that memory stays open"); assert!(!sealed, "the rule seals memory, but the owner ruled on 16 Nov 2026 that memory stays open: put it back on the pending list (default.json)"); assert!(rule().pending.contains_key("memory") || rule().open.contains_key("memory"), "memory is named open or pending in the rule"); }}