Skip to main content

Module session

Module session 

Source
Expand description

What the envelope needs to know about a harness’s session.

The envelope’s job is to turn a resolved session identity into the X-Tapes-* header set. To do that it needs six things — a harness id, a session id, and four optional fields — and it needs them from every harness, present and future.

Before this trait it got them by naming one: the producer imported Claude’s session-file struct and read its fields directly. That is what made the envelope un-shareable. It sat in the crate that declares harnesses, so adding a harness could change it, and the harness registry could not take its ids from the envelope without the two crates depending on each other.

HarnessSession states the requirement instead of importing a supplier of it. A harness crate implements it for whatever shape it already parses — a foreign trait on a local type, which is always allowed — and the envelope constructs from &impl HarnessSession, naming nobody. The next harness implements the same trait without a line changing here.

§Absence is a first-class answer

Every field but the two required ones defaults to “this harness has no such thing”. A harness that never names a session, or ships no version string, implements nothing extra and the corresponding header is simply omitted — which is the envelope’s existing meaning for an absent optional (see X-Tapes-* field docs: absent and empty stay distinguishable downstream). Nothing is ever filled with a placeholder to satisfy the shape.

Traits§

HarnessSession
A harness session, as the envelope producer sees it.