Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/modwerk-pr-ready/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Follow `docs/DEVELOPER_WORKFLOW.md#make-it-mergeable`.
2. **Regenerate** generated files rather than resolving them by hand: `npm run modules:generate`, `npm run licenses:generate`, `npm run machines:generate`.
3. **Run** `npm run pr:ready` until it says Ready. For a registered author's update, use `npm run pr:ready -- --author <login>`.
- It also claims on the agent board what the branch adds (a new module, hook or table index, migration) and stops when someone else holds one. Never work around a claim: renumber, rename or ask its holder yourself. Signed out, it asks for `npm run board -- login` first. When it notes questions or replies in the developer's board inbox, read them (`npm run board -- inbox`), answer them yourself from what you can check, close your settled ones, and tell the developer what you said; only a decision about their own work goes to them first. When it offers a finding, post it yourself.
4. **Push** and open or update the pull request. A change outside a module is titled `Fix: …`, `Improvement: …` or `Docs: …`. Write the description in the template's shape: what changed, how you checked it, and a line that answers the guides question ("Guides: nothing" is fine). CI checks it.
4. **Push** and open or update the pull request. If it changes what runs on an instrument (a `.mwrm` package or `.elemod` base), open it as a draft (`gh pr create --draft`) and mark it ready only after the developer has tested that exact build on a unit; the description then names it on a line of its own ("Tested on a unit: base 8d1db124, MKII, what ran", or "Not tested on a unit: <why>"). Ready from pr:ready means the checks pass, not that it was tested. A change outside a module is titled `Fix: …`, `Improvement: …` or `Docs: …`. Write the description in the template's shape: what changed, how you checked it, and a line that answers the guides question ("Guides: nothing" is fine). CI checks it.
- Watch `gh pr checks <n> --watch` until green. For a red job, read `gh run view <id> --log-failed`.
- If `main` moves before the merge, start again at 1.
5. **Answer what pr:ready asks:** a guide edit for what you learned, or "nothing" in the pull request.
2 changes: 1 addition & 1 deletion .claude/skills/modwerk-pr-ready/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Follow `docs/DEVELOPER_WORKFLOW.md#make-it-mergeable`.
2. **Regenerate** generated files rather than resolving them by hand: `npm run modules:generate`, `npm run licenses:generate`, `npm run machines:generate`.
3. **Run** `npm run pr:ready` until it says Ready. For a registered author's update, use `npm run pr:ready -- --author <login>`.
- It also claims on the agent board what the branch adds (a new module, hook or table index, migration) and stops when someone else holds one. Never work around a claim: renumber, rename or ask its holder yourself. Signed out, it asks for `npm run board -- login` first. When it notes questions or replies in the developer's board inbox, read them (`npm run board -- inbox`), answer them yourself from what you can check, close your settled ones, and tell the developer what you said; only a decision about their own work goes to them first. When it offers a finding, post it yourself.
4. **Push** and open or update the pull request. A change outside a module is titled `Fix: …`, `Improvement: …` or `Docs: …`. Write the description in the template's shape: what changed, how you checked it, and a line that answers the guides question ("Guides: nothing" is fine). CI checks it.
4. **Push** and open or update the pull request. If it changes what runs on an instrument (a `.mwrm` package or `.elemod` base), open it as a draft (`gh pr create --draft`) and mark it ready only after the developer has tested that exact build on a unit; the description then names it on a line of its own ("Tested on a unit: base 8d1db124, MKII, what ran", or "Not tested on a unit: <why>"). Ready from pr:ready means the checks pass, not that it was tested. A change outside a module is titled `Fix: …`, `Improvement: …` or `Docs: …`. Write the description in the template's shape: what changed, how you checked it, and a line that answers the guides question ("Guides: nothing" is fine). CI checks it.
- Watch `gh pr checks <n> --watch` until green. For a red job, read `gh run view <id> --log-failed`.
- If `main` moves before the merge, start again at 1.
5. **Answer what pr:ready asks:** a guide edit for what you learned, or "nothing" in the pull request.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- **What was wrong or hard:**
- **What this changes:**
- **How I checked it:** (`npm run pr:ready` and anything else you ran)
- **Tested on a unit:** (a change to a built package or base: the exact build, the model and what ran; keep the pull request a draft until then, or write "Not tested on a unit:" and why)
- **What the guides lacked or got wrong, and where I fixed it:** ("nothing" is a fine answer)

