Custody of a session's record: locate it, read its conversation entries (main thread and sub-agent sidechains), and mirror the whole tree into an archive directory.
Every locate and read resolves the session vendor-first, falling back to the archive mirror once the vendor tree has been pruned; the located record's root names which one won. Locating encodes a known cwd into a project directory — never decodes a directory name, which is ambiguous — and looks for that directory under the vendor projects tree first, then under the mirror. The record is a tree (the main .jsonl plus the sub-agent .jsonl and .meta.json sidechains), so the mirror copies the tree, not a single file. Entry reads tolerate vendor drift by degrading unrecognized lines to raw entries rather than losing them.
Type parameters
F
the effect type; the abstract EntryStream lets each backend pick its own streaming type.
Reads the page of up to limit entries immediately older than token.
Reads the page of up to limit entries immediately older than token.
The token is pinned to the transcript it was minted against; if the session now resolves to a different file (the vendor tree was pruned between pages), this fails with ArchiveError.PageSourceMoved rather than reading a stale offset against the wrong file. If the session no longer resolves under either root at all, this fails with ArchiveError.SessionNotFound.
Locates a session by encoding the configured cwd, resolving the live vendor tree first and falling back to the archive mirror; None when no main transcript exists under either root. The returned record's root names which one won.
Locates a session by encoding the configured cwd, resolving the live vendor tree first and falling back to the archive mirror; None when no main transcript exists under either root. The returned record's root names which one won.
Reads the last limit main-thread entries of a session without parsing the transcript from the start. Entries within the returned page are oldest-first; the page itself is the newest slice of the transcript. The page's older cursor pages backward through earlier, older pages. Resolves vendor-then-mirror like forSession, so a pruned session still tails from the mirror.
Reads the last limit main-thread entries of a session without parsing the transcript from the start. Entries within the returned page are oldest-first; the page itself is the newest slice of the transcript. The page's older cursor pages backward through earlier, older pages. Resolves vendor-then-mirror like forSession, so a pruned session still tails from the mirror.
Idempotently mirrors the whole session tree into the archive directory, reporting what was copied, extended, refreshed, and skipped.
Idempotently mirrors the whole session tree into the archive directory, reporting what was copied, extended, refreshed, and skipped.
Custody is one-directional: when the session resolves under works.iterative.claude.core.log.model.RecordRoot.Archive (the vendor tree is already pruned), this is a no-op returning works.iterative.claude.core.log.model.MirrorReport.empty — the archive is never truncated or recopied from nothing. Only a Vendor-resolved record is ever a mirror source. SessionNotFound is raised only when neither root holds the session.
Streams a sub-agent's own sidechain entries, joined to its parent by the tool_use id recorded in the sub-agent's .meta.json. Resolves vendor-then-mirror like forSession.
Streams a sub-agent's own sidechain entries, joined to its parent by the tool_use id recorded in the sub-agent's .meta.json. Resolves vendor-then-mirror like forSession.