3D engine that AI agents drive
Count a removed look hold as approval in the PR check (#885)
Nguyen Xuan Anb42dccb1e305
diff --git a/.github/workflows/pr-metadata.yml b/.github/workflows/pr-metadata.ymlindex be96692e..fa2976d4 100644--- a/.github/workflows/pr-metadata.yml+++ b/.github/workflows/pr-metadata.yml@@ -23,7 +23,8 @@ permissions:issues: writeconcurrency:- group: pr-metadata+ # One queue per pull request, so a run for one pull request never replaces the pending run of another.+ group: pr-metadata-${{ github.event.pull_request.number || 'sweep' }}cancel-in-progress: falsejobs:diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex fcf92f38..73a85ce4 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -93,7 +93,7 @@ Paste the table into the pull request. The bench runs through a Claude Code logi### Look changes-A change to shaders, lighting, materials, the default render or a post step changes how every scene looks. Add a before and an after picture to the pull request. A bot adds the label `hold:look-approval`. Only the owner removes it, and nothing with that label merges.+A change to shaders, lighting, materials, the default render or a post step changes how every scene looks. Add a before and an after picture to the pull request. A bot adds the label `hold:look-approval`. Only the owner removes it, and nothing with that label merges. Once the owner removes it, the check counts the look as approved and stops asking for pictures.### Who runs the GPU and person checksdiff --git a/scripts/pr-metadata-check.mjs b/scripts/pr-metadata-check.mjsindex 78b78068..e3dcaec4 100644--- a/scripts/pr-metadata-check.mjs+++ b/scripts/pr-metadata-check.mjs@@ -1,7 +1,9 @@// Checks the description and the files of a pull request against CONTRIBUTING.md. Pure: it reads no network and no disk,// so tests call it with plain objects. The `PR metadata` workflow (.github/workflows/pr-metadata.yml) runs it on the base branch.//-// Input: { pr: { body, title, author, authorAssociation, labels, milestone, draft }, files: [{ filename, additions, deletions }] }+// Input: { pr: { body, title, author, authorAssociation, labels, milestone, draft, lookApproved }, files: [{ filename, additions, deletions }] }+// lookApproved is true when hold:look-approval was added and the owner removed it later. The pictures were then+// reviewed, so the look change needs no picture in the description and no new hold label.// Output: { contributorFixes: [{ id, message, docsAnchor }], maintainerTodos: [string], addLabels: [string], removeLabels: [string] }//// A contributor fix is something the author can change. Labels and the milestone are the maintainer's job, so a gap there@@ -167,7 +169,7 @@ function contributorFixesFor(pr, files, light) {}const touchesLook = paths.some(isLookPath);- if (touchesLook && !imagePattern.test(body)) {+ if (touchesLook && !pr.lookApproved && !imagePattern.test(body)) {fixes.push(fix('look-without-image','This changes how a scene looks, so add a before and an after picture to the description.',@@ -184,7 +186,7 @@ function maintainerTodosFor(pr, files, contributorFixes) {if (!labels.some(label => ['bug', 'enhancement', 'documentation'].includes(label))) todos.push('Set a type label (bug, enhancement or documentation).');if (!pr.milestone) todos.push('Set a milestone.');const paths = files.map(file => normalizePath(file.filename));- if (paths.some(isLookPath)) todos.push('Look change: only the owner removes hold:look-approval after seeing the pictures.');+ if (!pr.lookApproved && paths.some(isLookPath)) todos.push('Look change: only the owner removes hold:look-approval after seeing the pictures.');const needsToolBench = paths.some(path => toolOrSkillPathPattern.test(path));if (needsToolBench && contributorFixes.length === 0 && benchOptOutPattern.test(pr.body ?? '')) {todos.push('Run the agent bench for this pull request (bench/agent-modeling).');@@ -204,7 +206,8 @@ export function checkPullRequest({ pr, files }) {if (classificationMissing && !labels.includes(NEEDS_TRIAGE_LABEL)) addLabels.push(NEEDS_TRIAGE_LABEL);if (!classificationMissing && labels.includes(NEEDS_TRIAGE_LABEL)) removeLabels.push(NEEDS_TRIAGE_LABEL);- if (files.some(file => isLookPath(file.filename)) && !labels.includes(LOOK_HOLD_LABEL)) addLabels.push(LOOK_HOLD_LABEL);+ const needsHold = !pr.lookApproved && files.some(file => isLookPath(file.filename));+ if (needsHold && !labels.includes(LOOK_HOLD_LABEL)) addLabels.push(LOOK_HOLD_LABEL);if (!isAutoCloseExempt(pr)) {if (contributorFixes.length > 0 && !labels.includes(NEEDS_AUTHOR_LABEL)) addLabels.push(NEEDS_AUTHOR_LABEL);diff --git a/scripts/pr-metadata-run.mjs b/scripts/pr-metadata-run.mjsindex 21799587..a188c078 100644--- a/scripts/pr-metadata-run.mjs+++ b/scripts/pr-metadata-run.mjs@@ -1,7 +1,7 @@// GitHub glue of the `PR metadata` workflow. It reads a pull request and its file list through the API, never checks out the// pull request's code, and runs the pure rules of pr-metadata-check.mjs and pr-metadata-flow.mjs on them.// `github` is the Octokit client that actions/github-script passes in. Tests pass a fake with the same few methods.-import { checkPullRequest, isAutoCloseExempt, LOOK_HOLD_LABEL } from './pr-metadata-check.mjs';+import { checkPullRequest, isAutoCloseExempt, isLookPath, LOOK_HOLD_LABEL } from './pr-metadata-check.mjs';import {CLOSE_MARKER,REMINDER_MARKER,@@ -30,10 +30,13 @@ function toCheckInput(pullRequest, files) {};}-// The owner may remove hold:look-approval. Add it only if it was never added, so a removal sticks.-async function labelWasEverAdded({ github, repo, number, label }) {+// Only the owner removes hold:look-approval, after seeing the pictures. A look change whose hold label was added and is gone+// now is approved: the removal sticks and no picture is asked for again.+async function lookWasApproved({ github, repo, number, input }) {+ const touchesLook = input.files.some(file => isLookPath(file.filename));+ if (!touchesLook || input.pr.labels.includes(LOOK_HOLD_LABEL)) return false;const events = await github.paginate(github.rest.issues.listEvents, { ...repo, issue_number: number, per_page: 100 });- return events.some(event => event.event === 'labeled' && event.label?.name === label);+ return events.some(event => event.event === 'labeled' && event.label?.name === LOOK_HOLD_LABEL);}export async function checkOnePullRequest({ github, repo, number, now, reopened, dryRun, log }) {@@ -41,6 +44,7 @@ export async function checkOnePullRequest({ github, repo, number, now, reopened,if (pullRequest.state !== 'open') return { skipped: 'closed' };const files = await github.paginate(github.rest.pulls.listFiles, { ...repo, pull_number: number, per_page: 100 });const input = toCheckInput(pullRequest, files);+ input.pr.lookApproved = await lookWasApproved({ github, repo, number, input });const result = checkPullRequest(input);const exempt = isAutoCloseExempt(input.pr);const comments = await github.paginate(github.rest.issues.listComments, { ...repo, issue_number: number, per_page: 100 });@@ -61,10 +65,7 @@ export async function checkOnePullRequest({ github, repo, number, now, reopened,if (!dryRun) await action();};- let addLabels = result.addLabels;- if (addLabels.includes(LOOK_HOLD_LABEL) && await labelWasEverAdded({ github, repo, number, label: LOOK_HOLD_LABEL })) {- addLabels = addLabels.filter(label => label !== LOOK_HOLD_LABEL);- }+ const addLabels = result.addLabels;if (addLabels.length > 0) {await act(`add labels ${addLabels.join(', ')}`, () => github.rest.issues.addLabels({ ...repo, issue_number: number, labels: addLabels }));}diff --git a/tests/pr-metadata-check.test.js b/tests/pr-metadata-check.test.jsindex 39976f7c..6d418534 100644--- a/tests/pr-metadata-check.test.js+++ b/tests/pr-metadata-check.test.js@@ -349,9 +349,21 @@ test('a dry run changes nothing and a hold label that was added before is not adfiles: [{ filename: 'src/lighting.js' }],events: [{ event: 'labeled', label: { name: 'hold:look-approval' } }],});- await checkOnePullRequest({ github: removedByOwner, repo: {}, number: 5, now: 0, reopened: false, dryRun: false, log() {} });+ const approved = await checkOnePullRequest({ github: removedByOwner, repo: {}, number: 5, now: 0, reopened: false, dryRun: false, log() {} });const added = removedByOwner.calls.filter(call => call.name === 'addLabels').flatMap(call => call.params.labels);assert.ok(!added.includes('hold:look-approval'));+ assert.ok(!approved.result.contributorFixes.some(item => item.id === 'look-without-image'));+ assert.ok(!approved.result.maintainerTodos.some(todo => todo.startsWith('Look change')));+});++test('a look change the owner approved by removing the hold label needs no picture', () => {+ const files = [file('src/lighting.js'), file('changes/12.md')];+ const approved = checkPullRequest({ pr: pullRequest({ lookApproved: true }), files });+ assert.deepEqual(approved.contributorFixes, []);+ assert.ok(!approved.addLabels.includes('hold:look-approval'));+ assert.ok(!approved.maintainerTodos.some(todo => todo.startsWith('Look change')));+ const waiting = checkPullRequest({ pr: pullRequest({ lookApproved: false }), files });+ assert.deepEqual(waiting.contributorFixes.map(item => item.id), ['look-without-image']);});test('the CI gate fails a shipped change without a note and a protected file edit', () => {diff --git a/tests/triage-bot-hardening.test.js b/tests/triage-bot-hardening.test.jsindex a1e26cb0..37597deb 100644--- a/tests/triage-bot-hardening.test.js+++ b/tests/triage-bot-hardening.test.js@@ -11,7 +11,8 @@ const decide = (overrides = {}, event = {}) =>decideTriage({ eventName: 'pull_request_target', action: 'opened', item: { ...outsider, ...overrides }, ...event });// Parsed instead of matched, so the test says which hosts and paths survive and not just which substring does.const linkedAddresses = text => (text.match(/https?:\/\/[^\s)]+/g) ?? []).map(address => new URL(address));-const workflow = readFileSync(new URL('../.github/workflows/claude-triage.yml', import.meta.url), 'utf8');+// A Windows checkout may have CRLF line ends. The patterns below match LF, as on CI.+const workflow = readFileSync(new URL('../.github/workflows/claude-triage.yml', import.meta.url), 'utf8').replace(/\r\n/g, '\n');test('a push or a reopen never starts another run', () => {for (const action of ['synchronize', 'reopened']) assert.equal(decide({}, { action }).run, false, action);diff --git a/tests/triage-bot.test.js b/tests/triage-bot.test.jsindex 649f8d39..6ea41b5e 100644--- a/tests/triage-bot.test.js+++ b/tests/triage-bot.test.js@@ -83,7 +83,8 @@ test('the sticky comment is found only when the Actions bot wrote it', () => {});test('the workflow keeps Claude read-only and runs from the base branch', () => {- const workflow = readFileSync(new URL('../.github/workflows/claude-triage.yml', import.meta.url), 'utf8');+ // A Windows checkout may have CRLF line ends. The patterns below match LF, as on CI.+ const workflow = readFileSync(new URL('../.github/workflows/claude-triage.yml', import.meta.url), 'utf8').replace(/\r\n/g, '\n');assert.match(workflow, /permissions:\n\s+contents: read\n\s+issues: write\n\s+pull-requests: write\n/);assert.doesNotMatch(workflow, /contents: write|actions: write|id-token|workflows: write/);assert.match(workflow, /anthropics\/claude-code-action@[0-9a-f]{40} # v1\.\d+\.\d+/);