recorder

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package recorder captures bounded application-layer observations and commits only sanitized payloads to the evidence CAS.

Index

Constants

View Source
const DefaultMaxObservationBytes = 1 << 20
View Source
const DefaultMaxSSEBufferBytes = 1 << 20

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RunID               schema.InstanceID
	InvocationID        schema.InstanceID
	AttemptID           schema.InstanceID
	Producer            schema.Producer
	CaptureLayer        schema.CaptureLayer
	InstrumentationMode schema.InstrumentationMode
	MaxObservationBytes int
	Now                 func() time.Time
}

Config freezes the observation point for a recorder. A caller cannot change capture layer or instrumentation mode on individual observations.

type Observation

type Observation struct {
	Sequence            uint64
	CaptureLayer        schema.CaptureLayer
	InstrumentationMode schema.InstrumentationMode
	Direction           schema.Direction
	Kind                string
	MonotonicOffsetNS   int64
	ByteOffset          *int64
	EventOffset         *int64
	Payload             []byte
	Format              PayloadFormat
	Relations           []schema.EvidenceRelation
}

Observation is source-faithful only at its declared application capture layer. Payload remains in memory until redaction succeeds.

type PayloadFormat

type PayloadFormat string
const (
	PayloadText PayloadFormat = "text"
	PayloadJSON PayloadFormat = "json"
)

type ReadChunk

type ReadChunk struct {
	Sequence   uint64
	ByteOffset int64
	Data       []byte
}

ReadChunk is one transport read at an explicitly declared application capture layer. Its boundary is not an SSE logical-event boundary.

type Recorder

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

func New

func New(config Config, redactorInstance *redaction.Redactor, store *cas.Store) (*Recorder, error)

func (*Recorder) Record

func (recorder *Recorder) Record(ctx context.Context, observation Observation) (schema.Evidence, error)

Record sanitizes an in-memory observation, commits the sanitized bytes to CAS, constructs digest-bound evidence, and persists that typed envelope. Sequence advances only after both immutable objects validate and commit.

type SSEAssembler

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

func NewSSEAssembler

func NewSSEAssembler(maxBufferBytes int) *SSEAssembler

func (*SSEAssembler) Feed

func (assembler *SSEAssembler) Feed(chunk ReadChunk) ([]SSELogicalEvent, error)

Feed records one read boundary and emits zero or more logical SSE events. Arbitrary rechunking produces the same event fields while preserving different SourceChunkSequences.

func (*SSEAssembler) Finish

func (assembler *SSEAssembler) Finish() StreamTail

Finish reports an incomplete tail and deliberately does not dispatch it. A caller can therefore return inconclusive instead of inventing a terminal event at EOF.

type SSEField

type SSEField struct {
	Name  string
	Value string
}

type SSELogicalEvent

type SSELogicalEvent struct {
	Sequence             uint64
	EventOffset          int64
	Event                string
	Data                 string
	ID                   string
	RetryMillis          *int64
	Fields               []SSEField
	Issues               []string
	SourceChunkSequences []uint64
}

SSELogicalEvent is assembled from lines and retains the read chunks that contributed bytes. SourceChunkSequences is provenance, not event identity.

type StreamTail

type StreamTail struct {
	BufferedBytes        int
	PendingFieldCount    int
	SourceChunkSequences []uint64
}

Jump to

Keyboard shortcuts

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