dashboard

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package dashboard implements the HTML dashboard for visualizing scheduler state, task queues, and active foremen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoardStep

type BoardStep struct {
	ID     string
	Title  string
	Status string // "done" | "active" | "pending"
	Commit string
}

BoardStep is one task row from the board, for the roadmap visualization.

type FleetData

type FleetData struct {
	Title           string
	GeneratedAt     string
	BudgetTotal     int
	BudgetUsed      int
	ActiveTicks     int
	TotalProjects   int
	EnabledProjects int
	Projects        []FleetRow
	RecentTicks     []TickRow
	Namespaces      []NamespaceRow
	NamespaceTicks  []NamespaceTickRow
	CostTodayTotal  float64
	CostWeekTotal   float64
}

FleetData holds all data for the dashboard.

type FleetRow

type FleetRow struct {
	Name        string
	Weight      int
	Priority    int
	Enabled     bool
	LastTick    string
	LastOutcome string
	SessionID   string
	Urgency     float64
	RunningNow  int // 0 or 1; int avoids modernc.org/sqlite int→bool scan bug
	Completed   int
	Failed      int
	Timeout     int
	CostToday   float64
	CostWeek    float64
	// Board progress (parsed from <workdir>/.coding-hermes/tasks.md).
	Workdir           string
	CooldownS         int
	LastTickCompleted string
	BoardDone         int
	BoardTotal        int
	NextTickIn        string // human-readable "in Xm Ys", "running", "due now", or "—"
	// Recent cost series (last up-to-N completed ticks, oldest→newest) for the
	// cost sparkline, plus the count of recent failed/timeout ticks (failure flag).
	CostSeries     []float64
	RecentFailures int
	RecentTicks    int
	// Observability: average tick duration (seconds), success rate (0-100),
	// and estimated time-to-completion (from avg duration × steps left).
	AvgTickSecs int
	SuccessRate int // percent
	ETA         string
	// CompletionAt is the projected wall-clock completion as RFC3339 (UTC);
	// the dashboard renders it in the viewer's local timezone via JS.
	CompletionAt string
	// ProjectedCost is the estimated remaining cost to finish the board
	// (avg cost per completed tick × steps remaining).
	ProjectedCost float64
	// AvgCost is the mean cost per completed tick, used for live-cost estimate
	// of running ticks.
	AvgCost float64
	// EtaBreakdown is the learning-predictor per-type estimate, e.g.
	// "code ×2 40m + test ×5 25m" (empty when no signal).
	EtaBreakdown string
	// GitReins LLM-judge verdict pass rate (0-100) over the project history.
	GitReinsPass int // percent; -1 = no verdicts
	// CIConclusion is the latest GitHub Actions run conclusion (success/failure/
	// "" ) for the project's repo — an INDEPENDENT cross-check on GitReins. A
	// GitReins 100% is only trustworthy when CI is also green; a red CI flags
	// that the LLM-judge gate may be passing a suite that is actually failing
	// (e.g. cached test results). "" = unknown (no CI workflow or query failed).
	CIConclusion string
}

FleetRow is one project in the fleet overview table.

type Generator

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

Generator produces the fleet dashboard as a single-file HTML page.

func NewGenerator

func NewGenerator(db *sql.DB, gatewayURL ...string) *Generator

NewGenerator creates a dashboard generator. Template is parsed at construction time so hot-path Generate() never pays the parse cost. gatewayURL is optional; when supplied, the health panel probes its /health endpoint.

func (*Generator) Generate

func (g *Generator) Generate(w io.Writer) error

Generate writes the dashboard HTML to w. Template is pre-parsed — zero hot-path overhead.

func (*Generator) GenerateFleetTable

func (g *Generator) GenerateFleetTable(w io.Writer) error

GenerateFleetTable renders the fleet table partial (tbody only) for htmx to swap into the dashboard page. Routes get this from /dashboard/partial.

func (*Generator) GenerateHealth

func (g *Generator) GenerateHealth(w io.Writer) error

GenerateHealth renders daemon, database, and gateway liveness information. The page refreshes itself with htmx, so every render performs fresh probes.

func (*Generator) GenerateHealthPartial

func (g *Generator) GenerateHealthPartial(w io.Writer) error

GenerateHealthPartial renders only the .cards fragment for htmx polling (HX-Request). The page's .cards div polls /health with hx-swap=outerHTML, so the response must be the fragment — a full page swapped in compounds itself on every 10s refresh.

func (*Generator) GenerateNamespaceView

func (g *Generator) GenerateNamespaceView(w io.Writer, id string) error

GenerateNamespaceView renders namespace configuration, assigned projects, and recent utilization history.

func (*Generator) GenerateProjectDetail

func (g *Generator) GenerateProjectDetail(w io.Writer, name string) error

GenerateProjectDetail renders the project detail page. Returns an error wrapping ErrProjectNotFound when no project matches the given name.

func (*Generator) GenerateQueue

func (g *Generator) GenerateQueue(w io.Writer) error

GenerateQueue renders the evaluation queue page — all enabled projects sorted by urgency (descending) with their weight, priority, and cooldown.

func (*Generator) GenerateTickHistory

func (g *Generator) GenerateTickHistory(w io.Writer, page int) error

GenerateTickHistory renders one page of the global tick history. Pages are one-based; values below one are normalized to the first page.

func (*Generator) GenerateTickHistoryPartial

func (g *Generator) GenerateTickHistoryPartial(w io.Writer, page int) error

GenerateTickHistoryPartial renders only the pagination fragment for htmx polling (HX-Request). The page's #tick-history div polls /ticks with hx-swap=outerHTML, so the response must be the fragment — a full page swapped in compounds itself on every 30s refresh.

