58 lines
2.4 KiB
Python
58 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Dependency-free smoke verifier for the landing-zone agent contract."""
|
|
from __future__ import annotations
|
|
import json
|
|
import sys
|
|
import xml.etree.ElementTree as ET
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
CONTRACT = ROOT / "contracts" / "application_landing_zone_contract.json"
|
|
REQUIRED_HEADINGS = (
|
|
"Executive Summary", "Requirements and Assumptions", "Context and Scope",
|
|
"Architecture Overview", "Components and Responsibilities",
|
|
"Data and Integrations", "Security and Compliance",
|
|
"Deployment and Operations", "Reliability and Observability",
|
|
"Risks, Decisions, and Open Questions",
|
|
)
|
|
|
|
|
|
def check(condition: bool, message: str) -> None:
|
|
if not condition:
|
|
raise AssertionError(message)
|
|
|
|
|
|
def main() -> int:
|
|
contract = json.loads(CONTRACT.read_text(encoding="utf-8"))
|
|
check(contract["title"] == "Application Landing Zone Agent contract", "contract title")
|
|
check("application_requirements" in contract["properties"]["input"]["required"], "required input")
|
|
check(set(contract["properties"]["output"]["required"]) == {"tsd_markdown", "architecture_diagram_drawio"}, "required outputs")
|
|
|
|
tsd = "\n".join(f"## {heading}\ncontent" for heading in REQUIRED_HEADINGS)
|
|
for heading in REQUIRED_HEADINGS:
|
|
check(heading in tsd, f"TSD heading: {heading}")
|
|
|
|
xml = ET.fromstring("""<mxfile><diagram><mxGraphModel><root>
|
|
<mxCell id='0'/><mxCell id='1' parent='0'/>
|
|
<mxCell id='component' vertex='1' parent='1'/>
|
|
<mxCell id='flow' edge='1' source='component' target='component' parent='1'/>
|
|
</root></mxGraphModel></diagram></mxfile>""")
|
|
model = xml.find(".//mxGraphModel")
|
|
check(model is not None, "mxGraphModel")
|
|
vertices = model.findall(".//mxCell[@vertex='1']")
|
|
edges = model.findall(".//mxCell[@edge='1']")
|
|
check(vertices, "at least one diagram vertex")
|
|
check(edges, "at least one diagram edge")
|
|
vertex_ids = {v.attrib.get("id") for v in vertices}
|
|
check(all(e.attrib.get("source") in vertex_ids and e.attrib.get("target") in vertex_ids for e in edges), "edge references")
|
|
print("PASS: contract, TSD headings, and draw.io XML smoke checks")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
raise SystemExit(main())
|
|
except (AssertionError, KeyError, json.JSONDecodeError, ET.ParseError) as exc:
|
|
print(f"FAIL: {exc}", file=sys.stderr)
|
|
raise SystemExit(1)
|