feat: publish authoritative fabric cutover export
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a053ff-1d6f-7fe2-ac1c-a6eb40a42a0c
This commit is contained in:
parent
7745a965f6
commit
113445def9
5 changed files with 112 additions and 6 deletions
|
|
@ -16,6 +16,7 @@ from .financial import (
|
|||
materialize_financial_graph_export,
|
||||
merge_financial_graph_exports,
|
||||
)
|
||||
from .financial_baseline import financial_export_from_legacy
|
||||
from .loader import load_yaml, repo_root
|
||||
from .schema_validation import draft202012_validator
|
||||
|
||||
|
|
@ -470,10 +471,11 @@ class RegistryStore:
|
|||
def combined_graph(self) -> dict[str, Any]:
|
||||
snapshots = self.latest_snapshots()
|
||||
if snapshots and all(is_financial_graph_export(snapshot["graph"]) for snapshot in snapshots):
|
||||
return merge_financial_graph_exports(
|
||||
graph = merge_financial_graph_exports(
|
||||
[snapshot["graph"] for snapshot in snapshots],
|
||||
generated_at=_utc_now(),
|
||||
)
|
||||
return _with_registry_provenance(graph, snapshots)
|
||||
nodes: dict[str, dict[str, Any]] = {}
|
||||
edges: list[dict[str, str]] = []
|
||||
for snapshot in snapshots:
|
||||
|
|
@ -491,14 +493,21 @@ class RegistryStore:
|
|||
nodes[node_id] = node
|
||||
for edge in projected_edges:
|
||||
edges.append(_edge_with_canon_metadata(edge))
|
||||
return {
|
||||
graph = {
|
||||
"apiVersion": "railiance.fabric/v1alpha1",
|
||||
"kind": "FabricGraphExport",
|
||||
"generated_at": _utc_now(),
|
||||
"source": {"repo": "registry", "commit": "", "path": ""},
|
||||
"nodes": [nodes[key] for key in sorted(nodes)],
|
||||
"edges": sorted(edges, key=lambda edge: (edge["from"], edge["to"], edge["type"])),
|
||||
}
|
||||
return _with_registry_provenance(graph, snapshots)
|
||||
|
||||
def financial_graph(self) -> dict[str, Any]:
|
||||
"""Return the accepted graph through the financial Fabric contract."""
|
||||
graph = self.combined_graph()
|
||||
if is_financial_graph_export(graph):
|
||||
return graph
|
||||
return financial_export_from_legacy(graph)
|
||||
|
||||
def add_artifact(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
repo_slug = _required_text(payload, "repo_slug")
|
||||
|
|
@ -1394,6 +1403,35 @@ def _with_source(graph: dict[str, Any], repo_slug: str, commit: str, generated_a
|
|||
return copy
|
||||
|
||||
|
||||
def _with_registry_provenance(
|
||||
graph: dict[str, Any], snapshots: list[dict[str, Any]]
|
||||
) -> dict[str, Any]:
|
||||
"""Identify the exact accepted snapshot set behind a combined export."""
|
||||
copy = json.loads(json.dumps(graph))
|
||||
revisions = [
|
||||
{
|
||||
"repo_slug": str(snapshot["repo_slug"]),
|
||||
"commit": str(snapshot["commit"]),
|
||||
"generated_at": str(snapshot["generated_at"]),
|
||||
}
|
||||
for snapshot in sorted(
|
||||
snapshots,
|
||||
key=lambda item: (str(item["repo_slug"]), str(item["commit"])),
|
||||
)
|
||||
]
|
||||
raw = json.dumps(revisions, sort_keys=True, separators=(",", ":"), ensure_ascii=True)
|
||||
revision_digest = hashlib.sha256(raw.encode("utf-8")).hexdigest()
|
||||
copy["source"] = {
|
||||
"producer": "railiance-fabric",
|
||||
"repo": "railiance-fabric",
|
||||
"registry": "accepted-snapshots",
|
||||
"commit": f"snapshot-set:sha256:{revision_digest}",
|
||||
"path": "registry://accepted-snapshots",
|
||||
"snapshots": revisions,
|
||||
}
|
||||
return copy
|
||||
|
||||
|
||||
def _snapshot_dict(row: sqlite3.Row) -> dict[str, Any]:
|
||||
return {
|
||||
"id": row["id"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue