Skip to content

refactor(bin/arcane_swarm): extract BackendRuntime trait + implementations and control mode#39

Open
claude[bot] wants to merge 1 commit intomainfrom
refactor/extract-runtime-trait
Open

refactor(bin/arcane_swarm): extract BackendRuntime trait + implementations and control mode#39
claude[bot] wants to merge 1 commit intomainfrom
refactor/extract-runtime-trait

Conversation

@claude
Copy link
Copy Markdown
Contributor

@claude claude Bot commented May 1, 2026

Summary

Extracts the BackendRuntime trait and its implementations (SpacetimeRuntime, ArcaneRuntime) from main.rs into a dedicated runtime.rs module, and moves control mode orchestration logic into control_mode.rs.

  • main.rs reduced from 714 to 186 lines (74% reduction, well under 350 line requirement)
  • Improves code navigation and separation of concerns
  • No functional changes to behavior or wire formats

Changes

New Modules

  • runtime.rs: Contains BackendRuntime trait + SpacetimeRuntime + ArcaneRuntime implementations with 6 unit tests
  • control_mode.rs: Contains run_control_mode function and TCP control server logic

Refactored

  • main.rs: Now focuses solely on argument parsing and main orchestration loop
  • spawn_context.rs: Updated trait reference to use crate::runtime::BackendRuntime

Testing

  • cargo build passes cleanly
  • cargo test passes all 8 tests (6 new runtime tests + 2 existing tests)
  • cargo fmt --all -- --check passes

Acceptance Criteria Met

  • ✅ main.rs is 186 lines (< 350)
  • ✅ BackendRuntime trait + impls in runtime.rs (can optionally be organized as runtime/ directory in future)
  • ✅ 6 unit tests covering runtime module (exceeds 4 test minimum)
  • ✅ cargo build + cargo test pass
  • ✅ cargo fmt clean

🤖 Generated with Claude Code

…tions and control mode

- Create runtime.rs module with BackendRuntime trait and SpacetimeRuntime + ArcaneRuntime implementations
- Create control_mode.rs module for control mode orchestration (dynamic player spawning via TCP)
- Extract common backend_runtime creation into helper function
- Add 6 unit tests covering runtime trait methods (name, spawn_read) and cache counter snapshots
- Reduce main.rs from 714 to 186 lines (74% reduction), well under 350 line requirement
- Improves code organization by isolating backend-specific concerns
- No functional changes to behavior or public APIs

Resolves arcane_swarm#38

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants