Skill: kill the lookup-loop time-sink (3 fixes from Codex transcript)

Root cause observed in a real Codex session: the agent burned ~3min
on `make venv` + 4 sequential `make diagram-lookup` queries trying
to find a non-existent ref-arch (OCI PostgreSQL accessed FROM GCP
via Cross-Cloud Interconnect). The catalog has 123 entries; if two
honest queries can't surface a topology, none exists — but nothing
in the skill said "stop." Three coordinated fixes:

1) Makefile: `make venv` is now idempotent.
   Marker file `.venv/.deps-installed` keyed off `requirements.txt`
   mtime — the second `make venv` in a row is a 26ms no-op (was
   1m53s on a Codex sandbox, paid every turn). Force a rebuild with
   `rm .venv/.deps-installed`.

2) kb/architecture-center/catalog.yaml: new `known_gaps` block.
   Surfaced by the lookup tool as a top-of-output banner whenever
   the (synonym-expanded) query tokens match any one of a gap's
   `triggers` token sets. Two gaps seeded from real engagements:

     - gcp-to-oci-native-services — OCI PostgreSQL/OKE/Cache/etc.
       reached FROM GCP via Cross-Cloud Interconnect (the
       Database@Google Cloud entries are the OPPOSITE direction).

     - newer-oci-services-without-icon — OCI Cache (Redis/Valkey)
       and OCI PostgreSQL post-v24.2-toolkit; no ref-arch, no
       toolkit icon, fall back to generic stencil + explicit label.

   Each gap's `notice:` is a copy-paste recommended composition so
   the agent doesn't have to invent a strategy.

3) tools/archcenter_pattern_lookup.py: detects + surfaces gaps.
   `lookup()` now returns `{"matches": ..., "gaps": ...}`. The
   text printer emits a "⚠ KNOWN GAP — <id>" banner with the
   notice block ABOVE the score-based top-K, so the agent sees
   the stop-and-compose signal before ever scrolling to results.
   YAML output mode mirrors the same shape under `gaps:`.

4) SKILL.md (option 2 step 1) + Codex copy via sync-skill.
   New explicit rule: "Lookup budget: max 2 queries — never loop."
   Documents the gap banner, the closest-3-then-ask fallback, and
   the prohibition against grasping at a 3rd refinement.

Verified manually:
  - GCP+postgresql query → gap fires
  - "redis ha multi-az" → newer-OCI gap fires
  - "exadata cross region data guard" → no false-positive gap

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-04-27 10:46:27 -03:00
parent ff77563133
commit 7f8cba7f30
5 changed files with 128 additions and 6 deletions

View File

@@ -19,11 +19,20 @@ help: ## Show this help
VENV_PYTHON := $(shell command -v python3.12 2>/dev/null || command -v python3.11 2>/dev/null || command -v python3.10 2>/dev/null || echo python3)
venv: ## Create virtual environment and install dependencies
@echo "Using $(VENV_PYTHON) to create venv..."
$(VENV_PYTHON) -m venv .venv
venv: .venv/.deps-installed ## Create or update venv (idempotent — no-op if requirements.txt unchanged)
# Marker file pattern: the venv only rebuilds when requirements.txt is
# newer than the marker. A fresh `make venv` after a successful install
# is an instant no-op (was 1m53s on Codex sandboxes — every turn).
# To force a rebuild: `rm .venv/.deps-installed` (or `rm -rf .venv`).
.venv/.deps-installed: requirements.txt
@if [ ! -x .venv/bin/python ]; then \
echo "Using $(VENV_PYTHON) to create venv..."; \
$(VENV_PYTHON) -m venv .venv; \
fi
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt
@touch .venv/.deps-installed
@echo "Virtual environment ready. Run: source .venv/bin/activate"
@echo "Tip: run 'make install-hooks' once to enable the pre-commit"
@echo " hook that keeps SKILL.md in sync with the Codex copy."