Skip to main content

Module session_ref

Module session_ref 

Source
Expand description

V9 session_ref: the session a write names, and whether the enrolled Cloud may hear it.

An older Cloud refuses the closed event envelope and receipt document with the member, and a refused signed event or receipt batch is moved to outbox/failed for good. So the engine reads GET /v1/capabilities (cached per server in <config>/capabilities.json, refreshed with the instance card) and attaches a session only while that server announces the session_ref feature.

What leaves is never the session id: it is an HMAC-SHA256 under the engine-local receipts key (receipts.hmac-key, never uploaded), so Cloud cannot test a guessed id (session ids carry a timestamp and a process id and are guessable). Events name only sessions this engine generated (lean_ctx::core::session::is_engine_session_id); labels such as an import never become a session.

The older body field session_ref (ses_ and 24 hex characters) of drafts, task claims, task proposals and episodes needs no capability: its shape is unchanged. It is keyed the same way (uploaded_ses_ref); when the local key cannot be read or created, the write is not uploaded at all, so no unsalted digest of a guessable session id leaves the machine.

Structs§

SessionRefs
Keyed session refs, present only while the enrolled Cloud accepts them.

Constants§

EVENT_REF_PREFIX
Prefix of the envelope ref: hs_ and 32 lowercase hex characters, the first half of the receipt’s hmac-sha256: value for the same input.
FEATURE_SESSION_REF
The features entry of a Cloud that accepts session_ref (cloud_wire::engine::FEATURE_SESSION_REF).
NO_SESSION_KEY
Why nothing naming a session is uploaded: the local receipts key cannot be read or created, and the unsalted digest of a guessable session id must not stand in for the keyed one.

Functions§

announced
Whether the server this machine is enrolled with announced feature when last asked.
record
Record what server announced.
refresh
Ask the enrolled Cloud what it accepts and record it. A Cloud without the route announces nothing; any other failure keeps the last answer.
rekeyed_legacy_ref
The ref a draft or proposal queued before body refs were keyed is sent with: its stored unsalted ses_ digest (the queue never kept the session id), keyed under the local key with its own label. Errors as uploaded_ses_ref does, and the item then stays queued.
uploaded_ses_ref
The body ses_ ref an upload (draft, task claim, task proposal, episode) names session id (or a fixed label such as cli-import) by: keyed under the local receipts key in cloud_data (SessionRefs::episode_ref, no capability needed, the shape is unchanged). When that key cannot be read or created this is an error (NO_SESSION_KEY) and the caller skips the upload: every contract that carries the field requires it, and the unsalted crate::knowledge::draft::session_ref of a guessable id never stands in. Local-only uses (file names, done markers) keep the unsalted ref.