Documentation
¶
Overview ¶
Package models defines shared types used across the Samverk system.
Index ¶
- Constants
- func IsEven(n int) bool
- func IsOdd(n int) bool
- func RenderFrontmatter(fm *IssueFrontmatter, markdown string) string
- type AgentType
- type Complexity
- type CostRecord
- type CostSummary
- type IssueFrontmatter
- type IssueType
- type ParseResult
- type Priority
- type ScalingControl
- type ScalingEvent
- type Session
- type SessionStatus
- type Status
- type TaskProfile
Constants ¶
const SchemaVersion = "1.0.0"
SchemaVersion is the current issue schema version.
Variables ¶
This section is empty.
Functions ¶
func RenderFrontmatter ¶
func RenderFrontmatter(fm *IssueFrontmatter, markdown string) string
RenderFrontmatter produces an issue body with YAML frontmatter followed by markdown.
Types ¶
type AgentType ¶
type AgentType string
AgentType identifies which agent pool should handle an issue.
const ( AgentTypeOrchestrator AgentType = "orchestrator" AgentTypeDispatcher AgentType = "dispatcher" AgentTypeCodeGen AgentType = "code-gen" AgentTypeTest AgentType = "test" AgentTypeDocs AgentType = "docs" AgentTypeResearch AgentType = "research" AgentTypeQC AgentType = "qc" AgentTypeHuman AgentType = "human" AgentTypeInfra AgentType = "infra" AgentTypePC AgentType = "pc" )
type Complexity ¶
type Complexity string
Complexity hints at whether work should run locally or in the cloud.
const ( ComplexityLocal Complexity = "local" ComplexityCloud Complexity = "cloud" ComplexityAmbiguous Complexity = "ambiguous" )
type CostRecord ¶
type CostRecord struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Provider string `json:"provider"`
Model string `json:"model"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CostUSD float64 `json:"cost_usd"` // 0 for local models
CreatedAt time.Time `json:"created_at"`
}
CostRecord tracks token usage for a single API call.
type CostSummary ¶
type CostSummary struct {
TotalInputTokens int `json:"total_input_tokens"`
TotalOutputTokens int `json:"total_output_tokens"`
TotalCostUSD float64 `json:"total_cost_usd"`
RecordCount int `json:"record_count"`
}
CostSummary aggregates cost data over a time period.
type IssueFrontmatter ¶
type IssueFrontmatter struct {
SchemaVersion string `yaml:"schema_version"`
Type IssueType `yaml:"type"`
AgentType AgentType `yaml:"agent_type"`
Priority Priority `yaml:"priority"`
ParentIssue int `yaml:"parent_issue,omitempty"`
DependsOn []int `yaml:"depends_on,omitempty"`
EstimatedTokens int `yaml:"estimated_tokens,omitempty"`
ActualTokens int `yaml:"actual_tokens,omitempty"`
ModelUsed string `yaml:"model_used,omitempty"`
TimeoutMinutes int `yaml:"timeout_minutes,omitempty"`
}
IssueFrontmatter represents the YAML frontmatter parsed from an issue body.
type ParseResult ¶
type ParseResult struct {
Frontmatter *IssueFrontmatter
Body string // markdown after the closing ---
}
ParseResult holds the parsed frontmatter and remaining body text.
func ParseFrontmatter ¶
func ParseFrontmatter(body string) (*ParseResult, error)
ParseFrontmatter extracts YAML frontmatter from an issue body. The frontmatter must be delimited by --- on its own line at the start of the body. Returns error if frontmatter is present but malformed. Returns nil Frontmatter (no error) if no frontmatter block exists.
type ScalingControl ¶ added in v0.1.11
ScalingControl is a single-row record that holds manual override state written by the REST API or CLI and consumed by the autoscaler on each evaluation cycle. ManualWorkers == 0 means no manual target is set. Paused == true means the autoscaler should hold (take no autonomous action).
type ScalingEvent ¶ added in v0.1.11
type ScalingEvent struct {
ID string
Timestamp time.Time
Action string // "scale-up" | "scale-down" | "manual-override"
FromWorkers int
ToWorkers int
Reason string
Confidence float64
}
ScalingEvent records a single autoscaler decision.
type Session ¶
type Session struct {
ID string `json:"id"`
IssueNumber int `json:"issue_number"`
AgentType string `json:"agent_type"` // e.g., "code-gen", "qc", "research"
Provider string `json:"provider"` // e.g., "ollama", "claude", "openai"
Model string `json:"model"` // e.g., "qwen2.5-coder:7b"
Status SessionStatus `json:"status"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Error string `json:"error,omitempty"`
PartialOutput string `json:"partial_output,omitempty"` // last checkpoint of streaming output
CheckpointHash string `json:"checkpoint_hash,omitempty"` // SHA-256 of posted checkpoint for dedup
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Session represents a unit of agent work on an issue.
type SessionStatus ¶
type SessionStatus string
SessionStatus represents the lifecycle state of a work session.
const ( SessionStatusPending SessionStatus = "pending" SessionStatusActive SessionStatus = "active" SessionStatusCompleted SessionStatus = "completed" SessionStatusFailed SessionStatus = "failed" SessionStatusCancelled SessionStatus = "cancelled" )
type TaskProfile ¶ added in v0.1.11
type TaskProfile struct {
AgentType string `json:"agent_type"`
Provider string `json:"provider"`
AvgDuration time.Duration `json:"avg_duration"`
P50Duration time.Duration `json:"p50_duration"`
P90Duration time.Duration `json:"p90_duration"`
SampleCount int `json:"sample_count"`
AvgTokens int `json:"avg_tokens"`
UpdatedAt time.Time `json:"updated_at"`
}
TaskProfile holds rolling performance statistics for a specific (AgentType, Provider) combination, computed from completed sessions. Values are updated after each successful task completion.