repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

docs(system): extract plugin system into own spec

0b0647c848a660361c1b01d11ee9bac1ada44359

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (5)

+149 / −93 text lines

Diff layout

.system/plans/SMH-PLAN-AIAGD002-provider-and-oauth-plugins/index.md

Modified

+2 / −2 text lines

22id: SMH-PLAN-AIAGD002
33type: plan
44title: "Provider and OAuth Plugins"
5spec: SMH-SPEC-SPEC0001
5spec: SMH-SPEC-PLUG0001
66status: draft
7depends_on: [SMH-PLAN-PLUG0001]
7depends_on: []
88---
1010# Provider and OAuth Plugins

.system/plans/SMH-PLAN-PLUG0001-plugin-harness/index.md

Modified

+1 / −1 text lines

44title: "Sandboxed Plugin Harness"
55spec: SMH-SPEC-SPEC0001
66status: draft
7depends_on: [SMH-PLAN-AIAG0001, SMH-PLAN-VOETK_DD]
7depends_on: []
88research: [SMH-RESEARCH-WASM0001]
99---

.system/plans/SMH-PLAN-TUIR0001-tui-and-replay/index.md

Modified

+1 / −1 text lines

44title: "Fullscreen TUI and Replay"
55spec: SMH-SPEC-SPEC0001
66status: draft
7depends_on: [SMH-PLAN-PLUG0001]
7depends_on: []
88---
1010# Fullscreen TUI and Replay

.system/specs/SMH-SPEC-PLUG0001-plugin-system/index.md

Added
new file mode 100644

+138 / −0 text lines

1---
2id: SMH-SPEC-PLUG0001
3type: spec
4title: "Plugin System"
5research: [SMH-RESEARCH-TBKDJHVX, SMH-RESEARCH-WASM0001]
6---
7
8# Plugin System
9
10## Intent
12One typed plugin system where unprivileged wasm components extend Smith.
13Built-ins and user plugins share the same contracts, effects, and sandbox; parity is law, not aspiration.
15Engine mechanics (determinism, fuel, memory ceilings, artifact validation) live in `SMH-SPEC-WASM0001`.
16Product integration points live in `SMH-SPEC-SPEC0001`.
18## Runtime and parity
20Plugins run in a restricted runtime without direct operating-system, filesystem, environment, network, or clock access.
21Plugin execution is resource-bounded.
22Host effects are available only through typed Smith SDK component interfaces granted by manifest and trust decisions.
23Built-in plugins have no privileged effect path.
25Built-in coding tools are embedded component artifacts loaded through the normal sandbox; they call the same typed host primitives available to user plugins.
27## Contributions
29Plugins may contribute:
31- tools,
32- commands,
33- providers and models,
34- credential sources,
35- prompts and context transforms,
36- event handlers,
37- themes and keybindings,
38- layout and render descriptions,
39- VCS workflows.
41## Generations
43Plugin events are ordered and typed.
44A candidate generation can declare and validate contributions but cannot invoke operational effects or mutate the active runtime before publication.
45A failed load leaves no registrations or subscriptions active.
46Reload publishes one complete generation or retains the previous generation.
48A generation owns every plugin instance, registration, subscription, binding, and contribution.
49Session, branch, queue, secrets, cancellation, and active-turn state live outside the generation and survive reload.
50Guest-local implementation state resets on reload.
51Removed contributions disappear at publication.
52Calls already running complete against their pinned generation; later calls resolve against the published generation.
54Each provider request pins one generation through its response and complete tool-call/result batch.
55The pinned generation supplies both advertised definitions and executable handlers.
57## Budgets and failure
59Smith SDK calls may catch ordinary typed guest errors, but not cancellation, budget exhaustion, sandbox violations, or host-effect recording failures.
60Smith SDK child work is structured and host-orchestrated: it shares the parent invocation budget and generation pin, serializes per plugin instance, and finishes or cancels before the parent handler returns.
61Fan-out cannot multiply resource limits.
62The budget covers deadline, guest fuel, component memory and table ceilings, host allocations, logs, conversions, and output.
64## Event boundary
66Plugin handlers run synchronously in deterministic registration order under one bounded invocation budget shared with structured child tasks.
67They return typed actions rather than mutable runtime ownership.
68Actions may request cancellation, queued input, reload, or runtime-only model, provider, tool, prompt, and configuration changes.
69Cancellation applies immediately.
70Other actions are validated as one batch and apply atomically between provider requests, after the current stream and complete tool-result batch.
71Conflicting mutations are rejected; no implicit winner is selected.
73A failed or over-budget handler emits one typed diagnostic, is disabled for the current generation, and does not abort the turn unless its event contract requires a decision.
74Terminal agent events remain singular.
76```mermaid
77sequenceDiagram
78 participant P as Provider round
79 participant A as Agent boundary
80 participant H as Ordered handlers
81 participant G as Runtime generation
82 P-->>A: Stream and complete tool batch
83 A->>H: Typed lifecycle events
84 H-->>A: Typed action batch
85 A->>A: Validate and reject conflicts
86 A->>G: Publish coherent runtime changes
87 G-->>P: Next request snapshot
88```
90## Discovery and modules
92Version 1 discovers plugin packages by path convention.
93Each package carries a manifest declaring its plugin artifact, world version, and requested capabilities.
94Package, artifact, and manifest identities are deterministic and validated before instantiation.
95Artifacts failing validation never execute.
96Manifest and artifact reads are bounded before materialization, and canonical paths cannot escape their declared root.
98A module contract is a typed, major-versioned component interface.
99Undeclared exports remain private.
100A module can have zero, one, or multiple implementations.
101One implementation binds automatically.
102Zero or ambiguous implementations fail only when consumed, with sorted candidates and the consumer reported.
103Explicit user binding overrides automatic binding and must satisfy the requested contract.
105Module consumers use logical major-versioned handles.
106A new invocation resolves each handle against the published generation; nested accesses during an active invocation resolve within its pinned generation.
107Reload can rebind only to an implementation satisfying the same major contract; guest-local state resets.
109Precedence is built-in, global user, project, then explicit override.
110Later registration replaces earlier registration only where the earlier contract explicitly permits replacement.
111Installed capabilities are validated as a complete set before atomic replacement or removal.
113## Project trust
115Project-local executable configuration, plugins, modules, and managed packages are not enumerated or loaded before trust is resolved.
116A project trust identity is its lossless, platform-tagged canonical native path.
117Symlink aliases share one decision; distinct native paths cannot collide through text conversion.
118Interactive mode can ask and persist the decision.
119Non-interactive modes require an explicit or previously persisted decision to load project-local executable behavior.
120An explicit plugin path grants one-run trust only to that exact canonical source.
121Capability grants resolve at trust time for project plugins and at install time for user plugins.
122Ignoring untrusted project behavior produces a visible diagnostic.
124Trust does not remove the plugin sandbox or tool boundaries.
126## World surface
128Incomplete: the `smith:plugin` world's interface design follows the wasm-limitation review and the research synthesis rules (minimal surface, one grammar, tiny contracts, explicit parameters, two-layer core-plus-grants, mechanical versioning).
130## Acceptance criteria
132- Project plugins cannot execute before trust resolution.
133- Built-in and user plugins use the same sandboxed effect APIs.
134- Event handlers are bounded, ordered, and publish conflict-free runtime actions only at safe points.
135- Reload atomically replaces one complete generation while active provider rounds remain pinned.
136- Callable module handles rebind only to conforming implementations of the same major contract.
137- Structured child work cannot suppress cancellation or exceed its shared budget.
138- A failed or over-budget handler disables only itself for the generation.

.system/specs/SMH-SPEC-SPEC0001-smith-specification/index.md

Modified

+7 / −89 text lines

