feat(eda): wire the playbook coordinator into production workflow selection

A loaded playbook now decides a real task's workflow. The wiring point is the
daemon's definition pin (Daemon.resolveWorkflowID, consumed by
pinWorkflowFromCollection), not pollNATS/publishTask as the design doc
assumed: routing moved out of the agent process when workflow definitions
became database rows pinned before dispatch, so the pin is the one place a
task's workflow is chosen.

Precedence: an explicit Task.Workflow (the waiting_human -> approved requeue)
still wins, then a matching playbook, then workflow.ResolveWorkflowID's
existing label/kind bindings. A playbook naming an undefined workflow is a
reported failure that parks the task rather than a silent fall-through to the
binding's choice -- the operator bound that trigger deliberately.

Store.Dispatch returns the selected workflow name plus the matching playbook's
id and version, instead of a compiled workflow.Workflow: the production caller
decides against the active definition collection, and the id/version are the
first two components of the resolved gap-2 idempotency key. The playbook
package no longer imports internal/domain/workflow.

The shipped example's `when` read event.priority, a field no intake supplies,
so it could never have fired once wired. Both examples now read the event
surface playbookInput really builds, and label-trigger.yaml documents the axis
an instance defines for itself: trigger.kind is the closed workintake
vocabulary because a kind addresses a NATS subject, while trigger.labels is
free-form and binds an operator's own taxonomy to a workflow.

Module/Channel/Forge positions stay rejected at load; they need the
playbook_dispatches ledger first (archie-core-t2db.24).

Closes archie-core-t2db.23
This commit is contained in:
sam committed 2026-09-21 23:47:06 +10:00
1 parent 9374e32fc4
commit 298c3133f3
9 files changed
+504 -79

No files matched your search

+34 -8
View File
@@ -926,14 +926,40 @@ are unblocked on the execution-time questions.
**Status 2026-09-03: resolved across t2db.13-15.** The Module position
(registry + log kind, t2db.13), the CEL expression environment
(t2db.14), and the playbook document + event coordinator with
single-action workflow-kind dispatch (t2db.15) are shipped. The
coordinator is NOT yet wired into production task intake
(daemon.go/pollNATS/publishTask) -- that is a follow-up ticket;
production wiring would make a real forge-triggered task flow through
this coordinator instead of only workflow.Route(). The trigger shape
reuses the existing workintake kind/label vocabulary; multi-action and
non-workflow-position playbooks remain rejected at load (hard
boundary, blocked on gap 2, idempotency).
single-action workflow-kind dispatch (t2db.15) are shipped.
**Status 2026-09-21: wired into production intake (t2db.23).** The
coordinator decides a real task's workflow. The wiring point is the
daemon's definition pin (`Daemon.resolveWorkflowID`, consumed by
`pinWorkflowFromCollection` in `internal/daemon/daemon.go`), not
`pollNATS`/`publishTask` as the earlier note assumed: routing moved out
of the agent process when workflow definitions became database rows
pinned before dispatch, so the pin is now the one place a task's
workflow is chosen. Precedence there is explicit `Task.Workflow` (the
waiting_human -> approved requeue) → matching playbook →
`workflow.ResolveWorkflowID`'s label binding → kind binding → triage →
implement. A playbook naming an undefined workflow is a reported
failure that parks the task rather than a silent fall-through to the
binding's choice.
`Store.Dispatch` returns the selected workflow *name* and the matching
playbook's id/version, not a compiled `workflow.Workflow`: the
production caller decides against the active definition collection, and
the returned id/version are the first two components of the gap-2
idempotency key. The playbook package no longer imports
`internal/domain/workflow`.
The `event` surface a `when` condition reads at this point is what the
intake actually knows about the originating issue: `kind`, `labels`,
`owner`, `repo`, `number`, `title`, `body`, `source`
(`playbookInput` in `internal/daemon/daemon.go`).
The trigger shape reuses the existing workintake kind/label vocabulary;
multi-action and non-workflow-position playbooks remain rejected at
load (hard boundary). Module/Channel/Forge action positions therefore
still have no production dispatch path: the resolved gap-2 scheme's
`playbook_dispatches` ledger is design-only and must land before a
side-effecting position can fire.
5. **Monetization boundary.** Sam has flagged this may be commercialized,
and explicitly wants it discerned from other OSS event-driven-automation
tooling. No design decision needed yet, but worth a note if/when