# Definition of Done — applies to every phase

A phase is **done** only when *all* of the following are true. Each phase file adds its own
phase-specific criteria on top of this shared baseline.

## Code
- [ ] The full scope in the phase file is implemented — no laziness, no unsanctioned stubs. Anything
      not real is mocked **behind a DI seam** and recorded in the mock registry.
- [ ] It follows the project conventions exactly (server `CLAUDE.md` + `CONVENTIONS.md`, or client
      `CLAUDE.md` + the frontend-designer skill) and the relevant conventions checklist.
- [ ] No dead code (unused vars/imports/usings/params/members). Comments explain *why*, not *what*.
- [ ] Best practices honoured: (backend) clean-arch boundaries, projected/paginated reads, caching where
      it pays, idempotency/locks on the money path, IRR `BIGINT` money, validation at the boundary;
      (frontend) RSC/client boundary, query caching + no needless refetch, minimal re-renders, MUI
      primitives reused, i18n in both locales, tokens-based colours, RTL-correct.

## Gate
- [ ] **Backend:** `dotnet build Baya.sln` has zero new warnings **and** `dotnet test Baya.sln` passes,
      including the tests this phase adds.
- [ ] **Frontend:** `npm run check` passes **and** `npm run test:ci` passes if a shared component was
      touched/added; `en.json` and `fa.json` are in sync.

## Documentation
- [ ] The relevant architecture map is updated in the same change (server *Project map* / client
      *Project Structure* / root *Repository layout*) if the structure changed.
- [ ] Any business rule discovered/decided is reflected in the `product/` docs (no invented rules).
- [ ] New reusable patterns/seams are noted in the relevant `CLAUDE.md`/`CONVENTIONS.md`.

## Contracts & handoff
- [ ] **Backend:** the API contract for what shipped is written to `dev/contracts/domains/<domain>.md`
      and the `swagger.json` snapshot is published per `dev/contracts/openapi/README.md`.
- [ ] **Frontend:** types/services are derived from the published contract (not guessed); any contract
      gap is appended to `dev/shared-working-context/frontend/requests/for-backend.md`.
- [ ] The handoff note `dev/shared-working-context/<lane>/...` is written (backend: a new
      `handoff/after-backend-phase-N.md`; both lanes: a STATUS append).

## Reporting & memory
- [ ] The per-phase report `dev/shared-working-context/reports/<lane>-phase-N-report.md` is written:
      what was built, **what is now testable and exactly how**, what is mocked + how to make it real,
      contracts produced/consumed, follow-ups.
- [ ] The mock registry `dev/shared-working-context/reports/mocks-registry.md` is updated for every
      seam this phase mocked/touched.
- [ ] Persistent memory is saved for any non-obvious decision/seam/gotcha, with a `MEMORY.md` pointer.
