From 80f5b0a3362ee4beb59d88061850f3aaf5cb8820 Mon Sep 17 00:00:00 2001 From: Clarence Lee Date: Wed, 2 Dec 2026 17:57:34 +0800 Subject: [PATCH 1/3] fix(harness): close the second batch of minor review findings Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/validate-skills.yml | 21 ++++- changelog.d/minors-batch-2.fixed.md | 1 + scripts/check-docs.test.sh | 19 +++++ scripts/gate-baselined-paths.test.sh | 46 ++++++++++ scripts/gate-budget.test.sh | 83 ++++++++++++++++--- scripts/harness-live.test.sh | 18 +++- scripts/harness-refresh-keys.test.sh | 61 ++++++++++++++ scripts/lint-skills.sh | 11 +++ scripts/lint-skills.test.sh | 15 +++- scripts/run-gates.map | 2 + scripts/seeded-coverage-floor.test.sh | 58 ++++++++++++- skills/migrate/general/adopt-install.md | 2 +- skills/migrate/general/harness-live.sh | 14 +++- skills/migrate/general/harness-refresh.sh | 4 + .../shared/template/.claude/gate-budget.sh | 9 +- .../shared/template/scripts/gate-baselined.sh | 5 +- .../template/scripts/set-coverage-floor.sh | 35 +++++--- tests/golden/fastapi-azure.sha256 | 6 +- tests/golden/fastapi-github.sha256 | 6 +- tests/golden/nestjs-azure.sha256 | 6 +- tests/golden/nestjs-github.sha256 | 6 +- tests/golden/nextjs-azure.sha256 | 6 +- tests/golden/nextjs-github.sha256 | 6 +- tests/golden/vite-react-azure.sha256 | 6 +- tests/golden/vite-react-github.sha256 | 6 +- 25 files changed, 388 insertions(+), 64 deletions(-) create mode 100644 changelog.d/minors-batch-2.fixed.md create mode 100755 scripts/gate-baselined-paths.test.sh create mode 100755 scripts/harness-refresh-keys.test.sh diff --git a/.github/workflows/validate-skills.yml b/.github/workflows/validate-skills.yml index 2aa0c2b7..c7b6a969 100644 --- a/.github/workflows/validate-skills.yml +++ b/.github/workflows/validate-skills.yml @@ -218,6 +218,8 @@ jobs: run: bash scripts/seeded-gates.test.sh - name: Seeded gate-time budget, record, check, hook and ratchet guards run: bash scripts/gate-budget.test.sh + - name: Seeded gate wrapper path-word tests + run: bash scripts/gate-baselined-paths.test.sh seeded-gate-ci-tests: name: Seeded gate tests, day-one and CI templates @@ -629,6 +631,8 @@ jobs: run: bash scripts/harness-merge.test.sh - name: Harness refresh superseded-file tests run: bash scripts/harness-refresh-stale-guard.test.sh + - name: Harness refresh manifest key tests + run: bash scripts/harness-refresh-keys.test.sh refresh-adopt-route-tests: name: Refresh adopt-route tests @@ -785,11 +789,23 @@ jobs: fetch-tags: true - name: Migrate gate baseline tests run: bash scripts/migrate-baseline.test.sh - - name: Adopted docs baseline tests - run: bash scripts/adopt-docs-baseline.test.sh - name: Pristine hashes are current run: bash skills/migrate/general/gen-pristine-hashes.sh --check + adopt-docs-baseline-tests: + name: Adopted docs baseline tests + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + fetch-tags: true + - name: Adopted docs baseline tests + run: bash scripts/adopt-docs-baseline.test.sh + lint-negative-tests: name: Lint check negative tests runs-on: ubuntu-24.04 @@ -933,6 +949,7 @@ jobs: - sonar-parity-tests - defect-report-tests - migrate-baseline-tests + - adopt-docs-baseline-tests - lint-negative-tests - fence-snapshot-frozen - line-budget-frozen diff --git a/changelog.d/minors-batch-2.fixed.md b/changelog.d/minors-batch-2.fixed.md new file mode 100644 index 00000000..4ede94a6 --- /dev/null +++ b/changelog.d/minors-batch-2.fixed.md @@ -0,0 +1 @@ +- Several smaller gaps in the seeded harness and its tests are closed: the gate-time budget hook never waits on a stdin that does not close, and its test now reaps every process it starts and fails if one survives; `scripts/set-coverage-floor.sh` reads a jest section in `package.json` and `jest.config.json` honestly, names the real limit in its messages, and ignores comment text when it looks for the insertion line; `harness-refresh.sh` stops on a repeated or non-plain `stack` or `route` key; the docs gate refuses a linked or empty baseline wrapper; the gate wrapper refuses control characters in a path word; the live harness check asks a jest `test:ci` line for a floor in `jest.config.*`; and the CI=none branch lint covers every form of a second early exit. diff --git a/scripts/check-docs.test.sh b/scripts/check-docs.test.sh index 5d33e298..f21ee699 100755 --- a/scripts/check-docs.test.sh +++ b/scripts/check-docs.test.sh @@ -613,6 +613,25 @@ printf '[a](docs\\real.md) [b](C:\\x)\n' > "$d/README.md" run_check "$d" check 0 "$EC" "backslash_targets: not checked ($OUT)" +# a baseline file with no usable wrapper stops the gate (exit 2) instead of running unjudged; a usable wrapper routes through +d="$T/clean-nestjs" +printf '# templatecentral gate baseline v2\ndocs\tREADME.md:1: x\n' > "$d/.claude/gate-baseline.txt" +for wrapper in missing linked empty; do + rm -rf "$T/wrap-$wrapper" + cp -R "$d" "$T/wrap-$wrapper" + rm -f "$T/wrap-$wrapper/scripts/gate-baselined.sh" + case "$wrapper" in + linked) ln -s ../../clean-nestjs/scripts/gate-baseline.sh "$T/wrap-$wrapper/scripts/gate-baselined.sh" ;; + empty) : > "$T/wrap-$wrapper/scripts/gate-baselined.sh" ;; + esac + run_check "$T/wrap-$wrapper" + check 2 "$EC" "baseline_wrapper[$wrapper]: exits 2 ($OUT)" + check 1 "$(printf '%s\n' "$OUT" | grep -c 'is missing, linked or empty')" "baseline_wrapper[$wrapper]: names the cause ($OUT)" +done +run_check "$d" +check 0 "$(printf '%s\n' "$OUT" | grep -c 'is missing, linked or empty')" "baseline_wrapper[control]: a real wrapper is not refused for being unusable ($OUT)" +rm -f "$d/.claude/gate-baseline.txt" + # the retired gate and its opt-in appear nowhere in the seeded layer or the kit old=$(grep -rnE 'readme-coupling|readme-freshness|skip-readme-check|ci-gates\.sh readme|richReadme|TC_RICH_README|README freshness' \ "$REPO_ROOT/skills/scaffold" "$REPO_ROOT/skills/add" "$REPO_ROOT/skills/cleanup" "$REPO_ROOT/skills/review" "$REPO_ROOT/skills/standards" 2>/dev/null) diff --git a/scripts/gate-baselined-paths.test.sh b/scripts/gate-baselined-paths.test.sh new file mode 100755 index 00000000..2897b6ea --- /dev/null +++ b/scripts/gate-baselined-paths.test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# scripts/gate-baselined-paths.test.sh — gate-baselined.sh refuses a path word that holds a control character (tab, carriage return, newline), as well as the shell operators, and still runs a plain path. +# The probe is paired with a guard: with the control-character test removed from the real script, the probe fails. +# Usage: bash scripts/gate-baselined-paths.test.sh +set -uo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +SRC="$REPO_ROOT/skills/scaffold/shared/template/scripts/gate-baselined.sh" + +PASS=0 +FAIL=0 +check() { if [[ "$1" == "$2" ]]; then PASS=$((PASS + 1)); else FAIL=$((FAIL + 1)); echo "FAIL: $3 — expected [$1], got [$2]"; fi; } + +T=$(mktemp -d "${TMPDIR:-/tmp}/gbp.XXXXXX") || exit 2 +trap 'rm -rf "$T"' EXIT +mkdir -p "$T/scripts" "$T/.claude" +printf '#!/usr/bin/env bash\necho ran\n' > "$T/scripts/check-docs.sh" + +# gate