Repository navigation
A graph citation's source entry carries the sentence the fact was read from, and the preview and the document page mark it - #977
Merged
WaylandYang merged 4 commits intoSep 27, 2026
Conversation
…d from, and the preview and the document page mark it Signed-off-by: dada-yan <BinjunYann@gmail.com>
Maintainer edits on deeplethe#977. A source entry keeps at most eight quoted sentences of at most 400 characters each: the list is resent after every tool call and goes into the final request. The quote that travels in the document page's address is dropped when it is longer than 300 characters, since it stays in history and access logs and a long CJK sentence outgrows a request header; it is dropped whole because a cut sentence cannot be found in the passage. The two ordering terms on the quote are removed: fact_evidence has one row per fact and chunk, so they never decided anything. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Wayland Yang <wayland0916@gmail.com>
WaylandYang
approved these changes
Sep 27, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Thank you. The sentence travels with the entry, one chunk keeps one number, the frame goes out when the list changed and not only when it grew, and the marking is a pure function that returns nodes. Both follow-ups from #968 are covered, including the shared number between a search and a graph tool.
I pushed one commit with three bounds:
- A source entry keeps at most eight sentences of at most 400 characters. The list is resent after every tool call and goes into the final request, and a chunk that yields many facts should not grow it.
- The quote in the document page's address is dropped above 300 characters, whole rather than cut, since a cut sentence cannot be found in the passage. It stays in browser history and access logs, and a long Chinese sentence outgrows a request header on reload.
- The two ordering terms on the quote are gone. fact_evidence has one row per fact and chunk, so they never decided anything.
Landing it. Thanks again.
WaylandYang
approved these changes
Sep 27, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Maintainer review: sound, landing.
WaylandYang
added a commit
to Maya-Kid/utopia
that referenced
this pull request
Sep 27, 2026
Maintainer edits on deeplethe#976. dev is merged in (deeplethe#977's tests and design sentence kept beside this PR's). Reading which rows a person corrected scanned every audit row of the base, on every read of an entity's facts, even in a base with no correction; migration 0097 adds a partial index on that one action, and CURRENT_SCHEMA_VERSION is 88. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Wayland Yang <wayland0916@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #968: the two follow-ups its review asked for.
Change
The entry carries the sentence.
graph::first_live_evidencereturns the quote of the evidence it picks, along with the chunk. The order now ends in the quote's position within the chunk, so the pick is deterministic when a chunk holds several evidence rows for one fact.Evidence::markstill numbers by chunk throughcite, so one chunk keeps one number. It then adds the fact's quote to that entry'squotes(tools::add_quote), deduplicated and in citation order.The stream publishes the change.
citeused to only append, so the producer sent asourcesframe when the list grew. An added quote does not grow it, so the frame now goes out when the list changed at all. Stored sources are what they were, withquoteswhere a graph tool cited.The web marks it.
Sourcegainsquotes.u-mark), and the list row leads with the first sentence instead of the chunk's opening.quotesearch parameter, and the document page marks it in the cited chunk.quotes.ts):Docs.
docs/design/chat-and-mcp.mdsays what the entry carries.Known limits
Verification
Run in containers on a Linux host: Rust 1.98.1 and PostgreSQL 16 with pgvector, Node 20, and Playwright's Chromium for the browser tests.
New tests
In
chat_graph_citation_tests.rs, on #968's fixture:a_graph_number_opens_the_sentence_it_was_read_fromas_ofbefore the supersession, it is the charter chunk and the charter's sentence again.a_search_and_a_graph_tool_share_one_number:search_chunksregisters the handover chunk, thenentity_factscites Li Si's fact with the same number, and the entry gains the sentence. In the other order, the search reuses the graph's number and the sentence stays.a_quote_added_to_a_search_hit_is_published: a scripted chat searches, then callsentity_factsfor Li Si, whose chunks the search already registered. The secondsourcesframe has the same entries plus their quotes, and the stored sources equal the last frame.web/src/quotes.test.tscovers:quoteparameter.On dev (0fbcd38) with the new tests
The control branch is dev plus the new tests, with a stub of today's behaviour for the web helper.
quotes. The chat test fails because no second frame is sent when only a quote changes.This branch
api::tests): 202 passed.cargo fmt --all --checkis clean.cargo clippy --locked --workspace --all-targets -- -D warningsis clean.UTOPIA_TEST_REQUIRE_PDFTOTEXT=1 cargo test --locked --workspacepasses.pnpm test: 203 passed;pnpm buildpasses (style guard, tsc, vite);tests/chat-view.test.mjsin Chromium: 30 passed.