返回 CodeWhale
conformance.rs
根目录 / crates / tui / src / conformance.rs
1 //! Conformance harness for the Rust → TypeScript edge migration.
2 //!
3 //! `codewhale-ops/CURRENT_DECISIONS.md` §26 moves MCP, hook orchestration,
4 //! script tools, tool adapters and slash commands to the TypeScript extension
5 //! host one subsystem at a time, each behind a flag that defaults to Rust. A
6 //! subsystem may flip only after it meets the same expectations the Rust
7 //! implementation meets today, on recorded fixtures. This module is that
8 //! gate's Rust half.
9 //!
10 //! Every family replays committed, language-neutral fixtures from
11 //! `crates/tui/tests/fixtures/conformance/<family>/` through the *current*
12 //! production path and compares a normalized result with a committed golden:
13 //!
14 //! | family | production path under test | proves |
15 //! |---|---|---|
16 //! | `sse` | `CodewhaleClient::create_message_stream` over a loopback HTTP server | wire bytes → normalized stream events |
17 //! | `responses` | route resolver, `prepare_outbound_request`, and the same loopback stream | profile id, request body, and Responses termination |
18 //! | `events` | `Engine::run` → `run_turn` with a scripted provider | one turn → protocol `EventMsg` sequence |
19 //! | `mcp` | `Engine::execute_mcp_tool_with_pool` + `McpPool::to_api_tools` against a transcript server | catalog and call results for one dispatch |
20 //! | `prompt` | the first model request of a real turn | model-visible prefix bytes (system prompt + tool catalog) |
21 //! | `hooks` | `run_tool_call_before_hooks` / `HookExecutor::execute` | hook verdict fold, env contract and schema-1 stdin |
22 //!
23 //! Default is compare-only. `CODEWHALE_CONFORMANCE_UPDATE=1` rewrites goldens
24 //! from the current source for review in the diff; it refuses to run under CI.
25 //! The fixture README states the normalized formats a second implementation
26 //! must reproduce.
27 //!
28 //! Known limits, stated so nobody assumes them: the harness pins what the
29 //! Rust side does today. A provider error after a collected tool call must
30 //! settle it without executing it (C02-05); the invariant is mandatory. It runs
31 //! no real provider, MCP server binary, or Node host. The `events`, `prompt`
32 //! and `hooks` goldens were recorded on Unix and are compiled only there:
33 //! hook fixtures are POSIX shell, and a Windows turn differs in shell and
34 //! path facts that no recorded golden covers yet. `sse`, `responses`, and `mcp` run
35 //! everywhere.
36 #![cfg(test)]
37
38 #[cfg(unix)]
39 #[cfg(test)]
40 mod events;
41 #[cfg(test)]
42 pub(crate) mod golden;
43 #[cfg(unix)]
44 #[cfg(test)]
45 mod hooks;
46 #[cfg(test)]
47 mod mcp;
48 #[cfg(unix)]
49 #[cfg(test)]
50 mod prompt;
51 #[cfg(test)]
52 mod responses;
53 #[cfg(test)]
54 mod sse;
55 #[cfg(test)]
56 mod stream_json;
57
57 lines RUST