|
| 1 | +--- |
| 2 | +name: records |
| 3 | +description: Commit records and review pages for the ReScript compiler repository. Use when committing a change, when an agent reports its work, and when someone asks to review a commit, a pull request or a branch. Every commit message is a structured record that answers the questions ReScript reviewers ask; review pages are rendered from records with scripts/commitRecords.js, never written by hand. |
| 4 | +--- |
| 5 | + |
| 6 | +# Commit records and review pages |
| 7 | + |
| 8 | +A **record** is a commit message whose body has named prose sections and |
| 9 | +whose last block is git trailers. Its fields are the questions reviewers of |
| 10 | +this repository ask on pull requests, answered before they are asked. A |
| 11 | +review page is rendered from records: one card per commit, and for a range a |
| 12 | +summary, a changelog draft and the files more than one commit changes. |
| 13 | + |
| 14 | +## The record |
| 15 | + |
| 16 | +``` |
| 17 | +<subject: present tense, what the compiler or tool now does> |
| 18 | +
|
| 19 | +<one paragraph: the change at the level of the language or the tool> |
| 20 | +
|
| 21 | +Example (rescript): |
| 22 | + <the ReScript source that shows the change, at most 15 lines> |
| 23 | +
|
| 24 | +Before (js): |
| 25 | + <generated JavaScript before, for that source> |
| 26 | +
|
| 27 | +After (js): |
| 28 | + <generated JavaScript after> |
| 29 | +
|
| 30 | +Source: <how the Before/After JavaScript was produced: compiler and revision, |
| 31 | +or the snapshot file in the diff> |
| 32 | +
|
| 33 | +Breaking: <what existing code or tooling stops working, and the migration> |
| 34 | +
|
| 35 | +Review: <a question a reviewer raised or will raise, and its answer; repeat> |
| 36 | +
|
| 37 | +Area: syntax printer frontend typechecker lambda codegen runtime rewatch |
| 38 | + analysis reanalyze gentype tools playground scripts ci docs tests |
| 39 | +Output: unchanged | changed <which programs>, <evidence> |
| 40 | +Formatting: unchanged | changed <which source shapes> |
| 41 | +Formats: none | <bumped magic numbers: ast cmi cmt cmj> |
| 42 | +PPX: unchanged | <effect on the frozen v0 PPX wire> |
| 43 | +Editor: unchanged | <effect on completion, hover, hints; fixtures> |
| 44 | +Errors: <ERROR_VARIANTS.md rows added, removed or relinked> |
| 45 | +Tests: +added/path ~updated/path -removed/path | none, because <reason> |
| 46 | +Measured: <quantity before -> after, and what produced it>; ... |
| 47 | +PR: #<number> |
| 48 | +Signed-off-by: <Name> <email> |
| 49 | +``` |
| 50 | + |
| 51 | +- **Prose sections** are a line `Name:` or `Name (lang):` followed by text or |
| 52 | + a block indented by 4 spaces. `lang` is `rescript`, `js`, `ts`, `sh`, |
| 53 | + `rust`, `ocaml` or `text`; the renderer highlights ReScript and JavaScript. |
| 54 | + `Before` and `After` sections of one language render side by side with |
| 55 | + changed lines marked. Use `Before (rescript)` / `After (rescript)` for a |
| 56 | + formatter change and `Diagnostic (text)` for compiler output. Any other |
| 57 | + name is allowed and renders as prose or code. |
| 58 | +- **The final block is git trailers**: `Key: value` lines, continuation lines |
| 59 | + indented by one space, nothing after them. `git interpret-trailers --parse` |
| 60 | + must read every key. `Signed-off-by` (DCO) is required on every commit. |
| 61 | +- **No changelog in the record**: the `changes/<name>.<category>.md` |
| 62 | + fragment the commit adds is the single source of truth for its changelog |
| 63 | + category and entry (see `changes/README.md`). The record repeats neither; |
| 64 | + the review page reads the fragment from the diff. |
| 65 | +- **Required keys**: `Area`, `Output`, `Tests`. `Formatting`, `Formats`, |
| 66 | + `PPX` and `Editor` are required whenever the change touches the syntax |
| 67 | + library, the parsetree, the typed tree or Lambda. Omit the others when they |
| 68 | + do not apply. |
| 69 | +- **Wording** follows the writing rules: present facts, positive statements, |
| 70 | + claims as strong as their evidence, every number labelled by what produced |
| 71 | + it. A JavaScript `Before`/`After` pair says where it came from in a |
| 72 | + `Source:` paragraph (compiler run, or a snapshot file in the diff). |
| 73 | +- **Lists in trailers**: `Measured` separates items with `; ` |
| 74 | + (outside parentheses); each item renders on its own line. `Output` and the |
| 75 | + other state trailers start with their state word (`unchanged`, `changed`, |
| 76 | + `none`), followed by the detail. |
| 77 | + |
| 78 | +## What each field states |
| 79 | + |
| 80 | +| Field | What the record states | |
| 81 | +| --- | --- | |
| 82 | +| `Area` | The layers the change touches. They decide who reviews it and which suites apply; a parsetree or typed-tree change also reaches editor analysis. | |
| 83 | +| `Output` + `Before`/`After (js)` | The generated JavaScript for the example before and after, and which existing programs compile differently. `unchanged` holds when no committed generated JS changes, or when a rebuild of the test suites is byte-identical. | |
| 84 | +| `Formatting` + `Before`/`After (rescript)` | Whether `rescript format` rewrites existing code, and whether formatted output parses back to the same tree with its comments. | |
| 85 | +| `Formats` | The magic numbers bumped in `compiler/ext/config.ml`. Any change to the marshaled parsetree, typed tree (`.cmi`, `.cmt`) or `.cmj` layout, constructor order included, bumps the matching number. | |
| 86 | +| `PPX` | The effect on the frozen v0 PPX wire: `parsetree0.ml` is unchanged, and a change to the v0 mapping comes with an ast-mapping fixture. | |
| 87 | +| `Editor` | Completion, hover and inlay hints on new or changed nodes, and the analysis fixtures that cover them. | |
| 88 | +| `Errors` | The `tests/ERROR_VARIANTS.md` rows added, removed or relinked for changed error variants or fixtures. | |
| 89 | +| `Tests` | The tests added, changed or removed, each observing the effect the record claims, so that it fails without the change. `none, because …` gives the reason when no test changes. | |
| 90 | +| `Measured` | Performance before and after, with the input and the command that produced each number. | |
| 91 | +| `Breaking` | What existing code or tooling stops working, and the migration. | |
| 92 | +| `Review` | Questions a reviewer raised or will raise, with their answers. | |
| 93 | +| `PR` | The pull request; the renderer links it. | |
| 94 | +| `Signed-off-by` | The DCO sign-off, with the commit author's name and email, as the last trailer. | |
| 95 | + |
| 96 | +## Rendering |
| 97 | + |
| 98 | +```sh |
| 99 | +node scripts/commitRecords.js --out review.html <rev>... |
| 100 | +node scripts/commitRecords.js --out review.html <base>..<branch>... |
| 101 | +node scripts/commitRecords.js --fragment --out part.html <rev>... |
| 102 | +node scripts/commitRecords.js --out review.html --pr 1234 --title "<PR title>" <base>..<branch> |
| 103 | +``` |
| 104 | + |
| 105 | +- `--pr` and `--title` head the page with the pull request's number (linked) |
| 106 | + and title; without them the page is headed "Semantic Diff". |
| 107 | + |
| 108 | +- A revision renders one card. A range renders a summary row, a changelog |
| 109 | + draft grouped by category, its commits as cards, and the files more than |
| 110 | + one commit (or more than one range) changes. The changelog category, the |
| 111 | + entries and the draft come from the `changes/` fragments in the diff: a |
| 112 | + card shows the fragments its commit adds or changes, and a range's draft |
| 113 | + shows the fragments the range leaves, in their last version. |
| 114 | +- Each card checks the record against its diff: a `changes/` fragment that |
| 115 | + `yarn changelog:check` rejects (such as one still carrying the placeholder |
| 116 | + PR link), an edit to `CHANGELOG.md`, modified generated `.mjs`, `.cjs` and `.res.js` files under |
| 117 | + `Output: unchanged` (new ones from new tests are counted, not flagged), a |
| 118 | + magic number bumped in `compiler/ext/config.ml` that |
| 119 | + `Formats` does not name, a parsetree change with no ast-mapping fixture, a |
| 120 | + new `super_errors` fixture with no `ERROR_VARIANTS.md` change, a missing |
| 121 | + `Tests` trailer, `Tests: none` on a diff that changes tests. A failed |
| 122 | + check is shown on the card. The DCO app checks `Signed-off-by`. |
| 123 | +- The page is one self-contained HTML file: no script, no external data |
| 124 | + (fonts fall back to system faces), light and dark themes, phone width. |
| 125 | + `--fragment` omits the document skeleton for embedding. |
| 126 | +- A note on `refs/notes/records` replaces the commit message's record. Use it |
| 127 | + for commits that exist already (history, a squash merge) and for review |
| 128 | + outcomes added later; a new commit carries its record in its message. |
| 129 | + |
| 130 | +## When to use |
| 131 | + |
| 132 | +- Every commit an agent makes carries a record in its message. |
| 133 | +- An agent's report lists its commits and the rendered page; the records are |
| 134 | + the description of the work. A pull request description is a rendering of |
| 135 | + its range. |
| 136 | +- Before review or merge: render `master..<branch>` and hand over the page. |
| 137 | +- On GitHub, `.github/workflows/semantic_diff.yml` renders each pull |
| 138 | + request's range when it is opened or pushed, and comments the page's link |
| 139 | + (`Semantic diff: https://cdn.rescript-lang.org/semantic-diff/pr-<N>/…`). |
0 commit comments