Skip to main content

Module continuity_segments

Module continuity_segments 

Source
Expand description

Segment index (SPEC_DURABLE_CONVERSATION_MEMORY_2026_09_23.md §4.1, P1): one record per provider session an agent has run, so “this agent’s conversation” is a chain AgentMux owns rather than whatever session id a pane happens to hold.

Stored as an append-only event log, segments.jsonl in the global transcript store’s agent-uid:<uid>:segments zone, not as a SQL table (§4.1.1): that store is shared by every srv on the machine and takes additions without a schema version bump, where a new table in identity-store.db would bump its version and lock older builds out of it (check_schema_compat). Events: start at spawn, session when a fresh process reports its provider session id, end when the process goes away. segments folds them back into one row per segment.

The zone is keyed by the agent’s UID (AGENTMUX_AGENT_UID), not its definition id: a template launch shares the template’s transcript zone but is a different agent. It is deliberately not the transcript zone, so “New conversation” (which clears agent:<defId>:current) never erases the chain; a new conversation is just a segment whose rung is fresh.

Structs§

Head
Where the agent’s conversation was last: the newest segment that has a provider session, and what that segment recorded about it.
Segment
One segment, folded from its events.
Start
What is known about a segment when its process starts.

Enums§

Rung
How a segment began (§4.2’s rungs; relocated arrives with P4).

Functions§

chain_head
Where the agent’s conversation was last, read from its chain in fs. None when the UID has no chain.
fork_source_head
The chain head of the agent agent_uid was forked from (its definition has a branch_label and a parent_id): what a fork with no conversation of its own starts from (ResumeGate::ForkFrom). Shared by the spawn’s gate and the pane’s resume preflight.
record_start
Records a segment’s start and returns its id. start.segment_id and start.predecessor_segment_id are filled in here.
rung_for_spawn
The rung a spawn started on, from what the spawn knows: whether it passed --resume, and whether it carries a continuation packet.
segments
Every segment the agent has run, oldest first. A segment with no end is running, or its srv died before it could record one.
with_legacy_identity
A head whose segment predates identity_key (recorded by a build before #3839) takes the identity from its own config dir’s .claude.json, so an agent’s first upgrade from such a build can still relocate (spec §4.1). That file names whoever is signed in there now, which for an account’s own dir is the login the session ran under unless the dir was since re-logged-into as someone else; a recorded key always wins. Unreadable (the dir is gone) stays unknown, which never relocates.
zone_for
agent-uid:<uid>:segments, or None for a UID outside the safe zone-name character set.