Skip to content

Commit 5ddbf9b

Browse files
cristianocclaude
andcommitted
Render review pages from structured commit messages
A commit record is a commit message whose prose sections and git trailers answer the questions reviewers of this repository ask on pull requests: which layer changed, the changelog category and entry, the generated JavaScript before and after, formatter, marshaled-format, PPX and editor effects, error-catalog rows, and the tests added or changed (or why none). .claude/skills/records/SKILL.md defines the format and what each field states. scripts/commitRecords.js renders a semantic diff page: one card per record, checks each record against its own diff (changelog fragment, modified generated JavaScript, magic-number bumps, v0 PPX bridge fixtures, ERROR_VARIANTS.md, the Tests trailer), and for a range adds a summary, a changelog draft and the files that more than one commit changes. `--pr` and `--title` head the page with the pull request. The page is one HTML file with no script. `make semantic-diff` renders master..HEAD to _build/semantic-diff.html and opens it. Example (sh): make semantic-diff node scripts/commitRecords.js --out review.html master..my-branch Changelog entry: - Add commit records, a commit message format that answers recurring review questions, and a semantic diff page rendered from them and linked on each pull request. #8870 Review: Does the renderer need the compiler? No: it reads git (messages, notes on refs/notes/records, and diffs) and has no dependencies. Area: scripts tests docs ci Changelog: internal Output: unchanged Tests: +scripts/commitRecords.test.js PR: #8870 Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent bc2e0e1 commit 5ddbf9b

7 files changed

Lines changed: 1315 additions & 2 deletions

File tree

