The model does not write markup or product facts. It selects from five typed rendering tools; React owns rendering, and the catalog owns product identity, price, and availability.
Controlled composition, not generated code
Missing key or model failure takes the deterministic preset path. The same grounded tools are also exposed through a stateless MCP endpoint.
The model-callable vocabulary contains hero, product grid, guide, gift collection, and comparison tools. Each tool has a bounded Zod schema. Product-bearing calls filter IDs through the 40-item catalog before the block reaches the browser. The renderer switches over a finite TypeScript union, so model output never becomes HTML or JSX.
Streaming, completeness, and fallback
/api/gen-page uses required tool calling and streams each valid block as NDJSON. The browser can render progressively rather than wait for one monolithic response. Request input is truncated to 800 characters and model output is capped at 1,200 tokens.
Without an API key, the route streams one of eight hand-authored, catalog-grounded presets. A model or stream exception produces the same deterministic fallback. The explicit persona path also checks that the final page has a hero and product content, plus mode-specific guide or comparison blocks.
The current live-cluster reliability boundary is explicit: it accepts any non-empty set of individually valid blocks. If generation fails after activation, the cluster is suppressed until reload and the UI can remain on a skeleton. Durable background recovery is a production-hardening priority.
Intent drift stays deterministic
The model does not decide when the shopper’s intent changed. Search and browse signals are scored against repair, gift, outdoor, project, and starter clusters using rule-based keyword and tag matching.
- Score 0.3 starts background generation.
- Score 0.6 plus a 0.1 lead activates the cluster.
- A 60-second lock raises the competing threshold to 0.8.
- Signals and generated pages persist in
sessionStoragefor the browser session.
Appliance is implemented as a persona and generation mode, but not as a live drift cluster. That distinction prevents the portfolio from claiming a broader detector than the code implements.
MCP reuse and its security boundary
/api/mcp exposes the catalog resource, a composition prompt, and the same five render tools over stateless HTTP. Product tools reject calls that do not retain enough catalog IDs after grounding.
The endpoint has no authentication, tenant authorization, rate limiting, or tool-use policy. “MCP-enabled” therefore describes implemented interoperability—not a production-secured agent gateway.
Deterministic evaluation
No model key was available for the evaluation, so it measured the code around the model rather than inventing tool-selection metrics.
| Check | Result |
|---|---|
| Valid and invalid tool cases | 10/10 expected outcomes |
| Invalid IDs after grounding | 0 |
| No-key fallback executions | 200/200 successful |
| Fallback presets covered | 8 |
| Invalid fallback product references | 0 |
| In-process fallback latency | p50 0.041 ms; p95 0.113 ms |
Fallback latency is direct Node route execution. It excludes network time, browser rendering, cold starts, and provider latency.
The evaluator found a concrete gap: catalog grounding removes unknown IDs but does not deduplicate valid ones. A comparison containing the same real product twice currently satisfies the two-product minimum.
Reliability, security, and economics
| Area | Implemented | Next control or measurement |
|---|---|---|
| Generated fields | Per-tool Zod rejection | Server-enforced page order and uniqueness |
| Product grounding | Unknown IDs removed | Distinct-product invariant |
| Model outage | Deterministic preset | Background recovery after activation |
| Caching | Browser-session cache | Shared cache, expiry, invalidation |
| Security | Typed inputs and length limits | Auth, rate and spend limits, audit log |
| Observability | Development intent log | Request traces, tokens, provider latency, cost |
The evidence-branch dependency audit currently reports 20 findings—4 low, 5 moderate, 9 high, and 2 critical—including a warning against the pinned Next.js 14.2.5 release. The build succeeds, but the dependency set must be upgraded and re-audited before deployment.
The no-key path bypasses model calls, and session caches avoid repeat generation. Those mechanisms reduce calls, but token usage is not recorded. A cost-per-success number would therefore be invented and is intentionally absent.
What the implementation demonstrates
The credible claim is bounded generative composition: typed tools, catalog grounding, finite rendering, deterministic intent drift, streaming, caching, MCP reuse, and explicit fallbacks.
Production hardening priorities are product deduplication, a server-side page contract, completeness checks for background generation, live-model evaluation, token and latency instrumentation, and protection for public model and MCP endpoints.
