Skip to content

fix(mastery): make source preparation demand-driven and preserve partial teaching - #1954

Merged
pancacake merged 9 commits into
HKUDS:devfrom
yepyhun:contrib/mastery-demand-source-preparation
Oct 18, 2026
Merged

pancacake merged 9 commits into
HKUDS:devfrom
yepyhun:contrib/mastery-demand-source-preparation

Conversation

@yepyhun

@yepyhun yepyhun commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem and behavior

Refs #1902 and #1949. Missing cached evidence, genuinely unavailable source material and incomplete coverage of one subtopic are different situations. Treating them alike can cause repeated expensive preparation or a tutor that repeatedly apologizes instead of teaching the supported part.

This makes preparation demand-driven through the existing Mastery and turn-loop owners:

  • Before each request, reuse only a current authorized cached packet. A cache miss or administrative/style feedback does not automatically initiate a paid preparation call.
  • The existing explicit preparation tool owns targeted recovery. A stale packet points to focused preparation using the already selected materials, not a permanent refusal or request to upload them again.
  • Partial evidence supports useful teaching of that slice without claiming full coverage. Assessments retain their own exact question/source contract.
  • Successful explicit preparation binds the actual focus for that turn. Advancing the policy objective invalidates it; model-provided private callbacks cannot spoof the binding.
  • The pre-request check runs in ordinary rounds and forced finish. Real source failures propagate rather than silently becoming an empty successful fallback.
  • Prepared pixels are transient and bounded; newer tool-retrieved images take precedence. Original dialogue/tool pairs and archive markers remain intact. Other source pages remain retrievable anchors, not a claim that every image was inspected in the current request.
  • Teaching records validate source evidence inside the existing transaction and explicitly record partial coverage, without granting mastery credit.

Dependency and ownership

Stacked on #1953 at a15c14b, which provides the real preparation/page/source and assessment owners; that PR is itself based on #1943. Incremental implementation: 3175b81, verification: ca006fb. Please coordinate review/rebase in that order rather than merging competing preparation mechanisms.

#1952 remains the complementary owner of publicly delivered teaching receipts. This branch does not import or claim that independent behavior. It also adds no alternative memory database, automatic critic, provider override or translated prompt overhaul.

Verification

  • 85 focused deterministic tests passed for demand/cache behavior, real synthetic PDF pages, transaction source checks and native request boundaries.
  • 22 boundary/cache/source-guard tests passed after rebasing onto the latest feat(mastery): evaluate source-bound answers semantically with repairable uncertainty #1953.
  • RED cases reproduced missing hook execution, accepted unprepared teaching, absent partial coverage and a forced-finish catch swallowing source failures before fixes.
  • Scoped Ruff and whitespace checks passed.

The combined local application separately passed its Mastery/source/profile/group integration checks and built-browser recovery smoke. No real learner records were changed for tests. An optional broader run had 268 passes and two failures also reproduced on the unchanged parent: an existing stream-timing assertion and a summary fixture needing initialized configuration. Those are not reported fixed by this PR.

Detailed contracts and proof: docs/verification/mastery-demand-source-preparation.md.

An equivalent native design is welcome; the important behavior is proportionate, reusable source grounding that does not turn ordinary retrieval uncertainty into a teaching deadlock or weaken real access/evidence checks.

Contribution map and remaining requirements: tracking issue #1940.

Connected follow-up

#1957 is stacked on this branch and adds private source inspection, intentional authenticated source presentation, attempt-scoped assistance and bounded delivery after successful repair. It also reuses identical successful inspection batches within one preparation. Please review its incremental range separately; those changes are not claimed to be in this PR's head. #1956 independently fixes explicitly incomplete terminal outcomes. The updated dependency/evidence map is maintained in the main body of #1940.

@pancacake
pancacake merged commit 3196b6d into HKUDS:dev Oct 18, 2026
8 of 15 checks passed
alvinets pushed a commit to alvinets/DeepTutor that referenced this pull request Nov 8, 2026
alvinets pushed a commit to alvinets/DeepTutor that referenced this pull request Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants