runtime

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrorCodeNotImplemented indicates a placeholder runtime capability.
	ErrorCodeNotImplemented = "not_implemented"
	// ErrorCodeTaskNotFound indicates the task ID does not exist.
	ErrorCodeTaskNotFound = "task_not_found"
	// ErrorCodeInvalidTransition indicates an illegal status transition.
	ErrorCodeInvalidTransition = "invalid_transition"
	// ErrorCodeRetryExhausted indicates no retry budget remains.
	ErrorCodeRetryExhausted = "retry_exhausted"
	// ErrorCodeTaskTimeout is the canonical timeout code for runtime tasks.
	ErrorCodeTaskTimeout = "task_timeout"
	// ErrorCodeTaskCancelled is the canonical cancellation code for runtime tasks.
	ErrorCodeTaskCancelled = "task_cancelled"
	// ErrorCodeQuotaExceeded indicates runtime quota acquisition failure.
	ErrorCodeQuotaExceeded = "quota_exceeded"
	// ErrorCodeTaskExecutionFailed indicates runtime executor returned a non-timeout failure.
	ErrorCodeTaskExecutionFailed = "task_execution_failed"
)
View Source
const TaskExecutionTokenMetadataKey = "runtime_execution_token"

Variables

View Source
var ErrTaskNotImplemented = newRuntimeError(ErrorCodeNotImplemented, "runtime task manager is not wired", false, nil)

Functions

func IsTerminalTaskStatus

func IsTerminalTaskStatus(status corepkg.TaskStatus) bool

func ValidateTaskTransition

func ValidateTaskTransition(from, to corepkg.TaskStatus, opts TransitionOptions) error

Types

type InMemoryQuotaManager

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

func NewInMemoryQuotaManager

func NewInMemoryQuotaManager(defaultLimit int, perKeyLimits map[string]int) *InMemoryQuotaManager

func (*InMemoryQuotaManager) Acquire

func (q *InMemoryQuotaManager) Acquire(ctx context.Context, key string) error

func (*InMemoryQuotaManager) Release

func (q *InMemoryQuotaManager) Release(key string)

type InMemorySubAgentCoordinator

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

func NewInMemorySubAgentCoordinator

func NewInMemorySubAgentCoordinator(taskManager TaskManager, quotaManager QuotaManager) *InMemorySubAgentCoordinator

func (*InMemorySubAgentCoordinator) Spawn

func (*InMemorySubAgentCoordinator) Wait

type InMemoryTaskManager

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

InMemoryTaskManager is a safe placeholder until runtime orchestration is wired.

func NewInMemoryTaskManager

func NewInMemoryTaskManager(opts ...InMemoryTaskManagerOption) *InMemoryTaskManager

func (*InMemoryTaskManager) Cancel

func (*InMemoryTaskManager) Get

func (*InMemoryTaskManager) ReadIncrement

func (m *InMemoryTaskManager) ReadIncrement(_ context.Context, id corepkg.TaskID, offset uint64, limit int) (items []TaskLogEntry, nextOffset uint64, hasMore bool, err error)

func (*InMemoryTaskManager) RegisterExecution

func (m *InMemoryTaskManager) RegisterExecution(token string, executor TaskExecutorFunc)

func (*InMemoryTaskManager) Retry

func (*InMemoryTaskManager) Stream

func (m *InMemoryTaskManager) Stream(ctx context.Context, id corepkg.TaskID) (<-chan TaskEvent, error)

func (*InMemoryTaskManager) Submit

func (*InMemoryTaskManager) UnregisterExecution

func (m *InMemoryTaskManager) UnregisterExecution(token string)

func (*InMemoryTaskManager) Wait

type InMemoryTaskManagerOption

type InMemoryTaskManagerOption func(*InMemoryTaskManager)

func WithTaskEventStore

func WithTaskEventStore(store TaskEventStore) InMemoryTaskManagerOption

func WithTaskExecutor

func WithTaskExecutor(executor TaskExecutorFunc) InMemoryTaskManagerOption

func WithTerminalHistoryCap

func WithTerminalHistoryCap(limit int) InMemoryTaskManagerOption

type LogReader

type LogReader interface {
	ReadIncrement(ctx context.Context, taskID corepkg.TaskID, offset uint64, limit int) (items []TaskLogEntry, nextOffset uint64, hasMore bool, err error)
}

type NopTaskEventStore

type NopTaskEventStore struct{}

func (NopTaskEventStore) AppendTaskEvent

func (NopTaskEventStore) AppendTaskEvent(context.Context, TaskEvent) error

func (NopTaskEventStore) AppendTaskLog

type QuotaManager

type QuotaManager interface {
	Acquire(ctx context.Context, key string) error
	Release(key string)
}

type Scheduler

