@jeiemgi/cckit 0.9.0 → 0.10.0

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.
Files changed (305) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +169 -21
  3. package/README.md +491 -35
  4. package/SECURITY.md +5 -0
  5. package/bin/cckit +182 -17
  6. package/cckit.config.json +1 -1
  7. package/commands/kit-doctor.md +13 -5
  8. package/commands/kit-export-project.md +0 -2
  9. package/commands/kit-export-training.md +6 -9
  10. package/commands/kit-init.md +43 -13
  11. package/commands/kit-routines.md +1 -1
  12. package/commands/kit-update.md +11 -6
  13. package/databases/supabase/guide.html +106 -0
  14. package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
  15. package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
  16. package/databases/supabase.json +70 -0
  17. package/integrations/emil-design-eng.json +41 -0
  18. package/integrations/graft.json +81 -0
  19. package/integrations/impeccable.json +42 -0
  20. package/integrations/integration.schema.json +215 -0
  21. package/integrations/lavish.json +43 -0
  22. package/integrations/mempalace.json +28 -0
  23. package/integrations/mlx-lm.json +32 -0
  24. package/integrations/web-design-guidelines.json +42 -0
  25. package/kit.config.schema.json +183 -5
  26. package/package.json +4 -1
  27. package/profiles/automation.json +7 -1
  28. package/profiles/content.json +10 -2
  29. package/profiles/marketing.json +57 -0
  30. package/profiles/minimal.json +7 -1
  31. package/profiles/research.json +7 -1
  32. package/profiles/software.json +7 -1
  33. package/recipes/nextjs-shadcn.json +49 -0
  34. package/scripts/agent-skills-external.txt +45 -0
  35. package/scripts/agent-skills-lint-test.sh +131 -0
  36. package/scripts/agent-skills-lint.sh +115 -0
  37. package/scripts/agent-template-lint-test.sh +42 -0
  38. package/scripts/agent-template-lint.sh +58 -0
  39. package/scripts/annotate-setup.sh +1 -1
  40. package/scripts/autopilot-run-test.sh +338 -0
  41. package/scripts/autopilot-run.sh +448 -0
  42. package/scripts/autopilot-test.sh +8 -0
  43. package/scripts/autopilot.sh +10 -1
  44. package/scripts/benchmark/benchmark-test.sh +85 -0
  45. package/scripts/benchmark/checkpoint-test.sh +314 -0
  46. package/scripts/benchmark/checkpoint.sh +408 -0
  47. package/scripts/benchmark/lib/model.sh +31 -6
  48. package/scripts/benchmark/report.sh +17 -2
  49. package/scripts/benchmark/run-quality.sh +36 -10
  50. package/scripts/benchmark/verb-timings-test.sh +124 -0
  51. package/scripts/benchmark/verb-timings.sh +149 -0
  52. package/scripts/check.sh +29 -19
  53. package/scripts/content-skills-test.sh +144 -0
  54. package/scripts/copilot-loop-test.sh +25 -0
  55. package/scripts/database-supabase-test.sh +121 -0
  56. package/scripts/docs-marketing-words-test.sh +73 -0
  57. package/scripts/docs-record-tables-test.sh +72 -0
  58. package/scripts/hook-adapter-test.sh +193 -0
  59. package/scripts/init-content-test.sh +225 -0
  60. package/scripts/init-guided-test.sh +474 -0
  61. package/scripts/init-recipes-test.sh +104 -0
  62. package/scripts/init-upgrade-test.sh +341 -2
  63. package/scripts/init.sh +746 -95
  64. package/scripts/instruction-budget-baseline.txt +8 -0
  65. package/scripts/instruction-budget-lint-test.sh +166 -0
  66. package/scripts/instruction-budget-lint.sh +219 -0
  67. package/scripts/integrations-check-test.sh +200 -0
  68. package/scripts/integrations-check.sh +157 -0
  69. package/scripts/kit-add-test.sh +214 -0
  70. package/scripts/kit-add.sh +305 -5
  71. package/scripts/kit-adopt-test.sh +16 -0
  72. package/scripts/kit-adopt.sh +3 -2
  73. package/scripts/kit-digest.sh +2 -2
  74. package/scripts/kit-doctor-test.sh +293 -0
  75. package/scripts/kit-doctor.sh +272 -140
  76. package/scripts/kit-export-project-test.sh +3 -3
  77. package/scripts/kit-remove-test.sh +19 -0
  78. package/scripts/kit-routines.sh +2 -2
  79. package/scripts/kit-self-update.sh +1 -1
  80. package/scripts/kit-version-check-test.sh +4 -0
  81. package/scripts/kit-version-check.sh +4 -2
  82. package/scripts/knowledge-lint.sh +4 -4
  83. package/scripts/leak-fence-test.sh +89 -0
  84. package/scripts/lib/adapter-select-test.sh +136 -0
  85. package/scripts/lib/adapter-select.sh +158 -0
  86. package/scripts/lib/agent-def-test.sh +69 -0
  87. package/scripts/lib/agent-def.sh +106 -0
  88. package/scripts/lib/agent-launch-test.sh +212 -0
  89. package/scripts/lib/agent-launch.sh +335 -0
  90. package/scripts/lib/board-view-test.sh +11 -0
  91. package/scripts/lib/board-view.sh +42 -26
  92. package/scripts/lib/branch-owner-test.sh +26 -0
  93. package/scripts/lib/branch-owner.sh +16 -9
  94. package/scripts/lib/captain-test.sh +105 -0
  95. package/scripts/lib/captain.sh +87 -8
  96. package/scripts/lib/codex-hooks-test.sh +100 -0
  97. package/scripts/lib/codex-hooks.sh +69 -0
  98. package/scripts/lib/commitlint.sh +1 -1
  99. package/scripts/lib/content-kinds-gc-test.sh +88 -0
  100. package/scripts/lib/copilot-test.sh +70 -4
  101. package/scripts/lib/copilot.sh +66 -14
  102. package/scripts/lib/effort-dispatch-test.sh +3 -3
  103. package/scripts/lib/effort-metrics-test.sh +178 -1
  104. package/scripts/lib/effort-metrics.sh +175 -35
  105. package/scripts/lib/effort-ops-test.sh +205 -7
  106. package/scripts/lib/effort-ops.sh +198 -43
  107. package/scripts/lib/effort-parity-test.sh +49 -13
  108. package/scripts/lib/effort-plan-test.sh +337 -0
  109. package/scripts/lib/effort-plan.sh +200 -23
  110. package/scripts/lib/effort.sh +56 -11
  111. package/scripts/lib/errors-header-test.sh +1 -1
  112. package/scripts/lib/gh-project-test.sh +35 -1
  113. package/scripts/lib/gh-project.sh +23 -16
  114. package/scripts/lib/gh-rest-test.sh +32 -3
  115. package/scripts/lib/gh-rest.sh +17 -2
  116. package/scripts/lib/hook-refresh.sh +1 -1
  117. package/scripts/lib/init-github.sh +412 -0
  118. package/scripts/lib/init-guide.sh +630 -0
  119. package/scripts/lib/integration-install-test.sh +343 -0
  120. package/scripts/lib/integration-install.sh +257 -0
  121. package/scripts/lib/integrations-test.sh +366 -0
  122. package/scripts/lib/integrations.sh +244 -0
  123. package/scripts/lib/kinds-test.sh +125 -0
  124. package/scripts/lib/kinds.sh +66 -0
  125. package/scripts/lib/kit-brief-test.sh +22 -3
  126. package/scripts/lib/kit-brief.sh +45 -5
  127. package/scripts/lib/kit-config-resolve.sh +2 -2
  128. package/scripts/lib/kit-config-test.sh +64 -1
  129. package/scripts/lib/kit-config.sh +37 -1
  130. package/scripts/lib/kit-events.sh +7 -0
  131. package/scripts/lib/kit-gc-test.sh +173 -1
  132. package/scripts/lib/kit-gc.sh +226 -37
  133. package/scripts/lib/kit-hotfix.sh +216 -0
  134. package/scripts/lib/kit-interview-test.sh +93 -0
  135. package/scripts/lib/kit-interview.sh +117 -8
  136. package/scripts/lib/kit-lib-test.sh +1 -1
  137. package/scripts/lib/kit-lib.sh +3 -3
  138. package/scripts/lib/kit-local.sh +2 -2
  139. package/scripts/lib/kit-manifest.sh +33 -1
  140. package/scripts/lib/kit-profile-test.sh +3 -3
  141. package/scripts/lib/kit-status-test.sh +112 -4
  142. package/scripts/lib/kit-status.sh +246 -16
  143. package/scripts/lib/kit-task-ops-test.sh +37 -0
  144. package/scripts/lib/kit-task-ops.sh +175 -31
  145. package/scripts/lib/kto-hotfix-test.sh +232 -0
  146. package/scripts/lib/kto-task-close-test.sh +1 -1
  147. package/scripts/lib/kto-task-new-test.sh +95 -0
  148. package/scripts/lib/kto-task-pr-merge-test.sh +37 -3
  149. package/scripts/lib/kto-task-pr-test.sh +70 -0
  150. package/scripts/lib/leak-fence.sh +89 -0
  151. package/scripts/lib/light-task-run-test.sh +255 -0
  152. package/scripts/lib/light-task-test.sh +309 -0
  153. package/scripts/lib/light-task.sh +706 -0
  154. package/scripts/lib/next-test.sh +99 -0
  155. package/scripts/lib/next.sh +9 -3
  156. package/scripts/lib/orchestration-runtime-test.sh +72 -0
  157. package/scripts/lib/orchestration-runtime.sh +57 -5
  158. package/scripts/lib/plan-machine-test.sh +15 -2
  159. package/scripts/lib/plan-machine.sh +20 -7
  160. package/scripts/lib/plan-next-test.sh +1 -1
  161. package/scripts/lib/plan-next.sh +4 -4
  162. package/scripts/lib/pr-evidence-test.sh +3 -3
  163. package/scripts/lib/pr-evidence.sh +1 -1
  164. package/scripts/lib/qa-lane-test.sh +626 -0
  165. package/scripts/lib/qa-lane.sh +1357 -0
  166. package/scripts/lib/qa-lanes-test.sh +175 -0
  167. package/scripts/lib/react-detect.sh +1 -1
  168. package/scripts/lib/render-test.sh +1 -1
  169. package/scripts/lib/review-page-test.sh +318 -0
  170. package/scripts/lib/review-page.sh +369 -0
  171. package/scripts/lib/review-stage-test.sh +62 -11
  172. package/scripts/lib/review-stage.sh +42 -60
  173. package/scripts/lib/role-identity-test.sh +65 -0
  174. package/scripts/lib/role-identity.sh +25 -2
  175. package/scripts/lib/secret-guard.sh +3 -3
  176. package/scripts/lib/session-registry-test.sh +111 -0
  177. package/scripts/lib/session-registry.sh +233 -0
  178. package/scripts/lib/stage-receipt-test.sh +14 -1
  179. package/scripts/lib/stage-receipt.sh +13 -8
  180. package/scripts/lib/task-source-file.sh +309 -0
  181. package/scripts/lib/task-source.sh +130 -0
  182. package/scripts/lib/upgrade-report-test.sh +120 -0
  183. package/scripts/lib/upgrade-report.sh +138 -0
  184. package/scripts/lib/version-bump.sh +3 -3
  185. package/scripts/lib/wave-result-test.sh +80 -0
  186. package/scripts/lib/wave-result.sh +127 -0
  187. package/scripts/lib/worker-brief-test.sh +5 -0
  188. package/scripts/lib/worker-brief.sh +2 -2
  189. package/scripts/lib/worktree-issue-test.sh +30 -1
  190. package/scripts/lib/worktree-issue.sh +82 -12
  191. package/scripts/lib/worktree-ports-test.sh +57 -4
  192. package/scripts/lib/worktree-start-test.sh +197 -0
  193. package/scripts/lib/worktree-start.sh +153 -31
  194. package/scripts/lib/zsh-safety-test.sh +19 -3
  195. package/scripts/marketing-walkthrough-test.sh +152 -0
  196. package/scripts/night-grant-test.sh +37 -0
  197. package/scripts/night-grant.sh +448 -0
  198. package/scripts/night-run-test.sh +8 -0
  199. package/scripts/night-run.mjs +275 -0
  200. package/scripts/night-run.test.mjs +324 -0
  201. package/scripts/orchestrate-test.sh +190 -0
  202. package/scripts/orchestrate.sh +79 -8
  203. package/scripts/portable-test.sh +11 -2
  204. package/scripts/publish.sh +28 -3
  205. package/scripts/review-lint-test.sh +7 -7
  206. package/scripts/review-lint.sh +2 -2
  207. package/scripts/review-rules.conf +8 -0
  208. package/scripts/rule-recipes-test.sh +96 -0
  209. package/scripts/self-install-test.sh +39 -9
  210. package/scripts/setup-labels.sh +18 -1
  211. package/scripts/setup-milestones.sh +1 -1
  212. package/scripts/showcase.sh +1 -1
  213. package/scripts/skill-frontmatter-lint-test.sh +4 -4
  214. package/scripts/skill-frontmatter-lint.sh +1 -1
  215. package/scripts/status-test.sh +113 -2
  216. package/scripts/status.sh +16 -3
  217. package/scripts/task-sync-test.sh +154 -0
  218. package/scripts/task-sync.sh +243 -32
  219. package/scripts/test-runner-test.sh +158 -0
  220. package/scripts/test.sh +131 -23
  221. package/scripts/update-path-test.sh +279 -0
  222. package/scripts/ux-ds-audit.sh +1 -1
  223. package/scripts/ux-graph-scan.sh +6 -6
  224. package/scripts/wave-worker.sh +54 -0
  225. package/skills/kit-add/SKILL.md +77 -0
  226. package/skills/kit-autopilot/SKILL.md +123 -12
  227. package/skills/kit-cleanup/SKILL.md +5 -2
  228. package/skills/kit-contribute/SKILL.md +4 -4
  229. package/skills/kit-docs-writer/SKILL.md +16 -6
  230. package/skills/kit-effort-close/SKILL.md +17 -8
  231. package/skills/kit-effort-new/SKILL.md +15 -9
  232. package/skills/kit-effort-pr/SKILL.md +15 -7
  233. package/skills/kit-effort-start/SKILL.md +5 -2
  234. package/skills/kit-gc/SKILL.md +5 -2
  235. package/skills/kit-next/SKILL.md +5 -1
  236. package/skills/kit-onboard/SKILL.md +3 -3
  237. package/skills/kit-page/SKILL.md +93 -0
  238. package/skills/kit-plan-next/SKILL.md +8 -4
  239. package/skills/kit-security-sweep/SKILL.md +1 -3
  240. package/skills/kit-ship/SKILL.md +2 -3
  241. package/skills/kit-status/SKILL.md +35 -4
  242. package/skills/kit-task-new/SKILL.md +3 -3
  243. package/skills/kit-task-pr/SKILL.md +7 -2
  244. package/skills/kit-task-pr-merge/SKILL.md +7 -2
  245. package/skills/kit-task-start/SKILL.md +7 -7
  246. package/skills/kit-task-sync/SKILL.md +19 -3
  247. package/skills/kit-ux-audit/SKILL.md +3 -2
  248. package/templates/agents/auto-dev.md +5 -4
  249. package/templates/agents/backend.md +1 -1
  250. package/templates/agents/designer.md +2 -0
  251. package/templates/agents/devops.md +1 -1
  252. package/templates/agents/editor.md +9 -1
  253. package/templates/agents/frontend.md +1 -1
  254. package/templates/agents/local-delegate.md +1 -1
  255. package/templates/agents/pm.md +5 -5
  256. package/templates/agents/tech-lead.md +1 -1
  257. package/templates/benchmarks/SCHEMA.md +9 -3
  258. package/templates/codex/hooks.json.tmpl +89 -0
  259. package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
  260. package/templates/hooks/guard-raw-git-ops.sh.tmpl +12 -12
  261. package/templates/hooks/mempal_followup.sh.tmpl +2 -2
  262. package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
  263. package/templates/hooks/prepush_gate.sh.tmpl +4 -2
  264. package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
  265. package/templates/instructions.md.tmpl +174 -0
  266. package/templates/kit.config.json.tmpl +3 -3
  267. package/templates/knowledge-INDEX.md.tmpl +1 -1
  268. package/templates/lib/kit-sigil.sh.tmpl +1 -1
  269. package/templates/rules/authoring.md +106 -0
  270. package/templates/rules/branch-naming.md +40 -4
  271. package/templates/rules/code-retrieval.md +63 -0
  272. package/templates/rules/delegation-brief.md +0 -3
  273. package/templates/rules/design-routing.md +3 -3
  274. package/templates/rules/effort-model.md +14 -10
  275. package/templates/rules/gate-and-review.md +94 -0
  276. package/templates/rules/issue-lifecycle.md +88 -0
  277. package/templates/rules/knowledge-base.md +1 -1
  278. package/templates/rules/mempalace.md +1 -1
  279. package/templates/rules/merge-safety.md +108 -0
  280. package/templates/rules/naming-and-ids.md +23 -17
  281. package/templates/rules/plain-language.md +59 -0
  282. package/templates/rules/plan-next.md +9 -11
  283. package/templates/rules/react-annotate.md +6 -0
  284. package/templates/rules/review-pages.md +49 -0
  285. package/templates/rules/risk-tiered-review.md +13 -4
  286. package/templates/rules/shared-checkout.md +106 -0
  287. package/templates/rules/skill-gaps.md +2 -7
  288. package/templates/rules/task-management.md +13 -1
  289. package/templates/skills/brand-voice/SKILL.md +91 -0
  290. package/templates/skills/brand-voice/references/voice-template.md +61 -0
  291. package/templates/skills/campaign/SKILL.md +123 -0
  292. package/templates/skills/campaign/references/plan-template.md +55 -0
  293. package/templates/skills/concrete/SKILL.md +2 -2
  294. package/templates/skills/copywriting/SKILL.md +8 -1
  295. package/templates/skills/feature-build-refine/SKILL.md +2 -4
  296. package/templates/skills/morning-briefing/SKILL.md +2 -2
  297. package/templates/skills/page-design/SKILL.md +145 -0
  298. package/templates/skills/page-design/add.json +5 -0
  299. package/templates/skills/page-design/references/design-file-template.md +40 -0
  300. package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
  301. package/templates/skills/page-design/references/minimum-rules.md +42 -0
  302. package/templates/skills/speckit/SKILL.md +4 -5
  303. package/templates/skills/supabase-patterns/SKILL.md +1 -1
  304. package/commands/kit-add.md +0 -42
  305. package/templates/CLAUDE.md.tmpl +0 -106
@@ -0,0 +1,408 @@
1
+ #!/usr/bin/env bash
2
+ # benchmark/checkpoint.sh — recorded benchmark checkpoints, one file per release version (#452).
3
+ #
4
+ # A checkpoint is one scored retrieval run, kept. A release has one run file,
5
+ # benchmarks/runs/<X.Y.Z>.json, holding every checkpoint taken while that version was being built:
6
+ # { "schema": 1, "version": "X.Y.Z", "checkpoints": [ { "n": 1, … }, { "n": 2, … } ] }
7
+ # The format is specified in benchmarks/runs/README.md.
8
+ #
9
+ # Usage:
10
+ # checkpoint.sh record <X.Y.Z> [--from <run.json>]… [--passes <N>] [--model <name>]
11
+ # [--commit <sha>] [--ref <name>] [--date <YYYY-MM-DD>] [--note <text>]
12
+ # [--verbs <timings.json>]
13
+ # Append a checkpoint to benchmarks/runs/<X.Y.Z>.json. Without --from it runs the benchmark
14
+ # (run.sh --json) --passes times (default 1). Each --from is one pass already run: the JSON
15
+ # `cckit bench run --json` printed. Passes are summed, so score = answers right / answers asked.
16
+ # --verbs attaches a per-verb measurement already taken (the JSON verb-timings.sh --json
17
+ # printed) as the checkpoint's `verbs`: wall milliseconds and gh calls per verb.
18
+ # Rewrites the results page when benchmark.config.json names one in `resultsPage`.
19
+ # checkpoint.sh list [--json]
20
+ # Every recorded checkpoint, oldest first.
21
+ # checkpoint.sh check <X.Y.Z>
22
+ # The release gate. The version's last checkpoint is compared with the checkpoint recorded
23
+ # before it over the questions BOTH asked (matched by set file + id). Exit 0 when it scores at
24
+ # least as high on those, or when the two share no question (a new baseline); exit 1 when the
25
+ # version has no checkpoint, or it scores lower on the shared questions; exit 2 on a usage
26
+ # error or a run file that is not a checkpoint file.
27
+ # checkpoint.sh page [--out <file>] [--check]
28
+ # Print the results page (markdown) built from the run files; --out writes it; --check exits 1
29
+ # when the file on disk differs from what the run files produce.
30
+ #
31
+ # Env: BENCH_DIR (the benchmarks dir; default ./benchmarks).
32
+ set -uo pipefail
33
+
34
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
35
+ # shellcheck source=/dev/null
36
+ . "$SCRIPT_DIR/lib/bench-common.sh"
37
+
38
+ command -v jq >/dev/null 2>&1 || { echo "checkpoint.sh: jq is required" >&2; exit 2; }
39
+
40
+ DIR="$(bench_dir)"
41
+ RUNS="$DIR/runs"
42
+ PROJECT_ROOT="$(cd "$DIR/.." 2>/dev/null && pwd)"
43
+
44
+ usage() { sed -n '2,31p' "$0" | sed 's/^# \{0,1\}//'; }
45
+
46
+ # A flag that takes a value, given as the last argument, has none: refuse it. Without this check
47
+ # `shift 2` fails on one remaining argument, shifts nothing, and the parse loop never ends.
48
+ need_value() { [ "$2" -ge 2 ] || { echo "checkpoint $1: $3 needs a value" >&2; return 2; }; }
49
+
50
+ is_version() { grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' <<<"$1"; }
51
+
52
+ # Recorded versions, oldest first (numeric per field: 0.10.0 sorts after 0.9.0).
53
+ cp_versions() {
54
+ local f v
55
+ [ -d "$RUNS" ] || return 0
56
+ for f in "$RUNS"/*.json; do
57
+ [ -e "$f" ] || continue
58
+ v="$(basename "$f" .json)"
59
+ is_version "$v" && printf '%s\n' "$v"
60
+ done | sort -t. -k1,1n -k2,2n -k3,3n
61
+ }
62
+
63
+ # One JSON array of every checkpoint, oldest first, each tagged with its version. Returns 2, with
64
+ # the file named on stderr, when a run file is not a checkpoint file.
65
+ cp_all() {
66
+ local v files=()
67
+ while IFS= read -r v; do [ -n "$v" ] && files+=("$RUNS/$v.json"); done < <(cp_versions)
68
+ [ "${#files[@]}" -gt 0 ] || { printf '[]'; return 0; }
69
+ # One unreadable file would make every verdict, list and page silently empty: name it and stop.
70
+ for v in "${files[@]}"; do
71
+ jq -e 'type == "object" and (.checkpoints | type == "array")' "$v" >/dev/null 2>&1 \
72
+ || { echo "checkpoint.sh: $v is not a checkpoint file (invalid JSON, or no .checkpoints array)" >&2; return 2; }
73
+ done
74
+ jq -s -c '[ .[] | .version as $v | (.checkpoints // [])[] | . + {version: $v} ]' "${files[@]}"
75
+ }
76
+
77
+ # ---- record ----------------------------------------------------------------
78
+ cmd_record() {
79
+ local version="" passes=1 model="" commit="" ref="" date_s="" note="" verbs="" froms=() tmp i f
80
+ while [ "$#" -gt 0 ]; do
81
+ case "$1" in
82
+ --from|--passes|--model|--commit|--ref|--date|--note|--verbs) need_value record "$#" "$1" || return 2 ;;
83
+ -h|--help) usage; return 0 ;;
84
+ esac
85
+ case "$1" in
86
+ --from) froms+=("${2:-}"); shift 2 ;;
87
+ --from=*) froms+=("${1#*=}"); shift ;;
88
+ --passes) passes="${2:-}"; shift 2 ;;
89
+ --passes=*) passes="${1#*=}"; shift ;;
90
+ --model) model="${2:-}"; shift 2 ;;
91
+ --model=*) model="${1#*=}"; shift ;;
92
+ --commit) commit="${2:-}"; shift 2 ;;
93
+ --commit=*) commit="${1#*=}"; shift ;;
94
+ --ref) ref="${2:-}"; shift 2 ;;
95
+ --ref=*) ref="${1#*=}"; shift ;;
96
+ --date) date_s="${2:-}"; shift 2 ;;
97
+ --date=*) date_s="${1#*=}"; shift ;;
98
+ --note) note="${2:-}"; shift 2 ;;
99
+ --note=*) note="${1#*=}"; shift ;;
100
+ --verbs) verbs="${2:-}"; shift 2 ;;
101
+ --verbs=*) verbs="${1#*=}"; shift ;;
102
+ -*) echo "checkpoint record: unknown flag '$1'" >&2; return 2 ;;
103
+ *) if [ -z "$version" ]; then version="$1"; shift
104
+ else echo "checkpoint record: unexpected argument '$1'" >&2; return 2; fi ;;
105
+ esac
106
+ done
107
+ is_version "$version" || { echo "checkpoint record: version must be X.Y.Z (got '${version}')" >&2; return 2; }
108
+ grep -Eq '^[1-9][0-9]*$' <<<"$passes" || { echo "checkpoint record: --passes must be a positive integer" >&2; return 2; }
109
+
110
+ cp_all >/dev/null || return 2 # an unreadable run file is reported before anything is run or written
111
+
112
+ # A measurement to attach is validated before anything is run: every row needs the five fields
113
+ # the page prints, as a string and four non-negative numbers.
114
+ if [ -n "$verbs" ]; then
115
+ [ -f "$verbs" ] || { echo "checkpoint record: no such verb timings file: $verbs" >&2; return 2; }
116
+ jq -e '(.verbs | type == "array") and (.verbs | length) > 0
117
+ and ([ .verbs[] | (.verb | type == "string")
118
+ and ([.runs, .min_ms, .median_ms, .gh_calls] | all(type == "number" and . >= 0)) ] | all)' \
119
+ "$verbs" >/dev/null 2>&1 \
120
+ || { echo "checkpoint record: $verbs is not a verb timings file (.verbs rows need verb, runs, min_ms, median_ms, gh_calls)" >&2; return 2; }
121
+ fi
122
+
123
+ tmp="$(mktemp -d)" || return 2
124
+ # shellcheck disable=SC2064
125
+ trap "rm -rf '$tmp'" EXIT
126
+
127
+ if [ "${#froms[@]}" -gt 0 ]; then
128
+ i=0
129
+ for f in "${froms[@]}"; do
130
+ [ -f "$f" ] || { echo "checkpoint record: no such run file: $f" >&2; return 2; }
131
+ jq -e 'type == "object" and (.results | type == "array")' "$f" >/dev/null 2>&1 \
132
+ || { echo "checkpoint record: $f is not a run (no .results array)" >&2; return 2; }
133
+ i=$((i+1)); cp "$f" "$tmp/pass-$i.json"
134
+ done
135
+ else
136
+ i=0
137
+ while [ "$i" -lt "$passes" ]; do
138
+ i=$((i+1))
139
+ echo "checkpoint record: pass $i of $passes" >&2
140
+ # run.sh exits 1 when any question failed; that is a score, not an error here.
141
+ bash "$SCRIPT_DIR/run.sh" --json > "$tmp/pass-$i.json" 2>"$tmp/pass-$i.err"
142
+ jq -e '.results | type == "array"' "$tmp/pass-$i.json" >/dev/null 2>&1 \
143
+ || { echo "checkpoint record: pass $i produced no run JSON" >&2; cat "$tmp/pass-$i.err" >&2; return 2; }
144
+ done
145
+ fi
146
+
147
+ # Question text, looked up by set file + id, so the page can show what was asked.
148
+ local qmap="$tmp/questions.json" setf
149
+ printf '{}' > "$qmap"
150
+ for setf in "$DIR"/*.jsonl; do
151
+ [ -e "$setf" ] || continue
152
+ bench_records "$setf" | jq -s -c --arg set "$(basename "$setf")" \
153
+ '[ .[] | select(.id != null) | {key: ($set + "|" + (.id|tostring)), value: (.q // .claim // "")} ] | from_entries' \
154
+ > "$tmp/one.json" 2>/dev/null || continue
155
+ jq -s -c '.[0] + .[1]' "$qmap" "$tmp/one.json" > "$tmp/merged.json" && mv "$tmp/merged.json" "$qmap"
156
+ done
157
+
158
+ # Defaults that describe where the run came from.
159
+ [ -n "$date_s" ] || date_s="$(date +%Y-%m-%d)"
160
+ [ -n "$commit" ] || commit="$(git -C "$PROJECT_ROOT" rev-parse --short HEAD 2>/dev/null || true)"
161
+ [ -n "$ref" ] || ref="$(git -C "$PROJECT_ROOT" branch --show-current 2>/dev/null || true)"
162
+ [ -n "$model" ] || model="$(jq -r '.model // empty' "$tmp/pass-1.json" 2>/dev/null)"
163
+ [ -n "$model" ] || model="${BENCH_MODEL:-${BENCH_BACKEND:-claude}}"
164
+
165
+ local out="$RUNS/$version.json" existing="$tmp/existing.json"
166
+ mkdir -p "$RUNS"
167
+ if [ -f "$out" ]; then
168
+ jq -e '.checkpoints | type == "array"' "$out" >/dev/null 2>&1 \
169
+ || { echo "checkpoint record: $out is not a checkpoint file (no .checkpoints array)" >&2; return 2; }
170
+ cp "$out" "$existing"
171
+ else
172
+ jq -n --arg v "$version" '{schema: 1, version: $v, checkpoints: []}' > "$existing"
173
+ fi
174
+
175
+ local vfile="$tmp/verbs.json"
176
+ if [ -n "$verbs" ]; then
177
+ jq -c '[ .verbs[] | {verb, runs, min_ms, median_ms, gh_calls} + (if (.exit // 0) != 0 then {exit} else {} end) ]' "$verbs" > "$vfile" || return 2
178
+ else
179
+ printf 'null' > "$vfile"
180
+ fi
181
+
182
+ jq -s --slurpfile ex "$existing" --slurpfile q "$qmap" --slurpfile vb "$vfile" \
183
+ --arg date "$date_s" --arg commit "$commit" --arg ref "$ref" --arg model "$model" --arg note "$note" '
184
+ . as $passes
185
+ | [ $passes[] | select(.dry == true) ] as $dry
186
+ | if ($dry | length) > 0 then error("a --dry run has no scores to record") else . end
187
+ # run.sh stores an empty answer only when the model backend failed (a real answer is a path or
188
+ # NONE). Such a run measures the backend, not the docs, and an empty answer passes the abstain tier.
189
+ | ( [ $passes[].results[] | select((.got // "") == "") ] | length ) as $noanswer
190
+ | if $noanswer > 0 then error("\($noanswer) answer(s) are empty: the model backend returned nothing, so there is no score to record") else . end
191
+ # One row per question, in the order the first pass asked them.
192
+ | ( [ $passes[].results[] ] | group_by(.set + "|" + (.id|tostring)) ) as $groups
193
+ | ( [ $passes[0].results[] | .set + "|" + (.id|tostring) ] ) as $order
194
+ | ( $groups | map({ key: (.[0].set + "|" + (.[0].id|tostring)), value: . }) | from_entries ) as $by
195
+ | [ $order[] | $by[.] as $g
196
+ | { set: $g[0].set, tier: $g[0].tier, id: $g[0].id,
197
+ q: ($q[0][ $g[0].set + "|" + ($g[0].id|tostring) ] // ""),
198
+ expect: $g[0].expect,
199
+ got: ( ([ $g[] | select(.pass | not) | .got ] | first) // $g[-1].got ),
200
+ passed: ([ $g[] | select(.pass) ] | length),
201
+ asked: ($g | length),
202
+ latency_ms: (([ $g[] | .latency_ms // 0 ] | add) / ($g | length) | floor) }
203
+ | . + { pass: (.passed == .asked) } ] as $results
204
+ | ( [ $results[].asked ] | add // 0 ) as $total
205
+ | ( [ $results[].passed ] | add // 0 ) as $pass
206
+ | if $total == 0 then error("the run has no results") else . end
207
+ | $ex[0] as $file
208
+ | $file
209
+ | .schema = 1
210
+ | .checkpoints += [ {
211
+ n: (($file.checkpoints | length) + 1),
212
+ date: $date, ref: $ref, commit: $commit, model: $model,
213
+ passes: ($passes | length),
214
+ questions: ($results | length),
215
+ total: $total, pass: $pass,
216
+ score_pct: (($pass * 100 / $total) | floor),
217
+ tiers: ( $results | group_by(.tier)
218
+ | map({ key: .[0].tier, value: { total: ([.[].asked] | add), pass: ([.[].passed] | add) } })
219
+ | from_entries ),
220
+ note: $note,
221
+ results: $results }
222
+ + (if $vb[0] != null then { verbs: $vb[0] } else {} end) ]
223
+ ' "$tmp"/pass-*.json > "$tmp/new.json" || { echo "checkpoint record: could not build the checkpoint" >&2; return 2; }
224
+
225
+ mv "$tmp/new.json" "$out"
226
+ jq -r '.checkpoints[-1] | "recorded checkpoint \(.n) of '"$version"': \(.pass)/\(.total) (\(.score_pct)%) · \(.passes) pass(es) · \(.model) · \(.ref)@\(.commit)" + (if .verbs then " · \(.verbs | length) verb timings" else "" end)' "$out"
227
+ echo " file: $out"
228
+
229
+ local page; page="$(cp_page_path)"
230
+ if [ -n "$page" ]; then
231
+ cmd_page --out "$page" && echo " page: $page"
232
+ fi
233
+ }
234
+
235
+ # ---- list ------------------------------------------------------------------
236
+ cmd_list() {
237
+ local json=0 all
238
+ for a in "$@"; do case "$a" in --json|--llm) json=1 ;; *) echo "checkpoint list: unknown arg '$a'" >&2; return 2 ;; esac; done
239
+ all="$(cp_all)" || return 2
240
+ if [ "$json" -eq 1 ]; then
241
+ printf '%s' "$all" | jq -c '[ .[] | del(.results) ]'
242
+ return 0
243
+ fi
244
+ if [ "$(printf '%s' "$all" | jq 'length')" -eq 0 ]; then
245
+ echo "no recorded checkpoints in $RUNS"; return 0
246
+ fi
247
+ printf '%s' "$all" | jq -r '.[] | "\(.version) #\(.n) \(.date) \(.pass)/\(.total) (\(.score_pct)%) \(.passes) pass(es) \(.model) \(.ref)@\(.commit)"'
248
+ }
249
+
250
+ # ---- check (the release gate) ----------------------------------------------
251
+ # Two checkpoints are compared over the questions BOTH asked, matched by set file + id (#452). The
252
+ # question set grows between checkpoints (18 to 55 in 0.10.0), and a whole-run fraction would read
253
+ # 54 of 55 as lower than 18 of 18 although no question got worse. On the shared questions the scores
254
+ # compare as fractions (answers right / answers asked, cross-multiplied), so a different number of
255
+ # passes still compares and integer-percent rounding never decides a release. Two checkpoints that
256
+ # share no question cannot be compared: the newer one is a new baseline and passes.
257
+ cmd_check() {
258
+ local version="${1:-}" all
259
+ is_version "$version" || { echo "checkpoint check: version must be X.Y.Z (got '${version}')" >&2; return 2; }
260
+ all="$(cp_all)" || return 2
261
+ if [ ! -f "$RUNS/$version.json" ] || [ "$(jq '(.checkpoints // []) | length' "$RUNS/$version.json" 2>/dev/null || echo 0)" -eq 0 ]; then
262
+ echo "benchmark check: no recorded checkpoint for $version (expected $RUNS/$version.json)"
263
+ echo " record one: cckit bench checkpoint $version"
264
+ return 1
265
+ fi
266
+ local verdict line
267
+ line="$(printf '%s' "$all" | jq -r --arg v "$version" '
268
+ def key: .set + "|" + (.id | tostring);
269
+ def bykey(c): [ (c.results // [])[] | { key: key, value: . } ] | from_entries;
270
+ def lbl(c): "\(c.version) checkpoint \(c.n): \(c.pass)/\(c.total) (\(c.score_pct)%)";
271
+ . as $a
272
+ | ( [ range(0; length) | select($a[.].version == $v) ] | last ) as $idx
273
+ | $a[$idx] as $cur
274
+ | ( if $idx > 0 then $a[$idx - 1] else null end ) as $prev
275
+ | if $prev == null then "ok\tbenchmark check: " + lbl($cur) + " — no earlier checkpoint to compare against"
276
+ else
277
+ bykey($cur) as $c | bykey($prev) as $p
278
+ | [ $c | keys_unsorted[] | select($p[.] != null) ] as $shared
279
+ | ( ($c | length) - ($shared | length) ) as $new
280
+ | ( ($p | length) - ($shared | length) ) as $gone
281
+ | "\($new) new, \($gone) removed" as $delta
282
+ | if ($shared | length) == 0
283
+ then "ok\tbenchmark check: " + lbl($cur) + " — new baseline: it shares no question with "
284
+ + lbl($prev) + " (\($delta))"
285
+ else
286
+ ( [ $shared[] | $c[.].passed ] | add ) as $cp | ( [ $shared[] | $c[.].asked ] | add ) as $ct
287
+ | ( [ $shared[] | $p[.].passed ] | add ) as $pp | ( [ $shared[] | $p[.].asked ] | add ) as $pt
288
+ | [ $shared[] | select($p[.].pass and ($c[.].pass | not)) | $c[.] | "\(.set) \(.id)" ] as $worse
289
+ | "on the \($shared | length) question(s) both asked (\($cp)/\($ct) now, \($pp)/\($pt) before); \($delta)" as $on
290
+ | ( if ($worse | length) > 0 then "\n right before, missed now: " + ($worse | join(", ")) else "" end ) as $tail
291
+ | if ($cp * $pt) < ($pp * $ct)
292
+ then "low\tbenchmark check: " + lbl($cur) + " is lower than " + lbl($prev) + " " + $on + $tail
293
+ else "ok\tbenchmark check: " + lbl($cur) + " — not lower than " + lbl($prev) + " " + $on + $tail
294
+ end
295
+ end
296
+ end
297
+ ')"
298
+ verdict="${line%% *}"
299
+ printf '%s\n' "${line#* }"
300
+ [ "$verdict" = "ok" ]
301
+ }
302
+
303
+ # ---- page ------------------------------------------------------------------
304
+ # The results page named by benchmark.config.json `resultsPage` (relative to the project root).
305
+ cp_page_path() {
306
+ local cfg rel
307
+ cfg="$(bench_config)"
308
+ [ -n "$cfg" ] || return 0
309
+ rel="$(jq -r '.resultsPage // empty' "$cfg" 2>/dev/null)"
310
+ [ -n "$rel" ] || return 0
311
+ case "$rel" in /*) printf '%s' "$rel" ;; *) printf '%s' "$PROJECT_ROOT/$rel" ;; esac
312
+ }
313
+
314
+ cp_render_page() {
315
+ local all
316
+ all="$(cp_all)" || return 2
317
+ printf '%s' "$all" | jq -r '
318
+ def cell: tostring | gsub("[\r\n]+"; " ") | gsub("\\|"; "\\|") | gsub("<"; "&lt;") | gsub("\\{"; "&#123;");
319
+ def code: tostring | gsub("[\r\n]+"; " ") | gsub("`"; "") | gsub("\\|"; "\\|") | .[0:120] | "`" + . + "`";
320
+ def docs: if type == "array" then map(code) | join(" or ") else code end;
321
+ def tier(c; t): if c.tiers[t] then "\(c.tiers[t].pass)/\(c.tiers[t].total)" else "—" end;
322
+ def vkey: split(".") | map(tonumber);
323
+ . as $all
324
+ | "---",
325
+ "title: Benchmark results",
326
+ "description: The documentation benchmark score recorded at every checkpoint of every release.",
327
+ "---",
328
+ "",
329
+ "<!-- Generated from benchmarks/runs/*.json by `cckit bench page`. Do not edit by hand: scripts/check.sh fails when this page differs from the run files. -->",
330
+ "",
331
+ "Each release records the [documentation benchmark](/benchmark/) as one or more checkpoints: a run, the fixes it showed were needed, then another run. A release is refused when its last checkpoint scores lower than the checkpoint recorded before it, counted over the questions both checkpoints asked ([How cckit itself is released](/releasing-cckit/#the-benchmark-check)).",
332
+ "",
333
+ "Score is answers right out of answers asked. A checkpoint with more than one pass asks every question that many times.",
334
+ "",
335
+ ( if ($all | length) == 0 then "No checkpoint has been recorded yet." else
336
+ ( [ $all[].version ] | unique | sort_by(vkey) | reverse | .[] ) as $v
337
+ | [ $all[] | select(.version == $v) ] as $cps
338
+ | "## " + $v,
339
+ "",
340
+ "| Checkpoint | Date | Commit | Model | Passes | Score | Retrieval | Adversarial | Abstain |",
341
+ "| --- | --- | --- | --- | --- | --- | --- | --- | --- |",
342
+ ( $cps[] | "| \(.n) | \(.date | cell) | \(((.ref // "") + "@" + (.commit // "")) | code) | \(.model | cell) | \(.passes) | **\(.pass)/\(.total)** (\(.score_pct)%) | \(tier(.; "retrieval")) | \(tier(.; "adversarial")) | \(tier(.; "abstain")) |" ),
343
+ "",
344
+ ( $cps[]
345
+ | . as $c
346
+ | [ $c.results[] | select(.pass | not) ] as $missed
347
+ | ( if ($c.note // "") != "" then "Checkpoint \($c.n) note: \($c.note | cell)", "" else empty end ),
348
+ ( if ($missed | length) == 0 then "Checkpoint \($c.n): no missed questions.", ""
349
+ else
350
+ "Checkpoint \($c.n) missed \($missed | length) of \($c.questions) questions:",
351
+ "",
352
+ "| Question | Tier | Expected | Answered | Right |",
353
+ "| --- | --- | --- | --- | --- |",
354
+ ( $missed[] | "| \(.id | code) \(.q // "" | cell) | \(.tier | cell) | \(.expect | docs) | \(.got | code) | \(.passed)/\(.asked) |" ),
355
+ ""
356
+ end ),
357
+ ( if (($c.verbs // []) | length) == 0 then empty
358
+ else
359
+ "Checkpoint \($c.n) verb timings: wall time of each read-only verb and the number of times it ran `gh`.",
360
+ "",
361
+ "| Verb | Runs | Min ms | Median ms | gh calls |",
362
+ "| --- | --- | --- | --- | --- |",
363
+ ( $c.verbs[] | "| \("cckit " + .verb | code)\(if (.exit // 0) != 0 then " (exit \(.exit))" else "" end) | \(.runs) | \(.min_ms) | \(.median_ms) | \(.gh_calls) |" ),
364
+ ""
365
+ end ) )
366
+ end )
367
+ '
368
+ }
369
+
370
+ cmd_page() {
371
+ local out="" check=0
372
+ while [ "$#" -gt 0 ]; do
373
+ case "$1" in
374
+ --out) need_value page "$#" "$1" || return 2; out="$2"; shift 2 ;;
375
+ --out=*) out="${1#*=}"; shift ;;
376
+ --check) check=1; shift ;;
377
+ *) echo "checkpoint page: unknown arg '$1'" >&2; return 2 ;;
378
+ esac
379
+ done
380
+ [ -n "$out" ] || [ "$check" -eq 0 ] || out="$(cp_page_path)"
381
+ if [ "$check" -eq 1 ]; then
382
+ [ -n "$out" ] || { echo "checkpoint page --check: no page configured (benchmark.config.json resultsPage) and no --out" >&2; return 2; }
383
+ local want
384
+ want="$(cp_render_page)" || return 2
385
+ if [ -f "$out" ] && [ "$want" = "$(cat "$out")" ]; then
386
+ echo "benchmark results page is current: $out"; return 0
387
+ fi
388
+ echo "benchmark results page is stale: $out" >&2
389
+ echo " regenerate: cckit bench page --out $out" >&2
390
+ return 1
391
+ fi
392
+ if [ -n "$out" ]; then
393
+ mkdir -p "$(dirname "$out")"
394
+ cp_render_page > "$out.tmp.$$" && mv "$out.tmp.$$" "$out" || { rm -f "$out.tmp.$$"; return 2; }
395
+ else
396
+ cp_render_page
397
+ fi
398
+ }
399
+
400
+ sub="${1:-}"; [ "$#" -gt 0 ] && shift
401
+ case "$sub" in
402
+ record) cmd_record "$@" ;;
403
+ list) cmd_list "$@" ;;
404
+ check) cmd_check "$@" ;;
405
+ page) cmd_page "$@" ;;
406
+ -h|--help|"") usage; [ -n "$sub" ] && exit 0 || exit 2 ;;
407
+ *) echo "checkpoint.sh: unknown subcommand '$sub' (record|list|check|page)" >&2; exit 2 ;;
408
+ esac
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env bash
2
2
  # benchmark/lib/model.sh — the pluggable model backend for the benchmark harness.
3
3
  #
4
- # Two entry points, both cascade-shaped so the backend is swappable with NO hard dependency on a
4
+ # Three entry points, all cascade-shaped so the backend is swappable with NO hard dependency on a
5
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]
6
+ # bench_ask "<question>" -> prints ONE repo-relative doc path, or "NONE"
7
+ # bench_answer "<question>" -> prints the model's full answer from the docs
8
+ # bench_judge "<claim>" "<answer>" "<must>" -> prints a score in [0,1]
8
9
  #
9
10
  # Backend selection (first that applies wins), driven by env so a project overrides without editing:
10
11
  # BENCH_BACKEND=mock deterministic, offline (tests + --dry); never calls a model
@@ -61,13 +62,15 @@ _bench_complete() {
61
62
  bench_timeout "$BENCH_TIMEOUT_SECS" curl -sS "$url" \
62
63
  -H 'Content-Type: application/json' \
63
64
  ${BENCH_API_KEY:+-H "Authorization: Bearer $BENCH_API_KEY"} \
64
- -d "$body" 2>/dev/null \
65
+ -d "$body" </dev/null 2>/dev/null \
65
66
  | jq -r '.choices[0].message.content // empty' 2>/dev/null ;;
66
67
  claude|*)
67
68
  command -v claude >/dev/null 2>&1 || { return 1; }
68
69
  # Headless one-shot. `-p` prints the final answer and exits; the model may use its tools to
69
70
  # 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
+ # stdin is /dev/null on purpose: the runners call this inside `while read … done < <(records)`,
72
+ # and a child that inherits that stdin drains it, so every set stopped after its first record.
73
+ bench_timeout "$BENCH_TIMEOUT_SECS" claude -p "$prompt" </dev/null 2>/dev/null ;;
71
74
  esac
72
75
  }
73
76
 
@@ -90,6 +93,25 @@ If no document genuinely answers it, reply with exactly: NONE"
90
93
  printf '%s' "$out"
91
94
  }
92
95
 
96
+ # ---- bench_answer ----------------------------------------------------------
97
+ # Ask the model to ANSWER a question from the docs — the whole answer, every line of it. The quality
98
+ # tier grades this text. bench_ask is the wrong call there: it returns one path, and a path covers
99
+ # none of a rubric's points. $2 = knowledge dir (for the prompt). Prints nothing when the backend
100
+ # fails or times out; the caller scores an empty answer 0.
101
+ bench_answer() {
102
+ local question="$1" kdir="${2:-knowledge}" prompt
103
+ prompt="You are answering a question about this project from its own documentation.
104
+
105
+ QUESTION:
106
+ $question
107
+
108
+ Read the documents under '$kdir/' and answer from what they state. Give the complete answer: every
109
+ condition, default, exit code and command the documents give for it. Do not add anything they do not
110
+ state. End with one line naming the document(s) you used, as repo-relative paths. If the documents
111
+ do not cover the question, say so."
112
+ _bench_complete "$prompt" || return 1
113
+ }
114
+
93
115
  # ---- bench_judge -----------------------------------------------------------
94
116
  # Score a claim-style answer against a `must` rubric (newline-separated points). The rubric de-biases
95
117
  # the judge: it scores coverage of the required points, not vibes. Prints a float in [0,1].
@@ -110,7 +132,10 @@ $must
110
132
  Reply with ONLY a number between 0 and 1 (e.g. 0.75) = the fraction of required points the answer
111
133
  correctly covers. No words."
112
134
  out="$(_bench_complete "$prompt")" || { printf '0'; return 0; }
113
- score="$(printf '%s' "$out" | grep -oE '0(\.[0-9]+)?|1(\.0+)?' | head -1)"
135
+ # BENCH_JUDGE_RAW=<file> keeps the judge's reply as it came back, before the number is cut out of
136
+ # it: a score that looks wrong can then be told apart from a reply that was parsed wrong.
137
+ [ -z "${BENCH_JUDGE_RAW:-}" ] || printf '%s\n' "$out" > "$BENCH_JUDGE_RAW"
138
+ score="$(printf '%s' "$out" | grep -oE '0(\.[0-9]+)?|1(\.0+)?' | sed -n 1p)"
114
139
  [ -n "$score" ] || score="0"
115
140
  printf '%s' "$score"
116
141
  }
@@ -35,13 +35,28 @@ DIR="$(bench_dir)"
35
35
  [ -n "$OUT" ] || OUT="$DIR/RESULTS.md"
36
36
  DRYFLAG=""; [ "$DRY" -eq 1 ] && DRYFLAG="--dry"
37
37
 
38
+ # tier_json <script> — one tier's --json summary, or {} when the tier printed no usable JSON.
39
+ # The exit code is deliberately NOT the signal: run.sh exits 1 whenever a record failed and still
40
+ # prints its full summary, so `$(run … || echo '{}')` captured two documents and every
41
+ # `jq -r '.x // 0'` below printed two lines — "33\n0%" in the headline (#252).
42
+ tier_json() {
43
+ local out
44
+ # shellcheck disable=SC2086 # DRYFLAG is empty or one flag; it must word-split away when empty
45
+ out="$(bash "$1" $DRYFLAG --json 2>/dev/null)"
46
+ if [ "$(printf '%s' "$out" | jq -s 'length == 1 and (.[0] | type == "object")' 2>/dev/null)" = "true" ]; then
47
+ printf '%s' "$out"
48
+ else
49
+ printf '{}'
50
+ fi
51
+ }
52
+
38
53
  # Gather the two tier summaries (retrieval+abstain+adversarial in one, quality separately).
39
54
  if [ "$STDIN" -eq 1 ]; then
40
55
  RET_JSON="$(cat)"
41
56
  QUAL_JSON='{"kind":"quality-run","dry":true,"count":0,"mean":0,"results":[]}'
42
57
  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 '{}')"
58
+ RET_JSON="$(tier_json "$SCRIPT_DIR/run.sh")"
59
+ QUAL_JSON="$(tier_json "$SCRIPT_DIR/run-quality.sh")"
45
60
  fi
46
61
 
47
62
  # Pull the numbers with safe defaults (a tier may be absent).
@@ -2,16 +2,21 @@
2
2
  # benchmark/run-quality.sh — the quality judge tier.
3
3
  #
4
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
5
+ # claim-style record the model answers headlessly (bench_answer: a full answer, not a path), then a
6
+ # judge scores that answer 0..1 against the record's `must` rubric. The rubric de-biases the judge: it
7
7
  # grades coverage of the required points, not tone. The tier score is the mean.
8
8
  #
9
9
  # Usage:
10
- # benchmark/run-quality.sh [--set <file>] [--dir <benchmarks>] [--dry] [--json]
10
+ # benchmark/run-quality.sh [--set <file>] [--dir <benchmarks>] [--dry] [--json] [--answers <dir>]
11
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).
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
14
+ # every *quality*.jsonl in the dir).
15
+ # --answers keep each graded answer as <dir>/<id>.txt and the judge's reply to it as
16
+ # <dir>/<id>.judge.txt, to read why a claim scored what it did.
17
+ #
18
+ # A record may carry extra keys (`source`: the page its rubric was written from). Only `claim` and
19
+ # `must` are read here.
15
20
  set -uo pipefail
16
21
 
17
22
  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -20,7 +25,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
20
25
  # shellcheck source=/dev/null
21
26
  . "$SCRIPT_DIR/lib/model.sh"
22
27
 
23
- DRY=0; JSON=0; ONE_SET=""
28
+ DRY=0; JSON=0; ONE_SET=""; ANSWERS_DIR=""
24
29
  while [ "$#" -gt 0 ]; do
25
30
  case "$1" in
26
31
  --dry) DRY=1; shift ;;
@@ -29,7 +34,11 @@ while [ "$#" -gt 0 ]; do
29
34
  --set=*) ONE_SET="${1#*=}"; shift ;;
30
35
  --dir) BENCH_DIR="$2"; export BENCH_DIR; shift 2 ;;
31
36
  --dir=*) BENCH_DIR="${1#*=}"; export BENCH_DIR; shift ;;
32
- -h|--help) sed -n '2,18p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
37
+ --answers) [ "$#" -ge 2 ] || { echo "run-quality.sh: --answers needs a directory" >&2; exit 2; }
38
+ ANSWERS_DIR="$2"; shift 2 ;;
39
+ --answers=*) ANSWERS_DIR="${1#*=}"; shift
40
+ [ -n "$ANSWERS_DIR" ] || { echo "run-quality.sh: --answers needs a directory" >&2; exit 2; } ;;
41
+ -h|--help) sed -n '2,22p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
33
42
  *) echo "run-quality.sh: unknown arg '$1'" >&2; exit 2 ;;
34
43
  esac
35
44
  done
@@ -53,6 +62,11 @@ fi
53
62
 
54
63
  [ "${#SETS[@]}" -ge 1 ] || { echo "run-quality.sh: no quality sets found in $DIR" >&2; exit 2; }
55
64
 
65
+ if [ -n "$ANSWERS_DIR" ] && [ "$DRY" -eq 0 ]; then
66
+ mkdir -p "$ANSWERS_DIR" 2>/dev/null \
67
+ || { echo "run-quality.sh: cannot create the --answers directory: $ANSWERS_DIR" >&2; exit 2; }
68
+ fi
69
+
56
70
  N=0; SUM="0"; FAILN=0
57
71
  RESULTS_JSON="[]"
58
72
 
@@ -71,8 +85,20 @@ for file in "${SETS[@]}"; do
71
85
  continue
72
86
  fi
73
87
 
74
- answer="$(bench_ask "$claim" "$KDIR")"
75
- score="$(bench_judge "$claim" "$answer" "$must")"
88
+ answer="$(bench_answer "$claim" "$KDIR")"
89
+ if [ -n "$ANSWERS_DIR" ]; then
90
+ # A reply left by an earlier run into the same directory is not this run's: drop it first, so
91
+ # a claim that reaches no judge now is not read next to a stale <id>.judge.txt.
92
+ rm -f "$ANSWERS_DIR/$id.judge.txt"
93
+ printf '%s\n' "$answer" > "$ANSWERS_DIR/$id.txt"
94
+ fi
95
+ # No answer (backend failed or timed out) covers no point. Do not spend a judge call on it.
96
+ if [ -n "$answer" ]; then
97
+ [ -z "$ANSWERS_DIR" ] || export BENCH_JUDGE_RAW="$ANSWERS_DIR/$id.judge.txt"
98
+ score="$(bench_judge "$claim" "$answer" "$must")"
99
+ else
100
+ score="0"
101
+ fi
76
102
  N=$((N+1))
77
103
  SUM="$(awk -v a="$SUM" -v b="$score" 'BEGIN{printf "%.4f", a+b}')"
78
104
  RESULTS_JSON="$(printf '%s' "$RESULTS_JSON" | jq -c \