dreamstack/examples/compose-master.ds
enzotar a8235c48b3 feat: stream composition API — select, schema, relay filtering
1. Receiver-side `select` clause:
   - `stream from "url" { select: field1, field2 }`
   - Parser, AST, codegen all updated
   - Emits: `_connectStream(url, ["field1","field2"])`
   - Client-side _csFilter strips unwanted fields

2. Schema announcement (0x32):
   - Sources send output schema on connect
   - Lists registered signal names and mode

3. Relay schema cache:
   - ChannelState stores schema from 0x32
   - Forwarded to late-joining receivers

4. Relay-side subscribe filter (0x33):
   - Receivers send wanted fields after connecting
   - Relay strips unwanted JSON keys from 0x30/0x31
     frames before forwarding — saves bandwidth

Protocol: SchemaAnnounce=0x32, SubscribeFilter=0x33
54 tests pass, all crates build clean.
2026-02-26 10:07:47 -08:00

46 lines
1.4 KiB
Text

-- DreamStack Chained Composition — Layer 2: Master Dashboard
-- Receives the aggregated metrics (from Layer 1) AND mood (from Layer 0).
--
-- Architecture:
-- Counter ──┐
-- Clock ───┤──► compose-metrics ──┐
-- Stats ───┘ (Layer 1) │
-- ├──► THIS APP (Layer 2)
-- Mood ────────────────────────────┘
--
-- This demonstrates:
-- 1. Chained composition (3 → 1 → final)
-- 2. Multiple layers of signal derivation
-- 3. Mixing independently-sourced streams
--
-- Run with:
-- dreamstack build examples/compose-master.ds
let metrics = stream from "ws://localhost:9100/stream/metrics" {
select: uptime, events, status
}
let mood = stream from "ws://localhost:9100/stream/mood" {
select: mood, energy, color
}
view main =
column [
text "🏗️ Master Dashboard (Layer 2)"
text "Chained: 3→1→here + mood"
row [
column [
text "── ⚡ Aggregated Metrics ──"
text "(from compose-metrics)"
text "Uptime: {metrics.uptime}s"
text "Total Events: {metrics.events}"
text "Status: {metrics.status}"
]
column [
text "── 😊 Mood (Direct) ──"
text "(from streaming-mood)"
text "Mood: {mood.mood}"
text "Energy: {mood.energy}%"
text "Color: {mood.color}"
]
]
]