README Source History Refs Reviews Compare Notes Search Review guide Merge pull request #10 from bugabinga/claude/specs-progress-n5u27n 2a051899fe79c2ace16803197c093a12a20bd611
Oliver Jan Krylow <oliver@bugabinga.net > · 18 Jul 2026
SSH signature · not checked
Browse files Compare with HEAD
Validate the frontend boundary and the cross-build/arch-gate toolchain Changed files (21) Diff layout Auto Unified Split
.github/workflows/ci-prototype.yml Added new file mode 100644+123 / −0 text lines
14 + branches : ["claude/specs-progress-n5u27n" ]16 + - ".github/workflows/ci-prototype.yml" 17 + - "prototypes/p34-ci-pipeline/**" 18 + workflow_dispatch : {}24 + group : ci-prototype-${{ github.ref }} 25 + cancel-in-progress : true 30 + runs-on : ubuntu-latest 33 + working-directory : prototypes/p34-ci-pipeline/cross 35 + - uses : actions/checkout@v4 36 + - name : toolchain + targets 38 + rustup default stable 39 + rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-pc-windows-gnu 40 + - name : zig + cargo-zigbuild 43 + cargo install cargo-zigbuild --locked 44 + - name : cross x86_64-unknown-linux-musl 46 + continue-on-error : true 47 + run : cargo zigbuild --target x86_64-unknown-linux-musl 48 + - name : cross aarch64-unknown-linux-musl 50 + continue-on-error : true 51 + run : cargo zigbuild --target aarch64-unknown-linux-musl 52 + - name : cross x86_64-pc-windows-gnu 54 + continue-on-error : true 55 + run : cargo zigbuild --target x86_64-pc-windows-gnu 56 + - name : per-target summary 58 + echo "## §14 cross-build (mlua vendored + gix)" >> "$GITHUB_STEP_SUMMARY" 59 + echo "| target | result |" >> "$GITHUB_STEP_SUMMARY" 60 + echo "|--------|--------|" >> "$GITHUB_STEP_SUMMARY" 61 + echo "| x86_64-unknown-linux-musl | ${{ steps.musl_x64.outcome }} |" >> "$GITHUB_STEP_SUMMARY" 62 + echo "| aarch64-unknown-linux-musl | ${{ steps.musl_arm.outcome }} |" >> "$GITHUB_STEP_SUMMARY" 63 + echo "| x86_64-pc-windows-gnu | ${{ steps.win_gnu.outcome }} |" >> "$GITHUB_STEP_SUMMARY" 71 + os : [ubuntu-latest , macos-latest , windows-latest ]72 + runs-on : ${{ matrix.os }} 75 + working-directory : prototypes/p34-ci-pipeline/cross 77 + - uses : actions/checkout@v4 78 + - run : rustup default stable 79 + - name : build + run cross bin natively 88 + runs-on : ubuntu-latest 91 + working-directory : prototypes/p34-ci-pipeline/archgate 93 + - uses : actions/checkout@v4 94 + - run : rustup default stable 95 + - name : metadata gate PASSES the legal graph 97 + - name : metadata gate FAILS once the forbidden edge is injected 99 + cp wcore/Cargo.toml /tmp/wcore.bak 100 + printf 'wai = { path = "../wai" }\n' >> wcore/Cargo.toml 101 + if python3 gate.py; then 102 + echo "BUG: gate passed an illegal graph"; cp /tmp/wcore.bak wcore/Cargo.toml; exit 1 104 + cp /tmp/wcore.bak wcore/Cargo.toml 105 + echo "gate correctly rejected the injected wcore->wai edge" 106 + - name : cargo_pup source gate on pinned nightly (P32 probe) 108 + continue-on-error : true 111 + rustup toolchain install nightly-2026-01-22 --profile minimal 112 + rustup component add --toolchain nightly-2026-01-22 rust-src rustc-dev llvm-tools-preview 113 + cargo +nightly-2026-01-22 install cargo_pup --locked 114 + echo "=== generate-config sample (reveals the real pup.ron schema) ===" 115 + cp pup.ron pup.ron.mine 116 + cargo +nightly-2026-01-22 pup generate-config || true 117 + echo "--- generated pup.ron ---"; cat pup.ron || true 118 + echo "=== print-modules ==="; cargo +nightly-2026-01-22 pup print-modules || true 119 + echo "=== lint the legal 3-crate workspace with the generated config ===" 120 + cargo +nightly-2026-01-22 pup 123 + echo "cargo_pup probe outcome = ${{ steps.pup.outcome }}" >> "$GITHUB_STEP_SUMMARY" .github/workflows/prototypes.yml Added new file mode 100644+67 / −0 text lines
14 + branches : ["claude/specs-progress-n5u27n" ]17 + - "!prototypes/**/*.md" 18 + - "!prototypes/p34-ci-pipeline/**" 19 + - ".github/workflows/prototypes.yml" 20 + workflow_dispatch : {}26 + group : prototypes-${{ github.ref }} 27 + cancel-in-progress : true 31 + runs-on : ubuntu-latest 33 + - uses : actions/checkout@v4 35 + run : rustup default stable && rustc -V && cargo -V 36 + - name : build + test every prototype (fail if any regresses) 38 + # Each cargo compile runs with CWD inside the prototype tree so the 39 + # cap-lints=warn exemption (prototypes/.cargo/config.toml) applies; 40 + # building via --manifest-path from the root inherits -D warnings. 41 + echo "## Prototype build+test" >> "$GITHUB_STEP_SUMMARY" 42 + echo "| crate | result | seconds |" >> "$GITHUB_STEP_SUMMARY" 43 + echo "|-------|--------|---------|" >> "$GITHUB_STEP_SUMMARY" 46 + for d in prototypes/p*/; do 47 + [ -f "$d/Cargo.toml" ] || continue 48 + case "$d" in prototypes/p34-ci-pipeline/) continue;; esac 49 + name=$(basename "$d") 51 + if ( cd "$d" && cargo test --quiet ) >/tmp/proto.log 2>&1; then 55 + failed="$failed $name" 56 + echo "::group::$name FAILED"; cat /tmp/proto.log; echo "::endgroup::" 58 + dur=$((SECONDS - start)) 59 + total=$((total + dur)) 60 + echo "| $name | $status | $dur |" >> "$GITHUB_STEP_SUMMARY" 62 + echo "| **total** | | **$total** |" >> "$GITHUB_STEP_SUMMARY" 63 + if [ -n "$failed" ]; then 64 + echo "prototype regressions:$failed" 67 + echo "all prototypes green" +46 / −5 text lines
742 742 - provider/model changes,- provider/model changes,743 743 - errors and shutdown.- errors and shutdown.745 - `EngineEvent` is consumed by `smith-harness` and `smith-tui`.745 + `EngineEvent` is consumed by `smith-harness` and `smith-tui`. It is the 746 + frontend stream: every frontend (the built-in TUI in-process, §8; any RPC747 + client out-of-process, §10.4) consumes `EngineEvent` and submits intents back.748 + Some variants — TUI-internal UI state changes — are in-process-frontend-private749 + and are not exposed out-of-process.747 751 ### 6.4 Hooks ### 6.4 Hooks 1288 1292 `smith-tui` owns terminal primitives, normalized events, widgets, themes, and`smith-tui` owns terminal primitives, normalized events, widgets, themes, and1289 1293 render loop. It depends only on `smith`.render loop. It depends only on `smith`.
1295 + **Frontend boundary.** `smith-tui` is the built-in *in-process frontend* — one1296 + consumer of the `EngineEvent` stream (§6.3) that renders it and feeds intents1297 + (prompt submit, steer, command, abort) back. It is not privileged as *the* UI:1298 + the same event-out/intent-in surface is exposed out-of-process by `smith rpc`1299 + (§10.4), which is the canonical boundary for additional frontends (web, native,1300 + mobile). Those are RPC clients and link no smith Rust code. The render model1301 + below — cells, borders, ratatui `Rect`s — is deliberately terminal-specific and1302 + is **not** a cross-UI abstraction: a browser or GPU frontend brings its own1303 + rendering and consumes only the event/intent surface, never smith's widgets.1291 1305 ### 8.1 Backend ### 8.1 Backend 1293 1307 Rendering uses:Rendering uses:2397 2411 client can answer block/allow/replace. A pure observer client that client can answer block/allow/replace. A pure observer client that2398 2412 registers nothing still needs the reverse channel for these. registers nothing still needs the reverse channel for these.2399 2413 - **A driver namespace has no §9.10 origin** and is RPC-only: `session/open`,- **A driver namespace has no §9.10 origin** and is RPC-only: `session/open`,2400 - `session/attach`, `session/list`, `session/dump`, `session/fork `,2401 - `session/subscribe`, `prompt/submit`, `command/run`. Lua never needs these 2402 - because a plugin already runs inside a live session; an RPC client must 2403 - drive one from outside.2414 + `session/attach`, `session/list`, `session/dump`, `session/snapshot `,2415 + `session/fork ` , ` session/ subscribe`, `prompt/submit`, `command/run`. Lua2416 + never needs these because a plugin already runs inside a live session; an RPC2417 + client must drive one from outside. `session/dump` returns persisted state2418 + (transcript, tree, leaf, folds); `session/snapshot` returns the *ephemeral*2419 + process state a live tail cannot replay — the steering/follow-up queue2420 + (§6.1) and in-flight run status — which a mid-session attach needs and which2421 + is never a session entry (prototype-proven, p28).2404 2422 - **Lua-runtime-only surfaces are omitted** in headless RPC: `tui`,- **Lua-runtime-only surfaces are omitted** in headless RPC: `tui`,2405 2423 `shortcut` (no terminal, no keyboard). `shortcut` (no terminal, no keyboard).2407 2425 Framing (line-delimited JSON vs `Content-Length`) is an implementation choiceFraming (line-delimited JSON vs `Content-Length`) is an implementation choice2408 2426 settled when `smith rpc` is built.settled when `smith rpc` is built.
2428 + **RPC is the multi-frontend boundary.** An RPC client is a frontend peer of the2429 + built-in TUI (§8), so its event surface is an adapter over the `EngineEvent`2430 + stream (§6.3) — the same source the TUI consumes — not the plugin bridge2431 + (§9.8). It is an adapter, not a mirror, by three rules: non-blocking events2432 + project to notifications; blocking events (`tool_call`, `session_before_*`)2433 + project to server→client requests the client answers; and frontend-private2434 + `EngineEvent` variants (panel toggle, resize, selection/focus/scroll) are2435 + omitted. Prototype-proven sufficient for a full alternative UI (p28: a headless2436 + client reconstructed transcript, tools, steering queue, tree/leaf, model, cost,2437 + fold, and secret placeholders from the wire alone), subject to:2439 + - two notification payload guarantees the reconstruction depends on —2440 + `session_compact` carries the covered span `{summary_id, start, end}` (the2441 + fold is assembly-time and storage-invisible, §6.9), and `session_tree`2442 + carries `{id, parent, kind}` plus the leaf (branches are emergent, §6.5);2443 + - `session/snapshot` for mid-session attach, since the live notification tail2444 + has no replay and the steering queue + run status are ephemeral (above);2445 + - cost/context is poll-only via `getContextUsage` in v1 (no push event); a2446 + `context_usage` notification may be added if a live indicator warrants it.2448 + Secret plaintext never crosses the wire — only `smith:sec:N` placeholders and2449 + their labels (§6.7), tap-verified in p28.2410 2451 ## 11. Security Model ## 11. Security Model prototypes/PLAN.md Modified +413 / −0 text lines
1936 1936 §8.7 and §17.6. Spec issues: P1 resolution contract, P2 property target, P2§8.7 and §17.6. Spec issues: P1 resolution contract, P2 property target, P21937 1937 composition rules.composition rules.
1939 + ## Campaign 6 — Multi-frontend readiness 1941 + ## P28 — `p28-rpc-frontend-sufficiency` 1945 + - §8 frontend boundary / §10.4: `smith rpc` is the multi-frontend boundary; an1946 + RPC client is a frontend peer of the TUI, consuming an adapter over the1947 + `EngineEvent` stream (§6.3) — non-blocking → notifications, blocking →1948 + requests, frontend-private omitted.1949 + - Implicit sufficiency claim: a full alternative UI (web/native/mobile) can be1950 + built on the RPC surface alone.1954 + p24 proved the projection *mechanics*, not *sufficiency*. An `EngineEvent`1955 + variant may carry state a real frontend must render that is unreachable over1956 + the §10.4 surface — a completeness gap that would only surface when someone1957 + actually builds a web UI.1959 + ### Minimal artifact 1962 + p28-rpc-frontend-sufficiency/1963 + Cargo.toml (serde, serde_json)1967 + A mock engine emits the full `EngineEvent` stream over the RPC adapter during a1968 + scripted complete session; a headless mock frontend client (no smith-tui code,1969 + no Lua) consumes only the RPC surface and reconstructs everything a UI renders.1974 + cd prototypes/p28-rpc-frontend-sufficiency1975 + cargo run -- classify1976 + cargo run -- reconstruct1977 + cargo run -- blocking-roundtrip1983 + - `classify`: every `EngineEvent` variant (§6.2 AgentEvent + §6.3 harness1984 + events: session lifecycle, steering/follow-up, UI-state, provider/model1985 + change, error, shutdown) tagged `notification` / `request` /1986 + `frontend-private-omitted` / `MISSING`; the MISSING set is the finding,1987 + - `reconstruct`: a scripted session (turns, streaming text/thinking deltas,1988 + tool calls incl. a blocking `tool_call`, steering queue, compaction/fold,1989 + leaf switch/tree, secret placeholders, model change, error) drives the mock1990 + client, whose reconstructed UI state (transcript, tool views, steering queue,1991 + leaf/tree, cost/context, active model) deep-equals the engine's ground truth,1992 + built from the RPC stream ALONE,1993 + - `blocking-roundtrip`: a blocking `tool_call` reaches the client as a request1994 + and the client's reply flows back into the engine,1995 + - verdict: the RPC surface is sufficient for a full frontend, or the exact1996 + MISSING variants/state are listed.2000 + Upgrade the §10.4 completeness claim from p28-gated to proven, or add the2001 + missing driver methods / event projections the spike finds.2005 + Status: complete. Proved: a headless client reconstructs a full session's2006 + `UiState` (transcript with reassembled deltas, tool views, steering queue,2007 + tree/leaf, model, cost, fold, secret labels) deep-equal to ground truth from2008 + the RPC stream alone; 34 EngineEvent variants classify as 25 notification / 42009 + request / 5 frontend-private; blocking `tool_call` round-trips; secret2010 + plaintext never crosses the wire. **Disproved**: the sufficiency claim for2011 + mid-session ATTACH — the live tail has no replay, so a late client cannot2012 + rebuild the ephemeral steering queue + run status (never a session entry;2013 + `session/dump` covers persisted state only). Folded into §10.4: added2014 + `session/snapshot`, two notification payload guarantees (`session_compact`2015 + span, `session_tree` node), poll-only cost/context for v1. Spec issues: P22016 + session/snapshot, P2 payload guarantees, P3 cost/context push.2018 + ## Campaign 7 — external integration surface 2020 + The internal architecture is heavily validated; the least-tested claims are the2021 + external boundaries — real provider wire formats, tool mutation semantics,2022 + OAuth, cross-platform builds, and the arch-gate tooling. Ranked by2023 + spec-impact × uncertainty. p29/p31/p33 are environment-feasible; p30/p32 are2024 + tooling-gated (need a release/CI toolchain) and are attempted where possible.2026 + ## P29 — `p29-provider-streaming` 2030 + - §7.1/§7.2: required providers (Anthropic, OpenAI, Google, OpenAI-compatible)2031 + normalize vendor wire formats into `ProviderEvent` (§5.2); quirks handled at2032 + 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.2039 + Each provider's streaming shape differs (Anthropic content-block events, OpenAI2040 + delta chunks, Google candidates); normalizing all into one `ProviderEvent`2041 + sequence, assembling split tool-call JSON, and preserving thinking signatures2042 + is unvalidated for the current provider set (only pre-consolidation MiniMax was).2044 + ### Minimal artifact 2047 + p29-provider-streaming/2048 + Cargo.toml (serde, serde_json)2049 + fixtures/anthropic.sse fixtures/openai.sse fixtures/google.sse2050 + fixtures/anthropic-error-200.json (non-SSE error body)2054 + Realistic hand-authored fixtures of each provider's streaming bytes (no2055 + network). A per-provider normalizer parses them into a `Vec<ProviderEvent>`.2060 + cd prototypes/p29-provider-streaming2061 + cargo run -- anthropic2064 + cargo run -- tool-call-assembly2065 + cargo run -- error-detection2066 + cargo run -- thinking-roundtrip2072 + - 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 one2075 + complete `ToolCall`,2076 + - a non-SSE JSON error body returned with HTTP 200 becomes2077 + `ProviderEvent::Error`, not a hang,2078 + - a thinking block with a provider signature survives as2079 + `provider_metadata` and replays on a follow-up request,2080 + - report any provider shape §7.2's quirk list does not cover.2084 + Tighten §7.2 with the concrete per-provider normalization rules and any quirk2085 + the fixtures expose.2087 + ## P31 — `p31-edit-write-tool` 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 exact2093 + matches (zero fails, multiple fails unless `allow_multiple`) → re-read+hash2094 + before write → fail `ESTALE` if changed → write atomically → return change2095 + 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.2101 + The stale-hash race (re-read between match and write) and the exact error-code2102 + taxonomy are subtle and unvalidated; p07 only mocked tools. Atomic rename must2103 + hold on same-filesystem temp.2105 + ### Minimal artifact 2108 + p31-edit-write-tool/2109 + Cargo.toml (sha2; std only otherwise)2113 + Real files in temp dirs; drive `write`/`edit` against them.2118 + cd prototypes/p31-edit-write-tool2119 + cargo run -- write-atomic2120 + cargo run -- edit-happy2121 + cargo run -- edit-errors2122 + cargo run -- edit-stale-race2123 + cargo run -- parallel-abort2129 + - write: temp+rename is atomic (a crash between leaves either old or new, never2130 + partial — simulate by asserting no partial file); parent dirs created,2131 + - edit: happy path returns change count + before/after hashes; each error code2132 + 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 stops2135 + cleanly and leaves no half-written file.2139 + Confirm or refine the §9.12 edit algorithm ordering and the stale/atomic2140 + guarantees under real filesystem semantics.2142 + ## P33 — `p33-oauth-flow` 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 HTTP2148 + server on a random port (or manual paste), exchanges it for2149 + `{access_token, refresh_token, expires_at}`, persists to `auth.json`,2150 + auto-refreshes on expiry.2154 + The callback-server + exchange + refresh flow (state/PKCE, random-port bind,2155 + redirect capture, refresh timing) is fiddly and unvalidated.2157 + ### Minimal artifact 2161 + Cargo.toml (serde, serde_json; std TcpListener for both servers)2165 + A mock OAuth provider (std `TcpListener`) plays authorize + token endpoints; the2166 + client runs the §7.4 flow end to end, no external network.2171 + cd prototypes/p33-oauth-flow2173 + cargo run -- callback-capture2174 + cargo run -- refresh2175 + cargo run -- persist2181 + - 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, exchange2184 + - `state` mismatch is rejected,2185 + - an expired `access_token` triggers a refresh using `refresh_token`; a revoked2186 + refresh surfaces a clear auth error,2187 + - tokens persist to and reload from the `auth.json` shape (§7.4).2191 + Pin any §7.4 OAuth detail the flow exposes (state/PKCE requirement, callback2192 + timeout, refresh-ahead-of-expiry window).2194 + ## P30 — `p30-cross-build` (tooling-gated) 2198 + §14: `cargo run -p xtask -- release` cross-builds all targets via2199 + cargo-zigbuild — windows-msvc, apple-silicon, linux gnu/musl (x86_64 + arm64).2203 + The heavy C tree (vendored LuaJIT, aws-lc-sys via cmake, jj-lib's gix/prost)2204 + cross-compiled to Windows/musl is a real "does it even build" unknown, like p172205 + and p26 — and could force dependency or feature changes.2207 + ### Verify (attempt where tooling allows) 2209 + Install `cargo-zigbuild` + `zig`; attempt `cargo zigbuild --target2210 + x86_64-unknown-linux-musl` and `aarch64-unknown-linux-musl` on a minimal bin2211 + pulling mlua(vendored) + aws-lc + gix. Report per-target build success/failure2212 + and the first blocking C/link error. If zig/targets are unavailable, report2213 + BLOCKED with what a release environment must provide.2217 + Confirm §14's target list is buildable, or record the per-target blockers /2218 + feature changes needed.2220 + ## P32 — `p32-arch-gate` (tooling-gated) 2224 + §11 / PROJECT-INVARIANTS §11: `cargo run -p xtask -- pup` on pinned nightly2225 + enforces the forbidden inter-crate dependency rules (e.g. `smith-core` must not2226 + depend on `smith-ai`).2230 + The whole architecture gate bets on cargo-pup expressing these rules; if it2231 + cannot, §11 enforcement is vapor and needs a different mechanism.2233 + ### Verify (attempt where tooling allows) 2235 + On the pinned nightly, install `cargo_pup`; author a rule expressing a §112236 + forbidden edge over a tiny 3-crate workspace; prove it PASSES a legal graph and2237 + FAILS an illegal one. If the nightly/tool is unavailable, report BLOCKED and2238 + whether `cargo run -p xtask -- arch` (stable metadata check) can enforce the2239 + same rules as a fallback.2243 + Confirm cargo-pup enforces §11, or fall back the arch gate to the stable2244 + metadata check and record it.1939 2246 ## Reporting Template ## Reporting Template 1941 2248 Each completed prototype updates this plan with a result block in theEach completed prototype updates this plan with a result block in the1942 2249 Markdown shape required by `prototypes/CLAUDE.md` (canonical:Markdown shape required by `prototypes/CLAUDE.md` (canonical:1943 2250 `.claude/skills/pioneer/SKILL.md`). Result blocks recorded before`.claude/skills/pioneer/SKILL.md`). Result blocks recorded before1944 2251 2026-07-16 use the earlier JSON shape and stand as historical records.2026-07-16 use the earlier JSON shape and stand as historical records.
2253 + ## Result — P34 `p34-ci-pipeline` (2026-07-17) 2255 + CI stood up on GitHub Actions to un-gate the two tooling-gated Campaign 72256 + claims. Run: bugabinga/smith actions run 29595424305, all six jobs green.2262 + - **§14 cross-build**: a bin pulling the two heaviest native trees — vendored2263 + LuaJIT (`mlua`) and `gix` — cross-compiles cleanly via `cargo-zigbuild` to2264 + `x86_64-unknown-linux-musl` (~73s), `aarch64-unknown-linux-musl` (~76s), and2265 + `x86_64-pc-windows-gnu` (~121s), and builds+runs natively on `ubuntu-latest`2266 + (~71s), `macos-latest` (~62s), and `windows-latest`/msvc (~218s). The §142267 + required matrix is buildable for the LuaJIT+gix trees; zig covers the2268 + linux/windows-gnu cross, native runners cover msvc/darwin.2269 + - **§11 arch-gate (stable path)**: the `cargo metadata` gate PASSES the legal2270 + 3-crate graph and FAILS the moment a forbidden `wcore -> wai` edge is injected2271 + (`ARCH VIOLATION: wcore -> wai is forbidden by §11`). §11 has a working2272 + enforcement path on plain stable, no nightly required.2273 + - **§17.10 hermeticity / §13.1 cold build**: a clean runner cold-builds and2274 + tests all 28 prototype crates in ~9m46s (ubuntu-latest, 2 vCPU) with no TTY2275 + and no network — the first real seed for the cold-build sub-budget.2278 + - Nothing in the spec. An earlier draft of this block claimed cargo-pup was2279 + unpublished; that was a defect in this prototype's recipe, not the spec —2280 + see the correction below. §3.5's two-gate design stands.2282 + ### Correction (recipe bug, not a spec defect) 2283 + - The first arch-gate run reported `cargo install cargo-pup` "not in registry".2284 + Root cause: the crate is published by DataDog as **`cargo_pup`** (underscore);2285 + `cargo install` matches the name literally and does not normalize the hyphen2286 + the way `Cargo.toml` dependency resolution does, so `cargo-pup` (hyphen) was2287 + "not found". Secondary cause: the source gate needs2288 + `rust-src rustc-dev llvm-tools-preview` on `nightly-2026-01-22` (it links2289 + rustc internals), which the minimal nightly lacked.2290 + - Re-run (run 29633526704, arch-gate job) with the corrected recipe: cargo_pup2291 + **v0.1.8 downloaded from crates.io, built in 47s, installed `cargo-pup` +2292 + `pup-driver`**, and `cargo +nightly-2026-01-22 pup` ran against the workspace.2293 + So §3.5/§11/§15 are correct as written; **cargo_pup stays, no demotion.**2296 + rustup toolchain install nightly-2026-01-22 --profile minimal2297 + rustup component add --toolchain nightly-2026-01-22 rust-src rustc-dev llvm-tools-preview2298 + cargo +nightly-2026-01-22 install cargo_pup --locked 2300 + - Two things the re-run also nailed down, both matters for the fixture, not the2302 + 1. The real `pup.ron` top-level struct is **`LintBuilder`**, not the `Pup(..)`2303 + this prototype guessed (`Expected struct LintBuilder but found Pup`).2304 + 2. `pup print-modules` on the 3-crate fixture emits **`unknown_crate`** —2305 + exactly the §3.5-documented caveat that pup synthesizes `unknown_crate`2306 + for crates with no child `mod` items. The trivial single-file crates are2307 + too structureless for pup's module matcher; a real enforcement proof needs2308 + crates with genuine module structure and a source-level import to catch.2309 + So cargo_pup is proven installable and runnable; proving it *enforces* the2310 + §11 edge is still open, blocked only on a richer fixture + a `LintBuilder`2311 + config, not on the tool or the spec.2314 + - `docs/SPEC.md §14`2315 + - Issue: cross-build is proven only for the LuaJIT+gix trees. `jj-lib`2316 + (+ prost) and the `aws-lc`/reqwest-TLS tree named in §13.1/P30's risk were2317 + NOT in the cross bin and remain unproven under cross-compilation.2318 + - Evidence: p34-ci-pipeline/cross/Cargo.toml pulls mlua+gix only.2320 + - `prototypes/.cargo/config.toml (§18)`2321 + - Issue: the prototype cap-lints=warn exemption is resolved by working2322 + directory, not by `--manifest-path`. A prototype built from the repo root2323 + (or by any tool passing `--manifest-path` from outside `prototypes/`)2324 + inherits the production `-D warnings`/`-D missing_docs` policy and fails.2325 + - Evidence: identical `-D missing_docs` failure on all three OS runners in the2326 + first run; reproduced locally (errors via `--manifest-path` from root, warns2327 + when CWD is under prototypes/). Fixed by building from inside the tree.2330 + ### Prototype Artifacts 2331 + - `prototypes/p34-ci-pipeline/NOTES.md`2332 + - `prototypes/p34-ci-pipeline/cross/` (mlua+gix cross bin)2333 + - `prototypes/p34-ci-pipeline/archgate/` (3-crate workspace, `gate.py`, `pup.ron`)2334 + - `.github/workflows/ci-prototype.yml` (temporary)2337 + - `git push` → GitHub Actions run 29595424305 (push trigger)2338 + - cross: `cargo zigbuild --target {x86_64,aarch64}-unknown-linux-musl`,2339 + `--target x86_64-pc-windows-gnu`2340 + - native: `cargo run` on ubuntu/macos/windows runners2341 + - arch: `python3 gate.py` (pass), inject edge → `python3 gate.py` (fail)2344 + - (Deferred by owner 2026-07-18 — "pup works" accepted; reopen only if the2345 + source-level rules become load-bearing.) Close the pup enforcement proof:2346 + give the archgate crates real module2347 + structure (so pup sees `wcore`/`wai` instead of `unknown_crate`), add a2348 + source-level `use wai::...` in wcore for the illegal case, write a2349 + `LintBuilder` pup.ron with a `restrict_imports` rule per §3.5's2350 + `^crate($|::.*)` guidance, and prove pup PASSES the legal graph and FAILS the2351 + illegal one. Keep the stable metadata gate as the always-on companion (§3.52352 + already specifies both). No spec change.2353 + - Extend the cross bin with `jj-lib` and the TLS/aws-lc tree to close the P302354 + gap, or accept it as a release-time risk.2355 + - Split standing prototype CI (`prototypes.yml`, evidence bit-rot guard) from2356 + the p34-specific cross/arch evidence (`ci-prototype.yml`, path-scoped).2357 + deleted now that its evidence is recorded.prototypes/p28-rpc-frontend-sufficiency/Cargo.lock Added new file mode 100644+107 / −0 text lines
8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" 14 + source = "registry+https://github.com/rust-lang/crates.io-index" 15 + checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" 18 + name = "p28-rpc-frontend-sufficiency" 28 + source = "registry+https://github.com/rust-lang/crates.io-index" 29 + checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" 37 + source = "registry+https://github.com/rust-lang/crates.io-index" 38 + checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" 46 + source = "registry+https://github.com/rust-lang/crates.io-index" 47 + checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" 56 + source = "registry+https://github.com/rust-lang/crates.io-index" 57 + checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" 65 + source = "registry+https://github.com/rust-lang/crates.io-index" 66 + checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" 76 + source = "registry+https://github.com/rust-lang/crates.io-index" 77 + checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" 89 + source = "registry+https://github.com/rust-lang/crates.io-index" 90 + checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" 98 + name = "unicode-ident" 100 + source = "registry+https://github.com/rust-lang/crates.io-index" 101 + checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" 106 + source = "registry+https://github.com/rust-lang/crates.io-index" 107 + checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" prototypes/p28-rpc-frontend-sufficiency/Cargo.toml Added new file mode 100644+9 / −0 text lines
2 + name = "p28-rpc-frontend-sufficiency" 8 + serde = { version = "1" , features = ["derive" ] }prototypes/p28-rpc-frontend-sufficiency/src/main.rs Added new file mode 100644+1222 / −0 text lines
24 + use serde_json::{json, Value};25 + use std::collections::HashMap;26 + use std::sync::atomic::{AtomicU64, Ordering};27 + use std::sync::mpsc::{channel, Receiver, Sender};28 + use std::sync::{Arc, Mutex};42 + #[derive(Debug, Clone)]48 + type Handler = Arc<dyn Fn (& Arc<Endpoint>, &str , Value) -> Result <Value, RpcError> + Send + Sync >;49 + type NotifySink = Arc<dyn Fn (& Arc<Endpoint>, &str , Value) + Send + Sync >;50 + type Tap = Arc<Mutex<Vec <String >>>;53 + out: Mutex<Sender<String >>,55 + pending: Mutex<HashMap<u64 , Sender<Result <Value, RpcError>>>>,60 + fn new (out: Sender<String >, tap: Option <Tap>) -> Arc<Self > {62 + out: Mutex::new(out),63 + next_id: AtomicU64::new(1 ),64 + pending: Mutex::new(HashMap::new()),69 + fn start (self: & Arc<Self >, inbound: Receiver<String >, handler: Handler, notify: NotifySink) {70 + let ep = self.clone ();71 + thread::spawn(move || {72 + for line in inbound {73 + let msg: Value = match serde_json::from_str(& line) {77 + if msg.get ("method" ).is_some () {78 + let method = msg["method" ].as_str ().unwrap_or ("" ).to_string ();79 + let params = msg.get ("params" ).cloned ().unwrap_or (Value::Null);80 + match msg.get ("id" ).and_then (Value::as_u64) {82 + let ep2 = ep.clone ();83 + let h = handler.clone ();84 + thread::spawn(move || {85 + let res = h (& ep2, & method, params);86 + ep2.send_response (id, res);89 + None => notify (& ep, & method, params),91 + } else if let Some (id) = msg.get ("id" ).and_then (Value::as_u64) {92 + let res = match msg.get ("error" ) {93 + Some (err) => Err (RpcError {94 + code: err.get ("code" ).and_then (Value::as_i64).unwrap_or (- 1 ),97 + .and_then (Value::as_str)101 + None => Ok (msg.get ("result" ).cloned ().unwrap_or (Value::Null)),103 + if let Some (tx) = ep.pending.lock ().unwrap ().remove (& id) {104 + let _ = tx.send (res);111 + fn call (& self, method: &str , params: Value) -> Result <Value, RpcError> {112 + let id = self.next_id.fetch_add (1 , Ordering::SeqCst);113 + let (tx, rx) = channel ();114 + self.pending.lock ().unwrap ().insert (id, tx);115 + self.send (json! ({"jsonrpc" : "2.0" , "id" : id, "method" : method, "params" : params}));116 + rx.recv ().unwrap_or (Err (RpcError {118 + message: "transport closed" .into (),122 + fn notify (& self, method: &str , params: Value) {123 + self.send (json! ({"jsonrpc" : "2.0" , "method" : method, "params" : params}));126 + fn send_response (& self, id: u64 , res: Result <Value, RpcError>) {127 + let msg = match res {128 + Ok (v) => json! ({"jsonrpc" : "2.0" , "id" : id, "result" : v}),130 + json! ({"jsonrpc" : "2.0" , "id" : id, "error" : {"code" : e.code, "message" : e.message}})136 + fn send (& self, v: Value) {137 + let line = v.to_string ();138 + if let Some (t) = & self.tap {139 + t.lock ().unwrap ().push (line.clone ());141 + let _ = self.out.lock ().unwrap ().send (line);150 + #[derive(Clone, Copy, PartialEq, Eq)]161 + fn tag (& self) -> &'static str {163 + Shape::Notification => "notification" ,164 + Shape::Request => "request" ,165 + Shape::PrivateOmitted => "frontend-private-omitted" ,173 + fn project (method: &str ) -> Shape {177 + | "session_before_switch" 178 + | "session_before_fork" 179 + | "session_before_compact" => Shape::Request,181 + "panel_toggle" | "resize" | "ui_selection" | "ui_focus" | "ui_scroll" => {182 + Shape::PrivateOmitted185 + _ => Shape::Notification,195 + #[derive(Serialize, PartialEq, Clone, Debug, Default)]201 + #[derive(Serialize, PartialEq, Clone, Debug)]212 + #[derive(Serialize, PartialEq, Clone, Debug)]218 + #[derive(Serialize, PartialEq, Clone, Debug)]226 + #[derive(Serialize, PartialEq, Clone, Debug, Default)]230 + total_cost_micros: u64 ,233 + #[derive(Serialize, PartialEq, Clone, Debug, Default)]239 + #[derive(Serialize, PartialEq, Clone, Debug, Default)]242 + parent: Option <String >,246 + #[derive(Serialize, PartialEq, Clone, Debug, Default)]248 + transcript: Vec <Msg>,249 + tools: Vec <ToolView>,250 + queue: Vec <QueueItem>,251 + tree: Vec <TreeNode>,254 + secret_labels: Vec <(u64 , String)>,260 + errors: Vec <String >,264 + fn tool_mut (&mut self, id: &str ) -> Option <&mut ToolView> {265 + self.tools.iter_mut ().find (|t| t.id == id)277 + state: Mutex<UiState>,279 + streaming: Mutex<HashMap<String , (String, String)>>,280 + blocking_replies: Mutex<Vec <(String, Value)>>, 284 + fn new (window: u64 ) -> Arc<Self > {285 + let mut st = UiState::default();286 + st.context.window = window;288 + state: Mutex::new(st),289 + streaming: Mutex::new(HashMap::new()),290 + blocking_replies: Mutex::new(Vec ::new()),295 + fn on_notification (& self, method: &str , p: Value) {296 + let mut s = self.state.lock ().unwrap ();298 + "message_start" => {299 + let id = p["id" ].as_str ().unwrap_or ("" ).to_string ();300 + let role = p["role" ].as_str ().unwrap_or ("assistant" ).to_string ();301 + self.streaming.lock ().unwrap ().insert (id, (role, String ::new()));304 + let id = p["id" ].as_str ().unwrap_or ("" );305 + if let Some (acc) = self.streaming.lock ().unwrap ().get_mut (id) {306 + acc.1. push_str (p["text" ].as_str ().unwrap_or ("" ));309 + "thinking_delta" => {310 + let id = p["id" ].as_str ().unwrap_or ("" );311 + let mut stream = self.streaming.lock ().unwrap ();313 + .entry (format! ("think:{id}" ))314 + .or_insert_with (|| ("thinking" .to_string (), String ::new()));315 + acc.1. push_str (p["text" ].as_str ().unwrap_or ("" ));318 + let id = p["id" ].as_str ().unwrap_or ("" );320 + if let Some ((role, text)) = self.streaming.lock ().unwrap ().remove (& format! ("think:{id}" )) {321 + s.transcript.push (Msg { role, text });323 + if let Some ((role, text)) = self.streaming.lock ().unwrap ().remove (id) {324 + s.transcript.push (Msg { role, text });327 + "tool_execution_start" => {328 + s.tools.push (ToolView {329 + id: p["id" ].as_str ().unwrap_or ("" ).to_string (),330 + name: p["name" ].as_str ().unwrap_or ("" ).to_string (),331 + input: p.get ("input" ).cloned ().unwrap_or (Value::Null),332 + status: "running" .into (),333 + output: String ::new(),338 + "tool_execution_update" => {339 + let id = p["id" ].as_str ().unwrap_or ("" ).to_string ();340 + if let Some (t) = s.tool_mut (& id) {341 + t.progress = p["progress" ].as_u64 ().unwrap_or (0 );344 + "tool_execution_end" => {345 + let id = p["id" ].as_str ().unwrap_or ("" ).to_string ();346 + let out = p["output" ].as_str ().unwrap_or ("" ).to_string ();347 + let err = p["is_error" ].as_bool ().unwrap_or (false );348 + if let Some (t) = s.tool_mut (& id) {349 + t.status = "done" .into ();355 + let node = & p["node" ];356 + s.tree.push (TreeNode {357 + id: node["id" ].as_str ().unwrap_or ("" ).to_string (),358 + parent: node["parent" ].as_str ().map (|x| x.to_string ()),359 + kind: node["kind" ].as_str ().unwrap_or ("" ).to_string (),361 + if let Some (l) = p["leaf" ].as_str () {362 + s.leaf = l.to_string ();366 + if let Some (l) = p["leaf" ].as_str () {367 + s.leaf = l.to_string ();370 + "session_compact" => {372 + summary_id: p["summary_id" ].as_str ().unwrap_or ("" ).to_string (),373 + start: p["start" ].as_str ().unwrap_or ("" ).to_string (),374 + end: p["end" ].as_str ().unwrap_or ("" ).to_string (),375 + outcome: p["outcome" ].as_str ().unwrap_or ("" ).to_string (),378 + "secret_registered" => {379 + let id = p["id" ].as_u64 ().unwrap_or (0 );380 + let label = p["label" ].as_str ().unwrap_or ("" ).to_string ();381 + s.secret_labels.push ((id, label));383 + "steer_enqueue" => s.queue.push (QueueItem {384 + kind: "steer" .into (),385 + text: p["text" ].as_str ().unwrap_or ("" ).to_string (),387 + "followup_enqueue" => s.queue.push (QueueItem {388 + kind: "followup" .into (),389 + text: p["text" ].as_str ().unwrap_or ("" ).to_string (),391 + "steer_deliver" | "followup_deliver" => {392 + let text = p["text" ].as_str ().unwrap_or ("" );393 + if let Some (pos) = s.queue.iter ().position (|q| q.text == text) {394 + s.queue.remove (pos);398 + if let Some (m) = p["model" ].as_str () {399 + s.model = m.to_string ();401 + if let Some (pr) = p["provider" ].as_str () {402 + s.provider = pr.to_string ();405 + "error" => s.errors.push (p["message" ].as_str ().unwrap_or ("" ).to_string ()),407 + "agent_start" | "agent_end" | "turn_start" | "turn_end" | "message_update" 408 + | "session_open" | "session_fork" | "shutdown" => {}416 + fn on_request (& self, method: &str , p: Value) -> Result <Value, RpcError> {417 + let reply = match method {418 + "tool_call" => json! ({ "block" : false }),419 + "session_before_switch" | "session_before_fork" | "session_before_compact" => {420 + json! ({ "block" : false })423 + return Err (RpcError {425 + message: format! ("client answers no blocking method {other}" ),429 + self.blocking_replies432 + .push ((method.to_string (), p));437 + fn refresh_usage (& self, ep: & Endpoint) {438 + if let Ok (v) = ep.call ("getContextUsage" , Value::Null) {439 + let mut s = self.state.lock ().unwrap ();440 + s.cost.input_tokens = v["input_tokens" ].as_u64 ().unwrap_or (0 );441 + s.cost.output_tokens = v["output_tokens" ].as_u64 ().unwrap_or (0 );442 + s.cost.total_cost_micros = v["total_cost_micros" ].as_u64 ().unwrap_or (0 );443 + s.context.used = v["context_used" ].as_u64 ().unwrap_or (0 );444 + s.context.window = v["context_window" ].as_u64 ().unwrap_or (s.context.window);450 + fn attach_snapshot (& self, ep: & Endpoint) -> bool {451 + match ep.call ("session/snapshot" , Value::Null) {453 + let mut s = self.state.lock ().unwrap ();454 + s.queue = v["queue" ]458 + .map (|q| QueueItem {459 + kind: q["kind" ].as_str ().unwrap_or ("" ).to_string (),460 + text: q["text" ].as_str ().unwrap_or ("" ).to_string (),464 + .unwrap_or_default ();483 + secrets: Vec <(u64 , String, String)>, 484 + turn_input_tokens: u64 ,485 + open_msg_id: Option <String >,489 + fn new (server: Arc<Endpoint>, window: u64 ) -> Self {490 + let mut truth = UiState::default();491 + truth.context.window = window;498 + secrets: Vec ::new(),499 + turn_input_tokens: 0 ,507 + fn emit (& self, method: &str , params: Value) -> Option <Value> {508 + match project (method) {509 + Shape::Notification => {510 + self.ep.notify (method, params);513 + Shape::Request => match self.ep.call (method, params) {515 + Err (_ ) => Some (json! ({"block" : false })),517 + Shape::PrivateOmitted => None , 521 + fn next_entry (&mut self, kind: &str ) -> String {523 + let id = format! ("e{}" , self.entry_no);524 + let parent = self.truth.tree.last ().map (|n| n.id.clone ());525 + self.truth.tree.push (TreeNode {527 + parent: parent.clone (),528 + kind: kind.to_string (),530 + self.truth.leaf = id.clone ();533 + json! ({"node" : {"id" : id, "parent" : parent, "kind" : kind}, "leaf" : id}),539 + fn mask (& self, text: &str ) -> String {542 + let mut secrets = self.secrets.clone ();543 + secrets.sort_by_key (|(_, pt, _)| std::cmp::Reverse(pt.len ()));544 + let mut out = text.to_string ();545 + for (id, pt, _ ) in secrets {546 + out = out.replace (& pt, & format! ("smith:sec:{id}" ));551 + fn charge (&mut self, input: u64 , output: u64 ) {552 + self.turn_input_tokens += input;553 + self.truth.cost.input_tokens += input;554 + self.truth.cost.output_tokens += output;556 + self.truth.cost.total_cost_micros += input + output;557 + self.truth.context.used = self.truth.cost.input_tokens + self.truth.cost.output_tokens;562 + fn open (&mut self, model: &str , provider: &str ) {563 + self.truth.model = model.to_string ();564 + self.truth.provider = provider.to_string ();565 + self.emit ("session_open" , json! ({"session_id" : "01HSESSP28" }));566 + self.emit ("model_select" , json! ({"model" : model, "provider" : provider}));567 + self.emit ("agent_start" , Value::Null);570 + fn user_says (&mut self, text: &str ) {571 + self.emit ("turn_start" , Value::Null);572 + let masked = self.mask (text);573 + self.truth.transcript.push (Msg {574 + role: "user" .into (),575 + text: masked.clone (),578 + let id = format! ("m{}" , self.msg_no);579 + self.emit ("message_start" , json! ({"id" : id, "role" : "user" }));580 + self.emit ("text_delta" , json! ({"id" : id, "text" : masked}));581 + self.emit ("message_end" , json! ({"id" : id}));582 + self.next_entry ("user" );583 + self.charge (text.len () as u64 / 4 + 1 , 0 );586 + fn assistant_thinks (&mut self, chunks: & [&str ]) {588 + let id = format! ("m{}" , self.msg_no);589 + self.emit ("message_start" , json! ({"id" : id, "role" : "assistant" }));590 + let mut think = String ::new();592 + let m = self.mask (c);594 + self.emit ("thinking_delta" , json! ({"id" : id, "text" : m}));596 + self.truth.transcript.push (Msg {597 + role: "thinking" .into (),601 + self.open_msg_id = Some (id);604 + fn assistant_says (&mut self, chunks: & [&str ]) {606 + let id = self.open_msg_id.take ().unwrap_or_else (|| {608 + let id = format! ("m{}" , self.msg_no);609 + self.emit ("message_start" , json! ({"id" : id, "role" : "assistant" }));612 + let mut text = String ::new();614 + let m = self.mask (c);616 + self.emit ("text_delta" , json! ({"id" : id, "text" : m}));618 + self.truth.transcript.push (Msg {619 + role: "assistant" .into (),622 + self.emit ("message_end" , json! ({"id" : id}));623 + self.next_entry ("assistant" );629 + fn tool (&mut self, id: &str , name: &str , input: Value, output: &str , blocking: bool ) -> bool {630 + let masked_out = self.mask (output);633 + .emit ("tool_call" , json! ({"id" : id, "name" : name, "input" : input}))634 + .unwrap_or (json! ({"block" : false }));635 + if reply["block" ].as_bool ().unwrap_or (false ) {637 + self.truth.tools.push (ToolView {640 + input: input.clone (),641 + status: "done" .into (),642 + output: reply["reason" ].as_str ().unwrap_or ("blocked" ).into (),646 + self.emit ("tool_execution_start" , json! ({"id" : id, "name" : name, "input" : input}));648 + "tool_execution_end" ,649 + json! ({"id" : id, "output" : reply["reason" ].as_str ().unwrap_or ("blocked" ), "is_error" : true }),651 + self.next_entry ("tool_result" );655 + self.truth.tools.push (ToolView {658 + input: input.clone (),659 + status: "done" .into (),660 + output: masked_out.clone (),664 + self.emit ("tool_execution_start" , json! ({"id" : id, "name" : name, "input" : input}));665 + self.emit ("tool_execution_update" , json! ({"id" : id, "progress" : 50 }));666 + self.emit ("tool_execution_update" , json! ({"id" : id, "progress" : 100 }));668 + "tool_execution_end" ,669 + json! ({"id" : id, "output" : masked_out, "is_error" : false }),671 + self.next_entry ("tool_result" );672 + self.charge (output.len () as u64 / 4 + 1 , 0 );676 + fn enqueue_steer (&mut self, text: &str ) {677 + self.truth.queue.push (QueueItem {678 + kind: "steer" .into (),681 + self.emit ("steer_enqueue" , json! ({"text" : text}));684 + fn deliver_steer (&mut self, text: &str ) {685 + if let Some (pos) = self.truth.queue.iter ().position (|q| q.text == text) {686 + self.truth.queue.remove (pos);688 + self.emit ("steer_deliver" , json! ({"text" : text}));690 + self.truth.transcript.push (Msg {691 + role: "user" .into (),695 + let id = format! ("m{}" , self.msg_no);696 + self.emit ("message_start" , json! ({"id" : id, "role" : "user" }));697 + self.emit ("text_delta" , json! ({"id" : id, "text" : text}));698 + self.emit ("message_end" , json! ({"id" : id}));699 + self.next_entry ("user" );702 + fn compact (&mut self, start: &str , end: &str , outcome: &str ) {704 + self.emit ("session_before_compact" , json! ({"start" : start, "end" : end}));705 + let summary_id = self.next_entry ("compaction_summary" );706 + self.truth.folds.push (Fold {707 + summary_id: summary_id.clone (),708 + start: start.into (),710 + outcome: outcome.into (),715 + json! ({"summary_id" : summary_id, "start" : start, "end" : end, "outcome" : outcome}),719 + fn switch_leaf (&mut self, target: &str ) {721 + self.emit ("session_before_switch" , json! ({"target" : target}));724 + let sw_id = format! ("e{}" , self.entry_no);725 + let parent = self.truth.tree.last ().map (|n| n.id.clone ());726 + self.truth.tree.push (TreeNode {729 + kind: "leaf_switch" .into (),731 + self.truth.leaf = target.into ();732 + self.emit ("session_leaf" , json! ({"leaf" : target}));736 + json! ({"node" : {"id" : sw_id, "parent" : self.truth.tree[self.truth.tree.len ()- 1 ].parent, "kind" : "leaf_switch" }, "leaf" : target}),740 + fn register_secret (&mut self, plaintext: &str , label: &str ) -> u64 {741 + self.secret_no += 1 ;742 + let id = self.secret_no;743 + self.secrets.push ((id, plaintext.to_string (), label.to_string ()));744 + self.truth.secret_labels.push ((id, label.to_string ()));745 + self.next_entry ("secret_registration" );747 + self.emit ("secret_registered" , json! ({"id" : id, "label" : label}));751 + fn change_model (&mut self, model: &str , provider: &str ) {752 + self.truth.model = model.into ();753 + self.truth.provider = provider.into ();754 + self.next_entry ("model_change" );755 + self.emit ("model_select" , json! ({"model" : model, "provider" : provider}));758 + fn error (&mut self, message: &str ) {759 + self.truth.errors.push (message.into ());760 + self.emit ("error" , json! ({"message" : message}));763 + fn turn_end (&mut self) {764 + self.emit ("turn_end" , Value::Null);767 + fn shutdown (&mut self) {768 + self.emit ("agent_end" , Value::Null);769 + self.emit ("shutdown" , Value::Null);782 + Arc<Endpoint>, // client endpoint (to originate data-method calls)785 + let (c2s_tx, c2s_rx) = channel::<String >();786 + let (s2c_tx, s2c_rx) = channel::<String >();787 + let tap: Tap = Arc::new(Mutex::new(Vec ::new()));789 + let server = Endpoint::new(s2c_tx, Some (tap.clone ()));790 + let client_ep = Endpoint::new(c2s_tx, Some (tap.clone ()));792 + let engine = Arc::new(Mutex::new(Engine::new(server.clone (), window)));793 + let client = Client::new(window);796 + let eng_for_handler = engine.clone ();799 + Arc::new(move | _ep, method, params| server_data_method (& eng_for_handler, method, params)),800 + Arc::new(|_ep, _m, _p| {}),804 + let cl = client.clone ();805 + let cl2 = client.clone ();808 + Arc::new(move | _ep, method, params| cl.on_request (method, params)),809 + Arc::new(move | _ep, method, params| cl2.on_notification (method, params)),812 + (engine, client, client_ep, tap)816 + fn server_data_method (817 + engine: & Arc<Mutex<Engine>>,820 + ) -> Result <Value, RpcError> {821 + let e = engine.lock ().unwrap ();823 + "getContextUsage" => Ok (json! ({824 + "input_tokens" : e.truth.cost.input_tokens,825 + "output_tokens" : e.truth.cost.output_tokens,826 + "total_cost_micros" : e.truth.cost.total_cost_micros,827 + "context_used" : e.truth.context.used,828 + "context_window" : e.truth.context.window,831 + "session/snapshot" => Ok (json! ({832 + "queue" : e.truth.queue.iter ().map (|q| json! ({"kind" : q.kind, "text" : q.text})).collect::<Vec <_ >>(),833 + "leaf" : e.truth.leaf,834 + "model" : e.truth.model,836 + other => Err (RpcError {838 + message: format! ("method not found: {other}" ),843 + fn check (label: &str , cond: bool ) -> bool {844 + println! ("{} {label}" , if cond { "PASS" } else { "FAIL" });850 + thread::sleep(std::time::Duration::from_millis(40 ));858 + fn drive_full_session (engine: & Arc<Mutex<Engine>>) {859 + let mut e = engine.lock ().unwrap ();860 + e.open ("claude-opus-4" , "anthropic" );863 + e.user_says ("summarize the repo and run the linter" );866 + e.assistant_thinks (& ["let me " , "inspect the tree" ]);867 + e.assistant_says (& ["I'll read files " , "then lint." ]);870 + let sid = e.register_secret ("ghp_TOPSECRET_TOKEN_9000" , "github-token" );874 + e.tool ("call-1" , "read_file" , json! ({"path" : "Cargo.toml" }), "edition = 2021" , false );879 + json! ({"path" : ".env" }),880 + "TOKEN=ghp_TOPSECRET_TOKEN_9000" ,884 + e.tool ("call-3" , "run_shell" , json! ({"cmd" : "cargo clippy" }), "0 warnings" , true );889 + e.enqueue_steer ("also check formatting" );890 + e.enqueue_steer ("and fix imports" );891 + e.deliver_steer ("also check formatting" );894 + e.compact ("e1" , "e4" , "fit" );897 + e.switch_leaf ("e2" );900 + e.change_model ("claude-haiku-4" , "anthropic" );903 + e.error ("provider stream reset (retrying)" );906 + e.assistant_says (& ["done: 0 warnings, imports fixed." ]);911 + fn scn_reconstruct () -> bool {912 + let (engine, client, client_ep, tap) = wire (200_000 );913 + drive_full_session (& engine);916 + client.refresh_usage (& client_ep);919 + let truth = engine.lock ().unwrap ().truth.clone ();920 + let recon = client.state.lock ().unwrap ().clone ();924 + "reconstruct: transcript (streamed text + thinking deltas reassembled) equals ground truth" ,925 + truth.transcript == recon.transcript,928 + "reconstruct: tool call/result views equal ground truth (incl. blocked/approved)" ,929 + truth.tools == recon.tools,932 + "reconstruct: steering/follow-up queue snapshot equals ground truth" ,933 + truth.queue == recon.queue,936 + "reconstruct: current leaf + tree nodes equal ground truth" ,937 + truth.leaf == recon.leaf && truth.tree == recon.tree,940 + "reconstruct: compaction fold (summary + covered span) equals ground truth" ,941 + truth.folds == recon.folds && ! recon.folds.is_empty (),944 + "reconstruct: active model/provider equals ground truth" ,945 + truth.model == recon.model && truth.provider == recon.provider,948 + "reconstruct: secret labels (id→label) reconstructed for `‹secret: label›` rendering" ,949 + truth.secret_labels == recon.secret_labels && ! recon.secret_labels.is_empty (),952 + "reconstruct: cost/context indicators equal ground truth (pulled via getContextUsage)" ,953 + truth.cost == recon.cost && truth.context == recon.context && recon.cost.total_cost_micros > 0 ,956 + "reconstruct: error surface equals ground truth" ,957 + truth.errors == recon.errors && ! recon.errors.is_empty (),960 + "reconstruct: FULL UiState deep-equals ground truth built from the RPC stream ALONE" ,961 + serde_json::to_value(& truth).unwrap () == serde_json::to_value(& recon).unwrap (),969 + .any (|line| line.contains ("ghp_TOPSECRET_TOKEN_9000" ));971 + "reconstruct: secret plaintext never crossed the wire (only smith:sec:N placeholders)" ,974 + let saw_placeholder = tap978 + .any (|line| line.contains ("smith:sec:1" ));980 + "reconstruct: masked placeholder smith:sec:1 did cross the wire" ,992 + fn scn_blocking_roundtrip () -> bool {993 + let (engine, client, _ep, _tap) = wire (200_000 );995 + let mut e = engine.lock ().unwrap ();996 + e.open ("claude-opus-4" , "anthropic" );997 + e.user_says ("run the build" );999 + let executed = e.tool ("call-1" , "run_shell" , json! ({"cmd" : "cargo build" }), "ok" , true );1005 + let replies = client.blocking_replies.lock ().unwrap ();1007 + "blocking-roundtrip: client received tool_call as a server→client REQUEST" ,1008 + replies.iter ().any (|(m, _)| m == "tool_call" ),1012 + "blocking-roundtrip: client's allow reply flowed back; engine executed the tool" ,1019 + .any (|t| t.id == "call-1" && t.status == "done" && ! t.is_error),1023 + let (engine2, client2, _ep2, _tap2) = wire (200_000 );1030 + let mut e = engine2.lock ().unwrap ();1031 + e.open ("claude-opus-4" , "anthropic" );1037 + let reply = e.emit (1039 + json! ({"id" : "call-x" , "name" : "rm" , "input" : {"cmd" : "rm -rf /" }}),1042 + "blocking-roundtrip: engine received a structured reply for the blocking request" ,1043 + reply.map (|r| r.get ("block" ).is_some ()).unwrap_or (false ),1055 + fn scn_classify () -> bool {1057 + let variants: & [(&str , &str , &str )] = & [1059 + ("AgentStart" , "agent_start" , "run lifecycle; observers show 'running'" ),1060 + ("AgentEnd" , "agent_end" , "run lifecycle; observers show 'idle'" ),1061 + ("TurnStart" , "turn_start" , "turn lifecycle" ),1062 + ("TurnEnd" , "turn_end" , "turn lifecycle; a natural cost/context refresh point" ),1063 + ("MessageStart" , "message_start" , "opens a transcript message; carries role/id" ),1064 + ("MessageUpdate" , "message_update" , "message metadata update" ),1065 + ("MessageEnd" , "message_end" , "finalizes a transcript message" ),1066 + ("TextDelta" , "text_delta" , "streamed assistant text; reassembled by id" ),1067 + ("ThinkingDelta" , "thinking_delta" , "streamed reasoning; reassembled by id" ),1068 + ("ToolExecutionStart" , "tool_execution_start" , "opens a tool view" ),1069 + ("ToolExecutionUpdate" , "tool_execution_update" , "per-tool streaming progress" ),1070 + ("ToolExecutionEnd" , "tool_execution_end" , "closes a tool view with result" ),1071 + ("ToolCall (BLOCKING)" , "tool_call" , "§9.8 blockable → REQUEST; client answers allow/block/replace" ),1072 + ("Error" , "error" , "error surface" ),1074 + ("SessionOpen" , "session_open" , "session opened/loaded" ),1075 + ("SessionTree" , "session_tree" , "tree node created; carries {id,parent,kind}+leaf" ),1076 + ("SessionLeaf (switch)" , "session_leaf" , "leaf moved (tree navigation)" ),1077 + ("SessionBeforeSwitch (BLOCKING)" , "session_before_switch" , "§9.8 blockable → REQUEST" ),1078 + ("SessionFork" , "session_fork" , "fork completed → new session id" ),1079 + ("SessionBeforeFork (BLOCKING)" , "session_before_fork" , "§9.8 blockable → REQUEST" ),1080 + ("SessionCompact" , "session_compact" , "fold completed; MUST carry summary_id+covered span" ),1081 + ("SessionBeforeCompact (BLOCKING)" , "session_before_compact" , "§9.8 blockable → REQUEST" ),1082 + ("SecretRegistered" , "secret_registered" , "id+label only; plaintext never crosses (§6.7)" ),1084 + ("SteerEnqueue" , "steer_enqueue" , "queue grew (steer)" ),1085 + ("SteerDeliver" , "steer_deliver" , "queue drained (steer) → recorded as entry" ),1086 + ("FollowupEnqueue" , "followup_enqueue" , "queue grew (follow-up)" ),1087 + ("FollowupDeliver" , "followup_deliver" , "queue drained (follow-up)" ),1089 + ("ModelSelect" , "model_select" , "active model/provider changed" ),1090 + ("Shutdown" , "shutdown" , "engine shutting down" ),1092 + ("UiPanelToggle" , "panel_toggle" , "TUI-internal panel visibility" ),1093 + ("UiResize" , "resize" , "TUI-internal terminal resize" ),1094 + ("UiSelection" , "ui_selection" , "TUI-internal cursor/selection" ),1095 + ("UiFocus" , "ui_focus" , "TUI-internal focus" ),1096 + ("UiScroll" , "ui_scroll" , "TUI-internal scroll offset" ),1099 + println! ("-- EngineEvent classification (framing: line-delimited JSON-RPC 2.0) --" );1100 + let (mut n_note, mut n_req, mut n_priv) = (0 , 0 , 0 );1101 + for (variant, method, why) in variants {1102 + let tag = project (method).tag ();1103 + match project (method) {1104 + Shape::Notification => n_note += 1 ,1105 + Shape::Request => n_req += 1 ,1106 + Shape::PrivateOmitted => n_priv += 1 ,1108 + println! (" {variant:<34} {tag:<24} {why}" );1112 + " tally: notification={n_note} request={n_req} frontend-private-omitted={n_priv} (total {})" ,1118 + println! ("-- MISSING: state a real frontend must render, unreachable over the §10.4 surface --" );1119 + let missing: & [(&str , &str , &str )] = & [1121 + "queue snapshot on attach" ,1122 + "session/queue (or session/snapshot.queue)" ,1123 + "queues are ephemeral process state (§6.1); enqueue/deliver notifications track the queue only from empty. A frontend that ATTACHES to a live session (or reconnects after a drop) cannot fetch the current pending steers/follow-ups — no driver method returns them." ,1126 + "in-flight run status on attach" ,1127 + "session/status (or session/snapshot.run)" ,1128 + "AgentStart/TurnStart/ToolExecutionStart already fired before a late attach; there is no method to read 'a turn is active / tool call-3 is executing'. A reconnecting UI cannot show the current run state." ,1131 + "live cost/context indicator" ,1132 + "usage notification (e.g. context_usage event)" ,1133 + "cost/context is reachable ONLY by polling the getContextUsage data method — there is no push event, so a live ticking cost/context meter must poll. Reachable, but not from the stream." ,1136 + for (state, fix, why) in missing {1137 + println! (" MISSING {state}" );1138 + println! (" closes with: {fix}" );1139 + println! (" why: {why}" );1142 + println! ("-- projection guarantees the surface MUST make (else reconstruct FAILS) --" );1143 + println! (" session_compact MUST carry {{summary_id,start,end}} — the covered span (§6.9 fold" );1144 + println! (" is assembly-time, storage-invisible); without it the fold is unrenderable." );1145 + println! (" session_tree MUST carry the node {{id,parent,kind}} + leaf — else tree/leaf nav" );1146 + println! (" beyond the current leaf is unreachable (branches are emergent, §6.5)." );1152 + let (engine, client, client_ep, _tap) = wire (200_000 );1158 + let mut e = engine.lock ().unwrap ();1160 + e.truth.queue.push (QueueItem { kind: "steer" .into (), text: "first steer" .into () });1161 + e.truth.queue.push (QueueItem { kind: "steer" .into (), text: "second steer" .into () });1166 + let before = client.state.lock ().unwrap ().queue.clone ();1167 + let ok_gap = check (1168 + "classify: late-attach client CANNOT reconstruct the queue from notifications alone" ,1172 + let snapped = client.attach_snapshot (& client_ep);1173 + let after = client.state.lock ().unwrap ().queue.clone ();1174 + let truth_q = engine.lock ().unwrap ().truth.queue.clone ();1175 + let ok_fix = check (1176 + "classify: PROPOSED session/snapshot reconstructs the queue → matches ground truth" ,1177 + snapped && after == truth_q && after.len () == 2 ,1180 + let ok_counts = check (1181 + "classify: every EngineEvent variant tagged (14 agent + 9 session + 4 queue + 2 misc + 5 private UI)" ,1182 + variants.len () == 34 && n_req == 4 && n_priv == 5 && n_note == 25 ,1185 + ok_counts && ok_gap && ok_fix1188 + fn main () -> Result <(), Box <dyn std::error::Error>> {1189 + let scenario = std::env::args().nth (1 ).unwrap_or_else (|| "all" .into ());1190 + let run = |name: &str | -> bool {1192 + "classify" => scn_classify (),1193 + "reconstruct" => scn_reconstruct (),1194 + "blocking-roundtrip" => scn_blocking_roundtrip (),1196 + println! ("unknown scenario {other}" );1202 + let ok = if scenario == "all" {1203 + let names = ["classify" , "reconstruct" , "blocking-roundtrip" ];1204 + let mut all = true ;1206 + println! ("== {n} ==" );1217 + println! ("p28 RESULT: '{scenario}' holds" );1220 + Err (format! ("p28 RESULT: '{scenario}' failed" ).into ())prototypes/p34-ci-pipeline/NOTES.md Added new file mode 100644+24 / −0 text lines
3 + One prototype, three SPEC claims that only a real CI toolchain can settle:5 + - **§14 cross-build** (was P30, tooling-gated): does the heavy native tree6 + (vendored LuaJIT via `mlua`, `gix`) cross-compile to the required musl and7 + Windows triples through `cargo-zigbuild`? `cross/` is a minimal bin pulling8 + those deps; the `cross-build` job attempts the §14 matrix and reports the9 + first per-target link/build error.10 + - **§11 arch-gate** (was P32, tooling-gated): can `cargo-pup` on the pinned11 + nightly express and enforce a forbidden inter-crate edge? `archgate/` is a12 + tiny 3-crate workspace with a `pup.ron` forbidding `wcore -> wai`. The job13 + proves the gate PASSES the legal graph and FAILS once the edge is injected.14 + The same job runs the stable-metadata fallback (`§3.5 xtask arch`) so §11 has15 + an enforcement path even if `cargo-pup` proves unusable.16 + - **§13.1 cold-build sub-budget + §17.10 hermeticity**: the `prototypes` job17 + builds and tests every existing prototype crate on a clean runner and records18 + per-crate wall-clock — the first real cold-build numbers the §13.1 budget is19 + meant to be seeded from, and a check that the mocked-everything test policy20 + actually runs green with no TTY / no network.22 + The workflow lives at `.github/workflows/ci-prototype.yml`. It is temporary23 + evidence, not the production pipeline: it targets the prototype crates because24 + no production crate exists yet (spec/planning phase). Result block: `../PLAN.md`.prototypes/p34-ci-pipeline/archgate/Cargo.lock Added new file mode 100644+19 / −0 text lines
prototypes/p34-ci-pipeline/archgate/Cargo.toml Added new file mode 100644+8 / −0 text lines
8 + members = ["wcore" , "wai" , "wharness" ]prototypes/p34-ci-pipeline/archgate/gate.py Added new file mode 100644+39 / −0 text lines
13 + FORBIDDEN = [("wcore" , "wai" )] 17 + out = subprocess.run(18 + ["cargo" , "metadata" , "--format-version=1" , "--no-deps" ],19 + capture_output= True , text= True , check= True ,21 + meta = json.loads(out)22 + by_name = {p["name" ]: p for p in meta["packages" ]}24 + for src, dst in FORBIDDEN:25 + pkg = by_name.get(src)28 + if any (d["name" ] == dst for d in pkg["dependencies" ]):29 + violations.append((src, dst))31 + for s, d in violations:32 + print (f "ARCH VIOLATION: {s} -> {d} is forbidden by §11" , file= sys.stderr)34 + print ("arch gate clean: no forbidden inter-crate edges" )38 + if __name__ == "__main__" :prototypes/p34-ci-pipeline/archgate/pup.ron Added new file mode 100644+18 / −0 text lines
1 + // KNOWN-WRONG SCHEMA, kept as the evidence that produced the finding.2 + // The re-run (run 29633526704) proved the real cargo_pup top-level struct is3 + // `LintBuilder`, not `Pup` (error: "Expected struct LintBuilder but found Pup").4 + // It also showed these single-file crates present to pup as `unknown_crate`5 + // (the §3.5-documented caveat), so they are too structureless to hang a6 + // restrict_imports rule on. Closing the enforcement proof needs a richer7 + // fixture + a LintBuilder config — see PLAN.md P34 "Next Steps". Until then the8 + // stable `cargo metadata` gate (gate.py) is the proven §11 enforcement.12 + name: "core-must-not-depend-on-ai",14 + (from: "wcore", to: "wai"),prototypes/p34-ci-pipeline/archgate/wai/Cargo.toml Added new file mode 100644+6 / −0 text lines
prototypes/p34-ci-pipeline/archgate/wai/src/lib.rs Added new file mode 100644+1 / −0 text lines
1 + pub fn ai_marker () -> &'static str { "wai" }prototypes/p34-ci-pipeline/archgate/wcore/Cargo.toml Added new file mode 100644+7 / −0 text lines
prototypes/p34-ci-pipeline/archgate/wcore/src/lib.rs Added new file mode 100644+1 / −0 text lines
1 + pub fn core_marker () -> &'static str { "wcore" }prototypes/p34-ci-pipeline/archgate/wharness/Cargo.toml Added new file mode 100644+9 / −0 text lines
8 + wcore = { path = "../wcore" }9 + wai = { path = "../wai" }prototypes/p34-ci-pipeline/archgate/wharness/src/lib.rs Added new file mode 100644+1 / −0 text lines
1 + pub fn wire () -> String { format! ("{}+{}" , wcore::core_marker(), wai::ai_marker()) }prototypes/p34-ci-pipeline/cross/Cargo.toml Added new file mode 100644+13 / −0 text lines
12 + mlua = { version = "0.10" , features = ["luajit" , "vendored" ] }13 + gix = { version = "0.85" , default-features = false , features = ["blame" , "revision" , "sha1" ] }prototypes/p34-ci-pipeline/cross/src/main.rs Added new file mode 100644+16 / −0 text lines
6 + let lua = mlua::Lua::new();8 + .load ("return _VERSION .. ' ok'" )10 + .expect ("luajit eval" );11 + println! ("lua: {v}" );14 + let oid = gix::hash::ObjectId::empty_blob(gix::hash::Kind::Sha1);15 + println! ("gix empty-blob oid: {oid}" );