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.
MemSubject
The subject block of a mem — what it covers, by what method, and above all what was considered and deliberately left out. Exactly three members, by design: every additional slot invites the working-notes leakage this block exists to avoid, and three is what a recipient can actually read before deciding whether to trust the mem. Published verbatim in PublishedMemConfig; the engine never parses, links, or validates the prose.
MutationStamp
Engine-owned version stamp of the last successful mutation on a mem — see MemConfig::mutation_stamp. Both values are recorded at mutation time: engine_version is the engine crate version the acting binary was built from, schema the resolved <name>@<version> the mutation validated against (the resolved schema, not merely the pin — mid-migration mems stamp the target they validated against).
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_ANCHORS_PATH
Member path of the optional engine-owned anchors sidecar inside a sealed archive (the E3a provenance-anchor payload). Additive: archives with no anchors omit it. Recognised as a first-class member so the canonical re-pack threads it through verbatim rather than silently stripping it (a recognised-but-malformed member is a typed validation failure, unlike unknown future meta members which stay tolerate-and-ignore).
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 4 for the mem title + subject block (both optional — a format-3 archive simply has neither). Readers accept 3 and 4 via published_format_accepted; format: 1 (V1) and format: 2 (V2, top-level schema/ tree) archives keep refusing cleanly.
PUBLISHED_MEM_FORMATS_ACCEPTED
Every archive format a current reader accepts, newest first: the current integer plus format 3 (the pre-title/subject shape — the two mems already published on the live registry stay installable without a re-publish). format: 1 (V1) and format: 2 (V2, top-level schema/ tree) keep refusing cleanly.

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.
published_format_accepted
Does a reader updated for the current format accept an archive at format? The single predicate every reader gate that checks at all consults, so acceptance cannot drift between them — but see PUBLISHED_MEM_FORMATS_ACCEPTED: the archive-hydration path does not check, so “every reader” overstates today’s reach.
update_config_field
Update a top-level config field.