Expand description
Wire schema version 1 (baseline).
Shared types between host (cc-lb-runtime-wasmtime) and guest
(cc-lb-pdk-wasmtime) compiled in lockstep.
Wire types for the three hooks the wasmtime runtime ships:
filter (Phase 1), shape (Phase 2), observe
(Phase 2). Signer extension is intentionally not exposed across
the plugin boundary — host-side built-in AnthropicKeySigner /
AnthropicOAuthSigner handle credential signing in-process.
rkyv derives Archive + Serialize + Deserialize for every wire type.
The host calls rkyv::access::<ArchivedFilterRequest, rkyv::rancor::Error>
to get a zero-copy &ArchivedFilterRequest view straight out of guest
linear memory; the guest mirrors that pattern in reverse for the response.
§ABI invariants (review consensus)
- Every guest-allocated buffer is aligned to
align_of::<Archived<T>>()for its root type. rkyv 0.8’s default relative pointers require this; the alignment is propagated throughcc_lb_alloc(size, align). Arc/RcMUST NOT appear in any wire type (rkyv 0.8 Issue #670 —ArchivedRc::verifycan be bypassed for DST shared pointers).- The wire schema is fingerprinted via BLAKE3 of
cc_lb_schema_hashcustom section content. Host and guest must agree byte-for-byte.
§Borrowed-wire optimisation (RFC-0001 #9)
Host-to-guest request types (FilterRequest, ShapeRequest) come in two flavours that produce IDENTICAL archived bytes:
- Owned (
FilterRequest,ShapeRequest, …) — ownedBox<str>/Box<[u8]>fields. Used by the guest forrkyv::deserializeround-trips and for round-trip test fixtures. - Borrowed ref (
FilterRequestRef<'a>,ShapeRequestRef<'a>, …) —&'a str/&'a [u8]fields with#[rkyv(with = InlineAsBox)]. Used by the host inwire_to_host_wire_requestso the request body (up to 100 MiB on/v1/files) is serialised IN PLACE from the request pipeline’sbytes::Byteswithout any.to_vec()copy.
Both variants archive to the same ArchivedBox<ArchivedSlice<u8>>
/ ArchivedBox<ArchivedStr> byte layouts — verified by the wire
round-trip tests in crates/cc-lb-plugin-wire/tests/borrowed_wire_roundtrip.rs.
When either variant is written to guest memory, the guest reads it
via rkyv::access::<ArchivedFilterRequest, _> — the archived
type name is identical because the owned type is the sole Archive
source of truth; the ref type carries #[rkyv(archived = ...)] to
reuse the owned type’s archived form.
See docs/rfc/0001-plugin-runtime-vnext.md.
Structs§
- Archived
Claim - An archived
Claim - Archived
Claim Ref - An archived
ClaimRef - Archived
Filter Request - An archived
FilterRequest - Archived
Filter Request Ref - An archived
FilterRequestRef - Archived
Filter Response - An archived
FilterResponse - Archived
Header - An archived
Header - Archived
Header Ref - An archived
HeaderRef - Archived
PerCandidate Reason - An archived
PerCandidateReason - Archived
Principal - An archived
Principal - Archived
Principal Ref - An archived
PrincipalRef - Archived
Query Ref - An archived
QueryRef - Archived
Shape Request - An archived
ShapeRequest - Archived
Shape Request Ref - An archived
ShapeRequestRef - Archived
Shape Response - An archived
ShapeResponse - Archived
Upstream Candidate - An archived
UpstreamCandidate - Archived
Upstream Candidate Ref - An archived
UpstreamCandidateRef - Claim
- One claim key/value pair — see
Principal::claims. Named struct (not tuple) so thatClaimRef<'a>matches the archived byte layout without an extra Ref wrapper. - Claim
Ref - One claim entry inside
PrincipalRef. The tuple form used by the owned type does not have a straight borrowed equivalent, so we promote it to a named struct with two borrowed fields. - Claim
RefResolver - The resolver for an archived
ClaimRef - Claim
Resolver - The resolver for an archived
Claim - Filter
Request - Filter hook input (owned form used by the guest).
- Filter
Request Ref - Borrowed mirror of
FilterRequestused by the host encode path. Serialising this emits the same archived byte layout asFilterRequestso the guest reads it viarkyv::access::<ArchivedFilterRequest, _>unchanged. - Filter
Request RefResolver - The resolver for an archived
FilterRequestRef - Filter
Request Resolver - The resolver for an archived
FilterRequest - Filter
Response - Filter hook output.
- Filter
Response Resolver - The resolver for an archived
FilterResponse - Header
- One header on the inbound request.
- Header
Ref - Borrowed mirror of
Header. - Header
RefResolver - The resolver for an archived
HeaderRef - Header
Resolver - The resolver for an archived
Header - PerCandidate
Reason - Decision the plugin made for one candidate.
- PerCandidate
Reason Resolver - The resolver for an archived
PerCandidateReason - Principal
- Principal context as seen by the filter plugin.
- Principal
Ref - Borrowed mirror of
Principalused by the host encode path. Every reference field carries#[rkyv(with = InlineAsBox)]so serialising this struct emits the same archived byte layout asPrincipal. - Principal
RefResolver - The resolver for an archived
PrincipalRef - Principal
Resolver - The resolver for an archived
Principal - Query
Ref - Borrowed wrapper for the optional
queryfield. Necessary becauseOption<InlineAsBox<&'a str>>does not compose directly at the derive layer; a named struct pushes the#[rkyv(with = ...)]attribute onto the inner reference. - Query
RefResolver - The resolver for an archived
QueryRef - Shape
Request - Shape hook input (owned form).
- Shape
Request Ref - Borrowed mirror of
ShapeRequestused by the host encode path. - Shape
Request RefResolver - The resolver for an archived
ShapeRequestRef - Shape
Request Resolver - The resolver for an archived
ShapeRequest - Shape
Response - Shape hook output — the upstream-bound request the plugin produced.
- Shape
Response Resolver - The resolver for an archived
ShapeResponse - Upstream
Candidate - One upstream candidate the filter plugin can choose to keep or drop.
- Upstream
Candidate Ref - Borrowed mirror of
UpstreamCandidate. - Upstream
Candidate RefResolver - The resolver for an archived
UpstreamCandidateRef - Upstream
Candidate Resolver - The resolver for an archived
UpstreamCandidate
Enums§
- Archived
Observe Event - An archived
ObserveEvent - Archived
Upstream - An archived
Upstream - Archived
Upstream Ref - An archived
UpstreamRef - Observe
Event - Lifecycle event delivered to the observe hook. rkyv mirror of
cc_lb_plugin_api::ObserveEvent. - Observe
Event Resolver - The resolver for an archived
ObserveEvent - Upstream
- Upstream backend exposed to plugins. Mirrors
cc_lb_plugin_api::Upstream(currently a single variant — extending the host enum requires extending this one in lockstep and bumping a wire schema tag). - Upstream
Ref - Borrowed mirror of
Upstream. - Upstream
RefResolver - The resolver for an archived
UpstreamRef - Upstream
Resolver - The resolver for an archived
Upstream