Expand description
toml_edit-backed writer for .memstead/workspace.toml.
Backs the memstead workspace allow-create / revoke-create / allow-delete / revoke-delete / grant-cross-link / revoke-cross-link / set-mutations
subcommand family. Every operation is a load → mutate → write triple;
toml_edit preserves operator-authored comments and formatting on
sections the CLI doesn’t touch (cross-mem forward-reference
rationale, ingest-namespace pairings, operator-mode bypass semantics,
pattern-grammar examples).
Errors carry symbolic codes (WORKSPACE_NOT_INITIALISED,
RULE_ALREADY_EXISTS, RULE_NOT_FOUND, BEFORE_PATTERN_NOT_FOUND,
CROSS_LINK_ALREADY_GRANTED, CROSS_LINK_NOT_GRANTED,
CROSS_LINK_CONFLICT, INVALID_TOML) so the CLI’s typed exit envelope
lifts them as code in the --json payload. The CLI layer maps the
enum variants onto CliError / ExitKind.
Enums§
- Cross
Link Target - Either-or shape mirroring
[cross_mem_links]semantics on disk:<from> = "*"(wildcard) or<from> = ["a", "b"](allowlist). The CLI exposes both via--target *and--target <name>ongrant-cross-link. - Scrubbed
Entry - One scrubbed entry returned from
scrub_policy_for_deleted_mem. Thememstead_mem_deleteresponse surfaces these so an agent sees every policy side effect in one round-trip. Only dangling[cross_mem_links]grants are scrubbed; the[[mem_management.*]]allowlist rules are preserved, so this enum carries the one scrubbed shape. - Workspace
Edit Error - Errors returned by the writer.
- Workspace
Edit Warning - Idempotency notices emitted by the writer when a call lands on a state the caller intended (re-grant of an existing grant, re-revoke of an absent grant, etc.). Surfacing these as warnings rather than errors lets agents and scripts retry without branching on prior state.
Functions§
- add_
create_ rule memstead workspace allow-create <pattern> --schema <pin>[,…] [--cross-link …] [--before <pattern>]— append a[[mem_management.create]]rule. Default ordering is append (lowest priority);beforeflags lift it above the named pattern.- add_
delete_ rule memstead workspace allow-delete <pattern>— append a[[mem_management.delete]]rule.- grant_
cross_ link memstead workspace grant-cross-link <from> <to>— addtoto the allowlist forfromin[cross_mem_links].to == "*"sets the wildcard shape; named targets accumulate into a list.- remove_
create_ rule memstead workspace revoke-create <pattern>— remove a[[mem_management.create]]rule by pattern.- remove_
delete_ rule memstead workspace revoke-delete <pattern>— remove a[[mem_management.delete]]rule by pattern.- rename_
mem_ in_ cross_ links - Rename every occurrence of mem
oldin the workspace’s[cross_mem_links]table — as a granting key and inside named allowlist arrays — tonew. The mem-rename counterpart of the grant/revoke pair: a pure key/value rewrite with none of their conflict semantics. A missingworkspace.tomlor absent[cross_mem_links]table is a no-op (nothing names the mem). Returns whether anything changed on disk. - revoke_
cross_ link memstead workspace revoke-cross-link <from> <to>— removetofrom the allowlist forfrom. When the underlying list becomes empty, the<from>key is dropped entirely;*is matched as a literal.- scrub_
policy_ for_ deleted_ mem - Scrub
.memstead/workspace.tomlof the now-dangling[cross_mem_links]grants namingmem_nameso the workspace no longer references a mem the engine just destructively deleted. The[[mem_management.create]]/[[mem_management.delete]]allowlist rules are deliberately left intact. - set_
mutation_ require_ notes memstead workspace set-mutations --require-notes <bool>— set the[mutations] require_notesfield. Creates the section on demand.- workspace_
toml_ path - Path of the workspace config file relative to the workspace root.