wiki-vault/Sources/Homelab/2026-05-17-vault-create-artifact-verification-2026-05-16.md

47 lines
2.3 KiB
Markdown

---
created: '2026-05-17'
path: Sources/Homelab
project: postgres-consolidation-reflection-layer
tags:
- mcp
- embeddings
- automation
- pgvector
type: session-notes
---
## Outcome
End-to-end verification of vault MCP create_artifact after the full diagnostic + fix chain: search_path override removed from db.py connection pool (commit 051c3ba), letting the vault_mcp role's default `wiki, public` apply naturally. Goal: confirm the dual-write lands a markdown file in the vault repo AND a row in petalbrain.wiki.artifacts AND chunked rows in petalbrain.public.embeddings.
## Topics Covered
The full chain of fixes for this single end-to-end write:
- Renamed mcp_server → vault_mcp package (rename worker)
- Fixed artifacts subsystem imports (rename completion worker)
- Hidden artifact tools (mistake) then re-exposed + hidden save_note shim
- Fixed create_artifact wrapper dispatch (was pointing at save_note_impl)
- Added missing HERBYLAB_DATABASE_URL env var
- Removed search_path = herbylab override in connection pool's configure hook
- Multiple container rebuilds with --no-cache to defeat image caching
If this artifact lands successfully, six iterations of architectural debugging culminated in a working vault MCP write surface.
## Key Learnings
When debugging MCP integration paths, work upward through the stack systematically:
1. MCP transport (auth + tool dispatch)
2. Wrapper layer (param translation + delegation target)
3. Env config (every env var referenced by every code path)
4. Database state (schemas, roles, search_path defaults)
5. Code-level overrides (session-level SET commands, SQLAlchemy connect_args, hardcoded schema names in MetaData)
Issues at any layer can mask issues at another. The "rebuild fixed it" theory was tempting at each step but only the layer 5 fix actually unblocked the write.
## Follow-ons
- [ ] Worker verifies wiki.artifacts row exists for this entry with correct schema
- [ ] Worker verifies public.embeddings has chunked rows with source_schema='wiki', source_table='artifacts' (or 'notes', depending on routing)
- [ ] Worker confirms chunk_text non-NULL and chunk_token_count ≤ 512
- [ ] If success: vault MCP write surface considered operational end-to-end
- [ ] Address the three out-of-scope items the worker flagged: tests/conftest.py:59 search_path SET, alembic/env.py:41 SCHEMA constant, HERBYLAB_DATABASE_URL env var name