Skip to content

refactor(server): split grpc.rs into submodules#777

Merged
drew merged 1 commit intomainfrom
refactor-grpc-split-modules/an
Apr 8, 2026
Merged

refactor(server): split grpc.rs into submodules#777
drew merged 1 commit intomainfrom
refactor-grpc-split-modules/an

Conversation

@drew
Copy link
Copy Markdown
Collaborator

@drew drew commented Apr 7, 2026

Summary

Break apart the 6,890-line grpc.rs monolith into a grpc/ module directory with 5 focused submodules. Each OpenShell trait method is now a one-line delegation to the appropriate submodule handler.

Changes

  • mod.rs (420 lines)OpenShellService struct, thin trait impl delegation, shared types (StoredSettings, StoredSettingValue), field-size constants, clamp_limit
  • policy.rs (3,066 lines) — Policy updates/status, draft chunk handlers, config/settings layer, sandbox logs
  • sandbox.rs (1,412 lines) — Sandbox lifecycle (create/get/list/delete/watch), exec over SSH, SSH session management, SSH transport helpers
  • provider.rs (920 lines) — Provider CRUD, resolve_provider_environment, ObjectType/ObjectId/ObjectName impls
  • validation.rs (948 lines) — All validation functions (sandbox spec, provider fields, policy safety, static fields, exec request, log filtering)

Design decisions

  • Thin delegation pattern: The impl OpenShell trait block stays in mod.rs but each method body is a one-liner call like sandbox::handle_create_sandbox(&self.state, request).await
  • Shared types in mod.rs: StoredSettings/StoredSettingValue and all field-size constants live in mod.rs since they're referenced by multiple submodules
  • Tests follow their code: Each submodule has its own #[cfg(test)] mod tests block with the relevant tests redistributed from the original monolith
  • No behavioral changes: Pure refactor — all 205 unit tests preserved and passing, all integration tests green

Testing

  • cargo check -p openshell-server passes
  • cargo test -p openshell-server — all 205 unit tests + 20 integration tests pass
  • cargo clippy -p openshell-server --no-deps — zero new warnings in grpc/ directory
  • cargo fmt -p openshell-server -- --check passes

Checklist

  • Follows Conventional Commits
  • Architecture docs updated (if applicable)

Break apart the 6,890-line grpc.rs into a grpc/ module directory with
focused submodules:

- mod.rs (420 lines): Service struct, thin trait delegation, shared types
- policy.rs (3,066 lines): Policy updates, status, draft chunks, settings
- sandbox.rs (1,412 lines): Sandbox lifecycle, exec, SSH transport
- provider.rs (920 lines): Provider CRUD, env resolution
- validation.rs (948 lines): All validation functions, log filtering

Each trait method in the OpenShell impl is now a one-line delegation to
the appropriate submodule handler. All 205 unit tests preserved and
passing.
@drew drew self-assigned this Apr 7, 2026
@drew drew requested a review from a team as a code owner April 7, 2026 16:51
@drew drew added the test:e2e Requires end-to-end coverage label Apr 8, 2026
@drew drew merged commit d7acfc1 into main Apr 8, 2026
15 checks passed
@drew drew deleted the refactor-grpc-split-modules/an branch April 8, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants