metrics

package
v0.14.0 Latest Latest
Warning

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

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

Documentation

Overview

Package metrics provides dashboard rendering for project metrics.

Package metrics provides evaluation and reconciliation metrics tracking.

This package collects and aggregates metrics about spec quality, evaluation results, and reconciliation outcomes to provide insights into the specification process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlignMetrics

type AlignMetrics struct {
	AlignmentScore   float64 `json:"alignment_score"`
	CoveragePercent  float64 `json:"coverage_percent"`
	DiscrepancyCount int     `json:"discrepancy_count"`
	CriticalCount    int     `json:"critical_count"`
	HighCount        int     `json:"high_count"`
	MediumCount      int     `json:"medium_count"`
	LowCount         int     `json:"low_count"`
	MissingFeatures  int     `json:"missing_features"`
	UndocumentedCode int     `json:"undocumented_code"`
}

AlignMetrics contains alignment-related metrics.

type Collector

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

Collector gathers metrics from various sources.

func NewCollector

func NewCollector(projectPath string) (*Collector, error)

NewCollector creates a new metrics collector.

func (*Collector) Collect

func (c *Collector) Collect() (*ProjectMetrics, error)

Collect gathers all available metrics for the project.

func (*Collector) History

func (c *Collector) History() *MetricsHistory

History returns the metrics history tracker.

type Dashboard

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

Dashboard renders project metrics in various formats.

func NewDashboard

func NewDashboard(metrics *ProjectMetrics) *Dashboard

NewDashboard creates a new dashboard from project metrics.

func (*Dashboard) Render

func (d *Dashboard) Render(w io.Writer, format OutputFormat) error

Render outputs the dashboard in the specified format.

type DriftMetrics

type DriftMetrics struct {
	HasDrift       bool    `json:"has_drift"`
	DriftScore     float64 `json:"drift_score"`
	ItemCount      int     `json:"item_count"`
	CriticalCount  int     `json:"critical_count"`
	HighCount      int     `json:"high_count"`
	TrendDirection string  `json:"trend_direction"` // "improving", "stable", "degrading"
}

DriftMetrics contains drift-related metrics.

type EvalMetrics

type EvalMetrics struct {
	TotalEvaluations int                `json:"total_evaluations"`
	PassCount        int                `json:"pass_count"`
	FailCount        int                `json:"fail_count"`
	AverageScore     float64            `json:"average_score"`
	ScoresBySpec     map[string]float64 `json:"scores_by_spec"`
	FindingsCount    int                `json:"findings_count"`
	BySeverity       map[string]int     `json:"by_severity"`
	Trend            []TrendPoint       `json:"trend,omitempty"`
}

EvalMetrics contains evaluation-related metrics.

type Metric

type Metric struct {
	Type      MetricType        `json:"type"`
	Name      string            `json:"name"`
	Value     float64           `json:"value"`
	Unit      string            `json:"unit,omitempty"`
	Timestamp time.Time         `json:"timestamp"`
	Labels    map[string]string `json:"labels,omitempty"`
}

Metric represents a single metric data point.

type MetricType

type MetricType string

MetricType categorizes different types of metrics.

const (
	MetricTypeEval      MetricType = "evaluation"
	MetricTypeReconcile MetricType = "reconciliation"
	MetricTypeAlign     MetricType = "alignment"
	MetricTypeDrift     MetricType = "drift"
	MetricTypeCoverage  MetricType = "coverage"
)

type MetricsHistory

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

MetricsHistory tracks metrics over time.

func NewMetricsHistory

func NewMetricsHistory(path string) (*MetricsHistory, error)

NewMetricsHistory creates a new metrics history tracker. Returns an error if the history file exists but cannot be parsed.

func (*MetricsHistory) Add

func (h *MetricsHistory) Add(entry MetricsHistoryEntry)

Add adds a new entry to history.

func (*MetricsHistory) Recent

func (h *MetricsHistory) Recent(count int) []MetricsHistoryEntry

Recent returns the most recent entries.

func (*MetricsHistory) Save

func (h *MetricsHistory) Save() error

Save persists history to file.

func (*MetricsHistory) Trend

func (h *MetricsHistory) Trend() string

Trend returns the trend direction based on recent history.

type MetricsHistoryEntry

type MetricsHistoryEntry struct {
	Timestamp   time.Time `json:"timestamp"`
	HealthScore float64   `json:"health_score"`
	EvalScore   float64   `json:"eval_score,omitempty"`
	AlignScore  float64   `json:"align_score,omitempty"`
}

MetricsHistoryEntry represents a single history entry.

type MetricsSummary

type MetricsSummary struct {
	TotalSpecs     int     `json:"total_specs"`
	ApprovedSpecs  int     `json:"approved_specs"`
	EvaluatedSpecs int     `json:"evaluated_specs"`
	PassingEvals   int     `json:"passing_evals"`
	OverallScore   float64 `json:"overall_score"`
	ReadinessScore float64 `json:"readiness_score"`
	QualityScore   float64 `json:"quality_score"`
}

MetricsSummary provides high-level project health indicators.

type OutputFormat

type OutputFormat string

OutputFormat specifies the dashboard output format.

const (
	FormatJSON     OutputFormat = "json"
	FormatHTML     OutputFormat = "html"
	FormatTerminal OutputFormat = "terminal"
	FormatMarkdown OutputFormat = "markdown"
)

type ProjectMetrics

type ProjectMetrics struct {
	Project      string            `json:"project"`
	GeneratedAt  time.Time         `json:"generated_at"`
	Eval         *EvalMetrics      `json:"evaluation,omitempty"`
	Reconcile    *ReconcileMetrics `json:"reconciliation,omitempty"`
	Align        *AlignMetrics     `json:"alignment,omitempty"`
	Drift        *DriftMetrics     `json:"drift,omitempty"`
	Summary      MetricsSummary    `json:"summary"`
	HealthScore  float64           `json:"health_score"`  // 0-100
	HealthStatus string            `json:"health_status"` // "healthy", "warning", "critical"
}

ProjectMetrics contains all metrics for a project.

type ReconcileMetrics

type ReconcileMetrics struct {
	TotalReconciliations int        `json:"total_reconciliations"`
	SuccessCount         int        `json:"success_count"`
	ConflictCount        int        `json:"conflict_count"`
	AverageTime          float64    `json:"average_time_seconds"`
	SpecsIncluded        int        `json:"specs_included"`
	TasksGenerated       int        `json:"tasks_generated"`
	LastReconcile        *time.Time `json:"last_reconcile,omitempty"`
}

ReconcileMetrics contains reconciliation-related metrics.

type TrendPoint

type TrendPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
	Label     string    `json:"label,omitempty"`
}

TrendPoint represents a point in a trend over time.

Jump to

Keyboard shortcuts

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