Skip to main content

Module v1_blocks

Module v1_blocks 

Source
Expand description

One-time migration: per-block zones → per-agent zones.

Gated by the migration framework (db_migrations, via migrations::m0002_block_zones_v1), NOT by its own marker file — see migrate_block_zones_v1’s doc comment for what the marker is still for.

Structs§

MigrationStats
Stats from migrate_block_zones_v1. Logged at INFO at startup.

Constants§

MIGRATION_MARKER_V1
Marker file written under the data dir when the migration completes.

Functions§

agent_definition_id 🔒
The agent definition id a block carries, if it is an agent block with a valid one. Stored under agentId (current shape, set by agent.open + the frontend launch flow) or the legacy agent:id.
block_zones_look_incomplete
Read-only content check: is there an agent block whose per-block snapshot has bytes, while its agent’s :current zone is still empty? That is the state this migration exists to fix, so true means it has not (fully) run on this data — regardless of what any marker says.
existing_archive_snapshots 🔒
Every archive snapshot already stored for def_id, by bytes. Read once per definition so the dedupe below is O(archives) per agent, not per block. Enumerates zone ids directly rather than through list_archives, which caps at 100 rows and reads previews this has no use for.
migrate_block_zones_v1
One-shot migration of per-block agent session zones to per-agent zones. Content-idempotent: an archive is only written when no archive for that agent already holds the same bytes, and :current is only seeded when empty — so running twice (or over a data dir that a stale MIGRATION_MARKER_V1 wrongly calls done) writes nothing twice. The framework’s db_migrations row is the gate; the marker is written at the end as evidence only.