repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

Plan the external-integration prototype campaign

8cb0ac690355e908b2f1aeb328a5aa7baf2e017d

Claude <noreply@anthropic.com> ·

SSH signature · not checked

Browse filesCompare with HEAD

The internal architecture is now heavily prototype-proven; the thinnest
evidence is at the outer boundaries — real provider wire formats, tool
mutation semantics, OAuth, cross-platform builds, and the arch-gate tooling.
Campaign 7 ranks these by spec-impact × uncertainty so the next wave targets
the claims most likely to be wrong, not the easiest to test.

Two entries (cross-build, arch-gate) are marked tooling-gated: they need a
release/CI toolchain the local sandbox lacks, and are the reason to stand up
a CI prototype rather than keep asserting §14 and §11 on faith.

Recorded in prototypes/PLAN.md as Campaign 7 (P29–P33).

Changed files (1)

+228 / −0 text lines

Diff layout

prototypes/PLAN.md

Modified

+228 / −0 text lines

20152015span, `session_tree` node), poll-only cost/context for v1. Spec issues: P2
20162016session/snapshot, P2 payload guarantees, P3 cost/context push.
2018## Campaign 7 — external integration surface
2020The internal architecture is heavily validated; the least-tested claims are the
2021external boundaries — real provider wire formats, tool mutation semantics,
2022OAuth, cross-platform builds, and the arch-gate tooling. Ranked by
2023spec-impact × uncertainty. p29/p31/p33 are environment-feasible; p30/p32 are
2024tooling-gated (need a release/CI toolchain) and are attempted where possible.
2026## P29 — `p29-provider-streaming`
2028### SPEC claims
2030- §7.1/§7.2: required providers (Anthropic, OpenAI, Google, OpenAI-compatible)
2031 normalize vendor wire formats into `ProviderEvent` (§5.2); quirks handled at
2032 the boundary — partial tool-call argument chunks assembled, thinking/
2033 reasoning fields (reasoning may arrive in `content`), provider stop reasons,
2034 cache usage; non-SSE JSON error on a streaming request → `ProviderEvent::Error`.
2035- §5.1: `Thinking { content, provider_metadata? }` — signed thinking round-trips.
2037### Risk
2039Each provider's streaming shape differs (Anthropic content-block events, OpenAI
2040delta chunks, Google candidates); normalizing all into one `ProviderEvent`
2041sequence, assembling split tool-call JSON, and preserving thinking signatures
2042is unvalidated for the current provider set (only pre-consolidation MiniMax was).
2044### Minimal artifact
2046```text
2047p29-provider-streaming/
2048 Cargo.toml (serde, serde_json)
2049 fixtures/anthropic.sse fixtures/openai.sse fixtures/google.sse
2050 fixtures/anthropic-error-200.json (non-SSE error body)
2051 src/main.rs
2052```
2054Realistic hand-authored fixtures of each provider's streaming bytes (no
2055network). A per-provider normalizer parses them into a `Vec<ProviderEvent>`.
2057### Verify
2059```bash
2060cd prototypes/p29-provider-streaming
2061cargo run -- anthropic
2062cargo run -- openai
2063cargo run -- google
2064cargo run -- tool-call-assembly
2065cargo run -- error-detection
2066cargo run -- thinking-roundtrip
2067cargo run -- all
2068```
2070### Pass evidence
2072- each provider's fixture → the expected deterministic `ProviderEvent`
2073 sequence (TextDelta/ThinkingDelta/ToolCall assembled/Done{usage,stop}),
2074- a tool call whose JSON arguments are split across chunks assembles to one
2075 complete `ToolCall`,
2076- a non-SSE JSON error body returned with HTTP 200 becomes
2077 `ProviderEvent::Error`, not a hang,
2078- a thinking block with a provider signature survives as
2079 `provider_metadata` and replays on a follow-up request,
2080- report any provider shape §7.2's quirk list does not cover.
2082### SPEC impact
2084Tighten §7.2 with the concrete per-provider normalization rules and any quirk
2085the fixtures expose.
2087## P31 — `p31-edit-write-tool`
2089### SPEC claims
2091- §9.12 `write`: atomic temp-file + rename, creates parent dirs, records a VCS op.
2092- §9.12 `edit`: read → validate (non-empty `old_text`, non-binary) → count exact
2093 matches (zero fails, multiple fails unless `allow_multiple`) → re-read+hash
2094 before write → fail `ESTALE` if changed → write atomically → return change
2095 count + before/after hashes. Errors: `ENOENT`, `EEMPTY`, `EBINARY`,
2096 `ENOMATCH`, `EMULTI`, `ESTALE`, `ELOCK`.
2097- §5.3/§6.1: parallel vs sequential tool execution; every tool observes abort.
2099### Risk
2101The stale-hash race (re-read between match and write) and the exact error-code
2102taxonomy are subtle and unvalidated; p07 only mocked tools. Atomic rename must
2103hold on same-filesystem temp.
2105### Minimal artifact
2107```text
2108p31-edit-write-tool/
2109 Cargo.toml (sha2; std only otherwise)
2110 src/main.rs
2111```
2113Real files in temp dirs; drive `write`/`edit` against them.
2115### Verify
2117```bash
2118cd prototypes/p31-edit-write-tool
2119cargo run -- write-atomic
2120cargo run -- edit-happy
2121cargo run -- edit-errors
2122cargo run -- edit-stale-race
2123cargo run -- parallel-abort
2124cargo run -- all
2125```
2127### Pass evidence
2129- write: temp+rename is atomic (a crash between leaves either old or new, never
2130 partial — simulate by asserting no partial file); parent dirs created,
2131- edit: happy path returns change count + before/after hashes; each error code
2132 reproduced with its exact condition,
2133- stale race: mutate the file between match-count and write → `ESTALE`, no write,
2134- parallel mode runs independent edits concurrently; an abort mid-batch stops
2135 cleanly and leaves no half-written file.
2137### SPEC impact
2139Confirm or refine the §9.12 edit algorithm ordering and the stale/atomic
2140guarantees under real filesystem semantics.
2142## P33 — `p33-oauth-flow`
2144### SPEC claims
2146- §7.4: OAuth configured with `id/name/auth_url/token_url/scope/client_id`;
2147 login surfaces the auth URL, receives the code via a local callback HTTP
2148 server on a random port (or manual paste), exchanges it for
2149 `{access_token, refresh_token, expires_at}`, persists to `auth.json`,
2150 auto-refreshes on expiry.
2152### Risk
2154The callback-server + exchange + refresh flow (state/PKCE, random-port bind,
2155redirect capture, refresh timing) is fiddly and unvalidated.
2157### Minimal artifact
2159```text
2160p33-oauth-flow/
2161 Cargo.toml (serde, serde_json; std TcpListener for both servers)
2162 src/main.rs
2163```
2165A mock OAuth provider (std `TcpListener`) plays authorize + token endpoints; the
2166client runs the §7.4 flow end to end, no external network.
2168### Verify
2170```bash
2171cd prototypes/p33-oauth-flow
2172cargo run -- login
2173cargo run -- callback-capture
2174cargo run -- refresh
2175cargo run -- persist
2176cargo run -- all
2177```
2179### Pass evidence
2181- login binds a random-port callback server, emits the auth URL with `state`,
2182 the mock provider redirects with a code, the server captures it, exchange
2183 yields tokens,
2184- `state` mismatch is rejected,
2185- an expired `access_token` triggers a refresh using `refresh_token`; a revoked
2186 refresh surfaces a clear auth error,
2187- tokens persist to and reload from the `auth.json` shape (§7.4).
2189### SPEC impact
2191Pin any §7.4 OAuth detail the flow exposes (state/PKCE requirement, callback
2192timeout, refresh-ahead-of-expiry window).
2194## P30 — `p30-cross-build` (tooling-gated)
2196### SPEC claim
2198§14: `cargo run -p xtask -- release` cross-builds all targets via
2199cargo-zigbuild — windows-msvc, apple-silicon, linux gnu/musl (x86_64 + arm64).
2201### Risk
2203The heavy C tree (vendored LuaJIT, aws-lc-sys via cmake, jj-lib's gix/prost)
2204cross-compiled to Windows/musl is a real "does it even build" unknown, like p17
2205and p26 — and could force dependency or feature changes.
2207### Verify (attempt where tooling allows)
2209Install `cargo-zigbuild` + `zig`; attempt `cargo zigbuild --target
2210x86_64-unknown-linux-musl` and `aarch64-unknown-linux-musl` on a minimal bin
2211pulling mlua(vendored) + aws-lc + gix. Report per-target build success/failure
2212and the first blocking C/link error. If zig/targets are unavailable, report
2213BLOCKED with what a release environment must provide.
2215### SPEC impact
2217Confirm §14's target list is buildable, or record the per-target blockers /
2218feature changes needed.
2220## P32 — `p32-arch-gate` (tooling-gated)
2222### SPEC claim
2224§11 / PROJECT-INVARIANTS §11: `cargo run -p xtask -- pup` on pinned nightly
2225enforces the forbidden inter-crate dependency rules (e.g. `smith-core` must not
2226depend on `smith-ai`).
2228### Risk
2230The whole architecture gate bets on cargo-pup expressing these rules; if it
2231cannot, §11 enforcement is vapor and needs a different mechanism.
2233### Verify (attempt where tooling allows)
2235On the pinned nightly, install `cargo_pup`; author a rule expressing a §11
2236forbidden edge over a tiny 3-crate workspace; prove it PASSES a legal graph and
2237FAILS an illegal one. If the nightly/tool is unavailable, report BLOCKED and
2238whether `cargo run -p xtask -- arch` (stable metadata check) can enforce the
2239same rules as a fallback.
2241### SPEC impact
2243Confirm cargo-pup enforces §11, or fall back the arch gate to the stable
2244metadata check and record it.
20182246## Reporting Template
20202248Each completed prototype updates this plan with a result block in the