---
path: /studio/yemaya/ai-safety
surface: studio
domain: yemaya
auth: signed-in + studio entitlement
source: apps/oshun/web/src/app/studio/yemaya/ai-safety/page.tsx
status: walked
last_walked:
  '2026-05-29 automated runtime walk (Playwright headless) — render, /v1 data
  (2xx), console/page-errors, expected content, screenshot verified; live
  screen-reader, touch, offline, and telemetry-delivery checks pending a manual
  AT pass. Evidence: WALKTHROUGH/results/runtime-sweep-2026-05-29.md; body
  re-derived 2026-06-03 from current source (lane-console architecture)'
---

# Studio · Yemaya · AI Safety

## Purpose

Admin lane console that runs the shipped `@yemaya/safety` rule-based content
classifier over a prompt or generated output — prompt-injection detection,
keyword rules and the keyword registry across all 19 safety categories. The
operations lane is wired to the live classifier over
`/v1/admin/yemaya/ai-safety`; access is admin-scoped and fail-closed. Four
capability cards summarise the surface above the lane.

## Entry points

- Breadcrumb chain on this page: **Studio › Yemaya Community Features › AI
  Safety**.
- Reachable from sibling Yemaya routes that quick-action here.
- Direct URL / bookmark (signed-in + studio entitlement).

## Layout regions

`page.tsx` renders `ShellLayout active="studio"` and:

- **Breadcrumbs panel** (`data-yemaya-ai-safety-breadcrumbs`): Studio › Yemaya
  Community Features › AI Safety.
- **Workspace panel** (`StudioYemayaAiSafetyWorkspace`,
  `data-yemaya-ai-safety-workspace`):
  - `<h1>` (`WorkspaceHeading`) **"Yemaya AI Safety Workspace"**.
  - Summary paragraph (`data-yemaya-ai-safety-summary`).
  - **Capability Summary** (`data-yemaya-ai-safety-capability-summary`, `<h2>`):
    four informational cards — Safety Control Plane, Risk Diagnostics and
    Observability, Security and Compliance Enforcement, Parity and Contract
    Validation.
  - **AI Safety Operations Lane** (`data-yemaya-ais-lane-heading`, `<h2>`): the
    catalog-loaded scan form (`data-yemaya-ais-form`).
- **Route Map panel** (`data-yemaya-ai-safety-route-map`): `<h2>` "Route Map" +
  six entries from `STUDIO_YEMAYA_AI_SAFETY_ROUTE_MAP`.
- **Quick-action panel**: three `quickAction` links.

## States

- [ ] **Loading** — `data-yemaya-ais-loading` "Loading safety engine…" until the
      GET catalog resolves.
- [ ] **Unauthorized** — `data-yemaya-ais-unauthorized` "Access restricted." on a
      401/403 (Yemaya workspace scope required to run the classifier).
- [ ] **Error** — `data-yemaya-ais-error` "Could not load the safety engine." on
      a non-OK / malformed catalog response.
- [ ] **Ready (form)** — engine summary (`data-yemaya-ais-engine-summary`,
      "(N categories)") + the scan form render once the catalog loads.
- [ ] **Result** — `data-yemaya-ais-result` with a flagged/clean headline
      (`data-yemaya-ais-headline`) and the flagged-category rows
      (`data-yemaya-ais-flagged-row`); submit-side validation surfaces in
      `data-yemaya-ais-scan-error`.

## Interactions

### AI Safety Operations Lane

- [ ] **"Prompt or generated output to scan"** — `<textarea
      data-yemaya-ais-content>` (aria-label "content to scan"), prefilled with a
      prompt-injection sample.
- [ ] **"Scan for safety risks"** — `<button data-yemaya-ais-submit>`; submitting
      POSTs `{ content }` to `/v1/admin/yemaya/ai-safety/scan` and renders the
      flagged-category breakdown (severity, confidence, matched rule) or "No
      safety risks detected.".

### Capability cards

`data-yemaya-ai-safety-capability` — four informational `<article>` cards
(Safety Control Plane, Risk Diagnostics and Observability, Security and
Compliance Enforcement, Parity and Contract Validation); not interactive.

### Route map

`data-yemaya-ai-safety-route-map` — six non-interactive entries:

- [ ] `/studio/yemaya/ai-safety` — primary workspace
- [ ] `/studio/yemaya/ai-safety/scenes/[sceneId]`
- [ ] `/studio/yemaya/ai-safety/exports/[exportId]`
- [ ] `/studio/yemaya/ai-safety/revisions/[revisionId]`
- [ ] `/studio/yemaya/ai-safety/parity/[parityId]`
- [ ] `/studio/yemaya/ai-safety/governance/[policyId]`

### Quick actions

- [ ] **"Open Yemaya Community Features workspace"** →
      `/studio/yemaya/community-features`.
- [ ] **"Open Yemaya Enterprise Analytics workspace"** →
      `/studio/yemaya/enterprise-analytics`.
- [ ] **"Back to Studio workspace index"** → `/studio`.

## Data & contracts

- **Reads**: `GET /v1/admin/yemaya/ai-safety` (catalog: summary + category list)
  on mount.
- **Writes**: `POST /v1/admin/yemaya/ai-safety/scan` (content → scan result).
- **Realtime**: none.
- **Caching**: client `fetch` on mount with `cache: 'no-store'`;
  `buildBffAuthHeaders()`.
- **Auth/role check**: admin-scoped, fail-closed (401/403 → unauthorized state);
  signed-in + studio entitlement enforced by the proxy/middleware.

## Cross-references

- Studio overview: [`studio-overview.md`](../../studio-overview.md)
- Workspace source:
  `apps/oshun/web/src/components/studio/StudioYemayaAiSafetyWorkspace.tsx`
- Route map source:
  `apps/oshun/web/src/components/studio/StudioYemayaAiSafetyRouteMap.ts`
- Feature spec: [`V1/features.md`](../../../../V1/features.md)

## Open questions / known gaps

- [ ] The route-map dynamic children (scenes / exports / revisions / parity /
      governance) are sitemap-only — confirm whether any are backed by `page.tsx`
      files yet.
- [ ] The breadcrumb parent is Community Features while the quick-actions point at
      Community Features + Enterprise Analytics — verify this is the intended
      navigational placement for a safety console.
