akm-cli 0.9.0-beta.2 → 0.9.0-beta.26

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 (111) hide show
  1. package/CHANGELOG.md +614 -0
  2. package/dist/assets/prompts/consolidate-system.md +23 -0
  3. package/dist/assets/prompts/contradiction-judge.md +33 -0
  4. package/dist/assets/prompts/distill-knowledge-system.md +22 -0
  5. package/dist/assets/prompts/distill-lesson-system.md +36 -0
  6. package/dist/assets/prompts/extract-session.md +5 -1
  7. package/dist/assets/prompts/graph-extract-system.md +1 -0
  8. package/dist/assets/prompts/memory-infer-system.md +1 -0
  9. package/dist/assets/prompts/memory-infer-user.md +5 -0
  10. package/dist/assets/prompts/metadata-enhance-system.md +1 -0
  11. package/dist/assets/prompts/procedural-system.md +44 -0
  12. package/dist/assets/prompts/recombine-system.md +40 -0
  13. package/dist/assets/prompts/staleness-detect-system.md +6 -0
  14. package/dist/assets/prompts/validate-summary-judge.md +1 -0
  15. package/dist/assets/templates/html/default.html +78 -0
  16. package/dist/assets/templates/html/health.html +730 -0
  17. package/dist/assets/templates/html/vendor/echarts.min.js +45 -0
  18. package/dist/cli/shared.js +21 -5
  19. package/dist/cli.js +47 -5
  20. package/dist/commands/agent/contribute-cli.js +16 -3
  21. package/dist/commands/feedback-cli.js +15 -6
  22. package/dist/commands/graph/graph.js +75 -71
  23. package/dist/commands/health/checks.js +48 -0
  24. package/dist/commands/health/html-report.js +790 -0
  25. package/dist/commands/health.js +478 -15
  26. package/dist/commands/improve/calibration.js +161 -0
  27. package/dist/commands/improve/consolidate.js +634 -111
  28. package/dist/commands/improve/dedup.js +482 -0
  29. package/dist/commands/improve/distill.js +145 -69
  30. package/dist/commands/improve/encoding-salience.js +205 -0
  31. package/dist/commands/improve/extract-cli.js +115 -1
  32. package/dist/commands/improve/extract-prompt.js +33 -2
  33. package/dist/commands/improve/extract-watch.js +140 -0
  34. package/dist/commands/improve/extract.js +280 -35
  35. package/dist/commands/improve/feedback-valence.js +54 -0
  36. package/dist/commands/improve/homeostatic.js +467 -0
  37. package/dist/commands/improve/improve-auto-accept.js +139 -6
  38. package/dist/commands/improve/improve-profiles.js +12 -0
  39. package/dist/commands/improve/improve.js +1851 -515
  40. package/dist/commands/improve/memory/memory-contradiction-detect.js +23 -28
  41. package/dist/commands/improve/outcome-loop.js +256 -0
  42. package/dist/commands/improve/proactive-maintenance.js +87 -0
  43. package/dist/commands/improve/procedural.js +409 -0
  44. package/dist/commands/improve/recombine.js +488 -0
  45. package/dist/commands/improve/reflect-noise.js +0 -0
  46. package/dist/commands/improve/reflect.js +51 -1
  47. package/dist/commands/improve/related-sessions.js +120 -0
  48. package/dist/commands/improve/salience.js +386 -0
  49. package/dist/commands/improve/triage.js +95 -0
  50. package/dist/commands/lint/agent-linter.js +19 -24
  51. package/dist/commands/lint/base-linter.js +173 -60
  52. package/dist/commands/lint/command-linter.js +19 -24
  53. package/dist/commands/lint/env-key-rules.js +34 -1
  54. package/dist/commands/lint/index.js +30 -13
  55. package/dist/commands/lint/memory-linter.js +1 -1
  56. package/dist/commands/lint/registry.js +5 -2
  57. package/dist/commands/lint/task-linter.js +3 -3
  58. package/dist/commands/lint/workflow-linter.js +26 -1
  59. package/dist/commands/proposal/drain.js +73 -6
  60. package/dist/commands/proposal/proposal-cli.js +22 -10
  61. package/dist/commands/proposal/proposal.js +17 -1
  62. package/dist/commands/proposal/validators/proposals.js +369 -329
  63. package/dist/commands/read/curate.js +294 -79
  64. package/dist/commands/read/search-cli.js +7 -0
  65. package/dist/commands/read/search.js +1 -0
  66. package/dist/commands/remember.js +6 -2
  67. package/dist/commands/sources/installed-stashes.js +5 -1
  68. package/dist/commands/sources/stash-cli.js +10 -2
  69. package/dist/core/asset/frontmatter.js +166 -167
  70. package/dist/core/asset/markdown.js +8 -0
  71. package/dist/core/config/config-schema.js +241 -0
  72. package/dist/core/config/config.js +2 -2
  73. package/dist/core/logs-db.js +305 -0
  74. package/dist/core/paths.js +3 -0
  75. package/dist/core/state-db.js +706 -42
  76. package/dist/indexer/db/db.js +347 -38
  77. package/dist/indexer/db/graph-db.js +81 -86
  78. package/dist/indexer/ensure-index.js +152 -17
  79. package/dist/indexer/graph/graph-boost.js +51 -41
  80. package/dist/indexer/index-writer-lock.js +99 -0
  81. package/dist/indexer/indexer.js +114 -111
  82. package/dist/indexer/passes/memory-inference.js +71 -25
  83. package/dist/indexer/passes/staleness-detect.js +2 -5
  84. package/dist/indexer/search/db-search.js +15 -4
  85. package/dist/indexer/search/ranking.js +4 -0
  86. package/dist/integrations/harnesses/claude/session-log.js +27 -5
  87. package/dist/integrations/harnesses/opencode/session-log.js +9 -0
  88. package/dist/integrations/session-logs/index.js +16 -0
  89. package/dist/llm/client.js +38 -4
  90. package/dist/llm/embedder.js +27 -3
  91. package/dist/llm/embedders/local.js +66 -2
  92. package/dist/llm/graph-extract.js +2 -1
  93. package/dist/llm/memory-infer.js +4 -8
  94. package/dist/llm/metadata-enhance.js +9 -1
  95. package/dist/llm/usage-persist.js +77 -0
  96. package/dist/llm/usage-telemetry.js +103 -0
  97. package/dist/output/context.js +3 -2
  98. package/dist/output/html-render.js +73 -0
  99. package/dist/output/shapes/curate.js +14 -2
  100. package/dist/output/shapes/helpers.js +17 -1
  101. package/dist/output/text/helpers.js +78 -1
  102. package/dist/runtime.js +25 -1
  103. package/dist/scripts/migrate-storage.js +1194 -607
  104. package/dist/scripts/migrations/import-fs-improve-runs-to-db.js +455 -270
  105. package/dist/sources/providers/tar-utils.js +16 -8
  106. package/dist/storage/sqlite-pragmas.js +146 -0
  107. package/dist/tasks/runner.js +99 -16
  108. package/dist/workflows/db.js +5 -2
  109. package/dist/workflows/validate-summary.js +2 -7
  110. package/docs/data-and-telemetry.md +1 -0
  111. package/package.json +7 -5
