feat(workers): use types for worker messages#1767
Conversation
Greptile SummaryThis PR refactors worker inter-process communication to use typed frozen dataclasses ( Confidence Score: 5/5Safe to merge — the refactor is a clean drop-in of typed frozen dataclasses with no logic changes. All findings are P2 style suggestions. The typed message classes are well-structured, pickling is correct, structural pattern matching aligns with the new types, and the shutdown/locking flow is unchanged and correct. No files require special attention.
|
| Filename | Overview |
|---|---|
| dimos/core/coordination/worker_messages.py | New module defining typed frozen dataclasses for worker messages; frozen=True on DeployModuleRequest and CallMethodRequest does not prevent in-place mutation of their dict fields. |
| dimos/core/coordination/python_worker.py | Updated to import and use typed message dataclasses; structural pattern matching, locking, and shutdown flow all look correct. |
Sequence Diagram
sequenceDiagram
participant P as PythonWorker (parent)
participant C as Connection (pipe)
participant W as _worker_loop (child)
P->>C: DeployModuleRequest(module_id, module_class, kwargs)
C->>W: recv()
W-->>C: WorkerResponse(result=module_id)
C-->>P: recv()
P->>C: SetRefRequest(module_id, ref=actor)
C->>W: recv()
W-->>C: WorkerResponse(result=worker_id)
C-->>P: recv()
P->>C: CallMethodRequest(module_id, name, args, kwargs)
C->>W: recv()
W-->>C: WorkerResponse(result=return_value)
C-->>P: recv()
P->>C: GetAttrRequest(module_id, name)
C->>W: recv()
W-->>C: WorkerResponse(result=attr_value)
C-->>P: recv()
P->>C: UndeployModuleRequest(module_id)
C->>W: recv()
W-->>C: WorkerResponse(result=True)
C-->>P: recv()
P->>C: ShutdownRequest()
C->>W: recv()
W-->>C: WorkerResponse(result=True)
C-->>P: poll + recv()
Reviews (1): Last reviewed commit: "feat(workers): use types for worker mess..." | Re-trigger Greptile
leshy
left a comment
There was a problem hiding this comment.
great, this stuff is cool for logging also, as you can write str on these etc
Problem
Closes DIM-XXX
Solution
Breaking Changes
How to Test
Contributor License Agreement