Lookup speed (78s → 1s) + drawio ADB-S/RC alias coverage

Two persistent fixes flagged from a Codex session:

1. ``archcenter_pattern_lookup`` ran in 78 s on WSL2 because:
   - ``_cached_assets`` did ``iterdir`` + recursive ``rglob`` over the
     whole 113-folder cache for EVERY catalog entry (123x).
   - ``_patterns_for`` reloaded ``reference-patterns.yaml`` for every
     match (125 reloads = ~5 s).
   - Description text from disk was read for every entry, even those
     that wouldn't make the top-K.

   Now: one-shot scan of the cache dir cached in-memory AND persisted
   to ``kb/diagram/assets/archcenter-refs-index.json`` keyed by mtime;
   patterns YAML loaded once and indexed by URL; a two-pass scoring
   pipeline that only reads description text + cached_assets +
   visual_patterns for the top-K candidates instead of every entry.
   Result: cold run 14 s (one-time index build), warm run 1.1 s.

2. The drawio renderer had no alias for ``adb_s`` / ``adb_serverless``
   / ``autonomous_database_serverless`` / ``refreshable_clone`` —
   Codex's spec used ``type: adb_s`` and the icon never resolved.
   Mapped them to ``autonomous_database`` (the canonical 7-cell
   stencil shipped by the OCI Toolkit), with ``adb_d`` as fallback.
   Same proactive expansion in the drawio side that the PPTX side
   already got (oci_goldengate, dynamic_routing_gateway, atp/adw,
   kms/secret, identity/iam, iac/terraform, oac/oic, kafka).

The persisted lookup index is committed so a fresh clone hits warm
performance on first ``make diagram-lookup``.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-04-25 23:33:40 -03:00
parent 82d09aeee6
commit c46219468f
3 changed files with 616 additions and 33 deletions

View File

@@ -808,18 +808,54 @@ class OCIDiagramGenerator:
ICON_TYPE_ALIASES = {
"database_system": ["db_system", "dbcs"],
"base_db": ["db_system", "dbcs"],
"base_database": ["db_system", "dbcs"],
"virtual_machine": ["compute", "vm"],
"compute_instance": ["compute", "vm"],
"oci_functions": ["functions"],
"function": ["functions"],
# ADB family — drawio toolkit ships ``autonomous_database`` (the
# canonical generic icon, 7 cells) and ``adb_d`` (Dedicated, 28
# cells with the wider footprint). There is NO separate
# ``adb_s`` stencil — Serverless is rendered with the canonical
# ``autonomous_database`` icon. Map every ADB-S synonym to that
# entry first, falling back to ``adb_d`` only if the canonical
# is absent. Diego flagged 2026-04-25: "el icono de ADB-S no se
# genero en drawio" because the renderer had no alias for it.
"adb_s": ["autonomous_database", "autonomous_db", "adb_d"],
"adb_serverless": ["autonomous_database", "autonomous_db", "adb_d"],
"autonomous_database_serverless": ["autonomous_database", "autonomous_db", "adb_d"],
"autonomous_database": ["autonomous_database", "autonomous_db"],
"refreshable_clone": ["autonomous_database", "autonomous_db", "adb_d"],
"adb_clone": ["autonomous_database", "autonomous_db", "adb_d"],
"adb_d": ["adb_d", "adb", "autonomous_db"],
"adb_dedicated": ["adb_d", "adb", "autonomous_db"],
"autonomous_database_dedicated": ["adb_d", "adb", "autonomous_db"],
"adw_d": ["adw", "autonomous_db"],
"adw": ["adw", "autonomous_db"],
"atp_d": ["atp", "autonomous_db"],
"atp": ["atp", "autonomous_db"],
# GoldenGate aliases — same rule that fixes the PPTX side.
"oci_goldengate": ["goldengate"],
"ogg": ["goldengate"],
"oracle_goldengate": ["goldengate"],
# DRG variants
"dynamic_routing_gateway": ["drg"],
# Misc
"block_volume": ["block_storage"],
"oci_streaming": ["streaming", "kafka"],
"kafka": ["streaming"],
"web_application_firewall": ["waf"],
"network_firewall": ["network_firewall"],
"queue": ["queue", "oci_queue"],
"kms": ["vault"],
"secret": ["vault"],
"secrets_manager": ["vault"],
"identity": ["oracle_identity"],
"iam": ["oracle_identity"],
"iac": ["resource_manager"],
"terraform": ["resource_manager"],
"oac": ["analytics"],
"oic": ["integration"],
}
@classmethod