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
55 changes: 55 additions & 0 deletions .github/workflows/panel-board-refresh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Panel board refresh

# Weekly: refetch the public Bug Hunt board for the panel recommendations catalog and, only when it changed,
# push the regenerated snapshot and catalog to the branch panel-board-refresh and log its URL. The job opens no
# pull request (this repository does not allow Actions to create them): a maintainer opens one from the branch.
# Own results never enter this job (a fetch keeps the catalog's own entries). The job runs the catalog check
# and the skill tests itself before it pushes, because a branch pushed with the workflow token starts no CI.

on:
schedule:
- cron: "17 14 * * 1" # Monday 14:17 UTC
workflow_dispatch:

permissions:
contents: read

concurrency:
group: panel-board-refresh
cancel-in-progress: false

jobs:
refresh:
if: github.repository == 'bompus/house-rules'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
env:
BRANCH: panel-board-refresh
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Comment thread
bompus marked this conversation as resolved.
Resolved
with:
# Always main, even for a manual run started from another branch, and the whole history, so the
# publish step can tell which commits the refresh branch has that main lacks.
ref: main
fetch-depth: 0
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.4
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Refetch the board and check the result
id: refresh
run: bash scripts/refresh-panel-board.sh
# The write token reaches only this step, never the install, the board fetch or the tests.
- name: Put the result on the refresh branch
id: publish
if: steps.refresh.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
bash scripts/publish-panel-board.sh
echo "The refresh branch holds the new board: https://github.com/${GITHUB_REPOSITORY}/tree/${BRANCH}" | tee -a "$GITHUB_STEP_SUMMARY"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Notable changes to house-rules. Versions follow [semantic versioning](https://se

## Unreleased

- `hr-code-review`'s panel recommendations catalog is generated: `scripts/refresh-recommendations.mjs` builds `panel-recommendations.json` from a source spec, a snapshot of the public Bug Hunt board (`--fetch` rewrites it) and the maintainer's own results (`--from-file` replaces them from a file of structured facts: a model and harness the spec lists, fixed choices and bounded numbers, with a deny file for private names; they live only in the catalog's own entries), and `--check` fails offline when the catalog is not what those inputs generate or the references folder holds a file the spec does not list or any symlink. The refresh no longer deletes inside a leftover transaction folder beyond the files it wrote, restores a file through a staged copy and keeps the before images when a restore fails, compares a stale lock's whole record before removing it, removes an interrupted run's before images, leaves the snapshot alone on an import, refuses malformed board rows and a repeated key in a fetched board, and states the board's planted total once. The one-time refresh moves the Opus, Sonnet and Muse figures to the board's current rows and adds GPT-6.2 Astra and Gemini 4 Neon entries; entries gain a `kind`.
- `hr-code-review`'s panel recommendations catalog is generated: `scripts/refresh-recommendations.mjs` builds `panel-recommendations.json` from a source spec, a snapshot of the public Bug Hunt board (`--fetch` rewrites it) and the maintainer's own results (`--from-file` replaces them from a file of structured facts: a model and harness the spec lists, fixed choices and bounded numbers, with a deny file for private names; they live only in the catalog's own entries), and `--check` fails offline when the catalog is not what those inputs generate or the references folder holds a file the spec does not list or any symlink. The refresh no longer deletes inside a leftover transaction folder beyond the files it wrote, restores a file through a staged copy and keeps the before images when a restore fails, compares a stale lock's whole record before removing it, removes an interrupted run's before images, leaves the snapshot alone on an import, refuses malformed board rows and a repeated key in a fetched board, and states the board's planted total once. A weekly workflow refetches the public board and pushes a branch for a maintainer's pull request only when it changed. The deny screen also folds a capital sharp s and a sigma's final form. The one-time refresh moves the Opus, Sonnet and Muse figures to the board's current rows and adds GPT-6.2 Astra and Gemini 4 Neon entries; entries gain a `kind`.
- `hr-better-colors`' focus-ring table row says it gives the blue step and that other hues are measured (Radix yellow `9` is 1.26:1 on white); the paragraph under the table is split in three.
- `hr-better-colors` puts the focus ring and input boundary on Radix step `9`, not `8`: Radix blue `8` (`#5eb1ef`) measures 2.33:1 on white, `9` measures 3.26:1 (Tailwind `500` stays 3.68:1). The previous entry's wording gave step `8`.
- Five review points on the vendored jakubkrehel text (from the private reviewer on the pin adoption) are fixed in wording: `hr-better-accessibility` limits `novalidate` to forms whose submit handler renders the errors (a form that renders each error from the field's `invalid` event needs none) and carries the typed-name destructive-confirmation exception into `forms.md`, `semantics-and-aria.md` and the checklist; `hr-better-colors` stops giving the focus ring to the decorative `300` border step (`--blue-300` measures 1.80:1 on white) and gives the focus ring and input boundary their own table row on the first step that measures 3:1, and its class-based theme recipe resolves the theme in one function (a saved choice wins, System reads the current query value) run at startup, on a choice change and on the system `change` event; `hr-better-typography` says `65ch` and the `max-w-md` / `max-w-lg` mapping assume a proportional font (in single-width monospace text the range is `60ch`–`75ch` and `max-w-md` holds about 46 characters; full-width glyphs take two cells, so a mixed-width line needs a rendered count), with a separate cheat-sheet row for monospace.
Expand Down
71 changes: 71 additions & 0 deletions scripts/publish-panel-board.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# Puts the regenerated snapshot and catalog on the refresh branch, without ever rewriting work that is not the job's
# own and without a new commit when the branch already holds this board. The branch is overwritten only when every
# commit on it that main lacks was made by the workflow bot and touches only the two generated files; it is then
# replaced with a lease on the SHA that was read. Run from a full clone of main with the regenerated files in place.
#
# Usage: BRANCH=panel-board-refresh scripts/publish-panel-board.sh
# Prints ready=true (the branch holds this board) or ready=false (the branch holds other work and was left alone;
# the script then exits 1, so the run is red) to $GITHUB_OUTPUT when set. REMOTE (default origin) names the remote.
set -euo pipefail
cd "$(dirname "$0")/.."

branch="${BRANCH:?set BRANCH to the refresh branch}"
remote="${REMOTE:-origin}"
refs=skills/hr-code-review/references
files=("$refs/panel-board-snapshot.json" "$refs/panel-recommendations.json")
bot_email="41898282+github-actions[bot]@users.noreply.github.com"
out="${GITHUB_OUTPUT:-/dev/stdout}"

# A JSON file from stdin without the dates every fetch rewrites.
shape() {
jq -S 'del(.fetched, .reviewed) | if .entries then .entries |= map(del(.checked)) else . end'
}

# The branch holds work that is not the job's: leave it alone and fail the run, so a stuck refresh is seen.
refuse() {
echo "::error::$1; left alone. Delete or merge the branch so the weekly refresh can continue."
echo "ready=false" >>"$out"
exit 1
}

lease=()
if git ls-remote --exit-code --heads "$remote" "$branch" >/dev/null 2>&1; then
git fetch --no-tags "$remote" "$branch"
tip="$(git rev-parse FETCH_HEAD)"
# Every commit the branch has that main lacks must be the bot's and touch only the generated files.
while read -r commit; do
[ -n "$commit" ] || continue
# A merge commit (GitHub's "Update branch" makes one) lists no files of its own, so it is never the job's.
if [ "$(git log -1 --format=%ae "$commit")" != "$bot_email" ] \
|| [ "$(git rev-list --parents -n 1 "$commit" | wc -w)" -ne 2 ]; then
refuse "$branch has a commit that is not the workflow's, or is a merge ($commit)"
fi
while read -r name; do
[ -n "$name" ] || continue
if [ "$name" != "${files[0]}" ] && [ "$name" != "${files[1]}" ]; then
refuse "$branch has a commit that touches $name ($commit)"
fi
done < <(git diff-tree --no-commit-id --name-only -r "$commit")
done < <(git rev-list "$tip" "^HEAD")
same=true
for file in "${files[@]}"; do
if [ "$(shape <"$file")" != "$(git show "$tip:$file" | shape)" ]; then
same=false
fi
done
if [ "$same" = true ]; then
echo "$branch already holds this board; nothing pushed"
echo "ready=true" >>"$out"
exit 0
fi
lease=("--force-with-lease=refs/heads/$branch:$tip")
fi

git config user.name "github-actions[bot]"
git config user.email "$bot_email"
git checkout -B "$branch"
git add -- "${files[@]}"
git commit -m "Panel recommendations: refresh the board snapshot and catalog"
git push ${lease[@]+"${lease[@]}"} "$remote" "$branch"
echo "ready=true" >>"$out"
47 changes: 47 additions & 0 deletions scripts/refresh-panel-board.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Refetches the public Bug Hunt board for the panel recommendations catalog and says whether anything but the
# dates changed. When it did, the catalog is checked and the skill's tests run before the caller commits it.
# Own results are never read: a fetch keeps the catalog's own entries as they are. Only the snapshot and the
# catalog are touched, and when nothing but a date changed they are put back byte for byte from copies taken
# before the fetch, so other edits in the references folder are never discarded.
#
# Usage: scripts/refresh-panel-board.sh (prints changed=true or changed=false; to $GITHUB_OUTPUT when set)
# PANEL_BOARD_FILE: a saved board to read instead of fetching (a dry run; it must sit outside the skill folder).
set -euo pipefail
cd "$(dirname "$0")/.."

refs=skills/hr-code-review/references
script=skills/hr-code-review/scripts/refresh-recommendations.mjs
snapshot="$refs/panel-board-snapshot.json"
catalog="$refs/panel-recommendations.json"
out="${GITHUB_OUTPUT:-/dev/stdout}"

# The files without the dates every fetch rewrites (the fetch date, the review date, each entry's checked date).
shape() {
jq -S 'del(.fetched, .reviewed) | if .entries then .entries |= map(del(.checked)) else . end' "$1"
}
before_snapshot="$(shape "$snapshot")"
before_catalog="$(shape "$catalog")"
saved="$(mktemp -d)"
trap 'rm -rf "$saved"' EXIT
cp "$snapshot" "$saved/snapshot.json"
cp "$catalog" "$saved/catalog.json"

args=(--fetch)
if [ -n "${PANEL_BOARD_FILE:-}" ]; then
args+=(--board-file "$PANEL_BOARD_FILE")
fi
bun "$script" "${args[@]}"

if [ "$before_snapshot" = "$(shape "$snapshot")" ] \
&& [ "$before_catalog" = "$(shape "$catalog")" ]; then
cp "$saved/snapshot.json" "$snapshot"
cp "$saved/catalog.json" "$catalog"
echo "the board is unchanged"
echo "changed=false" >>"$out"
exit 0
fi

bun "$script" --check
bun test skills/hr-code-review test/doc-rules.test.mjs
echo "changed=true" >>"$out"
6 changes: 6 additions & 0 deletions skills/hr-code-review/references/panel-recommendations.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ the catalog's own entries. `--check` runs offline, with no clock and no network,
fails when the catalog is not what those inputs generate. A raw results file is never
kept in this folder: the script refuses a leftover `panel-recommendations.own.json`.

A weekly workflow in the source repository (`.github/workflows/panel-board-refresh.yml`)
runs `--fetch` against the public board and, only when a row or the board's own update
changed, pushes the regenerated snapshot and catalog to the branch
`panel-board-refresh` and logs its URL; it opens no pull request, so a maintainer
opens one from that branch. It never reads own results, so those stay as the maintainer last imported them.

Check an entry again when a model, route, price or benchmark correction changes the
choice, and when preparing a release. Only changed entries need new evidence. An
update shows the old and suggested choices, the evidence date, the expected
Expand Down
7 changes: 5 additions & 2 deletions skills/hr-code-review/scripts/refresh-recommendations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ const MAX_BOARD_BYTES = 20 * 1024 * 1024;
const readJson = (path) => parseStrict(readFileSync(path, "utf8"), path);

// Compared with case, spacing and punctuation removed, so "Internal Tool" and "internal_tool" match "internal-tool".
// Compatibility-normalized, upper then lower case (a sharp s matches SS, a final sigma its capital), normalized
// again, then only letters and digits kept.
// Compatibility-normalized, upper then lower case, normalized again; then the two letters whose lower case depends
// on context or has no single form are folded by hand (a final or medial sigma is one letter, and a sharp s, small or
// capital, is ss); then only letters and digits kept.
const squash = (/** @type {string} */ s) =>
s
.normalize("NFKC")
.toUpperCase()
.toLowerCase()
.normalize("NFKC")
.replaceAll("ς", "σ")
.replaceAll("ß", "ss")
.replace(/[^\p{L}\p{N}]/gu, "");
/** @param {unknown} v a finite number that is not negative */
const nonNegative = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0;
Expand Down
Loading
Loading