monitor.session¶
Session framing for live monitor runs (spec 2026-07-12).
The collector stays session-blind: one process run == one live session, and the frame is stamped at the edges (CLI at launch, shutdown hook at exit).
-
class otto.monitor.session.SessionFrame(id: str, label: str | None, note: str | None, start: datetime, end: datetime | None =
None)¶ Bases:
objectIdentity + lifetime of one live monitoring session.
end is Nonemeans still-open — a crash never rewrites history, and readers fall back to the last sample’s timestamp (producer’s job).
-
otto.monitor.session.new_frame(label: str | None, note: str | None, *, now: datetime | None =
None) SessionFrame¶ Create a frame stamped at now (wall-clock UTC when omitted).
The id is the UTC start time as a filesystem/URL-safe slug — unique per database because two live runs can’t write one file (flock guard).
- otto.monitor.session.snapshot_lab(hosts: Sequence[RemoteHost], declared: list[Link]) LabSnapshot¶
Freeze the view-relevant lab config into a session snapshot.
Static links only (implicit hop edges + declared routes; contract spec 2026-07-10 §2) — dynamic/tunnel links are runtime state and never enter a snapshot. Credentials never leave the host object.
elementsstays empty: real labs declare membership per-host (elementfield) and the frontend derives the grouping, exactly as with generator fixtures.A link is exported only when both endpoints resolve to a host in this snapshot, mirroring the fixture generator’s
_implicit_links. That drops thelocaledgeimplicit_linksgives every hop-less host: the local root is the frontend’s own synthesized node (Plan 4 topology), never aRemoteHost, so alocalendpoint in the document would be a phantom. The same filter drops a declared link naming an unknown host.- Parameters:¶
hosts – Hosts to include, in the caller’s order.
declared – Already-resolved declared links (see
otto.link.derive.resolve_declared_links) — resolution against the active lab config is the CLI’s job, not this pure module’s.
- Returns:¶
The frozen
LabSnapshot.
- otto.monitor.session.snapshot_lab_json(hosts: Sequence[RemoteHost], declared: list[Link]) str¶
Build the same snapshot as
snapshot_lab(), serialized to JSON.