refactor(core): split wiki_classifier and wiki_axis_registry under the 500-line limit - #153
Merged
Merged
Conversation
Split mcp_server/core/wiki_classifier.py (922 lines, over the 500-line hard limit in coding-standards.md §4.1) along four cohesive concerns: - wiki_classifier_patterns.py — pure regex/constant tables (reject, legacy-kind, hard-negative, audit-tag, positive-signal patterns) - wiki_classifier_gates.py — admission gate functions that consume those tables (fails_hard_negatives, fails_audit_tag_gate, positive_score) - wiki_title.py — title derivation (derive_title, slugify), a distinct concern from kind classification - wiki_kind_detection.py — ADR-2244 modern kind/lifecycle/audience/ provenance detection, delegating to wiki_axis_registry wiki_classifier.py keeps admission orchestration (_classify_to_legacy_kind), the user-rules reverse-DI provider (left in place because tests_py/core/test_wiki_classifier.py monkeypatches its module globals directly), and the public classify_memory / derive_title entry points — all public import paths continue to work unchanged. Before: 922 lines (1 file) After: 331 + 306 + 131 + 132 + 118 = 1018 lines (5 files, each < 500) Tests: 468 passed before, 468 passed after (0 modified); 1 pre-existing env failure (missing psycopg) unrelated to this change, present before and after. Boy-scout: fixed a stale docstring reference in recall_helpers.py that pointed at the old wiki_classifier._AUDIT_TAGS location. Refs #134 Co-Authored-By: Claude <noreply@anthropic.com>
Split mcp_server/core/wiki_axis_registry.py (705 lines, over the 500-line hard limit in coding-standards.md §4.1) into: - wiki_axis_defaults.py — the bootstrap seed AxisValue data for every axis (DEFAULT_KINDS, DEFAULT_LIFECYCLES, DEFAULT_AUDIENCES, DEFAULT_PROVENANCES) — pure data, no registry mechanics - wiki_axis_registry.py — keeps the AxisValue/AxisRegistry data model, schema-file parsing, lookup helpers (match_axis, did_you_mean), and the reverse-DI wiki-root provider (left in place because tests_py/core/test_wiki_axis_registry.py monkeypatches its module global directly) build_default_registry() imports wiki_axis_defaults lazily (function-local) rather than at module top, because wiki_axis_defaults imports AxisValue/AXIS_* back from wiki_axis_registry to build its seed data — a module-level import would be circular. Before: 705 lines (1 file) After: 408 + 340 = 748 lines (2 files, each < 500) Tests: 468 passed before, 468 passed after (0 modified); 1 pre-existing env failure (missing psycopg) unrelated to this change, present before and after. Boy-scout: fixed a stale docstring reference in wiki_seed_codebase.py that pointed at the old wiki_axis_registry._DEFAULT_KINDS location. Refs #134 Co-Authored-By: Claude <noreply@anthropic.com>
5 tasks
cdeust
added a commit
that referenced
this pull request
Jul 17, 2026
…ps bump (#154) * chore(release): prepare v4.14.3 (fix write-gate, launcher-deps; deps bump; refactor split) Bump version 4.14.2 -> 4.14.3 across pyproject.toml, .claude-plugin/plugin.json, .claude-plugin/marketplace.json (SemVer patch: 4 fix/chore/refactor commits since v4.14.2, no new features -- #147/#148, #149/#150, #152, #134/#153). CHANGELOG.md: new [4.14.3] entry per Keep a Changelog, dated 2026-07-17, with a PENDING placeholder in the Verified section for the mandatory pre-tag benchmarks/reproduce.sh non-regression evidence (user mandate 2026-07-10) -- this commit prepares the release, it does not run the bench or cut the tag. marketplace.json version_note for the cortex plugin entry updated to match, same PENDING placeholder. zetetic-team-subagents cross-reference (2.28.1) left unchanged: no open release PR found on cdeust/zetetic-team-subagents and its latest tag (v2.28.1) already matches the pinned version. Co-Authored-By: Claude <noreply@anthropic.com> * chore(release): commit v4.14.3 pre-tag bench evidence and adjudication Pre-tag guard on the exact release tree 4e3a202: LongMemEval MRR 0.9166/R@10 0.9820 PASS; LoCoMo 3-run mean MRR 0.7998/R@10 0.9135 — MRR mean sits 0.0002 below the floor-tolerance threshold and was adjudicated as sampling noise by explicit maintainer decision (delta vs 4.14.2 mean −0.0011 < SEM ~0.0013; rep1 0.8013 vs 0.8015; reranker loaded in all MANIFESTs; no released commit in the LoCoMo harness dependency graph — ingestion via BenchmarkDB, not the #148 write path). BEAM 0.5417, inside the documented noise band. Evidence: benchmarks/results/repro/20260717-v4.14.3-pretag/. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BxpvWMSYo2FLCw4c1xw7iJ --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #134.
Both files exceeded the 500-line hard limit (coding-standards §4.1). Behavior-preserving decomposition along concern boundaries — no logic changes, no test modifications.
Decomposition
mcp_server/core/wiki_classifier.pymcp_server/core/wiki_classifier_patterns.pymcp_server/core/wiki_classifier_gates.pymcp_server/core/wiki_title.pymcp_server/core/wiki_kind_detection.pymcp_server/core/wiki_axis_registry.pymcp_server/core/wiki_axis_defaults.pyReverse-DI ports kept in their original modules: existing tests monkeypatch those module globals directly; relocating them would silently break the monkeypatches.
Circular-import constraint:
build_default_registry()importswiki_axis_defaultslazily (function-local) — defaults needAxisValue/AXIS_*from the registry while the registry needs the seed data.Verification
uv run pytest tests_py/ -q -k "wiki": 468 passed, identical to pre-refactor baseline (1 pre-existing psycopg env failure, verified failing before any edit).uv run ruff check .anduv run ruff format --check .: clean repo-wide.Boy-scout (same PR)
handlers/recall_helpers.py: stale docstringwiki_classifier._AUDIT_TAGS→wiki_classifier_patterns.AUDIT_TAGS.handlers/wiki_seed_codebase.py: stale docstringwiki_axis_registry._DEFAULT_KINDS→wiki_axis_defaults.DEFAULT_KINDS.🤖 Generated with Claude Code
https://claude.ai/code/session_01BxpvWMSYo2FLCw4c1xw7iJ