fix(cli): bundle registry into wheel so installed warden works outside the repo

issue-core flagged the installed `warden` lacked the `route` subcommand. Two causes:

1. uv reused a cached wheel (version stayed 0.1.0) so the installed warden.cli was
   stale. Documented the cache-clean + --reinstall fix in ADHOC-2026-06-27.
2. Even rebuilt, route/access/policy were unusable outside a checkout because the
   routing catalog + posture descriptors live in registry/ at repo root, outside the
   package. Bundle registry/ into the wheel (hatch force-include -> warden/_registry)
   and add a packaged-data fallback in find_catalog_path / find_posture_path after the
   repo walk, so source runs still prefer the repo's registry/ (single source of truth).

Verified `warden route list` / `warden policy list` work from /tmp. 200 tests, lint clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 19:40:14 +02:00
parent 475db3c122
commit 0b3486af9e
4 changed files with 54 additions and 0 deletions

View File

@@ -111,6 +111,10 @@ def find_posture_path(start: Optional[Path] = None) -> Path:
candidate = parent / rel
if candidate.exists():
return candidate
# Fallback: registry bundled into the installed wheel (warden/_registry/...).
bundled = Path(__file__).resolve().parent / "_registry" / "policy" / "security-posture.yaml"
if bundled.exists():
return bundled
raise PostureError(f"Posture descriptors not found ({rel}).")

View File

@@ -98,6 +98,10 @@ def find_catalog_path(start: Optional[Path] = None) -> Path:
candidate = parent / rel
if candidate.exists():
return candidate
# Fallback: registry bundled into the installed wheel (warden/_registry/...).
bundled = Path(__file__).resolve().parent.parent / "_registry" / "routing" / "catalog.yaml"
if bundled.exists():
return bundled
raise CatalogError(
f"Routing catalog not found ({rel}). Set WARDEN_ROUTING_CATALOG to override."
)