Files
DeepTutor/tests/reading/test_mode_registration.py
Bingxi Zhao (Frank) 7c6bcfaef7 release: v1.5.14
Immersive Reading, self-configuration, and a two-way IMA library.

- Immersive Reading: a new capability that opens a document beside the
  thread. New reading engine (PDF pages / slides / page-sized sections),
  five reading tools, a deterministic locate pre-pass that grounds the
  turn without a second LLM call, /api/v1/reading, and a reader pane with
  selection, highlights, notes, and export to an annotated PDF or Markdown.
- Setup capability: inspect the install, apply a setting, install a
  parsing engine, or request a credential from a chat turn. New settings
  spec table; a candidate value is probed before it is committed, and API
  keys never enter the model's context.
- Tencent IMA: pipeline split into transport/envelope/models/sources/
  notes/media/inventory, an additive capability with five tools, and
  connected libraries that can finally be enumerated (bounded listings
  are reported as a lower bound).
- Retrieval: supports_rag_retrieval() replaces is_connected_kb() for the
  "can I sweep this?" question, so linked / lightrag_server / ima sources
  stop being silently dropped from every book.
- Notebooks: their own console at /notebook, per-notebook locks and atomic
  writes, copy / move / export routes, damaged files surfaced instead of
  dropped, and renaming a record no longer clears its knowledge-base link.
- Settings persistence: one lock and one atomic replace shared by every
  writer of interface.json; the PUT endpoints stop writing the
  defaults-merged view back to disk.

Release notes: assets/releases/ver1-5-14.md
2026-08-19 17:34:52 +08:00

66 lines
2.6 KiB
Python

"""The immersive-reading mode must be resolvable by the orchestrator.
This file exists because of a real failure: the loop capability and its tools
were registered, but the *mode* the composer sends as ``capability`` was not, so
every turn died with "Unknown capability: immersive_reading". The two registries
are separate on purpose — one holds modes the user picks, the other holds
turn-scoped loop capabilities — and nothing previously forced them to agree.
"""
from __future__ import annotations
import pytest
from deeptutor.capabilities.reading import READING_TOOL_NAMES
from deeptutor.capabilities.registry import LOOP_CAPABILITIES, capability_tool_owners
from deeptutor.runtime.bootstrap.builtin_capabilities import BUILTIN_CAPABILITY_CLASSES
from deeptutor.runtime.registry.capability_registry import get_capability_registry
def test_immersive_reading_is_a_resolvable_mode() -> None:
registry = get_capability_registry()
capability = registry.get("immersive_reading")
assert capability is not None, (
"the composer sends capability='immersive_reading'; without a registered "
"mode the orchestrator rejects the turn before it starts"
)
assert capability.manifest.name == "immersive_reading"
@pytest.mark.parametrize("name", sorted(BUILTIN_CAPABILITY_CLASSES))
def test_every_declared_mode_loads_and_reports_its_own_name(name: str) -> None:
"""A typo in the class path or a mismatched manifest name fails here.
Both are silent otherwise: the mode simply disappears from the list and the
only symptom is a rejected turn.
"""
capability = get_capability_registry().get(name)
assert capability is not None, f"{name} is declared but does not load"
assert capability.manifest.name == name
def test_the_reading_mode_and_its_loop_capability_are_both_registered() -> None:
"""The feature needs both halves: the mode routes the turn, the loop
capability supplies the tools once a document is open."""
assert get_capability_registry().get("immersive_reading") is not None
assert any(cap.name == "immersive_reading" for cap in LOOP_CAPABILITIES)
def test_reading_tools_are_attributed_to_the_reading_capability() -> None:
owners = capability_tool_owners()
for tool in READING_TOOL_NAMES:
assert owners.get(tool) == "immersive_reading", (
f"{tool} must be grouped under its owning capability in the settings UI"
)
def test_the_mode_declares_the_tools_it_actually_mounts() -> None:
manifest = get_capability_registry().get("immersive_reading").manifest
for tool in READING_TOOL_NAMES:
assert tool in manifest.tools_used