auto-sync: tudo-para-ia-mais-humana 2026-05-02 06:29:22
This commit is contained in:
@@ -30,6 +30,7 @@ from .identity_policy import (
|
||||
from .models import GeneratedFile, as_plain_data, merge_unique, slugify, utc_now
|
||||
from .repository_mesh import RepositoryTarget, default_repository_targets, stable_digest
|
||||
from .repository_mesh_naming import plataform_to_platform, platform_to_plataform
|
||||
from .storage import connect, upsert_files
|
||||
|
||||
|
||||
class CanonicalAliasKind(str, Enum):
|
||||
@@ -848,6 +849,53 @@ def write_identity_graph_artifacts(
|
||||
return tuple(records)
|
||||
|
||||
|
||||
def _semantic_status_record(project_root: Path) -> GeneratedFile:
|
||||
return GeneratedFile(
|
||||
path=str(project_root / "dados" / "canonical-identity-semantic-write-status.json"),
|
||||
description="Status da escrita semantica local do grafo canonico.",
|
||||
function="canonical identity local semantic write status",
|
||||
file_type="json",
|
||||
changed_by="mais_humana.canonical_identity",
|
||||
change_summary="Registrado resultado da atualizacao do controle-semantico.sqlite local.",
|
||||
relation_to_order="0035_EXECUTIVA__reconciliar-nome-canonico-real-alias-platform",
|
||||
)
|
||||
|
||||
|
||||
def write_local_semantic_records(project_root: Path, records: Sequence[GeneratedFile]) -> tuple[GeneratedFile, ...]:
|
||||
sqlite_path = project_root / "controle-semantico.sqlite"
|
||||
status_record = _semantic_status_record(project_root)
|
||||
status_path = Path(status_record.path)
|
||||
tracked_records = tuple(records) + (status_record,)
|
||||
error = ""
|
||||
ok = False
|
||||
try:
|
||||
with connect(sqlite_path) as conn:
|
||||
upsert_files(conn, tracked_records)
|
||||
ok = True
|
||||
except Exception as exc:
|
||||
error = f"{type(exc).__name__}: {exc}"
|
||||
status_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
status_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"generatedAt": utc_now(),
|
||||
"ok": ok,
|
||||
"error": error,
|
||||
"sqlitePath": str(sqlite_path),
|
||||
"filesCount": len(tracked_records),
|
||||
},
|
||||
ensure_ascii=False,
|
||||
indent=2,
|
||||
sort_keys=True,
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
if ok:
|
||||
with connect(sqlite_path) as conn:
|
||||
upsert_files(conn, (status_record,))
|
||||
return tracked_records
|
||||
|
||||
|
||||
def run_canonical_identity_graph(
|
||||
*,
|
||||
project_root: Path,
|
||||
@@ -856,4 +904,5 @@ def run_canonical_identity_graph(
|
||||
) -> tuple[CanonicalIdentityGraph, tuple[GeneratedFile, ...]]:
|
||||
graph = build_identity_graph(use_generated=use_generated)
|
||||
records = write_identity_graph_artifacts(graph, project_root, central_platform_folder=central_platform_folder)
|
||||
return graph, records
|
||||
semantic_records = write_local_semantic_records(project_root, records)
|
||||
return graph, semantic_records
|
||||
|
||||
Reference in New Issue
Block a user