repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

docs: add prototype plan

837833043b4897e63005a82897cee4f5c461298b

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (1)

+416 / −0 text lines

Diff layout

prototypes/PLAN.md

Added
new file mode 100644

+416 / −0 text lines

1# Prototype Plan
2
3Purpose: prove or invalidate high-risk `../docs/SPEC.md` claims before production
4Rust exists.
5
6Rules from `AGENTS.md` apply:
7
8- one prototype = one claim/risk,
9- minimal runnable proof,
10- every prototype has a verifying command,
11- evidence drives SPEC changes,
12- prototypes are disposable.
14## Execution Order
161. `p01-pup-gate`
172. `p02-lua-interface-descriptor`
183. `p03-subagent-ecosystem-simulation`
194. `p04-plugin-install-uninstall`
205. `p05-provider-fetch-normalize`
216. `p06-session-codec-recovery`
227. `p07-streamfn-agent-loop`
238. `p08-tui-testbackend`
25Run in order unless a later prototype is needed to answer an active SPEC dispute.
27## P01 — `p01-pup-gate`
29### SPEC claims
31- `cargo-pup` can be a required architecture gate on pinned nightly.
32- Stable product build and pinned-nightly architecture gate can coexist.
33- `pup.ron` can enforce crate-boundary and module-hygiene rules.
35### Risk
37`cargo-pup` may be too unstable, too slow, or unable to express the required
38Smith architecture rules.
40### Minimal artifact
42Tiny Rust workspace:
44```text
45p01-pup-gate/
46 Cargo.toml
47 pup.ron
48 smith/
49 smith-core/
50 smith-ai/
51 xtask/
52```
54Include one passing case and one intentionally failing case gated by file rename
55or feature flag.
57### Verify
59```bash
60cd prototypes/p01-pup-gate
61cargo +stable check --workspace
62cargo +nightly-2026-01-22 pup
63```
65### Pass evidence
67- stable check passes,
68- pup passes on valid crate graph,
69- pup fails with useful diagnostic when forbidden import is enabled.
71### SPEC impact
73If pup cannot express needed rules, change SPEC to keep `xtask arch` as the hard
74architecture gate and redefine pup scope.
76## P02 — `p02-lua-interface-descriptor`
78### SPEC claims
80- Smith can support community-defined plugin interfaces without core authors
81 predicting all future features.
82- Plain Lua descriptors plus runtime validation might approximate signature
83 matching.
85### Risk
87Plain Lua may be too weak or too verbose for reliable interface conformance.
89### Minimal artifact
91Lua-only or small Rust+mlua proof:
93```text
94p02-lua-interface-descriptor/
95 Cargo.toml
96 interfaces/subagent.lua
97 impl/good.lua
98 impl/missing_fn.lua
99 impl/bad_shape.lua
100 src/main.rs
101```
103Descriptor defines required exports/events. Validator loads descriptor and
104implementations, then reports conformance errors.
106### Verify
108```bash
109cd prototypes/p02-lua-interface-descriptor
110cargo run
111```
113### Pass evidence
115- good implementation passes,
116- missing function fails with exact path/name,
117- bad shape fails with expected/actual diagnostic,
118- extra implementation fields are hidden/ignored when viewed through interface.
120### SPEC impact
122If viable, SPEC can make Lua interface descriptors the mandatory plugin shape.
123If not, run P02b for Teal/typed Lua.
125## P03 — `p03-subagent-ecosystem-simulation`
127### SPEC claims
129- Interface packages can prevent plugin ecosystem fragmentation.
130- Consumers can target an interface while users choose implementation.
131- Adapters can normalize incompatible implementations.
133### Risk
135The idea may work in prose but fail under realistic plugin composition.
137### Minimal artifact
139```text
140p03-subagent-ecosystem-simulation/
141 Cargo.toml
142 plugins/community-subagent-interface/
143 plugins/alice-subagents/
144 plugins/bob-agents/
145 plugins/bob-to-subagent-adapter/
146 plugins/fancy-subagent-ui/
147 src/main.rs
148```
150Simulate plugin manager resolving `community/subagent` to selected impl.
152### Verify
154```bash
155cd prototypes/p03-subagent-ecosystem-simulation
156cargo run -- alice
157cargo run -- bob-adapted
158cargo run -- bob-direct-fails
159```
161### Pass evidence
163- UI plugin works with Alice implementation,
164- UI plugin works with Bob only through adapter,
165- direct incompatible Bob usage fails with clear interface error,
166- user config swaps implementation without UI plugin change.
168### SPEC impact
170Clarify interface selection, adapter role, conformance test requirements, and
171user override syntax.
173## P04 — `p04-plugin-install-uninstall`
175### SPEC claims
177- v1 plugin install supports local path and git URL only.
178- Plugin names are `<org>/<name>`.
179- `smith/*` namespace is reserved.
180- Manifests are mandatory Lua data files.
181- `smith_api` is optional and defaults to generation `1`.
182- Uninstall keeps data unless `--purge-data`.
184### Risk
186Install semantics may require too much code execution, ambiguous path layout, or
187awkward namespace/data mapping.
189### Minimal artifact
191```text
192p04-plugin-install-uninstall/
193 Cargo.toml
194 fixtures/good-plugin/smith-plugin.lua
195 fixtures/bad-name/smith-plugin.lua
196 fixtures/reserved-smith/smith-plugin.lua
197 src/main.rs
198```
200Use temp dirs for fake `data_dir` and project dir. Git URL can be simulated with
201a local bare repo first; note whether gix is used or shelling out is required.
203### Verify
205```bash
206cd prototypes/p04-plugin-install-uninstall
207cargo run -- install-local
208cargo run -- install-git
209cargo run -- reject-bad-name
210cargo run -- reject-smith-namespace
211cargo run -- uninstall-keeps-data
212cargo run -- uninstall-purge-data
213```
215### Pass evidence
217Each command exits 0 and prints checked filesystem assertions.
219### SPEC impact
221Clarify manifest filename, install layout, duplicate handling, `--force`, git
222implementation boundary, and data purge rules.
224## P05 — `p05-provider-fetch-normalize`
226### SPEC claims
228- `providers.json` is runtime authority.
229- `fetch-providers` is only bootstrap/maintenance suggestion generator.
230- pi.dev is primary, catwalk fills gaps.
231- Unknown fields are preserved.
232- Correctness requires review.
234### Risk
236Merge rules may be under-specified; generated data may silently corrupt provider
237metadata.
239### Minimal artifact
241```text
242p05-provider-fetch-normalize/
243 Cargo.toml
244 fixtures/pi.json
245 fixtures/catwalk.json
246 fixtures/current-providers.json
247 src/main.rs
248```
250No network. Use fake source shapes with overlapping models, missing costs,
251unknown fields, and conflicting metadata.
253### Verify
255```bash
256cd prototypes/p05-provider-fetch-normalize
257cargo run -- generate
258cargo run -- diff
259cargo run -- conflict-fails
260```
262### Pass evidence
264- pi.dev wins conflicts,
265- catwalk fills missing fields,
266- unknown fields preserved,
267- conflict report is explicit,
268- generated patch is reviewable.
270### SPEC impact
272Clarify provider schema, conflict policy, and PR-agent workflow inputs/outputs.
274## P06 — `p06-session-codec-recovery`
276### SPEC claims
278- Length-prefixed CBOR sequence supports crash recovery.
279- Truncated tail stops parsing.
280- Corrupt entries are skipped or reported without losing prior entries.
281- Unknown future entries can be preserved where possible.
283### Risk
285CBOR recovery behavior may be less precise than SPEC promises.
287### Minimal artifact
289```text
290p06-session-codec-recovery/
291 Cargo.toml
292 src/main.rs
293```
295Encode sample entries, truncate bytes, inject corrupt frame, and include unknown
296variant representation if possible.
298### Verify
300```bash
301cd prototypes/p06-session-codec-recovery
302cargo run
303```
305### Pass evidence
307Program asserts counts and diagnostics for normal/truncated/corrupt/unknown
308cases.
310### SPEC impact
312Tighten exact recovery guarantees if corruption cannot be safely skipped.
314## P07 — `p07-streamfn-agent-loop`
316### SPEC claims
318- `smith-core` can drive agent behavior through `StreamFn` without depending on
319 `smith-ai`.
320- Text, tool call, tool result, and done events can produce deterministic
321 `AgentEvent` sequence.
322- Tool execution hooks can block/replace/retry.
324### Risk
326The proposed event/hook shape may be too complex or insufficiently typed.
328### Minimal artifact
330```text
331p07-streamfn-agent-loop/
332 Cargo.toml
333 src/main.rs
334```
336Mock StreamFn emits deterministic text/tool/done events. Mock tool returns a
337result. Hook variants exercise allow/block/replace.
339### Verify
341```bash
342cd prototypes/p07-streamfn-agent-loop
343cargo run -- basic
344cargo run -- tool
345cargo run -- hook-block
346cargo run -- hook-replace
347```
349### Pass evidence
351Each scenario prints/compares expected event sequence.
353### SPEC impact
355Clarify event ordering, hook return semantics, and session-entry conversion.
357## P08 — `p08-tui-testbackend`
359### SPEC claims
361- ratatui `TestBackend` supports deterministic widget snapshots.
362- Theme tables can drive Rust widget rendering.
363- TUI primitives can be tested without terminal I/O.
365### Risk
367Snapshot output may be unstable or theming may require more structure.
369### Minimal artifact
371```text
372p08-tui-testbackend/
373 Cargo.toml
374 src/main.rs
375```
377Render one status bar and one message/tool-result widget using a theme table.
378Print stable buffer text for assertion.
380### Verify
382```bash
383cd prototypes/p08-tui-testbackend
384cargo run
385```
387### Pass evidence
389Output equals checked expected snapshot string.
391### SPEC impact
393Clarify theme schema, widget test strategy, and snapshot normalization.
395## Reporting Template
397Each completed prototype updates this plan with a result block:
399```json
400{
401 "status": "complete|blocked|failed",
402 "proved": [],
403 "disproved": [],
404 "specIssues": [
405 {
406 "file": "../docs/SPEC.md",
407 "issue": "...",
408 "evidence": "prototype path + command + result",
409 "severity": "P0|P1|P2|P3"
410 }
411 ],
412 "prototypeArtifacts": [],
413 "commands": [],
414 "nextSteps": []
415}
416```