Expand description
agent:open_tail: an agent pane’s first screen from one small read.
The open-first-screen design (#5156), under #5141.
The pane used to open with three or four calls (the snapshot, the line
count, a range of up to 10,000 lines) before it showed anything, and those
could write under the store’s single write lock: extending output.idx,
catching the line counter up, a stat on a cache miss. This returns the
newest ~64 KB of the transcript, the line positions the live feed resumes
from, and the snapshot overlay, from one reader snapshot: it takes the
WAL reader pool only, never the writer mutex, and never writes or extends
an index.
Line positions come from the line counter, caught up in memory when the
file has grown past it (SnapshotReader::tail_state). A transcript with no
usable counter epoch is counted first (transcript::counting, one scan at a
time per file, off this read’s snapshot): a small one is counted within the
call, a large one answers counting and the pane asks again. Without that
the pane’s usual open could not read it either: output.idx is never
fresh for a file with no generation. A transcript whose newest line fits no
window comes back without line positions and the pane opens the usual way.
Structs§
- Slice 🔒
Enums§
- Read 🔒
- What one pass over the reader snapshot found.
Constants§
- COUNT_
WAIT 🔒 - How long a call waits for a transcript with no epoch to be counted before it answers “counting” (the pane’s call times out at 5 s). A small file is counted well inside it.
- DEFAULT_
TAIL_ 🔒BYTES - A first screen: about what fits one pane, plus a margin.
- MAX_
CATCH_ 🔒UP_ BYTES - The most a counter that is only behind is caught up by in memory.
- MAX_
WINDOW_ 🔒BYTES - The most a tail read grows to when the newest line is larger than the window.
- RESTORE_
BUDGET_ 🔒BYTES - The most a slice is extended back to reach a turn start, and the most
tail_bytesasks for: the pane’s restore size today.
Functions§
- open_
tail 🔒 - open_
tail_ 🔒waiting - [
open_tail], waiting up tocount_waitfor a transcript with no epoch to be counted. - pick_
source 🔒 - Which store and zone a block’s transcript is read from: the same rule
blockfile:read_rangeandblockfile:line_countuse (global_output_source: the agent’s global zone when the block has a validagentId, is not archived and the zone has content, the block’s own otherwise), so the first screen and the older pages the pane reads next come from one file. Decided here from a reader snapshot rather thanstat, which takes the writer mutex on a cache miss. - read_
overlay 🔒 - The agent’s session snapshot, from reader snapshots: the global store first
(it always holds the agent-anchored copy), the block’s store as a fallback,
as
agent:session:readdoes. - read_
slice 🔒 - read_
stamps 🔒 - Receive-time stamps for lines starting at
offsets(ascending byte offsets), fromoutput.tsidxin this snapshot: the same lookupblockfile:read_rangeuses (stamps_for), which finds the records around the range wherever they are in the sidecar.Nonewithout a sidecar or records near the range. - read_
window 🔒 - The newest
wantbytes (the newest line always) of the complete lines in[0, complete_end), with the non-blank lines in them and each one’s byte offset.Nonewhen the bytes aren’t all stored or the newest line is larger thanMAX_WINDOW_BYTES. - register
- trim_
window 🔒 windowtrimmed by the rulesblockfile:read_rangeuses (tail_turns, thentail_bytes), with its receive-time stamps.