docs(system): rework harness plan, add provider and oauth plugins plan
bdde5762996c6e4a09deef900e107f70700948df
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: 73829ded186d
There are many coding harnesses - but this one is fast
bdde5762996c6e4a09deef900e107f70700948df
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+136 / −167 text lines
+7 / −1 text lines
new file mode 100644+82 / −0 text lines
---id: SMH-PLAN-AIAGD002type: plantitle: "Provider and OAuth Plugins"spec: SMH-SPEC-SPEC0001status: draftdepends_on: [SMH-PLAN-PLUG0001]---# Provider and OAuth Plugins## OutcomeEvery supported vendor ships as an unprivileged per-family plugin.Users log in with a Z.ai key and with OpenAI, Anthropic, and Google subscriptions; provider-specific code is gone from the core.## ScopePer-family provider plugins, the shared OAuth plugin, plugin-to-plugin dependencies, and core adapter removal.Host surface and scaffolding come from the harness plan.## BehaviorsOrdered by delivery value.1. **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.2. **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.3. **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.4. **OpenAI plugin**: subscription login via the OAuth plugin plus key support; provider registration advertises models with capabilities.5. **Anthropic plugin**: subscription login plus key support; wire format and model catalog live in the plugin.6. **Google plugin**: subscription login plus key support; same registration path.7. **Core adapter removal**: native vendor decoders and vendor catalogs are deleted; mux routes plugin-registered providers; conformance fixtures validate plugin streams against recorded transcripts.## Login surface```mermaidflowchart LR U["smith login --provider VENDOR"] --> O{"flow?"} O -- key --> K["auth store (stdin secret)"] O -- subscription --> P["oauth plugin flow"] P --> N["net-scope http"] N --> SP["secret-proxy exchange"] SP --> S["auth store"] K --> R["resolve before dispatch"] S --> R```## Plan dependencies```mermaidflowchart LR PLUG["PLUG0001 harness + scaffolding"] --> Z["zai plugin"] Z --> OA["oauth plugin"] OA --> DEP["plugin dependency validation"] DEP --> OAI["openai"] DEP --> ANT["anthropic"] DEP --> GOO["google"] OAI --> RM["remove core adapters"] ANT --> RM GOO --> RM```## Interfaces- `plugins/provider-zai`, `plugins/provider-openai`, `plugins/provider-anthropic`, `plugins/provider-google`.- `plugins/oauth`: exports the credential-source module contract.- `smith login`: vendor login command over key or subscription flows.## Verification- Each vendor completes one eval round using only its plugin-registered provider.- Subscription credentials renew before expiry without re-login.- A provider plugin missing its OAuth dependency fails at consumption with the consumer and candidates named.- No native vendor decoder remains; conformance validates each plugin stream against recorded transcripts.- Credential plaintext never appears in logs, traces, replay, or plugin diagnostics.- Embedded built-in provider artifacts update without a smith rebuild in dev configurations.## Stop conditions- A vendor requires an effect absent from the public world.- OAuth flows cannot complete without ambient capabilities beyond net-scope and secret-proxy.- Plugin dependency validation cannot reject incomplete sets atomically.+47 / −166 text lines
Each slice leaves one observable path integrated and verified.Ordered by delivery value.1. **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.2. **Core shrink**: vendor wire decoders, vendor catalogs, and conformance fixtures leave the core path; `smith-ai` keeps auth, mux, and model types.3. **Wasm host**: wasmtime engine with deterministic settings, fuel and memory ceilings, artifact validation against the pinned world, and no ambient WASI.4. **Trust and discovery**: project packages stay undiscovered until trust resolves; manifests declare artifact, world version, and capabilities; grants resolve at trust or install time.5. **Transactional load**: load, validate, instantiate, and register one component atomically; failure leaves no registrations.6. **Capability effects**: guests reach host effects only through granted imports — HTTP via net-scope, credential exchange via secret-proxy, logging; ungranted imports fail instantiation.7. **Registration surface**: plugins register provider streams, credential sources, and model contributions; the host pulls stream chunks by explicit request.8. **Generations and reload**: one complete generation publishes atomically; provider rounds pin one generation; reload keeps session continuity.9. **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.10. **Embedded built-ins**: release binaries embed system plugin artifacts and load them through the same loader, sandbox, and effect grants as user plugins.11. **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.## Behavior structure AIAG["AIAG: shared agent runtime"] --> S1["Trusted transactional command"] S1 --> S2["Durable bounded effects"] S2 --> S3["Bounded composition and fatal failures"] S3 --> S4["Callable modules"] S4 --> S5["Common tool and provider path"] S5 --> S6["Live typed actions"] S6 --> S7["Atomic reload and precedence"] S7 --> S8["Plugin tooling"] S7 --> TUIR["TUIR: UI, VCS, replay surfaces"] S8 --> RELS["RELS: release readiness"] TUIR --> RELS P1["Typed HTTP effect"] --> P2["Core shrink"] P2 --> H["Wasm host"] H --> T["Trust + discovery"] T --> L["Transactional load"] L --> E["Capability effects"] E --> R["Registration surface"] R --> G["Generations + reload"] G --> S["Scaffolding"] S --> B["Embedded built-ins"] B --> X["Tooling"] X --> PROV["Provider plugins plan"]- `smith-harness::wasm`: engine config, instantiation, capabilities, fuel, ceilings.- `smith-harness::trust`: persisted and one-run project decisions.- `smith-harness::plugins`: discovery, binding, registration transactions, reload.- `smith-harness::http`: typed HTTP effect with durable records.- `smith-harness::wasm`: engine, validation, instantiation, capabilities, ceilings.- `smith-harness::trust`, `smith-harness::plugins`: discovery, binding, registration, reload.- `smith-plugin-sdk`: pinned WIT, guest types, effect wrappers.- `plugins/*`: system plugin crates.### 1. Trusted transactional commandA trusted built-in or user package contributes one command through the wasm component sandbox.Project packages remain undiscovered until trust resolves.An explicit path grants one-run trust only to its canonical source.Failed instantiation publishes nothing.Touches: `smith-harness::wasm`, `smith-harness::trust`, `smith-harness::plugins`, `smith-harness::runtime`, `smith-cli`.Verify:- Canonical native paths distinguish otherwise-colliding project identities.- Manifest and artifact reads cannot escape their declared root.- Ambient WASI imports fail validation; ungranted capability imports fail instantiation.- Artifact reads, decoding, instantiation, memory and table ceilings, fuel, logs, output, deadline, and cancellation remain bounded.- Host effects are unavailable before generation publication.- Interactive, eval, and RPC modes expose the same trust outcome and diagnostics.### 2. Durable bounded effectsThe command invokes a typed filesystem or search effect through a granted capability.The session stores bounded full intent and completion records with stable identity, causal parent, generation, redacted secrets, and three-state mutation evidence.Replay exposes the same records without re-execution.Touches: `smith::tool`, `smith::session`, `smith-core::tools`, `smith-core::session`, `smith-core::replay`, `smith-harness::plugins`, `smith:plugin` world effect interfaces.Verify:- Intent persistence failure prevents execution.- Success, ordinary failure, cancellation, partial mutation, and completion-persistence failure retain correct evidence.- A dangling intent recovers as unknown and never retries automatically.- Full bounded effect payloads survive deterministic compressed-frame round trips.- Compression preserves traversal, corruption recovery, unknown frames, and allocation bounds.- Secret plaintext never enters effect records, diagnostics, or replay.- A `--no-session` eval effect records against the temporary store; clean exit removes it, abnormal termination retains it.### 3. Bounded composition and fatal failuresA plugin command uses host-orchestrated structured child work and controlled error handling.Ordinary typed guest errors are catchable; cancellation, budgets, sandbox violations, and recording failures are not.Touches: `smith-harness::wasm`, `smith-harness::plugins`, `smith:plugin` world task and error interfaces.Verify:- Child work shares the parent invocation budget and generation pin.- Every child finishes or cancels before its parent returns.- Calls to one plugin instance never run concurrently.- Fan-out cannot multiply resource limits.- Error reports retain package, generation, handler, event, and child-task context.### 4. Callable modulesHost and plugin consumers invoke a discovered module through a logical major-versioned handle.Singleton binding is automatic; zero and ambiguous binding fail only on consumption; explicit binding is deterministic.Touches: `smith-harness::plugins`, `smith:plugin` world module interface.Verify:- Manifest-based discovery validates bounded contract and artifact sources before instantiation.- Undeclared exports remain private.- Diagnostics report the consumer and sorted candidates.- Explicit bindings must satisfy the requested major contract.- Existing logical handles resolve against a newly published conforming generation; active calls finish against their pinned generation.- Guest-local state resets after rebinding.### 5. Common tool and provider pathA plugin contributes an executable provider-visible tool and a provider through the same generation and SDK effect boundary.Built-in `read`, `write`, `edit`, `bash`, `find`, `grep`, and `ls` become embedded component artifacts over the public typed primitives.Touches: `smith::tool`, `smith::provider`, `smith-core::agent`, `smith-ai`, `smith-harness::plugins`, `smith-harness::runtime`, built-in component packages.Verify:- The provider request and returned tool batch use one pinned generation.- Advertised definitions and invoked handlers cannot diverge.- Built-in and user tools have identical sandbox, cancellation, validation, effect recording, and error behavior.- Provider operations use durable SDK effects without exposing credentials.- A missing public primitive blocks migration rather than creating a privileged built-in path.### 6. Live typed actionsAn installed handler receives ordered live lifecycle events and returns cancellation, queued input, reload, model, provider, tool, prompt, or runtime-configuration actions.Cancellation is immediate; other actions publish only after the current provider stream and complete tool batch.Touches: `smith::event`, `smith-core::agent`, `smith-harness::plugins`, `smith-harness::runtime`, eval and RPC event bridges, `smith:plugin` world lifecycle interface.Verify:- Handler order is deterministic across interface modes.- Non-conflicting actions publish atomically between provider requests.- Conflicting field mutations are rejected without an implicit winner.- Runtime configuration actions do not persist configuration.- A failed or over-budget handler emits one diagnostic, remains disabled for its generation, and does not duplicate terminal events.### 7. Atomic reload and precedenceGlobal, trusted project, explicit, and built-in sources assemble one candidate generation.Successful reload replaces the complete installed capability set; failed reload retains the previous generation.Touches: `smith-harness::trust`, `smith-harness::plugins`, `smith-harness::runtime`, `smith-core::agent`, `smith:plugin` world registration interfaces.Verify:- Precedence is built-in, global user, project, then explicit override.- Replacement succeeds only where the earlier contract permits it.- Removed registrations and subscriptions disappear together.- Session, branch, queue, secrets, cancellation, and active-turn state survive reload.- An installed `Agent` completes active calls on the old generation and uses the new generation for the next provider request.- Failed candidate validation, instantiation, binding, or publication leaves the active generation unchanged.- UI and VCS registrations participate in validation, ownership, replacement, and removal without executing deferred behavior.### 8. Plugin tooling`smith plugin init`, `build`, `check`, `dev`, and `test` cover scaffold, artifact build, lint, hot swap, and hosted testing.Tooling dispatches on language adapters; no command assumes the Rust toolchain.Touches: `smith-harness::wasm`, `smith-cli`, `smith:plugin` WIT world.Verify:- Init scaffolds a cargo project with a pinned WIT copy.- Build emits artifact and manifest without recompiling at load time.- Check rejects ambient imports, growable memories, and capability-versus-grant mismatches with concrete fixes.- Dev watch swaps atomically into a running runtime.- Test uses mocked capabilities and golden determinism fixtures.- Provider network calls through the typed effect are replay-visible and cancellable.- Ambient WASI imports fail validation; ungranted capability imports fail instantiation with a named grant.- Failed load or reload leaves no registrations; reload preserves session continuity.- One generation serves a provider round end to end.- `plugins/` members pass the same fmt, clippy, test, and arch gates as core crates.- `cargo x dev` loads a freshly built component through a dev-link without manual steps.- Embedded built-in artifacts pass the same validation as installed plugins.## Exit- Eval and RPC run trusted plugin commands, tools, providers, modules, and event actions through one live harness.- Every host effect is bounded, cancellable, attributable, durable, replay-visible, and secret-safe.- Built-in coding tools have no privileged effect path.- Reload swaps one coherent generation through an installed agent.- Plugin tooling scaffolds, builds, validates, hot-swaps, and tests plugins.- UI and VCS registrations are ready for `SMH-PLAN-TUIR0001`.- Fresh workspace formatting, lint, tests, docs, architecture, audit, and pinned nightly gates pass without warnings.