Playbooks can trigger on an event type #152

Closed
opened 2026-10-27 13:35:10 +00:00 by sam · 2 comments
Owner

Goal

A playbook can name a captured event type as its trigger; a matching capture runs its actions through the idempotency ledger.

Evidence

Trigger has only kind and labels (internal/domain/eda/playbook/playbook.go:103-106); playbooks run only at task pin (daemon.go:1853).

Rules

Read CLAUDE.md. Do only what the Goal and Stop when need. File anything else you notice as a bead; do not fix it. Run task check once at the end; if it fails twice on the same problem, comment on this bead and stop.

Stop when

  • Trigger field for event type, validated on save.
  • Capture dispatch path runs matching playbooks once.
    Then commit (Conventional Commits, scoped by package), bd close this bead and stop.

Imported from beads archie-core-bdb5.6 · GitHub #1312 · type feature · priority P2 · created 2026-10-05

## Goal A playbook can name a captured event type as its trigger; a matching capture runs its actions through the idempotency ledger. ## Evidence Trigger has only kind and labels (internal/domain/eda/playbook/playbook.go:103-106); playbooks run only at task pin (daemon.go:1853). ## Rules Read CLAUDE.md. Do only what the Goal and Stop when need. File anything else you notice as a bead; do not fix it. Run `task check` once at the end; if it fails twice on the same problem, comment on this bead and stop. ## Stop when - [ ] Trigger field for event type, validated on save. - [ ] Capture dispatch path runs matching playbooks once. Then commit (Conventional Commits, scoped by package), `bd close` this bead and stop. --- _Imported from beads `archie-core-bdb5.6` · GitHub #1312 · type feature · priority P2 · created 2026-10-05_
sam added the mediumfeature labels 2026-10-27 13:35:10 +00:00
sam self-assigned this 2026-10-27 13:35:10 +00:00
Author
Owner

archie's PRD is ready -- awaiting your go/no-go.

