akm-cli 0.7.0 → 0.7.2

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 (332) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{src/cli.js → cli.js} +22 -8
  3. package/dist/{src/commands → commands}/installed-stashes.js +1 -1
  4. package/dist/{src/commands → commands}/source-add.js +1 -1
  5. package/dist/{src/core → core}/common.js +16 -1
  6. package/dist/{src/core → core}/config.js +5 -2
  7. package/dist/{src/indexer → indexer}/db-search.js +16 -1
  8. package/dist/{src/indexer → indexer}/graph-extraction.js +5 -3
  9. package/dist/{src/indexer → indexer}/indexer.js +27 -11
  10. package/dist/{src/indexer → indexer}/memory-inference.js +47 -58
  11. package/dist/{src/indexer → indexer}/search-source.js +1 -1
  12. package/dist/{src/llm → llm}/client.js +61 -1
  13. package/dist/{src/llm → llm}/embedder.js +8 -5
  14. package/dist/{src/llm → llm}/embedders/local.js +8 -2
  15. package/dist/{src/llm → llm}/embedders/remote.js +4 -2
  16. package/dist/{src/llm → llm}/graph-extract.js +4 -4
  17. package/dist/llm/memory-infer.js +114 -0
  18. package/dist/{src/llm → llm}/metadata-enhance.js +2 -2
  19. package/dist/{src/output → output}/cli-hints.js +2 -0
  20. package/dist/{src/setup → setup}/setup.js +30 -20
  21. package/dist/sources/providers/website.js +27 -0
  22. package/dist/{src/sources/providers/website.js → sources/website-ingest.js} +38 -51
  23. package/docs/README.md +7 -0
  24. package/docs/migration/release-notes/0.7.0.md +14 -0
  25. package/package.json +11 -8
  26. package/dist/src/llm/memory-infer.js +0 -86
  27. package/dist/tests/add-website-source.test.js +0 -119
  28. package/dist/tests/agent/agent-config-loader.test.js +0 -70
  29. package/dist/tests/agent/agent-config.test.js +0 -221
  30. package/dist/tests/agent/agent-detect.test.js +0 -100
  31. package/dist/tests/agent/agent-spawn.test.js +0 -234
  32. package/dist/tests/agent-output.test.js +0 -186
  33. package/dist/tests/architecture/agent-no-llm-sdk-guard.test.js +0 -103
  34. package/dist/tests/architecture/agent-spawn-seam.test.js +0 -193
  35. package/dist/tests/architecture/llm-stateless-seam.test.js +0 -112
  36. package/dist/tests/asset-ref.test.js +0 -192
  37. package/dist/tests/asset-registry.test.js +0 -103
  38. package/dist/tests/asset-spec.test.js +0 -241
  39. package/dist/tests/bench/attribution.test.js +0 -996
  40. package/dist/tests/bench/cleanup-sigint.test.js +0 -83
  41. package/dist/tests/bench/cleanup.js +0 -234
  42. package/dist/tests/bench/cleanup.test.js +0 -166
  43. package/dist/tests/bench/cli.js +0 -1018
  44. package/dist/tests/bench/cli.test.js +0 -445
  45. package/dist/tests/bench/compare.test.js +0 -556
  46. package/dist/tests/bench/corpus.js +0 -317
  47. package/dist/tests/bench/corpus.test.js +0 -258
  48. package/dist/tests/bench/doctor.js +0 -525
  49. package/dist/tests/bench/driver.js +0 -401
  50. package/dist/tests/bench/driver.test.js +0 -584
  51. package/dist/tests/bench/environment.js +0 -233
  52. package/dist/tests/bench/environment.test.js +0 -199
  53. package/dist/tests/bench/evolve-metrics.js +0 -179
  54. package/dist/tests/bench/evolve-metrics.test.js +0 -187
  55. package/dist/tests/bench/evolve.js +0 -647
  56. package/dist/tests/bench/evolve.test.js +0 -624
  57. package/dist/tests/bench/failure-modes.test.js +0 -349
  58. package/dist/tests/bench/feedback-integrity.test.js +0 -457
  59. package/dist/tests/bench/leakage.test.js +0 -228
  60. package/dist/tests/bench/learning-curve.test.js +0 -134
  61. package/dist/tests/bench/metrics.js +0 -2395
  62. package/dist/tests/bench/metrics.test.js +0 -1150
  63. package/dist/tests/bench/no-os-tmpdir-invariant.test.js +0 -43
  64. package/dist/tests/bench/opencode-config.js +0 -194
  65. package/dist/tests/bench/opencode-config.test.js +0 -370
  66. package/dist/tests/bench/report.js +0 -1885
  67. package/dist/tests/bench/report.test.js +0 -1038
  68. package/dist/tests/bench/run-config.js +0 -355
  69. package/dist/tests/bench/run-config.test.js +0 -298
  70. package/dist/tests/bench/run-curate-test.js +0 -32
  71. package/dist/tests/bench/run-failing-tasks.js +0 -56
  72. package/dist/tests/bench/run-full-bench.js +0 -51
  73. package/dist/tests/bench/run-items36-targeted.js +0 -69
  74. package/dist/tests/bench/run-nano-quick.js +0 -42
  75. package/dist/tests/bench/run-waveg-targeted.js +0 -62
  76. package/dist/tests/bench/runner.js +0 -699
  77. package/dist/tests/bench/runner.test.js +0 -958
  78. package/dist/tests/bench/search-bridge.test.js +0 -331
  79. package/dist/tests/bench/tmp.js +0 -131
  80. package/dist/tests/bench/trajectory.js +0 -116
  81. package/dist/tests/bench/trajectory.test.js +0 -127
  82. package/dist/tests/bench/verifier.js +0 -114
  83. package/dist/tests/bench/verifier.test.js +0 -118
  84. package/dist/tests/bench/workflow-evaluator.js +0 -557
  85. package/dist/tests/bench/workflow-evaluator.test.js +0 -421
  86. package/dist/tests/bench/workflow-spec.js +0 -345
  87. package/dist/tests/bench/workflow-spec.test.js +0 -363
  88. package/dist/tests/bench/workflow-trace.js +0 -472
  89. package/dist/tests/bench/workflow-trace.test.js +0 -254
  90. package/dist/tests/benchmark-search-quality.js +0 -536
  91. package/dist/tests/benchmark-suite.js +0 -1441
  92. package/dist/tests/capture-cli.test.js +0 -112
  93. package/dist/tests/cli-errors.test.js +0 -204
  94. package/dist/tests/commands/events.test.js +0 -370
  95. package/dist/tests/commands/history.test.js +0 -418
  96. package/dist/tests/commands/import.test.js +0 -103
  97. package/dist/tests/commands/proposal-cli.test.js +0 -209
  98. package/dist/tests/commands/reflect-propose-cli.test.js +0 -333
  99. package/dist/tests/commands/remember.test.js +0 -97
  100. package/dist/tests/commands/scope-flags.test.js +0 -300
  101. package/dist/tests/commands/search.test.js +0 -537
  102. package/dist/tests/commands/show-indexer-parity.test.js +0 -117
  103. package/dist/tests/commands/show.test.js +0 -294
  104. package/dist/tests/common.test.js +0 -266
  105. package/dist/tests/completions.test.js +0 -142
  106. package/dist/tests/config-cli.test.js +0 -193
  107. package/dist/tests/config-llm-features.test.js +0 -139
  108. package/dist/tests/config.test.js +0 -569
  109. package/dist/tests/contracts/migration-baseline.test.js +0 -43
  110. package/dist/tests/contracts/reflect-propose-envelope.test.js +0 -139
  111. package/dist/tests/contracts/spec-helpers.js +0 -46
  112. package/dist/tests/contracts/v1-spec-section-11-proposal-queue.test.js +0 -228
  113. package/dist/tests/contracts/v1-spec-section-12-agent-config.test.js +0 -56
  114. package/dist/tests/contracts/v1-spec-section-13-lesson-type.test.js +0 -34
  115. package/dist/tests/contracts/v1-spec-section-14-llm-features.test.js +0 -94
  116. package/dist/tests/contracts/v1-spec-section-4-1-asset-types.test.js +0 -39
  117. package/dist/tests/contracts/v1-spec-section-4-2-quality-rules.test.js +0 -44
  118. package/dist/tests/contracts/v1-spec-section-5-configuration.test.js +0 -47
  119. package/dist/tests/contracts/v1-spec-section-6-orchestration.test.js +0 -40
  120. package/dist/tests/contracts/v1-spec-section-7-module-layout.test.js +0 -58
  121. package/dist/tests/contracts/v1-spec-section-8-extension-points.test.js +0 -34
  122. package/dist/tests/contracts/v1-spec-section-9-4-cli-surface.test.js +0 -75
  123. package/dist/tests/contracts/v1-spec-section-9-7-llm-agent-boundary.test.js +0 -36
  124. package/dist/tests/core/write-source.test.js +0 -366
  125. package/dist/tests/curate-command.test.js +0 -87
  126. package/dist/tests/db-scoring.test.js +0 -201
  127. package/dist/tests/db.test.js +0 -654
  128. package/dist/tests/distill-cli-flag.test.js +0 -208
  129. package/dist/tests/distill.test.js +0 -515
  130. package/dist/tests/docker-install.test.js +0 -120
  131. package/dist/tests/e2e.test.js +0 -1419
  132. package/dist/tests/embedder.test.js +0 -340
  133. package/dist/tests/embedding-model-config.test.js +0 -379
  134. package/dist/tests/feedback-command.test.js +0 -172
  135. package/dist/tests/file-context.test.js +0 -552
  136. package/dist/tests/fixtures/scripts/git/summarize-diff.js +0 -9
  137. package/dist/tests/fixtures/scripts/lint/eslint-check.js +0 -7
  138. package/dist/tests/fixtures/stashes/load.js +0 -166
  139. package/dist/tests/fixtures/stashes/load.test.js +0 -97
  140. package/dist/tests/fixtures/stashes/ranking-baseline/scripts/mem0-search.js +0 -12
  141. package/dist/tests/frontmatter.test.js +0 -190
  142. package/dist/tests/fts-field-weighting.test.js +0 -254
  143. package/dist/tests/fuzzy-search.test.js +0 -230
  144. package/dist/tests/git-provider-clone.test.js +0 -45
  145. package/dist/tests/github.test.js +0 -161
  146. package/dist/tests/graph-boost-ranking.test.js +0 -305
  147. package/dist/tests/graph-extraction.test.js +0 -282
  148. package/dist/tests/helpers/usage-events.js +0 -8
  149. package/dist/tests/index-pass-llm.test.js +0 -161
  150. package/dist/tests/indexer.test.js +0 -570
  151. package/dist/tests/info-command.test.js +0 -166
  152. package/dist/tests/init.test.js +0 -69
  153. package/dist/tests/install-script.test.js +0 -246
  154. package/dist/tests/integration/agent-real-profile.test.js +0 -94
  155. package/dist/tests/issue-36-repro.test.js +0 -304
  156. package/dist/tests/issues-191-194.test.js +0 -160
  157. package/dist/tests/lesson-lint.test.js +0 -111
  158. package/dist/tests/llm-client.test.js +0 -115
  159. package/dist/tests/llm-feature-gate.test.js +0 -151
  160. package/dist/tests/llm.test.js +0 -139
  161. package/dist/tests/lockfile.test.js +0 -216
  162. package/dist/tests/manifest.test.js +0 -205
  163. package/dist/tests/markdown.test.js +0 -126
  164. package/dist/tests/matchers-unit.test.js +0 -189
  165. package/dist/tests/memory-inference.test.js +0 -299
  166. package/dist/tests/merge-scoring.test.js +0 -136
  167. package/dist/tests/metadata.test.js +0 -313
  168. package/dist/tests/migration-help.test.js +0 -89
  169. package/dist/tests/origin-resolve.test.js +0 -124
  170. package/dist/tests/output-baseline.test.js +0 -218
  171. package/dist/tests/output-shapes-unit.test.js +0 -478
  172. package/dist/tests/parallel-search.test.js +0 -272
  173. package/dist/tests/parameter-metadata.test.js +0 -365
  174. package/dist/tests/paths.test.js +0 -177
  175. package/dist/tests/progressive-disclosure.test.js +0 -280
  176. package/dist/tests/proposals.test.js +0 -279
  177. package/dist/tests/proposed-quality.test.js +0 -271
  178. package/dist/tests/provider-registry.test.js +0 -32
  179. package/dist/tests/ranking-regression.test.js +0 -548
  180. package/dist/tests/reflect-propose.test.js +0 -455
  181. package/dist/tests/registry-build-index.test.js +0 -394
  182. package/dist/tests/registry-cli.test.js +0 -290
  183. package/dist/tests/registry-index-v2.test.js +0 -430
  184. package/dist/tests/registry-install.test.js +0 -728
  185. package/dist/tests/registry-providers/parity.test.js +0 -189
  186. package/dist/tests/registry-providers/skills-sh.test.js +0 -309
  187. package/dist/tests/registry-providers/static-index.test.js +0 -238
  188. package/dist/tests/registry-resolve.test.js +0 -126
  189. package/dist/tests/registry-search.test.js +0 -923
  190. package/dist/tests/remember-frontmatter.test.js +0 -378
  191. package/dist/tests/remember-unit.test.js +0 -123
  192. package/dist/tests/ripgrep-install.test.js +0 -251
  193. package/dist/tests/ripgrep-resolve.test.js +0 -108
  194. package/dist/tests/ripgrep.test.js +0 -163
  195. package/dist/tests/save-command.test.js +0 -94
  196. package/dist/tests/save-trust-qa-fixes.test.js +0 -270
  197. package/dist/tests/scoring-pipeline.test.js +0 -648
  198. package/dist/tests/search-include-proposed-cli.test.js +0 -118
  199. package/dist/tests/self-update.test.js +0 -442
  200. package/dist/tests/semantic-search-e2e.test.js +0 -512
  201. package/dist/tests/semantic-status.test.js +0 -471
  202. package/dist/tests/setup-run.integration.js +0 -877
  203. package/dist/tests/setup-wizard.test.js +0 -198
  204. package/dist/tests/setup.test.js +0 -131
  205. package/dist/tests/source-add.test.js +0 -11
  206. package/dist/tests/source-clone.test.js +0 -254
  207. package/dist/tests/source-manage.test.js +0 -366
  208. package/dist/tests/source-providers/filesystem.test.js +0 -82
  209. package/dist/tests/source-providers/git.test.js +0 -252
  210. package/dist/tests/source-providers/website.test.js +0 -128
  211. package/dist/tests/source-qa-fixes.test.js +0 -286
  212. package/dist/tests/source-registry.test.js +0 -350
  213. package/dist/tests/source-resolve.test.js +0 -100
  214. package/dist/tests/source-source.test.js +0 -281
  215. package/dist/tests/source.test.js +0 -533
  216. package/dist/tests/tar-utils-scan.test.js +0 -73
  217. package/dist/tests/toggle-components.test.js +0 -73
  218. package/dist/tests/usage-telemetry.test.js +0 -265
  219. package/dist/tests/utility-scoring.test.js +0 -558
  220. package/dist/tests/vault-load-error.test.js +0 -78
  221. package/dist/tests/vault-qa-fixes.test.js +0 -194
  222. package/dist/tests/vault.test.js +0 -429
  223. package/dist/tests/vector-search.test.js +0 -608
  224. package/dist/tests/walker.test.js +0 -252
  225. package/dist/tests/wave2-cluster-bc.test.js +0 -228
  226. package/dist/tests/wave2-cluster-d.test.js +0 -180
  227. package/dist/tests/wave2-cluster-e.test.js +0 -179
  228. package/dist/tests/wiki-qa-fixes.test.js +0 -270
  229. package/dist/tests/wiki.test.js +0 -529
  230. package/dist/tests/workflow-cli.test.js +0 -271
  231. package/dist/tests/workflow-markdown.test.js +0 -171
  232. package/dist/tests/workflow-path-escape.test.js +0 -132
  233. package/dist/tests/workflow-qa-fixes.test.js +0 -395
  234. package/dist/tests/workflows/indexer-rejection.test.js +0 -213
  235. /package/dist/{src/commands → commands}/completions.js +0 -0
  236. /package/dist/{src/commands → commands}/config-cli.js +0 -0
  237. /package/dist/{src/commands → commands}/curate.js +0 -0
  238. /package/dist/{src/commands → commands}/distill.js +0 -0
  239. /package/dist/{src/commands → commands}/events.js +0 -0
  240. /package/dist/{src/commands → commands}/history.js +0 -0
  241. /package/dist/{src/commands → commands}/info.js +0 -0
  242. /package/dist/{src/commands → commands}/init.js +0 -0
  243. /package/dist/{src/commands → commands}/install-audit.js +0 -0
  244. /package/dist/{src/commands → commands}/migration-help.js +0 -0
  245. /package/dist/{src/commands → commands}/proposal.js +0 -0
  246. /package/dist/{src/commands → commands}/propose.js +0 -0
  247. /package/dist/{src/commands → commands}/reflect.js +0 -0
  248. /package/dist/{src/commands → commands}/registry-search.js +0 -0
  249. /package/dist/{src/commands → commands}/remember.js +0 -0
  250. /package/dist/{src/commands → commands}/search.js +0 -0
  251. /package/dist/{src/commands → commands}/self-update.js +0 -0
  252. /package/dist/{src/commands → commands}/show.js +0 -0
  253. /package/dist/{src/commands → commands}/source-clone.js +0 -0
  254. /package/dist/{src/commands → commands}/source-manage.js +0 -0
  255. /package/dist/{src/commands → commands}/vault.js +0 -0
  256. /package/dist/{src/core → core}/asset-ref.js +0 -0
  257. /package/dist/{src/core → core}/asset-registry.js +0 -0
  258. /package/dist/{src/core → core}/asset-spec.js +0 -0
  259. /package/dist/{src/core → core}/errors.js +0 -0
  260. /package/dist/{src/core → core}/events.js +0 -0
  261. /package/dist/{src/core → core}/frontmatter.js +0 -0
  262. /package/dist/{src/core → core}/lesson-lint.js +0 -0
  263. /package/dist/{src/core → core}/markdown.js +0 -0
  264. /package/dist/{src/core → core}/paths.js +0 -0
  265. /package/dist/{src/core → core}/proposals.js +0 -0
  266. /package/dist/{src/core → core}/warn.js +0 -0
  267. /package/dist/{src/core → core}/write-source.js +0 -0
  268. /package/dist/{src/indexer → indexer}/db.js +0 -0
  269. /package/dist/{src/indexer → indexer}/file-context.js +0 -0
  270. /package/dist/{src/indexer → indexer}/graph-boost.js +0 -0
  271. /package/dist/{src/indexer → indexer}/manifest.js +0 -0
  272. /package/dist/{src/indexer → indexer}/matchers.js +0 -0
  273. /package/dist/{src/indexer → indexer}/metadata.js +0 -0
  274. /package/dist/{src/indexer → indexer}/search-fields.js +0 -0
  275. /package/dist/{src/indexer → indexer}/semantic-status.js +0 -0
  276. /package/dist/{src/indexer → indexer}/usage-events.js +0 -0
  277. /package/dist/{src/indexer → indexer}/walker.js +0 -0
  278. /package/dist/{src/integrations → integrations}/agent/config.js +0 -0
  279. /package/dist/{src/integrations → integrations}/agent/detect.js +0 -0
  280. /package/dist/{src/integrations → integrations}/agent/index.js +0 -0
  281. /package/dist/{src/integrations → integrations}/agent/profiles.js +0 -0
  282. /package/dist/{src/integrations → integrations}/agent/prompts.js +0 -0
  283. /package/dist/{src/integrations → integrations}/agent/spawn.js +0 -0
  284. /package/dist/{src/integrations → integrations}/github.js +0 -0
  285. /package/dist/{src/integrations → integrations}/lockfile.js +0 -0
  286. /package/dist/{src/llm → llm}/embedders/cache.js +0 -0
  287. /package/dist/{src/llm → llm}/embedders/types.js +0 -0
  288. /package/dist/{src/llm → llm}/feature-gate.js +0 -0
  289. /package/dist/{src/llm → llm}/index-passes.js +0 -0
  290. /package/dist/{src/output → output}/context.js +0 -0
  291. /package/dist/{src/output → output}/renderers.js +0 -0
  292. /package/dist/{src/output → output}/shapes.js +0 -0
  293. /package/dist/{src/output → output}/text.js +0 -0
  294. /package/dist/{src/registry → registry}/build-index.js +0 -0
  295. /package/dist/{src/registry → registry}/create-provider-registry.js +0 -0
  296. /package/dist/{src/registry → registry}/factory.js +0 -0
  297. /package/dist/{src/registry → registry}/origin-resolve.js +0 -0
  298. /package/dist/{src/registry → registry}/providers/index.js +0 -0
  299. /package/dist/{src/registry → registry}/providers/skills-sh.js +0 -0
  300. /package/dist/{src/registry → registry}/providers/static-index.js +0 -0
  301. /package/dist/{src/registry → registry}/providers/types.js +0 -0
  302. /package/dist/{src/registry → registry}/resolve.js +0 -0
  303. /package/dist/{src/registry → registry}/types.js +0 -0
  304. /package/dist/{src/setup → setup}/detect.js +0 -0
  305. /package/dist/{src/setup → setup}/ripgrep-install.js +0 -0
  306. /package/dist/{src/setup → setup}/ripgrep-resolve.js +0 -0
  307. /package/dist/{src/setup → setup}/steps.js +0 -0
  308. /package/dist/{src/sources → sources}/include.js +0 -0
  309. /package/dist/{src/sources → sources}/provider-factory.js +0 -0
  310. /package/dist/{src/sources → sources}/provider.js +0 -0
  311. /package/dist/{src/sources → sources}/providers/filesystem.js +0 -0
  312. /package/dist/{src/sources → sources}/providers/git.js +0 -0
  313. /package/dist/{src/sources → sources}/providers/index.js +0 -0
  314. /package/dist/{src/sources → sources}/providers/install-types.js +0 -0
  315. /package/dist/{src/sources → sources}/providers/npm.js +0 -0
  316. /package/dist/{src/sources → sources}/providers/provider-utils.js +0 -0
  317. /package/dist/{src/sources → sources}/providers/sync-from-ref.js +0 -0
  318. /package/dist/{src/sources → sources}/providers/tar-utils.js +0 -0
  319. /package/dist/{src/sources → sources}/resolve.js +0 -0
  320. /package/dist/{src/sources → sources}/types.js +0 -0
  321. /package/dist/{src/templates → templates}/wiki-templates.js +0 -0
  322. /package/dist/{src/version.js → version.js} +0 -0
  323. /package/dist/{src/wiki → wiki}/wiki.js +0 -0
  324. /package/dist/{src/workflows → workflows}/authoring.js +0 -0
  325. /package/dist/{src/workflows → workflows}/cli.js +0 -0
  326. /package/dist/{src/workflows → workflows}/db.js +0 -0
  327. /package/dist/{src/workflows → workflows}/document-cache.js +0 -0
  328. /package/dist/{src/workflows → workflows}/parser.js +0 -0
  329. /package/dist/{src/workflows → workflows}/renderer.js +0 -0
  330. /package/dist/{src/workflows → workflows}/runs.js +0 -0
  331. /package/dist/{src/workflows → workflows}/schema.js +0 -0
  332. /package/dist/{src/workflows → workflows}/validator.js +0 -0
@@ -1,139 +0,0 @@
1
- /**
2
- * Envelope-shape contract tests for `akm reflect` and `akm propose` (#226).
3
- *
4
- * Locks the structural shape of the success and failure envelopes so a
5
- * future refactor cannot silently rename or drop a field. The producer-shape
6
- * functions in `src/output/shapes.ts` are the production rendering path —
7
- * we exercise them with realistic command result objects.
8
- *
9
- * Backfill for issue #284 GAP-MED 2.
10
- */
11
- import { describe, expect, test } from "bun:test";
12
- import { shapeProposalProducerOutput } from "../../src/output/shapes";
13
- const proposal = {
14
- id: "uuid-1",
15
- ref: "lesson:rg-over-grep",
16
- status: "pending",
17
- source: "reflect",
18
- sourceRun: "run-7",
19
- createdAt: "2026-04-27T00:00:00Z",
20
- updatedAt: "2026-04-27T00:00:00Z",
21
- payload: { content: "BODY" },
22
- };
23
- describe("reflect/propose success envelope contract", () => {
24
- test("normal: required fields present", () => {
25
- const result = {
26
- schemaVersion: 1,
27
- ok: true,
28
- ref: "lesson:rg-over-grep",
29
- agentProfile: "claude",
30
- durationMs: 12,
31
- proposal,
32
- };
33
- const out = shapeProposalProducerOutput(result, "normal");
34
- expect(out.ok).toBe(true);
35
- expect(out.ref).toBe("lesson:rg-over-grep");
36
- expect(out.agentProfile).toBe("claude");
37
- expect(out.durationMs).toBe(12);
38
- expect(out).toHaveProperty("proposal");
39
- // schemaVersion only at full
40
- expect(out).not.toHaveProperty("schemaVersion");
41
- });
42
- test("full: success envelope adds schemaVersion", () => {
43
- const result = {
44
- schemaVersion: 1,
45
- ok: true,
46
- ref: "lesson:rg-over-grep",
47
- agentProfile: "claude",
48
- durationMs: 12,
49
- proposal,
50
- };
51
- const out = shapeProposalProducerOutput(result, "full");
52
- expect(out.schemaVersion).toBe(1);
53
- });
54
- test("brief: shaped proposal still includes id+ref+status (via brief→normal upgrade)", () => {
55
- const result = { schemaVersion: 1, ok: true, ref: "lesson:rg-over-grep", proposal };
56
- const out = shapeProposalProducerOutput(result, "brief");
57
- const p = out.proposal;
58
- expect(p.id).toBe("uuid-1");
59
- expect(p.ref).toBe("lesson:rg-over-grep");
60
- expect(p.status).toBe("pending");
61
- });
62
- });
63
- describe("reflect/propose failure envelope contract", () => {
64
- test("non_zero_exit: required failure fields present", () => {
65
- const failure = {
66
- schemaVersion: 1,
67
- ok: false,
68
- reason: "non_zero_exit",
69
- error: "exited with code 7",
70
- ref: "lesson:rg-over-grep",
71
- exitCode: 7,
72
- stdout: "out",
73
- stderr: "err",
74
- };
75
- const out = shapeProposalProducerOutput(failure, "normal");
76
- expect(out.ok).toBe(false);
77
- expect(out.reason).toBe("non_zero_exit");
78
- expect(out.error).toBe("exited with code 7");
79
- expect(out.ref).toBe("lesson:rg-over-grep");
80
- expect(out.exitCode).toBe(7);
81
- // stdio only at full
82
- expect(out).not.toHaveProperty("stdout");
83
- expect(out).not.toHaveProperty("stderr");
84
- });
85
- test("spawn_failed: exitCode null is preserved", () => {
86
- const failure = {
87
- schemaVersion: 1,
88
- ok: false,
89
- reason: "spawn_failed",
90
- error: "ENOENT: command not found",
91
- exitCode: null,
92
- };
93
- const out = shapeProposalProducerOutput(failure, "normal");
94
- expect(out.ok).toBe(false);
95
- expect(out.reason).toBe("spawn_failed");
96
- expect(out.exitCode).toBeNull();
97
- });
98
- test("parse_error: ref optional", () => {
99
- const failure = {
100
- schemaVersion: 1,
101
- ok: false,
102
- reason: "parse_error",
103
- error: "agent stdout was not valid JSON",
104
- exitCode: 0,
105
- };
106
- const out = shapeProposalProducerOutput(failure, "normal");
107
- expect(out.reason).toBe("parse_error");
108
- expect(out).not.toHaveProperty("ref");
109
- });
110
- test("timeout: timeout reason discriminant", () => {
111
- const failure = {
112
- schemaVersion: 1,
113
- ok: false,
114
- reason: "timeout",
115
- error: "timed out after 100ms",
116
- exitCode: 143,
117
- };
118
- const out = shapeProposalProducerOutput(failure, "full");
119
- expect(out.reason).toBe("timeout");
120
- expect(out.schemaVersion).toBe(1);
121
- });
122
- test("propose-specific failure: type+name appear when set on the result", () => {
123
- // propose surfaces `type` and `name` in failure envelopes (the input args),
124
- // separate from the agent-side `ref`. shapeProposalProducerOutput threads
125
- // both fields through unconditionally when present.
126
- const failure = {
127
- schemaVersion: 1,
128
- ok: false,
129
- reason: "non_zero_exit",
130
- error: "agent failed",
131
- type: "skill",
132
- name: "hello",
133
- exitCode: 3,
134
- };
135
- const out = shapeProposalProducerOutput(failure, "normal");
136
- expect(out.type).toBe("skill");
137
- expect(out.name).toBe("hello");
138
- });
139
- });
@@ -1,46 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- const repoRoot = path.resolve(import.meta.dir, "..", "..");
4
- export const SPEC_PATH = path.join(repoRoot, "docs", "technical", "v1-architecture-spec.md");
5
- export const CLI_DOC_PATH = path.join(repoRoot, "docs", "cli.md");
6
- export const CONFIG_DOC_PATH = path.join(repoRoot, "docs", "configuration.md");
7
- export const MIGRATION_PATH = path.join(repoRoot, "docs", "migration", "v1.md");
8
- export function readDoc(p) {
9
- return fs.readFileSync(p, "utf8");
10
- }
11
- /**
12
- * Extract a section by its heading line (e.g. "## 9. Locked contracts for v1").
13
- * Returns an empty string if the heading is not present.
14
- *
15
- * Used by contract tests to scope their assertions to a single spec
16
- * section so unrelated edits elsewhere in the doc don't cause false
17
- * positives.
18
- */
19
- export function extractSection(doc, heading) {
20
- const start = doc.indexOf(heading);
21
- if (start < 0)
22
- return "";
23
- const depthMatch = heading.match(/^#+/);
24
- const depth = depthMatch ? depthMatch[0].length : 2;
25
- // Stop only on a heading at the SAME depth or shallower, OUTSIDE any
26
- // fenced code block. Markdown headings inside ```...``` blocks are not
27
- // real headings and must not terminate a section. We stream the doc line
28
- // by line tracking fence state.
29
- const lines = doc.slice(start + heading.length).split("\n");
30
- const stopRe = new RegExp(`^#{1,${depth}}\\s`);
31
- let inFence = false;
32
- let consumed = 0;
33
- // Skip the rest of the heading line itself.
34
- consumed += (lines.shift() ?? "").length + 1;
35
- for (const line of lines) {
36
- const fenceMatch = /^(```+|~~~+)/.test(line.trimStart());
37
- if (fenceMatch) {
38
- inFence = !inFence;
39
- }
40
- else if (!inFence && stopRe.test(line)) {
41
- return doc.slice(start, start + heading.length + consumed);
42
- }
43
- consumed += line.length + 1;
44
- }
45
- return doc.slice(start);
46
- }
@@ -1,228 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2
- import fs from "node:fs";
3
- import os from "node:os";
4
- import path from "node:path";
5
- import { akmDistill } from "../../src/commands/distill";
6
- import { akmPropose } from "../../src/commands/propose";
7
- import { akmReflect } from "../../src/commands/reflect";
8
- import { readEvents } from "../../src/core/events";
9
- import { extractSection, readDoc, SPEC_PATH } from "./spec-helpers";
10
- // Pins v1 spec §11 — Proposal queue (Planned for v1).
11
- const REQUIRED_PROPOSAL_FIELDS = ["id", "ref", "status", "source", "sourceRun", "createdAt", "updatedAt"];
12
- const REQUIRED_PROPOSAL_COMMANDS = ["list", "show", "diff", "accept", "reject"];
13
- const REQUIRED_EVENTS = ["propose_invoked", "reflect_invoked", "distill_invoked", "promoted", "rejected"];
14
- describe("v1 spec §11 — proposal queue", () => {
15
- const spec = readDoc(SPEC_PATH);
16
- const section = extractSection(spec, "## 11. Proposal queue");
17
- test("§11 exists and is marked Planned for v1", () => {
18
- expect(section).not.toBe("");
19
- expect(section).toContain("Planned for v1");
20
- });
21
- test("§11.1 names the per-id proposal directory layout as the durable store", () => {
22
- // Storage is one directory per proposal under <stashRoot>/.akm/proposals/<id>/
23
- // containing a single proposal.json (queue state, not asset state).
24
- expect(section).toContain(".akm/proposals/<id>/");
25
- expect(section).toContain("proposal.json");
26
- });
27
- test("§11.1 declares each required proposal field", () => {
28
- for (const field of REQUIRED_PROPOSAL_FIELDS) {
29
- expect(section).toContain(`\`${field}\``);
30
- }
31
- });
32
- test("§11.1 declares pending/accepted/rejected statuses + archive-by-move", () => {
33
- expect(section).toContain("`pending`");
34
- expect(section).toContain("`accepted`");
35
- expect(section).toContain("`rejected`");
36
- // Archival is a directory move, not a separate status (see §11.1 prose).
37
- expect(section).toMatch(/archive\/<id>\/|archive-by-move|moved to.*archive/i);
38
- });
39
- test("§11.2 lists every proposal subcommand", () => {
40
- for (const cmd of REQUIRED_PROPOSAL_COMMANDS) {
41
- expect(section).toContain(`akm proposal ${cmd}`);
42
- }
43
- });
44
- test("§11.2 says `accept` validates BEFORE promoting", () => {
45
- const flat = section.replace(/\s+/g, " ");
46
- expect(flat).toMatch(/validation .*\*\*before\*\* promoting/i);
47
- });
48
- test("§11.2 says `accept` promotes via writeAssetToSource()", () => {
49
- // The locked rule is "all asset writes funnel through writeAssetToSource".
50
- // The proposal queue is the only legal path that bypasses it for queue
51
- // state — promotion must hand back to the single dispatch point.
52
- expect(section).toContain("writeAssetToSource()");
53
- });
54
- test("§11.1 says multiple proposals per `ref` coexist", () => {
55
- // The id is per-proposal; the ref isn't unique. The queue must hold N
56
- // proposals for the same target ref without filesystem collisions.
57
- // Directory-per-id is the mechanism the spec calls out for this.
58
- expect(section).toMatch(/multiple proposals.*for the same `ref`|coexist for the same `ref`/i);
59
- });
60
- test("§11.2 names a `--reason` flag on `reject`", () => {
61
- expect(section).toMatch(/akm proposal reject.*--reason/);
62
- });
63
- test("§11.3 declares every locked event name", () => {
64
- for (const event of REQUIRED_EVENTS) {
65
- expect(section).toContain(`\`${event}\``);
66
- }
67
- });
68
- test("§11.3 says other plugins cannot reuse these event names", () => {
69
- expect(section).toMatch(/cannot reuse these names/i);
70
- });
71
- test("§11 stops before §12 (helper boundary check)", () => {
72
- // Defensive: extractSection() returns to EOF if no sibling stop
73
- // heading exists. Pin the section terminus so a missing §12 heading
74
- // (or a renamed one) trips this test instead of silently spilling
75
- // §12+§13+§14 content into the §11 assertions above.
76
- expect(section).not.toContain("## 12.");
77
- expect(section).not.toContain("## 13.");
78
- expect(section).not.toContain("## 14.");
79
- });
80
- });
81
- // ── #284 GAP-MED 4: event metadata shape ─────────────────────────────────────
82
- //
83
- // Locks the metadata payload of the producer events so observers (audit,
84
- // dashboards) can rely on consistent keys.
85
- const tempDirs = [];
86
- const savedEnv = {
87
- AKM_STASH_DIR: process.env.AKM_STASH_DIR,
88
- XDG_CACHE_HOME: process.env.XDG_CACHE_HOME,
89
- XDG_CONFIG_HOME: process.env.XDG_CONFIG_HOME,
90
- };
91
- function makeTempDir(prefix) {
92
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
93
- tempDirs.push(dir);
94
- return dir;
95
- }
96
- function makeStashDir() {
97
- const stash = makeTempDir("akm-events-meta-stash-");
98
- for (const sub of ["lessons", "skills", "memories"]) {
99
- fs.mkdirSync(path.join(stash, sub), { recursive: true });
100
- }
101
- return stash;
102
- }
103
- function makeProfile() {
104
- return {
105
- name: "fake-agent",
106
- bin: "fake-agent",
107
- args: [],
108
- stdio: "captured",
109
- envPassthrough: ["PATH"],
110
- parseOutput: "text",
111
- };
112
- }
113
- function asReadableStream(text) {
114
- const bytes = new TextEncoder().encode(text);
115
- return new ReadableStream({
116
- start(controller) {
117
- controller.enqueue(bytes);
118
- controller.close();
119
- },
120
- });
121
- }
122
- function fakeSpawn(stdout, exitCode) {
123
- return () => {
124
- const proc = {
125
- exitCode,
126
- exited: Promise.resolve(exitCode),
127
- stdout: asReadableStream(stdout),
128
- stderr: asReadableStream(""),
129
- stdin: null,
130
- kill: () => undefined,
131
- };
132
- return proc;
133
- };
134
- }
135
- const VALID_LESSON_PAYLOAD = JSON.stringify({
136
- ref: "lesson:rg",
137
- content: "---\ndescription: Use rg\nwhen_to_use: large repos\n---\n\nUse rg.\n",
138
- });
139
- const VALID_SKILL_PAYLOAD = JSON.stringify({
140
- ref: "skill:hello",
141
- content: "---\ndescription: hi\nwhen_to_use: greeting\n---\n\nHi.\n",
142
- });
143
- beforeEach(() => {
144
- process.env.XDG_CACHE_HOME = makeTempDir("akm-events-meta-cache-");
145
- process.env.XDG_CONFIG_HOME = makeTempDir("akm-events-meta-config-");
146
- });
147
- afterEach(() => {
148
- if (savedEnv.AKM_STASH_DIR === undefined)
149
- delete process.env.AKM_STASH_DIR;
150
- else
151
- process.env.AKM_STASH_DIR = savedEnv.AKM_STASH_DIR;
152
- if (savedEnv.XDG_CACHE_HOME === undefined)
153
- delete process.env.XDG_CACHE_HOME;
154
- else
155
- process.env.XDG_CACHE_HOME = savedEnv.XDG_CACHE_HOME;
156
- if (savedEnv.XDG_CONFIG_HOME === undefined)
157
- delete process.env.XDG_CONFIG_HOME;
158
- else
159
- process.env.XDG_CONFIG_HOME = savedEnv.XDG_CONFIG_HOME;
160
- for (const dir of tempDirs.splice(0)) {
161
- fs.rmSync(dir, { recursive: true, force: true });
162
- }
163
- });
164
- describe("§11 event metadata shape (runtime)", () => {
165
- test("reflect_invoked carries `task` + optional `profile` in metadata", async () => {
166
- const stash = makeStashDir();
167
- await akmReflect({
168
- ref: "lesson:rg",
169
- task: "focus on perf",
170
- profile: "claude",
171
- stashDir: stash,
172
- agentProfile: makeProfile(),
173
- runAgentOptions: { spawn: fakeSpawn(VALID_LESSON_PAYLOAD, 0) },
174
- });
175
- const { events } = readEvents({ type: "reflect_invoked" });
176
- expect(events.length).toBe(1);
177
- const md = (events[0].metadata ?? {});
178
- expect(md.task).toBe("focus on perf");
179
- expect(md.profile).toBe("claude");
180
- expect(events[0].ref).toBe("lesson:rg");
181
- });
182
- test("propose_invoked carries `type`+`name`+`task` in metadata", async () => {
183
- const stash = makeStashDir();
184
- await akmPropose({
185
- type: "skill",
186
- name: "hello",
187
- task: "say hi",
188
- stashDir: stash,
189
- agentProfile: makeProfile(),
190
- runAgentOptions: { spawn: fakeSpawn(VALID_SKILL_PAYLOAD, 0) },
191
- });
192
- const { events } = readEvents({ type: "propose_invoked" });
193
- expect(events.length).toBe(1);
194
- const md = (events[0].metadata ?? {});
195
- expect(md.type).toBe("skill");
196
- expect(md.name).toBe("hello");
197
- expect(md.task).toBe("say hi");
198
- expect(events[0].ref).toBe("skill:hello");
199
- });
200
- test("distill_invoked metadata includes `outcome` (queued|skipped|validation_failed)", async () => {
201
- const stash = makeStashDir();
202
- const config = {
203
- stashDir: stash,
204
- sources: [{ type: "filesystem", name: "stash", path: stash, writable: true }],
205
- defaultWriteTarget: "stash",
206
- llm: {
207
- endpoint: "http://localhost:11434/v1/chat/completions",
208
- model: "test-model",
209
- features: { feedback_distillation: true },
210
- },
211
- };
212
- await akmDistill({
213
- ref: "skill:deploy",
214
- config,
215
- stashDir: stash,
216
- chat: async () => "---\ndescription: x\nwhen_to_use: y\n---\n\nbody.\n",
217
- lookupFn: async () => null,
218
- readEventsFn: (() => ({ events: [], nextOffset: 0 })),
219
- });
220
- const { events } = readEvents({ type: "distill_invoked" });
221
- expect(events.length).toBe(1);
222
- const md = (events[0].metadata ?? {});
223
- expect(["queued", "skipped", "validation_failed"]).toContain(md.outcome);
224
- // `proposalId` only stamped on the queued path
225
- if (md.outcome === "queued")
226
- expect(typeof md.proposalId).toBe("string");
227
- });
228
- });
@@ -1,56 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { CONFIG_DOC_PATH, extractSection, readDoc, SPEC_PATH } from "./spec-helpers";
3
- // Pins v1 spec §12 — Agent CLI integration (Planned for v1).
4
- const BUILT_IN_PROFILES = ["opencode", "claude", "codex", "gemini", "aider"];
5
- const SPAWN_FAILURE_REASONS = ["timeout", "spawn_failed", "non_zero_exit", "parse_error"];
6
- describe("v1 spec §12 — agent CLI integration", () => {
7
- const spec = readDoc(SPEC_PATH);
8
- const section = extractSection(spec, "## 12. Agent CLI integration");
9
- test("§12 exists and is marked Planned for v1", () => {
10
- expect(section).not.toBe("");
11
- expect(section).toContain("Planned for v1");
12
- });
13
- test("§12.1 lists every built-in profile", () => {
14
- for (const p of BUILT_IN_PROFILES) {
15
- expect(section).toContain(`\`${p}\``);
16
- }
17
- });
18
- test("§12.1 declares the AgentProfile shape", () => {
19
- expect(section).toMatch(/interface AgentProfile/);
20
- expect(section).toMatch(/readonly bin: string/);
21
- expect(section).toMatch(/readonly args: readonly string\[\]/);
22
- expect(section).toMatch(/captured.*interactive/s);
23
- });
24
- test("§12.2 names every spawn-wrapper failure reason", () => {
25
- for (const r of SPAWN_FAILURE_REASONS) {
26
- expect(section).toContain(`"${r}"`);
27
- }
28
- });
29
- test("§12.4 declares reflect/propose write only to the proposal queue", () => {
30
- expect(section).toMatch(/write\s*\*\*only\*\*\s*to the proposal queue/i);
31
- });
32
- test("§12 stops before §13 (helper boundary check)", () => {
33
- // Defensive: extractSection() returns to EOF if no sibling stop
34
- // heading exists. Pin the section terminus so a missing §13 heading
35
- // (or a renamed one) trips this test instead of silently spilling
36
- // §13+§14 content into the §12 assertions above.
37
- expect(section).not.toContain("## 13.");
38
- expect(section).not.toContain("## 14.");
39
- });
40
- });
41
- describe("v1 spec §12 — configuration.md mirrors the agent block", () => {
42
- const config = readDoc(CONFIG_DOC_PATH);
43
- const block = extractSection(config, "## `agent.*` block");
44
- test("configuration.md has the agent block section", () => {
45
- expect(block).not.toBe("");
46
- });
47
- test("configuration.md declares the three top-level agent keys", () => {
48
- expect(block).toContain("`agent.default`");
49
- expect(block).toContain("`agent.timeoutMs`");
50
- expect(block).toContain("`agent.profiles[<name>]`");
51
- });
52
- test("configuration.md says missing `agent` block raises ConfigError with hint", () => {
53
- expect(block).toMatch(/ConfigError/);
54
- expect(block).toMatch(/hint/i);
55
- });
56
- });
@@ -1,34 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { ASSET_SPECS, TYPE_DIRS } from "../../src/core/asset-spec";
3
- import { extractSection, readDoc, SPEC_PATH } from "./spec-helpers";
4
- // Pins v1 spec §13 — Lesson asset type (Planned for v1).
5
- describe("v1 spec §13 — lesson asset type", () => {
6
- const spec = readDoc(SPEC_PATH);
7
- const section = extractSection(spec, "## 13. Lesson asset type");
8
- test("§13 exists and is marked Planned for v1", () => {
9
- expect(section).not.toBe("");
10
- expect(section).toContain("Planned for v1");
11
- });
12
- test("§13.1 declares `description` and `when_to_use` are required", () => {
13
- expect(section).toMatch(/description:\s*required/);
14
- expect(section).toMatch(/when_to_use:\s*required/);
15
- });
16
- test("§13.2 stores lessons under `lessons/`", () => {
17
- expect(section).toContain("`lessons/<name>.md`");
18
- });
19
- test("§13.3 routes distill output through the proposal queue", () => {
20
- expect(section).toMatch(/akm distill/);
21
- expect(section).toMatch(/akm proposal accept/);
22
- });
23
- test("`lesson` is registered as a well-known asset type at runtime", () => {
24
- expect(ASSET_SPECS.lesson).toBeDefined();
25
- expect(TYPE_DIRS.lesson).toBe("lessons");
26
- });
27
- test("§13 stops before §14 (helper boundary check)", () => {
28
- // Defensive: extractSection() returns to EOF if no sibling stop
29
- // heading exists. Pin the section terminus so a missing §14 heading
30
- // (or a renamed one) trips this test instead of silently spilling
31
- // §14 content into the §13 assertions above.
32
- expect(section).not.toContain("## 14.");
33
- });
34
- });
@@ -1,94 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { isLlmFeatureEnabled, tryLlmFeature } from "../../src/llm/feature-gate";
3
- import { CONFIG_DOC_PATH, extractSection, readDoc, SPEC_PATH } from "./spec-helpers";
4
- // Pins v1 spec §14 — `llm.features.*` (Planned for v1).
5
- //
6
- // The locked feature keys cannot be renamed after v1.0. New keys may be
7
- // added; these must not move. Spec §14 retains the historical phantom keys
8
- // (`tag_dedup`, `memory_consolidation`, `embedding_fallback_score`) so the
9
- // spec text continues to compile, but they are not in the runtime schema or
10
- // in user-facing configuration.md (issue #284 phantom-flag cleanup).
11
- const LOCKED_FEATURE_KEYS = ["curate_rerank", "feedback_distillation", "memory_inference", "graph_extraction"];
12
- describe("v1 spec §14 — llm.features.*", () => {
13
- const spec = readDoc(SPEC_PATH);
14
- const section = extractSection(spec, "## 14. `llm.features.*`");
15
- test("§14 exists and is marked Planned for v1", () => {
16
- expect(section).not.toBe("");
17
- expect(section).toContain("Planned for v1");
18
- });
19
- test("§14.1 declares every locked feature key", () => {
20
- for (const k of LOCKED_FEATURE_KEYS) {
21
- expect(section).toContain(`\`${k}\``);
22
- }
23
- });
24
- test("§14.1 declares all defaults are false", () => {
25
- expect(section).toMatch(/defaults are\s*`false`|all defaults are\s*`false`|defaults\s*`false`/i);
26
- });
27
- test("§14.2 defines mandatory failure-mode rules", () => {
28
- expect(section).toMatch(/check the feature flag before/i);
29
- expect(section).toMatch(/hard timeout/i);
30
- expect(section).toMatch(/never\s*\*\*\s*mutate state on failure/i);
31
- });
32
- test("§14.4 codifies the statelessness invariant", () => {
33
- expect(section).toMatch(/holds no state across calls/i);
34
- expect(section).toMatch(/no streaming sessions/i);
35
- });
36
- test("§14.5 routes distill output through the proposal queue", () => {
37
- const flat = section.replace(/\s+/g, " ");
38
- expect(flat).toMatch(/`lesson` \*\*proposal\*\*/i);
39
- expect(section).toContain("distill_invoked");
40
- });
41
- test("§14 documents orthogonality between llm.features.* and index.<pass>.llm", () => {
42
- expect(section).toMatch(/orthogonal/i);
43
- expect(section).toMatch(/llm\.features\.<key>/);
44
- expect(section).toMatch(/index\.<pass>\.llm/);
45
- });
46
- test("§14 stops before §15 (helper boundary check)", () => {
47
- // Defensive: extractSection() returns to EOF if no sibling stop
48
- // heading exists. Pin the section terminus so a missing §15 heading
49
- // (or a renamed one) trips this test instead of silently spilling
50
- // §15+ content into the §14 assertions above.
51
- expect(section).not.toContain("## 15.");
52
- expect(section).not.toContain("## Appendix");
53
- });
54
- });
55
- describe("v1 spec §14 — configuration.md mirrors the feature gates", () => {
56
- const config = readDoc(CONFIG_DOC_PATH);
57
- const block = extractSection(config, "## `llm.features.*` map");
58
- test("configuration.md has the llm.features section", () => {
59
- expect(block).not.toBe("");
60
- });
61
- test("configuration.md lists every locked feature key", () => {
62
- for (const k of LOCKED_FEATURE_KEYS) {
63
- expect(block).toContain(k);
64
- }
65
- });
66
- test("configuration.md says unknown llm.features keys are warn-and-ignore", () => {
67
- expect(block).toMatch(/Unknown keys.*warn-and-ignore/i);
68
- });
69
- });
70
- describe("v1 spec §14 — runtime gate seam", () => {
71
- // The graceful-fallback contract says: disabled gate returns the fallback
72
- // without ever calling fn; throws are swallowed and return fallback. We
73
- // pin the seam shape here so renames trigger the contract test.
74
- test("isLlmFeatureEnabled is exported and pure", () => {
75
- expect(typeof isLlmFeatureEnabled).toBe("function");
76
- expect(isLlmFeatureEnabled(undefined, "curate_rerank")).toBe(false);
77
- });
78
- test("tryLlmFeature returns fallback when the gate is disabled (no fn call)", async () => {
79
- let called = false;
80
- const result = await tryLlmFeature("curate_rerank", undefined, () => {
81
- called = true;
82
- return "ran";
83
- }, "fallback");
84
- expect(result).toBe("fallback");
85
- expect(called).toBe(false);
86
- });
87
- test("tryLlmFeature swallows throws and returns fallback when enabled", async () => {
88
- const config = { llm: { features: { curate_rerank: true } } };
89
- const result = await tryLlmFeature("curate_rerank", config, () => {
90
- throw new Error("boom");
91
- }, "fallback");
92
- expect(result).toBe("fallback");
93
- });
94
- });
@@ -1,39 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { ASSET_SPECS } from "../../src/core/asset-spec";
3
- import { isAssetType } from "../../src/core/common";
4
- import { extractSection, readDoc, SPEC_PATH } from "./spec-helpers";
5
- // Pins v1 spec §4.1 — Asset type rules (open set).
6
- //
7
- // These tests are intentionally about the *rule*, not the specific list of
8
- // well-known types. The closed-set list can grow without breaking the
9
- // contract; what cannot change is that types are an open string set and
10
- // that the renderer registry is the authority.
11
- describe("v1 spec §4.1 — asset type rules (open set)", () => {
12
- const spec = readDoc(SPEC_PATH);
13
- const section = extractSection(spec, "### 4.1 Asset type rules (open set)");
14
- test("§4.1 declares the open set rule in the spec", () => {
15
- expect(section).not.toBe("");
16
- expect(section).toContain("open string");
17
- // Renderer registry is named as the authority for well-known types.
18
- expect(section).toMatch(/renderer/i);
19
- });
20
- test("§4.1 names every well-known type that has a renderer today", () => {
21
- // Every type that ships with an ASSET_SPECS entry today must be named in
22
- // the well-known list. Adding a new type is fine; silently dropping one
23
- // is not.
24
- for (const type of Object.keys(ASSET_SPECS)) {
25
- expect(section).toContain(`\`${type}\``);
26
- }
27
- });
28
- test("§4.1 names `lesson` as a planned-for-v1 well-known type", () => {
29
- expect(section).toContain("`lesson`");
30
- });
31
- test("isAssetType() accepts arbitrary strings — open set in code", () => {
32
- // The spec says the type is an open string. The runtime validator must
33
- // not reject unknown types as part of ref parsing. We only assert the
34
- // function returns the expected boolean shape; specific well-known
35
- // values are allowed but not required to be the only true cases.
36
- expect(typeof isAssetType("skill")).toBe("boolean");
37
- expect(typeof isAssetType("definitely-not-a-real-type")).toBe("boolean");
38
- });
39
- });