Commit e1a088a
feat(wiki): richer multi-axis classification (ADR-2244 Phase 1) (#27)
Replace the single ``kind`` axis with a 4-tuple
``(kind, lifecycle, audience, provenance) + tags``. Solves the audit
finding (2026-05-12) that 92% of the methodology wiki was stuck in the
``notes`` catch-all because the 9-kind taxonomy was too coarse and had
no facet dimensions.
Schema (ADR-2244 §4):
kind exclusive — one of {tutorial, how-to, reference,
explanation, adr, runbook, rfc, journal}
lifecycle facet — {seedling, draft, active, deprecated, archived}
or ADR-only {proposed, accepted, rejected,
superseded}
audience facet — multi-valued, closed enum
{developer, ops, security, internal, external}
provenance facet — {human, ai-generated, imported, auto-generated};
ai/auto-generated require a full Generator
block {model, version, prompt_template,
generated_at}
tags free — capped ~50 controlled-vocab terms
What changed
------------
* ``mcp_server/shared/wiki_classification.py`` (new) — ``Classification``
+ ``Generator`` dataclasses, closed-enum constants, validators that
fail fast on invalid tuples, ``to_frontmatter()`` for serialization,
``normalize_legacy_kind`` for read-time backward compat.
* ``mcp_server/core/wiki_layout.py`` — split ``PAGE_KINDS`` into
``MODERN_PAGE_KINDS`` (8 ADR-2244 kinds) and ``LEGACY_PAGE_KINDS``
(6 pre-ADR kinds kept readable for the migration window).
* ``mcp_server/core/wiki_classifier.py`` — ``classify_memory`` now
returns a ``Classification | None`` (single function, no v1/v2
parallel per user direction 2026-05-12). New detection patterns
for tutorial, how-to, runbook, rfc, journal. Provenance and
audience inference. Legacy kind detection (adr/lesson/convention/
spec/note) is preserved as a private ``_classify_to_legacy_kind``
helper and mapped to modern kinds (lesson/convention/note all
collapse to ``explanation``; spec → ``rfc``).
* ``mcp_server/core/wiki_sync.py`` — routes via the 4-tuple, writes
modern frontmatter. **Fixes Task #8** (file→notes/ misroute,
7820 pages affected): file documentation from ``codebase_analyze``
now lands in ``reference/<domain>/`` with
``provenance=auto-generated`` instead of the silent ``notes/``
fallback caused by the old ``_KIND_TO_DIR`` having no ``file``
mapping.
* ``mcp_server/core/wiki_templates.py`` — 5 new templates
(tutorial, how-to, runbook, rfc, explanation). Required-frontmatter
contracts for every modern kind include the 4-tuple axes.
* ``mcp_server/handlers/wiki_purge.py`` — minimal update for the new
return shape (uses ``result.kind`` for reporting, ``None`` still
signals purge).
Backward compatibility
----------------------
Legacy directories (``notes/``, ``specs/``, ``conventions/``,
``lessons/``, ``guides/``, ``files/``) remain accepted by
``page_path`` / ``domain_page_path`` so existing pages stay
readable. ``normalize_legacy_kind`` maps legacy frontmatter kinds
to modern equivalents for callers that need a uniform view.
New writes go through the modern schema exclusively.
Tests
-----
* ``tests_py/shared/test_wiki_classification.py`` (new) — 24 tests
for Classification validation: empty audience rejected, unknown
audience rejected, ADR/non-ADR lifecycle disjoint, generator
block required for ai/auto-generated, frontmatter serialization,
legacy normalization.
* ``tests_py/core/test_wiki_classifier.py`` — extended with 7 tests
for tutorial/how-to/runbook/rfc/journal pattern detection plus
provenance and audience inference. Legacy
``test_valid_lesson_admitted`` updated to assert the new
``kind == "explanation"`` mapping per ADR-2244.
* ``tests_py/core/test_wiki_sync_routing.py`` (new) — 6 end-to-end
routing tests including the explicit Task #8 regression for
file-documentation routing.
* ``tests_py/core/test_wiki_layout.py`` — ``test_page_kinds_stable``
rewritten as ``test_page_kinds_modern_plus_legacy`` to assert the
new split.
Local run: ``pytest tests_py/core/ tests_py/shared/`` → 1964 passed.
Targeted ADR-2244 suite (85 tests) → all green. ``ruff format`` /
``ruff check`` → clean.
Research basis
--------------
docs/research/wiki-classification-survey.md — literature survey
(Cochrane-style synthesis) across 14 mature documentation systems
(Diátaxis, DITA, Cloudflare, MediaWiki, Confluence, Backstage,
Nygard/MADR, digital gardens, SRE conventions, Ranganathan, …).
Every schema dimension is grounded in ≥2 prior systems. GRADE
certainty: moderate — strong convergence in practice, but no
controlled study comparing single-axis vs. multi-axis findability.
Recommend a ~100-page pilot migration (Phase 2) before bulk
rollout (Phase 4).
ADR
---
adr/_general/2244-richer-wiki-classification.md (in the methodology
wiki). Accepted 2026-05-12. Phase 1 = this PR; Phases 2–6 (pilot
migration → stable IDs → bulk migration → cleanup → producer
audit) follow.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f9fab48 commit e1a088a
11 files changed
Lines changed: 1426 additions & 49 deletions
File tree
- docs/research
- mcp_server
- core
- handlers
- tests_py
- core
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
446 | | - | |
447 | | - | |
| 446 | + | |
| 447 | + | |
448 | 448 | | |
449 | | - | |
450 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
451 | 453 | | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
| 454 | + | |
| 455 | + | |
463 | 456 | | |
464 | 457 | | |
465 | 458 | | |
| |||
508 | 501 | | |
509 | 502 | | |
510 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
511 | 509 | | |
512 | 510 | | |
| 511 | + | |
513 | 512 | | |
514 | 513 | | |
515 | 514 | | |
| |||
521 | 520 | | |
522 | 521 | | |
523 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
524 | 538 | | |
525 | 539 | | |
526 | 540 | | |
| |||
562 | 576 | | |
563 | 577 | | |
564 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
565 | 787 | | |
566 | 788 | | |
567 | 789 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
23 | 40 | | |
24 | 41 | | |
25 | | - | |
26 | 42 | | |
27 | 43 | | |
28 | 44 | | |
29 | | - | |
30 | 45 | | |
31 | 46 | | |
32 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
33 | 53 | | |
34 | 54 | | |
35 | 55 | | |
| |||
0 commit comments