115 lines
2.7 KiB
Go
115 lines
2.7 KiB
Go
package agenttask
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
|
|
"iop/packages/go/agentguard"
|
|
)
|
|
|
|
var ErrRevisionConflict = errors.New("agenttask state revision conflict")
|
|
|
|
// AgentTaskManager is the host-neutral lifecycle contract. StartProject records
|
|
// a durable manual intent; only Reconcile may advance workflow state.
|
|
type AgentTaskManager interface {
|
|
StartProject(context.Context, StartRequest) error
|
|
Reconcile(context.Context) error
|
|
StopProject(context.Context, ProjectID) error
|
|
}
|
|
|
|
type Clock interface {
|
|
Now() time.Time
|
|
}
|
|
|
|
type StateStore interface {
|
|
Load(context.Context) (ManagerState, StateRevision, error)
|
|
CompareAndSwap(
|
|
context.Context,
|
|
StateRevision,
|
|
ManagerState,
|
|
) (StateRevision, error)
|
|
}
|
|
|
|
// WorkflowAdapter normalizes project-owned task artifacts. Listing projects is
|
|
// separate from loading snapshots so one corrupt project cannot stop siblings.
|
|
type WorkflowAdapter interface {
|
|
RegisteredProjects(context.Context) ([]ProjectID, error)
|
|
Snapshot(context.Context, ProjectID) (ProjectWorkflowSnapshot, error)
|
|
}
|
|
|
|
type SelectionRequest struct {
|
|
Project ProjectRecord
|
|
Work WorkRecord
|
|
}
|
|
|
|
type Selector interface {
|
|
Select(context.Context, SelectionRequest) (ExecutionTarget, error)
|
|
}
|
|
|
|
type IsolationRequest struct {
|
|
Project ProjectRecord
|
|
Work WorkRecord
|
|
Target ExecutionTarget
|
|
IdempotencyKey string
|
|
}
|
|
|
|
type PreparedIsolation struct {
|
|
Grant *agentguard.WorkspaceGrant
|
|
Descriptor *agentguard.IsolationDescriptor
|
|
Profile agentguard.ProviderProfile
|
|
}
|
|
|
|
type IsolationBackend interface {
|
|
Prepare(context.Context, IsolationRequest) (PreparedIsolation, error)
|
|
}
|
|
|
|
type DispatchRequest struct {
|
|
Project ProjectRecord
|
|
Work WorkRecord
|
|
Target ExecutionTarget
|
|
AdmissionRequest agentguard.AdmissionRequest
|
|
Permit *agentguard.Permit
|
|
Workspace agentguard.CanonicalWorkspace
|
|
IdempotencyKey string
|
|
}
|
|
|
|
type ProviderInvoker interface {
|
|
Invoke(context.Context, DispatchRequest) (Submission, error)
|
|
}
|
|
|
|
type ReviewRequest struct {
|
|
Project ProjectRecord
|
|
Work WorkRecord
|
|
Submission Submission
|
|
IdempotencyKey string
|
|
}
|
|
|
|
type Reviewer interface {
|
|
Review(context.Context, ReviewRequest) (ReviewResult, error)
|
|
}
|
|
|
|
type IntegrationRequest struct {
|
|
Project ProjectRecord
|
|
Work WorkRecord
|
|
ChangeSet ChangeSetIdentity
|
|
Ordinal DispatchOrdinal
|
|
Attempt IntegrationAttempt
|
|
IdempotencyKey string
|
|
}
|
|
|
|
type Integrator interface {
|
|
Integrate(context.Context, IntegrationRequest) (IntegrationResult, error)
|
|
}
|
|
|
|
type EventSink interface {
|
|
Emit(context.Context, Event) error
|
|
}
|
|
|
|
type nopEventSink struct{}
|
|
|
|
func (nopEventSink) Emit(context.Context, Event) error { return nil }
|
|
|
|
type systemClock struct{}
|
|
|
|
func (systemClock) Now() time.Time { return time.Now().UTC() }
|