Skip to main content

Module mem_sweep

Module mem_sweep 

Source
Expand description

Mem-rename content sweep — the referrer-rewrite half of memstead mem rename.

Entity ids are derived from (mount name, file path), so renaming a mount re-ids every entity in it for free; what the rename must rewrite by hand is every textual <old>--<slug> / <old>:<slug> reference across the workspace — cross-mem wiki-links and ## Relationships entries in peer mems, full-id self-references in the renamed mem itself, and the renamed mem’s anchors-sidecar keys.

The sweep is a raw-text pass over each entity file ([crate::entity::wikilink_rewrite::rewrite_mem_prefix], sharing the parser’s code-masking discipline) rather than a parse → mutate → regenerate round-trip: formatting outside the rewritten links stays byte-identical, and both link surfaces (bodies and the ## Relationships section) are covered by the one pass because both are wiki-links.

One commit per affected mem, every commit tagged with a shared logical_operation_id. Peer commits are parent-pinned (commit_with_expected_parent) so a concurrent sibling writer surfaces as EngineError::RenamePartialFailure rather than a silent overwrite. Read-only mounts cannot be rewritten — their stale references degrade to load-time stubs, which health surfaces.

The sweep deliberately does NOT maintain the in-memory store — the orchestrator (memstead_engine::rename_mem) reloads the engine after the storage-identity flip, and everything between the sweep and that reload happens inside one engine call.

Structs§

MemSweepOutcome
Outcome of Engine::rewrite_mem_references.