Files
OpenFlare/.auto/measure.sh
T
ryan 5971e2a9ed chore(autoresearch): re-baseline harness on pinned real-risk yardstick
The committed golangci gate now reports 0 issues, so the previous
lint_issues metric was saturated and could no longer measure progress.
Measure debt against an immutable .auto/lint.ref.yaml snapshot that adds
analyzers for genuine defects (panics, error unwrapping, dead stores,
missing enum cases, method ordering, suppression hygiene) while excluding
cosmetic churn (tagliatelle, wrapcheck). Guard enforces build, vet, tests,
the Cordis architecture gate, and anti-cheat floors: the yardstick cannot
be edited, the project gate may only be strengthened, nolint directives may
only shrink, and no test may disappear.
2026-08-29 07:52:03 +08:00

39 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Autoresearch measure — pinned yardstick.
# debt : findings under .auto/lint.ref.yaml (lower is better) [PRIMARY]
# nolint_dirs : raw //nolint directive count (lower is better, floor 0)
# tests_passed : go test packages passing (floor, must never drop)
# test_funcs : total Test*/Benchmark* funcs (floor, must never drop)
# arch_viol : Cordis architecture script violations (floor 0)
# coverage : backend statement coverage % (informational)
set -uo pipefail
cd "$(dirname "$0")/../backend"
REF_CFG="$(cd .. && pwd)/.auto/lint.ref.yaml"
# Primary: pinned yardstick findings (never the mutable project config).
golangci-lint run -c "${REF_CFG}" > /tmp/ar_debt.txt 2>&1 || true
DEBT=$(grep -cE '\.go:[0-9]+:[0-9]+: ' /tmp/ar_debt.txt || true)
# Suppression reliance — anti-cheat signal.
NOLINT=$(rg '//\s*nolint' --glob '*.go' 2>/dev/null | wc -l | tr -d ' ')
# Regression floors. One covered run feeds both the pass floor and coverage.
go test -cover ./... > /tmp/ar_test.txt 2>&1 || true
TESTS_PASSED=$(grep -c '^ok' /tmp/ar_test.txt || true)
FAILS=$(grep -cE '^(FAIL|--- FAIL)' /tmp/ar_test.txt || true)
TEST_FUNCS=$(rg -c '^(func Test|func Benchmark)' --glob '*_test.go' 2>/dev/null | awk -F: '{s+=$2} END {print s+0}')
# Cordis architecture violations (count of FAIL lines emitted by the gate script).
ARCH_VIOL=$("../scripts/check_cordis_architecture.sh" 2>&1 | grep -c 'FAIL' || true)
COVERAGE=$(grep -oE 'coverage: [0-9.]+%' /tmp/ar_test.txt | awk '{gsub("%","",$2); s+=$2; n++} END {if(n>0) printf "%.2f", s/n; else print "0"}')
echo "METRIC debt=${DEBT}"
echo "METRIC nolint_dirs=${NOLINT}"
echo "METRIC tests_passed=${TESTS_PASSED}"
echo "METRIC test_funcs=${TEST_FUNCS}"
echo "METRIC arch_viol=${ARCH_VIOL}"
echo "METRIC coverage=${COVERAGE}"
echo "INFO test_failures=${FAILS}"