model

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanTransition

func CanTransition(from, to Status) bool

CanTransition reports whether moving a task from `from` to `to` is a legal transition.

func SaveTasksFile

func SaveTasksFile(path string, f TasksFile) error

SaveTasksFile writes f to path as 2-space indented JSON (matching the shipped templates), creating the file if needed. It is every writer's one encoding (#531), and atomic: a temp file of its own beside path, then a rename, so a reader — orch run reloading it — never sees half a file, and two writers never share a temp name. Serialising read-modify-write cycles is the caller's job (project.MutateTasks, project.TaskEditor).

Types

type Backend

type Backend string

Backend names a supported CLI coding agent. Ported from the Python `Backend` literal in orchestrator/models.py.

const (
	BackendClaude   Backend = "claude"
	BackendCodex    Backend = "codex"
	BackendOpencode Backend = "opencode"
	BackendGemini   Backend = "gemini"
	BackendAgy      Backend = "agy"
	BackendMuse     Backend = "muse"
)

type Meta

type Meta struct {
	Project     string
	GeneratedAt string
	Template    string
	Note        string
	Extra       map[string]json.RawMessage
	// contains filtered or unexported fields
}

Meta is tasks.json's top-level `meta` object. `Template` is only present when the project was scaffolded from a named template (see orchestrator/templates/projects/*/tasks.json.tmpl vs the bare orchestrator/templates/tasks.json.tmpl skeleton, which omits it).

func (Meta) MarshalJSON

func (m Meta) MarshalJSON() ([]byte, error)

MarshalJSON preserves both Python's field order (project, generatedAt, template, note) and, for a decoded Meta, its own present-keys set — see Task.MarshalJSON's doc comment for why order is part of the contract here, not cosmetic.

func (*Meta) UnmarshalJSON

func (m *Meta) UnmarshalJSON(data []byte) error

type Phase

type Phase struct {
	ID    int
	Name  string
	Extra map[string]json.RawMessage
}

Phase is one entry in tasks.json's top-level `phases` array.

func (Phase) MarshalJSON

func (p Phase) MarshalJSON() ([]byte, error)

MarshalJSON preserves Python's field order (id, name) — see Task.MarshalJSON's doc comment. Invisible today ("id" < "name" alphabetically too), but not guaranteed to stay that way, and the other two structs in this file prove alphabetical-by-accident isn't a property worth relying on.

func (*Phase) UnmarshalJSON

func (p *Phase) UnmarshalJSON(data []byte) error

type RouteEntry

type RouteEntry struct {
	Backend   Backend `yaml:"backend"`
	CLIModel  string  `yaml:"cli_model"`
	Tier      Tier    `yaml:"tier"`
	IsPremium bool    `yaml:"is_premium"`

	FallbackCLIModel *string `yaml:"fallback_cli_model,omitempty"`
	// EscalationModel names another ROUTE KEY (not a raw CLIModel) that the
	// reap loop promotes to on attempt 3 after a retryable failure on
	// attempt 2. A non-nil value that doesn't correspond to a real route
	// entry is a fail-fast startup error in internal/router, not here.
	EscalationModel *string `yaml:"escalation_model,omitempty"`

	// Backend-specific extras (agy — issues #87/#88). Agent is agy's
	// `--agent <role>` selector, passed only when set: agy 1.4 has no
	// "executor" persona and its default executes in-process (#382). Effort is agy's
	// `--effort {low,medium,high}` for base-name Gemini models that
	// require it; left nil when the cli_model already encodes effort as a
	// suffix (e.g. "gemini-3.7-flash-high").
	Agent  *string `yaml:"agent,omitempty"`
	Effort *string `yaml:"effort,omitempty"`
	// ServiceTier is codex's service_tier for this route's dispatches (#416),
	// so a Fast mode set globally in ~/.codex/config.toml is not forced on
	// every one: "default" is the standard tier. Nil leaves codex's config.
	ServiceTier *string `yaml:"service_tier,omitempty"`

	// Failover names other ROUTE KEYS, in order, that a dispatch moves to
	// when this route's provider runs out of quota (#439): a rate-limit
	// failure retries on the next one instead of backing off, and later
	// tasks skip the exhausted provider until its window resets. Like
	// EscalationModel, a key that is not a route is a load error in
	// internal/router. Empty keeps the plain rate-limit backoff.
	Failover []string `yaml:"failover,omitempty"`
}