func (*Generator) HTMXJS

func (g *Generator) HTMXJS() []byte

HTMXJS returns the bundled htmx library bytes for serving via HTTP.

func (*Generator) SetDuckBrainURL

func (g *Generator) SetDuckBrainURL(u string)

SetDuckBrainURL registers the DuckBrain HTTP endpoint so the health panel can probe it (mirrors gateway probing). Optional.

func (*Generator) SetSpawnCounts

func (g *Generator) SetSpawnCounts(fn func() (httpCount, execCount int64))

SetSpawnCounts wires a callback returning (http, exec) spawn counts since restart, surfaced on the /health panel (upstream merge compatibility).

type GitReinsSummary

type GitReinsSummary struct {
	Total   int
	Passed  int
	Failed  int
	RatePct int
	Latest  []GitReinsVerdict // newest first, capped
}

GitReinsSummary is the aggregate pass rate + latest verdicts for a project.

type GitReinsVerdict

type GitReinsVerdict struct {
	TaskID      string
	TaskTitle   string
	Passed      bool
	Tier1Passed bool
	Tier2Passed bool
	HasTier2    bool
	EvaluatedAt string
}

GitReinsVerdict is one LLM-judge verdict from .gitreins/history.

type HealthData

type HealthData struct {
	Title            string
	GeneratedAt      string
	DaemonStatus     string
	DatabaseStatus   string
	GatewayStatus    string
	GatewayURL       string
	DuckBrainStatus  string
	DuckBrainBaseURL string
	DuckBrainSpooled int
	Uptime           string
	ActiveTicks      int
	TotalTicks       int
	Goroutines       int
	MemoryMB         float64
}

HealthData holds daemon, database, gateway, and DuckBrain liveness info.

type NamespaceRow

type NamespaceRow struct {
	ID           string
	Weight       int
	Reserved     int
	HardCap      int
	Allocated    int
	Used         int
	Borrowed     int
	Lent         int
	ProjectCount int
	Utilization  float64
}

NamespaceRow is one namespace in the allocation overview table.

type NamespaceTickRow

type NamespaceTickRow struct {
	TickGroup   string
	NamespaceID string
	Allocated   int
	Used        int
	Borrowed    int
	Lent        int
	CreatedAt   string
}

NamespaceTickRow is one namespace_tick in the utilization history table.

type NamespaceViewData

type NamespaceViewData struct {
	Title           string
	Namespace       *database.Namespace
	Projects        []database.Project
	RecentTicks     []database.NamespaceTick
	LatestTick      *database.NamespaceTick
	EnabledProjects int
	TotalWeight     int
	Utilization     float64
}

NamespaceViewData holds namespace configuration, projects, and recent allocation history for /namespaces/{id}.

type ProjectDetailData

type ProjectDetailData struct {
	Title         string
	Project       *database.Project
	LatestTick    *database.Tick
	RecentTicks   []database.Tick
	BoardDone     int
	BoardTotal    int
	NextTickIn    string
	AvgTickSecs   int
	SuccessRate   int
	ETA           string
	BoardSteps    []BoardStep
	TickWork      map[string]string // tick id → what it worked on (commit subjects)
	GitReins      GitReinsSummary
	CompletionAt  string
	ProjectedCost float64
	AvgCost       float64          // mean cost per completed tick (for live-cost estimate)
	EtaBreakdown  string           // per-type estimate, e.g. "code ×2 40m + test ×5 25m"
	SpeedCost     []SpeedCostPoint // for the speed/cost-over-time charts
}

ProjectDetailData holds all data for the /projects/{name} page.

type QueueData

type QueueData struct {
	Title       string
	Count       int
	TotalWeight int
	Entries     []QueueEntry
}

QueueData holds all data for the queue page.

type QueueEntry

type QueueEntry struct {
	Name      string
	Weight    int
	Priority  int
	CooldownS int
	Enabled   bool
	Urgency   float64
}

QueueEntry is one project in the evaluation queue view.

type SpeedCostPoint

type SpeedCostPoint struct {
	Label    string // "14:12", "16:44", ...
	Duration int    // tick duration in seconds (speed)
	Cost     float64
	Commits  int
	Files    int
}

SpeedCostPoint is one completed tick's (time, speed, cost, output) data point for the per-project speed/cost/commits/files charts.

type TaskType

type TaskType string

TaskType buckets a board task (or a completed tick's work) into a coarse work category so ETA/cost can learn per-type estimates instead of assuming every step is identical. The key insight: "2 steps left" is a bad signal when both are heavy implementation tasks, and "10 steps left" is a bad signal when all ten are fast smoke tests.

const (
	TaskSpec  TaskType = "spec"
	TaskCode  TaskType = "code"
	TaskTest  TaskType = "test"
	TaskDocs  TaskType = "docs"
	TaskChore TaskType = "chore"
	TaskOther TaskType = "other"
)

type TickHistoryData

type TickHistoryData struct {
	Title        string
	GeneratedAt  string
	Ticks        []database.Tick
	Page         int
	PageSize     int
	TotalTicks   int
	TotalPages   int
	HasPrevious  bool
	PreviousPage int
	HasNext      bool
	NextPage     int
}

TickHistoryData holds one page of the global tick history.

type TickRow

type TickRow struct {
	ID, Project, Status, Outcome, SessionID, SpawnedAt, CompletedAt string
	Commits, FilesChanged                                           int
	Duration                                                        string // human-readable elapsed time between spawned and completed
}

TickRow is one tick in the history table.

Jump to

Keyboard shortcuts

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