Skip to content

fix(health): add /health alias + secret-safe db_wrapper CLI#54

Open
metazen11 wants to merge 1 commit into
mainfrom
fix/health-route-alias
Open

fix(health): add /health alias + secret-safe db_wrapper CLI#54
metazen11 wants to merge 1 commit into
mainfrom
fix/health-route-alias

Conversation

@metazen11

Copy link
Copy Markdown
Owner

Summary

  • Add /health as an alias for /api/health so anvil's vbot probe (and other platform-convention callers) find the service without needing to know our /api/ prefix. Same handler, two paths, no logic change.
  • Add app/db_wrapper.py: CLI for ad-hoc SQL that never surfaces credentials. Mirrors the fire-map db.py pattern — DDL refused, DML behind --force, asyncpg DSN errors redacted.

Why

Hit during an anvil integration session: anvil reported agent-memory: not available (memory features disabled) even though the service was healthy. Anvil's cli_vbot.py hits f"{memory_url}/health"; we only mount /api/health. The fix lives better here (one-line FastAPI alias) than in anvil (which would diverge from upstream).

The db_wrapper.py is unrelated but came out of the same incident — needed a way to inspect the DB during diagnosis without cat-ing .env. Useful on its own.

Test plan

  • curl http://localhost:3377/health returns 200 with same body as /api/health
  • curl http://localhost:3377/api/health still returns 200 (no regression)
  • python -m app.db_wrapper --health connects, prints status, never prints DSN
  • python -m app.db_wrapper "DROP TABLE x" refuses with migration-system pointer
  • anvil vbot (with the alias) prints agent-memory: running at http://localhost:3377

🤖 Generated with Claude Code

Two changes that came out of an anvil integration session:

1. app/routes/health.py: add `/health` as an alias for `/api/health`.
   Anvil's vbot startup probe hits `{memory_url}/health` (the platform
   convention) and was reporting "memory features disabled" because
   only `/api/health` was mounted. Same handler, two paths, no logic
   change.

2. app/db_wrapper.py: new CLI for ad-hoc SQL against agentMemory.
   Mirrors the fire-map db.py pattern — credentials never appear in
   stdout/stderr, DDL is refused (use scripts/migrations/ instead),
   DML requires --force, asyncpg DSN errors are redacted before
   surfacing. Reads creds via app.config.Settings so .env stays the
   single source of truth.

   Usage:
     python -m app.db_wrapper "SELECT count(*) FROM mem_observations"
     python -m app.db_wrapper --health
     python -m app.db_wrapper --tables

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants