pub(crate) fn backfill_newly_verified(
id_store: &Store,
targets: &[(String, PathBuf)],
known: &mut HashSet<String>,
) -> usizeExpand description
Give every verified agent’s memory file with no recorded version its
first one, labelled agent_inferred (“Agent” in Memory), before the
drift detector starts. Otherwise the detector finds these ordinary files
on its first sweep and records them as external_fs_write, “Detected
outside AgentMux”, as it did for every file after a new local-build
channel (SPEC_MEMORY_FOLLOWS_THE_AGENT_2026_09_24.md §1.3, phase M1).
Covers only files that predate tracking: those already in the directory at the moment it is first verified — at startup (after the identity stores are attached, so an agent’s account-linked directory resolves; this used to be migration m0024, which ran before that and fell back to a registry guess), or later for an agent verified mid-session.
Anything written after that is a change, and drift detection records it exactly as it records every direct write to the folder today — including Claude’s own auto-memory writes, which never go through AgentMux. So an agent whose folder doesn’t exist yet is still counted as seen: its first files are written after verification, like every later one. Pre-existing files raise no fs-watch event, so the fast path can’t race this. Returns the number of versions recorded.