From 63fdc59471cc78adbbacbd4fcd2d78643e0eb61b Mon Sep 17 00:00:00 2001 From: Michael Duncan McArthur Date: Sat, 5 Dec 2026 16:18:19 -0500 Subject: [PATCH 1/5] claude-review: lockfile, generated and patch-bump diffs get the Sonnet reviewer in Opus repositories (row 1.252) Replaces PR 376. Docs are not a class: a deny-list over markdown leaked rule files four times, so a docs diff keeps the repository's normal reviewer. A package.json bump is read from git: same section, range prefix, major and minor. Co-Authored-By: Claude Sonnet 5.5 AI-Use: L3 made undo unread (Claude Sonnet 5.5) AI-Use-Standing: https://github.com/gorfednet/ai-use-levels/blob/main/docs/delegation.md 2026-11-18 --- .github/workflows/claude-review.yml | 74 ++++++++++++++++++++++++++ test/claudeReview.test.mjs | 81 ++++++++++++++++++++++++++++- 2 files changed, 153 insertions(+), 2 deletions(-) diff --git a/.github/workflows/claude-review.yml b/.github/workflows/claude-review.yml index 9ebdfe20..2cd643d7 100644 --- a/.github/workflows/claude-review.yml +++ b/.github/workflows/claude-review.yml @@ -250,14 +250,84 @@ jobs: # One place for the model. The small sites get Sonnet; 4thcltr.com, heuristics, papers, # gorfed.net, bindercurve.com, assess and ops keep Opus under "auto". Matching is by # repository name, case-insensitive (ACID2REAPER's remote is spelled in capitals). + # A diff whose every changed path is a mechanical R0 class (lockfiles, generated files, a + # patch bump in package.json) gets Sonnet in an Opus repository too. Docs are not a class: + # a deny-list over *.md leaked rule files four times, so a docs diff keeps the repository's + # normal reviewer. Fails closed: a missing or empty file list, a rename, a quoted path or any + # path outside those classes keeps Opus. - name: Pick the model if: steps.dup.outputs.skip != 'true' id: model env: REPO: ${{ github.repository }} REQUESTED: ${{ inputs.model }} + REVIEW_INPUT: review-input + BASE: ${{ steps.pr.outputs.base }} + HEAD: ${{ steps.pr.outputs.head }} run: | set -euo pipefail + # 0 only when every changed path is R0. Matching is on the lowercased path, as ship-bot's + # touchesControlPlane does (a case-insensitive disk lands Docs/x on docs/x). + r0_only() { + local list="${REVIEW_INPUT:-review-input}/files.txt" added deleted path lower found=0 + [[ -s "$list" ]] || return 1 + while IFS=$'\t' read -r added deleted path; do + [[ -n "$path" ]] || return 1 + found=1 + lower="$(printf '%s' "$path" | tr '[:upper:]' '[:lower:]')" + case "$lower" in + *'=>'*|\"*) return 1 ;; + # Control plane and rule paths (ship-bot's touchesControlPlane): never R0, whatever the file type. + .claude/*|.github/*|control/*|scripts/*|ship-bot/*|janitor/*|capacity/*|verification-kit/*|*/verification-kit/*|templates/*|docs/claude-home/*) return 1 ;; + package-lock.json|*/package-lock.json|pnpm-lock.yaml|*/pnpm-lock.yaml|yarn.lock|*/yarn.lock|bun.lock|*/bun.lock|bun.lockb|*/bun.lockb|cargo.lock|*/cargo.lock|poetry.lock|*/poetry.lock|gemfile.lock|*/gemfile.lock) ;; + *.generated.*|*/generated/*) ;; + package.json|*/package.json) patch_bump_only "$path" || return 1 ;; + *) return 1 ;; + esac + done < "$list" + [[ "$found" == 1 ]] + } + # 0 only when this package.json changed nothing but dependency versions that stay within + # the same range prefix, major and minor, inside the same section (dependencies, + # devDependencies, peerDependencies, optionalDependencies, overrides, resolutions). Read + # from git, so a line's section is known. Fails closed on any error. + patch_bump_only() { + [[ -n "${BASE:-}" && -n "${HEAD:-}" ]] || return 1 + local mb + mb="$(git merge-base "$BASE" "$HEAD")" || return 1 + node - "$mb" "$HEAD" "$1" <<'JS' || return 1 + import { execFileSync } from 'node:child_process' + import { isDeepStrictEqual } from 'node:util' + const [, , base, head, path] = process.argv + const read = (rev) => JSON.parse(execFileSync('git', ['show', `${rev}:${path}`], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 })) + const before = read(base) + const after = read(head) + const SECTIONS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies', 'overrides', 'resolutions'] + const VERSION = /^([\^~]?)(\d+)\.(\d+)\.\d+$/ + const sameBump = (x, y) => { + if (x === y) return true + if (typeof x !== 'string' || typeof y !== 'string') return false + const a = VERSION.exec(x) + const b = VERSION.exec(y) + return Boolean(a && b && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]) + } + const ok = (() => { + const keys = new Set([...Object.keys(before), ...Object.keys(after)]) + for (const key of keys) { + if (!SECTIONS.includes(key)) { + if (!isDeepStrictEqual(before[key], after[key])) return false + continue + } + const x = before[key] ?? {} + const y = after[key] ?? {} + if (!isDeepStrictEqual(Object.keys(x).sort(), Object.keys(y).sort())) return false + for (const name of Object.keys(x)) if (!sameBump(x[name], y[name])) return false + } + return true + })() + process.exit(ok ? 0 : 1) + JS + } model="${REQUESTED:-auto}" if [[ "$model" == auto ]]; then model=claude-opus-5-5 @@ -265,6 +335,10 @@ jobs: case "$repo" in promptboi.com|denseware.com|ssatcy.com|gorfmusic.com|subrythm.com|blackpixelrecords.com|anal0g.org|rowanmcarthur.com|acid2reaper) model=claude-sonnet-5-5 ;; esac + if [[ "$model" == claude-opus-5-5 ]] && r0_only; then + model=claude-sonnet-5-5 + echo "every changed path is R0: Sonnet reads it" + fi fi echo "model=${model}" >> "$GITHUB_OUTPUT" echo "reviewing ${REPO} with ${model}" diff --git a/test/claudeReview.test.mjs b/test/claudeReview.test.mjs index dc6ed254..66137450 100644 --- a/test/claudeReview.test.mjs +++ b/test/claudeReview.test.mjs @@ -663,11 +663,33 @@ describe('claude-review model choice', () => { const script = /run: \|\n([\s\S]*)$/.exec(pick)[1].replace(/^ {10}/gm, '') /** The model the step selects for a repository and requested model. */ - function choose(repo, requested) { + function choose(repo, requested, input) { const dir = mkdtempSync(join(tmpdir(), 'pick-model-')) const out = join(dir, 'out') writeFileSync(out, '') - execFileSync('bash', ['-c', script], { env: { PATH: process.env.PATH, REPO: repo, REQUESTED: requested, GITHUB_OUTPUT: out } }) + let cwd = dir + const env = { PATH: process.env.PATH, REPO: repo, REQUESTED: requested, GITHUB_OUTPUT: out } + if (input) { + mkdirSync(join(dir, 'in')) + if (input.files !== undefined) writeFileSync(join(dir, 'in', 'files.txt'), input.files.map((p) => `1\t0\t${p}`).join('\n') + (input.files.length ? '\n' : '')) + if (input.diff !== undefined) writeFileSync(join(dir, 'in', 'full.diff'), input.diff) + env.REVIEW_INPUT = join(dir, 'in') + } + if (input?.pkg) { + const repoDir = join(dir, 'repo') + mkdirSync(repoDir) + const git = (...args) => execFileSync('git', ['-c', 'user.name=t', '-c', 'user.email=t@t', '-c', 'commit.gpgsign=false', ...args], { cwd: repoDir, encoding: 'utf8' }).trim() + git('init', '-q', '-b', 'main') + writeFileSync(join(repoDir, 'package.json'), JSON.stringify(input.pkg.before, null, 2) + '\n') + git('add', '-A') + git('commit', '-q', '-m', 'base') + env.BASE = git('rev-parse', 'HEAD') + writeFileSync(join(repoDir, 'package.json'), JSON.stringify(input.pkg.after, null, 2) + '\n') + git('commit', '-q', '-am', 'head') + env.HEAD = git('rev-parse', 'HEAD') + cwd = repoDir + } + execFileSync('bash', ['-c', script], { env, cwd }) const model = /^model=(.*)$/m.exec(readFileSync(out, 'utf8'))[1] rmSync(dir, { recursive: true, force: true }) return model @@ -702,4 +724,59 @@ describe('claude-review model choice', () => { assert.equal(choose('gorfednet/promptboi.com', ''), 'claude-sonnet-5-5') assert.equal(choose('gorfednet/assess', ''), 'claude-opus-5-5') }) + + describe('R0-only diffs', () => { + const opus = 'claude-opus-5-5' + const sonnet = 'claude-sonnet-5-5' + const pick = (files, pkg) => choose('gorfednet/ops', 'auto', { files, pkg }) + const pkgOf = (deps, extra = {}) => ({ name: 'x', version: '1.0.0', ...extra, ...deps }) + const dep = (v, section = 'dependencies') => ({ [section]: { 'left-pad': v, other: '^2.0.0' } }) + + it('picks Sonnet for lockfiles and generated files in an Opus repository', () => { + assert.equal(pick(['package-lock.json', 'pnpm-lock.yaml', 'src/x.generated.ts', 'a/generated/y.ts']), sonnet) + }) + it('keeps Opus for a lockfile or generated file under a control-plane path', () => { + for (const p of ['scripts/x.generated.mjs', 'ship-bot/package-lock.json', 'control/generated/a.json', '.github/x.generated.yml', 'templates/yarn.lock']) assert.equal(pick([p]), opus, p) + }) + it('picks Sonnet for a patch bump in package.json and its lockfile', () => { + assert.equal(pick(['package.json', 'package-lock.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^1.2.9')) }), sonnet) + }) + it('keeps Opus for a minor or major bump', () => { + assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^1.3.0')) }), opus) + assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^2.0.0')) }), opus) + }) + it('keeps Opus when only the range prefix changes (not a patch bump)', () => { + assert.equal(pick(['package.json'], { before: pkgOf(dep('~1.2.3')), after: pkgOf(dep('^1.2.3')) }), opus) + assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^1.2.4')) }), sonnet) + }) + it('keeps Opus when a dependency moves between sections', () => { + const before = pkgOf({ dependencies: { esbuild: '^0.25.1' }, devDependencies: {} }) + const after = pkgOf({ dependencies: {}, devDependencies: { esbuild: '^0.25.2' } }) + assert.equal(pick(['package.json'], { before, after }), opus) + for (const [a, b] of [['dependencies', 'peerDependencies'], ['devDependencies', 'optionalDependencies'], ['dependencies', 'overrides'], ['dependencies', 'resolutions']]) { + assert.equal(pick(['package.json'], { before: pkgOf({ [a]: { x: '1.0.0' }, [b]: {} }), after: pkgOf({ [a]: {}, [b]: { x: '1.0.1' } }) }), opus, `${a} to ${b}`) + } + }) + it('keeps Opus for a package.json edit that is not a version bump', () => { + assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3'), { scripts: { a: 'x' } }), after: pkgOf(dep('^1.2.4'), { scripts: { a: 'y' } }) }), opus) + assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^1.2.4'), { version: '1.0.1' }) }), opus) + }) + it('keeps Opus for a mixed list (code beside a lockfile)', () => { + assert.equal(pick(['package-lock.json', 'src/app.ts']), opus) + assert.equal(pick(['package-lock.json', '.github/workflows/ci.yml']), opus) + }) + it('keeps Opus for every markdown file: docs are not an R0 class', () => { + for (const p of ['REVIEW.md', 'CLAUDE.md', 'control/claude-home/rules/x.md', '.claude/agents/a.md', 'README.md', 'ship-bot/README.md', 'docs/verification-rules.md', 'docs/retired-checks.md', 'docs/content-guidelines.md', 'templates/REVIEW.site-footer.md', 'templates/CLAUDE.snippet.md', 'scripts/local-llm/out.md', 'janitor/PROMPT.md', 'janitor/SKILL.md', 'skills/x/SKILL.md', 'docs/skills/a.md', 'a/agents/b.md', 'x/rules/y.md', 'Docs/Verification-Rules.md', 'MEMORY.md', 'ship-bot/lib/notes.md', 'docs/programme-template.md', 'docs/a.md', 'docs/notes/README.md', 'hosts/x/README.md', 'infra/README.md']) assert.equal(pick([p]), opus, p) + }) + it('fails closed: an empty, missing or unreadable list keeps Opus', () => { + assert.equal(pick([]), opus) + assert.equal(choose('gorfednet/ops', 'auto', {}), opus) + assert.equal(choose('gorfednet/ops', 'auto'), opus) + assert.equal(pick(['docs/{a => b}.md']), opus) + assert.equal(pick(['"docs/odd\\303\\251.md"']), opus) + }) + it('never overrides an explicit model', () => { + assert.equal(choose('gorfednet/ops', 'claude-opus-5-5', { files: ['package-lock.json'] }), opus) + }) + }) }) From 02bad7da7aabc6ffce81154c899c6777dda5d5ad Mon Sep 17 00:00:00 2001 From: Michael Duncan McArthur Date: Sat, 5 Dec 2026 16:21:57 -0500 Subject: [PATCH 2/5] claude-review: R0 never applies to ship-bot's control-plane paths, per repository (row 1.252) The workflow carries drafts.mjs's CONTROL_PLANE_PATHS, BASENAMES and the per-repository extras (ops hosts/, infra/, inventory-patches/, ship-bot patches; .github scripts/, templates/, fleet.json, docs/claude-home/). A drift test fails when drafts.mjs gains an entry the workflow lacks. Co-Authored-By: Claude Sonnet 5.5 AI-Use: L3 made undo unread (Claude Sonnet 5.5) AI-Use-Standing: https://github.com/gorfednet/ai-use-levels/blob/main/docs/delegation.md 2026-11-18 --- .github/workflows/claude-review.yml | 39 +++++++++++++++++++++---- test/claudeReview.test.mjs | 44 ++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/.github/workflows/claude-review.yml b/.github/workflows/claude-review.yml index 2cd643d7..04947d07 100644 --- a/.github/workflows/claude-review.yml +++ b/.github/workflows/claude-review.yml @@ -266,6 +266,36 @@ jobs: HEAD: ${{ steps.pr.outputs.head }} run: | set -euo pipefail + # The lists of ship-bot/lib/drafts.mjs: CONTROL_PLANE_PATHS, CONTROL_PLANE_BASENAMES and + # REPO_EXTRA. test/claudeReview.test.mjs fails when they drift apart. + cp_paths=(.github/ .claude/ ship-bot/ scripts/gates/ scripts/lib/ scripts/review-status.mjs janitor/ capacity/ verification-kit/) + cp_basenames=(review.md claude.md agents.md skill.md canaries.json) + case "$(printf '%s' "$REPO" | tr '[:upper:]' '[:lower:]')" in + gorfednet/.github) cp_paths+=(scripts/ fleet.json templates/ docs/claude-home/) ;; + gorfednet/ops) cp_paths+=(control/claude-home/ control/ship-bot-patches/ hosts/ infra/ scripts/ inventory-patches/ credentials.json rotations.json crawler-policy.json cta-sites.json) ;; + esac + # 0 when the lowercased path is control plane. + control_plane() { + local p="${1#./}" x + for x in "${cp_paths[@]}"; do + if [[ "$x" == */ ]]; then + [[ "$p" == "$x"* || "$p" == "${x%/}" ]] && return 0 + else + [[ "$p" == "$x" ]] && return 0 + fi + done + for x in "${cp_basenames[@]}"; do [[ "${p##*/}" == "$x" ]] && return 0; done + return 1 + } + # 0 when the path is a lockfile, a generated file or a patch-bumped package.json. + r0_class() { + case "$1" in + package-lock.json|*/package-lock.json|pnpm-lock.yaml|*/pnpm-lock.yaml|yarn.lock|*/yarn.lock|bun.lock|*/bun.lock|bun.lockb|*/bun.lockb|cargo.lock|*/cargo.lock|poetry.lock|*/poetry.lock|gemfile.lock|*/gemfile.lock) return 0 ;; + *.generated.*|*/generated/*) return 0 ;; + package.json|*/package.json) patch_bump_only "$2" ;; + *) return 1 ;; + esac + } # 0 only when every changed path is R0. Matching is on the lowercased path, as ship-bot's # touchesControlPlane does (a case-insensitive disk lands Docs/x on docs/x). r0_only() { @@ -277,12 +307,9 @@ jobs: lower="$(printf '%s' "$path" | tr '[:upper:]' '[:lower:]')" case "$lower" in *'=>'*|\"*) return 1 ;; - # Control plane and rule paths (ship-bot's touchesControlPlane): never R0, whatever the file type. - .claude/*|.github/*|control/*|scripts/*|ship-bot/*|janitor/*|capacity/*|verification-kit/*|*/verification-kit/*|templates/*|docs/claude-home/*) return 1 ;; - package-lock.json|*/package-lock.json|pnpm-lock.yaml|*/pnpm-lock.yaml|yarn.lock|*/yarn.lock|bun.lock|*/bun.lock|bun.lockb|*/bun.lockb|cargo.lock|*/cargo.lock|poetry.lock|*/poetry.lock|gemfile.lock|*/gemfile.lock) ;; - *.generated.*|*/generated/*) ;; - package.json|*/package.json) patch_bump_only "$path" || return 1 ;; - *) return 1 ;; + # Control plane (ship-bot's touchesControlPlane, ship-bot/lib/drafts.mjs): never R0. + *) control_plane "$lower" && return 1 + r0_class "$lower" "$path" || return 1 ;; esac done < "$list" [[ "$found" == 1 ]] diff --git a/test/claudeReview.test.mjs b/test/claudeReview.test.mjs index 66137450..6e0500f0 100644 --- a/test/claudeReview.test.mjs +++ b/test/claudeReview.test.mjs @@ -17,6 +17,7 @@ import { tmpdir } from 'node:os' import { dirname, join } from 'node:path' import { after, describe, it } from 'node:test' import { buildReviewInput } from '../.github/actions/review-input/review-input.mjs' +import { CONTROL_PLANE_BASENAMES, CONTROL_PLANE_PATHS, touchesControlPlane } from '../ship-bot/lib/drafts.mjs' import { claudeReviewVerdict, REVIEW_BOT_LOGIN } from '../scripts/lib/reviewVerdict.mjs' const workflow = readFileSync('.github/workflows/claude-review.yml', 'utf8') @@ -736,7 +737,7 @@ describe('claude-review model choice', () => { assert.equal(pick(['package-lock.json', 'pnpm-lock.yaml', 'src/x.generated.ts', 'a/generated/y.ts']), sonnet) }) it('keeps Opus for a lockfile or generated file under a control-plane path', () => { - for (const p of ['scripts/x.generated.mjs', 'ship-bot/package-lock.json', 'control/generated/a.json', '.github/x.generated.yml', 'templates/yarn.lock']) assert.equal(pick([p]), opus, p) + for (const p of ['scripts/x.generated.mjs', 'ship-bot/package-lock.json', 'control/claude-home/generated/a.json', '.github/x.generated.yml']) assert.equal(pick([p]), opus, p) }) it('picks Sonnet for a patch bump in package.json and its lockfile', () => { assert.equal(pick(['package.json', 'package-lock.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^1.2.9')) }), sonnet) @@ -761,6 +762,47 @@ describe('claude-review model choice', () => { assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3'), { scripts: { a: 'x' } }), after: pkgOf(dep('^1.2.4'), { scripts: { a: 'y' } }) }), opus) assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^1.2.4'), { version: '1.0.1' }) }), opus) }) + const REPO_EXTRA = (() => { + const source = readFileSync('ship-bot/lib/drafts.mjs', 'utf8') + const block = /const REPO_EXTRA = \{([\s\S]*?)\n\}/.exec(source)[1] + const out = {} + for (const m of block.matchAll(/'(gorfednet\/[^']+)': \[([^\]]*)\]/g)) out[m[1]] = [...m[2].matchAll(/'([^']+)'/g)].map((x) => x[1]) + return out + })() + /** A lockfile or generated file inside each control-plane entry (the entry itself when it is a file). */ + const probes = (entry) => (entry.endsWith('/') ? [`${entry}package-lock.json`, `${entry}generated/x.json`] : [entry]) + + it('keeps Opus for every control-plane path ship-bot knows, in the repository it applies to', () => { + assert.deepEqual(Object.keys(REPO_EXTRA).sort(), ['gorfednet/.github', 'gorfednet/ops']) + for (const repo of ['gorfednet/assess', ...Object.keys(REPO_EXTRA)]) { + for (const entry of [...CONTROL_PLANE_PATHS, ...(REPO_EXTRA[repo] ?? [])]) { + for (const path of probes(entry)) { + assert.equal(touchesControlPlane(path, repo), true, `${repo} ${path}`) + assert.equal(choose(repo, 'auto', { files: [path] }), opus, `${repo} ${path}`) + } + } + } + }) + it('names each ops and .github extra by path, with a test per path', () => { + for (const [path, repo] of [['infra/generated/nginx.conf', 'ops'], ['hosts/web/package-lock.json', 'ops'], ['inventory-patches/generated/x.json', 'ops'], ['control/ship-bot-patches/generated/a.json', 'ops'], ['scripts/package-lock.json', 'ops'], ['templates/yarn.lock', '.github'], ['docs/claude-home/generated/a.json', '.github'], ['scripts/x.generated.mjs', '.github']]) { + assert.equal(choose(`gorfednet/${repo}`, 'auto', { files: [path] }), opus, `${repo} ${path}`) + } + }) + it('lets a lockfile through where ship-bot does not call the path control plane', () => { + assert.equal(choose('gorfednet/assess', 'auto', { files: ['scripts/package-lock.json', 'hosts/x/package-lock.json'] }), sonnet) + assert.equal(choose('gorfednet/ops', 'auto', { files: ['apps/web/package-lock.json'] }), sonnet) + }) + it("carries ship-bot's lists exactly: drift in drafts.mjs fails here", () => { + const lists = /cp_paths=\(([^)]*)\)\n\s+cp_basenames=\(([^)]*)\)/.exec(workflow) + const words = (text) => text.trim().split(/\s+/).sort() + assert.deepEqual(words(lists[1]), [...CONTROL_PLANE_PATHS].sort()) + assert.deepEqual(words(lists[2]), CONTROL_PLANE_BASENAMES.map((b) => b.toLowerCase()).sort()) + const extras = /case "\$\(printf[^\n]*\n([\s\S]*?)\n\s+esac/.exec(workflow)[1] + for (const [repo, entries] of Object.entries(REPO_EXTRA)) { + const line = extras.split('\n').find((l) => l.includes(repo + ')')) + assert.deepEqual(words(/\+=\(([^)]*)\)/.exec(line)[1]), [...entries].sort(), repo) + } + }) it('keeps Opus for a mixed list (code beside a lockfile)', () => { assert.equal(pick(['package-lock.json', 'src/app.ts']), opus) assert.equal(pick(['package-lock.json', '.github/workflows/ci.yml']), opus) From 1d7b29483eeee7db5ebb0d3b22abc42f71285cf2 Mon Sep 17 00:00:00 2001 From: Michael Duncan McArthur Date: Sat, 5 Dec 2026 16:38:30 -0500 Subject: [PATCH 3/5] claude-review tests: the rename and quoted-path cases fail without the guard (row 1.252) Co-Authored-By: Claude Sonnet 5.5 AI-Use: L3 made undo unread (Claude Sonnet 5.5) AI-Use-Standing: https://github.com/gorfednet/ai-use-levels/blob/main/docs/delegation.md 2026-11-18 --- test/claudeReview.test.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/claudeReview.test.mjs b/test/claudeReview.test.mjs index 6e0500f0..9d03e6a6 100644 --- a/test/claudeReview.test.mjs +++ b/test/claudeReview.test.mjs @@ -814,8 +814,10 @@ describe('claude-review model choice', () => { assert.equal(pick([]), opus) assert.equal(choose('gorfednet/ops', 'auto', {}), opus) assert.equal(choose('gorfednet/ops', 'auto'), opus) - assert.equal(pick(['docs/{a => b}.md']), opus) - assert.equal(pick(['"docs/odd\\303\\251.md"']), opus) + // Only the guard stops these: each matches */generated/* and no control-plane prefix sees through the brace or the quote. + assert.equal(pick(['{.github/workflows => x}/generated/ci.yml']), opus) + assert.equal(pick(['"x/generated/odd\\303\\251.json"']), opus) + assert.equal(pick(['x/generated/ok.json']), sonnet) }) it('never overrides an explicit model', () => { assert.equal(choose('gorfednet/ops', 'claude-opus-5-5', { files: ['package-lock.json'] }), opus) From 8fee44ccd161aea02861ddf88d696b02e2dfee43 Mon Sep 17 00:00:00 2001 From: Michael Duncan McArthur Date: Sat, 5 Dec 2026 17:08:22 -0500 Subject: [PATCH 4/5] claude-review: test the control-plane basename check; the model input names the R0 exception (row 1.252) Co-Authored-By: Claude Sonnet 5.5 AI-Use: L3 made undo unread (Claude Sonnet 5.5) AI-Use-Standing: https://github.com/gorfednet/ai-use-levels/blob/main/docs/delegation.md 2026-11-18 --- .github/workflows/claude-review.yml | 4 +++- test/claudeReview.test.mjs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude-review.yml b/.github/workflows/claude-review.yml index 04947d07..8d18500b 100644 --- a/.github/workflows/claude-review.yml +++ b/.github/workflows/claude-review.yml @@ -65,7 +65,9 @@ on: description: >- Claude model that reviews. "auto" (the default) means Opus, except that the "Pick the model" step reviews the small sites (the repositories it lists) with Sonnet, so one - place sets the model for 19 callers (owner, 2026-10-30, token efficiency). Any other + place sets the model for 19 callers (owner, 2026-10-30, token efficiency). A diff of + only lockfiles, generated files or package.json patch bumps (outside ship-bot's + control-plane paths) gets Sonnet in any repository. Any other value, claude-opus-5-5 included, is used exactly as passed. required: false type: string diff --git a/test/claudeReview.test.mjs b/test/claudeReview.test.mjs index 9d03e6a6..98477751 100644 --- a/test/claudeReview.test.mjs +++ b/test/claudeReview.test.mjs @@ -803,6 +803,10 @@ describe('claude-review model choice', () => { assert.deepEqual(words(/\+=\(([^)]*)\)/.exec(line)[1]), [...entries].sort(), repo) } }) + it('keeps Opus for a rule basename at any depth, even inside a generated directory', () => { + for (const p of ['docs/generated/CLAUDE.md', 'x/generated/canaries.json', 'a/generated/REVIEW.md', 'a/generated/SKILL.md', 'a/generated/AGENTS.md']) assert.equal(pick([p]), opus, p) + assert.equal(pick(['x/generated/notes.json']), sonnet) + }) it('keeps Opus for a mixed list (code beside a lockfile)', () => { assert.equal(pick(['package-lock.json', 'src/app.ts']), opus) assert.equal(pick(['package-lock.json', '.github/workflows/ci.yml']), opus) From c19f14bdaf9e9549c83e8d4bc18936d084c791a6 Mon Sep 17 00:00:00 2001 From: Michael Duncan McArthur Date: Sat, 5 Dec 2026 17:26:31 -0500 Subject: [PATCH 5/5] claude-review: no markdown in a generated path, a patch must rise, last path kept (row 1.252) Fable read of 8fee44cc: a markdown arm ahead of the generated arm, --input-type=module, a list with no final newline keeps its last path, the patch must rise and 0.0.x is no patch bump, and *.generated.* matches the file name only. Co-Authored-By: Claude Sonnet 5.5 AI-Use: L3 made undo unread (Claude Sonnet 5.5) AI-Use-Standing: https://github.com/gorfednet/ai-use-levels/blob/main/docs/delegation.md 2026-11-18 --- .github/workflows/claude-review.yml | 20 +++++++++++++------- test/claudeReview.test.mjs | 21 +++++++++++++++++++-- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/workflows/claude-review.yml b/.github/workflows/claude-review.yml index 8d18500b..b4b242cd 100644 --- a/.github/workflows/claude-review.yml +++ b/.github/workflows/claude-review.yml @@ -292,18 +292,23 @@ jobs: # 0 when the path is a lockfile, a generated file or a patch-bumped package.json. r0_class() { case "$1" in + *.md|*.mdx|*.markdown) return 1 ;; package-lock.json|*/package-lock.json|pnpm-lock.yaml|*/pnpm-lock.yaml|yarn.lock|*/yarn.lock|bun.lock|*/bun.lock|bun.lockb|*/bun.lockb|cargo.lock|*/cargo.lock|poetry.lock|*/poetry.lock|gemfile.lock|*/gemfile.lock) return 0 ;; - *.generated.*|*/generated/*) return 0 ;; - package.json|*/package.json) patch_bump_only "$2" ;; - *) return 1 ;; + */generated/*) return 0 ;; + package.json|*/package.json) patch_bump_only "$2"; return ;; esac + # *.generated.* on the file name only: a pattern over the whole path would cross slashes. + case "${1##*/}" in + *.generated.*) return 0 ;; + esac + return 1 } # 0 only when every changed path is R0. Matching is on the lowercased path, as ship-bot's # touchesControlPlane does (a case-insensitive disk lands Docs/x on docs/x). r0_only() { local list="${REVIEW_INPUT:-review-input}/files.txt" added deleted path lower found=0 [[ -s "$list" ]] || return 1 - while IFS=$'\t' read -r added deleted path; do + while IFS=$'\t' read -r added deleted path || [[ -n "$path" ]]; do [[ -n "$path" ]] || return 1 found=1 lower="$(printf '%s' "$path" | tr '[:upper:]' '[:lower:]')" @@ -324,7 +329,7 @@ jobs: [[ -n "${BASE:-}" && -n "${HEAD:-}" ]] || return 1 local mb mb="$(git merge-base "$BASE" "$HEAD")" || return 1 - node - "$mb" "$HEAD" "$1" <<'JS' || return 1 + node --input-type=module - "$mb" "$HEAD" "$1" <<'JS' || return 1 import { execFileSync } from 'node:child_process' import { isDeepStrictEqual } from 'node:util' const [, , base, head, path] = process.argv @@ -332,13 +337,14 @@ jobs: const before = read(base) const after = read(head) const SECTIONS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies', 'overrides', 'resolutions'] - const VERSION = /^([\^~]?)(\d+)\.(\d+)\.\d+$/ + const VERSION = /^([\^~]?)(\d+)\.(\d+)\.(\d+)$/ const sameBump = (x, y) => { if (x === y) return true if (typeof x !== 'string' || typeof y !== 'string') return false const a = VERSION.exec(x) const b = VERSION.exec(y) - return Boolean(a && b && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]) + // Same prefix, major and minor; the patch must rise; 0.0.x moves every patch, so it is no patch bump. + return Boolean(a && b && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && !(a[2] === '0' && a[3] === '0') && Number(b[4]) > Number(a[4])) } const ok = (() => { const keys = new Set([...Object.keys(before), ...Object.keys(after)]) diff --git a/test/claudeReview.test.mjs b/test/claudeReview.test.mjs index 98477751..91425b4b 100644 --- a/test/claudeReview.test.mjs +++ b/test/claudeReview.test.mjs @@ -672,7 +672,7 @@ describe('claude-review model choice', () => { const env = { PATH: process.env.PATH, REPO: repo, REQUESTED: requested, GITHUB_OUTPUT: out } if (input) { mkdirSync(join(dir, 'in')) - if (input.files !== undefined) writeFileSync(join(dir, 'in', 'files.txt'), input.files.map((p) => `1\t0\t${p}`).join('\n') + (input.files.length ? '\n' : '')) + if (input.files !== undefined) writeFileSync(join(dir, 'in', 'files.txt'), input.files.map((p) => `1\t0\t${p}`).join('\n') + (input.files.length && !input.noFinalNewline ? '\n' : '')) if (input.diff !== undefined) writeFileSync(join(dir, 'in', 'full.diff'), input.diff) env.REVIEW_INPUT = join(dir, 'in') } @@ -742,6 +742,11 @@ describe('claude-review model choice', () => { it('picks Sonnet for a patch bump in package.json and its lockfile', () => { assert.equal(pick(['package.json', 'package-lock.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^1.2.9')) }), sonnet) }) + it('keeps Opus when the patch does not rise, and for 0.0.x', () => { + assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.9')), after: pkgOf(dep('^1.2.3')) }), opus) + assert.equal(pick(['package.json'], { before: pkgOf(dep('0.0.1')), after: pkgOf(dep('0.0.2')) }), opus) + assert.equal(pick(['package.json'], { before: pkgOf(dep('^0.1.2')), after: pkgOf(dep('^0.1.3')) }), sonnet) + }) it('keeps Opus for a minor or major bump', () => { assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^1.3.0')) }), opus) assert.equal(pick(['package.json'], { before: pkgOf(dep('^1.2.3')), after: pkgOf(dep('^2.0.0')) }), opus) @@ -803,6 +808,18 @@ describe('claude-review model choice', () => { assert.deepEqual(words(/\+=\(([^)]*)\)/.exec(line)[1]), [...entries].sort(), repo) } }) + it('does not let *.generated.* cross a slash in a directory name', () => { + assert.equal(pick(['a.generated.d/app.ts']), opus) + assert.equal(pick(['a.generated.d/sub/app.ts']), opus) + assert.equal(pick(['a/app.generated.ts']), sonnet) + }) + it('keeps the last path of a list with no final newline', () => { + assert.equal(choose('gorfednet/ops', 'auto', { files: ['package-lock.json', 'src/app.ts'], noFinalNewline: true }), opus) + assert.equal(choose('gorfednet/ops', 'auto', { files: ['package-lock.json', 'x/app.generated.ts'], noFinalNewline: true }), sonnet) + }) + it('reads the heredoc script as a module', () => { + assert.match(workflow, /node --input-type=module - "\$mb"/) + }) it('keeps Opus for a rule basename at any depth, even inside a generated directory', () => { for (const p of ['docs/generated/CLAUDE.md', 'x/generated/canaries.json', 'a/generated/REVIEW.md', 'a/generated/SKILL.md', 'a/generated/AGENTS.md']) assert.equal(pick([p]), opus, p) assert.equal(pick(['x/generated/notes.json']), sonnet) @@ -812,7 +829,7 @@ describe('claude-review model choice', () => { assert.equal(pick(['package-lock.json', '.github/workflows/ci.yml']), opus) }) it('keeps Opus for every markdown file: docs are not an R0 class', () => { - for (const p of ['REVIEW.md', 'CLAUDE.md', 'control/claude-home/rules/x.md', '.claude/agents/a.md', 'README.md', 'ship-bot/README.md', 'docs/verification-rules.md', 'docs/retired-checks.md', 'docs/content-guidelines.md', 'templates/REVIEW.site-footer.md', 'templates/CLAUDE.snippet.md', 'scripts/local-llm/out.md', 'janitor/PROMPT.md', 'janitor/SKILL.md', 'skills/x/SKILL.md', 'docs/skills/a.md', 'a/agents/b.md', 'x/rules/y.md', 'Docs/Verification-Rules.md', 'MEMORY.md', 'ship-bot/lib/notes.md', 'docs/programme-template.md', 'docs/a.md', 'docs/notes/README.md', 'hosts/x/README.md', 'infra/README.md']) assert.equal(pick([p]), opus, p) + for (const p of ['REVIEW.md', 'CLAUDE.md', 'control/claude-home/rules/x.md', '.claude/agents/a.md', 'README.md', 'ship-bot/README.md', 'docs/verification-rules.md', 'docs/retired-checks.md', 'docs/content-guidelines.md', 'templates/REVIEW.site-footer.md', 'templates/CLAUDE.snippet.md', 'scripts/local-llm/out.md', 'janitor/PROMPT.md', 'janitor/SKILL.md', 'skills/x/SKILL.md', 'docs/skills/a.md', 'a/agents/b.md', 'x/rules/y.md', 'Docs/Verification-Rules.md', 'MEMORY.md', 'ship-bot/lib/notes.md', 'docs/programme-template.md', 'docs/a.md', 'docs/notes/README.md', 'hosts/x/README.md', 'infra/README.md', 'docs/generated/notes.md', 'docs/x.generated.md', 'a/generated/page.mdx', 'a/x.generated.markdown']) assert.equal(pick([p]), opus, p) }) it('fails closed: an empty, missing or unreadable list keeps Opus', () => { assert.equal(pick([]), opus)