Skip to main content

Module conversation

Module conversation 

Source
Expand description

One seat’s conversation, held by the transport and kept up to date.

The read is what costs. Measured on a 68.9 MB transcript (13,451 messages), one request spends 202 ms reading and parsing the file, 18 ms folding it into turns and 20 ms encoding those turns - so a fix caching only the fold removes 8% of the cost it was written for. The transport holds the read’s own output and shares it: a page slices a window out of it, and a subscribe encodes the newest of it.

A seat’s history has two sources, and the seed never overwrites the stream’s. The first is the session task, which produces the conversation: the fold sees Connected for every seat that starts or resumes while the transport runs, so the frames and the copy they build have one producer and one order.

The second is the seat’s own transcript, read when the transport holds nothing and a page opens on it - a sleeping seat has no live copy, and waiting for the spawn that would carry the same history back is the wait this exists to remove (transport::wire::seed_from_transcript). It only ever inserts: a copy the stream inserted while the file was being read is kept, and a copy of another occupant is waited for rather than replaced. A transcript is a row subset - it carries no Result frames - so a seed over a live copy would drop frames the stream had already delivered.

That is what makes a buffer unnecessary rather than merely deleted. A frame emitted before a seat is held finds no conversation and is dropped - the precondition is that the fold is attached before the first Connected, which the transport’s own test asserts. A frame emitted after is applied to what the seed left.

What is released is the front, and no more of it than the cap. A page cursor names a message in the conversation’s own numbering rather than in the held list’s, so a cursor a drop has passed is answered as what it is - the floor, with nothing above it - rather than as a window the client did not ask for. The seat’s copy is therefore kept for the seat’s life, and what that costs is bounded by the cap below rather than by the transcript.

Re-exports§

use std::collections::HashMap; 🔒
use std::sync::Arc; 🔒
use std::sync::Condvar; 🔒
use std::sync::Mutex; 🔒
use std::sync::PoisonError; 🔒
use forge_primitives::Message; 🔒
use forge_primitives::SessionSlot; 🔒
use forge_workspace::conversation_turns::TurnScan; 🔒
use forge_workspace::conversation_turns::opens_for_debt; 🔒
use forge_workspace::conversation_window::Window; 🔒
use forge_workspace::TurnLiveness; 🔒
use forge_workspace::liveness_of; 🔒
use crate::SessionUpdate; 🔒
use crate::transcript::Rendered; 🔒

Structs§

Conversation
One seat’s conversation: the messages, where its turns sit and how many times it has compacted.
Conversations
The conversations the transport is holding, one per seat it has heard of.
Folding 🔒
The messages a fold has taken out, and the promise that they go back.
Held
One seat’s conversation, and the fold that may be running over it.
SeedHold
Where a held transcript seed parks.

Functions§

as_blocks 🔒
A history as the CLI wrote it, with its task notices in the shape a view reads an ending from.
frame_id 🔒
The id a frame carries, for the frames that carry one.
live_of_seed 🔒
The delivered ladder folded over a seed’s own frames: the last frame that says anything about the turn wins, the way every frame appended later folds in (see Conversation::live).