taskflow

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package taskflow owns deterministic task synchronization and execution coordination. It does not create a second scheduler or lend provider tokens to models, browsers, or mesh peers.

Index

Constants

This section is empty.

Variables

View Source
var ErrBudget = errors.New("automation token budget exhausted")
View Source
var ErrConcurrency = errors.New("local execution concurrency limit reached")

ErrConcurrency is a normal per-connection wait, not a failure of discovery for other accounts or connections. Foreground requests still report it.

View Source
var ErrEmptyPreparation = errors.New("automation preparation returned no content")
View Source
var ErrRuntimeHeld = errors.New("task synchronization runtime is owned by another process")
View Source
var ErrStale = errors.New("task connection changed during synchronization")

Functions

This section is empty.

Types

type Action

type Action struct {
	ID          string                 `json:"actionId"`
	RequestID   string                 `json:"requestId"`
	DeliveryID  string                 `json:"deliveryId"`
	Revision    uint64                 `json:"deliveryRevision"`
	Fingerprint string                 `json:"fingerprint"`
	Intent      finalaction.FileIntent `json:"intent"`
	State       string                 `json:"state"`
	Proof       tsync.SignedProof      `json:"-"`
	Receipt     *finalaction.Receipt   `json:"receipt,omitempty"`
	// contains filtered or unexported fields
}

type AutomationOptions

type AutomationOptions struct {
	Model         func() AuxiliaryModel
	PrivateMemory func() ([]string, error)
	ProjectMemory func(string) ([]string, error)
}

AutomationOptions is installed only by the process owning the core. Model access is tool-free and uses the user's live configuration and credentials.

type AuxiliaryModel

type AuxiliaryModel interface {
	CompleteBounded(context.Context, string, string, int) (string, error)
	AuxiliaryVersion() string
}

type ConnectOptions

type ConnectOptions struct {
	ID     string   `json:"connectionId"`
	Root   string   `json:"rootUrl"`
	Name   string   `json:"name"`
	Scopes []string `json:"scopes"`
}

type ConnectResult

type ConnectResult struct {
	Connection    Connection          `json:"connection"`
	Authorization tsync.Authorization `json:"authorization"`
}

type Connection

type Connection struct {
	ID           string                     `json:"connectionId"`
	Provider     string                     `json:"provider"`
	Root         string                     `json:"rootUrl"`
	AccountID    string                     `json:"accountId"`
	InstanceID   string                     `json:"instanceId"`
	DeviceID     string                     `json:"deviceId"`
	AuthEpoch    string                     `json:"authEpoch"`
	State        string                     `json:"state"`
	FeedEpoch    string                     `json:"feedEpoch"`
	Capabilities taskproviders.Capabilities `json:"capabilities"`
	Spaces       []taskproviders.Space      `json:"spaces"`
	Scopes       []string                   `json:"scopes"`
	LastError    string                     `json:"lastError"`
	SyncedAt     int64                      `json:"syncedAt"`
	NextSyncAt   int64                      `json:"nextSyncAt"`
	RequestedAt  int64                      `json:"requestedAt"`
	Failures     int                        `json:"failures"`
	Generation   int64                      `json:"-"`
	// contains filtered or unexported fields
}

Connection is safe for the local UI. The credential reference and generation are internal bookkeeping; tokens and signing material never enter SQLite.

type DraftConsent

type DraftConsent struct {
	AccountID    string `json:"accountId"`
	AuthEpoch    string `json:"authEpoch"`
	TaskRevision string `json:"taskRevision"`
}

DraftConsent binds a new draft-only policy to the task and account on screen.

type FilePublication

type FilePublication struct {
	Directory         string `json:"directory"`
	DirectoryIdentity string `json:"directoryIdentity,omitempty"`
	Filename          string `json:"filename"`
	FullGoal          bool   `json:"fullGoal"`
}

FilePublication is explicit local authorization. The model cannot choose a directory or filename. FullGoal is a separate human assertion of coverage; it defaults to false, keeping a published draft from completing the task.

type Policy

