@jeiemgi/cckit 0.4.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +9 -1
- package/bin/cckit +18 -0
- package/cckit.config.json +2 -2
- package/package.json +1 -1
- package/scripts/benchmark/benchmark-test.sh +83 -0
- package/scripts/benchmark/gate.sh +55 -0
- package/scripts/benchmark/lib/bench-common.sh +70 -0
- package/scripts/benchmark/lib/model.sh +116 -0
- package/scripts/benchmark/report.sh +105 -0
- package/scripts/benchmark/run-quality.sh +102 -0
- package/scripts/benchmark/run.sh +166 -0
- package/scripts/benchmark/stop-check.sh +83 -0
- package/scripts/commitlint-test.sh +58 -0
- package/scripts/init.sh +26 -0
- package/scripts/kit-self-update.sh +55 -0
- package/scripts/lib/commitlint.sh +53 -0
- package/scripts/lib/kit-task-ops-test.sh +21 -0
- package/scripts/lib/kit-task-ops.sh +50 -2
- package/scripts/orchestrate.sh +8 -1
- package/scripts/portable-test.sh +1 -1
- package/scripts/status.sh +53 -40
- package/scripts/task-sync.sh +13 -0
- package/scripts/ux-a11y-scan.sh +96 -0
- package/scripts/ux-ds-audit.sh +146 -0
- package/scripts/ux-graph-scan.sh +188 -0
- package/skills/kit-autopilot/SKILL.md +6 -1
- package/skills/kit-ux-audit/SKILL.md +241 -0
- package/skills/kit-ux-audit/references/a11y.md +79 -0
- package/skills/kit-ux-audit/references/consistency.md +106 -0
- package/skills/kit-ux-audit/references/graph-model.md +92 -0
- package/skills/kit-ux-audit/references/heuristics.md +157 -0
- package/skills/kit-ux-audit/references/report.md +172 -0
- package/templates/agents/ux.md +89 -0
- package/templates/benchmarks/SCHEMA.md +75 -0
- package/templates/benchmarks/abstain.jsonl +8 -0
- package/templates/benchmarks/adversarial.jsonl +8 -0
- package/templates/benchmarks/benchmark.config.json +14 -0
- package/templates/benchmarks/quality.jsonl +8 -0
- package/templates/benchmarks/retrieval.jsonl +7 -0
- package/templates/settings/settings.json.tmpl +9 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cckit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"installationPreference": "beta",
|
|
5
5
|
"description": "cckit — a project operating system for coding agents. The full GitHub work lifecycle (start/pr/close/sync, efforts, worktrees, orchestrate, gc) as agents + skills + rules, drivable by Claude Code and any other agent. Driven from cckit.config.json; no org or repo hardcoded.",
|
|
6
6
|
"author": {
|
package/README.md
CHANGED
|
@@ -156,7 +156,9 @@ cckit wave --llm # the fan-out (one subagent prompt per issue) as TOON
|
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
Human output renders as markdown — rich via `glow` in a terminal, native in the Claude Code
|
|
159
|
-
transcript, pipe-safe everywhere (`
|
|
159
|
+
transcript, pipe-safe everywhere. Every human-facing verb (`sync`, `plan`, `next`, `status`) shares
|
|
160
|
+
one rendering seam, so board tables, wave plans, and the status dashboard read the same in every
|
|
161
|
+
surface and never leak escape codes down a pipe (`cckit render` exposes the seam for any script).
|
|
160
162
|
|
|
161
163
|
## cckit builds cckit
|
|
162
164
|
|
|
@@ -182,6 +184,7 @@ prompt** you can paste straight into Claude Code — start exactly where you are
|
|
|
182
184
|
cckit/
|
|
183
185
|
bin/cckit # the CLI dispatcher
|
|
184
186
|
scripts/lib/*.sh # the git-mechanics bundle (effort, worktree, gh, gc, …)
|
|
187
|
+
scripts/benchmark/ # doc-retrieval benchmark harness (cckit bench)
|
|
185
188
|
.claude-plugin/ # the Claude Code plugin manifest
|
|
186
189
|
skills/ commands/ # Claude Code skills + slash commands
|
|
187
190
|
profiles/ templates/ # init profiles + scaffold templates
|
|
@@ -190,6 +193,11 @@ cckit/
|
|
|
190
193
|
cckit.config.json # project configuration (no hardcoded org/repo)
|
|
191
194
|
```
|
|
192
195
|
|
|
196
|
+
`cckit init` also scaffolds `benchmarks/` — a per-project **documentation benchmark** that scores how
|
|
197
|
+
well an agent finds and uses your own canonical docs (retrieval / adversarial / abstain / quality
|
|
198
|
+
tiers). Run `cckit bench report` after a docs or kit-version change to catch findability regressions;
|
|
199
|
+
see the [benchmark guide](https://cckit.dev/benchmark/).
|
|
200
|
+
|
|
193
201
|
## Built with cckit
|
|
194
202
|
|
|
195
203
|
Using cckit in your project? Add a badge (optional, but appreciated):
|
package/bin/cckit
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
# cckit migrate reshuffle an old kit layout to the current one
|
|
37
37
|
# cckit adopt record kit-shaped files a repo already has into the manifest
|
|
38
38
|
# cckit digest <path|url> summarize a file or URL (local model)
|
|
39
|
+
# cckit bench [run|report|…] doc-retrieval benchmark: score how well docs are found + used
|
|
39
40
|
# cckit release <ver> [--publish] cut a release (dry-run by default)
|
|
40
41
|
# cckit version [--llm] the installed cckit version
|
|
41
42
|
# cckit commands [--llm] list every verb (the command catalog)
|
|
@@ -259,6 +260,23 @@ case "$cmd" in
|
|
|
259
260
|
adopt) exec "$ROOT/scripts/kit-adopt.sh" "$@" ;;
|
|
260
261
|
doctor) exec "$ROOT/scripts/kit-doctor.sh" "$@" ;;
|
|
261
262
|
digest) exec "$ROOT/scripts/kit-digest.sh" "$@" ;;
|
|
263
|
+
bench)
|
|
264
|
+
# Documentation benchmark (#200) — score how well this project finds + uses its OWN canonical
|
|
265
|
+
# docs. Runs the PROJECT's scaffolded harness if present, else cckit's own copy. BENCH_KIT_ROOT
|
|
266
|
+
# lets the runner fall back to the shipped example set before a project grows its own data.
|
|
267
|
+
BENCH_ROOT="$PWD/scripts/benchmark"; [ -d "$BENCH_ROOT" ] || BENCH_ROOT="$ROOT/scripts/benchmark"
|
|
268
|
+
export BENCH_KIT_ROOT="$ROOT"
|
|
269
|
+
sub="${1:-report}"; shift || true
|
|
270
|
+
case "$sub" in
|
|
271
|
+
run) exec bash "$BENCH_ROOT/run.sh" "$@" ;;
|
|
272
|
+
quality) exec bash "$BENCH_ROOT/run-quality.sh" "$@" ;;
|
|
273
|
+
report) exec bash "$BENCH_ROOT/report.sh" "$@" ;;
|
|
274
|
+
gate) exec bash "$BENCH_ROOT/gate.sh" "$@" ;;
|
|
275
|
+
stop-check) exec bash "$BENCH_ROOT/stop-check.sh" "$@" ;;
|
|
276
|
+
-h|--help) echo 'cckit bench <run|quality|report|gate|stop-check> [--dry] [--json]'; exit 0 ;;
|
|
277
|
+
*) echo 'cckit bench <run|quality|report|gate|stop-check> [--dry] [--json]' >&2; exit 2 ;;
|
|
278
|
+
esac
|
|
279
|
+
;;
|
|
262
280
|
scan) source "$LIB/project-scan.sh"; project_scan "$@" ;;
|
|
263
281
|
encode-context) source "$LIB/toon.sh"; toon_encode ;;
|
|
264
282
|
render) source "$LIB/render.sh"; cckit_render ;;
|
package/cckit.config.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./kit.config.schema.json",
|
|
3
|
-
"kitVersion": "0.
|
|
3
|
+
"kitVersion": "0.6.1",
|
|
4
4
|
"project": {
|
|
5
5
|
"name": "cckit",
|
|
6
6
|
"slug": "cckit",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"github": {
|
|
13
13
|
"repo": "jeiemgi/cckit",
|
|
14
14
|
"owner": "jeiemgi",
|
|
15
|
-
"baseBranch": "
|
|
15
|
+
"baseBranch": "develop",
|
|
16
16
|
"projectsV2": false,
|
|
17
17
|
"projectNumber": null,
|
|
18
18
|
"projectTitle": null
|
package/package.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark-test.sh — self-test for the benchmark harness (#200). Offline only: the mock backend +
|
|
3
|
+
# --dry paths, so it never calls a real model. Run: bash scripts/benchmark/benchmark-test.sh
|
|
4
|
+
set -uo pipefail
|
|
5
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
6
|
+
|
|
7
|
+
fail=0
|
|
8
|
+
t() { if [ "$2" != "$3" ]; then echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; else echo "ok: $1"; fi; }
|
|
9
|
+
|
|
10
|
+
command -v jq >/dev/null 2>&1 || { echo "SKIP: jq absent"; exit 0; }
|
|
11
|
+
|
|
12
|
+
# ---- isolated fixture ------------------------------------------------------
|
|
13
|
+
FIX="$(mktemp -d)"; trap 'rm -rf "$FIX"' EXIT
|
|
14
|
+
mkdir -p "$FIX/bench"
|
|
15
|
+
cat > "$FIX/bench/benchmark.config.json" <<'JSON'
|
|
16
|
+
{ "knowledgeDir": "knowledge",
|
|
17
|
+
"sets": [
|
|
18
|
+
{"name":"retrieval","file":"retrieval.jsonl","tier":"retrieval"},
|
|
19
|
+
{"name":"abstain","file":"abstain.jsonl","tier":"abstain"},
|
|
20
|
+
{"name":"quality","file":"quality.jsonl","tier":"quality"} ],
|
|
21
|
+
"target": {"minRecords": 3, "cleanRounds": 2} }
|
|
22
|
+
JSON
|
|
23
|
+
printf '%s\n' '{"id":"r1","q":"How do we release?","expect":"releasing.md"}' \
|
|
24
|
+
'{"id":"r2","q":"Branch model?","expect":["branching.md","git.md"]}' > "$FIX/bench/retrieval.jsonl"
|
|
25
|
+
printf '%s\n' '{"id":"a1","q":"DB password?","expect":"NONE"}' > "$FIX/bench/abstain.jsonl"
|
|
26
|
+
printf '%s\n' '{"id":"q1","claim":"Summarize releasing.","must":["version bumped","tag pushed"]}' > "$FIX/bench/quality.jsonl"
|
|
27
|
+
|
|
28
|
+
export BENCH_DIR="$FIX/bench"
|
|
29
|
+
|
|
30
|
+
# ---- 1. --dry on well-formed data passes -----------------------------------
|
|
31
|
+
bash "$HERE/run.sh" --dry >/dev/null 2>&1; t "run --dry well-formed" "$?" "0"
|
|
32
|
+
bash "$HERE/run-quality.sh" --dry >/dev/null 2>&1; t "quality --dry well-formed" "$?" "0"
|
|
33
|
+
|
|
34
|
+
# ---- 2. --dry catches a malformed record -----------------------------------
|
|
35
|
+
printf '%s\n' '{"id":"bad","expect":"x.md"}' >> "$FIX/bench/retrieval.jsonl" # no q
|
|
36
|
+
bash "$HERE/run.sh" --dry >/dev/null 2>&1; t "run --dry missing q fails" "$?" "1"
|
|
37
|
+
# restore
|
|
38
|
+
printf '%s\n' '{"id":"r1","q":"How do we release?","expect":"releasing.md"}' \
|
|
39
|
+
'{"id":"r2","q":"Branch model?","expect":["branching.md","git.md"]}' > "$FIX/bench/retrieval.jsonl"
|
|
40
|
+
|
|
41
|
+
# ---- 3. abstain record with a stray expect path is caught? (abstain allows NONE only, so a non-
|
|
42
|
+
# abstain tier needs an expect; abstain with NONE is fine — validate a retrieval with NONE) -
|
|
43
|
+
printf '%s\n' '{"id":"noexp","q":"orphan?","expect":"NONE"}' >> "$FIX/bench/retrieval.jsonl"
|
|
44
|
+
bash "$HERE/run.sh" --dry >/dev/null 2>&1; t "run --dry retrieval w/ NONE expect fails" "$?" "1"
|
|
45
|
+
printf '%s\n' '{"id":"r1","q":"How do we release?","expect":"releasing.md"}' \
|
|
46
|
+
'{"id":"r2","q":"Branch model?","expect":["branching.md","git.md"]}' > "$FIX/bench/retrieval.jsonl"
|
|
47
|
+
|
|
48
|
+
# ---- 4. path matching ------------------------------------------------------
|
|
49
|
+
# shellcheck source=/dev/null
|
|
50
|
+
. "$HERE/lib/bench-common.sh"
|
|
51
|
+
bench_path_match "knowledge/releasing.md" '"releasing.md"'; t "match: kdir prefix stripped" "$?" "0"
|
|
52
|
+
bench_path_match "./releasing.md" '"releasing.md"'; t "match: ./ stripped" "$?" "0"
|
|
53
|
+
bench_path_match "git.md" '["branching.md","git.md"]'; t "match: array member" "$?" "0"
|
|
54
|
+
bench_path_match "other.md" '"releasing.md"'; t "no-match: different doc" "$?" "1"
|
|
55
|
+
|
|
56
|
+
# ---- 5. mock live scoring (mock backend always returns NONE) ----------------
|
|
57
|
+
# retrieval records fail (NONE != a path); the abstain record passes (NONE is correct).
|
|
58
|
+
res="$(BENCH_BACKEND=mock bash "$HERE/run.sh" --json 2>/dev/null)"
|
|
59
|
+
t "mock: abstain passes only" "$(printf '%s' "$res" | jq -r '.pass')" "1"
|
|
60
|
+
t "mock: retrieval both fail" "$(printf '%s' "$res" | jq -r '.fail')" "2"
|
|
61
|
+
|
|
62
|
+
# ---- 6. gate.sh clean on well-formed fixture -------------------------------
|
|
63
|
+
BENCH_SKIP_KNOWLEDGE_LINT=1 bash "$HERE/gate.sh" >/dev/null 2>&1; t "gate clean" "$?" "0"
|
|
64
|
+
|
|
65
|
+
# ---- 7. stop-check: size met but streak < rounds -> CONTINUE; 2nd clean -> STOP ----
|
|
66
|
+
rm -f "$FIX/bench/.stop-state.json"
|
|
67
|
+
BENCH_SKIP_KNOWLEDGE_LINT=1 bash "$HERE/stop-check.sh" >/dev/null 2>&1; rc1=$?
|
|
68
|
+
BENCH_SKIP_KNOWLEDGE_LINT=1 bash "$HERE/stop-check.sh" >/dev/null 2>&1; rc2=$?
|
|
69
|
+
t "stop-check round1 CONTINUE" "$rc1" "1"
|
|
70
|
+
t "stop-check round2 STOP" "$rc2" "0"
|
|
71
|
+
|
|
72
|
+
# ---- 8. stop-check below size target never stops ---------------------------
|
|
73
|
+
# minRecords=99 forces size_ok=false regardless of clean streak.
|
|
74
|
+
rm -f "$FIX/bench/.stop-state.json"
|
|
75
|
+
BENCH_SKIP_KNOWLEDGE_LINT=1 bash "$HERE/stop-check.sh" --min 99 >/dev/null 2>&1; t "stop-check below size CONTINUE" "$?" "1"
|
|
76
|
+
|
|
77
|
+
# ---- 9. report.sh writes a RESULTS.md --------------------------------------
|
|
78
|
+
bash "$HERE/report.sh" --dry --out "$FIX/RESULTS.md" >/dev/null 2>&1
|
|
79
|
+
t "report wrote RESULTS.md" "$([ -s "$FIX/RESULTS.md" ] && echo yes)" "yes"
|
|
80
|
+
grep -q "Documentation benchmark" "$FIX/RESULTS.md"; t "report has heading" "$?" "0"
|
|
81
|
+
|
|
82
|
+
[ "$fail" -eq 0 ] && echo "ALL OK" || echo "SOME FAILED"
|
|
83
|
+
exit "$fail"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark/gate.sh — the per-round "no-mistakes" bundle for the objective autopilot loop. It is the
|
|
3
|
+
# offline bar every round of growing/hardening the benchmark sets must clear before it counts as a
|
|
4
|
+
# clean round: nothing may be broken by an edit.
|
|
5
|
+
#
|
|
6
|
+
# Checks (all offline — NO model calls):
|
|
7
|
+
# 1. bash -n on every harness script (syntax).
|
|
8
|
+
# 2. run.sh --dry + run-quality.sh --dry on every set (dataset shape: every record well-formed).
|
|
9
|
+
# 3. the project's knowledge-lint (canonical-doc governance), if present — so a set that points at
|
|
10
|
+
# a doc which drifted out of the manifest is caught here.
|
|
11
|
+
#
|
|
12
|
+
# Usage: benchmark/gate.sh [--dir <benchmarks>]
|
|
13
|
+
# Exit 0 = clean round; non-zero = something is broken, do not count the round.
|
|
14
|
+
set -uo pipefail
|
|
15
|
+
|
|
16
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
17
|
+
DIRFLAG=()
|
|
18
|
+
while [ "$#" -gt 0 ]; do
|
|
19
|
+
case "$1" in
|
|
20
|
+
--dir) DIRFLAG=(--dir "$2"); shift 2 ;;
|
|
21
|
+
--dir=*) DIRFLAG=(--dir "${1#*=}"); shift ;;
|
|
22
|
+
-h|--help) sed -n '2,16p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
23
|
+
*) echo "gate.sh: unknown arg '$1'" >&2; exit 2 ;;
|
|
24
|
+
esac
|
|
25
|
+
done
|
|
26
|
+
|
|
27
|
+
fail=0
|
|
28
|
+
note() { printf '%s\n' "$*" >&2; }
|
|
29
|
+
|
|
30
|
+
note "==> [1/3] harness syntax (bash -n)"
|
|
31
|
+
for f in "$SCRIPT_DIR"/*.sh "$SCRIPT_DIR"/lib/*.sh; do
|
|
32
|
+
[ -e "$f" ] || continue
|
|
33
|
+
bash -n "$f" || { note "x syntax: $f"; fail=1; }
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
note "==> [2/3] every set --dry (dataset shape)"
|
|
37
|
+
bash "$SCRIPT_DIR/run.sh" --dry "${DIRFLAG[@]+"${DIRFLAG[@]}"}" || { note "x retrieval/abstain sets failed --dry"; fail=1; }
|
|
38
|
+
bash "$SCRIPT_DIR/run-quality.sh" --dry "${DIRFLAG[@]+"${DIRFLAG[@]}"}" || { note "x quality set failed --dry"; fail=1; }
|
|
39
|
+
|
|
40
|
+
note "==> [3/3] knowledge-lint (canonical-doc governance)"
|
|
41
|
+
# Prefer the project's own linter (it knows the project's knowledge dir + manifest); fall back to
|
|
42
|
+
# the kit's copy. Absent linter is not a failure — the gate stays dependency-light.
|
|
43
|
+
# BENCH_SKIP_KNOWLEDGE_LINT=1 opts out (self-tests run against a throwaway fixture, not a real KB).
|
|
44
|
+
if [ "${BENCH_SKIP_KNOWLEDGE_LINT:-0}" = "1" ]; then
|
|
45
|
+
note " (knowledge-lint skipped — BENCH_SKIP_KNOWLEDGE_LINT=1)"
|
|
46
|
+
elif [ -f "$PWD/scripts/knowledge-lint.sh" ]; then
|
|
47
|
+
bash "$PWD/scripts/knowledge-lint.sh" || { note "x knowledge-lint failed"; fail=1; }
|
|
48
|
+
elif [ -f "$SCRIPT_DIR/../knowledge-lint.sh" ]; then
|
|
49
|
+
bash "$SCRIPT_DIR/../knowledge-lint.sh" || { note "x knowledge-lint failed"; fail=1; }
|
|
50
|
+
else
|
|
51
|
+
note " (knowledge-lint absent — skipping)"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
[ "$fail" -eq 0 ] && note "PASS benchmark gate clean" || note "FAIL benchmark gate"
|
|
55
|
+
exit "$fail"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark/lib/bench-common.sh — shared plumbing for the benchmark harness: locate the benchmarks
|
|
3
|
+
# dir + its config, resolve the knowledge dir, read JSONL records, and the objective path-match
|
|
4
|
+
# predicate. Source this; do not execute it. Requires: jq.
|
|
5
|
+
|
|
6
|
+
# Resolve the benchmarks directory: explicit $BENCH_DIR wins, else ./benchmarks under the invoking
|
|
7
|
+
# project, else the example set shipped with cckit (templates/benchmarks) as a last resort so a
|
|
8
|
+
# fresh checkout can `--dry` before it has grown its own data.
|
|
9
|
+
bench_dir() {
|
|
10
|
+
if [ -n "${BENCH_DIR:-}" ]; then printf '%s' "$BENCH_DIR"; return; fi
|
|
11
|
+
if [ -d "$PWD/benchmarks" ]; then printf '%s' "$PWD/benchmarks"; return; fi
|
|
12
|
+
printf '%s' "${BENCH_KIT_ROOT:-.}/templates/benchmarks"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
# The benchmark config (sets + tiers + targets). Optional — the runner falls back to discovering
|
|
16
|
+
# *.jsonl in the dir when it is absent.
|
|
17
|
+
bench_config() {
|
|
18
|
+
local d; d="$(bench_dir)"
|
|
19
|
+
[ -f "$d/benchmark.config.json" ] && printf '%s' "$d/benchmark.config.json"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# The knowledge dir the docs live in. Prefer the benchmark config, else the loaded kit config
|
|
23
|
+
# (KIT_KNOWLEDGE_DIR), else the conventional default.
|
|
24
|
+
bench_knowledge_dir() {
|
|
25
|
+
local cfg kd
|
|
26
|
+
cfg="$(bench_config)"
|
|
27
|
+
if [ -n "$cfg" ]; then
|
|
28
|
+
kd="$(jq -r '.knowledgeDir // empty' "$cfg" 2>/dev/null)"
|
|
29
|
+
[ -n "$kd" ] && { printf '%s' "$kd"; return; }
|
|
30
|
+
fi
|
|
31
|
+
printf '%s' "${KIT_KNOWLEDGE_DIR:-knowledge}"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Objective top-hit path match. Args: <returned-path> <expected-json>. The expected value may be a
|
|
35
|
+
# single path or a JSON array of acceptable paths (split-canonical). A match is suffix-or-basename
|
|
36
|
+
# equality after stripping ./ and a leading knowledge-dir prefix — lenient about where the model
|
|
37
|
+
# rooted the path, strict about which document it named. Returns 0 on match.
|
|
38
|
+
bench_path_match() {
|
|
39
|
+
local got="$1" expect_json="$2" e norm_got norm_e
|
|
40
|
+
norm_got="$(bench_norm_path "$got")"
|
|
41
|
+
# Iterate the expected paths (works for a bare string too, jq -r '.[]?' handles arrays only, so
|
|
42
|
+
# normalize to an array first).
|
|
43
|
+
while IFS= read -r e; do
|
|
44
|
+
[ -n "$e" ] || continue
|
|
45
|
+
norm_e="$(bench_norm_path "$e")"
|
|
46
|
+
[ "$norm_got" = "$norm_e" ] && return 0
|
|
47
|
+
# basename equality catches "docs/x.md" vs "x.md"
|
|
48
|
+
[ "${norm_got##*/}" = "${norm_e##*/}" ] && [ "${norm_e##*/}" = "$norm_e" -o "${norm_got##*/}" != "$norm_got" ] && return 0
|
|
49
|
+
done < <(printf '%s' "$expect_json" | jq -r 'if type=="array" then .[] else . end' 2>/dev/null)
|
|
50
|
+
return 1
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Normalize a path for comparison: lowercase, strip surrounding quotes/space, drop a leading ./ and
|
|
54
|
+
# a leading <knowledge-dir>/ segment so "knowledge/a.md" and "a.md" compare equal.
|
|
55
|
+
bench_norm_path() {
|
|
56
|
+
local p="$1" kd
|
|
57
|
+
kd="$(bench_knowledge_dir)"
|
|
58
|
+
p="$(printf '%s' "$p" | tr 'A-Z' 'a-z' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')"
|
|
59
|
+
p="${p#./}"
|
|
60
|
+
p="${p#"$(printf '%s' "$kd" | tr 'A-Z' 'a-z')/"}"
|
|
61
|
+
printf '%s' "$p"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Emit each record of a JSONL set as one compact JSON object per line. Blank lines + # comments are
|
|
65
|
+
# skipped so a set file can be annotated.
|
|
66
|
+
bench_records() {
|
|
67
|
+
local file="$1"
|
|
68
|
+
[ -f "$file" ] || return 0
|
|
69
|
+
grep -vE '^[[:space:]]*(#|$)' "$file" | jq -c '.' 2>/dev/null
|
|
70
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark/lib/model.sh — the pluggable model backend for the benchmark harness.
|
|
3
|
+
#
|
|
4
|
+
# Two entry points, both cascade-shaped so the backend is swappable with NO hard dependency on a
|
|
5
|
+
# specific provider:
|
|
6
|
+
# bench_ask "<question>" -> prints ONE repo-relative doc path, or "NONE"
|
|
7
|
+
# bench_judge "<claim>" "<answer>" "<must>" -> prints a score in [0,1]
|
|
8
|
+
#
|
|
9
|
+
# Backend selection (first that applies wins), driven by env so a project overrides without editing:
|
|
10
|
+
# BENCH_BACKEND=mock deterministic, offline (tests + --dry); never calls a model
|
|
11
|
+
# BENCH_MODEL_ENDPOINT=<url> any OpenAI-compat /chat/completions endpoint (curl)
|
|
12
|
+
# (default) headless `claude -p` — the $0-API subscription path
|
|
13
|
+
#
|
|
14
|
+
# Everything is stdout-only + exit-code clean so the runner can capture answers and latency without
|
|
15
|
+
# a provider SDK. Source this file; do not execute it.
|
|
16
|
+
|
|
17
|
+
# ---- portable timeout ------------------------------------------------------
|
|
18
|
+
# `timeout(1)` is GNU/coreutils and absent on stock macOS. Fall back to a perl watchdog (perl is a
|
|
19
|
+
# kit dependency, see cckit doctor), then to a no-op that just runs the command. Usage:
|
|
20
|
+
# bench_timeout <seconds> <cmd> [args…]
|
|
21
|
+
bench_timeout() {
|
|
22
|
+
local secs="$1"; shift
|
|
23
|
+
if command -v timeout >/dev/null 2>&1; then
|
|
24
|
+
timeout "$secs" "$@"
|
|
25
|
+
elif command -v gtimeout >/dev/null 2>&1; then
|
|
26
|
+
gtimeout "$secs" "$@"
|
|
27
|
+
elif command -v perl >/dev/null 2>&1; then
|
|
28
|
+
perl -e 'my $s=shift; $SIG{ALRM}=sub{exit 124}; alarm $s; exec @ARGV or exit 127;' "$secs" "$@"
|
|
29
|
+
else
|
|
30
|
+
"$@"
|
|
31
|
+
fi
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
BENCH_TIMEOUT_SECS="${BENCH_TIMEOUT_SECS:-90}"
|
|
35
|
+
|
|
36
|
+
# ---- backend resolution ----------------------------------------------------
|
|
37
|
+
bench_backend() {
|
|
38
|
+
if [ -n "${BENCH_BACKEND:-}" ]; then printf '%s' "$BENCH_BACKEND"; return; fi
|
|
39
|
+
if [ -n "${BENCH_MODEL_ENDPOINT:-}" ]; then printf 'openai'; return; fi
|
|
40
|
+
printf 'claude'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# Low-level completion: prompt on $1, prints the model's raw text answer. Empty on failure — the
|
|
44
|
+
# callers decide what an empty answer means (NONE for ask, 0 for judge).
|
|
45
|
+
_bench_complete() {
|
|
46
|
+
local prompt="$1" backend
|
|
47
|
+
backend="$(bench_backend)"
|
|
48
|
+
case "$backend" in
|
|
49
|
+
mock)
|
|
50
|
+
# Deterministic offline stand-in. Never used for scoring — the runner only reaches a real
|
|
51
|
+
# backend when NOT --dry — but keeps the cascade total so sourcing never explodes.
|
|
52
|
+
printf 'NONE' ;;
|
|
53
|
+
openai)
|
|
54
|
+
command -v curl >/dev/null 2>&1 || { return 1; }
|
|
55
|
+
command -v jq >/dev/null 2>&1 || { return 1; }
|
|
56
|
+
local url="${BENCH_MODEL_ENDPOINT%/}/chat/completions"
|
|
57
|
+
local model="${BENCH_MODEL:-gpt-4o-mini}"
|
|
58
|
+
local body
|
|
59
|
+
body="$(jq -n --arg m "$model" --arg p "$prompt" \
|
|
60
|
+
'{model:$m, temperature:0, messages:[{role:"user",content:$p}]}')"
|
|
61
|
+
bench_timeout "$BENCH_TIMEOUT_SECS" curl -sS "$url" \
|
|
62
|
+
-H 'Content-Type: application/json' \
|
|
63
|
+
${BENCH_API_KEY:+-H "Authorization: Bearer $BENCH_API_KEY"} \
|
|
64
|
+
-d "$body" 2>/dev/null \
|
|
65
|
+
| jq -r '.choices[0].message.content // empty' 2>/dev/null ;;
|
|
66
|
+
claude|*)
|
|
67
|
+
command -v claude >/dev/null 2>&1 || { return 1; }
|
|
68
|
+
# Headless one-shot. `-p` prints the final answer and exits; the model may use its tools to
|
|
69
|
+
# grep the repo, which is exactly the retrieval behavior we want to measure.
|
|
70
|
+
bench_timeout "$BENCH_TIMEOUT_SECS" claude -p "$prompt" 2>/dev/null ;;
|
|
71
|
+
esac
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# ---- bench_ask -------------------------------------------------------------
|
|
75
|
+
# Ask the model which single canonical doc answers a question. Returns ONE repo-relative path (its
|
|
76
|
+
# top hit) or the literal NONE when nothing canonical covers it. $2 = knowledge dir (for the prompt).
|
|
77
|
+
bench_ask() {
|
|
78
|
+
local question="$1" kdir="${2:-knowledge}" out
|
|
79
|
+
local prompt
|
|
80
|
+
prompt="You are auditing a project's documentation. Question: \"$question\"
|
|
81
|
+
|
|
82
|
+
Find the SINGLE canonical document under '$kdir/' that best answers it. Reply with ONLY that
|
|
83
|
+
document's repo-relative path on one line (for example: $kdir/releasing.md) and nothing else.
|
|
84
|
+
If no document genuinely answers it, reply with exactly: NONE"
|
|
85
|
+
out="$(_bench_complete "$prompt")" || return 1
|
|
86
|
+
# Keep only the last non-empty line, trimmed — models sometimes narrate before the path.
|
|
87
|
+
out="$(printf '%s\n' "$out" | awk 'NF{last=$0} END{print last}')"
|
|
88
|
+
out="$(printf '%s' "$out" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//; s/^["`'\'']//; s/["`'\'']$//')"
|
|
89
|
+
[ -n "$out" ] || out="NONE"
|
|
90
|
+
printf '%s' "$out"
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# ---- bench_judge -----------------------------------------------------------
|
|
94
|
+
# Score a claim-style answer against a `must` rubric (newline-separated points). The rubric de-biases
|
|
95
|
+
# the judge: it scores coverage of the required points, not vibes. Prints a float in [0,1].
|
|
96
|
+
bench_judge() {
|
|
97
|
+
local claim="$1" answer="$2" must="$3" out score
|
|
98
|
+
local prompt
|
|
99
|
+
prompt="Grade an answer against a rubric. Be strict and objective.
|
|
100
|
+
|
|
101
|
+
QUESTION/CLAIM:
|
|
102
|
+
$claim
|
|
103
|
+
|
|
104
|
+
ANSWER TO GRADE:
|
|
105
|
+
$answer
|
|
106
|
+
|
|
107
|
+
REQUIRED POINTS (the answer must cover these; ignore style):
|
|
108
|
+
$must
|
|
109
|
+
|
|
110
|
+
Reply with ONLY a number between 0 and 1 (e.g. 0.75) = the fraction of required points the answer
|
|
111
|
+
correctly covers. No words."
|
|
112
|
+
out="$(_bench_complete "$prompt")" || { printf '0'; return 0; }
|
|
113
|
+
score="$(printf '%s' "$out" | grep -oE '0(\.[0-9]+)?|1(\.0+)?' | head -1)"
|
|
114
|
+
[ -n "$score" ] || score="0"
|
|
115
|
+
printf '%s' "$score"
|
|
116
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark/report.sh — turn a benchmark run into a plain, low-jargon RESULTS.md a non-expert can
|
|
3
|
+
# read: what we tested, what passed, and the one headline score. Runs the retrieval + quality tiers
|
|
4
|
+
# (unless handed pre-computed JSON on stdin) and writes RESULTS.md into the benchmarks dir.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# benchmark/report.sh [--dir <benchmarks>] [--dry] [--out <path>]
|
|
8
|
+
# benchmark/run.sh --json | benchmark/report.sh --stdin # report a run you already have
|
|
9
|
+
#
|
|
10
|
+
# --dry run both tiers in --dry (offline, no model) so the report renders the shape of the
|
|
11
|
+
# suite without spending a model call — handy in CI to prove report.sh works.
|
|
12
|
+
set -uo pipefail
|
|
13
|
+
|
|
14
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
15
|
+
# shellcheck source=/dev/null
|
|
16
|
+
. "$SCRIPT_DIR/lib/bench-common.sh"
|
|
17
|
+
|
|
18
|
+
DRY=0; OUT=""; STDIN=0
|
|
19
|
+
while [ "$#" -gt 0 ]; do
|
|
20
|
+
case "$1" in
|
|
21
|
+
--dry) DRY=1; shift ;;
|
|
22
|
+
--stdin) STDIN=1; shift ;;
|
|
23
|
+
--out) OUT="$2"; shift 2 ;;
|
|
24
|
+
--out=*) OUT="${1#*=}"; shift ;;
|
|
25
|
+
--dir) BENCH_DIR="$2"; export BENCH_DIR; shift 2 ;;
|
|
26
|
+
--dir=*) BENCH_DIR="${1#*=}"; export BENCH_DIR; shift ;;
|
|
27
|
+
-h|--help) sed -n '2,14p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
28
|
+
*) echo "report.sh: unknown arg '$1'" >&2; exit 2 ;;
|
|
29
|
+
esac
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
command -v jq >/dev/null 2>&1 || { echo "report.sh: jq is required" >&2; exit 2; }
|
|
33
|
+
|
|
34
|
+
DIR="$(bench_dir)"
|
|
35
|
+
[ -n "$OUT" ] || OUT="$DIR/RESULTS.md"
|
|
36
|
+
DRYFLAG=""; [ "$DRY" -eq 1 ] && DRYFLAG="--dry"
|
|
37
|
+
|
|
38
|
+
# Gather the two tier summaries (retrieval+abstain+adversarial in one, quality separately).
|
|
39
|
+
if [ "$STDIN" -eq 1 ]; then
|
|
40
|
+
RET_JSON="$(cat)"
|
|
41
|
+
QUAL_JSON='{"kind":"quality-run","dry":true,"count":0,"mean":0,"results":[]}'
|
|
42
|
+
else
|
|
43
|
+
RET_JSON="$(bash "$SCRIPT_DIR/run.sh" $DRYFLAG --json 2>/dev/null || echo '{}')"
|
|
44
|
+
QUAL_JSON="$(bash "$SCRIPT_DIR/run-quality.sh" $DRYFLAG --json 2>/dev/null || echo '{}')"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
# Pull the numbers with safe defaults (a tier may be absent).
|
|
48
|
+
r_total="$(printf '%s' "$RET_JSON" | jq -r '.total // 0')"
|
|
49
|
+
r_pass="$(printf '%s' "$RET_JSON" | jq -r '.pass // 0')"
|
|
50
|
+
r_pct="$(printf '%s' "$RET_JSON" | jq -r '.score_pct // 0')"
|
|
51
|
+
r_dry="$(printf '%s' "$RET_JSON" | jq -r '.dry // false')"
|
|
52
|
+
q_count="$(printf '%s' "$QUAL_JSON" | jq -r '.count // 0')"
|
|
53
|
+
q_mean="$(printf '%s' "$QUAL_JSON" | jq -r '.mean // 0')"
|
|
54
|
+
|
|
55
|
+
STAMP="$(date -u '+%Y-%m-%d %H:%M UTC' 2>/dev/null || echo 'unknown time')"
|
|
56
|
+
MODE="live"; [ "$r_dry" = "true" ] && MODE="dry (data validated offline, no model asked)"
|
|
57
|
+
|
|
58
|
+
# Per-tier breakdown table from the detailed results.
|
|
59
|
+
TIER_ROWS="$(printf '%s' "$RET_JSON" | jq -r '
|
|
60
|
+
(.results // []) | group_by(.tier)[]
|
|
61
|
+
| { tier: .[0].tier, pass: (map(select(.pass)) | length), total: length }
|
|
62
|
+
| "| \(.tier) | \(.pass)/\(.total) | \( (if .total>0 then (.pass*100/.total) else 0 end) | floor )% |"' 2>/dev/null)"
|
|
63
|
+
[ -n "$TIER_ROWS" ] || TIER_ROWS="| (no per-tier detail in --dry) | $r_pass/$r_total | ${r_pct}% |"
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
echo "# Documentation benchmark — RESULTS"
|
|
67
|
+
echo
|
|
68
|
+
echo "_Generated ${STAMP} · mode: ${MODE}_"
|
|
69
|
+
echo
|
|
70
|
+
echo "## What this measures"
|
|
71
|
+
echo
|
|
72
|
+
echo "How well this project's own canonical documents can be **found and used** by an agent that"
|
|
73
|
+
echo "starts cold — the same way a new teammate or an AI assistant would. A high score means the"
|
|
74
|
+
echo "docs are discoverable and the answers in them are complete."
|
|
75
|
+
echo
|
|
76
|
+
echo "## Headline"
|
|
77
|
+
echo
|
|
78
|
+
if [ "$r_dry" = "true" ]; then
|
|
79
|
+
echo "- **Offline shape check** — ${r_total} retrieval/abstain records and the quality set were"
|
|
80
|
+
echo " validated as well-formed. This is not a live score; run without \`--dry\` to score."
|
|
81
|
+
else
|
|
82
|
+
echo "- **Retrieval score: ${r_pct}%** — of ${r_total} questions, the agent pointed at the right"
|
|
83
|
+
echo " canonical document (or correctly abstained) **${r_pass}** times."
|
|
84
|
+
if [ "$q_count" -gt 0 ]; then
|
|
85
|
+
echo "- **Answer quality: ${q_mean} / 1.0** — average completeness of ${q_count} judged answers."
|
|
86
|
+
fi
|
|
87
|
+
fi
|
|
88
|
+
echo
|
|
89
|
+
echo "## By tier"
|
|
90
|
+
echo
|
|
91
|
+
echo "| Tier | Passed | Score |"
|
|
92
|
+
echo "| --- | --- | --- |"
|
|
93
|
+
printf '%s\n' "$TIER_ROWS"
|
|
94
|
+
echo
|
|
95
|
+
echo "## How to read this"
|
|
96
|
+
echo
|
|
97
|
+
echo "- **Retrieval** — plain questions; can the agent find the one right doc?"
|
|
98
|
+
echo "- **Adversarial** — reworded / no-keyword / trap questions; does retrieval survive them?"
|
|
99
|
+
echo "- **Abstain** — questions with no documented answer; the agent must say \"none\", not invent one."
|
|
100
|
+
echo "- **Quality** — the answer is graded 0–1 for completeness against a fixed checklist."
|
|
101
|
+
echo
|
|
102
|
+
echo "Run again with \`benchmark/report.sh\` after any docs or kit change to catch regressions."
|
|
103
|
+
} > "$OUT"
|
|
104
|
+
|
|
105
|
+
echo "report.sh: wrote $OUT (retrieval ${r_pct}%${q_count:+, quality ${q_mean}})"
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark/run-quality.sh — the quality judge tier.
|
|
3
|
+
#
|
|
4
|
+
# Beyond "did the agent find the doc", this measures "was the answer correct + complete". For each
|
|
5
|
+
# claim-style record the model answers headlessly (bench_ask-style, but a full answer), then a judge
|
|
6
|
+
# scores that answer 0..1 against the record's `must` rubric. The rubric de-biases the judge: it
|
|
7
|
+
# grades coverage of the required points, not tone. The tier score is the mean.
|
|
8
|
+
#
|
|
9
|
+
# Usage:
|
|
10
|
+
# benchmark/run-quality.sh [--set <file>] [--dir <benchmarks>] [--dry] [--json]
|
|
11
|
+
#
|
|
12
|
+
# --dry validate every record has a claim + a non-empty `must` rubric; call NO model; exit 0.
|
|
13
|
+
# --set run one quality set; else every tier:"quality" set in benchmark.config.json (or every
|
|
14
|
+
# *quality*.jsonl in the dir).
|
|
15
|
+
set -uo pipefail
|
|
16
|
+
|
|
17
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
18
|
+
# shellcheck source=/dev/null
|
|
19
|
+
. "$SCRIPT_DIR/lib/bench-common.sh"
|
|
20
|
+
# shellcheck source=/dev/null
|
|
21
|
+
. "$SCRIPT_DIR/lib/model.sh"
|
|
22
|
+
|
|
23
|
+
DRY=0; JSON=0; ONE_SET=""
|
|
24
|
+
while [ "$#" -gt 0 ]; do
|
|
25
|
+
case "$1" in
|
|
26
|
+
--dry) DRY=1; shift ;;
|
|
27
|
+
--json|--llm) JSON=1; shift ;;
|
|
28
|
+
--set) ONE_SET="$2"; shift 2 ;;
|
|
29
|
+
--set=*) ONE_SET="${1#*=}"; shift ;;
|
|
30
|
+
--dir) BENCH_DIR="$2"; export BENCH_DIR; shift 2 ;;
|
|
31
|
+
--dir=*) BENCH_DIR="${1#*=}"; export BENCH_DIR; shift ;;
|
|
32
|
+
-h|--help) sed -n '2,18p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
33
|
+
*) echo "run-quality.sh: unknown arg '$1'" >&2; exit 2 ;;
|
|
34
|
+
esac
|
|
35
|
+
done
|
|
36
|
+
|
|
37
|
+
command -v jq >/dev/null 2>&1 || { echo "run-quality.sh: jq is required" >&2; exit 2; }
|
|
38
|
+
|
|
39
|
+
DIR="$(bench_dir)"
|
|
40
|
+
KDIR="$(bench_knowledge_dir)"
|
|
41
|
+
CFG="$(bench_config)"
|
|
42
|
+
|
|
43
|
+
SETS=()
|
|
44
|
+
if [ -n "$ONE_SET" ]; then
|
|
45
|
+
f="$ONE_SET"; [ -f "$f" ] || f="$DIR/$ONE_SET"
|
|
46
|
+
SETS+=("$f")
|
|
47
|
+
elif [ -n "$CFG" ]; then
|
|
48
|
+
while IFS= read -r f; do [ -n "$f" ] && SETS+=("$DIR/$f"); done \
|
|
49
|
+
< <(jq -r '.sets[]? | select((.tier // "") == "quality") | .file' "$CFG")
|
|
50
|
+
else
|
|
51
|
+
for f in "$DIR"/*quality*.jsonl; do [ -e "$f" ] && SETS+=("$f"); done
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
[ "${#SETS[@]}" -ge 1 ] || { echo "run-quality.sh: no quality sets found in $DIR" >&2; exit 2; }
|
|
55
|
+
|
|
56
|
+
N=0; SUM="0"; FAILN=0
|
|
57
|
+
RESULTS_JSON="[]"
|
|
58
|
+
|
|
59
|
+
for file in "${SETS[@]}"; do
|
|
60
|
+
[ -f "$file" ] || { echo "run-quality.sh: set missing: $file" >&2; FAILN=$((FAILN+1)); continue; }
|
|
61
|
+
while IFS= read -r rec; do
|
|
62
|
+
[ -n "$rec" ] || continue
|
|
63
|
+
id="$(printf '%s' "$rec" | jq -r '.id // "?"')"
|
|
64
|
+
claim="$(printf '%s' "$rec" | jq -r '.claim // .q // empty')"
|
|
65
|
+
must="$(printf '%s' "$rec" | jq -r '(.must // []) | join("\n")')"
|
|
66
|
+
|
|
67
|
+
if [ "$DRY" -eq 1 ]; then
|
|
68
|
+
N=$((N+1))
|
|
69
|
+
if [ -z "$claim" ]; then echo "run-quality.sh --dry: $file id=$id missing 'claim'" >&2; FAILN=$((FAILN+1)); fi
|
|
70
|
+
if [ -z "$must" ]; then echo "run-quality.sh --dry: $file id=$id has empty 'must' rubric" >&2; FAILN=$((FAILN+1)); fi
|
|
71
|
+
continue
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
answer="$(bench_ask "$claim" "$KDIR")"
|
|
75
|
+
score="$(bench_judge "$claim" "$answer" "$must")"
|
|
76
|
+
N=$((N+1))
|
|
77
|
+
SUM="$(awk -v a="$SUM" -v b="$score" 'BEGIN{printf "%.4f", a+b}')"
|
|
78
|
+
RESULTS_JSON="$(printf '%s' "$RESULTS_JSON" | jq -c \
|
|
79
|
+
--arg set "$(basename "$file")" --arg id "$id" --arg score "$score" \
|
|
80
|
+
'. + [{set:$set,id:$id,score:($score|tonumber)}]')"
|
|
81
|
+
done < <(bench_records "$file")
|
|
82
|
+
done
|
|
83
|
+
|
|
84
|
+
MEAN="0"; [ "$N" -gt 0 ] && MEAN="$(awk -v s="$SUM" -v n="$N" 'BEGIN{printf "%.3f", s/n}')"
|
|
85
|
+
|
|
86
|
+
if [ "$JSON" -eq 1 ]; then
|
|
87
|
+
jq -n --argjson n "$N" --arg mean "$MEAN" --argjson dry "$DRY" --argjson results "$RESULTS_JSON" \
|
|
88
|
+
'{kind:"quality-run", dry:($dry==1), count:$n, mean:($mean|tonumber), results:$results}'
|
|
89
|
+
else
|
|
90
|
+
printf 'quality run%s — %s\n' "$([ "$DRY" -eq 1 ] && echo ' (--dry)')" "$DIR"
|
|
91
|
+
if [ "$DRY" -eq 1 ]; then
|
|
92
|
+
printf 'validated %s record(s)\n' "$N"
|
|
93
|
+
else
|
|
94
|
+
printf 'mean score: %s over %s claim(s)\n' "$MEAN" "$N"
|
|
95
|
+
fi
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
if [ "$DRY" -eq 1 ]; then
|
|
99
|
+
[ "$FAILN" -eq 0 ] && exit 0 || exit 1
|
|
100
|
+
fi
|
|
101
|
+
# A live quality run is informational (a mean, not a pass/fail bar) — exit 0 unless a set was missing.
|
|
102
|
+
[ "$FAILN" -eq 0 ] && exit 0 || exit 1
|