diff --git a/CHANGELOG.md b/CHANGELOG.md index ca8cdb0..73f1c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ output schemas (see `spec/non-functional/NFR-006-cli-stability.md`). ## [Unreleased] +### Fixed + +- `quire relations` human output now names each counterpart a relation's `to_where` rejected, with the field and its value (or `absent`), beneath the row, so a `GAP` row shows its reason. `--json` is unchanged. + ### Changed - Adopt quire-rs 0.65.0 (tag `v0.65.0`). The checked semantic clause language is diff --git a/spec/functional/FR-030-relations-subcommand.md b/spec/functional/FR-030-relations-subcommand.md index 1089e66..f3a6b9f 100644 --- a/spec/functional/FR-030-relations-subcommand.md +++ b/spec/functional/FR-030-relations-subcommand.md @@ -132,6 +132,7 @@ with nothing on stdout. | FR-030-AC-26 | `quire relations --scope --module $M --json` over a fixture module declaring two relation declarations over the same verb, each setting `record_keys` to a key that at least one document entry and at least one resolved `linked` entry of that declaration's rows state, so the quire-rs FR-084 report holds a non-empty `record` on such an entry in both declarations, emits for the rows of both declarations the `document` and `linked` records unchanged from that report, and emits no `record` and no `regulatedCategories` key on an entry for which FR-084 omits it. A CLI that drops `record` therefore fails this criterion. | Test | | FR-030-AC-27 | With only a security module explicit, whose `semantic.imports` pins process `0.3.0`, architecture `0.5.0` and ISO `0.3.0`, `quire relations` loads only the installed providers matching those package/version pairs and retains the security module's relations using each provider's edge vocabulary; unrelated installed modules are absent, and no `semantic.import-unresolved` diagnostic is emitted. | Test | | FR-030-AC-28 | With one `required_relations` declaration dropped for an undeclared `record_keys` kind beside a valid sibling, default and `--design` JSON preserve the engine's `RelationReport.errors` objects unchanged and the complete valid report; default and `--design` human output print each error before entries exactly as `error: dropped relation from module : `. Default, `--design`, `--flow` and `--health-data-flows` retain their complete valid report (with the latter two preserving their own stdout schema), write one such error line per dropped relation to stderr, and exit 1 regardless of `--strict`; a dropped non-`required_relations` declaration instead exits 3 with nothing on stdout. | Test | +| FR-030-AC-29 | A fixture requirement covered only by targets that the declaration's `to_where` selector rejects prints each rejected counterpart beneath its row as `to_where rejected: has `, quoting a string value and printing `absent` for a missing field, in human output; `--json` carries them as `to_rejected` ([FR-084](ix://agent-ix/quire-rs/FR-084)). | Test | ## Dependencies diff --git a/src/commands/relations.rs b/src/commands/relations.rs index ee27f40..8563402 100644 --- a/src/commands/relations.rs +++ b/src/commands/relations.rs @@ -96,6 +96,7 @@ pub struct Args { #[implements("FR-030-AC-26")] #[implements("FR-030-AC-27")] #[implements("FR-030-AC-28")] +#[implements("FR-030-AC-29")] #[implements("FR-030-AC-3")] #[implements("FR-030-AC-4")] #[implements("FR-030-AC-5")] @@ -914,6 +915,21 @@ fn render_human(report: &RelationReport, design: bool) -> String { entry.accepted.join("/") )); } + for entry in &row.to_rejected { + let counterpart = match &entry.repo { + Some(repo) => format!("{repo}:{}", entry.id), + None => entry.id.clone(), + }; + let value = match &entry.value { + Some(serde_json::Value::String(text)) => format!("{text:?}"), + Some(other) => other.to_string(), + None => "absent".to_string(), + }; + out.push_str(&format!( + " to_where rejected: {counterpart} has {} {value}\n", + entry.field + )); + } } let s = §ion.summary; out.push_str(&format!( diff --git a/tests/cli_relations.rs b/tests/cli_relations.rs index 9c98ec9..5c47715 100644 --- a/tests/cli_relations.rs +++ b/tests/cli_relations.rs @@ -1016,3 +1016,53 @@ fn each_members_declarations_resolve_against_its_own_repository_root() { stderr(&included) ); } + +/// The fixture module plus one `to_where` relation: a `Concern` is covered +/// only by a gold-tier `Rule` that `addresses` it. +fn write_to_where_module(world: &World) { + let mut text = manifest(true, false); + text.push_str( + " - name: concern-addressed-by-gold\n from: Concern\n edges: [addresses]\n to: [Rule]\n to_where:\n field: tier\n values: [gold]\n direction: incoming\n check: concern-not-gold-addressed\n", + ); + fs::write(world.module_dir().join("manifest.yaml"), text).unwrap(); +} + +#[trace("FR-030-AC-29")] +#[test] +fn a_to_where_rejected_counterpart_is_named_in_the_human_report() { + let world = World::new(); + write_to_where_module(&world); + let scope = world.repo( + "repo", + &[ + ("CON-001", concern("CON-001")), + ("CON-002", concern("CON-002")), + ( + "RULE-001", + rule("RULE-001", Some("silver"), &[("addresses", "CON-001")], &[]), + ), + ( + "RULE-002", + rule("RULE-002", None, &[("addresses", "CON-002")], &[]), + ), + ], + &[], + ); + let json = json_of(&relations(&world, &scope, &["--json"])); + let rejected = &row(&json, "concern-addressed-by-gold", "CON-001")["to_rejected"]; + assert_eq!(rejected[0]["id"], "RULE-001", "{json}"); + assert_eq!(rejected[0]["value"], "silver"); + let absent = &row(&json, "concern-addressed-by-gold", "CON-002")["to_rejected"]; + assert_eq!(absent[0]["id"], "RULE-002"); + assert!(absent[0].get("value").is_none(), "{absent}"); + + let text = stdout(&relations(&world, &scope, &[])); + assert!( + text.contains("to_where rejected: RULE-001 has tier \"silver\""), + "human output: {text}" + ); + assert!( + text.contains("to_where rejected: RULE-002 has tier absent"), + "human output: {text}" + ); +}