Companion to docs/pipeline.html. That doc numbers 12 stages; this doc takes each RAG-relevant piece of infrastructure and says precisely which numbered stage it belongs to — not just "retrieval happens somewhere in the middle."
The easiest way to lose clarity on a RAG system is treating "the data" as one thing. Bandhu has three, and they never share a code path.
Vetted, short, human-reviewed entries — grounding techniques, reframes, thinking-trap psychoeducation. Static-ish, updated rarely, shared across every user.
Small, per-person facts: mood tag, theme, last suggestion + outcome, rolling help-offer count, and the Summarizer's rolling narrative. Updated every check-in.
The tone-scoring rubric (not retrievable content) — used only by the sampled evaluator to grade a response after the fact. Never touches a live reply before it's sent.
Same 12 stages and numbering as docs/pipeline.html. Stages with a highlighted number touch one of the three stores above or a RAG-specific process; muted stages are pure logic and don't.
Produces the emotion·category·intensity tag that pre-filters stage 6's vector search. The special-case branch here also does a direct, non-vector lookup into the Content Library's fixed redirect templates.
Reads the per-user structured store directly, plus stage 11's rolling narrative.
Reads the rolling help-offer count from the same structured store — no new component, same one as stage 4.
The core RAG operation. Embeds the check-in text, checks the cache, queries pgvector filtered by stage 3's tag, returns top 2-3 chunks.
The fast/cheap phrasing model — constrained to only use what stage 6 retrieved. This is the "generation" half of retrieval-augmented generation.
Writes the new structured fact to the per-user store — the raw material stage 11 later synthesizes.
Reads the structured store's accumulated facts, writes back a short rolling narrative — the thing stage 4 actually reads on the next check-in.
The only stage that touches the MITI rubric. Scores a sample of already-sent responses — never in the live path.
Same components as above, described in full, each tagged with exactly which stage(s) call it — the reverse lookup.
Short, 1-3 sentence, human-reviewed entries — never paragraphs pulled wholesale from a source document. Two distinct kinds live here: general retrievable entries (tagged, embedded, found by similarity) and fixed redirect templates (medical doubt, disorder questions, medication questions, medical-document handling — looked up directly by category, never embedded or searched).
Turns text into a vector once, at corpus build time, for every Content Library entry (offline, one-time cost). Turns the live check-in text into a vector at query time — one small, cheap call per check-in.
Holds the Content Library's embedded, tagged entries. Queried with metadata pre-filtering (emotion/category/intensity/language) before similarity search runs, so top_k can stay small — 2-3 results, never a long list.
Stores embedding + retrieval results for common or near-duplicate check-ins, with a similarity threshold to reuse a cached result instead of re-embedding. Sits directly in front of the vector database — a cache hit skips both the embedding call and the pgvector query.
Not embedded, not vector-searched — a small structured record per person: current mood tag, recurring theme, last suggestion offered + whether it helped, and the rolling help-offer count the eligibility gate reads. Written every check-in, never grows into a raw transcript.
Not per-message. Runs on its own schedule (still undecided — see open items in pipeline.html) over the accumulated structured facts, and writes back a short rolling narrative. This is what lets a pattern from Monday actually inform Wednesday's response, and what "Let's look" / Looking Back actually shows.
Fast, cheap model — its only job is phrasing. It composes the acknowledgment plus at most one optional line, using exclusively what Retrieval or the structured memory handed it. Never generates advice or content freely; the model's job is tone, not invention.
The Motivational Interviewing Treatment Integrity coding manual — the scoring rubric, not something retrieved into a live reply. Feeds only the sampled evaluator, which grades 5-10% of already-sent responses for tone drift over time.