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§
- Community
Override - Community detection override.
- Config
Check Result - 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. - Mutation
Stamp - Engine-owned version stamp of the last successful mutation on a
mem — see
MemConfig::mutation_stamp. Both values are recorded at mutation time:engine_versionis the engine crate version the acting binary was built from,schemathe resolved<name>@<version>the mutation validated against (the resolved schema, not merely the pin — mid-migration mems stamp the target they validated against). - Publish
Config - Publish config.
- Published
MemConfig - Strict-ingress shape of a mem config. This is the only metadata
form that enters a
.memarchive.MemConfigcarries author-only fields (writeGuidance, rules, publish, readMems, language, community, defaultSchema, vcs, plus any key captured inextra) that never belong in a published archive;published_config_fromprojectsMemConfig→PublishedMemConfig, dropping everything outside the whitelist. - Read
MemSpec - One entry in
MemConfig.read_mems— a read-only sealed mem archive attached to the primary mem as reference material. - Role
Config - Role-based publish config.
- Schema
Ref - 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§
- Config
Error - Publish
Conversion Error - 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. - Read
MemSource - 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/holdsconfig.jsonandchanges.jsonl. Defined here (rather than inmemstead-base) because mem-config loading lives in this crate andmemstead-basedepends on it;memstead-basere-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
formatfield. Bumped to4for the mem title + subject block (both optional — a format-3 archive simply has neither). Readers accept3and4viapublished_format_accepted;format: 1(V1) andformat: 2(V2, top-levelschema/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) andformat: 2(V2, top-levelschema/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.
formatis pinned atPUBLISHED_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 seePUBLISHED_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.