Retrieval feeds the Enrichment prompt (#125) - #137
Merged
Conversation
Research stops starting cold. Before a report is written, what this walk already worked out about the same things is retrieved into the prompt — Threads that named the same nouns first, then ones that merely read alike — with the reason each is there and a plain instruction to build on them and say which one. The Thread being enriched has neither mentions nor an embedding of its own yet: it earns both from the report about to be written. So both paths start from the Capture itself. The embedding fallback embeds the walker's words at query time rather than looking the Thread up and finding nothing. And mention-first — which would otherwise never fire on a first Capture, the common case — matches nouns the corpus already knows against the words the walker just used: a known noun appearing whole in what they said is the same exact link a stored mention would have been. Names under four characters are skipped; a short noun matches everything and means nothing. All of it is best-effort by construction. A Capture with no history is prompted exactly as it was before retrieval existed, and a retrieval that throws — a broken index, a gateway that will not embed — writes the cold-start report rather than failing the job. Also hardens two tests that read enrichment-derived UI: rows paint from the store before their Enrichments land, so asserting a mention chip without waiting for a mention-derived element was a race that only showed under both browser projects at once. Closes #125
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Research stops starting cold. Before a report is written, what this walk already worked out about the same things is retrieved into the prompt — Threads that named the same nouns first, then ones that merely read alike — each with the reason it is there, and a plain instruction to build on them and say which one.
The chicken-and-egg this had to solve. The Thread being enriched has neither mentions nor an embedding of its own: it earns both from the report about to be written. So both retrieval paths start from the Capture itself.
Best-effort by construction. A Capture with no history is prompted exactly as it was before any of this existed. A retrieval that throws — a broken index, a gateway that will not embed — writes the cold-start report rather than failing the job. Every failure path is caught and returns an empty list.
Closes #125
Test plan
tests/enrichment-retrieval.spec.ts— a Capture whose past shares a noun gets that Thread in its prompt, with the walk date and the shared noun named; a Capture with no history produces a prompt containing no retrieval section at all; a repository whose index throws still completes with the cold-start report; a Thread linked only by resemblance is retrieved and labelled "reads alike"; the renderer's exact output; and the text matcher (whole words only, short names skipped, case-insensitive)pnpm typecheckclean;pnpm test— 337 passed, 1 failed (trash-repository.spec.ts, Neon-backed, fails identically on a clean checkout ofmainhere), 10 skippedpnpm lint— 6 errors, all pre-existingTwo tests hardened.
desk-priors-desktopfailed once under full-suite load and passed on re-run. The cause is real and mine: rows paint from the local store before their Enrichments land, so asserting a mention-derived chip without first waiting for a mention-derived element is a race that only shows when both browser projects run at once. Both assertions now gate on the Mentions rail row, which cannot exist until Enrichments have loaded. I ran the full suite twice after the change.Note for production
The retrieval quality depends on embeddings existing. Until
mise run embeddings:backfillis run (after checking the model against the gateway's live/v1/modelstable), only Threads enriched since #124 have vectors — so the fallback half is thin and mention matching carries it. That is the intended degradation, not a defect.Generated by Claude Code