Commit Graph

2 Commits

Author SHA1 Message Date
root
5b8a6ad5ec Lookup index auto-invalidates on KB updates + manual rebuild flag
Diego asked: does the persisted ``archcenter-refs-index.json`` auto-
update when the KB is updated? Partially — mtime on the cache root
catches add/remove of subdirs (POSIX), but NOT changes to files
INSIDE existing subdirs (description.md added, .drawio replaced).

Two fixes:

1. Both KB-update tools now ``touch`` ``kb/diagram/assets/archcenter-refs``
   when they finish a run that produced changes:
   - ``archcenter_description_fetcher.py`` after fetched > 0
   - ``archcenter_zip_downloader.py`` after downloaded / extract /
     overwrite events
   The touch bumps the parent mtime, which the next lookup detects
   and uses to rebuild its persisted index. Closes the silent-drift
   case where description.md fetches landed but the index didn't
   notice.

2. ``archcenter_pattern_lookup.py --rebuild-index`` flag — escape
   hatch for manual KB edits (someone replaces a cached .drawio by
   hand) where neither tool ran. Removes the stale index file before
   the lookup, forcing a cold rebuild.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 23:38:29 -03:00
root
c46219468f 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>
2026-04-25 23:33:40 -03:00