Skip to content

feat(slice-4c.8): scenario clone server-side wired to POST /api/scenarios#36

Merged
lopadova merged 1 commit into
mainfrom
task/v1.7-slice-4c-scenario-clone
May 19, 2026
Merged

feat(slice-4c.8): scenario clone server-side wired to POST /api/scenarios#36
lopadova merged 1 commit into
mainfrom
task/v1.7-slice-4c-scenario-clone

Conversation

@lopadova
Copy link
Copy Markdown
Contributor

Summary

v1.7 slice 4c.8 — Scenario Clone, server-side.

Server

  • New `POST /api/scenarios` with atomic `Store.createScenario`: schema-validates body, 409 + EEXIST on id collision, 201 on create, requires `risk-map:edit`. Mirrors POST `/api/profiles` (slice 4c.3).
  • 5 unit tests (happy path 201, schema rejection on empty oracles, 409 EEXIST, concurrent-POST atomicity, permission).

Store

  • New `StoreProvider.createScenario(scenario): { created: boolean }` contract. Memory implements atomically via `has+set` in a single sync block. Postgres stays notImpl.
  • Scaffold "every method throws not implemented" test extended.

Scope note

Admin-side Scenario Clone wizard is deferred — same rationale as slice 4c.7. The scenario detail page is currently a read-only YAML preview, and a clone modal needs either fabricated scenario fixtures or full-scenario reads from the store, both larger than this slice. The server contract is ready when that UI lands.

Test plan

  • `bun run --filter @aqa/server test` (72/72)
  • `bun run --filter @aqa/store test` (6/6)
  • `bun run typecheck`
  • `bun run lint` (4 preexisting warnings)

🤖 Generated with Claude Code

…rios

Server:
- New POST /api/scenarios with atomic Store.createScenario:
  schema-validates body, 409 + EEXIST on id collision, 201 on
  create, requires risk-map:edit. Mirrors POST /api/profiles
  (slice 4c.3).
- 5 unit tests added (happy path 201, schema rejection on empty
  oracles, 409 EEXIST, concurrent-POSTs atomicity, permission).

Store:
- New StoreProvider.createScenario(scenario): { created: boolean }
  contract. MemoryStore implements via has+set in a single sync
  block (no TOCTOU window). PostgresStore stays notImpl.
- Scaffold "every method throws not implemented" test extended
  to cover createScenario.

Scope note: this slice delivers server-side trust-boundary +
atomic-create only. The admin-side Scenario Clone wizard is
deferred — same rationale as slice 4c.7 (the scenario detail
page is currently a read-only YAML preview; building a clone
modal requires either fabricating schema-conforming scenario
fixtures or wiring full-scenario reads from the store, both
larger than this slice).

Server: 72/72 (+5). Store: 6/6. Lint preexisting only.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds server-side support for “Scenario Clone” by introducing a create-only POST /api/scenarios endpoint backed by an atomic store operation, mirroring the existing profile-clone flow.

Changes:

  • Introduces POST /api/scenarios that schema-validates the request, uses StoreProvider.createScenario atomically, returns 201 on create and 409 (code=EEXIST) on id collision, and requires risk-map:edit.
  • Extends the store contract with createScenario(scenario): Promise<{ created: boolean }> and implements it in MemoryStore (with PostgresStore scaffolded to throw not implemented).
  • Adds/extends unit tests covering the new endpoint behavior and the Postgres scaffold “not implemented” surface.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/store/test/store.test.ts Extends Postgres scaffold tests to include createScenario as “not implemented”.
packages/store/src/types.ts Adds StoreProvider.createScenario atomic-create contract.
packages/store/src/postgres.ts Adds createScenario stub that throws not implemented.
packages/store/src/memory.ts Implements createScenario with create-only semantics returning { created }.
packages/server/test/api.test.ts Adds POST /api/scenarios tests: 201, 400 schema failure, 409 EEXIST, concurrency atomicity, permission.
packages/server/src/api.ts Adds POST /api/scenarios handler wired to ctx.store.createScenario with correct status codes and permission.

@lopadova lopadova merged commit 7396194 into main May 19, 2026
16 checks passed
@lopadova lopadova deleted the task/v1.7-slice-4c-scenario-clone branch May 19, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants