You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 514d106
Browse filesBrowse the repository at this point in the historyBrowse files
fix(core): remove pathlib from abstention_gate and codebase_graph (#560)
core/ must be zero-I/O and may not import os/pathlib
(docs/module-inventory.md, Dependency Rules table), but both modules did:
- codebase_graph.py used PurePosixPath purely for string manipulation
(path normalization and dirname) with no filesystem access. Replaced
with local pure-string helpers (_posix_normalize/_posix_parent) whose
equivalence to PurePosixPath is pinned by a new test
(TestPosixPathHelpers). Zero blast radius: no caller signature changed.
- abstention_gate.py used Path.home()/".cache"/... to locate and load an
optional ML model file, which is genuine filesystem I/O. Moved that
read into a new mcp_server/infrastructure/abstention_classifier.py
(load_abstention_classifier), and core now accepts an injectable
classifier_factory callable (None by default, matching the historical
"package not installed" fallback). This module has no production caller
today (verified repo-wide grep; only its own tests exercise it, despite
ADR-0097 documenting intent) so there is no composition root to wire yet;
whoever wires it into retrieval later passes
classifier_factory=load_abstention_classifier from the handler.
Pruned exactly the 3 now-stale layer-violation baseline entries for
these two files (pathlib x2, cortex_beam_abstain x1); left the other
pre-existing, unrelated baseline entries for these files untouched
(method-size, unsourced-constant, networkx layer-violation; none of
these reproduce differently after this change).
Part of #560 (17 core/ modules import os/pathlib); 15 remain, tracked
for follow-up PRs (ablation.py's is_mechanism_disabled alone fans out to
about 30 call sites and needs its own dedicated pass).
Verified: scripts/check_craftsmanship.py --base origin/main returns OK;
grep for os/pathlib in the two touched files returns empty; ruff
check/format are clean; pyright mcp_server/ reports 0 errors; full
pytest reports 8118 passed, 290 skipped, 1 pre-existing failure
(test_pg_driver_passes_in_dev_env, reproduces identically on unmodified
origin/main under this same --extra dev --extra sqlite sync since no
postgresql extra is installed, per the contract's prescribed env;
unrelated to this change).
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
0 commit comments