Skip to main content

Module append

Module append 

Source
Expand description

Writing an agent’s transcript: the line appends to the block’s output and the agent’s global zone, the order lock that keeps one block’s events in line order, and the announcements of a replaced or deleted transcript.

These lived in blockcontroller/shell/file_ops.rs next to the terminal output path, which made the store-lock warnings (site=) and a reader’s search for “where does a transcript get written” point at the terminal code. Terminal output (handle_append_block_file for term) stays in shell/.

Functions§

append_agent_output_line
append_output_line for a line an agent’s process wrote: besides an echo’s origin, it is stored with which runtime wrote it (origin_sig::stamp_writer), so a reader decides what the message may name by who wrote it.
append_output_line
Appends one NDJSON stdout line, plus the newline the frontend’s line splitter needs, to the block’s output file and global_output_zone.
persist_injected_user_line
persist_user_line for a message no pane typed (a jekt, a broadcast, a schedule, the app API): the record is published as a plain one, which an open pane shows, because no agent-message-accepted node stands for it.
persist_user_line
Persist a user message the controller wrote to the agent’s stdin, so parseHistoryLines can reconstruct its user_message node on reopen.
publish_transcript_changed
Tell a block’s panes that its transcript output was replaced or deleted as a whole (Phase 5a-3), so an open pane resyncs at once instead of on its next read. fileop is mps::FILE_OP_REPLACE — with the new generation and line count read from filestore — or mps::FILE_OP_DELETE. Call it, with the replace or delete itself, inside with_transcript_order.
resolve_global_output_zone
Resolve a block’s GLOBAL transcript zone (agent:<defId>:current) from its agentId meta, looking the block up in mstore. Returns None for non-agent blocks, when there’s no store, or when the block can’t be loaded — the caller then passes None and no global mirror happens. Shared by the subprocess / persistent / acp agent controllers.
with_transcript_order
Run f holding block_id’s transcript order lock — the lock every append holds from its first write to its publish (see [append_transcript]). A replace or delete of the block’s transcript, and its announcement (publish_transcript_changed), run inside it, so no append’s write and event can interleave with them and one block’s events stay in order (review of #3636). f must not append to the same block: the lock isn’t reentrant.