repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

Name the multi-frontend boundary and anchor RPC on EngineEvent

2e868210a4edd4e8b32e578eb124d7f475da06e7

Claude <noreply@anthropic.com> ·

SSH signature · not checked

Browse filesCompare with HEAD

The spec never said how a second UI would attach, so future work would
have to reverse-engineer it. State it: frontends consume the EngineEvent
stream and submit intents; the TUI is the in-process default; smith rpc
is the out-of-process boundary for web/native/mobile, which link no
smith code; and the terminal render model is deliberately not a
cross-UI abstraction. Anchoring matters — a frontend is a peer of the
TUI, not a plugin, so the RPC event surface adapts EngineEvent (§6.3),
not the plugin bridge, and it is an adapter not a mirror: blocking
events invert to requests and TUI-private events are omitted. Whether
that adapter is complete for a real UI is left prototype-gated rather
than asserted.

Edits SPEC §6.3/§8/§10.4 and adds the p28 plan to prototypes/PLAN.md.

Changed files (2)

+90 / −1 text lines

Diff layout

docs/SPEC.md

Modified

+26 / −1 text lines

742742- provider/model changes,
743743- errors and shutdown.
745`EngineEvent` is consumed by `smith-harness` and `smith-tui`.
745`EngineEvent` is consumed by `smith-harness` and `smith-tui`. It is the
746frontend stream: every frontend (the built-in TUI in-process, §8; any RPC
747client out-of-process, §10.4) consumes `EngineEvent` and submits intents back.
748Some variants — TUI-internal UI state changes — are in-process-frontend-private
749and are not exposed out-of-process.
747751### 6.4 Hooks
12881292`smith-tui` owns terminal primitives, normalized events, widgets, themes, and
12891293render loop. It depends only on `smith`.
1295**Frontend boundary.** `smith-tui` is the built-in *in-process frontend* — one
1296consumer of the `EngineEvent` stream (§6.3) that renders it and feeds intents
1297(prompt submit, steer, command, abort) back. It is not privileged as *the* UI:
1298the same event-out/intent-in surface is exposed out-of-process by `smith rpc`
1299(§10.4), which is the canonical boundary for additional frontends (web, native,
1300mobile). Those are RPC clients and link no smith Rust code. The render model
1301below — cells, borders, ratatui `Rect`s — is deliberately terminal-specific and
1302is **not** a cross-UI abstraction: a browser or GPU frontend brings its own
1303rendering and consumes only the event/intent surface, never smith's widgets.
12911305### 8.1 Backend
12931307Rendering uses:
24072421Framing (line-delimited JSON vs `Content-Length`) is an implementation choice
24082422settled when `smith rpc` is built.
2424**RPC is the multi-frontend boundary.** An RPC client is a frontend peer of the
2425built-in TUI (§8), so its event surface is an adapter over the `EngineEvent`
2426stream (§6.3) — the same source the TUI consumes — not the plugin bridge
2427(§9.8). It is an adapter, not a mirror, by three rules: non-blocking events
2428project to notifications; blocking events (`tool_call`, `session_before_*`)
2429project to server→client requests the client answers; and frontend-private
2430`EngineEvent` variants (TUI-internal UI state) are omitted. Whether this
2431adapter is *complete* — every externally-meaningful `EngineEvent` reaching a
2432frontend that needs it — is prototype-gated (p28); p24 proved the projection
2433mechanics, not sufficiency for a full alternative UI.
24102435## 11. Security Model
24122437Trusted:

prototypes/PLAN.md

Modified

+64 / −0 text lines

19361936§8.7 and §17.6. Spec issues: P1 resolution contract, P2 property target, P2
19371937composition rules.
1939## Campaign 6 — Multi-frontend readiness
1941## P28 — `p28-rpc-frontend-sufficiency`
1943### SPEC claims
1945- §8 frontend boundary / §10.4: `smith rpc` is the multi-frontend boundary; an
1946 RPC client is a frontend peer of the TUI, consuming an adapter over the
1947 `EngineEvent` stream (§6.3) — non-blocking → notifications, blocking →
1948 requests, frontend-private omitted.
1949- Implicit sufficiency claim: a full alternative UI (web/native/mobile) can be
1950 built on the RPC surface alone.
1952### Risk
1954p24 proved the projection *mechanics*, not *sufficiency*. An `EngineEvent`
1955variant may carry state a real frontend must render that is unreachable over
1956the §10.4 surface — a completeness gap that would only surface when someone
1957actually builds a web UI.
1959### Minimal artifact
1961```text
1962p28-rpc-frontend-sufficiency/
1963 Cargo.toml (serde, serde_json)
1964 src/main.rs
1965```
1967A mock engine emits the full `EngineEvent` stream over the RPC adapter during a
1968scripted complete session; a headless mock frontend client (no smith-tui code,
1969no Lua) consumes only the RPC surface and reconstructs everything a UI renders.
1971### Verify
1973```bash
1974cd prototypes/p28-rpc-frontend-sufficiency
1975cargo run -- classify
1976cargo run -- reconstruct
1977cargo run -- blocking-roundtrip
1978cargo run -- all
1979```
1981### Pass evidence
1983- `classify`: every `EngineEvent` variant (§6.2 AgentEvent + §6.3 harness
1984 events: session lifecycle, steering/follow-up, UI-state, provider/model
1985 change, error, shutdown) tagged `notification` / `request` /
1986 `frontend-private-omitted` / `MISSING`; the MISSING set is the finding,
1987- `reconstruct`: a scripted session (turns, streaming text/thinking deltas,
1988 tool calls incl. a blocking `tool_call`, steering queue, compaction/fold,
1989 leaf switch/tree, secret placeholders, model change, error) drives the mock
1990 client, whose reconstructed UI state (transcript, tool views, steering queue,
1991 leaf/tree, cost/context, active model) deep-equals the engine's ground truth,
1992 built from the RPC stream ALONE,
1993- `blocking-roundtrip`: a blocking `tool_call` reaches the client as a request
1994 and the client's reply flows back into the engine,
1995- verdict: the RPC surface is sufficient for a full frontend, or the exact
1996 MISSING variants/state are listed.
1998### SPEC impact
2000Upgrade the §10.4 completeness claim from p28-gated to proven, or add the
2001missing driver methods / event projections the spike finds.
19392003## Reporting Template
19412005Each completed prototype updates this plan with a result block in the