config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config defines the mnemos configuration schema, its built-in defaults, and the loader that merges those defaults with the single mnemos.toml found inside the active MNEMOS_DIR. The config carries behaviour only — indexing rules, chunking, search, the MCP surface, and security — never locations: every path is derived from the MNEMOS_DIR by package workspace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultTOML

func DefaultTOML() []byte

DefaultTOML returns the canonical default configuration document. `init` uses it to seed a new mnemos.toml.

Types

type CaptureConfig

type CaptureConfig struct {
	// DeferToWatcher, when true, makes mnemos.remember write-only: the OKF file
	// is written but not ingested one-shot, leaving kb/capture ingestion to a
	// running watcher. Default false keeps the one-shot ingest, which is safe
	// even alongside a watcher because the Phase 1 hash-skip makes the watcher's
	// re-sighting of the file a no-op.
	DeferToWatcher bool `koanf:"defer_to_watcher"`
}

CaptureConfig configures write-back behaviour. The capture location itself is not configurable: it is always the kb/capture directory of the active MNEMOS_DIR (see package workspace).

type ChunkingConfig

type ChunkingConfig struct {
	TargetTokens  int `koanf:"target_tokens"`
	OverlapTokens int `koanf:"overlap_tokens"`
}

ChunkingConfig configures deterministic chunk sizing.

type Config

type Config struct {
	Indexing  IndexingConfig  `koanf:"indexing"`
	Chunking  ChunkingConfig  `koanf:"chunking"`
	Search    SearchConfig    `koanf:"search"`
	Embedding EmbeddingConfig `koanf:"embedding"`
	MCP       MCPConfig       `koanf:"mcp"`
	Capture   CaptureConfig   `koanf:"capture"`
	Security  SecurityConfig  `koanf:"security"`
}

Config mirrors mnemos.toml. It is loaded by overlaying the file (if present) on top of built-in defaults, so a missing section or key always falls back to a sane value.

func Load

func Load(path string, fileExists func(string) bool) (*Config, error)

Load builds a Config from the embedded defaults, then overlays the single config file at path when it exists. A missing file is fine: the defaults stand on their own. A malformed file is an error. fileExists is the caller-supplied existence check so callers control filesystem semantics in tests.

func (*Config) ConfinementExclude

func (c *Config) ConfinementExclude() []string

ConfinementExclude returns the globs the write/delete confinement guard enforces on caller-supplied paths (remember custom path, forget, move, okfy). Unlike SecurityExclude it is NOT gated by exclude_secrets: these globs define paths a write/delete tool may never touch, a boundary that must hold regardless of whether secrets are also being kept out of the index.

func (*Config) EncodingRules added in v0.3.0

func (c *Config) EncodingRules() []EncodingRule

EncodingRules returns the declared legacy charset rules in config order, which is the precedence order the pipeline applies (first match wins).

func (*Config) HiddenCollections added in v0.3.0

func (c *Config) HiddenCollections() []string

HiddenCollections returns the collections hidden from every query surface (the security.visibility.deny list). Empty by default. The query layer excludes these collections server-side so hidden content never surfaces in search/context/read/list/task regardless of caller-supplied filters.

func (*Config) SecurityExclude

func (c *Config) SecurityExclude() []string

SecurityExclude returns the indexing-time secret-exclusion globs, gated by exclude_secrets: turning that off means "index everything", so the globs no longer remove matching files from the scan and an empty set is returned.

type EmbeddingConfig added in v0.3.0

type EmbeddingConfig struct {
	// Model is the model name, used both to locate ~/.mnemos/models/<name> and
	// as the identity persisted in embeddings.model. Changing it points mnemos
	// at a different model directory and labels new vectors accordingly; vectors
	// written under the previous name are not matched by semantic search until
	// they are reindexed. Empty falls back to embed.DefaultModel.
	Model string `koanf:"model"`
}

EmbeddingConfig selects which embedding model semantic search loads. It names the model only; the directory is still derived from the name by embed.ModelDir, keeping locations out of the config.

type EncodingRule added in v0.3.0

type EncodingRule struct {
	Match   []string `koanf:"match"`
	Charset string   `koanf:"charset"`
}

