akm-cli 0.9.30 → 0.10.26101001-alpha

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 (353) hide show
  1. package/CHANGELOG.md +282 -0
  2. package/README.md +10 -10
  3. package/ROADMAP.md +112 -0
  4. package/STABILITY.md +79 -53
  5. package/dist/api-node.mjs +20 -0
  6. package/dist/api.d.ts +23 -0
  7. package/dist/api.js +45 -0
  8. package/dist/assets/hints/cli-hints-full.md +13 -27
  9. package/dist/assets/hints/cli-hints-short.md +1 -1
  10. package/dist/assets/improve-strategies/default.json +3 -3
  11. package/dist/assets/prompts/consolidate-pair.md +9 -7
  12. package/dist/cli/shared.js +31 -48
  13. package/dist/cli/unknown-flags.js +6 -43
  14. package/dist/cli.js +8 -34
  15. package/dist/commands/agent/contribute-cli.js +1 -1
  16. package/dist/commands/completions.js +1 -2
  17. package/dist/commands/config-cli.js +5 -28
  18. package/dist/commands/env/env-cli.js +5 -5
  19. package/dist/commands/env/secret-cli.js +2 -2
  20. package/dist/commands/health/checks.js +41 -16
  21. package/dist/commands/health/plugin-staleness.js +52 -22
  22. package/dist/commands/improve/autonomy-gate.js +5 -3
  23. package/dist/commands/improve/consolidate/pair-pass.js +7 -1
  24. package/dist/commands/improve/consolidate.js +6 -35
  25. package/dist/commands/improve/distill/lesson-update.js +91 -0
  26. package/dist/commands/improve/distill-guards.js +1 -43
  27. package/dist/commands/improve/distill.js +140 -20
  28. package/dist/commands/improve/extract-cli.js +1 -1
  29. package/dist/commands/improve/improve-cli.js +120 -114
  30. package/dist/commands/improve/improve-strategies.js +8 -12
  31. package/dist/commands/improve/loop-stages.js +0 -1
  32. package/dist/commands/improve/planner.js +0 -1
  33. package/dist/commands/improve/preparation.js +40 -99
  34. package/dist/commands/improve/proactive-maintenance.js +2 -2
  35. package/dist/commands/improve/reflect-noise.js +3 -55
  36. package/dist/commands/improve/reflect.js +3 -8
  37. package/dist/commands/improve/retrieval-scope.js +2 -2
  38. package/dist/commands/improve/salience.js +2 -9
  39. package/dist/commands/improve/stage.js +14 -9
  40. package/dist/commands/lint/index.js +5 -20
  41. package/dist/commands/observability-cli.js +3 -9
  42. package/dist/commands/proposal/drain.js +39 -6
  43. package/dist/commands/proposal/proposal-cli.js +10 -30
  44. package/dist/commands/proposal/repository.js +3 -3
  45. package/dist/commands/read/knowledge.js +3 -3
  46. package/dist/commands/read/remember-cli.js +0 -13
  47. package/dist/commands/read/search-cli.js +29 -97
  48. package/dist/commands/read/search.js +0 -11
  49. package/dist/commands/read/show.js +0 -19
  50. package/dist/commands/sources/plugin-upgrade.js +164 -101
  51. package/dist/commands/sources/sources-cli.js +1 -15
  52. package/dist/commands/sources/stash-cli.js +4 -12
  53. package/dist/commands/tasks/tasks-cli.js +4 -115
  54. package/dist/commands/workflow/plan.js +11 -33
  55. package/dist/commands/workflow-cli.js +2 -7
  56. package/dist/core/adapter/adapter-ids.js +1 -2
  57. package/dist/core/adapter/adapters/agent-skills-adapter.js +0 -4
  58. package/dist/core/adapter/adapters/akm-adapter.js +9 -48
  59. package/dist/core/adapter/adapters/akm-lint.js +10 -26
  60. package/dist/core/adapter/adapters/akm-metadata.js +2 -72
  61. package/dist/core/adapter/adapters/akm-task-adapter.js +0 -5
  62. package/dist/core/adapter/adapters/akm-workflow-adapter.js +9 -28
  63. package/dist/core/adapter/adapters/dotenv-adapter.js +1 -20
  64. package/dist/core/adapter/adapters/generic-files-adapter.js +0 -10
  65. package/dist/core/adapter/adapters/llm-wiki-adapter.js +0 -4
  66. package/dist/core/adapter/adapters/tool-dir-shared.js +0 -24
  67. package/dist/core/adapter/adapters/website-snapshot-adapter.js +4 -4
  68. package/dist/core/adapter/recognize-match.js +3 -4
  69. package/dist/core/common.js +18 -2
  70. package/dist/core/config/config-schema.js +12 -15
  71. package/dist/core/config/config-types.js +6 -15
  72. package/dist/core/config/config-walker.js +6 -23
  73. package/dist/core/config/config.js +17 -80
  74. package/dist/core/config/engine-semantics.js +7 -3
  75. package/dist/core/config/schema/engines.js +7 -7
  76. package/dist/core/config/schema/improve-processes.js +8 -61
  77. package/dist/core/config/schema/improve.js +2 -21
  78. package/dist/core/config/schema/index-config.js +6 -39
  79. package/dist/core/env-secret-ref.js +2 -45
  80. package/dist/core/errors.js +1 -2
  81. package/dist/core/extra-params.js +2 -86
  82. package/dist/core/file-lock.js +10 -1
  83. package/dist/core/improve-result.js +11 -1
  84. package/dist/core/mutation-target.js +2 -2
  85. package/dist/core/recognition-util.js +4 -5
  86. package/dist/core/warn.js +21 -4
  87. package/dist/core/write-source.js +3 -3
  88. package/dist/execution/target-ref.js +1 -2
  89. package/dist/indexer/search/db-search.js +4 -19
  90. package/dist/indexer/search/fts-query.js +0 -19
  91. package/dist/integrations/agent/engine-resolution.js +5 -2
  92. package/dist/integrations/agent/index.js +1 -1
  93. package/dist/integrations/agent/profiles.js +41 -98
  94. package/dist/integrations/agent/request-lowering.js +3 -3
  95. package/dist/integrations/harnesses/aider/index.js +5 -0
  96. package/dist/integrations/harnesses/amazonq/index.js +1 -0
  97. package/dist/integrations/harnesses/claude/config-import.js +2 -3
  98. package/dist/integrations/harnesses/claude/index.js +5 -0
  99. package/dist/integrations/harnesses/codex/index.js +1 -0
  100. package/dist/integrations/harnesses/copilot/index.js +1 -0
  101. package/dist/integrations/harnesses/gemini/index.js +1 -0
  102. package/dist/integrations/harnesses/index.js +18 -39
  103. package/dist/integrations/harnesses/opencode/agent-builder.js +60 -35
  104. package/dist/integrations/harnesses/opencode/config-import.js +121 -52
  105. package/dist/integrations/harnesses/opencode/index.js +22 -0
  106. package/dist/integrations/harnesses/opencode/plugin-layout.js +68 -0
  107. package/dist/integrations/harnesses/opencode/session-log-types.js +12 -0
  108. package/dist/integrations/harnesses/opencode/session-log-v1.js +72 -0
  109. package/dist/integrations/harnesses/opencode/session-log-v2.js +140 -0
  110. package/dist/integrations/harnesses/opencode/session-log.js +104 -115
  111. package/dist/integrations/harnesses/opencode/version.js +98 -0
  112. package/dist/integrations/harnesses/opencode-sdk/{harness.js → index.js} +5 -17
  113. package/dist/integrations/harnesses/opencode-sdk/sdk-runner.js +105 -206
  114. package/dist/integrations/harnesses/opencode-sdk/v1-adapter.js +199 -0
  115. package/dist/integrations/harnesses/opencode-sdk/v2-adapter.js +228 -0
  116. package/dist/integrations/harnesses/opencode-sdk/wire.js +66 -0
  117. package/dist/integrations/harnesses/openhands/index.js +1 -0
  118. package/dist/integrations/harnesses/pi/index.js +1 -0
  119. package/dist/integrations/harnesses/shared.js +2 -0
  120. package/dist/integrations/harnesses/types.js +2 -0
  121. package/dist/llm/client.js +74 -14
  122. package/dist/output/cli-hints.js +1 -1
  123. package/dist/output/context.js +10 -19
  124. package/dist/output/format-exempt.js +5 -8
  125. package/dist/output/shapes/helpers.js +1 -22
  126. package/dist/output/shapes/passthrough.js +0 -1
  127. package/dist/output/shapes.js +3 -31
  128. package/dist/output/stdout.js +5 -1
  129. package/dist/output/text/command-format.js +6 -1
  130. package/dist/output/text/workflow-format.js +4 -22
  131. package/dist/scripts/akm-migrate-node.js +15746 -16706
  132. package/dist/scripts/akm-migrate.js +16319 -17275
  133. package/dist/setup/detect.js +10 -4
  134. package/dist/setup/harness-config-import.js +5 -14
  135. package/dist/setup/setup.js +1 -1
  136. package/dist/setup/steps/tasks.js +12 -13
  137. package/dist/storage/repositories/task-history-repository.js +0 -5
  138. package/dist/storage/repositories/workflow-runs-repository.js +5 -15
  139. package/dist/tasks/embedded.js +2 -1
  140. package/dist/tasks/run/task-history.js +0 -2
  141. package/dist/tasks/schedule-gates.js +39 -0
  142. package/dist/tasks/scheduler-binding.js +0 -16
  143. package/dist/tasks/scheduler-sync.js +3 -97
  144. package/dist/tasks/source/bounded-document.js +1 -1
  145. package/dist/tasks/source/task-source-v4.js +2 -12
  146. package/dist/tasks/task-run-reserved-flags.js +2 -31
  147. package/dist/workflows/authoring/authoring.js +6 -6
  148. package/dist/workflows/compile.js +8 -65
  149. package/dist/workflows/exec/child-workflow.js +22 -3
  150. package/dist/workflows/exec/native-executor.js +12 -147
  151. package/dist/workflows/exec/run-workflow.js +31 -103
  152. package/dist/workflows/exec/step-work.js +9 -178
  153. package/dist/workflows/exec/unit-dispatch.js +0 -10
  154. package/dist/workflows/freeze/environment.js +3 -44
  155. package/dist/workflows/freeze/freeze.js +8 -41
  156. package/dist/workflows/freeze/targets/child-workflow.js +27 -63
  157. package/dist/workflows/freeze/targets/command.js +2 -16
  158. package/dist/workflows/freeze/targets/shell.js +0 -2
  159. package/dist/workflows/freeze/task-bindings.js +2 -28
  160. package/dist/workflows/ir/params.js +12 -2
  161. package/dist/workflows/parser.js +82 -232
  162. package/dist/workflows/plan.js +1 -1
  163. package/dist/workflows/renderer.js +10 -19
  164. package/dist/workflows/runtime/run-plan.js +11 -53
  165. package/dist/workflows/runtime/runs.js +4 -27
  166. package/dist/workflows/source-files.js +12 -16
  167. package/dist/workflows/source-semantics.js +1 -93
  168. package/docs/README.md +43 -42
  169. package/docs/agents/README.md +15 -0
  170. package/docs/agents/agent-install.md +14 -0
  171. package/docs/architecture/README.md +67 -0
  172. package/docs/architecture/adapters.md +258 -0
  173. package/docs/architecture/akm-architecture-decision-history.md +2055 -0
  174. package/docs/architecture/akm-core-principles.md +126 -0
  175. package/docs/architecture/architecture.md +578 -0
  176. package/docs/architecture/comparisons/claude-code-vs-akm-workflows-full.md +550 -0
  177. package/docs/architecture/decisions/0001-no-interpolation-attached-structured-context.md +72 -0
  178. package/docs/architecture/decisions/0002-unit-reuse-and-input-hash-scope.md +142 -0
  179. package/docs/architecture/decisions/0003-child-env-allowlist-and-provenance.md +189 -0
  180. package/docs/architecture/decisions/0004-task-input-contract-and-flag-coercion.md +97 -0
  181. package/docs/architecture/decisions/0005-task-result-vocabulary-and-legacy-read-mapping.md +108 -0
  182. package/docs/architecture/decisions/0006-task-source-version-routing.md +124 -0
  183. package/docs/architecture/decisions/0007-workflow-composition-bounds.md +83 -0
  184. package/docs/architecture/decisions/0008-task-binding-normalization.md +88 -0
  185. package/docs/architecture/decisions/0009-child-run-publication-column-parity.md +80 -0
  186. package/docs/architecture/decisions/0010-driver-protocol-cut.md +36 -0
  187. package/docs/architecture/decisions/0011-engine-run-loop-invariants.md +125 -0
  188. package/docs/architecture/decisions/README.md +62 -0
  189. package/docs/architecture/improvement.md +471 -0
  190. package/docs/architecture/internals/classification.md +154 -0
  191. package/docs/architecture/internals/fresh-host-rebuild-runbook.md +40 -0
  192. package/docs/architecture/internals/functional-contract-patterns.md +340 -0
  193. package/docs/architecture/internals/health-advisories.md +110 -0
  194. package/docs/architecture/internals/improve-workflow.md +720 -0
  195. package/docs/architecture/internals/indexing.md +498 -0
  196. package/docs/architecture/internals/registry-network-boundary.md +57 -0
  197. package/docs/architecture/internals/search.md +248 -0
  198. package/docs/architecture/internals/storage-locations.md +943 -0
  199. package/docs/architecture/persisted-data-compat.md +68 -0
  200. package/docs/architecture/reviews/env-secret-access.md +319 -0
  201. package/docs/architecture/runtime-boundary-design.md +153 -0
  202. package/docs/architecture/specs/0.9.0-close-out-plan.md +361 -0
  203. package/docs/architecture/specs/0.9.0-decisions.md +532 -0
  204. package/docs/architecture/specs/0.9.0-docs-code-drift-register.md +745 -0
  205. package/docs/architecture/specs/0.9.0-open-items-register.md +135 -0
  206. package/docs/architecture/specs/0.9.0-public-api-issue-backlog.md +740 -0
  207. package/docs/architecture/specs/0.9.0-release-surface-review.md +636 -0
  208. package/docs/architecture/specs/agent-command-engine-model-design.md +513 -0
  209. package/docs/architecture/specs/akm-0.9.0-bundle-adapter-spec.md +501 -0
  210. package/docs/architecture/specs/akm-0.9.0-ref-grammar-decision.md +291 -0
  211. package/docs/architecture/specs/akm-format-neutral-bundle-workspace-spec.md +2059 -0
  212. package/docs/architecture/specs/di-seams-plan.md +539 -0
  213. package/docs/architecture/specs/driver-protocol-keep-or-cut.md +275 -0
  214. package/docs/architecture/specs/fact-asset-type.md +142 -0
  215. package/docs/architecture/specs/improve-collapse-churn-detector-design.md +634 -0
  216. package/docs/architecture/specs/okf-support.md +148 -0
  217. package/docs/architecture/specs/ref.md +329 -0
  218. package/docs/architecture/specs/reviews/task-workflow-unification/README.md +72 -0
  219. package/docs/architecture/specs/reviews/task-workflow-unification/findings-consolidated.md +152 -0
  220. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-alternatives.md +352 -0
  221. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-bunqueue.md +300 -0
  222. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-openworkflow.md +402 -0
  223. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-1.md +758 -0
  224. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-2.md +645 -0
  225. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-3.md +602 -0
  226. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-adversarial.md +27 -0
  227. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-architecture.md +27 -0
  228. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-coverage.md +74 -0
  229. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-security.md +15 -0
  230. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-adversarial.md +132 -0
  231. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-verification.md +147 -0
  232. package/docs/architecture/specs/stash-conventions-code-spec.md +275 -0
  233. package/docs/architecture/specs/stash-organization-conventions.md +377 -0
  234. package/docs/architecture/specs/task-workflow-format-unification.md +721 -0
  235. package/docs/architecture/specs/workflow-engine-buy-vs-build.md +231 -0
  236. package/docs/architecture/specs/workflow-format-unification.md +432 -0
  237. package/docs/architecture/testing/manual-testing-checklist.md +3411 -0
  238. package/docs/architecture/testing/okf-v0.2-conformance-runbook.md +924 -0
  239. package/docs/architecture/testing/task-workflow-manual-tests.md +1720 -0
  240. package/docs/architecture/testing/testing-workflow.md +446 -0
  241. package/docs/architecture/workflow-engine.md +223 -0
  242. package/docs/guides/README.md +33 -0
  243. package/docs/guides/author-bundles.md +310 -0
  244. package/docs/guides/author-workflows.md +490 -0
  245. package/docs/guides/bundles.md +321 -0
  246. package/docs/guides/capture-knowledge.md +136 -0
  247. package/docs/guides/claude-code-vs-akm-workflows.md +29 -0
  248. package/docs/guides/concepts.md +93 -0
  249. package/docs/guides/discover-and-load.md +158 -0
  250. package/docs/guides/getting-started.md +240 -0
  251. package/docs/guides/improve-the-library.md +246 -0
  252. package/docs/guides/knowledge-management.md +18 -0
  253. package/docs/guides/recipes/headless-install.md +97 -0
  254. package/docs/guides/recipes/website-source.md +28 -0
  255. package/docs/guides/run-workflows.md +279 -0
  256. package/docs/guides/scheduling.md +123 -0
  257. package/docs/guides/use-with-any-agent.md +174 -0
  258. package/docs/guides/wikis.md +81 -0
  259. package/docs/integration/bundling-akm.md +7 -6
  260. package/docs/maintainers/README.md +19 -0
  261. package/docs/maintainers/curate-workmap.md +335 -0
  262. package/docs/maintainers/eval.md +3 -0
  263. package/docs/maintainers/local-development.md +108 -0
  264. package/docs/maintainers/release-checklist.md +132 -0
  265. package/docs/migration/README.md +2 -2
  266. package/docs/migration/release-notes/0.0.13.md +1 -1
  267. package/docs/migration/release-notes/0.1.0.md +1 -1
  268. package/docs/migration/release-notes/0.2.0.md +1 -1
  269. package/docs/migration/release-notes/0.3.0.md +1 -1
  270. package/docs/migration/release-notes/0.5.0.md +1 -1
  271. package/docs/migration/release-notes/0.6.0.md +1 -1
  272. package/docs/migration/release-notes/0.7.0.md +1 -1
  273. package/docs/migration/release-notes/0.7.3.md +2 -2
  274. package/docs/migration/release-notes/0.7.4.md +1 -1
  275. package/docs/migration/release-notes/0.7.5.md +1 -1
  276. package/docs/migration/release-notes/0.8.0.md +1 -1
  277. package/docs/migration/release-notes/0.9.0.md +1 -1
  278. package/docs/migration/release-notes/0.9.14.md +1 -1
  279. package/docs/migration/release-notes/0.9.15.md +1 -1
  280. package/docs/migration/release-notes/0.9.16.md +1 -1
  281. package/docs/migration/release-notes/0.9.17.md +1 -1
  282. package/docs/migration/release-notes/0.9.19.md +1 -1
  283. package/docs/migration/release-notes/0.9.2.md +1 -1
  284. package/docs/migration/release-notes/README.md +27 -31
  285. package/docs/migration/v0.5-to-v0.6.md +759 -0
  286. package/docs/migration/v0.8-to-v0.9.md +1 -1
  287. package/docs/plans/0.9.2-agent-command-workflow-plan.md +423 -0
  288. package/docs/posts/README.md +30 -0
  289. package/docs/posts/akm-command-tour.md +495 -0
  290. package/docs/posts/akm-logo-sized.webp +0 -0
  291. package/docs/posts/belief-aware-memory-12.md +139 -0
  292. package/docs/posts/config-v2-lessons-16.md +191 -0
  293. package/docs/posts/improve-loop-autonomous-10.md +225 -0
  294. package/docs/posts/improve-pipeline-debugging-0803.md +179 -0
  295. package/docs/posts/intro-part-01.md +76 -0
  296. package/docs/posts/intro-part-02.md +221 -0
  297. package/docs/posts/intro-part-03.md +190 -0
  298. package/docs/posts/intro-part-04.md +221 -0
  299. package/docs/posts/llm-mode-reflect-13.md +166 -0
  300. package/docs/posts/openpalm-built-on-akm.md +86 -0
  301. package/docs/posts/progressive-disclosure-06.md +129 -0
  302. package/docs/posts/proposal-safety-net-15.md +112 -0
  303. package/docs/posts/release-0.5.0.md +247 -0
  304. package/docs/posts/release-0.6.0.md +117 -0
  305. package/docs/posts/release-0.7.0.md +159 -0
  306. package/docs/posts/release-0.8.0.md +332 -0
  307. package/docs/posts/scattered-skills-05.md +100 -0
  308. package/docs/posts/task-assets-persistent-workflows-11.md +222 -0
  309. package/docs/posts/team-skills-07.md +198 -0
  310. package/docs/posts/wiki-agent-knowledge-08.md +223 -0
  311. package/docs/posts/workflows-vaults-09.md +321 -0
  312. package/docs/product-surface.md +54 -0
  313. package/docs/reference/README.md +2 -2
  314. package/docs/reference/api.md +65 -0
  315. package/docs/reference/asset-types.md +166 -0
  316. package/docs/reference/bundle-types.md +2 -4
  317. package/docs/reference/cli.md +129 -175
  318. package/docs/reference/configuration.md +84 -19
  319. package/docs/reference/data-and-telemetry.md +1 -1
  320. package/docs/reference/env-and-secrets.md +126 -0
  321. package/docs/reference/memory.md +124 -0
  322. package/docs/reference/refs.md +156 -0
  323. package/docs/reference/registry.md +489 -0
  324. package/docs/reference/supported-formats.md +3 -4
  325. package/docs/reference/tasks.md +12 -19
  326. package/docs/reference/website-sources.md +141 -0
  327. package/docs/reference/workflow-schema.md +89 -317
  328. package/docs/reference/workflows.md +20 -48
  329. package/package.json +23 -16
  330. package/schemas/akm-config.json +2 -243
  331. package/schemas/akm-task.json +2 -3
  332. package/schemas/akm-workflow.json +47 -84
  333. package/dist/assets/improve-strategies/catchup.json +0 -41
  334. package/dist/assets/improve-strategies/proactive-maintenance.json +0 -24
  335. package/dist/assets/improve-strategies/quick.json +0 -17
  336. package/dist/assets/improve-strategies/reflect-distill.json +0 -29
  337. package/dist/assets/improve-strategies/thorough.json +0 -49
  338. package/dist/assets/tasks/improve/akm-improve-catchup.yml +0 -6
  339. package/dist/assets/tasks/improve/akm-improve-frequent.yml +0 -4
  340. package/dist/assets/tasks/improve/akm-improve-nightly.yml +0 -4
  341. package/dist/cli/retired-commands.js +0 -118
  342. package/dist/commands/tasks/validate.js +0 -176
  343. package/dist/core/config/legacy-source-shape-shim.js +0 -117
  344. package/dist/integrations/harnesses/ids.js +0 -28
  345. package/dist/tasks/source/task-source-v3-frozen.js +0 -424
  346. package/dist/tasks/source/task-to-v4.js +0 -863
  347. package/dist/workflows/exec/worktree.js +0 -372
  348. package/dist/workflows/freeze/child-output-references.js +0 -83
  349. package/dist/workflows/freeze/identity.js +0 -22
  350. package/dist/workflows/freeze/targets/script.js +0 -50
  351. package/dist/workflows/freeze/targets/task.js +0 -124
  352. package/dist/workflows/github-yaml.js +0 -506
  353. package/dist/workflows/runtime/run-outputs.js +0 -80
