Skip to main content

resume_gate

Function resume_gate 

Source
pub(crate) fn resume_gate(
    input: &GateInput<'_>,
    size_here: impl Fn(&str) -> Option<u64>,
    resumable_at: impl Fn(&str, &str, &str) -> bool,
) -> ResumeGate
Expand description

Only the chain head is resumed natively (spec §3 I1), and never across identities (I2). input.head is the agent’s chain_head; None (an agent from before the segment index, or no readable chain) allows the candidate, as before the gate existed. A head equal to the poisoned id allows too: that head is known dead, so the chain has nothing better to offer than the candidate. The identity check refuses only when both sides are known and differ. A head recorded under the spawn’s own config dir whose file isn’t there is refused too: the provider never wrote it.

size_here(sid): the size of the session’s file under the spawn’s config dir and cwd, None when it isn’t there. resumable_at(config_dir, cwd, sid): a session file for that working dir exists under that config dir with a complete record to copy (§4.3; its last record may still be being written, and the copy is cut back to a complete one).