EncodingRule declares the charset of the files matching Match, so ingest decodes them to UTF-8 instead of rejecting them as binary. Match holds doublestar globs applied to the project-root-relative path, using the same matcher as [indexing].include; they select an encoding only and never widen discovery, so a matched file must still be covered by include to be ingested. Charset is any name or alias resolvable by golang.org/x/text's IANA index (e.g. "windows-1250", "cp1252", "ISO-8859-2") and is validated at config load. Rules are ordered and the first whose Match hits wins, so a narrower per-directory rule placed first overrides a broad per-extension one. A declared charset relaxes the UTF-8 requirement and nothing else: content holding a NUL byte is still skipped as binary.

type IndexingConfig

type IndexingConfig struct {
	Include []string `koanf:"include"`
	Exclude []string `koanf:"exclude"`
	// MaxFileBytes caps the size of a single file read into memory during
	// ingestion. A matched file larger than this is skipped with a warning
	// rather than read whole, which bounds memory under the parallel pipeline.
	// 0 (or negative) disables the cap.
	MaxFileBytes int64 `koanf:"max_file_bytes"`
	// Encoding declares the charset of legacy, non-UTF-8 source files so they are
	// decoded at ingest instead of skipped as binary. Empty (the default) keeps
	// ingest UTF-8-only. See EncodingRule.
	Encoding []EncodingRule `koanf:"encoding"`
}

IndexingConfig configures which files are discovered for ingestion.

type MCPConfig

type MCPConfig struct {
	AllowWrite bool `koanf:"allow_write"`
	// AllowDelete gates the destructive tree operations mnemos.forget and
	// mnemos.move (and their CLI counterparts). It is distinct from AllowWrite
	// so capture can be enabled without granting delete/move. Default false.
	AllowDelete bool `koanf:"allow_delete"`
	// ResultMode selects how tool responses are placed on the wire: "text"
	// (default) emits the JSON payload once as a text content block;
	// "structured" emits it once as structuredContent; "both" emits both (the
	// legacy double-emit, kept for clients that require structuredContent).
	// Validated at load time to one of those three values.
	ResultMode string `koanf:"result_mode"`
}

MCPConfig configures the MCP server surface.

type SearchConfig

type SearchConfig struct {
	DefaultLimit int  `koanf:"default_limit"`
	UseVectors   bool `koanf:"use_vectors"`
	// GraphExpansion enables link-neighbor expansion: when a query under-fills the
	// limit, the top hits' 1-hop link neighbors fill the remaining slots. Off by
	// default; it never reorders base results, so ranking cannot regress.
	GraphExpansion bool `koanf:"graph_expansion"`
	// GraphSeedDepth is how many top hits graph expansion pulls neighbors from
	// (0 = built-in default).
	GraphSeedDepth int `koanf:"graph_seed_depth"`
	// GraphDecay scales a seed's score for its injected neighbors, in (0,1]
	// (0 = built-in default).
	GraphDecay float64 `koanf:"graph_decay"`
	// TemporalWeight, in [0,1], is how much a document's age discounts its score.
	// Zero (the default) leaves ranking byte-identical to a build without recency,
	// so enabling the feature is always the caller's explicit choice.
	TemporalWeight float64 `koanf:"temporal_weight"`
	// TemporalHalflife is the age at which a document keeps half its recency
	// factor, as a Go duration string (e.g. "168h"). Empty uses the built-in
	// default. Ignored when TemporalWeight is 0.
	TemporalHalflife string `koanf:"temporal_halflife"`
}

SearchConfig configures retrieval defaults.

type SecurityConfig

type SecurityConfig struct {
	ExcludeSecrets bool             `koanf:"exclude_secrets"`
	Exclude        []string         `koanf:"exclude"`
	Visibility     VisibilityConfig `koanf:"visibility"`
	// Accept lists the scanner findings known not to be secrets
	// ([[security.accept]]). Each entry drops one finding shape at its paths,
	// never a whole file, and is validated at load by security.ValidateAccepts.
	Accept []security.Accept `koanf:"accept"`
}

SecurityConfig configures secret exclusion during ingestion and cross-scope query visibility.

type VisibilityConfig added in v0.3.0

type VisibilityConfig struct {
	Deny []string `koanf:"deny"`
}

VisibilityConfig lists collections hidden from every query surface. The deny list is enforced server-side in the query layer (search, context, list, task), not merely at display, so a hidden collection can never surface — even if a caller names it explicitly. Empty by default: nothing is hidden until configured, keeping a single-store KB fully visible out of the box.

Jump to

Keyboard shortcuts

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