host: execute-fold — universality proven with a second fold (composition step 7)

The keystone validation of the universal-algebra thesis. lib/host/execute.sx is a SECOND
interpreter over the SAME seq/alt/each composition algebra as the render-fold — but a
different fold: leaves are EFFECTS, seq = steps in order, alt+when = branch, each =
for-each, and the accumulator is an effect log instead of an HTML string. It REUSES
compose.sx's shared machinery verbatim — host/comp--pred? (when), host/comp--field
(field/value), host/comp--source (each source) — so the predicate set, context-environment,
and iteration source are domain-agnostic; only the leaf semantics + accumulator are new.

KEYSTONE (tested): ONE (alt (when (has "auth") …) …) skeleton + ONE context folds two ways
— render picks the branch → "<b>in</b>", execute picks the SAME branch → {:verb "enter"}.
A publish workflow (validate → branch-on-status → notify-each) runs as one execute-fold over
a composition object. So the behaviour model (Slice 9) is "an execute-fold over a composition
object", not a separate system — the way the recursive tree proved recursion, this proves the
algebra is domain-agnostic. host/exec-run; 13/13 (new execute suite); wired into conformance
+ serve. Full host conformance 371/373 in 42s (warm); the 2 fails are the pre-existing
relate-picker pair.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 23:49:41 +00:00
parent b78491a5a1
commit ed68b9883d
5 changed files with 175 additions and 5 deletions

View File

@@ -125,11 +125,15 @@ Transclusion = a `ref` leaf. Sort/filter/limit/group = the *source query* langua
`POST /:slug/blocks/{add,:cslug/remove,:cslug/move}` (guarded, SX-htmx outerHTML swap).
Per-block field editing is free — a card is an object, edited via its own `/<cslug>/edit`.
(Live SX-htmx swap still wants a Playwright check; `alt`/`each` block insertion deferred.)
7. **Prove universality with a second fold.** Write a tiny `execute`-fold over the *same*
`seq/alt/each` structure that *runs* a workflow (leaves = effects; `seq` = steps in order, `alt`
= branch, `each` = for-each) — the way the recursive tree proved recursion, this proves the
composition algebra is domain-agnostic. Then the *behaviour* model (Slice 9) is "an `execute`-fold
over a composition object", not a separate system.
7. **(done)** Prove universality with a second fold. `lib/host/execute.sx` is an `execute`-fold
over the *same* `seq/alt/each` structure: leaves = effects, `seq` = steps in order, `alt`+`when`
= branch, `each` = for-each; the fold returns an effect log. It REUSES compose.sx's shared
machinery — `host/comp--pred?` (when), `host/comp--field` (field/value), `host/comp--source`
(each source) — so only the leaf semantics + accumulator differ. KEYSTONE proven (tests): ONE
`(alt (when …) …)` skeleton + ONE context folds two ways — render picks the branch → HTML,
execute picks the SAME branch → effect. A publish workflow (validate→branch→notify-each) runs as
one execute-fold. The behaviour model (Slice 9) is "an execute-fold over a composition object",
not a separate system. 13/13 (execute suite). Wired into conformance + serve.
8. **Factor out the shared machinery** once two folds exist: the fork model (ordered, labelled,
`when`), the combinator dispatch, the context-environment, and recursion become a reusable
`compose` core; each domain (`render`, `execute`, `eval`, …) supplies only its leaf + combinator