fix(health): add /health alias + secret-safe db_wrapper CLI#54
Open
metazen11 wants to merge 1 commit into
Open
fix(health): add /health alias + secret-safe db_wrapper CLI#54metazen11 wants to merge 1 commit into
metazen11 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/healthas an alias for/api/healthso 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.app/db_wrapper.py: CLI for ad-hoc SQL that never surfaces credentials. Mirrors the fire-mapdb.pypattern — 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'scli_vbot.pyhitsf"{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.pyis unrelated but came out of the same incident — needed a way to inspect the DB during diagnosis withoutcat-ing.env. Useful on its own.Test plan
curl http://localhost:3377/healthreturns 200 with same body as/api/healthcurl http://localhost:3377/api/healthstill returns 200 (no regression)python -m app.db_wrapper --healthconnects, prints status, never prints DSNpython -m app.db_wrapper "DROP TABLE x"refuses with migration-system pointeranvil vbot(with the alias) printsagent-memory: running at http://localhost:3377🤖 Generated with Claude Code