Conventional install: pipx + Makefile, drop in-tree venv#3
Conversation
Sacred Brain is now installed as a proper Python package via pipx, driven by a Makefile that honors DESTDIR/PREFIX/SYSCONFDIR. Drops the in-tree .venv approach and gives you `make install` / `make uninstall`. Package: - pyproject.toml ships console-script entry points: `hippocampus` (runs the FastAPI app via uvicorn) and `memory-governor` (runs memory_governor.app:run). - Packages now cover brain.*, memory_governor.*, sacred_brain.*, including sacred_brain/prompts/sam_system.txt as package data. Previously only memory_governor was listed; the others worked under `pip install -e` because the project root was on sys.path, but a real install missed them. - New brain/hippocampus/__main__.py with main() that calls uvicorn.run. Installer: - New Makefile with install / install-update / uninstall / uninstall-purge targets. install runs `pipx install --force .` into PIPX_HOME (default /opt/pipx) with bins symlinked to PREFIX/bin. install-update reinstalls the package, refreshes units, and restarts enabled services. - scripts/install.sh becomes a thin shim that exec's the Makefile so any external automation calling ./scripts/install.sh keeps working. - sacred-search now installed by the Makefile to PREFIX/bin instead of the per-user ~/.local/bin/ symlink dance. Systemd: - hippocampus.service ExecStart now /usr/local/bin/hippocampus, no longer needs WorkingDirectory. - memory-governor.service same treatment. - Timer-target services use /opt/pipx/venvs/sacred-brain-hippocampus/bin/python instead of /opt/sacred-brain/.venv/bin/python. - ReadOnlyPaths updated: /opt/pipx replaces /opt/sacred-brain for service units, timers keep both (they read scripts from the repo and python from pipx). Migration: - `make install` auto-detects /opt/sacred-brain/.venv/ from a pre-pipx install and removes it. Idempotent — silent if already clean. Misc: - .gitignore now covers build/ and dist/ (left over from `python -m build`). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
kerykeion (Swiss Ephemeris / pyswisseph C build) was a hard dependency but is only used by memory_governor's astrology oracle + scripts/natal_to_sacred_brain — never by the hippocampus core (the sqlite backend is lexical: no embeddings, no LLM). Requiring it forced a compiler + libswe-dev on every install, blocking a clean user-space core-only deploy. Astrology/natal computation is owned by the separate `astrotunes` project, so remove it here. Governor astrology that imports kerykeion lazily should delegate to astrotunes (or install kerykeion explicitly where the governor runs). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- hippocampus: GET /memories/{user_id} query is now optional (empty query
-> adapter.list_memories), limit cap raised to 1000. Unblocks dream_sweep
and the Governor recall-fallback, which list with no query and hit 422.
- governor: make _rerank robust (ask the model for an index ORDER and
reorder the ORIGINAL objects, safe fallback on error/disabled) and
actually call it from /recall (fetch a wider pool -> rerank -> top-k).
_rerank was previously defined but never invoked (dead code).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Both units load /etc/sacred-brain/secrets.env as an optional second EnvironmentFile so shared keys (LITELLM_API_KEY, HIPPOCAMPUS_API_KEY) can come from a secrets store instead of literals in the per-service *.env. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Heads-up: this branch now carries an extra commit beyond the conventional-install work — It adds one optional line to each unit: so shared API keys ( Companion side (already on |
Stacked on top of #2. Builds on the cleaned-up bash installer to replace it with a proper Python-package-shipped-via-pipx flow.
Summary
pyproject.tomlnow defines[project.scripts]entry points:hippocampus(runs the FastAPI app via uvicorn) andmemory-governor(callsmemory_governor.app:run). Packages coverbrain.*,memory_governor.*,sacred_brain.*— previously onlymemory_governorwas in the package list, which only worked underpip install -ethanks to sys.path leakage.Makefiledrives the install. Targets:install,install-update,uninstall,uninstall-purge. HonorsDESTDIR,PREFIX,SYSCONFDIR,PIPX_HOME.make installrunspipx install --force .into/opt/pipx/venvs/sacred-brain-hippocampus/and symlinkshippocampus/memory-governor/sacred-searchinto$(PREFIX)/bin/.scripts/install.shbecomes a thin shim thatexec makes the right target, sosudo ./scripts/install.sh [--update|--uninstall|--uninstall --purge]still works for existing automation.hippocampus.serviceandmemory-governor.serviceExecStartpoint at/usr/local/bin/hippocampusand/usr/local/bin/memory-governor. Timer-target services use/opt/pipx/venvs/sacred-brain-hippocampus/bin/python.ReadOnlyPathsnow grants/opt/pipx(timers keep both/opt/sacred-brainand/opt/pipx).make installauto-detects and removes/opt/sacred-brain/.venv/from pre-pipx installs. Idempotent.sacred-searchis now installed by the Makefile to$(PREFIX)/bin/, replacing the per-user~/.local/bin/symlink convention fromdocs/APP_ONBOARDING.md(server-side; client hosts still use scp/rsync).Verified:
python -m build --wheelproduces a valid wheel with both entry points andsacred_brain/prompts/sam_system.txtincluded as package data. Both shellscripts passshellcheck -S warning.Test plan
git clone→sudo make install→ edit configs →sudo systemctl start hippocampus memory-governor→just healthpasseswhich hippocampus memory-governor sacred-searchshows them all in/usr/local/bin/journalctl -u hippocampusshows clean startup; no references to/opt/sacred-brain/.venvcd /opt/sacred-brain && sudo git pull && sudo make installremoves/opt/sacred-brain/.venv/and migrates services without data losssudo make uninstall-purgecleanly removes all units, the pipx venv, configs, state, and thesacredusermake -n install DESTDIR=/tmp/stage PREFIX=/usrproduces a sane staging plan🤖 Generated with Claude Code