package/CHANGELOG.md CHANGED
@@ -6,6 +6,459 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.0-beta.26] — 2026-06-20
10
+
11
+ ### Added
12
+
13
+ - **#628 — configurable SQLite journal mode (`AKM_SQLITE_JOURNAL_MODE`) for network
14
+ filesystems.** AKM previously opened every database with `PRAGMA journal_mode = WAL`
15
+ unconditionally, which cannot run on a network filesystem (NFS/SMB/Azure Files) —
16
+ WAL's `-shm` shared-memory wal-index can't be `mmap`'d over a network mount. You can
17
+ now set `AKM_SQLITE_JOURNAL_MODE` to `WAL` (default), `DELETE`, or `TRUNCATE`, applied
18
+ at **all five** db openers (`state.db`, `index.db` ×2 paths, `workflow.db`, `logs.db`).
19
+ At the `WAL` default AKM auto-detects a network mount for the data dir and transparently
20
+ falls back to `DELETE` (rollback journal + `synchronous = FULL`) with a one-line warning;
21
+ invalid values warn once and fall back to `WAL`. **Default behavior is byte-identical.**
22
+ This lets the AKM database subtree live on a shared volume (e.g. Azure Files under
23
+ Azure Container Apps). New docs section "Hosting AKM databases on a network share
24
+ (NFS/SMB)" in `docs/configuration.md`.
25
+
26
+ ## [0.9.0-beta.25] — 2026-06-19
27
+
28
+ Completes the recombine / extract-efficiency / graph thread. All new improve
29
+ passes are **opt-in (default off)**, so default behavior is unchanged.
30
+
31
+ ### Added
32
+
33
+ - **#606 — event-driven extract (`akm extract --watch`).** Opt-in watch mode: an
34
+ injectable, debounced watcher triggers extraction shortly after a session file
35
+ appears, with a clean `stop()` handle. The `8,28,48` cron remains the fallback;
36
+ no daemon is auto-launched.
37
+ - **#625 — recombine second pass (hypothesis → lesson).** The opt-in `recombine`
38
+ process (#609) now consumes `confirmThreshold` (default 2): a generalization
39
+ re-induced that many consecutive runs is promoted from a `type: hypothesis`
40
+ proposal to a `type: lesson` proposal through the normal queue + quality gate
41
+ (never a direct stash write). Hypotheses that stop recurring decay. Backed by a
42
+ new `recombine_hypotheses` table in `state.db`.
43
+
44
+ ### Changed
45
+
46
+ - **#624 (P1) — graph storage decoupled from `entries.id`.** `graph_files` is
47
+ re-keyed on `(stash_root, file_path, body_hash)`, so extracted graph data now
48
+ **survives a reindex** of unchanged files instead of being cascade-wiped. The
49
+ upgrade is migrated in a **targeted, graph-only path** that preserves existing
50
+ graph data and leaves the entry index, embeddings, FTS, and LLM-enrichment cache
51
+ untouched — **no full index rebuild and no re-embed** on upgrade. (P2 priority-
52
+ ranked extraction and P3 lazy/on-demand extraction remain deferred.)
53
+
54
+ ### Fixed
55
+
56
+ - Graph re-key migration no longer triggers a destructive full-index rebuild: it
57
+ is a graph-scoped table migration (no `DB_VERSION` bump), and it **copies** the
58
+ existing graph rows into the new schema rather than dropping them.
59
+ - Test-suite `/tmp` hygiene: sandbox teardown now fires on `SIGINT`/`SIGTERM`/
60
+ `SIGHUP` (not just clean exit), and a `sweep:tmp` step reclaims stale `akm-*`
61
+ sandbox dirs left by force-killed workers — eliminating the tmpfs accumulation
62
+ that caused intermittent `EEXIST: epoll_ctl` test flakes.
63
+
64
+ ## [0.9.0-beta.20] — 2026-06-18
65
+
66
+ ### Fixed
67
+
68
+ - **`akm update --all` no longer fails for writable `github:` entries stored as `source:"git"`**. `updateRegistryEntry` was using `synced.source` (re-derived from the ref scheme as `"github"`) instead of the existing `entry.source`, causing the config validator to reject `writable:true` on every update cycle.
69
+
70
+ ## [0.9.0-beta.19] — 2026-06-17
71
+
72
+ ### Fixed
73
+
74
+ - **`akm feedback` now completes in ~0.3s** (was 3+ minutes). Root cause: the command was calling `ensureIndex` with `mode: "blocking"` inside `withIndexWriterLease`, triggering a full reindex on every feedback call. Fix: removed the `ensureIndex` call entirely (feedback only needs the index to exist, not be current — a stale index is fine for ref lookup); removed the application-level writer lock (SQLite WAL + `busy_timeout=30s` handles concurrent access with `akm improve`); added a fast DB-exists guard with a clear error for first-time users.
75
+ - **`akm health --format html` now completes in ~11s** (was ~18s). Root cause: `akmHealth()` was called twice — once for the main result and once to get `deltas`. Fix: merged into a single call passing both `groupBy: "run"` and `windowCompare` together.
76
+
77
+ ## [0.9.0-beta.18] — 2026-06-17
78
+
79
+ ### Changed
80
+
81
+ - **Health report: Recent Runs table now shows all filtered runs in descending order** (newest first) instead of capping at the last 10.
82
+ - **Health report: Removed "Command Set Used" section.**
83
+ - **Health report: All timestamps now display in the viewer's local timezone** (chart axis labels, runs table, freshness line, executive summary, footer). Server-rendered ISO strings are wrapped in `<time data-iso>` elements and converted to local time by client-side JS on page load.
84
+
85
+ ### Changed (migration required)
86
+
87
+ - **WS-2 outcome loop (#613) — default-off weight change (state.db migration 010).**
88
+ Every `akm improve` run now writes an `asset_outcome` row per processed asset
89
+ (state.db migration `010`) and computes a differential usefulness signal
90
+ (`outcome_score`) per ref. The outcome signal is persisted and visible in the
91
+ health report, but the **weight change is gated behind a config flag** (see
92
+ below). Ranking is unchanged from WS-1 by default.
93
+
94
+ **Opt-in weight change.** The WS-2 projection weights (`w_e=0.25, w_o=0.15,
95
+ w_r=0.60`) affect ranking only when you explicitly set
96
+ `improve.salience.outcomeWeightEnabled: true` in your `akm.yaml`. The default
97
+ (`false`) keeps WS-1 parity weights (`w_e=0.30, w_r=0.70`, `w_o=0`), so
98
+ existing users see no ranking change on upgrade.
99
+
100
+ **Part-V measurement gate.** Before enabling the weight change, run the Part-V
101
+ T0 baseline (`scripts/akm-eval` + `akm health`; confirm proactive accept
102
+ ≥ 0.9× reactive; reversion ≤ 0.15; retrieval-delta ≥ 0; coverage not
103
+ regressed). That gate requires a running production stash and cannot be
104
+ exercised in CI. Once confirmed, set
105
+ `improve.salience.outcomeWeightEnabled: true` to activate the three-way split.
106
+
107
+ **Outcome loop mechanics.** `outcome_score` is a differential prediction-error
108
+ signal: `(retrieval_delta − expected_delta) − PENALTY × retrieval_delta × (1 −
109
+ accepted_change_rate) + valence`, tracked via an EMA (α=0.3). New rows are
110
+ warm-started from the utility EMA score (clipped to 0.3) so the signal is
111
+ non-zero from launch. A stash-wide diversity floor (10% of the max score) prevents
112
+ rare-but-correct assets from being permanently outcompeted. An inverted-proxy
113
+ tripwire (`corr(outcome_score, accepted_change_rate) < −0.3`) emits an
114
+ `outcome_proxy_inverted` health event when the signal degrades.
115
+
116
+ `review_pressure` is computed and persisted per asset but is **not yet wired into
117
+ the admission policy** — that is deferred to a later work stream per plan §Part-VI
118
+ #613. The column is present and populated; routing it into the consolidation-
119
+ selection filter is the next step.
120
+
121
+ - **WS-1 salience vector (#618) — default-on ranking change.** The eligibility sort
122
+ for all `akm improve` runs (whole-stash, type, and ref scope) has changed from
123
+ `combinedEligibilityScore = utility·0.7 + negativeOnlyRatio·0.3` to
124
+ `rankScore = (0.3·encodingSalience + 0.7·retrievalSalience) × sizePenalty`
125
+ (feedback valence and utility EMA dropped from ordering until WS-2 re-introduces
126
+ outcome salience). Assets are now ranked by retrieval frequency × recency × type
127
+ importance rather than by feedback magnitude. Because the old
128
+ `combinedEligibilityScore` ordering was never persisted, a forgetting comparison is
129
+ not possible on the first run; instead a one-time `improve_salience_first_run` marker
130
+ event is emitted to record the transition. On every subsequent run a stash-wide
131
+ `improve_salience_rank_change` drift report (including `stashSize`) is emitted so
132
+ rank movement under the new scoring can be tracked over time.
133
+ The Part-V measurement protocol (T0 baseline via `scripts/akm-eval` + health report,
134
+ throughput/quality gate) is deferred to the WS-2 milestone, when outcome salience
135
+ re-joins the projection and re-tuning is triggered.
136
+
137
+ ## [0.9.0-beta.12] - 2026-06-15
138
+
139
+ Improve-tuning work streams (all **default-off / parity-preserving** — no behavior
140
+ change until explicitly enabled).
141
+
142
+ ### Added
143
+
144
+ - **#617 — deterministic near-duplicate memory dedup** (`processes.consolidate.dedup`,
145
+ default off). A cheap no-LLM pre-pass in front of consolidation collapses obvious
146
+ duplicates — `.derived`+origin pairs and content twins (normalized content-hash
147
+ equality, or embedding cosine ≥ `cosineThreshold`, default 0.97). Each dropped
148
+ variant is archived + backed up before deletion; hot memories are never
149
+ collapsed; distinct-but-related memories fall through to the LLM.
150
+ - **#581 — judged-state cache for consolidation** (`processes.consolidate.judgedCache`,
151
+ default off). New state.db table (`consolidation_judged`) records each memory's
152
+ content hash + outcome when the LLM judges it; subsequent runs skip
153
+ judged-unchanged memories, converting coverage from O(time-window) to
154
+ O(changed/new) so a run can sweep the full corpus. Fails open; failed chunks
155
+ and dry-runs never poison the cache. (state.db migration `007`.)
156
+ - **#612 — auto-accept gate calibration** (`improve.calibration`, auto-tune default
157
+ off). Joins predicted gate confidence to realized accept/reject outcomes into a
158
+ reliability table + calibration gap, surfaced in `akm health` (+ summary rows in
159
+ the HTML report). Opt-in bounded threshold auto-tune nudges the accept threshold
160
+ within a configured band toward a target accept rate, logged via a
161
+ `calibration_autotune` event. (Replay-prioritization from prediction error is
162
+ deferred — it depends on the #610 replay budget, a 0.10 item.)
163
+
164
+ ### Fixed
165
+
166
+ - **#614 — symmetric valence weighting** (`profiles.improve.*.symmetricValence`,
167
+ default off). The eligibility sort weighted feedback negative-only; when enabled
168
+ it uses a symmetric `|valence|` magnitude so strong positive and strong negative
169
+ feedback both drive attention (utility stays the dominant factor), routing
170
+ high-negative → fix and high-positive → reinforce lanes.
171
+
172
+ ## [0.9.0-beta.11] - 2026-06-15
173
+
174
+ ### Added
175
+
176
+ - **`extract.maxSessionsPerRun`** (default 25) — caps the NEW sessions the
177
+ extract pass LLM-processes in a single run so a backlog (e.g. after downtime)
178
+ can't push one run past its scheduled-task timeout. Overflow sessions stay
179
+ unseen and are picked up by later runs, so coverage is preserved. `0` disables.
180
+
181
+ ### Fixed
182
+
183
+ - **Auto-accept validation failures are no longer a blind leak.** When a
184
+ confidence-passing proposal fails promotion validation, the gate now captures
185
+ the reason (the `validateProposal` finding kind, e.g. `validation:description-quality`),
186
+ records it on the proposal (`akm proposal show` explains the rejection), logs
187
+ it, and exposes `failedByReason` on the gate result — so the ~5% leak is
188
+ diagnosable instead of silently warned-and-dropped.
189
+ - **Inflated skip-reason aggregates in `akm health`.** `no_new_signal` /
190
+ `profile_filtered_all_passes` are per-run snapshots of a stable set; the
191
+ window aggregator summed their per-run counts (≈2.7M / 3M). It now uses the
192
+ most recent run's count for these aggregated-snapshot reasons while still
193
+ summing genuine per-occurrence skips.
194
+
195
+ ## [0.9.0-beta.10] - 2026-06-15
196
+
197
+ ### Added
198
+
199
+ - **#603** — `akm health` pool-saturation advisory. Instead of alerting on the
200
+ raw `sessionsScanned` count (which false-alarmed on normal cadence changes),
201
+ a new `pool-saturation` advisory reports the ratio of new (unseen) sessions
202
+ to the total session pool: informational below 10% (expected steady state),
203
+ warning below 2% (possible discovery/dedup bug). Heuristic, never gates
204
+ overall status.
205
+ - **#576** — the `akm health` HTML report now renders the real per-stage LLM
206
+ token/time aggregate (a "🧠 LLM Work" KPI card + LLM token/call/wall-time
207
+ summary rows) from the captured `llm_usage` events, replacing the GPU-time
208
+ proxy.
209
+ - **Built-in `akm health --format html` report overhaul** — the report is now a
210
+ strict superset of (and supersedes) the external `akm-health-report` stash
211
+ skill. Restored the interactive filter bar (time-slice 1d–21d, task, status)
212
+ with client-side chart/table re-render and the Last-10 "Task" column;
213
+ reordered sections to a decision-first flow (verdict → action items → KPIs →
214
+ table → charts); added a synthesized one-sentence **Verdict** (status + 2–3
215
+ drivers) and a freshness line; merged the duplicate Advisories / What-to-Watch
216
+ into one prioritized, de-duplicated **Action Items** list (P1/P2/P3 +
217
+ remediation command); added a per-stage **LLM token** stacked-bar chart and
218
+ `dataZoom` sliders on dense charts; fixed the failed-run scatter x-alignment
219
+ (now shape-encoded); KPI-card colors are now health signals (not decoration);
220
+ added metric-glossary tooltips, chart `aria-label`s, contrast fixes, and
221
+ empty-state overlays. Deterministic output preserved.
222
+
223
+ ### Fixed
224
+
225
+ - **Health report accuracy** (follow-ups to the overhaul): the per-run **Task**
226
+ column/filter now show the real scheduled task (`akm-improve-frequent`, …) via
227
+ a ±5min `task_history` join instead of the run's scope (which is `all` for
228
+ every scheduled run); the time-**slice** filter options are now derived from
229
+ the report's `--since` window (e.g. All/3d/1d/12h/6h for a 7d report) and
230
+ default to "All" — replacing the hard-coded 1d–21d list that didn't match the
231
+ window; and the trend **deltas** now default their compare window to `--since`
232
+ (like-for-like, e.g. last 7d vs prior 7d) instead of a fixed 24h, which had
233
+ produced nonsensical period-over-period percentages on multi-day reports.
234
+ - **Inflated stash-snapshot metrics in `akm health`.** `memorySummary`
235
+ (derived/eligible) and `profileFilteredRefs` are whole-stash snapshots recorded
236
+ on every run, but the window aggregator was **summing** them across all runs —
237
+ e.g. "915,258 of 1,226,025 eligible" and a 2.4M filtered-ref count. They now
238
+ take the most recent run's snapshot (the current state). Per-run *work* metrics
239
+ (promoted, MI written, graph entities, …) remain genuine window sums.
240
+ - **Health report polish:** the akm version is stamped in the header (under the
241
+ AKM logo) and footer; the steady-state `no new signal since last proposal`
242
+ distill reason is excluded from the skip-reason chart (it drowned out the
243
+ actionable reasons); and the Consolidation Output chart now draws Promoted as a
244
+ line on a secondary right-hand axis (it dwarfs merged/deleted) with merged and
245
+ deleted as bars on the left axis.
246
+
247
+ - **#598** — process-level tuning fields (`consolidate.incrementalSince`,
248
+ `minPoolSize`, `neighborsPerChanged`, `extract.minContentChars`, per-process
249
+ `enabled` flags) now survive an `akm config` rewrite. They are first-class
250
+ typed `ImproveProcessConfigSchema` fields, so the load→save round trip no
251
+ longer silently drops them. Unknown process sub-keys hard-error at load
252
+ (`ConfigError`) rather than being silently discarded — the deliberate,
253
+ documented resolution. Regression-guarded by
254
+ `tests/config-process-roundtrip.test.ts`.
255
+
256
+ ## [0.9.0-beta.9] - 2026-06-14
257
+
258
+ Restore and instrument `akm improve` steady-state output. The reflect/distill
259
+ self-improvement lanes had been near-zero in steady state because the
260
+ signal-delta eligibility gate was the only lane (cache "no-access = no-work"
261
+ pathology) and the high-retrieval fallback was structurally dead. This release
262
+ revives proactive improvement, adds attribution + a measurement/kill-criterion
263
+ system so the lane must prove its value, and right-sizes reflect budgets to
264
+ their task timeouts.
265
+
266
+ ### Added
267
+
268
+ - **Proactive maintenance selector** (`proactiveMaintenance` improve process):
269
+ due-gated, composite-priority (`importance × log(1+retrievalFreq) ×
270
+ recencyDecay / log(size)`), bounded rotating top-N reflect/distill over
271
+ stale/never-reflected assets. **Disabled by default**; enable per profile.
272
+ - **Eligibility attribution**: every reflect/distill proposal is stamped
273
+ `eligibilitySource ∈ {signal-delta, high-retrieval, proactive, scope,
274
+ unknown}` on `reflect_invoked`/`distill_invoked`/`promoted` events and the
275
+ proposal record, so outcomes are sliceable by lane.
276
+ - **Measurement system** under `scripts/akm-eval/`: a real-query retrieval suite
277
+ generated from `usage_events`, and `akm-eval-proactive-verdict` — a read-only
278
+ kill-criterion runner comparing the proactive lane (treatment) vs due-but-
279
+ untouched assets (control). Emits PASS/FAIL/INCONCLUSIVE and recommends
280
+ disabling the lane on FAIL. New `proactive_selected` event +
281
+ `proactiveSelected`/`proactiveDueTotal`/`proactiveNeverReflected` fields on
282
+ `improve_completed`.
283
+
284
+ ### Fixed
285
+
286
+ - Revived the P0-A high-retrieval fallback: genuinely zero-feedback assets were
287
+ routed to the fully-skipped branch one phase before the fallback could see
288
+ them, so frequently-retrieved-but-never-rated assets were never improved.
289
+ - `getRetrievalCounts` now normalizes bare vs `origin//`-prefixed refs (it was
290
+ dropping ~half the retrieval signal) and counts `curate` events
291
+ (`akm curate` now records per-item `entry_ref`).
292
+ - The fully-skipped `no_new_signal` branch emitted one `improve_skipped` event
293
+ per ref (~11K writes/run, ~400K rows/day) — a contributor to 900s improve
294
+ timeouts and state.db bloat. Collapsed into one aggregated counted event.
295
+
296
+ ## [0.9.0-beta.8] - 2026-06-13
297
+
298
+ Fix multi-process SQLite contention in `index.db` and harden concurrent proposal
299
+ queue mutations.
300
+
301
+ ### Changed
302
+
303
+ - Added a global `index.db` writer lease used by foreground indexing,
304
+ background auto-index, improve maintenance index writers, graph updates, and
305
+ feedback writes.
306
+ - Replaced the racy background index PID-file dedup flow with lease-based
307
+ coordination and explicit handoff to the spawned worker.
308
+ - `akm feedback` now uses blocking index preparation and writes under the same
309
+ `index.db` lease, avoiding self-inflicted `database is locked` failures.
310
+ - Proposal queue create/archive/gate-decision mutations now run under
311
+ `BEGIN IMMEDIATE` state.db transactions so concurrent processes serialize on
312
+ live queue state.
313
+
314
+ ## [0.9.0-beta.7] - 2026-06-13
315
+
316
+ Fix the `akm improve` regression introduced by background `ensureIndex`.
317
+
318
+ ### Changed
319
+
320
+ - Added an explicit `ensureIndex` mode so callers choose `background` or
321
+ `blocking` behavior directly instead of relying on hidden environment state.
322
+ - `akm improve` now uses blocking index preparation before collecting eligible
323
+ refs, restoring the post-upgrade empty-index recovery path.
324
+ - Removed the `AKM_INDEX_INLINE` test-only override so tests exercise the same
325
+ index behavior model as production.
326
+
327
+ ## [0.9.0-beta.6] - 2026-06-12
328
+
329
+ Pipeline optimization: new per-process config fields wire up the consolidation
330
+ and improve pipeline knobs exposed by the optimization report — incremental
331
+ consolidation, pool caps, distill gating, and memory inference throttling.
332
+
333
+ ### Added
334
+
335
+ - **`consolidate.incrementalSince`** — profile config field that narrows the
336
+ consolidation candidate pool to memories modified within the given window
337
+ (e.g. `"1h"`, `"4h"`) plus their graph neighbours. Enables frequent
338
+ consolidation passes (e.g. `quick-shredder` every 15 min) without full-pool
339
+ sweeps. Absent = full-pool sweep (correct for nightly runs).
340
+ - **`consolidate.limit`** — hard cap on memories processed per consolidation
341
+ pass, applied after incremental narrowing. Prevents runaway full-pool sweeps
342
+ in the nightly default profile.
343
+ - **`consolidate.neighborsPerChanged`** — configurable graph-neighbour count
344
+ per changed memory during incremental consolidation (was hardcoded to 5).
345
+ `quick-shredder` sets this to 3 for a 40% candidate reduction per burst.
346
+ - **`distill.requirePlannedRefs`** — when `true`, the distill process is
347
+ skipped entirely for distill-only refs when the reflect phase produced zero
348
+ planned refs. Eliminates hundreds of `distill-skipped` events on quiet passes
349
+ where all refs are on reflect cooldown.
350
+ - **`memoryInference.minPendingCount`** — minimum pending split-parent memory
351
+ count below which the inference pass is skipped entirely (zero LLM calls).
352
+ Prevents lock acquisition on passes where there is nothing to infer.
353
+ - **`reflect.limit`** — per-process ref limit for the reflect/distill loop,
354
+ applied as the improve run limit when no CLI `--limit` is given.
355
+ - **New `reflect-distill` improve profile** — dedicated reflect + distill +
356
+ memoryInference + triage profile for the every-4h `akm-improve-frequent`
357
+ task. `reflect.limit: 25` bounds LLM cost per pass.
358
+
359
+ ### Changed
360
+
361
+ - **`quick-shredder` profile tuned**: `incrementalSince` `4h` → `1h`,
362
+ `maxChunkSize` 25 → 35, added `minPoolSize: 10`, `neighborsPerChanged: 3`,
363
+ `memoryInference.minPendingCount: 5`. All `profile: "qwen-9b-shredder"`
364
+ process references removed — falls back to default LLM.
365
+ - **`default` improve profile** (nightly): extract disabled (dedicated
366
+ `akm-extract` task runs at 01:48), consolidate gets `limit: 500`,
367
+ reflect gets `limit: 100` and `allowedTypes`, distill gets
368
+ `requirePlannedRefs: true`, triage enabled at 50 accepts/run,
369
+ graphExtraction explicitly enabled.
370
+ - **Cron schedule optimised**: extract reverted to `8,28,48 * * * *` (3×/hr),
371
+ quick-shredder shifted to `4,19,34,49` (4-min extract gap), health-report
372
+ shifted to `:03` (avoids `:00` collision), `akm-improve-frequent` re-enabled
373
+ at `45 */4` with `reflect-distill` profile.
374
+
375
+ ## [0.9.0-beta.3] - 2026-06-12
376
+
377
+ Stabilization batch closing the remaining 0.9.0 milestone: DB-locking and
378
+ improve-pipeline perf backports, extract/reflect gate fixes, SQLite-first
379
+ proposal and log storage, `--format html` output, and per-stage LLM telemetry.
380
+
381
+ ### Added
382
+
383
+ - **`--format html` output with per-command templates** (#582). `akm health
384
+ --format html` renders the full interactive health report (ECharts inlined by
385
+ default, or via CDN with `AKM_ECHARTS=cdn`); every other command falls back to
386
+ a dark-mode default template that pretty-prints its JSON. A global `--output
387
+ <path>` flag writes the rendered HTML to a file instead of stdout. Token
388
+ replacement only — no template engine. The standalone health-report skill is
389
+ now folded into core.
390
+ - **Per-stage LLM telemetry** (#576). Every `chatCompletion` call now records
391
+ tokens (prompt/completion/total/reasoning), wall-time, model, and
392
+ finish_reason as an `llm_usage` event, attributed to the pipeline stage via an
393
+ ambient `AsyncLocalStorage` context (`withLlmStage`) set once per phase — no
394
+ `stage` parameter threaded through call sites. `akm health` exposes per-stage
395
+ token and time aggregates. Telemetry is best-effort and can never fail a run;
396
+ capture is forward-only.
397
+ - **Per-proposal gate decision + confidence** (#577). When a proposal passes
398
+ through the auto-accept/triage gate, its outcome (`auto-accepted` /
399
+ `deferred` / `auto-rejected`), reason, confidence, measured value, and the
400
+ thresholds in effect are persisted on the proposal (in the SQLite metadata).
401
+ `akm proposal show`/`list` surface them with reconstructable comparisons
402
+ (e.g. `0.72 < 0.90`), so tooling can explain *why* each proposal is pending
403
+ instead of relying on a run-level aggregate. Forward-only; legacy proposals
404
+ render `unknown`.
405
+
406
+ ### Fixed
407
+
408
+ - **`SQLITE_BUSY` / "database is locked" under concurrent runs** (#584, #585,
409
+ #589). `busy_timeout` raised from 5 s to 30 s on every SQLite open path
410
+ (index.db and state.db); the improve maintenance pass now closes its index.db
411
+ handle before each reindex (which opens its own writer to the same WAL file);
412
+ and the post-loop purge reuses the long-lived events connection instead of
413
+ opening a second state.db writer. Together these eliminate all observed
414
+ lock failures from overlapping cron improve runs. (Backports of 0.8.8.)
415
+ - **Extract gate ignored the active profile's `extract.enabled: false`** (#593,
416
+ #594). The session-extraction gate hardcoded the `default` profile, so a
417
+ non-default profile (e.g. a quick pass) ran extract anyway — 300–600 s of
418
+ redundant work per run when a dedicated extract task also exists. The gate
419
+ now resolves `extract` against the active improve profile. (Backport of
420
+ 0.8.11.)
421
+ - **Memory inference burned LLM calls on already-derived parents** (#588). The
422
+ primary pass now checks for the `<parent>.derived.md` child on disk *before*
423
+ the LLM/cache call, and opportunistically marks the parent processed so it
424
+ never re-pends. Previously ~55 % of the inference budget was spent
425
+ rediscovering children that already existed.
426
+ - **Reflect no longer queues empty-diff or cosmetic-only proposals** (#580).
427
+ A deterministic, LLM-free noise gate diffs each candidate against the current
428
+ asset; byte-identical edits are dropped and changes that are pure formatting
429
+ (whitespace reflow, hard-wrap changes, code-fence language hints, YAML scalar
430
+ re-folding) are suppressed, each recorded via summary events so suppression
431
+ rates are visible in `akm health`.
432
+
433
+ ### Added
434
+
435
+ - **`minContentChars` pre-LLM extract gate** (#595, #596). Sessions whose raw
436
+ size is below `profiles.improve.<name>.processes.extract.minContentChars`
437
+ (default 10 — only truly empty sessions/journal files) skip the extract LLM
438
+ call entirely. Gates on raw input size, not post-noise-filter size.
439
+ (Backports of 0.8.12–0.8.14.)
440
+ - **Structured logs database** (#579). Task and run log lines now land in a
441
+ dedicated `logs.db` (WAL, 30 s busy_timeout) keyed by task, run, stream, and
442
+ time, with retention/purge wired into the existing purge pass and `ATTACH`
443
+ support for joining log lines to `state.db` rows (e.g. a failed
444
+ `task_history` row to its log output). The scattered-log audit and per-source
445
+ keep/move/drop decisions are documented in `docs/technical/logs-audit.md`.
446
+
447
+ ### Changed
448
+
449
+ - **Proposals are now stored canonically in SQLite** (#578). The previously
450
+ bypassed `proposals` table in state.db is the single source of truth; all
451
+ proposal commands (`list`/`show`/`diff`/`accept`/`reject`/`revert`/`drain`),
452
+ the improve auto-accept gate, and health metrics read and write it through
453
+ one storage layer. Pending file-based proposals are imported on first read;
454
+ `akm proposal *` UX is unchanged. Design and migration notes live in
455
+ `docs/technical/proposal-storage.md`.
456
+ - **Improve planning no longer does per-ref DB lookups or per-ref skip events**
457
+ (#591, #592). Eligible refs carry a pre-resolved `filePath`, removing a
458
+ serial async lookup per ref (~500 s on 9 k-ref stashes), and the
459
+ profile-filtered skip loop emits one summary event with a count instead of
460
+ thousands of rows. (Backports of 0.8.9–0.8.10.)
461
+
9
462
  ## [0.9.0-beta.2] - 2026-06-09
10
463
 
11
464
  ### Fixed
@@ -254,6 +707,167 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
254
707
  `migrate-storage` change is pinned by a sha256 + file-mode fixture-stash
255
708
  differential test.
256
709
 
710
+ ## [0.8.14] - 2026-06-11
711
+
712
+ ### Fixed
713
+
714
+ - **`akm extract` minContentChars default lowered from 500 to 10.** The 500-char
715
+ threshold used inputCount (raw session size) but analysis showed 209 of 218
716
+ candidate-producing sessions had inputCount < 500 — tiny agent sessions (22–368
717
+ chars) regularly yield 1–5 candidates. The only reliably skippable sessions are
718
+ empty ones (0 chars, journal files). Default lowered to 10 to catch only
719
+ truly empty sessions while preserving all signal-bearing content. Closes #597.
720
+
721
+ ## [0.8.13] - 2026-06-11
722
+
723
+ ### Fixed
724
+
725
+ - **`akm extract` minContentChars gate filtered all sessions.** The threshold was
726
+ checked against `filtered.stats.outputCount` (post-noise-filter chars), but the
727
+ pre-filter strips so much boilerplate that even signal-bearing sessions end up
728
+ below 500 chars of output. All 75 sessions in the first post-deploy run were
729
+ filtered, dropping candidates from 4–13 to 0. Fix: gate on `inputCount` (raw
730
+ session size) instead — a session with < 500 raw chars has nothing worth
731
+ extracting regardless of what the pre-filter produces. Closes #596.
732
+
733
+ ## [0.8.12] - 2026-06-11
734
+
735
+ ### Fixed
736
+
737
+ - **`akm extract` calling the LLM for noise sessions that never yield candidates.**
738
+ 96% of processed sessions (72/75 measured) produced zero candidates, consuming
739
+ ~330 s of LLM time per run. The pre-filter had no minimum content threshold —
740
+ sessions as short as 50 chars were sent to the LLM regardless. A new
741
+ `minContentChars` gate (default 500) skips the LLM call when post-filter
742
+ content falls below threshold, cutting extract LLM calls by ~95% on typical
743
+ stashes. Configurable via `profiles.improve.<name>.processes.extract.minContentChars`.
744
+ Closes #595.
745
+
746
+ ## [0.8.11] - 2026-06-11
747
+
748
+ ### Fixed
749
+
750
+ - **`akm improve --profile <name>` ignored profile's `extract.enabled: false` setting.**
751
+ The session-extraction gate in the preparation stage called
752
+ `isLlmFeatureEnabled(config, "session_extraction")`, which hardcodes a lookup
753
+ against `profiles.improve.default.processes.extract.enabled`. Any non-default
754
+ profile that set `extract.enabled: false` (e.g. `quick-shredder`) was silently
755
+ ignored, causing the extract pass to run regardless. The fix adds a
756
+ `resolveProcessEnabled("extract", improveProfile)` check so the active
757
+ resolved profile gates the pass correctly. Closes #593.
758
+
759
+ ## [0.8.10] - 2026-06-11
760
+
761
+ ### Fixed
762
+
763
+ - **`akm improve` taking 8–10 minutes per run due to O(n) DB writes for
764
+ profile-filtered refs.** When a profile disables reflect and distill for
765
+ certain asset types, `collectEligibleRefs` marks those refs as
766
+ `profile_filtered_all_passes`. The caller then emitted one `improve_skipped`
767
+ event per ref — a sequential DB write for each. On a ~9 000-ref stash this
768
+ was ~500 s of SQLite writes before any consolidation or memory inference
769
+ began. The fix collapses the per-ref loop into a single summary event
770
+ carrying a `count` field, eliminating ~9 000 sequential writes per run.
771
+ Closes #590.
772
+
773
+ ## [0.8.9] - 2026-06-11
774
+
775
+ ### Fixed
776
+
777
+ - **`akm improve` validation pass was O(n) in stash size, causing ~510 s overhead
778
+ on large stashes.** For every indexed ref, the preparation phase called
779
+ `findAssetFilePath()` — an async round-trip to the index DB followed by a
780
+ filesystem probe — serially inside a `for…await` loop. With ~9 000 indexed
781
+ refs at ~55 ms each, this loop consumed the entire 600–900 s run budget before
782
+ any reflect, triage, or memory-inference work began. The fix threads
783
+ `filePath` from the planning stage (`collectEligibleRefs`) through
784
+ `ImproveEligibleRef` so the validation pass and the disk-existence guard can
785
+ use the pre-resolved path directly. The async lookup is retained only as a
786
+ fallback for refs that enter via a narrow scope (e.g. `--scope ref:foo`).
787
+ Closes #587.
788
+
789
+ ## [0.8.8] - 2026-06-11
790
+
791
+ ### Fixed
792
+
793
+ - **SQLite `SQLITE_BUSY` errors under concurrent improve runs.** `busy_timeout`
794
+ was set to 5 000 ms in all three database open paths (`openDatabase`,
795
+ `openExistingDatabase`, `openStateDatabase`). Under a busy cron schedule — or
796
+ when a reindex triggered by memory inference ran concurrently with an event
797
+ write — the 5 s window was routinely exhausted, producing "database is locked"
798
+ failures. Raised to 30 000 ms across all three paths so transient lock
799
+ contention is retried for up to 30 s before surfacing as an error.
800
+
801
+ ## [0.8.7] - 2026-06-09
802
+
803
+ ### Fixed
804
+
805
+ - **`incrementalSince` duration strings were silently ignored.** Values like
806
+ `"30m"`, `"24h"`, `"7d"` were passed raw to `narrowToIncrementalCandidates`,
807
+ which compared them against ISO timestamps via string sort. All `2026-...`
808
+ timestamps are lexicographically less than `"30m"` (`'2' < '3'`) and `"24h"`
809
+ (`"20" < "24"`), so `isChanged()` always returned `false` and the candidate
810
+ pool was silently emptied rather than filtered to the window. The fix adds
811
+ `parseSinceToIso()`, which resolves human duration strings to absolute ISO
812
+ timestamps before comparison. Values that already look like ISO timestamps
813
+ are passed through unchanged.
814
+
815
+ ## [0.8.6] - 2026-06-09
816
+
817
+ ### Added
818
+
819
+ - **`consolidate.incrementalSince` profile config field.** Setting
820
+ `incrementalSince: "7d"` (or any duration string) in the `consolidate` block
821
+ of an improve profile narrows the candidate pool to memories modified within
822
+ that window plus their top-5 graph neighbours, keeping each pass focused on
823
+ recent changes. This makes it practical to run consolidation more often than
824
+ once per day (e.g. via `akm-improve-consolidate` every 4 h) without
825
+ re-scanning the full pool every time. The nightly default profile leaves this
826
+ unset (full-pool sweep, same as before). The `incrementalSince` option already
827
+ existed in `akmConsolidate()` but was hardcoded off at the call site; the
828
+ field is now surfaced in the config schema and read from the profile.
829
+
830
+ ## [0.8.5] - 2026-06-09
831
+
832
+ ### Fixed
833
+
834
+ - **Consolidation starved merge recall; the memory pool grew unbounded.** Commit
835
+ `633ece41` made the `incrementalSince` narrowing unconditional, so every
836
+ consolidation run only judged memories changed since the last run plus their
837
+ immediate vector-neighbors. Stale-but-unmerged duplicate clusters were never
838
+ re-examined, so the eligible pool grew monotonically and never shrank, and
839
+ contradiction detection (which rides on the consolidation pass) went dark.
840
+ Consolidation only runs on the nightly default-profile pass (`quick`/`frequent`
841
+ disable it), so a full-pool sweep is correct and affordable; the override is
842
+ removed. `lastConsolidateTs` still gates whether the pass runs.
843
+
844
+ ## [0.8.4] - 2026-06-08
845
+
846
+ ### Fixed
847
+
848
+ - **`akm tasks sync` ignored schedule changes.** Sync classified any task already
849
+ present in the OS scheduler as "unchanged" without comparing its installed
850
+ entry, so editing a task's `schedule:` in the `.yml` never reached the crontab —
851
+ the only way to apply a new schedule was to `remove` and re-`add` the task. The
852
+ same gap affected `tasks enable`/`disable`, which merely toggled the existing
853
+ cron line's comment and so re-enabled a stale schedule. Sync now compares the
854
+ backend's installed signature against the signature the current definition would
855
+ produce and reinstalls on drift (reported in a new `updated[]` field);
856
+ `enable`/`disable` reinstall from the current `.yml` instead of toggling in
857
+ place. Backends that can't cheaply read their installed form fall back to an
858
+ idempotent reinstall, so the fix is correct on launchd/schtasks too. The cron
859
+ backend gains `expectedSignature()` and a signature on each `list()` entry.
860
+
861
+ ### Added
862
+
863
+ - **`akm improve --skip-if-locked`.** When another improve run already holds the
864
+ lock, the run logs and exits 0 with a no-op result (`skipped.reason:
865
+ "lock-held"`) instead of failing with the "already running" config error
866
+ (exit 78). Intended for high-frequency scheduled runs (e.g. an every-30-min
867
+ `quick` pass) that would otherwise pile up exit-78 failures whenever a longer
868
+ run overlaps them. Default off — the hard error is preserved for interactive
869
+ use. The result is still recorded so the skip is auditable.
870
+
257
871
  ## [0.8.3] - 2026-06-08
258
872
 
259
873
  ### Fixed
@@ -0,0 +1,23 @@
1
+ You are the akm consolidate assistant analyzing memory assets.
2
+
3
+ Rules:
4
+ 1. MERGE: Two or more memories are substantially duplicated or closely related → propose merging. Return the primary ref to keep and secondary refs to delete. Do NOT include mergedContent — the merge will be executed in a separate step.
5
+ 2. DELETE: Memory is clearly outdated, contradicted, or redundant → propose deletion. NEVER propose delete for memories annotated `(captureMode: hot)` — they are user-explicit and only the user can retire them. The downstream guard will refuse these regardless, so proposing them just wastes tokens.
6
+ 3. PROMOTE: Memory expresses a stable, reusable fact suitable as a `knowledge:` asset → propose promotion. Do NOT delete the source memory. NEVER propose promote / merge / contradict for memories annotated `(already queued)` — they have a pending proposal whose body matches; a duplicate will be deterministically dropped, so proposing them just wastes tokens.
7
+ 4. CONTRADICT: Two memories assert logically exclusive facts such that following BOTH simultaneously is impossible — not merely related or overlapping. You MUST cite the exact sentence from Memory A and the exact sentence from Memory B that are in direct conflict. If you cannot cite specific opposing sentences, use KEEP instead. Sharing a topic, tool, domain, or workflow stage is NOT sufficient. Only direct factual opposites qualify: opposing recommended commands, opposing boolean flags, opposing version numbers, or mutually exclusive instructions. Use confidence ≥ 0.92 only; omit the op entirely if below that threshold.
8
+ 5. KEEP: Memory is unique and current → omit from output.
9
+
10
+ Return ONLY JSON (no prose, no code fences):
11
+ {
12
+ "operations": [
13
+ { "op": "merge", "primary": "memory:<name>", "secondaries": ["memory:<name>", ...], "mergeStrategy": "synthesize", "confidence": 0.95 },
14
+ { "op": "delete", "ref": "memory:<name>", "reason": "<brief reason>", "confidence": 0.90 },
15
+ { "op": "promote", "ref": "memory:<name>", "knowledgeRef": "knowledge:<suggested-slug>", "reason": "<brief reason>", "description": "<one sentence describing the new knowledge asset>", "confidence": 0.92 },
16
+ { "op": "contradict", "ref": "memory:<name>", "contradictedByRef": "memory:<name>", "reason": "<brief reason>", "confidence": 0.88 }
17
+ ],
18
+ "warnings": ["<optional concerns>"]
19
+ }
20
+
21
+ For every operation, emit a `confidence` field in [0, 1] expressing your certainty that the operation is correct and safe. Use 0.95+ only when evidence is unambiguous. Omit the field rather than guessing if you are uncertain.
22
+
23
+ When the merged content includes an `updated` frontmatter field, the value MUST be a real ISO date string (e.g. `updated: 2026-05-20`). NEVER emit `updated: today`, `updated: {today}`, `updated: {today: null}`, `updated: now`, or any other literal placeholder/template-variable. If you do not have a real source-of-truth date, OMIT the `updated` field entirely — the post-processor will not invent one for you.