Skip to content

refactor(core): split wiki_classifier and wiki_axis_registry under the 500-line limit - #153

Merged
cdeust merged 2 commits into
mainfrom
fix/issue-134-file-size-limits
Jul 17, 2026
Merged

refactor(core): split wiki_classifier and wiki_axis_registry under the 500-line limit#153
cdeust merged 2 commits into
mainfrom
fix/issue-134-file-size-limits

Conversation

@cdeust

@cdeust cdeust commented Jul 16, 2026

Copy link
Copy Markdown
Owner

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

File Before After
mcp_server/core/wiki_classifier.py 922 331 (orchestration + user-rules reverse-DI port)
mcp_server/core/wiki_classifier_patterns.py 306 (pure regex/constant tables)
mcp_server/core/wiki_classifier_gates.py 131 (admission gates consuming those tables)
mcp_server/core/wiki_title.py 132 (title derivation)
mcp_server/core/wiki_kind_detection.py 118 (ADR-2244 axis detection)
mcp_server/core/wiki_axis_registry.py 705 408 (data model + schema parsing + lookup)
mcp_server/core/wiki_axis_defaults.py 340 (bootstrap seed data only)

Reverse-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() imports wiki_axis_defaults lazily (function-local) — defaults need AxisValue/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 . and uv run ruff format --check .: clean repo-wide.
  • All 7 files ≤500 lines; imports verified clean.

Boy-scout (same PR)

  • handlers/recall_helpers.py: stale docstring wiki_classifier._AUDIT_TAGSwiki_classifier_patterns.AUDIT_TAGS.
  • handlers/wiki_seed_codebase.py: stale docstring wiki_axis_registry._DEFAULT_KINDSwiki_axis_defaults.DEFAULT_KINDS.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BxpvWMSYo2FLCw4c1xw7iJ

cdeust and others added 2 commits July 17, 2026 01:31
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>
@cdeust
cdeust merged commit ee3173d into main Jul 17, 2026
14 checks passed
@cdeust
cdeust deleted the fix/issue-134-file-size-limits branch July 17, 2026 05:22
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core/wiki_classifier.py and core/wiki_axis_registry.py exceed 500-line file limit

1 participant