Commit Graph

640 Commits

Author SHA1 Message Date
Benjamin Schwing
66b33e29f2 fix(notebook): reject non-finite numbers in a PATCHed verdict
FastAPI's JSON parser accepts NaN/Infinity, so a crafted entry PATCH
stored a verdict that made every later read of the entry fail. Reject it
with a 422 in the route: a model validator's 422 body would echo the
value and fail to serialise as well.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-25 01:31:34 +00:00
Benjamin Schwing
f8378140ee fix(quiz): reject overflowing numbers in the judge verdict
parse_constant only sees the NaN/Infinity literals; a literal such as
1e999 still parsed to inf and produced a verdict frame browsers cannot
JSON.parse. Let the verdict model reject every non-finite number instead
of the custom decoder.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-25 01:31:34 +00:00
Benjamin Schwing
4cbe18ebfd fix(sessions): leave pending answers out of the quiz score
The [Quiz Performance] score counts only graded answers and states how many
are not graded yet, instead of counting a pending photo answer as wrong.
Refresh the router index for the router changes in this series.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-24 22:00:01 +00:00
Benjamin Schwing
67db2e8dd7 fix(quiz): parse the last judge verdict block and tolerate contract slips
The splitter holds text from the first <verdict> tag and, at the end, takes
the last block as the verdict and releases the prose around it, so prose
that quotes the tag and text after </verdict> are no longer lost. Verdict
tags in learner-supplied prompt fields are neutralised so an echoed tag
cannot grade an answer. The parser case-folds result, truncates an
over-long summary, drops steps without a boolean ok, coerces non-list
steps to none, ignores text after the JSON object and rejects
NaN/Infinity, which browsers cannot parse.

Replace the per-language 'images unreadable' prompt variants with one
neutral system-prompt note; the user prompt only mentions images the
model receives, and the server still forces ungraded.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-24 21:54:40 +00:00
Benjamin Schwing
afe49a26da fix(notebook): reject contradictory or malformed grades in the entry PATCH
The PATCH restricts result to the four verdict results, derives is_correct
from result when only result is sent, rejects an is_correct that contradicts
result, and checks the stored ai_verdict's shape (known result, boolean
final, no final ungraded) and size.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-24 21:52:44 +00:00
Benjamin Schwing
b152302a6e chore(api): refresh the router index after the notebook and quiz router changes
Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-24 20:24:59 +00:00
Benjamin Schwing
73835e9c37 fix(quiz): keep re-judged notebook entries consistent
A re-judge that lowers a verdict now replaces the stored result instead
of leaving result=correct behind an is_correct=0 row: the client always
sends an explicit result and the entry PATCH derives result and resolved
from is_correct with the upsert's rules. Invalid step entries are
trimmed or dropped rather than voiding a clear verdict, and the verdict
is saved even when the submit upsert lands after the judge starts.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-24 18:51:55 +00:00
Benjamin Schwing
310588801c fix(quiz): accept judge verdicts without a summary sentence
Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-24 18:33:45 +00:00
Benjamin Schwing
4cad709b71 feat(notebook): store AI-judge verdicts and stop counting judged answers as mistakes
Notebook entries gain an ai_verdict JSON column (additive migration) and
the entry PATCH accepts ai_verdict, is_correct and result, so a judged
photo or free-text answer keeps its structured verdict and real result.
Quiz results accept an optional result and report partial/ungraded
answers honestly.

A practice trigger releases a mistake captured from the provisional
exact-match result when an AI verdict marks the same answer correct or
ungraded, unless the learner already practised it. Partial verdicts stay
reviewable with result=partial.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-24 18:24:05 +00:00
Benjamin Schwing
9c5db755bb feat(quiz): emit a structured verdict frame from the AI judge
The judge now ends its reply with a <verdict> JSON trailer that the
server strips from the streamed prose, validates against the learning
Verdict model (same result vocabulary and 0.8 confidence gate) and sends
as a separate "verdict" frame before "done". Missing or invalid
trailers, low confidence and vision-incapable models yield "ungraded";
points are only kept when the question states them and they are
consistent. Clients that ignore unknown frames see unchanged prose.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-24 18:15:29 +00:00
Bingxi Zhao (Frank)
8ab4ecfee9 feat(books): review and undo scoped chapter and section edits
Fixes #2571
2026-11-15 01:42:47 +08:00
Bingxi Zhao (Frank)
ce4434e75a fix(workspaces): reuse knowledge references in selective conversation moves
Fixes #2289
2026-11-15 01:42:46 +08:00
Bingxi Zhao (Frank)
53bc9eb99d fix(learning): paginate and search question bank sources
Fixes #2641
2026-11-15 01:20:53 +08:00
Bingxi Zhao (Frank)
8ecf2da95f fix(parsing): validate uploads against available parser formats
Fixes #2338
2026-11-15 01:20:52 +08:00
Bingxi Zhao (Frank)
b46d9b5763 fix(mcp): reconnect after consent and refresh authorization status
Local dev repairs for #2586.

OAuth owner isolation and refresh-token stability verified. Hook polls until connected, refreshes on focus and stops on unmount. Python rechecks: 56 passed; UI batch: 25 passed. Web typecheck, 1407 Node tests, eslint and i18n passed.
2026-11-15 00:50:30 +08:00
Bingxi Zhao (Frank)
3a533c6c5f fix(auth): allow chat learners to record and play voice
Local dev repairs for #2437.

Guarded voice endpoints and negative permissions tested in the 375-pass first batch.
2026-11-15 00:50:30 +08:00
Bingxi Zhao (Frank)
47ae8a27e4 Merge PR #2515: feat(i18n): add Hungarian as an interface and reply language
Combine Hungarian with Italian UI and Hindi reply-language registries; translate 49 newly integrated keys and add the Hungarian endonym to Italian. Regenerate router and frontend contracts. 33 Python locale tests, full Node suite and locale parity pass.
2026-11-14 23:36:26 +08:00
Bingxi Zhao (Frank)
95aa81d624 Merge PR #2544: feat(i18n): add Italian (it) localization
Make Italian quality tests compatible with CommonJS Node test compiler; accept Italiano as reply-language alias; translate 48 keys added by other integrated PRs; regenerate router index and format i18n. 26 Python locale tests and full Node suite pass.
2026-11-14 23:34:48 +08:00
Bingxi Zhao (Frank)
af403550ce Merge PR #2639: fix: explain missing LLM access in chat
Retain admission error text and localized model-access guidance; allow explicit retry to revalidate access instead of permanently blocking stored messages. No automatic retry on reload. Backend tests and both manual retry paths passed.
2026-11-14 23:19:09 +08:00
Bingxi Zhao (Frank)
2d493edb84 Merge PR #2521: feat(i18n): add Hindi as a reply language
Regenerate the lazy route index after the reply-language contract changes; targeted tests passed.
2026-11-14 23:16:33 +08:00
Bingxi Zhao (Frank)
33078edd49 Merge PR #2542: fix: register connected knowledge bases in the viewing workspace
Regenerate the lazy route index after workspace registration changes; targeted API tests passed.
2026-11-14 23:16:29 +08:00
Bingxi Zhao (Frank)
9934fb15ca Merge PR #2625: feat(book): post-generation chapter CRUD without recompiling
Validate chapter existence, spine presence, and protected overview deletion before claiming a revision; cover failed edits followed by valid retries (22 passed).
2026-11-14 23:11:57 +08:00
Bingxi Zhao (Frank)
3fc9d2ce18 Merge PR #2534: feat(web_fetch): pluggable fetch backend with DeepSeek Fetch as first alternative
Combine independent locale additions and regenerate integrated route index.
2026-11-14 23:00:23 +08:00
Bingxi Zhao (Frank)
68220257af Merge PR #2568: feat(guardian): show scoped Reading progress and quiz records
Combine independent locale additions and regenerate integrated route index.
2026-11-14 23:00:03 +08:00
Bingxi Zhao (Frank)
c60e0e0331 Merge PR #2576: feat(reading): record question-linked help without replacing the quiz
Keep server-only quiz answer keys before persisting help results; retain relationship and extension-policy revalidation.
2026-11-14 22:59:16 +08:00
Bingxi Zhao (Frank)
fa3debf4b4 Merge PR #2560: fix(reading): keep quiz answer keys on the server 2026-11-14 22:58:53 +08:00
Bingxi Zhao (Frank)
a768f739a2 Merge PR #2578: fix(book): don't advance revision when refresh-fingerprints is refused 2026-11-14 22:58:50 +08:00
Bingxi Zhao (Frank)
d76a4cbe7e Merge PR #2526: fix: resolve workspace KB scope past dead registrations; keep the progress stream off the activity lease
Regenerate the lazy router index against the integrated route sources.
2026-11-14 22:58:00 +08:00
Bingxi Zhao (Frank)
f691217179 Merge PR #2589: fix(mcp): pass the server name into the OAuth store during Test
Regenerate the lazy router index against the integrated route sources.
2026-11-14 22:57:40 +08:00
Bingxi Zhao (Frank)
54324f8318 Merge PR #2674: fix: reject partner session branches that already exist
Preserve both image-only partner history coverage and existing-destination validation tests; combined partner suite: 146 passed.
2026-11-14 22:57:24 +08:00
qq1069730908
9bc95d6bee fix: regenerate router index for chat patch 2026-11-14 20:06:58 +08:00
mpichini1
48e1e66c23 fix(api): refresh partner router index fingerprint 2026-11-14 10:14:47 +01:00
mpichini1
44dee85814 fix: reject partner session branches that already exist 2026-11-13 19:26:35 +01:00
mpichini1
64626e3015 fix: deliver task stream terminal events when subscriber queues fill 2026-11-13 19:14:00 +01:00
Junlin Li
560a80a17f fix: explain missing LLM access in chat 2026-11-12 16:58:52 +08:00
ZQR1101
e2d16b5b5e chore(book): regenerate router index for the chapter CRUD endpoints
Adding the four chapter routes changed the router source fingerprint, so
the tracked lazy-routing index must be rebuilt via scripts/build_router_index.py
to keep test_repository_index_matches_router_sources green.
2026-11-11 20:45:37 +08:00
ZQR1101
71a05602d5 feat(book): post-generation chapter CRUD without recompiling
Add / rename / reorder / delete chapters after generation through REST
endpoints mirroring the block-CRUD handlers. New chapters are pending
shells; already-compiled pages are never recompiled or discarded. Each
edit carries the chapter's order/title onto its pages so the reader-visible
sequence follows, and delete prunes only its own pages plus the concept
graph, prerequisites, and progress refs.

Part of #2571
2026-11-11 17:45:37 +08:00
evan188199-tech
4847abff1b chore(api): regenerate router_index after the MCP Test name fix (#2587)
Signed-off-by: evan188199-tech <238371241+evan188199-tech@users.noreply.github.com>
2026-11-10 16:06:32 +08:00
evan188199-tech
585d7656c7 fix(mcp): pass the server name into the OAuth store during Test (#2587)
POST /api/space/mcp/servers/{name}/test discarded the path name, so a
probe of an OAuth-backed server built its token store with '' and every
Test answered "ValueError: Unsafe MCP server name for an OAuth store: ''"
— including for a server that was authorized and connected.

probe_server now takes a server_name (the name the saved connection
would address the grant under) and the space router passes the path
name for OAuth configs. A scratch name no grant could live under (an
unnamed draft) is answered the way an unauthorized server is instead of
the store's refusal; non-OAuth probes stay nameless as before.

Fixes #2587

Signed-off-by: evan188199-tech <238371241+evan188199-tech@users.noreply.github.com>
2026-11-10 15:35:07 +08:00
evan188199-tech
b04ac1bbc0 fix(book): run refresh-fingerprints refusal gate before claiming revision
A rejected POST /api/books/{id}/refresh-fingerprints (force=false, stale
pages not yet recompiled) bumped and persisted book.revision before the
engine refused it, so the client's expected_revision went stale and the
force=true retry always lost the revision race (409 forever).

Run the engine's refusal check (new read-only preflight
check_refresh_kb_fingerprints -> ensure_can_refresh_fingerprints) before
_claim_content_mutation; a rejected dismissal is now side-effect free and
the force retry with the same expected_revision succeeds. Regenerate the
router index fingerprint.
2026-11-10 00:47:45 +08:00
Yin
caee2c5ff6 feat(reading): persist question-linked help receipts and events 2026-11-10 00:12:58 +08:00
Yin
a420707623 feat(guardian): show scoped reading progress and quiz records 2026-11-09 23:07:32 +08:00
Yin
9e4db3c292 fix(api): synchronize router index after quiz response change 2026-11-09 22:45:38 +08:00
Yin
5d16a6a2f0 fix(reading): keep quiz answer keys on the server 2026-11-09 22:17:03 +08:00
Daniele Lucarelli
377bf10fa9 feat(i18n): add Italian (it) localization 2026-11-09 08:48:31 +00:00
evan188199-tech
aaf19c6352 fix: regenerate router_index after web-fetch settings routes (#2448) 2026-11-09 16:47:49 +08:00
evan188199-tech
91104d9a3f fix(web_fetch): settings UI for backend + harden DeepSeek fetch cap (#2448)
Addresses Air R1/R2 review blockers on top of the opened PR head:
Settings GET/PUT /api/settings/web-fetch with UI control; DeepSeek fetch
uses identity encoding, raw bytes, and capacity checks before buffer extend;
provider-branding treats `local` as generic.
Air Codex R3 on MacBook Air: READY.
2026-11-09 16:23:50 +08:00
zhang.kom
152c00ca58 fix: register connected knowledge bases in the viewing workspace 2026-11-09 16:00:04 +08:00
denghui996
0902053a12 fix: do not hold the workspace activity lease across a progress stream
The authenticated-request dependency takes a shared lease on
workspace-activity.sqlite3 for the whole ASGI call, and the middleware
releases it when that call returns. A streaming response only returns when
the stream ends, so an indexing-progress SSE held the lease for as long as
its tab stayed open -- and when the indexed task never starts (see the
preceding commit) that is indefinitely.

Every exclusive workspace operation (KB move, registration update, data
migration) then answered 'Workspace data is busy' until the backend was
restarted, because acquire_activity() uses timeout=0 and a leaked shared
lock never expires.

Task-board events and the calendar stream were already excluded for this
reason; the knowledge-base task progress stream reads only in-memory task
state and is equally safe to exclude. A failing task therefore no longer
locks the workspace it cannot even reach.

Regenerate the router index for the changed router sources.

Fixes #2525
2026-11-09 02:07:08 +08:00
denghui996
d39b470d91 fix: resolve a KB's storage scope past unreadable workspace registrations
workspace_id_for_kb_base_dir() walks every registered workspace to find the
one that owns a KB directory, and it runs on every upload, folder sync and
reindex. A registration whose folder no longer exists (archived leftovers, a
directory the user moved) raises WorkspaceError on entry, which aborted the
whole lookup and dropped the storage scope from the background task.

Because WorkspaceError is a ValueError, the upload/sync routes then answered
404 'Knowledge base <name> not found' for a KB that exists, the background
task was never registered (the call sits in add_task's argument list), and
the KB kept the progress entry written just before it, so the UI showed an
endless 'scanning' state with no error on disk.

- skip registrations that cannot be entered instead of aborting the scan
- resolve the scope before copying files or marking the KB queued, so a
  failure cannot leave a task-less progress entry behind
- surface WorkspaceError as 409 with its real message instead of a 404

Fixes #2524
2026-11-09 02:07:05 +08:00