‎.claude/skills/records/SKILL.md‎

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
Changelog entry: <the exact bullet of the changes/<name>.<category>.md fragment>
36+
37+
Review: <a question a reviewer raised or will raise, and its answer; repeat>
38+
39+
Area: syntax printer frontend typechecker lambda codegen runtime rewatch
40+
analysis reanalyze gentype tools playground scripts ci docs tests
41+
Changelog: breaking | feature | fix | docs | polish | internal | none
42+
Output: unchanged | changed <which programs>, <evidence>
43+
Formatting: unchanged | changed <which source shapes>
44+
Formats: none | <bumped magic numbers: ast cmi cmt cmj>
45+
PPX: unchanged | <effect on the frozen v0 PPX wire>
46+
Editor: unchanged | <effect on completion, hover, hints; fixtures>
47+
Errors: <ERROR_VARIANTS.md rows added, removed or relinked>
48+
Tests: +added/path ~updated/path -removed/path | none, because <reason>
49+
Measured: <quantity before -> after, and what produced it>; ...
50+
PR: #<number>
51+
Signed-off-by: <Name> <email>
52+
```
53+
54+
- **Prose sections** are a line `Name:` or `Name (lang):` followed by text or
55+
a block indented by 4 spaces. `lang` is `rescript`, `js`, `ts`, `sh`,
56+
`rust`, `ocaml` or `text`; the renderer highlights ReScript and JavaScript.
57+
`Before` and `After` sections of one language render side by side with
58+
changed lines marked. Use `Before (rescript)` / `After (rescript)` for a
59+
formatter change and `Diagnostic (text)` for compiler output. Any other
60+
name is allowed and renders as prose or code.
61+
- **The final block is git trailers**: `Key: value` lines, continuation lines
62+
indented by one space, nothing after them. `git interpret-trailers --parse`
63+
must read every key. `Signed-off-by` (DCO) is required on every commit.
64+
- **Required keys**: `Area`, `Changelog`, `Output`, `Tests`. `Formatting`, `Formats`,
65+
`PPX` and `Editor` are required whenever the change touches the syntax
66+
library, the parsetree, the typed tree or Lambda. Omit the others when they
67+
do not apply.
68+
- **Wording** follows the writing rules: present facts, positive statements,
69+
claims as strong as their evidence, every number labelled by what produced
70+
it. A JavaScript `Before`/`After` pair says where it came from in a
71+
`Source:` paragraph (compiler run, or a snapshot file in the diff).
72+
- **Lists in trailers**: `Measured` separates items with `; `
73+
(outside parentheses); each item renders on its own line. `Output` and the
74+
other state trailers start with their state word (`unchanged`, `changed`,
75+
`none`), followed by the detail.
76+
77+
## What each field states
78+
79+
| Field | What the record states |
80+
| --- | --- |
81+
| `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. |
82+
| `Changelog` + `Changelog entry` | Whether the change is user-facing, and its category: `breaking` when existing code or tooling must adapt, `internal` when nothing user-visible changes. The entry is one short line ending in the PR link, identical to the fragment's bullet. |
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.
111+
- Each card checks the record against its diff: a changelog category with no
112+
new `changes/` fragment (or a `Changelog entry` that differs from the
113+
fragment's bullet), modified generated `.mjs`, `.cjs` and `.res.js` files under
114+
`Output: unchanged` (new ones from new tests are counted, not flagged), a
115+
magic number bumped in `compiler/ext/config.ml` that
116+
`Formats` does not name, a parsetree change with no ast-mapping fixture, a
117+
new `super_errors` fixture with no `ERROR_VARIANTS.md` change, a missing
118+
`Tests` trailer, `Tests: none` on a diff that changes tests. A failed
119+
check is shown on the card. The DCO app checks `Signed-off-by`.
120+
- The page is one self-contained HTML file: no script, no external data
121+
(fonts fall back to system faces), light and dark themes, phone width.
122+
`--fragment` omits the document skeleton for embedding.
123+
- A note on `refs/notes/records` replaces the commit message's record. Use it
124+
for commits that exist already (history, a squash merge) and for review
125+
outcomes added later; a new commit carries its record in its message.
126+
127+
## When to use
128+
129+
- Every commit an agent makes carries a record in its message.
130+
- An agent's report lists its commits and the rendered page; the records are
131+
the description of the work. A pull request description is a rendering of
132+
its range.
133+
- Before review or merge: render `master..<branch>` and hand over the page.

‎AGENTS.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ relevant guidance from each.
7575
need to.
7676
- Include appropriate tests with all changes
7777
- Build must pass before committing
78+
- Write each commit message as a record in the format of
79+
[`.claude/skills/records/SKILL.md`](.claude/skills/records/SKILL.md), and
80+
render review pages from records with `node scripts/commitRecords.js`
7881

7982
### Stacked pull requests
8083

‎Makefile‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,17 @@ format: | $(YARN_INSTALL_STAMP)
238238
checkformat: | $(YARN_INSTALL_STAMP)
239239
./scripts/format_check.sh
240240

241+
# Semantic diff: renders the commit records of SEMANTIC_DIFF_BASE..HEAD
242+
# (scripts/commitRecords.js) to _build/semantic-diff.html and opens it
243+
244+
SEMANTIC_DIFF_BASE ?= master
245+
246+
semantic-diff:
247+
mkdir -p _build
248+
node scripts/commitRecords.js --out _build/semantic-diff.html --title "$$(git branch --show-current)" $(SEMANTIC_DIFF_BASE)..HEAD
249+
@if command -v open >/dev/null; then open _build/semantic-diff.html; \
250+
elif command -v xdg-open >/dev/null; then xdg-open _build/semantic-diff.html; fi
251+
241252
# Coverage (bisect_ppx)
242253
#
243254
# Requires the pending `bisect_ppx` OCaml 5.5 compatibility patch in your switch:
@@ -371,4 +382,4 @@ clean: clean-lib clean-compiler clean-rewatch clean-coverage
371382

372383
.DEFAULT_GOAL := build
373384

374-
.PHONY: yarn-install build rewatch compiler lib artifacts bench test test-analysis test-reanalyze benchmark-reanalyze test-tools test-syntax test-syntax-roundtrip test-gentype test-rewatch test-all playground playground-compiler playground-test playground-cmijs playground-release format checkformat clean-rewatch clean-compiler clean-lib clean-gentype clean-tests clean
385+
.PHONY: yarn-install build rewatch compiler lib artifacts bench test test-analysis test-reanalyze benchmark-reanalyze test-tools test-syntax test-syntax-roundtrip test-gentype test-rewatch test-all playground playground-compiler playground-test playground-cmijs playground-release format checkformat semantic-diff clean-rewatch clean-compiler clean-lib clean-gentype clean-tests clean

‎changes/commit-records.internal.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add commit records, a commit message format that answers recurring review questions, and a semantic diff page rendered from them and linked on each pull request. https://github.com/rescript-lang/rescript/pull/8870

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
"changelog:preview": "node scripts/changelog.js preview",
6363
"changelog:release": "node scripts/changelog.js release",
6464
"changelog:open": "node scripts/changelog.js open",
65-
"test-changelog": "node --test scripts/changelog.test.js"
65+
"test-changelog": "node --test scripts/changelog.test.js",
66+
"test-commit-records": "node --test scripts/commitRecords.test.js"
6667
},
6768
"files": [
6869
"CHANGELOG.md",

0 commit comments

Comments
 (0)