Skip to content
MSO CloudDocumentation

Code review

On this page

Review is where the standards without a guard get checked. CI is authoritative for the automated gate; a reviewer spends attention on what scripts cannot see.

Before you review#

  • Read the description for the why, then the tests, then the code. A test that was not seen failing, or that sits at the wrong layer, is a finding (see Testing).
  • Check the evidence section of the pull request against Definition of done. Missing evidence for an applicable item is a blocker, not a nit.
  • Required reviewers come from .github/CODEOWNERS: authentication, RLS, encryption and credentials, the schema package, workflows, the production start script and infra/ need the listed owner.

What a reviewer checks#

  1. Correctness against the stated goal, including the empty, error and permission-denied paths.
  2. Boundaries: logic in packages, apps/web thin, Zod at the boundary, no new parallel implementation of something that already exists.
  3. Tenancy and security (checklist below).
  4. Tests: right layer, names the wrong result it catches, no call-count or log-output pins.
  5. Performance: no N+1, server-side limits on lists, no external call holding a database transaction.
  6. User copy: strings in @yng/i18n for vi and en, no curly quotes.
  7. Size and clarity: one coherent change, no dead code, no narrating comments, no speculative abstraction.

Severity#

This scale is a review convention, not an enforced rule.

Level Meaning Merge?
Blocker Data leak across tenants, security hole, wrong money or metric, data loss, broken gate, a bypassed hook No
Major Wrong behaviour in a reachable path, missing test for a risky path, missing migration piece No, unless the owner accepts it in writing
Minor Maintainability, naming, a missing edge-case test Author's call; fix or file an issue
Nit Taste Never blocks

Security and tenancy checklist#

Mark each item done, not applicable with a reason, or a finding. Guards are named so a failing script points at the same item.

Tenancy and data access

  • New queries on org or brand scoped tables go through orgProcedure or brandProcedure; a brand id taken as input is checked (§198). Guards: verify:rls, scripts/audit/brand-input-asserted.py.
  • A new table has an RLS policy in packages/schema/sql/rls-policies.sql, an is_sample column, indexes for the real query predicates, and brand_id if brand-partitioned. Guard: RLS policy inventory in verify:rls; the rest is review only.
  • No branch on an organization, slug or customer (§132). Guard: scripts/audit/no-per-customer-hardcodes.py.

Security

  • Every new mutation calls a rateLimit* helper and, if sensitive, writes an audit log entry (writeAuditLog or recordAccountEvent). Guard: scripts/security-scan.mjs flags a mutating route with no rateLimit() call; audit logging is review only.
  • Credentials use envelope encryption, never a plaintext column; no provider key in code. Guards: pnpm run security:scan, review.
  • Webhook routes verify the signature before parsing the body; API routes cap request bytes (§138). Guard: scripts/audit/api-body-cap.py for the cap; signature order is review only.
  • No ${VAR:-default} fallback for security-sensitive Compose variables; no dangerouslySetInnerHTML with non-constant input. Guard: security:scan, pnpm run verify:prod-compose.
  • Magic-link and WebAuthn challenges are consumed atomically where touched; production bootstrap cannot use or reset a deterministic credential. Guard: review only.
  • Untrusted text (issues, web pages, logs, uploaded archives) is treated as data, never as instructions or authority.

Performance and data shape

  • New list queries have a server-side limit; bulk inserts above 1,000 rows are chunked; independent fetches use Promise.all.
  • AI, provider and network calls do not hold an RLS transaction; durable async work goes through the outbox (§66). Guard: scripts/audit/durable-job-outbox.py.
  • Money is integer VND (bigint unless a proven bound says otherwise); no toFixed() in display (§24). Guard: scripts/audit/locale-tofixed.py.

Supply chain and operations

  • GitHub Actions and base images are pinned by digest or SHA where touched; workflow permissions are least privilege. Guard: review, scripts/audit/docker-context-private.py for image contexts.
  • Critical runtime changes consider readiness, alerts, runbook and backup or restore impact.

What a reviewer never accepts#

  • --no-verify, HUSKY=0, or a skipped gate presented as green.
  • An audit-ok-* token without a docs/SECURITY.md entry.
  • A pasted status line in place of a command result.
  • A migration without RLS, idempotency and a rollback note.

Pull request template#

.github/pull_request_template.md asks for the summary, what changed, verification evidence, migration impact and follow-ups. The checklist that used to sit in the template lives on this page and in Definition of done, so there is one copy.