# Adolf P4 — Cognee memory service config (mounted at /app/.env in the
# `cognee` container; matches upstream's own docker-compose `.env` pattern).
# cognee-mcp does NOT need this file — it runs in API mode (see
# service-block.yml) and only ever talks HTTP to `cognee`, never touching
# these DBs directly.

ENV=local
DEBUG=false
LOG_LEVEL=INFO
CORS_ALLOWED_ORIGINS=*

###############################################################################
# LLM — cognee runs on the Kimi subscription via the `cognee-llm` wrapper
# (:8011, built in P3). This is the intended backbone: the whole reason
# cognee-llm exists is to be cognee's LLM on the flat Kimi subscription (no
# per-token cost), consistent with adolf-llm doing the same for the assistant.
#
# Tradeoff (SPIKE-FINDINGS gate 5, accepted): the agentic CLI adds latency
# (~5s floor + ~22-24s/structured call) and runs on a single-seat subscription,
# so batch cognify is slower than a raw API. cognee-llm bounds concurrency
# (MAX_CONCURRENCY=3) to protect the account. If cognify throughput ever
# becomes a problem, the LiteLLM route below is the documented fallback.
#
# Requires: `kimi login` seeded into the `cognee-llm-home` volume (same as
# adolf-llm/kimi-agent).
###############################################################################
LLM_PROVIDER=openai
LLM_MODEL=openai/cognee-llm
# Must include /v1 — cognee's OpenAI-compatible LLM adapter passes this
# straight through to litellm as api_base and litellm appends
# "/chat/completions" verbatim (no path normalization). Without /v1 this hits
# http://cognee-llm:8011/chat/completions, which 404s (cognee-llm only serves
# /v1/chat/completions and /v1/models) — confirmed 2026-07-05 during the P4
# smoke test (litellm.NotFoundError: Error code 404 - 'not found').
LLM_ENDPOINT=http://cognee-llm:8011/v1
LLM_API_KEY=sk-cognee-llm-local

# Force instructor's plain JSON-in-content mode instead of its default
# tool-calling mode. cognee-llm's Kimi CLI wrapper is a text-only pass-through
# (no real OpenAI function/tool-calling support — it just returns
# {"content": "..."}), so instructor's default mode for the "openai" provider
# (tool-calling, since no explicit LLM_INSTRUCTOR_MODE means it never applies
# json_schema_mode either) fails with "Instructor does not support multiple
# tool calls, use List[Model] instead" — confirmed 2026-07-05 during the P4
# smoke test. json_mode matches cognee-llm's own documented behavior
# (STRUCTURED_SYSTEM_PREAMBLE: "When asked for JSON, output raw JSON only").
LLM_INSTRUCTOR_MODE=json_mode

# Fallback only (NOT the default) — route cognify's LLM to a LiteLLM model if
# the Kimi CLI path is ever too slow under batch load. Requires a working
# LiteLLM general model (fix judge's ANTHROPIC_API_KEY or a local qwen's port):
#LLM_MODEL=openai/judge
#LLM_ENDPOINT=http://litellm:4000

###############################################################################
# Embeddings — ollama directly (P4 blocker #1 resolution, per orchestrator:
# "use ollama directly"). LiteLLM's `embedder` route was dead (port bug), so
# rather than fix that indirection we go straight to ollama's own dedicated
# embedding-engine implementation (OllamaEmbeddingEngine, verified present in
# cognee 1.2.2's infra/databases/vector/embeddings/).
#
# Ollama lives in a SEPARATE compose project (not on this `openai` network),
# reachable from containers only via host.docker.internal — hence
# extra_hosts: host.docker.internal:host-gateway on the cognee service in
# docker-compose.yml. Verified 2026-07-05: `curl host.docker.internal:11436`
# from a throwaway container with that extra_hosts entry returns 200.
#
# EMBEDDING_ENDPOINT must be the FULL endpoint URL including path —
# OllamaEmbeddingEngine POSTs directly to whatever EMBEDDING_ENDPOINT is (its
# own default is "http://localhost:11434/api/embed"), unlike the
# openai_compatible engine which appends its own path onto a base URL. Ollama's
# native /api/embed (batch endpoint, not the singular /api/embeddings) returns
# {"embeddings": [[...]]}; the engine handles that key.
#
# Swapped nomic-embed-text (768-d) -> bge-m3 (1024-d, multilingual, GPU-served)
# 2026-07-06 [Adolf kb#60]. bge-m3 pulled into the same :11436 ollama; tested
# directly against :11436 -> 1024-dim vector, confirmed working. cognee's
# Qdrant collections were all still 768-d (a handful of P4 smoke-test points
# only — "pineapple-7742"/"p4 deployment smoke test" fixtures, no real
# conversation data; adolf-llm's cogneeSearch/cogneeAdd are still stubs and
# have never actually written to cognee), so the stale 768-d collections were
# dropped rather than migrated — cognee recreates them at the new dimension
# on first write.
###############################################################################
EMBEDDING_PROVIDER=ollama
EMBEDDING_MODEL=bge-m3
EMBEDDING_ENDPOINT=http://host.docker.internal:11436/api/embed
EMBEDDING_DIMENSIONS=1024
HUGGINGFACE_TOKENIZER=BAAI/bge-m3

