fed-sx-types Phase 6: DefineTrigger verb + trigger_registry
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 53s

The trigger declaration layer (fed-sx-triggers-loop.md Phase 1): bind an
activity-type to a durable flow so an arriving activity can fan out into
a business flow.

- next/genesis/activity-types/define_trigger.sx — the DefineTrigger verb
  (DefineActivity form, nested-get schema). :object carries
  :activity-type, :flow-name, optional :guard / :actor-scope.
- next/kernel/trigger_registry.erl — pure core + registered gen_server,
  mirroring peer_actors/peer_types. Keyed by activity-type, multiple
  specs per type fire independently. Spec = {TriggerCid, FlowName,
  Guard, ActorScope}. Hydrates on start from a fold over DefineTrigger
  activities (restart-safe, same content-addressing as define_registry).

Manifest activity-types 7->8 (total bundle 38->39); the four bootstrap
count suites + genesis_parse bumped, and bootstrap_load's internal
timeout raised (the larger bundle's double cid:to_string was truncating).

Tests: define_trigger.sh (6), trigger_registry.sh (17). lib/erlang
771/771 + next/flow 34/34 untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-30 18:18:22 +00:00
parent 8b3d92ed5f
commit fc6a47ad62
10 changed files with 472 additions and 10 deletions

View File

@@ -0,0 +1,33 @@
;; next/genesis/activity-types/define_trigger.sx
;;
;; Bootstrap definition of the DefineTrigger verb per
;; plans/agent-briefings/fed-sx-triggers-loop.md (Phase 1) and
;; plans/fed-sx-design.md §13. Read as data by the bundler
;; (bootstrap.erl) — never evaluated as code.
;;
;; DefineTrigger binds an activity-type to a flow. When a matching
;; activity is appended to the log, the kernel's trigger fan-out
;; (pipeline.erl, post-append) looks the type up in the trigger
;; registry and starts the named flow with the activity as input.
;; The activity's :object is the binding record:
;; {:activity-type "Create" ;; the verb to fire on
;; :flow-name "blog-publish-digest"
;; :guard <optional predicate> ;; discriminator
;; :actor-scope <optional actor id>} ;; default: any
;;
;; The schema validates the *activity* shape: :object present with
;; string :activity-type and :flow-name. The optional :guard lets one
;; type bind to multiple flows with discriminators; it is resolved to
;; an Erlang predicate at registration time (trigger_registry), not
;; carried in the pure-predicate schema here. Schema bodies use nested
;; `get` (not keyword-threading) so the predicate is evaluatable.
(DefineActivity
:name "DefineTrigger"
:doc "Bind an activity-type to a flow. :object carries :activity-type, :flow-name, and optional :guard and :actor-scope."
:schema (fn
(act)
(and
(not (nil? (get act :object)))
(string? (get (get act :object) :activity-type))
(string? (get (get act :object) :flow-name))))
:semantics (fn (state act) state))

View File

@@ -24,7 +24,8 @@
"activity-types/announce.sx"
"activity-types/endorse.sx"
"activity-types/define_type.sx"
"activity-types/subtype_of.sx")
"activity-types/subtype_of.sx"
"activity-types/define_trigger.sx")
:object-types ("object-types/sx-artifact.sx"
"object-types/note.sx"
"object-types/tombstone.sx"