Security/correctness:
- Stop leaking diagnostic answers: persist a _sanitize_diagnostic() snapshot
(drops top-level answers + inline answer keys) into progress.diagnostic,
which is returned verbatim by the /progress endpoints. Grading is unaffected
(authoritative answers live in LearningStore).
- _safe_json_parse + generate_from_notebook now use the shared fence-stripping
parse_json_response instead of bare json.loads, so the common fenced/lightly
-malformed LLM output is recovered instead of silently dropped / 500'd.
Decoupling:
- unified_ws change_module: move module lookup + PRETEST reset into
LearningService.switch_module(); router keeps only the WS ordering
(module_changed before cancel) and no longer imports learning.models.
- unified_ws check_active_turn: use new public TurnRuntimeManager
.has_live_execution() instead of reaching into _lock/_executions.
- redo endpoint: LearningStore.clear_questions() instead of poking _questions_path.
- remove unused StreamEventType.USER_INPUT enum; document the WS message types.
Stability:
- LearningStore: question read-modify-write (save_question_answers/_meta),
delete(), and clear_questions() now hold _cas_lock — consistent concurrency
model; _atomic_write_text cleans up its temp file on failure.
Cleanliness/clarity:
- router: shared _validate_book_id() (9 endpoints) + _parse_modules()
(init/replace); _classify_error drops unused expected_answer param.
- guided_learning: hoist logging/RAGService imports + module logger; move tuning
constants to class top; ContextVar declared after imports.
- storage: hoist json import (7 inline copies removed).
- pocketbase_store: move _VALID_ID/_validate_id below the import block.
- rename misleading mastered_pct -> avg_mastery_pct (service + web consumers).
Frontend:
- learning [bookId] page uses lib fetchProgress (apiFetch -> auth redirect)
instead of a raw credentials fetch; track/clear the retry + auto-advance
timers on unmount; drop dead currentStage state + ModuleTree prop.
- learning-api: remove orphaned submitAnswer + AnswerRequest.
- CreateModuleDialog: use the static bookApi import; reset manualBookId to ''
to match initial state; learning list page: stop shadowing the t() translator.
Conflict-resolution carryover: dropped the PR's incidental 300s factory timeout
(kept dev's stream runner).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Auto capability (agents/auto/) gains a three-stage agent loop:
ANALYZING (one LLM call, streamed as thinking) -> DELEGATING (router
emits delegate_to_<cap> tool calls or atomic tool calls, with bounded
retries and a same-cap quota) -> SYNTHESIZING (final inline answer).
Sub-capability events flow through forward_events with call_id tagging
so conversation history keeps only Auto's own synthesis.
New chat-mountable tools:
- ask_user: pauses the turn for 1-3 structured questions, frontend
renders a card the user navigates and submits in one batch
- web_fetch: HTTP + readable-content extraction with strict
scheme/private-IP/size guards (pre-flight + post-redirect)
- write_note: replaces save_to_notebook; append (new record) and
edit (existing record by id) modes
- list_notebook: read-only index / drill-down listing; only mounted
when the user has notebooks
- github_query: read-only ``gh`` CLI wrapper (pr/issue/run/repo plus
GET-only api); no mutation verbs reachable
Updates chat agentic_pipeline.py + agentic_chat.yaml (en/zh) to the
new tool surface and source-inventory contract, refits
tools/builtin/__init__.py as the single place to register
chat-mounted tools and their argument-augmentation wrappers, and
tightens core stream + tool_protocol around tool-result metadata.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>