# MS-GATE-001 Scratchpad

## Objective

Build the API Gatekeeper module for PR auto-merge orchestration using Gitea PR webhooks, Woodpecker CI webhooks, and a `pending_merges` Prisma model.

## Constraints

- Work in `/home/jwoltje/src/mosaic-stack-worktrees/gate-001`
- Do not merge or deploy
- Must pass:
  - `pnpm format:check`
  - `SKIP_ENV_VALIDATION=true pnpm turbo typecheck`
  - `SKIP_ENV_VALIDATION=true pnpm turbo lint`
  - `SKIP_ENV_VALIDATION=true pnpm turbo test --filter=@mosaic/api -- --testPathPattern="gatekeeper"`

## ASSUMPTION

- Woodpecker PR pipelines expose `CI_COMMIT_PULL_REQUEST` and `CI_COMMIT_SHA`, so the webhook notifier can send `prNumber` and `headSha`.
  - Rationale: Gatekeeper needs an exact PR/head tuple to safely match CI back to `pending_merges`.

## Plan

1. Add Prisma model + SQL migration for `pending_merges`
2. Add Gatekeeper NestJS module/controller/service/DTO/tests
3. Wire Woodpecker webhook -> Gatekeeper CI handler
4. Add env/config documentation and compose variables
5. Run quality gates, review, remediate, push, open PR

## Progress

- [x] Context loaded
- [ ] Tests added first
- [ ] Implementation complete
- [ ] Quality gates green
- [ ] Push + PR opened

## Verification

- Pending
