Whole-System Overview

Closed-loop platform · Inputs → Core → Data → Outputs → (feedback) → Corpus → next prompt · R89 decision-corpus-as-few-shot

01 / User Inputs 02 / Platform Core 03 / Data Layer 04 / Outputs Chat chat.ai-globalfoodsolutions.co Email intake bids@ · 5 mailboxes Admin dashboard review_queue + tools NetSuite direct TBA + MCP (R83) CF Worker src/index.ts · ~18.5K lines Tiered crons Hot 5m · Warm 15m · Cold 60m 4 model families Claude · Llama · Cohere · Codex HITL + Constitutional review_queue · R87 screen D1 mirror 144 tables · 500K+ rows R2 raw + analytics email · parquet · system-context KV + Vectorize cache · 8 namespaces pricing_master derived · every 15m Streaming chat SSE + citations Push to NS NS_PUSH_QUEUE · HITL gate Email outbound quote · approval · ack 17 Pages HTML + /api/health/super · flows-diagrams Legend User UI Agent logic Policy Tool action Context / trace

What makes it perfect

  • • council_v2: 3 models + chairman + anonymized peer review
  • • Multi-source validation (D1 + Vectorize + cite-backed)
  • • Reflexion: agent self-critiques before responding
  • • Constitutional review screens every chat turn
  • • Decision corpus loop (R89): chat gets smarter over time
  • • Role-gated tools (R85): 10 chat roles · least-privilege
  • • Citations on every numeric answer · trace to D1/R2
  • • Eval-gated deploys: verify-round.sh blocks bad tags
  • • 11/11 Karpathy patterns adopted · pattern #12 enforced

Closed feedback loop (R89)

  • • Chat answer + tool calls → decision_corpus row
  • • Few-shot sampler picks N similar past decisions
  • • Injected into next prompt as proven exemplars
  • • Reinforces good patterns · attenuates bad ones
  • • No retraining needed · self-reinforcing inference

Mike-side open actions

  • • R83: NS-side MCP standard tools install (pending)
  • • R82: autoresearch trigger refinement
  • • R75-G: 9 remaining health probes to ship
  • • R49: drop 36 empty tables + 17 dead intents

Hard invariants

  • • All write endpoints require ?preview/confirm + X-Edit-Token
  • • D1 = canonical store · NS = system of record
  • • Cloudflare-only stack · no AWS / GCP
  • • Every AI-proposed action lands in review_queue first