5858### Plugin event boundary
60Plugin handlers run synchronously in deterministic registration order under one bounded invocation budget shared with structured child tasks.
61They return typed actions rather than mutable runtime ownership.
62Actions may request cancellation, queued input, reload, or runtime-only model, provider, tool, prompt, and configuration changes.
63Cancellation applies immediately.
64Other actions are validated as one batch and apply atomically between provider requests, after the current stream and complete tool-result batch.
65Conflicting mutations are rejected; no implicit winner is selected.
67A failed or over-budget handler emits one typed diagnostic, is disabled for the current generation, and does not abort the turn unless its event contract requires a decision.
68Terminal agent events remain singular.
60Plugin handlers and their action semantics are specified in `SMH-SPEC-PLUG0001`.
61The agent applies published actions only at the safe points defined here: between provider requests, after the current stream and complete tool-result batch.
7063```mermaid
7164sequenceDiagram
253246Normal operation does not require an external VCS executable.
254247Mutating VCS operations validate their target and remain attributable to session events.
256## Plugins and configuration
249## Plugin system and configuration
258Plugins run in a restricted runtime without direct operating-system, filesystem, environment, network, or clock access.
259Plugin execution is resource-bounded.
260Host effects are available only through typed Smith SDK component interfaces granted by manifest and trust decisions.
261Built-in plugins have no privileged effect path.
263Plugins may contribute:
265- tools,
266- commands,
267- providers and models,
268- prompts and context transforms,
269- event handlers,
270- themes and keybindings,
271- layout and render descriptions,
272- VCS workflows.
274Plugin events are ordered and typed.
275A candidate generation can declare and validate contributions but cannot invoke operational effects or mutate the active runtime before publication.
276A failed load leaves no registrations or subscriptions active.
277Reload publishes one complete generation or retains the previous generation.
279A generation owns every plugin instance, registration, subscription, binding, and contribution.
280Session, branch, queue, secrets, cancellation, and active-turn state live outside the generation and survive reload.
281Guest-local implementation state resets on reload.
282Removed contributions disappear at publication.
283Calls already running complete against their pinned generation; later calls resolve against the published generation.
285Each provider request pins one generation through its response and complete tool-call/result batch.
286The pinned generation supplies both advertised definitions and executable handlers.
287Built-in coding tools are embedded component artifacts loaded through the normal sandbox; they call the same typed host primitives available to user plugins.
289Smith SDK calls may catch ordinary typed guest errors, but not cancellation, budget exhaustion, sandbox violations, or host-effect recording failures.
290Smith SDK child work is structured and host-orchestrated: it shares the parent invocation budget and generation pin, serializes per plugin instance, and finishes or cancels before the parent handler returns.
291Fan-out cannot multiply resource limits.
292The budget covers deadline, guest fuel, component memory and table ceilings, host allocations, logs, conversions, and output.
294Session continuity survives reload.
296### Discovery and modules
298Version 1 discovers plugin packages by path convention.
299Each package carries a manifest declaring its plugin artifact, world version, and requested capabilities.
300Package, artifact, and manifest identities are deterministic and validated before instantiation.
301Artifacts failing validation never execute.
302Manifest and artifact reads are bounded before materialization, and canonical paths cannot escape their declared root.
304A module contract is a typed, major-versioned component interface.
305Undeclared exports remain private.
306A module can have zero, one, or multiple implementations.
307One implementation binds automatically.
308Zero or ambiguous implementations fail only when consumed, with sorted candidates and the consumer reported.
309Explicit user binding overrides automatic binding and must satisfy the requested contract.
311Module consumers use logical major-versioned handles.
312A new invocation resolves each handle against the published generation; nested accesses during an active invocation resolve within its pinned generation.
313Reload can rebind only to an implementation satisfying the same major contract; guest-local state resets.
315Precedence is built-in, global user, project, then explicit override.
316Later registration replaces earlier registration only where the earlier contract explicitly permits replacement.
317Installed capabilities are validated as a complete set before atomic replacement or removal.
319### Project trust
321Project-local executable configuration, plugins, modules, and managed packages are not enumerated or loaded before trust is resolved.
322A project trust identity is its lossless, platform-tagged canonical native path.
323Symlink aliases share one decision; distinct native paths cannot collide through text conversion.
324Interactive mode can ask and persist the decision.
325Non-interactive modes require an explicit or previously persisted decision to load project-local executable behavior.
326An explicit plugin path grants one-run trust only to that exact canonical source.
327Capability grants resolve at trust time for project plugins and at install time for user plugins.
328Ignoring untrusted project behavior produces a visible diagnostic.
330Trust does not remove the plugin sandbox or tool boundaries.
251The plugin system is specified in `SMH-SPEC-PLUG0001`; engine mechanics in `SMH-SPEC-WASM0001`.
252Plugin events respect the agent lifecycle boundary defined there.
253Plugins contribute configuration values per the precedence below.
332255### Configuration
453376- concurrent or interrupted session operations do not silently corrupt history,
454377- provider catalogs remain usable offline and reject stale refresh publication,
455378- model requests never use unadvertised capabilities,
456- project plugins cannot execute before trust resolution,
379- plugin system acceptance is defined in `SMH-SPEC-PLUG0001`,
457380- every SDK effect has durable intent, completion, causal attribution, and three-state mutation evidence,
458381- replay exposes incomplete effects as unknown and never retries them automatically,
459- event handlers are bounded, ordered, and publish conflict-free runtime actions only at safe points,
460- reload atomically replaces one complete generation while active provider rounds remain pinned,
461- callable module handles rebind only to conforming implementations of the same major contract,
462- built-in and user plugins use the same sandboxed effect APIs,
463- structured child work cannot suppress cancellation or exceed its shared budget,
464382- compressed session frames remain bounded, recoverable, traversable, and deterministic,
465383- terminal shutdown restores host state across supported exit paths,
466384- RPC consumers can assemble complete messages from ordered events,