workflows

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentdExecutor

type AgentdExecutor interface {
	Execute(ctx context.Context, workspaceID, podIP string, req *NodeExecRequest) (*NodeExecResponse, error)
}

AgentdExecutor dispatches a single node execution to the agentd user mux on a workspace pod. workspaceID identifies the workspace whose agentd Basic-auth password must accompany the dispatch.

type AppEngineLogger

type AppEngineLogger struct {
	LogFn func(msg string, kv ...any)
	ErrFn func(err error, msg string, kv ...any)
}

AppEngineLogger adapts an external logger to the engine's Logger interface. The concrete type is created by the caller (app.go) — this struct is just a type definition that the caller wraps around its own logger.

func (*AppEngineLogger) Error

func (l *AppEngineLogger) Error(err error, msg string, kv ...any)

func (*AppEngineLogger) Info

func (l *AppEngineLogger) Info(msg string, kv ...any)

type HTTPAgentExecutor

type HTTPAgentExecutor struct {
	Port   int
	Client *http.Client
	// PasswordProvider resolves the per-workspace agentd Basic-auth
	// password (US-46.11; *handlers.ProxyHandler satisfies it). Required —
	// agentd rejects unauthenticated node dispatches (#762).
	PasswordProvider apiinterfaces.WorkspacePasswordProvider
}

HTTPAgentExecutor calls agentd on the workspace pod via HTTP. Uses context for cancellation and timeout propagation.

func (*HTTPAgentExecutor) Execute

func (e *HTTPAgentExecutor) Execute(ctx context.Context, workspaceID, podIP string, req *NodeExecRequest) (*NodeExecResponse, error)

type K8sWorkspaceActivator

type K8sWorkspaceActivator struct {
	K8sClient pkgk8s.KubernetesClient
	Namespace string
}

func (*K8sWorkspaceActivator) EnsureActive

func (a *K8sWorkspaceActivator) EnsureActive(ctx context.Context, workspaceID string, timeout time.Duration) (string, error)

type Logger

type Logger interface {
	Info(msg string, keysAndValues ...any)
	Error(err error, msg string, keysAndValues ...any)
}

type NodeExecRequest

type NodeExecRequest struct {
	NodeID   string          `json:"nodeId"`
	NodeType string          `json:"nodeType"`
	Spec     json.RawMessage `json:"spec"`
	Input    json.RawMessage `json:"input"`
	Timeout  string          `json:"timeout,omitempty"`
	// WorkflowID/RunID carry the logical-execution identity agentd
	// derives its harness dedupe key from (#1327): the run's WorkflowID
	// and ID on the workflow path; the routine's trigger ID (its
	// reusable definition) and fire ID (its logical execution) on the
	// routine path. Stable across a node's retries and a pending fire's
	// re-drives, distinct across runs/fires — the key must upsert retry
	// re-POSTs but never two executions. Non-agent node types ignore
	// them (no harness transcript write); identity-less callers omit
	// them and agentd POSTs keyless exactly as before.
	WorkflowID string `json:"workflowId,omitempty"`
	RunID      string `json:"runId,omitempty"`
}

type NodeExecResponse

type NodeExecResponse struct {
	Output    json.RawMessage `json:"output,omitempty"`
	Branch    string          `json:"branch,omitempty"`
	ErrorCode string          `json:"errorCode,omitempty"`
	Detail    string          `json:"detail,omitempty"`
	// SessionID is the first-class session identity (#1470): set by
	// agentd iff a session still exists when the node finished — on
	// failure envelopes too, so the engine can origin-record and index
	// exactly the sessions that survived. Absent on old agentd (the
	// engine falls back to parsing the output payload) and on
	// transport errors (no response object at all).
	SessionID string `json:"sessionId,omitempty"`
}

type Reconciler

type Reconciler struct {
	Store            ReconcilerStore
	AgentdClient     AgentdExecutor
	Activator        WorkspaceActivator
	WorkspaceCreator WorkspaceCreator
	Logger           Logger
	MaxConcurrent    int
	TickInterval     time.Duration
	// PasswordProvider resolves the per-workspace agentd Basic-auth
	// password for the node-retry session cleanup (#1476 DAG adoption).
	// Nil → cleanup skipped (unwired/embedded reconcilers keep today's
	// behavior).
	PasswordProvider apiinterfaces.WorkspacePasswordProvider
	// AgentdPort overrides the agentd user-mux port for the cleanup
	// delete. Zero → default (4097); mirrors the Scheduler's field.
	AgentdPort int
	// contains filtered or unexported fields
}

