run

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package run provides the Worker-side RunCoordinator.

Coordinator manages Worker-local scheduling: concurrent slot limits, per-session serialization, debounce merging, cancellation, and active run tracking.

Coordinator MUST NOT depend on workspace, model, engine, artifact, event types, or NATS subjects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxConcurrency int
	DebounceWindow time.Duration
}

Config controls Coordinator behavior.

type Coordinator

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

Coordinator manages Worker-local scheduling for agent runs.

func NewCoordinator

func NewCoordinator(cfg Config, executeFunc ExecuteFunc) (*Coordinator, error)

NewCoordinator creates a new RunCoordinator.

func (*Coordinator) Cancel

func (c *Coordinator) Cancel(ctx context.Context, orgID, workerID uint, sessionID, runID string) error

Cancel cancels the active run for the given session+runID.

func (*Coordinator) Close

func (c *Coordinator) Close() error

Close shuts down the coordinator gracefully, waiting for all in-flight runs.

func (*Coordinator) RegisterRun

func (c *Coordinator) RegisterRun(sessionKey, runID, taskID string, cancel context.CancelFunc)

RegisterRun records an active run for cancellation tracking.

func (*Coordinator) Submit

func (c *Coordinator) Submit(ctx context.Context, submission RunSubmission) (RunOutcome, error)

Submit submits a run request. For session-keyed submissions, it goes through debounce merging; the caller blocks until the consolidated batch completes.

func (*Coordinator) UnregisterRun

func (c *Coordinator) UnregisterRun(sessionKey string)

UnregisterRun removes a previously registered active run.

type ExecuteFunc

type ExecuteFunc func(
	ctx context.Context,
	submission RunSubmission,
) (*agentrundomain.RunResult, error)

ExecuteFunc is the actual execution function injected by the command adapter.

type RunOutcome

type RunOutcome struct {
	Result       *agentrundomain.RunResult
	DeliverySeqs []uint64
}

RunOutcome is the result of executing a run (possibly merged from multiple submissions).

type RunSubmission

type RunSubmission struct {
	Request      *agentrundomain.RunRequest
	EventContext agentrun.EventContext
	DeliverySeqs []uint64
	// contains filtered or unexported fields
}

RunSubmission is a submitted run request with event context and delivery sequences.

Jump to

Keyboard shortcuts

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