akm-cli 0.9.17-alpha.2 → 0.9.17-alpha.4

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 (343) hide show
  1. package/CHANGELOG.md +756 -0
  2. package/dist/akm +94 -196
  3. package/dist/cli/shared.js +6 -2
  4. package/dist/cli.js +22 -9
  5. package/dist/commands/agent/agent-dispatch.js +1 -1
  6. package/dist/commands/command/command-execution.js +24 -62
  7. package/dist/commands/feedback-cli.js +0 -1
  8. package/dist/commands/health/accept-rate.js +2 -2
  9. package/dist/commands/health/checks.js +30 -75
  10. package/dist/commands/health/config-skew.js +38 -0
  11. package/dist/commands/health/egress.js +54 -0
  12. package/dist/commands/health/html-report.js +0 -38
  13. package/dist/commands/health/improve-metrics.js +123 -562
  14. package/dist/commands/health/plugin-staleness.js +53 -3
  15. package/dist/commands/health/renderers.js +12 -4
  16. package/dist/commands/health/report-view-model.js +11 -106
  17. package/dist/commands/health/types-improve.js +4 -19
  18. package/dist/commands/health/windows.js +64 -73
  19. package/dist/commands/health.js +122 -143
  20. package/dist/commands/improve/consolidate/chunking.js +25 -100
  21. package/dist/commands/improve/consolidate/sanitize.js +54 -149
  22. package/dist/commands/improve/consolidate.js +538 -1075
  23. package/dist/commands/improve/content-hash.js +16 -24
  24. package/dist/commands/improve/distill/content-repair.js +18 -100
  25. package/dist/commands/improve/distill-guards.js +20 -81
  26. package/dist/commands/improve/distill-promotion-policy.js +23 -243
  27. package/dist/commands/improve/distill.js +608 -1075
  28. package/dist/commands/improve/eligibility.js +126 -400
  29. package/dist/commands/improve/execution.js +3 -5
  30. package/dist/commands/improve/extract.js +487 -1046
  31. package/dist/commands/improve/feedback-valence.js +0 -25
  32. package/dist/commands/improve/improve-cli.js +29 -166
  33. package/dist/commands/improve/improve-result-file.js +10 -66
  34. package/dist/commands/improve/improve-strategies.js +12 -7
  35. package/dist/commands/improve/improve-usage-report.js +18 -64
  36. package/dist/commands/improve/improve.js +443 -1063
  37. package/dist/commands/improve/ledger.js +114 -0
  38. package/dist/commands/improve/locks.js +2 -8
  39. package/dist/commands/improve/loop-stages.js +459 -1172
  40. package/dist/commands/improve/memory/derived-ref.js +12 -77
  41. package/dist/commands/improve/memory/memory-belief.js +14 -118
  42. package/dist/commands/improve/memory/memory-improve.js +4 -3
  43. package/dist/commands/improve/outcome-loop.js +28 -156
  44. package/dist/commands/improve/planner.js +5 -10
  45. package/dist/commands/improve/preparation.js +851 -2339
  46. package/dist/commands/improve/proactive-maintenance.js +34 -101
  47. package/dist/commands/improve/reflect-noise.js +104 -280
  48. package/dist/commands/improve/reflect.js +621 -1367
  49. package/dist/commands/improve/salience.js +46 -232
  50. package/dist/commands/improve/session-asset.js +19 -100
  51. package/dist/commands/improve/stage.js +323 -0
  52. package/dist/commands/proposal/drain.js +251 -644
  53. package/dist/commands/proposal/proposal-cli.js +3 -18
  54. package/dist/commands/proposal/proposal-types.js +20 -41
  55. package/dist/commands/proposal/proposal.js +1 -2
  56. package/dist/commands/proposal/propose.js +134 -160
  57. package/dist/commands/proposal/repository.js +502 -1487
  58. package/dist/commands/proposal/validators/proposal-quality-validators.js +71 -174
  59. package/dist/commands/proposal/validators/proposal-validators.js +1 -1
  60. package/dist/commands/proposal/validators/proposals.js +13 -89
  61. package/dist/commands/read/curate.js +63 -413
  62. package/dist/commands/read/search-cli.js +16 -33
  63. package/dist/commands/read/search.js +17 -23
  64. package/dist/commands/read/show.js +2 -13
  65. package/dist/commands/sources/bundle-cli.js +25 -2
  66. package/dist/commands/sources/bundle-config-ops.js +7 -0
  67. package/dist/commands/sources/dangerous-env-audit.js +1 -2
  68. package/dist/commands/sources/info.js +2 -11
  69. package/dist/commands/sources/installed-stashes.js +197 -746
  70. package/dist/commands/sources/schema-repair.js +98 -129
  71. package/dist/commands/sources/source-add.js +62 -12
  72. package/dist/commands/sources/stash-cli.js +1 -1
  73. package/dist/commands/tasks/explain.js +10 -13
  74. package/dist/commands/tasks/tasks-cli.js +9 -8
  75. package/dist/commands/tasks/tasks.js +326 -930
  76. package/dist/commands/tasks/validate.js +42 -21
  77. package/dist/commands/workflow/plan.js +22 -29
  78. package/dist/commands/workflow-cli.js +4 -4
  79. package/dist/core/adapter/adapters/akm-adapter.js +0 -1
  80. package/dist/core/adapter/adapters/akm-lint.js +2 -3
  81. package/dist/core/adapter/adapters/akm-metadata.js +11 -12
  82. package/dist/core/adapter/adapters/akm-workflow-adapter.js +1 -1
  83. package/dist/core/adapter/execution-source.js +17 -29
  84. package/dist/core/asset/resolve-ref.js +1 -1
  85. package/dist/core/bundle-id.js +42 -5
  86. package/dist/core/bundle-rename.js +291 -0
  87. package/dist/core/config/config-io.js +1 -2
  88. package/dist/core/config/config-schema.js +1 -33
  89. package/dist/core/config/config-walker.js +1 -1
  90. package/dist/core/config/config.js +163 -68
  91. package/dist/core/config/legacy-source-shape-shim.js +38 -9
  92. package/dist/core/config/schema/embedding.js +20 -5
  93. package/dist/core/config/schema/engines.js +5 -0
  94. package/dist/core/config/schema/execution.js +1 -1
  95. package/dist/core/config/schema/experimental.js +1 -1
  96. package/dist/core/config/schema/improve-processes.js +21 -95
  97. package/dist/core/config/schema/improve.js +4 -42
  98. package/dist/core/config/schema/scheduler.js +12 -12
  99. package/dist/core/config/schema/search.js +6 -22
  100. package/dist/core/env-secret-ref.js +0 -1
  101. package/dist/core/errors.js +8 -9
  102. package/dist/core/file-lock.js +76 -173
  103. package/dist/core/logs-db.js +2 -2
  104. package/dist/core/paths.js +0 -27
  105. package/dist/core/redaction.js +109 -2
  106. package/dist/core/run-lock.js +2 -5
  107. package/dist/core/spawn-env.js +1 -1
  108. package/dist/core/state/migrations.js +108 -61
  109. package/dist/core/state-db-scope.js +2 -4
  110. package/dist/core/state-db.js +126 -692
  111. package/dist/core/type-presentation.js +1 -9
  112. package/dist/core/write-source.js +293 -1012
  113. package/dist/execution/input-contract.js +1 -1
  114. package/dist/execution/resolved-request.js +135 -689
  115. package/dist/execution/source.js +63 -257
  116. package/dist/execution/target-ref.js +1 -1
  117. package/dist/indexer/bundle-identity-guard.js +2 -2
  118. package/dist/indexer/db/graph-db.js +106 -46
  119. package/dist/indexer/ensure-index.js +44 -85
  120. package/dist/indexer/graph/graph-extraction.js +340 -562
  121. package/dist/indexer/graph/graph-related.js +130 -0
  122. package/dist/indexer/index-rebuild-lock.js +3 -11
  123. package/dist/indexer/index-writer-lock.js +8 -17
  124. package/dist/indexer/index-written-assets.js +139 -151
  125. package/dist/indexer/indexer.js +524 -846
  126. package/dist/indexer/materialize-embeddings.js +60 -397
  127. package/dist/indexer/passes/memory-inference.js +81 -90
  128. package/dist/indexer/passes/metadata.js +132 -200
  129. package/dist/indexer/read-preflight.js +0 -7
  130. package/dist/indexer/scan/doc-to-entry.js +1 -3
  131. package/dist/indexer/scan/drain-dir.js +1 -1
  132. package/dist/indexer/search/db-search.js +181 -590
  133. package/dist/indexer/search/fts-query.js +30 -41
  134. package/dist/indexer/search/ranking.js +28 -154
  135. package/dist/indexer/search/search-attribution.js +12 -32
  136. package/dist/indexer/search/search-fields.js +11 -15
  137. package/dist/indexer/search/search-hit-enrichers.js +54 -85
  138. package/dist/indexer/search/search-source.js +1 -4
  139. package/dist/indexer/usage/usage-events.js +2 -7
  140. package/dist/integrations/agent/engine-fallback.js +23 -40
  141. package/dist/integrations/agent/engine-resolution.js +93 -183
  142. package/dist/integrations/agent/execution.js +507 -0
  143. package/dist/integrations/agent/model-map.js +28 -156
  144. package/dist/integrations/agent/request-lowering.js +66 -141
  145. package/dist/integrations/agent/runner-dispatch.js +143 -321
  146. package/dist/integrations/agent/runner.js +54 -14
  147. package/dist/integrations/lockfile.js +53 -101
  148. package/dist/llm/embedders/deterministic.js +2 -3
  149. package/dist/llm/embedders/profile.js +71 -0
  150. package/dist/llm/embedders/remote.js +10 -15
  151. package/dist/llm/graph-extract.js +3 -12
  152. package/dist/llm/index-passes.js +3 -5
  153. package/dist/llm/memory-infer.js +1 -2
  154. package/dist/llm/metadata-enhance.js +1 -2
  155. package/dist/llm/structured-call.js +5 -24
  156. package/dist/output/generic-render.js +23 -11
  157. package/dist/output/html-render.js +13 -10
  158. package/dist/output/render-registry.js +3 -32
  159. package/dist/output/shapes/helpers.js +2 -34
  160. package/dist/output/shapes/passthrough.js +1 -9
  161. package/dist/{indexer/search/ranking-types.js → output/text/bundle-rename.js} +4 -1
  162. package/dist/output/text/command-format.js +60 -23
  163. package/dist/output/text/helpers.js +1 -1
  164. package/dist/output/text/migrate.js +5 -14
  165. package/dist/output/text/proposal-format.js +1 -2
  166. package/dist/output/text/workflow-format.js +0 -32
  167. package/dist/output/text.js +2 -0
  168. package/dist/registry/factory.js +4 -19
  169. package/dist/registry/network.js +66 -220
  170. package/dist/registry/providers/index.js +0 -2
  171. package/dist/registry/providers/skills-sh.js +3 -14
  172. package/dist/registry/providers/static-index.js +24 -26
  173. package/dist/registry/resolve.js +55 -131
  174. package/dist/scripts/akm-migrate-node.js +43937 -93313
  175. package/dist/scripts/akm-migrate.js +43697 -93071
  176. package/dist/setup/registry-stash-loader.js +4 -13
  177. package/dist/setup/semantic-assets.js +3 -44
  178. package/dist/setup/setup.js +1 -1
  179. package/dist/setup/steps/tasks.js +25 -15
  180. package/dist/sources/provider-factory.js +17 -18
  181. package/dist/sources/providers/filesystem.js +2 -3
  182. package/dist/sources/providers/git-install.js +7 -1
  183. package/dist/sources/providers/git-provider.js +0 -3
  184. package/dist/sources/providers/git-stash.js +0 -17
  185. package/dist/sources/providers/npm.js +2 -4
  186. package/dist/sources/providers/provider-utils.js +5 -10
  187. package/dist/sources/providers/website.js +0 -2
  188. package/dist/sources/snapshot-fetchers/website-ingest.js +1 -1
  189. package/dist/sources/website-url.js +2 -2
  190. package/dist/storage/database.js +9 -35
  191. package/dist/storage/repositories/improve-ledger-repository.js +168 -0
  192. package/dist/storage/repositories/index-connection.js +34 -70
  193. package/dist/storage/repositories/index-entries-repository.js +69 -111
  194. package/dist/storage/repositories/index-entry-mapper.js +1 -2
  195. package/dist/storage/repositories/index-entry-schema.js +83 -269
  196. package/dist/storage/repositories/index-fts-repository.js +86 -256
  197. package/dist/storage/repositories/index-llm-cache-repository.js +17 -0
  198. package/dist/storage/repositories/index-meta-repository.js +6 -4
  199. package/dist/storage/repositories/index-schema.js +192 -220
  200. package/dist/storage/repositories/index-utility-repository.js +8 -29
  201. package/dist/storage/repositories/index-vec-repository.js +133 -414
  202. package/dist/storage/repositories/outcome-repository.js +2 -1
  203. package/dist/storage/repositories/proposals-repository.js +35 -0
  204. package/dist/storage/repositories/registry-index-cache-repository.js +100 -0
  205. package/dist/storage/repositories/task-history-repository.js +26 -4
  206. package/dist/storage/repositories/workflow-runs-repository.js +53 -244
  207. package/dist/storage/sqlite-migrations.js +136 -0
  208. package/dist/storage/sqlite-pragmas.js +11 -9
  209. package/dist/storage/sqlite-transaction.js +170 -0
  210. package/dist/storage/state-db-integrity.js +34 -27
  211. package/dist/tasks/activation-config.js +134 -62
  212. package/dist/tasks/backends/cron.js +129 -277
  213. package/dist/tasks/backends/exec-utils.js +2 -5
  214. package/dist/tasks/backends/launchd.js +125 -745
  215. package/dist/tasks/backends/schtasks.js +101 -620
  216. package/dist/tasks/prepare/prepare-support.js +5 -15
  217. package/dist/tasks/prepare/prepare.js +0 -2
  218. package/dist/tasks/resolve-akm-bin.js +20 -79
  219. package/dist/tasks/run/attempt-lifecycle.js +0 -1
  220. package/dist/tasks/scheduler-binding.js +18 -238
  221. package/dist/tasks/scheduler-invocation.js +52 -52
  222. package/dist/tasks/scheduler-lock.js +53 -0
  223. package/dist/tasks/scheduler-sync.js +363 -679
  224. package/dist/tasks/source/parse-task-source.js +160 -10
  225. package/dist/tasks/source/task-source-v3-frozen.js +3 -4
  226. package/dist/tasks/source/task-to-v4.js +2 -2
  227. package/dist/workflows/authoring/authoring.js +3 -12
  228. package/dist/workflows/compile.js +211 -0
  229. package/dist/workflows/concurrency-policy.js +13 -74
  230. package/dist/workflows/exec/child-invocation.js +3 -17
  231. package/dist/workflows/exec/child-workflow.js +32 -141
  232. package/dist/workflows/exec/dispatch-redaction.js +13 -53
  233. package/dist/workflows/exec/environment.js +98 -0
  234. package/dist/workflows/exec/exec-unit.js +33 -140
  235. package/dist/workflows/exec/frozen-judge.js +7 -59
  236. package/dist/workflows/exec/native-executor.js +82 -341
  237. package/dist/workflows/exec/param-secrets.js +29 -47
  238. package/dist/workflows/exec/run-workflow.js +154 -387
  239. package/dist/workflows/exec/scheduler.js +9 -36
  240. package/dist/workflows/exec/step-work.js +127 -430
  241. package/dist/workflows/exec/unit-dispatch.js +11 -63
  242. package/dist/workflows/exec/unit-writer.js +8 -52
  243. package/dist/workflows/exec/worktree.js +39 -273
  244. package/dist/workflows/freeze/child-output-references.js +4 -15
  245. package/dist/workflows/freeze/environment.js +99 -92
  246. package/dist/workflows/freeze/freeze.js +172 -0
  247. package/dist/workflows/freeze/step-values.js +19 -21
  248. package/dist/workflows/freeze/targets/child-workflow.js +23 -92
  249. package/dist/workflows/freeze/targets/command.js +10 -33
  250. package/dist/workflows/freeze/targets/script.js +5 -12
  251. package/dist/workflows/freeze/targets/shell.js +3 -6
  252. package/dist/workflows/freeze/targets/task.js +25 -80
  253. package/dist/workflows/freeze/task-bindings.js +20 -67
  254. package/dist/workflows/{source-ir/github-yaml.js → github-yaml.js} +88 -206
  255. package/dist/workflows/ir/params.js +6 -51
  256. package/dist/workflows/ir/plan-hash.js +2 -34
  257. package/dist/workflows/parser.js +140 -43
  258. package/dist/{commands/improve/consolidate/types.js → workflows/plan.js} +2 -1
  259. package/dist/workflows/renderer.js +36 -69
  260. package/dist/workflows/resource-limits.js +12 -120
  261. package/dist/workflows/runtime/agent-identity.js +8 -40
  262. package/dist/workflows/runtime/run-outputs.js +3 -6
  263. package/dist/workflows/runtime/run-plan.js +316 -0
  264. package/dist/workflows/runtime/runs.js +48 -200
  265. package/dist/workflows/runtime/workflow-asset-loader.js +24 -57
  266. package/dist/workflows/{source-ir/semantics.js → source-semantics.js} +16 -20
  267. package/dist/workflows/validate-summary.js +2 -7
  268. package/docs/integration/bundling-akm.md +49 -42
  269. package/docs/migration/README.md +1 -0
  270. package/docs/migration/release-notes/0.9.17.md +41 -0
  271. package/docs/migration/v0.9.1-to-v0.9.2.md +19 -7
  272. package/docs/reference/cli.md +182 -125
  273. package/docs/reference/configuration.md +49 -56
  274. package/docs/reference/data-and-telemetry.md +19 -20
  275. package/docs/reference/tasks.md +86 -38
  276. package/docs/reference/workflow-schema.md +14 -18
  277. package/docs/reference/workflows.md +6 -9
  278. package/package.json +1 -1
  279. package/schemas/akm-config.json +87 -406
  280. package/dist/commands/health/advisories.js +0 -150
  281. package/dist/commands/health/metrics.js +0 -329
  282. package/dist/commands/health/surfaces.js +0 -102
  283. package/dist/commands/improve/anti-collapse.js +0 -83
  284. package/dist/commands/improve/collapse-detector.js +0 -432
  285. package/dist/commands/improve/consolidate/eligibility.js +0 -48
  286. package/dist/commands/improve/consolidate/merge.js +0 -146
  287. package/dist/commands/improve/distill/promote-memory.js +0 -329
  288. package/dist/commands/improve/distill/quality-gate.js +0 -500
  289. package/dist/commands/improve/memory/memory-contradiction-detect.js +0 -291
  290. package/dist/commands/improve/proposal-envelope.js +0 -31
  291. package/dist/commands/improve/run-context.js +0 -123
  292. package/dist/commands/improve/shared.js +0 -21
  293. package/dist/commands/improve/source-identity.js +0 -28
  294. package/dist/commands/improve/triage.js +0 -96
  295. package/dist/commands/proposal/drain-policies.js +0 -151
  296. package/dist/commands/sources/update-transaction.js +0 -220
  297. package/dist/core/action-contributors.js +0 -28
  298. package/dist/core/config/config-version-shim.js +0 -101
  299. package/dist/core/config/retired-experimental-keys-shim.js +0 -62
  300. package/dist/core/fs-txn.js +0 -405
  301. package/dist/core/lexical-score.js +0 -25
  302. package/dist/core/maintenance-barrier.js +0 -167
  303. package/dist/execution/executable-identity.js +0 -105
  304. package/dist/execution/guarded-source.js +0 -427
  305. package/dist/indexer/graph/graph-boost.js +0 -427
  306. package/dist/indexer/graph/graph-dedup.js +0 -95
  307. package/dist/indexer/search/name-match.js +0 -35
  308. package/dist/indexer/search/ranking-contributors.js +0 -515
  309. package/dist/indexer/walk/project-context.js +0 -192
  310. package/dist/integrations/agent/execution-cascade.js +0 -566
  311. package/dist/integrations/agent/execution-definitions.js +0 -202
  312. package/dist/integrations/agent/execution-lowering.js +0 -841
  313. package/dist/integrations/agent/execution-preparation.js +0 -98
  314. package/dist/integrations/agent/inline-execution.js +0 -74
  315. package/dist/registry/create-provider-registry.js +0 -29
  316. package/dist/registry/pinned-request-helper.js +0 -247
  317. package/dist/registry/pinned-transport.js +0 -717
  318. package/dist/sources/providers/index.js +0 -14
  319. package/dist/storage/engines/sqlite-migrations.js +0 -271
  320. package/dist/storage/repositories/canaries-repository.js +0 -107
  321. package/dist/storage/repositories/embedding-salvage-repository.js +0 -184
  322. package/dist/storage/repositories/registry-cache.js +0 -113
  323. package/dist/tasks/scheduler-sync-preview.js +0 -52
  324. package/dist/workflows/freeze/resolve-steps.js +0 -86
  325. package/dist/workflows/freeze/source-freeze.js +0 -64
  326. package/dist/workflows/ir/compile.js +0 -321
  327. package/dist/workflows/ir/environment-v4.js +0 -330
  328. package/dist/workflows/ir/freeze-v4.js +0 -153
  329. package/dist/workflows/ir/schema-v4.js +0 -745
  330. package/dist/workflows/ir/schema.js +0 -354
  331. package/dist/workflows/program/schema.js +0 -78
  332. package/dist/workflows/runtime/checkin.js +0 -57
  333. package/dist/workflows/runtime/plan-classifier.js +0 -196
  334. package/dist/workflows/runtime/unit-checkin.js +0 -45
  335. package/dist/workflows/runtime/unit-phases.js +0 -20
  336. package/dist/workflows/schema.js +0 -4
  337. package/dist/workflows/source-ir/compile.js +0 -200
  338. package/dist/workflows/source-ir/program.js +0 -50
  339. package/dist/workflows/source-ir/result.js +0 -26
  340. package/dist/workflows/source-ir/schema.js +0 -786
  341. package/dist/workflows/source-ir/triggers.js +0 -79
  342. package/dist/workflows/source-ir/uses.js +0 -40
  343. package/dist/workflows/validator.js +0 -60
