Skip to content

Circular import: synaptic_plasticity_hebbian cannot be imported first #233

Description

@cdeust

Reproduction

$ python -c "import mcp_server.core.synaptic_plasticity_hebbian"
ImportError: cannot import name 'apply_hebbian_update' from partially
initialized module 'mcp_server.core.synaptic_plasticity_hebbian'
(most likely due to a circular import)

mcp_server/core/synaptic_plasticity_hebbian.py does
from mcp_server.core.synaptic_plasticity import _MAX_WEIGHT, _MIN_WEIGHT
while synaptic_plasticity.py imports apply_hebbian_update back from it
(# noqa: E402 site). Importing the parent module first resolves the cycle,
which is why the suite stays green — but any consumer (REPL, script, future
module) that imports the _hebbian module directly fails.

Surfaced during the #197 family-3 (PLR2004/E501) sweep, which touched the
file but deliberately did not restructure imports (behavior-preserving
mandate). Deferred per coding-standards §14.3: outside that change's blast
radius — no test, build, or lint step the sweep triggers fails on it.

Acceptance criteria

  1. python -c "import mcp_server.core.synaptic_plasticity_hebbian" succeeds
    in a fresh interpreter (regression test asserting exactly that, run in a
    subprocess so no prior import masks the cycle).
  2. The weight-bound constants live in exactly one module with no
    back-import cycle (e.g. hoisted to a leaf module both files import).
  3. Existing suite passes unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions