akm-cli 0.9.30 → 0.9.31

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 (161) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +10 -10
  3. package/ROADMAP.md +112 -0
  4. package/dist/commands/improve/improve-cli.js +33 -12
  5. package/dist/core/file-lock.js +10 -1
  6. package/dist/llm/client.js +33 -3
  7. package/dist/scripts/akm-migrate-node.js +5 -1
  8. package/dist/scripts/akm-migrate.js +5 -1
  9. package/docs/README.md +42 -41
  10. package/docs/agents/README.md +15 -0
  11. package/docs/agents/agent-install.md +14 -0
  12. package/docs/architecture/README.md +67 -0
  13. package/docs/architecture/adapters.md +272 -0
  14. package/docs/architecture/akm-architecture-decision-history.md +2055 -0
  15. package/docs/architecture/akm-core-principles.md +126 -0
  16. package/docs/architecture/architecture.md +579 -0
  17. package/docs/architecture/comparisons/claude-code-vs-akm-workflows-full.md +550 -0
  18. package/docs/architecture/decisions/0001-no-interpolation-attached-structured-context.md +72 -0
  19. package/docs/architecture/decisions/0002-unit-reuse-and-input-hash-scope.md +142 -0
  20. package/docs/architecture/decisions/0003-child-env-allowlist-and-provenance.md +189 -0
  21. package/docs/architecture/decisions/0004-task-input-contract-and-flag-coercion.md +97 -0
  22. package/docs/architecture/decisions/0005-task-result-vocabulary-and-legacy-read-mapping.md +108 -0
  23. package/docs/architecture/decisions/0006-task-source-version-routing.md +124 -0
  24. package/docs/architecture/decisions/0007-workflow-composition-bounds.md +83 -0
  25. package/docs/architecture/decisions/0008-task-binding-normalization.md +88 -0
  26. package/docs/architecture/decisions/0009-child-run-publication-column-parity.md +80 -0
  27. package/docs/architecture/decisions/0010-driver-protocol-cut.md +36 -0
  28. package/docs/architecture/decisions/0011-engine-run-loop-invariants.md +125 -0
  29. package/docs/architecture/decisions/README.md +62 -0
  30. package/docs/architecture/improvement.md +440 -0
  31. package/docs/architecture/internals/classification.md +154 -0
  32. package/docs/architecture/internals/fresh-host-rebuild-runbook.md +40 -0
  33. package/docs/architecture/internals/functional-contract-patterns.md +340 -0
  34. package/docs/architecture/internals/health-advisories.md +110 -0
  35. package/docs/architecture/internals/improve-workflow.md +713 -0
  36. package/docs/architecture/internals/indexing.md +498 -0
  37. package/docs/architecture/internals/registry-network-boundary.md +57 -0
  38. package/docs/architecture/internals/search.md +249 -0
  39. package/docs/architecture/internals/storage-locations.md +943 -0
  40. package/docs/architecture/persisted-data-compat.md +59 -0
  41. package/docs/architecture/reviews/env-secret-access.md +319 -0
  42. package/docs/architecture/runtime-boundary-design.md +153 -0
  43. package/docs/architecture/specs/0.9.0-close-out-plan.md +361 -0
  44. package/docs/architecture/specs/0.9.0-decisions.md +528 -0
  45. package/docs/architecture/specs/0.9.0-docs-code-drift-register.md +745 -0
  46. package/docs/architecture/specs/0.9.0-open-items-register.md +135 -0
  47. package/docs/architecture/specs/0.9.0-public-api-issue-backlog.md +740 -0
  48. package/docs/architecture/specs/0.9.0-release-surface-review.md +636 -0
  49. package/docs/architecture/specs/agent-command-engine-model-design.md +513 -0
  50. package/docs/architecture/specs/akm-0.9.0-bundle-adapter-spec.md +501 -0
  51. package/docs/architecture/specs/akm-0.9.0-ref-grammar-decision.md +291 -0
  52. package/docs/architecture/specs/akm-format-neutral-bundle-workspace-spec.md +2059 -0
  53. package/docs/architecture/specs/di-seams-plan.md +539 -0
  54. package/docs/architecture/specs/driver-protocol-keep-or-cut.md +275 -0
  55. package/docs/architecture/specs/fact-asset-type.md +142 -0
  56. package/docs/architecture/specs/improve-collapse-churn-detector-design.md +634 -0
  57. package/docs/architecture/specs/okf-support.md +148 -0
  58. package/docs/architecture/specs/ref.md +329 -0
  59. package/docs/architecture/specs/reviews/task-workflow-unification/README.md +72 -0
  60. package/docs/architecture/specs/reviews/task-workflow-unification/findings-consolidated.md +152 -0
  61. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-alternatives.md +352 -0
  62. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-bunqueue.md +300 -0
  63. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-openworkflow.md +402 -0
  64. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-1.md +758 -0
  65. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-2.md +645 -0
  66. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-3.md +602 -0
  67. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-adversarial.md +27 -0
  68. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-architecture.md +27 -0
  69. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-coverage.md +74 -0
  70. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-security.md +15 -0
  71. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-adversarial.md +132 -0
  72. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-verification.md +147 -0
  73. package/docs/architecture/specs/stash-conventions-code-spec.md +275 -0
  74. package/docs/architecture/specs/stash-organization-conventions.md +377 -0
  75. package/docs/architecture/specs/task-workflow-format-unification.md +721 -0
  76. package/docs/architecture/specs/workflow-engine-buy-vs-build.md +231 -0
  77. package/docs/architecture/specs/workflow-format-unification.md +437 -0
  78. package/docs/architecture/testing/manual-testing-checklist.md +3420 -0
  79. package/docs/architecture/testing/okf-v0.2-conformance-runbook.md +924 -0
  80. package/docs/architecture/testing/task-workflow-manual-tests.md +1817 -0
  81. package/docs/architecture/testing/testing-workflow.md +446 -0
  82. package/docs/architecture/workflow-engine.md +274 -0
  83. package/docs/guides/README.md +33 -0
  84. package/docs/guides/author-bundles.md +310 -0
  85. package/docs/guides/author-workflows.md +520 -0
  86. package/docs/guides/bundles.md +321 -0
  87. package/docs/guides/capture-knowledge.md +136 -0
  88. package/docs/guides/claude-code-vs-akm-workflows.md +30 -0
  89. package/docs/guides/concepts.md +93 -0
  90. package/docs/guides/discover-and-load.md +158 -0
  91. package/docs/guides/getting-started.md +240 -0
  92. package/docs/guides/improve-the-library.md +246 -0
  93. package/docs/guides/knowledge-management.md +18 -0
  94. package/docs/guides/recipes/headless-install.md +97 -0
  95. package/docs/guides/recipes/website-source.md +28 -0
  96. package/docs/guides/run-workflows.md +279 -0
  97. package/docs/guides/scheduling.md +123 -0
  98. package/docs/guides/use-with-any-agent.md +129 -0
  99. package/docs/guides/wikis.md +81 -0
  100. package/docs/maintainers/README.md +19 -0
  101. package/docs/maintainers/curate-workmap.md +336 -0
  102. package/docs/maintainers/eval.md +3 -0
  103. package/docs/maintainers/local-development.md +108 -0
  104. package/docs/maintainers/release-checklist.md +103 -0
  105. package/docs/migration/README.md +2 -2
  106. package/docs/migration/release-notes/0.0.13.md +1 -1
  107. package/docs/migration/release-notes/0.1.0.md +1 -1
  108. package/docs/migration/release-notes/0.2.0.md +1 -1
  109. package/docs/migration/release-notes/0.3.0.md +1 -1
  110. package/docs/migration/release-notes/0.5.0.md +1 -1
  111. package/docs/migration/release-notes/0.6.0.md +1 -1
  112. package/docs/migration/release-notes/0.7.0.md +1 -1
  113. package/docs/migration/release-notes/0.7.3.md +2 -2
  114. package/docs/migration/release-notes/0.7.4.md +1 -1
  115. package/docs/migration/release-notes/0.7.5.md +1 -1
  116. package/docs/migration/release-notes/0.8.0.md +1 -1
  117. package/docs/migration/release-notes/0.9.0.md +1 -1
  118. package/docs/migration/release-notes/0.9.14.md +1 -1
  119. package/docs/migration/release-notes/0.9.15.md +1 -1
  120. package/docs/migration/release-notes/0.9.16.md +1 -1
  121. package/docs/migration/release-notes/0.9.17.md +1 -1
  122. package/docs/migration/release-notes/0.9.19.md +1 -1
  123. package/docs/migration/release-notes/0.9.2.md +1 -1
  124. package/docs/migration/release-notes/README.md +27 -31
  125. package/docs/migration/v0.5-to-v0.6.md +759 -0
  126. package/docs/migration/v0.8-to-v0.9.md +1 -1
  127. package/docs/plans/0.9.2-agent-command-workflow-plan.md +423 -0
  128. package/docs/posts/README.md +30 -0
  129. package/docs/posts/akm-command-tour.md +495 -0
  130. package/docs/posts/akm-logo-sized.webp +0 -0
  131. package/docs/posts/belief-aware-memory-12.md +139 -0
  132. package/docs/posts/config-v2-lessons-16.md +191 -0
  133. package/docs/posts/improve-loop-autonomous-10.md +225 -0
  134. package/docs/posts/improve-pipeline-debugging-0803.md +179 -0
  135. package/docs/posts/intro-part-01.md +76 -0
  136. package/docs/posts/intro-part-02.md +221 -0
  137. package/docs/posts/intro-part-03.md +190 -0
  138. package/docs/posts/intro-part-04.md +221 -0
  139. package/docs/posts/llm-mode-reflect-13.md +166 -0
  140. package/docs/posts/openpalm-built-on-akm.md +86 -0
  141. package/docs/posts/progressive-disclosure-06.md +129 -0
  142. package/docs/posts/proposal-safety-net-15.md +112 -0
  143. package/docs/posts/release-0.5.0.md +247 -0
  144. package/docs/posts/release-0.6.0.md +117 -0
  145. package/docs/posts/release-0.7.0.md +159 -0
  146. package/docs/posts/release-0.8.0.md +332 -0
  147. package/docs/posts/scattered-skills-05.md +100 -0
  148. package/docs/posts/task-assets-persistent-workflows-11.md +222 -0
  149. package/docs/posts/team-skills-07.md +198 -0
  150. package/docs/posts/wiki-agent-knowledge-08.md +223 -0
  151. package/docs/posts/workflows-vaults-09.md +321 -0
  152. package/docs/product-surface.md +54 -0
  153. package/docs/reference/README.md +1 -2
  154. package/docs/reference/asset-types.md +168 -0
  155. package/docs/reference/cli.md +5 -6
  156. package/docs/reference/env-and-secrets.md +126 -0
  157. package/docs/reference/memory.md +124 -0
  158. package/docs/reference/refs.md +156 -0
  159. package/docs/reference/registry.md +489 -0
  160. package/docs/reference/website-sources.md +141 -0
  161. package/package.json +12 -15
