Skip to content

refactor(binary): split main.rs and bootstrap.rs into focused modules#906

Merged
bug-ops merged 6 commits intomainfrom
831-binary-restructuring
Feb 25, 2026
Merged

refactor(binary): split main.rs and bootstrap.rs into focused modules#906
bug-ops merged 6 commits intomainfrom
831-binary-restructuring

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Feb 25, 2026

Summary

Implements epic #831 — binary crate restructuring (closes #839, #840).

  • src/main.rs reduced from 3177 to 26 LOC — thin orchestrator delegating to runner::run()
  • crates/zeph-core/src/bootstrap/mod.rs reduced from 1791 to 278 LOCAppBuilder only
  • All functionality preserved, 2693 tests pass

Changes

Binary crate (zeph):

  • src/runner.rs — dispatch logic for all run modes (acp, tui-remote, tui, cli, daemon)
  • src/agent_setup.rs — tool executor + MCP setup, feature-gated extensions (index, candle-stt, whisper-stt)
  • src/tracing_init.rsinit_file_logger() deduplicates 4 identical tracing init blocks
  • src/tui_bridge.rsrun_tui_agent() extracted from main()
  • src/channel.rsbuild_cli_history() extracted from main()
  • src/tests.rs — unit tests moved from main.rs

zeph-core bootstrap:

  • bootstrap/config.rs — config path resolution, vault arg parsing
  • bootstrap/health.rs — health check and provider warmup
  • bootstrap/mcp.rs — MCP manager and registry creation
  • bootstrap/provider.rs — provider factory functions
  • bootstrap/skills.rs — skill matcher and embedding model helpers
  • bootstrap/tests.rs — unit tests moved from bootstrap/mod.rs

Test plan

  • cargo build passes
  • cargo clippy --workspace -- -D warnings — zero warnings
  • cargo +nightly fmt --check — clean
  • cargo nextest run --workspace --lib --bins — 2693 passed, 9 skipped

Split 3177-line main.rs into thin orchestrator (26 LOC) + focused modules:
- src/runner.rs: dispatch logic for all run modes (acp, tui, cli, daemon)
- src/agent_setup.rs: tool executor, MCP setup, feature-gated agent extensions
- src/agent_setup.rs: apply_code_index, apply_candle_stt, apply_whisper_stt helpers
- src/tests.rs: unit tests extracted from main.rs
- src/tracing_init.rs: init_file_logger() deduplicates 4 identical tracing setups
- src/tui_bridge.rs: run_tui_agent() and TUI event forwarding
- src/channel.rs: build_cli_history() and channel creation
- src/cli.rs, acp.rs, daemon.rs, scheduler.rs, commands/: pre-existing splits

Split 1791-line bootstrap.rs into focused submodules under bootstrap/:
- bootstrap/config.rs: config path resolution, vault arg parsing
- bootstrap/health.rs: health check and provider warmup
- bootstrap/mcp.rs: MCP manager and registry creation
- bootstrap/provider.rs: provider factory functions
- bootstrap/skills.rs: skill matcher and embedding model helpers
- bootstrap/tests.rs: unit tests extracted from bootstrap/mod.rs
- bootstrap/mod.rs: AppBuilder struct (278 LOC, was 1791)

Closes #839, #840
…ucturing

- CHANGELOG.md: add [Unreleased] entries for #839, #840
- docs/src/architecture/crates.md: document new zeph binary modules and bootstrap submodules
- docs/src/architecture/overview.md: update bootstrap and binary structure design decisions
- crates/zeph-core/README.md: update bootstrap module table to reflect submodule split
- src/agent_setup.rs: add unit tests for apply_cost_tracker, apply_summary_provider, apply_response_cache
@github-actions github-actions bot added documentation Improvements or additions to documentation refactor size/XL labels Feb 25, 2026
- Replace unused LlmProvider import with IndexConfig in agent_setup.rs
- Change apply_code_index provider param from impl LlmProvider to AnyProvider
- Add LlmProvider trait import under index cfg gate in runner.rs
- Replace generic P: LlmProvider in TuiRunParams/run_tui_agent with AnyProvider
- Box::pin large futures in main.rs and runner.rs to satisfy clippy::large_futures
- Remove bootstrap.rs (replaced by bootstrap/ submodule directory); apply
  vault() doc comment from #902 to bootstrap/mod.rs
- Update CHANGELOG.md combining #839/#840 and #848/#849/#850 entries
- Fix src/commands/skill.rs: use SourceKind enum from zeph_memory::sqlite
  instead of stringly-typed source_kind values
@bug-ops bug-ops enabled auto-merge (squash) February 25, 2026 19:47
@bug-ops bug-ops merged commit d95c6a5 into main Feb 25, 2026
28 checks passed
@bug-ops bug-ops deleted the 831-binary-restructuring branch February 25, 2026 20:00
bug-ops added a commit that referenced this pull request Feb 25, 2026
- Resolve modify/delete conflict: bootstrap.rs refactored into bootstrap/ module (#906)
- Resolve content conflict: main.rs tests extracted to src/tests.rs (#906)
- Apply #[allow(unsafe_code)] to std::env tests in bootstrap/tests.rs and src/commands/vault.rs
- Add 4 BTreeMap coverage tests to vault.rs (deterministic order, save/load roundtrip, into_iter regression)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decompose AppBuilder in bootstrap.rs Split main.rs into modules Epic: Binary crate restructuring

1 participant