fn collapse_and_reindex(
identity_conn: &Connection,
channel_mstore: Option<&Store>,
) -> Result<usize, String>Expand description
Collapse every group of global db_skills rows sharing a name (however
large) to the earliest-created_at row (ties broken by id, for
determinism), rewriting channel_mstore’s own ref rows (if given) and
deleting the loser(s) from identity_conn’s db_skills — then swaps the
uniqueness index. Returns the number of rows collapsed away.
Takes explicit connections/stores rather than resolving paths itself so
it can be exercised directly in tests without depending on
registry::resolve_identity_store_path’s env-var-driven resolution (the
same reason m0031’s carry_skills/carry_mcp_servers take explicit
Store params instead of opening their own).