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 5c5a62ae3b
commit 61887fd781
9 files changed
+504 -79

No files matched your search

+30 -5
View File
@@ -10,10 +10,35 @@
# Multi-action playbooks and Module/Channel/Forge action positions stay
# blocked on the unresolved execution-time gaps and are rejected at load.
#
# Trigger matching reuses the existing workintake label/kind vocabulary
# (bug/feature/bootstrap, or a label set). The `when` condition is a CEL
# expression over `event` (the triggering event's fields) -- see
# docs/prds/eda-playbook-engine.md, resolved open question 1.
# A trigger matches on either axis, and both are checked when both are given:
#
# kind: the closed workintake routing vocabulary -- bug, feature,
# bootstrap, default. It is closed because a kind also addresses the
# task's NATS subject; anything else is rejected at load. Set it
# when you want the rule to follow archie's own classification.
# labels: any labels you like, including ones no kind recognises
# ("ops::security-review"). All of them must be present on the
# issue. This is the axis an instance defines for itself: it binds
# your own taxonomy to a workflow with no code change. See
# label-trigger.yaml. The `when` condition is a CEL
# expression over `event` -- see docs/prds/eda-playbook-engine.md, resolved
# open question 1.
#
# A matching playbook decides the task's workflow ahead of the kind/label
# binding files, and a workflow it names that is not defined parks the task
# rather than falling back. For a forge-discovered task, `event` carries:
#
# kind routing kind the labels produced (bug/feature/bootstrap/default)
# labels the issue's labels, as a list
# owner repo owner
# repo repo name
# number issue number
# title issue title
# body issue body
# source "forge" or "chat"
#
# Reading a field that is not in that set is an evaluation error, which the
# coordinator treats as the condition being false (the playbook is skipped).
trigger:
kind: bug
@@ -21,4 +46,4 @@ trigger:
actions:
- position: workflow
workflow: tdd
when: event.priority == 3
when: '"regression" in event.labels'
+19
View File
@@ -0,0 +1,19 @@
# Example EDA playbook triggering on an instance-defined label.
#
# The kind axis (bug/feature/bootstrap/default) is archie's own closed
# classification. This file is the other axis: a label set of your own
# choosing, matched as a subset of the issue's labels. Every label listed here
# must be present on the issue for the playbook to fire.
#
# A matching playbook decides the task's workflow ahead of the
# workflow_routing_file, workflow_labels_file and playbook_dirs bindings. The
# workflow it names must be a defined workflow; naming one that is not parks
# the task with a reported error rather than quietly running a different one.
trigger:
labels:
- ops::security-review
actions:
- position: workflow
workflow: feasibility