Skip to main content

Module transcript_backfill

Module transcript_backfill 

Source
Expand description

Put an agent’s CONVERSATION back into the GLOBAL transcript store from the copies that live in the channels it ran in (restore_damaged, after a repair of the shared store).

Cross-channel transcripts mirror agent output into the global agent:<defId>:current zone, but the channel the agent ran in keeps its own copy. This scans every channel/dev objects.db for blocks belonging to each agent definition, reads the richest output from that channel’s filestore.db, and seeds the global zone with it.

Source = the channel block’s output, NOT the provider .jsonl. The block output is the exact stdout stream-json the renderer already parses (parseHistoryLines + the claude-stream-json translator); the provider ~/.claude/projects/<slug>/<sid>.jsonl transcript is a different envelope (queue-operation / user+parentUuid/sessionId) the renderer can’t consume, so copying it would render empty. Using the block output needs zero translation.

The seeded snapshot overlay uses sourceBlockId: "", which the frontend treats as “matches any block” — so opening the agent (a fresh local block with no local output) takes the v2 fast-path and the blockfile:read_range global fallback (#1399) serves the restored zone.

Read-only on every scanned SQLite (the global store is the only thing written).

Structs§

RestoreStats
What restore_damaged did.

Functions§

restore_damaged
After a repair of the shared store (filestore::repair): put back the conversation of each agent whose zone in zones lost rows, from the richest whole copy of it in a channel’s own store. A copy that is shorter than the size the zone records is not used: the shared zone also holds conversation from other channels and builds. Best-effort, never fatal.