Skip to main content

Module episodes

Module episodes 

Source
Expand description

The episodes module: the execution episode of a client that has no provider hooks, opened and closed by the MCP connection itself (ADR 0103).

Three capabilities, and the shape of them is the argument. attach is what a client calls to say this connection is carrying this piece of work, naming the work with its own durable identity; detach is what it calls when the work is done; list is what anybody reads. initialize is not on that list, deliberately: a connection that never attaches holds no episode and writes nothing, so a client that merely wants to read the repository’s AI layer is a peer and never becomes a worker with a record. That is also what keeps test/cases/90_mcp_shared_server.sh true — serving changes the repository not at all — while an episode still opens for the client that asks for one.

Everything after attach is automatic and needs no cooperation: the client’s own traffic is the heartbeat, losing the connection detaches rather than closes, and coming back under the same identity resumes. See crate::episodes for why a peer id cannot be that identity.

use majordomus_cli::capability::builtin::episodes;
let m = episodes::module();
let ids: Vec<&str> = m.capabilities.iter().map(|e| e.capability.id.as_str()).collect();
assert_eq!(ids, ["episodes.list", "episodes.attach", "episodes.detach"]);
// only the listing reads; attaching and detaching are commands with an effect
let reads: Vec<bool> = m.capabilities.iter().map(|e| e.capability.kind.is_read_only()).collect();
assert_eq!(reads, [true, false, false]);

Structs§

AttachInput
The input of episodes.attach: which piece of work this connection is carrying.
Attached
The answer of episodes.attach: the episode the connection now holds, whether it was resumed rather than opened, and how long it outlives a lost connection.
DetachInput
The input of episodes.detach: the episode to close.
Detached
The answer of episodes.detach: the episode as it was closed, no longer held by any connection, with what the repository’s end event reported.
EpisodeList
The answer of episodes.list: every episode this server holds, counted by state, and the one the caller holds. In memory only — it is the association between live connections and the repository’s records, which stops being true when the process stops.

Constants§

CONNECTION_PROVIDER
The provider an episode drawn by a connection is recorded under.

Functions§

module
The module the registry composes: one read and two commands, each declared once here and projected to HTTP and MCP; none to the command line, since a command-line call has no connection to hold an episode.