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

@@ -634,7 +634,7 @@ def _identity_from_evidence(root: dict[str, Any], item: dict[str, Any]) -> dict[
"subfabric_id": subfabric_id,
"owner_actor_id": owner_actor_id,
"evidence_ids": evidence_ids,
"aliases": [path, Path(path).stem],
"aliases": [path],
"attributes": {**attributes, "source_evidence_type": evidence_type},
"confidence": 0.75,
}
@@ -1096,7 +1096,11 @@ def _glob_root_evidence(root: dict[str, Any], evidence_type: str, *, max_items:
return [_declared_evidence(root, f"{evidence_type}_missing", "unavailable", f"Root path missing: {base}")]
matches: list[Path] = []
for pattern in patterns:
matches.extend(sorted(base.glob(str(pattern))))
matches.extend(
path
for path in sorted(base.glob(str(pattern)))
if not _is_noise_match(evidence_type, path)
)
if len(matches) >= max_items:
break
evidence = [
@@ -1117,6 +1121,26 @@ def _glob_root_evidence(root: dict[str, Any], evidence_type: str, *, max_items:
return evidence
def _is_noise_match(evidence_type: str, path: Path) -> bool:
if evidence_type not in {"deployment_automation", "infrastructure_manifest", "service_config", "endpoint_contract"}:
return False
parts = path.parts
noisy_parts = {
".cache",
".mypy_cache",
".nvm",
".pytest_cache",
".tox",
".venv",
"__pycache__",
"node_modules",
"site-packages",
}
if any(part in noisy_parts for part in parts):
return True
return any(parts[index : index + 3] == ("go", "pkg", "mod") for index in range(max(len(parts) - 2, 0)))
def _state_hub_evidence(root: dict[str, Any], *, include_remote: bool) -> list[dict[str, Any]]:
source = _source(root)
if not include_remote:

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
import json
from datetime import datetime, timezone
from pathlib import Path
from typing import Any
@@ -67,8 +68,7 @@ def financial_export_from_legacy(
],
"unresolved": [],
}
if legacy_graph.get("generated_at"):
graph["generated_at"] = legacy_graph["generated_at"]
graph["generated_at"] = legacy_graph.get("generated_at") or _utc_now()
materialized = materialize_financial_graph_export(graph)
errors = financial_graph_errors(materialized)
if errors:
@@ -135,3 +135,7 @@ def _has_value(value: Any) -> bool:
if isinstance(value, list):
return any(_has_value(item) for item in value)
return value not in (None, "")
def _utc_now() -> str:
return datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")