diff --git a/internal/api/httpapi/security_test.go b/internal/api/httpapi/security_test.go index 238edbb..03509d2 100644 --- a/internal/api/httpapi/security_test.go +++ b/internal/api/httpapi/security_test.go @@ -89,10 +89,16 @@ func TestGetPlayerHidesCrossTenant(t *testing.T) { t.Fatalf("do: %v", err) } defer func() { _ = resp.Body.Close() }() + b, _ := io.ReadAll(resp.Body) if resp.StatusCode != http.StatusNotFound { - b, _ := io.ReadAll(resp.Body) t.Fatalf("status=%d want 404 body=%s", resp.StatusCode, b) } + if json.Valid(b) { + t.Fatalf("cross-tenant body is JSON: %s", b) + } + if bytes.Contains(b, []byte("vip")) || bytes.Contains(b, []byte("balance")) || bytes.Contains(b, []byte("acme-casino")) { + t.Fatalf("cross-tenant body leaked snapshot: %s", b) + } } func newSecurityTestServer(t *testing.T) (*store.Store, *httptest.Server) { diff --git a/web/README.md b/web/README.md index d74b28e..58a84b4 100644 --- a/web/README.md +++ b/web/README.md @@ -8,7 +8,7 @@ Next.js App Router console for the Go service. HMAC is signed in the BFF. The br | --- | --- | | `/` | Arena. Dual-tenant stage (`acme-casino` VIP vs `nova-sports` velocity). Ignite runs HMAC, outbox, Kafka, worker tx, then GET player. | | `/architecture` | Live counters and the event path. Select a node. Dead letters: last N from Kafka; Redrive is a human-clicked signed ingest of the same event_id. | -| `/contract` | `make replay` snapshot contract. Tools tab: `ingest` / `get_player` / `get_metrics`. Not tools: `credit` / `set_vip`. Shadow tab: mock vs velocity disagreements. | +| `/contract` | Run contract: duplicate credit-once, `credit`/`set_vip` 404, Nova cannot read an Acme player, shadow no-write, poison→DLQ when inject is on. Replay / tools / shadow tabs. | Tab URLs: `/contract?tab=tools`, `/contract?tab=shadow`. diff --git a/web/app/api/contract/route.ts b/web/app/api/contract/route.ts index e871d44..2b40ac5 100644 --- a/web/app/api/contract/route.ts +++ b/web/app/api/contract/route.ts @@ -1,10 +1,12 @@ import { NextResponse } from "next/server"; import { fetchPlayer, + getPlayerRaw, ingestEvent, parseMetrics, postTool, } from "@/lib/engagepulse"; +import { getTenants } from "@/lib/tenants"; import { scoreShadowBoard } from "@/lib/shadow-score"; export const dynamic = "force-dynamic"; @@ -130,6 +132,23 @@ export async function POST() { }; } + const isolationPlayerId = `probe-iso-${suffix}`; + await ingestEvent("acme-casino", { + event_id: `probe-iso-${suffix}`, + player_id: isolationPlayerId, + type: "deposit", + amount: 50, + occurred_at: new Date().toISOString(), + }); + const nova = getTenants()["nova-sports"]; + const cross = await getPlayerRaw(nova.apiKey, isolationPlayerId); + const lower = cross.body.toLowerCase(); + const isolationPass = + cross.status === 404 && + !lower.includes("vip") && + !lower.includes("balance") && + !lower.includes("acme-casino"); + return NextResponse.json({ llm: "The LLM is not on the credit path.", hmac: "HMAC is signed in the BFF and verified in Go.", @@ -155,6 +174,12 @@ export async function POST() { pass: shadowPass, }, dlq: dlqProbe, + isolation: { + player_id: isolationPlayerId, + status: cross.status, + body_empty: cross.body.trim() === "player not found", + pass: isolationPass, + }, }); } catch (err) { const message = err instanceof Error ? err.message : "contract probe failed"; diff --git a/web/components/contract-run.tsx b/web/components/contract-run.tsx index 21d26a7..9723bff 100644 --- a/web/components/contract-run.tsx +++ b/web/components/contract-run.tsx @@ -41,6 +41,12 @@ type Probe = { balance: number | null; pass: boolean; }; + isolation: { + player_id: string; + status: number; + body_empty: boolean; + pass: boolean; + }; error?: string; }; @@ -72,7 +78,8 @@ export function ContractRun() { Run contract

Duplicate event_id, 404 on credit/set_vip, sparse-bets vs velocity, - and poison retry to DLQ when inject is on. + Nova cannot read an Acme player, and poison retry to DLQ when inject + is on.