**A module or module update:** describe the change in behaviour, module version(s), compatibility and source/media attribution. Then say what the guides lacked or got wrong while you built it and link the `Docs:` pull request that fixes it, or write "nothing"; the module release itself stays free of guide edits.
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/pr-flags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
name: Flag and describe PRs
# A fork cannot label its own PR, so the title carries the flag: "Fix: …", "Improvement: …" or "Docs: …".
# The flag job reads only the title (passed as data, never as script) and adds the matching existing label.
# The describe job runs main's scripts/pr-body.mjs on the description (passed as data): no PR code, no dependencies.
# The describe job runs main's scripts/pr-body.mjs on the description, the draft flag and the changed file names (all passed as data):
# no PR code, no dependencies. A ready PR that changes what runs on an instrument names the build that ran on a unit; a draft may still be in test.
on:
pull_request_target:
types: [opened, edited, reopened, synchronize]
types: [opened, edited, reopened, synchronize, ready_for_review, converted_to_draft]
branches: [main]
permissions:
pull-requests: write
Expand Down Expand Up @@ -36,6 +37,7 @@ jobs:
timeout-minutes: 2
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand All @@ -45,7 +47,14 @@ jobs:
scripts/pr-body.mjs
.github/pull_request_template.md
sparse-checkout-cone-mode: false
- name: Require a description that answers the guides question
- name: Require a description that answers the guides question, and names the build a ready instrument change ran on
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
PR_BODY: ${{ github.event.pull_request.body }}
run: node scripts/pr-body.mjs
PR_DRAFT: ${{ github.event.pull_request.draft }}
run: |
PR_FILES="$(gh api "repos/$REPOSITORY/pulls/$NUMBER/files" --paginate --jq '.[].filename')"
export PR_FILES
node scripts/pr-body.mjs
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Skills load on clone: Claude Code reads `.claude/skills/`, Codex the identical `

## Pull requests

- Work on a branch off current `main`; a push to `main` deploys, so never push to it. Put this session's work on the pull request you already have open, as further commits with an updated description; open a new one only when none is open, for each `/modwerk-contribute` change, and for a module release or new module, which ships alone. Push only once the developer says their testing is done, then push and `gh pr create` before you report the work as done. The owner merges and approves every module's first release; registered authors then release their own updates ([docs/MODULE_AUTHOR_UPDATES.md](docs/MODULE_AUTHOR_UPDATES.md)).
- Work on a branch off current `main`; a push to `main` deploys, so never push to it. Add this session's work to your open pull request with an updated description; open another only when none is open, for each `/modwerk-contribute` change, and for a module release or new module, which ships alone. Push once the developer says their testing is done, then `gh pr create` before you report the work as done; a built package or base opens as a draft until that exact build ran on a unit, named in the description. The owner merges and approves every module's first release; registered authors then release their own updates ([docs/MODULE_AUTHOR_UPDATES.md](docs/MODULE_AUTHOR_UPDATES.md)).
- Fold what you learn back into the context. First ask whether `module:doctor`, `pr:ready` or a test can catch it next time, and add that; write a sentence only for what no program can see, in the file a reader would open for that task: the matching guide, or this file. Correct a stale line rather than contradict it; keep it short, general and stock-free. A document in `docs/` and this file stay under 40 KB, so make room rather than append; history goes in a dated record ([where](docs/README.md)). Every pull request says what the guides lacked or got wrong and where you fixed it, and "nothing" is a fine answer ([Share what you learn](docs/DEVELOPER_WORKFLOW.md#share-what-you-learn)).
- A bug, fix or improvement outside the task at hand goes on the pull request you have open, with what it is and how you checked it in the description; with none open, in its own small `Fix: …`, `Improvement: …` or `Docs: …` pull request with one change, never in a module release. In a contributor's fork, offer it and open it with their OK; if you can't fix it, open an issue ([Fixes and improvements](docs/DEVELOPER_WORKFLOW.md#fixes-and-improvements)).
- A bug, fix or improvement outside the task goes on your open pull request, described with how you checked it; with none open, in its own small `Fix: …`, `Improvement: …` or `Docs: …` pull request with one change, never in a module release. In a contributor's fork, offer it and open it with their OK; if you can't fix it, open an issue ([Fixes and improvements](docs/DEVELOPER_WORKFLOW.md#fixes-and-improvements)).

## Site, machines and operations

Expand Down
1 change: 1 addition & 0 deletions changelog/2026-11-17-draft-until-tested.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Development: a pull request that changes what runs on an instrument (a built module package or base) now opens as a draft until its exact build has run on a unit. `npm run pr:ready` says so instead of "can merge", and CI refuses a ready one whose description does not name the build that ran ("Tested on a unit: …") or say plainly that it was not tested.
40 changes: 33 additions & 7 deletions scripts/pr-body.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// SPDX-License-Identifier: Elastic-2.0
// Copyright (c) 2026 Jannik Aßfalg (repeat98)
// Is the pull request described? Reviewers asked one module PR in nine to fill in its description, and half the merged PRs skipped the
// guides question AGENTS.md asks of every PR ("Fold what you learn back"). Reads only the description and the template: no PR code runs.
// guides question AGENTS.md asks of every PR ("Fold what you learn back"). And does a ready one that changes what runs on an instrument
// name the exact build that ran on a unit? A base went up ready to merge after only development twins had run (#1694, 17 November 2026).
// Reads only the description, the template, the draft flag and the changed file names: no PR code runs.
//
// PR_BODY="$(gh pr view <n> --json body --jq .body)" node scripts/pr-body.mjs
// node scripts/pr-body.mjs FILE.md # a description still in a file, before the pull request is open
// PR_BODY="$(gh pr view <n> --json body --jq .body)" PR_DRAFT=false PR_FILES="$(gh pr diff <n> --name-only)" node scripts/pr-body.mjs
// node scripts/pr-body.mjs FILE.md # a description still in a file, before the pull request is open (as a ready one, with
// # this branch's files against origin/main)
import { execFileSync } from 'node:child_process'
import { readFileSync } from 'node:fs'
import { pathToFileURL } from 'node:url'

Expand All @@ -25,20 +29,42 @@ function answersGuides(line, next) {
return /:\s*\S/.test(text) || ((isHeading(line) || open(line)) && !!next && !isHeading(next) && !open(next))
}

/** What the description still lacks; [] when it is described and answers the guides question. */
export function bodyProblems(body, template) {
// What reaches an instrument: a built module package or a base (.mwrm, .elemod). Sources alone change nothing on a unit, and CI rebuilds
// the packages from them, so a source change that matters always carries a changed package.
export const INSTRUMENT = /\.(?:mwrm|elemod)$/
/** The changed files that run on an instrument. */
export const instrumentFiles = files => (files ?? []).filter(file => INSTRUMENT.test(file))
// "Tested on a unit: base 8d1db124, MKII, …" names the build by a hash (a base identity or a package's sha256, 8 hex digits or more);
// "Not tested on a unit: <why>" says it plainly, for the owner to waive or not.
const TESTED = /^tested on (?:a|the|an?) (?:unit|instrument)\b[^:]*:.*\b[0-9a-f]{8,}\b/i
const UNTESTED = /^not tested on (?:a|the|an?) (?:unit|instrument)\b[^:]*:\s*\S/i
const plain = line => line.replaceAll('**', '').replaceAll('`', '').replace(/^(?:[-*]|#+)\s*/, '').trim()

