runrecord

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package runrecord reconstructs durable run evidence without workflow history.

Index

Constants

View Source
const (
	// Adopted means a canonical record event names this call.
	Adopted CallClass = "adopted"
	// Abandoned means a terminal call was not named by a record event.
	Abandoned CallClass = "abandoned"
	// Incomplete means a call started without a durable completion.
	Incomplete CallClass = "incomplete"
	// PresentationAdopted means the presentation's call is adopted.
	PresentationAdopted PresentationClass = "adopted"
	// PresentedNotAdopted means a recorded presentation's call was not adopted.
	PresentedNotAdopted PresentationClass = "presented-not-adopted"
	// PresentedUnrecorded means a standalone presentation carries no call key.
	PresentedUnrecorded PresentationClass = "presented-unrecorded"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	// Record is the original opaque keyed call record.
	Record runstore.CallRecord `json:"record"`
	// Class is derived solely from canonical adoption events and record state.
	Class CallClass `json:"class"`
	// Activity identifies the activity that made the call.
	Activity callrecord.ActivityKind `json:"activity"`
	// Step is the activity's recorded planner step.
	Step int `json:"step"`
	// Started is the decoded immutable request and identity.
	Started callrecord.Started `json:"started"`
	// Completion is nil for incomplete calls.
	Completion *callrecord.Completion `json:"completion"`
	// Request is the verified exported model request.
	Request *model.Request `json:"request"`
}

Call combines the original evidence with its exact rebuilt request.

type CallClass

type CallClass string

CallClass reports adoption independently of a call's terminal outcome.

type Checkpoint

type Checkpoint struct {
	// Scope owns the immutable record.
	Scope string `json:"scope"`
	// Hash is its content address.
	Hash runstore.Hash `json:"hash"`
	// Record contains every field of the stored checkpoint.
	Record index.CheckpointRecord `json:"record"`
}

Checkpoint qualifies resolved compaction evidence by content scope.

type ContentPart

type ContentPart struct {
	// EntryID is the originating canonical transcript position.
	EntryID index.MessageID `json:"entry_id"`
	// InputID identifies a typed input, when applicable.
	InputID string `json:"input_id,omitzero"`
	// Hash is the original content address.
	Hash runstore.Hash `json:"hash"`
	// Content is the exact stored payload, not a preview.
	Content []byte `json:"content"`
}

ContentPart associates full content with its transcript entry or run-log event.

type Export

type Export struct {
	// Version identifies this export schema.
	Version int `json:"version"`
	// RootRunID is the original content scope.
	RootRunID string `json:"root_run_id"`
	// Runs includes all evidence and rebuilt requests in parent-first order.
	Runs []Run `json:"runs"`
	// Content holds exact addressed bytes, including server-only content.
	Content map[runstore.Hash][]byte `json:"content"`
}

Export is the version-1 self-contained run-tree encoding. It includes rendered transcripts so reading it never depends on historical template implementations.

func (Export) Marshal

func (e Export) Marshal() ([]byte, error)

Marshal returns deterministic JSON v2, including nanosecond durations.

type Presentation

type Presentation struct {
	// ID is the activity's presentation identifier.
	ID string `json:"id"`
	// EventKey identifies the canonical atomic presentation commit.
	EventKey string `json:"event_key"`
	// Call names its recorded model invocation, or is nil for standalone streams.
	Call *runstore.CallKey `json:"call"`
	// Class separates adopted, unadopted and unrecorded presentations.
	Class PresentationClass `json:"class"`
}

Presentation is one committed presentation and its adoption classification.

type PresentationClass

type PresentationClass string

PresentationClass reports whether a committed presentation was adopted.

type ProjectedCall

type ProjectedCall struct {
	Key       runstore.CallKey   `json:"key"`
	Class     CallClass          `json:"class"`
	State     runstore.CallState `json:"state"`
	Activity  string             `json:"activity"`
	Step      int                `json:"step"`
	Model     string             `json:"model"`
	Started   time.Time          `json:"started"`
	ErrorKind string             `json:"error_kind,omitzero"`
	Error     jsontext.Value     `json:"error,omitzero"`
	Usage     model.TokenUsage   `json:"usage"`
	LatencyNS int64              `json:"latency_ns"`
	Request   []ProjectedMessage `json:"request"`
	Response  []ProjectedMessage `json:"response"`
	ToolCalls []ProjectedValue   `json:"tool_calls"`
}

ProjectedCall retains call identity independently of adoption and outcome.

