Spaces:
Running

AHMDRTAP / GLOSSARY.md
Z User
refactor(architecture): deep-module chat-context assembly + lane-parity guard
8ed78fa
|
Raw History Blame Contribute Delete
2.91 kB
# GLOSSARY — Domain & Architecture Vocabulary
The shared language for the chatbot context stack and the architecture
review round (2026-11-30). Use these terms exactly — they name the **seams**
future refactors must respect, so a reviewer never has to re-derive them
from code. Architecture terms follow the codebase-design vocabulary:
**module** (interface + implementation), **interface** (everything a caller
must know), **depth** (leverage per unit of interface), **seam** (where the
interface lives), **adapter** (concrete thing satisfying an interface at a
seam), **leverage** / **locality**.
## Chat context stack
**Routing Signal**
The latest user message text (string or joined multipart), extracted by
`extractRoutingSignal` (chatbot-skillnet.ts). The single input every intent
gate and the skill router key off. One extraction per request — never
re-derive it per layer.
**Knowledge Layer**
A grounded expert corpus with intent gating, retrieval, citation
enforcement and (optionally) number verification. Today: Saadat (academic
solutions manual), Cables (Elsewedy catalogue + Egyptian Code), Refs
(Saudi DPS-01 / ABB / Schneider). Each lives behind its own module;
`chatbot-context.ts` is the only caller allowed to sequence them.
**Chat Context Assembly**
The one prompt-assembly recipe — routing signal → saadat → cables → refs →
`getSystemPrompt` — implemented once in the deep module
`api/lib/chatbot-context.ts` (`assembleChatContext`). Every lane (legacy
text cascade, stream legacy picker, vision pass-2, BYOK, dynamic router)
calls it; none re-implements the recipe. Guarded byte-for-byte by
`chatbot-context.parity.test.ts`.
**Lane**
One execution path that turns a chat request into a provider call:
legacy text cascade, stream legacy picker, vision pass-2, BYOK
(bring-your-own-key), dynamic router. Lanes differ ONLY in the named
options they pass to `assembleChatContext` — never in the recipe itself.
**Cables Cross-Gate**
The v3.9.2 owner discipline (legacy text-cascade lane only): when a Refs
route owns the question, the Cables block stays empty unless the query
names an explicit cable noun — load words («محركات», «إنارة») alone never
drag the Elsewedy/EgyCode KB into a Saudi-DPS question. Expressed as the
`cablesCrossGate` input of `assembleChatContext`.
**Citation Enforcement**
The deterministic pinned → cables → refs composition applied to every
successful reply before it leaves the server (`enforceAllCitations` in
chatbot-context.ts). The stream terminator passes `appendOnly: true` —
appended citations may stream as a final text event, already-streamed text
is never rewritten.
**AppendOnly (stream seam)**
The stream-terminator mode of citation enforcement: the reply body already
reached the client, so enforcement may only APPEND. Contrast with the
non-stream path where the reply can be mutated in place.