Commit Graph

4169 Commits

Author SHA1 Message Date
9ac6a8afd5 host P0.3: wire the seam into the live publish path (LIVE-VERIFIED)
Publishing a post now fires the on-publish behavior DAG through the seam. host/blog--{transport
(activity log), triggers (on-publish: create+article → publish-DAG), driver (records each effect in
the flow log), publish-engine (behavior/make-engine over the four adapters + the execute-fold runner
+ publish-ctx), fire-publish!, maybe-publish!}. Both write handlers (form-submit POST /new,
edit-submit POST /:slug/edit) detect the draft→published TRANSITION (fire-once) in the handler body
and run behavior/process. GET /flows renders the flow log (the effect-as-data the driver dispatched).

LIVE PROOF: logged in + POST /new on blog.rose-ash.com → /flows shows 'validate' + 'notify' (the
publish-DAG branched on the default urgent category), driven end-to-end by the real behavior engine.
Every piece is a seam adapter — swapping the runner for Erlang (RA) or the transport for fed-sx (TA)
federates this same wiring unchanged.

blog 207/207 (+4 P0.3), full host conformance 595/595. GAP: flow log is in-memory (P0.3b = persist).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 14:56:00 +00:00
564fa7dd7d plan: don't calcify P0.2 — artdag may grow to contain business logic (phase AX)
Per the user: the execute-fold-vs-artdag split from P0.2 is a capability SNAPSHOT, not a permanent
boundary. artdag MAY grow +{effect,branch,each} node-kinds; business logic then migrates onto it to
inherit the DAG-engine superpowers — content-addressed memoization (recompute only on input-CID
change), optimize (fuse/dedup/dce), schedule, and above all FEDERATION (a flow result reused across
peers by content-id — the federation vision, for free). The capability model makes the migration
seamless (same DAGs + seam; the runner just advertises more). Named the real design work: dynamic
control in a static DAG (branch prunes a path); effect nodes non-cacheable vs pure nodes memoized.
Demand-driven (phase AX); execute-fold stays the lean default for cheap synchronous flows. Annotated
the P0.2 finding + flows.sx header so the finding doesn't harden into dogma.

Doc/comment-only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 14:38:36 +00:00
e38a8381d4 host P0.2: publish-DAG + execute-fold runner + capability check (hypothesis confirmed)
The hypothesis test. FINDING: a synchronous business flow expresses NATURALLY as an EXECUTE-FOLD
composition (host/execute.sx: seq/effect/alt — the category branch IS 'alt'), NOT an artdag
DATAFLOW DAG (which has no control flow). So 'business logic = art-dag' holds at the ABSTRACTION
(both content-addressed op-DAGs) and is REFINED at the vocabulary: the synchronous control-flow
runner is the execute-fold (caps {effect,branch,each}); artdag is the dataflow sibling. Two
instances of one thing, run very differently — exactly the framing.

lib/host/flows.sx: capability typing (host/flow--node-cap/required-caps derive a DAG's capability
set from its node vocabulary; effect→effect, alt→branch, each→each, wait→suspend), the execute-fold
seam runner (advertises {effect,branch,each}), and host/flow--bind (required ⊆ advertised → derive
the runner, else fail-fast). host/blog--publish-dag (the publish workflow) + publish-ctx.

Verified: publish-DAG required-caps = {effect,branch} → binds to the sync runner; runs →
newsletter→[validate,digest] / urgent→[validate,notify] / other→[validate,skip]; a  node →
{suspend} → binds FAIL-FAST against the exec-runner (would need the Erlang runner, RA). Runner is
DERIVED, not chosen. flows 7/7, blog 203/203, full host conformance 591/591.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 14:18:08 +00:00
8c48cac46f plan: capability-typed nodes + capability-advertising runners (derived runner)
Folds in the sharpest refinement: business logic and art-dag are the SAME op-DAG structure,
differing only in the CAPABILITIES their nodes require — so the runner is DERIVED, not chosen.
A node declares :needs (wait→suspend, fan-out→parallel, heavy→offload); a runner advertises
:capabilities (op-table {effect,branch,each}; Erlang +suspend; celery-sx +parallel,retry,offload);
artdag/analyze computes a DAG's required set → its minimum runner; the binder checks required ⊆
runner-caps (fail fast). The sync/durable/distributed split falls out of the DAG (a {effect}-only
DAG runs with zero ceremony; a wait node auto-requires Erlang) — turning 'simple in SX / complex
in Erlang' from a judgment call into a derivable property. Removed the :runner hint from the type
binding; P0.2 gains the hypothesis test (natural-as-a-DAG? + flip-to-wait fails fast); runner
contract gains :capabilities; type-def editor can show the derived classification.

Doc-only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 14:09:24 +00:00
689d4bd363 plan: whole-plan coherence review — align the middle with the artdag+seam reframe
The reframe updated the vision but left the P0 section stale + contradictory: P0.2/P0.3 still
described the Erlang-bridge-first path the reframe deferred; P0.1's activity ({:type :object-dict})
didn't match the seam's canonical activity ({:verb :object-cid}); the seam-contract section
predated the 2 enrichment passes (no status/dedup/pump). Coherence fixes:
- P0 rewritten around the seam + SX op-table runner (all-SX publish-DAG, local-SX registry,
  in-process transport, host driver) — no Erlang/fed-sx.
- Erlang/fed-sx DEMOTED to explicit adapter phases: RA (durable Erlang runner wrapping next/
  flow_dispatch) + TA (fed-sx transport wrapping next/ delivery). P3-federation folded into TA.
- canonical seam activity shape defined; P0.4 reconciles P0.1's next/-shaped activity + a marshaller.
- seam contract refreshed to behavior.sx (result {:status :effects :resume :error}, dedup
  per-invocation, pump/async-completion, behavior 10/10); stray fragments + 9/9→10/10 cleared.

Doc-only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 14:00:02 +00:00
6ed523623b host: correct the seam's async-completion contract + prove it (2nd review)
Second review of the (core) seam caught a subtle one — and that my first 'fix' was itself wrong.
The async completion of a SUSPENDED durable flow happens AFTER the synchronous process call has
returned, so an :emit captured in the run env would be stale. The correct seam is construction-
wiring: a durable runner is wired to the transport's INBOUND channel at construction and injects
its completion activity there, out-of-band; a later behavior/pump drains it → effects flow. So the
engine code was already right (pump is the async re-entry seam); only the contract comment was
wrong — corrected. New test proves the loop: process(wait) suspends (no effect), then pump drains
the out-of-band completion → the flow's digest effect flows. Also clarified: dedup is per-
invocation (global idempotency = emitter fire-once + durable inbox); retry is flow-level; the
engine-facing runner result is {:status :effects :resume :error} (:results is runner-internal).

behavior 10/10 (+ async-completion). No engine change — comment + test only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 13:55:32 +00:00
e4fc66bfeb host: enrich the adapter seam to be substrate-agnostic (review fixes)
After review, the seam was only synchronous-complete; the durable/celery-sx runners couldn't
plug in cleanly. Additive fixes (pipeline unchanged): (1) :status branch in run-binding — 'done'
dispatches effects, 'suspended' records the flow + :resume (a durable runner holds it; completion
re-enters as a new activity via pump), 'failed' records + :error for retry/dead-letter. (2) richer
runner env — :ctx (per-activity, via engine :ctx-of) + injected :effects (external-read interfaces,
e.g. a deterministic fetch_followers). (3) dedup by content :id — a cycle is caught by identity,
not just the depth guard. (4) behavior/pump — drain transport.deliver for inbound (peer activities
+ async runner completions), sharing one trace so dedup spans the batch.

