Help us shape the future of Go! Take the 2026 Go Developer Survey

goal

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package goal is the session goal: an objective wopr keeps working toward across turns, continuing automatically until an independent audit accepts the orchestrator's completion claim or a cap pauses it. It holds the state, its caps, and the texts the models read; the session runs the loop.

Index

Constants

View Source
const (
	MetMarker     = "GOAL MET"
	BlockedMarker = "GOAL BLOCKED"
)

Claim markers: a line the orchestrator ends its reply with.

View Source
const EntryType = "wopr-goal-v1"

EntryType is the custom session entry type holding the goal.

View Source
const IdleTurns = 3

IdleTurns is how many automatic turns in a row without a tool call pause the goal: the model is talking, not working.

View Source
const MessageType = "goal"

MessageType is the custom message type of the goal's kickoff and continuation messages.

Variables

This section is empty.

Functions

func Verdict

func Verdict(accepted bool, answer string) (pass bool, feedback string)

Verdict reads an audit result: PASS only when the task was accepted and its answer starts with PASS. feedback is the answer for the orchestrator.

Types

type Caps

type Caps struct {
	Turns int `json:"turns"`
	// Cost is the most non-free spend in dollars.
	Cost float64 `json:"cost"`
	// Time is the most active wall time.
	Time time.Duration `json:"time"`
}

Caps bound one working window of a goal; resuming opens a new window.

func DefaultCaps

func DefaultCaps() Caps

DefaultCaps are the caps a goal gets unless /goal overrides them.

func ParseArgs

func ParseArgs(args string) (string, Caps, error)

ParseArgs reads /goal's arguments: leading --turns N, --cost DOLLARS, and --time DURATION caps, then the objective.

type Claim

type Claim struct {
	// Kind is MetMarker, BlockedMarker, or "" for no claim.
	Kind string
	// Evidence is the text after the marker line, or the reply before it
	// when nothing follows.
	Evidence string
}

Claim is what the orchestrator's final reply says about the goal.

func ParseClaim

func ParseClaim(text string) Claim

ParseClaim finds the last marker line in a reply. A marker counts only on a line of its own (markdown emphasis and a trailing colon allowed), so prose that mentions it is not a claim.

type State

type State struct {
	Version   int    `json:"version"`
	ID        string `json:"id"`
	Objective string `json:"objective"`
	Status    Status `json:"status"`
	// Reason says why the goal is paused or done.
	Reason string `json:"reason,omitempty"`
	Caps   Caps   `json:"caps"`
	// Turns, Spent, and Elapsed are this window's automatic turns, non-free
	// spend, and active time.
	Turns   int           `json:"turns"`
	Spent   float64       `json:"spent"`
	Elapsed time.Duration `json:"elapsed"`
	// TotalSpent is the spend across windows.
	TotalSpent float64 `json:"totalSpent"`
	// Idle counts automatic turns in a row without a tool call.
	Idle int `json:"idle,omitempty"`
	// Audits counts completion audits; Feedback is the last failed one's.
	Audits   int    `json:"audits,omitempty"`
	Feedback string `json:"feedback,omitempty"`
	// Audited identifies the last claim audited, so a claim is audited once.
	Audited string `json:"audited,omitempty"`
	// Started is when the goal was set.
	Started time.Time `json:"started"`
	// Tasks are the background tasks started while the goal was active.
	Tasks []string `json:"tasks,omitempty"`
}

State is the persisted goal.

func New

func New(id, objective string, caps Caps, now time.Time) State

New returns an active goal.

func (State) AuditBrief

func (s State) AuditBrief(claim string) string

AuditBrief is the auditor subagent's brief: the goal and the orchestrator's claim, which it must check against the working tree.

func (State) CapHit

func (s State) CapHit() string

CapHit names the cap this window has reached, or "".

func (State) Continuation

func (s State) Continuation() string

Continuation is the message of an automatic turn.

func (State) Kickoff

func (s State) Kickoff() string

Kickoff is the message that starts work on a new goal.

func (State) Open

func (s State) Open() bool

Open reports whether the goal still needs work.

func (State) Summary

func (s State) Summary() string

Summary is one line of status: status, turns, spend, and time.

type Status

type Status string

Status is the goal's state.

const (
	Active  Status = "active"
	Paused  Status = "paused"
	Done    Status = "done"
	Stopped Status = "stopped"
)

Goal statuses.

type Step

type Step struct {
	// Message, when set, is the next automatic turn's message.
	Message *agent.AgentMessage
	// Wait reports background tasks of the goal still running; delivering
	// their results settles another run, which asks again.
	Wait bool
	// Event is "done" or "paused" when the goal just changed that way, and
	// Text says why.
	Event, Text string
}

Step is what a frontend does after a run settles.

Jump to

Keyboard shortcuts

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