type Scheduler interface {
	Enqueue(ctx context.Context, taskID corepkg.TaskID) error
}

type SubAgentCoordinator

type SubAgentCoordinator interface {
	Spawn(ctx context.Context, spec TaskSpec) (corepkg.TaskID, error)
	Wait(ctx context.Context, id corepkg.TaskID) (TaskResult, error)
}

type Task

type Task struct {
	ID         corepkg.TaskID
	Spec       TaskSpec
	Status     corepkg.TaskStatus
	Attempt    int
	Output     []byte
	CreatedAt  time.Time
	StartedAt  *time.Time
	FinishedAt *time.Time
	ErrorCode  string
}

type TaskEvent

type TaskEvent struct {
	Type      TaskEventType
	Offset    uint64
	TaskID    corepkg.TaskID
	SessionID corepkg.SessionID
	TraceID   corepkg.TraceID
	Status    corepkg.TaskStatus
	Attempt   int
	Payload   []byte
	Metadata  map[string]string
	ErrorCode string
	Timestamp time.Time
}

type TaskEventStore

type TaskEventStore interface {
	AppendTaskEvent(ctx context.Context, event TaskEvent) error
	AppendTaskLog(ctx context.Context, taskID corepkg.TaskID, entry TaskLogEntry) error
}

type TaskEventType

type TaskEventType string
const (
	TaskEventStatus TaskEventType = "status"
	TaskEventLog    TaskEventType = "log"
	TaskEventResult TaskEventType = "result"
	TaskEventError  TaskEventType = "error"
)

type TaskExecutionRegistry

type TaskExecutionRegistry interface {
	RegisterExecution(token string, executor TaskExecutorFunc)
	UnregisterExecution(token string)
}

type TaskExecutorFunc

type TaskExecutorFunc func(ctx context.Context, task Task) ([]byte, error)

type TaskLogEntry

type TaskLogEntry struct {
	TaskID    corepkg.TaskID
	Offset    uint64
	Payload   []byte
	Timestamp time.Time
}

type TaskManager

type TaskManager interface {
	Submit(ctx context.Context, spec TaskSpec) (corepkg.TaskID, error)
	Get(ctx context.Context, id corepkg.TaskID) (Task, error)
	Cancel(ctx context.Context, id corepkg.TaskID, reason string) error
	Retry(ctx context.Context, id corepkg.TaskID) (corepkg.TaskID, error)
	Stream(ctx context.Context, id corepkg.TaskID) (<-chan TaskEvent, error)
	Wait(ctx context.Context, id corepkg.TaskID) (TaskResult, error)
}

type TaskResult

type TaskResult struct {
	TaskID     corepkg.TaskID
	Status     corepkg.TaskStatus
	Output     []byte
	ErrorCode  string
	FinishedAt time.Time
}

type TaskSpec

type TaskSpec struct {
	SessionID        corepkg.SessionID
	TraceID          corepkg.TraceID
	Name             string
	Kind             string
	Input            []byte
	ParentTaskID     corepkg.TaskID
	Timeout          time.Duration
	MaxRetries       int
	Background       bool
	IsolatedWorktree bool
	Metadata         map[string]string
}

type TransitionOptions

type TransitionOptions struct {
	AllowRetryTransition bool
}

type WorktreeHandle added in v0.1.8

type WorktreeHandle struct {
	ID     string
	Path   string
	Branch string
	Commit string
}

WorktreeHandle carries metadata for an active worktree managed by WorktreeManager.

type WorktreeManager added in v0.1.8

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

WorktreeManager manages temporary git worktrees for subagent isolation.

func NewWorktreeManager added in v0.1.8

func NewWorktreeManager(workspaceRoot string) (*WorktreeManager, error)

NewWorktreeManager creates a WorktreeManager for the given workspace. Returns an error if the workspace is not a git repository.

func (*WorktreeManager) Cleanup added in v0.1.8

func (m *WorktreeManager) Cleanup(ctx context.Context, h *WorktreeHandle) error

Cleanup removes a worktree and its owner metadata. Idempotent.

func (*WorktreeManager) HasChanges added in v0.1.8

func (m *WorktreeManager) HasChanges(ctx context.Context, h *WorktreeHandle) (bool, error)

HasChanges detects whether a worktree has uncommitted modifications.

func (*WorktreeManager) IsAvailable added in v0.1.8

func (m *WorktreeManager) IsAvailable() bool

IsAvailable reports whether the manager is ready to create worktrees.

func (*WorktreeManager) Prepare added in v0.1.8

Prepare creates a temporary git worktree and writes owner metadata.

type WorktreeRequest added in v0.1.8

type WorktreeRequest struct {
	InvocationID  string
	WorkspaceRoot string
}

WorktreeRequest carries the parameters needed to create a worktree.

Jump to

Keyboard shortcuts

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