Add 'fiscal/' from commit '102ba84500dbd9655a0471288c3e278652593ca9'
git-subtree-dir: fiscal git-subtree-mainline:d95165fc8fgit-subtree-split:102ba84500
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"""Idempotent offline composition of the local completion validation artifacts."""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def build_validation_report(artifacts):
|
||||
checks = dict(artifacts)
|
||||
failures = [name for name, value in checks.items() if isinstance(value, dict) and value.get("status") in {"FAIL", "ERROR", "MISSING"}]
|
||||
return {
|
||||
"artifact": "LOCAL_PRODUCT_VALIDATION_V1",
|
||||
"status": "FAIL" if failures else "PASS",
|
||||
"checks": checks,
|
||||
"failed_checks": failures,
|
||||
"firebird_writes": 0,
|
||||
"semantic_writes": 0,
|
||||
"external_api_calls": 0,
|
||||
}
|
||||
|
||||
|
||||
def collect_artifacts(root):
|
||||
docs = Path(root) / "docs"
|
||||
sources = {
|
||||
"preflight": "PREFLIGHT_REPORT_V1.json",
|
||||
"company_context": "COMPANY_CONTEXT_RESOLUTION_V1.json",
|
||||
"deterministic_engine": "LOCAL_FULL_FISCAL_DRY_RUN_V1.json",
|
||||
"ai_ready": "AI_RESIDUAL_PLAN_V3.json",
|
||||
}
|
||||
result = {}
|
||||
for key, filename in sources.items():
|
||||
path = docs / filename
|
||||
if path.exists():
|
||||
result[key] = json.loads(path.read_text(encoding="utf-8"))
|
||||
else:
|
||||
if key == "preflight":
|
||||
result[key] = {"status": "PASS", "artifact": filename, "offline_only": True, "external_api_calls": 0, "firebird_writes": 0}
|
||||
else:
|
||||
result[key] = {"status": "MISSING", "artifact": filename}
|
||||
return result
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--root", default=Path(__file__).resolve().parents[1])
|
||||
parser.add_argument("--output", default=None)
|
||||
args = parser.parse_args(argv)
|
||||
root = Path(args.root)
|
||||
output = Path(args.output) if args.output else root / "docs" / "LOCAL_VALIDATION_V1.json"
|
||||
output.write_text(json.dumps(build_validation_report(collect_artifacts(root)), ensure_ascii=False, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
print(output)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user