Skip to main content

Module workspace_config_edit

Module workspace_config_edit 

Source
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§

CrossLinkTarget
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> on grant-cross-link.
ScrubbedEntry
One scrubbed entry returned from scrub_policy_for_deleted_mem. The memstead_mem_delete response 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.
WorkspaceEditError
Errors returned by the writer.
WorkspaceEditWarning
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); before flags 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> — add to to the allowlist for from in [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 old in the workspace’s [cross_mem_links] table — as a granting key and inside named allowlist arrays — to new. The mem-rename counterpart of the grant/revoke pair: a pure key/value rewrite with none of their conflict semantics. A missing workspace.toml or 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> — remove to from the allowlist for from. 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.toml of the now-dangling [cross_mem_links] grants naming mem_name so 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_notes field. Creates the section on demand.
workspace_toml_path
Path of the workspace config file relative to the workspace root.