Skip to content

fix(mastery): unblock manual confirmation and expose objective deferral - #2728

Open
lipeh1 wants to merge 9 commits into
HKUDS:devfrom
lipeh1:feat/mastery-manual-review
Open

lipeh1 wants to merge 9 commits into
HKUDS:devfrom
lipeh1:feat/mastery-manual-review

Conversation

@lipeh1

@lipeh1 lipeh1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Description

Manual mastery confirmation currently leaves a matching question pending, so the route can remain stuck at answer_pending even after the learner has confirmed mastery.

This change releases the matching pending interaction atomically with confirmation, including grouped questions containing the selected objective. Assessment attempts and review evidence are preserved, and questions for unrelated objectives remain open.

The topic outline also offers Skip this knowledge point for now with an optional note. This exposes the existing objective-deferral policy through an account-scoped API and works even when no question card was generated. Deferral gives no mastery credit, retains unfinished objectives, and cannot complete a path by skipping every objective.

Both operations use the existing turn-cancellation and exclusive path-mutation guard. The UI explains the different effects, displays deferred status, preserves notes on failure, supports retry, and prevents duplicate submissions. Existing Return to assessment remains available for learner confirmations.

Includes updates to all 13 UI catalogs, generated API contracts, and recovery documentation.

Related Issues

Related to #2588.

This extends the existing objective-level learner confirmation. Original individual assessment verdicts remain available as evidence.

Module(s) Affected

  • api
  • web (Frontend)
  • docs (Documentation)
  • tests
  • Other: learning

Validation

Base: dev at 4c1e000d8563c5ac3b231baaaf149dc4dc4d2406.

  • Reproduced pending-question retention on the original implementation before the fix.
  • 13 focused API regressions pass, covering matching/grouped and unrelated pending questions, assessment preservation, withdrawing confirmation, deferral without a card, invalid inputs, mutation conflicts, and skipping every remaining objective.
  • Authenticated API coverage verifies anonymous rejection, cross-account isolation, and successful owner deferral.
  • 6 rendered component tests pass, covering confirmation, cancellation, distinct mastery/deferral calls, failure/retry, duplicate-click prevention, deferred status, and withdrawing confirmation.
  • Production-browser audits pass at desktop (1280px) and mobile (390px) widths using Chrome. Browser API responses use disposable fixtures; persistence and authorization are tested separately through the real router/store.
  • All 1,407 Node tests and 1,470 Vitest tests pass. One settings-page test initially timed out during concurrent checks; its 24-test file passed in isolation, and the complete suite passed with two workers.
  • Typecheck, frontend dependency boundaries, lint (0 errors / 58 existing warnings), i18n checks, generated contract checks, production build, and route budgets pass.
  • Repository-wide Ruff and architecture checks pass. All applicable pre-commit hooks for changed files pass, including Bandit and Mypy. Workspace hygiene passes.

Existing baseline findings, outside this change:

  • The broader learning regression selection reports 845 passed, 1 failed. test_old_submission_retry_cannot_overwrite_newer_answer fails identically in an untouched checkout of the exact base on Windows/Python 3.12.
  • pre-commit run --all-files passes every hook except Mypy. Its 23 platform-related errors in unchanged files are identical to the untouched base.
  • No checks, thresholds, or hook configurations were relaxed.

Checklist

  • Target branch is dev.
  • Added relevant regression tests and recovery documentation.
  • Regenerated API contracts and checked translation parity.
  • pre-commit run --all-files is entirely green (baseline Mypy findings described above).

@pancacake pancacake added web Web frontend (Next.js UI & components) bug Something isn't working backend Python runtime, capabilities, tools, API & CLI labels Nov 27, 2026
@lipeh1

lipeh1 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Could a maintainer rerun the failed iOS simulator job? The build succeeded, and the final screenshot showed the simulator home screen. The same mobile code passed in #2718.

@lipeh1

lipeh1 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Could a maintainer rerun the failed Import Check (Python 3.14, windows-latest) job? The original run failed while building lxml 6.2.1 from source. PyPI now has a Windows x64 wheel, and the same check on dev installed it and passed.

@AleFlyX AleFlyX self-assigned this Dec 3, 2026

@AleFlyX AleFlyX left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the other submitted answers in a question group gradable when a learner acts on one objective.

[P2] Confirming one objective strands another objective’s submitted answer. I made a group with objectives A and B, submitted only B’s answer, then marked A as known. _abandon_objective_question matched A and abandoned the whole group. B’s reply was still in the store, but grading returned The question was abandoned. The same reply graded successfully on the PR base and on current dev. Deferring A through the service hits the same group-wide abandonment, which the new endpoint exposes. Please add a regression that preserves the ability to grade B’s submitted answer for both actions. Question group handling

[P3] Rejected deferrals can still stop an active lesson. I sent a deferral for already-mastered A while another session held the path lease. The endpoint returned 409 and left progress unchanged, but it called cancel_turn_and_wait and released the other session’s lease. The HTTP test used a real SQLite lease and stubbed the cancellation service. Please check whether the objective is already mastered before cancelling a turn, and keep the check inside the mutation for concurrent updates. Deferral endpoint

I ran 97 backend tests and 6 rendered component tests on 084a7988d. All passed. Please resolve the conflicts with dev and rerun the affected tests on the refreshed branch.

Deferral also leaves already-graded wrong answers in the mastery calculation. The single-question part of #2588 still needs follow-up.

@lipeh1

lipeh1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the reproductions, @AleFlyX. I merged dev and addressed both findings in 57a456c.

  • Confirming or deferring A keeps B’s submitted answer gradable on the original group. The regression tests also cover a retry and a three-question group where the last question is still unanswered.
  • Deferring an already-mastered objective now returns 409 before cancelling the active lesson. The test checks that the same SQLite lease is still held. The transaction also rechecks mastery.

The 250 affected backend tests and 27 frontend tests passed locally. Could you take another look?

@AleFlyX AleFlyX left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm keeping this at Request changes on 1a1aa17d. The two cases from the previous review pass in my focused checks. B can still be graded after either manual action on A, and deferring an already-mastered objective returns 409 without releasing the active lesson's lease. I found two remaining cases where acting on A prevents the learner from answering C.

[P2] The old card can submit a skipped question and get a valid answer rejected with it.

Start with a group containing A, B, and C. Submit B and leave it ungraded. Then mark A as known or defer it from the outline. The server keeps the group and marks A skipped, but the outline still shows A under “Next up.” Its Continue link opens the original chat, where the card gets its per-question state from chat receipts. The outline action doesn't supply that receipt, so A is still editable. At the service layer, I reproduced that submitting A and C together rejects the whole submission. Submitting C alone succeeds. Card state · Submission validation · Next step

Could the existing topic refresh include the saved per-question status for the active card? The original chat could use it to lock A, and “Next up” could use the same state to point to a question that still needs work. Please cover returning to the original chat from the outline and submitting C there.

[P2] Marking A as known closes the card if B was graded first, even though C is still unanswered.

Use the same group, but grade B before marking A as known. On the merge base and current dev, I could still submit C. On 1a1aa17d, the group becomes abandoned and submitting C returns The question was abandoned. The keep-open check only considers submitted answers awaiting grading, so once B is graded, an unanswered C doesn't keep the card open. Keep-open check

Please keep the original card open when another question still needs an answer or a grade. The existing three-question test covers acting on A before B is graded. Add the reverse order and check that C can still be answered after confirming A. Existing test

The router index and locale files still conflict with dev. Please resolve those before rerunning the affected checks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Python runtime, capabilities, tools, API & CLI bug Something isn't working web Web frontend (Next.js UI & components)

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants