KwadMarket Docs
Road to Production

Track B — Code Quality

The remediation phases sequenced against launch — what blocks, what runs in the background

The engineering-debt work is already fully specified in the remediation plan (phases 0–9 with acceptance criteria). Don't re-plan it — this page only sequences it against the launch milestones and separates what blocks launch from what runs as background hygiene.

Phase → milestone mapping

PhaseWhatEffortBlocking?Milestone
0 — CI greene2e selector fixes, lint --fix removal~½ dayYes — nothing ships redM0
1 — Secrets fail-fastKill default-secret, Joi prod-required~½ dayYesM0
2 — Test harnessVitest + supertest + testcontainers, authz suites1–2 daysYes — prerequisite for 3–4 landing testedM1
3 — Auth hygienebcrypt hash off request.user, RequestUser type~½ dayYesM1
4 — Security patch setOAuth fragment, ownership checks, helmet, throttler, pagination clamp~1 dayYesM1
7a — Vulnerability bumpsmailer/handlebars, multer, next; delete dead deps~½ dayYesM1
5 — Data accessPrismaService DI, migrations, transactions, mappersper moduleNo — backgroundM2 → M4
6 — Backend qualityPromise<any> purge, Logger, service decompositionper moduleNo — backgroundM2 → M4
7b — OpsHealth, Sentry, jobs module, Swagger, Renovate~2 daysYes for beta — you can't run a beta blindM3
8 — FrontendQuick wins → review-queue refactor → consistencyindependentNo — parallel any timeM2 → M4
9 — Production gapsEmail verification, GDPR, SEO, backups, legalYesM3 (tracked as Track C)

Two orderings are non-negotiable: 0 → 1 → 2 → 3 → 4 (each builds on the last), and 7a before any feature work (don't build features on vulnerable deps). Everything else interleaves freely.

Background phases: the module rhythm

Phases 5, 6 and 8 are sweeps, not gates. Run them between feature PRs, one module per PR, in the plan's order: deals → products → discussions → users (backend), and the frontend list top-to-bottom. Two rules keep them from dragging forever:

  • Touch-it-fix-it: any feature PR that touches a module brings that module up to phase 5/6 standard as part of the PR (mappers, no Promise<any>, Logger). The sweep then only has to cover untouched modules.
  • Ratchet, don't boil: once a grep gate (see conventions) reaches 0 repo-wide, add it to CI so it can't regress. Do this gate by gate as they hit zero.

Rules for every quality PR

  • One phase step (or one module of a sweep) per PR — never mixed with feature work.
  • Run the verification gates before declaring done; phases have their own Accept: lines in the plan — those are the merge criteria.
  • Implementer agents get: the relevant conventions doc + the single plan/spec page for the step. Nothing else.
  • After Phase 2 exists: every security-relevant change (3, 4, and anything auth/ownership) lands with a regression test that fails if the check is reverted.

What "done enough for launch" means

Launch does not require phases 5/6/8 finished. It requires:

  • Phases 0–4 + 7 complete (their Accept lines green).
  • Phase 9's items done via Track C.
  • Background sweeps at least past the deals and auth modules — the code paths real users hit hardest on day one.

On this page