Secure, Fast, and Extensible Sandbox runtime for AI agents.
chore(egress): trim resolver client comments to match repo terseness
高然d423c013fa04
diff --git a/components/egress/pkg/constants/configuration.go b/components/egress/pkg/constants/configuration.goindex 4c6aa0fdf..0785ffe17 100644--- a/components/egress/pkg/constants/configuration.go+++ b/components/egress/pkg/constants/configuration.go@@ -39,20 +39,13 @@ const (EnvCredentialVaultRequireScopedMatch = "OPENSANDBOX_EGRESS_CREDENTIAL_VAULT_REQUIRE_SCOPED_MATCH")-// Credential header resolver client (OSEP-0025): egress → resolver transport-// configuration. Ownership of this surface lives with the resolver client-// (pkg/credentialvault/resolver_client.go); interception consumers only-// consume the client interface.-//-// EnvCredentialResolverTimeout: per-resolve deadline in seconds (1..120).-// EnvCredentialResolverMaxConcurrency: in-flight resolve cap (1..1024).-// EnvCredentialResolverAuth: origin-scoped bearer tokens-// "scheme://host:port=token[,...]" (D5). An endpoint whose normalized origin-// has no entry resolves WITHOUT an Authorization header — there is no global-// token. Never logged.+// Credential header resolver client (OSEP-0025); owned by+// pkg/credentialvault/resolver_client.go — consumers use the client interface+// only. Auth is "scheme://host:port=token,..." (D5); endpoints without a+// matching origin resolve without an Authorization header. Never logged.const (- EnvCredentialResolverTimeout = "OPENSANDBOX_EGRESS_CREDENTIAL_RESOLVER_TIMEOUT"- EnvCredentialResolverMaxConcurrency = "OPENSANDBOX_EGRESS_CREDENTIAL_RESOLVER_MAX_CONCURRENCY"+ EnvCredentialResolverTimeout = "OPENSANDBOX_EGRESS_CREDENTIAL_RESOLVER_TIMEOUT" // seconds, 1..120+ EnvCredentialResolverMaxConcurrency = "OPENSANDBOX_EGRESS_CREDENTIAL_RESOLVER_MAX_CONCURRENCY" // 1..1024EnvCredentialResolverAuth = "OPENSANDBOX_EGRESS_CREDENTIAL_RESOLVER_AUTH")diff --git a/components/egress/pkg/credentialvault/resolver_client.go b/components/egress/pkg/credentialvault/resolver_client.goindex dee4a7b6b..99c270f13 100644--- a/components/egress/pkg/credentialvault/resolver_client.go+++ b/components/egress/pkg/credentialvault/resolver_client.go@@ -37,44 +37,31 @@ import ("github.com/alibaba/opensandbox/egress/pkg/constants")-// Egress → credential header resolver client (OSEP-0025, frozen contract-// §3.3): one POSTed JSON request document answered with a header map plus-// optional incremental redactions. The envelope is untrusted input (D14):-// every response over a limit is a per-request denial, never a global fault.+// Egress → credential header resolver client (OSEP-0025 frozen contract).+// The envelope is untrusted input (D14): over-limit responses are per-request+// denials, never global faults.const (- // maxResolverResponseBytes (D14): total response body byte cap.- maxResolverResponseBytes = 64 << 10- // maxResolverHeaderCount (D14): header entries per response.- maxResolverHeaderCount = 16- // maxResolverValueBytes (D14): single header name/value or redaction value cap.- maxResolverValueBytes = 8 << 10- // maxResolverRedactionCount (D14): total resolver-provided redaction values.+ // D14 envelope caps.+ maxResolverResponseBytes = 64 << 10+ maxResolverHeaderCount = 16+ maxResolverValueBytes = 8 << 10maxResolverRedactionCount = 64- // maxResolverResponseHeaderBytes caps the HTTP response header block itself.+ // Caps the HTTP response header block itself, not the JSON body.maxResolverResponseHeaderBytes = 8 << 10)-// ResolverErrorKind classifies a failed resolve for the interception path.-// Denied/invalid/rejected/timeout/unavailable are all per-request outcomes:-// the request proceeds without resolver headers (fail closed), the client-// itself stays healthy.+// ResolverErrorKind classifies a failed resolve; all kinds are per-request+// outcomes and fail closed.type ResolverErrorKind stringconst (- // ResolverInvalidRequest: caller-supplied input violates the request contract.- ResolverInvalidRequest ResolverErrorKind = "invalid_request"- // ResolverUnavailable: transport failure (dial/write/read error).- ResolverUnavailable ResolverErrorKind = "unavailable"- // ResolverTimeout: per-call deadline exceeded.- ResolverTimeout ResolverErrorKind = "timeout"- // ResolverRejected: resolver answered with a non-200 status.- ResolverRejected ResolverErrorKind = "rejected"- // ResolverInvalidResponse: 200 but the body is not the contracted JSON envelope.- ResolverInvalidResponse ResolverErrorKind = "invalid_response"- // ResolverDenied (D14/R14): envelope limit exceeded or header name denied —- // per-request denial.- ResolverDenied ResolverErrorKind = "denied"+ ResolverInvalidRequest ResolverErrorKind = "invalid_request"+ ResolverUnavailable ResolverErrorKind = "unavailable"+ ResolverTimeout ResolverErrorKind = "timeout"+ ResolverRejected ResolverErrorKind = "rejected" // non-200+ ResolverInvalidResponse ResolverErrorKind = "invalid_response" // 200, bad envelope+ ResolverDenied ResolverErrorKind = "denied" // D14/R14)// ResolverError is the typed failure of one resolve call.@@ -103,8 +90,7 @@ func resolverErrorf(kind ResolverErrorKind, reason string) *ResolverError {return &ResolverError{Kind: kind, Reason: reason}}-// ResolverClient resolves one HTTP exchange's credential headers against the-// credential header resolver.+// ResolverClient resolves one exchange's credential headers.type ResolverClient interface {Resolve(ctx context.Context, input ResolveInput) (*ResolverDecision, error)}@@ -113,13 +99,12 @@ type ResolverClient interface {type ResolveInput struct {// Subject is the egress-authoritative sandboxId.Subject string- // Credential and Binding name the vault credential and binding whose- // headers the resolver renders.+ // Credential and Binding name the vault credential and binding.Credential stringBinding string- // Destination is the target origin of the intercepted exchange.+ // Destination is the intercepted target origin.Destination ResolveDestination- // Request describes the outbound request frame the headers apply to.+ // Request is the outbound frame the headers apply to.Request ResolveRequestFrame}@@ -138,10 +123,9 @@ type ResolveRequestFrame struct {Headers map[string]string}-// ResolverDecision is the validated per-request outcome: headers to inject,-// the header names to suppress from passthrough, and the merged redaction-// set (derived variants are authoritative; resolver-provided redactions are-// incremental only, R9).+// ResolverDecision is the validated outcome: headers to inject, names to+// suppress, and merged redactions (derived variants authoritative; resolver+// redactions incremental only, R9).type ResolverDecision struct {Headers map[string]stringSuppress map[string]struct{} // lowercase header names@@ -150,24 +134,22 @@ type ResolverDecision struct {// ResolverClientOptions constructs one client.type ResolverClientOptions struct {- // Endpoint is the resolver URI: "uds:///absolute/socket/path" or- // "unix://..." (alias) or "https://host[:port][/prefix]".+ // Endpoint is "uds:///absolute/socket/path", "unix://..." (alias), or+ // "https://host[:port][/prefix]".Endpoint string- // Timeout bounds every resolve call; 0 selects the configured default.+ // Timeout bounds every resolve call; 0 selects the default.Timeout time.Duration- // MaxConcurrency bounds in-flight resolves; 0 selects the configured default.+ // MaxConcurrency bounds in-flight resolves; 0 selects the default.MaxConcurrency int- // Auth maps normalized origins ("https://host:port") to the bearer token- // presented for that origin only (D5). Endpoints without a matching- // origin resolve without an Authorization header.+ // Auth maps normalized origins ("https://host:port") to bearer tokens+ // (D5); unmatched origins resolve without an Authorization header.Auth map[string]string- // TLSClientConfig overrides the HTTPS transport TLS configuration (test- // and deployment seam). Nil selects system verification.+ // TLSClientConfig overrides HTTPS TLS (test/deployment seam); nil keeps+ // system verification.TLSClientConfig *tls.Config}-// NewResolverClient validates the endpoint and constructs the transport-// without dialing.+// NewResolverClient validates the endpoint; no connection is dialed.func NewResolverClient(options ResolverClientOptions) (ResolverClient, error) {if options.Timeout <= 0 {options.Timeout = ResolverTimeoutFromEnv()@@ -212,9 +194,7 @@ func NewResolverClient(options ResolverClientOptions) (ResolverClient, error) {if parsed.origin == "" {return nil, resolverErrorf(ResolverInvalidRequest, "missing_https_origin")}- // Proxy stays nil: the resolver hop is direct TLS and must never- // chain through an outbound proxy (the bearer token must not leak- // to one).+ // Proxy stays nil: the token must never leak through an outbound proxy.transport = &http.Transport{DisableKeepAlives: true,ForceAttemptHTTP2: false,@@ -241,9 +221,8 @@ type parsedResolverEndpoint struct {resolvePath string // request target: prefix + "/resolve"}-// parseResolverEndpoint validates the resolver URI and derives the framing-// (D15): https endpoints may carry a path prefix; the resolve target is-// prefix + "/resolve". Unix endpoints carry no prefix.+// parseResolverEndpoint derives the D15 framing: https targets are+// prefix + "/resolve"; unix endpoints carry no prefix.func parseResolverEndpoint(endpoint string) (*parsedResolverEndpoint, error) {raw, err := url.Parse(strings.TrimSpace(endpoint))if err != nil {@@ -291,8 +270,7 @@ func parseResolverEndpoint(endpoint string) (*parsedResolverEndpoint, error) {}}-// normalizeResolverOrigin canonicalizes an https URL to "https://host:port"-// (D5): lowercase scheme and host, explicit port (443 added when absent).+// normalizeResolverOrigin canonicalizes to "https://host:port" (D5).func normalizeResolverOrigin(u *url.URL) (string, error) {if strings.ToLower(u.Scheme) != "https" {return "", resolverErrorf(ResolverInvalidRequest, "origin_requires_https_scheme")@@ -311,10 +289,8 @@ func normalizeResolverOrigin(u *url.URL) (string, error) {return "https://" + host + ":" + port, nil}-// ParseResolverAuthEnv parses OPENSANDBOX_EGRESS_CREDENTIAL_RESOLVER_AUTH-// (D5): comma-separated "origin=token" entries. Origins are normalized; a-// malformed entry is a configuration error (fail closed), and an empty token-// is rejected rather than treated as "no auth".+// ParseResolverAuthEnv parses "origin=token,..." entries (D5). Origins are+// normalized; malformed entries and empty tokens fail closed.func ParseResolverAuthEnv(raw string) (map[string]string, error) {tokens := make(map[string]string)for _, entry := range strings.Split(raw, ",") {@@ -345,17 +321,16 @@ func normalizeResolverOriginString(origin string) (string, error) {if err != nil {return "", err}- // D5 key format is exactly scheme://host:port — an operator writing a- // path/query-qualified origin would silently broaden the token's scope- // after normalization, so reject rather than accept.+ // Reject path-qualified origins: normalization would silently broaden+ // the token's scope (D5 keys are exactly scheme://host:port).if parsed.Path != "" && parsed.Path != "/" || parsed.RawQuery != "" || parsed.Fragment != "" || parsed.User != nil {return "", errors.New("origin must be scheme://host:port")}return normalizeResolverOrigin(parsed)}-// ResolverTimeoutFromEnv reads OPENSANDBOX_EGRESS_CREDENTIAL_RESOLVER_TIMEOUT-// (seconds); unparseable or out-of-range values keep the default.+// ResolverTimeoutFromEnv reads the timeout env (seconds); bad values keep+// the default.func ResolverTimeoutFromEnv() time.Duration {seconds := constants.EnvIntRange(constants.EnvCredentialResolverTimeout,@@ -365,9 +340,8 @@ func ResolverTimeoutFromEnv() time.Duration {return time.Duration(seconds) * time.Second}-// ResolverMaxConcurrencyFromEnv reads-// OPENSANDBOX_EGRESS_CREDENTIAL_RESOLVER_MAX_CONCURRENCY; unparseable or-// out-of-range values keep the default.+// ResolverMaxConcurrencyFromEnv reads the concurrency env; bad values keep+// the default.func ResolverMaxConcurrencyFromEnv() int {return constants.EnvIntRange(constants.EnvCredentialResolverMaxConcurrency,@@ -376,9 +350,8 @@ func ResolverMaxConcurrencyFromEnv() int {)}-// NewResolverClientFromEnv constructs a client from the three resolver-// environment variables (endpoint supplied by the caller — there is no-// endpoint env; wiring owns it).+// NewResolverClientFromEnv builds a client from the resolver envs; wiring+// supplies the endpoint.func NewResolverClientFromEnv(endpoint string) (ResolverClient, error) {auth, err := authTokensFromEnv()if err != nil {@@ -398,8 +371,7 @@ func authTokensFromEnv() (map[string]string, error) {return ParseResolverAuthEnv(raw)}-// resolverClient is the UDS/HTTPS resolver transport. The zero value is not-// usable; construct through NewResolverClient.+// resolverClient is the UDS/HTTPS transport; construct via NewResolverClient.type resolverClient struct {http *http.ClientrequestURL string@@ -411,8 +383,7 @@ type resolverClient struct {var _ ResolverClient = (*resolverClient)(nil)-// Resolve performs one resolution. Failures are typed ResolverError values;-// envelope violations (D14) are per-request denials.+// Resolve performs one resolution; failures are typed ResolverError values.func (c *resolverClient) Resolve(ctx context.Context, input ResolveInput) (*ResolverDecision, error) {if err := ctx.Err(); err != nil {return nil, &ResolverError{Kind: ResolverTimeout, err: err}@@ -422,7 +393,7 @@ func (c *resolverClient) Resolve(ctx context.Context, input ResolveInput) (*Resoreturn nil, err}- // Bound in-flight resolves; the acquire honors caller cancellation.+ // Bound in-flight resolves; acquire honors cancellation.select {case c.concurrency <- struct{}{}:defer func() { <-c.concurrency }()@@ -439,8 +410,7 @@ func (c *resolverClient) Resolve(ctx context.Context, input ResolveInput) (*Reso}request.Header.Set("Content-Type", "application/json")if c.hostHeader != "" {- // D15: Host is the endpoint authority (https) or localhost (unix,- // applied by the request URL above).+ // D15: Host is the endpoint authority (localhost over unix).request.Host = c.hostHeader}if c.authorization != "" {@@ -458,8 +428,7 @@ func (c *resolverClient) Resolve(ctx context.Context, input ResolveInput) (*Resodefer response.Body.Close()if response.StatusCode != http.StatusOK {- // Drain a little so the connection can be reclaimed without letting- // the peer stream unbounded bytes into the client.+ // Drain a little so the peer cannot stream unbounded bytes._, _ = io.Copy(io.Discard, io.LimitReader(response.Body, maxResolverResponseHeaderBytes))return nil, &ResolverError{Kind: ResolverRejected, Status: response.StatusCode}}@@ -469,7 +438,7 @@ func (c *resolverClient) Resolve(ctx context.Context, input ResolveInput) (*Resodata, err := io.ReadAll(io.LimitReader(response.Body, maxResolverResponseBytes+1))if err != nil {- // A trickling body past the deadline is a timeout, not unavailability.+ // A body trickling past the deadline is a timeout, not unavailability.if callCtx.Err() != nil {return nil, &ResolverError{Kind: ResolverTimeout, err: callCtx.Err()}}@@ -485,8 +454,8 @@ func (c *resolverClient) Resolve(ctx context.Context, input ResolveInput) (*Resoreturn deriveResolverDecision(envelope.headers, envelope.redactions), nil}-// marshalResolveInput validates the request-side contract (mirror of the-// resolver's own validation) and encodes the exact request document.+// marshalResolveInput validates the request contract and encodes the exact+// wire document.func marshalResolveInput(input ResolveInput) ([]byte, error) {nonEmpty := func(value string) bool { return value != "" }switch {@@ -508,9 +477,8 @@ func marshalResolveInput(input ResolveInput) ([]byte, error) {}requestHeaders := input.Request.Headersif requestHeaders == nil {- // D15 wire shape: the frozen contract requires request.headers to be- // a JSON object; a nil Go map would serialize as null and be- // rejected by a contract-compliant resolver.+ // D15: request.headers must be a JSON object; a nil Go map would+ // serialize as null.requestHeaders = map[string]string{}}document := resolveRequestDocument{@@ -560,10 +528,9 @@ type resolveRequestFrameDocument struct {Headers map[string]string `json:"headers"`}-// decodeResolveResponse strictly decodes the response envelope: exactly the-// contracted fields, no duplicate keys, no unknown fields, no nulls, no-// trailing data (D14). Limit violations are ResolverDenied; schema violations-// are ResolverInvalidResponse.+// decodeResolveResponse strictly decodes the envelope: exact fields only,+// no duplicates/nulls/trailing data. Limits are ResolverDenied; schema+// violations are ResolverInvalidResponse.func decodeResolveResponse(data []byte) (*resolveResponseDocument, error) {fields, err := strictJSONObject(data)if err != nil {@@ -598,10 +565,8 @@ type resolveResponseDocument struct {redactions map[string][]string}-// decodeHeaderMap validates one resolved header map (D14/R14): names pass the-// credential-header rules (token pattern + reserved/hop-by-hop blacklist,-// vault.go reservedHeaderNames), values are non-empty strings within the-// per-value cap, and the map stays within the entry cap.+// decodeHeaderMap enforces the credential-header rules: token-pattern names+// off the reserved/hop-by-hop blacklist, non-empty values within the caps.func decodeHeaderMap(raw json.RawMessage) (map[string]string, error) {fields, err := strictJSONObject(raw)if err != nil {@@ -613,8 +578,8 @@ func decodeHeaderMap(raw json.RawMessage) (map[string]string, error) {headers := make(map[string]string, len(fields))seenNames := make(map[string]struct{}, len(fields))for name, valueRaw := range fields {- // HTTP header names are case-insensitive: byte-different JSON keys- // naming one header are a contract violation, not two headers.+ // Header names are case-insensitive; byte-different keys naming one+ // header are one header, not two.lowerName := strings.ToLower(name)if _, duplicate := seenNames[lowerName]; duplicate {return nil, resolverErrorf(ResolverInvalidResponse, "duplicate_header_name")@@ -630,9 +595,7 @@ func decodeHeaderMap(raw json.RawMessage) (map[string]string, error) {if err != nil {return nil, err}- // D14 boundary: the envelope is untrusted input and these values are- // injected into outbound HTTP frames; reject anything that is not a- // legal HTTP field-value (control bytes incl. CR/LF/NUL/DEL).+ // Values land in outbound HTTP frames; reject illegal field-values.if !httpguts.ValidHeaderFieldValue(value) {return nil, resolverErrorf(ResolverDenied, "denied_header_value")}@@ -641,9 +604,7 @@ func decodeHeaderMap(raw json.RawMessage) (map[string]string, error) {return headers, nil}-// decodeRedactionMap validates the resolver-provided incremental redactions-// (R14): total values within the redaction cap, each value non-empty and-// within the per-value cap.+// decodeRedactionMap validates resolver-provided incremental redactions (R9).func decodeRedactionMap(raw json.RawMessage) (map[string][]string, error) {fields, err := strictJSONObject(raw)if err != nil {@@ -679,8 +640,7 @@ func decodeNonEmptyString(raw json.RawMessage, tooLongReason string) (string, erreturn "", resolverErrorf(ResolverInvalidResponse, "value_not_string")}if value == "" {- // A schema violation (the contract requires non-empty strings), not- // a limit exceedance.+ // Schema violation, not a limit.return "", resolverErrorf(ResolverInvalidResponse, "empty_value")}if len(value) > maxResolverValueBytes {@@ -712,9 +672,8 @@ func decodeNonEmptyStringArray(raw json.RawMessage) ([]string, error) {return values, nil}-// strictJSONObject decodes exactly one JSON object with unique keys into-// name → raw value. Duplicate keys, non-objects, or trailing bytes are-// rejected.+// strictJSONObject decodes one JSON object with unique keys; rejects+// non-objects and trailing bytes.func strictJSONObject(data []byte) (map[string]json.RawMessage, error) {decoder := json.NewDecoder(bytes.NewReader(data))token, err := decoder.Token()@@ -755,8 +714,8 @@ func strictJSONObject(data []byte) (map[string]json.RawMessage, error) {return fields, nil}-// canonicalResolverRedactions orders redaction values the way the decision-// snapshot expects: non-empty, deduped, ascending length then bytes.+// canonicalResolverRedactions dedups and orders values by length then+// bytes (decision-snapshot canonical form).func canonicalResolverRedactions(values []string) []string {seen := make(map[string]struct{}, len(values))merged := make([]string, 0, len(values))diff --git a/components/egress/pkg/credentialvault/resolver_client_test.go b/components/egress/pkg/credentialvault/resolver_client_test.goindex 4bb1b579e..a4b06b0c2 100644--- a/components/egress/pkg/credentialvault/resolver_client_test.go+++ b/components/egress/pkg/credentialvault/resolver_client_test.go@@ -135,8 +135,7 @@ func TestParseResolverAuthEnv(t *testing.T) {"=alpha","notaentry","https://resolver.internal:8443=alpha,https://resolver.internal:8443=beta",- // Path/query-qualified origins would silently broaden the token- // scope after normalization — rejected, not accepted.+ // Path-qualified origins would silently broaden the token scope."https://resolver.internal/base=alpha","https://resolver.internal?zone=1=alpha","https://resolver.internal:8443/#frag=alpha",@@ -243,8 +242,7 @@ func TestDecodeResolveResponseStrictness(t *testing.T) {requireKind(t, err, ResolverInvalidResponse)}- // Duplicate object keys are rejected, not last-wins — including- // case-insensitive header names, which HTTP treats as one header.+ // Duplicate keys are rejected, not last-wins — case-insensitively too._, err := decodeResolveResponse([]byte(`{"headers":{"x-a":"1"},"headers":{"x-a":"2"}}`))requireKind(t, err, ResolverInvalidResponse)_, err = decodeResolveResponse([]byte(`{"headers":{"x-a":"1","x-a":"2"}}`))@@ -288,8 +286,7 @@ func TestResolveUnavailableWhenSocketMissing(t *testing.T) {requireKind(t, err, ResolverUnavailable)}-// startEnvelopeServer runs an HTTPS test resolver answering every POST with-// status/body. It returns the endpoint URI and the test TLS configuration.+// startEnvelopeServer runs an HTTPS test resolver returning status/body.func startEnvelopeServer(t *testing.T, status int, body string, captured *capturedRequest) (string, *tls.Config) {t.Helper()server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {@@ -374,9 +371,7 @@ func TestHTTPSFrameAndHappyPath(t *testing.T) {}func TestResolveHeaderlessFrameWireShape(t *testing.T) {- // A nil Go header map must serialize as an empty JSON object: the frozen- // contract requires request.headers to be an object, and null would be- // rejected by a contract-compliant resolver as malformed_request.+ // nil must serialize as {} — a contract-compliant resolver rejects null.var captured capturedRequestendpoint, tlsConfig := startEnvelopeServer(t, http.StatusOK, `{"headers":{}}`, &captured)client, err := NewResolverClient(ResolverClientOptions{Endpoint: endpoint, Timeout: time.Second, MaxConcurrency: 1, TLSClientConfig: tlsConfig})@@ -483,8 +478,7 @@ func TestResolverDeniedLimits(t *testing.T) {}func TestResolverDeniedResponseTooLarge(t *testing.T) {- // A 200 with a body over the 64KiB envelope cap is a per-request denial;- // the client must also stop reading promptly.+ // A 200 body over the 64KiB cap is a per-request denial.large := `{"headers":{"x-a":"` + strings.Repeat("v", maxResolverResponseBytes) + `"}}`endpoint, tlsConfig := startEnvelopeServer(t, http.StatusOK, large, nil)client, err := NewResolverClient(ResolverClientOptions{Endpoint: endpoint, Timeout: 5 * time.Second, MaxConcurrency: 1, TLSClientConfig: tlsConfig})@@ -623,8 +617,8 @@ func TestResolverMaxConcurrencyBounded(t *testing.T) {}func TestResolverClientInterfaceContract(t *testing.T) {- // The decision shape is the interception contract: headers as returned,- // lowercase suppress names, canonically ordered redactions.+ // Decision shape: headers as returned, lowercase suppress, canonical+ // redactions.envelope := `{"headers":{"X-Signature":"sig","X-Token":"tok"},"redactions":{"X-Signature":["sig"]}}`endpoint, tlsConfig := startEnvelopeServer(t, http.StatusOK, envelope, nil)client, err := NewResolverClient(ResolverClientOptions{Endpoint: endpoint, Timeout: time.Second, MaxConcurrency: 1, TLSClientConfig: tlsConfig})diff --git a/components/egress/pkg/credentialvault/resolver_redaction.go b/components/egress/pkg/credentialvault/resolver_redaction.goindex 2845defc3..5f6fb1ce2 100644--- a/components/egress/pkg/credentialvault/resolver_redaction.go+++ b/components/egress/pkg/credentialvault/resolver_redaction.go@@ -16,18 +16,15 @@ package credentialvaultimport "strings"-// Resolver response → interception decision (OSEP-0025 R9): the resolved-// headers themselves drive the suppress and redaction derivation; anything-// the resolver volunteers as redactions is merged incrementally and is never-// authoritative. The derived set cannot be shrunk by the response.+// Resolver response → interception decision (OSEP-0025 R9): resolved headers+// drive the derivation; resolver-volunteered redactions merge incrementally+// and can never shrink the derived set.-// deriveResolverDecision builds the per-request decision from a validated-// envelope. For every resolved header: the lowercased name joins the suppress-// set and the value joins the redaction set through the same 7-variant-// expansion used for substitutions (raw, URL-escaped ×2 case forms,-// form-escaped ×2 case forms, JSON-escaped ×2 encodings —-// substitutionRedactionVariants). Resolver-provided redactions are additive-// only, deduped, and never remove derived entries.+// deriveResolverDecision builds the decision from a validated envelope: each+// header's lowercased name joins the suppress set and its value joins the+// redactions via the 7-variant substitution expansion+// (substitutionRedactionVariants); resolver redactions are additive and+// deduped.func deriveResolverDecision(headers map[string]string, resolverRedactions map[string][]string) *ResolverDecision {decision := &ResolverDecision{Headers: headers,@@ -38,8 +35,7 @@ func deriveResolverDecision(headers map[string]string, resolverRedactions map[stdecision.Suppress[strings.ToLower(name)] = struct{}{}redactions = append(redactions, substitutionRedactionVariants(value)...)}- // R9: resolver-supplied redactions merge incrementally only — they can- // add entries but never remove or replace the derived ones.+ // R9: resolver redactions only add, never remove derived entries.for _, values := range resolverRedactions {redactions = append(redactions, values...)}diff --git a/components/egress/pkg/credentialvault/resolver_redaction_test.go b/components/egress/pkg/credentialvault/resolver_redaction_test.goindex 2d5ea7662..4bccaa826 100644--- a/components/egress/pkg/credentialvault/resolver_redaction_test.go+++ b/components/egress/pkg/credentialvault/resolver_redaction_test.go@@ -22,9 +22,7 @@ import ()func TestDeriveResolverDecisionVariantCompleteness(t *testing.T) {- // One value exercising every encoding family: spaces, plus signs,- // reserved URL characters, JSON-escaped quotes/newlines, non-ASCII, and- // an astral character (surrogate pair territory).+ // One value exercising every encoding family incl. an astral char.value := "a b+c/d?e=\"f\"&g\nh\U0001F600"decision := deriveResolverDecision(map[string]string{"X-Handled": value}, nil)@@ -37,9 +35,8 @@ func TestDeriveResolverDecisionVariantCompleteness(t *testing.T) {require.Contains(t, decision.Redactions, variant)}- // URL encoding appears in both percent-escape cases; form encoding in- // both plus/percent forms; JSON escaping in both raw-UTF-8 and- // ASCII-escape encodings.+ // URL and form encoding in both percent-escape cases; JSON escaping in+ // both raw-UTF-8 and ASCII-escape forms.expected := []string{value, // raw"a%20b%2Bc%2Fd%3Fe%3D%22f%22%26g%0Ah%F0%9F%98%80", // URL, uppercase escapes, space as %20@@ -50,8 +47,7 @@ func TestDeriveResolverDecisionVariantCompleteness(t *testing.T) {for _, want := range expected {require.Contains(t, decision.Redactions, want)}- // JSON escape: quote, newline, and ampersand escaped, non-ASCII kept- // as UTF-8 (encoding/json default HTML escaping).+ // JSON escape: encoding/json default escaping (incl. \u0026).require.Contains(t, decision.Redactions, "a b+c/d?e=\\\"f\\\"\\u0026g\\nh\U0001F600")// JSON ASCII escape: emoji as the UTF-16 surrogate pair.require.Contains(t, decision.Redactions, "a b+c/d?e=\\\"f\\\"&g\\nh\\ud83d\\ude00")@@ -81,8 +77,7 @@ func TestResolverRedactionsAreIncrementalR9(t *testing.T) {require.NotContains(t, decision.Redactions, "")require.Len(t, decision.Redactions, len(expected)+1)- // The resolver cannot shrink the set: with no redactions at all the- // derived variants remain.+ // The resolver cannot shrink the derived set.decision = deriveResolverDecision(map[string]string{"x-a": value}, nil)require.Equal(t, expected, decision.Redactions)}diff --git a/components/egress/pkg/credentialvault/resolver_stub_integration_test.go b/components/egress/pkg/credentialvault/resolver_stub_integration_test.goindex fa9d00bc0..ff92a24d4 100644--- a/components/egress/pkg/credentialvault/resolver_stub_integration_test.go+++ b/components/egress/pkg/credentialvault/resolver_stub_integration_test.go@@ -37,10 +37,8 @@ import ()// Integration tests against the frozen OSEP-0025 contract stub-// (tests/resolver/resolver.py, PR #2495). Every stub assertion is based on-// the deterministic signature sha256(subject|credential|binding|authority|-// path) or fixed status codes, never on wall-clock behavior beyond injected-// delays.+// (tests/resolver/resolver.py). Assertions key on the deterministic+// sha256(subject|credential|binding|authority|path) signature, not wall-clock.const stubResolverReadyPrefix = "test resolver ready: "@@ -74,9 +72,8 @@ type stubResolverProcess struct {endpoint string}-// startStubResolver launches one resolver.py server process and returns the-// endpoint it printed on the ready line ("uds://<path>" or-// "https://HOST:PORT").+// startStubResolver launches one resolver.py process; returns the ready+// line endpoint ("uds://<path>" or "https://HOST:PORT").func startStubResolver(t *testing.T, stubEnv []string, args ...string) *stubResolverProcess {t.Helper()script := stubResolverScript(t)@@ -157,8 +154,8 @@ func requireStubHappyDecision(t *testing.T, decision *ResolverDecision) {"authorization": {}, "x-test-signature": {}, "x-test-subject": {},}, decision.Suppress)- // R9: the derived 7-variant set covers every resolved header value even- // when the resolver reports no redactions for them.+ // R9: derived variants cover every header value even without resolver+ // redactions.for _, value := range decision.Headers {for _, variant := range substitutionRedactionVariants(value) {require.Contains(t, decision.Redactions, variant)@@ -180,8 +177,7 @@ func TestStubIntegrationUDSHappyPath(t *testing.T) {}func TestStubIntegrationUDSHeaderlessFrame(t *testing.T) {- // The wire shape for a header-less request frame: nil must serialize as- // an empty JSON object (the stub answers null with 400 malformed_request).+ // nil headers must serialize as {} — the stub 400s on null.socketPath := filepath.Join(shortTempDir(t), "r.sock")stub := startStubResolver(t, nil, "--uds", socketPath)@@ -195,8 +191,7 @@ func TestStubIntegrationUDSHeaderlessFrame(t *testing.T) {}func TestStubIntegrationUDSIncompleteRedactions(t *testing.T) {- // The stub reports redactions for only one header; derivation stays- // authoritative (R9) and still covers every header value.+ // Redactions reported for one header; derivation still covers all (R9).socketPath := filepath.Join(shortTempDir(t), "r.sock")stub := startStubResolver(t, nil, "--uds", socketPath, "--incomplete-redactions")@@ -217,16 +212,14 @@ func stubHTTPSArgs(t *testing.T, port int) []string {}func TestStubIntegrationHTTPSAuthOriginTable(t *testing.T) {- // Pre-bind a port so both sides can be configured with the origin before- // the stub reads its auth table at startup.+ // Pre-bind the port: the stub reads its auth table at startup.listener, err := net.Listen("tcp", "127.0.0.1:0")require.NoError(t, err)port := listener.Addr().(*net.TCPAddr).Portrequire.NoError(t, listener.Close())origin := fmt.Sprintf("https://127.0.0.1:%d", port)- // The same env table configures the stub's expected token and the- // client's origin-scoped credential (D5).+ // One env table drives both the stub's expected token and the client.authEntry := constants.EnvCredentialResolverAuth + "=" + origin + "=resolver-token-1"stub := startStubResolver(t, []string{authEntry}, stubHTTPSArgs(t, port)...)require.Equal(t, origin, stub.endpoint)@@ -245,8 +238,7 @@ func TestStubIntegrationHTTPSAuthOriginTable(t *testing.T) {}func TestStubIntegrationHTTPSUnmatchedOriginGetsNoToken(t *testing.T) {- // The client only holds a token for a different origin; the stub expects- // one for its own origin and must answer 401 — proving no token leaked.+ // The client holds only another origin's token; the stub must 401.listener, err := net.Listen("tcp", "127.0.0.1:0")require.NoError(t, err)port := listener.Addr().(*net.TCPAddr).Port