feat(mars): self-hosted Honcho memory server for luna
Honcho v3.2.2 (API + deriver containers) on loopback, with native Postgres/pgvector and Ollama embeddings. Not wired into Hermes yet; Mnemosyne stays her memory provider until the switch. - Peer auth over the Postgres socket: the containers run as the host's honcho uid, so there is no DB password. - Embeddings: qwen3-embedding:0.6b (1024 dims, fixed at first migration). The API runs configure_embeddings on start to resize Honcho's default vector(1536) schema. - LLMs via OpenRouter: glm-5.3-flash:nitro at minimal reasoning for the deriver and quick dialectic, deepseek-v4-pro for deep dialectic and dreams (which maintain the peer cards). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
./disk-config.nix # disko: OS-disk partitions + filesystems
|
||||
./secrets.nix # sops-nix: samba/tailscale/hermes secrets
|
||||
./hermes-agent.nix
|
||||
./honcho.nix # luna's memory server (Postgres + Ollama embeddings)
|
||||
./livesync-bridge.nix
|
||||
./luna-sites.nix # luna's LAN web apps: http://mars.sol/<name>/
|
||||
../../common.nix # shared base: user / ssh / nix / firewall
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
# Honcho memory server for luna (Hermes's memory provider, once switched in
|
||||
# Hermes's own config). API + deriver from the official image; Postgres and
|
||||
# Ollama (embeddings) run natively. Everything binds loopback only.
|
||||
let
|
||||
honchoImage = "ghcr.io/plastic-labs/honcho@sha256:c74955d6dbea6dda42c2dd9dd13dea726fcba36ba5c0b6bae4867f7ed762896d"; # v3.2.2
|
||||
honchoUid = 984;
|
||||
honchoGid = 984;
|
||||
|
||||
# :nitro = OpenRouter's fastest-provider routing; the default picks cheap, slow hosts.
|
||||
fastModel = "z-ai/glm-5.3-flash:nitro";
|
||||
# Dreams maintain the peer cards, incl. her AI identity card.
|
||||
smartModel = "deepseek/deepseek-v4-pro";
|
||||
embedModel = "qwen3-embedding:0.6b";
|
||||
|
||||
# Peer auth over the socket: the container runs as the host's honcho uid,
|
||||
# so there is no DB password to manage.
|
||||
env = {
|
||||
DB_CONNECTION_URI = "postgresql+psycopg://honcho@/honcho?host=/run/postgresql";
|
||||
AUTH_USE_AUTH = "false";
|
||||
CACHE_ENABLED = "false";
|
||||
HOME = "/tmp";
|
||||
|
||||
LLM_OPENAI_BASE_URL = "https://openrouter.ai/api/v1";
|
||||
# Lowest reasoning GLM allows ("none" is rejected): hidden reasoning can
|
||||
# eat the deriver's whole output budget before any JSON is written.
|
||||
DERIVER_MODEL_CONFIG__MODEL = fastModel;
|
||||
DERIVER_MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||
SUMMARY_MODEL_CONFIG__MODEL = fastModel;
|
||||
DIALECTIC_LEVELS__minimal__MODEL_CONFIG__MODEL = fastModel;
|
||||
DIALECTIC_LEVELS__minimal__MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||
DIALECTIC_LEVELS__low__MODEL_CONFIG__MODEL = fastModel;
|
||||
DIALECTIC_LEVELS__low__MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||
DIALECTIC_LEVELS__medium__MODEL_CONFIG__MODEL = smartModel;
|
||||
DIALECTIC_LEVELS__high__MODEL_CONFIG__MODEL = smartModel;
|
||||
DIALECTIC_LEVELS__max__MODEL_CONFIG__MODEL = smartModel;
|
||||
DREAM_DEDUCTION_MODEL_CONFIG__MODEL = smartModel;
|
||||
DREAM_INDUCTION_MODEL_CONFIG__MODEL = smartModel;
|
||||
|
||||
EMBEDDING_MODEL_CONFIG__MODEL = embedModel;
|
||||
EMBEDDING_MODEL_CONFIG__OVERRIDES__BASE_URL = "http://127.0.0.1:11434/v1";
|
||||
EMBEDDING_MODEL_CONFIG__OVERRIDES__API_KEY = "ollama";
|
||||
# Fixed at the first migration; changing it later means a fresh DB.
|
||||
EMBEDDING_VECTOR_DIMENSIONS = "1024";
|
||||
EMBEDDING_MODEL_CONFIG__DIMENSIONS_MODE = "never";
|
||||
};
|
||||
|
||||
container = {
|
||||
image = honchoImage;
|
||||
user = "${toString honchoUid}:${toString honchoGid}";
|
||||
extraOptions = [ "--network=host" ];
|
||||
volumes = [ "/run/postgresql:/run/postgresql" ];
|
||||
environment = env;
|
||||
environmentFiles = [ config.sops.templates."honcho.env".path ];
|
||||
};
|
||||
|
||||
deps = [ "postgresql-setup.service" "honcho-db-setup.service" "ollama.service" ];
|
||||
in
|
||||
{
|
||||
users.users.honcho = {
|
||||
isSystemUser = true;
|
||||
uid = honchoUid;
|
||||
group = "honcho";
|
||||
};
|
||||
users.groups.honcho.gid = honchoGid;
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
extensions = ps: [ ps.pgvector ];
|
||||
ensureDatabases = [ "honcho" ];
|
||||
ensureUsers = [{
|
||||
name = "honcho";
|
||||
ensureDBOwnership = true;
|
||||
}];
|
||||
};
|
||||
|
||||
# CREATE EXTENSION needs a superuser; Honcho's migrations only re-assert it.
|
||||
systemd.services.honcho-db-setup = {
|
||||
description = "Enable pgvector in the honcho database";
|
||||
# ensureDatabases runs in postgresql-setup, not postgresql itself.
|
||||
after = [ "postgresql-setup.service" ];
|
||||
requires = [ "postgresql-setup.service" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
User = "postgres";
|
||||
};
|
||||
script = ''
|
||||
${config.services.postgresql.package}/bin/psql -d honcho -c 'CREATE EXTENSION IF NOT EXISTS vector'
|
||||
'';
|
||||
};
|
||||
|
||||
services.ollama = {
|
||||
enable = true;
|
||||
host = "127.0.0.1";
|
||||
loadModels = [ embedModel ];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers.honcho-api = container // {
|
||||
# Image CMD binds 0.0.0.0 and skips migrations. Migrations create
|
||||
# vector(1536); configure_embeddings resizes them (no-op once matching,
|
||||
# refuses on populated tables).
|
||||
entrypoint = "sh";
|
||||
cmd = [
|
||||
"-c"
|
||||
"/app/.venv/bin/python scripts/provision_db.py && /app/.venv/bin/python scripts/configure_embeddings.py --yes && exec /app/.venv/bin/fastapi run --host 127.0.0.1 --port 8000 src/main.py"
|
||||
];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers.honcho-deriver = container // {
|
||||
# Waits for the API, i.e. for the schema resize above.
|
||||
entrypoint = "sh";
|
||||
cmd = [
|
||||
"-c"
|
||||
"until /app/.venv/bin/python -c \"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)\" 2>/dev/null; do sleep 2; done; exec /app/.venv/bin/python -m src.deriver"
|
||||
];
|
||||
};
|
||||
|
||||
systemd.services.podman-honcho-api = {
|
||||
after = deps;
|
||||
requires = deps;
|
||||
};
|
||||
systemd.services.podman-honcho-deriver = {
|
||||
after = [ "podman-honcho-api.service" ];
|
||||
requires = [ "podman-honcho-api.service" ];
|
||||
};
|
||||
}
|
||||
@@ -98,4 +98,13 @@
|
||||
# markdown to disk. Also feeds the bridge's separate obfuscatePassphrase
|
||||
# field, since the plugin derives path obfuscation from the same value.
|
||||
sops.secrets.obsidian_luna_passphrase = { };
|
||||
|
||||
# Honcho (honcho.nix): OpenRouter key for its own LLM calls.
|
||||
sops.secrets.openrouter_api_key = { };
|
||||
sops.templates."honcho.env" = {
|
||||
content = ''
|
||||
LLM_OPENAI_API_KEY=${config.sops.placeholder.openrouter_api_key}
|
||||
'';
|
||||
restartUnits = [ "podman-honcho-api.service" "podman-honcho-deriver.service" ];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user