type Policy struct {
	Research          bool                       `json:"research"`
	Execute           bool                       `json:"execute"`
	FinalAction       bool                       `json:"finalAction"`
	Mode              taskproviders.ApprovalMode `json:"mode"`
	ExpiresAt         int64                      `json:"expiresAt"`
	MaxConcurrent     int                        `json:"maxConcurrent"`
	DailyTokens       int                        `json:"dailyTokens"`
	PreparationTokens int                        `json:"preparationTokens"`
	TaskIDs           []string                   `json:"taskIds"`
	ProjectID         string                     `json:"projectId"`
	Capabilities      []string                   `json:"capabilities"`
	Publication       *FilePublication           `json:"publication,omitempty"`
}

Policy is local, account/space scoped operation authorization. A remote task cannot edit it. Connecting a provider creates no policy and grants only sync. Capabilities are enforced by concrete adapters; draft has no tools or network access beyond the configured model transport.

type ProjectBinding

type ProjectBinding struct {
	RemoteProject string `json:"remoteProjectId"`
	LocalProject  string `json:"localProject"`
}

ProjectBinding is an explicit account-scoped mapping. An empty RemoteProject binds a space; an empty LocalProject in SetBinding removes that mapping. Directory and execution permissions remain the local project's own settings.

type RequestedExecution

type RequestedExecution struct {
	RequestID      string `json:"requestId"`
	AlreadyStarted bool   `json:"alreadyStarted"`
	State          string `json:"state"`
}

type ResearchBrief

type ResearchBrief struct {
	Brief          string `json:"brief"`
	State          string `json:"state"`
	InputRevision  string `json:"inputRevision"`
	ModelVersion   string `json:"modelVersion"`
	ReservedTokens int    `json:"reservedTokens"`
	CreatedAt      int64  `json:"createdAt"`
	ExpiresAt      int64  `json:"expiresAt"`
}

type RunSummary

type RunSummary struct {
	RequestID    string                     `json:"requestId"`
	ConnectionID string                     `json:"connectionId"`
	TaskKey      string                     `json:"taskKey"`
	Title        string                     `json:"title"`
	State        string                     `json:"state"`
	Error        string                     `json:"error"`
	Mode         taskproviders.ApprovalMode `json:"mode"`
	UpdatedAt    int64                      `json:"updatedAt"`
	// contains filtered or unexported fields
}

type Service

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

func New

func New(db *sql.DB, dbPath string) *Service

func (*Service) ApproveAction

func (s *Service) ApproveAction(ctx context.Context, id, fingerprint string) error

ApproveAction is the local user's specific final-submit consent. A changed fingerprint or delivery revision cannot reuse it. Mode after_execution uses the same immutable consent binding under explicit local preauthorization.

func (*Service) Bindings

func (s *Service) Bindings(ctx context.Context, connection, space string) ([]ProjectBinding, error)

func (*Service) ConfigureExecution

func (s *Service) ConfigureExecution(c *core.Core, opts AutomationOptions)

ConfigureExecution must precede queue startup. The core also fails closed when this owner or a fresh cloud lease is unavailable.

func (*Service) Connect

func (s *Service) Connect(ctx context.Context, opts ConnectOptions) (ConnectResult, error)

func (*Service) CreateTask

func (s *Service) CreateTask(ctx context.Context, connection, space string, input taskproviders.Snapshot, command string) (taskproviders.Snapshot, error)

func (*Service) DecideDelivery

func (s *Service) DecideDelivery(ctx context.Context, id string, revision uint64, decision, reason string) error

DecideDelivery records one immutable, revision-bound human decision. Repeating it reuses its original proof and event; a contrary decision requires a new delivery revision. Returning work never claims to undo a physical action.

func (*Service) Disconnect

func (s *Service) Disconnect(ctx context.Context, id string) error

func (*Service) FinishConnect

func (s *Service) FinishConnect(ctx context.Context, id string) (Connection, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (Connection, error)

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Connection, error)

func (*Service) LookupPolicy

func (s *Service) LookupPolicy(ctx context.Context, connection, space string) (Policy, bool, error)

LookupPolicy distinguishes an explicitly disabled policy from a new space.

func (*Service) Members

func (s *Service) Members(ctx context.Context, id, space string) ([]taskproviders.Member, error)

Members reads only the directory for the current authorized subject. A revoked or replaced connection cannot expose a previous account's cache.