type ProjectedEvent

type ProjectedEvent struct {
	ID           string         `json:"id"`
	Type         string         `json:"type"`
	AgentID      string         `json:"agent_id"`
	SessionID    string         `json:"session_id"`
	TurnID       string         `json:"turn_id"`
	Timestamp    time.Time      `json:"timestamp"`
	Status       string         `json:"status,omitzero"`
	Phase        string         `json:"phase,omitzero"`
	ChildRunID   string         `json:"child_run_id,omitzero"`
	ChildAgentID string         `json:"child_agent_id,omitzero"`
	ToolID       string         `json:"tool_id,omitzero"`
	ToolName     string         `json:"tool_name,omitzero"`
	Diagnostic   jsontext.Value `json:"diagnostic,omitzero"`
}

ProjectedEvent contains only terminal outcomes or child-run attribution. Other event payloads are explicitly omitted, never copied wholesale.

type ProjectedMessage

type ProjectedMessage struct {
	Role     model.ConversationRole `json:"role"`
	Parts    []ProjectedValue       `json:"parts"`
	Metadata jsontext.Value         `json:"metadata,omitzero"`
}

ProjectedMessage retains the original message boundary and speaker.

type ProjectedRun

type ProjectedRun struct {
	RunID      string             `json:"run_id"`
	Sealed     bool               `json:"sealed"`
	Transcript []ProjectedMessage `json:"transcript"`
	Calls      []ProjectedCall    `json:"calls"`
	Events     []ProjectedEvent   `json:"events"`
	Content    []ProjectedValue   `json:"content"`
}

ProjectedRun preserves run attribution, outcomes and selected content.

type ProjectedValue

type ProjectedValue struct {
	Kind        string           `json:"kind"`
	Path        string           `json:"path"`
	ToolID      string           `json:"tool_id,omitzero"`
	ToolName    string           `json:"tool_name,omitzero"`
	IsError     bool             `json:"is_error,omitzero"`
	Value       jsontext.Value   `json:"value,omitzero"`
	Attachments []ProjectedValue `json:"attachments,omitzero"`
}

ProjectedValue contains policy-approved content, without a raw content hash.

type Projection

type Projection struct {
	Kind       string               `json:"kind"`
	Version    int                  `json:"version"`
	Source     ProjectionSource     `json:"source"`
	Policy     string               `json:"policy"`
	Incomplete bool                 `json:"incomplete"`
	Runs       []ProjectedRun       `json:"runs"`
	Omissions  []ProjectionOmission `json:"omissions"`
	Failures   []ProjectionFailure  `json:"failures"`
}

Projection is a sharing artifact, never a replay export. Source hashes refer only to the original export; projected values make no replay-fidelity claim.

func FromProjection

func FromProjection(data []byte) (*Projection, error)

FromProjection decodes only the separate sharing schema. It does not restore a RunRecord and cannot be passed to a replay API.

func (*Projection) Marshal

func (p *Projection) Marshal() ([]byte, error)

Marshal deterministically encodes a sharing artifact, including its explicit Incomplete marker. Consumers must not treat incomplete evidence as complete.

type ProjectionContent

type ProjectionContent struct {
	Kind  string
	Path  string
	RunID string
	Role  model.ConversationRole
	Value jsontext.Value
}

ProjectionContent is one classified candidate at an unambiguous source path.

type ProjectionFailure

type ProjectionFailure struct {
	Path string `json:"path"`
	Code string `json:"code"`
}

ProjectionFailure reports a failed projection without copying unsafe errors.

type ProjectionOmission

type ProjectionOmission struct {
	Path string `json:"path"`
	Kind string `json:"kind"`
}

ProjectionOmission records an intentionally excluded source value.

type ProjectionPolicy

type ProjectionPolicy struct {
	Name    string
	Content func(ProjectionContent) (value jsontext.Value, include bool, err error)
}

ProjectionPolicy explicitly approves, transforms or omits every content leaf. Name should identify the application's exact versioned sharing policy. Content receives owned JSON and must return valid JSON when include is true. No PII detection or authorization is implicit. Identity and structural outcomes are always retained; applications must authorize sharing those before projecting.

type ProjectionSource

type ProjectionSource struct {
	RootRunID    string `json:"root_run_id"`
	ExportSHA256 string `json:"export_sha256"`
}

ProjectionSource identifies the original raw evidence, not projected bytes.

type Run

type Run struct {
	// ModelCallLimit records an unsent logical invocation refused by the run cap.
	ModelCallLimit *policy.ModelCallLimit `json:"model_call_limit,omitzero"`
	// NonTextResident reconstructs sticky original-attachment preservation.
	NonTextResident bool `json:"nontext_resident,omitzero"`
	// ToolResultParts is the support intersection rebuilt from adopted call facts.
	ToolResultParts model.ToolResultPartSupport `json:"tool_result_parts,omitzero"`
	// Pos and Prev are recorded session-chain identity, absent on older exports.
	Pos  int     `json:"pos,omitzero"`
	Prev *string `json:"prev,omitzero"`

	// Summary rebuilds rejection disablement from canonical summary records.
	Summary compaction.SummaryState `json:"summary,omitzero"`
	// ContextFingerprint identifies the stored canonical effective settings.
	ContextFingerprint string `json:"context_fingerprint,omitzero"`
	// ContextSettings holds resolved recovery and threshold settings for every agent.
	ContextSettings *compaction.ContextSettings `json:"context_settings,omitzero"`
	// RecoverySettings is the resolved runtime-stamped lookup configuration.
	RecoverySettings *run.ContextRecovery `json:"recovery_settings,omitzero"`
	// Recall reconstructs independently charged and refilled allowances.
	Recall compaction.RecallAllowances `json:"recall,omitzero"`
	// CompactionSettings contains client-stamped threshold settings from adoption records.
	CompactionSettings *compaction.Settings `json:"compaction_settings,omitzero"`
	// KeepResultTools contains the recorded result retention list.
	KeepResultTools []tools.Ident `json:"keep_result_tools,omitzero"`
	// RunID identifies this run.
	RunID string `json:"run_id"`
	// WorkflowProtocolVersion is the record-event stamp, or zero when no stamp exists.
	WorkflowProtocolVersion int `json:"workflow_protocol_version"`
	// Sealed reports whether terminal workflow code committed the last head.
	Sealed bool `json:"sealed"`
	// IndexHead is the seal head, or the latest planner-step head.
	IndexHead runstore.Hash `json:"index_head"`
	// Entries contains only the authoritative head's reachable entries.
	Entries []index.MessageEntry `json:"entries"`
	// Transcript is the rendered transcript, without history-policy filtering.
	Transcript []*model.Message `json:"transcript"`
	// Checkpoints contains every checkpoint resolved from recorded views.
	Checkpoints []Checkpoint `json:"checkpoints"`
	// Calls includes every attempt, including zombie and incomplete records.
	Calls []Call `json:"calls"`
	// Presentations describes committed presentations independently of transcript.
	Presentations []Presentation `json:"presentations"`
	// TypedAnswers contains complete typed-input payloads.
	TypedAnswers []ContentPart `json:"typed_answers"`
	// AwaitAnswers contains complete clarification answers.
	AwaitAnswers []ContentPart `json:"await_answers"`
	// Results contains full model-eligible results, including previewed results.
	Results []ContentPart `json:"results"`
	// ServerOnly contains record-only content, never included in Transcript.
	ServerOnly []ContentPart `json:"server_only"`
	// Events is the canonical run log, in store order.
	Events []*runlog.Event `json:"events"`
}

Run holds one run's transcript and evidence in canonical order.

type RunRecord

type RunRecord struct {
	// RootRunID is the authorized content scope.
	RootRunID string `json:"root_run_id"`
	// Runs is parent-first, following canonical child-link order.
	Runs []Run `json:"runs"`
	// Content includes every resolved address, including server-only bytes.
	Content map[runstore.Hash][]byte `json:"content"`
}

RunRecord is a self-contained record of a run and its linked descendants.

func FromExport

func FromExport(data []byte) (*RunRecord, error)

FromExport decodes an export and verifies new attachment evidence entirely from its included content and canonical records.

func Read

func Read(ctx context.Context, store runstore.Store, log runlog.Store, rootRunID, runID string) (*RunRecord, error)

Read reconstructs a parent-first run tree from root-scoped content and the canonical log alone. It never queries a workflow engine or observer projection.

func (*RunRecord) Export

func (r *RunRecord) Export() Export

Export returns a versioned snapshot suitable for deterministic encoding.

func (*RunRecord) Project

func (r *RunRecord) Project(policy ProjectionPolicy) (*Projection, error)

Project applies an explicit application policy to a fresh sharing DTO. On a content failure it returns partial evidence marked Incomplete and a joined error. Neither the source record nor any source-owned bytes are mutated.

Jump to

Keyboard shortcuts

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