From ebc23fe955a8af55e811d9553a6f931a0be6b964 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:03:45 -0500 Subject: [PATCH 1/4] fix(scripts): run the comment-lint gate in check-affected.sh Issue-lane PRs failed CI's comment-lint gate because the lane's only self-check, check-affected.sh --uncommitted, listed it as CI only, and the lane commits through the API with hooks off, so the commit-time hook never ran. check-affected.sh now runs the code-tidying comment-lint hook over ..HEAD: a scratch repository holds HEAD at the merge-base and the index at HEAD's tree, so the hook's staged diff is the branch's, with the merge-base's settings files as scripts/check-comment-lint.sh uses in CI. A python3 without pygments is a SKIP. The lane's base copy of the checks now carries code-tidying's git-hooks, lib and scripts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtV6H7kcRVG5xeX1rtT --- .../actions/collect-base-activity/action.yml | 10 +- .../collect-base-activity.test.mjs | 22 +++++ scripts/check-affected-comment-lint.test.sh | 91 +++++++++++++++++++ scripts/check-affected-gates.txt | 2 +- scripts/check-affected.sh | 35 ++++++- 5 files changed, 157 insertions(+), 3 deletions(-) create mode 100755 scripts/check-affected-comment-lint.test.sh diff --git a/.github/actions/collect-base-activity/action.yml b/.github/actions/collect-base-activity/action.yml index 563f8458451..4d91b9c63d0 100644 --- a/.github/actions/collect-base-activity/action.yml +++ b/.github/actions/collect-base-activity/action.yml @@ -200,7 +200,7 @@ runs: # the copy at , where the runner leaves it. Sets check_wrappers # (their paths at ) and check_prompt. stage_checks() { - local dir=$1 at=$2 check script flags wrapper config + local dir=$1 at=$2 check script flags wrapper config part check_wrappers=() [[ $at =~ ^/[A-Za-z0-9_./-]+$ && $WORKSPACE =~ ^/[A-Za-z0-9_./-]+$ ]] || fail "the checks directory or workspace has a name a rule cannot carry" @@ -220,6 +220,14 @@ runs: mkdir -p "$dir/plugins/skill-quality" cp -R "$BASE_PATH/plugins/skill-quality/scripts" "$dir/plugins/skill-quality/" fi + # check-affected.sh runs the comment-lint hook from this copy, which + # sources and reads files across these three directories. + if [ -d "$BASE_PATH/plugins/code-tidying/git-hooks" ]; then + mkdir -p "$dir/plugins/code-tidying" + for part in git-hooks lib scripts; do + cp -R "$BASE_PATH/plugins/code-tidying/$part" "$dir/plugins/code-tidying/" + done + fi for check in "${checks[@]}"; do script=${check%% *} flags=${check#"$script"} diff --git a/.github/actions/collect-base-activity/collect-base-activity.test.mjs b/.github/actions/collect-base-activity/collect-base-activity.test.mjs index b5b4c44be2a..b28151c788a 100644 --- a/.github/actions/collect-base-activity/collect-base-activity.test.mjs +++ b/.github/actions/collect-base-activity/collect-base-activity.test.mjs @@ -371,6 +371,28 @@ test("a listed check's copy carries the base's skill-quality scripts", () => { } }); +test("a listed check's copy carries the base's code-tidying comment-lint files", () => { + const tidying = path.join(base, "plugins", "code-tidying"); + const files = { + "git-hooks/comment-lint.sh": "echo base hook\n", + "lib/git-hooks/check-lib.sh": "echo base lib\n", + "scripts/comment-settings.sh": "echo base settings\n", + }; + for (const [rel, body] of Object.entries(files)) { + mkdirSync(path.dirname(path.join(tidying, rel)), { recursive: true }); + writeFileSync(path.join(tidying, rel), body); + } + try { + const { status, checksDir } = withChecks(["scripts/check-x.sh --check"]); + assert.equal(status, 0); + for (const [rel, body] of Object.entries(files)) { + assert.equal(readFileSync(path.join(checksDir, "plugins", "code-tidying", rel), "utf8"), body, rel); + } + } finally { + rmSync(tidying, { recursive: true }); + } +}); + // A skill that commits runs its checks, fixes and re-runs them before it // commits, since the checks read the working tree (#8319 review). test("a committing skill with checks is told to commit after the checks and their fixes", () => { diff --git a/scripts/check-affected-comment-lint.test.sh b/scripts/check-affected-comment-lint.test.sh new file mode 100755 index 00000000000..4a4d6cfa188 --- /dev/null +++ b/scripts/check-affected-comment-lint.test.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# test-scope: scripts/check-affected.sh scripts/check-affected-gates.txt plugins/code-tidying/git-hooks/* plugins/code-tidying/lib/* plugins/code-tidying/scripts/* +# shellcheck disable=SC2016 +set -uo pipefail + +SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit 2 +# shellcheck source=lib/test-harness.sh +. "$SELF_DIR/lib/test-harness.sh" || exit 2 +# shellcheck source=test-git-helpers.sh +. "$SELF_DIR/test-git-helpers.sh" || exit 2 + +if ! python3 -c 'import pygments' 2>/dev/null; then + echo "FAIL - python3 cannot import pygments, which the comment lint needs" >&2 + exit 1 +fi + +tmp="$(mktemp -d)" || exit 2 +trap 'rm -rf "$tmp"' EXIT +repo="$tmp/repo" +planted="$SELF_DIR/../plugins/code-tidying/git-hooks/fixtures/shape2.sh.txt" +mkdir -p "$repo/scripts" +git_init_test_repo "$repo" || exit 2 +cp "$SELF_DIR/check-affected.sh" "$SELF_DIR/check-affected-gates.txt" "$repo/scripts/" +printf '#!/bin/sh\necho "$1"\n' >"$repo/tool.sh" +git_test_config "$repo" add -A +git_test_config "$repo" commit -q -m base +git_test_config "$repo" branch -q bare +printf 'x\n' >"$repo/notes.txt" +git_test_config "$repo" add notes.txt +git_test_config "$repo" commit -q -m notes + +run() { + local -a envs=() + while [[ "$1" != -- ]]; do + envs+=("$1") + shift + done + shift + RC=0 + OUT="$(cd "$repo" && env ${envs[@]+"${envs[@]}"} bash scripts/check-affected.sh --no-fetch "$@" 2>"$tmp/err")" || RC=$? + ERR="$(cat "$tmp/err")" +} +check() { + if eval "$2"; then ok "$1"; else bad "$1" "rc=$RC out=$OUT err=$ERR"; fi +} + +run -- --base bare +check "a tree without the comment-lint hook skips comment-lint" \ + '[[ $ERR == *"SKIP comment-lint (no plugins/code-tidying/git-hooks/comment-lint.sh beside this script)"* ]]' + +mkdir -p "$repo/plugins/code-tidying" "$repo/docs/conventions" +for part in git-hooks lib scripts; do + cp -R "$SELF_DIR/../plugins/code-tidying/$part" "$repo/plugins/code-tidying/" +done +printf 'comment_posture: necessary\ncomment_lint: block\n' >"$repo/docs/conventions/code-tidying.yaml" +git_test_config "$repo" add -A +git_test_config "$repo" commit -q -m lint-base +git_test_config "$repo" branch -q lint-base +printf '#!/bin/sh\necho "$1" "$2"\n' >"$repo/tool.sh" +git_test_config "$repo" commit -q -am clean-tool + +mkdir -p "$tmp/nopy" +printf '#!/bin/sh\nexit 1\n' >"$tmp/nopy/python3" +chmod +x "$tmp/nopy/python3" +run PATH="$tmp/nopy:$PATH" -- --base lint-base +check "a python3 that cannot import pygments skips comment-lint, not a failure" \ + '[[ $ERR == *"SKIP comment-lint (python3 with pygments not installed)"* && $ERR != *"FAIL comment-lint"* ]]' + +run -- --base lint-base +check "a change with no comment passes comment-lint" \ + '[[ $ERR != *"FAIL comment-lint"* && $ERR != *"SKIP comment-lint"* && $ERR != *"CI only: comment-lint "* ]]' + +cp "$planted" "$repo/tool.sh" +git_test_config "$repo" commit -q -am planted-tool +run -- --base lint-base +check "a committed comment the posture disallows fails comment-lint at its line" \ + '[[ $RC == 1 && $ERR == *"FAIL comment-lint"* && $ERR == *"tool.sh:8:"* ]]' + +printf 'comment_posture: necessary\ncomment_lint: off\n' >"$repo/docs/conventions/code-tidying.yaml" +git_test_config "$repo" commit -q -am lint-off +run -- --base lint-base +check "the merge-base's comment_lint level decides, not one the branch sets" \ + '[[ $RC == 1 && $ERR == *"FAIL comment-lint"* && $ERR == *"tool.sh:8:"* ]]' + +git_test_config "$repo" reset -q --hard lint-base +cp "$planted" "$repo/tool.sh" +run -- --uncommitted +check "an uncommitted comment the posture disallows fails comment-lint under --uncommitted" \ + '[[ $RC == 1 && $ERR == *"FAIL comment-lint"* && $ERR == *"tool.sh:8:"* ]]' + +test_harness::report diff --git a/scripts/check-affected-gates.txt b/scripts/check-affected-gates.txt index aace9d39b6b..98118a4a211 100644 --- a/scripts/check-affected-gates.txt +++ b/scripts/check-affected-gates.txt @@ -28,6 +28,7 @@ as-of-recheck run as-of-recheck cost-figures run cost-figures changed-skills run changed-skills comment-hygiene run comment-hygiene +comment-lint run comment-lint size-check run size-check # Not run by scripts/check-affected.sh. The reason names where the gate comes from @@ -51,7 +52,6 @@ changelog-fragments-release ci-only release pull request only, scripts/check-cha vendor-version-bump ci-only scripts/check-vendor-version-bump.sh --check-bump portability-lint ci-only scripts/check-skill-portability.sh cant-fail-scan ci-only scripts/check-cant-fail-scan.sh -comment-lint ci-only pull request only; the code-tidying comment-lint git hook runs it at commit, scripts/check-comment-lint.sh with HEAD_SHA and BASE_REF by hand evals-quality ci-only bash plugins/skill-quality/scripts/check-evals-quality.sh eval-cases ci-only python3 plugins/evals/skills/validate/scripts/validate-cases.py listing-budget-configured ci-only whole-repo scanner, bash plugins/skill-quality/scripts/check-listing-budget.sh plugins/*/skills diff --git a/scripts/check-affected.sh b/scripts/check-affected.sh index 555cc1997c4..31627e432e5 100755 --- a/scripts/check-affected.sh +++ b/scripts/check-affected.sh @@ -278,7 +278,7 @@ fi gates_file="$tools/scripts/check-affected-gates.txt" declare -a passed=() skipped=() failed=() out="$(mktemp)" || exit 2 -trap 'rm -rf "$out" "$out.failures" "$out.patterns" "$out.not-run" "$out.left" "$out.node" "$out.md"' EXIT +trap 'rm -rf "$out" "$out.failures" "$out.patterns" "$out.not-run" "$out.left" "$out.node" "$out.md" "$out.cl"' EXIT skip() { skipped+=("$1 ($2)"); } @@ -525,6 +525,39 @@ else bash "$tools/scripts/check-comment-hygiene.sh" "$merge_base" "${changed[@]}" fi +comment_lint=plugins/code-tidying/git-hooks/comment-lint.sh +comment_lint_merge_base_diff() { + local d="$out.cl" f home head + head="$(git rev-parse HEAD)" && + git -c init.defaultBranch=lint init --quiet --template= "$d" && + printf '%s\n' "$(cd "$(git rev-parse --git-common-dir)/objects" && pwd -P)" >"$d/.git/objects/info/alternates" && + git -C "$d" update-ref --no-deref HEAD "$merge_base" && + git -C "$d" read-tree "$head" || return 2 + copy_from_merge_base() { + if git cat-file -e "$merge_base:$1" 2>/dev/null; then + mkdir -p "$d/$(dirname "$1")" && git show "$merge_base:$1" >"$d/$1" + fi + } + copy_from_merge_base AGENTS.md && copy_from_merge_base CLAUDE.md || return 2 + home="$(bash "$tools/plugins/code-tidying/lib/resolve-convention-home.sh" --root "$d" 2>/dev/null)" || home="" + [[ -n "$home" && "$home" != /* && "$home" != *..* ]] || home=docs/conventions + for f in code-tidying.yaml code-tidying.local.yaml; do + copy_from_merge_base "${home%/}/$f" || return 2 + done + (cd "$d" && AI_AGENT=ci sh "$tools/$comment_lint") +} +if ((${#changed[@]} == 0)); then + skip comment-lint "no changed files" +elif [[ ! -f "$tools/$comment_lint" ]]; then + skip comment-lint "no $comment_lint beside this script" +elif ! python3 -c 'import pygments' >/dev/null 2>&1; then + skip comment-lint "python3 with pygments not installed" +else + run_check comment-lint \ + "AI_AGENT=ci sh $comment_lint --worktree for uncommitted edits, else scripts/check-comment-lint.sh with HEAD_SHA, BASE_REF and GITHUB_EVENT_NAME=pull_request" \ + comment_lint_merge_base_diff +fi + # machine-specific-paths: the scan the workflow's check-machine-paths composite # (melodic-software/ci-workflows) runs, over the changed files of the types it # scans. The regex bodies come from the merge-base's guardrails plugin copy of From aa2d65ca8b8a89c20a39c69b27e16ecc46a36e7f Mon Sep 17 00:00:00 2001 From: "melodic-automation-lanes[bot]" <337595936+melodic-automation-lanes[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2026 00:16:56 +0000 Subject: [PATCH 2/4] Address review feedback on fix/check-affected-comment-lint Lane-Activity: pr-unblock/address-feedback Lane-Thread: PRRT_kwDOTCGFQM66d9g0 Lane-Thread: PRRT_kwDOTCGFQM66d92Q --- scripts/check-affected.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-affected.sh b/scripts/check-affected.sh index 31627e432e5..649d4274e72 100755 --- a/scripts/check-affected.sh +++ b/scripts/check-affected.sh @@ -539,7 +539,7 @@ comment_lint_merge_base_diff() { fi } copy_from_merge_base AGENTS.md && copy_from_merge_base CLAUDE.md || return 2 - home="$(bash "$tools/plugins/code-tidying/lib/resolve-convention-home.sh" --root "$d" 2>/dev/null)" || home="" + home="$(bash "$tools/plugins/code-tidying/lib/resolve-convention-home.sh" --root "$d" --ref "$merge_base" 2>/dev/null)" || home="" [[ -n "$home" && "$home" != /* && "$home" != *..* ]] || home=docs/conventions for f in code-tidying.yaml code-tidying.local.yaml; do copy_from_merge_base "${home%/}/$f" || return 2 From 1cfa4ac8be0b00d1651aa20fdbb709a7c70d238c Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:17:45 -0500 Subject: [PATCH 3/4] test(collect-base-activity): declare the suite's reads in test-scope Test Selection traces a changed suite, and this one reads the base's resolve-config package.json, apply-patch files and the skill-quality plugin, which no test-scope line declared (scripts/affected-tests.sh R8). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtV6H7kcRVG5xeX1rtT --- .../actions/collect-base-activity/collect-base-activity.test.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/collect-base-activity/collect-base-activity.test.mjs b/.github/actions/collect-base-activity/collect-base-activity.test.mjs index b28151c788a..c9be12247be 100644 --- a/.github/actions/collect-base-activity/collect-base-activity.test.mjs +++ b/.github/actions/collect-base-activity/collect-base-activity.test.mjs @@ -3,6 +3,7 @@ // come from the contract (pr-run-activity.md, "Skill activities" and // "prepare: merge-base"): a writing skill gets the signed-commit tool and the // instruction to commit; a merge-base skill runs on run-claude-cli alone. +// test-scope: .github/actions/resolve-config/package.json .github/scripts/apply-patch/* plugins/skill-quality/* import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs"; From 0d05631a0193213a2d6704d37b4bb885a9e970d7 Mon Sep 17 00:00:00 2001 From: "melodic-automation-lanes[bot]" <337595936+melodic-automation-lanes[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2026 00:29:00 +0000 Subject: [PATCH 4/4] Address review feedback on fix/check-affected-comment-lint Lane-Activity: pr-unblock/address-feedback Lane-Thread: PRRT_kwDOTCGFQM66d92Q --- scripts/check-affected-comment-lint.test.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/check-affected-comment-lint.test.sh b/scripts/check-affected-comment-lint.test.sh index 4a4d6cfa188..51a1f2fa8f9 100755 --- a/scripts/check-affected-comment-lint.test.sh +++ b/scripts/check-affected-comment-lint.test.sh @@ -88,4 +88,17 @@ run -- --uncommitted check "an uncommitted comment the posture disallows fails comment-lint under --uncommitted" \ '[[ $RC == 1 && $ERR == *"FAIL comment-lint"* && $ERR == *"tool.sh:8:"* ]]' +git_test_config "$repo" reset -q --hard lint-base +mkdir -p "$repo/team-conventions" +git_test_config "$repo" mv docs/conventions/code-tidying.yaml team-conventions/code-tidying.yaml +printf '\nTeam conventions live in `team-conventions`.\n\n' >"$repo/AGENTS.md" +git_test_config "$repo" add AGENTS.md +git_test_config "$repo" commit -q -m home-base +git_test_config "$repo" branch -q home-base +cp "$planted" "$repo/tool.sh" +git_test_config "$repo" commit -q -am planted-tool-home +run -- --base home-base +check "a merge-base whose AGENTS.md points at a non-default home reads its comment_lint level there" \ + '[[ $RC == 1 && $ERR == *"FAIL comment-lint"* && $ERR == *"tool.sh:8:"* ]]' + test_harness::report