Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/functional/FR-030-relations-subcommand.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ with nothing on stdout.
| FR-030-AC-26 | `quire relations --scope <DIR> --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 <item> from module <module>: <reason>`. 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: <id> has <field> <value>`, 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

Expand Down
16 changes: 16 additions & 0 deletions src/commands/relations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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 = &section.summary;
out.push_str(&format!(
Expand Down
50 changes: 50 additions & 0 deletions tests/cli_relations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
);
}