probe

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadStrategyFixedWindow   = "fixed_window"
	ReadStrategyUntilResolved = "until_resolved"

	DefaultChunkBytes int64 = 64 * 1024

	OnMissingFail       = "fail"
	OnMissingQuarantine = "quarantine"

	TransformSubstring    = "substring"
	TransformRegexCapture = "regex_capture"
	TransformFormat       = "format"
	TransformPad          = "pad"
	TransformLowercase    = "lowercase"
	TransformUppercase    = "uppercase"
	TransformLookup       = "lookup"

	LookupMatchModeRegex  = "regex"
	LookupMatchModePrefix = "prefix"
	LookupMatchModeExact  = "exact"

	MaxPadWidth = 1024
)
View Source
const (
	TerminationAllRequiredResolved = "all_required_resolved"
	TerminationMaxBytesReached     = "max_bytes_reached"
	TerminationStreamExhausted     = "stream_exhausted"
	TerminationParseError          = "parse_error"
	TerminationFixedWindow         = "fixed_window"
)
View Source
const SummaryRecordType = "gonimbus.content.probe.summary.v1"

SummaryRecordType identifies terminal content-probe control evidence.

Variables

This section is empty.

Functions

func FinalizeAuditForTermination

func FinalizeAuditForTermination(audit *ProbeAudit)

func KnownErrorCode

func KnownErrorCode(code string) bool

KnownErrorCode bounds the published histogram vocabulary. Rejected codes must not be echoed into a diagnostic or used as a map key.

Types

type Config

type Config struct {
	ReadStrategy     ReadStrategyConfig `json:"read_strategy,omitempty" yaml:"read_strategy,omitempty"`
	QuarantinePrefix string             `json:"quarantine_prefix,omitempty" yaml:"quarantine_prefix,omitempty"`
	Extract          []ExtractorConfig  `json:"extract" yaml:"extract"`
	Derived          []DerivedConfig    `json:"derived,omitempty" yaml:"derived,omitempty"`
}

Config controls content probing and derived field extraction.

The intent is to support generic extraction without embedding dataset-specific logic. Extractors are applied to the provided byte window (usually a header read).

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) ValidateWithRewriteCaptures

func (c *Config) ValidateWithRewriteCaptures(rewriteCaptures []string) error

type DerivationError

type DerivationError struct {
	Field     string
	From      string
	Transform string
	Detail    string
}

func (*DerivationError) Error

func (e *DerivationError) Error() string

type DerivedConfig

type DerivedConfig struct {
	Name      string         `json:"name" yaml:"name"`
	From      string         `json:"from" yaml:"from"`
	Transform string         `json:"transform" yaml:"transform"`
	Args      map[string]any `json:"args,omitempty" yaml:"args,omitempty"`
	Required  *bool          `json:"required,omitempty" yaml:"required,omitempty"`
	OnMissing string         `json:"on_missing,omitempty" yaml:"on_missing,omitempty"`
	// contains filtered or unexported fields
}

func (DerivedConfig) RequiredValue

func (d DerivedConfig) RequiredValue() bool

type EmittedCounts

type EmittedCounts struct {
	ReflowInput int64 `json:"reflow_input"`
	Probe       int64 `json:"probe"`
}

type ExtractorAudit

type ExtractorAudit struct {
	Name              string `json:"name"`
	Type              string `json:"type"`
	Resolved          bool   `json:"resolved"`
	Required          bool   `json:"required"`
	OnMissing         string `json:"on_missing,omitempty"`
	BytesAtResolution *int64 `json:"bytes_at_resolution"`
	ResolvedPriority  *int   `json:"resolved_priority,omitempty"`
	ResolvedXPath     string `json:"resolved_xpath,omitempty"`
	TruncatedFallback bool   `json:"truncated_fallback,omitempty"`
}

type ExtractorConfig

type ExtractorConfig struct {
	Name      string `json:"name" yaml:"name"`
	Type      string `json:"type" yaml:"type"`
	Required  bool   `json:"required,omitempty" yaml:"required,omitempty"`
	OnMissing string `json:"on_missing,omitempty" yaml:"on_missing,omitempty"`

	// For type=xml_xpath.
	XPath         string   `json:"xpath" yaml:"xpath"`
	XPathPriority []string `json:"xpath_priority,omitempty" yaml:"xpath_priority,omitempty"`

	// For type=regex.
	Pattern string `json:"pattern" yaml:"pattern"`
	Group   int    `json:"group" yaml:"group"`

	// For type=json_path.
	JSONPath string `json:"json_path" yaml:"json_path"`
}

type JSONPath

type JSONPath struct {
	// contains filtered or unexported fields
}

JSONPath is a small JSON path selector.

Supported forms: - $.a.b.c - a.b.c - a[0].b

This is intentionally minimal for v0.1.x.

func CompileJSONPath

func CompileJSONPath(expr string) (*JSONPath, error)

func (*JSONPath) Eval

func (p *JSONPath) Eval(v any) (any, bool)

type ProbeAudit

type ProbeAudit struct {
	Extractors             []ExtractorAudit `json:"extractors"`
	BytesRead              int64            `json:"bytes_read"`
	TerminationReason      string           `json:"termination_reason"`
	TruncatedFallbackCount int              `json:"truncated_fallback_count,omitempty"`
}

