Documentation
¶
Overview ¶
Package cassette records and replays versioned direct-PTY evidence.
Index ¶
- Constants
- type Clock
- type Command
- type ContentDigest
- type DiscoveryRecord
- type Emulator
- type Event
- type EventKind
- type FinalRecord
- type FrameRecord
- type Harness
- type InputRecord
- type Manifest
- type OpenOption
- type OutputRecord
- type Provenance
- type QuotaRecord
- type Reader
- func (r *Reader) Discovery() *DiscoveryRecord
- func (r *Reader) Events() ([]Event, error)
- func (r *Reader) Final() FinalRecord
- func (r *Reader) Frames() []FrameRecord
- func (r *Reader) Inputs() []InputRecord
- func (r *Reader) Manifest() Manifest
- func (r *Reader) OutputBytes(rec OutputRecord) ([]byte, error)
- func (r *Reader) OutputChunks() []OutputRecord
- func (r *Reader) Quota() *QuotaRecord
- func (r *Reader) RawOutput() []byte
- func (r *Reader) Replay(ctx context.Context, opts ReplayOptions, sink func(Event) error) error
- func (r *Reader) ScrubReport() ScrubReport
- func (r *Reader) ServiceEvents() []ServiceEventRecord
- type RecordLock
- type Recorder
- func (r *Recorder) Close() error
- func (r *Recorder) Manifest() Manifest
- func (r *Recorder) RecordFinal(final FinalRecord) error
- func (r *Recorder) RecordFrame(frame terminal.Frame) (FrameRecord, error)
- func (r *Recorder) RecordInput(kind session.EventKind, b []byte, key session.Key, size *session.Size, ...) (InputRecord, error)
- func (r *Recorder) RecordOutput(chunk session.OutputChunk) (OutputRecord, error)
- func (r *Recorder) RecordServiceEvent(payload any) (ServiceEventRecord, error)
- func (r *Recorder) RecordSessionEvent(ev session.Event) error
- func (r *Recorder) WriteDiscovery(discovery DiscoveryRecord) error
- func (r *Recorder) WriteQuota(quota QuotaRecord) error
- func (r *Recorder) WriteScrubReport(report ScrubReport) error
- type RecorderOption
- type ReplayMode
- type ReplayOptions
- type ScrubReport
- type Scrubber
- type ServiceEventRecord
- type Sleeper
- type Terminal
- type Timed
- type Timing
Constants ¶
View Source
const ( Version = 1 ManifestFile = "manifest.json" InputFile = "input.jsonl" OutputRawFile = "output.raw" OutputEventsFile = "output.jsonl" FramesFile = "frames.jsonl" ServiceEventsFile = "service-events.jsonl" FinalFile = "final.json" QuotaFile = "quota.json" DiscoveryFile = "discovery.json" ScrubReportFile = "scrub-report.json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentDigest ¶
type ContentDigest struct {
SHA256 string `json:"sha256"`
}
type DiscoveryRecord ¶
type DiscoveryRecord struct {
Source string `json:"source"`
Status string `json:"status"`
Models []string `json:"models,omitempty"`
ReasoningLevels []string `json:"reasoning_levels,omitempty"`
CapturedAt string `json:"captured_at,omitempty"`
FreshnessWindow string `json:"freshness_window,omitempty"`
StalenessBehavior string `json:"staleness_behavior,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
DiscoveryRecord stores harness capability evidence captured from a live PTY or a documented CLI surface and replayed by tests without credentials.
type Event ¶
type Event struct {
Seq uint64
TMS int64
Kind EventKind
Input *InputRecord
Output *OutputRecord
Frame *FrameRecord
Service *ServiceEventRecord
Final *FinalRecord
}
type FinalRecord ¶
type FinalRecord struct {
Timed
Exit *session.ExitStatus `json:"exit,omitempty"`
DurationMS int64 `json:"duration_ms"`
Metadata map[string]any `json:"metadata,omitempty"`
Usage map[string]any `json:"usage,omitempty"`
CostUSD float64 `json:"cost_usd,omitempty"`
RoutingActual string `json:"routing_actual,omitempty"`
SessionLogPath string `json:"session_log_path,omitempty"`
FinalText string `json:"final_text,omitempty"`
}
type FrameRecord ¶
type FrameRecord struct {
Timed
Size terminal.Size `json:"size"`
Text []string `json:"text"`
Cells [][]terminal.Cell `json:"cells,omitempty"`
Cursor terminal.Cursor `json:"cursor"`
Title string `json:"title,omitempty"`
RawStart int64 `json:"raw_start"`
RawEnd int64 `json:"raw_end"`
ParserOffset int64 `json:"parser_offset"`
}
type Harness ¶
type Harness struct {
Name string `json:"name"`
BinaryPathDigestSHA string `json:"binary_path_digest_sha256,omitempty"`
BinaryVersion string `json:"binary_version,omitempty"`
Capability map[string]any `json:"capability,omitempty"`
AccountClass string `json:"account_class,omitempty"`
CapturedAt string `json:"captured_at,omitempty"`
FreshnessWindow string `json:"freshness_window,omitempty"`
}
type InputRecord ¶
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
ID string `json:"id"`
ContentDigest ContentDigest `json:"content_digest"`
Harness Harness `json:"harness"`
Command Command `json:"command"`
Terminal Terminal `json:"terminal"`
Timing Timing `json:"timing"`
Provenance Provenance `json:"provenance"`
RequiredFeatures []string `json:"required_features,omitempty"`
Optional map[string]any `json:"optional,omitempty"`
}
type OpenOption ¶
type OpenOption func(*openConfig)
func WithExpectedBinding ¶
func WithExpectedBinding(id, sha256 string) OpenOption
func WithRequiredEmulator ¶
func WithRequiredEmulator(emulator Emulator) OpenOption
type OutputRecord ¶
type Provenance ¶
type QuotaRecord ¶
type QuotaRecord struct {
Source string `json:"source"`
Status string `json:"status"`
CapturedAt string `json:"captured_at,omitempty"`
FreshnessWindow string `json:"freshness_window,omitempty"`
StalenessBehavior string `json:"staleness_behavior,omitempty"`
AccountClass string `json:"account_class,omitempty"`
Windows []map[string]any `json:"windows,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) Discovery ¶
func (r *Reader) Discovery() *DiscoveryRecord
func (*Reader) Final ¶
func (r *Reader) Final() FinalRecord
func (*Reader) Frames ¶
func (r *Reader) Frames() []FrameRecord
func (*Reader) Inputs ¶
func (r *Reader) Inputs() []InputRecord
func (*Reader) OutputBytes ¶
func (r *Reader) OutputBytes(rec OutputRecord) ([]byte, error)
func (*Reader) OutputChunks ¶
func (r *Reader) OutputChunks() []OutputRecord
func (*Reader) Quota ¶
func (r *Reader) Quota() *QuotaRecord
func (*Reader) ScrubReport ¶
func (r *Reader) ScrubReport() ScrubReport
func (*Reader) ServiceEvents ¶
func (r *Reader) ServiceEvents() []ServiceEventRecord
type RecordLock ¶
type RecordLock struct {
// contains filtered or unexported fields
}
func AcquireRecordLock ¶
func AcquireRecordLock(root, account string) (*RecordLock, error)
func (*RecordLock) Release ¶
func (l *RecordLock) Release() error
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
func (*Recorder) RecordFinal ¶
func (r *Recorder) RecordFinal(final FinalRecord) error
func (*Recorder) RecordFrame ¶
func (r *Recorder) RecordFrame(frame terminal.Frame) (FrameRecord, error)
func (*Recorder) RecordInput ¶
func (*Recorder) RecordOutput ¶
func (r *Recorder) RecordOutput(chunk session.OutputChunk) (OutputRecord, error)
func (*Recorder) RecordServiceEvent ¶
func (r *Recorder) RecordServiceEvent(payload any) (ServiceEventRecord, error)
func (*Recorder) WriteDiscovery ¶
func (r *Recorder) WriteDiscovery(discovery DiscoveryRecord) error
func (*Recorder) WriteQuota ¶
func (r *Recorder) WriteQuota(quota QuotaRecord) error
func (*Recorder) WriteScrubReport ¶
func (r *Recorder) WriteScrubReport(report ScrubReport) error
type RecorderOption ¶
type RecorderOption func(*recorderConfig)
func WithClock ¶
func WithClock(clock Clock) RecorderOption
type ReplayMode ¶
type ReplayMode string
const ( ReplayRealtime ReplayMode = "realtime" ReplayScaled ReplayMode = "scaled" ReplayCollapsed ReplayMode = "collapsed" )
type ReplayOptions ¶
type ReplayOptions struct {
Mode ReplayMode
Scale float64
Sleeper Sleeper
}
type ScrubReport ¶
type Scrubber ¶
type Scrubber struct {
Home string
Worktree string
EnvAllowlist []string
AccountIdentifiers []string
IntentionallyPreserved []string
// contains filtered or unexported fields
}
func NewScrubber ¶
func (*Scrubber) NormalizeVolatile ¶
func (*Scrubber) ScrubString ¶
func (s *Scrubber) ScrubString(input string) (string, ScrubReport)
type ServiceEventRecord ¶
type ServiceEventRecord struct {
Timed
Payload json.RawMessage `json:"payload"`
}
type Timing ¶
type Timing struct {
ResolutionMS int64 `json:"resolution_ms"`
ClockPolicy string `json:"clock_policy"`
ReplayDefault ReplayMode `json:"replay_default"`
}
Click to show internal directories.
Click to hide internal directories.