@@ -0,0 +1,2055 @@
1
+ # AKM Architecture Decision History and Conversation Summary
2
+
3
+ ## From an OKF asset proposal to a format-neutral bundle workspace with verified improvement and bounded memory
4
+
5
+ **Status:** Non-normative companion to the architecture specification
6
+ **Date:** 2026-07-14 (2026-07-13: §5.4/§5.5 updated to the reconciled DEV-1/DEV-2 grammar; D8 framing corrected; D27–D29 added after the design/plan review pass. 2026-07-14: D30 added — final release-scope decisions)
7
+ **Normative specification:** [AKM Format-Neutral Bundle Workspace Architecture Specification](./specs/akm-format-neutral-bundle-workspace-spec.md) (v0.3, amended in place)
8
+ **Repository reviewed:** [`itlackey/akm`](https://github.com/itlackey/akm)
9
+ **Reference revision:** [`ddc0a1b417efc820ad73d76bfcbef65c9f87b243`](https://github.com/itlackey/akm/commit/ddc0a1b417efc820ad73d76bfcbef65c9f87b243)
10
+ **Original proposal under review:** [AKM PR #718](https://github.com/itlackey/akm/pull/718)
11
+
12
+ ---
13
+
14
+ ## 1. Purpose of this document
15
+
16
+ This document records the complete architectural reasoning developed through the review of PR #718, the OKF specification, the current AKM implementation, adjacent standards and products, self-improving-agent research, and several rounds of adversarial design review.
17
+
18
+ It is intentionally different from the normative specification:
19
+
20
+ - The **specification** states what the target architecture requires.
21
+ - This document explains **how the design arrived there**, which alternatives were rejected or superseded, why they were rejected, which current AKM capabilities are retained, and which subtle constraints were learned through prior implementation work.
22
+
23
+ It also acts as a guard against architectural regression. Several rejected designs were locally reasonable and may be proposed again unless their failure modes are documented.
24
+
25
+ ---
26
+
27
+ ## 2. Executive summary
28
+
29
+ The final position is:
30
+
31
+ > **AKM does not define a universal content format or asset taxonomy. AKM is a format-neutral workspace that installs and mounts bundles, indexes native files through adapters, searches them through one local index, binds portable runtime exports under local policy, and improves files through evidence-driven, verified transactions.**
32
+
33
+ The final high-level model is:
34
+
35
+ ```text
36
+ Workspace
37
+ ├── installed bundles
38
+ │ ├── one or more adapter-governed components
39
+ │ ├── portable content
40
+ │ └── optional runtime exports
41
+ ├── workspace bindings and enabled schedules
42
+ ├── one local search index
43
+ ├── durable operational state
44
+ ├── execution engines and runtime handlers
45
+ ├── proposals and verified file changes
46
+ └── bounded evidence and memory lifecycle
47
+ ```
48
+
49
+ The major decisions are:
50
+
51
+ 1. **OKF is the first-class Markdown baseline.** AKM Markdown is a progressively enhanced OKF-compatible superset; non-Markdown formats remain native.
52
+ 2. **The closed asset-type system is removed.** Types are open descriptive data, and adapters decide which types receive specialized behavior.
53
+ 3. **A bundle may contain multiple components**, each governed by one adapter.
54
+ 4. **Conventions and authoring rules move into adapters.** They are not deleted.
55
+ 5. **Sources materialize bytes; adapters interpret files; runtime handlers execute approved capabilities.** These are separate responsibilities.
56
+ 6. **Installation is not activation.** Installing and indexing a bundle never grants execution, secret, tool, or scheduling authority.
57
+ 7. **The normalized core projection is additive.** It guarantees generic identity/search/read behavior and permits adapter-owned enhancements; there is no semantic-view registry.
58
+ 8. **Search remains one local index.** Search never calls adapters, registries, materializers, or the network at query time.
59
+ 9. **Ordinary reads use the absolute path already stored in the index.** There is no adapter read facade for deterministic file reads.
60
+ 10. **Website remains a supported refreshable source**, and website snapshots may also be exported into writable native bundles.
61
+ 11. **Workflows, tasks, environment definitions, agents, commands, skills, and scripts may be distributed in bundles.** Workspace binding controls local execution and activation.
62
+ 12. **Proposals contain explicit file changes with before hashes, evidence, evaluation, and reversible transaction state.**
63
+ 13. **Model confidence does not authorize publication.** Semantic acceptance requires review or meaningful external verification.
64
+ 14. **Improve is refactored around three semantic operations: revise, learn, and consolidate.**
65
+ 15. **Memory consolidation remains a first-class responsibility.** It bounds growth through deterministic cleanup, semantic compaction, formalization, reversible retirement, bounded archival, purge, and backpressure.
66
+ 16. **The existing repository is retained as the host and behavioral oracle.** Incorrect architectural centers are replaced inside the same repository and then deleted; there is no separate full-product rewrite and no permanent legacy adapter.
67
+ 17. **The final storage model is three databases:** `state.db`, `index.db`, and `logs.db`.
68
+
69
+ ---
70
+
71
+ ## 3. What AKM contributes beyond a file format
72
+
73
+ The analysis began by separating representation from lifecycle.
74
+
75
+ OKF provides a minimal interoperable representation for hierarchical Markdown knowledge: concepts, frontmatter, links, optional indexes, and optional logs. It intentionally does not prescribe a complete workspace, search engine, execution runtime, package manager, or improvement process. See the [OKF specification](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md) and [reference README](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/README.md).
76
+
77
+ AKM's enduring value is the operating layer around native files:
78
+
79
+ ```text
80
+ source materialization
81
+ + package and bundle installation
82
+ + unified local search
83
+ + progressive retrieval
84
+ + feedback and usage ranking
85
+ + native validation
86
+ + authoring guidance
87
+ + proposals and review
88
+ + safe transactions and recovery
89
+ + workflow and task execution
90
+ + environment and secret binding
91
+ + scheduling
92
+ + continuous improvement
93
+ + memory lifecycle
94
+ + audit and health
95
+ ```
96
+
97
+ The design therefore stopped asking, “How should every AKM asset become OKF?” and started asking:
98
+
99
+ > “How should AKM safely operate across several native bundle formats while preserving one coherent workspace experience?”
100
+
101
+ ---
102
+
103
+ ## 4. Evolution of the architecture
104
+
105
+ ### 4.1 Starting point: OKF as another asset type
106
+
107
+ PR #718 proposed adding OKF support alongside the existing `wiki` and other asset types. The first concern was that an `okf` type would create another generic Markdown category while preserving the same overloaded architecture:
108
+
109
+ ```text
110
+ asset type
111
+ -> storage directory
112
+ -> matcher
113
+ -> canonical ref
114
+ -> renderer
115
+ -> validator
116
+ -> actions
117
+ ```
118
+
119
+ This would make OKF a bolt-on and leave both `wiki` and `okf` as overlapping generic knowledge abstractions.
120
+
121
+ **First correction:** remove `wiki` as a core asset type and support OKF through
122
+ a dedicated adapter rather than a sibling asset type.
123
+
124
+ ### 4.2 OKF-native direction
125
+
126
+ The next design treated OKF concepts as AKM's canonical knowledge objects and separated:
127
+
128
+ ```text
129
+ Workspace
130
+ -> Bundle
131
+ -> Concept
132
+ -> optional native resource
133
+ ```
134
+
135
+ This established two useful distinctions:
136
+
137
+ - A **bundle** is portable content.
138
+ - A **workspace** is local state, search, engines, policy, proposals, schedules, credentials, and telemetry.
139
+
140
+ This was a major improvement over the overloaded `stash` concept.
141
+
142
+ However, it still made OKF the hidden universal semantic center of AKM.
143
+
144
+ ### 4.3 Frontmatter purity and workspace metadata
145
+
146
+ The proposed `akm:` frontmatter namespace, UUIDs, and automation settings were challenged.
147
+
148
+ The important correction was:
149
+
150
+ ```text
151
+ file metadata = portable meaning owned by the native format
152
+ workspace metadata = local behavior, policy, ranking, trust, and automation
153
+ ```
154
+
155
+ Decisions from this phase:
156
+
157
+ - The AKM ref, not a UUID embedded in the file, is the item identity.
158
+ - Automation configuration does not belong in document frontmatter.
159
+ - Usage, embeddings, utility, schedules, trust, credentials, and improve policy are workspace state.
160
+ - AKM should preserve unknown extension fields but should not require an AKM frontmatter extension.
161
+
162
+ ### 4.4 Conceptual simplification of the current AKM model
163
+
164
+ A deeper review found that `stash`, refs, `StashEntry`, `.meta`, wiki, and the asset registry mixed multiple unrelated responsibilities.
165
+
166
+ The proposed simplification became:
167
+
168
+ ```text
169
+ Workspace
170
+ └── Bundle
171
+ └── Concept
172
+ ```
173
+
174
+ with refs based on bundle-relative paths rather than type and provider.
175
+
176
+ This phase correctly identified that:
177
+
178
+ - provider details should not determine document identity;
179
+ - type should not determine identity;
180
+ - runtime state must leave portable roots;
181
+ - wiki is a bundle-like subsystem inside another bundle-like subsystem;
182
+ - knowledge, fact, lesson, and memory are all document-like files with different policies rather than fundamentally different I/O systems.
183
+
184
+ The remaining problem was that AKM still owned the universal concept model.
185
+
186
+ ### 4.5 Format-neutral bundle adapters
187
+
188
+ The architecture was then reframed from another direction:
189
+
190
+ > AKM itself defines no content formats. It knows how to install, search, read, validate, improve, and use bundles through adapters for OKF, LLM Wiki, Claude, OpenCode, Agent Skills, website snapshots, AKM workflow files, and other formats.
191
+
192
+ This was the decisive conceptual shift.
193
+
194
+ The initial adapter proposal introduced composable semantic views such as:
195
+
196
+ ```text
197
+ akm.document@1
198
+ akm.concept@1
199
+ akm.skill@1
200
+ akm.agent@1
201
+ akm.workflow@1
202
+ ```
203
+
204
+ The rationale was to avoid a lowest-common-denominator object and support items with several meanings.
205
+
206
+ ### 4.6 Views were superseded as over-engineering
207
+
208
+ The view registry was later rejected because it risked becoming `AssetSpec 2.0`:
209
+
210
+ - another global registry;
211
+ - another version-negotiation layer;
212
+ - another dispatch vocabulary;
213
+ - another compatibility burden;
214
+ - another semantic model that adapters must map into.
215
+
216
+ The replacement was a small service-specific contract and one narrow search projection.
217
+
218
+ The core no longer needs to know whether an item “is” a skill, document, concept, script, or agent in a universal ontology. The adapter may emit an opaque `kind` for filtering and presentation, while dedicated runtime codecs can parse executable formats when invoked.
219
+
220
+ ### 4.7 Search and improve were identified as high-risk seams
221
+
222
+ Two cautions changed the migration plan:
223
+
224
+ 1. **Search quality must not regress while discovery is replaced.**
225
+ 2. **Improve must not be generalized merely to make every adapter appear uniform.**
226
+
227
+ The current index uses intentionally weighted fields and a substantial ranking pipeline. The safe first migration is:
228
+
229
+ ```text
230
+ adapter scan
231
+ -> equivalent search projection
232
+ -> current FTS/vector/ranking implementation
233
+ ```
234
+
235
+ Adapters run during indexing, not during search.
236
+
237
+ Improve was initially preserved behind a narrow compatibility repository, but that was rejected as another way to retain current complexity without addressing its quality limitations.
238
+
239
+ ### 4.8 Improve became verified file evolution
240
+
241
+ A deep analysis of current improve behavior found the central quality defect:
242
+
243
+ > AKM could prove that a proposal survived structural gates, but not that the accepted revision was better than the file it replaced.
244
+
245
+ The current confidence and calibration mechanisms primarily measured whether a self-scored proposal survived validators. Asset outcome tracked the item over time, not the causal outcome of one specific change.
246
+
247
+ Research on [Reflexion](https://arxiv.org/abs/2303.11366), [Voyager](https://arxiv.org/abs/2305.16291), [Self-Refine](https://arxiv.org/abs/2303.17651), [GEPA](https://arxiv.org/abs/2507.19457), [Darwin Gödel Machine](https://arxiv.org/abs/2505.22954), and [AlphaEvolve](https://deepmind.google/blog/alphaevolve-a-gemini-powered-coding-agent-for-designing-advanced-algorithms/) consistently pointed toward candidate generation coupled to external, task-grounded, or environment-grounded evaluation.
248
+
249
+ The target improve loop became:
250
+
251
+ ```text
252
+ corrective evidence
253
+ -> candidate file changes
254
+ -> native validation
255
+ -> baseline/candidate comparison
256
+ -> review or verified application
257
+ -> observed outcome
258
+ ```
259
+
260
+ ### 4.9 Three-perspective review
261
+
262
+ The plan was reviewed through three distinct lenses:
263
+
264
+ 1. **Empirical learning-system reviewer:** Does the change prove real value or optimize proxies?
265
+ 2. **Minimalist file-and-search reviewer:** Does the architecture remain understandable as paths, searches, hashes, and file changes?
266
+ 3. **Delivery and migration reviewer:** Can the architecture be implemented without losing mature behavior or creating two products?
267
+
268
+ No independent external agent instances were available. The “debate” was performed as three explicitly separated adversarial reviews with different assumptions and success criteria.
269
+
270
+ The reviews converged on:
271
+
272
+ - a narrow normalized model;
273
+ - one local search index;
274
+ - direct file reads;
275
+ - proposal-first semantic changes;
276
+ - measured feature retention;
277
+ - modular replacement in the current repository;
278
+ - a deletion ledger for temporary seams.
279
+
280
+ ### 4.10 Rewrite versus aggressive replacement
281
+
282
+ A full greenfield rewrite was considered seriously because the asset model, refs, indexing discovery, wiki, lint, writes, and improve are deeply coupled.
283
+
284
+ The final decision was not a conventional incremental refactor and not a separate rewrite. It was:
285
+
286
+ > **Aggressive modular replacement inside the existing repository.**
287
+
288
+ The current codebase remains:
289
+
290
+ - the release vehicle;
291
+ - the behavioral oracle;
292
+ - the source of security and failure-path knowledge;
293
+ - the host for new vertical slices.
294
+
295
+ The asset architecture and current improve orchestrator are sacrificial modules. They are replaced from clean boundaries and then deleted.
296
+
297
+ This follows the practical lessons in Martin Fowler's [Strangler Fig Application](https://martinfowler.com/bliki/StranglerFigApplication.html) and [Sacrificial Architecture](https://martinfowler.com/bliki/SacrificialArchitecture.html), while avoiding the failure pattern described in Joel Spolsky's [Things You Should Never Do, Part I](https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/). Google's guidance on [large-scale changes](https://abseil.io/resources/swe-book/html/ch22.html) also supports independently testable, reversible slices rather than one unmergeable replacement.
298
+
299
+ ### 4.11 Repository-wide audit
300
+
301
+ The current implementation was reviewed for all areas coupled to the proposed architecture. The audit surfaced required changes beyond asset types and improve:
302
+
303
+ - source and installed-state configuration;
304
+ - registry package metadata;
305
+ - website ingestion;
306
+ - search/show/curate/manifest;
307
+ - refs, moves, feedback, and history;
308
+ - proposal transactions;
309
+ - workflows and workflow database;
310
+ - tasks and scheduler state;
311
+ - harness/session/runtime coupling;
312
+ - environment and secret handling;
313
+ - events, health, migrations, and output shaping;
314
+ - bundle-local runtime state leaks.
315
+
316
+
317
+ ### 4.12 Final corrections: adapters, websites, portable runtime exports, and memory
318
+
319
+ Four concerns corrected the first repository-wide disposition:
320
+
321
+ 1. **Conventions and authoring rules are not removed.** They move to adapters.
322
+ 2. **Website remains a supported source.** It needs a neutral refreshable snapshot model and a website-to-native export path.
323
+ 3. **Workflows, tasks, and environment definitions remain portable bundle content.** Workspace binding controls execution and activation.
324
+ 4. **Memory consolidation cannot be reduced to generic maintenance or removed.** A supported path must prevent unbounded memory growth while preserving information and enabling formalization.
325
+
326
+ These corrections produced the final architecture in the normative specification.
327
+
328
+ ---
329
+
330
+ ## 5. Current architecture at a glance
331
+
332
+ ### 5.1 Responsibility stack
333
+
334
+ ```text
335
+ Materializer
336
+ answers: how do bytes arrive and refresh?
337
+
338
+ Bundle package
339
+ answers: what portable components are distributed together?
340
+
341
+ Component adapter
342
+ answers: what do these files mean, how are they indexed,
343
+ what rules apply, and how are native changes rendered?
344
+
345
+ Workspace index
346
+ answers: what can be found quickly across installed components?
347
+
348
+ Binding
349
+ answers: which portable exports are approved for local use?
350
+
351
+ Runtime handler
352
+ answers: how is an approved workflow, task, agent, script,
353
+ skill, command, or environment used safely?
354
+
355
+ Improve
356
+ answers: what evidence justifies a change, did the candidate
357
+ outperform the baseline, and can it be safely applied?
358
+ ```
359
+
360
+ ### 5.2 Minimal durable core concepts
361
+
362
+ The implementation should resist creating a large universal domain model. The smallest useful set is:
363
+
364
+ ```text
365
+ BundleInstallation
366
+ BundleComponent
367
+ IndexDocument
368
+ FileChange
369
+ Proposal
370
+ Diagnostic
371
+ Binding
372
+ ```
373
+
374
+ A native format may have richer parser types internally. Those types do not become universal kernel objects.
375
+
376
+ ### 5.3 Multi-component bundles
377
+
378
+ A package may contain multiple native roots:
379
+
380
+ ```yaml
381
+ schemaVersion: 1
382
+ name: release-automation
383
+ components:
384
+ knowledge:
385
+ adapter: okf
386
+ root: knowledge
387
+ workflows:
388
+ adapter: akm-workflow
389
+ root: workflows
390
+ tasks:
391
+ adapter: akm-task
392
+ root: tasks
393
+ environment:
394
+ adapter: akm-env
395
+ root: env
396
+ skills:
397
+ adapter: agent-skills
398
+ root: skills
399
+ ```
400
+
401
+ The package manifest describes composition. It does not create a universal AKM file format.
402
+
403
+ ### 5.4 Identity
404
+
405
+ *(Amended 2026-07-13 by the maintainer reconciliation, DEV-2: the three-segment form originally recorded here is superseded. Current grammar: normative spec §7.8/§11.)*
406
+
407
+ The canonical item ref is:
408
+
409
+ ```text
410
+ [ <bundle> "//" ] <concept-id> [ "#" <fragment> ]
411
+ ```
412
+
413
+ Examples:
414
+
415
+ ```text
416
+ personal//engineering/http-caching
417
+ release-automation//workflows/release
418
+ project-claude//skills/pdf-processing
419
+ ```
420
+
421
+ Component is provenance from the bundle's single configured component, not a ref segment. The adapter derives concept IDs relative to that component root. Identity excludes:
422
+
423
+ - source provider;
424
+ - cache path;
425
+ - semantic type;
426
+ - component id;
427
+ - file extension where the adapter does not treat it as meaningful;
428
+ - embedded UUIDs.
429
+
430
+ ### 5.5 Search document
431
+
432
+ *(Amended 2026-07-13: the field is the open `type` (DEV-1), and the query-time ranking/filter signals are first-class fields — see normative §14.1 for the current shape. The sketch below is the historical minimal form.)*
433
+
434
+ The normalized content projection stops at search needs:
435
+
436
+ ```ts
437
+ interface IndexDocument {
438
+ ref: string;
439
+ bundle: string;
440
+ component: string;
441
+ conceptId: string;
442
+ path: string;
443
+ hash: string;
444
+ type?: string;
445
+
446
+ name: string;
447
+ description?: string;
448
+ tags?: string[];
449
+ aliases?: string[];
450
+ hints?: string[];
451
+ content?: string;
452
+ // + the pinned query-time signal fields (normative §14.1)
453
+ }
454
+ ```
455
+
456
+ `type` is an open descriptive label. It MAY drive presentation/ranking/filtering (trust-clamped for untrusted content) and never authorizes execution or selects storage, identity, or the write path.
457
+
458
+ ---
459
+
460
+ ## 6. Decision register
461
+
462
+ ### D1. AKM is format-neutral
463
+
464
+ **Decision:** AKM does not define the native storage format for every file it manages.
465
+
466
+ **Why:** The current asset registry causes every new format to become a cross-cutting core change. It also forces unrelated formats into one taxonomy and makes storage, validation, rendering, identity, and execution depend on the same type switch.
467
+
468
+ **Consequence:** OKF, LLM Wiki, Claude, OpenCode, Agent Skills, website snapshots, workflows, tasks, environments, and future standards are integrated through adapters and runtime codecs.
469
+
470
+ ### D2. OKF is the first-class Markdown baseline
471
+
472
+ **Decision:** AKM guarantees conformant OKF consumption, indexing, search, and generic content/fragment reads. AKM-authored Markdown is an OKF-compatible superset, and adapters add native behavior progressively. The `okf` adapter remains consumer-only until it owns a complete authoring path.
473
+
474
+ **Why:** OKF deliberately defines the useful minimum for portable Markdown. Using that minimum as the read baseline avoids a closed type gate; keeping capabilities adapter-owned avoids translation loss for native skills, agent configuration, workflow programs, tasks, scripts, sensitive files, and product-specific instruction systems.
475
+
476
+ **Consequence:** Plain OKF bundles remain independently valid and portable. Unknown types receive generic behavior, while the AKM adapter enhances recognized native types without injecting automation policy or identity UUIDs into plain OKF bundles.
477
+
478
+ ### D3. A bundle has one adapter-owned component
479
+
480
+ **Decision:** One bundle maps to one component root and one adapter. The adapter owns file processing throughout that root and may recognize multiple native types.
481
+
482
+ **Why:** Nested adapter mounts created ambiguous file ownership and required subtraction, collision, and manifest machinery that AKM does not need. Native heterogeneous layouts such as an AKM stash or `.claude` directory already have one format-family owner.
483
+
484
+ **Consequence:** Separately governed roots are registered as separate bundles. There is no package manifest, nested-root subtraction, or cross-component collision machinery.
485
+
486
+ ### D4. Conventions and authoring rules belong to adapters
487
+
488
+ **Decision:** Adapters own native hard rules, soft conventions, guidance discovery, precedence, scaffolding, validation, and native serialization.
489
+
490
+ **Why:** A format cannot be safely edited if the code generating instructions and the code validating output evolve separately. Core-owned per-type convention files would reproduce the closed asset taxonomy.
491
+
492
+ **Consequence:** The adapter should derive model instructions and validators from one authoritative rule set where practical.
493
+
494
+ ### D5. Workspace policy remains distinct from native rules
495
+
496
+ **Decision:** Writability, trust, protected paths, engine selection, execution approval, auto-application, quotas, and retention remain workspace concerns.
497
+
498
+ **Why:** Two workspaces may consume the same bundle under different security and operational policies. Embedding these choices in portable files would reduce interoperability and permit bundles to escalate their own authority.
499
+
500
+ ### D6. Source materialization and content interpretation are separate
501
+
502
+ **Decision:** Materializers only acquire and refresh bytes. Adapters interpret native files.
503
+
504
+ **Why:** Combining transport and format creates a combinatorial architecture such as `git-okf`, `npm-claude`, and `filesystem-opencode`.
505
+
506
+ **Consequence:** Filesystem, Git, npm/archive, and website snapshot materialization can be reused with appropriate adapters.
507
+
508
+ ### D7. Website is a first-class refreshable source
509
+
510
+ **Decision:** AKM retains a safe website materializer and website snapshot adapter.
511
+
512
+ **Why:** Current website support is useful and should not be discarded merely because the existing implementation emits an AKM-specific `knowledge/` tree.
513
+
514
+ **Consequence:** A website may be mounted read-only and refreshed. It may also be exported or ingested into a writable destination bundle under that destination adapter's rules.
515
+
516
+ ### D8. Installation is not activation
517
+
518
+ **Decision:** Installing and indexing a bundle never activates code, schedules, tools, environment values, or secrets.
519
+
520
+ **Why:** Portable distribution and local authority are different trust decisions. A registry package must not gain execution rights simply because it is searchable.
521
+
522
+ **Consequence:** Runtime exports are explicitly bound; task schedules are explicitly enabled; secret and environment values are explicitly mapped.
523
+
524
+ **Framing correction (2026-07-13 review pass; staging finalized 2026-07-14, D30):** code verification showed the *current* install path already grants nothing (`akm add` only syncs+indexes; task sync scans only the primary writable stash; env injection is explicit and already origin-gated; workflow runs are explicit). D8 stands as design — but bindings are a **portability/correctness** capability (distributable runnable exports, digest-pinned updates, tamper detection), not a fix for a present-day escalation. Accordingly, 0.9.0 ships only the Tier-A consolidation of the existing enforcement; the record/digest machinery is Tier B, and a review-pass proposal to add an untrusted read-path clamp was considered and **rejected** as false-confidence machinery (D30, deviation §4.3c).
525
+
526
+ ### D9. Portable runtime definitions remain in bundles
527
+
528
+ **Decision:** Workflows, tasks, environment definitions, agents, commands, skills, and scripts may be distributed as native files.
529
+
530
+ **Why:** Reusability and package distribution are core AKM value. Moving all definitions into private workspace state would make them difficult to version, review, share, and install.
531
+
532
+ **Consequence:** The file definition is portable; the binding is local. Runs pin a definition digest and resolved policy.
533
+
534
+ ### D10. The core normalized content model stops at search
535
+
536
+ **Decision:** Core receives a narrow `IndexDocument`; it does not require universal `Concept`, `Skill`, `Agent`, or `Workflow` views.
537
+
538
+ **Why:** A richer universal semantic registry would become another asset framework and impose version negotiation on every adapter.
539
+
540
+ **Consequence:** Rich native parser types remain adapter- or runtime-specific.
541
+
542
+ ### D11. Search is local and adapter-free at query time
543
+
544
+ **Decision:** Adapters and materializers run during installation, refresh, indexing, validation, and mutation—not during ordinary search.
545
+
546
+ **Why:** Query-time adapters would produce inconsistent latency, partial failures, ranking differences, network dependencies, and difficult failure isolation.
547
+
548
+ **Consequence:** A failed refresh leaves the last good indexed state available where policy permits.
549
+
550
+ ### D12. Search behavior is preserved before it is simplified
551
+
552
+ **Decision:** Bundle discovery is replaced without simultaneously changing FTS weights, embedding inputs, ranking boosts, or result ordering.
553
+
554
+ **Why:** Search quality is sensitive and already has deterministic evaluation infrastructure. Combining discovery and ranking changes would make regressions ambiguous.
555
+
556
+ **Consequence:** Search simplifications and ranking ablations occur after parity.
557
+
558
+ ### D13. Ordinary reads use indexed paths
559
+
560
+ **Decision:** Once the index has resolved an item to an absolute local path, `show`, improve, execution loaders, and other services read the filesystem directly.
561
+
562
+ **Why:** An `adapter.read()` or repository facade adds indirection without adding value for deterministic local files.
563
+
564
+ **Consequence:** Adapters remain responsible for parsing and native interpretation when needed, not byte retrieval.
565
+
566
+ ### D14. Indexing never mutates bundles
567
+
568
+ **Decision:** `akm index` writes only derived workspace state.
569
+
570
+ **Why:** Search maintenance should not create source-control changes or unexpectedly rewrite native indexes and summaries.
571
+
572
+ **Consequence:** Native generated files such as an LLM Wiki `index.md` are repaired through explicit lint/fix, ingest, or adapter maintenance operations.
573
+
574
+ ### D15. Proposals and change sets are one concept
575
+
576
+ **Decision:** A proposal directly contains one or more `FileChange` records.
577
+
578
+ **Why:** Chains such as candidate → proposal → mutation plan → change set → transaction multiply terminology and conversion code.
579
+
580
+ **Consequence:** The transaction engine applies the same changes that were reviewed and evaluated.
581
+
582
+ ### D16. Every change carries a before hash
583
+
584
+ **Decision:** Updates and deletions include expected content hashes.
585
+
586
+ **Why:** Long-running model calls and review queues make stale overwrite a realistic risk.
587
+
588
+ **Consequence:** Diverged files fail safely and require regeneration or explicit conflict handling.
589
+
590
+ ### D17. Model confidence is diagnostic, not authority
591
+
592
+ **Decision:** Self-reported confidence cannot auto-accept a semantic proposal.
593
+
594
+ **Why:** The candidate generator cannot be its own ground truth. Current calibration largely measures validation survival rather than usefulness.
595
+
596
+ **Consequence:** Mechanical changes may auto-apply after deterministic validation; semantic changes require objective evidence or review.
597
+
598
+ ### D18. Improve is evidence-driven
599
+
600
+ **Decision:** Unattended semantic generation requires corrective evidence.
601
+
602
+ **Examples:** explicit negative feedback, failed task/eval, native validation failure, broken link, newly observed contradiction, or recurring independent session evidence.
603
+
604
+ **Not sufficient alone:** age, high retrieval, file size, salience, or elapsed time.
605
+
606
+ **Why:** Importance does not prove defect.
607
+
608
+ ### D19. Improve uses one stable snapshot
609
+
610
+ **Decision:** All semantic proposals in one run read the same file/index snapshot, and accepted output does not feed another semantic cycle in the same run.
611
+
612
+ **Why:** Same-run reindex and reprocessing create echo loops, order dependence, difficult evaluation, and extra locking.
613
+
614
+ **Consequence:** Subsequent scheduled runs provide later cycles only when new evidence or changed inputs exist.
615
+
616
+ ### D20. Improve has revise, learn, and consolidate
617
+
618
+ **Decision:** The durable semantic vocabulary is intentionally small:
619
+
620
+ ```text
621
+ revise improve an existing file
622
+ learn create a new durable item from evidence
623
+ consolidate bound a memory tier while preserving knowledge
624
+ ```
625
+
626
+ **Why:** Reflect, distill, recombine, inference, procedural compilation, and similar names had grown into separate orchestration paths despite sharing common mechanics.
627
+
628
+ ### D21. Memory lifecycle remains a core semantic capability
629
+
630
+ **Decision:** Memory maintenance stays within improve rather than being reduced to generic workspace housekeeping.
631
+
632
+ **Why:** Without consolidation and retirement, memory files grow without bound. Operational TTL cleanup alone cannot determine whether information is duplicated, superseded, contradictory, or ready for formalization.
633
+
634
+ **Consequence:** Memory-capable adapters expose native memory records and render lifecycle changes; core owns pressure, evidence, evaluation, transactions, and archive policy.
635
+
636
+ ### D22. Retirement is distinct from semantic status and purge
637
+
638
+ **Decision:** Operational lifecycle is:
639
+
640
+ ```text
641
+ active -> retired -> purged
642
+ active -> quarantined -> restored | purged
643
+ ```
644
+
645
+ **Why:** Native statuses such as superseded, contradicted, historical, and deprecated express meaning, while retirement expresses retrieval/storage policy. Purge is irreversible byte removal after a grace period.
646
+
647
+ ### D23. Memory pressure creates backpressure, not deletion proof
648
+
649
+ **Decision:** High-water thresholds trigger required maintenance, but storage pressure alone cannot authorize unsafe semantic deletion.
650
+
651
+ **Why:** A quota cannot prove that a unique claim is expendable.
652
+
653
+ **Consequence:** If safe reduction cannot reach the low-water mark, background intake queues evidence instead of continuing to publish memory files indefinitely.
654
+
655
+ ### D24. Semantic consolidation is non-destructive until verified
656
+
657
+ **Decision:** The system first creates and validates a successor, proves claim coverage and retrieval continuity, and only then retires source memories.
658
+
659
+ **Why:** LLM merge/delete decisions are vulnerable to omission, temporal flattening, and contradiction loss.
660
+
661
+ ### D25. The current repository is the host, not the permanent architecture
662
+
663
+ **Decision:** Replace incorrect centers in the existing repository, then delete them.
664
+
665
+ **Why:** The mature codebase contains security fixes, migration behavior, concurrency handling, exact Git boundaries, and thousands of tests that a clean-room rewrite would have to rediscover.
666
+
667
+ **Consequence:** Temporary seams have named deletion milestones. There is no permanent `legacy-akm` format.
668
+
669
+ ### D26. Three databases remain
670
+
671
+ **Decision:** The final storage model is:
672
+
673
+ ```text
674
+ state.db durable workspace truth
675
+ index.db disposable search and derived caches
676
+ logs.db high-volume purgeable logs
677
+ ```
678
+
679
+ **Why:** `workflow.db` is durable state with the same migration discipline and should merge into `state.db`; logs remain operationally distinct.
680
+
681
+ ### D27. The retirement archive supersedes the WS-3a git-only recovery decision (added 2026-07-13)
682
+
683
+ **Decision:** the workspace content-addressed archive (`$DATA/archive/blobs/sha256/<digest>`, owner-only modes, grace + purge + holds; normative §25.8) is the retirement recovery mechanism. This **explicitly supersedes** the 2026-06-15 WS-3a signoff (`consolidate.ts:1921`) that retired the archive-retention machinery in favor of "git history is the recovery path."
684
+
685
+ **Why WS-3a was right then and wrong now:** with a single git-backed writable stash, git history was a sufficient recovery path and the TTL archive scan was gold-plating. The bundle-workspace model breaks WS-3a's premise three ways: read-only installed components cannot be edited to mark retirement (the overlay needs workspace-side state), non-git-backed bundles (filesystem/npm/website materializations) have no history at all, and format-independent recovery cannot depend on one VCS. Git history remains an *additional* recovery path.
686
+
687
+ **Consequence:** one retirement encoding at a time — the bundle-local `archiveCleanupCandidate` move (`.akm/memory-cleanup/archive/`, shared by memory cleanup, consolidate pair-pass retire proposals, and promotion retirement since 0.9.17-alpha.9) is a bounded stopgap until the workspace store lands; there are never two coexisting encodings.
688
+
689
+ ### D28. The `type:name` ref contract is broken deliberately, once, with a written migration story (added 2026-07-13)
690
+
691
+ **Decision:** dropping `[origin//]type:name` breaks the top item in STABILITY.md's Stable tier and the roadmap's planned 1.0 ref-format freeze. This is done deliberately in 0.9.0 (pre-1.0, the last window where it is cheap), with: STABILITY.md/roadmap/AGENTS.md rewritten to the new grammar in the same release; the CHANGELOG carrying the breaking-change migration note per STABILITY's own policy; no read-only compat resolver for old refs post-cutover (a permanent dual-parser is prohibited, normative §11.4); and the one-time migrator handling all durable state under the orphan taxonomy.
692
+
693
+ **Why:** the ref grammar is the coupling spine the whole refactor exists to remove; carrying a compat parser would preserve the architecture the release deletes.
694
+
695
+ ### D29. Canonical ref spelling, short-ref resolution, and bundle rename (added 2026-07-13)
696
+
697
+ **Decision:** durable state always stores the fully-qualified `bundle//conceptId`; the short form is CLI input sugar only; short refs inside bundle content resolve to the containing bundle (portable by construction); prose body refs use only the anchored fully-qualified form; `akm bundle rename` is a first-class rekey transaction; conceptIds are NFC-normalized, `/`-separated, byte-wise case-sensitive with case-collision diagnostics. (Normative §11.1/§11.5.)
698
+
699
+ **Why:** today's `rekeyStateDbForMove` probing three legacy spellings per ref is the measured cost of leaving canonical spelling open; installer-default resolution of in-content short refs would silently retarget shared bundles per consumer; a bundle rename without rekey orphans all ref-keyed durable state.
700
+
701
+ ### D30. Release staging: demand-driven machinery only (added 2026-07-14)
702
+
703
+ **Decision:** 0.9.0 ships no machinery built ahead of demand. Concretely: **bindings at Tier A only** — the existing install≠activation enforcement consolidates into one workspace activation-policy point as ports with port-preservation tests; the persisted `Binding` record, export digests, rebind-on-update, and the bind CLI are Tier B, deferred indefinitely, revisited only on concrete demand. **The memory-lifecycle state model (§25) is deferred entirely** — 0.9.0 decomposes `consolidate.ts` with behavior preserved exactly; the lifecycle begins only when its load-bearing dependency (the claim extractor + benchmark) exists. **All new trust/approval machinery is dropped** — trusted labeling, action clamping, approval prompts, catch-all sensitive-content refusals: in practice these are not helpful, provide a false sense of security, and force maintenance of brittle code; only protections that exist in code today survive the port. **Net-LOC is a reported ledger, not a DoD gate** — deletion is gated by inventory (zero-count greps, per-chunk ledgers) and behavior tests, so the prove-or-delete tier is never pressured by a vanity number. **Sequencing is hygiene-first**: the code-quality half (decomposition, DI, one transaction, DRY) lands as Wave 1 before the identity-migration half, so its value banks independently.
704
+
705
+ **Why:** the D8 framing correction showed install already grants nothing; the external code-quality review showed the lifecycle state model was feature work in a refactor's clothing with an unshippable central gate; and the accepted residual (installed-source refs re-read current content per invocation — crontab semantics) is a deliberate operator-responsibility model, not an oversight. Guard against regression: proposals to re-add approval/trust/lifecycle machinery must name the concrete consumer that demands it.
706
+
707
+ **Consequence:** normative §18/§25 carry release-staging notes; the plan's Chunk 6.5 and §6 encode the Tier-A/deferred scopes; deviation-analysis §4.3a–3c are the decision record.
708
+
709
+ ---
710
+
711
+ ## 7. Choices that were superseded
712
+
713
+ | Superseded choice | Why it looked reasonable | Why it was rejected | Replacement |
714
+ |---|---|---|---|
715
+ | Add `okf` as an asset type | Small change to the current registry | Preserves closed type dispatch and duplicates wiki/knowledge semantics | Built-in OKF component adapter |
716
+ | Keep wiki and OKF as separate generic types | Preserves current commands and layout | Maintains two competing Markdown knowledge systems | LLM Wiki and OKF adapters plus generic bundle commands |
717
+ | Make every AKM-managed file native OKF | Maximizes apparent standardization | Invalidates or distorts native Agent Skills, Claude, OpenCode, YAML workflow, task, and script formats | Native adapters; optional OKF export |
718
+ | Use OKF as AKM's hidden universal object model | Gives the core one semantic vocabulary | Creates translation loss and makes the standard carry AKM concerns | Narrow search projection plus native parsers |
719
+ | Add an `akm:` frontmatter namespace by default | Portable place for IDs, provenance, and automation | Pollutes otherwise standard files and mixes workspace policy with file meaning | Preserve native fields; store operational state in workspace |
720
+ | Add persistent document UUIDs | Stable identity across moves | Duplicates transparent path identity and requires modifying third-party files | Bundle/component/local-ID refs plus explicit move rekey |
721
+ | Put automation policy in frontmatter | Keeps behavior near content | Lets a bundle prescribe local authority and makes the same file behave identically in unrelated workspaces | Workspace improve/execution policy |
722
+ | Include provider details in refs | Disambiguates multiple sources | Moving from Git cache to local checkout changes durable identity | Bundle installation name plus adapter-local ID |
723
+ | One adapter per bundle package | Simple initial model | Cannot naturally package knowledge, workflows, tasks, env, and skills together | Multi-component bundle package |
724
+ | Semantic view registry | Supports multiple meanings per item | Introduces another global ontology, dispatch system, and versioning burden | Narrow `IndexDocument`; native/runtime-specific codecs |
725
+ | Replaceable primitive base classes | Familiar extensibility pattern | Recreates inheritance and type-registry coupling | Plain adapter methods and opaque native kinds |
726
+ | `adapter.read()` for all reads | Encapsulates formats | Abstracts a deterministic `fs.readFile(path)` and obscures the actual source | Direct read by indexed path |
727
+ | Adapter-owned improve implementations | Lets each format customize improvement | Fragments quality policy and turns adapters into miniature AKM systems | Core revise/learn/consolidate with adapter guidance/validation/rendering |
728
+ | Preserve current improve unchanged behind a compatibility repository | Low migration risk | Retains proxy quality gates and orchestration complexity | Verified file-evolution refactor |
729
+ | Permanent `legacy-akm` adapter | Allows indefinite compatibility | Makes the old asset system a permanent supported format and prevents deletion | Migration-only reader, one-time conversion, removal milestone |
730
+ | Replace the whole product in a new repository | Clean architectural start | Reimplements mature safety/runtime behavior, creates two products, freezes assumptions too early | Modular replacement in the current repository |
731
+ | Website import only | Simplifies source types | Loses refreshable documentation and research use cases | Website snapshot materializer + adapter + native export |
732
+ | Put tasks and workflows only in workspace state | Clean portability boundary | Makes reusable automation difficult to distribute and version | Portable definitions plus local binding/activation |
733
+ | Forbid environment definitions in bundles | Strong default safety | Removes useful templates, key contracts, and private-bundle configurations | Portable safe definitions; explicit value binding and trust |
734
+ | Remove all improve housekeeping | Separates maintenance from semantics | Leaves memory tiers unbounded | Move operational GC out; retain semantic memory lifecycle in improve |
735
+ | Never remove semantic memories | Maximum preservation | Produces unbounded active and archived storage, degraded retrieval, and no forgetting path | Verified retirement, bounded archive, purge, and backpressure |
736
+ | Let LLM consolidation merge and delete directly | Efficient corpus reduction | Risks omitted claims, flattened contradictions, and irreversible loss | Successor-first, coverage-verified, reversible retirement |
737
+ | High retrieval or age triggers rewrite | Targets important or stale files | Importance and age do not demonstrate a defect | Corrective evidence gates; importance orders eligible work |
738
+ | Confidence threshold auto-accept | Cheap admission control | Generator self-score is not external evidence | Change-class policy plus objective verification/review |
739
+ | Auto-tune confidence thresholds | Appears to learn admission policy | Calibrates against validation survival, not user value | Tune from real outcomes only, if later justified |
740
+ | Live exploration promotion | Learns from lower-confidence candidates | Uses production bundles as an experiment | Shadow candidate evaluation |
741
+ | Same-run multiple improve cycles | Reaches a fixed point quickly | Creates self-feeding, order dependence, extra reindexing, and churn | One snapshot; future scheduled runs |
742
+ | Generic LLM quality judge for every kind | Uniform semantic gate | Rubric mismatch and documented judge biases | Recipe- and format-specific evaluators; judge as supporting signal |
743
+ | Universal task, memory, lesson, fact, and session schemas | Gives core consistent handling | Makes AKM itself a format standard and bloats `StashEntry` | Adapter-native schemas and workspace state |
744
+ | Remove conventions entirely | Simplifies core | Loses essential native authoring quality and bundle-specific rules | Move them to adapters |
745
+ | Index regenerates native `index.md` files | Keeps navigation fresh | Makes a read/cache command mutate source | Explicit adapter fix/maintenance operation |
746
+ | Registry results mixed into content search | One discovery command | Combines installed files with remote packages and incomparable ranking | Separate local search and package discovery |
747
+ | `manifest` as parallel discovery path | Cheap listing without search | Duplicates DB and filesystem discovery logic | Bundle items/search projection |
748
+ | Separate `curate` architecture | Focused context selection | Duplicates search, show, graph, and registry behavior | Search/context result-shaping mode |
749
+
750
+ ---
751
+
752
+ ## 8. Detailed final architecture
753
+
754
+ ### 8.1 Bundle installation and component composition
755
+
756
+ A bundle installation records:
757
+
758
+ ```text
759
+ stable workspace bundle name
760
+ materialized root
761
+ source revision/integrity
762
+ one component root
763
+ one adapter ID
764
+ writability and trust state
765
+ ```
766
+
767
+ The bundle name is a workspace identity, not necessarily the upstream package name. Two installations of the same package may use different names when intentionally mounted twice.
768
+
769
+ Each bundle's selected adapter owns its entire component root. Separately registered bundles may point into the same package, but each has an independent identity and no file is dispatched between nested adapters within one bundle.
770
+
771
+ ### 8.2 Materializers
772
+
773
+ Materializers should remain small:
774
+
775
+ ```ts
776
+ interface Materializer {
777
+ materialize(request: MaterializeRequest): Promise<MaterializedSource>;
778
+ refresh?(installation: MaterializedSource): Promise<MaterializedSource>;
779
+ }
780
+ ```
781
+
782
+ They own:
783
+
784
+ - downloading or cloning;
785
+ - cache paths;
786
+ - revision and integrity resolution;
787
+ - secure archive extraction;
788
+ - refresh behavior;
789
+ - stale-cache fallback where appropriate.
790
+
791
+ They do not own:
792
+
793
+ - indexing fields;
794
+ - item refs;
795
+ - native validation;
796
+ - authoring rules;
797
+ - execution;
798
+ - search.
799
+
800
+ ### 8.3 Adapter contract
801
+
802
+ The adapter owns format semantics:
803
+
804
+ ```ts
805
+ interface BundleAdapter {
806
+ index(component: InstalledComponent): AsyncIterable<IndexDocument>;
807
+
808
+ validate(
809
+ component: InstalledComponent,
810
+ changes: FileChange[],
811
+ ): Promise<Diagnostic[]>;
812
+
813
+ getAuthoringContext?(
814
+ component: InstalledComponent,
815
+ target: AuthoringTarget,
816
+ operation: "create" | "update" | "move" | "consolidate",
817
+ ): Promise<AuthoringContext>;
818
+
819
+ create?(
820
+ component: InstalledComponent,
821
+ request: CreateRequest,
822
+ ): Promise<FileChange[]>;
823
+ }
824
+ ```
825
+
826
+ Optional facets expose runtime exports and memory lifecycle behavior. These are targeted ports, not semantic views.
827
+
828
+ ### 8.4 Adapter authoring context
829
+
830
+ The authoring context should contain:
831
+
832
+ - a rule-set version;
833
+ - native format instructions;
834
+ - applicable convention or guidance files;
835
+ - path and precedence information;
836
+ - examples where useful;
837
+ - restrictions on allowed file changes.
838
+
839
+ The evidence fingerprint for a semantic proposal includes the rule-set version and hashes of the applicable guidance. A change in conventions therefore invalidates an old no-op or rejected fingerprint without relying on arbitrary time cooldowns.
840
+
841
+ ### 8.5 Local search
842
+
843
+ The query path is:
844
+
845
+ ```text
846
+ query
847
+ -> local FTS/vector index
848
+ -> common ranking
849
+ -> bundle/component/kind filters
850
+ -> result shaping
851
+ ```
852
+
853
+ It does not perform:
854
+
855
+ - adapter calls;
856
+ - materializer refresh;
857
+ - filesystem scanning;
858
+ - remote registry search;
859
+ - website fetches;
860
+ - LLM enrichment;
861
+ - graph extraction.
862
+
863
+ The initial migration preserves the current search field composition and ranking behavior. Later ablations may remove complexity such as type boosts, graph boosts, scoped utility, or project-context heuristics only when benchmarks show no loss or a net gain.
864
+
865
+ ### 8.6 Progressive disclosure
866
+
867
+ The design adopts a retrieval behavior similar to OpenViking's abstract/overview/detail layers and Agent Skills' metadata/instructions/resources structure without requiring sidecar files in every format. See [OpenViking context layers](https://github.com/volcengine/OpenViking/blob/main/docs/en/concepts/03-context-layers.md) and the [Agent Skills specification](https://agentskills.io/specification).
868
+
869
+ ```text
870
+ L0 card indexed title, summary, kind, hints
871
+ L1 overview outline, native links, applicability, navigation
872
+ L2 detail full native file
873
+ resources supporting files loaded on demand
874
+ ```
875
+
876
+ Derived cards, outlines, chunks, and embeddings live in `index.db` unless the native format itself defines portable equivalents.
877
+
878
+ ### 8.7 Direct read and show
879
+
880
+ `show` should:
881
+
882
+ 1. resolve the item ref in `index.db`;
883
+ 2. verify the file remains inside its component root;
884
+ 3. read the absolute path;
885
+ 4. return indexed metadata and requested content detail;
886
+ 5. record usage.
887
+
888
+ Format-specific parsing is performed only when the requested operation needs it. `show` does not invoke a global renderer registry.
889
+
890
+ ### 8.8 Website snapshot and export
891
+
892
+ A refreshable website installation preserves page-level provenance:
893
+
894
+ ```text
895
+ canonical URL
896
+ fetched URL
897
+ title
898
+ text/Markdown
899
+ content hash
900
+ outbound links
901
+ ETag/Last-Modified when available
902
+ fetch timestamp
903
+ snapshot revision
904
+ ```
905
+
906
+ The current safety behavior remains important:
907
+
908
+ - private and loopback hosts denied by default;
909
+ - redirect targets revalidated;
910
+ - response byte caps;
911
+ - bounded pages/depth/queue;
912
+ - whole-crawl wall-clock cap;
913
+ - stale cache fallback;
914
+ - explicit refresh.
915
+
916
+ Export into a writable bundle runs through the destination adapter's authoring and validation rules. The exported copy and the live website snapshot are separate items with explicit provenance; refresh does not silently overwrite the curated destination.
917
+
918
+ ### 8.9 Registry and package discovery
919
+
920
+ Registry search discovers installable packages and their declared components. It does not participate in local relevance ranking.
921
+
922
+ A registry entry should expose:
923
+
924
+ - package identity and description;
925
+ - source locator;
926
+ - version/revision;
927
+ - integrity metadata where available;
928
+ - component roots and adapter IDs where declared;
929
+ - trust/provenance information;
930
+ - install command.
931
+
932
+ It should not require a full inventory of every contained item.
933
+
934
+ ### 8.10 Runtime exports and bindings
935
+
936
+ An adapter may expose:
937
+
938
+ ```ts
939
+ interface BundleExport {
940
+ id: string;
941
+ kind: "workflow" | "task" | "environment" |
942
+ "agent" | "command" | "skill" | "script";
943
+ itemRef: string;
944
+ digest: string;
945
+ requirements?: BindingRequirement[];
946
+ }
947
+ ```
948
+
949
+ A binding records local approval and configuration:
950
+
951
+ ```text
952
+ export ref and digest
953
+ local alias
954
+ engine/runtime selection
955
+ parameters
956
+ workspace environment/secret mappings
957
+ tool and filesystem policy
958
+ approval state
959
+ update policy
960
+ enabled scheduler state where applicable
961
+ ```
962
+
963
+ Bindings are workspace state and are not written back into portable files.
964
+
965
+ ### 8.11 Workflow behavior
966
+
967
+ A workflow remains portable and may be run directly by full export ref or through a binding.
968
+
969
+ A run freezes:
970
+
971
+ - bundle revision;
972
+ - component/adapter version;
973
+ - export digest;
974
+ - parsed or compiled plan;
975
+ - plan hash;
976
+ - resolved non-secret parameters and engine settings;
977
+ - approved environment binding identities.
978
+
979
+ An installed update cannot mutate the definition used by an in-flight run.
980
+
981
+ ### 8.12 Task behavior
982
+
983
+ A portable task describes a schedule template and target. Binding a task:
984
+
985
+ - pins its digest;
986
+ - supplies local parameters and environment bindings;
987
+ - validates the target;
988
+ - registers a scheduler entry only after explicit enablement.
989
+
990
+ A bundle update that changes the schedule, target, or requirements does not silently rewrite the active scheduler entry. AKM shows the diff and requires explicit application.
991
+
992
+ ### 8.13 Environment definitions
993
+
994
+ Portable environment components may contain:
995
+
996
+ - key names and descriptions;
997
+ - required/optional declarations;
998
+ - non-secret defaults;
999
+ - `.env` templates;
1000
+ - placeholders for secrets;
1001
+ - trusted private environment files when intentionally distributed.
1002
+
1003
+ Indexing exposes only safe metadata. Values are never indexed or printed. Workspace binding maps keys to local values, files, keychains, secret stores, or approved private-bundle values.
1004
+
1005
+ ### 8.14 Execution security
1006
+
1007
+ The design follows the same fundamental separation emphasized by MCP between passive resources and actionable tools: descriptive content is not execution authority. See [MCP server concepts](https://modelcontextprotocol.io/docs/learn/server-concepts).
1008
+
1009
+ An indexed `kind: script` or native file named `task` does not authorize execution. The workspace must have:
1010
+
1011
+ - a trusted adapter/runtime codec;
1012
+ - an explicit binding or direct operator invocation;
1013
+ - an approved runtime handler;
1014
+ - applicable environment and tool policy;
1015
+ - path and process controls.
1016
+
1017
+ ---
1018
+
1019
+ ## 9. Improve: from self-scored proposals to verified evolution
1020
+
1021
+ ### 9.1 What current improve does well
1022
+
1023
+ The current implementation contains valuable mechanisms that should inform the replacement:
1024
+
1025
+ - candidate selection from usage, feedback, and session evidence;
1026
+ - proposal queues rather than universal direct writes;
1027
+ - deterministic validators;
1028
+ - backups and revert;
1029
+ - run metrics;
1030
+ - memory-specific cleanup and contradiction handling;
1031
+ - model call caching and bounded work;
1032
+ - replay/evaluation infrastructure;
1033
+ - collapse and churn monitoring.
1034
+
1035
+ The problem is not that current improve has no value. The problem is that orchestration, maintenance, selection policy, file mutation, and quality claims became entangled.
1036
+
1037
+ ### 9.2 The proxy-quality failure
1038
+
1039
+ Several current signals are useful but insufficient:
1040
+
1041
+ - A proposal passing syntax and structure checks proves it is valid, not better.
1042
+ - A model's confidence is correlated with its own generation process, not independent ground truth.
1043
+ - Auto-accept calibration against validator survival measures gate throughput, not usefulness.
1044
+ - An asset being retrieved more often does not establish that the most recent rewrite caused the increase.
1045
+ - A generic novelty/actionability judge cannot verify every skill, workflow, script, factual document, or agent prompt.
1046
+
1047
+ This is consistent with research showing that intrinsic self-correction without grounded feedback is unreliable. See [Large Language Models Cannot Self-Correct Reasoning Yet](https://arxiv.org/abs/2310.01798). LLM judges are useful but exhibit known biases, including position effects; see [Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena](https://arxiv.org/abs/2306.05685) and [Position Bias in LLM-based Evaluators](https://arxiv.org/abs/2406.07791).
1048
+
1049
+ ### 9.3 Target improve stages
1050
+
1051
+ ```text
1052
+ 1. Collect corrective evidence.
1053
+ 2. Select an eligible target or learning destination.
1054
+ 3. Freeze paths, hashes, guidance hashes, and relevant search context.
1055
+ 4. Generate candidate FileChange records.
1056
+ 5. Run deterministic native and security validation.
1057
+ 6. Compare candidate with baseline using a recipe-specific evaluator.
1058
+ 7. Queue for review or apply under explicit policy.
1059
+ 8. Reindex affected paths once.
1060
+ 9. Observe later acceptance, task, retrieval, feedback, and revert outcomes.
1061
+ ```
1062
+
1063
+ ### 9.4 Corrective evidence
1064
+
1065
+ Examples include:
1066
+
1067
+ - explicit user correction or negative feedback;
1068
+ - a failed task or workflow;
1069
+ - a failed retrieval or quality benchmark;
1070
+ - a native adapter diagnostic;
1071
+ - a broken link or unresolved resource;
1072
+ - a newly detected contradiction;
1073
+ - a new completed session with extractable evidence;
1074
+ - recurrence across independent sessions, tasks, projects, or sources.
1075
+
1076
+ Importance signals such as usage, salience, and retrieval frequency may prioritize eligible items but do not independently admit semantic rewriting.
1077
+
1078
+ ### 9.5 Input fingerprints
1079
+
1080
+ A stable fingerprint replaces several overlapping cooldown and duplicate mechanisms:
1081
+
1082
+ ```text
1083
+ fingerprint = hash(
1084
+ recipe version
1085
+ + target before hashes
1086
+ + evidence IDs and hashes
1087
+ + applicable guidance hashes
1088
+ + evaluator version
1089
+ )
1090
+ ```
1091
+
1092
+ If the same fingerprint has already produced a no-op, rejected candidate, or completed evaluation, AKM does not spend another model call unless explicitly forced. A changed file, new evidence, changed convention, new recipe version, or new evaluator opens a new attempt naturally.
1093
+
1094
+ ### 9.6 Verification ladder
1095
+
1096
+ #### Level 1: native and security safety
1097
+
1098
+ - format parses and validates;
1099
+ - paths remain inside authorized components;
1100
+ - protected fields and unknown native fields are preserved;
1101
+ - links/resources remain valid;
1102
+ - secrets do not enter output or indexable content;
1103
+ - before hashes still match.
1104
+
1105
+ This proves safety, not improvement.
1106
+
1107
+ #### Level 2: behavioral comparison
1108
+
1109
+ Depending on the recipe:
1110
+
1111
+ - failing tests pass against the candidate;
1112
+ - workflow dry run or task replay improves;
1113
+ - trigger and holdout retrieval metrics improve;
1114
+ - protected search canaries do not regress;
1115
+ - required claims remain covered;
1116
+ - native examples or conformance cases pass;
1117
+ - output-size, latency, or cost improves without quality loss.
1118
+
1119
+ #### Level 3: field outcome
1120
+
1121
+ - human accepts or prefers the proposal;
1122
+ - later use earns positive feedback;
1123
+ - production task success improves;
1124
+ - the change survives its observation period;
1125
+ - the proposal is not reverted;
1126
+ - downstream users select the successor rather than searching around it.
1127
+
1128
+ Only Level 2 or explicit review should normally authorize unattended semantic application. Level 3 improves future policy and recipe selection.
1129
+
1130
+ ### 9.7 Change classes
1131
+
1132
+ | Class | Examples | Default treatment |
1133
+ |---|---|---|
1134
+ | Mechanical | deterministic formatting, generated index repair, exact link rewrite | Auto-apply after validation |
1135
+ | Objectively verified semantic | task replay improvement, retrieval improvement with protected non-regression | Auto-apply only when workspace policy permits |
1136
+ | Subjective semantic | prose rewrite, style change, unverified synthesis | Review |
1137
+ | Destructive | deletion, broad merge, supersession, cross-file rewrite | Review unless deterministic and recoverable |
1138
+
1139
+ ### 9.8 Process mapping
1140
+
1141
+ | Current behavior | Target behavior |
1142
+ |---|---|
1143
+ | Reflect | Revise recipe |
1144
+ | Distill | Learn recipe |
1145
+ | Extract | Evidence intake that may feed learn |
1146
+ | Recombine | Multi-source learn recipe, not a separate framework |
1147
+ | Memory inference | Evidence normalization or learn recipe |
1148
+ | Consolidate | First-class memory consolidation |
1149
+ | Procedural compilation | Removed until recurring executable traces and task-level evaluation exist |
1150
+ | Graph extraction | Optional index processor |
1151
+ | URL checks | Lint/health |
1152
+ | Proposal expiry and orphan cleanup | Proposal maintenance |
1153
+ | DB and log retention | Workspace maintenance |
1154
+ | Git commit/push | Transaction/materializer boundary |
1155
+
1156
+ ### 9.9 Features that must earn their way back
1157
+
1158
+ The replacement does not automatically carry forward:
1159
+
1160
+ - self-consistency sampling selected by text similarity;
1161
+ - generic self-critique and rewrite loops;
1162
+ - generic LLM quality judging;
1163
+ - high-retrieval proactive rewriting;
1164
+ - multi-cycle same-run execution;
1165
+ - confidence-threshold auto-tuning;
1166
+ - live exploration promotion;
1167
+ - procedural compilation;
1168
+ - LLM graph boosts;
1169
+ - complex salience and homeostatic selection.
1170
+
1171
+ Each must beat a simpler baseline on verified quality, regressions, runtime, and cost.
1172
+
1173
+ Anthropic's [Building Effective Agents](https://www.anthropic.com/engineering/building-effective-agents) reinforces this burden-of-proof approach: use the simplest composable pattern that works, and add evaluator-optimizer loops only when criteria are clear and measurable.
1174
+
1175
+ ---
1176
+
1177
+ ## 10. Bounded memory lifecycle
1178
+
1179
+ ### 10.1 Why memory is the largest unresolved design area
1180
+
1181
+ A system that continuously captures sessions, feedback, and observations will grow indefinitely unless it supports:
1182
+
1183
+ - deduplication;
1184
+ - contradiction handling;
1185
+ - consolidation;
1186
+ - formalization;
1187
+ - retirement;
1188
+ - actual removal.
1189
+
1190
+ Removing memory housekeeping would preserve every observation but eventually degrade retrieval, increase model context pressure, increase indexing cost, and make review impossible. Conversely, aggressive automated merging and deletion can destroy unique evidence.
1191
+
1192
+ The final design therefore treats memory lifecycle as a required semantic capability with reversible and measurable stages.
1193
+
1194
+ ### 10.2 Memory is a capability, not a universal AKM schema
1195
+
1196
+ A memory-capable adapter exposes its native memory files through a narrow operational record. The adapter owns:
1197
+
1198
+ - discovery;
1199
+ - native metadata;
1200
+ - provenance representation;
1201
+ - contradiction/supersession representation;
1202
+ - serialization;
1203
+ - applicable conventions;
1204
+ - native validation.
1205
+
1206
+ Core owns:
1207
+
1208
+ - pressure calculation;
1209
+ - evidence and usage signals;
1210
+ - candidate selection;
1211
+ - verification;
1212
+ - proposals and transactions;
1213
+ - retirement overlays;
1214
+ - archive and purge policy;
1215
+ - scheduling and backpressure.
1216
+
1217
+ ### 10.3 Lifecycle states
1218
+
1219
+ ```text
1220
+ active
1221
+ -> retired
1222
+ -> purged
1223
+
1224
+ active
1225
+ -> quarantined
1226
+ -> restored | purged
1227
+ ```
1228
+
1229
+ These operational states are distinct from native semantic states such as:
1230
+
1231
+ ```text
1232
+ asserted
1233
+ active
1234
+ superseded
1235
+ contradicted
1236
+ deprecated
1237
+ historical
1238
+ archived
1239
+ ```
1240
+
1241
+ A memory may be semantically contradicted yet retained for historical evidence. It may be semantically active but operationally retired because its claims were formalized into a durable successor.
1242
+
1243
+ ### 10.4 Consolidation outcomes
1244
+
1245
+ #### A. Compact within the memory tier
1246
+
1247
+ Use when several memories repeat or fragment the same observation.
1248
+
1249
+ ```text
1250
+ source memories
1251
+ -> stronger replacement memory or small coherent set
1252
+ -> verified claim coverage
1253
+ -> source retirement
1254
+ ```
1255
+
1256
+ #### B. Formalize into durable content
1257
+
1258
+ Use when recurring evidence has matured into:
1259
+
1260
+ - knowledge;
1261
+ - a lesson;
1262
+ - a convention;
1263
+ - a runbook;
1264
+ - a workflow;
1265
+ - a task;
1266
+ - an agent instruction;
1267
+ - another native destination supported by an adapter.
1268
+
1269
+ ```text
1270
+ memory cluster
1271
+ -> destination adapter authoring context
1272
+ -> successor file changes
1273
+ -> destination validation and evaluation
1274
+ -> source retirement
1275
+ ```
1276
+
1277
+ The destination is workspace-configured and may be in another bundle or repository.
1278
+
1279
+ #### C. Retire without formalization
1280
+
1281
+ Valid examples:
1282
+
1283
+ - exact duplicate;
1284
+ - explicit supersession;
1285
+ - TTL-expired ephemeral state;
1286
+ - obsolete temporary context;
1287
+ - unsafe or privacy-sensitive capture;
1288
+ - user-requested forgetting;
1289
+ - invalid generated derivative.
1290
+
1291
+ Not every memory warrants promotion into a formal document.
1292
+
1293
+ ### 10.5 High-water and low-water marks
1294
+
1295
+ A memory policy should support both item and byte pressure:
1296
+
1297
+ ```yaml
1298
+ memory:
1299
+ highWaterItems: 1000
1300
+ lowWaterItems: 800
1301
+ highWaterBytes: 52428800
1302
+ retireGraceDays: 30
1303
+ archiveRetentionDays: 180
1304
+ archiveMaxBytes: 1073741824
1305
+ backgroundIntakeWhenBlocked: queue
1306
+ ```
1307
+
1308
+ Behavior:
1309
+
1310
+ 1. High-water crossing makes consolidation required.
1311
+ 2. Deterministic candidates are processed first.
1312
+ 3. Semantic work proceeds until low water is reached or no safe action remains.
1313
+ 4. Pressure does not lower preservation gates.
1314
+ 5. If the tier cannot be safely reduced, new background memory publication pauses.
1315
+ 6. New observations stay in a workspace evidence queue.
1316
+ 7. Explicit user capture may remain available with a clear warning.
1317
+ 8. Health reports active count, retired count, archive size, pending evidence, and unresolved pressure.
1318
+
1319
+ This backpressure mechanism is the safe alternative to “delete until under quota.”
1320
+
1321
+ ### 10.6 Deterministic cleanup first
1322
+
1323
+ No model is needed for:
1324
+
1325
+ - byte-identical duplicates;
1326
+ - content-identical files with equivalent provenance;
1327
+ - expired ephemeral memories under explicit policy;
1328
+ - derived artifacts whose source and successor are known;
1329
+ - missing or invalid generated files;
1330
+ - explicit supersession with a valid successor;
1331
+ - known unsafe content requiring quarantine.
1332
+
1333
+ This is cheaper, more reliable, and reduces the semantic candidate pool.
1334
+
1335
+ ### 10.7 Source-to-successor coverage map
1336
+
1337
+ Before source retirement, every durable claim receives a disposition:
1338
+
1339
+ ```text
1340
+ claim
1341
+ ├── preserved in successor
1342
+ ├── preserved in another retained source
1343
+ ├── explicitly superseded
1344
+ └── intentionally discarded with reason and policy authority
1345
+ ```
1346
+
1347
+ An unaccounted durable claim blocks retirement.
1348
+
1349
+ Coverage also preserves:
1350
+
1351
+ - temporal qualifiers;
1352
+ - uncertainty;
1353
+ - attribution;
1354
+ - contradictory evidence;
1355
+ - source links;
1356
+ - scope and applicability.
1357
+
1358
+ ### 10.8 Retrieval and task non-regression
1359
+
1360
+ A consolidation proposal should be compared against the current corpus in a sandboxed index.
1361
+
1362
+ Evaluation should include:
1363
+
1364
+ - queries that retrieved each source;
1365
+ - related holdout queries;
1366
+ - global protected canaries;
1367
+ - historical queries where the original source remains important;
1368
+ - negative/banned queries;
1369
+ - tasks or workflows affected by formalized content;
1370
+ - destination-format validation.
1371
+
1372
+ A successor that simply repeats trigger keywords but loses broader retrieval should fail.
1373
+
1374
+ ### 10.9 Cross-bundle and cross-repository formalization
1375
+
1376
+ True filesystem atomicity is impossible across independent repositories.
1377
+
1378
+ Use a recoverable two-phase protocol:
1379
+
1380
+ ```text
1381
+ Phase 1
1382
+ create, commit, and validate successor in destination
1383
+
1384
+ Phase 2
1385
+ retire sources in memory component
1386
+ ```
1387
+
1388
+ If Phase 2 fails, duplicate knowledge temporarily remains, which is safer than source loss. The operation journal records both phases and can resume.
1389
+
1390
+ ### 10.10 Retirement archive
1391
+
1392
+ Retired bytes move to a bounded workspace content-addressed archive:
1393
+
1394
+ ```text
1395
+ $AKM_DATA/archive/blobs/sha256/<digest>
1396
+ ```
1397
+
1398
+ `state.db` stores:
1399
+
1400
+ - original bundle/component/ref/path;
1401
+ - source content hash;
1402
+ - retirement reason;
1403
+ - successor refs;
1404
+ - proposal/change ID;
1405
+ - retired timestamp;
1406
+ - grace and purge eligibility;
1407
+ - legal/user hold;
1408
+ - restore status.
1409
+
1410
+ The archive is not inside a bundle and is not normally indexed.
1411
+
1412
+ ### 10.11 Purge
1413
+
1414
+ After the grace period, purge requires:
1415
+
1416
+ - no active hold;
1417
+ - successor still valid when one exists;
1418
+ - no detected retrieval or task regression;
1419
+ - retention policy approval;
1420
+ - archive size or age eligibility.
1421
+
1422
+ Git history may provide additional recovery for Git-backed bundles, but the workspace archive is the controlled, format-independent recovery mechanism.
1423
+
1424
+ ### 10.12 Read-only bundles
1425
+
1426
+ A read-only source cannot be edited to mark retirement. The workspace therefore supports a retirement overlay keyed by item ref and source digest.
1427
+
1428
+ The overlay:
1429
+
1430
+ - suppresses the item from normal retrieval;
1431
+ - remains workspace-local;
1432
+ - invalidates automatically when source content changes materially;
1433
+ - never pretends the upstream file was modified.
1434
+
1435
+ ### 10.13 Evidence from adjacent memory systems
1436
+
1437
+ The design draws useful principles from, without blindly copying:
1438
+
1439
+ - [Generative Agents](https://arxiv.org/abs/2304.03442): observation streams plus higher-level reflections;
1440
+ - [A-MEM](https://arxiv.org/abs/2502.12110): dynamic organization and linking of agent memories;
1441
+ - [Zep: A Temporal Knowledge Graph Architecture for Agent Memory](https://arxiv.org/abs/2501.13956): temporal and historical relationship preservation;
1442
+ - [All-Mem](https://arxiv.org/abs/2603.19595): explicit memory lifecycle and non-destructive consolidation ideas;
1443
+ - [E-mem](https://arxiv.org/abs/2601.21714): risks of destructive preprocessing and loss of sequential context.
1444
+
1445
+ These systems support separating episodic evidence from consolidated semantic knowledge, but AKM still requires its own claim-coverage, retrieval, task, and recovery gates.
1446
+
1447
+ ---
1448
+
1449
+ ## 11. Repository implementation implications
1450
+
1451
+ ### 11.1 Architectural centers to replace
1452
+
1453
+ The following are not merely renamed:
1454
+
1455
+ - `AssetSpec` and the asset registry;
1456
+ - `AkmAssetType` and `TYPE_DIRS`;
1457
+ - global file matchers and specificity scores;
1458
+ - renderer and action-builder registries;
1459
+ - `[origin//]type:name` refs;
1460
+ - `StashEntry`;
1461
+ - `.stash.json` overlays;
1462
+ - `.meta` special files;
1463
+ - wiki special cases;
1464
+ - type-derived write paths;
1465
+ - current one-file proposal payload;
1466
+ - confidence auto-accept and threshold tuning;
1467
+ - the current broad improve loop.
1468
+
1469
+ ### 11.2 Infrastructure to retain
1470
+
1471
+ The replacement should reuse or preserve the behavior of:
1472
+
1473
+ - atomic file writes with data and directory sync;
1474
+ - realpath and symlink containment;
1475
+ - secure archive extraction;
1476
+ - file locks and stale-lock recovery;
1477
+ - SQLite WAL and busy-timeout handling;
1478
+ - migration-ledger verification;
1479
+ - `BEGIN IMMEDIATE` contention hardening;
1480
+ - proposal transaction journals and crash recovery;
1481
+ - exact-path Git commits;
1482
+ - credential redaction and safe environment injection;
1483
+ - deterministic search evaluation;
1484
+ - workflow frozen-plan integrity;
1485
+ - scheduler backend safety;
1486
+ - typed errors and output isolation;
1487
+ - test XDG/data-directory guards.
1488
+
1489
+ ### 11.3 Source and installed-state configuration
1490
+
1491
+ Replace:
1492
+
1493
+ ```text
1494
+ stashDir
1495
+ sources[]
1496
+ installed[]
1497
+ primary
1498
+ defaultWriteTarget
1499
+ wikiName
1500
+ ```
1501
+
1502
+ with:
1503
+
1504
+ ```text
1505
+ bundles desired installations and component declarations
1506
+ defaultBundle default creation destination
1507
+ lock state resolved revisions, versions, integrity, and cache paths
1508
+ bindings local runtime activation
1509
+ ```
1510
+
1511
+ ### 11.4 Index schema migration
1512
+
1513
+ The conceptual row becomes:
1514
+
1515
+ ```text
1516
+ item_ref
1517
+ bundle_id
1518
+ component_id
1519
+ adapter_id
1520
+ local_id
1521
+ kind
1522
+ file_path
1523
+ content_hash
1524
+ search projection JSON
1525
+ ```
1526
+
1527
+ The existing integer row ID can remain for FTS and vector joins. Durable feedback and usage should ultimately key by item ref so deleting/rebuilding the disposable index does not erase learning.
1528
+
1529
+ ### 11.5 Show, manifest, and curate
1530
+
1531
+ - `show` becomes direct index resolution and file read.
1532
+ - `manifest` becomes `bundle items` or a compact list/search projection.
1533
+ - `curate` becomes context-oriented search result shaping.
1534
+ - Registry discovery leaves ordinary content search.
1535
+ - Lazy graph extraction leaves read paths.
1536
+
1537
+ ### 11.6 Wiki
1538
+
1539
+ Move native wiki behavior into the LLM Wiki adapter and replace the command family with generic bundle/search/lint/import/ingest operations.
1540
+
1541
+ ### 11.7 Workflows and tasks
1542
+
1543
+ - Load portable definitions by indexed path.
1544
+ - Keep native workflow/task codecs.
1545
+ - Freeze run definition digests and plans.
1546
+ - Move scheduler activation into bindings.
1547
+ - Merge workflow durable state into `state.db`.
1548
+
1549
+ ### 11.8 Environment and secrets
1550
+
1551
+ - Keep the current secure injection and redaction behavior.
1552
+ - Stop modeling values as general searchable assets.
1553
+ - Permit portable definitions and private values only under explicit trust and binding policy.
1554
+
1555
+ ### 11.9 Sessions and capture
1556
+
1557
+ - Session logs and summaries are workspace evidence by default.
1558
+ - They may be indexed without being written into a portable bundle.
1559
+ - Explicit publish can create a native destination item.
1560
+ - `remember` should evolve into capture evidence or create a native item in a selected component rather than impose one universal memory schema.
1561
+
1562
+ ### 11.10 Feedback
1563
+
1564
+ Feedback remains durable workspace state. It must not mutate portable files merely to record lesson strength, retrieval count, or utility.
1565
+
1566
+ ### 11.11 Graph
1567
+
1568
+ Index native deterministic links first. Keep LLM graph extraction only if ablation proves meaningful value beyond FTS, embeddings, native links, and usage signals.
1569
+
1570
+ ### 11.12 Databases
1571
+
1572
+ Target:
1573
+
1574
+ ```text
1575
+ state.db
1576
+ events
1577
+ proposals and changes
1578
+ bindings
1579
+ task schedules and history
1580
+ workflow runs/steps/units
1581
+ evidence/session cursors
1582
+ memory retirement and archive metadata
1583
+ change outcomes
1584
+
1585
+ index.db
1586
+ indexed documents
1587
+ FTS
1588
+ embeddings
1589
+ derived outlines/chunks/links
1590
+ optional measured enrichment caches
1591
+
1592
+ logs.db
1593
+ task/workflow/runtime log lines
1594
+ ```
1595
+
1596
+ ---
1597
+
1598
+ ## 12. Delivery strategy
1599
+
1600
+ ### 12.1 Why not a separate rewrite
1601
+
1602
+ A separate rewrite would have to reproduce mature behavior in:
1603
+
1604
+ - source synchronization;
1605
+ - package handling;
1606
+ - search and ranking;
1607
+ - SQLite concurrency;
1608
+ - proposals and rollback;
1609
+ - engines and harnesses;
1610
+ - workflows and schedules;
1611
+ - secret handling;
1612
+ - migration and recovery;
1613
+ - platform-specific execution.
1614
+
1615
+ Much of that behavior is encoded in tests and incident fixes rather than architecture documents.
1616
+
1617
+ ### 12.2 Why ordinary incremental refactoring is insufficient
1618
+
1619
+ The asset registry, refs, index metadata, wiki, lint, writes, and improve are mutually reinforcing. Slowly renaming them in place would likely preserve the same architecture.
1620
+
1621
+ ### 12.3 Modular replacement
1622
+
1623
+ Use vertical slices:
1624
+
1625
+ ```text
1626
+ new clean module
1627
+ -> parity or quality gate
1628
+ -> cut consumers over
1629
+ -> migrate durable state/content
1630
+ -> delete old implementation
1631
+ ```
1632
+
1633
+ No temporary abstraction is complete until it has a deletion milestone.
1634
+
1635
+ ### 12.4 Recommended implementation sequence
1636
+
1637
+ 1. Freeze current search and improve evaluation baselines.
1638
+ 2. Introduce workspace context, bundle installations, components, and lock state.
1639
+ 3. Implement the first complete OKF read/search/lint vertical slice.
1640
+ 4. Add the new index document and dual-compare projections.
1641
+ 5. Move LLM Wiki behind an adapter and replace wiki commands.
1642
+ 6. Separate local search from registry discovery.
1643
+ 7. Introduce multi-file proposals and the general transaction engine.
1644
+ 8. Refactor improve into evidence, revise, learn, consolidate, evaluate, and apply.
1645
+ 9. Add portable runtime exports and binding.
1646
+ 10. Cut workflows, tasks, environment, agents, skills, and scripts over.
1647
+ 11. Merge workflow durable state into `state.db`.
1648
+ 12. Implement one-time current-layout and ref migration.
1649
+ 13. Delete the asset architecture, old wiki subsystem, old refs, and temporary compatibility readers.
1650
+
1651
+ ### 12.5 First vertical slice
1652
+
1653
+ The safest first proof is:
1654
+
1655
+ ```text
1656
+ mount one OKF component
1657
+ -> adapter produces the current-equivalent search projection
1658
+ -> existing index stores it
1659
+ -> search ranks it
1660
+ -> show reads its absolute path
1661
+ -> lint runs native OKF validation
1662
+ ```
1663
+
1664
+ This slice excludes improve and runtime activation. It proves the adapter boundary without destabilizing the highest-risk systems.
1665
+
1666
+ ### 12.6 Deletion ledger
1667
+
1668
+ Track explicit zero-count gates:
1669
+
1670
+ ```text
1671
+ git grep TYPE_DIRS
1672
+ git grep AkmAssetType
1673
+ git grep parseAssetRef
1674
+ git grep wikiName
1675
+ git grep StashEntry
1676
+ git grep resolveStashDir
1677
+ git grep '/.akm' under bundle-write code
1678
+ ```
1679
+
1680
+ Migration or archival code may temporarily retain old terms, but the final release must remove them.
1681
+
1682
+ ---
1683
+
1684
+ ## 13. Hard-earned details and subtle constraints
1685
+
1686
+ This section records details that were easy to miss and often emerged only after examining current failure paths, prior incidents, test protections, or interactions between subsystems.
1687
+
1688
+ ### 13.1 Bundle and component are different boundaries
1689
+
1690
+ The bundle is the distribution and version boundary. The component is the native-format ownership boundary. Treating them as identical either prevents coherent multi-format packages or creates adapters that understand too much.
1691
+
1692
+ ### 13.2 Installation, binding, and enabling are three different actions
1693
+
1694
+ ```text
1695
+ install -> files are local and searchable
1696
+ bind -> a portable export is approved and locally configured
1697
+ enable -> an ongoing side effect such as a scheduler entry becomes active
1698
+ ```
1699
+
1700
+ Collapsing these creates supply-chain authority escalation.
1701
+
1702
+ ### 13.3 Writability is not trust
1703
+
1704
+ A writable Git checkout means AKM may edit and push it. It does not mean the bundle may grant itself tools, secrets, or command authority. Current AKM already contains a version of this lesson in tool-policy handling: contribution permission and runtime trust are orthogonal.
1705
+
1706
+ ### 13.4 Provider identity is not item identity
1707
+
1708
+ A GitHub cache, local checkout, npm package, and filesystem directory may contain the same logical bundle. Switching materialization should not rekey every item, usage event, proposal, or binding.
1709
+
1710
+ ### 13.5 Component-local IDs remain opaque to core
1711
+
1712
+ The first path segment must not quietly become a new core type. The adapter may interpret `skills/foo`, `pages/bar`, or `agents/reviewer`; the kernel treats the local ID as one native identifier.
1713
+
1714
+ ### 13.6 A path move is a real identity migration
1715
+
1716
+ Path-based identity is transparent and portable, but moves are not free. A safe move must:
1717
+
1718
+ - rewrite native links where supported;
1719
+ - rekey workspace feedback and history;
1720
+ - update proposal/binding targets;
1721
+ - preserve retrieval utility;
1722
+ - use before hashes;
1723
+ - produce a migration map and audit event.
1724
+
1725
+ This is preferable to embedding UUIDs in every third-party file.
1726
+
1727
+ ### 13.7 Do not abstract deterministic file reads
1728
+
1729
+ When the index has already resolved an absolute local path, the correct operation is usually:
1730
+
1731
+ ```ts
1732
+ fs.readFile(path, "utf8")
1733
+ ```
1734
+
1735
+ A repository, provider, or adapter read facade hides the source of truth, complicates errors, and can accidentally introduce query-time adapter behavior.
1736
+
1737
+ ### 13.8 Adapter parsing is still necessary
1738
+
1739
+ Direct byte reads do not mean the core parses every format. Workflows, tasks, skills, agents, and native configuration still use their adapter/runtime codecs when structured interpretation is required.
1740
+
1741
+ ### 13.9 Search must never depend on adapter availability at query time
1742
+
1743
+ A newly broken adapter should stop refresh or reindex for its component. It should not make all workspace search fail. The last valid indexed state may remain visible with a stale warning.
1744
+
1745
+ ### 13.10 Preserve field composition before changing ranking
1746
+
1747
+ Current name/description/tags/hints/content weighting and ranking behavior are coupled to existing retrieval and collapse benchmarks. Replacing file discovery and ranking simultaneously destroys the ability to attribute regressions.
1748
+
1749
+ ### 13.11 Progressive disclosure is a retrieval behavior, not a required file layout
1750
+
1751
+ OpenViking's layered context model is valuable, but writing `.abstract.md` and `.overview.md` beside every native file would pollute bundles and conflict with formats. Cards, outlines, chunks, and embeddings should normally remain derived index data.
1752
+
1753
+ ### 13.12 Indexing must be read-only with respect to bundles
1754
+
1755
+ An index command that regenerates `index.md`, enriches frontmatter, or repairs source files makes search infrastructure a hidden author. Native maintenance requires an explicit mutation command and transaction.
1756
+
1757
+ ### 13.13 Adapter instructions and validation must share authority
1758
+
1759
+ If prompt guidance says one thing while the validator enforces another, model retries cannot converge reliably. The adapter's rule-set version must be part of proposal fingerprints and diagnostics.
1760
+
1761
+ ### 13.14 Preserve unknown native fields and formatting where practical
1762
+
1763
+ Adapters must avoid destructive parse-and-reserialize behavior. Native comments, ordering, extension keys, and formatting can be semantically meaningful or important to users. Source-preserving edits and golden round-trip tests are required.
1764
+
1765
+ ### 13.15 A native kind never grants execution
1766
+
1767
+ An item called `Script`, a file under `tasks/`, or an OKF concept describing a workflow remains passive until a workspace runtime handler and policy authorize use.
1768
+
1769
+ ### 13.16 Installed task updates must not silently reschedule the machine
1770
+
1771
+ A package update can change cron frequency, target, arguments, or environment requirements. Active scheduler state remains pinned until the operator reviews and applies the binding update.
1772
+
1773
+ ### 13.17 Workflow runs freeze definitions
1774
+
1775
+ A run must not reread a moving source file after it starts. Freeze the package revision, export digest, compiled plan, and relevant settings. This preserves determinism and safe resume behavior.
1776
+
1777
+ ### 13.18 Environment contracts are portable; secret authority is local
1778
+
1779
+ A bundle can state that `DATABASE_URL` and `TOKEN` are required. It cannot choose the actual local values or automatically gain access to a workspace secret store.
1780
+
1781
+ ### 13.19 Private bundles may intentionally carry values
1782
+
1783
+ The architecture should not prohibit a trusted operator from distributing private environment files. It must make the trust decision explicit and continue to exclude values from search, logs, and ordinary output.
1784
+
1785
+ ### 13.20 Website snapshot and curated export are separate identities
1786
+
1787
+ Refreshing a live documentation snapshot must not overwrite a human- or agent-curated wiki derived from it. The curated destination records provenance and evolves independently.
1788
+
1789
+ ### 13.21 Redirect security must be rechecked on every hop
1790
+
1791
+ A public URL can redirect to loopback, link-local, or private infrastructure. Website materialization must validate every destination, not only the initial URL.
1792
+
1793
+ ### 13.22 Proposal and file changes must not drift apart
1794
+
1795
+ The reviewed object should contain the exact file mutations that the transaction applies. Recomputing paths or content after approval creates a review gap.
1796
+
1797
+ ### 13.23 Before hashes protect long-running and deferred work
1798
+
1799
+ Model generation, human review, and cross-repository operations may take long enough for source files to change. A stale proposal should fail instead of overwriting new work.
1800
+
1801
+ ### 13.24 One semantic snapshot prevents self-feeding
1802
+
1803
+ If an accepted revision is immediately reindexed and becomes input to another process in the same run, process order affects results and the system may amplify its own wording. One snapshot makes runs understandable and comparable.
1804
+
1805
+ ### 13.25 A model's confidence is not independent evidence
1806
+
1807
+ It may help debugging or analysis but cannot establish truth, usefulness, or safety. Confidence-threshold calibration against validator acceptance optimizes the gate, not the product outcome.
1808
+
1809
+ ### 13.26 Asset outcome and change outcome are different
1810
+
1811
+ “Users retrieve this item often” is an item-level signal. “Revision B outperformed revision A” is a change-level causal comparison. Improve needs both, but only the second evaluates a proposal.
1812
+
1813
+ ### 13.27 Retrieval evaluation needs holdouts and protected canaries
1814
+
1815
+ A model can improve the triggering query by copying its words into the file. Evaluation must include related unseen queries, negative cases, global canaries, and task behavior.
1816
+
1817
+ ### 13.28 No corrective evidence means no unattended rewrite
1818
+
1819
+ A frequently used file may be excellent. Age may reflect stability. Storage size may reflect necessary detail. These signals can schedule an audit, not justify semantic mutation.
1820
+
1821
+ ### 13.29 Independent recurrence matters
1822
+
1823
+ Ten observations derived from one session are not ten independent confirmations. Durable learning should distinguish separate sessions, tasks, projects, sources, and explicit human correction.
1824
+
1825
+ ### 13.30 Retirement is not deletion
1826
+
1827
+ Retirement removes an item from normal active retrieval and may remove it from the active component tree. The bytes remain recoverable for a grace period. Purge is the later irreversible step.
1828
+
1829
+ ### 13.31 Semantic state is not operational state
1830
+
1831
+ A contradicted memory may remain valuable evidence. A semantically active memory may be retired after its claims are formalized elsewhere. Native meaning and storage/retrieval policy must not be conflated.
1832
+
1833
+ ### 13.32 Storage pressure cannot prove expendability
1834
+
1835
+ High-water marks establish that action is required, not which unique information may be discarded. When safe reduction fails, queue new background evidence instead of weakening deletion gates.
1836
+
1837
+ ### 13.33 Archive retention must itself be bounded
1838
+
1839
+ Moving every removed memory to an unlimited archive only relocates unbounded growth. Archive age, size, holds, successors, and purge eligibility require explicit policy.
1840
+
1841
+ ### 13.34 Read-only bundles need workspace retirement overlays
1842
+
1843
+ AKM cannot rewrite an installed package merely to hide a superseded memory. A digest-bound local overlay can suppress it without pretending the source changed. The overlay must invalidate when upstream content changes.
1844
+
1845
+ ### 13.35 Formalization across repositories is two-phase
1846
+
1847
+ Publish and validate the successor first. Retire the sources second. Temporary duplication is safer than loss when the second phase fails.
1848
+
1849
+ ### 13.36 Contradictions should not be averaged away
1850
+
1851
+ A consolidation model may be tempted to create a bland compromise. Contradictory claims need preserved evidence, temporal qualification, scope, or an explicit current-belief decision.
1852
+
1853
+ ### 13.37 Claim coverage is stronger than text similarity
1854
+
1855
+ A merged document can look similar to its sources while omitting the most important fact. Retirement evaluation needs claim-level disposition, not only cosine or Jaccard similarity.
1856
+
1857
+ ### 13.38 Exact duplicates and semantic duplicates need different policies
1858
+
1859
+ Byte/content-identical records can often be retired deterministically. Semantic near-duplicates require provenance and claim analysis.
1860
+
1861
+ ### 13.39 Background capture must have a pressure valve
1862
+
1863
+ Session extraction should not continue creating active memory files when the memory component is above its high-water mark and no safe consolidation exists. Evidence can wait in workspace state.
1864
+
1865
+ ### 13.40 Feedback should not rewrite portable files
1866
+
1867
+ Usage counts, lesson credit, utility, and retrieval outcomes are local observations. Writing them into frontmatter creates noisy source-control churn and makes the same bundle vary by consumer.
1868
+
1869
+ ### 13.41 Registry and search scores are not comparable
1870
+
1871
+ Package popularity/relevance and local file retrieval use different corpora and scoring scales. Combining them in one ranked list produces misleading ordering.
1872
+
1873
+ ### 13.42 Graph extraction is derived, expensive, and optional
1874
+
1875
+ It belongs in indexing, not `show`, `curate`, or improve. Native links are deterministic and should be indexed first. LLM graph value must be demonstrated by ablation.
1876
+
1877
+ ### 13.43 Workspace state must never leak under bundle roots
1878
+
1879
+ Locks, journals, proposals, embeddings, evaluation artifacts, rejected drafts, schedules, credentials, and telemetry make a bundle non-portable and may be accidentally committed or published.
1880
+
1881
+ ### 13.44 Three databases have distinct durability classes
1882
+
1883
+ - `state.db`: losing it is data loss.
1884
+ - `index.db`: it can be rebuilt.
1885
+ - `logs.db`: it is useful but intentionally purgeable.
1886
+
1887
+ This distinction should drive migration, backup, and recovery behavior.
1888
+
1889
+ ### 13.45 Temporary compatibility is a migration tool, not a product feature
1890
+
1891
+ A migration reader may understand the current layout. It must not become a documented permanent adapter, or the old architecture will constrain every future change.
1892
+
1893
+ ### 13.46 Existing tests are architectural knowledge
1894
+
1895
+ Tests covering path traversal, symlinks, Git exact paths, SQLite contention, interrupted transactions, secret redaction, and workflow resume are not merely implementation tests. They encode production knowledge that the new modules must preserve.
1896
+
1897
+ ### 13.47 Not every current feature deserves migration
1898
+
1899
+ A sophisticated mechanism can still have negative net value. Salience, graph boosts, self-consistency voting, proactive rewrites, and process-specific caches must be evaluated against simpler alternatives.
1900
+
1901
+ ### 13.48 Net deletion is an acceptance criterion
1902
+
1903
+ The adapter refactor is unsuccessful if it only adds a new layer while leaving asset specs, matchers, wiki special cases, type refs, and old improve processes intact.
1904
+
1905
+ ---
1906
+
1907
+ ## 14. Open and deferred decisions
1908
+
1909
+ The final architecture is clear, but several implementation choices should remain evidence-driven.
1910
+
1911
+ ### 14.1 Single-component config representation
1912
+
1913
+ 0.9.0 retains a single-entry `components` map in workspace config while the runtime enforces one bundle = one component = one adapter. A later config revision may flatten that map; the one-component cardinality and absence of an in-bundle manifest are settled.
1914
+
1915
+ ### 14.2 Third-party adapter ABI
1916
+
1917
+ Built-in adapters should prove the contract first. A stable external plugin API should wait until independently implemented adapters reveal what actually needs stability and isolation.
1918
+
1919
+ ### 14.3 Adapter isolation
1920
+
1921
+ Built-in trusted adapters may run in process. Third-party adapters may eventually need a subprocess or sandbox boundary. The cost and threat model should be evaluated before standardizing the ABI.
1922
+
1923
+ ### 14.4 Search ranking simplification
1924
+
1925
+ The refactor initially preserves current ranking. Later experiments should decide whether to retain:
1926
+
1927
+ - type/kind boosts;
1928
+ - project-context boosts;
1929
+ - scoped utility;
1930
+ - graph boosts;
1931
+ - belief-state boosts;
1932
+ - recency and salience terms.
1933
+
1934
+ ### 14.5 LLM index enrichment
1935
+
1936
+ Default indexing should be deterministic. An optional processor may return only if measured retrieval benefit exceeds cost, latency, and drift.
1937
+
1938
+ ### 14.6 Memory claim extraction
1939
+
1940
+ Claim coverage is required conceptually, but the implementation may combine deterministic sentence/heading extraction, structured native fields, and an LLM. It needs a benchmark before auto-retirement depends on it.
1941
+
1942
+ ### 14.7 Memory thresholds and archive defaults
1943
+
1944
+ The specification defines behavior, not universal limits. Defaults should be derived from real corpus size, index performance, and user expectations.
1945
+
1946
+ ### 14.8 Cross-bundle transaction user experience
1947
+
1948
+ The two-phase safety model is clear. Resume, review, and rollback commands for partial cross-repository formalization need detailed UX design.
1949
+
1950
+ ### 14.9 Direct invocation versus binding
1951
+
1952
+ Workflows and scripts may support one-shot invocation by full export ref without a persistent binding. The exact policy and prompts should remain strict enough that convenience does not become silent activation.
1953
+
1954
+ ### 14.10 Naming of `bundle`, `component`, `binding`, and `export`
1955
+
1956
+ The current terms are precise and should be used unless implementation proves a simpler public vocabulary. Internal precision may exceed what every CLI command needs to expose.
1957
+
1958
+ ---
1959
+
1960
+ ## 15. Annotated references
1961
+
1962
+ ### 15.1 Knowledge and bundle formats
1963
+
1964
+ - [Open Knowledge Format specification](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md) — Established OKF's intentionally minimal concept, link, hierarchy, and conformance model and supported treating it as an interoperable adapter rather than a complete AKM runtime.
1965
+ - [OKF reference README](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/README.md) — Reinforced the distinction between the format and optional producer/visualizer tooling.
1966
+ - [Agent Skills specification](https://agentskills.io/specification) — Demonstrated that useful agent capability packages have their own strict native contract and progressive-loading structure; they should not be modified into pseudo-OKF files.
1967
+ - [OpenViking context layers](https://github.com/volcengine/OpenViking/blob/main/docs/en/concepts/03-context-layers.md) — Informed metadata/overview/detail progressive disclosure while avoiding mandatory sidecar files.
1968
+
1969
+ ### 15.2 Native agent configuration
1970
+
1971
+ - [Claude Code memory and instruction files](https://code.claude.com/docs/en/memory) — Informed adapter-owned scope, hierarchy, imports, and instruction precedence.
1972
+ - [Claude Code subagents](https://code.claude.com/docs/en/sub-agents) — Demonstrated native agent definitions with their own metadata, prompts, tool controls, and scope.
1973
+ - [OpenCode rules](https://opencode.ai/docs/rules/) — Demonstrated a different instruction and fallback model that should remain native rather than normalized away.
1974
+ - [OpenCode agents](https://opencode.ai/docs/agents/) — Informed native agent parsing and the separation between portable definitions and local runtime authority.
1975
+ - [Model Context Protocol server concepts](https://modelcontextprotocol.io/docs/learn/server-concepts) — Reinforced the distinction between descriptive resources and actionable tools, a key execution-security boundary.
1976
+
1977
+ ### 15.3 Effective agent and self-improvement design
1978
+
1979
+ - [Anthropic: Building Effective Agents](https://www.anthropic.com/engineering/building-effective-agents) — Supported simple, composable architecture and evaluator-optimizer loops only where evaluation is clear.
1980
+ - [Reflexion](https://arxiv.org/abs/2303.11366) — Demonstrated improvement grounded in task feedback and stored reflections.
1981
+ - [Voyager](https://arxiv.org/abs/2305.16291) — Demonstrated environment feedback, execution errors, skill accumulation, and self-verification.
1982
+ - [Self-Refine](https://arxiv.org/abs/2303.17651) — Provided evidence that iterative refinement can help under appropriate tasks, but not that self-critique is universally reliable.
1983
+ - [Large Language Models Cannot Self-Correct Reasoning Yet](https://arxiv.org/abs/2310.01798) — Supported rejecting ungrounded intrinsic correction as a publication gate.
1984
+ - [GEPA](https://arxiv.org/abs/2507.19457) — Informed candidate generation, rollout evaluation, and retention of variants that actually perform better.
1985
+ - [Darwin Gödel Machine](https://arxiv.org/abs/2505.22954) — Reinforced benchmark-evaluated agent modification rather than trusting the modifier's self-assessment.
1986
+ - [AlphaEvolve](https://deepmind.google/blog/alphaevolve-a-gemini-powered-coding-agent-for-designing-advanced-algorithms/) — Reinforced continuous candidate generation with automated evaluators and explicit performance signals.
1987
+
1988
+ ### 15.4 Evaluation and judge limitations
1989
+
1990
+ - [Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena](https://arxiv.org/abs/2306.05685) — Useful background on judge-based evaluation and its role as a proxy.
1991
+ - [Position Bias in LLM-based Evaluators](https://arxiv.org/abs/2406.07791) — Supported treating LLM judges as supporting evidence rather than ground truth.
1992
+
1993
+ ### 15.5 Agent memory
1994
+
1995
+ - [Generative Agents](https://arxiv.org/abs/2304.03442) — Informed the distinction between an observation stream and higher-level reflection.
1996
+ - [A-MEM](https://arxiv.org/abs/2502.12110) — Informed dynamic memory organization and link-based evolution.
1997
+ - [Zep: A Temporal Knowledge Graph Architecture for Agent Memory](https://arxiv.org/abs/2501.13956) — Informed preservation of temporal history, contradiction, and relationship semantics.
1998
+ - [All-Mem](https://arxiv.org/abs/2603.19595) — Informed explicit memory lifecycle and non-destructive consolidation ideas.
1999
+ - [E-mem](https://arxiv.org/abs/2601.21714) — Informed caution around destructive compression and loss of sequential evidence.
2000
+
2001
+ ### 15.6 Modernizing the current codebase
2002
+
2003
+ - [Martin Fowler: Strangler Fig Application](https://martinfowler.com/bliki/StranglerFigApplication.html) — Supported vertical replacement and cutover rather than a single full rewrite.
2004
+ - [Martin Fowler: Sacrificial Architecture](https://martinfowler.com/bliki/SacrificialArchitecture.html) — Supported replacing architectural modules after learning while retaining mature infrastructure.
2005
+ - [Joel Spolsky: Things You Should Never Do, Part I](https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/) — Highlighted the hidden operational knowledge and bug fixes lost in broad rewrites.
2006
+ - [Google Software Engineering: Large-Scale Changes](https://abseil.io/resources/swe-book/html/ch22.html) — Supported independently testable, incremental, tool-assisted changes.
2007
+
2008
+ ### 15.7 Current AKM implementation and prior analysis
2009
+
2010
+ - [AKM PR #718](https://github.com/itlackey/akm/pull/718) — Original OKF integration proposal that initiated the review.
2011
+ - [AKM repository](https://github.com/itlackey/akm) — Current implementation analyzed for refs, asset types, indexing, improve, proposals, sources, workflows, tasks, security, and storage.
2012
+ - [Current `SourceProvider` contract](https://github.com/itlackey/akm/blob/ddc0a1b417efc820ad73d76bfcbef65c9f87b243/src/sources/provider.ts) — Demonstrated a useful narrow materializer seam.
2013
+ - [Current consolidation implementation](https://github.com/itlackey/akm/blob/ddc0a1b417efc820ad73d76bfcbef65c9f87b243/src/commands/improve/consolidate.ts) — Provided existing merge/delete/promote/contradict behavior, pressure triggers, journals, and safety mechanisms to preserve or improve.
2014
+ - [Current task schema](https://github.com/itlackey/akm/blob/ddc0a1b417efc820ad73d76bfcbef65c9f87b243/src/tasks/schema.ts) — Demonstrated that task definitions are already portable and should move behind an adapter rather than disappear.
2015
+ - [Current proposal substrate](https://github.com/itlackey/akm/blob/ddc0a1b417efc820ad73d76bfcbef65c9f87b243/src/commands/proposal/proposal.ts) — Provided crash-recovery, backup, acceptance, and revert behavior for the new multi-file transaction model.
2016
+
2017
+ ---
2018
+
2019
+ ## 16. Working-document lineage
2020
+
2021
+ The architecture evolved through the following generated working documents. They are historical context, not competing current specifications:
2022
+
2023
+ 1. `akm-okf-foundation-proposal.md` — rejected OKF-as-asset direction and proposed OKF projection.
2024
+ 2. `akm-okf-native-architecture-proposal.md` — made OKF concepts canonical and split workspace from bundle.
2025
+ 3. `akm-okf-native-integration-refined.md` — removed required AKM frontmatter extensions and clarified workspace state.
2026
+ 4. `akm-okf-conceptual-simplification.md` — simplified stash, refs, wiki, and `StashEntry` around OKF.
2027
+ 5. `akm-format-neutral-bundle-adapter-architecture.md` — introduced format-neutral adapters but overdesigned semantic views.
2028
+ 6. `akm-bundle-adapter-simplified-safe-revision.md` — removed views and protected search/improve behavior.
2029
+ 7. `akm-improve-verified-evolution-refactor.md` — reframed improve around external verification and measurable change outcome.
2030
+ 8. `akm-three-perspective-review-and-rewrite-decision.md` — reviewed empirical value, minimalism, delivery risk, and rewrite strategy.
2031
+ 9. `akm-repository-wide-refactor-audit.md` — identified repository-wide replacement/removal areas.
2032
+ 10. `akm-repository-wide-refactor-audit-v2.md` — corrected convention ownership, website support, portable runtime definitions, and bounded memory lifecycle.
2033
+ 11. `akm-format-neutral-bundle-workspace-spec.md` — current normative target.
2034
+
2035
+ ---
2036
+
2037
+ ## 17. Final position
2038
+
2039
+ The architecture can be summarized without introducing another framework:
2040
+
2041
+ ```text
2042
+ AKM installs files in bundles.
2043
+ Adapters explain their native formats.
2044
+ The index makes them searchable.
2045
+ The workspace binds approved capabilities.
2046
+ Runtime handlers execute them safely.
2047
+ Improve changes files only when evidence justifies it.
2048
+ Memory consolidation keeps learning bounded without casually losing knowledge.
2049
+ ```
2050
+
2051
+ The core test for every future feature is:
2052
+
2053
+ > **Does this complexity produce measurable value that cannot be achieved with ordinary file operations, search queries, native adapter rules, explicit bindings, and verified file changes?**
2054
+
2055
+ If not, it does not belong in the kernel.