func (*Service) PatchTask

func (s *Service) PatchTask(ctx context.Context, connection string, key taskproviders.Key, revision string, patch json.RawMessage, command string) (taskproviders.Snapshot, error)

func (*Service) PauseWork

func (s *Service) PauseWork(ctx context.Context, request string) error

func (*Service) Policy

func (s *Service) Policy(ctx context.Context, connection, space string) (Policy, error)

func (*Service) RejectAction

func (s *Service) RejectAction(ctx context.Context, id, fingerprint string) error

func (*Service) RequestExecution

func (s *Service) RequestExecution(ctx context.Context, connection string, key taskproviders.Key, requestID string) (RequestedExecution, error)

RequestExecution requests the current canonical generation. Explicit reruns are human TaskSync operations; device requests cannot create a new generation or bypass local policy. The owning runtime later claims the cloud slot.

func (*Service) RequestFirstDraft

func (s *Service) RequestFirstDraft(ctx context.Context, connection string, key taskproviders.Key, requestID string, consent DraftConsent) (RequestedExecution, error)

func (*Service) RequestSync

func (s *Service) RequestSync(ctx context.Context, id string) error

func (*Service) Research

func (s *Service) Research(ctx context.Context, connection, key string) ([]ResearchBrief, error)

Research remains private and is hidden immediately after assignment, policy expiry, scope loss, input changes or account replacement.

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run belongs to the node owner, not to a browser request or borrowed front end. Closing any page leaves this duty running; cancelling ownership stops requests and joins the lease heartbeat before returning.

func (*Service) Runs

func (s *Service) Runs(ctx context.Context, connection, key string) ([]RunSummary, error)

Runs is a bounded discovery view. Content is read separately through Work.

func (*Service) SetBinding

func (s *Service) SetBinding(ctx context.Context, connection, space string, b ProjectBinding) error

func (*Service) SetPolicy

func (s *Service) SetPolicy(ctx context.Context, connection, space string, p Policy) error

func (*Service) Start

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

Start waits for the ownership/recovery barrier; only then may the caller start the core scheduler. Run remains available for sync-only owners.

func (*Service) SyncNow

func (s *Service) SyncNow(ctx context.Context, id string) error

SyncNow is a bounded one-shot owner for a CLI with no daemon. When a persistent owner exists, callers leave RequestSync queued for that owner.

func (*Service) Wait

func (s *Service) Wait(ctx context.Context) error

Wait joins the runtime after its owning context has been cancelled.

func (*Service) Work

func (s *Service) Work(ctx context.Context, request string) (WorkRun, error)

Work reads only the current connected account's business history. Revoked accounts cannot retrieve private drafts or action bodies through old IDs.

type SyncStatus

type SyncStatus struct {
	EventID  string `json:"eventId"`
	Kind     string `json:"kind"`
	State    string `json:"state"`
	Error    string `json:"error"`
	Attempts int    `json:"attempts"`
	NextAt   int64  `json:"nextAt"`
}

SyncStatus intentionally contains no signed proof, request body or credential.

type WorkDelivery

type WorkDelivery struct {
	Delivery  tsync.Delivery `json:"delivery"`
	AttemptID string         `json:"attemptId"`
	Files     []string       `json:"files"`
	Failure   string         `json:"failure"`
	SyncState string         `json:"syncState"`
}

type WorkRun

type WorkRun struct {
	RequestID    string                     `json:"requestId"`
	TaskKey      string                     `json:"taskKey"`
	State        string                     `json:"state"`
	Error        string                     `json:"error"`
	Prepared     string                     `json:"prepared"`
	Deliveries   []WorkDelivery             `json:"deliveries"`
	Actions      []Action                   `json:"actions"`
	ConnectionID string                     `json:"connectionId"`
	Title        string                     `json:"title"`
	Mode         taskproviders.ApprovalMode `json:"mode"`
	Sync         []SyncStatus               `json:"sync"`
}

func (WorkRun) Export

func (w WorkRun) Export() string

Directories

Path Synopsis
Package finalaction provides concrete, enforceable side effect adapters.
Package finalaction provides concrete, enforceable side effect adapters.

Jump to

Keyboard shortcuts

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