PRISM (Second-Brain)

wiki/decisions/2026-06-28-unified-chat-on-prism-hub.md

ADR: Unified grounded chat, Hermes one-brain on the published reports hub + Telegram

Date: 2026-06-28 Status: Accepted (LIVE, proven)

Context

PRISM needed the same conversational agent in two places: Telegram (already live as grounded report-QA) and the published audit-report SPA so prospects/AEs can "chat with this audit." The SPA in question is the published reports hub (algolia-arian-v2.vercel.app, now GH repo prism-hub), static per-company report pages from render-audit.ts, NOT the internal PIP/frontend aRRIe app (that was a wrong-target assumption early in the session).

Decision

One Hermes brain serves both channels. The hub embeds a vanilla chat widget (chat-widget.js) on each report page; a Vercel Node serverless proxy (api/chat.js) streams from the Hermes API (/v1/responses) with the bearer kept server-side. Each page binds its own company's report via an invisible [Account: <slug>] tag (the prism-report-qa plugin binds by message content per session). Grounding = the same transform_llm_output Gemini gate as Telegram.

Rationale

  • Same brain + same grounding gate across channels = consistency, no divergence.
  • Server-side proxy → bearer never in the browser, no CORS surface.
  • Report-QA needs NO tool registration (closed-book over the injected report), sidesteps the tool-name-contract risk; tools are a v2 for interactive module-running.
  • Node serverless (not Edge): this Vercel project deploys /api as a Node λ and ignores the edge runtime config, an Edge handler returning a Web Response hangs (HTTP 000). Handler must be (req,res) + res.end().

Alternatives Considered

Option Why rejected
Embed into PIP/frontend (internal aRRIe app) Wrong surface, the destination is the published reports hub.
Browser-direct calls to the Hermes API Leaks the bearer + needs CORS.
Edge function proxy This project won't honor edge runtime → hangs.
Register 25 FastAPI tools first Not needed for report-QA; defer to v2.
Deterministic session-key→report bind (plugin patch) Hermes doesn't thread X-Hermes-Session-Key into the hook; patch deployed but no-ops. Use the [Account:] message tag.

Consequences

  • Live + proven: PetSmart page returned "no-results rate is 15.98% [FACT]" through the deployed proxy.
  • Infra now live on the VPS: prism_platform FastAPI (R1, systemd) + Hermes API public at judge.contentengagement.info/hermes-api (bearer+TLS).
  • New env on the Vercel prism project: HERMES_API_URL, HERMES_API_KEY.
  • Open: rotate the free-tier grounding-gate Gemini key (intermittent 429); rename the Vercel project → prism-hub + domain (keep algolia-arian-v2 alias); the 7 dataless report pages have the widget removed until re-audited.
  • Reports must be in /root/.hermes-prism/reports/ to ground (10 of 17 loaded).