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>
92 lines
2.8 KiB
Python
92 lines
2.8 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
|
TOOLS_DIR = PROJECT_ROOT / "tools"
|
|
|
|
if str(TOOLS_DIR) not in sys.path:
|
|
sys.path.insert(0, str(TOOLS_DIR))
|
|
|
|
from oci_diagram_gen import OCIDiagramGenerator
|
|
|
|
|
|
def test_from_spec_accepts_name_aliases_and_generates_ids():
|
|
spec = {
|
|
"external": [{"name": "Users"}],
|
|
"clouds": [{"name": "AWS", "services": [{"name": "EC2 App", "service_type": "ec2"}]}],
|
|
"tenancy": {
|
|
"regions": [
|
|
{
|
|
"name": "Ashburn",
|
|
"vcns": [
|
|
{
|
|
"name": "App VCN",
|
|
"subnets": [
|
|
{"name": "App Subnet", "services": [{"name": "App VM"}]}
|
|
],
|
|
}
|
|
],
|
|
}
|
|
]
|
|
},
|
|
"on_prem": {"name": "Primary DC", "services": [{"name": "Legacy DB"}]},
|
|
}
|
|
|
|
gen = OCIDiagramGenerator.from_spec(spec)
|
|
values = [getattr(obj, "value", "") for obj in gen._objects.values()]
|
|
|
|
assert "Users" in values
|
|
assert "AWS" in values
|
|
assert "Ashburn" in values
|
|
assert "VCN App VCN" in values
|
|
assert "App Subnet" in values
|
|
assert "App VM" in values
|
|
assert "Primary DC" in values
|
|
assert "Legacy DB" in values
|
|
|
|
|
|
def test_from_spec_accepts_source_target_and_omits_unresolved_connections():
|
|
spec = {
|
|
"external": [{"name": "Users"}],
|
|
"tenancy": {
|
|
"regions": [
|
|
{
|
|
"name": "Ashburn",
|
|
"vcns": [
|
|
{
|
|
"name": "App VCN",
|
|
"subnets": [
|
|
{"name": "App Subnet", "services": [{"name": "App VM"}]}
|
|
],
|
|
}
|
|
],
|
|
}
|
|
]
|
|
},
|
|
"connections": [
|
|
{"source": "Users", "target": "App VM", "type": "standard", "label": "HTTPS"},
|
|
{"from": "Users", "to": "App VM", "type": "standard", "label": "Duplicate"},
|
|
{"source": "Users", "target": "Missing VM", "type": "standard", "label": "Broken"},
|
|
],
|
|
}
|
|
|
|
gen = OCIDiagramGenerator.from_spec(spec)
|
|
|
|
assert gen._connection_count == 1
|
|
|
|
|
|
def test_drawio_icon_resolution_accepts_common_native_aliases():
|
|
gen = OCIDiagramGenerator()
|
|
|
|
db_icon, db_key = gen._resolve_icon_entry("database_system")
|
|
vm_icon, vm_key = gen._resolve_icon_entry("virtual_machine")
|
|
stream_icon, stream_key = gen._resolve_icon_entry("oci_streaming")
|
|
|
|
assert db_icon is not None
|
|
assert db_key in {"db_system", "dbcs"}
|
|
assert vm_icon is not None
|
|
assert vm_key in {"compute", "vm"}
|
|
assert stream_icon is not None
|
|
assert stream_key in {"streaming", "kafka"}
|