返回 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 //! | `events` | `Engine::run` → `run_turn` with a scripted provider | one turn → protocol `EventMsg` sequence |
18 //! | `mcp` | `Engine::execute_mcp_tool_with_pool` + `McpPool::to_api_tools` against a transcript server | catalog and call results for one dispatch |
19 //! | `prompt` | the first model request of a real turn | model-visible prefix bytes (system prompt + tool catalog) |
20 //! | `hooks` | `run_tool_call_before_hooks` / `HookExecutor::execute` | hook verdict fold, env contract and schema-1 stdin |
21 //!
22 //! Default is compare-only. `CODEWHALE_CONFORMANCE_UPDATE=1` rewrites goldens
23 //! from the current source for review in the diff; it refuses to run under CI.
24 //! The fixture README states the normalized formats a second implementation
25 //! must reproduce.
26 //!
27 //! Known limits, stated so nobody assumes them: the harness pins what the
28 //! Rust side does today. A provider error after a collected tool call must
29 //! settle it without executing it (C02-05); the invariant is mandatory. It runs
30 //! no real provider, MCP server binary, or Node host. The `events`, `prompt`
31 //! and `hooks` goldens were recorded on Unix and are compiled only there:
32 //! hook fixtures are POSIX shell, and a Windows turn differs in shell and
33 //! path facts that no recorded golden covers yet. `sse` and `mcp` run
34 //! everywhere.
35 #![cfg(test)]
36
37 #[cfg(unix)]
38 #[cfg(test)]
39 mod events;
40 #[cfg(test)]
41 pub(crate) mod golden;
42 #[cfg(unix)]
43 #[cfg(test)]
44 mod hooks;
45 #[cfg(test)]
46 mod mcp;
47 #[cfg(unix)]
48 #[cfg(test)]
49 mod prompt;
50 #[cfg(test)]
51 mod sse;
52 #[cfg(test)]
53 mod stream_json;
54
54 lines RUST