Files
oci-deal-accelerator/scripts/analyze_mcp_outputs.py
root b30a4f0d32 Diagram generation: ref-arch-driven procedure + spec validator + KB enrichment
The diagram path now follows a documented standard procedure (lookup
the closest Oracle Architecture Center reference → confirm components
→ author absolute_layout → spec validator → render → visually verify)
and ships persistent guardrails so layout regressions can't recur.

Persistent procedure changes (apply to all users, all sessions):
- tools/diagram_spec_validator.py — geometry checks (CONTAINER_TOO_THIN,
  CONTAINER_PADDING_VIOLATION, LABEL_OVERFLOW_PARENT) run BEFORE either
  renderer (drawio + PPTX). Catches the subnet-collapse / label-overflow
  bugs that the post-render drawio validator missed.
- tools/oci_diagram_gen.py + tools/oci_pptx_diagram_gen.py — call the
  spec validator before emitting any output. Adds mysql / mysql_heatwave
  type aliases.
- tools/archcenter_pattern_lookup.py — scores against cached page
  descriptions (not just the 1-line summary), supports --queries for
  multi-fragment composition, and applies synonym expansion via
  kb/architecture-center/synonyms.yaml so "LB HA cross AD" matches
  "load balancer high availability availability domain".
- kb/architecture-center/synonyms.yaml — canonical synonym table
  (load balancer, autonomous database, data guard, …) used by the
  lookup scorer.

KB enrichment:
- tools/archcenter_description_fetcher.py + 121 cached _description.md
  under kb/diagram/assets/archcenter-refs/<slug>/. Removes the runtime
  dependency on docs.oracle.com when authoring specs and feeds the
  pattern-lookup scorer.
- 110+ cached .drawio / .svg / .png references for offline reuse,
  plus the OCI Toolkit v24.2 import (kb/diagram/assets/oci-toolkit-drawio).

Documentation:
- docs/skill/output-formats.md — new "Standard diagram-generation
  procedure (MANDATORY)" + geometry rules + the new validator entry.
- SKILL.md option 2 — references the mandatory procedure.
- README.md — describes the spec validator, archcenter_pattern_lookup
  and description fetcher, and updates the KB-health table.

Tooling that backs the procedure (cumulative across recent sessions):
tools/archcenter_case_runner.py, archcenter_batch_driver.py,
archcenter_zip_downloader.py, drawio_visual_validator.py,
drawio_fidelity_eval.py, harvest_drawio_icon.py, import_oci_library.py,
oci_pptx_diagram_gen.py, oci_pptx_render.py, refresh_pptx_icon_index.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 21:15:21 -03:00

97 lines
3.4 KiB
Python

#!/usr/bin/env python3
"""Download MCP-generated artifacts and compare them against local analysis."""
from __future__ import annotations
import argparse
import json
import sys
import urllib.request
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parent.parent
SCRIPT_DIR = Path(__file__).resolve().parent
if str(SCRIPT_DIR) not in sys.path:
sys.path.insert(0, str(SCRIPT_DIR))
from random_eval_cases import analyze_drawio, analyze_pptx, analyze_xlsx
def download(url: str, path: Path):
path.parent.mkdir(parents=True, exist_ok=True)
urllib.request.urlretrieve(url, path)
def main():
parser = argparse.ArgumentParser(description="Analyze MCP artifacts against local baseline.")
parser.add_argument("--out-dir", required=True)
parser.add_argument("--local-analysis", required=True)
parser.add_argument("--deck-url", required=True)
parser.add_argument("--diagram-url", required=True)
parser.add_argument("--bizcase-url", required=True)
parser.add_argument("--bom-url", required=True)
parser.add_argument("--appca-url", required=True)
args = parser.parse_args()
out_dir = PROJECT_ROOT / args.out_dir
out_dir.mkdir(parents=True, exist_ok=True)
files = {
"deck": ("mcp-deck.pptx", args.deck_url, analyze_pptx),
"diagram": ("mcp-diagram.drawio", args.diagram_url, analyze_drawio),
"business_case": ("mcp-bizcase.pptx", args.bizcase_url, analyze_pptx),
"bom": ("mcp-bom.xlsx", args.bom_url, analyze_xlsx),
"bom_appca": ("mcp-bom-appca.xlsx", args.appca_url, analyze_xlsx),
}
analysis = {}
for key, (filename, url, analyzer) in files.items():
path = out_dir / filename
download(url, path)
analysis[key] = analyzer(path)
local = json.loads((PROJECT_ROOT / args.local_analysis).read_text(encoding="utf-8"))
local_analysis = local["local_analysis"]
comparison = {
"deck": {
"local_slides": local_analysis["deck"]["slide_count"],
"mcp_slides": analysis["deck"]["slide_count"],
"local_blank_slides": local_analysis["deck"]["blank_slides"],
"mcp_blank_slides": analysis["deck"]["blank_slides"],
},
"business_case": {
"local_slides": local_analysis["business_case"]["slide_count"],
"mcp_slides": analysis["business_case"]["slide_count"],
"local_blank_slides": local_analysis["business_case"]["blank_slides"],
"mcp_blank_slides": analysis["business_case"]["blank_slides"],
},
"bom": {
"local_empty_sheets": local_analysis["bom"]["empty_sheets"],
"mcp_empty_sheets": analysis["bom"]["empty_sheets"],
},
"bom_appca": {
"local_empty_sheets": local_analysis["bom_appca"]["empty_sheets"],
"mcp_empty_sheets": analysis["bom_appca"]["empty_sheets"],
},
"diagram": {
"local_bytes": local_analysis["diagram"]["bytes"],
"mcp_bytes": analysis["diagram"]["bytes"],
"local_cell_values": local_analysis["diagram"]["cell_values"],
"mcp_cell_values": analysis["diagram"]["cell_values"],
},
}
output = {
"mcp_analysis": analysis,
"comparison": comparison,
}
output_path = out_dir / "mcp-analysis.json"
output_path.write_text(json.dumps(output, indent=2), encoding="utf-8")
print(output_path.relative_to(PROJECT_ROOT))
if __name__ == "__main__":
main()