Repository navigation
refactor(tui): remove 16 dead modules, the MCP loaders and the folder-trust gate (plan D.8, decision 10) - #62
Merged
zy1233 merged 8 commits intoOct 31, 2026
Conversation
This was referenced Oct 30, 2026
…othing calls The dispatcher, the command runner and the HTTP runner of pi-hooks had no caller since the Rust agent runtime left (plan D.8). The call-graph tool lists dispatcher, result, runner, runner::command and runner::http as dead units: 4,339 lines, 48 % of the crate. The crate keeps what pi-agent, pi-workspace and pi-config still read: the hook definitions (config), the file discovery, the event types, the matcher, the trust files and the env expansion. - Delete src/dispatcher.rs, src/result.rs, src/runner/ and tests/integration.rs. - env_expand.rs: expand_env_vars_with_extra is a test helper now, so it moves into the test module. The docs no longer name the deleted modules. - Cargo.toml: remove reqwest, pi-extra-ca, url and tokio. No source file of the crate names them now. Cargo.lock follows. - lib.rs: the crate docs say that the crate loads and checks hook definitions and does not run them. The examples in pi-hooks/examples describe hooks of the old runtime that nothing runs. They stay for now.
Plan D.8. The call-graph tool lists seven units of pi-shell as dead: auth::flow, config::reloader, session::events, session::telemetry, session::unified_list, upload and upload::turn (1,008 lines). Five of them hold only tests: auth::flow, config::reloader, upload, upload::turn and session::telemetry. The tests of session::telemetry are a drift guard between the telemetry enums and the permission reasons, and no code emits these telemetry events. session::events holds the reason strings of goal and laziness events that nothing sends. session::unified_list builds the _meta of a session/list row that nothing builds. - Delete the files and their `mod` lines. - Cargo.toml: remove pi-session-events. Only session::events named it. Cargo.lock follows. - pi-workspace, permission/manager/reasons.rs: two comments no longer say that a telemetry enum asserts coverage against `ALL`. The test that did is gone. pi-session-events still names these reason strings in the docs of its events, and pi-telemetry/events/permission_analytics.rs still names the drift test. Both are candidates for the next cleanup.
… pi-mcp, pi-agent) Plan D.8. The call-graph tool lists these units as dead, and no file under tui/crates names them: - pi-workspace, publish (462 lines): the merge-or-fail publish flow of the old app deployer. - pi-tools, implementations::editor_infra (276 lines): a file-operation lock. - pi-mcp, wire (39 lines): the x.ai/mcp/* ACP method strings. - pi-agent, prompt::browser_verification (24 lines): a rule text. The prompt template keeps its own <browser_verification> block, and the flag include_browser_verification stays. pi-tools types::error is on the same list, but it stays: it holds the From impls for ToolError that the `?` operator needs.
…dirs (plan decision 10)
load_mcp_servers has had no caller since zypi stopped handing MCP servers to the agent (plan 1.P4).
It was the only user of the chain below it, so the chain goes with it, in pi-shell
util/config/mcp.rs:
- load_mcp_servers and reload_mcp_servers_merged.
- The loaders for mcp_preferences.json, .mcp.json, ~/.claude.json and ~/.cursor/mcp.json, and their
helpers (McpPreferencesLoad, mcp_config_from_json_value, claude_json_mcp_from_value,
read_mcp_json). The re-export of find_mcp_json_files goes too; the function stays in pi-workspace.
- Seven tests. Four of them built the merge of the old loader by hand ("project overrides global")
and tested nothing else. Two read a file with read_mcp_json. One checked the JSON map of the
loader.
parse_mcp_servers_from_toml stays: Config still reads [mcp_servers] through it (agent/config.rs),
and so do its tests.
pi-pager recent_dirs.rs had one doc comment and nothing else. Its `mod` line goes too.
The pager test session_new_and_load_send_no_mcp_servers called load_mcp_servers to show that its
fixture is something the old code found. That premise check goes. The test still checks that
session/new and session/load carry no servers, and a comment says what the fixture is.
…s that nothing calls Both sat in util/config/mcp.rs, and no file outside that file names them (a search of tui/crates, whole words): - load_cli_plugin_registry. Its doc says that the pager's /agents modal uses it. The pager does not. - The session-registry helpers: session_registry_from_toml_opt, session_registry_from_env_opt, session_registry_local_override_sourced, RegistrySource and SESSION_REGISTRY_ENV_VAR. - Their two tests. This is not on the list of plan decision 10. The next commit builds on it: it removes the code that load_cli_plugin_registry was the last to call.
The commits before this one left more dead code behind. `cargo check` found it: 15 warnings, and the ceiling of the baseline is 0. - `agent::folder_trust`: the consume side of the folder-trust gate (the cache of verdicts, `project_scope_allowed`, `resolve_and_record` and their helpers) and its 19 tests. The loaders of MCP servers, plugins and permission policy were the only callers. `grant_folder_trust` stays, because the pager calls it. The decision side stays in `pi-workspace`, for the pager's dialog. - `config::resolve_effective_plugins_config` (the last callers went with the plugin-registry helpers), `PluginsConfig::merge_claude_enabled_plugins`, `PluginsConfig::to_discovery_config` and the module `claude_import` (7 tests). `PluginsConfig` stays as a section of the config. - The 3 tests of `resolve_effective_plugins_config` in `config/tests.rs`. The test `project_config_never_sources_feedback_user` stays: it guards live code. It now checks with `find_project_configs` that the project config is found. - The re-export `util::config::McpConfig`: two tests use the type, and they import it from `pi-config-types` now. - The dependency `dirs` of `pi-shell`. Its only use was `merge_claude_enabled_plugins`. - Two doc comments in `pi-workspace`, and one line in the README of `pi-shell`, that named the removed code. Tests of `pi-shell`: 838 - 54 = 784 (with the commits before this one).
- Residue ceilings: `leader` 243 to 239, `x.ai` 297 to 282. The gate asks for it, and the manifest says to lower a ceiling in the commit that removes lines. - Tests of `pi-shell`: reference 838 to 784, floor 820 to 766 (the same distance, 18). 54 tests went with the code that they tested; none was added. The comment in the manifest has the count for each part. - The dependency graph stays at 970 packages (measured): the other crates still use what the removed code used.
- CHANGELOG.md: an entry under Removed for the commits above. It says what went, what stays on purpose (`grant_folder_trust`, `pi-tools::types::error`), and the numbers. - docs/baselines/tui-support.md: generated again with `python scripts/tui_callgraph.py keep` (it names commit ebc6106). The support crates have one dead unit left, `pi-tools::types::error`. It stays: it holds the `From` impls for `ToolError`, which code uses without a name.
zy1233
force-pushed
the
refactor/tui-remove-dead-modules
branch
from
October 31, 2026 02:51
272a52a to
f3b280e
Compare
This was referenced Oct 31, 2026
Owner
Author
|
Stack #66, bottom to top: #58, #59, #56, #57, #60, #61, #62, #63, #64, #65. One atomic squash merge ( Position 7 of 10. Base: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Plan phase D.8 and decision 10. The call graph lists 16 modules that no live code refers to. The MCP loaders of
pi-shellandrecent_dirsofpi-pagerhave no caller either (decision 10). All of it goes. The compiler then found the code that only these called (15 warnings, and the ceiling is 0), and that goes too.Eight commits. Read them in order:
pi-hooks: dispatcher and runnerspi-shell: seven dead modulespi-workspace,pi-tools,pi-mcp,pi-agent)recent_dirsCHANGELOG.md,docs/baselines/tui-support.mdCommit 6 builds on commit 5. Kept on purpose:
grant_folder_trust(the pager calls it for--trust, and the pager's trust dialog still uses the decision side inpi-workspace),pi-tools::types::error(holds theFromimpls forToolError),parse_mcp_servers_from_toml(Configreads[mcp_servers]). The guard testproject_config_never_sources_feedback_userstays: it used a removed function, so it now usesfind_project_configsto show that the project config is found.Left for later (names only): the docs of
pi-session-eventsandpi-telemetry/src/events/permission_analytics.rsstill name the removed goal and laziness reasons and the removed drift test;pi-hooks/examples/; three functions ofpi-config-types::mcp(resolve_setup,expand_strings,to_acp_mcp_server) that only their own tests call now.Evidence
mainat7cb9e23. The call graph (docs/baselines/tui-support.md): 17 dead units, 6,192 lines in the support crates.After: 1 dead unit,
pi-tools::types::error(44 lines), kept on purpose.tui_baseline.py check: warnings 15 (ceiling 0):folder_trust(7 items),claude_import(4),resolve_effective_plugins_config, the twoPluginsConfigmethods (one warning) and 2 unused imports.After:
tui_baseline.py checkon272a52a(Linux, WSL2) is all green: warnings 0,cargo checkof the consumer build exit 0,cargo check --workspace --testsexit 0 (--locked), residueleader239/239 andx.ai282/282, graph 970/970.tui_baseline.py test, nextest):pi-shell784 passed, 0 failed, 1 skipped (838 before; the 54 arefolder_trust19, MCP loaders 9,claude_import7,config::reloader6,session::telemetry6, resolver 3,session::events2,auth::flow1,upload::turn1; none new).pi-pager5,651 passed, 0 failed, 12 skipped (unchanged; includespython_agent_e2eagainst the real Python agent).pi-hooks(not a suite of the manifest): 130 passed, 0 failed.tui_notices.py check: 984 packages ship, 984 entries, 0 missing, 0 stale.Cargo.lockloses 6 dependency lines and no package.ruff check .andruff format --check .pass;pytest scripts/tests: 234 passed, 11 skipped. No Python file changes.Merge Danger
Door: two-way. One revert brings everything back.
Blast Radius: the
tui/source tree. It removes code that no build refers to, and its tests: 9,067 lines go and 65 come, in 47 files undertui/.zypidoes not change: the build that ships has 0 warnings, and nothing else names the removed items. Two tests change what they check (session_new_and_load_send_no_mcp_serversandproject_config_never_sources_feedback_user).CHANGELOG.mdconflicts with #60 and #61: all three add a section under[Unreleased]. Keep both sections. A test merge with #56, #57, #58, #59, #60 and #61 shows no other conflict. The manifest numbers do not collide: #61 changes thepi-pagernumbers, and this PR changes thepi-shellnumbers and the two ceilings.