|
| 1 | +# Contribution Quality Gate |
| 2 | + |
| 3 | +A repeatable quality gate for PocketPay SDK issue work. Maintainers use it |
| 4 | +**before approving** a PR. Contributors should treat it as the bar their PR |
| 5 | +must clear. |
| 6 | + |
| 7 | +> **Merged ≠ payment-approved.** GrantFox and campaign rewards are assessed |
| 8 | +> separately. This gate reduces incomplete merges that later fail evaluation. |
| 9 | +
|
| 10 | +```text |
| 11 | +Contributor self-review → npm run verify:pr → PR opened |
| 12 | + ↓ |
| 13 | +Maintainer quality gate checklist → approve / hold |
| 14 | +``` |
| 15 | + |
| 16 | +## Checklist location |
| 17 | + |
| 18 | +Use the checklist in |
| 19 | +[`.github/checklists/contribution-quality-gate.md`](../.github/checklists/contribution-quality-gate.md). |
| 20 | + |
| 21 | +It covers five areas required by this gate: |
| 22 | + |
| 23 | +| Area | What must be true | |
| 24 | +| :--- | :--- | |
| 25 | +| **Implementation** | Real behaviour in the right modules; size is not enough | |
| 26 | +| **Tests** | Unit tests with failure paths; offline-safe | |
| 27 | +| **CI status** | Local verify green; GitHub checks green (or documented pre-existing red) | |
| 28 | +| **Docs** | Public contract / workflow docs updated when needed | |
| 29 | +| **Acceptance criteria** | Every issue criterion mapped and satisfied (or scoped out) | |
| 30 | + |
| 31 | +Copy the checklist into a review comment or fill it while reviewing the PR. |
| 32 | + |
| 33 | +## How contributors prepare |
| 34 | + |
| 35 | +1. Complete the [Contributor Self-Review Form](../.github/checklists/contributor-self-review.template.md). |
| 36 | +2. Run `npm run verify:pr` (see [Pre-PR Verification](./pre-pr-verification.md)). |
| 37 | +3. Fill the PR template sections: tests, commands run, CI, acceptance criteria. |
| 38 | +4. Map each issue acceptance criterion to a concrete change. |
| 39 | + |
| 40 | +## How maintainers validate |
| 41 | + |
| 42 | +Before clicking approve: |
| 43 | + |
| 44 | +1. Open [contribution-quality-gate.md](../.github/checklists/contribution-quality-gate.md). |
| 45 | +2. Walk each section against the PR diff, CI tab, and issue acceptance criteria. |
| 46 | +3. Cross-check with [Meaningful Change Review](./meaningful-change-review.md). |
| 47 | +4. **PASS** only when every applicable box is checked. |
| 48 | +5. **HOLD** with specific missing items if the gate fails — do not merge “to fix later” for incomplete criteria. |
| 49 | + |
| 50 | +### Quick maintainer questions |
| 51 | + |
| 52 | +- Does this PR solve the issue, or only touch nearby files / docs? |
| 53 | +- Are failure paths tested, or only the happy path? |
| 54 | +- Are GitHub checks green for *this* PR? |
| 55 | +- Is every acceptance criterion accounted for in the description? |
| 56 | +- Would this pass a later GrantFox evaluation as complete work? |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Examples of incomplete work |
| 61 | + |
| 62 | +These patterns should **fail** the quality gate. |
| 63 | + |
| 64 | +### 1. Tiny stub for a behaviour issue |
| 65 | + |
| 66 | +```ts |
| 67 | +// ❌ Issue asked for validation; PR returns input unchanged. |
| 68 | +export function validateSendXLMParams(params: SendXLMParams) { |
| 69 | + return { ok: true as const }; |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +**Why it fails:** no real implementation; acceptance criteria unmet. |
| 74 | + |
| 75 | +### 2. Implementation without tests |
| 76 | + |
| 77 | +```ts |
| 78 | +// ❌ New classify path shipped with zero tests. |
| 79 | +export function classifySubmitError(error: unknown): PocketPayError { /* ... */ } |
| 80 | +``` |
| 81 | + |
| 82 | +**Why it fails:** tests section of the gate is empty; regression risk. |
| 83 | + |
| 84 | +### 3. Happy-path-only tests |
| 85 | + |
| 86 | +```ts |
| 87 | +it('sends payment', async () => { |
| 88 | + await expect(sendXLM(valid)).resolves.toMatchObject({ success: true }); |
| 89 | +}); |
| 90 | +// ❌ Never asserts INVALID_AMOUNT, ACCOUNT_NOT_FOUND, PAYMENT_FAILED, etc. |
| 91 | +``` |
| 92 | + |
| 93 | +**Why it fails:** failure-path coverage required for payment / error work. |
| 94 | + |
| 95 | +### 4. Docs-only PR for a code issue |
| 96 | + |
| 97 | +```md |
| 98 | +<!-- ❌ Issue: "add trustline preflight". PR only edits README. --> |
| 99 | +``` |
| 100 | + |
| 101 | +**Why it fails:** implementation size/completeness gate — behaviour was required. |
| 102 | + |
| 103 | +### 5. Greenwashed CI |
| 104 | + |
| 105 | +```text |
| 106 | +Local: tests fail |
| 107 | +PR body: "CI will fix it" |
| 108 | +CI: red, unexplained |
| 109 | +``` |
| 110 | + |
| 111 | +**Why it fails:** CI status gate — checks must be green or pre-existing red must be documented. |
| 112 | + |
| 113 | +### 6. Acceptance criteria ignored |
| 114 | + |
| 115 | +```md |
| 116 | +## Acceptance criteria |
| 117 | +- [ ] (left blank) |
| 118 | +``` |
| 119 | + |
| 120 | +**Why it fails:** criteria mapping is mandatory; blank sections fail the gate. |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## Examples of acceptable work |
| 125 | + |
| 126 | +These patterns should **pass** the quality gate when CI is green. |
| 127 | + |
| 128 | +### 1. Complete behaviour + tests + criteria |
| 129 | + |
| 130 | +- Implements the rule in the owning module (e.g. `src/payments/`). |
| 131 | +- Adds `tests/*.test.ts` covering success **and** typed error paths. |
| 132 | +- `npm run verify` / `npm run verify:pr` green; GitHub checks green. |
| 133 | +- PR description checks every issue acceptance criterion. |
| 134 | +- Docs updated if the public contract changed. |
| 135 | + |
| 136 | +### 2. Focused bugfix with regression test |
| 137 | + |
| 138 | +- Minimal diff that fixes the root cause. |
| 139 | +- New failing test that would have caught the bug, then made green. |
| 140 | +- No unrelated refactors. |
| 141 | +- Criterion “regression test added” explicitly checked. |
| 142 | + |
| 143 | +### 3. Docs / DX workflow issue done end-to-end |
| 144 | + |
| 145 | +- When the issue is documentation or contributor tooling (e.g. this quality gate): |
| 146 | + - checklist / guide files exist, |
| 147 | + - PR template and README link them, |
| 148 | + - examples of incomplete vs acceptable work are present, |
| 149 | + - no fake `src/` stubs required. |
| 150 | +- Still runs `npm run verify` if package scripts or tests were touched. |
| 151 | + |
| 152 | +### 4. Refactor that preserves behaviour |
| 153 | + |
| 154 | +- Existing tests still pass; new coverage where gaps were found. |
| 155 | +- No silent public API break. |
| 156 | +- Rationale documented in the PR. |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## Relationship to other docs |
| 161 | + |
| 162 | +| Doc | Role | |
| 163 | +| :--- | :--- | |
| 164 | +| [contribution-quality-gate.md](../.github/checklists/contribution-quality-gate.md) | Maintainer checkbox form | |
| 165 | +| [Contributor Self-Review](../.github/checklists/contributor-self-review.template.md) | Contributor form before review | |
| 166 | +| [Meaningful Change Review](./meaningful-change-review.md) | What “meaningful” SDK work looks like | |
| 167 | +| [Pre-PR Verification](./pre-pr-verification.md) | `npm run verify:pr` automated reminders | |
| 168 | +| [Local Verification](./local-verification.md) | `npm run verify` pipeline details | |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +## PR template |
| 173 | + |
| 174 | +The [PR template](../.github/PULL_REQUEST_TEMPLATE.md) asks contributors to |
| 175 | +acknowledge this quality gate. Maintainers should still run the full checklist |
| 176 | +before approval — the template alone is not a pass. |
0 commit comments