You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RPC: give the worker a typed state and a typed handle registry #43
The whole worker layer is Any to the type checker, so pyright --strict
verifies none of it.
Evidence
HandleRegistry.get_typed(handle, expected_kind) -> Any
(rpc/worker/_handle_registry.py:42). The kind tag is checked at runtime and
discarded statically.
EvalServiceHandler.__init__(self, state: Any)
(rpc/worker/_worker_eval.py:196), and StoreServiceHandler is the same.
The symptom is visible at rpc/worker/_worker.py:555-567, _shutdown_worker,
which carries nine suppressions on eight lines. Each says "cascade from
WorkerState Any attributes", although every attribute of WorkerState has a
concrete type.
Why it matters
pyright --strict reports zero errors over this code because it can see
nothing to check. Every handler body is the code that turns a wire message
into a Nix call, and it is unverified. That is the layer where a wrong handle
kind or a wrong attribute name becomes a TypeError in a subprocess.
Scope
Two mechanical changes, in this order:
Type state as WorkerState on all three handlers. WorkerState is
defined in _worker.py, and _worker.py imports the handlers, so move WorkerState to a neutral module rpc/worker/_state.py to break the
cycle. AGENTS.md names that as the preferred correction.
Replace get_typed with one typed accessor for each kind: get_store, get_eval_entry, get_value, get_locked_flake. There are four kinds,
they do not change, and the call sites read better than a generic method.
Delete HandleRegistry.clear() (:65) at the same time. It has no caller,
and it resets _next = 1, so a use of it would reissue handle numbers that a
client still holds.
Activity
refactor(rpc): give the worker a typed state and a typed handle registry