Documentation
¶
Overview ¶
Package config provides configuration management for engram.
Index ¶
- Constants
- Variables
- func DBPath() string
- func DataDir() string
- func EnsureAll() error
- func EnsureDataDir() error
- func EnsureSettings() error
- func GetCollectionConfigPath() string
- func GetDatabaseDSN() string
- func GetEmbeddingAPIKey() string
- func GetEmbeddingBaseURL() string
- func GetEmbeddingDimensions() int
- func GetEmbeddingModelName() string
- func GetEmbeddingProvider() string
- func GetEmbeddingTruncate() bool
- func GetWorkerHost() string
- func GetWorkerPort() int
- func GetWorkerToken() string
- func GetWorkstationID() string
- func SettingsPath() string
- type Config
Constants ¶
const ( // DefaultWorkerPort is the default HTTP port for the worker service. DefaultWorkerPort = 37777 // DefaultModel for SDK agent (use "haiku" for cost-efficient processing). // Claude Code CLI accepts aliases: haiku, sonnet, opus (always latest versions) DefaultModel = "haiku" )
const DefaultEmbeddingModel = "bge-v1.5"
DefaultEmbeddingModel is the default embedding model to use.
Variables ¶
var CriticalConcepts = []string{
"gotcha", "pattern", "problem-solution", "trade-off",
}
CriticalConcepts are concepts that indicate "must know" information. Observations with these concepts are prioritized in context injection.
var DefaultObservationConcepts = []string{
"how-it-works", "why-it-exists", "what-changed",
"problem-solution", "gotcha", "pattern", "trade-off",
}
DefaultObservationConcepts are the concept tags to include in context.
var DefaultObservationTypes = []string{
"bugfix", "feature", "refactor", "change", "discovery", "decision",
}
DefaultObservationTypes are the observation types to include in context.
Functions ¶
func EnsureDataDir ¶
func EnsureDataDir() error
EnsureDataDir creates the data directory if it doesn't exist. Uses 0700 permissions (owner-only) for security.
func EnsureSettings ¶
func EnsureSettings() error
EnsureSettings creates a default settings file if it doesn't exist.
func GetCollectionConfigPath ¶
func GetCollectionConfigPath() string
GetCollectionConfigPath returns the path to the collections YAML config. Falls back to ~/.config/engram/collections.yml if env is unset.
func GetDatabaseDSN ¶
func GetDatabaseDSN() string
GetDatabaseDSN returns the PostgreSQL DSN. env DATABASE_DSN takes priority (contains password, never stored in config file). Returns empty string if not configured.
func GetEmbeddingAPIKey ¶
func GetEmbeddingAPIKey() string
GetEmbeddingAPIKey returns the embedding API key (env-only, never from config file).
func GetEmbeddingBaseURL ¶
func GetEmbeddingBaseURL() string
GetEmbeddingBaseURL returns the OpenAI-compatible API base URL.
func GetEmbeddingDimensions ¶
func GetEmbeddingDimensions() int
GetEmbeddingDimensions returns the embedding vector dimensions for external providers.
func GetEmbeddingModelName ¶
func GetEmbeddingModelName() string
GetEmbeddingModelName returns the embedding model name for external providers.
func GetEmbeddingProvider ¶
func GetEmbeddingProvider() string
GetEmbeddingProvider returns the embedding provider (e.g., "openai").
func GetEmbeddingTruncate ¶
func GetEmbeddingTruncate() bool
GetEmbeddingTruncate returns whether client-side MRL truncation is enabled. When true, vectors with more dimensions than configured are truncated and L2-normalized. Requires a Matryoshka-trained model for quality preservation. When false (default), a dimension mismatch causes an error (fail-fast).
func GetWorkerHost ¶
func GetWorkerHost() string
GetWorkerHost returns the worker host from environment, config, or fallback.
func GetWorkerPort ¶
func GetWorkerPort() int
GetWorkerPort returns the worker port from environment or config.
func GetWorkerToken ¶
func GetWorkerToken() string
GetWorkerToken returns the worker authentication token. GetWorkerToken returns the admin authentication token. Checks ENGRAM_AUTH_ADMIN_TOKEN first (preferred), falls back to ENGRAM_API_TOKEN (deprecated).
func GetWorkstationID ¶
func GetWorkstationID() string
GetWorkstationID returns the workstation identifier from environment. Returns empty string if not set; caller should fall back to sessions.WorkstationID().
Types ¶
type Config ¶
type Config struct {
ContextFullField string `json:"context_full_field"`
DBPath string `json:"db_path"`
Model string `json:"model"`
EmbeddingModel string `json:"embedding_model"`
VectorStorageStrategy string `json:"vector_storage_strategy"`
EmbeddingProvider string `json:"embedding_provider"`
EmbeddingBaseURL string `json:"embedding_base_url"`
EmbeddingModelName string `json:"embedding_model_name"`
EmbeddingDimensions int `json:"embedding_dimensions"`
EmbeddingAPIKey string
DatabaseDSN string `json:"-"` // env-only: DATABASE_DSN (contains password, never JSON)
DatabaseMaxConns int `json:"database_max_conns"` // PostgreSQL pool size (default: 10)
ContextObsConcepts []string `json:"context_obs_concepts"`
ContextObsTypes []string `json:"context_obs_types"`
ContextFullCount int `json:"context_full_count"`
GraphBranchFactor int `json:"graph_branch_factor"`
GraphEdgeWeight float64 `json:"graph_edge_weight"`
ContextRelevanceThreshold float64 `json:"context_relevance_threshold"`
RerankingCandidates int `json:"reranking_candidates"`
WorkerPort int `json:"worker_port"`
RerankingMinImprovement float64 `json:"reranking_min_improvement"`
ContextObservations int `json:"context_observations"`
ContextMaxPromptResults int `json:"context_max_prompt_results"`
ContextSessionCount int `json:"context_session_count"`
MaxConns int `json:"max_conns"`
RerankingAlpha float64 `json:"reranking_alpha"`
GraphMaxHops int `json:"graph_max_hops"`
RerankingResults int `json:"reranking_results"`
GraphRebuildIntervalMin int `json:"graph_rebuild_interval_min"`
HubThreshold int `json:"hub_threshold"`
ObservationRetentionDays int `json:"observation_retention_days"`
MaintenanceIntervalHours int `json:"maintenance_interval_hours"`
ContextShowWorkTokens bool `json:"context_show_work_tokens"`
ContextShowReadTokens bool `json:"context_show_read_tokens"`
RerankingPureMode bool `json:"reranking_pure_mode"`
GraphEnabled bool `json:"graph_enabled"`
MaintenanceEnabled bool `json:"maintenance_enabled"`
RerankingEnabled bool `json:"reranking_enabled"`
ContextShowLastSummary bool `json:"context_show_last_summary"`
CleanupStaleObservations bool `json:"cleanup_stale_observations"`
RerankingProvider string `json:"reranking_provider"`
RerankingAPIBaseURL string `json:"reranking_api_base_url"` // Full rerank endpoint URL (e.g. http://host:port/v1/rerank)
RerankingAPIModel string `json:"reranking_api_model"` // default: "rerank-english-v3.0"
RerankingTimeoutMS int `json:"reranking_timeout_ms"` // default: 500
RerankingBatchSize int `json:"reranking_batch_size"` // default: 32
RerankingAPIKey string // env-only: ENGRAM_RERANKING_API_KEY
ContextMaxTokens int `json:"context_max_tokens"` // Token budget for context injection (default: 8000, 0=unlimited)
HyDEEnabled bool `json:"hyde_enabled"` // Enable HyDE query expansion (default: false)
HyDEAPIURL string `json:"hyde_api_url"` // OpenAI-compatible chat API URL
HyDEModel string `json:"hyde_model"` // LLM model (default: "gpt-4o-mini")
HyDEMaxTokens int `json:"hyde_max_tokens"` // Max tokens for LLM response (default: 150)
HyDETimeoutMS int `json:"hyde_timeout_ms"` // Timeout in ms (default: 800)
HyDEAPIKey string // env-only: ENGRAM_HYDE_API_KEY
WorkerHost string // env-only
WorkerToken string // env-only
CollectionConfigPath string // env-only
WorkstationID string // env-only: WORKSTATION_ID
GraphProvider string `json:"graph_provider"` // "falkordb" or "" (disabled)
FalkorDBAddr string // env-only: ENGRAM_FALKORDB_ADDR
FalkorDBPassword string // env-only: ENGRAM_FALKORDB_PASSWORD
FalkorDBGraphName string `json:"falkordb_graph_name"` // default: "engram"
GraphSearchExpansion bool `json:"graph_search_expansion"` // expand search via graph (default: true when graph provider set)
TelemetryEnabled bool `json:"telemetry_enabled"`
SmartGCEnabled bool `json:"smart_gc_enabled"`
SmartGCThreshold float64 `json:"smart_gc_threshold"`
SmartGCMinAgeDays int `json:"smart_gc_min_age_days"`
LogBufferSize int `json:"log_buffer_size"` // Ring buffer capacity for /api/logs (default: 10000)
QueryExpansionTimeoutMS int `json:"query_expansion_timeout_ms"` // Timeout for query expansion (default: 3000ms)
DedupSimilarityThreshold float64 `json:"dedup_similarity_threshold"` // Cosine similarity threshold for dedup clustering (default: 0.7)
DedupWindowSize int `json:"dedup_window_size"` // Max observations considered for dedup (default: 200)
ClusteringThreshold float64 `json:"clustering_threshold"` // Similarity threshold for result clustering (default: 0.55)
StoreMemoryHardLimit int `json:"store_memory_hard_limit"` // Max chars for store_memory content (default: 10000)
StoreMemorySoftLimit int `json:"store_memory_soft_limit"` // Chars above which content is truncated (default: 1000)
StoreMemoryDedupThreshold float64 `json:"store_memory_dedup_threshold"` // Cosine similarity for dedup (default: 0.92)
StoreMemorySummarize bool `json:"store_memory_summarize"` // Use LLM to summarize long content (default: false)
EncryptionKeyFile string `json:"-"` // env-only: ENGRAM_ENCRYPTION_KEY_FILE (path to vault.key)
EncryptionKey string `json:"-"` // env-only: ENGRAM_ENCRYPTION_KEY (hex-encoded 256-bit key)
LLMMaxTokens int `json:"llm_max_tokens"` // ENGRAM_LLM_MAX_TOKENS (default: 4096)
LLMFilterEnabled bool `json:"llm_filter_enabled"` // ENGRAM_LLM_FILTER_ENABLED (default: false)
LLMFilterModel string `json:"llm_filter_model"` // ENGRAM_LLM_FILTER_MODEL (default: same as ENGRAM_LLM_MODEL)
LLMFilterTimeoutMS int `json:"llm_filter_timeout_ms"` // ENGRAM_LLM_FILTER_TIMEOUT_MS (default: 3000)
LLMFilterCandidates int `json:"llm_filter_candidates"` // ENGRAM_LLM_FILTER_CANDIDATES (default: 15)
ConsolidationEnabled bool `json:"consolidation_enabled"` // ENGRAM_CONSOLIDATION_ENABLED (default: false)
SupersessionEnabled bool `json:"supersession_enabled"` // ENGRAM_SUPERSESSION_ENABLED (default: true)
SupersessionThreshold float64 `json:"supersession_threshold"` // ENGRAM_SUPERSESSION_THRESHOLD (default: 0.9)
ConsolidationThreshold float64 `json:"consolidation_threshold"` // ENGRAM_CONSOLIDATION_THRESHOLD (default: 0.95)
AlwaysInjectLimit int `json:"always_inject_limit"` // ENGRAM_ALWAYS_INJECT_LIMIT (default: 20)
ProjectInjectLimit int `json:"project_inject_limit"` // ENGRAM_PROJECT_INJECT_LIMIT (default: 15)
InjectionFloor int `json:"injection_floor"` // ENGRAM_INJECTION_FLOOR (default: 3)
SessionBoost float64 `json:"session_boost"` // ENGRAM_SESSION_BOOST (default: 1.3)
}
Config holds the application configuration. Field order optimized for memory alignment (fieldalignment).