carrier

package
v0.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HardMaxBytes          int64 = 10 * 1024 * 1024
	DefaultMaxDepth             = 128
	DefaultMaxNodes             = 250_000
	DefaultMaxStringBytes       = 1024 * 1024
)

Variables

This section is empty.

Functions

func Pointer

func Pointer(parts []string) string

func UnpairedSurrogateEscape added in v0.23.0

func UnpairedSurrogateEscape(data []byte) (int, bool)

UnpairedSurrogateEscape reports the offset of the first \uD800-\uDFFF escape that is not one half of a well-formed pair, and whether one was found.

Go's decoder replaces such an escape with U+FFFD without complaint, which is silent lossy repair of a value RFC 8785 §3.2.2.2 says a canonicalizer must refuse: an authored "\ud800" would otherwise canonicalize to the same bytes as a literal U+FFFD, so two different documents would compare equal and a byte comparison §8.3 requires to be exact would not be. Refusing at the carrier fixes it once for every document that reaches this runtime — pack, matrix, facts, evidence, configuration, and graph — rather than once per reader.

It is exported for the one caller outside this package that faces the same defect one level up: the MCP stdio transport, where the escape is written in the JSON-RPC message rather than in a document it carries, and no carrier is reached because the tool argument has already been repaired into a Go string (ADR-0038). Every other reader gets this through Decode.

Callers must hand it bytes that already parsed as JSON, so a backslash appears only inside a string and every escape is well-formed; the walk still checks its own bounds rather than trusting that. Over bytes that are not JSON its string tracking is a guess — an unterminated string makes the rest of the input look like string content — so a caller settles JSON validity first and reports that defect instead.

Types

type Failure

type Failure struct {
	Resource   bool
	Diagnostic result.Diagnostic
}

func Decode

func Decode(data []byte, limits Limits) (any, *Failure)

func (*Failure) Error

func (f *Failure) Error() string

type Limits

type Limits struct {
	MaxDepth       int
	MaxNodes       int
	MaxStringBytes int
}

func DefaultLimits

func DefaultLimits() Limits

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL