Commits
2026-09-18
feat(service): 📄 rag.index answer carries the extracted text (passages)Ahmet Kaan Gümüş · 9e3b62d
feat(service): 📄 rag.index answer carries the extracted text (passages)
`chunks` alone was a dead end for the caller: the panel could print "18 metin
parçası" and nothing more, so clicking the AI output showed the source PDF
again — the extraction was invisible.
The answer now carries the indexed CHILD chunks with their full text:
"passages": [{"chunk_id", "doc_id", "text", "page_start", "page_end"}],
"passages_truncated": <bool>
Two additive keys; every existing key keeps its meaning and `chunks` is still
the TOTAL indexed count (not len(passages)). Cap: at most 50 rows and/or
512 KB for the WHOLE serialized answer, whichever binds first; the flag is true
whenever anything was dropped, false otherwise. The byte ceiling is a
storage/use ceiling, not a frame one — 8 MiB would pass the wire but is stored
verbatim in rag_output.payload and becomes the panel's download.
Passage text is verbatim (no ellipsis, no reflow); excerpting is the UI's job.
Parents are not listed: they duplicate child text (notes_index._chunks_for
indexes children only).
The budget counts the whole answer, not the list: the answer is serialized
once with an empty `passages` and each row is then charged its own bytes plus
one comma, so the running total is the final serialized size exactly — no
re-serialization, no over-conservative estimate.
Building passages can never fail the index: any error degrades to
passages:[] + passages_truncated:true on an otherwise successful answer, since
the backend keeps its previous rag_output rows only when the whole round trip
fails.
Measured (tests/unit/test_notes_index.py, MetinParcalariTestleri):
- 60-child note -> passages=50, truncated=true, chunks=60, answer 74_680 B
- 4x150 KB paragraphs -> passages=3, truncated=true, answer 461_331 B
(the cap is tight: one more row would be 615_055 B > 524_288 B)
- exactly 50 children -> passages=50, truncated=false
- builder raising -> passages=[], truncated=true, index still written
Local-Gate: eccfba42f84573622280a8f85deb7babb91856c9 (1392 passed, 31s)✨ feat(bridge): 🧩 rag.index served end to end — blob reads, note index, chat channelAhmet Kaan Gümüş · 0877e45
✨ feat(bridge): 🧩 rag.index served end to end — blob reads, note index, chat channel The live service advertised `rag.index` and then typed-refused every request (`index_path_unwired`), so the note "Özet oluştur" surface could never fill: the backend stored no `rag_output` row. The refusal is gone; the capability is now served for real. * transport: `read_blob()` opens the client-initiated stream the contract names (one `BlobRequest` → `BlobResponse` header → exactly `size` RAW bytes), bridged from the executor thread by `_LoopBlobReader`; the transport installs it on the dispatcher at registration. * indexing (`service/notes_index.py`): the note's own title+content always, plus every attachment read over its own blob stream — PDFs through the corpus's own canonical loader, plain text decoded directly — chunked, embedded in one pass (`embed_both`), and written into the school's note index. * store (`index/notes.py`): one bucket per school, `replace_note()` swaps a note's rows as a unit (a re-index cannot duplicate); `rag.chat` merges this channel's ranked hits into the subject corpus's (`Generator(note_index=…)`), with `chunks_by_id`/`span_meta` consulting the live index through `NoteAwareChunks`. * one refused attachment never aborts an index: the note body lands, the answer names what failed (`failed[]`), and the reply echoes `files[].id` so the backend can stamp the doc id it minted. Honest limit (documented in `index/notes.py` and PROJECT_STATE): a note's (class, subject) is not on the wire — the payload carries the course uuid only — so the note channel is school-scoped; the (class, subject) gate cannot be applied to it. The note index is in-process: a restart loses it and the next note edit re-dispatches. Tests: `test_bridge_transport.py` runs the acceptance path against the fake QUIC backend (blob bytes served on a client stream, `files[0].id` echoed) and proves a refused blob is reported, not fatal; `test_notes_index.py` covers the offline indexing path (body-only, re-index dedup, failure isolation, school filter, `rerank_select` compatibility). Pre-fix run (src stashed) shows `'index_path_unwired' != 'malformed'` plus both acceptance tests failing. Unit suite: 1387 passed, 34 skipped. PDF branch smoke-checked against a real 4.5 KB textbook PDF (15 units → 5 children).