researchtrace

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 13 Imported by: 0 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

Index

Constants

View Source
const (
	SchemaVersion   = "research_trace.v1"
	CompleteMarker  = ".complete"
	DefaultKeepRuns = 500
	DefaultMaxAge   = 180 * 24 * time.Hour
)

Variables

This section is empty.

Functions

func ResolvePath

func ResolvePath(cfg config.Config, path string) (string, error)

Types

type ArtifactContents

type ArtifactContents struct {
	PlannerInput    string
	PlannerOutput   string
	PlannerAttempts map[string]PlannerAttemptContents
	SynthesisInput  string
}

type ChatContinuity

type ChatContinuity struct {
	OriginalQuestion    string                          `json:"original_question,omitempty"`
	RetrievalQuestion   string                          `json:"retrieval_question,omitempty"`
	PriorQuestionIDs    []string                        `json:"prior_question_ids,omitempty"`
	PinnedEvidenceKeys  []string                        `json:"pinned_evidence_keys,omitempty"`
	MergedPriorEvidence []string                        `json:"merged_prior_evidence,omitempty"`
	ContinuityAnchors   []brainresearch.ProtectedAnchor `json:"continuity_anchors,omitempty"`
}

type PlannerAttemptContents added in v0.3.0

type PlannerAttemptContents struct {
	Input  string
	Output string
}

type PlannerAttemptPaths added in v0.3.0

type PlannerAttemptPaths struct {
	InputPath  string `json:"input_path,omitempty"`
	OutputPath string `json:"output_path,omitempty"`
}

type PruneResult

type PruneResult struct {
	Deleted int
	Kept    int
}

func Prune

func Prune(cfg config.Config, opts RetentionOptions, activeRunID string) (PruneResult, error)

type Recorder

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

func NewRecorder

func NewRecorder(surface string, question string) *Recorder

func (*Recorder) Event

func (r *Recorder) Event(name string, data map[string]interface{})

func (*Recorder) PlannerInput

func (r *Recorder) PlannerInput(input string)

func (*Recorder) PlannerInputAttempt added in v0.3.0

func (r *Recorder) PlannerInputAttempt(attempt string, input string)

func (*Recorder) PlannerOutput

func (r *Recorder) PlannerOutput(output string)

func (*Recorder) PlannerOutputAttempt added in v0.3.0

func (r *Recorder) PlannerOutputAttempt(attempt string, output string)

func (*Recorder) SetChatContinuity

func (r *Recorder) SetChatContinuity(continuity *ChatContinuity)

func (*Recorder) SetClock

func (r *Recorder) SetClock(now func() time.Time)

func (*Recorder) SetFailure

func (r *Recorder) SetFailure(stage string, code string, err error)

func (*Recorder) SetPack

func (r *Recorder) SetPack(pack brainresearch.Pack)

func (*Recorder) SetPreparedSynthesis

func (r *Recorder) SetPreparedSynthesis(prepared brainresearch.PreparedSynthesis)

func (*Recorder) SetStopReason

func (r *Recorder) SetStopReason(reason string)

func (*Recorder) SetSynthesis

func (r *Recorder) SetSynthesis(result brainresearch.SynthesisResult)

func (*Recorder) Snapshot

func (r *Recorder) Snapshot() (ResearchTrace, ArtifactContents)

type ResearchTrace

type ResearchTrace struct {
	SchemaVersion     string                           `json:"schema_version"`
	RunID             string                           `json:"run_id"`
	Surface           string                           `json:"surface"`
	Question          string                           `json:"question"`
	ChatContinuity    *ChatContinuity                  `json:"chat_continuity,omitempty"`
	StartedAt         time.Time                        `json:"started_at"`
	CompletedAt       time.Time                        `json:"completed_at"`
	Events            []ResearchTraceEvent             `json:"events,omitempty"`
	Metrics           TraceMetrics                     `json:"metrics"`
	Pack              *brainresearch.Pack              `json:"pack,omitempty"`
	PreparedSynthesis *brainresearch.PreparedSynthesis `json:"prepared_synthesis,omitempty"`
	Synthesis         *brainresearch.SynthesisResult   `json:"synthesis,omitempty"`
	EvidenceFlow      *brainresearch.EvidenceFlow      `json:"evidence_flow,omitempty"`
	Artifacts         TraceArtifacts                   `json:"artifacts,omitempty"`
	StopReason        string                           `json:"stop_reason"`
	Failure           *TraceFailure                    `json:"failure,omitempty"`
}

func Decode

func Decode(data []byte) (ResearchTrace, error)

func Load

func Load(cfg config.Config, path string) (ResearchTrace, string, error)

type ResearchTraceEvent

type ResearchTraceEvent struct {
	At   time.Time              `json:"at"`
	Name string                 `json:"name"`
	Data map[string]interface{} `json:"data,omitempty"`
}

type RetentionOptions

type RetentionOptions struct {
	KeepLatest int
	MaxAge     time.Duration
	KeepAll    bool
}

type TraceArtifacts

type TraceArtifacts struct {
	PlannerInputPath    string                         `json:"planner_input_path,omitempty"`
	PlannerOutputPath   string                         `json:"planner_output_path,omitempty"`
	PlannerAttemptPaths map[string]PlannerAttemptPaths `json:"planner_attempt_paths,omitempty"`
	SynthesisInputPath  string                         `json:"synthesis_input_path,omitempty"`
}

type TraceFailure

type TraceFailure struct {
	Stage   string `json:"stage"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

type TraceMetrics

type TraceMetrics struct {
	TotalDurationMS            int64            `json:"total_duration_ms,omitempty"`
	StageDurationsMS           map[string]int64 `json:"stage_durations_ms,omitempty"`
	QueryVariantCount          int              `json:"query_variant_count,omitempty"`
	CandidateCountBeforeDedupe int              `json:"candidate_count_before_dedupe,omitempty"`
	EvidenceCountAfterDedupe   int              `json:"evidence_count_after_dedupe,omitempty"`
	ModelCallCount             int              `json:"model_call_count,omitempty"`
	CharactersSentToPlanner    int              `json:"characters_sent_to_planner,omitempty"`
	CharactersSentToSynthesis  int              `json:"characters_sent_to_synthesis,omitempty"`
	TraceArtifactBytes         int64            `json:"trace_artifact_bytes,omitempty"`
	PlannerEnabled             bool             `json:"planner_enabled"`
	Planner                    string           `json:"planner,omitempty"`
	PlannerFallbackStatus      string           `json:"planner_fallback_status,omitempty"`
}

type TraceSummary

type TraceSummary struct {
	RunID         string    `json:"run_id"`
	RelativePath  string    `json:"relative_path"`
	Surface       string    `json:"surface,omitempty"`
	Question      string    `json:"question,omitempty"`
	CompletedAt   time.Time `json:"completed_at,omitempty"`
	StopReason    string    `json:"stop_reason,omitempty"`
	EvidenceCount int       `json:"evidence_count,omitempty"`
	AnswerStatus  string    `json:"answer_status,omitempty"`
	LoadError     string    `json:"load_error,omitempty"`
}

func List

func List(cfg config.Config, limit int) ([]TraceSummary, error)

type WriteOptions

type WriteOptions struct {
	Retention RetentionOptions
	Now       func() time.Time
}

type WriteResult

type WriteResult struct {
	RunID        string
	RelativePath string
	Directory    string
	Bytes        int64
}

func Write

func Write(cfg config.Config, trace ResearchTrace, artifacts ArtifactContents, opts WriteOptions) (WriteResult, error)

Jump to

Keyboard shortcuts

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