/** What the description still lacks; [] when it is described, answers the guides question, and (ready, changing what runs on an
* instrument) names the build that ran on a unit. A draft may still be in test. */
export function bodyProblems(body, template, { draft = false, files = [] } = {}) {
const templateLines = new Set(template.split('\n').map(line => line.trim()).filter(Boolean))
const own = (body ?? '').split('\n').map(line => line.trim()).filter(line => line && !templateLines.has(line) && !NOT_OWN.test(line))
const problems = []
if (own.join(' ').length < OWN_TEXT) problems.push('Describe the change in your own words: what was wrong or hard, what this changes and how you checked it (the pull request template asks for each).')
const instrument = instrumentFiles(files)
if (!draft && instrument.length && !own.some(line => TESTED.test(plain(line)) || UNTESTED.test(plain(line)))) problems.push('This pull request changes what runs on an instrument (' + instrument.slice(0, 3).join(', ') + (instrument.length > 3 ? ` and ${instrument.length - 3} more` : '') + '). Keep it a draft until the exact build ran on a unit, then name it on a line of its own: "Tested on a unit: base 8d1db124 (or the package\'s sha256), MKII, what ran". If it cannot be tested, write "Not tested on a unit: <why>" for the owner to decide. `npm run pr:ready` saying Ready means the checks pass, not that it was tested.')
if (!own.some((line, index) => answersGuides(line, own[index + 1]))) problems.push('Say what the guides lacked or got wrong while you did this, and where you fixed it, on a line of its own, for example "Guides: nothing". It is how the next developer\'s agent learns what you did (AGENTS.md, Pull requests).')
return problems
}

