Repository navigation
test(agent_runtime): pin the layering rule and drop a stale docstring reference - #289
Conversation
830db3c to
e6e4481
Compare
|
Thanks for looking at import layering. We tried to reproduce the cycle on main and couldn't. There is no cycle on main. Each of these imports cleanly as the first import in a fresh interpreter:
Nothing under The new code works against what the test protects. What we'd accept:
With that, it's a quick merge. |
… reference
There is no import cycle on the current tree: each of core.config, core.compat,
core.agent_runtime, core.events and app_server imports cleanly as the first
import of a fresh interpreter, and the graph is
core.compat -> {core.config, core.agent_runtime} plus
core.config -> core.agent_runtime.
What remains is the layering rule itself: core.agent_runtime is the current
runtime and core.compat is the legacy shim, so the edge must not point back
from the runtime into the shim. This keeps that direction pinned statically --
a module-level core.compat import anywhere under core/agent_runtime/ fails at
the offending line, instead of surfacing later as an order-dependent
ImportError at import time.
Also drops the stale docstring line in core/agent_runtime/__init__.py that
advertised core.agent_runtime.parallel, a module that has never existed.
Deferred imports stay allowed (if TYPE_CHECKING: for annotations, or inside a
function body for call-time), because neither executes at module import time.
Tests: tests/test_import_layering.py (1 passed); neighbour
tests/test_config_layering.py (24 passed). The rule was falsified in both
directions: adding a module-level `from core.compat.request_params import
RequestParams` to core/agent_runtime/hook.py makes the test fail naming
hook.py:161, and removing it turns the test green again. ruff 0.15.21 check and
format --check clean.
e6e4481 to
389f66d
Compare
|
Thanks — all three points are done, and you were right that there is no cycle. Removed the stale docstring line. Kept the layering rule with an accurate docstring. Dropped the rest. Now 2 files, +72 / -1. Rebased onto Two verification notes, since a rule test that cannot fail is worth nothing:
One thing I want to flag rather than hide: with the rule test alone, the diff is a bit thin — it is one guard plus a docstring fix. If you would rather take just the docstring line as its own tiny change and let the guard wait until there is a real edge to protect, say so and I will split it. |
|
Merged in 916bbb9. Thank you. We kept it as one change: the layering rule is cheap to keep, and the docstring line is fixed. |
Add the news entry and changelog for the 2026-11-16 community batch (#289, #293, #303, #307) and fold the 2026-10-31 entry into the earlier updates. The three points under "What Deep means" now match the numbered parts of the framework figure, self-evolution is named as planned, and "Why DeepCode" no longer repeats them.
Summary
Pins one layering rule and removes a stale docstring reference, following the shape from the review on this PR.
core.agent_runtimeis the current runtime;core.compatis the legacy shim that adapts the oldmcp_agentsurface. The dependency must not point back from the runtime into the shim.tests/test_import_layering.pypins that direction statically: a module-levelcore.compatimport anywhere undercore/agent_runtime/fails at the offending line, instead of surfacing later as an order-dependentImportErrorat import time.core/agent_runtime/__init__.pythat advertisedcore.agent_runtime.parallel, a module that has never existed.What this is not
It does not claim an import cycle. There is none on main:
core.config,core.compat,core.compat.parallel,core.compat.agent,core.compat.runtime,core.agent_runtime,core.eventsandapp_servereach import cleanly as the first import of a fresh interpreter, and the graph iscore.compat -> {core.config, core.agent_runtime}pluscore.config -> core.agent_runtime.Changes
2 files, +72 / -1.
core/agent_runtime/__init__.py— remove the stalerun_parallel_llmdocstring line.tests/test_import_layering.py— new. One test, an AST scan; deferred imports (if TYPE_CHECKING:or inside a function body) stay allowed.Dropped from the earlier revision, as asked:
core/agent_runtime/parallel.py, its re-export, and theTYPE_CHECKINGchange incore/compat/parallel.py.Tests
tests/test_import_layering.py— 1 passed.tests/test_config_layering.py— 24 passed (neighbour).The rule was falsified in both directions: adding a module-level
from core.compat.request_params import RequestParamstocore/agent_runtime/hook.pyfails the test naminghook.py:161, and removing it turns the test green again.ruff 0.15.21 checkandruff 0.15.21 format --checkclean.Rebased onto
3dcb0fb4.Dependency note
None. One new test file plus one docstring line removed; no new imports, no new runtime path.