feat: bootstrap accountability-root fabric snapshot

This commit is contained in:
2026-05-24 10:41:29 +02:00
parent 7956415924
commit 735867392e
13 changed files with 9105 additions and 12 deletions

View File

@@ -63,6 +63,85 @@ def test_identity_projection_is_stable_and_reviewable(tmp_path: Path) -> None:
assert first["candidate_graph"]["edges"]
def test_deployable_identity_ignores_generic_filename_alias_ambiguity(tmp_path: Path) -> None:
workspace = tmp_path / "workspace"
for name in ("service-a", "service-b"):
service = workspace / name
service.mkdir(parents=True)
(service / "Dockerfile").write_text("FROM python:3.12-slim\n", encoding="utf-8")
manifest_path = _minimal_manifest(
tmp_path,
"""
- id: root.fixture.deployables
type: deployment_automation
status: active
fabric_id: fabric.fixture.primary
owner_actor_id: actor.fixture.lord
source:
path: {workspace}
patterns:
- "*/Dockerfile"
safe_discovery: local_files
evidence_scope:
- deployment_topology
""".format(workspace=workspace),
)
manifest = load_accountability_root_manifest(manifest_path)
projection = build_identity_projection(collect_accountability_root_evidence(manifest_path), manifest)
deployables = [
candidate
for candidate in projection["identity_candidates"]
if candidate["identity_type"] == "Deployable"
]
assert len(deployables) == 2
assert all("ambiguous_aliases" not in candidate.get("attributes", {}) for candidate in deployables)
def test_deployment_evidence_skips_dependency_cache_noise(tmp_path: Path) -> None:
workspace = tmp_path / "workspace"
(workspace / "service").mkdir(parents=True)
(workspace / "service" / "Dockerfile").write_text("FROM python:3.12-slim\n", encoding="utf-8")
(workspace / ".venv" / "lib" / "python3.12" / "site-packages" / "pkg").mkdir(parents=True)
(workspace / ".venv" / "lib" / "python3.12" / "site-packages" / "pkg" / "Dockerfile").write_text(
"FROM ignored\n",
encoding="utf-8",
)
(workspace / "go" / "pkg" / "mod" / "example").mkdir(parents=True)
(workspace / "go" / "pkg" / "mod" / "example" / "Dockerfile").write_text(
"FROM ignored\n",
encoding="utf-8",
)
manifest_path = _minimal_manifest(
tmp_path,
"""
- id: root.fixture.deployables
type: deployment_automation
status: active
fabric_id: fabric.fixture.primary
owner_actor_id: actor.fixture.lord
source:
path: {workspace}
patterns:
- "**/Dockerfile"
safe_discovery: local_files
evidence_scope:
- deployment_topology
""".format(workspace=workspace),
)
evidence = collect_accountability_root_evidence(manifest_path, max_items_per_root=20)
paths = [
item["source"]["path"]
for root in evidence["roots"]
for item in root["evidence"]
if item["evidence_type"] == "deployment_automation"
]
assert paths == [str(workspace / "service" / "Dockerfile")]
def test_evidence_store_persists_runs_items_and_identities(tmp_path: Path) -> None:
manifest_path = _fixture_manifest(tmp_path)
manifest = load_accountability_root_manifest(manifest_path)
@@ -381,3 +460,46 @@ refresh:
encoding="utf-8",
)
return manifest
def _minimal_manifest(tmp_path: Path, discovery_roots: str) -> Path:
manifest = tmp_path / "minimal-accountability-roots.yaml"
manifest.write_text(
"""
apiVersion: railiance.fabric/v1alpha2
kind: AccountabilityRootManifest
metadata:
id: fixture.minimal-accountability-roots
name: Fixture Minimal Accountability Roots
netkingdom:
id: fixture.netkingdom
name: Fixture Netkingdom
king_actor_id: actor.fixture.king
actors:
- id: actor.fixture.king
role: king
name: Fixture King
- id: actor.fixture.lord
role: lord
name: Fixture Lord
fabrics:
- id: fabric.fixture.primary
kind: Fabric
name: Fixture Primary Fabric
netkingdom_id: fixture.netkingdom
lord_actor_id: actor.fixture.lord
parent_fabric_id: null
status: active
boundary:
boundary_type: fabric
criterion: financial_and_operational_accountability
discovery_roots:
{discovery_roots}
refresh:
cadence: manual
triggers:
- operator_request
""".format(discovery_roots=discovery_roots.rstrip()),
encoding="utf-8",
)
return manifest