fix(runtime): include entrypoint in the handler cache key - #32
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Note on the The 3 files changed here pass both linters cleanly:
Running CI's repo-wide commands locally shows the failures are in unrelated files (36 would-reformat + 25 |
9c4470e to
e117bca
Compare
|
Update — the red Evidence:
So this PR is verified clean; the red checks are pre-existing CI-health debt (tracked separately). Happy to open a follow-up PR to green the CI (repo-wide |
RegistryDispatcher._load_handler cached the RESOLVED handler callable keyed by (module_uri, checksum) — dropping the entrypoint. Two facets registered from the same module (same module_uri + checksum) but with different entrypoints both got the first-cached callable, silently mis-routing every facet after the first to one handler. Domain packages register a single dispatch entrypoint per module, which masked this; a handler module exposing N distinct entrypoints (one per facet) hit it — e.g. a BuildMap facet dispatched to a sibling FetchGasPrices handler and returned the wrong schema. Fix: key the cache by (module_uri, checksum, entrypoint). Regression test added (two entrypoints in one module must each dispatch to their own handler; fails on the old key, passes on the new). Updated the checksum-eviction test for the new 3-tuple key. Full dispatcher + runner suites: 253 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e117bca to
fa66aaf
Compare
Problem
RegistryDispatcher._load_handlercached the resolved handler callable keyed by(module_uri, checksum)— dropping theentrypoint. Two facets registered from the same module (samemodule_uri+checksum) but with different entrypoints both received the first-cached callable, silently mis-routing every facet after the first to a single handler.Domain packages register one dispatch entrypoint per module (routing on the facet name internally), which masked this. A handler module that exposes N distinct entrypoints — one per facet — hits it directly: e.g. a
BuildMapfacet dispatched to a siblingFetchGasPriceshandler and returned the wrong return schema ({layer: …}instead of{html_path: …}), which then broke a downstreammap.html_pathreference.Found while standing up a multi-facet handler module on the runtime.
Fix
Key the cache by
(module_uri, checksum, entrypoint). One-line change in_load_handler; the_module_cachetype annotation updated to the 3-tuple with an explanatory comment.Tests
test_distinct_entrypoints_same_module_do_not_collide— two entrypoints in one module must each dispatch to their own handler, checked in both dispatch orders. Verified it fails on the old key and passes on the new.test_checksum_change_evicts_cacheassertion for the new 3-tuple key.test_dispatcher.py,test_registry_runner.py,test_runner_service.py,test_inline_dispatch.py— 253 passed.Risk
Low. The cache becomes strictly more specific; domains using a single entrypoint per module are unaffected (their key just gains a constant third element). No behavior change except correct routing for multi-entrypoint modules.
🤖 Generated with Claude Code