142 Commits

Author SHA1 Message Date
我也有友人账
53a827ba9f fix(mastery): keep mastery choice clarifications from blocking fresh practice (#3150)
Co-authored-by: wyyyrz <227647791+wyyyrz@users.noreply.github.com>
2026-12-01 21:38:42 +08:00
Leveling
d889815577 fix(mastery): resolve formatted choice answers by exact option body (#3129)
Fixes #2863.

Exact normalized option-body matching for resolve_answer (whitespace / Markdown / LaTeX wrappers), without normalized substring false positives. Preserves literal operators and unresolved ambiguity.

Co-authored-by: Chih-Kai-Wang <290806361+Chih-Kai-Wang@users.noreply.github.com>
2026-12-01 16:51:36 +08:00
Leoy
566465dc42 fix(mastery): ignore knowledge-base sources that no longer resolve (#2752)
* fix(mastery): ignore knowledge-base sources that no longer resolve

Refs #2748

* fix(mastery): filter the caller's mounted knowledge bases too

A study session left open across a deletion keeps sending the base it was
mounted with, and that list is merged verbatim with the topic's sources.
Run both through knowledge_base_ref_available so a stale name cannot reach
the tool bundles and raise AccessError.
2026-11-29 14:49:40 +08:00
Gaurav Dubey
d5637d5ba3 fix(mastery): keep language-course content in its target language (#2934)
* fix(mastery): keep language-course content in its target language

The reply-language directive is the last thing in every system prompt and
tells the model to write quiz stems and options in the reply language and
never switch. For a course whose subject is itself a language, the model
obeyed literally: an "Antonyms" objective in an English course, studied with
Chinese as the reply language, was drafted as 反义词 and taught in a later
session as Chinese antonyms.

- language_directive now says the reply language governs the explanation,
  not the subject: a studied language keeps its own words, sentences and
  exercise items.
- Route generation and the tutor's outline drafting name the target
  language in every module and knowledge point ("English antonyms").
- The tutor playbook keeps an existing language course on its target
  language even when an objective name does not repeat it.

Closes #2933

Co-Authored-By: Claude <noreply@anthropic.com>

* test(mastery): check the composed prompts keep a language course's target language

The strict reply-language directive is appended last, after the route and
tutor instructions. Assert the carve-out survives in the prompts the model
actually receives: zh route generation, and the zh tutor playbook rendered
with a fixed reply language.

Related to #2933

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-28 18:24:23 +08:00
Chih-Kai Wang
fa39a79e2f fix(mastery): stop same-turn mastery_grade retry loop on unreadable choice (#2866)
Co-authored-by: f0909172434 <290806361+f0909172434@users.noreply.github.com>
2026-11-28 18:22:21 +08:00
Bingxi Zhao (Frank)
4c1e000d85 release: v1.7.3
Prepare v1.7.3 notes for reading and book editing, expanded provider and
agent connections, learning records, model streams, and desktop upgrades.

Sync README prose and 11 translations, archive older release notes, and
update the package version. Resolve release lint/type blockers with explicit
parser and capability contracts, compatible Book call forwarding, accurate
auth task types, and quoted SQLite schema identifiers. Cover positional Book
calls and quoted legacy columns; align KB seed tests with visible retrieval
failure reporting. Keep HTTP fixtures independent of host proxies and translate
new Portuguese UI copy.

Release notes: assets/releases/ver1-7-3.md
2026-11-16 02:17:36 +08:00
Bingxi Zhao (Frank)
92ce9a27f4 fix(mastery): retain explanations across failed assessment attempts 2026-11-15 01:04:25 +08:00
Bingxi Zhao (Frank)
be4f36c166 fix(mastery): normalize option arrays and clarify grading evidence
Local dev repairs for #2687, #2691. Regression checks cover reported symptoms and compatibility boundaries.
2026-11-15 00:44:09 +08:00
Bingxi Zhao (Frank)
461093db5f Merge PR #2657: fix: register fresh mastery questions across conversations
Update the status contract for session_id and prove concurrent retries in a fresh session create only one card while retaining the archived question (139 passed).
2026-11-14 23:11:02 +08:00
Bingxi Zhao (Frank)
ebd0f11083 Merge PR #2605: fix(mastery): let a new reply supersede an ungraded clarification 2026-11-14 22:58:03 +08:00
Bingxi Zhao (Frank)
69a9ad9cc0 Merge PR #2608: fix: give lesson preparation and grading room for reasoning models 2026-11-14 22:58:03 +08:00
Bingxi Zhao (Frank)
da2369397c Merge PR #2548: fix(mastery): resolve shared books through access layer 2026-11-14 22:58:02 +08:00
AleFlyX
635c0394ef fix(mastery): restore the trusted-key requirement for revision
The reserved-name filter closed the injection path, but the revision branch
still fell back to the public `answer` parameter when `_learner_message`
was absent. `answer` is model-authored, so a tool call without the trusted
key could replace a committed learner reply and credit mastery for text
the learner never typed.

Reproduced on the previous head: commit a help request, grade it
(`is_correct: null`, `final: false`), then call with only
`answer="photosynthesis"` — `is_correct: true`, mastery 0.5, and
`user_answer` rewritten.

Revision now requires `_learner_message`. Without it the stored answer
stands and the call re-grades as ungraded, which costs no credit and
rewrites nothing. This guard existed earlier on this branch and was lost
when the schema layer was removed; the regression test is restored with
it.

Note this is the same defect the reviewer reported on the first commit,
which means removing the schema work also removed the protection that had
been added to answer it. Worth remembering when cutting scope: verify what
each removed commit was actually guarding.
2026-11-11 23:36:05 +08:00
elvisgraho
3bfdb0fc29 fix: give lesson preparation and grading room for reasoning models
Source selection asks for at most 1800 output tokens and grading for 2200.
Reasoning models count hidden reasoning against max_tokens. On a real course
page set, nvidia/nemotron-3.5-super-vl (OpenRouter) stopped with
finish_reason=length in 5 of 5 runs after spending all 1800 tokens on
reasoning, so the reply had no JSON and preparation failed with "invalid
source-selection response". The #2367 retry lowers reasoning_effort to "low",
which this model does not honour: on a small probe it reasoned more, not less,
and in the app the retry failed the same way.

Raise both caps to 8192. Replaying the same request with an 8000-token cap
finished in 3 of 3 runs (2.4k-4.1k reasoning tokens), and full preparation
then completed for 4 of 4 objectives. max_tokens is a ceiling, so models that
answer briefly are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 21:04:06 +01:00
AleFlyX
aa6f1dfc0c fix(mastery): let a new reply supersede an ungraded clarification
On a free-text mastery question, a learner's "I don't get it, explain"
was judged ungraded and stored as the interaction's user_answer. Every
later mastery_grade call then preferred that stored reply over the
learner's actual answer — the judge rejected the same help request again
as ungraded, and the question could never be cleared. The gate sat at
mastery 0.0 until the tutor called mastery_skip_question itself.

The committed user_answer is authoritative on purpose: the pause/resume
boundary stores the learner's exact words, and a later model round must
not paraphrase them. It stops being authoritative once the learner has
said something else *and* the stored reply was never ruled on. Revise
through the existing record_question_answer path, which rewrites
user_answer and keeps the superseded attempt in the event log as
assessment.revised.

A repeated, empty, or whitespace-identical reply is not a revision, and
a group interaction is excluded: its child questions keep their own
per-leaf revisable logic.

This is the free-text half of #1004, which only covered choice cards.
Closes #2595.
2026-11-10 21:57:52 +08:00
lazytalk
da7f4ed90d fix(mastery): resolve shared books through access layer 2026-11-09 18:02:40 +08:00
markxu
be2b971324 fix: refuse uninspected mastery visual cards
A visual whose source resolved but whose pixels were never in the model
input was still registered. Grade and correct then failed closed, and only
void could clear the card. Refuse that visual before registration, and tell
a correction of an already stored card to void it.

Fixes #2494

Co-authored-by: markxu <markjoin123@users.noreply.github.com>
2026-11-06 14:10:37 +00:00
Bingxi Zhao (Frank)
bff6530376 Merge #2325 from BenjiAvH 2026-11-06 01:56:40 +08:00
Bingxi Zhao (Frank)
c2cded910a Merge #2375 from Mahdi-Hasan 2026-11-06 01:56:24 +08:00
Bingxi Zhao (Frank)
1cb5c1daa9 Merge #2344 from rudycelekli 2026-11-06 01:56:24 +08:00
Mehedi Hasan
93fa314ce7 fix(learning): read lesson JSON from reasoning-model replies
Prepare Lesson parsed the model reply with json.loads after stripping
only a leading code fence. Reasoning models add <think> blocks or a
prose preface, and at high effort can spend the 1800-token budget on
hidden reasoning, so every attempt failed as an invalid source-selection
response. Assessment requests share the same parser.

Strip closed <think>/<thinking> blocks, treat a reply that still opens
with reasoning as unanswered, and scan for the first JSON object with
JSONDecoder.raw_decode. Truncated JSON still fails instead of being
repaired into a partial object. When the reply is unusable, retry once
at RETRY_REASONING_EFFORT, the project rule in structured_retry, for
both lesson preparation and semantic assessment.

Fixes #2367

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 19:45:55 +06:00
Rudy Celekli
ff39562d73 fix(mastery): resolve a module name fragment to the most specific match
resolve_module returned the first substring match in iteration order, so
"Limits and Continuity chapter" resolved to a shorter "Limits" module
that is a substring of it, sending the hand-off card to the wrong lesson.
Pick the match whose name length is closest to the phrase instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-02 00:03:01 -05:00
Benjamin Schwing
c4befc3706 fix(mastery): keep a partial explanation pending for the missing part
Builds on the clarification handling from #2261. After a final partial
grade the learner usually sends only the missing part, which was then
graded alone and found partial again, so answers split over several
messages could alternate between partial grades without ever passing.

Keep the graded explanation pending after a final partial, with the same
session/objective scope and TTL as a clarification request, so the next
explanation is graded together with it. Pending explanations are now
dropped when the path moves on after them (a final assessment of any
objective, a deferral, a question on another objective, a reset or
revision); ordering uses event ids instead of timestamps so the partial
that records the request does not cancel it. A pass or an incorrect
grade still ends it, and a retried turn replays its saved verdict.

Refs #2249
2026-11-01 18:51:31 +00:00
Benjamin Schwing
1a00aa9b5c fix(mastery): continue with next after mastery_assess clears a gate
mastery_assess returned mastered and next but no instruction, unlike
mastery_grade. After a passing explanation the tutor tended to end the
turn on an announcement of the next topic, leaving the learner nothing
to answer.

Add an instruction to the final mastery_assess payload: when mastered,
confirm briefly and continue with next in the same reply (or say the
path is complete); when not mastered, explain the gap and ask again.
The clarification (non-final) result is unchanged. One matching sentence
in the en/zh mastery loop prompt.

Fixes #2323
2026-11-01 18:51:26 +00:00
LucianVane
c1fe11b899 fix(mastery): grade a clarification together with the explanation it completes
When mastery_assess asks for clarification, keep the explanation for that
objective in the session. The next assessment grades the earlier explanation
plus the clarification instead of the short reply alone.

Fixes #2249
2026-10-31 23:55:11 +08:00
Bingxi Zhao
5f5f189c36 Merge pull request #2137 from nandanadileep/oss-harness/issue-2073
fix: Mastery Path re-poses a question the learner already answered correctly (fallback to the one source-verifiable item
2026-10-31 18:59:28 +08:00
Cursor Agent
de3afc8c5b style: fix ruff I001 and format in mastery restatement
Combine same-module imports in the restatement test and collapse the
dict comprehension so CI ruff check/format pass.

Co-authored-by: Nandana Dileep <nandanadileep@users.noreply.github.com>
2026-10-29 03:10:44 +00:00
nandanadileep
7c98b9c1b0 fix: refuse restating a correctly answered mastery 2026-10-28 23:36:28 +00:00
Bingxi Zhao (Frank)
04daf46c5d fix(learning): preserve legacy review history and idempotent strategy bindings 2026-10-29 01:04:55 +08:00
Bingxi Zhao (Frank)
d09a4d3a4f Merge pull request #2028: configurable review strategies 2026-10-29 01:04:33 +08:00
Bingxi Zhao (Frank)
e7f5823781 Merge pull request #2063 into validated PR integration 2026-10-29 00:56:13 +08:00
Rudy Celekli
3008c58ef4 fix(learning): resolve 'lesson N' by rank, not 0-based order value
resolve_module matched a learner's 1-based 'lesson N' against the module
'order' field with int(module['order']) == position. But order is stored
0-based (topic_generation uses order=len(modules); service and
outline_revision number with enumerate from 0), so 'lesson 1' matched the
module whose order is 1 — the second lesson — and every lesson but the last
resolved one too high, sending the learner's hand-off card to the wrong lesson.
Take the Nth module by rank in the order sequence instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-26 10:36:59 -04:00
XZH
aa7d54bd7b feat(learning): add mastery review strategies (#1908)
Mastery paths previously scheduled with one fixed interval template per knowledge type, which did not fit exam cramming, language drilling, science review, or learner-specific pacing.

Add four built-in strategy presets and custom per-round interval templates with validated persistence, CRUD, duplication, and path bindings. Bound paths keep a frozen strategy snapshot, replay durable evidence when switching, and mastery tools follow the bound path scheduler.

Expose strategy management in the mastery review trail, including custom interval editing and loading, empty, busy, invalid-input, and error states. Regenerate the OpenAPI contract and add focused backend and web regression coverage. Legacy paths without a binding continue to use the previous default scheduler.
2026-10-22 18:37:54 -07:00
dajiaohuang
3ce2937c82 fix: keep mastery review within the gate 2026-10-22 12:44:45 +08:00
Bingxi Zhao (Frank)
784de5fa6d fix: align integrated mastery catalog and regression fixtures 2026-10-19 01:17:50 +08:00
Bingxi Zhao (Frank)
0fd8dc8384 Merge PR #1953: source-bound assessment with portable lexical page lookup 2026-10-19 00:43:33 +08:00
Bingxi Zhao (Frank)
61719b18de Merge PR #1952: verify teaching delivery alongside durable feedback 2026-10-19 00:36:32 +08:00
Bingxi Zhao
5d108e54c1 Merge pull request #1820 from dajiaohuang/fix/learning-read-snapshots
fix(learning): keep aggregate reads in one SQLite snapshot
2026-10-19 00:19:22 +08:00
Bingxi Zhao
100b837886 Merge pull request #1805 from lorenzozanee/fix/qualitative-repair-persistence
test(learning): cover persisted qualitative repair turns
2026-10-15 03:16:09 +08:00
Bingxi Zhao
20a0af660b Merge branch 'dev' into fix/qualitative-repair-persistence 2026-10-15 02:05:01 +08:00
yepyhun
ccac56eec1 fix(mastery): bind semantic assessment to verified question evidence 2026-10-13 12:21:04 +02:00
yepyhun
cc079776c4 fix(mastery): bind teaching records to visible delivered explanation 2026-10-13 08:29:46 +02:00
XZH
cf37be0f5e fix(mastery): apply coordinated multi-module revisions atomically (#1929)
mastery_revise accepted one module per call, so a coordinated outline
adjustment across several modules cost one call, one transaction and one
full-outline snapshot echo per module. Add a modules=[{module_id,
rewrite, add, remove}, ...] form that validates every entry against a
shared id space, refuses the whole request on any rejection (unknown
ids, mastered waypoints, cross-module cycles), and commits all modules
in a single revision with one result payload. The single-module form
keeps its exact contract and payload shape.
2026-10-11 16:38:54 -07:00
dajiaohuang
30277b1798 Merge commit '6cf793bd868ba5ecbe64722936d4be8fab5a01df' into fix/learning-read-snapshots 2026-10-08 12:35:34 +08:00
dajiaohuang
80881c2500 fix(learning): read related projections in one snapshot 2026-10-08 12:35:34 +08:00
lorenzozanee
6dd1cb4dcb test(learning): cover persisted qualitative repair turns 2026-10-08 05:33:21 +08:00
Bingxi Zhao (Frank)
2350ea2dba feat(mastery): complete source-grounded visual practice and evidence (#1611)
Bind original visual sources and keys to supported tasks; verify accepted model pixels, preserve cues/assistance and canonical attempts, keep uncertainty ungraded, expose challenge/repair, and separate required visual evidence from generic text mastery.
2026-10-08 05:25:05 +08:00
KennySimpson
8dce2550b2 fix(mastery-path): allow editing legacy objective counts (#1790) 2026-10-07 20:20:29 +08:00
OrdoAbChao
a067db1116 fix(learning): prevent compounding SRS lapses during multi-turn qualitative repairs (#1781) (#1794) 2026-10-07 20:20:19 +08:00
XZH
cb00376260 test(mastery): resolve the factually-true label from the shuffled card
The repair-integrity test answered a hardcoded label, so whenever the
shuffle parked the wrong-key body on that same label the grader agreed
with the answer and the fixture flaked (CI Python 3.12 red while 3.11
and 3.13 stayed green on one commit). Read the rendered label of the
true statement off the persisted card instead — the registered wrong
key follows a different body and can never collide with it, so the
assertion is deterministic under any permutation.

Co-authored-by: multica-agent <github@multica.ai>
2026-10-03 13:23:40 -07:00