Plan item 3 of docs/prds/execution-tree-state-machine.md (archie-core-1220), on top of the transition tables and ErrIllegalTransition enforcement (1214/1215, archie-core-qdbo.5): - Migration 0017 adds step_executions -- id, org_id, workspace_id, execution_id, attempt, parent_id, depth, kind, name, called_execution_id, status, detail, tokens_used, started_at, finished_at, indexed on (execution_id, attempt, id). Ownership fields are stamped from the execution's row; depth is derived from the parent, never supplied by a caller. Existing rows gain no backfilled steps. - task.Store (the workflow engine's mid-run facade) gains StartStep/FinishStep (5 methods, within the 8 cap), with storecontract.StepRecorder fronting them on the server; deadlineStore wraps both with its per-call timeout. - The store enforces each write as one transaction: the guarded row write under the shared step transition table plus the transition's own stage_start/stage_finish event row. Staleness is decided before legality, the way guardTransition decides it, and the store returns the persisted event for the caller's post-commit publish -- the EmitDurable convention (the daemon's event sink skips already-persisted rows by assigned ID), which is why workflow.Run stops emitting stage events beside the store and no longer discards step-write errors: a failed start or finish parks the execution, and the stage does not run unrecorded. An interrupted stage records interrupted rather than failed; a recording failure on that shutdown path is logged and left to RecoverStale, which owns the interrupted-execution sweep in plan item 6. - The run credential of docs/prds/orgs-and-access.md authorises StartStep and FinishStep on its own execution only: both requests carry the execution ID the grant check verifies (FinishStep carries it because the interceptor never reads the database), and FinishStep verifies handler-side that the step really is that execution's. authorizesTaskScopedCall's sanctioned widenings are now held as a lookup table so the next one stops growing a switch. - The PRD's wire contract is StartStep(execution, attempt, parent, kind, name) -> step id; the responses also carry the persisted event (needed for the post-commit publish) and FinishStep's request carries execution_id (needed for the grant check) -- both noted here as deliberate additions to the PRD's shorthand. called_execution_id exists in the table but not yet on the wire: its named consumer is the workflow-call recording of plan item 4 (#1216). Conformance drives both adapters; grant tests pin the own-execution scoping; the wire sentinel set gains ErrInvalidStep (InvalidArgument, "step execution invalid") for a step kind no consumer names.
53 lines
1.8 KiB
Go
53 lines
1.8 KiB
Go
// Task-vocabulary aliases. The Task record, its statuses, the mid-run
|
|
// Store contract, and Definition moved to internal/domain/workflow/task
|
|
// (archie-core-8cda.5.6) so the UI process can hold the vocabulary without
|
|
// linking this package's pipeline engine (which imports agentexec, skill
|
|
// and tools). package workflow keeps these aliases, so daemon-side callers
|
|
// are unaffected.
|
|
package workflow
|
|
|
|
import "github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
|
|
|
type (
|
|
// Task is the task-execution record the workflow domain operates on.
|
|
Task = task.Task
|
|
// Store is the narrow, consumer-owned subset of the State Store
|
|
// contract that workflow stages call mid-run.
|
|
Store = task.Store
|
|
// StepStart and StepFinish are the step-execution writes the store
|
|
// records mid-run (docs/prds/execution-tree-state-machine.md).
|
|
StepStart = task.StepStart
|
|
StepFinish = task.StepFinish
|
|
// Definition is the operator-safe snapshot of an executable workflow.
|
|
Definition = task.Definition
|
|
)
|
|
|
|
// Step-execution kinds, defined beside the step writes in internal/domain/
|
|
// workflow/task with the same aliasing reason.
|
|
const (
|
|
StepKindStage = task.StepKindStage
|
|
StepKindAgent = task.StepKindAgent
|
|
StepKindCall = task.StepKindCall
|
|
)
|
|
|
|
// Task lifecycle statuses. Defined in internal/taskstate; these names are
|
|
// the workflow domain's public spelling.
|
|
const (
|
|
StatusQueued = task.StatusQueued
|
|
StatusRunning = task.StatusRunning
|
|
StatusWaitingHuman = task.StatusWaitingHuman
|
|
StatusPROpen = task.StatusPROpen
|
|
StatusMerged = task.StatusMerged
|
|
StatusParked = task.StatusParked
|
|
StatusDead = task.StatusDead
|
|
StatusRejected = task.StatusRejected
|
|
StatusClosedWontDo = task.StatusClosedWontDo
|
|
StatusCompleted = task.StatusCompleted
|
|
)
|
|
|
|
// Task.Source values.
|
|
const (
|
|
SourceForge = task.SourceForge
|
|
SourceChat = task.SourceChat
|
|
)
|