type Prober

type Prober struct {
	// contains filtered or unexported fields
}

Prober executes configured extractors against a byte window.

func New

func New(cfg Config) (*Prober, error)

func NewNormalizedWithRewriteCaptures

func NewNormalizedWithRewriteCaptures(cfg *Config, rewriteCaptures []string) (*Prober, error)

NewNormalizedWithRewriteCaptures validates cfg in place and builds a prober from the normalized config. Callers that need config-derived runtime values after construction, such as read_strategy byte limits, should use this form.

func NewWithRewriteCaptures

func NewWithRewriteCaptures(cfg Config, rewriteCaptures []string) (*Prober, error)

func (*Prober) AllRequiredResolved

func (p *Prober) AllRequiredResolved(vars map[string]string) bool

func (*Prober) ApplyMissingPolicies

func (p *Prober) ApplyMissingPolicies(vars map[string]string, audit *ProbeAudit) (routingClass string, requiredFailed bool)

func (*Prober) ApplyMissingPoliciesDetailed

func (p *Prober) ApplyMissingPoliciesDetailed(vars map[string]string, audit *ProbeAudit, failures map[string]error) (routingClass string, requiredFailed bool, failureErr error)

func (*Prober) HasPriorityExtractors

func (p *Prober) HasPriorityExtractors() bool

func (*Prober) HasRequiredExtractors

func (p *Prober) HasRequiredExtractors() bool

func (*Prober) Probe

func (p *Prober) Probe(data []byte) (map[string]string, error)

Probe returns derived fields. Missing fields are omitted.

func (*Prober) ProbeDetailed

func (p *Prober) ProbeDetailed(data []byte, bytesRead int64, terminationReason string) (*Result, error)

func (*Prober) ProbeDetailedAllowIncomplete

func (p *Prober) ProbeDetailedAllowIncomplete(data []byte, bytesRead int64, terminationReason string, incomplete func(error) bool) (*Result, error)

func (*Prober) ProbeDetailedAllowIncompleteWithVars

func (p *Prober) ProbeDetailedAllowIncompleteWithVars(data []byte, bytesRead int64, terminationReason string, initialVars map[string]string, incomplete func(error) bool) (*Result, error)

func (*Prober) ProbeDetailedWithVars

func (p *Prober) ProbeDetailedWithVars(data []byte, bytesRead int64, terminationReason string, initialVars map[string]string) (*Result, error)

func (*Prober) RequiredResolvedForTermination

func (p *Prober) RequiredResolvedForTermination(res *Result) bool

func (*Prober) UnresolvedResult

func (p *Prober) UnresolvedResult(bytesRead int64, terminationReason string) *Result

type ReadStrategyConfig

type ReadStrategyConfig struct {
	Mode       string `json:"mode,omitempty" yaml:"mode,omitempty"`
	MaxBytes   string `json:"max_bytes,omitempty" yaml:"max_bytes,omitempty"`
	ChunkBytes string `json:"chunk_bytes,omitempty" yaml:"chunk_bytes,omitempty"`

	MaxBytesValue   int64 `json:"-" yaml:"-"`
	ChunkBytesValue int64 `json:"-" yaml:"-"`
}

type Result

type Result struct {
	Vars     map[string]string
	Audit    ProbeAudit
	Failures map[string]error
}

type RoutingCounts

type RoutingCounts struct {
	Normal     int64 `json:"normal"`
	Quarantine int64 `json:"quarantine"`
}

type Summary

type Summary struct {
	Inputs        int64            `json:"inputs"`
	Enumerated    int64            `json:"enumerated"`
	Processed     int64            `json:"processed"`
	Emitted       EmittedCounts    `json:"emitted"`
	Routing       RoutingCounts    `json:"routing"`
	Errors        int64            `json:"errors"`
	ErrorsByCode  map[string]int64 `json:"errors_by_code"`
	InvalidInputs int64            `json:"invalid_inputs"`
	Termination   string           `json:"termination"`
	ExitCode      int              `json:"exit_code"`
	BytesRead     int64            `json:"bytes_read"`
	WallMS        int64            `json:"wall_ms"`
}

Summary reports handled termination, not provider custody or pipeline success. All counters are present even for empty or failed invocations.

func ParseSummary

func ParseSummary(raw json.RawMessage) (Summary, error)

ParseSummary validates the exact control payload without treating it as an object or accepting arbitrary unknown record types. Errors never echo data.

func (Summary) Validate

func (s Summary) Validate() error

type XMLXPath

type XMLXPath struct {
	// contains filtered or unexported fields
}

XMLXPath is a deliberately small XPath-like selector.

Supported forms: - //TagName (match any element with local name TagName) - /a/b/c (match exact element path)

Predicates, attributes, and namespaces are not supported.

func CompileXMLXPath

func CompileXMLXPath(expr string) (*XMLXPath, error)

func (*XMLXPath) FindFirstText

func (x *XMLXPath) FindFirstText(xmlBytes []byte) (string, bool, error)

Jump to

Keyboard shortcuts

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