Skip to main content

Module m0027_agents_workspace_backfill

Module m0027_agents_workspace_backfill 

Source
Expand description

Backfill db_agents.working_directory with the workspace each agent actually ran in, taken from its latest legacy db_agent_instances launch.

Agent-concept consolidation, Phase 3b (SPEC_AGENT_ARCHITECTURE_2026_05_27.md). Phase 3a’s dual-write stored the DEFINITION’s configured cwd on the consolidated row, on the reasoning that “db_agents holds durable agent config; the per-launch resolved cwd lives on the block”. The launch row held the real one — agent.open resolves it, including slug-collision suffixing — so on an upgraded store the two disagree for every agent whose workspace was suffixed or overridden.

That disagreement was harmless while readers still joined db_agent_instances. It stops being harmless the moment they don’t (Phase 3b PR 2, this release): continuing such an agent would open the template’s default directory instead of the workspace holding its files, and the cross-version JSON registry mirror silently skips any row whose working_directory is not under the agents root. Codex P1 on #3080.

Why a separate migration rather than a wider m0025: 0025 shipped in v0.55.39 and is already applied on upgraded installs, so amending it would fix nobody who most needs it. This runs for everyone, whether or not 0025 ran.

Rule: for each projection key (the db_agents row an instance chain maps to) take the most recently created instance in the chain and copy its non-empty working_directory onto the row. Frozen copy of the same v29 projection rule m0025 uses — deliberately a copy, per that module’s “freeze copies of live logic” policy: the live helper is deleted when the legacy table is dropped, and this must keep producing the same result on every machine it ever runs on.

Tolerates a store that has already dropped db_agent_instances (Phase 3c): nothing to backfill, Ok.

Structs§

LegacyLaunch 🔒
The legacy instance columns this backfill reads.
M0027AgentsWorkspaceBackfill
WorkspaceStats 🔒
Rows whose workspace was corrected.

Functions§

backfill_workspaces 🔒
projection_key 🔒
Frozen copy of the v29 projection rule (see m0025’s own copy): walk parent_instance_id to the chain root; if the root’s definition is a user clone (is_seeded = 0) the key is that definition’s id, otherwise it is the root launch’s own id. A missing definition counts as seeded.