Skip to content

Pull Request Guideline ​

Spirit (the 3 non-negotiables) ​

  • Scope before narrative: the reviewer knows the risk level, the blast radius, and the path through the diff before opening it.
  • Attach evidence to every claim: each change points at its test, each risk at its reproduction, each "not affected" at something checkable, and each "verified" at a command and its result.
  • Tests must match the stated risks: a PR that warns about a race condition and ships only sequential tests has not been verified.

A description exists to help the reviewer approve quickly and correctly — to know what to read closely, what to skim, and how to confirm the result without rebuilding your environment. It is not a log of what you did.

Title and commits ​

The PR title and every commit subject follow Conventional Commits:

text
type(scope): summary in the imperative
  • type: feat, fix, refactor, perf, test, docs, style, chore, ci, build, or revert. Add ! after the type or scope for a breaking change.
  • scope: the area in a monorepo (server, web, mobile) or the module (inventory, auth). Leave it out when the change has no single home.
  • summary: what the change does, not how it was done — fix(inventory): count partial receipts once, not fix: update service.

A commit is either mechanical — rename, formatting, generated code, dependency bump — or it changes behavior, never both. A logic change hidden in a mechanical commit does not get reviewed. Do not squash-merge a PR whose Review order lists several commits: those commits are what the reviewer approved.

Risk level ​

The description starts with the risk level. Judge the tier by what the change can break, not by how many lines it touches:

  • High — inventory, money, authorization, database migrations, multi-table transactions, background jobs, anything with a concurrent writer.
  • Medium — a new endpoint or screen on an isolated module, a refactor with no behavior change, a dependency upgrade.
  • Low — copy, styling, comments, documentation, test-only changes.

The tier decides what is required:

RequiredLowMediumHigh
Purpose, Review order, Changes and tests, VerificationYesYesYes
Scope, Migration, deploy and rollback—YesYes
Risks—One block may doEvery failure mode you can name
Docs review comment—YesYes

Delete the sections a Low PR does not need. Do not label a PR Low to skip the form. An under-stated risk level costs the reviewer more than a long description.

Pull request size ​

No template rescues a 2000-line diff. Aim for at most about 400 changed lines of hand-written logic. Lockfiles, generated code, snapshots, and mechanical commits do not count toward that, but they still go in their own commits.

When a change is larger, split it into pull requests that each merge and deploy alone without breaking clients: schema first, then behavior; refactor first, then feature. If a PR mixes a rename across 40 files with one logic change, the logic change will not be reviewed.

The exception is an implementation issue whose areas must ship together, such as server, web, and mobile in one monorepo. Keep one PR, split the commits by area and into mechanical and logic commits, and list them in the Review order.

Section guide ​