behavior 9/9 (+ suspended/failed/dedup/env/pump); full host conformance 580/580.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 13:50:41 +00:00
5d04da748a host: the adapter seam for business-logic-as-composition (design-first)
lib/host/behavior.sx — the substrate-independent seam every runner/transport/registry/driver
plugs into. An engine bundles four dict-of-functions adapters (trigger-registry, runner,
transport, driver); behavior/process folds an ACTIVITY through the pipeline: emit → match
triggers → run each behavior DAG → dispatch each effect-as-data → recurse on new activities
(loop closure, depth-guarded at 8). Every stage injected, so the same DAG + engine run over the
synchronous op-table runner / Erlang durable / celery-sx / fed-sx transport unchanged.

Reference tests (mock adapters) prove the contract: publish→trigger→runner→effect flows; a
non-matching activity fires nothing (log complete, execution precise); an effect that emits a new
activity re-triggers (loop closes); an unbounded loop is depth-guarded (terminates). Wired into
conformance.sh + serve.sh MODULES. behavior 4/4; full host conformance 575/575.

Next: P0 supplies the REAL adapters (publish activity ← host/blog--publish-activity, local-SX
trigger, sync op-table runner over a publish-DAG, host driver) — same engine.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 13:42:04 +00:00
f240c46fa8 plan: account for celery-sx as the distributed/durable runner adapter
celery-sx = one more runner on artdag/op-table-runner, not a Celery port: broker=persist KV,
workers=er-scheduler, result backend=content-addressed (dedup free), retries/replay=flow-on-
erlang, fan-out=artdag/schedule. ~few hundred lines of glue, zero packages, 'Celery the way it
should have been' on erlang-on-sx. DEMAND-DRIVEN (RX) — build when a DAG needs heavy compute /
long-running-retryable / cross-machine fan-out; the synchronous op-table runner covers P0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 13:35:44 +00:00
c147020059 plan: elevate — business logic IS art-dag; substrates are adapters
Reframe after the user's insight, confirmed in code: artdag-on-sx already IS the substrate-
independent behavior engine — artdag/run injects the RUNNER (execution adapter: SX op-table /
Erlang / Celery), federation.sx injects the TRANSPORT (communication adapter: fed-sx / HTTP /
IPFS). Business logic = a content-addressed DAG; durability is a RUNNER capability (same DAG runs
eager or durable); deployment (subdomain service / peer / L1 worker) is placement. fed-sx+Erlang
is ONE adapter set, not the architecture. The type carries content-grammar + allowed-relations +
a behavior DAG. The prior fed-sx/Erlang framing is kept as one concrete first slice.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 13:31:10 +00:00
5b46a18c61 plan: review corrections to business-logic-fed-flows
Three framing fixes after review: (1) the event source is object-level state changes, NOT just
CID deltas — relations write edge:* rows so they don't shift the CID; content/status → Create/
Update, relations → Add/Remove (ActivityPub-faithful). (2) verbs are TRANSITIONS (on-publish =
draft→published, fire-once, not every delta of a published post). (3) the hybrid flow split is by
DURABILITY not complexity — the execute-fold is eager/synchronous (no wait); suspend/timer/human
flows are the Erlang escape hatch. Plus: effects-as-data need a DRIVER (host, for P0); P0.2 must
gate on the transition + run in the handler body (VmSuspended/er-scheduler risk); P0.3 gets an
acceptance criterion; P3 flags the fed-sx delivery M2 blocker + the deferred actor model.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 13:02:59 +00:00
3675d059b5 host P0.1: publish-activity contract for federated composition-flows
Business logic as federated composition-flows (plans/business-logic-fed-flows.md). P0.1: the
host describes a published post as a fed-sx activity — host/blog--publish-activity(slug) →
{:type "create" :actor "site" :id <CID> :object {:type "article" :slug :category}} — the
exact shape next/'s trigger machinery consumes (verified: next/tests/triggers_e2e.sh 10/10).
category (drives the flow branch: newsletter suspends / urgent fires / else skip) comes from
the "category" field-value, else the first tag, else "urgent". + host/blog--post-category.

