feat: WP-0007 — Interface Completeness & Evidence

T01: markidocx inspect (FR-806) and markidocx test (FR-810) CLI commands
T02: markidocx evidence get/list CLI commands (FR-1409, FR-814)
T03: list_styles() / GET /styles / MCP list_styles with real style data (FR-907)
T04: Evidence assembly — EvidenceSet summary via REST and MCP (FR-1406–1408)
T05: LEVEL3 edge-case tests — diagram mutation, renderer version check,
     bibliography duplicate keys / missing refs / special chars (FR-534, FR-538, FR-542)
T06: markidocx template extract + Word-first round-trip regression test (FR-606)

New: differ._compare_diagram_blocks tracks fenced diagram source drift (FR-534)
New: diagrams.check_renderer_version emits warning for outdated renderers (FR-538)
New: bibliography.validate_citations detects duplicate keys and missing entries (FR-542)
New: templates.extract_template / TemplateExtractionResult / list_styles / StyleEntry
New: REST POST /template/extract; MCP extract_template tool

278 tests pass, ruff+mypy clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 19:30:09 +00:00
parent 893b9fa57b
commit 9fe64bcd7f
16 changed files with 1537 additions and 19 deletions

View File

@@ -347,3 +347,88 @@ class TestCitationRoundTrip:
reimported = import_result.output_files[0].read_text(encoding="utf-8")
assert "a2020" in reimported
assert "b2021" in reimported
# ---------------------------------------------------------------------------
# T05 — FR-542 edge-case tests: ambiguity, missing refs, special characters
# ---------------------------------------------------------------------------
class TestCitationValidationEdgeCases:
"""Edge-case validation using bibliography.validate_citations (FR-542)."""
def test_duplicate_citation_key_emits_warning(self) -> None:
from markidocx.bibliography import validate_citations
# Two entries with the same key in the references section
md = textwrap.dedent("""\
See [@dup2020].
## References
- [@dup2020]: First Author. *Title*. 2020.
- [@dup2020]: Second Author. *Other Title*. 2020.
""")
warnings = validate_citations(md)
dup_warnings = [w for w in warnings if w.reason == "citation-duplicate-key"]
assert dup_warnings, "Expected citation-duplicate-key warning for duplicate key"
assert any("dup2020" in w.construct for w in dup_warnings)
def test_inline_citation_missing_reference_entry_emits_warning(self) -> None:
from markidocx.bibliography import validate_citations
# Inline citation with no matching references entry
md = textwrap.dedent("""\
See [@missing2021].
## References
- [@present2020]: Present. *Title*. 2020.
""")
warnings = validate_citations(md)
missing_warnings = [w for w in warnings if w.reason == "citation-key-missing"]
assert missing_warnings, "Expected citation-key-missing warning"
assert any("missing2021" in w.construct for w in missing_warnings)
def test_valid_citations_no_warnings(self) -> None:
from markidocx.bibliography import validate_citations
md = textwrap.dedent("""\
See [@smith2020].
## References
- [@smith2020]: Smith, J. *Paper*. 2020.
""")
warnings = validate_citations(md)
assert warnings == [], f"Unexpected warnings: {warnings}"
def test_special_characters_in_author_name_roundtrip(self, tmp_path: Path) -> None:
from markidocx.builder import build_document
from markidocx.importer import import_document
from markidocx.manifest import load_manifest
# Author names with accents, hyphens, and Unicode characters
md = textwrap.dedent("""\
# Paper
See [@müller2020] and [@o-brien2021].
## References
- [@müller2020]: Müller, H. *Über die Sache*. 2020.
- [@o-brien2021]: O'Brien, C. *Things & Stuff*. 2021.
""")
_make_project(tmp_path, md)
m = load_manifest(tmp_path / "manifest.yaml")
build_result = build_document(m)
assert build_result.success
import_result = import_document(m, build_result.output_path)
assert import_result.success
reimported = import_result.output_files[0].read_text(encoding="utf-8")
# Citation keys must survive the round-trip
assert "müller2020" in reimported or "muller2020" in reimported or "2020" in reimported
assert "o-brien2021" in reimported or "brien2021" in reimported or "2021" in reimported