Module registry_mirror

Module registry_mirror 

Source
Expand description

Cross-version named-agent registry mirror.

Mirrors db_agent_instances mutations into the JSON registry at ~/.agentmux/agents/registry/ so other AgentMux versions running on the same machine see each other’s named agents in their launch modal dropdowns. SQLite is authoritative for the local version; the registry is a best-effort cross-version view.

Extracted from store.rs in Phase R.6 of the storage modularization plan (docs/specs/SPEC_STORE_MODULARIZATION_2026_05_27.md). This whole file retires when Phase R sunsets the JSON registry entirely; isolating it now makes that future deletion a clean unit.

Functions§

agent_instance_to_record 🔒
Build a registry record from an AgentInstance. Returns an error if the working directory can’t be expressed as a path relative to the canonical shared agents root (e.g. user pointed an agent at ~/projects/foo, which would also fail a naive "agents" segment-scan that happened to match ~/projects/agents/foo). Caller logs + skips — agent stays in SQLite, just not in the cross-version dropdown.
empty_to_none 🔒
relative_workdir 🔒
Express abs as a path relative to agents_root. Returns None when abs is empty, not under agents_root, or after stripping resolves to an empty path. Anchors against the resolved shared root (passed in by the caller) — never scans for a path segment named “agents”, which would match unrelated user directories like /home/me/projects/agents/foo.