Design decided: activity log = every CID delta (event source); triggers = declared subscriptions
(DefineTrigger); flows hybrid (SX composition for simple via the execute-fold, named Erlang flows
for complex); federated execution = Erlang (next/); the type carries content+relations+behavior.

blog 200/200 (+3: contract, category fallback, missing-post nil).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 12:55:08 +00:00
4c0a48834e preserve fed-sx-m1 loop briefings before pruning its worktree
4 untracked agent-briefing docs from the fed-sx-m1 worktree (merged branch loops/fed-sx-m2),
saved here so they survive the worktree cleanup.
2026-07-02 12:25:50 +00:00
a5e35b8f61 Merge loops/host into architecture (-s ours): otel work superseded
loops/host's 3 post-split otel commits (route-order fix, JIT self-warm, auto-refresh
dashboard) were INDEPENDENTLY superseded by architecture's parallel otel work, which has
better implementations of each: the /:slug route fix, a /dev/tcp detached self-warm (vs
loops/host's make-app warmup in the wrong JIT context), and a richer SPA-poll dashboard
(p50/p95/p99 chart + waterfall + tooltips + child spans) vs a meta-refresh. Taking loops/host's
versions would regress the live dashboard, so -s ours keeps architecture's tree and just joins
the history to close the branch.
2026-07-02 12:12:31 +00:00
5ff17ec6f5 Merge loops/fed-sx-types into architecture
Substrate for host-type federation + activity-driven flow triggers
(next/** only; clean/additive — zero file overlap with architecture).

Host-type federation (Phases 1-4):
- DefineType / SubtypeOf genesis verbs
- peer_types.erl receiver-side type cache
- GET /types/<cid> route + discovery_type_fetch.erl
- pipeline object-schema validation stage

flow-on-erlang + triggers (Phases 5-8):
- next/flow/ — native Erlang-on-SX durable workflow engine
  (deterministic-replay suspend/resume, combinator algebra, durable store)
- DefineTrigger genesis verb + trigger_registry.erl
- pipeline:apply_triggers/3 post-append fan-out + flow_dispatch.erl
- blog-publish-digest e2e; design §13.10 documents the fan-out convention

Gates at merge: lib/erlang 771/771, next/flow 36/36, all next/tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 12:06:50 +00:00
1cdfaa5035 otel: reliable bar tooltips (<title> inside <rect>, label pointer-events:none) 2026-07-02 11:56:34 +00:00
1e2ff38759 wasm: rebuild browser kernel — consistent loader + .assets + .sxbc modules
The deployed sx_browser.bc.wasm.js referenced content-hashed .wasm binaries that
weren't on disk (partial build), so the kernel 404'd and the SPA died site-wide.
Rebuilt via sx_build target=wasm and committed the matching artifacts so a git
checkout can't re-introduce the mismatch. (Staged only shared/static/wasm/;
other worktree changes left untouched.)
2026-07-02 11:54:58 +00:00
47a88ea158 otel: waterfall prefers newest multi-span trace (real page render) 2026-07-02 11:49:52 +00:00
6c2a6ccf07 otel: waterfall shows latest REAL trace (skip dashboard's own poll routes) 2026-07-02 11:48:05 +00:00
76941277fd otel: child spans in the blog render path (waterfall breakdown) 2026-07-02 11:44:00 +00:00
ca80df9ade otel: hover tooltips on waterfall bars (SVG <title>) 2026-07-02 11:00:40 +00:00
4f17a40187 otel: relative 'Ns ago' timestamp on recent traces 2026-07-02 10:53:02 +00:00
e49229c20b otel: sustained SPA poll via a hidden ticker sibling (browser-verified) 2026-07-02 09:34:20 +00:00
2785a14ece otel: robust SPA poll — stable #otel-body polls /otel/fragment (innerHTML) 2026-07-01 20:48:15 +00:00
44d29866e7 otel: wire /otel into the SPA (dual-mode SX + sx-trigger poll refresh) 2026-07-01 20:31:44 +00:00
7754666de1 otel: waterfall time ruler + recent-traces show actual target path & duration 2026-07-01 20:18:40 +00:00
322ff4f691 otel: funky dashboard (latency bar chart + status-colored waterfall) + boot self-warm
Dashboard gains a per-route latency bar chart (nested p50/p95/p99 bars, tail
visible) + status-colored waterfall with ms duration labels + a real 3s
auto-refresh (replacing the non-functional data-on-load SSE attr). serve.sh
self-warms the serving JIT over /dev/tcp so the first visitor after a restart
gets ~78ms not the one-time ~2.5s compile. otel suite 125/125.
2026-07-01 19:41:40 +00:00
0fda26f1d5 otel: real auto-refresh dashboard + HTTP self-warm (kills cold p99)
Dashboard: drop the non-functional data-on-load SSE attr; add <meta refresh 3s>
so it genuinely live-updates (the host serves single-body responses, no
server-push SSE). /otel/stream stays a snapshot for pollers.

serve.sh: replace the ineffective boot-time make-app warmup (wrong JIT context)
with a backgrounded self-warmer that GETs the hot pages over real HTTP (bash
/dev/tcp — no curl in the image) once /health is up, so the first real visitor
after a restart gets ~78ms instead of the one-time ~2.5s serving-JIT compile.
2026-07-01 19:32:36 +00:00
6868d984a0 otel/perf: JIT-warm the hot pages at boot to kill the cold-start p99 tail
The blog render path (comp-fold + relations + typed-block) JIT-compiles on first
call, so the first visitor after a restart paid ~2.5s (vs ~78ms warm) — that was
the /:slug p99 tail. Define the route groups once, render / + welcome +
nt-live-encore + /otel through a throwaway app at boot to force compilation, then
reset the otel ring so warmup spans don't skew live metrics.
2026-07-01 19:24:09 +00:00
d357a5a7b9 otel: mount otel/routes before the blog /:slug catch-all in serve.sh
The blog post-detail route /:slug matches any single segment, so /otel was
being served as a missing blog slug (404). Order otel/routes ahead of the blog
routes so the literal /otel + /otel/stream match first.
2026-07-01 19:00:12 +00:00
fa1afd7b5d host: mount otel/routes before blog-routes so GET /otel isn't swallowed by /:slug
The otel dashboard route (GET /otel) is single-segment, so blog-routes' /:slug catch-all
shadowed it (404 'no post: otel'); only /otel/stream (two segments) survived. Move otel/routes
ahead of the blog routes. Live-only wiring fix (route order); no test change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 18:50:25 +00:00
0d302b8a85 otel: wire into live boot — load otel.sx + mount otel/routes in serve.sh
Adds lib/host/otel.sx to serve.sh MODULES and otel/routes to the host/serve
group list so GET /otel (+ /otel/stream) serve on the live host once merged.
Build-time wiring only; no container touched.
2026-07-01 18:20:46 +00:00
351131e92b otel: tick P8, log progress — roadmap P1-P8 complete (124/124) 2026-07-01 18:20:46 +00:00
3d9dc832fc otel P8: W3C traceparent propagation + error spans
otel/format-traceparent + otel/current-traceparent emit '00-<32hex>-<16hex>-01';
otel/parse-traceparent round-trips it (nil on malformed/bad-width). otel/-timed
now guards the thunk: success spans get :status ok, a raised error records a
span with :status error + an exception event then propagates. Error propagation
uses a false-returning guard clause test (an explicit (raise e) in a guard
handler re-enters the guard and hangs).
2026-07-01 18:20:46 +00:00
b478d0a8da otel: tick P7, log progress 2026-07-01 18:20:46 +00:00
84285d23e9 otel P7: OTLP-JSON export + injected transport
otel/export-otlp folds spans → OTLP/JSON envelope (resourceSpans → scopeSpans →
spans) with hex traceId(32)/spanId(16)/parentSpanId, uint64-as-string nano
timestamps, typed attributes (stringValue/intValue), and span kind
(SERVER/INTERNAL). otel/export-otlp-json encodes via dream-json-encode;
otel/post-otlp POSTs through an injected transport (testable without a live
collector).
2026-07-01 18:20:46 +00:00
4e201ad107 otel: tick P6, log progress 2026-07-01 18:20:46 +00:00
4400870abe otel P6: live dashboard — GET /otel SSR + /otel/stream SSE
otel/dashboard SSRs the metrics strip + latest-trace waterfall + recent-traces
list as HTML carrying Datastar-style data-on-load subscribing to /otel/stream,
the SSE feed of SXTP otel.span events. Routes otel/dashboard-route +
otel/stream-route (otel/routes) mount via make-app. recent-traces/latest-trace
+ otel/span-event helpers.
2026-07-01 18:20:46 +00:00
296fa45bea otel: tick P5, log progress 2026-07-01 18:20:46 +00:00
c273467929 otel P5: metrics aggregate-fold (per-route counts + p50/p95/p99)
otel/metrics folds spans → {:total-requests :routes}; each route carries a
request count and nearest-rank latency percentiles over its durations. Route
key is the http.route attr (falls back to span name). Includes a small
insertion sort (no sort primitive) and order-preserving distinct.
2026-07-01 18:20:46 +00:00
41c62f0c8c otel: tick P4, log progress + splice-unquote gotcha 2026-07-01 18:20:46 +00:00
5f06b5e8e0 otel P4: render-fold → SVG waterfall
otel/waterfall-rects folds a trace's spans into rect geometry (x by start
offset, width by duration, y by depth via parent-link ancestor count);
otel/waterfall folds those into an inline <svg> (one <rect>+<text> per span).
Renders to real SVG markup via the html tag registry.
2026-07-01 18:20:46 +00:00
06294e964c otel: tick P3, log progress + pre-existing env note 2026-07-01 18:20:46 +00:00
c2def0ea16 otel P3: auto-instrument handlers at the make-app seam
otel/instrument-routes wraps each flattened Dream route's handler in a timed
span named METHOD /route with {:http.method :http.route :http.status} attrs;
host/make-app applies it so every matched request becomes a trace. Refactored
with-span onto a shared otel/-timed core that takes a finalize fn for
result-derived attrs (the http.status only known post-handler).
2026-07-01 18:20:46 +00:00
e521909b21 otel: tick P2, log progress 2026-07-01 18:20:46 +00:00
51d4224a55 otel P2: now-ns wraps host clock-milliseconds as epoch nanoseconds
Clamp against a high-water mark so the clock never steps backwards; span
durations stay non-negative. Real ns-scale timestamps replace the P1
placeholder counter.
2026-07-01 18:20:46 +00:00
c8cc4a70dc otel: tick P1, log progress 2026-07-01 18:20:46 +00:00
087c01e890 otel P1: span model + API (with-span, parent stack, ring buffer)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 18:20:46 +00:00
5535acf4e9 Merge branch 'loops/host' into merge/host-arch
# Conflicts:
#	lib/erlang/runtime.sx
2026-07-01 17:42:08 +00:00
62c9bdd270 host: nt-live-encore seed uses the SX HTML→SX converter (drops the Python one-off)
host/blog-seed-nt-live-encore! now embeds the RAW Ghost HTML (from rose-ash.com/rss) and
imports via the "html" field, so host/html->sx converts it at boot — no more pre-converted
sx_content from the external Python script. Verified: the converter produces the identical 11
cards (card-image/text ×4 pairs + 3 card-embed), handling the real post's kg-card comments,
srcset, and nested figcaption markup. blog 197/197.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 15:49:43 +00:00