RouteEntry is one row from model_router.yaml, ported from RouteEntry in orchestrator/models.py. Field names/tags mirror the YAML keys the Python router reads (see orchestrator/model_router.yaml's header comment) so internal/router can decode straight into this struct with yaml.v3.

FallbackCLIModel, EscalationModel, Agent and Effort are nil when the route doesn't set them, matching Python's `| None` optional fields — IsPremium is NOT optional: Python precomputes it at load time from Tier so the dispatch hot path never string-compares Tier, and Go keeps that contract rather than deriving it lazily.

type Status

type Status string

Status is a task's position in the workflow. The zero value ("") is not a valid Status — build one with ParseStatus or use a constant below.

const (
	StatusBacklog    Status = "backlog"
	StatusTodo       Status = "todo"
	StatusInProgress Status = "in-progress"
	StatusDone       Status = "done"
	StatusBlocked    Status = "blocked"
)

func ParseStatus

func ParseStatus(s string) (Status, error)

ParseStatus validates s against the five known statuses.

func Transitions

func Transitions(from Status) []Status

Transitions returns every status `from` may legally move to next, in the canonical status order — used by CLI error messages and `--help` text so the list is stable across runs.

type Task

type Task struct {
	ID            string
	Phase         int
	Title         string
	Description   string
	Model         string
	Reason        string
	Status        Status
	Dependencies  []string
	EstimateHours float64
	Files         []string
	SpecRef       string
	// SourceIssue is the URL of the GitHub issue the task was imported from
	// (`orch atomize --from-issues`, #525): the PR body closes it and the
	// client page links it. Optional on the wire (`sourceIssue`), and never
	// written for a task without one, so files from before it keep their
	// shape.
	SourceIssue string
	// Comments holds each entry's raw JSON value verbatim —
	// orchestrator/models.py types this `list[dict]` with no fixed shape,
	// so Go doesn't need to understand it to preserve it losslessly.
	Comments []json.RawMessage

	// Extra holds JSON object keys this struct doesn't know about, so a
	// tasks.json field added later (or by a newer/older Python version)
	// survives a Go Load→Save round trip untouched.
	Extra map[string]json.RawMessage
	// contains filtered or unexported fields
}

Task is a single unit of work from tasks.json. Field names match the frozen dataclass in orchestrator/models.py; JSON wire keys are handled by TaskFromJSON/MarshalJSON below rather than plain struct tags, because SaveTasksFile must reproduce Python's exact from_json defaulting AND must not invent a key (e.g. "comments") that the source file never had — see the `present` field.

func TaskFromJSON

func TaskFromJSON(raw map[string]json.RawMessage) (Task, error)

TaskFromJSON builds a Task from one decoded tasks.json row, applying the exact defaults Task.from_json (orchestrator/models.py) applies.

func (Task) MarshalJSON

func (t Task) MarshalJSON() ([]byte, error)

MarshalJSON reproduces the wire key set the Task was decoded with (t.present == nil, i.e. built in Go rather than decoded, emits every optional field), in the same field order Python's dataclass — and this struct's own declaration — use. Order matters here: tasks.json is a file both binaries write and a person reads, not just an API response.

func (*Task) UnmarshalJSON

func (t *Task) UnmarshalJSON(data []byte) error

UnmarshalJSON lets Task decode directly (e.g. as a TasksFile.Tasks element), delegating to TaskFromJSON for the actual defaulting logic.

type TasksFile

type TasksFile struct {
	Meta   Meta
	Phases []Phase
	Tasks  []Task
}

TasksFile is the full contents of a project's tasks.json.

func LoadTasksFile

func LoadTasksFile(path string) (TasksFile, error)

LoadTasksFile reads and parses a tasks.json file.

func (TasksFile) MarshalJSON

func (f TasksFile) MarshalJSON() ([]byte, error)

func (*TasksFile) UnmarshalJSON

func (f *TasksFile) UnmarshalJSON(data []byte) error

type Tier

type Tier string

Tier is a route's cost/capability class — drives the semi-auto gate and the budget guardrail's premium-spend accounting.

const (
	TierPremium  Tier = "premium"
	TierStandard Tier = "standard"
	TierCheap    Tier = "cheap"
)

Jump to

Keyboard shortcuts

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