From 3a716e09b4a4454ea57c43060e5da2b07c1a63d1 Mon Sep 17 00:00:00 2001 From: Agent IX Date: Sun, 15 Nov 2026 14:02:36 -0800 Subject: [PATCH 1/3] PLAT-1441: relations --json carries FR-084 record data (FR-030-AC-26) Bump quire-rs to 0.61.0 (supplies the selected record on relation rows) and adapt the three struct initialisers it extended. Tests prove connection, linked and reverse rows pass the engine's record through, omit unselected keys, and are byte-identical across runs. Co-Authored-By: Claude Sonnet 5.5 --- Cargo.lock | 8 +- src/commands/matrix.rs | 1 + src/commands/matrix_design.rs | 1 + src/commands/trace.rs | 1 + tests/cli_relations_record.rs | 209 ++++++++++++++++++++++++++++++++++ 5 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 tests/cli_relations_record.rs diff --git a/Cargo.lock b/Cargo.lock index 546265d..448c0d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 4 [[package]] name = "agent-ix-semantic-schema" version = "0.3.0" -source = "git+https://github.com/agent-ix/filament-core-data?branch=main#327a49ca9d7ab2c12269a8db65b75f1331e165bd" +source = "git+https://github.com/agent-ix/filament-core-data?branch=main#d7a9b7b60527b9640001acfb6fc8fdb5a9875a8f" [[package]] name = "ahash" @@ -1672,7 +1672,7 @@ dependencies = [ [[package]] name = "quire-code-extraction" version = "0.1.0" -source = "git+https://github.com/agent-ix/quire-rs?branch=main#5a45ec949737a41c69a90f6ac5eefcafb2e10716" +source = "git+https://github.com/agent-ix/quire-rs?branch=main#84c3e408c636b183de1ae88c89ad3a00e055cef6" dependencies = [ "quire-code-parse", ] @@ -1718,8 +1718,8 @@ dependencies = [ [[package]] name = "quire-rs" -version = "0.60.0" -source = "git+https://github.com/agent-ix/quire-rs?branch=main#5a45ec949737a41c69a90f6ac5eefcafb2e10716" +version = "0.61.0" +source = "git+https://github.com/agent-ix/quire-rs?branch=main#84c3e408c636b183de1ae88c89ad3a00e055cef6" dependencies = [ "agent-ix-semantic-schema", "globset", diff --git a/src/commands/matrix.rs b/src/commands/matrix.rs index d3f4e87..1defa4f 100644 --- a/src/commands/matrix.rs +++ b/src/commands/matrix.rs @@ -503,6 +503,7 @@ mod tests { method: None, binders: Vec::new(), record_binders: None, + unbacked_claims: Vec::new(), identity: None, status, }, diff --git a/src/commands/matrix_design.rs b/src/commands/matrix_design.rs index db04fff..0522f34 100644 --- a/src/commands/matrix_design.rs +++ b/src/commands/matrix_design.rs @@ -240,6 +240,7 @@ mod tests { method: None, binders: Vec::new(), record_binders: None, + unbacked_claims: Vec::new(), identity: None, status, }, diff --git a/src/commands/trace.rs b/src/commands/trace.rs index 6f01699..e56f6d0 100644 --- a/src/commands/trace.rs +++ b/src/commands/trace.rs @@ -484,6 +484,7 @@ fn search_by_prefix( query: Query::Id(prefix.to_string()), verifies, implements, + formalizes: Vec::new(), citations, ambiguous_matches: Vec::new(), resolved, diff --git a/tests/cli_relations_record.rs b/tests/cli_relations_record.rs new file mode 100644 index 0000000..08a2154 --- /dev/null +++ b/tests/cli_relations_record.rs @@ -0,0 +1,209 @@ +//! FR-030-AC-26 — `quire relations --json` passes the engine's selected FR-084 +//! `record` data through unchanged, on connection and linked entries and on the +//! reverse relation's rows. Kinds, verbs and keys are authored by the fixture +//! module below; the CLI knows none of them. +mod common; + +use std::fs; +use std::path::Path; +use std::process::Output; + +use ix_trace_rs::trace; +use serde_json::{json, Value}; +use tempfile::TempDir; + +const MANIFEST: &str = "\ +name: record-fixture +version: 0.1.0 +artifact_types: +- name: Connection +- name: Classification + data_schema: + schema: schemas/Classification.json +semantic: + contract_version: 1.0.0 + package: agent-ix/record-fixture + exports: [Classification] + targets: [json-schema, markdown] +traceability: + required_relations: + - name: conn-classified + from: Connection + edges: [classified-as] + to: [Classification] + direction: outgoing + check: conn-unclassified + record_keys: [cats] + - name: cls-used + from: Classification + edges: [classified-as] + to: [Connection] + direction: incoming + check: cls-unused + record_keys: [cats] +"; + +const SCHEMA: &str = r#"{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "cats": { "type": "array", "items": { "enum": ["a", "b", "c"] } }, + "lvl": { "enum": ["hi", "lo"] } + }, + "additionalProperties": false +}"#; + +fn write(root: &Path, rel: &str, text: &str) { + let path = root.join(rel); + fs::create_dir_all(path.parent().unwrap()).unwrap(); + fs::write(path, text).unwrap(); +} + +fn connection(id: &str, targets: &[&str]) -> String { + let mut rels = String::new(); + if !targets.is_empty() { + rels.push_str("relationships:\n"); + for target in targets { + rels.push_str(&format!( + " - target: \"{target}\"\n type: \"classified-as\"\n" + )); + } + } + format!("---\nid: {id}\ntype: Connection\ntitle: {id}\n{rels}---\n\n# {id}\n") +} + +fn classification(id: &str, record: &str) -> String { + format!("---\nid: {id}\ntype: Classification\ntitle: {id}\n{record}---\n\n# {id}\n") +} + +/// CLS-001 states `cats` and `lvl`; CLS-002 states only `lvl`, so it has no +/// selected record. CONN-001 points at both, CONN-002 at CLS-001. +fn world() -> TempDir { + let dir = TempDir::new().unwrap(); + let module = dir.path().join("m"); + write(&module, "manifest.yaml", MANIFEST); + write(&module, "schemas/Classification.json", SCHEMA); + let repo = dir.path().join("repo"); + write( + &repo, + "spec/CONN-001.md", + &connection("CONN-001", &["CLS-001", "CLS-002"]), + ); + write( + &repo, + "spec/CONN-002.md", + &connection("CONN-002", &["CLS-001"]), + ); + write( + &repo, + "spec/CLS-001.md", + &classification("CLS-001", "cats: [a, b]\nlvl: hi\n"), + ); + write( + &repo, + "spec/CLS-002.md", + &classification("CLS-002", "lvl: lo\n"), + ); + dir +} + +fn relations(dir: &TempDir) -> Output { + common::quire() + .arg("relations") + .arg("--scope") + .arg(dir.path().join("repo")) + .arg("--module") + .arg(dir.path().join("m")) + .arg("--json") + .output() + .unwrap() +} + +fn report(output: &Output) -> Value { + assert!( + output.status.success(), + "stderr: {}", + String::from_utf8_lossy(&output.stderr) + ); + serde_json::from_slice(&output.stdout).unwrap() +} + +fn rows<'v>(report: &'v Value, relation: &str) -> &'v Vec { + report["relations"] + .as_array() + .unwrap() + .iter() + .find(|s| s["name"] == relation) + .unwrap_or_else(|| panic!("no relation {relation}"))["rows"] + .as_array() + .unwrap() +} + +fn row<'v>(report: &'v Value, relation: &str, id: &str) -> &'v Value { + rows(report, relation) + .iter() + .find(|r| r["document"]["id"] == id) + .unwrap_or_else(|| panic!("no row {id} in {relation}")) +} + +fn linked<'v>(row: &'v Value, id: &str) -> &'v Value { + row["linked"] + .as_array() + .unwrap() + .iter() + .find(|e| e["id"] == id) + .unwrap_or_else(|| panic!("no linked {id}")) +} + +#[trace("FR-030-AC-26")] +#[test] +fn a_connection_reports_its_classifications_selected_record() { + let dir = world(); + let report = report(&relations(&dir)); + let conn = row(&report, "conn-classified", "CONN-001"); + // The selected key is carried; the unselected `lvl` is not. + assert_eq!( + linked(conn, "CLS-001")["record"], + json!({"cats": ["a", "b"]}) + ); + // A classification stating no selected key has no `record` key at all. + assert!(linked(conn, "CLS-002") + .as_object() + .unwrap() + .get("record") + .is_none()); +} + +#[trace("FR-030-AC-26")] +#[test] +fn the_reverse_relation_lists_each_classifications_connections() { + let dir = world(); + let report = report(&relations(&dir)); + let cls = row(&report, "cls-used", "CLS-001"); + assert_eq!(cls["document"]["record"], json!({"cats": ["a", "b"]})); + let ids: Vec<&str> = cls["linked"] + .as_array() + .unwrap() + .iter() + .map(|e| e["id"].as_str().unwrap()) + .collect(); + assert_eq!(ids, ["CONN-001", "CONN-002"]); + // Connections declare no `cats`, so their entries carry no record. + assert!(linked(cls, "CONN-001") + .as_object() + .unwrap() + .get("record") + .is_none()); +} + +#[trace("FR-030-AC-26")] +#[test] +fn level_and_unselected_keys_are_omitted_and_runs_are_byte_identical() { + let dir = world(); + let first = relations(&dir); + let second = relations(&dir); + assert_eq!(first.stdout, second.stdout); + let text = String::from_utf8(first.stdout).unwrap(); + assert!(!text.contains("\"lvl\""), "unselected key leaked: {text}"); + assert!(!text.contains("\"hi\""), "unselected value leaked: {text}"); +} From 5484220d9ab3fdc90843905e3ddab62f7f855f56 Mon Sep 17 00:00:00 2001 From: Agent IX Date: Sun, 15 Nov 2026 14:11:52 -0800 Subject: [PATCH 2/3] PLAT-1441: assert real regulatedCategories record on forward and reverse rows Co-Authored-By: Claude Sonnet 5.5 --- tests/cli_relations_record.rs | 140 +++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 60 deletions(-) diff --git a/tests/cli_relations_record.rs b/tests/cli_relations_record.rs index 08a2154..a1cb4a1 100644 --- a/tests/cli_relations_record.rs +++ b/tests/cli_relations_record.rs @@ -17,13 +17,15 @@ name: record-fixture version: 0.1.0 artifact_types: - name: Connection + data_schema: + schema: schemas/Record.json - name: Classification data_schema: - schema: schemas/Classification.json + schema: schemas/Record.json semantic: contract_version: 1.0.0 package: agent-ix/record-fixture - exports: [Classification] + exports: [Connection, Classification] targets: [json-schema, markdown] traceability: required_relations: @@ -33,22 +35,22 @@ traceability: to: [Classification] direction: outgoing check: conn-unclassified - record_keys: [cats] + record_keys: [regulatedCategories] - name: cls-used from: Classification edges: [classified-as] to: [Connection] direction: incoming check: cls-unused - record_keys: [cats] + record_keys: [regulatedCategories] "; const SCHEMA: &str = r#"{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { - "cats": { "type": "array", "items": { "enum": ["a", "b", "c"] } }, - "lvl": { "enum": ["hi", "lo"] } + "regulatedCategories": { "type": "array", "items": { "enum": ["alpha", "beta"] } }, + "level": { "enum": ["high", "low"] } }, "additionalProperties": false }"#; @@ -59,7 +61,7 @@ fn write(root: &Path, rel: &str, text: &str) { fs::write(path, text).unwrap(); } -fn connection(id: &str, targets: &[&str]) -> String { +fn doc(id: &str, ty: &str, record: &str, targets: &[&str]) -> String { let mut rels = String::new(); if !targets.is_empty() { rels.push_str("relationships:\n"); @@ -69,41 +71,50 @@ fn connection(id: &str, targets: &[&str]) -> String { )); } } - format!("---\nid: {id}\ntype: Connection\ntitle: {id}\n{rels}---\n\n# {id}\n") -} - -fn classification(id: &str, record: &str) -> String { - format!("---\nid: {id}\ntype: Classification\ntitle: {id}\n{record}---\n\n# {id}\n") + format!("---\nid: {id}\ntype: {ty}\ntitle: {id}\n{record}{rels}---\n\n# {id}\n") } -/// CLS-001 states `cats` and `lvl`; CLS-002 states only `lvl`, so it has no -/// selected record. CONN-001 points at both, CONN-002 at CLS-001. +/// Every document states `level`, which no relation selects. CONN-001 and +/// CLS-001 also state `regulatedCategories`; CONN-002 and CLS-002 state no +/// selected key at all. CONN-001 points at both classifications, CONN-002 at +/// CLS-001. fn world() -> TempDir { let dir = TempDir::new().unwrap(); let module = dir.path().join("m"); write(&module, "manifest.yaml", MANIFEST); - write(&module, "schemas/Classification.json", SCHEMA); + write(&module, "schemas/Record.json", SCHEMA); let repo = dir.path().join("repo"); - write( - &repo, - "spec/CONN-001.md", - &connection("CONN-001", &["CLS-001", "CLS-002"]), - ); - write( - &repo, - "spec/CONN-002.md", - &connection("CONN-002", &["CLS-001"]), - ); - write( - &repo, - "spec/CLS-001.md", - &classification("CLS-001", "cats: [a, b]\nlvl: hi\n"), - ); - write( - &repo, - "spec/CLS-002.md", - &classification("CLS-002", "lvl: lo\n"), - ); + let docs = [ + ( + "CONN-001", + doc( + "CONN-001", + "Connection", + "regulatedCategories: [alpha, beta]\nlevel: high\n", + &["CLS-001", "CLS-002"], + ), + ), + ( + "CONN-002", + doc("CONN-002", "Connection", "level: low\n", &["CLS-001"]), + ), + ( + "CLS-001", + doc( + "CLS-001", + "Classification", + "regulatedCategories: [alpha]\nlevel: high\n", + &[], + ), + ), + ( + "CLS-002", + doc("CLS-002", "Classification", "level: low\n", &[]), + ), + ]; + for (id, text) in docs { + write(&repo, &format!("spec/{id}.md"), &text); + } dir } @@ -128,7 +139,7 @@ fn report(output: &Output) -> Value { serde_json::from_slice(&output.stdout).unwrap() } -fn rows<'v>(report: &'v Value, relation: &str) -> &'v Vec { +fn row<'v>(report: &'v Value, relation: &str, id: &str) -> &'v Value { report["relations"] .as_array() .unwrap() @@ -137,10 +148,6 @@ fn rows<'v>(report: &'v Value, relation: &str) -> &'v Vec { .unwrap_or_else(|| panic!("no relation {relation}"))["rows"] .as_array() .unwrap() -} - -fn row<'v>(report: &'v Value, relation: &str, id: &str) -> &'v Value { - rows(report, relation) .iter() .find(|r| r["document"]["id"] == id) .unwrap_or_else(|| panic!("no row {id} in {relation}")) @@ -155,32 +162,42 @@ fn linked<'v>(row: &'v Value, id: &str) -> &'v Value { .unwrap_or_else(|| panic!("no linked {id}")) } +fn assert_no_record(entry: &Value) { + assert!( + entry.get("record").is_none(), + "expected no record key: {entry}" + ); +} + #[trace("FR-030-AC-26")] #[test] -fn a_connection_reports_its_classifications_selected_record() { +fn a_connection_and_its_linked_classifications_carry_the_selected_record() { let dir = world(); let report = report(&relations(&dir)); let conn = row(&report, "conn-classified", "CONN-001"); - // The selected key is carried; the unselected `lvl` is not. + assert_eq!( + conn["document"]["record"], + json!({"regulatedCategories": ["alpha", "beta"]}) + ); assert_eq!( linked(conn, "CLS-001")["record"], - json!({"cats": ["a", "b"]}) + json!({"regulatedCategories": ["alpha"]}) ); - // A classification stating no selected key has no `record` key at all. - assert!(linked(conn, "CLS-002") - .as_object() - .unwrap() - .get("record") - .is_none()); + assert_no_record(linked(conn, "CLS-002")); + // No selected key: no `regulatedCategories`, and no `record` at all. + assert_no_record(&row(&report, "conn-classified", "CONN-002")["document"]); } #[trace("FR-030-AC-26")] #[test] -fn the_reverse_relation_lists_each_classifications_connections() { +fn the_reverse_relation_lists_each_classifications_connections_with_their_record() { let dir = world(); let report = report(&relations(&dir)); let cls = row(&report, "cls-used", "CLS-001"); - assert_eq!(cls["document"]["record"], json!({"cats": ["a", "b"]})); + assert_eq!( + cls["document"]["record"], + json!({"regulatedCategories": ["alpha"]}) + ); let ids: Vec<&str> = cls["linked"] .as_array() .unwrap() @@ -188,22 +205,25 @@ fn the_reverse_relation_lists_each_classifications_connections() { .map(|e| e["id"].as_str().unwrap()) .collect(); assert_eq!(ids, ["CONN-001", "CONN-002"]); - // Connections declare no `cats`, so their entries carry no record. - assert!(linked(cls, "CONN-001") - .as_object() - .unwrap() - .get("record") - .is_none()); + assert_eq!( + linked(cls, "CONN-001")["record"], + json!({"regulatedCategories": ["alpha", "beta"]}) + ); + assert_no_record(linked(cls, "CONN-002")); + assert_no_record(&row(&report, "cls-used", "CLS-002")["document"]); } #[trace("FR-030-AC-26")] #[test] -fn level_and_unselected_keys_are_omitted_and_runs_are_byte_identical() { +fn level_is_omitted_and_runs_are_byte_identical() { let dir = world(); let first = relations(&dir); let second = relations(&dir); assert_eq!(first.stdout, second.stdout); let text = String::from_utf8(first.stdout).unwrap(); - assert!(!text.contains("\"lvl\""), "unselected key leaked: {text}"); - assert!(!text.contains("\"hi\""), "unselected value leaked: {text}"); + assert!(!text.contains("\"level\""), "unselected key leaked: {text}"); + assert!( + !text.contains("\"high\""), + "unselected value leaked: {text}" + ); } From 76bb8cc2900836d9098cba638594f4a468b9453f Mon Sep 17 00:00:00 2001 From: Agent IX Date: Sun, 15 Nov 2026 14:26:56 -0800 Subject: [PATCH 3/3] PLAT-1441: assert no regulatedCategories key on record-less entries (FND-003) Co-Authored-By: Claude Sonnet 5.5 --- tests/cli_relations_record.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/cli_relations_record.rs b/tests/cli_relations_record.rs index a1cb4a1..79ae518 100644 --- a/tests/cli_relations_record.rs +++ b/tests/cli_relations_record.rs @@ -167,6 +167,10 @@ fn assert_no_record(entry: &Value) { entry.get("record").is_none(), "expected no record key: {entry}" ); + assert!( + entry.get("regulatedCategories").is_none(), + "expected no regulatedCategories key: {entry}" + ); } #[trace("FR-030-AC-26")]