Documentation
¶
Overview ¶
Package cassette records and replays broker responses deterministically.
Recording is explicit opt-in; replay is the default and never falls back to the live network. Both paths run the identical broker admission, credential, and checkpoint checks — the cassette only substitutes for the network round trip, returning the already-filtered safe response that recording captured. A cassette never persists raw request or response bytes: it stores only the filtered safe response, keyed by a match digest that normalizes the host-injected idempotency key, request id, and timestamps without weakening the action, resource, origin, or response-policy binding. Recording fails closed if any secret-shaped value survives into what would be stored.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cassette ¶
type Cassette struct {
// contains filtered or unexported fields
}
Cassette is a deterministic record/replay store.
func (*Cassette) Marshal ¶
Marshal serializes the cassette deterministically for a byte-stable on-disk form and reviewable diffs.
func (*Cassette) Record ¶
func (c *Cassette) Record(key Key, status uint32, safeHeaders map[string]string, response *providerv0.ExecuteRequestResponse) error
Record stores a live filtered response. It fails closed if any secret-shaped value survived filtering, so a cassette can never become an exfiltration surface.
func (*Cassette) Replay ¶
func (c *Cassette) Replay(key Key) (uint32, *providerv0.ExecuteRequestResponse, error)
Replay returns the next recorded response for the key. It never falls back to the network: an unknown key or a response-policy mismatch is a hard error.
type Entry ¶
type Entry struct {
Sequence int `json:"sequence"`
Method string `json:"method"`
MatchDigest string `json:"match_digest"`
PolicyDigest string `json:"policy_digest"`
ProviderVersion string `json:"provider_version"`
Status uint32 `json:"status"`
SafeHeaders map[string]string `json:"safe_headers,omitempty"`
Response json.RawMessage `json:"response"`
}
Entry is one recorded exchange. It holds only safe, filtered material.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key identifies one logical request independent of host-injected volatile fields. Method, descriptor, path, query, body, origin, and response policy are bound; the idempotency key, request id, and timestamps are not.
func NewKey ¶
func NewKey(planned *providerv0.PlannedRequest, origin *providerv0.AdmittedOrigin) Key
NewKey builds a match key from the admitted planned request and origin.