func (*Reconciler) Cancel

func (r *Reconciler) Cancel(runID string)

func (*Reconciler) Start

func (r *Reconciler) Start(ctx context.Context) error

type ReconcilerStore

type ReconcilerStore interface {
	ClaimQueuedRuns(ctx context.Context, limit int) ([]*wf.WorkflowRunRow, error)
	UpdateWorkflowRunStatus(ctx context.Context, runID, status string, errorCode *string, errMsg json.RawMessage, output json.RawMessage) error
	CreateNodeRun(ctx context.Context, row *wf.WorkflowNodeRunRow) error
	UpdateNodeRunStatus(ctx context.Context, nodeRunID, status string, output json.RawMessage, branch *string, errorCode *string, errMsg json.RawMessage) error
	IncrementTriggerFailures(ctx context.Context, triggerID string) (int, error)
	ResetTriggerFailures(ctx context.Context, triggerID string) error
	GetWorkflowPolicy(ctx context.Context, workflowID string) (onMissing, ownerType, ownerID string, err error)
	UpdateRunWorkspace(ctx context.Context, runID, workspaceID string) error
}

type Scheduler

type Scheduler struct {
	Store        SchedulerStore
	Activator    WorkspaceActivator
	AgentdClient AgentdExecutor
	Logger       Logger
	TickInterval time.Duration
	// PasswordProvider resolves the per-workspace agentd Basic-auth
	// password for the PreserveOnFailure session-delete call (#762).
	PasswordProvider apiinterfaces.WorkspacePasswordProvider
	// AgentdPort overrides the agentd user-mux port for the
	// PreserveOnFailure session-delete call. Zero → default (4097).
	// Tests inject an httptest server port; mirrors HTTPAgentExecutor.Port.
	AgentdPort int
	// SessionIndex mirrors preserved routine sessions into the sidebar's
	// session_index (#1452): the platform's session list surface serves
	// only that index, and the routine fire path never touches the
	// proxy routes that write it. Nil → indexing skipped (fire result
	// is unaffected).
	SessionIndex SessionIndexWriter
}

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context) error

type SchedulerStore

type SchedulerStore interface {
	ClaimDueCronTriggers(ctx context.Context, now time.Time, limit int, nextFireFn func(*wf.TriggerRow) time.Time) ([]*wf.TriggerRow, error)
	ListPendingRoutineFires(ctx context.Context, limit int) ([]*wf.TriggerFireRow, error)
	GetTriggerByID(ctx context.Context, triggerID string) (*wf.TriggerRow, error)
	GetWorkflow(ctx context.Context, ownerType, ownerID, workflowID string) (*wf.WorkflowRow, error)
	CreateWorkflowRunWithFire(ctx context.Context, fire *wf.TriggerFireRow, run *wf.WorkflowRunRow) error
	CreateTriggerFire(ctx context.Context, row *wf.TriggerFireRow) error
	UpdateTriggerFireResult(ctx context.Context, fireID string, result json.RawMessage, status string) error
	GetLastRoutineResult(ctx context.Context, triggerID string) (json.RawMessage, error)
	GetRecentRoutineResults(ctx context.Context, triggerID string, limit int) ([]json.RawMessage, error)
	IncrementTriggerFailures(ctx context.Context, triggerID string) (int, error)
	ResetTriggerFailures(ctx context.Context, triggerID string) error
	DisableTrigger(ctx context.Context, triggerID string) error
	RecordSessionOrigin(ctx context.Context, row *wf.SessionOriginRow) error
}

type SessionIndexWriter added in v0.34.4

type SessionIndexWriter interface {
	UpsertTitle(ctx context.Context, workspaceID, sessionID, title string) error
	RecordMessage(workspaceID, sessionID, title string, at time.Time)
}

SessionIndexWriter is the session-index surface the routine path needs: a display title and one activity record per fire. Satisfied by the sessionindex service.

type WorkspaceActivator

type WorkspaceActivator interface {
	EnsureActive(ctx context.Context, workspaceID string, timeout time.Duration) (podIP string, err error)
}

type WorkspaceCreator added in v0.9.1

type WorkspaceCreator interface {
	CreateWorkspace(ctx context.Context, workflowID, ownerType, ownerID string) (workspaceID string, err error)
}

Jump to

Keyboard shortcuts

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