Skip to main content

tapes_capture/
lib.rs

1#![doc = include_str!("../README.md")]
2//!
3//! # Module map
4//!
5//! The README's seam list above says what each module is for. This is the same
6//! set with the arguments that decided their boundaries, and with links.
7//!
8//! * [`envelope`] — the `X-Tapes-*` request-header contract: the producer that
9//!   turns a resolved session identity into the on-wire header set, the header
10//!   names and caps that set obeys, and the vocabulary of harness ids it
11//!   stamps. It is a wire format, and a wire format that changed when a harness
12//!   was added would not be one. Every id it can carry is declared here, and
13//!   the harness registry takes its ids from this list rather than restating
14//!   them — that direction is the point, not an accident: the envelope is the
15//!   contract a harness declaration must be consistent *with*.
16//! * [`gateway`] — two protocols, not one. The launch-nonce protocol names the
17//!   proxy, mints a per-launch secret, and checks the header that echoes it
18//!   back; the provider-route protocol lets one gateway address serve several
19//!   upstream providers by labelling the path. Both are *protocol*; the plugin
20//!   files written against them are artifacts and live with the harness they
21//!   are installed into. Conflating the two is what let a protocol change ride
22//!   along with an artifact change.
23//! * [`peer_pid`] — maps an accepted loopback connection to one of a candidate
24//!   PID set via per-OS kernel APIs.
25//! * [`peer_trust`] — the ancestry walk that answers whether the process on the
26//!   other end of a connection is the harness this client launched, or one of
27//!   its descendants.
28//! * [`session`] — [`HarnessSession`], the trait a harness crate implements to
29//!   describe one of its sessions to the envelope producer. It is the shape of
30//!   the boundary rather than a primitive: stating what is needed, so nothing
31//!   here has to import a supplier of it.
32//!
33//! [`peer_pid`] and [`peer_trust`] together are the question every capture
34//! client asks before it believes anything a connection tells it about itself,
35//! and neither has ever needed a harness id to answer it.
36//!
37//! # Where the envelope contract is written down
38//!
39//! [`envelope`] documents the producer. The contract it implements is
40//! documented beside the fixture corpus that seals it, in
41//! `vendor/tapes-envelope-fixtures/SOURCE.md`, and the parts a parser author
42//! needs are summarised in `envelope::fixtures` (present with the
43//! `envelope-fixtures` feature; docs.rs builds it) — including the rule that
44//! makes several vendored copies one corpus:
45//!
46//! * The corpus is vendored into **every** implementation of the contract, in
47//!   every language, and all copies must move together from one upstream
48//!   revision. A copy that moves alone is a suite that goes green against bytes
49//!   no other implementation has.
50//! * `DIGEST` is what makes that checkable: sort the case files by base name,
51//!   feed `"<basename>  <sha256>\n"` for each into SHA-256, and compare. The
52//!   recipe is deliberately trivial so each language restates it in a few lines
53//!   rather than sharing an implementation that would itself need vendoring.
54//! * Cases carry a direction — `roundtrip`, `encode`, or `decode` — that says
55//!   which half of the contract asserts them. A producer runs the first two and
56//!   skips the third by design; a parser runs the first and third.
57//!
58//! # Names
59//!
60//! The repository is `tapes-crates`; this crate is one of its four members.
61//! `tapes` is a different repository entirely — the server whose ingest reads
62//! these headers back, and the authoring home of the fixture corpus vendored
63//! here.
64#![warn(missing_docs)]
65
66pub mod envelope;
67pub mod gateway;
68pub mod peer_pid;
69pub mod peer_trust;
70pub mod session;
71
72pub use gateway::{
73    GATEWAY_NONCE_ENV, GATEWAY_NONCE_HEADER, GATEWAY_PROVIDER_ROUTE_PREFIX,
74    GATEWAY_PROVIDER_ROUTES_ENV, GATEWAY_PROVIDER_ROUTES_ON, GATEWAY_SCHEMA_ENV, GATEWAY_URL_ENV,
75    nonce_matches, provider_route, split_provider_route,
76};
77pub use peer_pid::{PeerPidLookup, lookup as peer_pid_lookup};
78pub use peer_trust::{
79    is_launched_or_descendant, peer_is_launched_harness, peer_is_launched_harness_async,
80};
81pub use session::HarnessSession;