Adolf memory: migrate Cognee -> Hindsight + Kimi quota tooling

Memory migration (H1-H5, kb#73-77,84):
- hindsight service in openai/docker-compose.yml: LLM via Kimi (cognee-llm
  wrapper), multilingual GPU embeddings (bge-m3 via ollama), jina multilingual
  reranker; pg0 + model cache persisted
- openclaw.json/shared-mcp.json: mcp.servers cognee -> hindsight (bank "adolf")
- hindsight-openclaw-plugin: forced-hook memory (before_prompt_build recall +
  agent_end retain), replacing cognee's hook layer; cognify-sweep dropped
- verified live: Russian retain->recall, cross-session recall, bank isolation

Kimi quota (kb#62):
- adolf-llm/server.js: LLM-free GET /usage route (Kimi managed-usage API)
- quota-command-openclaw-plugin: /quota readout command

Cognee stack left running (decommission is H4/kb#76). Kimi-quota-footer
auto-append abandoned (streamed Matrix replies bypass outbound hooks).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014t8Qg9gi7H7HtT8MncoXAB
This commit is contained in:
2026-07-15 19:53:21 +00:00
parent 544637c073
commit 4ac595a3a9
11 changed files with 1254 additions and 63 deletions

View File

@@ -170,6 +170,25 @@ services:
# so read-only is safe. Edit the tracked file + restart to change config;
# runtime/UI edits are intentionally disabled by the ro mount.
- ../adolf/openclaw.json:/home/node/.openclaw/openclaw.json:ro
# quota-command plugin (kb #62) — same read-only-bind-over-volume
# pattern as openclaw.json above, applied to a single external plugin
# dir instead of the whole state tree. Previously the only precedent
# (cognee-memory) was docker cp'd straight into the adolf-state volume
# at runtime with no git backing; this plugin is small enough (no
# node_modules — only Node built-ins/global fetch) to just bind-mount
# its tracked source directly at its extensions/<id> path, so git stays
# the single source of truth the same way it already is for
# openclaw.json. Activated via plugins.entries.quota-command in that file.
- ./quota-command-openclaw-plugin:/home/node/.openclaw/extensions/quota-command:ro
# hindsight-memory plugin (kb #75, H3) — same read-only-bind-over-volume
# pattern as quota-command above. Structural successor to cognee-memory
# (still docker cp'd into the adolf-state volume, no git backing; that
# plugin's activation/container is decommissioned in H4, not here).
# Forced hooks (before_prompt_build recall / agent_end retain) against
# the hindsight service (see that service's block below), replacing
# Cognee as Adolf's memory backend. Activated via
# plugins.entries.hindsight-memory in openclaw.json.
- ./hindsight-openclaw-plugin:/home/node/.openclaw/extensions/hindsight-memory:ro
extra_hosts:
- "host.docker.internal:host-gateway"
# mtx.alogins.net's public A record can't hairpin-NAT back through the
@@ -218,6 +237,11 @@ services:
- adolf-llm-workspace:/workspace
- adolf-llm-home:/root/.kimi-code
- ./shared-mcp.json:/shared-mcp.json:ro
extra_hosts:
# Needed to reach kanboard-mcp-adolf (:3104, network_mode: host, outside
# this compose project's network) via shared-mcp.json's "kanboard"
# entry — same host-gateway trick used by adolf/cognee/pipecat above.
- "host.docker.internal:host-gateway"
restart: unless-stopped
# cognee — Adolf's memory backend (P4). FastAPI + embedded Kuzu graph +
@@ -261,8 +285,13 @@ services:
# Never opens the graph/vector files itself, so it's safe to run alongside
# `cognee` without a second writer on the same Kuzu database. Exposes 3
# tools: remember / recall / forget.
#
# Built from a local Dockerfile (kb#70 fix) instead of the bare upstream
# image: forget was missing a data_id parameter end-to-end, so agents
# could delete a whole dataset but never a single entry. See
# ./cognee-mcp/Dockerfile and ./cognee-mcp/src/ for the patched files.
cognee-mcp:
image: cognee/cognee-mcp:1.2.2
build: ./cognee-mcp
container_name: cognee-mcp
restart: unless-stopped
environment:
@@ -277,6 +306,95 @@ services:
depends_on:
- cognee
# hindsight — Adolf memory backend, replacing cognee/cognee-mcp/cognee-llm
# (kb#73, migration doc agap_git/adolf/HINDSIGHT-MIGRATION.md, H1). One
# container: REST API :8888 (also serves the built-in MCP at /mcp/{bank}/),
# UI :9999, built-in Postgres (pg0) bind-mounted to
# /mnt/ssd/dbs/hindsight/ (host dir created + chowned 1000:1000 to match
# the image's non-root `hindsight` user, confirmed via
# `docker run --entrypoint id`).
#
# LLM + embeddings reconfigured 2026-07-15 (kb#84) to fix two wrong H1
# choices for a Russian/multilingual use case:
#
# LLM -> cognee-llm:8011 (the existing Kimi-CLI wrapper, same shim cognee
# uses — see cognee/cognee.env's LLM section for the full precedent,
# including why LLM_INSTRUCTOR_MODE=json_mode isn't needed here since
# Hindsight's own client doesn't go through `instructor`). Replaces the
# H1 choice of LiteLLM + ollama/gemma3:4b (a tiny local model): validated
# 2026-07-15 that cognee-llm returns clean, JSON-parseable structured
# extraction for Russian input (see kb#84 probe B) — gemma3:4b's fluency
# on Russian was never actually verified, it was picked only to dodge
# qwen3:8b's <think>-token empty-content bug. Kimi is also the flat-rate
# subscription already paid for, so this isn't a new cost.
#
# Embeddings -> ollama's bge-m3 on the GPU (host.docker.internal:11436,
# separate compose project, same extra_hosts trick as cognee/adolf-llm
# below), via ollama's OpenAI-compatible /v1/embeddings endpoint
# (confirmed 200 + 1024-dim vector 2026-07-15, kb#84 probe A). Replaces
# the H1 choice of Hindsight's built-in `local` provider
# (BAAI/bge-small-en-v1.5, English-only, 384-d, CPU-bound in-process
# SentenceTransformers). The hindsight image itself is CPU-only (torch
# +cpu build, no onnxruntime GPU provider — confirmed 2026-07-15), so its
# in-process local/onnx embedders can never reach the GPU; routing
# through ollama's `openai` embeddings provider (HTTP, not the bespoke
# cognee-style `ollama` provider Hindsight doesn't have) is how GPU
# serving happens here. Dimensions var matches cognee.env's own bge-m3
# swap (kb#60): 1024.
#
# Runs ALONGSIDE cognee/cognee-mcp/cognee-llm during the migration; those
# are untouched here and only decommissioned in H4, after H2/H3/H5 prove
# this service out. Not yet wired into openclaw.json/shared-mcp.json
# (that's H2, kb#74) — this block only stands the service up and proves
# retain/recall against a throwaway bank.
hindsight:
image: ghcr.io/vectorize-io/hindsight:latest
container_name: hindsight
restart: unless-stopped
environment:
- HINDSIGHT_API_LLM_PROVIDER=openai
- HINDSIGHT_API_LLM_BASE_URL=http://cognee-llm:8011/v1
- HINDSIGHT_API_LLM_MODEL=openai/cognee-llm
# cognee-llm ignores the key entirely (Kimi CLI wrapper, no real
# OpenAI auth) — same dummy value cognee.env uses for LLM_API_KEY.
- HINDSIGHT_API_LLM_API_KEY=sk-cognee-llm-local
- HINDSIGHT_API_EMBEDDINGS_PROVIDER=openai
- HINDSIGHT_API_EMBEDDINGS_OPENAI_BASE_URL=http://host.docker.internal:11436/v1
- HINDSIGHT_API_EMBEDDINGS_OPENAI_MODEL=bge-m3
- HINDSIGHT_API_EMBEDDINGS_OPENAI_DIMENSIONS=1024
# ollama doesn't check this value at all (no auth), but the openai
# embeddings client requires a non-empty key to construct.
- HINDSIGHT_API_EMBEDDINGS_OPENAI_API_KEY=ollama
# Stable worker id (compose service name), not the container hostname
# default -- without this, recreating the container orphans any
# in-flight async retain/consolidation tasks under the old hostname
# (startup log warns about exactly this).
- HINDSIGHT_API_WORKER_ID=hindsight
# Reranker -> multilingual (kb#84 follow-up). The TEMPR rerank stage
# defaulted to English cross-encoder/ms-marco-MiniLM, which ranks
# Russian/multilingual candidates poorly. jina v2 multilingual fixes
# that. Runs on CPU in this image (no CUDA torch) but only over the
# small recall candidate set. trust_remote_code: jina ships custom code.
- HINDSIGHT_API_RERANKER_PROVIDER=local
- HINDSIGHT_API_RERANKER_LOCAL_MODEL=jinaai/jina-reranker-v2-base-multilingual
- HINDSIGHT_API_RERANKER_LOCAL_TRUST_REMOTE_CODE=true
volumes:
- /mnt/ssd/dbs/hindsight:/home/hindsight/.pg0
# Persist HuggingFace/sentence-transformers model cache so the jina
# reranker (~1GB) doesn't re-download on every container recreate.
- /mnt/ssd/dbs/hindsight-cache:/home/hindsight/.cache
ports:
- "8888:8888"
- "9999:9999"
extra_hosts:
# Needed to resolve host.docker.internal from inside the container
# for the ollama embeddings call above — ollama lives in a separate
# compose project, same trick as cognee/adolf-llm elsewhere in this
# file.
- "host.docker.internal:host-gateway"
depends_on:
- cognee-llm
# openclaw-tools — MCP bridge (P5) exposing a minimal slice of the Adolf
# OpenClaw gateway's agent tools (message/cron/nodes/browser) over MCP
# Streamable HTTP, so Kimi CLI sessions (adolf-llm) can call them instead of