repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

docs(system): rework harness plan, add provider and oauth plugins plan

bdde5762996c6e4a09deef900e107f70700948df

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

+136 / −167 text lines

Diff layout

.system/board.json

Modified

+7 / −1 text lines

88 },
99 "SMH-PLAN-AIAG0001": {
1010 "state": "done",
11 "source": "agent",
1211 "updatedAt": "2026-09-11T09:20:57.959Z",
12 "source": "agent",
1313 "note": "cargo x check exit 0, 107 tests pass; 11 order items verified incl. 3 conformance-proven adapters, catalog validation, agent loop with paired tool turns, failover router, eval+rpc e2e."
1414 },
1515 "SMH-PLAN-CORE0001": {
2222 "updatedAt": "2026-09-11T08:32:39.399Z",
2323 "source": "assess"
2424 },
25 "SMH-PLAN-VOETK_DD": {
26 "state": "done",
27 "source": "agent",
28 "updatedAt": "2026-09-25T14:26:25.602Z",
29 "note": "cargo x check green: auth CLI e2e, 0600 perms, flags+SMITH_ env+provenance, explicit failures, OpenAI default deleted, store resolution offline. Live rounds need real keys."
30 },
2531 "SMH-PLAN-WSPC0001": {
2632 "state": "done",
2733 "updatedAt": "2026-09-11T08:32:49.987Z",

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

Added
new file mode 100644

+82 / −0 text lines

1---
2id: SMH-PLAN-AIAGD002
3type: plan
4title: "Provider and OAuth Plugins"
5spec: SMH-SPEC-SPEC0001
6status: draft
7depends_on: [SMH-PLAN-PLUG0001]
8---
9
10# Provider and OAuth Plugins
12## Outcome
14Every supported vendor ships as an unprivileged per-family plugin.
15Users log in with a Z.ai key and with OpenAI, Anthropic, and Google subscriptions; provider-specific code is gone from the core.
17## Scope
19Per-family provider plugins, the shared OAuth plugin, plugin-to-plugin dependencies, and core adapter removal.
20Host surface and scaffolding come from the harness plan.
22## Behaviors
24Ordered by delivery value.
261. **Z.ai provider plugin**: key credential from the auth store, OpenAI-compatible stream behind the plugin boundary; one eval turn runs end to end with the core adapter absent from the dispatch path.
272. **OAuth plugin**: device or localhost-redirect flows through net-scope effects; tokens cross the secret-proxy boundary to the auth store; renewal refreshes before dispatch.
283. **Plugin dependency**: provider plugins declare a dependency on the OAuth plugin's major-versioned module contract; the harness validates the complete set before publication; missing or ambiguous bindings fail at consumption with sorted candidates.
294. **OpenAI plugin**: subscription login via the OAuth plugin plus key support; provider registration advertises models with capabilities.
305. **Anthropic plugin**: subscription login plus key support; wire format and model catalog live in the plugin.
316. **Google plugin**: subscription login plus key support; same registration path.
327. **Core adapter removal**: native vendor decoders and vendor catalogs are deleted; mux routes plugin-registered providers; conformance fixtures validate plugin streams against recorded transcripts.
34## Login surface
36```mermaid
37flowchart LR
38 U["smith login --provider VENDOR"] --> O{"flow?"}
39 O -- key --> K["auth store (stdin secret)"]
40 O -- subscription --> P["oauth plugin flow"]
41 P --> N["net-scope http"]
42 N --> SP["secret-proxy exchange"]
43 SP --> S["auth store"]
44 K --> R["resolve before dispatch"]
45 S --> R
46```
48## Plan dependencies
50```mermaid
51flowchart LR
52 PLUG["PLUG0001 harness + scaffolding"] --> Z["zai plugin"]
53 Z --> OA["oauth plugin"]
54 OA --> DEP["plugin dependency validation"]
55 DEP --> OAI["openai"]
56 DEP --> ANT["anthropic"]
57 DEP --> GOO["google"]
58 OAI --> RM["remove core adapters"]
59 ANT --> RM
60 GOO --> RM
61```
63## Interfaces
65- `plugins/provider-zai`, `plugins/provider-openai`, `plugins/provider-anthropic`, `plugins/provider-google`.
66- `plugins/oauth`: exports the credential-source module contract.
67- `smith login`: vendor login command over key or subscription flows.
69## Verification
71- Each vendor completes one eval round using only its plugin-registered provider.
72- Subscription credentials renew before expiry without re-login.
73- A provider plugin missing its OAuth dependency fails at consumption with the consumer and candidates named.
74- No native vendor decoder remains; conformance validates each plugin stream against recorded transcripts.
75- Credential plaintext never appears in logs, traces, replay, or plugin diagnostics.
76- Embedded built-in provider artifacts update without a smith rebuild in dev configurations.
78## Stop conditions
80- A vendor requires an effect absent from the public world.
81- OAuth flows cannot complete without ambient capabilities beyond net-scope and secret-proxy.
82- Plugin dependency validation cannot reject incomplete sets atomically.

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

Modified

+47 / −166 text lines

44title: "Sandboxed Plugin Harness"
55spec: SMH-SPEC-SPEC0001
66status: draft
7depends_on: [SMH-PLAN-AIAG0001]
7depends_on: [SMH-PLAN-AIAG0001, SMH-PLAN-VOETK_DD]
88research: [SMH-RESEARCH-WASM0001]
99---
1313## Outcome
15Trusted component packages extend the live agent through bounded, durable, generation-owned contracts.
16Failed load, effect, handler, or reload paths leave explicit evidence and no mixed plugin state.
15Provider and OAuth plugins run as unprivileged wasm components over core primitives.
16The host owns one typed effect surface; built-ins and user plugins share it with no privileged path.
1818## Scope
20This plan delivers executable commands, tools, providers, modules, events, built-in tool artifacts, and plugin tooling.
21It delivers validated generation-owned UI and VCS registrations; their execution remains in `SMH-PLAN-TUIR0001`.
20Host primitives extraction, the minimal wasm plugin system, plugin scaffolding, and plugin tooling.
21Provider and OAuth plugin delivery lives in the provider-plugins plan.
23## Delivery graph
23## Behaviors
25Each slice leaves one observable path integrated and verified.
25Ordered by delivery value.
271. **Typed HTTP effect**: provider network runs through one host-owned typed HTTP client with bounded bodies, cancellation, and durable recorded effects; `smith-ai` transport consumes it before any plugin exists.
282. **Core shrink**: vendor wire decoders, vendor catalogs, and conformance fixtures leave the core path; `smith-ai` keeps auth, mux, and model types.
293. **Wasm host**: wasmtime engine with deterministic settings, fuel and memory ceilings, artifact validation against the pinned world, and no ambient WASI.
304. **Trust and discovery**: project packages stay undiscovered until trust resolves; manifests declare artifact, world version, and capabilities; grants resolve at trust or install time.
315. **Transactional load**: load, validate, instantiate, and register one component atomically; failure leaves no registrations.
326. **Capability effects**: guests reach host effects only through granted imports — HTTP via net-scope, credential exchange via secret-proxy, logging; ungranted imports fail instantiation.
337. **Registration surface**: plugins register provider streams, credential sources, and model contributions; the host pulls stream chunks by explicit request.
348. **Generations and reload**: one complete generation publishes atomically; provider rounds pin one generation; reload keeps session continuity.
359. **Scaffolding**: `smith-plugin-sdk` crate pins the WIT and bindgen types; `plugins/` workspace members build components under the same gates; dev-links load fresh artifacts from the target directory.
3610. **Embedded built-ins**: release binaries embed system plugin artifacts and load them through the same loader, sandbox, and effect grants as user plugins.
3711. **Tooling**: `smith plugin init|build|check|dev|test` scaffold, produce artifacts, lint worlds and grants, hot-swap via dev-links, and run hosted tests with mocked capabilities.
39## Behavior structure
2741```mermaid
2842flowchart LR
29 AIAG["AIAG: shared agent runtime"] --> S1["Trusted transactional command"]
30 S1 --> S2["Durable bounded effects"]
31 S2 --> S3["Bounded composition and fatal failures"]
32 S3 --> S4["Callable modules"]
33 S4 --> S5["Common tool and provider path"]
34 S5 --> S6["Live typed actions"]
35 S6 --> S7["Atomic reload and precedence"]
36 S7 --> S8["Plugin tooling"]
37 S7 --> TUIR["TUIR: UI, VCS, replay surfaces"]
38 S8 --> RELS["RELS: release readiness"]
39 TUIR --> RELS
43 P1["Typed HTTP effect"] --> P2["Core shrink"]
44 P2 --> H["Wasm host"]
45 H --> T["Trust + discovery"]
46 T --> L["Transactional load"]
47 L --> E["Capability effects"]
48 E --> R["Registration surface"]
49 R --> G["Generations + reload"]
50 G --> S["Scaffolding"]
51 S --> B["Embedded built-ins"]
52 B --> X["Tooling"]
53 X --> PROV["Provider plugins plan"]
4054```
4256## Interfaces
44- `smith-harness::wasm`: engine config, instantiation, capabilities, fuel, ceilings.
45- `smith-harness::trust`: persisted and one-run project decisions.
46- `smith-harness::plugins`: discovery, binding, registration transactions, reload.
58- `smith-harness::http`: typed HTTP effect with durable records.
59- `smith-harness::wasm`: engine, validation, instantiation, capabilities, ceilings.
60- `smith-harness::trust`, `smith-harness::plugins`: discovery, binding, registration, reload.
61- `smith-plugin-sdk`: pinned WIT, guest types, effect wrappers.
62- `plugins/*`: system plugin crates.
4763- `smith:plugin` WIT world: the only plugin path to host effects.
49## Slices
65## Verification
51### 1. Trusted transactional command
53A trusted built-in or user package contributes one command through the wasm component sandbox.
54Project packages remain undiscovered until trust resolves.
55An explicit path grants one-run trust only to its canonical source.
56Failed instantiation publishes nothing.
58Touches: `smith-harness::wasm`, `smith-harness::trust`, `smith-harness::plugins`, `smith-harness::runtime`, `smith-cli`.
60Verify:
62- Canonical native paths distinguish otherwise-colliding project identities.
63- Manifest and artifact reads cannot escape their declared root.
64- Ambient WASI imports fail validation; ungranted capability imports fail instantiation.
65- Artifact reads, decoding, instantiation, memory and table ceilings, fuel, logs, output, deadline, and cancellation remain bounded.
66- Host effects are unavailable before generation publication.
67- Interactive, eval, and RPC modes expose the same trust outcome and diagnostics.
69### 2. Durable bounded effects
71The command invokes a typed filesystem or search effect through a granted capability.
72The session stores bounded full intent and completion records with stable identity, causal parent, generation, redacted secrets, and three-state mutation evidence.
73Replay exposes the same records without re-execution.
75Touches: `smith::tool`, `smith::session`, `smith-core::tools`, `smith-core::session`, `smith-core::replay`, `smith-harness::plugins`, `smith:plugin` world effect interfaces.
77Verify:
79- Intent persistence failure prevents execution.
80- Success, ordinary failure, cancellation, partial mutation, and completion-persistence failure retain correct evidence.
81- A dangling intent recovers as unknown and never retries automatically.
82- Full bounded effect payloads survive deterministic compressed-frame round trips.
83- Compression preserves traversal, corruption recovery, unknown frames, and allocation bounds.
84- Secret plaintext never enters effect records, diagnostics, or replay.
85- A `--no-session` eval effect records against the temporary store; clean exit removes it, abnormal termination retains it.
87### 3. Bounded composition and fatal failures
89A plugin command uses host-orchestrated structured child work and controlled error handling.
90Ordinary typed guest errors are catchable; cancellation, budgets, sandbox violations, and recording failures are not.
92Touches: `smith-harness::wasm`, `smith-harness::plugins`, `smith:plugin` world task and error interfaces.
94Verify:
96- Child work shares the parent invocation budget and generation pin.
97- Every child finishes or cancels before its parent returns.
98- Calls to one plugin instance never run concurrently.
99- Fan-out cannot multiply resource limits.
100- Error reports retain package, generation, handler, event, and child-task context.
102### 4. Callable modules
104Host and plugin consumers invoke a discovered module through a logical major-versioned handle.
105Singleton binding is automatic; zero and ambiguous binding fail only on consumption; explicit binding is deterministic.
107Touches: `smith-harness::plugins`, `smith:plugin` world module interface.
109Verify:
111- Manifest-based discovery validates bounded contract and artifact sources before instantiation.
112- Undeclared exports remain private.
113- Diagnostics report the consumer and sorted candidates.
114- Explicit bindings must satisfy the requested major contract.
115- Existing logical handles resolve against a newly published conforming generation; active calls finish against their pinned generation.
116- Guest-local state resets after rebinding.
118### 5. Common tool and provider path
120A plugin contributes an executable provider-visible tool and a provider through the same generation and SDK effect boundary.
121Built-in `read`, `write`, `edit`, `bash`, `find`, `grep`, and `ls` become embedded component artifacts over the public typed primitives.
123Touches: `smith::tool`, `smith::provider`, `smith-core::agent`, `smith-ai`, `smith-harness::plugins`, `smith-harness::runtime`, built-in component packages.
125Verify:
127- The provider request and returned tool batch use one pinned generation.
128- Advertised definitions and invoked handlers cannot diverge.
129- Built-in and user tools have identical sandbox, cancellation, validation, effect recording, and error behavior.
130- Provider operations use durable SDK effects without exposing credentials.
131- A missing public primitive blocks migration rather than creating a privileged built-in path.
133### 6. Live typed actions
135An installed handler receives ordered live lifecycle events and returns cancellation, queued input, reload, model, provider, tool, prompt, or runtime-configuration actions.
136Cancellation is immediate; other actions publish only after the current provider stream and complete tool batch.
138Touches: `smith::event`, `smith-core::agent`, `smith-harness::plugins`, `smith-harness::runtime`, eval and RPC event bridges, `smith:plugin` world lifecycle interface.
140Verify:
142- Handler order is deterministic across interface modes.
143- Non-conflicting actions publish atomically between provider requests.
144- Conflicting field mutations are rejected without an implicit winner.
145- Runtime configuration actions do not persist configuration.
146- A failed or over-budget handler emits one diagnostic, remains disabled for its generation, and does not duplicate terminal events.
148### 7. Atomic reload and precedence
150Global, trusted project, explicit, and built-in sources assemble one candidate generation.
151Successful reload replaces the complete installed capability set; failed reload retains the previous generation.
153Touches: `smith-harness::trust`, `smith-harness::plugins`, `smith-harness::runtime`, `smith-core::agent`, `smith:plugin` world registration interfaces.
155Verify:
157- Precedence is built-in, global user, project, then explicit override.
158- Replacement succeeds only where the earlier contract permits it.
159- Removed registrations and subscriptions disappear together.
160- Session, branch, queue, secrets, cancellation, and active-turn state survive reload.
161- An installed `Agent` completes active calls on the old generation and uses the new generation for the next provider request.
162- Failed candidate validation, instantiation, binding, or publication leaves the active generation unchanged.
163- UI and VCS registrations participate in validation, ownership, replacement, and removal without executing deferred behavior.
165### 8. Plugin tooling
167`smith plugin init`, `build`, `check`, `dev`, and `test` cover scaffold, artifact build, lint, hot swap, and hosted testing.
168Tooling dispatches on language adapters; no command assumes the Rust toolchain.
170Touches: `smith-harness::wasm`, `smith-cli`, `smith:plugin` WIT world.
172Verify:
174- Init scaffolds a cargo project with a pinned WIT copy.
175- Build emits artifact and manifest without recompiling at load time.
176- Check rejects ambient imports, growable memories, and capability-versus-grant mismatches with concrete fixes.
177- Dev watch swaps atomically into a running runtime.
178- Test uses mocked capabilities and golden determinism fixtures.
67- Provider network calls through the typed effect are replay-visible and cancellable.
68- Ambient WASI imports fail validation; ungranted capability imports fail instantiation with a named grant.
69- Failed load or reload leaves no registrations; reload preserves session continuity.
70- One generation serves a provider round end to end.
71- `plugins/` members pass the same fmt, clippy, test, and arch gates as core crates.
72- `cargo x dev` loads a freshly built component through a dev-link without manual steps.
73- Embedded built-in artifacts pass the same validation as installed plugins.
17974- Repeated runs of one artifact with recorded host inputs produce identical outputs.
181## Exit
183- Eval and RPC run trusted plugin commands, tools, providers, modules, and event actions through one live harness.
184- Every host effect is bounded, cancellable, attributable, durable, replay-visible, and secret-safe.
185- Built-in coding tools have no privileged effect path.
186- Reload swaps one coherent generation through an installed agent.
187- Plugin tooling scaffolds, builds, validates, hot-swaps, and tests plugins.
188- UI and VCS registrations are ready for `SMH-PLAN-TUIR0001`.
189- Fresh workspace formatting, lint, tests, docs, architecture, audit, and pinned nightly gates pass without warnings.
19176## Stop conditions
19378- An effect can begin before durable intent publication.
194- The agent cannot pin one generation through a provider round and tool batch.
195- Runtime mutations cannot wait for a between-request safe point.
196- Plugin execution can escape cancellation or resource budgets.
197- A built-in requires an effect absent from the public WIT world.
79- The engine cannot enforce deterministic settings without unacceptable latency.
80- A built-in requires an effect absent from the public world.
19881- Trust must execute or enumerate project code before deciding trust.
199- Candidate construction can mutate host or active runtime state.
200- Deterministic engine knobs cannot be enforced without unacceptable layout latency.