agentruns

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package agentruns records and reads persisted agent run metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prune

func Prune(runStore Store, taskStore background.Store, options background.PruneOptions) (background.PruneResult, error)

Prune removes stale completed or orphaned agent run records while preserving running tasks and the newest retained completed runs.

Types

type Board

type Board struct {
	GeneratedAt time.Time    `json:"generated_at"`
	Active      []BoardEntry `json:"active"`
	Blocked     []BoardEntry `json:"blocked"`
	Finished    []BoardEntry `json:"finished"`
	Orphaned    []BoardEntry `json:"orphaned,omitempty"`
}

Board groups agent runs by current execution state for operator views.

func BuildBoard

func BuildBoard(store background.Store, runs []Run, now time.Time, stalledAfter time.Duration) Board

BuildBoard groups agent runs into active, blocked, finished, and orphaned lanes using their background task state.

type BoardEntry

type BoardEntry struct {
	Run             Run                            `json:"run"`
	Task            *background.Task               `json:"task,omitempty"`
	Status          string                         `json:"status"`
	Freshness       background.LaneFreshness       `json:"freshness"`
	Provenance      background.EventProvenance     `json:"provenance"`
	ScopeBinding    background.ScopeBinding        `json:"scope_binding"`
	Lifecycle       background.LifecycleResolution `json:"lifecycle"`
	TerminalOutcome *background.TerminalOutcome    `json:"terminal_outcome,omitempty"`
	Heartbeat       *background.LaneHeartbeat      `json:"heartbeat,omitempty"`
	Error           string                         `json:"error,omitempty"`
}

BoardEntry is the lane-board view for a single agent run.

type HealthReport

type HealthReport struct {
	State             string `json:"state"`
	Summary           string `json:"summary"`
	RecommendedAction string `json:"recommended_action,omitempty"`
}

HealthReport gives operators a compact diagnosis and next action for a run.

type Run

type Run struct {
	ID           string    `json:"id"`
	Agent        string    `json:"agent"`
	Prompt       string    `json:"prompt,omitempty"`
	Workspace    string    `json:"workspace,omitempty"`
	SessionID    string    `json:"session_id,omitempty"`
	TaskID       string    `json:"task_id"`
	WorktreeID   string    `json:"worktree_id,omitempty"`
	WorktreePath string    `json:"worktree_path,omitempty"`
	WorktreeRef  string    `json:"worktree_ref,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

Run records the relationship between a named agent invocation and the background task that executes it.

type Status

type Status struct {
	Run             Run                            `json:"run"`
	Task            *background.Task               `json:"task,omitempty"`
	CurrentStatus   string                         `json:"current_status"`
	Heartbeat       *background.LaneHeartbeat      `json:"heartbeat,omitempty"`
	Freshness       background.LaneFreshness       `json:"freshness"`
	Provenance      background.EventProvenance     `json:"provenance"`
	ScopeBinding    background.ScopeBinding        `json:"scope_binding"`
	Lifecycle       background.LifecycleResolution `json:"lifecycle"`
	TerminalOutcome *background.TerminalOutcome    `json:"terminal_outcome,omitempty"`
	Health          HealthReport                   `json:"health"`
	Error           string                         `json:"error,omitempty"`
}

Status combines an agent run record with the current state of its background task, when that task can still be found.

func StatusForTask

func StatusForTask(store background.Store, run Run) Status

StatusForTask resolves an agent run against the background task store.

func StatusForTaskAt

func StatusForTaskAt(store background.Store, run Run, now time.Time, stalledAfter time.Duration) Status

StatusForTaskAt resolves an agent run at a specific time, which makes heartbeat freshness deterministic in tests and bridge status calls.

type Store

type Store struct {
	Dir string
}

Store persists agent run records under the Codog config home.

func NewStore

func NewStore(configHome string) Store

NewStore returns the agent run store rooted at configHome.

func (Store) Get

func (s Store) Get(id string) (Run, error)

Get loads a single agent run by id.

func (Store) List

func (s Store) List() ([]Run, error)

List returns all saved agent runs, newest first.

func (Store) Remove

func (s Store) Remove(id string) error

Remove deletes a saved agent run record.

func (Store) Save

func (s Store) Save(run Run) (Run, error)

Save writes a complete agent run record, filling timestamps when they are missing.

func (Store) Touch

func (s Store) Touch(id string) (Run, error)

Touch refreshes a run's UpdatedAt timestamp and saves it.

Jump to

Keyboard shortcuts

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