###############################################################################
# Graph store — SPIKE-FINDINGS gate 4: Kuzu embedded, not Neo4j.
# This is cognee's own default; listed explicitly for clarity.
###############################################################################
GRAPH_DATABASE_PROVIDER=kuzu
GRAPH_DATASET_DATABASE_HANDLER=kuzu

###############################################################################
# Vector store — Qdrant (existing infra, :6333). Community adapter installed
# via the custom Dockerfile in this directory (see comments there).
###############################################################################
VECTOR_DB_PROVIDER=qdrant
VECTOR_DB_URL=http://qdrant:6333
VECTOR_DB_KEY=
VECTOR_DATASET_DATABASE_HANDLER=qdrant

###############################################################################
# Relational metadata DB (cognee's own bookkeeping, not the memory graph).
###############################################################################
DB_PROVIDER=sqlite
DB_NAME=cognee_db

###############################################################################
# Storage paths — persisted under /mnt/ssd/dbs/cognee/ on the host (see
# service-block.yml volume mounts to /data and /system).
###############################################################################
DATA_ROOT_DIRECTORY=/data
SYSTEM_ROOT_DIRECTORY=/system

###############################################################################
# Single-user/single-agent posture. Adolf is one Matrix bot (SPIKE-FINDINGS
# gate 4's own reasoning: no multi-tenant/concurrent-writer need at this
# scale). Scoping happens at the *dataset* level (one dataset per OpenClaw
# chat_id — see P4 report), not via cognee's own per-user auth/isolation
# machinery, so we skip that machinery rather than bootstrap a default user
# just to satisfy it.
#
# ENABLE_BACKEND_ACCESS_CONTROL=true (cognee's own default) would give each
# (user, dataset) pair a fully isolated Kuzu+vector store, but *requires*
# authentication (REQUIRE_AUTHENTICATION=false is ignored when this is true)
# - extra machinery (default user bootstrap, token plumbing into cognee-mcp)
# for no real benefit in a single-owner home deployment. With it off, all
# datasets share one graph/vector backend; dataset_name/datasets filters on
# remember/recall/forget still scope top-level data points per conversation,
# with one documented caveat: GRAPH_COMPLETION search can traverse into
# nodes from other datasets. Acceptable for one person's own conversation
# threads; revisit (flip this flag + bootstrap a default user) if that
# leakage ever matters.
###############################################################################
ENABLE_BACKEND_ACCESS_CONTROL=False
REQUIRE_AUTHENTICATION=False

# Only exercised if the above is ever flipped to true.
FASTAPI_USERS_JWT_SECRET=059bd0fdd9cecc46d055cf589d4275bd34c0fb73543f286beff09da2c2d27b65
FASTAPI_USERS_VERIFICATION_TOKEN_SECRET=7246494bb622c9c89417fbe0b94de6d7718f1338eb40dd370fb072873f921832
FASTAPI_USERS_RESET_PASSWORD_TOKEN_SECRET=18ad75671edf003f0142aad124276268fa766e702ab6bdb71a75d1c71a688beb

TOKENIZERS_PARALLELISM=false
LITELLM_LOG=ERROR
