Documentation
¶
Overview ¶
Package config provides BrainConfig loading and defaults for synapses-intelligence.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶
func DefaultConfigPath() string
DefaultConfigPath returns the conventional path for brain.json: $BRAIN_CONFIG if set, otherwise ~/.synapses/brain.json.
func SaveFile ¶
func SaveFile(path string, cfg BrainConfig) error
SaveFile writes cfg as indented JSON to path, creating parent directories as needed.
Types ¶
type BrainConfig ¶
type BrainConfig struct {
// Enabled controls whether the brain is active. Default: false.
Enabled bool `json:"enabled"`
// IntelligenceMode controls RAM residency and model quality tier.
// "optimal" (<800 MB, 8 GB systems), "standard" (~2.2 GB, 16 GB systems),
// "full" (~4.5 GB, 32 GB+ systems). Leave empty to use legacy auto-scaling.
IntelligenceMode IntelligenceMode `json:"intelligence_mode,omitempty"`
// OllamaURL is the base URL of the Ollama server. Default: "http://localhost:11434".
OllamaURL string `json:"ollama_url,omitempty"`
// Model is the primary model tag (enrichment fallback when ModelEnrich is unset).
// Default: "qwen3.5:2b" — base model until fine-tuned SIL models are available.
Model string `json:"model,omitempty"`
// FastModel is the model tag for bulk ingestion (fallback when ModelIngest is unset).
// Default: "qwen3.5:2b" — unified single model until fine-tuned tiers are ready.
FastModel string `json:"fast_model,omitempty"`
// ModelIngest is the model for bulk node summarization at index time.
// Tier 0 (Reflex): simple extraction, no reasoning needed. Default: "qwen3.5:2b".
// Future: fine-tuned Sentry 0.5B (see PLAN-5-MODELS.md).
ModelIngest string `json:"model_ingest,omitempty"`
// ModelGuardian is the model for rule violation explanations.
// Tier 1 (Sensory): structured plain-English output. Default: "qwen3.5:2b".
// Future: fine-tuned Critic 1.5B (see PLAN-5-MODELS.md).
ModelGuardian string `json:"model_guardian,omitempty"`
// ModelEnrich is the model for architectural enrichment and insight generation.
// Tier 2 (Specialist): complex analysis across multiple callers/callees. Default: "qwen3.5:2b".
// Future: fine-tuned Librarian 1.5B (see PLAN-5-MODELS.md).
ModelEnrich string `json:"model_enrich,omitempty"`
// ModelOrchestrate is the model for multi-agent conflict resolution.
// Tier 3 (Architect): deep reasoning about competing scope claims. Default: "qwen3.5:2b".
// Future: fine-tuned Navigator 2B (see PLAN-5-MODELS.md).
ModelOrchestrate string `json:"model_orchestrate,omitempty"`
// ModelArchivist is the model for session memory synthesis.
// Tier 2 (Specialist): analyzes agent sessions and extracts persistent memories.
// Default: same as ModelOrchestrate. Future: fine-tuned Archivist 2B.
ModelArchivist string `json:"model_archivist,omitempty"`
// Backend selects the LLM backend.
// "ollama" (default): calls the Ollama HTTP API. Recommended for all users.
// "local": loads a GGUF file directly via gollama (no Ollama required).
// Build with -tags llamacpp and CGO_ENABLED=1 for the local backend.
Backend string `json:"backend,omitempty"`
// GGUFPath is the path to the fine-tuned GGUF model file.
// Only used when Backend == "local". If empty, auto-computed as ModelDir/HFFilename.
// Example: "~/.synapses/models/sil-coder-Q5_K_M.gguf"
GGUFPath string `json:"gguf_path,omitempty"`
// ModelDir is the directory where GGUF models are stored.
// Default: ~/.synapses/models/
ModelDir string `json:"model_dir,omitempty"`
// HFRepo is the HuggingFace repository to download the model from.
// Example: "divish/sil-coder"
// Used by `brain config download` and `brain serve` (auto-download on first run).
HFRepo string `json:"hf_repo,omitempty"`
// HFFilename is the GGUF filename within the HuggingFace repo.
// Default: "sil-coder-Q5_K_M.gguf"
HFFilename string `json:"hf_filename,omitempty"`
// TimeoutMS is the per-request LLM timeout in milliseconds.
// The HTTP server WriteTimeout is set to 2× this value. Default: 60000 (60s).
// Must exceed the slowest LLM inference time on your hardware (~25s for 9b CPU).
TimeoutMS int `json:"timeout_ms,omitempty"`
// DBPath is the path to the brain's own SQLite database.
// Default: ~/.synapses/brain.sqlite
DBPath string `json:"db_path,omitempty"`
// Port is the HTTP server port for sidecar mode. Default: 11435.
Port int `json:"port,omitempty"`
// v0.1.0 feature flags — all default to true when Enabled=true.
Ingest bool `json:"ingest"`
Enrich bool `json:"enrich"`
Guardian bool `json:"guardian"`
Orchestrate bool `json:"orchestrate"`
Memorize bool `json:"memorize"`
// v0.2.0: Context Packet and SDLC intelligence.
// ContextBuilder enables BuildContextPacket (default: true when Enabled=true).
ContextBuilder bool `json:"context_builder"`
// LearningEnabled enables the decision log and co-occurrence learning (default: true).
LearningEnabled bool `json:"learning_enabled"`
// DefaultPhase is the initial SDLC phase stored in brain.sqlite if none is set.
// Values: "planning" | "development" | "testing" | "review" | "deployment"
// Default: "development"
DefaultPhase string `json:"default_phase,omitempty"`
// DefaultMode is the initial quality mode stored in brain.sqlite if none is set.
// Values: "quick" | "standard" | "enterprise"
// Default: "standard"
DefaultMode string `json:"default_mode,omitempty"`
// PulseURL is the base URL of the synapses-pulse analytics sidecar.
// When set, every LLM inference call is reported as a BrainUsageEvent.
// Leave empty to disable (default). Example: "http://localhost:11437"
PulseURL string `json:"pulse_url,omitempty"`
// PulseTimeoutSec is the per-request HTTP timeout for pulse calls.
// Defaults to 2 when PulseURL is set.
PulseTimeoutSec int `json:"pulse_timeout_sec,omitempty"`
}
BrainConfig holds all configuration for the thinking brain.
func DefaultConfig ¶
func DefaultConfig() BrainConfig
DefaultConfig returns a BrainConfig with all defaults applied.
func LoadFile ¶
func LoadFile(path string) (BrainConfig, error)
LoadFile reads a JSON config file and merges it onto the defaults. Missing fields in the file retain their default values.
func (*BrainConfig) AutoConfigureModels ¶
func (c *BrainConfig) AutoConfigureModels(totalRAMGB float64)
AutoConfigureModels sets per-tier model tags based on IntelligenceMode.
Optimal mode uses base Qwen 3.5 2B (~1.5 GB). Standard and Full modes use Qwen 3.5 4B Q4_K_M (~2.7 GB) — the 4B model reaches IFEval 89.8, the threshold for reliable format compliance in classification tasks.
All tiers in a given mode share the same base model via Ollama Modelfile identities (system prompts + parameters). Ollama deduplicates weights: all 5 identities share one copy of the weights in RAM.
Model tags:
synapses/sentry — Gate & Router (classify entities) synapses/librarian — Enricher (analyze graph slices) synapses/critic — Guardian (review diffs for violations) synapses/navigator — Orchestrator (resolve scope conflicts) synapses/archivist — Memory synthesizer (session summaries)
In Optimal mode Guardian reuses Librarian's identity (same model, different system prompt would be wasted — they share weights anyway).
totalRAMGB is used only when IntelligenceMode is "" (legacy auto-scaling path).
func (*BrainConfig) BaseModelTag ¶
func (c *BrainConfig) BaseModelTag() string
BaseModelTag returns the raw Ollama model tag backing all synapses/* identities for this intelligence mode. This is the actual model weights loaded in RAM — not the identity name (synapses/sentry etc.).
Used by ModelManager for RAM requirement checks: is4BModel("synapses/sentry") returns false, but is4BModel(BaseModelTag()) correctly returns true when the mode is standard/full.
optimal → "qwen3.5:2b" (~1.5 GB, IFEval ~80) standard → "qwen3.5:4b" (~2.7 GB, IFEval 89.8, Q4_K_M) full → "qwen3.5:4b" (~2.7 GB, IFEval 89.8, Q4_K_M) "" → c.Model (legacy path, no mode set)
func (*BrainConfig) KeepAlive ¶
func (c *BrainConfig) KeepAlive() int
KeepAlive returns the keep_alive seconds for this intelligence mode.
All 5 Ollama identities (synapses/sentry, synapses/librarian, etc.) share the same base model weights, so Ollama treats them as a single loaded model. A single keep_alive value applies to all tiers — the last request's value wins.
Per-mode policy (Sprint 17 #3 — Model Manager):
optimal (8 GB) : 120s — model evicts after 2 min of idle; saves ~1.5 GB on
tight 8 GB machines between bursts.
standard (16 GB) : 300s — model evicts after 5 min of idle; good tradeoff for
developer workstations where the model is used often.
full (32 GB+): -1 — model stays pinned; the machine can afford it.
default (unset) : -1 — backward-compatible behaviour; pinned.
func (*BrainConfig) KeepAliveValues ¶
func (c *BrainConfig) KeepAliveValues() (kaGuardian, kaEnrich, kaOrchestrate, kaArchivist int)
KeepAliveValues returns the keep_alive seconds for guardian, enrich, orchestrate, and archivist tiers. All four values are identical — they delegate to KeepAlive() because all Ollama identities share the same model weights. Retained for backward compatibility with existing callers.
type IntelligenceMode ¶
type IntelligenceMode string
IntelligenceMode controls which models are loaded and how they are cached, allowing the brain to fit different RAM budgets.
const ( // ModeOptimal targets 8 GB RAM systems. // Guardian shares Librarian's identity (no separate Critic). // All identities share qwen3.5:2b weights (~1.5GB), evicts after 2 min. ModeOptimal IntelligenceMode = "optimal" // ModeStandard targets 16 GB+ RAM systems. // Critic gets its own identity for violation explanations. // All identities share qwen3.5:4b Q4_K_M weights (~2.7GB), evicts after 5 min. ModeStandard IntelligenceMode = "standard" // ModeFull is identical to ModeStandard. Kept for config compatibility. // All identities share qwen3.5:4b Q4_K_M weights (~2.7GB), pinned. ModeFull IntelligenceMode = "full" )