The description has two header lines, then level-two (##) sections in this order. Section headings are always in English.

Header lines ​

text
Risk: High
Closes #123
  • Risk: exactly High, Medium, or Low.
  • Issue: Closes #123 (or Fixes, Resolves) when the PR finishes the issue; Refs #123 or Part of #123 when it is one step of it. A PR without an issue says why: No issue: fix a typo on the login screen.

1. Purpose ​

Two or three sentences on the problem being solved and the result after merge. No technical detail here — that belongs in the sections below.

2. Scope ​

Two lists, labeled Affected: and Not affected::

  • Affected: the specific modules, endpoints, jobs, or screens.
  • Not affected: what the reviewer can safely skip — with the evidence that supports it.

"Not affected" is the most dangerous field in the template, because it tells the reviewer to stop looking. A bare assertion is not enough. Anchor it: name the callers of the changed method, state that the diff stays inside given directories, or point at the contract that did not move.

3. Review order ​

The path through the diff: one line per commit, in the order to read them. Each line says whether to read the commit closely or skim it, and where to start reading the ones that need care.

text
1. `a1b2c3d` feat(inventory): add completed_by and completed_at to lots — read closely, start at the migration
2. `d4e5f6a` feat(inventory): complete a Lot after receiving — read closely, start at LotReceivingService::complete()
3. `b7c8d9e` refactor(inventory): rename receiveQty to receivedQuantity — mechanical, skim

A single-commit PR needs one line: the entry point. The order matters most on PRs that span a transaction or several tables, where file order in the diff tells the reviewer nothing.

4. Changes and tests ​

List each change paired with the test that covers it. Pairing is what turns "tests added" from a checkbox into something verifiable, and it exposes any change that has no test at all.

text
- Update Lot status after receiving
  -> test: tests/Feature/LotReceivingTest.php::test_lot_status_updates
- Aggregate order status (Pending / In progress / Completed)
  -> test: tests/Feature/LotReceivingTest.php::test_order_status_aggregation
- Rename receiveQty to receivedQuantity -> no test: mechanical rename, covered by the tests above

If a change has no test, write no test and the reason. An honest gap is reviewable; a missing line is not.

When the PR closes an implementation issue, its acceptance criteria table is the approved test list. Write one pair per row, naming the row by its Given and When. Manual rows point at their result in Verification:

text
- AC: Server, receive the same Lot twice in parallel -> test: tests/Feature/LotReceivingTest.php::test_concurrent_receive
- AC: E2E (manual), receive on mobile and open on web -> no test: manual, see Verification

Then state how the code differs from the approved issue:

text
Deviations from the issue: None

If the specification turned out to be wrong, update the issue body first — the issue stays the source of truth — then list each change here with the part of the issue it touched, so the reviewer can re-check it against the specification they approved. A deviation recorded only in the PR is lost once the PR merges.

5. Risks ​

One block per risk, with all five labels filled in. This is where the third principle is enforced by structure rather than by reminder.

text
Risk: two requests updating the same Lot concurrently
Why: partial receiving can double-count stock
Reproduce: POST /lots/{id}/receive twice in parallel with the same payload
Expected: one stock movement; the second request fails or waits
Evidence: SELECT ... FOR UPDATE in LotReceivingService::lockLot(),
          tests/Feature/LotReceivingTest.php::test_concurrent_receive

Cover the cases that break, not just the happy path: partial input, full input, repeated submission, and failure midway through a transaction so no phantom state survives a rollback.

State the invariants in Expected as absolutes the system must hold — no duplicate stock movement, Lot status and order status always consistent.

On concurrency evidence. A true concurrent test needs multiple connections and is often impractical. When you cannot write one, an acceptable substitute is the lock statement itself plus a manual concurrent script and its recorded output. What is not acceptable is a sequential test named as if it were concurrent.

Also cover, when relevant:

  • Authorization: which policy or gate changed, and who gains or loses access.
  • Query cost: new N+1 risk or query count on the hot path. See Model and Custom Query Builder.

6. Migration, deploy and rollback ​

Answer each line definitively. Do not leave the options in place.

text
- Migration: Yes — add completed_by, completed_at to lots
- Deploy window: old code runs against the new schema for ~2 minutes; both columns are nullable, so it is safe
- In-flight jobs: queued ReceiveLot payloads keep the old shape; the handler accepts both
- Breaking API change: No
- Rollback: migration down is safe; no data has been generated yet

The deploy window and in-flight jobs are separate questions from the migration itself. A migration can be reversible and still break the minutes during which old code and new schema coexist. See Migration.

7. Verification ​

What you actually ran and saw, so the reviewer can confirm the result without rebuilding your environment:

text
- php artisan test — 644 passed
- pnpm check — passed
- Manual: ran the parallel receive script against Lot L-1024; one stock movement recorded (output below)
- POST /lots/1024/receive → 200; request and response below
- Not run: mobile tests — the diff does not touch mobile/
  • Name each command and its result. "All tests pass" without the command and count is not evidence.
  • A UI change shows before and after screenshots or a video. An API change shows one real request and response.
  • Say what you did not run, and why.

The description has no checklist of ticked boxes. Boxes ticked by reflex carry no information; the lines above do.

Docs review comment ​

For Medium and High risk, post the structured comment from PR Docs Review Checklist before requesting review. It records which engineering guidelines you checked against the current PR head, with evidence or a specific exclusion reason. Update it when the PR changes. Low risk PRs do not need it.

Validate the format ​

Run the validator on the draft before opening the PR, and after every edit. It needs Deno 2 on the machine, and an authenticated gh to fetch a pull request. There is nothing else to install: Deno downloads the Markdown parser the script pins.

bash
# A local draft
deno run -q --no-config --allow-read https://omes-engineering-docs.pages.dev/scripts/v1/validate-pull-request.ts --file body.md --title 'fix(inventory): count partial receipts once'

# A published pull request: owner/repo#123, a pull request URL, or 123 in the current repository
deno run -q --no-config --allow-run=gh https://omes-engineering-docs.pages.dev/scripts/v1/validate-pull-request.ts technicalors/obee#164

--no-config keeps Deno from reading the current repository's package.json or deno.json; without it, Deno looks for the parser in that repository's node_modules. The --allow-* flags are the only access the script gets: reading the draft, or running gh.

It exits with 0 when the format is valid, 1 with a list of problems and their line numbers, and 2 on a usage or fetch error. It only reads the pull request.

It parses the description as GitHub-flavored Markdown, the way GitHub renders it, and checks structure only: the title format, the Risk and issue lines, the sections the risk level requires and their order, a Review order list, a test or no test for each change, the five labels of each risk block, the five answers in "Migration, deploy and rollback", and leftover placeholders such as <what changed>. Placeholders that look like HTML tags disappear when GitHub renders the page, so the validator also reports the field they leave empty. Whether the evidence is real is still the reviewer's job.

Run it on every pull request ​

Add the check to each repository as .github/workflows/pull-request-format.yml. It runs when a PR is opened, edited, or updated:

yaml
name: Pull request format

on:
  pull_request:
    types: [opened, edited, reopened, synchronize]

permissions: {}

jobs:
  format:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Deno
        uses: denoland/setup-deno@v2
        with:
          deno-version: v2.9.6

      - name: Validate title and description
        env:
          DENO_NO_UPDATE_CHECK: '1'
          PR_TITLE: ${{ github.event.pull_request.title }}
          PR_BODY: ${{ github.event.pull_request.body }}
        run: |
          printf '%s' "$PR_BODY" > "$RUNNER_TEMP/pr-body.md"
          deno run -q --no-config --allow-read="$RUNNER_TEMP" \
            https://omes-engineering-docs.pages.dev/scripts/v1/validate-pull-request.ts \
            --file "$RUNNER_TEMP/pr-body.md" --title "$PR_TITLE"

The title and body reach the script through environment variables, never through expressions pasted into the run script, so a crafted PR title cannot run commands.

Merge rules ​

Merge a pull request only when:

  • the pull request format check and the repository's CI are green;
  • at least one reviewer other than the author has approved the current head;
  • for Medium and High risk, the docs review comment matches the current head.

Where the repository's GitHub plan has no branch protection, GitHub does not block the merge, so these rules hold by team agreement. A red check or a missing approval means do not merge — not "merge and fix later".

How to review ​

The description is built to be read in this order:

  1. Read the risk level, the issue, and Purpose; decide how closely to read.
  2. For Medium and High risk, read Scope and check one "Not affected" claim yourself.
  3. When the PR closes an implementation issue, check that every acceptance criteria row has a pair, and that deviations read None or already appear in the issue.
  4. Walk the diff in Review order. Read closely what says so; skim mechanical commits, after confirming they really are mechanical.
  5. Check that each risk has evidence and each Verification line names a real command and result.
  6. For Medium and High risk, compare the docs review comment with the diff.

Blank template ​

The same content ships as .github/pull_request_template.md, so it appears automatically when a pull request is opened. Copy it into each repository.

markdown
Risk: <High, Medium, or Low>
Closes #<issue>

<!-- Guideline: https://omes-engineering-docs.pages.dev/pull-request-guideline -->
<!-- No issue: replace the Closes line with "No issue: " and the reason. -->
<!-- Low risk: delete Scope, Risks, and Migration, deploy and rollback. -->

## Purpose

<the problem and the result after merge, in two or three sentences>

## Scope

Affected:

- <module, endpoint, job, or screen>

Not affected:

- <area> — <evidence the reviewer can check>

## Review order

1. `<short sha>` <commit subject> — <read closely, start at the entry point / mechanical, skim>

## Changes and tests

- <what changed> -> test: <test file and name>

## Risks

```text
Risk:
Why:
Reproduce:
Expected:
Evidence:
```

## Migration, deploy and rollback

- Migration: <Yes or No, and what>
- Deploy window: <old code against the new schema>
- In-flight jobs: <queued payloads in the old shape>
- Breaking API change: <Yes or No, and what>
- Rollback: <how to undo it, or why it cannot be undone>

## Verification

- <command> — <result>
- Not run: <check> — <reason>

Review questions ​

Before opening a pull request, ask:

  1. Can the reviewer tell from the first line how much attention this needs?
  2. Does the Review order say where to start and what is safe to skim?
  3. Does every change name a test, or an explicit reason it has none?
  4. Would the reviewer regret trusting the "not affected" list?
  5. Does every risk have a reproduction, an expected invariant, and a test or recorded evidence?
  6. Can a reviewer confirm the result from Verification without rebuilding your environment?
  7. Should this be two pull requests?

Internal engineering documentation