Documentation
¶
Index ¶
- Constants
- Variables
- func AuditTaskPrompt(obj *Objective) string
- func BudgetLimitMessage(obj *Objective) provider.Message
- func BudgetLimitPrompt(obj *Objective) string
- func ContinuationMessage(obj *Objective) provider.Message
- func ContinuationPrompt(_ *Objective) string
- func CriticTaskPrompt(obj *Objective) string
- func FormatObjective(obj *Objective) string
- func IsRunnableStatus(status Status) bool
- func IsUnfinishedStatus(status Status) bool
- func IsUsageLimitError(err error) bool
- func NewGetTool(store *Store, sessionID sessionIDFunc) tools.Tool
- func NewUpdateTool(store *Store, sessionID sessionIDFunc, runID ...runIDFunc) tools.Tool
- func RecoveryObserverTaskPrompt(obj *Objective, role, interruption string) string
- func SteeringMessage(obj *Objective) provider.Message
- func SteeringPrompt(obj *Objective) string
- func WorkerTaskPrompt(obj *Objective) string
- type AuditReport
- type Objective
- type Phase
- type RecoveryReport
- type Status
- type Store
- func (s *Store) AccountUsage(ctx context.Context, sessionID string, tokens, durationMS int64) (*Objective, error)
- func (s *Store) Clear(ctx context.Context, sessionID string) error
- func (s *Store) Create(ctx context.Context, sessionID, objective string, budget *int64) (*Objective, error)
- func (s *Store) Edit(ctx context.Context, sessionID, objective string) (*Objective, error)
- func (s *Store) FinishRun(ctx context.Context, sessionID, runID string) (*Objective, error)
- func (s *Store) Get(ctx context.Context, sessionID string) (*Objective, error)
- func (s *Store) MarkCompleteFromAudit(ctx context.Context, sessionID, review string) (*Objective, error)
- func (s *Store) MarkUsageLimited(ctx context.Context, sessionID string) (*Objective, error)
- func (s *Store) Pause(ctx context.Context, sessionID string) (*Objective, error)
- func (s *Store) RecordCompletionReview(ctx context.Context, sessionID, review string) (*Objective, error)
- func (s *Store) RecordRecovery(ctx context.Context, sessionID, reason, summary string, remainingWork []string) (*Objective, error)
- func (s *Store) RecordWorkerProgress(ctx context.Context, sessionID, summary string, remainingWork []string) (*Objective, error)
- func (s *Store) RejectCompletionCandidate(ctx context.Context, sessionID, review string) (*Objective, error)
- func (s *Store) RejectCompletionCandidateForRun(ctx context.Context, sessionID, runID, review string, missingWork []string) (*Objective, error)
- func (s *Store) RejectWorkerReport(ctx context.Context, sessionID, runID, review string, remainingWork []string) (*Objective, error)
- func (s *Store) Resume(ctx context.Context, sessionID string) (*Objective, error)
- func (s *Store) SetBudget(ctx context.Context, sessionID string, budget *int64) (*Objective, error)
- func (s *Store) SetPhase(ctx context.Context, sessionID string, phase Phase) (*Objective, error)
- func (s *Store) UpdateFromModel(ctx context.Context, sessionID string, status Status, reason string) (*Objective, error)
- func (s *Store) UpdateFromModelForRun(ctx context.Context, sessionID string, status Status, reason, runID string) (*Objective, error)
- type WorkerReport
Constants ¶
const ( WorkerStatusContinue = "continue" WorkerStatusCompleteCandidate = "complete_candidate" WorkerStatusBlockedCandidate = "blocked_candidate" AuditVerdictPass = "pass" AuditVerdictFail = "fail" RecoveryDecisionResume = "resume" RecoveryDecisionBlocked = "blocked" )
const CompletionRejectionLimit = 3
CompletionRejectionLimit is the number of consecutive completion rejections that pauses unattended ESM continuation.
const RecoveryLimit = 2
RecoveryLimit is the number of consecutive automatic recoveries permitted after interrupted ESM role runs. Further interruptions pause continuation.
Variables ¶
var ( ErrNotFound = errors.New("esm objective not found") ErrObjectiveExists = errors.New("esm objective already exists") ErrInvalidObjective = errors.New("esm objective cannot be empty") ErrInvalidTransition = errors.New("invalid esm status transition") ErrBudgetStillHit = errors.New("esm token budget is still exhausted") )
Functions ¶
func AuditTaskPrompt ¶
AuditTaskPrompt is the isolated read-only audit sub-agent task for a completion candidate.
func BudgetLimitMessage ¶
BudgetLimitMessage is injected into an active run once the ESM token budget is reached, so the model wraps up without starting new substantive work.
func BudgetLimitPrompt ¶
func ContinuationMessage ¶
ContinuationMessage is used when the TUI starts an idle continuation run.
func ContinuationPrompt ¶
func CriticTaskPrompt ¶
CriticTaskPrompt is the isolated skeptical review sub-agent task for a completion candidate. It runs before the verifier and is biased toward finding scope shrinkage, demos, and missing requirements.
func FormatObjective ¶
FormatObjective returns a compact plain-text representation safe for TUI and tools.
func IsRunnableStatus ¶
IsRunnableStatus reports whether normal ESM tools should remain visible.
func IsUnfinishedStatus ¶
IsUnfinishedStatus reports whether a status still represents an open objective. "complete" is terminal; clearing the objective deletes the row.
func IsUsageLimitError ¶
IsUsageLimitError applies a conservative text heuristic for provider/account limits that should stop unattended continuation.
func NewGetTool ¶
NewGetTool returns the model-facing ESM state query tool.
func NewUpdateTool ¶
NewUpdateTool returns the model-facing ESM status update tool.
func RecoveryObserverTaskPrompt ¶ added in v1.1.63
RecoveryObserverTaskPrompt asks a read-only observer to inspect the repository after an ESM role was interrupted before it could report state.
func SteeringMessage ¶
SteeringMessage injects current ESM instructions into a run without changing the frozen system prompt.
func SteeringPrompt ¶
func WorkerTaskPrompt ¶
WorkerTaskPrompt is the isolated worker sub-agent task for one ESM run.
Types ¶
type AuditReport ¶
type AuditReport struct {
Verdict string `json:"verdict"`
Review string `json:"review"`
RequirementsChecked []string `json:"requirements_checked"`
MissingWork []string `json:"missing_work"`
Evidence []string `json:"evidence"`
}
AuditReport is the structured final response from an isolated ESM auditor.
func ParseAuditReport ¶
func ParseAuditReport(text string) (AuditReport, error)
type Objective ¶
type Objective struct {
SessionID string
ESMID string
Objective string
Status Status
TokenBudget *int64
TokensUsed int64
TimeUsedMS int64
BlockedCount int
BlockedReason string
BlockedRunID string
CompletionReason string
CompletionRunID string
CompletionReview string
Phase Phase
ProgressSummary string
RemainingWork []string
RejectionCount int
RejectionRunID string
RecoveryCount int
RecoveryReason string
CreatedAt time.Time
UpdatedAt time.Time
}
Objective is the per-session Enable Supervisor Mode objective.
func (*Objective) CanAutoRun ¶
CanAutoRun reports whether TUI idle continuation may start a new agent run.
func (*Objective) HasObjective ¶
HasObjective reports whether the row contains a real objective.
type Phase ¶ added in v1.1.63
type Phase string
Phase identifies the current role in the ESM completion pipeline.
type RecoveryReport ¶ added in v1.1.63
type RecoveryReport struct {
Decision string `json:"decision"`
Summary string `json:"summary"`
Evidence []string `json:"evidence"`
RemainingWork []string `json:"remaining_work"`
Blockers []string `json:"blockers"`
}
RecoveryReport is the structured result of an observer inspecting work left behind by an interrupted ESM role.
func ParseRecoveryReport ¶ added in v1.1.63
func ParseRecoveryReport(text string) (RecoveryReport, error)
type Status ¶
type Status string
Status is the persisted lifecycle state for a supervised objective.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists Enable Supervisor Mode state in the shared sessions database.
func (*Store) AccountUsage ¶
func (s *Store) AccountUsage(ctx context.Context, sessionID string, tokens, durationMS int64) (*Objective, error)
AccountUsage accumulates one agent run's usage and applies token budget enforcement after the run finishes.
func (*Store) Create ¶
func (s *Store) Create(ctx context.Context, sessionID, objective string, budget *int64) (*Objective, error)
Create creates a new objective. A completed row may be replaced; unfinished objectives must be edited or cleared explicitly.
func (*Store) FinishRun ¶
FinishRun clears repeated blocker/rejection streaks when an active ESM run finishes without reporting the same condition.
func (*Store) MarkCompleteFromAudit ¶
func (s *Store) MarkCompleteFromAudit(ctx context.Context, sessionID, review string) (*Objective, error)
MarkCompleteFromAudit marks a completion candidate terminal complete after an independent ESM audit has verified the objective against the current state.
func (*Store) MarkUsageLimited ¶
MarkUsageLimited records a runtime/provider limit and stops continuation.
func (*Store) RecordCompletionReview ¶
func (s *Store) RecordCompletionReview(ctx context.Context, sessionID, review string) (*Objective, error)
RecordCompletionReview stores a completion rejection/review note without changing the current lifecycle state. This lets later worker runs learn why a previous completion claim was not accepted.
func (*Store) RecordRecovery ¶ added in v1.1.63
func (s *Store) RecordRecovery(ctx context.Context, sessionID, reason, summary string, remainingWork []string) (*Objective, error)
RecordRecovery persists a recovery diagnosis after an interrupted ESM role. It keeps the objective active for a bounded number of automatic retries and pauses it once the recovery limit is exceeded.
func (*Store) RecordWorkerProgress ¶ added in v1.1.63
func (s *Store) RecordWorkerProgress(ctx context.Context, sessionID, summary string, remainingWork []string) (*Objective, error)
RecordWorkerProgress persists the latest structured worker result so later runs and the TUI can show concrete progress and remaining work.
func (*Store) RejectCompletionCandidate ¶
func (s *Store) RejectCompletionCandidate(ctx context.Context, sessionID, review string) (*Objective, error)
RejectCompletionCandidate records a failed completion candidate. Repeated rejections pause unattended continuation at CompletionRejectionLimit.
func (*Store) RejectCompletionCandidateForRun ¶ added in v1.1.63
func (s *Store) RejectCompletionCandidateForRun(ctx context.Context, sessionID, runID, review string, missingWork []string) (*Objective, error)
RejectCompletionCandidateForRun records a critic/audit rejection with its structured missing work. A run contributes at most once to the streak.
func (*Store) RejectWorkerReport ¶ added in v1.1.63
func (s *Store) RejectWorkerReport(ctx context.Context, sessionID, runID, review string, remainingWork []string) (*Objective, error)
RejectWorkerReport records a worker report rejected before supervisor review while the objective is still active.
func (*Store) SetBudget ¶
SetBudget sets or clears the token budget. It does not implicitly resume a budget-limited objective; users must run /esm resume after raising/removing it.
func (*Store) SetPhase ¶ added in v1.1.63
SetPhase records the current role in the worker/critic/audit pipeline.
func (*Store) UpdateFromModel ¶
func (s *Store) UpdateFromModel(ctx context.Context, sessionID string, status Status, reason string) (*Objective, error)
UpdateFromModel accepts the two model-controlled transitions: complete and blocked. Complete records a candidate only; the orchestrator must audit the candidate before marking the objective terminal complete. Blocked transitions should normally use UpdateFromModelForRun so the repeated-blocker audit is counted across consecutive agent runs.
func (*Store) UpdateFromModelForRun ¶
func (s *Store) UpdateFromModelForRun(ctx context.Context, sessionID string, status Status, reason, runID string) (*Objective, error)
UpdateFromModelForRun accepts model-controlled complete/blocked transitions. Complete becomes complete_candidate, never terminal complete. The terminal complete state is reserved for the ESM orchestrator after an independent audit sub-agent passes. Blocked only becomes terminal after the same blocker repeats in three consecutive ESM agent runs. A run can contribute at most once to the audit.
type WorkerReport ¶
type WorkerReport struct {
Status string `json:"status"`
Summary string `json:"summary"`
Evidence []string `json:"evidence"`
RemainingWork []string `json:"remaining_work"`
Blockers []string `json:"blockers"`
}
WorkerReport is the structured final response from an isolated ESM worker.
func ParseWorkerReport ¶
func ParseWorkerReport(text string) (WorkerReport, error)