DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
chore(tests): keep regression coverage without internal audit artifacts
Bingxi Zhao (Frank)210163a19920
diff --git a/evidence/co-writer-tests-20261003/README.md b/evidence/co-writer-tests-20261003/README.mddeleted file mode 100644index 600b3e043..000000000--- a/evidence/co-writer-tests-20261003/README.md+++ /dev/null@@ -1,72 +0,0 @@-# co_writer 路由契约补测 — 证据(2026-10-03)--对应任务卡:AGEN-289(test: co_writer 路由契约补测,覆盖率备选 20)。-基线:`origin/main` @ `ef2d9e5c3`(release: v1.6.12),来自 `audit/coverage-gaps-20261003` 证据的备选节:-`deeptutor/api/routers/co_writer.py` — 246 缺失 / 40.0%。--## 产物--- 测试文件:`tests/api/routers/test_co_writer_contract.py`(新增目录 `tests/api/routers/`,含空 `__init__.py`)-- 分支:`myfork/test/co-writer-contract-20261003`(基于 origin/main @ ef2d9e5c3)-- 本目录:`evidence/co-writer-tests-20261003/`(说明 + 完整 pytest 输出)--## 测试命令与数字--```bash-python -m pytest tests/api/routers/test_co_writer_contract.py -v-# 40 passed in 0.51s--python -m pytest tests/api/routers/test_co_writer_contract.py tests/api/test_co_writer.py -q-# 74 passed(与既有 co_writer 测试同跑无互相污染)--ruff check tests/api/routers/test_co_writer_contract.py # 通过-ruff format --check 同文件 # 通过-```--运行环境:/Users/Shared/DeepTutor/.venv(Python 3.13.13, fastapi 0.141.1, pydantic 2.13.4, pytest 9.1.1)。--## 结论(跑通:PASS)--40/40 通过,0 失败。当前 origin/main 实现已满足本卡锁定的全部契约,**没有产生需要修复卡的失败用例**——"失败测试集"在此为空集;本集合的价值是把 40.0% 的路由契约空白固化为回归保护,后续任何改动破坏契约时会立即转红。--## 契约覆盖清单--会话/草稿 CRUD 请求形状(13 例)-- POST /documents:完整响应形状 {id,title,content,created_at,updated_at};id 满足 ^[0-9a-f]{8,32}$;无标题时从首个 heading 派生;空请求体默认 "Untitled draft"-- GET /documents:仅返回 summary 视图(无 content 字段),按 updated_at 倒序,preview 截断 ≤161 字符并以 … 结尾-- GET/PUT/DELETE /documents/{id}:读写删除与持久化一致性;PUT 空对象为 no-op(字段保留)-- 未知/畸形 doc id(合法形状缺失、大写、非 hex、过短、过长)在三条路由上一律 404,detail 为 "Document not found";DELETE 后重复删除 404(非幂等契约固化)--非法 payload 4xx(10 例)-- EditRequest:缺 text/instruction、非法 action/source 字面量、text 超 600,000、instruction 超 10,000 → 422,且验证失败不触达 agent-- ReactEditRequest:非法 mode/tools 字面量、selected_text 超 120,000 → 422;mode=none 且空 instruction → 400;空白选区 → 400-- edit-react/stream 预检:非法 payload 在进入 SSE 之前以 JSON 4xx 返回(不产生 event: 流)-- ExportDocxRequest:content 超 600,000 → 422-- CreateDocumentRequest/UpdateDocumentRequest:非字符串字段 → 422-- import/docx:.doc 与非 .docx 后缀 → 400;空文件 → 400(detail 含 "empty")--导出/导入失败分支(4 例)-- export:converter 抛 DocxConversionError → 400(detail 透传);抛任意异常 → 500-- export:Content-Disposition 对 `\/:*?"<>|` 等不安全字符统一替换为 "-"(filename="a-b-c-d-e-f-g-h-i.docx")-- import:真实损坏字节 → 400(真实 DocxConversionError 路径);converter 抛任意异常 → 500--Edit 动作与 agent 契约(7 例)-- /documents/actions/edit:请求字段逐一透传给 agent(text/instruction/action/source/kb_name),响应锁定 {edited_text, operation_id}-- /documents/actions/automark:text 透传,响应 {marked_text, operation_id}-- agent 抛异常 → edit/automark 均 500 且 detail 含原始异常信息-- edit-react:输出围栏剥离(```markdown…``` → 纯文本)、tools_used 上报、operation_id 形如 \d{8}_\d{6}_[0-9a-f]{6};rag 无 kb_name 时跳过、重复 tool 去重、kb_name 透传 gather_context;每次编辑落 history(action=react_edit)--history / tool-calls 端点(2 例)-- GET /documents/history → {history, total};GET /documents/history/{id} → 单条或 404 "Operation not found"-- GET /documents/tool-calls/{id} → 读取 {op}_*.json 或 404 "Tool call not found"--## 隔离与安全--- 存储经 monkeypatch 指向 tmp_path(_StubPathService),agent 为纯 stub,history/tool-calls 写入 tmp_path,不触碰真实 workspace、不发起任何 LLM 调用。-- 沿用 tests/api/test_co_writer.py 的模块级 load_config_with_main 桩(新 worktree 缺 data/user/settings/main.yaml,router 导入期需要)。-- 未修改任何产品代码(git diff 仅新增测试与证据文件)。--## 备注--- `markdown_to_docx` 实际不抛 DocxConversionError,export 的 400 分支当前不可自然触达(测试通过 monkeypatch 验证该分支行为正确);这属于现状记录,不构成缺陷。-- 遵守卡面规则:不向上游开 PR;PR 草稿标题/描述见完成评论,由人决定是否提交。diff --git a/evidence/co-writer-tests-20261003/pytest-run.txt b/evidence/co-writer-tests-20261003/pytest-run.txtdeleted file mode 100644index 80eae8b10..000000000--- a/evidence/co-writer-tests-20261003/pytest-run.txt+++ /dev/null@@ -1,51 +0,0 @@-============================= test session starts ==============================-platform darwin -- Python 3.13.13, pytest-9.1.1, pluggy-1.6.0 -- /Users/Shared/DeepTutor/.venv/bin/python-cachedir: .pytest_cache-rootdir: /Users/xzh/services/ai-development/multica-pilot/workspaces/agents-plan-5fede2af789a/agen-289-c9175b250985/workdir/dt-cowriter-wt-configfile: pyproject.toml-plugins: cov-7.1.0, devtools-0.12.2, asyncio-1.4.0, anyio-4.14.2-asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function-collecting ... collected 40 items--tests/api/routers/test_co_writer_contract.py::test_create_document_returns_full_document_shape PASSED [ 2%]-tests/api/routers/test_co_writer_contract.py::test_create_document_without_title_derives_it_from_first_heading PASSED [ 5%]-tests/api/routers/test_co_writer_contract.py::test_create_document_with_empty_body_uses_defaults PASSED [ 7%]-tests/api/routers/test_co_writer_contract.py::test_create_document_rejects_non_string_fields PASSED [ 10%]-tests/api/routers/test_co_writer_contract.py::test_list_documents_returns_summary_views_without_content PASSED [ 12%]-tests/api/routers/test_co_writer_contract.py::test_list_documents_truncates_preview_at_160_chars PASSED [ 15%]-tests/api/routers/test_co_writer_contract.py::test_get_document_returns_persisted_content PASSED [ 17%]-tests/api/routers/test_co_writer_contract.py::test_update_document_applies_title_and_content PASSED [ 20%]-tests/api/routers/test_co_writer_contract.py::test_update_document_with_empty_object_keeps_fields PASSED [ 22%]-tests/api/routers/test_co_writer_contract.py::test_update_document_rejects_non_string_title PASSED [ 25%]-tests/api/routers/test_co_writer_contract.py::test_delete_document_returns_deleted_true_then_404 PASSED [ 27%]-tests/api/routers/test_co_writer_contract.py::test_unknown_or_malformed_doc_ids_return_404_on_crud_routes[ffffffffffff] PASSED [ 30%]-tests/api/routers/test_co_writer_contract.py::test_unknown_or_malformed_doc_ids_return_404_on_crud_routes[A1B2C3D4E5F6] PASSED [ 32%]-tests/api/routers/test_co_writer_contract.py::test_unknown_or_malformed_doc_ids_return_404_on_crud_routes[g1b2c3d4e5f6] PASSED [ 35%]-tests/api/routers/test_co_writer_contract.py::test_unknown_or_malformed_doc_ids_return_404_on_crud_routes[abc123] PASSED [ 37%]-tests/api/routers/test_co_writer_contract.py::test_unknown_or_malformed_doc_ids_return_404_on_crud_routes[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 40%]-tests/api/routers/test_co_writer_contract.py::test_not_found_details_name_the_document PASSED [ 42%]-tests/api/routers/test_co_writer_contract.py::test_edit_action_rejects_missing_fields_and_bad_literals PASSED [ 45%]-tests/api/routers/test_co_writer_contract.py::test_edit_action_rejects_oversized_text_and_instruction PASSED [ 47%]-tests/api/routers/test_co_writer_contract.py::test_react_edit_rejects_invalid_mode_tools_and_oversized_selection PASSED [ 50%]-tests/api/routers/test_co_writer_contract.py::test_react_edit_requires_instruction_when_mode_is_none PASSED [ 52%]-tests/api/routers/test_co_writer_contract.py::test_react_edit_requires_a_non_blank_selection PASSED [ 55%]-tests/api/routers/test_co_writer_contract.py::test_react_edit_stream_rejects_bad_payloads_before_streaming PASSED [ 57%]-tests/api/routers/test_co_writer_contract.py::test_export_docx_rejects_oversized_content PASSED [ 60%]-tests/api/routers/test_co_writer_contract.py::test_import_docx_rejects_missing_unsupported_and_empty_files PASSED [ 62%]-tests/api/routers/test_co_writer_contract.py::test_export_docx_returns_400_when_converter_reports_bad_input PASSED [ 65%]-tests/api/routers/test_co_writer_contract.py::test_export_docx_returns_500_on_unexpected_converter_error PASSED [ 67%]-tests/api/routers/test_co_writer_contract.py::test_export_docx_sanitizes_unsafe_title_in_content_disposition PASSED [ 70%]-tests/api/routers/test_co_writer_contract.py::test_import_docx_returns_400_for_corrupt_upload PASSED [ 72%]-tests/api/routers/test_co_writer_contract.py::test_import_docx_returns_500_on_unexpected_conversion_error PASSED [ 75%]-tests/api/routers/test_co_writer_contract.py::test_edit_action_forwards_request_fields_to_agent PASSED [ 77%]-tests/api/routers/test_co_writer_contract.py::test_edit_action_maps_agent_exception_to_500 PASSED [ 80%]-tests/api/routers/test_co_writer_contract.py::test_automark_forwards_text_and_returns_payload PASSED [ 82%]-tests/api/routers/test_co_writer_contract.py::test_automark_maps_agent_exception_to_500 PASSED [ 85%]-tests/api/routers/test_co_writer_contract.py::test_react_edit_strips_output_fence_and_reports_tools_used PASSED [ 87%]-tests/api/routers/test_co_writer_contract.py::test_react_edit_skips_rag_tool_without_kb_name_and_deduplicates PASSED [ 90%]-tests/api/routers/test_co_writer_contract.py::test_react_edit_forwards_kb_name_to_rag_gather PASSED [ 92%]-tests/api/routers/test_co_writer_contract.py::test_react_edit_records_history_entry PASSED [ 95%]-tests/api/routers/test_co_writer_contract.py::test_history_endpoints_return_recorded_operations PASSED [ 97%]-tests/api/routers/test_co_writer_contract.py::test_tool_call_endpoint_serves_recorded_payload PASSED [100%]--============================== 40 passed in 0.51s ==============================diff --git a/evidence/launcher-tests-20261003/README.md b/evidence/launcher-tests-20261003/README.mddeleted file mode 100644index a0318809d..000000000--- a/evidence/launcher-tests-20261003/README.md+++ /dev/null@@ -1,53 +0,0 @@-# launcher 生命周期边界补测 · 2026-10-03(AGEN-287)--## 基线与运行环境--| 项 | 值 |-|---|---|-| 代码基线 | `origin/main` @ `ef2d9e5c3`(release: v1.6.12) |-| 分支 | `myfork/test/launcher-lifecycle-20261003` |-| Python | 3.13.13(复用主 checkout `.venv`,只读,未改动) |-| pytest | 9.1.1(pytest-cov 7.1.0) |-| 新增文件 | `tests/runtime/test_launcher_lifecycle.py`(19 个用例) |-| 产品代码 | 零改动;全部子进程 mock,未启动任何真实服务 |--## 覆盖范围--对应覆盖率缺口:`deeptutor/runtime/launcher.py`(295 缺失 / 66.7%)。--1. **`_send_tree_signal` 树终止原语**(POSIX killpg / 单 PID 回退 / 缺 PID 忽略 / Windows taskkill 仅在 KILL 时加 `/F`)-2. **`_terminate` 树终止**:已退出进程跳过、SIGTERM → wait 成功、wait 超时升级 KILL_SIGNAL、信号异常吞掉后仍 reap-3. **`_kill_port_listeners` 端口清理**:SIGTERM 释放端口(只发一轮)、端口持续占用时升级 KILL、始终不释放时记录失败日志、信号异常容错(不中断清理循环)-4. **标记文件损坏容错**:- - `_copy_packaged_web_if_needed`:marker 非法 JSON → 重建缓存(rmtree + copytree + 占位符替换 + 重写合法 marker);合法 marker → 命中缓存不重建- - `_ensure_source_production_build`:marker 损坏 → 触发重建且 `next-env.d.ts` 快照恢复;重建后 marker 合法 → 复用- - `_read_detached_state`:文件缺失 / 非法 JSON / 非 dict 载荷 → 一律返回 None- - `_clear_detached_runtime`:token 不匹配保留文件;token 匹配清除 state + stop;仅 stop 匹配时消费 stop--## 复跑命令(在仓库根目录执行)--```bash-PYTHONPATH=. python -m pytest tests/runtime/test_launcher_lifecycle.py -q--# launcher 相关全套 + 覆盖率(基线与对照)-PYTHONPATH=. python -m pytest tests/runtime/test_launcher.py \- tests/runtime/test_launcher_allocator_env.py \- tests/runtime/test_macos_command_launcher.py \- tests/runtime/test_launcher_lifecycle.py \- -q --cov=deeptutor.runtime.launcher --cov-report=term-missing-```--## 结果数字--- 新增用例:**19 passed**(0.3s 内,无网络、无子进程、无端口监听)-- launcher 相关全套(新旧合计 57 用例):**57 passed**-- `tests/runtime/` 全目录回归:**219 passed / 4 skipped**(连续 3 次稳定)-- `launcher.py` 行覆盖:**295 缺失 / 66.7% → 262 缺失 / 70.4%**(本组用例新覆盖 33 行语句)--对照文件:`coverage-before.txt`(仅既有 3 个 launcher 测试文件)、`coverage-after.txt`(含本卡新增文件)。--## 备注--- 时间控制:`_kill_port_listeners` 的等待循环用可快进的 `time.monotonic`/`time.sleep` 替身,避免真实 sleep。-- 既有 `test_launcher.py` 已覆盖 `_kill_port_listeners` 的间接 happy path 与 `_ensure_source_production_build` 的正常复用/输入变更重建;本卡只补损坏容错与终止/清理分支,无重复。-- 未发现上游已有关联 PR(`HKUDS/DeepTutor` 检索 "launcher" 全状态 PR,无生命周期补测类 PR)。diff --git a/evidence/launcher-tests-20261003/coverage-after.txt b/evidence/launcher-tests-20261003/coverage-after.txtdeleted file mode 100644index 398bfc49a..000000000--- a/evidence/launcher-tests-20261003/coverage-after.txt+++ /dev/null@@ -1,10 +0,0 @@-......................................................... [100%]-================================ tests coverage ================================-______________ coverage: platform darwin, python 3.13.13-final-0 _______________--Name Stmts Miss Cover Missing---------------------------------------------------------------deeptutor/runtime/launcher.py 886 262 70% 103-104, 142-159, 165-168, 172, 267-268, 294-296, 316, 337-362, 368, 378-379, 382-392, 396-412, 420, 427-429, 433-434, 437, 447-449, 452, 456-463, 515, 549, 581, 583, 597-598, 602-607, 671-672, 681-685, 806, 811, 822, 827, 834, 849-857, 863, 869, 886, 894, 897-898, 904, 907-908, 915, 919-920, 922, 924, 926, 934, 946, 949, 963-978, 982-983, 992-1024, 1033-1037, 1042-1043, 1061-1062, 1088-1089, 1126, 1157-1169, 1178-1179, 1188-1191, 1203-1204, 1227-1228, 1230, 1236-1237, 1248-1254, 1266-1267, 1269, 1293-1294, 1301, 1344-1350, 1352, 1386, 1483-1487, 1495, 1501, 1527, 1530-1532, 1543-1577, 1579, 1583-1584---------------------------------------------------------------TOTAL 886 262 70%-57 passed in 2.11sdiff --git a/evidence/launcher-tests-20261003/coverage-before.txt b/evidence/launcher-tests-20261003/coverage-before.txtdeleted file mode 100644index cb1cb2d66..000000000--- a/evidence/launcher-tests-20261003/coverage-before.txt+++ /dev/null@@ -1,10 +0,0 @@-...................................... [100%]-================================ tests coverage ================================-______________ coverage: platform darwin, python 3.13.13-final-0 _______________--Name Stmts Miss Cover-----------------------------------------------------deeptutor/runtime/launcher.py 886 295 67%-----------------------------------------------------TOTAL 886 295 67%-38 passed in 2.06sdiff --git a/evidence/pr/AGEN-127.md b/evidence/pr/AGEN-127.mddeleted file mode 100644index 0a27dce89..000000000--- a/evidence/pr/AGEN-127.md+++ /dev/null@@ -1,34 +0,0 @@-# PR: test(book): cover engine stage transitions--## Summary--- Adds `tests/book/test_engine_stage_transitions.py` (+495 lines): regression coverage for the three guarantees a long book-generation run depends on in `deeptutor/book/engine.py` — stage order with per-stage artefact persistence, single-stage failure retry without duplicating output, and pause/resume recovery that never re-pays finished pages.-- Pure test addition: no product code is touched, no API or behavior change.-- All agents (ideation/exploration/synthesizer/compiler) are replaced by lightweight async fakes — no LLM calls, no network, ~0.5s per run.--## Root cause--`deeptutor/book/engine.py` drives the longest-running generation flow in the project but had only 43% line coverage in the `tests/book` scope (535 of 945 statements uncovered, DT-21 Top-15 gap #6). The stage-transition invariants — every stage persists its artefacts before advancing, retries do not re-pay or duplicate work, and a user pause mid-compile is fully recoverable — were not pinned by any test, so a regression in the state machine would surface only in real multi-hour runs.--## Changes--- `tests/book/test_engine_stage_transitions.py` (+495): 4 tests with a shared FakeStorage + FakeCompiler harness:- - `test_stages_advance_in_order_and_persist_each_artefact` — create_book → DRAFT → confirm_proposal → SPINE_READY → confirm_spine → COMPILING → READY, asserting per-stage artefact persistence and the `proposal_ready → exploration_ready → spine_ready → overview_ready` StreamBus event order.- - `test_exploration_failure_degrades_and_retry_does_not_duplicate` — exploration failure degrades gracefully (spine still generated from the proposal), and retry clears the failure marker without duplicating exploration or spine artefacts.- - `test_compile_failure_marks_the_page_and_retry_pays_only_for_it` — a failing page lands in ERROR while the book stays COMPILING and sibling pages are unaffected; retry invokes the compiler only for the failed page.- - `test_pause_mid_compile_then_resume_finishes_without_repaying_ready_work` — pausing mid-compile flips the book to PAUSED, in-flight pages return to PENDING, compiles are rejected with `BookPausedError`, and resume re-queues only unfinished pages without re-compiling READY/Overview pages.--## Tests--All commands run on a branch based on the current `dev` tip (`ef2d9e5c3`, v1.6.12):--- `python -m pytest tests/book/test_engine_stage_transitions.py -v` → **4 passed** in ~0.7s-- `python -m pytest tests/book -q --cov=deeptutor.book.engine` → **184 passed** (baseline 180); `engine.py` line coverage **43% → 62%** (945 stmts, miss 535 → 359)-- `python -m pytest tests/book tests/reading -q` → **586 passed**-- `python -m pytest tests/architecture tests/core tests/logging tests/runtime -q` → 492 passed, 4 skipped, plus 1 pre-existing order-dependent failure (`test_api_import_memory_boundary.py::test_api_import_keeps_optional_heavy_dependencies_cold`) that reproduces identically on clean `dev` without this change and passes when run standalone-- `ruff check tests/book/test_engine_stage_transitions.py` → All checks passed-- `ruff format --check tests/book/test_engine_stage_transitions.py` → 1 file already formatted--## Related issue--None — `deeptutor/book/engine.py` was ranked #6 in an internal coverage-gap audit (DT-21 Top 15). No open upstream issue tracks these stage-transition invariants.diff --git a/evidence/pr/AGEN-150.md b/evidence/pr/AGEN-150.mddeleted file mode 100644index 9ecf333a4..000000000--- a/evidence/pr/AGEN-150.md+++ /dev/null@@ -1,36 +0,0 @@-# PR: test(session): cover pocketbase_store failure branches and pagination edges (57.7% → 72.4%)--`deeptutor/services/session/pocketbase_store.py` — the PocketBase-backed session store — had only 57.68% line coverage (347 of 820 statements missing). Every write-path test exercised only the happy path, so the store's documented degradation contract (sentinel returns instead of exceptions when the backend errors), its tolerance of old-schema rows, and its list-pagination edges were unverified. This PR adds 24 tests covering those branches without touching any product code.--## Summary--- Adds `tests/services/session/test_pocketbase_store_fallbacks.py` (24 cases).-- No product code is modified; all cases run against an in-memory fake PocketBase client plus a precisely gated `_FlakyClient`, so no external PocketBase runtime is needed and the file runs offline in ~0.4s.-- Module line coverage goes from 347 missing / 57.68% to **226 missing / 72.44%** (−121 missing lines, 820 statements), measured on the two PocketBase-focused test files.--## Root cause--An internal coverage audit ranked this store among the lowest-covered modules (#13 of the top-15 gaps, 225 missing / 72.6% across the full suite). Because the store wraps every backend call in try/except blocks that return sentinel values (`False` / `0` / `None` / `[]`) on failure, none of those degradation branches — nor the recovery-retry semantics, the default-filling for rows written by older schemas (the SQLite-era contract), or the pagination clamping/refill logic — were ever executed by tests, leaving silent-data-loss risks on backend hiccups unverified.--## Changes--- `tests/services/session/test_pocketbase_store_fallbacks.py` (new): 24 tests in three arms —- - **Write-failure degradation & recovery**: `update_session_title`, `update_summary`, `update_session_preferences`, `add_message`, `soft_delete_session`, `restore_session`, `hard_delete_session`, `delete_session` return their documented sentinels (`False` / `0`) instead of raising when the backend fails, leave already-stored rows untouched on failure, and succeed on retry once the backend recovers; read paths degrade to `None` / `[]` / empty summaries; `append_events` replays idempotently within the same batch, raises `ValueError` on same-seq content conflicts, and raises `RuntimeError` on stale fencing tokens.- - **Old-schema default filling**: bare rows without title/status/preferences/JSON columns read back as `New conversation` / `idle` / `""` / `0` / `{}` / `is_deleted=False` / `deleted_at=None`; messages missing columns get `events=[]`, `attachments=[]`, `metadata={}`, `created_at=0.0`; `_json_loads` / `_to_float` tolerate None, empty strings, malformed JSON, garbage strings, and ISO date strings.- - **Pagination boundaries & defensive re-checks**: `limit=0` clamps to 1, negative offsets clamp to 0, offsets beyond the total return an empty page, and an in-page skip triggers a page+1 refill that matches the full listing; the deleted-session listing paginates by `deleted_at` descending; `search_sessions` keeps the correct total for out-of-range offsets; soft-deleted rows are defensively re-filtered even if the backend-side filter fails.- - `test_add_message_touch_failure_orphans_persisted_row` pins the current behavior when the follow-up session-timestamp touch fails after the message row is written (the row stays persisted while the method returns `0`), giving a follow-up fix a stable contract baseline.--## Tests--All commands below pass on this branch (rebased onto the current `dev` tip `ef2d9e5c3`, v1.6.12; fresh worktree bootstrapped with the same minimal `data/user/settings/main.yaml` + `model_catalog.json` that CI's `tests.yml` creates):--- `python -m pytest tests/services/session/test_pocketbase_store_fallbacks.py -v` → **24 passed, 2 warnings in 0.40s**-- `python -m pytest tests/services/session/ -k "not test_model_history"` → **377 passed, 8 deselected, 7 warnings in 8.3s** (subsystem regression; `test_model_history` requires an untracked runtime config file and fails identically on a clean `dev` checkout, so it is deselected)-- `coverage run --source=deeptutor.services.session.pocketbase_store -m pytest tests/services/session/test_pocketbase_isolation.py tests/services/session/test_pocketbase_store_fallbacks.py -q && coverage report -m` → **820 stmts, 226 miss, 72.44%** (baseline with `test_pocketbase_isolation.py` alone: 347 miss, 57.68%)-- `ruff check tests/services/session/test_pocketbase_store_fallbacks.py` → All checks passed-- `ruff format --check tests/services/session/test_pocketbase_store_fallbacks.py` → 1 file already formatted-- `pre-commit run --files tests/services/session/test_pocketbase_store_fallbacks.py` → all hooks passed (incl. ruff, ruff format, detect-secrets, hygiene)--## Related issue--No upstream issue tracks this coverage gap; this PR comes from an internal coverage audit of the lowest-covered modules. "Related to" only — it adds tests exclusively and fixes nothing by itself. The pinned `add_message` orphan-row behavior is documented as the contract baseline for a future fix.diff --git a/evidence/pr/AGEN-166.md b/evidence/pr/AGEN-166.mddeleted file mode 100644index ce0a60bd3..000000000--- a/evidence/pr/AGEN-166.md+++ /dev/null@@ -1,37 +0,0 @@-# PR: test(book): cover SpineSynthesizer materialise, revise loop and fallback paths (14.0% → 94%)--`deeptutor/book/agents/spine_synthesizer.py` — the agent that turns a book's LLM proposal into the chapter spine and concept graph driving the reading flow — had only 14.0% line coverage (339 of 394 statements missing). The existing `tests/book/test_spine_synthesizer_llm_call.py` exercises only the LLM call itself, so every downstream seam was unverified: parsing of real payloads, tolerance of unusable LLM output, the draft→critique→revise loop, and the ordering/invariant logic. This PR adds 20 tests covering those seams without touching any product code.--## Summary--- Adds `tests/book/test_spine_synthesizer.py` (20 cases, +620 lines).-- No product code is modified; every case mocks `BaseAgent.stream_llm` to replay offline strings, so the suite makes no network calls and runs in ~0.4s. Each case injects a tmp `agents.yaml` derived from `DEFAULT_AGENTS_SETTINGS`, so nothing depends on local runtime config.-- Module line coverage goes from 339 missing / 14.0% to **24 missing / 94%** (394 statements), measured over the two spine test files together.-- Complements rather than duplicates the existing LLM-call test: that file covers the call; this file covers everything downstream of the reply.--## Root cause--An internal coverage audit of the lowest-covered backend modules ranked the book spine synthesizer among the top gaps (14.0%). Because the module tolerates unusable LLM output by construction (fallback chapters, silently skipped graph noise, best-effort ordering), none of those degradation branches nor the structural invariants (chapter count/order stability, cycle breaking, field clamping) were executed by any test, leaving book spine generation unguarded against regressions.--## Changes--- `tests/book/test_spine_synthesizer.py` (new): 20 tests in three arms —- - **Materialisation**: payload → chapter and concept-graph objects, concept dependencies lifted to chapter edges, `exploration_summary` passthrough, the `process` adapter, proposal/chunks rendered into the prompts.- - **Fallbacks**: empty output / invalid JSON / missing `chapters` key → single "Overview" fallback chapter; unparseable critique → treated as no findings (no revision); missing revise prompt → draft kept.- - **Invariants**: concept dependencies reorder chapters and renumber `order`; chapter count unchanged under cyclic dependencies (weakest-rationale edge broken); title dedup and field clamping (objectives ≤ 6, prerequisites ≤ 4, anchors ≤ 6, OVERVIEW entries kept with a type downgrade); unknown-concept edges dropped; disconnected chapters get a virtual root; Jaccard-based backfill assigns uncovered concepts to the most relevant chapter; `clip`/`slug` helpers tolerate garbage.-- CI-parity formatting: the file passes `ruff format --check` under ruff 0.16.0, the version `tests.yml` pins for its format gate.--## Tests--Verified on this branch (based on the current `dev` tip `ef2d9e5c3`, v1.6.12; fresh worktree seeded only with the gitignored runtime `data/user/settings/agents.yaml` that the pre-existing llm-call test reads):--- `python -m pytest tests/book/test_spine_synthesizer.py -q` → **20 passed in 0.30s**-- `python -m pytest tests/book/test_spine_synthesizer.py tests/book/test_spine_synthesizer_llm_call.py -q` → **25 passed in 0.24s**-- `python -m pytest tests/book -q` → **200 passed, 1 warning in 0.90s** (no cross-test pollution)-- `coverage run --source=deeptutor.book.agents.spine_synthesizer -m pytest tests/book/test_spine_synthesizer.py tests/book/test_spine_synthesizer_llm_call.py -q && coverage report -m` → **394 stmts, 24 miss, 94%**-- `ruff check tests/book/test_spine_synthesizer.py` and `ruff format --check tests/book/test_spine_synthesizer.py` (ruff 0.16.0) → pass-- `pre-commit run --files tests/book/test_spine_synthesizer.py` → all hooks passed--## Related issue--No upstream issue tracks this gap; this PR comes from an internal coverage audit of the lowest-covered modules. "Related to" only — it adds tests exclusively and fixes nothing by itself.diff --git a/evidence/test-plugins-loader-20261004/README.md b/evidence/test-plugins-loader-20261004/README.mddeleted file mode 100644index 4a92614af..000000000--- a/evidence/test-plugins-loader-20261004/README.md+++ /dev/null@@ -1,54 +0,0 @@-# test: plugins entry-point loader contract tests--Branch: `test/plugins-entrypoint-loader-20261004` (based on `origin/main` @ `ef2d9e5c3`)--## Scope--New file `tests/plugins/test_entrypoint_loader.py` — 13 contract tests pinning the-current behaviour of the entry-point loader stack, as groundwork for upstream-#961 (learning resource providers with lifecycle controls) and #1307 (managed-third-party plugin platform). No product code was modified.--Layers exercised:--- `deeptutor/core/entry_points.py` — shared `load_entry_point_group` plumbing-- `deeptutor/plugins/loader.py` — `discover_plugins` / `load_plugin_capability`-- `deeptutor/runtime/registry/capability_registry.py` — `CapabilityRegistry.load_plugins`--## Path families covered (asserting current real behaviour)--1. **Normal loading** — clean entry points are coerced in order (`load_entry_point_group`);- class- and instance-yielding plugins produce manifests (`discover_plugins`); the- canonical `deeptutor.extensions` group registers into the registry.-2. **Missing dependencies** — an entry point raising `ModuleNotFoundError` at load is- skipped while others load; instantiation via `load_plugin_capability` propagates a- missing module (discovery isolates, instantiation does not); a legacy manifest whose- entry cannot import aborts the remaining legacy manifests (logged only at debug).-3. **Load-error isolation** — a raising entry point is skipped with a warning naming the- group and entry point; a failing group read returns `[]` with a warning; a coercer- returning `None` rejects without error.-4. **Duplicate registration** — two canonical entry points shipping the same capability- name keep the first and warn "already registered"; a legacy plugin with a taken name- is skipped after canonical wins, and legacy-group presence emits a `DeprecationWarning`.-5. **Disable-gating status quo** — `PluginManifest` has no `enabled`/`disabled` field- (structural fields only), and the only gates are structural (empty entry,- `tool.py` entry, non-capability `type`) and short-circuit before resolving the entry,- so a gated manifest never imports its target.--## Commands and results--```-python -m pytest -q -p no:cacheprovider tests/plugins/test_entrypoint_loader.py-→ 13 passed, 1 warning in 0.27s--python -m pytest -q -p no:cacheprovider tests/plugins/-→ 19 passed, 2 warnings in 0.25s (13 new + 6 pre-existing in test_loader.py)--python -m ruff check tests/plugins/test_entrypoint_loader.py-→ All checks passed!-```--Full verbose run: `pytest-output.txt`.--Environment: Python 3.13.13, pytest 9.1.1, shared repo venv; worktree of-`/Users/Shared/DeepTutor` at `origin/main` (`ef2d9e5c3`, release v1.6.12).diff --git a/evidence/test-plugins-loader-20261004/pytest-output.txt b/evidence/test-plugins-loader-20261004/pytest-output.txtdeleted file mode 100644index 5a9743efd..000000000--- a/evidence/test-plugins-loader-20261004/pytest-output.txt+++ /dev/null@@ -1,12 +0,0 @@-============================= test session starts ==============================-platform darwin -- Python 3.13.13, pytest-9.1.1, pluggy-1.6.0-rootdir: /Users/xzh/services/ai-development/multica-pilot/workspaces/agents-plan-5fede2af789a/agen-480-1c472ac18bc5/workdir/dt-plugins-loader-wt-configfile: pyproject.toml-plugins: cov-7.1.0, devtools-0.12.2, asyncio-1.4.0, anyio-4.14.2-asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function-collected 19 items--tests/plugins/test_entrypoint_loader.py ............. [ 68%]-tests/plugins/test_loader.py ...... [100%]--======================== 19 passed, 2 warnings in 0.29s ========================