@@ -0,0 +1,471 @@
1
+ # Architecture: The Improvement Loop
2
+
3
+ ## Purpose and boundary
4
+
5
+ The improvement loop turns outcomes into ranking changes and reviewable proposals. This page is the
6
+ architecture-level reference for that loop — how a feedback signal becomes a
7
+ ranking change, how ranking and usage evidence become a proposal, and the
8
+ boundary around what AKM is allowed to write without a human or policy
9
+ reviewing the diff first.
10
+
11
+ The loop itself:
12
+
13
+ ```text
14
+ agent selects capability -> agent records outcome -> AKM updates utility and analyzes evidence ->
15
+ AKM creates a proposal -> human or policy reviews the diff -> accept / reject / revert
16
+ ```
17
+
18
+ The user-facing command surface for this loop (`akm feedback`, `akm log`,
19
+ `akm improve`, `akm proposal ...`) is documented in
20
+ [Improve the Library](../guides/improve-the-library.md) and
21
+ [CLI Reference](../reference/cli.md). This page covers the implementation
22
+ detail behind those commands: how utility moves, how strategies configure
23
+ what runs, what the autonomy gate does and does not allow, how sync happens
24
+ at the end of a run, and how session extraction fits in.
25
+
26
+ **Boundary:** `akm improve` (and its subprocesses — reflect, distill,
27
+ consolidate) never write asset files directly. The only durable artifact they
28
+ produce is a proposal row in `state.db`. The narrow set of writes that *are*
29
+ allowed to happen without review is enumerated below, under
30
+ [The autonomy gate](#the-autonomy-gate);
31
+ everything else routes through `akm proposal accept`.
32
+
33
+ ## Components
34
+
35
+ - **Utility policy** (`src/indexer/feedback/utility-policy.ts`) — pure
36
+ domain math that turns accumulated feedback counts into a new utility
37
+ score. No database access; unit-testable in isolation.
38
+ - **Strategies** (`src/commands/improve/improve-strategies.ts`,
39
+ `src/assets/improve-strategies/*.json`) — named presets that decide which
40
+ improve processes run and with what engine/model/limits.
41
+ - **Autonomy gate** (`src/commands/improve/autonomy-gate.ts`) — downgrades
42
+ the handful of processes that would otherwise mutate assets without review
43
+ (memory inference, memory cleanup, and a judged triage promote), unless
44
+ `experimental.improveAutonomy` is explicitly set.
45
+ - **Reflect / distill / consolidate subprocesses** — the improve pipeline's
46
+ proposal generators, invoked per asset (reflect, distill) or across the
47
+ whole memory corpus (consolidate). See
48
+ [Improve Workflow](internals/improve-workflow.md) for the full per-step
49
+ reference and flow diagram.
50
+ - **Proposal queue** (`state.db`) — written by `createProposal` (reflect,
51
+ distill, consolidate's promote operations, and the other proposal producers)
52
+ and by `createRetireProposal` (the pair pass's retire proposals).
53
+ - **Auto-sync** — the end-of-run commit/push step for git-backed bundles.
54
+ - **Session extraction** (`akm proposal extract`) — a separate entry point
55
+ that mines coding-agent session transcripts for durable insights and queues
56
+ them the same way.
57
+
58
+ ## Data flow
59
+
60
+ 1. An agent uses a capability and calls `akm feedback <ref> --positive|--negative`.
61
+ `--negative` is for content that is wrong or stale; a note that simply did
62
+ not fit the agent's task gets no feedback.
63
+ `--negative --reason "<what is wrong and what should change>"` flags the
64
+ asset: the next improve run may repair its frontmatter from the reason.
65
+ `--replace`/`--with`/`--source` attach an exact fix of its text once the
66
+ agent has verified the correct fact, which akm checks at once and queues as
67
+ a `feedback` proposal.
68
+ `--positive` records that the asset helped (it raises its ranking) and does
69
+ not trigger a rewrite.
70
+ 2. The feedback event is appended to `state.db`, and the asset's utility
71
+ score is updated immediately via the bounded-step formula (below) — no
72
+ reindex required.
73
+ 3. `akm improve` selects assets from the one bundle it writes to. A rewrite
74
+ (reflect) is planned only for an asset with negative feedback in the last
75
+ 30 days that is newer than the stage's last attempt, or for an explicit ref;
76
+ a positive or note-only signal never plans one, and neither does a negative whose exact fix has since been accepted as a `feedback` proposal. Distill reads any feedback
77
+ on a memory in that window, but skips a memory flagged wrong and not edited
78
+ since: a negative feedback in the window judged the body it still has (or,
79
+ recorded without that body's hash, is newer than its file's last write). It
80
+ also skips a memory whose only feedback in the window is positive with no
81
+ reason or note, which gives the writer nothing to distil (10 of the 11
82
+ lessons made from such memories were rejected). Unless
83
+ `--require-feedback-signal` is set, the
84
+ proactive-maintenance lane (where the strategy enables it, as `default`
85
+ does) adds the stable assets due for a revisit that the retrieval scope below
86
+ admits, and plans them with the feedback-bearing ones. At most `maxPerRun`
87
+ (15) assets are picked per run, an asset is due only if not reflected or
88
+ distilled for `dueDays` (30), and reflect's `limit` (25) bounds the run. It ranks the selected assets by salience, applies the limit, then
89
+ runs whichever processes the selected strategy enables against each one (see
90
+ [Improve Workflow](internals/improve-workflow.md#ledger-pre-filter-signal-delta)).
91
+ 4. Reflect and distill each emit at most one proposal per asset per run;
92
+ consolidate runs two passes alongside each other — the promote pass emits
93
+ a proposal turning a memory into knowledge (and, once accepted, retires
94
+ the source memory) unless a neighbouring `knowledge/` doc already covers
95
+ the memory, and it offers a memory whose promotion was accepted or
96
+ rejected, or that the model judged and left alone, again only after the
97
+ memory's body changes; the pair pass judges
98
+ near-duplicate and superseding pairs in the memory tier and emits a
99
+ `retire` proposal for the `duplicate`/`subsumed`/`supersedes` classes;
100
+ `overlap`, `unrelated` and `contradicts` are recorded as
101
+ `judged_no_action` with no proposal. The judge first lists the durable
102
+ claims each side alone holds, and a side with any listed claim is never
103
+ retired. Knowledge is never retired in favour of a memory: when the judge would
104
+ do that, the memory is retired in favour of the note if the memory lists no claim of its own,
105
+ and the pair is left alone otherwise. A retirement whose retired side lists nothing (a duplicate: neither
106
+ side), confirmed by a second look, is staged for the triage drain to accept; every other
107
+ retirement waits for a person.
108
+ 5. Every emitted proposal lands in the `proposals` table in `state.db`,
109
+ status `pending`.
110
+ 6. A human (via `akm proposal diff` / `accept` / `reject`) or a configured
111
+ drain policy (`akm proposal drain`) reviews and resolves each proposal. A
112
+ rejection is not final: `akm proposal reopen` puts a rejected proposal back
113
+ to `pending`.
114
+ 7. `akm proposal accept` promotes the proposal into the bundle; `akm proposal
115
+ revert` restores the prior content from the backup captured at promotion
116
+ time, if the proposal overwrote an existing asset. When the bundle is a git
117
+ repository (a `.git` directory, whatever its source kind), each accept is
118
+ committed as it happens, locally and with exactly the paths it wrote or
119
+ removed: `akm accept: <generator> <proposal-id-8> <ref>`. A retirement's
120
+ archived copy and tombstone, and the source memory a consolidate promotion
121
+ retires, go in the same commit. A commit that fails warns and the accept
122
+ stands.
123
+ 8. For a git-backed bundle, `akm improve`'s end-of-run auto-sync commits the
124
+ rest of the run's changes as a single batch and pushes (see below).
125
+
126
+ ## Current decisions
127
+
128
+ ### Utility scoring
129
+
130
+ Utility moves by the MemRL bounded-step EMA formula (arXiv:2601.03192),
131
+ implemented in `computeNextUtility` (`src/indexer/feedback/utility-policy.ts`):
132
+
133
+ ```text
134
+ reward = weighted average of positive (1.0) and negative (0.0) feedback in the batch
135
+ nextUtil = clamp(currentUtil + FEEDBACK_LR * (reward - currentUtil), 0, 1)
136
+ ```
137
+
138
+ `FEEDBACK_LR` is `0.1`, so a single feedback batch moves utility by at most
139
+ 0.1 in either direction regardless of how lopsided the batch is — `reward` is
140
+ a proportion of the counts, not their magnitude. When a previously
141
+ high-utility asset (utility ≥ 0.5) crosses back below 0.5, the update is
142
+ flagged as a review-threshold crossing so callers can escalate it. Decay is
143
+ time-proportional rather than tied to index frequency, and usage history
144
+ (and the utility it drives) is preserved across schema resets and full index
145
+ rebuilds — see [Architecture: Utility Scoring](architecture.md#utility-scoring)
146
+ for the storage-level summary.
147
+
148
+ ### Strategy inheritance
149
+
150
+ Improve presets live under `improve.strategies` (config) and the built-in
151
+ set: `default` and `consolidate` (`src/assets/improve-strategies/*.json`). The removed `quick`, `thorough`,
152
+ `catchup`, `reflect-distill` and `proactive-maintenance` still work as user-defined strategies. Selection
153
+ order is `--strategy`, then `defaults.improveStrategy`, then `default`.
154
+
155
+ Resolution is a two-step deep merge (`resolveImproveStrategy`): a named
156
+ built-in strategy is first merged onto the built-in `default` strategy, then
157
+ any user-defined override for that same name (under `improve.strategies` in
158
+ config) is merged on top. So a strategy — built-in or user-defined — that
159
+ omits a field, or an entire process block, inherits it from `default`; an
160
+ explicit `enabled: true`/`false` in the more specific layer always wins. This
161
+ is why, for example, `proactiveMaintenance` is on in `default` and off in
162
+ `consolidate`, and a preset that doesn't mention it at all inherits the
163
+ `default` value. A user-defined strategy named `proactive-maintenance` (the name
164
+ of the retired built-in) resolves the same way, merged onto `default`.
165
+
166
+ ### Retrieval scope
167
+
168
+ Improve reworks only what gets read (#986). Fresh feedback and an explicit ref
169
+ scope (`akm improve skills/x`) are usage evidence of their own. Every other
170
+ pick — the proactive-maintenance lane, and the memories consolidation judges — must be in the retrieval
171
+ scope (`src/commands/improve/retrieval-scope.ts`):
172
+
173
+ - **Retrieved:** a user-attributed `search`, `curate` or `show` returned the
174
+ asset, or user `feedback` named it, inside the window. A hit on a
175
+ `.derived` memory counts for its parent. Machine traffic (`improve`, `task`,
176
+ `audit`) does not count.
177
+ - **New material:** the file was written inside the window and no improve
178
+ stage has processed the asset — no `improve_ledger` row and no proposal from
179
+ any source but a capture (`extract`, `propose`, `remember`, `import`).
180
+
181
+ The window is the usage log's retention (`USAGE_EVENT_RETENTION_DAYS`, 90
182
+ days): the log keeps nothing older, and a shorter window would drop assets
183
+ read less often than it. There is no config key. Refs left out are counted by
184
+ the plan's `retrieval` gate and reported as the `not_retrieved` skip reason;
185
+ consolidation reports them in its warnings. A bulk rewrite of old files
186
+ (a rename, a lint fix, a fresh clone) makes them look new until improve has
187
+ processed each once.
188
+
189
+ ### Quality judge
190
+
191
+ Every reflect revision and every distilled lesson is scored by a judge before it
192
+ is queued (`runQualityJudge`, `src/commands/improve/stage.ts`): one call at
193
+ temperature 0, each criterion scored 1 to 5, failing closed (no runner, a
194
+ timeout, or an unparseable or incomplete reply never passes content and goes to
195
+ review). A reflect revision is scored on three criteria:
196
+
197
+ - **need**: does it fix a concrete problem in the source: something the
198
+ feedback reports as wrong or missing, a factual error, or broken, garbled,
199
+ truncated or missing text (frontmatter fields included)? A rewrite that only
200
+ rewords, restates or reformats a correct source, or adds headings, an
201
+ introduction or a table of contents, scores 1 or 2.
202
+ - **preservation**: does it keep every concrete fact, identifier, command, path,
203
+ number and example, without truncation?
204
+ - **quality**: is it coherent and accurate, with nothing the source or the
205
+ feedback does not support?
206
+
207
+ Content passes only when **every** criterion scores 4 or more (a lesson's
208
+ grounding is judged apart, see
209
+ [distill](internals/improve-workflow.md#distill-akmdistill)); a mean of 3.5
210
+ passed it before. A verdict that does not pass is a review when its mean is 2.5
211
+ or more and a rejection below that. The rubric and the rule were chosen on 90
212
+ labelled real rewrites, where judging on the mean let rewrites that only
213
+ reworded a correct asset through.
214
+
215
+ A reflect pass is stamped on the proposal as a `staged` decision from the
216
+ `quality-gate` with the per-criterion `scores` and the judge's `judgeReason`;
217
+ both stay on the proposal when the drain accepts it, so a later audit can read
218
+ why it passed (`akm proposal show --format json`). A distill pass is not staged:
219
+ the lesson or promotion is minted `deferred` for a person (reason
220
+ `distill-review`, same gate) with the same `scores` and `judgeReason`, and the
221
+ triage drain and its judgment tier leave it alone. A lesson that repeats an existing
222
+ lesson may instead be proposed as an update of that lesson (reason
223
+ `distill-update`, same gate), with only what the memory adds; the drain leaves
224
+ it for a person too. On 2026-10-05 the gate had
225
+ staged 12 lessons and 10 were bad (they restated the memory, claimed what it
226
+ does not say, or filed a dated status as a lesson), and no score separated them
227
+ from the two good ones. Reflect revises only an asset's
228
+ `description`, `when_to_use` and title, never its body. On 396 labelled edits,
229
+ those that fixed a frontmatter defect and left the body alone were good 24
230
+ times in 26, and those that also rewrote the body were bad 175 times in 224.
231
+
232
+ ### Judgment tier: promotions only
233
+
234
+ The triage drain's judgment tier (`processes.triage.judgment`, off in every
235
+ built-in strategy) may accept only a consolidate promotion, a memory proposed as
236
+ a new knowledge note. A retirement, an exact fix or a reflect revision it would
237
+ accept is left for a person (`judgment-not-promotion`); it may still reject.
238
+ Measured on the nightly eval with `experimental.improveAutonomy` (#1132, #1094),
239
+ judging every kind solved 0.49 (gpt-5.6-terra) and 0.53 (qwen3.8-27b) of the
240
+ items, harmed 14 and 11, and changed 18 and 21 notes outside the planted set.
241
+ Judging promotions alone: precision 0.87, recall 0.78 and 4.8% of bad promotions
242
+ accepted on qwen3.8-27b; precision 1.0, recall 0.17 on gpt-5.6-terra.
243
+
244
+ ### Proactive-lane proposals wait for a person
245
+
246
+ A proposal planned by the proactive-maintenance lane (`eligibilitySource:
247
+ "proactive"`, an asset with no feedback behind it) is never accepted by the
248
+ drain, whether a deterministic gate (a staged quality-judge pass), the judgment
249
+ tier or an accept staged by an earlier drain would take it. It is left for a
250
+ person with reason `proactive-needs-review`, and the judgment tier does not see
251
+ it. An empty diff is still rejected. Proposals driven by feedback (`signal-delta`,
252
+ `scope`) follow the one rule unchanged (#1147).
253
+
254
+ ### Retrieval regression gate
255
+
256
+ Reflect refuses a revision of an existing asset that grades lower on the
257
+ asset's own retrieval queries (#722, `src/commands/improve/retrieval-gate.ts`).
258
+ After the quality judge passes, up to five distinct user `search`/`curate`
259
+ queries that returned the asset (envelopes, the stash README line and inputs
260
+ over 2,000 characters dropped) are each graded 0–3 against the old and the new
261
+ content with the retrieval eval's prompt, `retrieval-relevance-judge.md`, and
262
+ its document shape: type, ref, name, description and the first 1,500 body
263
+ characters. A lower mean for the new content is a `quality_rejected` refusal
264
+ with the reflect rejection window. A grade that cannot be obtained refuses the
265
+ rewrite, as the quality judge fails closed. An asset with no such queries is
266
+ not graded.
267
+
268
+ The gate exists because it was measured first. Of 60 accepted reflect rewrites
269
+ (since 2026-07-01, stratified by lane) judged this way, 14 graded lower (23%,
270
+ 95% CI 14–35%) and 12 higher. Grading the same content twice flipped 11 of 174
271
+ query grades, which puts 3 of 60 rewrites in the "lower" bucket by noise
272
+ alone. The threshold for building it was fixed before judging: a lower bound of
273
+ at least 10%.
274
+
275
+ ### Retirement continuity
276
+
277
+ Before the consolidate pair pass mints a `retire` proposal (rule R3,
278
+ `src/commands/improve/consolidate/continuity-check.ts`), it replays up to five
279
+ of the retired asset's own past `search`/`curate` queries
280
+ (`loadRetrievalQueries`, the same cleaned set `../retrieval-gate.ts` replays
281
+ for the retrieval regression gate — boilerplate, harness/tool envelopes,
282
+ pastes and near-duplicates dropped before replay, S3a) through akm's own
283
+ search, in-process — the ranking a user actually gets, no LLM. For every
284
+ query where the retired asset ranked in the top 10, the successor must too
285
+ (N2: compared directly — search itself returns at most the top 10 hits, so
286
+ "ranked" and "absent from those hits" are the only two states there are, no
287
+ generic rank-change-report abstraction needed). An asset with no recorded
288
+ queries is not checked at all, and neither is a pair whose two bodies are
289
+ content-identical once whitespace is collapsed (S3b) — search's own
290
+ content-dedupe already hides the successor behind the retired asset for
291
+ every such query, so a "successor missing" finding there would not be a
292
+ real risk.
293
+
294
+ A failing pair still mints — the check flags, it never blocks — but the
295
+ proposal carries `continuityRisk` in its retirement metadata: the failing
296
+ query count and the rank pairs, visible in `akm proposal show`/`list`/`diff`. A
297
+ flagged proposal is excluded from every bulk accept path (`accept
298
+ --generator …`, with or without `--yes`); a person can still accept it by id.
299
+ Bulk *reject* is unaffected, since declining a flagged proposal is always the
300
+ safe direction.
301
+
302
+ A query that never ran (the search call threw) or that fell back to
303
+ keyword-only ranking instead of the real one (`mode: "fts-fallback"` — most
304
+ often a down or unreachable embedding endpoint) is "unverified": it is never
305
+ compared for rank at all, and on its own it is enough to set
306
+ `continuityRisk` (`unverifiedQueries` alongside the usual `ranks`), so an
307
+ endpoint outage reads as "risk unknown," never as the silent "no risk
308
+ found" a search that quietly used a degraded ranking would otherwise
309
+ produce. Once any query in a pair-pass run falls back, every later query in
310
+ that same run skips the semantic attempt entirely and goes straight to
311
+ keyword-only — a dead endpoint costs one failed attempt for the whole run,
312
+ not one per remaining query.
313
+
314
+ This check replaces the old per-run forgetting-safety lane (a one-time WS-1
315
+ cutover guard that compared improve's own salience ranking before and after
316
+ each run). The 30-day event window showed it made no pick the signal-delta
317
+ lane or the retrieval scope would not also have made, and it protected
318
+ `asset_salience.rank_score`, which only improve itself ever read — a rank drop
319
+ could not hide anything from search. `forgetting-safety` stays a valid
320
+ `eligibilitySource`/event-type value so old proposals and events still decode,
321
+ but nothing assigns or emits it any more.
322
+
323
+ ### Dry-run planning boundary
324
+
325
+ Dry and live improve runs call the same selectors for signal-delta eligibility,
326
+ the proactive-maintenance lane, the retrieval scope, salience ranking, disk presence, and the
327
+ final cap, and resolve the bundle they plan the same way: `--bundle`, else
328
+ `defaultWriteTarget`, else the working bundle (`AKM_BUNDLE_DIR`, else
329
+ `defaultBundle`). Each invocation reports a best-effort observation assembled
330
+ while it runs; it is not an atomic cross-store snapshot, a reservation, or a
331
+ durable frozen plan. A later live invocation re-inspects mutable index, state,
332
+ filesystem, and session-log inputs and can therefore differ from an earlier
333
+ dry preview. Given equivalent observed inputs, both paths produce the same
334
+ selection. The public schema-v2 result projects the observation as `plan`: raw
335
+ in-scope count, each gate's removals, configured and effective limits, final
336
+ ranked refs with lane attribution, proactive due statistics, consolidation
337
+ pool/delta/minimum gates and chunk estimate, maintenance-stage decisions,
338
+ triage mode/caps, and the read-side index snapshot status. `plannedRefs` means
339
+ the effective post-limit work set in both modes.
340
+
341
+ The dry path stops at that projection boundary. It may read indexed assets,
342
+ the filesystem, and an existing `state.db`, but opens state read-only and does
343
+ not create it when absent. It does not acquire the improve lock or write the
344
+ index, state, events, proposals, assets, cache, sync journal, or persisted run
345
+ result, and it never dispatches an LLM. SQLite inputs are inspected through
346
+ disposable main/WAL copies so even a held source SHM file is not touched.
347
+ Consolidation pool inspection and the extract `minNewSessions` gate use shared
348
+ zero-LLM selectors, while live execution re-inspects mutable inputs immediately
349
+ before dispatch. A missing index or one without the current `entries` table
350
+ yields an explicit empty `plan.snapshot` (`missing` or `incompatible`) rather
351
+ than creating or migrating the database.
352
+
353
+ `plan.limits.effective` is the cap on the refs a run dispatches, resolved from
354
+ `--limit`, then the reflect process's `limit`, then the strategy's `limit`. The
355
+ replay lane is retired, so `additiveReplayAllowance` is always `0` (the field
356
+ stays so the schema-v2 plan shape keeps validating) and a finite `totalCeiling`
357
+ equals `effective`. When the run is unbounded, `totalCeiling` is omitted.
358
+
359
+ ### The autonomy gate
360
+
361
+ `akm improve` runs by default and is review-first: reflect, distill, extract
362
+ candidates, validation, and proactive-maintenance selection are proposal-only
363
+ and never write assets directly regardless of this gate.
364
+ Three specific lanes *would* mutate assets without review and are downgraded
365
+ unless `experimental.improveAutonomy` is explicitly set to `true` (the triage
366
+ lane only when its judgment tier is on; see below):
367
+
368
+ | Lane | What it does when enabled | With autonomy off |
369
+ | --- | --- | --- |
370
+ | `memoryInference` | Writes `.derived.md` children and rewrites parent frontmatter | disabled |
371
+ | memory cleanup | Belief-state frontmatter rewrites, archive moves | analyzed but not applied |
372
+ | `triage` `applyMode: "promote"` **with judgment on** | The judgment tier auto-accepts consolidate promotions into the bundle | downgraded to `queue` — triage still runs, it just does not auto-accept |
373
+
374
+ A deterministic-only `promote` (triage with judgment off) is not gated (#1143):
375
+ the `default` strategy drains the queue through the deterministic gates, up to
376
+ `maxAcceptsPerRun` (25) per run, with no opt-in. The nightly eval's baseline is
377
+ exactly this path (`proposal drain --promote` without judgment): 0.91 (terra) and
378
+ 0.89 (qwen) of items solved, 0 to 1 harmed.
379
+
380
+ Every downgrade is reported, not silent: it warns on stderr, appends an
381
+ `improve_skipped` event with `reason: "autonomy_gated"`, and is counted in
382
+ `akm health`'s improve skip-reason summary. Consolidation stays enabled with
383
+ autonomy off: both its passes only ever emit a reviewable proposal. The one
384
+ pair-pass `retire` proposal `triage` `applyMode: "promote"` accepts is a
385
+ retirement the pair pass staged (nothing unique to the retired side, confirmed
386
+ by a second look, no continuity risk); every other one waits for `akm proposal accept`. An absent `experimental`
387
+ section, an absent key, and an explicit `false` all read identically as off —
388
+ autonomy is never inferred. `akm proposal drain --promote` is a second,
389
+ explicit promote surface independent of this gate.
390
+
391
+ ### Auto-sync
392
+
393
+ For git-backed bundles (detected by a `.git` directory), `akm improve`
394
+ automatically commits its changes as a single batch at the end of the run —
395
+ the same operation as `akm sync` — and pushes if the bundle is writable, per
396
+ the active strategy's `sync` setting. A user-defined strategy can turn sync off, so an interrupted run
397
+ does not leave an uncommitted backlog. `--no-sync` disables sync for a single
398
+ run; `--no-push` commits without pushing. Strategy sync behavior is
399
+ configured via the `sync` block under `improve.strategies.<name>`.
400
+
401
+ The sync always commits the paths it is given. A branch it cannot push (no
402
+ upstream branch, or behind or diverged from its upstream) only skips the push,
403
+ and the result says why: `sync.reason` reads `not pushed: ...`. A branch that is
404
+ ahead of its upstream, as it is after the accept commits above, is pushed with
405
+ the sync commit. A clean tree that is ahead is not pushed: the sync pushes what
406
+ it commits.
407
+
408
+ The commit is scoped by **write provenance**, not by directory: every akm write
409
+ path records the file it mutated into a run-scoped journal
410
+ (`src/core/write-provenance.ts`), and the end-of-run sync stages exactly the
411
+ journaled paths that Git still reports as changed. A file someone else edits
412
+ under a managed directory while the run is in flight is therefore left dirty for
413
+ its author, while a file that was already dirty when the run started and was
414
+ then rewritten by the run IS committed. Deletions are journaled like writes, so
415
+ the final on-disk state is what lands — a path written and then reverted or
416
+ purged produces no commit at all. The run reports its journal as
417
+ `writtenPaths` on the improve result. Callers that supply no explicit path list
418
+ (`akm sync`, `akm push`) keep the managed-pathspec fallback in `saveGitStash`.
419
+
420
+ ### Archive purge
421
+
422
+ A retirement's archived bytes (`.akm/memory-cleanup/archive/<stamp>-<ref>/`)
423
+ are not deleted at accept time — only the tombstone (`cleanup.md`) resolves
424
+ the ref going forward. `purgeGracedArchive`
425
+ (`src/commands/improve/memory/memory-improve.ts`) sweeps them later: run once
426
+ at the very start of every `akm improve` invocation, deterministic, no LLM,
427
+ before index bootstrap or triage. For a git-backed bundle, it deletes the
428
+ archived asset file(s) — never `cleanup.md` — of every retirement whose
429
+ tombstone `retiredAt` is more than 30 days old (`RETIRE_GRACE_DAYS`) AND
430
+ whose archive directory is entirely git-tracked and clean (`git ls-files`
431
+ plus `git status --porcelain -uall`, both checked once per sweep, not once
432
+ per directory). `.git` presence alone does not guarantee a retirement was
433
+ ever committed: an accept commits its own paths (`commitAcceptedPaths` in
434
+ `src/core/write-source.ts`), on a `kind: "filesystem"` source with a `.git`
435
+ directory too, but a commit that failed only warned, and a retirement accepted
436
+ by an older akm left archived bytes sitting on disk with no commit behind them
437
+ at all. A directory with even one untracked or modified file (the tombstone
438
+ included) is left whole for a later sweep, so the purge only ever removes
439
+ bytes git can already recover. Every deleted path is journaled individually,
440
+ so the end-of-run auto-sync commits the removal the same way it commits the
441
+ archive move itself. A bundle with no `.git` of its own has no history to
442
+ fall back on, so its archive is left untouched — `akm health` reports its
443
+ size and file count instead (`memory-cleanup-archive` advisory,
444
+ `src/commands/health/archive-usage.ts`).
445
+
446
+ ### Session extraction
447
+
448
+ `akm proposal extract` is the standalone entry point for mining coding-agent
449
+ session transcripts (`--type claude`, `--type codex`, `--type opencode`, or
450
+ `--auto` to iterate every harness with a detectable session-log location) into
451
+ proposals.
452
+ It replaced the legacy session-checkpoint hook and runs independently of
453
+ whether a strategy's own `processes.extract` stage is enabled — no shipped
454
+ strategy turns that improve-stage extraction on, and a direct
455
+ `akm proposal extract --type <harness>` or `--auto` invocation is never gated
456
+ by that toggle. Session indexing writes are additive
457
+ (`sessions/**`), which is why they are one of the writes left deliberately
458
+ ungated by the autonomy gate above.
459
+
460
+ ## See also
461
+
462
+ - [Improve the Library](../guides/improve-the-library.md) — the user-facing
463
+ command guide for this loop
464
+ - [Improve Workflow](internals/improve-workflow.md) — full per-step reference
465
+ and flow diagram for reflect/distill/consolidate
466
+ - [Architecture](architecture.md) — system-wide architecture summary,
467
+ including the Utility Scoring and Writing to Sources sections
468
+ - [Configuration Reference — Strategies](../reference/configuration.md#strategies)
469
+ and [Experimental opt-ins](../reference/configuration.md#experimental-opt-ins)
470
+ - [STABILITY.md](../../STABILITY.md#akm-improve-autonomy--opt-in-in-090) — the
471
+ normative autonomy-gate contract
@@ -0,0 +1,154 @@
1
+ # Classification System
2
+
3
+ akm recognizes files through **bundle adapters**. Each adapter owns a bundle
4
+ format and exposes a `recognize()` primitive that inspects a single file (path +
5
+ frontmatter + content) and returns an `IndexDocument` — the item's
6
+ subdir-qualified `conceptId`, type, renderer, and metadata — or `null` if the
7
+ adapter does not claim the file. There is no longer a global matcher registry;
8
+ the per-format adapter is the unit of recognition.
9
+
10
+ ## Built-in adapters
11
+
12
+ The registry is a **static frozen list** (`BUILTIN_ADAPTERS` in
13
+ `src/core/adapter/adapters/index.ts`, exposed through
14
+ `src/core/adapter/registry.ts`) — always populated at module load, no
15
+ registration call required. Eleven built-ins, in probe order:
16
+
17
+ | Adapter id | Format | Recognizes |
18
+ | --- | --- | --- |
19
+ | `website-snapshot` | Crawled website snapshot bundle (read-only) | snapshot pages |
20
+ | `agent-skills` | Agent-skills package (root `SKILL.md`) | skills |
21
+ | `claude` | A `.claude/` tool directory | commands, agents, skills, settings-adjacent files |
22
+ | `opencode` | An `.opencode/` tool directory | commands, agents, skills |
23
+ | `dotenv` | Env-file bundle | env/secret whole-file assets (values never indexed) |
24
+ | `akm-workflow` | Workflow-dir component | workflow programs |
25
+ | `akm-task` | Task-dir component | scheduled task definitions |
26
+ | `llm-wiki` | LLM Wiki bundle | a wiki root (`schema.md` + `pages/`) and its pages, raw, xrefs, citations |
27
+ | `akm` | The classic AKM bundle layout | scripts, skills, commands, agents, knowledge, instructions, workflows, memories, lessons, env, secrets, facts, tasks, sessions |
28
+ | `okf` | Open Knowledge Format bundle | OKF concept documents of any open type |
29
+ | `generic-files` | Catch-all file mount | explicit configuration only — never auto-probed |
30
+
31
+ `looksLikeRoot` probes run most-specific-first in the list order above; the
32
+ first match wins and the winner is recorded per component. A root matching no
33
+ probe falls back to `akm` (see `FALLBACK_ADAPTER_ID` in
34
+ `src/indexer/installations.ts`).
35
+ `generic-files` never participates in probing.
36
+
37
+ Configured adapter ownership wins over probing. `akm add` records the detected
38
+ adapter so later indexing does not reinterpret a bundle. The broad OKF probe
39
+ also recognizes index-less typed Markdown, but strong AKM layout evidence runs
40
+ first because AKM Markdown is an OKF-compatible superset.
41
+
42
+ See [Bundle Types](../../reference/bundle-types.md) for the user-facing detail
43
+ per adapter — conceptId/ref shape, what's indexed, `validate()` checks, and
44
+ read/write status in 0.9.0.
45
+
46
+ ## Item types
47
+
48
+ `type` is an open descriptive string. The core accepts every non-empty value;
49
+ the owning adapter decides whether a value receives specialized behavior. The
50
+ `akm` adapter emits its fourteen defined native types (`script`, `skill`,
51
+ `command`, `agent`, `knowledge`, `instruction`, `workflow`, `memory`,
52
+ `lesson`, `env`, `secret`, `fact`, `task`, `session`) — see
53
+ [Bundle Types](../../reference/bundle-types.md) for the full
54
+ purpose / agent-output table per type.
55
+
56
+ `wiki` is **no longer an item type**. Multi-page wikis are a bundle *format* owned
57
+ by the `llm-wiki` adapter, not a per-file type stamped by the classifier.
58
+
59
+ ## Reserved structural files
60
+
61
+ `index.md` and `log.md` are reserved structural files for the `akm`, `okf`, and
62
+ `llm-wiki` adapters. OKF defines their meaning in OKF bundles; AKM and LLM Wiki
63
+ reserve the same names under their own format contracts. Other adapters own
64
+ their reserved-name rules.
65
+
66
+ ## Adapter-owned filtering (AKM sensitive/infra abstention)
67
+
68
+ Each adapter decides which walked files it claims and which it abstains on — the
69
+ core always excludes VCS internals and symlink escapes. An OKF walk includes
70
+ ordinary dot directories and `bin/` because those paths can identify conformant
71
+ concepts; AKM keeps its existing cache/dot-directory hygiene. The `akm`
72
+ adapter's `recognize` abstains (returns `null`) on its own bundle's
73
+ non-content files, using **path/stat checks only** so the bytes of sensitive files
74
+ are never read to make the decision:
75
+
76
+ - an `env/…` `.env` file that has a sibling `.sensitive` marker;
77
+ - anything under the frozen legacy `vaults/` directory (the `vault` type was
78
+ removed in 0.9.0);
79
+ - a `secrets/` `.sensitive`/`.lock` marker, or a secret with a sibling
80
+ `<name>.sensitive` marker;
81
+ - a `wikis/<name>/` root-level infrastructure file (`schema.md`/`index.md`/`log.md`).
82
+
83
+ This policy previously lived in the indexer's `shouldIndexStashFile` pre-filter; it
84
+ now lives in the adapter (`akmStashAbstains` in
85
+ `src/core/adapter/adapters/akm-adapter.ts`), so each adapter owns its own bundle's
86
+ filtering (owner ruling 2026-07-21).
87
+
88
+ ## The akm adapter's recognition signals
89
+
90
+ Inside the `akm` adapter, recognition picks a winner by **specificity descending**,
91
+ ties broken by registration order (later wins). The signals:
92
+
93
+ | Specificity | Signal | Result |
94
+ | --- | --- | --- |
95
+ | 25 | `SKILL.md` (skill directory) | `skill` |
96
+ | 20 | `tools` frontmatter | `agent` |
97
+ | 19 | workflow markdown structure | `workflow` |
98
+ | 18 | command frontmatter / `$ARGUMENTS` body placeholders | `command` |
99
+ | 15 | immediate parent dir hint | directory-specific type |
100
+ | 10 | ancestor dir hint | directory-specific type |
101
+ | 8 | `model` frontmatter only | weak `agent` signal |
102
+ | 5 | fallback markdown | `knowledge` |
103
+ | 3 | known script extension | `script` |
104
+
105
+ ### Directory signals
106
+
107
+ - `scripts/` → `script`
108
+ - `skills/` → `skill`
109
+ - `commands/` → `command`
110
+ - `agents/` → `agent`
111
+ - `knowledge/` → `knowledge`
112
+ - `workflows/` → `workflow`
113
+ - `memories/` → `memory`
114
+ - `lessons/` → `lesson`
115
+ - `env/` → `env`
116
+ - `secrets/` → `secret`
117
+ - `tasks/` → `task`
118
+
119
+ ### Markdown signals
120
+
121
+ | Signal | Type | Specificity |
122
+ | --- | --- | --- |
123
+ | `tools` in frontmatter | `agent` | 20 |
124
+ | workflow heading/step structure | `workflow` | 19 |
125
+ | `agent` in frontmatter | `command` | 18 |
126
+ | `$ARGUMENTS` or `$1`-`$3` in body | `command` | 18 |
127
+ | `model` in frontmatter only | `agent` | 8 |
128
+ | any other `.md` | `knowledge` | 5 |
129
+
130
+ ## Asset quality values
131
+
132
+ The `quality` field marks how an item was produced. Four values are well-known:
133
+
134
+ | Value | Meaning |
135
+ | --- | --- |
136
+ | `"generated"` | Heuristically indexed; included in default search |
137
+ | `"curated"` | Human-authored; included in default search |
138
+ | `"enriched"` | Retired LLM enrichment pass (0.9.17-alpha.9) ran for this item; included in default search |
139
+ | `"proposed"` | Pending review; excluded from default search, opt-in via `--include-proposed` |
140
+
141
+ Unknown string values warn once at runtime and remain searchable.
142
+
143
+ ## Examples
144
+
145
+ | File | Winning signal | conceptId |
146
+ | --- | --- | --- |
147
+ | `scripts/deploy.sh` | parent dir (15) → `script` | `scripts/deploy.sh` |
148
+ | `skills/review/SKILL.md` | `SKILL.md` (25) → `skill` | `skills/review` |
149
+ | `commands/release.md` with `agent: coder` | command frontmatter (18) | `commands/release` |
150
+ | `agents/reviewer.md` with `tools:` | frontmatter (20) → `agent` | `agents/reviewer` |
151
+ | `workflows/release.md` with workflow structure | structure (19) → `workflow` | `workflows/release` |
152
+ | `env/prod.env` | parent dir (15) → `env` | `env/prod` |
153
+ | `secrets/deploy-token` | parent dir (15) → `secret` | `secrets/deploy-token` |
154
+ | `docs/guide.md` | fallback (5) → `knowledge` | `knowledge/guide` |
@@ -0,0 +1,40 @@
1
+ # Fresh-Host Rebuild Runbook
2
+
3
+ Rebuild a working akm install on a new machine. Assumes your bundle lives in a
4
+ git remote and that a versioned `config.json` copy is committed to the bundle
5
+ git (the 08-F1 recovery pattern — see step 3).
6
+
7
+ 1. **Install the CLI.** Prebuilt binary (no runtime needed):
8
+ `curl -fsSL https://github.com/itlackey/akm/releases/latest/download/install.sh | bash`
9
+ — or npm package (Node.js >= 22 required): `npm install -g akm-cli`.
10
+ If a working Bun >= 1.0 is also on `PATH`, the package prefers it after Node
11
+ bootstrap; old, unusable, or absent Bun installations fall back to Node.js.
12
+ The standalone binary is runtime-free.
13
+ (Windows: `irm https://github.com/itlackey/akm/releases/latest/download/install.ps1 | iex`.)
14
+ 2. **Confirm the binary resolves:** `akm --version`.
15
+ 3. **Restore `config.json`.** akm reads a single user config at
16
+ `~/.config/akm/config.json` (`%APPDATA%\akm\config.json` on Windows;
17
+ override with `AKM_CONFIG_DIR`). This file is gitignored on the host, so the
18
+ recovery source is the ONE versioned copy committed to the bundle git
19
+ (08-F1 pattern). Copy that file into place; it carries named `engines`,
20
+ `defaults.engine` / `defaults.llmEngine`, and cron-load-bearing improve
21
+ strategies that are otherwise unrecoverable.
22
+ 4. **Provide secrets/env.** `config.json` references API keys via `${VAR}`
23
+ placeholders; export those environment variables (or restore your env/secret
24
+ assets) so named engines and the embedding connection resolve. Never commit
25
+ the resolved values.
26
+ 5. **Restore the working bundle.** Clone your bundle git remote to the path
27
+ named by your working bundle's entry under `bundles` in the restored
28
+ config (`defaultBundle` selects which one; default path `~/akm`). There is
29
+ no top-level `stashDir` config key in 0.9 — it is retired and rejected at
30
+ load. If starting clean instead, run `akm setup --yes` to scaffold it.
31
+ 6. **Re-add non-git sources.** For each managed source not carried in the bundle
32
+ git (websites, npm packages, GitHub repos), run `akm bundle add <ref>`. Verify the
33
+ full set with `akm bundle list`.
34
+ 7. **Rebuild the index:** `akm index --full` (forces a complete reindex rather
35
+ than an incremental update).
36
+ 8. **Verify health:** `akm health` (checks runtime, artifacts, and improve
37
+ metrics — exits non-zero if `state.db` is missing) and `akm info` for index
38
+ stats and effective config.
39
+ 9. **Smoke-test discovery:** `akm search <term>` returns results, confirming the
40
+ index and bundle are wired correctly.