auto-sync: tudo-para-ia-mais-humana 2026-05-01 20:59:04
This commit is contained in:
@@ -134,6 +134,38 @@ def write_json(path: Path, payload: object) -> Path:
|
||||
return path
|
||||
|
||||
|
||||
def _central_write_probe(central_platform_folder: Path | None) -> tuple[Path | None, dict[str, object] | None]:
|
||||
if central_platform_folder is None:
|
||||
return None, None
|
||||
|
||||
probe_path = central_platform_folder / "reports" / ".mais_humana_write_probe.tmp"
|
||||
status: dict[str, object] = {
|
||||
"requested": str(central_platform_folder),
|
||||
"used": str(central_platform_folder),
|
||||
"ok": True,
|
||||
"error": "",
|
||||
"probePath": str(probe_path),
|
||||
}
|
||||
try:
|
||||
probe_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
probe_path.write_text("mais_humana central write probe\n", encoding="utf-8")
|
||||
try:
|
||||
probe_path.unlink()
|
||||
except OSError as exc:
|
||||
status["cleanupWarning"] = f"{type(exc).__name__}: {exc}"
|
||||
except OSError as exc:
|
||||
status.update(
|
||||
{
|
||||
"used": "",
|
||||
"ok": False,
|
||||
"error": f"{type(exc).__name__}: {exc}",
|
||||
"policy": "falha de escrita central nao deve abortar artefatos do projeto real",
|
||||
}
|
||||
)
|
||||
return None, status
|
||||
return central_platform_folder, status
|
||||
|
||||
|
||||
def write_platform_docx(path: Path, report: PlatformHumanReport) -> Path:
|
||||
doc = DocxDocument(title=f"Relatorio humano - {report.platform.title}")
|
||||
doc.heading("Missao", 2)
|
||||
@@ -255,6 +287,7 @@ def generate(
|
||||
push_status: str | None = None,
|
||||
) -> ReportBundle:
|
||||
ensure_project_dirs(project_root)
|
||||
central_for_write, central_write_status = _central_write_probe(central_platform_folder)
|
||||
scans = scan_ecosystem(ecosystem_root)
|
||||
evidence_records = build_evidence_index(scans)
|
||||
cells = build_matrix(scans)
|
||||
@@ -264,10 +297,22 @@ def generate(
|
||||
human_questions = questions_for_ecosystem(platform_reports)
|
||||
playbooks = build_playbooks(platform_reports)
|
||||
insights = build_insights(platform_reports, recommendations)
|
||||
command_specs = base_validation_commands(project_root, central_platform_folder) + platform_validation_commands(platform_reports)
|
||||
command_specs = base_validation_commands(project_root, central_for_write) + platform_validation_commands(platform_reports)
|
||||
ecosystem_report = EcosystemHumanReport(scans=scans, platform_reports=platform_reports, recommendations=recommendations)
|
||||
exit_orders = build_exit_orders(recommendations)
|
||||
generated: list[GeneratedFile] = []
|
||||
if central_write_status is not None:
|
||||
status_path = write_json(project_root / "dados" / "central-platform-write-status.json", central_write_status)
|
||||
generated.append(
|
||||
generated_file(
|
||||
status_path,
|
||||
project_root,
|
||||
"Status do probe de escrita automatica na pasta central da plataforma.",
|
||||
"central write status",
|
||||
"json",
|
||||
relation_to_order,
|
||||
)
|
||||
)
|
||||
round_dossier = build_execution_round_dossier(
|
||||
project_root=project_root,
|
||||
platform_reports=platform_reports,
|
||||
@@ -293,14 +338,14 @@ def generate(
|
||||
mesh_report, mesh_records = run_repository_mesh(
|
||||
ecosystem_root=ecosystem_root,
|
||||
project_root=project_root,
|
||||
central_platform_folder=central_platform_folder,
|
||||
central_platform_folder=central_for_write,
|
||||
fetch=False,
|
||||
plugin_auth_attempt=push_status or "",
|
||||
)
|
||||
mesh_plan, mesh_reconciliation_records = apply_reconciliation_to_report(
|
||||
mesh_report,
|
||||
project_root,
|
||||
central_platform_folder=central_platform_folder,
|
||||
central_platform_folder=central_for_write,
|
||||
)
|
||||
mesh_lock = acquire_lock(project_root / "dados" / "repository-mesh.lock.json", owner="mais_humana.generate")
|
||||
mesh_cycle = build_runtime_cycle(mesh_report, mesh_plan, lock=mesh_lock, execute=False)
|
||||
@@ -309,31 +354,31 @@ def generate(
|
||||
python_exe="C:\\Users\\Ami\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe",
|
||||
project_root=project_root,
|
||||
ecosystem_root=ecosystem_root,
|
||||
central_platform_folder=central_platform_folder,
|
||||
central_platform_folder=central_for_write,
|
||||
),
|
||||
cron_scheduler_spec(
|
||||
python_exe="python",
|
||||
project_root=project_root,
|
||||
ecosystem_root=ecosystem_root,
|
||||
central_platform_folder=central_platform_folder,
|
||||
central_platform_folder=central_for_write,
|
||||
),
|
||||
)
|
||||
mesh_runtime_records = write_runtime_artifacts(
|
||||
mesh_cycle,
|
||||
mesh_scheduler_specs,
|
||||
project_root,
|
||||
central_platform_folder=central_platform_folder,
|
||||
central_platform_folder=central_for_write,
|
||||
)
|
||||
mesh_semantic_records = ()
|
||||
if central_platform_folder is not None:
|
||||
if central_for_write is not None:
|
||||
mesh_semantic_counts = write_repository_mesh_semantic_state(
|
||||
central_platform_folder / "controle-semantico.sqlite",
|
||||
central_for_write / "controle-semantico.sqlite",
|
||||
report=mesh_report,
|
||||
plan=mesh_plan,
|
||||
cycle=mesh_cycle,
|
||||
schedulers=mesh_scheduler_specs,
|
||||
)
|
||||
mesh_semantic_records = semantic_generated_records(central_platform_folder / "controle-semantico.sqlite")
|
||||
mesh_semantic_records = semantic_generated_records(central_for_write / "controle-semantico.sqlite")
|
||||
else:
|
||||
from .repository_mesh_semantic import table_counts
|
||||
|
||||
@@ -348,24 +393,24 @@ def generate(
|
||||
mesh_readiness_records = write_readiness_artifacts(
|
||||
mesh_readiness,
|
||||
project_root,
|
||||
central_platform_folder=central_platform_folder,
|
||||
central_platform_folder=central_for_write,
|
||||
)
|
||||
mesh_gitea_plan = build_gitea_mesh_plan(mesh_report)
|
||||
mesh_gitea_records = write_gitea_plan_artifacts(
|
||||
mesh_gitea_plan,
|
||||
project_root,
|
||||
central_platform_folder=central_platform_folder,
|
||||
central_platform_folder=central_for_write,
|
||||
)
|
||||
release_lock(mesh_lock)
|
||||
lifecycle_package = (
|
||||
build_round_execution_package(
|
||||
central_platform_folder,
|
||||
central_for_write,
|
||||
governance_portfolio,
|
||||
round_dossier=round_dossier,
|
||||
total_code_lines_analyzed=line_budget.total_technical_lines,
|
||||
code_lines_available=line_budget.repositories[0].code_lines if line_budget.repositories else 0,
|
||||
)
|
||||
if central_platform_folder is not None
|
||||
if central_for_write is not None
|
||||
else None
|
||||
)
|
||||
evidence_graph = build_evidence_graph(
|
||||
@@ -550,12 +595,12 @@ def generate(
|
||||
)
|
||||
generated.append(generated_file(governance_delta_csv, project_root, "Delta de governanca operacional em CSV.", "delta governanca", "csv", relation_to_order))
|
||||
|
||||
if central_platform_folder is not None:
|
||||
written_orders = write_orders(exit_orders, central_platform_folder)
|
||||
if central_for_write is not None:
|
||||
written_orders = write_orders(exit_orders, central_for_write)
|
||||
write_json(order_summary, exit_orders)
|
||||
for path in written_orders:
|
||||
generated.append(generated_file(path, project_root, "Ordem de saida criada na central.", "ordem de servico", "markdown", relation_to_order))
|
||||
reports_dir = central_platform_folder / "reports"
|
||||
reports_dir = central_for_write / "reports"
|
||||
reports_dir.mkdir(parents=True, exist_ok=True)
|
||||
executed = reports_dir / "EXECUTADO__fundacao-tudo-para-ia-mais-humana.md"
|
||||
executed.write_text(executed_order_markdown(platform_reports, exit_orders), encoding="utf-8")
|
||||
@@ -563,7 +608,7 @@ def generate(
|
||||
pending = reports_dir / "PENDENCIAS-CODEX__fundacao-tudo-para-ia-mais-humana.md"
|
||||
pending.write_text(pending_markdown(platform_reports, push_status=push_status), encoding="utf-8")
|
||||
generated.append(generated_file(pending, project_root, "Registro de pendencias reais da rodada.", "pendencias", "markdown", relation_to_order))
|
||||
audit_dir = central_platform_folder / "audit"
|
||||
audit_dir = central_for_write / "audit"
|
||||
audit_dir.mkdir(parents=True, exist_ok=True)
|
||||
audit = audit_dir / "AUDITORIA-GPT__fundacao-tudo-para-ia-mais-humana.md"
|
||||
audit.write_text(audit_markdown(platform_reports, exit_orders), encoding="utf-8")
|
||||
@@ -577,7 +622,7 @@ def generate(
|
||||
operational_audit = audit_dir / "AUDITORIA-GPT__rodada-operacional-mais-humana.md"
|
||||
operational_audit.write_text(order_justifications_markdown(round_dossier), encoding="utf-8")
|
||||
generated.append(generated_file(operational_audit, project_root, "Auditoria operacional das ordens tratadas.", "auditoria", "markdown", relation_to_order))
|
||||
sqlite_path = central_platform_folder / "controle-semantico.sqlite"
|
||||
sqlite_path = central_for_write / "controle-semantico.sqlite"
|
||||
write_semantic_state(sqlite_path, tuple(generated), exit_orders, platform_reports, recommendations, round_dossier)
|
||||
|
||||
provisional_bundle = ReportBundle(
|
||||
@@ -606,7 +651,7 @@ def generate(
|
||||
delta_path.write_text(snapshot_delta_markdown(diff_snapshots(previous_snapshot, current_snapshot)), encoding="utf-8")
|
||||
generated.append(generated_file(delta_path, project_root, "Delta de maturidade humana contra snapshot anterior.", "delta", "markdown", relation_to_order))
|
||||
|
||||
if central_platform_folder is not None:
|
||||
if central_for_write is not None:
|
||||
central_bundle = ReportBundle(
|
||||
output_root=str(project_root),
|
||||
generated_files=tuple(generated),
|
||||
@@ -616,9 +661,9 @@ def generate(
|
||||
total_code_lines_analyzed=ecosystem_report.total_code_lines,
|
||||
warnings=tuple(warning for report in platform_reports for warning in report.scan.warnings),
|
||||
)
|
||||
for path in write_central_status_pages(central_platform_folder, central_bundle, platform_reports, exit_orders):
|
||||
for path in write_central_status_pages(central_for_write, central_bundle, platform_reports, exit_orders):
|
||||
generated.append(generated_file(path, project_root, "Pagina de estado/indice da central.", "estado central", "markdown", relation_to_order))
|
||||
sqlite_path = central_platform_folder / "controle-semantico.sqlite"
|
||||
sqlite_path = central_for_write / "controle-semantico.sqlite"
|
||||
write_semantic_state(sqlite_path, tuple(generated), exit_orders, platform_reports, recommendations, round_dossier)
|
||||
|
||||
final_bundle = ReportBundle(
|
||||
@@ -637,7 +682,7 @@ def generate(
|
||||
portfolio=governance_portfolio,
|
||||
lifecycle_package=lifecycle_package,
|
||||
compiled_orders=governance_orders,
|
||||
central_folder=central_platform_folder,
|
||||
central_folder=central_for_write,
|
||||
extra_text=(push_status or "",),
|
||||
)
|
||||
assurance_json = write_json(project_root / "dados" / "assurance-rodada.json", assurance)
|
||||
@@ -648,8 +693,8 @@ def generate(
|
||||
assurance_csv = project_root / "matrizes" / "assurance-rodada.csv"
|
||||
assurance_csv.write_text(rows_to_csv(assurance_rows(assurance)), encoding="utf-8")
|
||||
generated.append(generated_file(assurance_csv, project_root, "Assurance da rodada em CSV.", "assurance", "csv", relation_to_order))
|
||||
if central_platform_folder is not None and lifecycle_package is not None:
|
||||
for path in write_central_lifecycle_exports(central_platform_folder, lifecycle_package):
|
||||
if central_for_write is not None and lifecycle_package is not None:
|
||||
for path in write_central_lifecycle_exports(central_for_write, lifecycle_package):
|
||||
generated.append(generated_file(path, project_root, "Fechamento lifecycle das ordens ativas na central.", "lifecycle central", "markdown", relation_to_order))
|
||||
reconciled = build_reconciled_status(
|
||||
governance_portfolio,
|
||||
@@ -660,10 +705,10 @@ def generate(
|
||||
budget=line_budget,
|
||||
assurance=assurance,
|
||||
)
|
||||
for path in write_reconciled_status(central_platform_folder, reconciled):
|
||||
for path in write_reconciled_status(central_for_write, reconciled):
|
||||
generated.append(generated_file(path, project_root, "Estado reconciliado da central.", "estado reconciliado", "markdown", relation_to_order))
|
||||
write_governance_semantic_state(
|
||||
central_platform_folder / "controle-semantico.sqlite",
|
||||
central_for_write / "controle-semantico.sqlite",
|
||||
governance_portfolio,
|
||||
readiness_registry,
|
||||
workflow_portfolio,
|
||||
@@ -689,8 +734,8 @@ def generate(
|
||||
contract_md.write_text(contract_markdown(contract), encoding="utf-8")
|
||||
generated.append(generated_file(contract_md, project_root, "Contrato publico Markdown da plataforma Mais Humana.", "contrato", "markdown", relation_to_order))
|
||||
|
||||
if central_platform_folder is not None:
|
||||
sqlite_path = central_platform_folder / "controle-semantico.sqlite"
|
||||
if central_for_write is not None:
|
||||
sqlite_path = central_for_write / "controle-semantico.sqlite"
|
||||
write_semantic_state(sqlite_path, tuple(generated), exit_orders, platform_reports, recommendations, round_dossier)
|
||||
|
||||
return ReportBundle(
|
||||
|
||||
Reference in New Issue
Block a user