config

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config loads memmy's YAML configuration. Schema mirrors DESIGN.md §12.

Index

Constants

View Source
const (
	TransportMCP   = "mcp"   // streamable HTTP MCP transport
	TransportStdio = "stdio" // MCP over stdin/stdout
	TransportGRPC  = "grpc"  // reserved
	TransportHTTP  = "http"  // reserved
)

Transport name constants. The set of known names is closed so the validator can reason about mutual exclusivity (stdio).

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server      ServerConfig       `yaml:"server"`
	Storage     StorageConfig      `yaml:"storage"`
	Embedder    EmbedderConfig     `yaml:"embedder"`
	VectorIndex VectorIndexConfig  `yaml:"vector_index"`
	Memory      MemoryConfig       `yaml:"memory"`
	Tenant      TenantSchemaConfig `yaml:"tenant"`
}

Config is the top-level configuration loaded at startup.

func Default

func Default() Config

Default returns a Config populated with the documented defaults.

No transport is enabled by default — the operator must explicitly declare which one(s) to run via server.transports. An empty transports map fails Validate() so config typos can't accidentally bring up an unwanted listener (or, in the case of stdio, take over the parent's stdin/stdout silently).

func Load

func Load(path string) (Config, error)

Load reads and parses a YAML file at path, applying any unspecified fields from Default(). Returns a validated Config. Secrets that reference environment variables (`${VAR_NAME}`) are expanded in place before validation.

func (Config) EmbedderDim

func (c Config) EmbedderDim() int

EmbedderDim returns the dimensionality of the configured embedder.

func (Config) Validate

func (c Config) Validate() error

Validate reports an error if any required field is missing or any numeric tunable is outside a sane range.

type DecayConfig

type DecayConfig struct {
	NodeLambda            float64 `yaml:"node_lambda"`
	EdgeStructuralLambda  float64 `yaml:"edge_structural_lambda"`
	EdgeCoRetrievalLambda float64 `yaml:"edge_coretrieval_lambda"`
	EdgeCoTraversalLambda float64 `yaml:"edge_cotraversal_lambda"`
}

type EmbedderConfig

type EmbedderConfig struct {
	Backend string             `yaml:"backend"`
	Gemini  GeminiConfig       `yaml:"gemini"`
	Fake    FakeEmbedderConfig `yaml:"fake"`
}

type FakeEmbedderConfig

type FakeEmbedderConfig struct {
	Dim int `yaml:"dim"`
}

type GeminiConfig

type GeminiConfig struct {
	Model       string `yaml:"model"`
	APIKey      string `yaml:"api_key"`
	Dim         int    `yaml:"dim"`
	Concurrency int    `yaml:"concurrency"`
}

type MemoryConfig

type MemoryConfig struct {
	ChunkWindowSize       int           `yaml:"chunk_window_size"`
	ChunkStride           int           `yaml:"chunk_stride"`
	RetrievalK            int           `yaml:"retrieval_k"`
	RetrievalHops         int           `yaml:"retrieval_hops"`
	RetrievalOversample   int           `yaml:"retrieval_oversample"`
	StructuralRecentN     int           `yaml:"structural_recent_n"`
	StructuralRecentDelta time.Duration `yaml:"structural_recent_delta"`

	// RefractoryPeriod blocks repeated explicit Reinforce/Demote/Mark
	// bumps on the same node within the window. Implicit Recall
	// co-retrieval bumps are NOT throttled. Set to 0 to disable.
	RefractoryPeriod time.Duration `yaml:"refractory_period"`

	// LogDampening scales positive Reinforce/Mark deltas by
	// (1 - weight/WeightCap), so saturation is asymptotic instead of a
	// hard wall. Demote is unaffected.
	LogDampening bool `yaml:"log_dampening"`

	// MarkMaxNodes caps the number of recent nodes a single Mark call
	// will walk.
	MarkMaxNodes int `yaml:"mark_max_nodes"`

	Scoring   ScoringConfig   `yaml:"scoring"`
	Decay     DecayConfig     `yaml:"decay"`
	Reinforce ReinforceConfig `yaml:"reinforce"`
	Prune     PruneConfig     `yaml:"prune"`
	WeightCap float64         `yaml:"weight_cap"`
}

type Neo4jStorageConfig added in v0.2.0

type Neo4jStorageConfig struct {
	URI            string        `yaml:"uri"`
	User           string        `yaml:"user"`
	Password       string        `yaml:"password"` // ${ENV_VAR} expansion supported
	Database       string        `yaml:"database"`
	ConnectTimeout time.Duration `yaml:"connect_timeout"`
}

type PruneConfig

type PruneConfig struct {
	EdgeFloor float64 `yaml:"edge_floor"`
	NodeFloor float64 `yaml:"node_floor"`
}

type ReinforceConfig

type ReinforceConfig struct {
	NodeDelta                    float64 `yaml:"node_delta"`
	EdgeCoRetrievalBase          float64 `yaml:"edge_coretrieval_base"`
	EdgeCoTraversalMultiplier    float64 `yaml:"edge_cotraversal_multiplier"`
	EdgeStructuralWeight         float64 `yaml:"edge_structural_weight"`
	EdgeStructuralTemporalWeight float64 `yaml:"edge_structural_temporal_weight"`
}

type ScoringConfig

type ScoringConfig struct {
	SimAlpha   float64 `yaml:"sim_alpha"`
	WeightBeta float64 `yaml:"weight_beta"`
}

type ServerConfig

type ServerConfig struct {
	Transports map[string]TransportConfig `yaml:"transports"`
}

type StorageConfig

type StorageConfig struct {
	Backend string             `yaml:"backend"`
	Neo4j   Neo4jStorageConfig `yaml:"neo4j"`
}

type TenantKeyConfig

type TenantKeyConfig struct {
	Description string   `yaml:"description"`
	Pattern     string   `yaml:"pattern"`
	Enum        []string `yaml:"enum"`
	Required    bool     `yaml:"required"`
}

TenantKeyConfig describes one key in the tenant tuple. Tenant values are always strings (Go: map[string]string), so the type is implicit.

type TenantSchemaConfig

type TenantSchemaConfig struct {
	Description string                     `yaml:"description"`
	Keys        map[string]TenantKeyConfig `yaml:"keys"`
	OneOf       [][]string                 `yaml:"one_of"`
}

TenantSchemaConfig is the optional tenant-tuple schema. When empty, memmy accepts any string-keyed tuple; when set, every Service operation rejects tuples that don't match.

Stored memories are NOT migrated when the schema changes — TenantID is derived from the (validated) tuple as today, so data written under one schema remains addressable if the schema is changed back to one that accepts the original tuple shape.

func (TenantSchemaConfig) IsConfigured

func (t TenantSchemaConfig) IsConfigured() bool

IsConfigured reports whether the tenant schema has any rules. An unconfigured schema means "accept any tuple" — today's behavior.

func (TenantSchemaConfig) Validate

func (t TenantSchemaConfig) Validate() error

Validate parses regex patterns and cross-checks the tenant schema for internal consistency. Returns nil on success; the schema may then be handed to service.NewTenantSchema.

type TransportConfig

type TransportConfig struct {
	Enabled bool   `yaml:"enabled"`
	Addr    string `yaml:"addr"`
}

type VectorIndexConfig

type VectorIndexConfig struct {
	// FlatScanThreshold is the per-tenant size below which Recall uses
	// a Cypher flat scan instead of the native vector index. Neo4j's
	// vector index has no exposed HNSW knobs; tuning it requires DDL
	// on the index itself (see DESIGN.md §13.1).
	FlatScanThreshold int `yaml:"flat_scan_threshold"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL