BrainBank

DIARY KNOWLEDGE SETUP

中文
publishedobsidian8/9/2026

What

A DIY system for building a personal knowledge base from daily diary entries. It consists of two pages—/diary for writing daily entries and /assistant for viewing/managing the evolved knowledge base—and a background knowledge engine that extracts, embeds, links, and tracks 'knowledge atoms' derived from those entries.

How

Setup (4 steps): 1. Enable pgvector via CREATE EXTENSION IF NOT EXISTS vector against the Neon database. 2. Run npm run db:push to create diary_entries, knowledge_atoms, knowledge_atom_sources, knowledge_links, knowledge_insights, insight_atoms, knowledge_runs tables plus several new enums (diary, title_source, diary_mood, atom_kind, atom_status, etc.). 3. Confirm nomic-embed-text is reachable using .\check-embeddings.ps1; if needed run ollama pull nomic-embed-text and ensure agent-server proxies an embeddings route (/v1/embeddings for OpenAI-compat, /api/embed, or /api/embeddings for older Ollama). 4. npm run build. Knowledge engine pipeline: diary entry saved → extract candidate atoms (local model only) → embed each with nomic-embed-text → find similar existing atoms via pgvector cosine similarity on HNSW index → reconcile each match as same/conflicts/refines/distinct (reinforce confidence for repeats, create unresolved review links for contradictions, or new distinct entries). Separately the ✨ Think button reads known atoms and produces highlights, themes, and recommendations linked back to source evidence. Lifecycle mechanisms: repeated observations increment confidence/counter; unconfirmed knowledge fades after ~10 weeks; manual trim/pin/merge stays under user control; nothing is auto-deleted.

Why

The system gets smarter over time rather than growing a flat log—reinforcement turns repeated observations into stronger belief entries, contradictions trigger updates (user picks which side survives), and decay lowers salience of stale knowledge while leaving the raw entry in the evidence trail. Built-in privacy: diary text is processed exclusively by the self-hosted agent-server; LOCAL_ONLY_CHAIN strips all non-local models from the fallback chain for diary-title and distill tasks, so entries never reach external APIs like Google. Hand-added atoms are pinned with high confidence and immune to decay.

Other

Data model details: diary entries are notes rows (source_type='diary', always private), reuse the image-upload pipeline, shared tag table, wikilinks, and search; excluded from the homepage list; /notes/<slug> redirects to /diary/<slug>. Deleting an entry removes only that row in the evidence trail—the learned knowledge atom survives. Offline behavior: when the Mac is asleep distillation fails but retries later via the 'Catch up' button on /assistant, while the diary-entry write itself never blocks. If embeddings are unavailable atom matching degrades gracefully to keyword overlap and atoms still get stored; backfill is possible later via 'Backfill embeddings' on /assistant.