Skip to main content

Module config

Module config 

Source
Expand description

Mem configuration loading, validation, and top-level CRUD.

Handles .memstead/config.json parsing, cross-field validation, and the update_config_field write helper. Projections/mediums, their validators, and the pre-rework migration have been dropped by the workspace rewrite — projections / mediums survive as unknown keys captured into MemConfig.extra so legacy configs still round-trip, but the engine does not interpret them.

Port of @memstead/config (config-contract.js, index.js) and @agent-adapters/config-mcp (workspace.js).

Structs§

CommunityOverride
Community detection override.
ConfigCheckResult
Result of config validation — errors are fatal, warnings are informational.
MemConfig
Full mem configuration loaded from .memstead/config.json.
PublishConfig
Publish config.
PublishedMemConfig
Strict-ingress shape of a mem config. This is the only metadata form that enters a .mem archive. MemConfig carries author-only fields (writeGuidance, rules, publish, readMems, language, community, defaultSchema, vcs, plus any key captured in extra) that never belong in a published archive; published_config_from projects MemConfigPublishedMemConfig, dropping everything outside the whitelist.
ReadMemSpec
One entry in MemConfig.read_mems — a read-only sealed mem archive attached to the primary mem as reference material.
RoleConfig
Role-based publish config.
SchemaRef
Reference to a schema by exact name and version — name@x.y.z.
VcsConfig
VCS layout for a writable mem — optional { gitdir, worktree } pair in .memstead/config.json. When absent, the engine resolves the default: .git/ at mem root with . as worktree.

Enums§

ConfigError
PublishConversionError
Errors returned by published_config_from. Actionable messages — the caller (export pipeline, publish pipeline) surfaces these directly to the user without wrapping a raw serde error.
ReadMemSource
How the app reconstitutes a read mem’s cache file when missing.

Constants§

ARCHIVE_CONFIG_PATH
Member path of the published config inside a sealed archive.
ARCHIVE_EXTENSION
File extension (without dot) of a sealed archive — the sole spelling. The one deliberately-distinct token in a project that is otherwise “memstead” everywhere — short, and derived from the project name.
ARCHIVE_META_DIR
In-zip meta directory of a sealed archive — the only spelling.
ARCHIVE_PROVENANCE_PATH
Member path of the optional authoring-provenance payload inside a sealed archive (see crate::archive_provenance). Additive: archives predating provenance omit it, and an engine that does not recognise it tolerates it as an unknown meta member.
ARCHIVE_SCHEMA_PREFIX
Member-path prefix of the embedded schema tree (manifest at <prefix>schema.yaml, type files under <prefix>types/).
MEM_META_DIR
The per-mem engine-internal directory under a folder mem’s root — <mem_root>/.memstead/ holds config.json and changes.jsonl. Defined here (rather than in memstead-base) because mem-config loading lives in this crate and memstead-base depends on it; memstead-base re-exports the constant for downstream consumers. Distinct from the workspace store directory (memstead_base::WORKSPACE_STORE_DIR) and from the in-zip member paths inside sealed archives (ARCHIVE_META_DIR), which are a separate on-disk format and never use this constant.
PUBLISHED_MEM_FORMAT
Archive format integer written to the archive config’s format field. Bumped to 3 for the schema-path relocation (embedded schema moved from top-level schema/ to the meta-dir schema tree). format: 1 (V1) and format: 2 (V2, top-level schema/ tree) archives are rejected cleanly (pre-release, no external users to migrate).

Functions§

check_config
Validate a raw config JSON value. Returns structured errors and warnings.
load_and_validate
Load, validate, and parse a mem config from disk.
load_config
Load and parse a config from a mem directory. Reads <mem_dir>/.memstead/config.json.
parse_mem_config
Parse a raw JSON value into a MemConfig.
published_config_from
The whitelist projection. Everything author-only is discarded; only the fields that make sense outside the author’s working directory ride into the archive. format is pinned at PUBLISHED_MEM_FORMAT.
update_config_field
Update a top-level config field.