Skip to content

infrastructure/ imports core/ at 6+ sites — layer rule (CLAUDE.md §Code Style) violated beyond the documented 3 #406

Description

@cdeust

Evidence

grep -rln "from mcp_server\.core\." mcp_server/infrastructure/*.py (measured on this branch, chore/issue-pgstore-split-1384-lines, base origin/main @ 1ba020a) returns 6 files, not the 3 CLAUDE.md's "Code Style" section documents as known/tracked:

mcp_server/infrastructure/pg_store_memory_reheat.py   (core.write_class)
mcp_server/infrastructure/pg_store_near_dup.py         (core.near_dup_calibration)
mcp_server/infrastructure/pg_store_write.py            (core.temporal_normalize — relocated verbatim from pg_store.py by #<this-PR>, pre-existing since ba249989, 2026-07-29)
mcp_server/infrastructure/sqlite_store.py              (core.temporal_normalize — same violation, SQLite backend parity)
mcp_server/infrastructure/wiki_schema_reader.py        (already documented)
mcp_server/infrastructure/wiki_store.py                (already documented — one of these two is likely wiki_classifier.py/wiki_schema_loader.py under a since-renamed path; re-verify against the current 3-item list)

CLAUDE.md's Code Style section names only wiki_axis_registry.py, wiki_classifier.py, wiki_schema_loader.py as tracked pre-existing violations (found 2026-07-14 during #114). The pg_store_*.py family (near_dup, memory_reheat, write) and sqlite_store.py are not in that list.

Root cause

temporal_normalize.py / temporal_timezones.py / temporal.py (date parsing, zero I/O, no domain/business logic) and near_dup_calibration.py / write_class.py (pure classification, zero I/O) are placed under core/ in docs/module-inventory.md, but every one of their infrastructure-layer callers needs them purely as stdlib-adjacent utilities with no dependency on core's business rules. They read as misplaced under shared/'s stated criterion ("Pure utility functions ... no dependencies on other project layers") rather than a genuine core/infrastructure boundary crossing.

Why not fixed in this PR

Out of blast radius: this PR (chore/issue-pgstore-split-1384-lines) is a behavior-preserving line-count split of pg_store.py — it relocates the core.temporal_normalize import verbatim, introducing no new violation. Fixing this properly means moving 5 modules (temporal.py, temporal_normalize.py, temporal_timezones.py, near_dup_calibration.py, write_class.py) to shared/ and re-verifying every consumer (including sqlite_store.py, untouched by this PR, and the wiki_* files already tracked separately) — a distinct architectural change, not a mechanical split.

Suggested fix

  1. Re-audit whether temporal.py/temporal_normalize.py/temporal_timezones.py/near_dup_calibration.py/write_class.py truly belong in core/ per docs/module-inventory.md's own dependency-rule table, or should move to shared/.
  2. If moved: update docs/module-inventory.md's per-layer catalogue and re-run the layer grep (grep -rn "from mcp_server.infrastructure" mcp_server/core/ plus the reverse direction) as part of that PR's own gate.
  3. If kept in core/ deliberately: extend CLAUDE.md's "3 pre-existing violations" list to the full current count (6, per the grep above) so the documented exception list matches reality.

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