akm-cli 0.7.0 → 0.7.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.
Files changed (327) hide show
  1. package/package.json +8 -8
  2. package/dist/tests/add-website-source.test.js +0 -119
  3. package/dist/tests/agent/agent-config-loader.test.js +0 -70
  4. package/dist/tests/agent/agent-config.test.js +0 -221
  5. package/dist/tests/agent/agent-detect.test.js +0 -100
  6. package/dist/tests/agent/agent-spawn.test.js +0 -234
  7. package/dist/tests/agent-output.test.js +0 -186
  8. package/dist/tests/architecture/agent-no-llm-sdk-guard.test.js +0 -103
  9. package/dist/tests/architecture/agent-spawn-seam.test.js +0 -193
  10. package/dist/tests/architecture/llm-stateless-seam.test.js +0 -112
  11. package/dist/tests/asset-ref.test.js +0 -192
  12. package/dist/tests/asset-registry.test.js +0 -103
  13. package/dist/tests/asset-spec.test.js +0 -241
  14. package/dist/tests/bench/attribution.test.js +0 -996
  15. package/dist/tests/bench/cleanup-sigint.test.js +0 -83
  16. package/dist/tests/bench/cleanup.js +0 -234
  17. package/dist/tests/bench/cleanup.test.js +0 -166
  18. package/dist/tests/bench/cli.js +0 -1018
  19. package/dist/tests/bench/cli.test.js +0 -445
  20. package/dist/tests/bench/compare.test.js +0 -556
  21. package/dist/tests/bench/corpus.js +0 -317
  22. package/dist/tests/bench/corpus.test.js +0 -258
  23. package/dist/tests/bench/doctor.js +0 -525
  24. package/dist/tests/bench/driver.js +0 -401
  25. package/dist/tests/bench/driver.test.js +0 -584
  26. package/dist/tests/bench/environment.js +0 -233
  27. package/dist/tests/bench/environment.test.js +0 -199
  28. package/dist/tests/bench/evolve-metrics.js +0 -179
  29. package/dist/tests/bench/evolve-metrics.test.js +0 -187
  30. package/dist/tests/bench/evolve.js +0 -647
  31. package/dist/tests/bench/evolve.test.js +0 -624
  32. package/dist/tests/bench/failure-modes.test.js +0 -349
  33. package/dist/tests/bench/feedback-integrity.test.js +0 -457
  34. package/dist/tests/bench/leakage.test.js +0 -228
  35. package/dist/tests/bench/learning-curve.test.js +0 -134
  36. package/dist/tests/bench/metrics.js +0 -2395
  37. package/dist/tests/bench/metrics.test.js +0 -1150
  38. package/dist/tests/bench/no-os-tmpdir-invariant.test.js +0 -43
  39. package/dist/tests/bench/opencode-config.js +0 -194
  40. package/dist/tests/bench/opencode-config.test.js +0 -370
  41. package/dist/tests/bench/report.js +0 -1885
  42. package/dist/tests/bench/report.test.js +0 -1038
  43. package/dist/tests/bench/run-config.js +0 -355
  44. package/dist/tests/bench/run-config.test.js +0 -298
  45. package/dist/tests/bench/run-curate-test.js +0 -32
  46. package/dist/tests/bench/run-failing-tasks.js +0 -56
  47. package/dist/tests/bench/run-full-bench.js +0 -51
  48. package/dist/tests/bench/run-items36-targeted.js +0 -69
  49. package/dist/tests/bench/run-nano-quick.js +0 -42
  50. package/dist/tests/bench/run-waveg-targeted.js +0 -62
  51. package/dist/tests/bench/runner.js +0 -699
  52. package/dist/tests/bench/runner.test.js +0 -958
  53. package/dist/tests/bench/search-bridge.test.js +0 -331
  54. package/dist/tests/bench/tmp.js +0 -131
  55. package/dist/tests/bench/trajectory.js +0 -116
  56. package/dist/tests/bench/trajectory.test.js +0 -127
  57. package/dist/tests/bench/verifier.js +0 -114
  58. package/dist/tests/bench/verifier.test.js +0 -118
  59. package/dist/tests/bench/workflow-evaluator.js +0 -557
  60. package/dist/tests/bench/workflow-evaluator.test.js +0 -421
  61. package/dist/tests/bench/workflow-spec.js +0 -345
  62. package/dist/tests/bench/workflow-spec.test.js +0 -363
  63. package/dist/tests/bench/workflow-trace.js +0 -472
  64. package/dist/tests/bench/workflow-trace.test.js +0 -254
  65. package/dist/tests/benchmark-search-quality.js +0 -536
  66. package/dist/tests/benchmark-suite.js +0 -1441
  67. package/dist/tests/capture-cli.test.js +0 -112
  68. package/dist/tests/cli-errors.test.js +0 -204
  69. package/dist/tests/commands/events.test.js +0 -370
  70. package/dist/tests/commands/history.test.js +0 -418
  71. package/dist/tests/commands/import.test.js +0 -103
  72. package/dist/tests/commands/proposal-cli.test.js +0 -209
  73. package/dist/tests/commands/reflect-propose-cli.test.js +0 -333
  74. package/dist/tests/commands/remember.test.js +0 -97
  75. package/dist/tests/commands/scope-flags.test.js +0 -300
  76. package/dist/tests/commands/search.test.js +0 -537
  77. package/dist/tests/commands/show-indexer-parity.test.js +0 -117
  78. package/dist/tests/commands/show.test.js +0 -294
  79. package/dist/tests/common.test.js +0 -266
  80. package/dist/tests/completions.test.js +0 -142
  81. package/dist/tests/config-cli.test.js +0 -193
  82. package/dist/tests/config-llm-features.test.js +0 -139
  83. package/dist/tests/config.test.js +0 -569
  84. package/dist/tests/contracts/migration-baseline.test.js +0 -43
  85. package/dist/tests/contracts/reflect-propose-envelope.test.js +0 -139
  86. package/dist/tests/contracts/spec-helpers.js +0 -46
  87. package/dist/tests/contracts/v1-spec-section-11-proposal-queue.test.js +0 -228
  88. package/dist/tests/contracts/v1-spec-section-12-agent-config.test.js +0 -56
  89. package/dist/tests/contracts/v1-spec-section-13-lesson-type.test.js +0 -34
  90. package/dist/tests/contracts/v1-spec-section-14-llm-features.test.js +0 -94
  91. package/dist/tests/contracts/v1-spec-section-4-1-asset-types.test.js +0 -39
  92. package/dist/tests/contracts/v1-spec-section-4-2-quality-rules.test.js +0 -44
  93. package/dist/tests/contracts/v1-spec-section-5-configuration.test.js +0 -47
  94. package/dist/tests/contracts/v1-spec-section-6-orchestration.test.js +0 -40
  95. package/dist/tests/contracts/v1-spec-section-7-module-layout.test.js +0 -58
  96. package/dist/tests/contracts/v1-spec-section-8-extension-points.test.js +0 -34
  97. package/dist/tests/contracts/v1-spec-section-9-4-cli-surface.test.js +0 -75
  98. package/dist/tests/contracts/v1-spec-section-9-7-llm-agent-boundary.test.js +0 -36
  99. package/dist/tests/core/write-source.test.js +0 -366
  100. package/dist/tests/curate-command.test.js +0 -87
  101. package/dist/tests/db-scoring.test.js +0 -201
  102. package/dist/tests/db.test.js +0 -654
  103. package/dist/tests/distill-cli-flag.test.js +0 -208
  104. package/dist/tests/distill.test.js +0 -515
  105. package/dist/tests/docker-install.test.js +0 -120
  106. package/dist/tests/e2e.test.js +0 -1419
  107. package/dist/tests/embedder.test.js +0 -340
  108. package/dist/tests/embedding-model-config.test.js +0 -379
  109. package/dist/tests/feedback-command.test.js +0 -172
  110. package/dist/tests/file-context.test.js +0 -552
  111. package/dist/tests/fixtures/scripts/git/summarize-diff.js +0 -9
  112. package/dist/tests/fixtures/scripts/lint/eslint-check.js +0 -7
  113. package/dist/tests/fixtures/stashes/load.js +0 -166
  114. package/dist/tests/fixtures/stashes/load.test.js +0 -97
  115. package/dist/tests/fixtures/stashes/ranking-baseline/scripts/mem0-search.js +0 -12
  116. package/dist/tests/frontmatter.test.js +0 -190
  117. package/dist/tests/fts-field-weighting.test.js +0 -254
  118. package/dist/tests/fuzzy-search.test.js +0 -230
  119. package/dist/tests/git-provider-clone.test.js +0 -45
  120. package/dist/tests/github.test.js +0 -161
  121. package/dist/tests/graph-boost-ranking.test.js +0 -305
  122. package/dist/tests/graph-extraction.test.js +0 -282
  123. package/dist/tests/helpers/usage-events.js +0 -8
  124. package/dist/tests/index-pass-llm.test.js +0 -161
  125. package/dist/tests/indexer.test.js +0 -570
  126. package/dist/tests/info-command.test.js +0 -166
  127. package/dist/tests/init.test.js +0 -69
  128. package/dist/tests/install-script.test.js +0 -246
  129. package/dist/tests/integration/agent-real-profile.test.js +0 -94
  130. package/dist/tests/issue-36-repro.test.js +0 -304
  131. package/dist/tests/issues-191-194.test.js +0 -160
  132. package/dist/tests/lesson-lint.test.js +0 -111
  133. package/dist/tests/llm-client.test.js +0 -115
  134. package/dist/tests/llm-feature-gate.test.js +0 -151
  135. package/dist/tests/llm.test.js +0 -139
  136. package/dist/tests/lockfile.test.js +0 -216
  137. package/dist/tests/manifest.test.js +0 -205
  138. package/dist/tests/markdown.test.js +0 -126
  139. package/dist/tests/matchers-unit.test.js +0 -189
  140. package/dist/tests/memory-inference.test.js +0 -299
  141. package/dist/tests/merge-scoring.test.js +0 -136
  142. package/dist/tests/metadata.test.js +0 -313
  143. package/dist/tests/migration-help.test.js +0 -89
  144. package/dist/tests/origin-resolve.test.js +0 -124
  145. package/dist/tests/output-baseline.test.js +0 -218
  146. package/dist/tests/output-shapes-unit.test.js +0 -478
  147. package/dist/tests/parallel-search.test.js +0 -272
  148. package/dist/tests/parameter-metadata.test.js +0 -365
  149. package/dist/tests/paths.test.js +0 -177
  150. package/dist/tests/progressive-disclosure.test.js +0 -280
  151. package/dist/tests/proposals.test.js +0 -279
  152. package/dist/tests/proposed-quality.test.js +0 -271
  153. package/dist/tests/provider-registry.test.js +0 -32
  154. package/dist/tests/ranking-regression.test.js +0 -548
  155. package/dist/tests/reflect-propose.test.js +0 -455
  156. package/dist/tests/registry-build-index.test.js +0 -394
  157. package/dist/tests/registry-cli.test.js +0 -290
  158. package/dist/tests/registry-index-v2.test.js +0 -430
  159. package/dist/tests/registry-install.test.js +0 -728
  160. package/dist/tests/registry-providers/parity.test.js +0 -189
  161. package/dist/tests/registry-providers/skills-sh.test.js +0 -309
  162. package/dist/tests/registry-providers/static-index.test.js +0 -238
  163. package/dist/tests/registry-resolve.test.js +0 -126
  164. package/dist/tests/registry-search.test.js +0 -923
  165. package/dist/tests/remember-frontmatter.test.js +0 -378
  166. package/dist/tests/remember-unit.test.js +0 -123
  167. package/dist/tests/ripgrep-install.test.js +0 -251
  168. package/dist/tests/ripgrep-resolve.test.js +0 -108
  169. package/dist/tests/ripgrep.test.js +0 -163
  170. package/dist/tests/save-command.test.js +0 -94
  171. package/dist/tests/save-trust-qa-fixes.test.js +0 -270
  172. package/dist/tests/scoring-pipeline.test.js +0 -648
  173. package/dist/tests/search-include-proposed-cli.test.js +0 -118
  174. package/dist/tests/self-update.test.js +0 -442
  175. package/dist/tests/semantic-search-e2e.test.js +0 -512
  176. package/dist/tests/semantic-status.test.js +0 -471
  177. package/dist/tests/setup-run.integration.js +0 -877
  178. package/dist/tests/setup-wizard.test.js +0 -198
  179. package/dist/tests/setup.test.js +0 -131
  180. package/dist/tests/source-add.test.js +0 -11
  181. package/dist/tests/source-clone.test.js +0 -254
  182. package/dist/tests/source-manage.test.js +0 -366
  183. package/dist/tests/source-providers/filesystem.test.js +0 -82
  184. package/dist/tests/source-providers/git.test.js +0 -252
  185. package/dist/tests/source-providers/website.test.js +0 -128
  186. package/dist/tests/source-qa-fixes.test.js +0 -286
  187. package/dist/tests/source-registry.test.js +0 -350
  188. package/dist/tests/source-resolve.test.js +0 -100
  189. package/dist/tests/source-source.test.js +0 -281
  190. package/dist/tests/source.test.js +0 -533
  191. package/dist/tests/tar-utils-scan.test.js +0 -73
  192. package/dist/tests/toggle-components.test.js +0 -73
  193. package/dist/tests/usage-telemetry.test.js +0 -265
  194. package/dist/tests/utility-scoring.test.js +0 -558
  195. package/dist/tests/vault-load-error.test.js +0 -78
  196. package/dist/tests/vault-qa-fixes.test.js +0 -194
  197. package/dist/tests/vault.test.js +0 -429
  198. package/dist/tests/vector-search.test.js +0 -608
  199. package/dist/tests/walker.test.js +0 -252
  200. package/dist/tests/wave2-cluster-bc.test.js +0 -228
  201. package/dist/tests/wave2-cluster-d.test.js +0 -180
  202. package/dist/tests/wave2-cluster-e.test.js +0 -179
  203. package/dist/tests/wiki-qa-fixes.test.js +0 -270
  204. package/dist/tests/wiki.test.js +0 -529
  205. package/dist/tests/workflow-cli.test.js +0 -271
  206. package/dist/tests/workflow-markdown.test.js +0 -171
  207. package/dist/tests/workflow-path-escape.test.js +0 -132
  208. package/dist/tests/workflow-qa-fixes.test.js +0 -395
  209. package/dist/tests/workflows/indexer-rejection.test.js +0 -213
  210. /package/dist/{src/cli.js → cli.js} +0 -0
  211. /package/dist/{src/commands → commands}/completions.js +0 -0
  212. /package/dist/{src/commands → commands}/config-cli.js +0 -0
  213. /package/dist/{src/commands → commands}/curate.js +0 -0
  214. /package/dist/{src/commands → commands}/distill.js +0 -0
  215. /package/dist/{src/commands → commands}/events.js +0 -0
  216. /package/dist/{src/commands → commands}/history.js +0 -0
  217. /package/dist/{src/commands → commands}/info.js +0 -0
  218. /package/dist/{src/commands → commands}/init.js +0 -0
  219. /package/dist/{src/commands → commands}/install-audit.js +0 -0
  220. /package/dist/{src/commands → commands}/installed-stashes.js +0 -0
  221. /package/dist/{src/commands → commands}/migration-help.js +0 -0
  222. /package/dist/{src/commands → commands}/proposal.js +0 -0
  223. /package/dist/{src/commands → commands}/propose.js +0 -0
  224. /package/dist/{src/commands → commands}/reflect.js +0 -0
  225. /package/dist/{src/commands → commands}/registry-search.js +0 -0
  226. /package/dist/{src/commands → commands}/remember.js +0 -0
  227. /package/dist/{src/commands → commands}/search.js +0 -0
  228. /package/dist/{src/commands → commands}/self-update.js +0 -0
  229. /package/dist/{src/commands → commands}/show.js +0 -0
  230. /package/dist/{src/commands → commands}/source-add.js +0 -0
  231. /package/dist/{src/commands → commands}/source-clone.js +0 -0
  232. /package/dist/{src/commands → commands}/source-manage.js +0 -0
  233. /package/dist/{src/commands → commands}/vault.js +0 -0
  234. /package/dist/{src/core → core}/asset-ref.js +0 -0
  235. /package/dist/{src/core → core}/asset-registry.js +0 -0
  236. /package/dist/{src/core → core}/asset-spec.js +0 -0
  237. /package/dist/{src/core → core}/common.js +0 -0
  238. /package/dist/{src/core → core}/config.js +0 -0
  239. /package/dist/{src/core → core}/errors.js +0 -0
  240. /package/dist/{src/core → core}/events.js +0 -0
  241. /package/dist/{src/core → core}/frontmatter.js +0 -0
  242. /package/dist/{src/core → core}/lesson-lint.js +0 -0
  243. /package/dist/{src/core → core}/markdown.js +0 -0
  244. /package/dist/{src/core → core}/paths.js +0 -0
  245. /package/dist/{src/core → core}/proposals.js +0 -0
  246. /package/dist/{src/core → core}/warn.js +0 -0
  247. /package/dist/{src/core → core}/write-source.js +0 -0
  248. /package/dist/{src/indexer → indexer}/db-search.js +0 -0
  249. /package/dist/{src/indexer → indexer}/db.js +0 -0
  250. /package/dist/{src/indexer → indexer}/file-context.js +0 -0
  251. /package/dist/{src/indexer → indexer}/graph-boost.js +0 -0
  252. /package/dist/{src/indexer → indexer}/graph-extraction.js +0 -0
  253. /package/dist/{src/indexer → indexer}/indexer.js +0 -0
  254. /package/dist/{src/indexer → indexer}/manifest.js +0 -0
  255. /package/dist/{src/indexer → indexer}/matchers.js +0 -0
  256. /package/dist/{src/indexer → indexer}/memory-inference.js +0 -0
  257. /package/dist/{src/indexer → indexer}/metadata.js +0 -0
  258. /package/dist/{src/indexer → indexer}/search-fields.js +0 -0
  259. /package/dist/{src/indexer → indexer}/search-source.js +0 -0
  260. /package/dist/{src/indexer → indexer}/semantic-status.js +0 -0
  261. /package/dist/{src/indexer → indexer}/usage-events.js +0 -0
  262. /package/dist/{src/indexer → indexer}/walker.js +0 -0
  263. /package/dist/{src/integrations → integrations}/agent/config.js +0 -0
  264. /package/dist/{src/integrations → integrations}/agent/detect.js +0 -0
  265. /package/dist/{src/integrations → integrations}/agent/index.js +0 -0
  266. /package/dist/{src/integrations → integrations}/agent/profiles.js +0 -0
  267. /package/dist/{src/integrations → integrations}/agent/prompts.js +0 -0
  268. /package/dist/{src/integrations → integrations}/agent/spawn.js +0 -0
  269. /package/dist/{src/integrations → integrations}/github.js +0 -0
  270. /package/dist/{src/integrations → integrations}/lockfile.js +0 -0
  271. /package/dist/{src/llm → llm}/client.js +0 -0
  272. /package/dist/{src/llm → llm}/embedder.js +0 -0
  273. /package/dist/{src/llm → llm}/embedders/cache.js +0 -0
  274. /package/dist/{src/llm → llm}/embedders/local.js +0 -0
  275. /package/dist/{src/llm → llm}/embedders/remote.js +0 -0
  276. /package/dist/{src/llm → llm}/embedders/types.js +0 -0
  277. /package/dist/{src/llm → llm}/feature-gate.js +0 -0
  278. /package/dist/{src/llm → llm}/graph-extract.js +0 -0
  279. /package/dist/{src/llm → llm}/index-passes.js +0 -0
  280. /package/dist/{src/llm → llm}/memory-infer.js +0 -0
  281. /package/dist/{src/llm → llm}/metadata-enhance.js +0 -0
  282. /package/dist/{src/output → output}/cli-hints.js +0 -0
  283. /package/dist/{src/output → output}/context.js +0 -0
  284. /package/dist/{src/output → output}/renderers.js +0 -0
  285. /package/dist/{src/output → output}/shapes.js +0 -0
  286. /package/dist/{src/output → output}/text.js +0 -0
  287. /package/dist/{src/registry → registry}/build-index.js +0 -0
  288. /package/dist/{src/registry → registry}/create-provider-registry.js +0 -0
  289. /package/dist/{src/registry → registry}/factory.js +0 -0
  290. /package/dist/{src/registry → registry}/origin-resolve.js +0 -0
  291. /package/dist/{src/registry → registry}/providers/index.js +0 -0
  292. /package/dist/{src/registry → registry}/providers/skills-sh.js +0 -0
  293. /package/dist/{src/registry → registry}/providers/static-index.js +0 -0
  294. /package/dist/{src/registry → registry}/providers/types.js +0 -0
  295. /package/dist/{src/registry → registry}/resolve.js +0 -0
  296. /package/dist/{src/registry → registry}/types.js +0 -0
  297. /package/dist/{src/setup → setup}/detect.js +0 -0
  298. /package/dist/{src/setup → setup}/ripgrep-install.js +0 -0
  299. /package/dist/{src/setup → setup}/ripgrep-resolve.js +0 -0
  300. /package/dist/{src/setup → setup}/setup.js +0 -0
  301. /package/dist/{src/setup → setup}/steps.js +0 -0
  302. /package/dist/{src/sources → sources}/include.js +0 -0
  303. /package/dist/{src/sources → sources}/provider-factory.js +0 -0
  304. /package/dist/{src/sources → sources}/provider.js +0 -0
  305. /package/dist/{src/sources → sources}/providers/filesystem.js +0 -0
  306. /package/dist/{src/sources → sources}/providers/git.js +0 -0
  307. /package/dist/{src/sources → sources}/providers/index.js +0 -0
  308. /package/dist/{src/sources → sources}/providers/install-types.js +0 -0
  309. /package/dist/{src/sources → sources}/providers/npm.js +0 -0
  310. /package/dist/{src/sources → sources}/providers/provider-utils.js +0 -0
  311. /package/dist/{src/sources → sources}/providers/sync-from-ref.js +0 -0
  312. /package/dist/{src/sources → sources}/providers/tar-utils.js +0 -0
  313. /package/dist/{src/sources → sources}/providers/website.js +0 -0
  314. /package/dist/{src/sources → sources}/resolve.js +0 -0
  315. /package/dist/{src/sources → sources}/types.js +0 -0
  316. /package/dist/{src/templates → templates}/wiki-templates.js +0 -0
  317. /package/dist/{src/version.js → version.js} +0 -0
  318. /package/dist/{src/wiki → wiki}/wiki.js +0 -0
  319. /package/dist/{src/workflows → workflows}/authoring.js +0 -0
  320. /package/dist/{src/workflows → workflows}/cli.js +0 -0
  321. /package/dist/{src/workflows → workflows}/db.js +0 -0
  322. /package/dist/{src/workflows → workflows}/document-cache.js +0 -0
  323. /package/dist/{src/workflows → workflows}/parser.js +0 -0
  324. /package/dist/{src/workflows → workflows}/renderer.js +0 -0
  325. /package/dist/{src/workflows → workflows}/runs.js +0 -0
  326. /package/dist/{src/workflows → workflows}/schema.js +0 -0
  327. /package/dist/{src/workflows → workflows}/validator.js +0 -0
@@ -1,317 +0,0 @@
1
- /**
2
- * akm-bench corpus loader (spec §5.4 + §13.1).
3
- *
4
- * Tasks live at `tests/fixtures/bench/tasks/<domain>/<task-id>/task.yaml`. Each
5
- * task is a flat YAML record (see §13.1). The schema lands in #237 and grows
6
- * over time; #236 only ships the loader and one sample task fixture.
7
- *
8
- * The `tests/fixtures/bench/tasks/` directory may not exist on `release/0.7.0`
9
- * yet — that's #237's deliverable. `listTasks()` MUST return `[]` cleanly when
10
- * the directory is missing rather than throwing, so consumers degrade gracefully.
11
- */
12
- import { createHash } from "node:crypto";
13
- import fs from "node:fs";
14
- import path from "node:path";
15
- import { parse as parseYaml } from "yaml";
16
- /**
17
- * Closed set of memory-operation labels (#262).
18
- *
19
- * Each value names the kind of memory / knowledge ability the task exercises:
20
- * - `procedural_lookup` — find and apply a single procedural skill.
21
- * - `multi_asset_composition` — combine guidance from two+ assets.
22
- * - `temporal_update` — apply the most recent guidance over older versions.
23
- * - `conflict_resolution` — choose between conflicting assets.
24
- * - `abstention` — recognise no relevant asset exists and decline to load.
25
- * - `noisy_retrieval` — succeed despite distractor / irrelevant assets.
26
- *
27
- * Adding a value here is a CORPUS-schema change; callers iterate the closed
28
- * set when laying out coverage tables.
29
- */
30
- export const MEMORY_ABILITY_VALUES = [
31
- "procedural_lookup",
32
- "multi_asset_composition",
33
- "temporal_update",
34
- "conflict_resolution",
35
- "abstention",
36
- "noisy_retrieval",
37
- ];
38
- const TASKS_ROOT = path.resolve(__dirname, "..", "fixtures", "bench", "tasks");
39
- /** Public for tests; resolves the corpus root in case callers need to assert it. */
40
- export function getTasksRoot() {
41
- return TASKS_ROOT;
42
- }
43
- /**
44
- * Compute a deterministic SHA-256 hash over a selected task corpus (#250).
45
- *
46
- * Two reports with the same selected task IDs and the same task body bytes
47
- * produce the same hash. The hash is order-independent: callers may pass IDs
48
- * in any order — the function sorts them lexicographically before hashing.
49
- *
50
- * The `taskBodies` map is keyed by task id and carries the raw `task.yaml`
51
- * bytes (or any deterministic per-task identity payload). Tasks present in
52
- * `taskIds` but missing from `taskBodies` are hashed with an empty body so
53
- * the hash still distinguishes the selection.
54
- *
55
- * Encoding (per id, in sorted order):
56
- * `<id>\0<body-bytes>\0`
57
- *
58
- * Used by `bench compare` to refuse mismatched corpora unless the operator
59
- * explicitly opts in via `--allow-corpus-mismatch`.
60
- */
61
- export function computeTaskCorpusHash(taskIds, taskBodies) {
62
- const sortedIds = [...taskIds].sort();
63
- const hash = createHash("sha256");
64
- for (const id of sortedIds) {
65
- hash.update(id);
66
- hash.update("\0");
67
- hash.update(taskBodies.get(id) ?? "");
68
- hash.update("\0");
69
- }
70
- return hash.digest("hex");
71
- }
72
- /**
73
- * Read the raw `task.yaml` bytes for a task whose `taskDir` is known. Returns
74
- * the empty string when the file is missing — callers should still hash the
75
- * id so the selection's identity is preserved.
76
- */
77
- export function readTaskBody(taskDir) {
78
- const yamlPath = path.join(taskDir, "task.yaml");
79
- try {
80
- return fs.readFileSync(yamlPath, "utf8");
81
- }
82
- catch {
83
- return "";
84
- }
85
- }
86
- /**
87
- * The `_example/` task tree is reserved for loader unit tests; real corpus
88
- * statistics must exclude it. The path-prefix check matches both POSIX (`/`)
89
- * and Windows (`\`) separators.
90
- */
91
- const EXAMPLE_PREFIX = `${path.sep}_example${path.sep}`;
92
- function isExampleTaskDir(dir) {
93
- return dir.includes(EXAMPLE_PREFIX);
94
- }
95
- /**
96
- * Load a single task by id. Walks the tasks tree until a directory whose
97
- * `task.yaml` carries the requested `id` is found. By default the
98
- * `_example/` tree is skipped; pass `{ includeExamples: true }` to load
99
- * tasks under that prefix (used by loader-unit tests).
100
- *
101
- * Throws if the corpus directory is missing or no task matches.
102
- */
103
- export function loadTask(taskId, options = {}) {
104
- if (!fs.existsSync(TASKS_ROOT)) {
105
- throw new Error(`bench corpus directory missing: ${TASKS_ROOT}`);
106
- }
107
- for (const candidate of walkTaskDirs(TASKS_ROOT)) {
108
- if (!options.includeExamples && isExampleTaskDir(candidate))
109
- continue;
110
- const meta = readTask(candidate);
111
- if (meta && meta.id === taskId)
112
- return meta;
113
- }
114
- throw new Error(`task not found: ${taskId}`);
115
- }
116
- /**
117
- * Return every task in the corpus, optionally filtered by `slice`. When the
118
- * corpus directory is missing this returns `[]`. By default tasks under the
119
- * `_example/` tree are excluded; pass `{ includeExamples: true }` to include
120
- * them.
121
- */
122
- export function listTasks(options = {}) {
123
- if (!fs.existsSync(TASKS_ROOT))
124
- return [];
125
- const out = [];
126
- for (const dir of walkTaskDirs(TASKS_ROOT)) {
127
- if (!options.includeExamples && isExampleTaskDir(dir))
128
- continue;
129
- const meta = readTask(dir);
130
- if (!meta)
131
- continue;
132
- if (options.slice) {
133
- // Tasks without an explicit `slice:` are partitioned by id-hash so the
134
- // filter behaves consistently with `partitionSlice()`. Without this,
135
- // an unsliced task would always pass through both `slice: "train"` and
136
- // `slice: "eval"` filters, double-counting in evaluation reports.
137
- if (effectiveSlice(meta) !== options.slice)
138
- continue;
139
- }
140
- out.push(meta);
141
- }
142
- out.sort((a, b) => a.id.localeCompare(b.id));
143
- return out;
144
- }
145
- /**
146
- * Partition a list of tasks into train/eval slices. Tasks declaring an explicit
147
- * `slice:` are honoured; tasks that don't are placed by `id-hash mod 2 === 0`
148
- * → train, else eval. The hash is SHA-1 of the id (deterministic across hosts).
149
- */
150
- export function partitionSlice(tasks) {
151
- const train = [];
152
- const evalSlice = [];
153
- for (const task of tasks) {
154
- const slice = effectiveSlice(task);
155
- if (slice === "train")
156
- train.push(task);
157
- else
158
- evalSlice.push(task);
159
- }
160
- return { train, eval: evalSlice };
161
- }
162
- function assignSliceByHash(id) {
163
- // SHA-1 first byte parity is stable, fast, and uniformly distributed enough
164
- // for slice partitioning. We avoid `node:crypto.randomInt` (non-deterministic).
165
- const digest = createHash("sha1").update(id).digest();
166
- return digest[0] % 2 === 0 ? "train" : "eval";
167
- }
168
- /**
169
- * Resolve a task's effective slice. If `task.yaml` declares `slice:` we honour
170
- * it; otherwise the id-hash partition assigns one deterministically. Exported
171
- * so that consumers (and tests) can ask "which slice would this task fall in?"
172
- * without re-running `partitionSlice()`.
173
- */
174
- export function effectiveSlice(task) {
175
- return task.slice ?? assignSliceByHash(task.id);
176
- }
177
- /** Walk the corpus tree depth-first, yielding every directory containing a `task.yaml`. */
178
- function* walkTaskDirs(root) {
179
- const stack = [root];
180
- while (stack.length > 0) {
181
- const dir = stack.pop();
182
- if (!dir)
183
- continue;
184
- let entries;
185
- try {
186
- entries = fs.readdirSync(dir, { withFileTypes: true });
187
- }
188
- catch {
189
- continue;
190
- }
191
- if (entries.some((e) => e.isFile() && e.name === "task.yaml")) {
192
- yield dir;
193
- continue; // Don't recurse beneath a task directory.
194
- }
195
- for (const entry of entries) {
196
- if (entry.isDirectory())
197
- stack.push(path.join(dir, entry.name));
198
- }
199
- }
200
- }
201
- function readTask(taskDir) {
202
- const yamlPath = path.join(taskDir, "task.yaml");
203
- let text;
204
- try {
205
- text = fs.readFileSync(yamlPath, "utf8");
206
- }
207
- catch {
208
- return undefined;
209
- }
210
- return parseTaskYaml(text, taskDir);
211
- }
212
- export function parseTaskYaml(text, taskDir) {
213
- let raw;
214
- try {
215
- raw = parseYaml(text);
216
- }
217
- catch {
218
- return undefined;
219
- }
220
- if (!raw || typeof raw !== "object")
221
- return undefined;
222
- const id = asString(raw.id);
223
- const title = asString(raw.title);
224
- const domain = asString(raw.domain);
225
- const difficulty = asEnum(raw.difficulty, ["easy", "medium", "hard"]);
226
- const stash = asString(raw.stash);
227
- const verifier = asEnum(raw.verifier, ["script", "pytest", "regex"]);
228
- const tokens = asNumber(raw.budget?.tokens);
229
- const wallMs = asNumber(raw.budget?.wallMs);
230
- if (!id || !title || !domain || !difficulty || !stash || !verifier || tokens === undefined || wallMs === undefined) {
231
- return undefined;
232
- }
233
- const slice = raw.slice === undefined ? undefined : asEnum(raw.slice, ["train", "eval"]);
234
- const goldRef = asString(raw.gold_ref);
235
- const stashOverlay = asString(raw.stash_overlay);
236
- const expectedMatch = asString(raw.expected_match);
237
- const meta = {
238
- id,
239
- title,
240
- domain,
241
- difficulty,
242
- stash,
243
- verifier,
244
- budget: { tokens, wallMs },
245
- taskDir,
246
- };
247
- if (slice !== undefined)
248
- meta.slice = slice;
249
- if (goldRef !== undefined)
250
- meta.goldRef = goldRef;
251
- if (stashOverlay !== undefined)
252
- meta.stashOverlay = stashOverlay;
253
- if (expectedMatch !== undefined)
254
- meta.expectedMatch = expectedMatch;
255
- // #262 memory-operation tags. Each tag is OPTIONAL — invalid values are
256
- // silently ignored so a malformed tag never breaks an existing task. This
257
- // matches the broader "loader returns undefined on bad core fields, drops
258
- // bad tags" contract documented in the §13.1 schema.
259
- const memoryAbility = asEnum(raw.memory_ability, MEMORY_ABILITY_VALUES);
260
- if (memoryAbility !== undefined)
261
- meta.memoryAbility = memoryAbility;
262
- const workflowFocus = asString(raw.workflow_focus);
263
- if (workflowFocus !== undefined)
264
- meta.workflowFocus = workflowFocus;
265
- const taskFamily = asString(raw.task_family);
266
- if (taskFamily !== undefined)
267
- meta.taskFamily = taskFamily;
268
- const expectedTransferFrom = asStringArray(raw.expected_transfer_from);
269
- if (expectedTransferFrom !== undefined)
270
- meta.expectedTransferFrom = expectedTransferFrom;
271
- const abstentionCase = asBoolean(raw.abstention_case);
272
- if (abstentionCase !== undefined)
273
- meta.abstentionCase = abstentionCase;
274
- const conflictCase = asBoolean(raw.conflict_case);
275
- if (conflictCase !== undefined)
276
- meta.conflictCase = conflictCase;
277
- const staleGuidanceCase = asBoolean(raw.stale_guidance_case);
278
- if (staleGuidanceCase !== undefined)
279
- meta.staleGuidanceCase = staleGuidanceCase;
280
- const akmKeywords = asString(raw.akm_keywords);
281
- if (akmKeywords !== undefined)
282
- meta.akmKeywords = akmKeywords;
283
- return meta;
284
- }
285
- function asBoolean(value) {
286
- if (typeof value === "boolean")
287
- return value;
288
- return undefined;
289
- }
290
- function asStringArray(value) {
291
- if (!Array.isArray(value))
292
- return undefined;
293
- const out = [];
294
- for (const entry of value) {
295
- if (typeof entry === "string" && entry.length > 0)
296
- out.push(entry);
297
- }
298
- return out;
299
- }
300
- function asString(value) {
301
- return typeof value === "string" && value.length > 0 ? value : undefined;
302
- }
303
- function asNumber(value) {
304
- if (typeof value === "number" && Number.isFinite(value))
305
- return value;
306
- if (typeof value === "string") {
307
- const parsed = Number.parseFloat(value);
308
- if (Number.isFinite(parsed))
309
- return parsed;
310
- }
311
- return undefined;
312
- }
313
- function asEnum(value, allowed) {
314
- if (typeof value !== "string")
315
- return undefined;
316
- return allowed.includes(value) ? value : undefined;
317
- }
@@ -1,258 +0,0 @@
1
- /**
2
- * Unit tests for the bench corpus loader.
3
- *
4
- * • `listTasks()` returns `[]` cleanly when the corpus dir is missing.
5
- * • The shipped sample task at `_example/example-task` is excluded by
6
- * default but loadable via `{ includeExamples: true }`.
7
- * • The seeded corpus contains 23 tasks (issue #237 seeded 17 across
8
- * three domains; #259 added six workflow-compliance tasks) and every
9
- * entry validates against the §13.1 schema.
10
- * • `partitionSlice` is deterministic — same input → same partitioning
11
- * across calls.
12
- */
13
- import { describe, expect, test } from "bun:test";
14
- import fs from "node:fs";
15
- import path from "node:path";
16
- import { computeTaskCorpusHash, effectiveSlice, getTasksRoot, listTasks, loadTask, MEMORY_ABILITY_VALUES, parseTaskYaml, partitionSlice, readTaskBody, } from "./corpus";
17
- import { benchMkdtemp } from "./tmp";
18
- describe("listTasks", () => {
19
- test("the corpus root resolves under tests/fixtures/bench/tasks", () => {
20
- expect(getTasksRoot()).toMatch(/tests[\\/]+fixtures[\\/]+bench[\\/]+tasks$/);
21
- });
22
- test("returns an array (possibly empty) without throwing", () => {
23
- const tasks = listTasks();
24
- expect(Array.isArray(tasks)).toBe(true);
25
- });
26
- test("excludes `_example/` tasks by default", () => {
27
- const tasks = listTasks();
28
- expect(tasks.find((t) => t.id.startsWith("_example/"))).toBeUndefined();
29
- });
30
- test("loads `_example/` when includeExamples is set", () => {
31
- const tasks = listTasks({ includeExamples: true });
32
- const sample = tasks.find((t) => t.id === "_example/example-task");
33
- expect(sample).toBeDefined();
34
- expect(sample?.title).toContain("Example task");
35
- expect(sample?.stash).toBe("minimal");
36
- expect(sample?.verifier).toBe("script");
37
- expect(sample?.budget.tokens).toBe(1000);
38
- expect(sample?.budget.wallMs).toBe(30_000);
39
- });
40
- test("seeds hand-authored tasks across all domains", () => {
41
- const tasks = listTasks();
42
- expect(tasks).toHaveLength(40);
43
- const byDomain = new Map();
44
- for (const task of tasks) {
45
- const list = byDomain.get(task.domain) ?? [];
46
- list.push(task);
47
- byDomain.set(task.domain, list);
48
- }
49
- expect(new Set(byDomain.keys())).toEqual(new Set(["docker-homelab", "az-cli", "opencode", "workflow-compliance", "drillbit", "inkwell"]));
50
- expect(byDomain.get("docker-homelab")).toHaveLength(6);
51
- expect(byDomain.get("az-cli")).toHaveLength(6);
52
- expect(byDomain.get("opencode")).toHaveLength(6);
53
- expect(byDomain.get("workflow-compliance")).toHaveLength(6);
54
- expect(byDomain.get("drillbit")).toHaveLength(7);
55
- expect(byDomain.get("inkwell")).toHaveLength(9);
56
- });
57
- test("every task validates against the §13.1 schema", () => {
58
- const ID_RE = /^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/;
59
- for (const task of listTasks()) {
60
- expect(task.id).toMatch(ID_RE);
61
- expect(task.title.length).toBeGreaterThan(0);
62
- expect(["easy", "medium", "hard"]).toContain(task.difficulty);
63
- expect(["train", "eval"]).toContain(task.slice);
64
- expect(["pytest", "script", "regex"]).toContain(task.verifier);
65
- expect(typeof task.stash).toBe("string");
66
- expect(task.budget.tokens).toBeGreaterThan(0);
67
- expect(task.budget.wallMs).toBeGreaterThan(0);
68
- if (task.verifier === "regex") {
69
- expect(task.expectedMatch).toBeDefined();
70
- expect((task.expectedMatch ?? "").length).toBeGreaterThan(0);
71
- }
72
- }
73
- });
74
- test("filters by slice when requested", () => {
75
- const train = listTasks({ slice: "train" });
76
- const evalTasks = listTasks({ slice: "eval" });
77
- expect(train.every((t) => t.slice === "train")).toBe(true);
78
- expect(evalTasks.every((t) => t.slice === "eval")).toBe(true);
79
- // 23 train (19 + 2 drillbit train + 2 inkwell train)
80
- // 17 eval (15 prior + 2 new: inkwell/full-config + opencode/select-correct-skill)
81
- expect(train).toHaveLength(23);
82
- expect(evalTasks).toHaveLength(17);
83
- });
84
- });
85
- describe("loadTask", () => {
86
- test("loads a real corpus task by id", () => {
87
- const meta = loadTask("docker-homelab/redis-healthcheck");
88
- expect(meta.title).toContain("Redis healthcheck");
89
- expect(meta.taskDir).toContain("docker-homelab/redis-healthcheck");
90
- expect(meta.verifier).toBe("pytest");
91
- });
92
- test("loads the example task only with includeExamples", () => {
93
- expect(() => loadTask("_example/example-task")).toThrow();
94
- const meta = loadTask("_example/example-task", { includeExamples: true });
95
- expect(meta.taskDir).toContain("_example/example-task");
96
- });
97
- test("throws on unknown id", () => {
98
- expect(() => loadTask("does/not/exist")).toThrow();
99
- });
100
- });
101
- describe("partitionSlice", () => {
102
- function fakeTask(id, slice) {
103
- return {
104
- id,
105
- title: id,
106
- domain: "test",
107
- difficulty: "easy",
108
- stash: "minimal",
109
- verifier: "regex",
110
- budget: { tokens: 1000, wallMs: 1000 },
111
- taskDir: "/tmp/none",
112
- ...(slice ? { slice } : {}),
113
- };
114
- }
115
- test("explicit slice fields are honoured", () => {
116
- const tasks = [fakeTask("a", "train"), fakeTask("b", "eval"), fakeTask("c", "train")];
117
- const { train, eval: evalSlice } = partitionSlice(tasks);
118
- expect(train.map((t) => t.id).sort()).toEqual(["a", "c"]);
119
- expect(evalSlice.map((t) => t.id)).toEqual(["b"]);
120
- });
121
- test("tasks without explicit slice get a deterministic assignment", () => {
122
- const tasks = [fakeTask("alpha"), fakeTask("beta"), fakeTask("gamma"), fakeTask("delta"), fakeTask("epsilon")];
123
- const a = partitionSlice(tasks);
124
- const b = partitionSlice(tasks);
125
- expect(a.train.map((t) => t.id)).toEqual(b.train.map((t) => t.id));
126
- expect(a.eval.map((t) => t.id)).toEqual(b.eval.map((t) => t.id));
127
- // Sanity: every task ends up in exactly one slice.
128
- expect(a.train.length + a.eval.length).toBe(tasks.length);
129
- });
130
- test("partition of the real corpus is stable across calls", () => {
131
- const corpus = listTasks();
132
- const a = partitionSlice(corpus);
133
- const b = partitionSlice(corpus);
134
- expect(a.train.map((t) => t.id)).toEqual(b.train.map((t) => t.id));
135
- expect(a.eval.map((t) => t.id)).toEqual(b.eval.map((t) => t.id));
136
- });
137
- test("computeTaskCorpusHash is deterministic and order-independent (#250)", () => {
138
- const bodies = new Map([
139
- ["a/one", "id: a/one\ntitle: One\n"],
140
- ["b/two", "id: b/two\ntitle: Two\n"],
141
- ]);
142
- const h1 = computeTaskCorpusHash(["a/one", "b/two"], bodies);
143
- const h2 = computeTaskCorpusHash(["b/two", "a/one"], bodies);
144
- expect(h1).toBe(h2);
145
- expect(h1).toMatch(/^[0-9a-f]{64}$/);
146
- // Body change → hash change.
147
- const altBodies = new Map(bodies);
148
- altBodies.set("a/one", "id: a/one\ntitle: Different\n");
149
- const h3 = computeTaskCorpusHash(["a/one", "b/two"], altBodies);
150
- expect(h3).not.toBe(h1);
151
- // ID-set change → hash change.
152
- const h4 = computeTaskCorpusHash(["a/one"], bodies);
153
- expect(h4).not.toBe(h1);
154
- // readTaskBody returns "" for a missing taskDir without throwing.
155
- expect(readTaskBody("/does/not/exist")).toBe("");
156
- });
157
- test("a task without explicit slice is bucketed deterministically and goes to exactly one slice", () => {
158
- // This guards against the regression where `listTasks({ slice })` would
159
- // pass an unsliced task through *both* the train and eval filters because
160
- // the early code only excluded tasks whose explicit slice differed.
161
- const synthetic = {
162
- id: "synthetic/no-slice-task",
163
- title: "Synthetic task with no explicit slice",
164
- domain: "synthetic",
165
- difficulty: "easy",
166
- stash: "minimal",
167
- verifier: "regex",
168
- budget: { tokens: 1000, wallMs: 1000 },
169
- taskDir: "/tmp/none",
170
- };
171
- const slice = effectiveSlice(synthetic);
172
- expect(["train", "eval"]).toContain(slice);
173
- // Re-running must give the same bucket.
174
- expect(effectiveSlice(synthetic)).toBe(slice);
175
- // partitionSlice and effectiveSlice must agree.
176
- const { train, eval: evalSlice } = partitionSlice([synthetic]);
177
- if (slice === "train") {
178
- expect(train.map((t) => t.id)).toEqual([synthetic.id]);
179
- expect(evalSlice).toEqual([]);
180
- }
181
- else {
182
- expect(evalSlice.map((t) => t.id)).toEqual([synthetic.id]);
183
- expect(train).toEqual([]);
184
- }
185
- });
186
- });
187
- // ── Memory-operation tags (#262) ───────────────────────────────────────────
188
- describe("memory-operation tags (#262)", () => {
189
- test("MEMORY_ABILITY_VALUES is the documented closed set", () => {
190
- expect(new Set(MEMORY_ABILITY_VALUES)).toEqual(new Set([
191
- "procedural_lookup",
192
- "multi_asset_composition",
193
- "temporal_update",
194
- "conflict_resolution",
195
- "abstention",
196
- "noisy_retrieval",
197
- ]));
198
- });
199
- test("loader leaves tag fields undefined for legacy tasks (without new fields)", () => {
200
- // The shipped `_example/example-task` carries no #262 tags — it
201
- // continues to load cleanly with every new field undefined.
202
- const meta = loadTask("_example/example-task", { includeExamples: true });
203
- expect(meta.memoryAbility).toBeUndefined();
204
- expect(meta.taskFamily).toBeUndefined();
205
- expect(meta.workflowFocus).toBeUndefined();
206
- expect(meta.expectedTransferFrom).toBeUndefined();
207
- expect(meta.abstentionCase).toBeUndefined();
208
- expect(meta.conflictCase).toBeUndefined();
209
- expect(meta.staleGuidanceCase).toBeUndefined();
210
- });
211
- test("loader parses memory_ability + task_family from a tagged task", () => {
212
- // Every seeded corpus task is tagged with at least these two fields by
213
- // #262. Pick a representative entry and assert the round-trip.
214
- const meta = loadTask("docker-homelab/restart-policy");
215
- expect(meta.memoryAbility).toBe("procedural_lookup");
216
- expect(meta.taskFamily).toBe("docker-homelab/compose-basics");
217
- });
218
- test("every seeded corpus task carries memory_ability + task_family", () => {
219
- for (const task of listTasks()) {
220
- expect(task.memoryAbility).toBeDefined();
221
- expect(MEMORY_ABILITY_VALUES).toContain(task.memoryAbility);
222
- expect(task.taskFamily).toBeDefined();
223
- expect(task.taskFamily).toMatch(/^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/);
224
- }
225
- });
226
- test("invalid memory_ability values are dropped (loader stays permissive)", () => {
227
- const dir = benchMkdtemp("akm-bench-tag-");
228
- try {
229
- const taskDir = path.join(dir, "_example", "bad-tag");
230
- fs.mkdirSync(taskDir, { recursive: true });
231
- // Write a clone of `_example/example-task` augmented with a bogus tag.
232
- const yaml = [
233
- "id: _example/bad-tag",
234
- 'title: "Bogus tag"',
235
- "domain: _example",
236
- "difficulty: easy",
237
- "slice: train",
238
- "stash: minimal",
239
- "verifier: script",
240
- "budget:",
241
- " tokens: 1000",
242
- " wallMs: 30000",
243
- "memory_ability: not_a_real_ability",
244
- "task_family: _example/bad",
245
- "",
246
- ].join("\n");
247
- fs.writeFileSync(path.join(taskDir, "task.yaml"), yaml, "utf8");
248
- const parsed = parseTaskYaml(readTaskBody(taskDir), taskDir);
249
- expect(parsed).toBeDefined();
250
- expect(parsed?.id).toBe("_example/bad-tag");
251
- expect(parsed?.memoryAbility).toBeUndefined();
252
- expect(parsed?.taskFamily).toBe("_example/bad");
253
- }
254
- finally {
255
- fs.rmSync(dir, { recursive: true });
256
- }
257
- });
258
- });