host P1: types DECLARE behavior, runner DERIVED (LIVE-VERIFIED)

Generalizes the hardcoded publish trigger into declared, capability-routed behavior.

- Types carry :behavior — flat string-keyed bindings {"verb" "type" "dag"} on the type-post
  (persist-safe, like :type-relations). The "article" type declares on-create → the "publish" DAG.
- host/blog--load-behaviors! gathers ALL posts' declarations into a registry at boot (serve.sh); the
  trigger match (host/blog--triggers :match = host/blog--match-behaviors) consults it. Hardcoded
  create+article trigger removed.
- Runner DERIVED (DEBT #2 fixed): match resolves :dag via host/blog--dag-registry and picks the
  runner via host/flow--select-runner over host/blog--runner-fleet ([exec-runner]; RA joins at
  RA-live). Each binding carries its :runner; behavior/-run-binding now uses the binding's runner
  (else the engine default) — so the capability model drives the LIVE engine.
- The type-def view shows each behavior + its derived runner (host/blog--behavior-lines).

LIVE PROOF: /article shows 'on create → publish DAG · needs {effect, branch} · runner: synchronous
(exec-fold)'; publishing on blog.rose-ash.com fired /flows validate+notify via the DECLARED path.
blog 213/213 (+3 P1), full host conformance 610/610. FINDING: load-behaviors! scans all posts, not
is-type?-filtered (article failed is-type? on the durable store though it passed in-memory).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 16:34:39 +00:00
parent c21be815f3
commit 9d29295820
5 changed files with 115 additions and 16 deletions

View File

@@ -41,13 +41,16 @@
(define behavior/-empty-trace
{:emitted (list) :ran (list) :effects (list) :suspended (list) :failed (list) :seen (list)})
;; run one trigger binding: execute its DAG with the FULL env, then branch on :status.
;; run one trigger binding: execute its DAG with the FULL env, then branch on :status. The runner
;; is the binding's DERIVED runner (get binding :runner) if the registry resolved one (capability
;; selection — P1), else the engine's default :runner.
(define behavior/-run-binding
(fn (engine activity binding depth acc)
(let ((env {:activity activity :actor (get activity :actor)
:ctx (behavior/-ctx-of engine activity) :effects (behavior/-effects engine)
:binding binding}))
(let ((result ((get (behavior/-runner engine) :run) (get binding :dag) env)))
(let ((runner (or (get binding :runner) (behavior/-runner engine))))
(let ((result ((get runner :run) (get binding :dag) env)))
(let ((acc1 (assoc acc :ran (concat (get acc :ran) (list result))))
(status (or (get result :status) "done")))
(cond
@@ -62,7 +65,7 @@
(fn (a eff)
(behavior/-dispatch-effect engine eff depth
(assoc a :effects (concat (get a :effects) (list eff)))))
acc1 (or (get result :effects) (list))))))))))
acc1 (or (get result :effects) (list)))))))))))
;; dispatch one effect via the driver; recurse on any NEW activities it emits (the loop closes).
(define behavior/-dispatch-effect