PRD — Playbooks can trigger on an event type (#152)

Problem

An EDA playbook's trigger can only describe a task: Trigger holds Kind workintake.Kind and Labels []string and nothing else (internal/domain/eda/playbook/playbook.go:66-75), and the only required-field check is "kind or labels" (:238-240). Playbooks are therefore consulted in exactly one place — the workflow pin path: runActionPlaybooks from pinDefinition (internal/daemon/daemon.go:2266, :2332-2342) and resolveWorkflowID (:2346-2362). Store.Dispatch deliberately skips action playbooks (playbook.go:588-590), so a capture can never reach a playbook no matter what it contains.

Two things already exist and are unused for this input:

  • The trigger→action machinery: CEL when/args, typed module actions, and the playbook_dispatches ledger keyed (playbook_id, playbook_version, event_id, action_id) with a unique index (migrations/0002_edastore.sql:84-92), wired into production at internal/app/archied/bootstrap.go:674.
  • A per-org, newest-first capture read that needs no contract change: CaptureStore.ListCaptures (storecontract/capture.go:11-14), org-scoped SQL (queries/edastore.sql:10-15), implemented by staterpc.Client.ListCaptures (staterpc/captures.go:131-147), plus Client.ListEventTypes (staterpc/eventtypes.go:139-145) to turn a capture's event-type ID into (source, name).

So the gap is one trigger field, one save-time check, and one dispatch pass — not new machinery.

Why the pass cannot reuse the binding read. ListUndispatchedCaptures only lists captures that an armed binding's mapping matches (queries/edastore.sql:17-31) and dispatchOrgBindings returns before listing when no binding is enabled (daemon.go:611-632). A capture nobody has bound is invisible to the daemon, which is precisely the capture a playbook trigger should see.

Proposed solution

1. Trigger field, validated on save

trigger:
  event:
    source: sentry
    name: Error raised
actions:
  - position: module
    kind: log
    args:
      message: event.event_type
  • Trigger gains Event *EventType (new value type EventType{Source, Name string}), decoded from rawTrigger (playbook.go:110-114). The pair is optional; absent keeps today's behaviour exactly.
  • Validation lives in compileOne (playbook.go:222-250), which is the one compiler behind both save-time validation (playbooksDefinition().Validate → CompilePlaybooks, controlplanestore/playbooks.go:30-44) and the daemon's live load (LivePlaybooks.current, playbooks_client.go:96). New rejections, each naming the playbook and the field:
    • trigger.event with an empty source or name;
    • trigger.event together with kind or labels (a capture has neither, so the combination can never match one thing);
    • trigger.event on a playbook with a workflow action — a workflow playbook is selected only at pin, where there is no capture, so it would load, show up, and never fire;
    • the existing "trigger must declare a kind or labels" message becomes "…a kind, labels or event".
  • Shape only: no existence check of the named type (see Decision 2 and Non-goals).

2. Matching

Match (playbook.go:533-557) gains an explicit event branch: with Trigger.Event set, it compares the input's EventType{Source, Name} and nothing else. DispatchInput.TaskID is renamed EventID (documented as "the ledger's event key: a task's idempotency key at pin, a capture's id on the capture path"; usages: coordinator.go:24-31, daemon.playbookInput at daemon.go:2370-2388). DispatchInput gains EventType *EventType.

The event branch is what stops an event-triggered playbook firing at every task pin: task inputs carry no EventType, so the branch returns false. In the other direction no guard is needed — a capture input carries no labels and no kind, so a kind/labels trigger cannot match it, and a trigger with neither is already rejected at load.

3. Capture dispatch path

A new pass beside the binding pass, at the same three call sites (daemon.go:378, :405, :478):

dispatchCapturePlaybooks(ctx)
  ├─ return if Captures / Playbooks / PlaybookLedger is nil
  ├─ return unless the loaded set has an event-triggered playbook   (one method on Store/LivePlaybooks)
  ├─ for each org the daemon acts for (same principal iteration as dispatchBindings)
  └─ dispatchOrgCapturePlaybooks(ctx)
       ├─ captures := Captures.ListCaptures(ctx, capturePlaybookLimit)      // newest first, org-scoped
       ├─ types     := EventTypes.ListEventTypes(ctx) → map[id]{source,name}
       ├─ skip a capture that is not c.Dispatchable() or has no event type
       └─ oldest-first: Playbooks.Run(ctx, PlaybookLedger, Log, captureInput(c, t))
                        error → Log.WarnContext("capture playbook run failed", capture, err); continue

captureInput sets EventID = c.ID, EventType = {t.Source, t.Name}, and a CEL event map of source, event_type (name), delivery, received_at. No body (see Non-goals). capturePlaybookLimit is a new const (proposal: 20), deliberately smaller than bindingDispatchBatchLimit because the whole window is re-read every pass.

Daemon gains two fields, both already implemented by the staterpc.Client the daemon holds: Captures storecontract.CaptureStore and EventTypes interface{ ListEventTypes(context.Context) ([]eventtype.EventType, error) }, assigned in buildDaemon with the same assert-and-assign pattern as Bindings/BindingDispatcher (bootstrap.go:645-672) — ~8 lines. Suggested cleanup: extract the principal-per-org iteration in dispatchBindings (daemon.go:568-604) into one helper both passes call, so the two cannot drift.

Fire-and-forget in the same sense as today: Run joins errors, the pass logs and moves on, no task is failed, the loop is never aborted.

Semantics this buys, stated plainly

  • At most once per (playbook, version, capture, action) — the existing ledger guarantee, now keyed by capture id.
  • A bounded window. A capture that falls out of the newest-N list before it is seen (a burst larger than the window between passes) never fires. At current intake rates 20/second is far above real traffic; it is a limit, not a guarantee.
  • An edit can re-fire. The playbook version is part of the ledger key, so a capture still inside the window re-runs its actions under the new version. Today the only kind is log, so the effect is a second log line. Before the first side-effecting kind ships this must be closed — either a store-side undispatched-capture read (proto + sqlc anti-join, follow-up bead) or a load-time cutoff (fire only on captures received after this version was compiled).
  • No persisted cursor. A restart re-reads the window once and the ledger absorbs the repeats; work missed while the daemon was down is picked up if still in the window, and silently skipped otherwise.

Files and components affected

File Change ~lines
internal/domain/eda/playbook/playbook.go Trigger.Event, EventType type, raw decode, load validation, Match branch, DispatchInput.EventType, TaskID→EventID 55
internal/domain/eda/playbook/coordinator.go EventID field rename 3
internal/domain/eda/playbook/run.go comment (Run now has two callers); Store.HasEventTriggers() 10
internal/infrastructure/controlplanestore/playbooks_client.go HasEventTriggers delegate 5
internal/daemon/daemon.go two fields, const, dispatchCapturePlaybooks, dispatchOrgCapturePlaybooks, captureInput, 3 call sites, optional org-iteration helper 95
internal/app/archied/bootstrap.go wire Captures, EventTypes 8
internal/domain/eda/playbook/playbook_test.go (new) compile/Match table 70
internal/daemon/capture_playbook_test.go (new) pass behaviour against a fake store + ledger 80
WORKFLOWS.md (the playbook bullet, :327-328) event trigger, source+name naming, redacted-payload note, window caveat 6
CHANGELOG.md [Unreleased] under archied only if the maintainer records entries in the change commit; task news must then be re-run or news:check fails 2

No proto, sqlc, store-contract, RPC, config field, UI or migration change. The playbook editor is a YAML textarea (ui/src/settings/PlaybooksPage.vue) and the canvas lists only workflow playbooks (ui/src/workflows/workflow-triggers.ts:96-105), so neither needs touching.

Acceptance criteria

  1. A playbook whose trigger is event: {source: S, name: N} with module actions saves through the control plane (Command{command:"replace"} and "validate" both succeed).
  2. Save is refused, naming the playbook and the field, for: empty event.source; empty event.name; event combined with kind or labels; event on a workflow-action playbook; a trigger with no kind, labels or event.
  3. With that playbook loaded and a dispatchable capture from S identified as N, within one daemon pass (≤1 s in the drain loop, ≤ poll_interval otherwise) the playbook's actions run in order, one playbook_dispatches row per action exists with event_id = the capture id, and the log kind writes one daemon log line.
  4. A second pass over the same capture runs nothing (ledger returns ErrAlreadyDispatched), logs nothing new, and surfaces no error.
  5. A capture with event_type = '', or one that is neither authenticated nor unsigned (CapturedEvent.Dispatchable()), fires nothing.
  6. An event-triggered playbook never runs at task pin: pinning any task with that playbook set writes no ledger row.
  7. A kind/labels playbook behaves exactly as before at pin; the existing binding-dispatch tests still pass.
  8. task check passes once, on the finished tree.

Explicit non-goals

  • No change to bindings, mappings, the binding dispatch ledger, capture intake or payload redaction.
  • No capture body in CEL (event.body). Redacted bodies, payload size and "unauthenticated input inside expressions" need their own decision; follow-up bead.
  • No existence check of the named event type at save. Recommended because Definition.Validate/Decode take no context.Context and no org (controlplanestore/registry.go:56-84), and the same validator runs over every org's stored value at startup (registry.go:294-310) and over seeds — a check against live event types there would fail a stored playbook once its type is deleted and make the resource unrepairable. Precedent: binding.Validate is shape-only and workflow existence is checked elsewhere (domain/binding/binding.go:64-68). The cost is that a typo is a silent non-trigger.
  • No new module kind. log remains the only registered kind (module/module.go:30-36), so the observable effect of this feature today is a log line plus ledger rows.
  • No UI work: no playbook trigger editor, no canvas entry for event-triggered action playbooks.
  • No proto/sqlc/store-contract/RPC change, no persisted cursor, no exactly-once across edits or bursts, no at-least-once across restarts.
  • No access-chain authorization for playbook actions (see Risk 2).
  • Store.Dispatch (workflow selection) stays pin-only; workflow playbooks may not carry an event trigger.

Diff size

~350–400 lines including tests: ~180 shipped Go, ~6 docs, ~150 in two new test files; plus the optional ~25-line org-iteration extraction (moved, not added). No generated files change.

Risks and operator decisions

  1. Trigger vocabulary — event: {source, name} (recommended) vs the event-type ID. (source, name) is unique instance-wide (migrations/0007_event_types.sql:22, unchanged by later migrations); the ID is an opaque UUID and playbooks are hand-written YAML. Renaming an event type silently stops matching.
  2. Security shape. Bindings gate on the access chain and Dispatchable() (daemon.go:750-800, storecontract/capture.go:74-76); module actions have no gate. Recommended: fire only when c.Dispatchable() and the event type is non-empty, with the reason in a code comment — because this is an unauthenticated-input → in-process-action path once a side-effecting kind exists.
  3. Validation strictness — shape-only now (recommended, see Non-goals) vs existence check (needs Validate to take a ctx and an EventTypeStore injected into the control plane, ~40 lines across 16 definitions).
  4. Which shapes may carry the trigger — action playbooks only (recommended) vs both; a workflow playbook's trigger is evaluated at pin, where no capture exists.
  5. Window vs store-side read — list the newest 20 captures and let the ledger dedupe now (recommended: no proto/sqlc change, ships in one commit) vs build StreamPlaybookCaptures with a playbook_dispatches anti-join now (exactly-once over the backlog, but proto + sqlc + contract + generated churn). Recommend the cheap path now and file the anti-join as a blocking bead for the first side-effecting module kind.
  6. Duplicate route. Event bindings already do "captured event type → start work". This adds a second, mapping-free route over the same captures, with two ledgers and two loops. The distinction (in-process CEL reactions vs. mapped workflow inputs) is real; the README pipeline diagram gains an alternative edge, and WORKFLOWS.md:327-328 must say which to use when.

What I verified / did not

Verified by reading the tree: every file, line and behaviour cited above, including that ListCaptures and ListEventTypes are already on staterpc.Client and org-scoped, that playbook_dispatches has no org column and a per-version unique key, that log is the only module kind, and that the three dispatch call sites are the only ones. The working tree is already on branch feat/152-playbooks-can-trigger-on-an-event-type with no commits for it.

Not verified: I could not run task check, go test, bd or tea, so the diff estimate is a reading of the code, not a measurement; and I could not read the parent epic's other beads, so sequencing against it is unknown.

Decide in chat or on the dashboard.

**archie's PRD is ready -- awaiting your go/no-go.** # PRD — Playbooks can trigger on an event type (#152) ## Problem An EDA playbook's trigger can only describe a *task*: `Trigger` holds `Kind workintake.Kind` and `Labels []string` and nothing else (`internal/domain/eda/playbook/playbook.go:66-75`), and the only required-field check is "kind or labels" (`:238-240`). Playbooks are therefore consulted in exactly one place — the workflow pin path: `runActionPlaybooks` from `pinDefinition` (`internal/daemon/daemon.go:2266`, `:2332-2342`) and `resolveWorkflowID` (`:2346-2362`). `Store.Dispatch` deliberately skips action playbooks (`playbook.go:588-590`), so a capture can never reach a playbook no matter what it contains. Two things already exist and are unused for this input: - The trigger→action machinery: CEL `when`/`args`, typed module actions, and the `playbook_dispatches` ledger keyed `(playbook_id, playbook_version, event_id, action_id)` with a unique index (`migrations/0002_edastore.sql:84-92`), wired into production at `internal/app/archied/bootstrap.go:674`. - A per-org, newest-first capture read that needs no contract change: `CaptureStore.ListCaptures` (`storecontract/capture.go:11-14`), org-scoped SQL (`queries/edastore.sql:10-15`), implemented by `staterpc.Client.ListCaptures` (`staterpc/captures.go:131-147`), plus `Client.ListEventTypes` (`staterpc/eventtypes.go:139-145`) to turn a capture's event-type ID into `(source, name)`. So the gap is one trigger field, one save-time check, and one dispatch pass — not new machinery. **Why the pass cannot reuse the binding read.** `ListUndispatchedCaptures` only lists captures that an armed binding's mapping matches (`queries/edastore.sql:17-31`) and `dispatchOrgBindings` returns before listing when no binding is enabled (`daemon.go:611-632`). A capture nobody has bound is invisible to the daemon, which is precisely the capture a playbook trigger should see. ## Proposed solution ### 1. Trigger field, validated on save ```yaml trigger: event: source: sentry name: Error raised actions: - position: module kind: log args: message: event.event_type ``` - `Trigger` gains `Event *EventType` (new value type `EventType{Source, Name string}`), decoded from `rawTrigger` (`playbook.go:110-114`). The pair is optional; absent keeps today's behaviour exactly. - Validation lives in `compileOne` (`playbook.go:222-250`), which is the one compiler behind **both** save-time validation (`playbooksDefinition().Validate` → `CompilePlaybooks`, `controlplanestore/playbooks.go:30-44`) and the daemon's live load (`LivePlaybooks.current`, `playbooks_client.go:96`). New rejections, each naming the playbook and the field: - `trigger.event` with an empty `source` or `name`; - `trigger.event` together with `kind` or `labels` (a capture has neither, so the combination can never match one thing); - `trigger.event` on a playbook with a workflow action — a workflow playbook is selected only at pin, where there is no capture, so it would load, show up, and never fire; - the existing "trigger must declare a kind or labels" message becomes "…a kind, labels or event". - Shape only: no existence check of the named type (see Decision 2 and Non-goals). ### 2. Matching `Match` (`playbook.go:533-557`) gains an explicit event branch: with `Trigger.Event` set, it compares the input's `EventType{Source, Name}` and nothing else. `DispatchInput.TaskID` is renamed `EventID` (documented as "the ledger's event key: a task's idempotency key at pin, a capture's id on the capture path"; usages: `coordinator.go:24-31`, `daemon.playbookInput` at `daemon.go:2370-2388`). `DispatchInput` gains `EventType *EventType`. The event branch is what stops an event-triggered playbook firing at every task pin: task inputs carry no `EventType`, so the branch returns false. In the other direction no guard is needed — a capture input carries no labels and no kind, so a `kind`/`labels` trigger cannot match it, and a trigger with neither is already rejected at load. ### 3. Capture dispatch path A new pass beside the binding pass, at the same three call sites (`daemon.go:378`, `:405`, `:478`): ``` dispatchCapturePlaybooks(ctx) ├─ return if Captures / Playbooks / PlaybookLedger is nil ├─ return unless the loaded set has an event-triggered playbook (one method on Store/LivePlaybooks) ├─ for each org the daemon acts for (same principal iteration as dispatchBindings) └─ dispatchOrgCapturePlaybooks(ctx) ├─ captures := Captures.ListCaptures(ctx, capturePlaybookLimit) // newest first, org-scoped ├─ types := EventTypes.ListEventTypes(ctx) → map[id]{source,name} ├─ skip a capture that is not c.Dispatchable() or has no event type └─ oldest-first: Playbooks.Run(ctx, PlaybookLedger, Log, captureInput(c, t)) error → Log.WarnContext("capture playbook run failed", capture, err); continue ``` `captureInput` sets `EventID = c.ID`, `EventType = {t.Source, t.Name}`, and a CEL `event` map of `source`, `event_type` (name), `delivery`, `received_at`. No body (see Non-goals). `capturePlaybookLimit` is a new const (proposal: 20), deliberately smaller than `bindingDispatchBatchLimit` because the whole window is re-read every pass. Daemon gains two fields, both already implemented by the `staterpc.Client` the daemon holds: `Captures storecontract.CaptureStore` and `EventTypes interface{ ListEventTypes(context.Context) ([]eventtype.EventType, error) }`, assigned in `buildDaemon` with the same assert-and-assign pattern as `Bindings`/`BindingDispatcher` (`bootstrap.go:645-672`) — ~8 lines. Suggested cleanup: extract the principal-per-org iteration in `dispatchBindings` (`daemon.go:568-604`) into one helper both passes call, so the two cannot drift. Fire-and-forget in the same sense as today: `Run` joins errors, the pass logs and moves on, no task is failed, the loop is never aborted. ### Semantics this buys, stated plainly - **At most once per (playbook, version, capture, action)** — the existing ledger guarantee, now keyed by capture id. - **A bounded window.** A capture that falls out of the newest-N list before it is seen (a burst larger than the window between passes) never fires. At current intake rates 20/second is far above real traffic; it is a limit, not a guarantee. - **An edit can re-fire.** The playbook version is part of the ledger key, so a capture still inside the window re-runs its actions under the new version. Today the only kind is `log`, so the effect is a second log line. **Before the first side-effecting kind ships this must be closed** — either a store-side undispatched-capture read (proto + sqlc anti-join, follow-up bead) or a load-time cutoff (fire only on captures received after this version was compiled). - **No persisted cursor.** A restart re-reads the window once and the ledger absorbs the repeats; work missed while the daemon was down is picked up if still in the window, and silently skipped otherwise. ## Files and components affected | File | Change | ~lines | | --- | --- | --- | | `internal/domain/eda/playbook/playbook.go` | `Trigger.Event`, `EventType` type, raw decode, load validation, `Match` branch, `DispatchInput.EventType`, `TaskID`→`EventID` | 55 | | `internal/domain/eda/playbook/coordinator.go` | `EventID` field rename | 3 | | `internal/domain/eda/playbook/run.go` | comment (`Run` now has two callers); `Store.HasEventTriggers()` | 10 | | `internal/infrastructure/controlplanestore/playbooks_client.go` | `HasEventTriggers` delegate | 5 | | `internal/daemon/daemon.go` | two fields, const, `dispatchCapturePlaybooks`, `dispatchOrgCapturePlaybooks`, `captureInput`, 3 call sites, optional org-iteration helper | 95 | | `internal/app/archied/bootstrap.go` | wire `Captures`, `EventTypes` | 8 | | `internal/domain/eda/playbook/playbook_test.go` (new) | compile/Match table | 70 | | `internal/daemon/capture_playbook_test.go` (new) | pass behaviour against a fake store + ledger | 80 | | `WORKFLOWS.md` (the playbook bullet, `:327-328`) | event trigger, `source`+`name` naming, redacted-payload note, window caveat | 6 | | `CHANGELOG.md` `[Unreleased]` under archied | only if the maintainer records entries in the change commit; `task news` must then be re-run or `news:check` fails | 2 | No proto, sqlc, store-contract, RPC, config field, UI or migration change. The playbook editor is a YAML textarea (`ui/src/settings/PlaybooksPage.vue`) and the canvas lists only *workflow* playbooks (`ui/src/workflows/workflow-triggers.ts:96-105`), so neither needs touching. ## Acceptance criteria 1. A playbook whose trigger is `event: {source: S, name: N}` with module actions saves through the control plane (`Command{command:"replace"}` and `"validate"` both succeed). 2. Save is refused, naming the playbook and the field, for: empty `event.source`; empty `event.name`; `event` combined with `kind` or `labels`; `event` on a workflow-action playbook; a trigger with no kind, labels or event. 3. With that playbook loaded and a dispatchable capture from `S` identified as `N`, within one daemon pass (≤1 s in the drain loop, ≤ `poll_interval` otherwise) the playbook's actions run in order, one `playbook_dispatches` row per action exists with `event_id` = the capture id, and the `log` kind writes one daemon log line. 4. A second pass over the same capture runs nothing (ledger returns `ErrAlreadyDispatched`), logs nothing new, and surfaces no error. 5. A capture with `event_type = ''`, or one that is neither authenticated nor `unsigned` (`CapturedEvent.Dispatchable()`), fires nothing. 6. An event-triggered playbook never runs at task pin: pinning any task with that playbook set writes no ledger row. 7. A `kind`/`labels` playbook behaves exactly as before at pin; the existing binding-dispatch tests still pass. 8. `task check` passes once, on the finished tree. ## Explicit non-goals - No change to bindings, mappings, the binding dispatch ledger, capture intake or payload redaction. - No capture body in CEL (`event.body`). Redacted bodies, payload size and "unauthenticated input inside expressions" need their own decision; follow-up bead. - **No existence check of the named event type at save.** Recommended because `Definition.Validate`/`Decode` take no `context.Context` and no org (`controlplanestore/registry.go:56-84`), and the same validator runs over every org's stored value at startup (`registry.go:294-310`) and over seeds — a check against live event types there would fail a stored playbook once its type is deleted and make the resource unrepairable. Precedent: `binding.Validate` is shape-only and workflow existence is checked elsewhere (`domain/binding/binding.go:64-68`). The cost is that a typo is a silent non-trigger. - No new module kind. `log` remains the only registered kind (`module/module.go:30-36`), so the observable effect of this feature today is a log line plus ledger rows. - No UI work: no playbook trigger editor, no canvas entry for event-triggered action playbooks. - No proto/sqlc/store-contract/RPC change, no persisted cursor, no exactly-once across edits or bursts, no at-least-once across restarts. - No access-chain authorization for playbook actions (see Risk 2). - `Store.Dispatch` (workflow selection) stays pin-only; workflow playbooks may not carry an event trigger. ## Diff size ~350–400 lines including tests: ~180 shipped Go, ~6 docs, ~150 in two new test files; plus the optional ~25-line org-iteration extraction (moved, not added). No generated files change. ## Risks and operator decisions 1. **Trigger vocabulary** — `event: {source, name}` (recommended) vs the event-type ID. `(source, name)` is unique instance-wide (`migrations/0007_event_types.sql:22`, unchanged by later migrations); the ID is an opaque UUID and playbooks are hand-written YAML. Renaming an event type silently stops matching. 2. **Security shape.** Bindings gate on the access chain and `Dispatchable()` (`daemon.go:750-800`, `storecontract/capture.go:74-76`); module actions have no gate. Recommended: fire only when `c.Dispatchable()` and the event type is non-empty, with the reason in a code comment — because this is an unauthenticated-input → in-process-action path once a side-effecting kind exists. 3. **Validation strictness** — shape-only now (recommended, see Non-goals) vs existence check (needs `Validate` to take a ctx and an `EventTypeStore` injected into the control plane, ~40 lines across 16 definitions). 4. **Which shapes may carry the trigger** — action playbooks only (recommended) vs both; a workflow playbook's trigger is evaluated at pin, where no capture exists. 5. **Window vs store-side read** — list the newest 20 captures and let the ledger dedupe now (recommended: no proto/sqlc change, ships in one commit) vs build `StreamPlaybookCaptures` with a `playbook_dispatches` anti-join now (exactly-once over the backlog, but proto + sqlc + contract + generated churn). Recommend the cheap path now and file the anti-join as a blocking bead for the first side-effecting module kind. 6. **Duplicate route.** Event bindings already do "captured event type → start work". This adds a second, mapping-free route over the same captures, with two ledgers and two loops. The distinction (in-process CEL reactions vs. mapped workflow inputs) is real; the README pipeline diagram gains an alternative edge, and `WORKFLOWS.md:327-328` must say which to use when. ## What I verified / did not Verified by reading the tree: every file, line and behaviour cited above, including that `ListCaptures` and `ListEventTypes` are already on `staterpc.Client` and org-scoped, that `playbook_dispatches` has no org column and a per-version unique key, that `log` is the only module kind, and that the three dispatch call sites are the only ones. The working tree is already on branch `feat/152-playbooks-can-trigger-on-an-event-type` with no commits for it. Not verified: I could not run `task check`, `go test`, `bd` or `tea`, so the diff estimate is a reading of the code, not a measurement; and I could not read the parent epic's other beads, so sequencing against it is unknown. _Decide in chat or on the dashboard._
Author
Owner

Closed: goes against the product plan in epic #1977. Playbooks are being removed; triggers replace bindings, mappings, issue routing and playbooks (#1978).

Closed: goes against the product plan in epic #1977. Playbooks are being removed; triggers replace bindings, mappings, issue routing and playbooks (#1978).
sam closed this issue 2026-11-14 14:45:06 +00:00
sam added a new dependency 2026-11-14 14:45:09 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#152