generated from coulomb/repo-seed
feat: compare accountability update deltas
This commit is contained in:
@@ -5,6 +5,7 @@ from railiance_fabric.accountability_roots import (
|
||||
AccountabilityEvidenceStore,
|
||||
build_identity_projection,
|
||||
build_ownership_review,
|
||||
build_update_delta,
|
||||
collect_accountability_root_evidence,
|
||||
load_accountability_root_manifest,
|
||||
)
|
||||
@@ -191,6 +192,78 @@ def test_review_identity_cli_persists_decision_for_ownership_review(tmp_path: Pa
|
||||
assert repo_item["decision"]["reviewer"] == "tester"
|
||||
|
||||
|
||||
def test_update_delta_detects_ownership_changes_and_unchanged_runs(tmp_path: Path) -> None:
|
||||
manifest_path = _fixture_manifest(tmp_path)
|
||||
manifest = load_accountability_root_manifest(manifest_path)
|
||||
projection = build_identity_projection(collect_accountability_root_evidence(manifest_path), manifest)
|
||||
review = build_ownership_review(projection, manifest)
|
||||
|
||||
unchanged = build_update_delta(
|
||||
projection,
|
||||
review,
|
||||
previous_identity_projection=projection,
|
||||
previous_ownership_review=review,
|
||||
)
|
||||
validator = draft202012_validator(Path("schemas/accountability-update-delta.schema.yaml"))
|
||||
assert list(validator.iter_errors(unchanged)) == []
|
||||
assert unchanged["summary"]["promotion_needed"] is False
|
||||
assert unchanged["node_delta"]["unchanged"]
|
||||
|
||||
store = AccountabilityEvidenceStore(tmp_path / "evidence.sqlite3")
|
||||
store.add_review_decision(
|
||||
stable_key="identity:repository:fixture-repo",
|
||||
decision="accept",
|
||||
reviewer="tester",
|
||||
owner_actor_id="actor.fixture.lord",
|
||||
fabric_id="fabric.fixture.primary",
|
||||
)
|
||||
accepted_review = build_ownership_review(
|
||||
projection,
|
||||
manifest,
|
||||
review_decisions=store.latest_review_decisions(),
|
||||
)
|
||||
changed = build_update_delta(
|
||||
projection,
|
||||
accepted_review,
|
||||
previous_identity_projection=projection,
|
||||
previous_ownership_review=review,
|
||||
)
|
||||
assert changed["summary"]["promotion_needed"] is True
|
||||
assert "identity:repository:fixture-repo" in changed["change_sets"]["ownership"]
|
||||
assert "identity:repository:fixture-repo" in changed["change_sets"]["review_state"]
|
||||
|
||||
|
||||
def test_discover_roots_cli_can_emit_delta(tmp_path: Path, capsys) -> None:
|
||||
manifest = _fixture_manifest(tmp_path)
|
||||
manifest_data = load_accountability_root_manifest(manifest)
|
||||
projection = build_identity_projection(collect_accountability_root_evidence(manifest), manifest_data)
|
||||
review = build_ownership_review(projection, manifest_data)
|
||||
projection_path = tmp_path / "previous-identities.json"
|
||||
review_path = tmp_path / "previous-ownership.json"
|
||||
projection_path.write_text(json.dumps(projection), encoding="utf-8")
|
||||
review_path.write_text(json.dumps(review), encoding="utf-8")
|
||||
|
||||
assert (
|
||||
cli_main(
|
||||
[
|
||||
"discover-roots",
|
||||
"--manifest",
|
||||
str(manifest),
|
||||
"--delta",
|
||||
"--previous-identity-projection",
|
||||
str(projection_path),
|
||||
"--previous-ownership-review",
|
||||
str(review_path),
|
||||
]
|
||||
)
|
||||
== 0
|
||||
)
|
||||
|
||||
payload = json.loads(capsys.readouterr().out)
|
||||
assert payload["kind"] == "AccountabilityUpdateDelta"
|
||||
assert payload["summary"]["promotion_needed"] is False
|
||||
|
||||
|
||||
def _fixture_manifest(tmp_path: Path) -> Path:
|
||||
workspace = tmp_path / "workspace"
|
||||
repo = workspace / "fixture-repo"
|
||||
|
||||
Reference in New Issue
Block a user