if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const template = readFileSync(new URL('../.github/pull_request_template.md', import.meta.url), 'utf8')
const problems = bodyProblems(process.argv[2] ? readFileSync(process.argv[2], 'utf8') : process.env.PR_BODY, template)
const local = !!process.argv[2]
// In CI the workflow passes the draft flag and the file names; locally, a description in a file is checked as a ready pull request
// of this branch against origin/main.
let files = (process.env.PR_FILES ?? '').split('\n').map(file => file.trim()).filter(Boolean)
if (local && !process.env.PR_FILES) {
try { files = execFileSync('git', ['diff', '--name-only', 'origin/main...HEAD'], { encoding: 'utf8' }).split('\n').filter(Boolean) } catch { files = [] }
}
const problems = bodyProblems(local ? readFileSync(process.argv[2], 'utf8') : process.env.PR_BODY, template,
{ draft: process.env.PR_DRAFT === 'true', files })
for (const problem of problems) console.log('::error title=Pull request description::' + problem)
console.log(problems.length ? 'Edit the pull request description; this check runs again when you save it.' : 'The description says what changed and answers the guides question.')
console.log(problems.length ? 'Edit the pull request description (or keep it a draft); this check runs again when you save it or mark it ready.' : 'The description says what changed and answers the guides question.')
process.exitCode = problems.length ? 1 : 0
}
18 changes: 18 additions & 0 deletions scripts/pr-body.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@ it('accepts a description in the template\'s own shape and in free form', () =>
// A link to a guide is not an answer.
expect(bodyProblems('Follows docs/module-guides/effects.md for the new reverb; checked with pr:ready and on an MKII.', template)).toEqual([expect.stringMatching(/^Say what the guides lacked/)])
})

it('asks a ready pull request that changes what runs on an instrument to name the build that ran on a unit', () => {
const described = 'Octatrack base 0.7.8: a module that no track uses rests out of the per-frame hooks; checked with pr:ready.\n\nGuides: HOOKS.md.'
const base = ['src/engine/assets/octatrack-base.elemod', 'sdk/runtime/loader/loader.c']
const untested = expect.stringMatching(/^This pull request changes what runs on an instrument \(src\/engine\/assets\/octatrack-base\.elemod\)/)
// A draft may still be in test; a ready one says what ran, on which build.
expect(bodyProblems(described, template, { draft: true, files: base })).toEqual([])
expect(bodyProblems(described, template, { files: base })).toEqual([untested])
expect(bodyProblems(described + '\n\nTested on a unit: base 8d1db124, MKII, a full set and a power cycle.', template, { files: base })).toEqual([])
expect(bodyProblems(described + '\n\n- **Tested on a unit:** `8d1db124797e`, MKII', template, { files: base })).toEqual([])
// It must name the build: a hash of 8 hex digits or more.
expect(bodyProblems(described + '\n\nTested on a unit: yes, on my MKII.', template, { files: base })).toEqual([untested])
expect(bodyProblems(described + '\n\nNot tested on a unit: no unit at hand; the owner decides.', template, { files: base })).toEqual([])
expect(bodyProblems(described + '\n\nNot tested on a unit:', template, { files: base })).toEqual([untested])
// A package counts too; sources, docs and the site do not.
expect(bodyProblems(described, template, { files: ['public/octatrack-modules/repitch/0.2.1-experimental.mwrm'] })).toHaveLength(1)
expect(bodyProblems(described, template, { files: ['sdk/octatrack/modules/repitch/repitch.s', 'docs/MODULE_PERFORMANCE.md', 'src/App.tsx'] })).toEqual([])
})
Loading
Loading