|
1 | | -# Contributing to merjs |
| 1 | +# Rach's Agentic Contribution Template |
2 | 2 |
|
3 | | -Thanks for your interest. merjs is experimental — expect sharp edges and API churn. |
| 3 | +Maintainer process template by [@rachpradhan](https://x.com/rachpradhan). |
4 | 4 |
|
5 | | -## Prerequisites |
| 5 | +This repo moves quickly. Small, current, issue-linked PRs are much easier to review and much less likely to regress behavior. |
6 | 6 |
|
7 | | -- [Zig 0.15.x](https://ziglang.org/download/) — check with `zig version` |
8 | | -- macOS or Linux (Windows is untested) |
| 7 | +## Ground Rules |
9 | 8 |
|
10 | | -## Local setup |
| 9 | +1. Every PR must be tied to an issue. |
| 10 | +2. Rebase onto current `main` before requesting final review. |
| 11 | +3. Keep PRs tightly scoped. |
| 12 | +4. Do not commit generated artifacts. |
| 13 | +5. Do not mix unrelated lockfile churn, scaffolding, or benchmark churn into a focused fix. |
| 14 | +6. Keep each PR under **500 changed lines** by default. |
11 | 15 |
|
12 | | -```bash |
13 | | -git clone https://github.com/justrach/merjs.git |
14 | | -cd merjs |
15 | | -git config core.hooksPath .githooks # enable pre-commit (fmt+build) and pre-push (test) |
16 | | -``` |
| 16 | +If a branch goes stale, close it and open a smaller replacement instead of piling more changes onto the old PR. |
17 | 17 |
|
18 | | -## One-command dev start |
| 18 | +## PR Requirements |
19 | 19 |
|
20 | | -```bash |
21 | | -zig build codegen # generate src/generated/routes.zig from app/ |
22 | | -zig build serve # start dev server on :3000 with hot reload |
23 | | -``` |
| 20 | +Every PR description should include: |
| 21 | + |
| 22 | +- linked issue number |
| 23 | +- summary of the exact change |
| 24 | +- files or subsystems touched |
| 25 | +- tests run |
| 26 | +- failing test, xfail, or exact repro that demonstrated the problem before the fix |
| 27 | +- passing rerun of that same test or repro after the fix |
| 28 | +- nearby non-regression checks proving the change did not just move the bug |
| 29 | +- whether the branch was rebased onto current `main` |
| 30 | +- whether any generated files, lockfiles, or benchmarks changed |
| 31 | + |
| 32 | +If a PR does not map cleanly to an issue, open the issue first. |
| 33 | + |
| 34 | +## Red-To-Green Rule |
| 35 | + |
| 36 | +For bug fixes, compatibility fixes, runtime fixes, and perf regressions: |
| 37 | + |
| 38 | +1. show the failing test, xfail, or exact repro first |
| 39 | +2. make the code change |
| 40 | +3. rerun the same test or repro and show it passing |
| 41 | +4. run the closest neighboring tests to prove the fix did not just move the bug |
| 42 | + |
| 43 | +If there is no failing test yet, write one first unless the failure is impossible to encode cleanly. |
| 44 | + |
| 45 | +## Scope Rules |
| 46 | + |
| 47 | +Good PR scope: |
| 48 | + |
| 49 | +- one bug fix |
| 50 | +- one benchmark methodology fix |
| 51 | +- one small perf change |
| 52 | +- one docs-only clarification |
| 53 | + |
| 54 | +Bad PR scope: |
| 55 | + |
| 56 | +- runtime change + unrelated refactor |
| 57 | +- perf tweak + dependency upgrade |
| 58 | +- feature work + generated build output |
| 59 | +- benchmark change + docs rewrite + lockfile churn |
24 | 60 |
|
25 | | -Or via the `mer` CLI (built from `cli.zig`): |
| 61 | +If a reviewer cannot explain the PR in one sentence, it is probably too large. |
| 62 | + |
| 63 | +## Rebase Policy |
| 64 | + |
| 65 | +Before requesting review on any non-trivial PR: |
26 | 66 |
|
27 | 67 | ```bash |
28 | | -zig build cli # produces zig-out/bin/mer |
29 | | -./zig-out/bin/mer dev # codegen + serve in one step |
| 68 | +git fetch origin |
| 69 | +git rebase origin/main |
30 | 70 | ``` |
31 | 71 |
|
32 | | -## Build targets |
| 72 | +If rebasing reveals unrelated conflicts, split the PR. |
| 73 | + |
| 74 | +## Generated Files |
| 75 | + |
| 76 | +Do not commit generated or local-build artifacts, including: |
| 77 | + |
| 78 | +- `.zig-cache/` |
| 79 | +- `zig-out/` |
| 80 | +- `.dylib`, `.so`, `.o` |
| 81 | +- local benchmark artifacts/logs unless the PR is explicitly about publishing benchmark evidence |
| 82 | + |
| 83 | +If a file is generated during local builds, add or update `.gitignore` instead of committing it. |
| 84 | + |
| 85 | +## Lockfiles And Dependencies |
| 86 | + |
| 87 | +Do not update lockfiles unless the PR actually changes dependencies. |
| 88 | + |
| 89 | +If you touch dependency metadata: |
| 90 | + |
| 91 | +- explain why |
| 92 | +- keep that change isolated |
| 93 | +- mention it clearly in the PR summary |
| 94 | + |
| 95 | +## Tests |
| 96 | + |
| 97 | +Run the narrowest relevant tests for the code you changed. |
| 98 | + |
| 99 | +For fixes, do not just say “tests passed”. |
| 100 | + |
| 101 | +Show: |
| 102 | + |
| 103 | +- the failing command before the fix |
| 104 | +- the passing command after the fix |
| 105 | +- at least one neighboring or regression-guard command |
33 | 106 |
|
34 | | -| Command | What it does | |
35 | | -|---|---| |
36 | | -| `zig build` | Compile the framework binary | |
37 | | -| `zig build serve` | Dev server on :3000, hot reload | |
38 | | -| `zig build codegen` | Regenerate `src/generated/routes.zig` | |
39 | | -| `zig build worker` | Compile `worker/merjs.wasm` for Cloudflare Workers | |
40 | | -| `zig build desktop` | Native macOS `.app` bundle (macOS only, experimental) | |
41 | | -| `zig build test` | Run unit tests | |
42 | | -| `zig build test-auth` | Run `packages/merjs-auth` tests | |
43 | | -| `zig build css` | Recompile Tailwind → `public/styles.css` | |
| 107 | +## Benchmark PRs |
44 | 108 |
|
45 | | -## Before submitting a PR |
| 109 | +Benchmark-related PRs must say: |
46 | 110 |
|
47 | | -1. `zig fmt src/ app/ api/ examples/ *.zig` — formatter is enforced by pre-commit hook |
48 | | -2. `zig build` — must compile without errors |
49 | | -3. `zig build test` — must pass |
50 | | -4. Open an issue first for anything non-trivial so we can align on approach |
| 111 | +- what layer is being measured |
| 112 | +- whether caches are on or off |
| 113 | +- whether numbers are cold-start or warmed steady-state |
| 114 | +- number of runs |
| 115 | +- whether values are single-run or median |
| 116 | +- exact machine or CI environment |
51 | 117 |
|
52 | | -## Branch naming |
| 118 | +Do not publish cached results as uncached performance. |
53 | 119 |
|
54 | | -- `feat/<name>` — new feature |
55 | | -- `fix/<name>` — bug fix |
56 | | -- `docs/<name>` — documentation only |
57 | | -- `refactor/<name>` — no behaviour change |
| 120 | +## Review Expectations |
58 | 121 |
|
59 | | -## Repo layout |
| 122 | +Reviewers will push back on: |
60 | 123 |
|
61 | | -See [docs/architecture.md](docs/architecture.md) for a full breakdown. The short version: |
| 124 | +- stale branches |
| 125 | +- unrelated file churn |
| 126 | +- generated artifacts |
| 127 | +- oversized PRs |
| 128 | +- missing issue links |
| 129 | +- claims that do not match the changed code |
62 | 130 |
|
63 | | -- `src/` — framework runtime (server, router, SSR, HTML builder, watcher) |
64 | | -- `app/`, `api/`, `public/` — the merjs website / demo app (not the framework itself) |
65 | | -- `examples/` — standalone demo apps (kanban, desktop, singapore-data-dashboard) |
66 | | -- `packages/` — optional packages (`merjs-auth`) |
67 | | -- `cli.zig` — `mer` CLI entry point |
68 | | -- `wasm/` — client-side WASM modules |
| 131 | +That is process, not hostility. |
69 | 132 |
|
70 | | -## Reporting bugs |
| 133 | +The easiest way to get a fast review is: |
71 | 134 |
|
72 | | -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md). Please include: |
73 | | -- `zig version` output |
74 | | -- OS + arch |
75 | | -- Minimal reproduction steps |
| 135 | +1. open an issue |
| 136 | +2. make a small branch |
| 137 | +3. rebase onto `main` |
| 138 | +4. keep the diff narrow |
| 139 | +5. include exact tests and rationale |
0 commit comments