Skip to content

Conversation

@jeff-hykin
Copy link
Member

@jeff-hykin jeff-hykin commented Jan 30, 2026

NOTE: only merge this after the RPC rework merge

DimosCluster is basically untyped cause its a dynamic hack of the dask Client

This PR basically adds proper typing to DimosCluster, enforcing that both DimosCluster and WorkerManager follow a DeployerProtocol, which fixes a lot of the mypy ignores in ModuleCoordiator.

After adding the protocol, I think it made sense to use consistent names: WorkerManager => WorkerDeployer and DimosCluster => DaskDeployer (and we would eventually have a DockerDeployer) so those renames are in this PR.

@jeff-hykin jeff-hykin changed the base branch from dev to jeff/blueprint/6 January 30, 2026 21:53
@greptile-apps
Copy link

greptile-apps bot commented Jan 30, 2026

Greptile Overview

Greptile Summary

This PR improves typing throughout the core module system by introducing a DeployerProtocol that both DaskDeployer (formerly DimosCluster) and WorkerDeployer (formerly WorkerManager) implement. The new ModuleProxy type provides better type hints for deployed modules.

Major Changes:

  • Introduced DeployerProtocol to formalize the deployer interface with deploy() and close_all() methods
  • Renamed DimosClusterDaskDeployer for consistency with deployment pattern naming
  • Renamed WorkerManagerWorkerDeployer to align with the DeployerProtocol convention
  • Renamed ModuleBlueprintSetBlueprint for simplicity
  • Added Spec protocol support enabling modules to declare dependencies on abstract interfaces rather than concrete implementations
  • Added ModuleProxy type combining RPCClient and Module for better IDE/mypy support
  • Refactored ModuleCoordinator to use DeployerProtocol, eliminating many type: ignore comments
  • Added new _connect_module_refs() method to wire up Spec-based module references with structural and annotation compliance checking

The changes significantly improve type safety and enable better architectural patterns through interface-based module dependencies.

Confidence Score: 4.5/5

  • This PR is safe to merge with minor fixes needed
  • The refactoring is well-structured and improves type safety significantly. Two minor error message inconsistencies were found where old class names remain in error strings. The protocol-based architecture is sound and the test updates confirm backward compatibility. The addition of Spec support is properly integrated with structural and annotation compliance checking.
  • Pay attention to dimos/core/worker_manager.py for the error message fixes

Important Files Changed

Filename Overview
dimos/core/deployer_protocol.py New protocol defining deployer interface for type safety
dimos/core/module_coordinator.py Updated to use DeployerProtocol, improved type hints with ModuleProxy
dimos/core/worker_manager.py Renamed to WorkerDeployer, implements DeployerProtocol, but has inconsistent error messages
dimos/core/init.py DimosCluster renamed to DaskDeployer, implements DeployerProtocol with proper typing
dimos/core/blueprints.py Major refactor: renamed ModuleBlueprintSet to Blueprint, added Spec support, improved module ref connections
dimos/spec/utils.py New utilities for Spec protocol support, enabling module interface checking

Sequence Diagram

sequenceDiagram
    participant User
    participant Blueprint
    participant ModuleCoordinator
    participant DeployerProtocol
    participant WorkerDeployer
    participant DaskDeployer
    participant ModuleProxy
    participant Module

    Note over Blueprint,ModuleCoordinator: Refactor: ModuleBlueprintSet → Blueprint
    User->>Blueprint: create via Module.blueprint()
    Note over Blueprint: Now includes Spec support via ModuleRef
    
    User->>Blueprint: autoconnect(blueprints)
    Blueprint->>Blueprint: Resolve stream connections
    Blueprint->>Blueprint: Resolve module refs via Spec matching
    
    User->>Blueprint: build()
    Blueprint->>ModuleCoordinator: new ModuleCoordinator()
    ModuleCoordinator->>ModuleCoordinator: start()
    
    alt Using Dask
        Note over ModuleCoordinator,DaskDeployer: Refactor: DimosCluster → DaskDeployer
        ModuleCoordinator->>DaskDeployer: core.start()
        Note over DaskDeployer: Implements DeployerProtocol
    else Using Workers
        Note over ModuleCoordinator,WorkerDeployer: Refactor: WorkerManager → WorkerDeployer
        ModuleCoordinator->>WorkerDeployer: new WorkerDeployer()
        Note over WorkerDeployer: Implements DeployerProtocol
    end
    
    ModuleCoordinator->>DeployerProtocol: deploy(module_class, args, kwargs)
    DeployerProtocol-->>ModuleCoordinator: ModuleProxy
    Note over ModuleProxy: New type: RPCClient + Module for better typing
    
    Blueprint->>ModuleCoordinator: _connect_streams()
    Blueprint->>ModuleCoordinator: _connect_rpc_methods()
    Blueprint->>ModuleCoordinator: _connect_module_refs()
    Note over Blueprint,Module: New: Connects modules via Spec protocol matching
    
    ModuleCoordinator->>ModuleProxy: set_module_ref(name, target)
    ModuleProxy->>Module: setattr(name, target)
    
    ModuleCoordinator->>ModuleProxy: start()
    ModuleProxy->>Module: start()
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

def deploy(self, module_class: type[ModuleT], *args: Any, **kwargs: Any) -> ModuleProxy:
if self._closed:
raise RuntimeError("WorkerManager is closed")
raise RuntimeError("PureDeployer is closed")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message references PureDeployer but class is now named WorkerDeployer

Suggested change
raise RuntimeError("PureDeployer is closed")
raise RuntimeError("WorkerDeployer is closed")

) -> list[ModuleProxy]:
if self._closed:
raise RuntimeError("WorkerManager is closed")
raise RuntimeError("PureDeployer is closed")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message references PureDeployer but class is now named WorkerDeployer

Suggested change
raise RuntimeError("PureDeployer is closed")
raise RuntimeError("WorkerDeployer is closed")

@jeff-hykin jeff-hykin changed the base branch from jeff/blueprint/6 to dev January 30, 2026 22:44
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.

2 participants