@@ -219,11 +219,11 @@ Build or refresh the search index.
219
219
 
220
220
  ```sh
221
221
  akm index # Incremental (only changed directories)
222
- akm index --full # Full rebuild (reuses unchanged embeddings — see below)
222
+ akm index --full # Re-drain every directory (keeps unchanged embeddings — see below)
223
223
  akm index --verbose # Print phase progress to stderr
224
224
  akm index --clean # Normal index + remove stale entries from the DB
225
225
  akm index --clean --dry-run # Report stale entries without deleting
226
- akm index --reembed # Force re-embedding of every entry
226
+ akm index --reembed # Discard stored vectors and re-embed every entry
227
227
  akm index --skip-if-locked # for scheduled/opportunistic runs: skip (exit 0) if a run is already in progress
228
228
  ```
229
229
 
@@ -254,25 +254,22 @@ Use `--clean` to resolve the edge case where a deleted file in an unchanged
254
254
  directory lingers in the index across incremental runs. With `--dry-run`, reports
255
255
  which entries would be removed without modifying the database.
256
256
 
257
- **`--full` no longer re-embeds unchanged content (#955):** a full rebuild
258
- (and an index-generation bump on first open under a new binary) used to
259
- delete every embedding unconditionally, forcing a full re-embed of the
260
- whole corpus even when nothing changed. Vectors about to be discarded are
261
- now salvaged (keyed by a hash of their content plus the fingerprint they
262
- were generated under) and handed straight back to unchanged entries at the
263
- start of the next embedding pass, with zero provider calls for them — a
264
- progress line reports the split (`Reused N embeddings from the previous
265
- generation; embedding M new.`). Content that changed even by one byte, or
266
- a fingerprint that no longer matches, still goes through the provider
267
- normally. `--reembed` is the way to force a full re-embed regardless.
268
-
269
- **`--reembed` flag:** Forces a full purge and re-embed of every entry,
270
- independent of the embedding-model-rename compatibility check described
271
- below. Ordinary indexing already tells a config-only rename of
272
- `embedding.model` (e.g. a gateway that changes how it names the same model)
273
- apart from a genuine model change, and keeps the stored vectors when they
274
- are still compatible; `--reembed` skips that check and forces a rebuild
275
- regardless of what it would have decided.
257
+ **`--full` does not re-embed unchanged content:** a full run re-drains and
258
+ re-persists every directory, but entry ids are kept, so a vector stays
259
+ attached to its entry and only entries whose search text changed go back to
260
+ the embedding provider. An incremental run re-persists only the files that
261
+ changed.
262
+
263
+ **Embedding model changes:** every stored vector records the embedding model
264
+ it was generated under (`embedding.model` plus dimension for a remote
265
+ endpoint, the local model name otherwise). When the configured model
266
+ changes, the next `akm index` re-embeds entry by entry, committing each
267
+ batch; nothing is purged first, an interrupted run resumes where it
268
+ stopped, and search serves only vectors from the configured model in the
269
+ meantime.
270
+
271
+ **`--reembed` flag:** Discards every stored vector and re-embeds all entries
272
+ under the configured model.
276
273
 
277
274
  **`--skip-if-locked` flag:** Every explicit `akm index` run acquires an
278
275
  opt-in, PID-liveness-only rebuild lock and releases it on exit — this is
@@ -334,11 +331,10 @@ Returns a JSON object with:
334
331
  | `semanticSearch` | Semantic search status: `mode`, `status`, and optional `reason`/`message` |
335
332
  | `registries` | Configured registries |
336
333
  | `sourceProviders` | Configured sources (filesystem, git, website, npm) |
337
- | `indexStats` | Index stats: `entryCount`, `byType` (per-asset-type breakdown), `lastBuiltAt`, `hasEmbeddings`, `vecAvailable` |
334
+ | `indexStats` | Index stats: `entryCount`, `byType` (per-asset-type breakdown), `lastBuiltAt`, `hasEmbeddings` |
338
335
 
339
336
  `semanticSearch.status` values:
340
- - `"ready-vec"` — native sqlite-vec extension active (fastest)
341
- - `"ready-js"` — pure JS fallback active (correct but slower at scale)
337
+ - `"ready-js"` — every entry has a vector; semantic search is active (the name is historical: `"ready-vec"`, the sqlite-vec variant, is gone)
342
338
  - `"pending"` — not yet initialized (run `akm index` to set up)
343
339
  - `"blocked"` — setup failed (see `reason` and `message` fields)
344
340
  - `"disabled"` — semantic search is turned off in config
@@ -379,7 +375,7 @@ default agent engine, and summarizes recent `improve_*` events. Unless
379
375
  to the `default-llm-engine` and every `configured-engines` LLM connection (and
380
376
  an SDK engine's LLM fallback), one probe per distinct endpoint, checks the
381
377
  installed akm-cli version against the latest GitHub release (`cli-version`),
382
- and runs the scheduler's recorded akm binary with `--version` to check it
378
+ runs the scheduler's recorded akm binary with `--version` to check it
383
379
  against the running CLI (`scheduler-binary`).
384
380
 
385
381
  Primary result fields:
@@ -387,9 +383,9 @@ Primary result fields:
387
383
  | Field | Description |
388
384
  | --- | --- |
389
385
  | `status` | Overall health verdict: `pass`, `warn`, or `fail` |
390
- | `hardChecks` | Deterministic checks such as `state-db-schema`, `state-db-round-trip`, `state-db-integrity`, `state-db-migrations`, `task-log-backing`, `active-runs`, `default-engine`, `model-map-files`, `default-llm-engine`, `configured-engines`, and `active-improve-strategy` |
386
+ | `hardChecks` | Deterministic checks such as `state-db-schema`, `state-db-round-trip`, `state-db-integrity`, `state-db-migrations`, `active-runs`, `default-engine`, `model-map-files`, `default-llm-engine`, `configured-engines`, and `active-improve-strategy` |
391
387
  | `advisories` | Non-fatal warnings including `semantic-search-runtime`, `session-extraction` (akmExtract pipeline health), `cli-version` (installed vs latest release), `thinking-control` (an `enableThinking: false` engine whose recorded usage still shows reasoning tokens), and `engine-last-used` (an engine bound to an enabled improve process with no recorded use in 30 days) |
392
- | `metrics` | Aggregate task/runtime metrics: `taskFailRate`, `agentFailureRate`, `stuckActiveRuns`, `logBackingRate`, `probeRoundTripMs` |
388
+ | `metrics` | Aggregate task/runtime metrics: `taskFailRate`, `agentFailureRate`, `stuckActiveRuns` |
393
389
  | `improve` | Recent improve-loop counts derived from `improve_invoked`, `improve_skipped`, and `improve_completed` events |
394
390
 
395
391
  The `improve` section includes counts for planned refs, reflect/distill actions,
@@ -397,13 +393,13 @@ memory-prune actions, memory-inference writes, graph-extraction refreshes,
397
393
  session-extraction outcomes (`sessionsScanned`, `sessionsExtracted`, `proposalsCreated`),
398
394
  dead-URL detections, and skip reasons observed in the selected time window.
399
395
 
400
- `state-db-migrations` reports whether `state.db`'s migration ledger has any
401
- pending entries (checked read-only, without applying anything). It `fail`s
402
- when migrations are pending — naming them and pointing at `akm migrate apply`
403
- — rather than the command crashing, which is what happens when `state.db`
404
- holds a pending historical-destructive migration and something other than
405
- `akm upgrade` / `akm migrate apply` opens it directly. Read this check's
406
- `status` instead of grepping akm's error text for that case.
396
+ `state-db-migrations` reports what `akm health`'s own open of `state.db`
397
+ applied. Every open applies pending migrations (copying the file to
398
+ `state.db.pre-<id>.bak` first when one drops schema), so the check passes and
399
+ names the applied IDs (`evidence.applied`) and the copy (`evidence.backupPath`).
400
+ It `fail`s only when a pending migration could not be applied — naming it and
401
+ pointing at `akm migrate apply` — rather than the command crashing. Read this
402
+ check's `status` instead of grepping akm's error text.
407
403
 
408
404
  `default-llm-engine` and `configured-engines` probe reachability (not just
409
405
  configuration) for a `kind: "llm"` engine — an unreachable endpoint is a hard
@@ -439,10 +435,8 @@ for an infrastructure reason (`llm_unavailable`, `read_failed`, `exception`,
439
435
  The indexed entity graph (entities/relations extracted from bundle assets) has
440
436
  no dedicated inspection command; its summary counts surface as an info-level
441
437
  metric in `akm health`. Graph data is automatically re-extracted on the first
442
- `akm improve` cycle after a `DB_VERSION` upgrade, and search ranking can
443
- optionally use graph-derived confidence-weighted boosts — tune
444
- `search.graphBoost.confidenceMode` and `search.graphBoost.confidenceWeight` in
445
- [`docs/reference/configuration.md#search-tuning`](configuration.md#search-tuning).
438
+ `akm improve` cycle after a `DB_VERSION` upgrade. The graph backs `akm show`'s
439
+ `related` list and curate's support refs; it does not affect search ranking.
446
440
 
447
441
  ### search
448
442
 
@@ -499,6 +493,18 @@ query. The last case also adds one sanitized, endpoint-naming entry to
499
493
  preserved by `--shape agent` so machine consumers can lower their confidence
500
494
  instead of treating keyword fallback as healthy semantic ranking.
501
495
 
496
+ Ranking fuses two candidate lists by reciprocal rank (k = 60, equal weights):
497
+ BM25 over whole documents matching any non-stopword query word, and the
498
+ document vectors nearest to the query embedding, 100 candidates each. A hit's
499
+ `score` is its fused score, and equal scores are ordered by ref. The query is
500
+ embedded with the model's query template (see `embedding.queryTemplate` in
501
+ [`configuration.md`](configuration.md)); when the embedding takes longer than
502
+ `embedding.queryTimeoutMs` (default 3000) or fails, the search is served by
503
+ keyword ranking alone with `fts-fallback` and a warning. Filters (`--type`,
504
+ `--from`, `--filter`, `--belief`, the default session exclusion, proposed
505
+ quality) and one-hit-per-file deduplication narrow the fused list without
506
+ reordering it.
507
+
502
508
  | Flag | Values | Default | Description |
503
509
  | --- | --- | --- | --- |
504
510
  | `--type` | `skill`, `command`, `agent`, `knowledge`, `instruction`, `workflow`, `script`, `memory`, `env`, `secret`, `lesson`, `task`, `session`, `fact`, `any` | `any` | Filter by asset type. Free-form and unvalidated — an unknown type returns no hits. Also accepts any adapter-defined type (e.g. `website`) — see [Bundle Types](bundle-types.md) for the open types each adapter emits. |
@@ -508,8 +514,7 @@ instead of treating keyword fallback as healthy semantic ranking.
508
514
  | `--filter` | `<key>=<value>` | _(none)_ | Scope filter — repeatable. Valid keys: `user`, `agent`, `run`, `channel`. Example: `--filter user=alice --filter channel=ops`. Narrows the result set; ranking is unchanged. |
509
515
  | `--include-proposed` | flag | `false` | Include entries with `quality: "proposed"` in the result set. Default search excludes them; `generated` and `curated` quality entries are always included. Unknown quality values warn once and remain searchable. |
510
516
  | `--belief` | `all`, `current`, `historical` | `all` | Memory belief filter. `current` keeps active memory beliefs; `historical` keeps contradicted/superseded/archived ones. |
511
- | `--no-project-context` | flag | `false` | Disable the automatic project-context ranking boost for this search only |
512
- | `--track-usage`, `--no-track-usage` | flag | `true` | Record or suppress local usage-event and ranking updates for this successful read |
517
+ | `--track-usage`, `--no-track-usage` | flag | `true` | Record or suppress local usage events for this successful read |
513
518
  | `--include-sessions` | flag | `false` | Include session assets, which are excluded from default results via `config.search.defaultExcludeTypes` |
514
519
  | `--format` | `json`, `jsonl`, `yaml`, `text`, `md`, `html` | `json` | Output format |
515
520
  | `--detail` | `brief`, `normal`, `full` | `brief` | Output verbosity level |
@@ -529,21 +534,12 @@ availability:
529
534
  - **`ref`** -- The asset handle to pass to `akm show` (for example
530
535
  `team//scripts/deploy.sh`); present at `brief`, `full`, and `agent` for local
531
536
  hits
532
- - **fragment provenance** -- when `ref` selects an indexed Markdown fragment,
533
- `selectedRef` and `parentRef` distinguish the ranked evidence from its parent;
534
- one-based `fragmentOrdinal`, `fragmentCount`, source-line bounds, neighbor
535
- refs, and separate fragment/parent size estimates are available without
536
- changing ranking. `estimatedTokens` describes the fragment for a
537
- fragment-qualified hit; `parentEstimatedTokens` describes the whole asset.
538
537
  - **`name`** -- The asset's filename or identifier; present at all levels
539
538
  - **`origin`** -- The source bundle (e.g. `npm:@scope/pkg`), present only for
540
539
  managed source assets; surfaced at `full` only
541
540
  - **`id`** -- Registry-level identifier (registry hits only)
542
- - **`matchStage`** -- Which stage of the progressive AND->OR lexical search
543
- ladder produced the hit: `exact` (strict AND), `prefix` (prefix AND), or
544
- `relaxed` (OR/prefix-OR recovery). Omitted for hits with no FTS component
545
- (e.g. a pure-semantic hybrid match) and for registry hits; surfaced at
546
- `normal`, `full`, and `--shape agent`
541
+ - **`whyMatched`** -- The hit's rank in each candidate list that returned
542
+ it (`lexical rank 3`, `vector rank 12`); surfaced at `full`
547
543
 
548
544
  The default brief shape is intentionally small. The exact field set per
549
545
  detail level (and per `--shape`) is authoritative in
@@ -553,9 +549,9 @@ assembled into the shape registry by the `src/output/shapes.ts` barrel:
553
549
  | Level | Local bundle hits | Registry hits |
554
550
  | --- | --- | --- |
555
551
  | `brief` (default) | `type`, `name`, `ref`, `action`, `estimatedTokens` | `name`, `installRef`, `score` |
556
- | `normal` | `type`, `name`, `description`, `action`, `score`, `estimatedTokens`, optional `warnings`/`quality`/`keys`/`matchStage` | `name`, `description`, `action`, `installRef`, `score`, optional `warnings` |
557
- | `full` | full hit object (includes `ref`, `origin`, `tags`, `whyMatched`, optional `warnings`, optional `quality`, optional `matchStage`, timings, bundle metadata) | full hit object |
558
- | `--shape agent` | `name`, `ref`, `type`, `path`, `editable`, conditional `editHint`, `description`, `action`, `score`, optional `estimatedTokens`/`keys`/`matchStage` | no local access fields |
552
+ | `normal` | `type`, `name`, `description`, `action`, `score`, `estimatedTokens`, optional `warnings`/`quality`/`keys` | `name`, `description`, `action`, `installRef`, `score`, optional `warnings` |
553
+ | `full` | full hit object (includes `ref`, `origin`, `tags`, `whyMatched`, optional `warnings`, optional `quality`, timings, bundle metadata) | full hit object |
554
+ | `--shape agent` | `name`, `ref`, `type`, `path`, `editable`, conditional `editHint`, `description`, `action`, `score`, optional `estimatedTokens`/`keys` | no local access fields |
559
555
 
560
556
  `--shape summary` is **not valid on `search`** — see
561
557
  [`--shape summary`](#--shape-summary) above; it is a usage error (exit 2)
@@ -594,18 +590,18 @@ akm curate "learn the release workflow" --from all --format text
594
590
  | `--type` | `skill`, `command`, `agent`, `knowledge`, `instruction`, `workflow`, `script`, `memory`, `env`, `secret`, `lesson`, `task`, `session`, `fact`, `any` | `any` | Filter curated results by asset type |
595
591
  | `--limit` | number | `4` | Maximum curated results |
596
592
  | `--from` | `local`, `registry`, `all` | `local` | Where to search before curating |
597
- | `--track-usage`, `--no-track-usage` | flag | `true` | Record or suppress local usage-event and ranking updates for this successful read |
598
-
599
- `akm curate` selects a small relevance-first shortlist. It preserves the
600
- strongest search hits first, uses only small type-aware nudges for close-score
601
- ties, can collapse obvious root/reference families into one top-level result,
602
- and falls back to token searches when the phrase result set is weak. Curate
603
- includes direct follow-up commands such as `akm show <ref>` or `akm bundle add <ref>`
604
- so you can immediately inspect or install what it found.
593
+ | `--track-usage`, `--no-track-usage` | flag | `true` | Record or suppress local usage events for this successful read |
594
+
595
+ `akm curate` takes the top `--limit` hits of one search, in search order, and
596
+ enriches each with a preview, run details and up to two graph-related support
597
+ refs. With `search.curateRerank.enabled`, a cross-encoder first reorders the
598
+ top 30 fused candidates (`search.curateRerank.topN`) by name, description and
599
+ the start of each asset's indexed content. Curate includes direct follow-up
600
+ commands such as `akm show <ref>` or `akm bundle add <ref>` so you can
601
+ immediately inspect or install what it found.
605
602
  `--detail` and `--shape agent` both work on curate output; `--shape summary`
606
603
  does not.
607
- Curate preserves the underlying `searchMode` and deduplicates semantic fallback
608
- warnings across its full-query and token-fallback searches.
604
+ Curate preserves the underlying search's `searchMode` and warnings.
609
605
  Agent-shaped local items include `ref`, `path`, and `editable`, plus `editHint`
610
606
  only for read-only items. Their `followUp` remains `akm show <ref>` rather than
611
607
  being replaced by clone guidance.
@@ -615,8 +611,7 @@ individual scripts, skills, or docs.
615
611
  every prompt: it only ever reads the index as it currently stands (the same
616
612
  non-blocking `ensureIndex()` path `search` uses) and never waits on or
617
613
  contends with a full `akm index` rebuild in progress.
618
- Use `--no-track-usage` when this inspection must not update local usage or
619
- ranking signals.
614
+ Use `--no-track-usage` when this inspection must not record usage events.
620
615
 
621
616
  ### show
622
617
 
@@ -624,8 +619,8 @@ Display an asset by ref. On a markdown document `#fragment` selects one
624
619
  section by heading slug (falling back to case-insensitive heading text); an
625
620
  unmatched fragment lists the available slugs.
626
621
 
627
- Successful reads record local usage and ranking signals by default; pass
628
- `--no-track-usage` to suppress those updates.
622
+ Successful reads record local usage events by default; pass
623
+ `--no-track-usage` to suppress them.
629
624
 
630
625
  ```sh
631
626
  akm show scripts/deploy.sh
@@ -655,7 +650,7 @@ akm show memories/retro --filter user=alice --filter agent=claude
655
650
  | `--max-chars` | positive integer | `3200` for `lead` | Hard contextual content budget in characters; requires `--context lead` and is mutually exclusive with `--max-tokens`. |
656
651
  | `--max-tokens` | positive integer | _(none)_ | Approximate contextual budget using four characters per token; requires `--context lead` and is mutually exclusive with `--max-chars`. |
657
652
  | `--filter` | `<key>=<value>` | _(none)_ | Repeatable scope filter (`user`, `agent`, `run`, `channel`). |
658
- | `--track-usage`, `--no-track-usage` | flag | `true` | Record or suppress local usage-event and ranking updates for this successful read. |
653
+ | `--track-usage`, `--no-track-usage` | flag | `true` | Record or suppress local usage events for this successful read. |
659
654
 
660
655
  `meta` is not an asset type — `[<origin>//]meta[:<name>]` direct-reads a
661
656
  human-authored orientation doc from a bundle's optional `.meta/` directory
@@ -816,7 +811,7 @@ The old `--params <json>` bag is removed.
816
811
  | `--max-retries <n>` | When a step fails, reopen the same run and retry the failed step up to this many additional times. Range: 0 through 100; default 0. Gate rejection and interruption are not retried. |
817
812
  | `--timeout <duration>` | Abort the whole invocation after `N`, `Nms`, `Ns`, or `Nm`; bare `N` is milliseconds. The active step remains resumable. |
818
813
  | `--new` | Start a fresh run even when one is already active for this ref, instead of resuming it. The existing active run is left untouched — it is never abandoned automatically. A workflow ref only: passing a run id with `--new` is a usage error (exit 2). Parameter flags are allowed together with `--new`, since it is starting a new run. |
819
- | `--skip-if-locked` | If another akm process already holds this run's engine lease (`RUN_LEASE_HELD`), or `state.db` is busy with another writer (`STATE_DB_CONTENDED`), skip gracefully (exit 0) instead of failing (exit 75, `TransientError`). The envelope reports `{ skipped: { reason: "lock-held" \| "state-db-contended", message } }`. Every other failure (a bad flag, an unresolvable target) still fails loudly regardless of this flag. Use for high-frequency scheduled runs so they don't pile up failures while a longer-running invocation is in progress — same family as `improve --skip-if-locked`. |
814
+ | `--skip-if-locked` | If another akm process is already driving this run (it holds the run's lock file: `RUN_LEASE_HELD`), or `state.db` is busy with another writer (`STATE_DB_CONTENDED`), skip gracefully (exit 0) instead of failing (exit 75, `TransientError`). The envelope reports `{ skipped: { reason: "lock-held" \| "state-db-contended", message } }`. Every other failure (a bad flag, an unresolvable target) still fails loudly regardless of this flag. Use for high-frequency scheduled runs so they don't pile up failures while a longer-running invocation is in progress — same family as `improve --skip-if-locked`. |
820
815
 
821
816
  **Resuming an active run is announced, not silent.** Passing a ref that
822
817
  already has an active run in the current scope resumes that run rather than
@@ -941,8 +936,8 @@ Two output modes:
941
936
  - **`--format json`**: the full envelope — `ok`, `ref`, `title`,
942
937
  `sourceFormat`, `sourcePath`, `irVersion`, `planHash`, `published` (always
943
938
  `false`, so a consumer can never mistake this for a run envelope),
944
- `execution`, `budget?`, `params?`, `outputs?`, `steps[]`, `sourceReadSet[]`,
945
- `notices[]`, `warnings[]`. Each step entry carries an `expansion` field
939
+ `execution`, `budget?`, `params?`, `outputs?`, `steps[]`, `notices[]`,
940
+ `warnings[]`. Each step entry carries an `expansion` field
946
941
  naming how its target was reached: `{via: "direct"}`, `{via: "task",
947
942
  taskRef}`, or — for a step composing a child workflow —
948
943
  `{via: "child", childRef, childPlanHash, childOutputs, steps[]}` with the
@@ -1038,7 +1033,7 @@ akm bundle add https://docs.example.com --max-pages 100 --max-depth 5
1038
1033
 
1039
1034
  | Flag | Description |
1040
1035
  | --- | --- |
1041
- | `--name` | Human-friendly name for the source |
1036
+ | `--name` | The bundle key. A contract, not a hint: it must be a legal bundle slug (no `:` `.` `#` `/` or whitespace) and not already taken by a different bundle, or the add fails before any write. Re-adding an already-installed source under a different `--name` than it already carries also fails — use `akm bundle rename <old> <new>` instead. Omit it and akm derives a name (falling back to a `-<hash>` suffix on a collision). |
1042
1037
  | `--provider` | Explicit provider for declarative source configuration; normally inferred from the input |
1043
1038
  | `--writable` | Mark a git source as writable so `akm sync` also pushes (default: false) |
1044
1039
  | `--options` | Provider options as JSON (e.g. `'{"ref":"main"}'`) |
@@ -1209,6 +1204,42 @@ in `processed`/`plainSynced`; rejected entries report `status: "blocked"` and a
1209
1204
  security code; provider or transaction errors report `status: "failed"`. The
1210
1205
  command continues with later bundles without half-publishing a blocked one.
1211
1206
 
1207
+ ### bundle rename
1208
+
1209
+ Rename a configured bundle's key everywhere akm itself persists it — the one
1210
+ command allowed to change it (renaming by hand-editing `config.json`'s
1211
+ `bundles` key strands every durable ref the tool minted under the old id; see
1212
+ `akm health` / the startup warning that names this).
1213
+
1214
+ ```sh
1215
+ akm bundle rename old-name new-name
1216
+ akm bundle rename old-name new-name --dry-run # Show the plan; write nothing
1217
+ ```
1218
+
1219
+ | Flag | Description |
1220
+ | --- | --- |
1221
+ | `--dry-run` | Report what would change (index/state row counts, scheduler refs, content files that still mention the old name) without writing anything |
1222
+
1223
+ `<new>` must be a legal, unused bundle slug (the same `--name` contract `akm
1224
+ bundle add` enforces) or the rename fails before any write. Rewritten: the
1225
+ config `bundles` key; `defaultBundle`/`defaultWriteTarget` when they name the
1226
+ old id; every `scheduler.enabled[].ref` with the old `<old>//` prefix; the
1227
+ lockfile entry id; every indexed entry's `bundle_id`/ref; and this tool's own
1228
+ state rows that name the old bundle (`proposals.ref`, a pending proposal's
1229
+ write target, and workflow `task_history.target_ref`). Reported, never
1230
+ rewritten: refs inside the bundle's own CONTENT (cross-references, `uses:` in
1231
+ a task, `supersededBy`) — the result's `contentRefs` lists the indexed files
1232
+ that still spell the old `<old>//` prefix so you can fix them by hand. A real
1233
+ run also re-syncs native scheduler bindings under the new name (`taskSync` in
1234
+ the result reports the outcome, never thrown, since config/index/state are
1235
+ already renamed by then). `taskSync.ok` is `false` both when the sync call
1236
+ itself fails and when it comes back reporting one or more
1237
+ `taskSync.result.failures` — a binding that failed to prepare has already
1238
+ lost its old native row and stays unscheduled until you re-run
1239
+ `akm task sync`; `--dry-run` lists the installed native rows that still name
1240
+ the old bundle (`nativeSchedulerRows`) so you can see what that sync will
1241
+ replace.
1242
+
1212
1243
  ### upgrade
1213
1244
 
1214
1245
  Upgrade `akm` itself to the latest release. Standalone binaries are downloaded,
@@ -1432,7 +1463,7 @@ akm remember "Deployment needs VPN access" --bundle team-bundle
1432
1463
  | `--expires <dur>` | Expiry shorthand (`30d`, `12h`, `6m`). Resolved to an ISO date |
1433
1464
  | `--source <s>` | Free-form source reference — URL, asset ref, file path, or any string |
1434
1465
  | `--xref <ref>` | Cross-reference ref recorded in the memory's `xrefs:` frontmatter list. Repeatable: `--xref knowledge/auth-flow --xref memories/vpn-note`. Each ref must resolve in the write target or a configured source (read-only sources count); an unresolvable ref fails with exit 2 before anything is written. More than 5 refs warns (soft cap) but still writes. Does not trigger the tags-required check. |
1435
- | `--supersedes <ref>` | Ref of an existing asset this memory corrects. Repeatable. Writes the correction with the old ref folded into its `xrefs:` (correction provenance) AND demotes the old asset — `beliefState: superseded` + `supersededBy: [<new ref>]`, a metadata-only frontmatter edit that preserves every other key and the body — then reindexes it so ranking prefers the correction and `--belief current` hides the stale version immediately. An unresolvable ref fails with exit 2 before anything is written or demoted; so does a ref naming the asset being written itself (a correction cannot supersede itself, e.g. `--force` overwriting the same name). A ref that resolves only outside the write target and the working bundle still writes the correction but skips the demotion: stderr warns and the JSON output reports `superseded: [{ref, applied: false, reason}]` — the reason names the `--bundle` remedy when the old asset lives in a configured writable source. An old asset whose existing frontmatter is not parseable YAML is skipped the same way (`applied: false`) instead of being rewritten lossily. Re-running the same correction is idempotent. On a git write target the correction and the demoted old asset land in the same single boundary commit. |
1466
+ | `--supersedes <ref>` | Ref of an existing asset this memory corrects. Repeatable. Writes the correction with the old ref folded into its `xrefs:` (correction provenance) AND demotes the old asset — `beliefState: superseded` + `supersededBy: [<new ref>]`, a metadata-only frontmatter edit that preserves every other key and the body — then reindexes it so `--belief current` hides the stale version immediately. An unresolvable ref fails with exit 2 before anything is written or demoted; so does a ref naming the asset being written itself (a correction cannot supersede itself, e.g. `--force` overwriting the same name). A ref that resolves only outside the write target and the working bundle still writes the correction but skips the demotion: stderr warns and the JSON output reports `superseded: [{ref, applied: false, reason}]` — the reason names the `--bundle` remedy when the old asset lives in a configured writable source. An old asset whose existing frontmatter is not parseable YAML is skipped the same way (`applied: false`) instead of being rewritten lossily. Re-running the same correction is idempotent. On a git write target the correction and the demoted old asset land in the same single boundary commit. |
1436
1467
  | `--auto` | Apply heuristic tagging from the body (opt-in, zero-latency, pure TS) |
1437
1468
  | `--enrich` | Call the configured LLM for tag/description proposals (opt-in, 10s timeout, fails soft) |
1438
1469
  | `--user <id>` | Scope this memory to a user id. Persisted as the canonical `scope_user` frontmatter key. |
@@ -1565,9 +1596,9 @@ akm feedback skills/code-review --negative --reason "flaky" --tag slice:train --
1565
1596
  Specify exactly one of `--positive` or `--negative`. The ref must already be
1566
1597
  present in the current local index.
1567
1598
 
1568
- The `--applied-to` flag drives the lesson-strength ranking signal: lessons that
1569
- have demonstrably helped resolve tasks receive a small additive ranking boost
1570
- (capped at +0.3) so they float to the top of search.
1599
+ The `--applied-to` flag records the lesson-strength signal: each credit is
1600
+ kept in the lesson's `lessonStrength[]` frontmatter. Search ranking does not
1601
+ use it.
1571
1602
 
1572
1603
  ### log
1573
1604
 
@@ -1671,27 +1702,25 @@ wrapper over the standalone `akm-migrate` executable (installed alongside
1671
1702
  akm has ever written so the CLI proper reads only current schemas. The steps,
1672
1703
  in order:
1673
1704
 
1674
- 1. legacy config `extraParams` keys lifted onto first-class engine fields
1675
- (`configExtraParams`);
1676
- 2. retired `experimental.*` config keys removed, today `workflowEngine`
1677
- (`configRetiredExperimentalKeys`) — config loading already ignores them
1678
- with a one-time warning, so this only cleans the file;
1679
- 3. scheduler grants bound to the configured source installation that was
1680
- approved, with stale grants for removed bundles dropped
1681
- (`configSchedulerSourceIds`);
1682
- 4. pending `state.db` migrations, historical-destructive ones included, with
1705
+ 1. config.json rewritten in its current shape (`configFile`): retired and
1706
+ unknown keys dropped, legacy `extraParams` lifted onto first-class engine
1707
+ fields, the legacy `stashDir`/`sources[]`/`installed` layout converted to
1708
+ `bundles`/`defaultBundle`, `configVersion` bumped — the same pipeline
1709
+ every load already runs in memory, so this only persists it, under a
1710
+ backup;
1711
+ 2. pending `state.db` migrations, historical-destructive ones included, with
1683
1712
  a verified sibling safety copy (`stateMigrations`) — the only path besides
1684
1713
  `akm upgrade` that admits released migration 018, which an ordinary
1685
1714
  command refuses;
1686
- 5. source-owned schedule enablement converted to host-local scheduler grants
1687
- (`schedulerActivation`);
1688
- 6. task-v2 files to task v3, then task-v3 files to task source v4
1689
- (`taskV3Migration`, `taskV4Migration`), each keeping its own lock, backup,
1690
- prevalidation, and rollback, so a file blocked in the first generation does
1691
- not stop the second from converting files already at `version: 3`;
1692
- 7. superseded pre-0.9.0 `.akm` residue and stale filesystem transactions
1693
- (`deadResidue`, `staleTxns`), then live `.akm` writers relocated to
1694
- `$STATE`/`$CACHE` (`writerRelocation`).
1715
+ 3. task files at version 2 or 3, and version 4 files still carrying the
1716
+ retired `schedule[].enabled` key, rewritten as task source v4
1717
+ (`taskFiles`) under one backup directory per run, each emitted document
1718
+ re-parsed by the runtime v4 parser first; a file the planner cannot
1719
+ convert unambiguously is reported `blocked` and left alone;
1720
+ 4. superseded residue removed (`deadResidue`): pre-0.9.0 `.akm` leftovers in
1721
+ the stash, and the transaction-journal, maintenance-barrier, lock-mutex and
1722
+ version-stamp files older releases kept under `$DATA`, `$STATE` and
1723
+ `$CONFIG`.
1695
1724
 
1696
1725
  ```sh
1697
1726
  akm migrate status
@@ -1710,6 +1739,16 @@ blocked-reason table and worked examples, and
1710
1739
  [Bundling akm](../integration/bundling-akm.md) for the plan JSON shape and
1711
1740
  how to drive this from a container/image boot step.
1712
1741
 
1742
+ Each step above runs under its own catch: a step's own anomaly is always
1743
+ recorded in the plan's `failedSteps: [{step, error}]` instead of ending the
1744
+ whole run — the remaining steps still run in order. Under `apply`, a failed
1745
+ step's section falls back to its read-only preview; if that fails too, the
1746
+ fallback adds its own `failedSteps` entry, and the section is absent from the
1747
+ plan. Any `failedSteps` entry
1748
+ forces `status: "blocked"` and adds a matching line to `blockers`, so
1749
+ `akm migrate status|apply` reports the plan and exits 1 (not the internal-error
1750
+ 70) the same way it does for any other blocked plan.
1751
+
1713
1752
  ### config
1714
1753
 
1715
1754
  Read and write configuration. Bare `akm config` (no subcommand) is a usage
@@ -2383,10 +2422,14 @@ akm improve report --since 7d # ...aggregated over every real run start
2383
2422
  `akm improve` is the public entrypoint for whole-bundle, type-scoped, and
2384
2423
  ref-scoped improvement. It owns the memory-cleanup and lesson-distillation
2385
2424
  flow. A qualified scope such as `team//skills/code-review` selects that bundle;
2386
- a different explicit `--bundle` is a usage error. Inspecting or re-minting the
2387
- collapse-detector canary set is maintainer tooling, not a CLI verb — run
2388
- `bun scripts/refresh-canary-set.ts` (add `--refresh` to mint a new set and
2389
- deactivate the old one; old rows and their cycle history are retained).
2425
+ a different explicit `--bundle` is a usage error.
2426
+
2427
+ Every stage records what it did with each asset in the improve ledger
2428
+ (`improve_ledger` in `state.db`) and reads it before any model call: an asset
2429
+ whose proposal was rejected waits 14 days (reflect), 30 days (distill) or 7
2430
+ days (other stages) before it is tried again; an expired proposal waits one
2431
+ day; an asset a stage looked at and left unchanged is revisited after 7 days,
2432
+ or as soon as new feedback (or, for consolidation, an edit) arrives.
2390
2433
 
2391
2434
  Built-in `default` and `frequent` leave the improve-stage extract process off,
2392
2435
  and `default` plus `reflect-distill` leave proactive maintenance off. Use the
@@ -2490,7 +2533,7 @@ default probe-on behavior) to check whether a named engine actually answers.
2490
2533
  builds the exact prompt reflect would send for one asset — the same source
2491
2534
  resolution, runner selection, feedback/schema-hint/related-lesson/rejected-
2492
2535
  proposal gathering `akm improve`'s live reflect step uses — and prints it
2493
- without acquiring a dispatch lease, so it never calls an engine. Add
2536
+ without reading a credential, so it never calls an engine. Add
2494
2537
  `--format text` (the default JSON/yaml envelope escapes the prompt into one
2495
2538
  line, which defeats a by-eye read) to confirm by eye that recent feedback is
2496
2539
  framed as an unverified report to investigate (never a fact to insert
@@ -2498,9 +2541,7 @@ verbatim) and that the response contract tells the model never to emit the
2498
2541
  truncation marker or any content from outside the shown asset.
2499
2542
 
2500
2543
  When reinforced facts need promotion, `knowledge` is the higher-authority
2501
- destination than `memory`. The deterministic search ranking also prefers
2502
- `knowledge` over `memory` hits, including inferred `.derived` memories, when
2503
- the evidence is otherwise comparable.
2544
+ destination than `memory`.
2504
2545
 
2505
2546
  #### improve report
2506
2547
 
@@ -2786,27 +2827,27 @@ requires `--reason`.
2786
2827
 
2787
2828
  #### proposal drain
2788
2829
 
2789
- Drain the standing pending-proposal backlog using a deterministic triage
2790
- policy, instead of adjudicating proposals one at a time. Default mode stages
2791
- decisions (queue mode); pass `--promote` to actually accept matching
2792
- proposals.
2830
+ Drain the standing pending-proposal backlog instead of adjudicating proposals
2831
+ one at a time. One rule decides each proposal: a proposal whose quality judge
2832
+ passed on its current content is accepted (unless its target changed since it
2833
+ was minted — that one is auto-rejected as `stale-target`); an empty diff is
2834
+ rejected; everything else goes to the judgment tier when one is enabled, and
2835
+ is otherwise left for review. Default mode stages decisions (queue mode); pass
2836
+ `--promote` to actually accept.
2793
2837
 
2794
2838
  ```sh
2795
2839
  akm proposal drain --dry-run # Preview without writing
2796
- akm proposal drain --policy personal-stash --promote -y
2797
- akm proposal drain --policy conservative --max-accepts 10 --promote -y
2798
- akm proposal drain --max-diff-lines 50 --older-than 7 --promote -y
2840
+ akm proposal drain --promote -y
2841
+ akm proposal drain --max-accepts 10 --older-than 7 --promote -y
2799
2842
  akm proposal drain --strategy default --promote -y # Read the triage block from an improve strategy
2800
2843
  ```
2801
2844
 
2802
2845
  | Flag | Description |
2803
2846
  | --- | --- |
2804
- | `--policy` | Built-in preset (`personal-stash`, `conservative`, `manual`) or a path to a policy file |
2805
- | `--strategy` | Read the triage block (policy, apply mode, ceilings, judgment) from this improve strategy instead |
2806
- | `--promote` | Promote (accept) matching proposals. Default is queue mode — stage only, no writes to assets. |
2847
+ | `--strategy` | Read the triage block (apply mode, ceilings, judgment) from this improve strategy instead |
2848
+ | `--promote` | Promote (accept) judge-passed proposals. Default is queue mode — stage only, no writes to assets. |
2807
2849
  | `--dry-run` | List what would be accepted/rejected/deferred, without writing |
2808
2850
  | `--max-accepts` | Hard per-run accept ceiling; accepts beyond this are reported as `skippedByCap` |
2809
- | `--max-diff-lines` | Defer (never promote) accepts whose proposed content exceeds this many lines |
2810
2851
  | `--older-than` | Only consider proposals created more than this many days ago |
2811
2852
  | `--judgment` | Explicitly enable the judgment tier for this standalone drain, including when the selected strategy says `judgment.enabled: false`; execution overrides still come from that strategy. Without this flag, strategy judgment config does not enable standalone drain judgment. A missing runner remains a no-op with a logged `triage_deferred` summary. |
2812
2853
  | `-y`, `--yes` | Skip the confirmation prompt (required in non-interactive mode for promotion) |
@@ -2855,10 +2896,10 @@ akm task prune --yes # Remove every currently-computed or
2855
2896
  akm task prune --id ghost,stale --yes # Remove only the named orphan ids
2856
2897
  ```
2857
2898
 
2858
- `task add` also accepts `--disabled` (register but leave off in the OS
2859
- scheduler), `--force` (overwrite an existing task with the same id), and
2860
- `--rebind` (explicitly permit scheduler creation from a local invocation that
2861
- would otherwise be considered ineligible).
2899
+ `task add` also accepts `--disabled` (write the task but leave its ref out of
2900
+ this host's scheduler activation), `--force` (overwrite an existing task with
2901
+ the same id), and `--rebind` (also point the bundle's installed scheduler rows
2902
+ at this akm invocation, as `akm task sync --rebind` does).
2862
2903
 
2863
2904
  `akm task list [<query>] [--limit <n>] [--from local|registry|all]` is a
2864
2905
  pure alias for `akm search --type task` with the query, `--limit`, and
@@ -2902,17 +2943,33 @@ time. Each run is recorded as a row in the durable `task_history` table
2902
2943
  no `task_invoked`/`task_completed` event type on the `akm log` stream.
2903
2944
 
2904
2945
  Task source cannot enable itself. `akm task enable <fully-qualified-ref>` adds
2905
- an exact source-bound `{kind, ref, sourceId}` grant to this host's
2906
- `scheduler.enabled` config and
2907
- syncs that bundle; `akm task disable` removes it and unschedules the task.
2946
+ the ref to this host's `scheduler.enabled` list and syncs that bundle; `akm task disable` removes it and unschedules the task.
2908
2947
  Manual `akm task run` remains available. To remove a task, delete its file
2909
2948
  (`<bundle>/tasks/<id>.yml`) and run `akm task sync` — sync uninstalls the
2910
2949
  orphaned scheduler entry.
2911
2950
 
2912
- `akm task sync --dry-run` prints the planned adds/updates/removes (removals
2913
- carry their owning bundle) without touching the scheduler — zero writes.
2914
- Exits non-zero when removals are pending, so it can gate a CI/health check
2915
- on "sync would change something."
2951
+ A config with no `scheduler.enabled` list at all (written before 0.9.17)
2952
+ means "keep what is installed": `akm task sync` takes the akm-written rows
2953
+ already in the scheduler as this host's choice and writes the list; an
2954
+ explicit list is never second-guessed. `akm task sync --dry-run` prints the
2955
+ planned adds/updates/removes (removals carry their owning bundle) without
2956
+ touching the scheduler — zero writes. Exits non-zero when removals are pending, so it can
2957
+ gate a CI/health check on "sync would change something."
2958
+
2959
+ `sync`'s (and `sync --dry-run`'s) result always carries `failures: [{path,
2960
+ ref?, reason}]` — one entry per item sync could not reconcile: a task/workflow
2961
+ source that failed to parse or prepare (its installed row is left as it is),
2962
+ two sources claiming the same scheduler id, a desired binding whose id is
2963
+ already scheduled from a different bundle or installation, a row whose
2964
+ install or removal failed, or — for an unscoped, multi-bundle sync — a whole
2965
+ bundle whose sources could not be read. Every one of these is a per-item
2966
+ failure: the item is left exactly as it was and reported here, while every
2967
+ OTHER item and bundle in the same sync still reconciles; with `--bundle`,
2968
+ that one bundle IS the whole sync, so a bundle that cannot be read raises
2969
+ instead of being reported here. `failures` is empty on a fully clean sync; a
2970
+ non-empty `failures` still exits non-zero, same as a pending removal. A
2971
+ crontab whose akm markers are malformed is refused unmodified, and another
2972
+ akm process holding the scheduler lock makes sync exit 75 (retry shortly).
2916
2973
 
2917
2974
  `akm task prune` reclaims installed scheduler entries that `sync` can never
2918
2975
  clean up on its own: entries whose own `--scheduler-context` descriptor no