Skip to content

[audit] 17 core/ modules import os or pathlib (core must be zero-I/O) #560

Closed

Description

@cdeust

Severity

MEDIUM (defer is OK with explicit follow-up)

Audit lens

architect (decomposition / dependency direction)

Finding

17 modules under mcp_server/core/ import os or pathlib. The layer rule forbids it: core is zero-I/O business logic and bans os/pathlib even though they are stdlib (docs/module-inventory.md:77-86, docs/agent-guidance.md § Code Style).

All 17 are grandfathered as layer-violation entries in .craftsmanship-baseline.json, so CI passes, but the debt is real:

  • ablation.py, abstention_gate.py, codebase_graph.py, conflict_monitor.py
  • pg_recall_weights.py (CORTEX_DECAY_DISABLED / CORTEX_HEAT_CONSTANT read at :77-78)
  • recall_pipeline.py (_env_float at :52-62 for CORTEX_HOPFIELD_BETA, CORTEX_HDC_BETA, CORTEX_SA_BETA)
  • reconsolidation.py, reranker_model.py, retrieval_dispatch.py, telemetry.py, thermodynamics.py
  • wiki_axis_registry.py, wiki_coverage.py, wiki_coverage_dashboard.py, wiki_drift.py, wiki_file_doc_skeleton.py, wiki_groomer.py

Most are environment-variable reads (feature flags, ablation switches, tuning constants) evaluated inside core; the wiki modules touch the filesystem.

Evidence required to close

python scripts/check_craftsmanship.py passes with the 17 os/pathlib layer-violation entries pruned from .craftsmanship-baseline.json, and the full test suite plus benchmarks/reproduce.sh --no-regression show no change in behavior.

Suggested remedy

Read the environment and the filesystem at the boundary (handlers or infrastructure, e.g. infrastructure/memory_config.py) and pass the resolved values into core as arguments or a frozen settings object. Moving the os.environ reads into shared/ would satisfy the import whitelist while keeping I/O on core's call path, so it is not an acceptable fix. Can land in several PRs (retrieval flags, ablation, wiki filesystem), each pruning its own baseline entries.

Activity

  1. added
    audit-findingFinding from the project's audit cycle (.github/ISSUE_TEMPLATE/audit-finding.yml)
    on Sep 15, 2026
  2. cdeust commented on Sep 15, 2026

    @cdeust
    OwnerAuthor

    Reopened: the squash commit of #569 (872855f) carried a closing keyword from one of its commits. Two of the three PRs are merged, #564 (2 modules) and #569 (6 modules). The remaining 9 modules (ablation.py and the retrieval env-flag modules) are in #568, which closes this issue when it merges. Its no-regression benchmark is running now.

  3. reopened this on Sep 15, 2026
  4. added a commit that references this issue on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    audit-findingFinding from the project's audit cycle (.github/ISSUE_TEMPLATE/audit-finding.yml)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions