taskstats

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package taskstats aggregates per-task execution analytics from all available cloop data sources: task state, step log tokens, artifact files, and verification results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration renders a duration in a human-readable form: "2h 3m 15s", "45m 2s", "12s".

func VariancePct

func VariancePct(estimated, actual int) (float64, bool)

VariancePct returns the percentage variance of actual vs estimated minutes. Returns (0, false) when either is zero.

Types

type AggregateStats

type AggregateStats struct {
	TotalTasks      int
	DoneTasks       int
	SkippedTasks    int
	FailedTasks     int
	PendingTasks    int
	InProgressTasks int

	CompletionRate float64 // (done+skipped) / total
	SuccessRate    float64 // done / (done+failed) when done+failed > 0

	TotalEstimatedMinutes int
	TotalActualMinutes    int

	TotalInputTokens  int
	TotalOutputTokens int
	TotalCostUSD      float64

	TotalHealAttempts int
	TotalVerifyPasses int
	TotalVerifyFails  int

	// Ranked sub-lists
	SlowestTasks    []*TaskStats // top 5 by actual minutes (desc)
	MostHealedTasks []*TaskStats // top 5 by HealAttempts (desc)

	All []*TaskStats
}

AggregateStats summarises analytics across all tasks in a plan.

func Collect

func Collect(s *state.ProjectState, workDir, model string) *AggregateStats

Collect gathers analytics for all tasks in the plan. workDir is the project root (.cloop is a sub-directory of workDir). model is used for cost estimation and may be empty.

type Phase

type Phase struct {
	Name string
	At   time.Time
}

Phase is a named point on the task execution timeline.

type TaskStats

type TaskStats struct {
	TaskID    int
	TaskTitle string
	Status    pm.TaskStatus

	// Timing
	StartedAt   *time.Time
	CompletedAt *time.Time
	WallTime    time.Duration // CompletedAt - StartedAt when both set

	// Estimate accuracy
	EstimatedMinutes int
	ActualMinutes    int // measured (or derived from StartedAt/CompletedAt)

	// Resilience
	HealAttempts  int
	VerifyRetries int
	FailCount     int

	// Verification
	VerifyPasses int
	VerifyFails  int

	// Tokens & cost (aggregated from step log)
	InputTokens  int
	OutputTokens int
	CostUSD      float64
	HasCostData  bool

	// Mini timeline
	Phases []Phase
}

TaskStats holds collected analytics for a single task.

func CollectOne

func CollectOne(s *state.ProjectState, workDir, model string, taskID int) (*TaskStats, error)

CollectOne gathers analytics for the single task with the given ID. Returns (nil, error) if not found.

Jump to

Keyboard shortcuts

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