---
path: /studio/hathor/scenario-generation
surface: studio
domain: hathor
auth: signed-in + studio entitlement
source: apps/oshun/web/src/app/studio/hathor/scenario-generation/page.tsx
status: walked
last_walked:
  '2026-07-04 focused real-dev-infra Playwright — anonymous redirect,
  Hathor-admin catalog load, bearer propagation, live BFF validation,
  fail-closed states, mobile controls, scoped axe, and direct BFF contract
  gates. Evidence: WALKTHROUGH/results/v1-real-infra-run-2026-06-22.md §281;
  spec: apps/oshun/web/e2e/studio-hathor-scenario-generation.spec.ts'
---

# Studio Hathor · Scenario Generation

## Purpose

Admin lane console for the `@hathor/quests` scene-dependency packet validator.
The validate lane submits a generated scenario's scene / quest / story-arc
dependency packet and checks its referential integrity — every required
scene/quest/arc resolves, scene cross-references and dependencies resolve,
scenes carry capture evidence, and the CGI export metadata is present. Blocking
issues fail the packet; capture gaps are warnings. Admin-scoped and fail-closed.

## Entry points

- **Direct URL / bookmark** — `/studio/hathor/scenario-generation`;
  `alternates.canonical` is set.
- **Quick-action from siblings** — this page links to the Culture Evolution
  Simulation lane.
- **Studio overview** — see
  [`../../studio-overview.md`](../../studio-overview.md).

## Layout regions

`page.tsx` renders inside `<ShellLayout active="studio">`:

- **Workspace** (`StudioHathorScenarioGenerationWorkspace`,
  `data-hathor-scenario-generation-workspace`):
  - `<h1>` `WorkspaceHeading` — "Hathor Scenario Generation Workspace"
  - Summary `<p data-hathor-scenario-generation-summary>`
  - Strict issue-type / severity catalog (`data-hathor-scg-catalog`,
    `data-hathor-scg-catalog-issue-type[data-issue-type]`,
    `data-hathor-scg-catalog-severity[data-severity]`), then the packet form +
    result.
- **Route Map panel** (`<section data-hathor-scenario-generation-route-map>`,
  `<h2>Route Map</h2>`): 5 entries from
  `STUDIO_HATHOR_SCENARIO_GENERATION_ROUTE_MAP` (path + purpose) with
  `data-hathor-scg-route-count` and
  `data-hathor-scg-route-map-entry[data-route-path]`.
- **Quick-action lane** (`data-hathor-scg-quick-actions`): Culture Evolution
  Simulation (`data-hathor-scg-quick-action="culture-evolution-simulation"`),
  Back to Studio workspace index
  (`data-hathor-scg-quick-action="studio-index"`).

## States

- [x] **Loading** — `<p data-hathor-scg-loading role="status">` "Loading
      scenario validator…".
- [x] **Unauthorized** — `data-hathor-scg-unauthorized` on 401/403 (admin-scope,
      `role="alert"`).
- [x] **Error** — `data-hathor-scg-error` on a non-OK catalog response or
      network failure.
- [x] **Ready (form)** — `data-hathor-scg-validate-form` with the packet
      textarea and `data-hathor-scg-form-state="idle"`.
- [x] **Pending validation** — `data-hathor-scg-validate-form` carries
      `data-hathor-scg-form-state="pending"` / `aria-busy="true"` while the
      submit button is disabled.
- [x] **Result** — `data-hathor-scg-result` with `data-hathor-scg-valid`
      verdict, `data-hathor-scg-counts` (scenes / quests / blocking / warnings),
      and `data-hathor-scg-issues` rows (or `data-hathor-scg-clean`).
- [x] **Validation error** — `data-hathor-scg-validate-error` for malformed
      JSON, a non-object packet, a malformed success payload, or a failed POST.

## Interactions

- [x] **`data-hathor-scg-packet`** (textarea, `aria-label="packet json"`) — edit
      the scenario dependency packet JSON.
- [x] **`data-hathor-scg-validate-submit`** ("Validate scenario packet") —
      parses the JSON, requires a non-array object, then POSTs `{ packet }`; on
      200 with a valid `result` renders the verdict.
- [x] **Route Map entries** — verified against
      `STUDIO_HATHOR_SCENARIO_GENERATION_ROUTE_MAP` (5 entries).
- [x] **Quick-action links** — Culture Evolution Simulation
      (`/studio/hathor/culture-evolution-simulation`), Back to Studio
      (`/studio`).

## Data & contracts

- **Reads**: `GET /v1/admin/hathor/scenario-generation` (catalog: `issueTypes`,
  `severities`).
- **Writes**: `POST /v1/admin/hathor/scenario-generation/validate` with
  `{ packet }`.
- **Realtime**: none.
- **Caching**: client fetch on mount, `cache: 'no-store'`,
  `buildBffAuthHeaders()`, `AbortController` on unmount.
- **Auth**: admin-scoped, fail-closed (401/403 → unauthorized); route is behind
  the signed-in + studio proxy gate.
- **Catalog guard**: client requires the complete Hathor scenario issue-type and
  severity catalog before exposing the validator. Malformed catalog payloads
  fail closed.
- **Validation guard**: client rejects malformed JSON and non-object packets
  without POST, and rejects malformed 200 validation payloads instead of
  rendering fabricated results.
- **Covered BFF outcomes**: seeded `missing-scene-dependency`, edited clean
  packet, `missing-objective`, warning-only `missing-capture-requirement`,
  `missing-cgi-export`, malformed-scene detail, transport failure, and direct
  BFF auth/schema gates.

## Cross-references

- Parent: [`../../studio-overview.md`](../../studio-overview.md)
- Component sources:
  - `apps/oshun/web/src/components/studio/StudioHathorScenarioGenerationWorkspace.tsx`
  - `apps/oshun/web/src/components/studio/StudioHathorScenarioGenerationRouteMap.ts`
- Focused E2E: `apps/oshun/web/e2e/studio-hathor-scenario-generation.spec.ts`
- Siblings:
  [`./studio-hathor-culture-evolution-simulation.md`](./studio-hathor-culture-evolution-simulation.md),
  [`./studio-hathor-quest-authoring.md`](./studio-hathor-quest-authoring.md)

## Open questions / known gaps

- [ ] This is a packet _validator_, not a generator; confirm whether scenario
      _generation_ (producing the packet) lives in a separate surface or is out
      of scope for this admin lane.
- [ ] Hathor is `unconfirmed-v1` per `WALKTHROUGH/matrix/routes.csv`; confirm
      whether the dedicated `/studio/hathor/*` admin lanes ship V1 or are
      internal-only.
