@konneal/engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +13 -0
  3. package/dist/admin.d.ts +26 -0
  4. package/dist/ai.d.ts +6 -0
  5. package/dist/anchors.d.ts +6 -0
  6. package/dist/answercache.d.ts +22 -0
  7. package/dist/ask.d.ts +5 -0
  8. package/dist/auth.d.ts +12 -0
  9. package/dist/bubble.d.ts +14 -0
  10. package/dist/chunk-LLWPT2XV.js +49 -0
  11. package/dist/chunk-MB74PTRM.js +114 -0
  12. package/dist/chunk-WOGQM7DJ.js +197 -0
  13. package/dist/chunk-WWNCWKKC.js +42 -0
  14. package/dist/completion.d.ts +5 -0
  15. package/dist/config.d.ts +154 -0
  16. package/dist/config.js +37 -0
  17. package/dist/context.d.ts +115 -0
  18. package/dist/conversations.d.ts +5 -0
  19. package/dist/drafts.d.ts +129 -0
  20. package/dist/env.d.ts +57 -0
  21. package/dist/faithfulness.d.ts +5 -0
  22. package/dist/grader.d.ts +3 -0
  23. package/dist/graph.d.ts +13 -0
  24. package/dist/hybrid.d.ts +7 -0
  25. package/dist/index.d.ts +9 -0
  26. package/dist/index.js +5373 -0
  27. package/dist/internal_gateway.d.ts +14 -0
  28. package/dist/lexical.d.ts +7 -0
  29. package/dist/livedata.d.ts +77 -0
  30. package/dist/memories.d.ts +10 -0
  31. package/dist/modelplane.d.ts +61 -0
  32. package/dist/oidc.d.ts +73 -0
  33. package/dist/pipeline.d.ts +57 -0
  34. package/dist/profile.d.ts +2 -0
  35. package/dist/profile.gen.d.ts +70 -0
  36. package/dist/profile.js +8 -0
  37. package/dist/projects.d.ts +8 -0
  38. package/dist/prompts/conversational.md +8 -0
  39. package/dist/prompts/enrichment.md +3 -0
  40. package/dist/prompts/faithfulness.md +1 -0
  41. package/dist/prompts/grader.md +5 -0
  42. package/dist/prompts/listwise.md +3 -0
  43. package/dist/prompts/precision.md +1 -0
  44. package/dist/prompts/reflect.md +1 -0
  45. package/dist/prompts/relevancy.md +1 -0
  46. package/dist/prompts/research.md +10 -0
  47. package/dist/prompts/section-summary.md +5 -0
  48. package/dist/prompts/summarize.md +1 -0
  49. package/dist/prompts/system.md +18 -0
  50. package/dist/prompts/understanding.md +17 -0
  51. package/dist/quota.d.ts +13 -0
  52. package/dist/reflect.d.ts +5 -0
  53. package/dist/refs.d.ts +40 -0
  54. package/dist/refusal.d.ts +9 -0
  55. package/dist/refusal.js +9 -0
  56. package/dist/requestScope.d.ts +26 -0
  57. package/dist/requestScope.js +10 -0
  58. package/dist/research.d.ts +8 -0
  59. package/dist/search.d.ts +4 -0
  60. package/dist/selfquery.d.ts +7 -0
  61. package/dist/session.d.ts +1 -0
  62. package/dist/share.d.ts +2 -0
  63. package/dist/structural.d.ts +27 -0
  64. package/dist/tablecontext.d.ts +11 -0
  65. package/dist/understand.d.ts +11 -0
  66. package/dist/understandContract.d.ts +29 -0
  67. package/dist/verdict.d.ts +24 -0
  68. package/docs/API.md +451 -0
  69. package/docs/ARCHITECTURE.md +302 -0
  70. package/docs/AUDIT-2026-08-24.md +71 -0
  71. package/docs/CONTRIBUTOR-AUDIT-2026-08-25.md +147 -0
  72. package/docs/INGEST-ARCHITECTURE.md +158 -0
  73. package/docs/MCP.md +92 -0
  74. package/docs/METANORMA-AI-SERIALIZATION.md +247 -0
  75. package/docs/MKO-EXPORT-PIPELINE.md +147 -0
  76. package/docs/REDESIGN-NORMATIVE-RAG-ETSI.md +485 -0
  77. package/docs/RESEARCH-SOTA-2026.md +243 -0
  78. package/docs/ROADMAP-SOTA.md +130 -0
  79. package/docs/SOTA-STAGE-SPECS.md +509 -0
  80. package/docs/annealment/F1-verdict.md +27 -0
  81. package/docs/annealment/F10-notes.md +19 -0
  82. package/docs/annealment/F11-composition.md +17 -0
  83. package/docs/annealment/F12-passport.md +17 -0
  84. package/docs/annealment/F2-counterfactual.md +20 -0
  85. package/docs/annealment/F3-absence.md +21 -0
  86. package/docs/annealment/F4-instance.md +18 -0
  87. package/docs/annealment/F5-workflow.md +21 -0
  88. package/docs/annealment/F6-impact.md +21 -0
  89. package/docs/annealment/F7-editions.md +18 -0
  90. package/docs/annealment/F8-selfverify.md +19 -0
  91. package/docs/annealment/F9-projection-qa.md +17 -0
  92. package/docs/annealment/L0-locate.md +19 -0
  93. package/docs/annealment/L1-extract.md +18 -0
  94. package/docs/annealment/L2-nomenclature.md +22 -0
  95. package/docs/annealment/L3-geometry.md +23 -0
  96. package/docs/annealment/L4-composition.md +21 -0
  97. package/docs/annealment/L5-cross-standard.md +20 -0
  98. package/docs/annealment/L6-diachrony.md +21 -0
  99. package/docs/annealment/L7-perception.md +20 -0
  100. package/docs/annealment/L8-computation.md +22 -0
  101. package/docs/annealment/L9-instance-process.md +23 -0
  102. package/docs/annealment/README.md +10 -0
  103. package/docs/guidelines-metanorma-ai-programme.md +279 -0
  104. package/docs/identity-onboarding-rag.md +65 -0
  105. package/docs/identity-service.md +219 -0
  106. package/docs/knowledge-annealment.md +273 -0
  107. package/docs/konneal-extraction-plan.md +481 -0
  108. package/docs/metanorma-for-ai.md +270 -0
  109. package/docs/mirror-plan.md +36 -0
  110. package/docs/multi-sdo-architecture.md +191 -0
  111. package/docs/paper-annealment-comparison.md +259 -0
  112. package/docs/paper-assets/architecture.svg +94 -0
  113. package/docs/paper-assets/contract-v2.svg +94 -0
  114. package/docs/paper-assets/mko-ingest.svg +91 -0
  115. package/docs/paper-oiml-bulletin.md +402 -0
  116. package/docs/paper-oiml-bulletin.mdx +419 -0
  117. package/docs/product-branding-options.md +172 -0
  118. package/docs/projects-design.md +88 -0
  119. package/docs/sota-mechanisms.md +184 -0
  120. package/docs/spec-api.md +77 -0
  121. package/docs/spec-pipeline.md +126 -0
  122. package/docs/vector-adapter.md +88 -0
  123. package/package.json +70 -0
  124. package/profile/corpora.yaml +5 -0
  125. package/profile/datasets.yaml +14 -0
  126. package/profile/prompts.yaml +5 -0
  127. package/profile/publisher.yaml +17 -0
  128. package/profile/retrieval.yaml +1 -0
  129. package/profile/sources.yaml +5 -0
  130. package/profile/ui.yaml +7 -0
  131. package/scripts/gen_profile.mjs +33 -0
  132. package/workers/shared/ai.ts +21 -0
  133. package/workers/shared/auth.ts +16 -0
  134. package/workers/shared/chunk.ts +108 -0
  135. package/workers/shared/oidc.ts +312 -0
  136. package/workers/shared/router.ts +45 -0
  137. package/workers/shared/session.ts +104 -0
  138. package/workers/worker_internal/src/index.ts +157 -0
  139. package/workers/worker_internal/tsconfig.json +15 -0
  140. package/workers/worker_internal/wrangler.toml +32 -0
  141. package/workers/worker_mcp/src/index.ts +175 -0
  142. package/workers/worker_mcp/tsconfig.json +13 -0
  143. package/workers/worker_mcp/wrangler.toml +18 -0
  144. package/workers/worker_public/migrations/0002_conversations.sql +22 -0
  145. package/workers/worker_public/migrations/0003_shared_conversations.sql +9 -0
  146. package/workers/worker_public/migrations/0004_graph.sql +16 -0
  147. package/workers/worker_public/migrations/0005_documents.sql +19 -0
  148. package/workers/worker_public/migrations/0006_conversation_entities.sql +11 -0
  149. package/workers/worker_public/migrations/0007_chunks_fts.sql +43 -0
  150. package/workers/worker_public/migrations/0008_unit_payloads.sql +15 -0
  151. package/workers/worker_public/migrations/0009_chunks_unit.sql +8 -0
  152. package/workers/worker_public/migrations/0009_message_context.sql +7 -0
  153. package/workers/worker_public/migrations/0010_model_nodes.sql +33 -0
  154. package/workers/worker_public/migrations/0011_schema_union.sql +38 -0
  155. package/workers/worker_public/migrations/0012_memories.sql +15 -0
  156. package/workers/worker_public/migrations/0013_projects.sql +21 -0
  157. package/workers/worker_public/node_modules/@cloudflare/workers-types/2021-11-03/index.d.ts +16306 -0
  158. package/workers/worker_public/node_modules/@cloudflare/workers-types/2021-11-03/index.ts +16261 -0
  159. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-01-31/index.d.ts +16373 -0
  160. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-01-31/index.ts +16328 -0
  161. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-03-21/index.d.ts +16382 -0
  162. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-03-21/index.ts +16337 -0
  163. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-08-04/index.d.ts +16383 -0
  164. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-08-04/index.ts +16338 -0
  165. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-10-31/index.d.ts +16403 -0
  166. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-10-31/index.ts +16358 -0
  167. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-11-30/index.d.ts +16408 -0
  168. package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-11-30/index.ts +16363 -0
  169. package/workers/worker_public/node_modules/@cloudflare/workers-types/2023-03-01/index.d.ts +16414 -0
  170. package/workers/worker_public/node_modules/@cloudflare/workers-types/2023-03-01/index.ts +16369 -0
  171. package/workers/worker_public/node_modules/@cloudflare/workers-types/2023-07-01/index.d.ts +16414 -0
  172. package/workers/worker_public/node_modules/@cloudflare/workers-types/2023-07-01/index.ts +16369 -0
  173. package/workers/worker_public/node_modules/@cloudflare/workers-types/README.md +135 -0
  174. package/workers/worker_public/node_modules/@cloudflare/workers-types/entrypoints.svg +53 -0
  175. package/workers/worker_public/node_modules/@cloudflare/workers-types/experimental/index.d.ts +17095 -0
  176. package/workers/worker_public/node_modules/@cloudflare/workers-types/experimental/index.ts +17050 -0
  177. package/workers/worker_public/node_modules/@cloudflare/workers-types/index.d.ts +16306 -0
  178. package/workers/worker_public/node_modules/@cloudflare/workers-types/index.ts +16261 -0
  179. package/workers/worker_public/node_modules/@cloudflare/workers-types/latest/index.d.ts +16447 -0
  180. package/workers/worker_public/node_modules/@cloudflare/workers-types/latest/index.ts +16402 -0
  181. package/workers/worker_public/node_modules/@cloudflare/workers-types/oldest/index.d.ts +16306 -0
  182. package/workers/worker_public/node_modules/@cloudflare/workers-types/oldest/index.ts +16261 -0
  183. package/workers/worker_public/node_modules/@cloudflare/workers-types/package.json +11 -0
  184. package/workers/worker_public/package.json +13 -0
  185. package/workers/worker_public/prompts/conversational.md +8 -0
  186. package/workers/worker_public/prompts/enrichment.md +3 -0
  187. package/workers/worker_public/prompts/faithfulness.md +1 -0
  188. package/workers/worker_public/prompts/grader.md +5 -0
  189. package/workers/worker_public/prompts/listwise.md +3 -0
  190. package/workers/worker_public/prompts/precision.md +1 -0
  191. package/workers/worker_public/prompts/reflect.md +1 -0
  192. package/workers/worker_public/prompts/relevancy.md +1 -0
  193. package/workers/worker_public/prompts/research.md +10 -0
  194. package/workers/worker_public/prompts/section-summary.md +5 -0
  195. package/workers/worker_public/prompts/summarize.md +1 -0
  196. package/workers/worker_public/prompts/system.md +18 -0
  197. package/workers/worker_public/prompts/understanding.md +17 -0
  198. package/workers/worker_public/public/app.js +166 -0
  199. package/workers/worker_public/public/index.html +48 -0
  200. package/workers/worker_public/public/style.css +147 -0
  201. package/workers/worker_public/schema.sql +248 -0
  202. package/workers/worker_public/src/admin.ts +358 -0
  203. package/workers/worker_public/src/ai.ts +71 -0
  204. package/workers/worker_public/src/anchors.ts +41 -0
  205. package/workers/worker_public/src/answercache.ts +72 -0
  206. package/workers/worker_public/src/ask.ts +1094 -0
  207. package/workers/worker_public/src/auth.ts +252 -0
  208. package/workers/worker_public/src/bubble.ts +111 -0
  209. package/workers/worker_public/src/completion.ts +75 -0
  210. package/workers/worker_public/src/config.ts +238 -0
  211. package/workers/worker_public/src/context.ts +238 -0
  212. package/workers/worker_public/src/conversations.ts +162 -0
  213. package/workers/worker_public/src/drafts.ts +497 -0
  214. package/workers/worker_public/src/env.ts +90 -0
  215. package/workers/worker_public/src/faithfulness.ts +63 -0
  216. package/workers/worker_public/src/grader.ts +89 -0
  217. package/workers/worker_public/src/graph.ts +63 -0
  218. package/workers/worker_public/src/hybrid.ts +77 -0
  219. package/workers/worker_public/src/index.ts +441 -0
  220. package/workers/worker_public/src/internal_gateway.ts +41 -0
  221. package/workers/worker_public/src/lexical.ts +86 -0
  222. package/workers/worker_public/src/lib/hit.ts +4 -0
  223. package/workers/worker_public/src/lib/http.ts +83 -0
  224. package/workers/worker_public/src/lib/router.ts +4 -0
  225. package/workers/worker_public/src/livedata.ts +334 -0
  226. package/workers/worker_public/src/memories.ts +81 -0
  227. package/workers/worker_public/src/modelplane.ts +213 -0
  228. package/workers/worker_public/src/oidc.ts +333 -0
  229. package/workers/worker_public/src/pipeline.ts +377 -0
  230. package/workers/worker_public/src/ports/blobs.ts +7 -0
  231. package/workers/worker_public/src/ports/cloudflare/adapters.ts +177 -0
  232. package/workers/worker_public/src/ports/kv.ts +8 -0
  233. package/workers/worker_public/src/ports/model.ts +28 -0
  234. package/workers/worker_public/src/ports/runtime.ts +13 -0
  235. package/workers/worker_public/src/ports/store.ts +20 -0
  236. package/workers/worker_public/src/ports/vector.ts +26 -0
  237. package/workers/worker_public/src/profile.gen.ts +101 -0
  238. package/workers/worker_public/src/profile.ts +16 -0
  239. package/workers/worker_public/src/projects.ts +108 -0
  240. package/workers/worker_public/src/prompts.d.ts +6 -0
  241. package/workers/worker_public/src/quota.ts +54 -0
  242. package/workers/worker_public/src/reflect.ts +67 -0
  243. package/workers/worker_public/src/refs.ts +107 -0
  244. package/workers/worker_public/src/refusal.ts +65 -0
  245. package/workers/worker_public/src/requestScope.ts +71 -0
  246. package/workers/worker_public/src/research.ts +126 -0
  247. package/workers/worker_public/src/search.ts +56 -0
  248. package/workers/worker_public/src/selfquery.ts +25 -0
  249. package/workers/worker_public/src/session.ts +4 -0
  250. package/workers/worker_public/src/share.ts +53 -0
  251. package/workers/worker_public/src/stages/conceptGraph.ts +68 -0
  252. package/workers/worker_public/src/stages/conceptSteer.ts +39 -0
  253. package/workers/worker_public/src/stages/corpusScope.ts +25 -0
  254. package/workers/worker_public/src/stages/dedup.ts +10 -0
  255. package/workers/worker_public/src/stages/dense.ts +73 -0
  256. package/workers/worker_public/src/stages/diversity.ts +33 -0
  257. package/workers/worker_public/src/stages/editionCover.ts +63 -0
  258. package/workers/worker_public/src/stages/editionSteer.ts +88 -0
  259. package/workers/worker_public/src/stages/familyBoost.ts +22 -0
  260. package/workers/worker_public/src/stages/federate.ts +22 -0
  261. package/workers/worker_public/src/stages/glossary.ts +65 -0
  262. package/workers/worker_public/src/stages/graphLane.ts +31 -0
  263. package/workers/worker_public/src/stages/hyde.ts +29 -0
  264. package/workers/worker_public/src/stages/index.ts +69 -0
  265. package/workers/worker_public/src/stages/lexicalUnion.ts +21 -0
  266. package/workers/worker_public/src/stages/multiQuery.ts +57 -0
  267. package/workers/worker_public/src/stages/overviewDemote.ts +14 -0
  268. package/workers/worker_public/src/stages/poolOpen.ts +10 -0
  269. package/workers/worker_public/src/stages/propagate.ts +15 -0
  270. package/workers/worker_public/src/stages/rerank.ts +47 -0
  271. package/workers/worker_public/src/stages/seal.ts +16 -0
  272. package/workers/worker_public/src/stages/sectionDescent.ts +61 -0
  273. package/workers/worker_public/src/stages/stdRefNudge.ts +35 -0
  274. package/workers/worker_public/src/stages/subQuery.ts +42 -0
  275. package/workers/worker_public/src/stages/termNudge.ts +24 -0
  276. package/workers/worker_public/src/stages/typedPin.ts +131 -0
  277. package/workers/worker_public/src/stages/types.ts +112 -0
  278. package/workers/worker_public/src/stages/windowFloor.ts +23 -0
  279. package/workers/worker_public/src/structural.ts +171 -0
  280. package/workers/worker_public/src/tablecontext.ts +41 -0
  281. package/workers/worker_public/src/understand.ts +72 -0
  282. package/workers/worker_public/src/understandContract.ts +67 -0
  283. package/workers/worker_public/src/verdict.ts +255 -0
  284. package/workers/worker_public/tsconfig.json +18 -0
  285. package/workers/worker_public/wrangler.toml +104 -0
@@ -0,0 +1,243 @@
1
+ # SOTA Research Digest — RAG & Chatbot Techniques, 2023→2026
2
+
3
+ *Compiled 2026-08-26 for the OIML SMART AI service. Sources are live web
4
+ research (arXiv, ACL/ACM/NeurIPS/SIGIR 2025–2026, vendor engineering blogs).
5
+ Companion document: `ROADMAP-SOTA.md` (gap analysis + phased plan).*
6
+
7
+ ---
8
+
9
+ ## 1. The paradigm timeline
10
+
11
+ | Era | Paradigm | Defining techniques |
12
+ |---|---|---|
13
+ | 2023 | **Naive RAG** | chunk → embed → top-k → generate. "PDFs into a vector DB" |
14
+ | 2023–24 | **Advanced RAG** | pre/post-retrieval optimization: query rewriting, HyDE, multi-query fusion, reranking, CRAG/Self-RAG correction |
15
+ | 2024–25 | **Modular RAG** | composable routing, adaptive retrieval depth, specialized indexes (graph, table), eval-driven components |
16
+ | 2025–26 | **Agentic RAG** | iterative retrieve→read→decide loops, planning, reflection, tool use; "deep research" workflows |
17
+
18
+ Surveys anchoring the arc: [Gao et al. 2312.10997](https://arxiv.org/abs/2312.10997) (Naive→Advanced), [2410.12837](https://www.alphaxiv.org/abs/2410.12837), [2506.00054](https://arxiv.org/abs/2506.00054) (comprehensive, June 2025), and the [Agentic RAG survey 2501.09136](https://arxiv.org/html/2501.09136v4). The 2026 field consensus: the "Hello World" RAG is dead ([AI with Aish](https://aishwaryasrinivasan.substack.com/p/all-you-need-to-know-about-rag-in)); production systems are multi-layer, adaptive, and eval-instrumented.
19
+
20
+ **Where we are:** our serving pipeline is squarely *Modular RAG* with one-shot agentic elements (CRAG corrective re-retrieval, self-RAG reflection). The main structural gap to 2026 SOTA is the **agentic loop** (§5) and the **graph lane** (§6).
21
+
22
+ ---
23
+
24
+ ## 2. Data preparation, chunking, contextual enrichment
25
+
26
+ **SOTA recipe (Anthropic Contextual Retrieval, verified in production widely):**
27
+ prepend an LLM-written situating context to each chunk before embedding.
28
+ Measured failure-rate reductions: contextual embedding **35%**, + contextual
29
+ BM25 **49%**, + reranking **67%**
30
+ ([Anthropic](https://www.anthropic.com/engineering/contextual-retrieval),
31
+ [Claude Cookbook](https://platform.claude.com/cookbook/capabilities-contextual-embeddings-guide),
32
+ [Tectonic breakdown](https://gettectonic.com/anthropics-new-approach-to-rag/)).
33
+ Follow-up analysis ([Reconstructing Context, 2504.19754](https://arxiv.org/html/2504.19754v1))
34
+ also validates **late chunking** (embed the full doc, pool per-chunk token
35
+ vectors) as a cheaper alternative with comparable gains on some corpora.
36
+
37
+ **Key subtlety:** the recipe has THREE parts — we historically did embedding
38
+ + reranking but lexical scoring over *raw* text. Once contextual enrichment
39
+ completes, our in-worker keyword layer scores enriched `chunk_text`, giving
40
+ us contextual BM25 for free (verify in the post-enrichment eval).
41
+
42
+ **2026 additions:** Matryoshka (MRL) embeddings — one embedding, multiple
43
+ truncatable dimensionalities, enabling coarse-to-fine search up to 5× faster
44
+ combined with quantization
45
+ ([Qdrant hybrid queries](https://qdrant.tech/documentation/search/hybrid-queries/),
46
+ [MRL × quantization](https://medium.com/data-science-collective/matryoshka-embeddings-how-to-make-vector-search-5x-faster-f9fdc54d5ffd)).
47
+
48
+ ---
49
+
50
+ ## 3. Vector database operations
51
+
52
+ 2026 feature baseline across Qdrant/Milvus/Weaviate/Redis
53
+ ([2026 comparison](https://www.firecrawl.dev/blog/best-vector-databases),
54
+ [Redis 2026 guide](https://redis.io/blog/vector-search-database-news-2026-guide/)):
55
+
56
+ - **Hybrid sparse+dense** as a first-class query: dense vectors + SPLADE/BM25 sparse vectors fused server-side
57
+ - **Quantization** (scalar/binary/product) for memory and speed
58
+ - **Matryoshka coarse-to-fine** retrieval
59
+ - **Multi-vector objects** and server-side reranking hooks
60
+ - Rich **metadata filtering** with index-backed predicates
61
+
62
+ **Cloudflare Vectorize (our platform) today:** dense-only, **no native sparse
63
+ vectors**, no exposed quantization knobs; 10M vectors/index; metadata indexes
64
+ required per filtered field; AutoRAG shipped for managed use cases
65
+ ([Anjin Digital 2026 review](https://www.anjin.digital/blog-posts/cloudflare-vectorize-v2-edge-rag-revolution),
66
+ [Firecrawl comparison notes the hybrid gap](https://www.firecrawl.dev/blog/best-vector-databases)).
67
+
68
+ **Implication:** our hybrid behavior must live in the worker — which it does
69
+ (in-worker keyword RRF) — and any sparse-index ambitions mean either waiting
70
+ for Vectorize or re-implementing lexical recall over a cheap store (D1/KV
71
+ inverted index). Constraint, not blocker; CLAUDE.md's metadata-filter
72
+ strategy already covers the exact-identifier query class.
73
+
74
+ ---
75
+
76
+ ## 4. Query understanding, intent, multi-turn handling
77
+
78
+ - **LLM query understanding** (routing, filters, rewriting, decomposition,
79
+ HyDE) is the accepted pre-retrieval core — [Agentic RAG survey](https://arxiv.org/html/2501.09136v4);
80
+ NVIDIA's blueprint, IBM granite, and dedicated LoRA rewriters
81
+ ([ModelScope granite-3.2 query-rewrite LoRA](https://modelscope.cn/models/AI-ModelScope/granite-3.2-8b-lora-rag-query-rewrite))
82
+ treat **decontextualization of the latest utterance** as its own model task.
83
+ - **Multi-turn SOTA:** standalone-query rewriting (we have), plus
84
+ **multi-turn entity graphs / entity memory** tracking referents across
85
+ turns ([CMU-LTI TREC CAsT](https://trec.nist.gov/pubs/trec30/papers/CMU-LTI-CAsT.pdf)),
86
+ and history-aware rewriting benchmarks — MTRAG, SemEval-2026 Task 8
87
+ ([UTRAG](https://aclanthology.org/2026.semeval-1.237.pdf),
88
+ [Sifei](https://arxiv.org/html/2606.28352v1)).
89
+ - **Semantic caching** of queries/answers by embedding similarity is a
90
+ recognized latency/cost lever ([HF discussion pattern](https://discuss.huggingface.co/t/multi-turn-rag-for-technical-documentation-using-context-aware-query-rewriting-semantic-caching-is-this-a-sound-approach/172433)).
91
+ - **Mixed-initiative / clarifying questions:** systems that proactively ask
92
+ ONE clarifying question under ambiguity, and *suggest* follow-ups
93
+ ([ACM 3814610](https://dl.acm.org/doi/10.1145/3814610),
94
+ [WWW 2024](https://arxiv.org/abs/2402.07742),
95
+ [ACL 2023 controllable mixed-initiative](https://aclanthology.org/2023.acl-short.82.pdf)).
96
+ Our system prompt permits a clarifying question but never generates
97
+ follow-up suggestions — a UX-level gap.
98
+
99
+ ---
100
+
101
+ ## 5. Retrieval accuracy: reranking, agentic loops, test-time compute
102
+
103
+ **Reranking (2025–26 consensus — cascades):**
104
+ cheap recall (BM25+dense, hundreds) → **cross-encoder** to top-50 → optional
105
+ **LLM listwise** rerank of the final 5–15 with joint list reasoning
106
+ ([ZeroEntropy deep dive](https://zeroentropy.dev/articles/should-you-use-llms-for-reranking-a-deep-dive-into-pointwise-listwise-and-cross-encoders/),
107
+ [Redis 2026 reranking roundup](https://redis.io/blog/top-reranking-models-rag-accuracy/),
108
+ [comparative analysis 2602.22219](https://arxiv.org/html/2602.22219v1)).
109
+ Listwise accelerators: [FIRST single-token decoding](https://github.com/gangiswag/llm-reranker),
110
+ RankZephyr, [self-calibrated listwise (SIGIR 2025)](https://dl.acm.org/doi/10.1145/3696410.3714658).
111
+ We run bge-reranker-base (cross-encoder) ✓; the missing rung is LLM-listwise
112
+ refinement of our top-12 for hard queries (already noted in CLAUDE.md for
113
+ the internal deep pool).
114
+
115
+ **Agentic loops / deep research:** retrieve → read → judge sufficiency →
116
+ retrieve again until evidence is enough
117
+ ([Agentic RAG survey](https://arxiv.org/html/2501.09136v4),
118
+ [FutureAGI patterns](https://futureagi.com/blog/agentic-rag-systems-2025/),
119
+ [Milvus DeepSearcher](https://milvus.io/zh/blog/stop-use-outdated-rag-deepsearcher-agentic-rag-approaches-changes-everything.md)).
120
+ Our CRAG + reflection are single-shot; a bounded loop (≤3 iterations, budget-
121
+ gated) is the SOTA shape. Cloudflare Workflows (durable, in our architecture
122
+ docs already) is the natural substrate for a long-form "research mode".
123
+
124
+ **Reasoning models × retrieval:** test-time compute scaling — parallel
125
+ retrieval over reasoning graphs ([MIRAGE 2508.18260](https://arxiv.org/html/2508.18260v1)),
126
+ plan-then-retrieve ([Plan\*RAG](https://openreview.net/pdf?id=gi9aqlYdBk)),
127
+ and sample-and-verify selection ([inference-time scaling list](https://github.com/ThreeSR/Awesome-Inference-Time-Scaling)).
128
+ Practical translation for us: generate 2 candidate answers for hard queries
129
+ and let the faithfulness judge pick — cheap on Workers AI reasoning models.
130
+
131
+ **Long-context vs RAG (2026 verdict: complementary):** RAG is ~1,250× cheaper
132
+ per query, faster, and citation-grounded; long context wins for focused
133
+ single-document analysis
134
+ ([Wire data](https://usewire.io/blog/long-context-vs-rag-what-the-data-shows/),
135
+ [2501.01880](https://arxiv.org/html/2501.01880v1),
136
+ [production decision framework](https://www.sabaoon.dev/blog/rag-vs-long-context-production-2026)).
137
+ Our planned doc-as-context lane (deepseek-v4 1.31M ctx) is exactly the right
138
+ complement — worth building for "explain clause 4.2 of THIS edition" queries.
139
+
140
+ ---
141
+
142
+ ## 6. Structured knowledge: graphs, tables, equations
143
+
144
+ - **GraphRAG** matured through 2025 into production
145
+ ([Microsoft GraphRAG](https://microsoft.github.io/graphrag/),
146
+ [KG2RAG, NAACL 2025](https://aclanthology.org/2025.naacl-long.449/),
147
+ [GraphRAG survey 2501.13958](https://arxiv.org/pdf/2501.13958),
148
+ [ACM CSUR survey](https://dl.acm.org/doi/10.1145/3777378)). Wins where
149
+ queries traverse relationships ("which standards reference R 60?").
150
+ **Our advantage: the graph data already exists** — vocab repo (6,031
151
+ Glossarist concepts) + relaton (5,707 citation relations) need no LLM
152
+ entity extraction, only projection + fusion.
153
+ - **Table RAG:** preserve 2D structure instead of flattening
154
+ ([TableRAG 2506.10380](https://arxiv.org/html/2506.10380v1),
155
+ [TabRAG 2511.06582](https://www.alphaxiv.org/abs/2511.06582)). Our parse.py
156
+ linearizes caption+rows; MPE tables and accuracy-class tables are exactly
157
+ the normative content users query. Structured table chunks (JSON
158
+ serialization + table-aware retrieval) are a differentiated win for a
159
+ standards corpus.
160
+ - Equations (`stem:[...]` AsciiMath): same principle — first-class retrievable
161
+ objects, currently chunk-embedded as text.
162
+
163
+ ---
164
+
165
+ ## 7. Answer formulation, attribution, verification
166
+
167
+ - **Span-level attribution** is the 2025–26 bar: every claim carries a
168
+ citation to a quoted span, verifiable against the retrieval log
169
+ ([survey: 134 papers / 300 metrics](https://www.semanticscholar.org/paper/8a921bf4a04336dfd78ec57765faa0477f51f07b),
170
+ [fine-grained grounded citations](https://openreview.net/forum?id=7atXKldh-r),
171
+ [LAQuer, ACL 2025](https://aclanthology.org/2025.acl-long.746/),
172
+ [G-Cite vs P-Cite 2509.21557](https://arxiv.org/html/2509.21557v2),
173
+ [FutureAGI 2026 attribution audit rules](https://futureagi.com/blog/evaluating-llm-citation-attribution-2026/)).
174
+ Our citations are passage-level with clause anchors — good, not span-level.
175
+ For a *normative* corpus, per-claim quote anchors ("MPE = 0.5e …" [3]) are
176
+ the trust feature.
177
+ - **Generation-time citation** (marker emitted with the sentence) beats
178
+ post-hoc citation on attribution accuracy — our prompt already does
179
+ inline [labels]; tightening to quote-span style is a prompt+eval change.
180
+
181
+ ---
182
+
183
+ ## 8. Evaluation
184
+
185
+ - **RAGAS metric suite** is the canonical battery: faithfulness, answer
186
+ relevancy, context precision, context recall
187
+ ([RAGAS docs](https://docs.ragas.io/en/stable/concepts/metrics/available_metrics/),
188
+ [2309.15217](https://arxiv.org/html/2309.15217v1),
189
+ [2026 guide](https://qaskills.sh/blog/ragas-rag-evaluation-metrics-complete-guide)).
190
+ We have faithfulness (judge) + hit@5 (≈ context recall). Missing: answer
191
+ relevancy and context precision — both computable with our existing judge
192
+ infrastructure.
193
+ - **Out-of-scope/unanswerable calibration:** ELOQ, UAEval4RAG (from our
194
+ earlier research) remain the reference for refusal behavior.
195
+ - **Production monitoring:** drift dashboards, feedback loops
196
+ ([DeepEval/Ragas comparison](https://medium.com/@sjha979/ragas-vs-deepeval-measuring-faithfulness-and-response-relevancy-in-rag-evaluation-2b3a9984bc77)) — we have D1 telemetry + spend ledger; no derived dashboards yet.
197
+
198
+ ---
199
+
200
+ ## 9. Memory & personalization
201
+
202
+ Session memory (we have via history+compaction) → **persistent memory**
203
+ (user facts across sessions, Mem0-style
204
+ ([Mem0](https://mem0.ai/blog/ai-chatbot-development-with-persistent-memory),
205
+ [Supermemory architecture guide](https://supermemory.ai/blog/how-to-make-ai-remember-user-preferences-across-conversations/),
206
+ [arXiv 2510.07925](https://arxiv.org/html/2510.07925v1)) → **user profiles**.
207
+ For a standards body: member-tier memory of "works with weighing instruments,
208
+ prefers French, follows R 76 revisions" is a legit differentiator with a
209
+ privacy surface to design deliberately (user-visible, deletable).
210
+
211
+ ---
212
+
213
+ ## 10. Agent ecosystem: MCP
214
+
215
+ MCP became the de-facto standard for agent↔knowledge access in 2026
216
+ ([official docs](https://modelcontextprotocol.io/docs/2026-07-28/getting-started/intro),
217
+ [IBM](https://www.ibm.com/think/topics/model-context-protocol),
218
+ [Red Hat developers](https://developers.redhat.com/articles/2026/01/08/building-effective-agents-mcp)).
219
+ Exposing our retrieval as an MCP server (one per audience, as our
220
+ architecture already plans) turns every MCP client (Claude, IDEs, member
221
+ tooling) into a consumer of OIML-grounded answers — the standards-arena
222
+ equivalent of being citable by the agent ecosystem.
223
+
224
+ ---
225
+
226
+ ## 11. What we already match (honest scoreboard)
227
+
228
+ | SOTA element | Us |
229
+ |---|---|
230
+ | Contextual embeddings + reranking | ✅ running (2/3 of the Anthropic recipe) |
231
+ | Contextual BM25 | 🟡 free once enrichment lands (verify) |
232
+ | LLM query understanding (routing/filters/HyDE/decomposition) | ✅ |
233
+ | Multi-query fusion + RRF hybrid | ✅ (lexical recall in-worker, Vectorize has no sparse) |
234
+ | CRAG + Self-RAG correction | ✅ single-shot |
235
+ | Prompt-as-data, context budget + compaction | ✅ (beyond most public systems) |
236
+ | Faithfulness judging + golden/e2e/retrieval evals | ✅ partial metric set |
237
+ | Graph lane, table-aware RAG | ❌ |
238
+ | Agentic loop / deep-research mode | ❌ (planned via Workflows) |
239
+ | LLM listwise rerank tier | ❌ |
240
+ | Span-level quote attribution | ❌ (passage-level) |
241
+ | Memory / personalization | ❌ (session only) |
242
+ | MCP servers | ❌ (planned) |
243
+ | Sample-and-verify answer selection | ❌ |
@@ -0,0 +1,130 @@
1
+ # Roadmap to SOTA — OIML SMART AI
2
+
3
+ *Gap analysis and phased plan derived from `RESEARCH-SOTA-2026.md`
4
+ (2026-08-26). Constraints honored: Cloudflare-only, minimal accounts,
5
+ Workers AI open-weight models, cost-first serving lane / quality-first
6
+ one-time lane, public+internal corpus isolation.*
7
+
8
+ ---
9
+
10
+ ## Where we stand
11
+
12
+ Serving is a 12-layer modular-RAG pipeline with LLM query understanding
13
+ (intent routing, filters, HyDE, decomposition), multi-query fusion, hybrid
14
+ reranking, CRAG grading, self-RAG reflection, prompts-as-data, context
15
+ budgeting with history compaction, canonical refusal contracts, and an eval
16
+ stack (golden, live e2e, retrieval hit@5 + paraphrase probes, faithfulness
17
+ judge). Contextual enrichment (31k chunks, deepseek-v4-pro) is completing
18
+ in-flight. That places us solidly in 2025-SOTA territory. The gaps below
19
+ are what separates us from 2026 frontier systems.
20
+
21
+ ## Gap register
22
+
23
+ | # | Layer | Gap | SOTA reference | Impact | Cost |
24
+ |---|---|---|---|---|---|
25
+ | G1 | Data prep | Tables/equations flattened into text chunks | TableRAG / TabRAG | normative-value queries (our core use case) | med |
26
+ | G2 | Data prep | No re-OCR of worst dirty docs | GLM-OCR protocol exists | recall on OCR-noisy docs | med |
27
+ | G3 | Vector ops | No sparse/lexical index (Vectorize limit); keyword layer scores only retrieved candidates | hybrid sparse+dense | exact-term recall | low (in-worker) |
28
+ | G4 | Vector ops | Single embedding model, no MRL/quantization knobs | Matryoshka + quantization | latency at scale | n/a on Vectorize; revisit |
29
+ | G5 | Chat processing | No cross-turn entity memory (only summary compaction) | entity graphs (CAsT) | follow-up accuracy | low |
30
+ | G6 | Chat processing | No semantic cache (exact-text KV only) | embedding-similarity cache | latency/cost on near-dupes | low |
31
+ | G7 | Chat UX | No generated follow-up suggestions; clarifying question allowed but rare | mixed-initiative | engagement | low |
32
+ | G8 | Retrieval | No graph lane (vocab 6,031 concepts + relaton 5,707 relations unused) | GraphRAG / KG2RAG | relationship queries ("what references R 60?") | med-high |
33
+ | G9 | Retrieval | No LLM-listwise rerank tier over top-12 | cascade reranking | precision on hard queries | low |
34
+ | G10 | Retrieval | No agentic loop / deep-research mode | Agentic RAG, Plan*RAG | multi-hop research questions | high |
35
+ | G11 | Answers | Passage-level citations, not span/quote-level | fine-grained attribution | verifiability (normative corpus!) | low |
36
+ | G12 | Answers | Single-pass generation (no sample-and-verify) | test-time compute | answer quality on hard queries | low-med |
37
+ | G13 | Eval | Missing answer-relevancy + context-precision metrics; no derived dashboards | RAGAS suite | regression visibility | low |
38
+ | G14 | Memory | Session-only; no persistent member memory | Mem0-style | personalization | med |
39
+ | G15 | Ecosystem | No MCP servers (planned in architecture) | MCP standard | agent-ecosystem reach | med |
40
+ | G16 | Long-context lane | Doc-as-context mode unbuilt | LC+RAG complementarity | "explain THIS edition" queries | med |
41
+ | G17 | Ops | No Turnstile on anon ask | bot economics | abuse resistance | low |
42
+
43
+ ## Phased roadmap
44
+
45
+ ### Phase 0 — in flight (complete before measuring anything else)
46
+ 1. **Finish contextual enrichment** (running; ~$50 total) → catch-up pass for
47
+ rate-limit stragglers → bump `INDEX_VERSION` → re-run e2e + retrieval
48
+ eval. **Success metric: paraphrase-probe hit@5 ≥ baseline 19/21, target
49
+ 21/21**, and golden e2e 13/13 (G3's contextual-BM25 effect lands here —
50
+ keyword layer now scores enriched text).
51
+
52
+ ### Phase 1 — cheap, high-leverage (days; all low cost)
53
+ 2. **Complete the RAGAS metric set (G13):** add answer-relevancy and
54
+ context-precision scorers next to the existing faithfulness judge
55
+ (same judge model, prompts as data); wire into a nightly eval snapshot
56
+ in `artifacts/eval/`. *Metric: full metric battery on every deploy.*
57
+ 3. **Span-level quote anchors (G11):** system prompt requires quoting the
58
+ exact normative phrase before paraphrasing it, cited inline
59
+ (`"MPE shall not exceed 0.5e" [3]`); eval asserts quotes exist on
60
+ table-value goldens. *Metric: quote-presence on value questions = 100%.*
61
+ 4. **Listwise rerank tier (G9):** for member/hard queries only, after
62
+ bge-reranking, one glm-4.7-flash listwise call reorders the top 12
63
+ (prompt as data; ~$0.0002/query). *Metric: hit@1 on paraphrase probes.*
64
+ 5. **Semantic answer cache (G6):** KV store of (embedding-quantized query →
65
+ answer) with similarity threshold; checked before understanding runs.
66
+ *Metric: p50 latency on repeat/near-dup queries.*
67
+ 6. **Follow-up suggestions (G7):** understanding output gains
68
+ `follow_ups[2]` — rendered as tappable chips after each answer
69
+ (API-driven, config-free). *Metric: follow-up CTR in telemetry.*
70
+ 7. **Turnstile on anon ask (G17).**
71
+
72
+ ### Phase 2 — structural upgrades (1–3 weeks each; medium cost)
73
+ 8. **Graph lane (G8):** project relaton citation edges + vocab concept
74
+ relations into D1 (nodes/edges tables); at query time, understanding
75
+ emits named entities → graph expansion feeds candidate doc_numbers into
76
+ the existing filter/fusion path (no new index; fusion in-worker).
77
+ Public projection only from OIML data. *Metric: relationship-query
78
+ golden cases (new probe set).*
79
+ 9. **Agentic deep-research mode (G10):** Cloudflare Workflows (durable,
80
+ already in the architecture doc) — bounded loop: retrieve → read →
81
+ sufficiency judge → re-retrieve (≤3 iterations, spend-capped), glm-5.2
82
+ with prompt caching; surfaced as a "Research this" action for members.
83
+ *Metric: multi-hop golden cases; cost/query ceiling.*
84
+ 10. **Table-aware chunks (G1):** re-parse MPE/accuracy-class tables into
85
+ structured chunk objects (header map + row tuples, JSON-serialized for
86
+ embedding, original rendered for display); retrieval treats them as a
87
+ distinct chunk type with table-aware boosting. *Metric: table-value
88
+ golden accuracy, esp. row-precise answers.*
89
+ 11. **MCP servers (G15):** one per audience (public OIML / internal
90
+ OIML+ISO), exposing search+ask as MCP tools with the same auth tiers.
91
+ *Metric: external MCP client can query grounded answers.*
92
+ 12. **Cross-turn entity memory (G5):** conversation table gains an entity
93
+ map (doc ids, terms, editions mentioned); understanding consumes it so
94
+ "it / that standard / the 2017 one" resolve without full re-derivation.
95
+ *Metric: MTRAG-style follow-up probes.*
96
+
97
+ ### Phase 3 — frontier (selective; quality-gated)
98
+ 13. **Sample-and-verify answers (G12):** hard-query lane generates 2
99
+ candidates; faithfulness+relevancy judges select. Eval-gated rollout.
100
+ 14. **Doc-as-context lane (G16):** deepseek-v4 1.31M ctx for
101
+ edition-scoped questions; chunk retrieval nominates the document,
102
+ full doc goes to context. Members-first, budget-capped.
103
+ 15. **Persistent member memory (G14):** explicit, user-visible, deletable
104
+ (privacy by design); informs terminology and preferred editions only.
105
+ 16. **Re-OCR the worst 5% dirty docs (G2)** via the GLM-OCR cache-first
106
+ protocol; re-ingest those slates only.
107
+ 17. **Multilingual index decision:** currently English-only by directive;
108
+ revisit when multilingual usage telemetry justifies FR/AR/SR lanes
109
+ (embedding model already supports 100+ languages).
110
+
111
+ ## Sequencing rationale
112
+
113
+ Phase 1 items are all prompt/worker-level and independently shippable;
114
+ each carries its own metric so regressions are attributable. Phase 2 items
115
+ change index shape or add subsystems — each lands with its own eval probes
116
+ first. Phase 3 is quality-gated: nothing ships without a measured win on
117
+ the golden + probe suites. Everything remains inside the two-lane cost
118
+ model (serving = cheap models; one-time/rare = best model).
119
+
120
+ ## Definition of "SOTA standards chatbot" (2026 bar)
121
+
122
+ 1. Every answer **quote-anchored and clause-linked** (G11 ✓ after Phase 1)
123
+ 2. **Relationship and multi-hop questions** answered via graph + agentic
124
+ loops (G8, G10 — Phase 2)
125
+ 3. **Normative tables answered row-precisely** (G1 — Phase 2)
126
+ 4. **Full RAGAS battery green** with drift dashboards (G13 — Phase 1)
127
+ 5. **Follow-ups that feel human** — entity memory + suggested next steps
128
+ (G5, G7)
129
+ 6. **Agent-native** — OIML knowledge reachable via MCP (G15)
130
+ 7. **Eval-gated everything** — no change ships without the probe suites