akm-cli 0.9.29 → 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.
- package/CHANGELOG.md +41 -0
- package/README.md +10 -10
- package/ROADMAP.md +112 -0
- package/dist/commands/improve/improve-cli.js +33 -12
- package/dist/commands/sources/plugin-upgrade.js +46 -23
- package/dist/core/file-lock.js +10 -1
- package/dist/llm/client.js +33 -3
- package/dist/scripts/akm-migrate-node.js +5 -1
- package/dist/scripts/akm-migrate.js +5 -1
- package/docs/README.md +42 -41
- package/docs/agents/README.md +15 -0
- package/docs/agents/agent-install.md +14 -0
- package/docs/architecture/README.md +67 -0
- package/docs/architecture/adapters.md +272 -0
- package/docs/architecture/akm-architecture-decision-history.md +2055 -0
- package/docs/architecture/akm-core-principles.md +126 -0
- package/docs/architecture/architecture.md +579 -0
- package/docs/architecture/comparisons/claude-code-vs-akm-workflows-full.md +550 -0
- package/docs/architecture/decisions/0001-no-interpolation-attached-structured-context.md +72 -0
- package/docs/architecture/decisions/0002-unit-reuse-and-input-hash-scope.md +142 -0
- package/docs/architecture/decisions/0003-child-env-allowlist-and-provenance.md +189 -0
- package/docs/architecture/decisions/0004-task-input-contract-and-flag-coercion.md +97 -0
- package/docs/architecture/decisions/0005-task-result-vocabulary-and-legacy-read-mapping.md +108 -0
- package/docs/architecture/decisions/0006-task-source-version-routing.md +124 -0
- package/docs/architecture/decisions/0007-workflow-composition-bounds.md +83 -0
- package/docs/architecture/decisions/0008-task-binding-normalization.md +88 -0
- package/docs/architecture/decisions/0009-child-run-publication-column-parity.md +80 -0
- package/docs/architecture/decisions/0010-driver-protocol-cut.md +36 -0
- package/docs/architecture/decisions/0011-engine-run-loop-invariants.md +125 -0
- package/docs/architecture/decisions/README.md +62 -0
- package/docs/architecture/improvement.md +440 -0
- package/docs/architecture/internals/classification.md +154 -0
- package/docs/architecture/internals/fresh-host-rebuild-runbook.md +40 -0
- package/docs/architecture/internals/functional-contract-patterns.md +340 -0
- package/docs/architecture/internals/health-advisories.md +110 -0
- package/docs/architecture/internals/improve-workflow.md +713 -0
- package/docs/architecture/internals/indexing.md +498 -0
- package/docs/architecture/internals/registry-network-boundary.md +57 -0
- package/docs/architecture/internals/search.md +249 -0
- package/docs/architecture/internals/storage-locations.md +943 -0
- package/docs/architecture/persisted-data-compat.md +59 -0
- package/docs/architecture/reviews/env-secret-access.md +319 -0
- package/docs/architecture/runtime-boundary-design.md +153 -0
- package/docs/architecture/specs/0.9.0-close-out-plan.md +361 -0
- package/docs/architecture/specs/0.9.0-decisions.md +528 -0
- package/docs/architecture/specs/0.9.0-docs-code-drift-register.md +745 -0
- package/docs/architecture/specs/0.9.0-open-items-register.md +135 -0
- package/docs/architecture/specs/0.9.0-public-api-issue-backlog.md +740 -0
- package/docs/architecture/specs/0.9.0-release-surface-review.md +636 -0
- package/docs/architecture/specs/agent-command-engine-model-design.md +513 -0
- package/docs/architecture/specs/akm-0.9.0-bundle-adapter-spec.md +501 -0
- package/docs/architecture/specs/akm-0.9.0-ref-grammar-decision.md +291 -0
- package/docs/architecture/specs/akm-format-neutral-bundle-workspace-spec.md +2059 -0
- package/docs/architecture/specs/di-seams-plan.md +539 -0
- package/docs/architecture/specs/driver-protocol-keep-or-cut.md +275 -0
- package/docs/architecture/specs/fact-asset-type.md +142 -0
- package/docs/architecture/specs/improve-collapse-churn-detector-design.md +634 -0
- package/docs/architecture/specs/okf-support.md +148 -0
- package/docs/architecture/specs/ref.md +329 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/README.md +72 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/findings-consolidated.md +152 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-alternatives.md +352 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-bunqueue.md +300 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-openworkflow.md +402 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-1.md +758 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-2.md +645 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-3.md +602 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-adversarial.md +27 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-architecture.md +27 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-coverage.md +74 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-security.md +15 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-adversarial.md +132 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-verification.md +147 -0
- package/docs/architecture/specs/stash-conventions-code-spec.md +275 -0
- package/docs/architecture/specs/stash-organization-conventions.md +377 -0
- package/docs/architecture/specs/task-workflow-format-unification.md +721 -0
- package/docs/architecture/specs/workflow-engine-buy-vs-build.md +231 -0
- package/docs/architecture/specs/workflow-format-unification.md +437 -0
- package/docs/architecture/testing/manual-testing-checklist.md +3420 -0
- package/docs/architecture/testing/okf-v0.2-conformance-runbook.md +924 -0
- package/docs/architecture/testing/task-workflow-manual-tests.md +1817 -0
- package/docs/architecture/testing/testing-workflow.md +446 -0
- package/docs/architecture/workflow-engine.md +274 -0
- package/docs/guides/README.md +33 -0
- package/docs/guides/author-bundles.md +310 -0
- package/docs/guides/author-workflows.md +520 -0
- package/docs/guides/bundles.md +321 -0
- package/docs/guides/capture-knowledge.md +136 -0
- package/docs/guides/claude-code-vs-akm-workflows.md +30 -0
- package/docs/guides/concepts.md +93 -0
- package/docs/guides/discover-and-load.md +158 -0
- package/docs/guides/getting-started.md +240 -0
- package/docs/guides/improve-the-library.md +246 -0
- package/docs/guides/knowledge-management.md +18 -0
- package/docs/guides/recipes/headless-install.md +97 -0
- package/docs/guides/recipes/website-source.md +28 -0
- package/docs/guides/run-workflows.md +279 -0
- package/docs/guides/scheduling.md +123 -0
- package/docs/guides/use-with-any-agent.md +129 -0
- package/docs/guides/wikis.md +81 -0
- package/docs/maintainers/README.md +19 -0
- package/docs/maintainers/curate-workmap.md +336 -0
- package/docs/maintainers/eval.md +3 -0
- package/docs/maintainers/local-development.md +108 -0
- package/docs/maintainers/release-checklist.md +103 -0
- package/docs/migration/README.md +2 -2
- package/docs/migration/release-notes/0.0.13.md +1 -1
- package/docs/migration/release-notes/0.1.0.md +1 -1
- package/docs/migration/release-notes/0.2.0.md +1 -1
- package/docs/migration/release-notes/0.3.0.md +1 -1
- package/docs/migration/release-notes/0.5.0.md +1 -1
- package/docs/migration/release-notes/0.6.0.md +1 -1
- package/docs/migration/release-notes/0.7.0.md +1 -1
- package/docs/migration/release-notes/0.7.3.md +2 -2
- package/docs/migration/release-notes/0.7.4.md +1 -1
- package/docs/migration/release-notes/0.7.5.md +1 -1
- package/docs/migration/release-notes/0.8.0.md +1 -1
- package/docs/migration/release-notes/0.9.0.md +1 -1
- package/docs/migration/release-notes/0.9.14.md +1 -1
- package/docs/migration/release-notes/0.9.15.md +1 -1
- package/docs/migration/release-notes/0.9.16.md +1 -1
- package/docs/migration/release-notes/0.9.17.md +1 -1
- package/docs/migration/release-notes/0.9.19.md +1 -1
- package/docs/migration/release-notes/0.9.2.md +1 -1
- package/docs/migration/release-notes/README.md +27 -31
- package/docs/migration/v0.5-to-v0.6.md +759 -0
- package/docs/migration/v0.8-to-v0.9.md +1 -1
- package/docs/plans/0.9.2-agent-command-workflow-plan.md +423 -0
- package/docs/posts/README.md +30 -0
- package/docs/posts/akm-command-tour.md +495 -0
- package/docs/posts/akm-logo-sized.webp +0 -0
- package/docs/posts/belief-aware-memory-12.md +139 -0
- package/docs/posts/config-v2-lessons-16.md +191 -0
- package/docs/posts/improve-loop-autonomous-10.md +225 -0
- package/docs/posts/improve-pipeline-debugging-0803.md +179 -0
- package/docs/posts/intro-part-01.md +76 -0
- package/docs/posts/intro-part-02.md +221 -0
- package/docs/posts/intro-part-03.md +190 -0
- package/docs/posts/intro-part-04.md +221 -0
- package/docs/posts/llm-mode-reflect-13.md +166 -0
- package/docs/posts/openpalm-built-on-akm.md +86 -0
- package/docs/posts/progressive-disclosure-06.md +129 -0
- package/docs/posts/proposal-safety-net-15.md +112 -0
- package/docs/posts/release-0.5.0.md +247 -0
- package/docs/posts/release-0.6.0.md +117 -0
- package/docs/posts/release-0.7.0.md +159 -0
- package/docs/posts/release-0.8.0.md +332 -0
- package/docs/posts/scattered-skills-05.md +100 -0
- package/docs/posts/task-assets-persistent-workflows-11.md +222 -0
- package/docs/posts/team-skills-07.md +198 -0
- package/docs/posts/wiki-agent-knowledge-08.md +223 -0
- package/docs/posts/workflows-vaults-09.md +321 -0
- package/docs/product-surface.md +54 -0
- package/docs/reference/README.md +1 -2
- package/docs/reference/asset-types.md +168 -0
- package/docs/reference/cli.md +5 -6
- package/docs/reference/env-and-secrets.md +126 -0
- package/docs/reference/memory.md +124 -0
- package/docs/reference/refs.md +156 -0
- package/docs/reference/registry.md +489 -0
- package/docs/reference/website-sources.md +141 -0
- package/package.json +12 -15
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# Functional Contract Patterns
|
|
2
|
+
|
|
3
|
+
Quick reference for the repeated design patterns used in akm's refactor away
|
|
4
|
+
from type-centric behavior.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Core Rule
|
|
9
|
+
|
|
10
|
+
Model behavior around core processes, not around one large `asset type` object.
|
|
11
|
+
|
|
12
|
+
Use:
|
|
13
|
+
|
|
14
|
+
- `type` as data
|
|
15
|
+
- small contracts as extension seams
|
|
16
|
+
- fixed-stage pipelines as orchestrators
|
|
17
|
+
|
|
18
|
+
Do not use:
|
|
19
|
+
|
|
20
|
+
- one mega interface with many optional methods
|
|
21
|
+
- open-ended plugin graphs
|
|
22
|
+
- process logic hidden behind global type switches
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 2. Repeated Pattern
|
|
27
|
+
|
|
28
|
+
For each process:
|
|
29
|
+
|
|
30
|
+
1. define a small context object
|
|
31
|
+
2. define a narrow contributor interface
|
|
32
|
+
3. register ordered contributors
|
|
33
|
+
4. let each contributor decide `appliesTo(...)`
|
|
34
|
+
5. keep one central orchestrator for stage order
|
|
35
|
+
|
|
36
|
+
This is the standard pattern to repeat across the codebase.
|
|
37
|
+
|
|
38
|
+
Contributor invariants:
|
|
39
|
+
|
|
40
|
+
1. registration is static and in-process only
|
|
41
|
+
2. ordering is deterministic
|
|
42
|
+
3. composition semantics are declared once per seam
|
|
43
|
+
4. execution is sequential by default
|
|
44
|
+
5. contributors do not dispatch into other registries directly
|
|
45
|
+
6. if a seam needs more machinery than this, it is probably too abstract
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 3. Pattern Catalog
|
|
50
|
+
|
|
51
|
+
## 3.1 Fixed-Stage Pipeline
|
|
52
|
+
|
|
53
|
+
Use when a process already has a clear top-down flow.
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
|
|
57
|
+
- search
|
|
58
|
+
- improve
|
|
59
|
+
- indexing
|
|
60
|
+
|
|
61
|
+
Shape:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
for (const stage of stages) {
|
|
65
|
+
for (const contributor of contributorsFor(stage)) {
|
|
66
|
+
if (!contributor.appliesTo(ctx)) continue;
|
|
67
|
+
contributor.run(ctx);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Why:
|
|
73
|
+
|
|
74
|
+
- preserves readability
|
|
75
|
+
- makes order explicit
|
|
76
|
+
- prevents plugin soup
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 3.2 Ordered Contributor Registry
|
|
81
|
+
|
|
82
|
+
Use when one stage needs several isolated policies.
|
|
83
|
+
|
|
84
|
+
Examples:
|
|
85
|
+
|
|
86
|
+
- ranking signals
|
|
87
|
+
- proposal validators
|
|
88
|
+
|
|
89
|
+
Shape:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
interface Contributor<TContext> {
|
|
93
|
+
name: string;
|
|
94
|
+
order?: number;
|
|
95
|
+
appliesTo?(ctx: TContext): boolean;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Why:
|
|
100
|
+
|
|
101
|
+
- testable in isolation
|
|
102
|
+
- easy to add behavior without editing the orchestrator
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 3.3 Structural Contract
|
|
107
|
+
|
|
108
|
+
Use for stable physical concerns such as refs and paths.
|
|
109
|
+
|
|
110
|
+
Example:
|
|
111
|
+
|
|
112
|
+
- `PathResolver`
|
|
113
|
+
|
|
114
|
+
Why:
|
|
115
|
+
|
|
116
|
+
- storage layout is real and durable
|
|
117
|
+
- should not be mixed with ranking, rendering, or validation
|
|
118
|
+
|
|
119
|
+
Rule:
|
|
120
|
+
|
|
121
|
+
- keep structural contracts small and boring
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 3.4 Classification As Facts
|
|
126
|
+
|
|
127
|
+
Classification should produce facts, not choose downstream behavior too early.
|
|
128
|
+
|
|
129
|
+
Good output:
|
|
130
|
+
|
|
131
|
+
- `type`
|
|
132
|
+
- `specificity`
|
|
133
|
+
- annotations or reasons
|
|
134
|
+
|
|
135
|
+
Avoid:
|
|
136
|
+
|
|
137
|
+
- coupling classification directly to renderer names or search policy
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 3.5 Process-Local Validation
|
|
142
|
+
|
|
143
|
+
Validation belongs to the process that needs it.
|
|
144
|
+
|
|
145
|
+
Examples:
|
|
146
|
+
|
|
147
|
+
- proposal validation
|
|
148
|
+
- lint validation
|
|
149
|
+
- improve preflight validation
|
|
150
|
+
|
|
151
|
+
Avoid one shared validator that tries to know every process.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 3.6 One Pipeline, Many Signals
|
|
156
|
+
|
|
157
|
+
Search must remain one pipeline.
|
|
158
|
+
|
|
159
|
+
Use contributors for:
|
|
160
|
+
|
|
161
|
+
- exact-match boosts
|
|
162
|
+
- type preference boosts
|
|
163
|
+
- belief-state boosts
|
|
164
|
+
- graph boosts
|
|
165
|
+
- utility boosts
|
|
166
|
+
|
|
167
|
+
Do not create separate per-type scoring pipelines.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 3.7 Adapters Before Rewrites
|
|
172
|
+
|
|
173
|
+
First move existing behavior behind the new seam.
|
|
174
|
+
|
|
175
|
+
Only after parity is proven should behavior be reorganized.
|
|
176
|
+
|
|
177
|
+
Why:
|
|
178
|
+
|
|
179
|
+
- lower risk
|
|
180
|
+
- easier regression testing
|
|
181
|
+
- architectural progress without feature churn
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 3.8 Refactor-Only Safety Rule
|
|
186
|
+
|
|
187
|
+
When the work is explicitly architectural cleanup:
|
|
188
|
+
|
|
189
|
+
- no functionality changes
|
|
190
|
+
- all tests must pass with the same validation expectations
|
|
191
|
+
- the only allowed test edits are import-path or symbol-import updates caused by file moves
|
|
192
|
+
- do not rewrite assertions, fixtures, or expected outputs to accommodate the refactor
|
|
193
|
+
|
|
194
|
+
This keeps architectural cleanup separate from feature or bug-fix work.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 3.8a Non-goals
|
|
199
|
+
|
|
200
|
+
This pattern guide is **not** permission to:
|
|
201
|
+
|
|
202
|
+
1. build a framework
|
|
203
|
+
2. add complexity for its own sake
|
|
204
|
+
3. create registries everywhere by default
|
|
205
|
+
4. replace simple code with abstract dispatch when no real hotspot exists
|
|
206
|
+
5. introduce dynamic plugin systems or runtime discovery
|
|
207
|
+
6. change runtime behavior under the banner of refactoring
|
|
208
|
+
|
|
209
|
+
The purpose of these patterns is to remove concrete duplication and switchboard logic while keeping the system simpler to reason about than it is today.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## 3.9 Execution Pipeline Contract
|
|
214
|
+
|
|
215
|
+
Every execution crosses the same plain functions:
|
|
216
|
+
|
|
217
|
+
1. `resolveExecution()` selects the engine (nearest layer, `defaults.engine`,
|
|
218
|
+
then the `opencode-sdk` fallback), merges the engine's defaults with the
|
|
219
|
+
caller's layers (nearest wins), expands a `models.json` alias once,
|
|
220
|
+
authorizes tools against `execution.allowedTools`, and returns the
|
|
221
|
+
`ResolvedExecutionRequestV1`, the engine's `RunnerSpec` with the request
|
|
222
|
+
applied, and per-field provenance. Credentials stay symbolic.
|
|
223
|
+
2. `buildExecution()` hands the request to the harness's own builder (derived
|
|
224
|
+
from `HARNESS_REGISTRY`), or builds chat messages for a direct LLM. A field
|
|
225
|
+
the transport cannot carry becomes a secret-free notice; a tool policy it
|
|
226
|
+
cannot enforce, or a denied tool selection, is a pre-dispatch error.
|
|
227
|
+
3. `buildExecutionFromWire()` does the same from a journaled
|
|
228
|
+
`{ request, runner }` without reading config, aliases, environment
|
|
229
|
+
variables, or credentials — workflow resume.
|
|
230
|
+
4. `runExecution()` reads credentials for the call, runs the agent CLI, the
|
|
231
|
+
OpenCode SDK, or the chat transport (an exhaustive switch over
|
|
232
|
+
`llm | agent | sdk`), and redacts every secret the child could have seen.
|
|
233
|
+
|
|
234
|
+
A prompt-free interactive native-agent launch (`akm agent`) resolves its
|
|
235
|
+
engine directly; it carries no request to build.
|
|
236
|
+
|
|
237
|
+
Diagnostic provenance is field metadata (`field`, `layer`, `kind`, `via`), not
|
|
238
|
+
resolved values or content. Lowering notices are secret-free records with a
|
|
239
|
+
fixed public vocabulary; arbitrary authored inference keys are represented by
|
|
240
|
+
wildcard field names rather than copied into diagnostics.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 3.10 Session Log Harness Contract
|
|
245
|
+
|
|
246
|
+
Use one narrow raw-event ingestion seam for harness logs and session histories.
|
|
247
|
+
|
|
248
|
+
Rule:
|
|
249
|
+
|
|
250
|
+
1. harness adapters discover files and parse raw events
|
|
251
|
+
2. shared AKM logic performs normalization, fingerprinting, aggregation, and de-duplication
|
|
252
|
+
3. new harnesses should not require edits to shared unions or duplicated aggregation logic
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## 4. Implemented Contracts
|
|
257
|
+
|
|
258
|
+
**[0.9.0 change, ruled Q-06/Q-16]** This section previously listed twelve
|
|
259
|
+
"recommended" contracts; seven had no implementation anywhere in `src/`
|
|
260
|
+
(`PathResolver`, `MatchContributor`, `MetadataContributor`,
|
|
261
|
+
`LintContributor`, `ImproveContributor`, `IndexPostProcessor`,
|
|
262
|
+
`AgentRunner`) and were aspirational, not a contract any code followed.
|
|
263
|
+
Trimmed to the contributor contracts below. `SearchHitEnricher` and
|
|
264
|
+
`ActionContributor` were later folded into direct calls
|
|
265
|
+
(`src/indexer/search/search-hit-enrichers.ts`, `buildLocalAction` in
|
|
266
|
+
`src/indexer/search/db-search.ts`) — each had one implementation. The engine-owned
|
|
267
|
+
`AgentRequestLowerer` is the separate structural boundary documented in
|
|
268
|
+
§3.9, not a revival of the removed generic `AgentRunner`. See the [drift
|
|
269
|
+
register](../specs/0.9.0-docs-code-drift-register.md#q-16--functional-contract-patternsmd-4-aspiration-or-contract)
|
|
270
|
+
if a removed entry needs reviving; add it back only alongside a real
|
|
271
|
+
implementation.
|
|
272
|
+
|
|
273
|
+
## 4.1 `RankingContributor`
|
|
274
|
+
|
|
275
|
+
For search score adjustments and explanations.
|
|
276
|
+
|
|
277
|
+
## 4.2 `ProposalValidator`
|
|
278
|
+
|
|
279
|
+
For proposal acceptance checks.
|
|
280
|
+
|
|
281
|
+
## 4.3 `SessionLogHarness`
|
|
282
|
+
|
|
283
|
+
For raw session-log or history ingestion from external harnesses.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 5. What Stays Centralized
|
|
288
|
+
|
|
289
|
+
- source/provider model
|
|
290
|
+
- CLI command contracts
|
|
291
|
+
- DB schema and persistence boundaries
|
|
292
|
+
- write-target resolution
|
|
293
|
+
- search stage order
|
|
294
|
+
- final score normalization and clamping
|
|
295
|
+
- proposal storage
|
|
296
|
+
|
|
297
|
+
If these become pluggable, the system becomes harder to reason about.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## 6. What Gets Delegated
|
|
302
|
+
|
|
303
|
+
- heuristics
|
|
304
|
+
- enrichment
|
|
305
|
+
- validation rules
|
|
306
|
+
- process-specific side-effects
|
|
307
|
+
- applicability logic
|
|
308
|
+
- search explanations
|
|
309
|
+
|
|
310
|
+
If these stay centralized, switchboards keep growing.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 7. Smells To Avoid
|
|
315
|
+
|
|
316
|
+
1. One large interface with many optional methods
|
|
317
|
+
2. Registries keyed only by `type`
|
|
318
|
+
3. Matching logic that also chooses presentation names
|
|
319
|
+
4. Renderers that also own indexing and search policy
|
|
320
|
+
5. Ad hoc per-command path lookup logic
|
|
321
|
+
6. Open-ended capability graphs with unclear precedence
|
|
322
|
+
7. Hidden special cases spread across callers instead of isolated behind one seam
|
|
323
|
+
8. Architectural cleanup that changes behavior or rewrites tests to fit the refactor
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## 8. Review Checklist
|
|
328
|
+
|
|
329
|
+
When adding a new seam, ask:
|
|
330
|
+
|
|
331
|
+
1. Is this a stable process boundary?
|
|
332
|
+
2. Can the contributor be tested in isolation?
|
|
333
|
+
3. Does orchestration remain readable top-down?
|
|
334
|
+
4. Is ordering explicit?
|
|
335
|
+
5. Is `type` only an input, not the behavior object?
|
|
336
|
+
6. Can existing behavior be adapted before rewriting it?
|
|
337
|
+
7. Is this a refactor-only change with behavior preserved?
|
|
338
|
+
8. Does onboarding a new external harness require only one narrow adapter?
|
|
339
|
+
|
|
340
|
+
If the answer is no to several of these, the abstraction is probably too large.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# `akm health` advisory → action map
|
|
2
|
+
|
|
3
|
+
Run `akm health` (add `--json` for machine output). The authoritative result
|
|
4
|
+
combines hard failures with deterministic warnings across both output
|
|
5
|
+
channels:
|
|
6
|
+
|
|
7
|
+
- Deterministic hard-check and advisory warnings set the overall status to `warn` and exit code 4.
|
|
8
|
+
- A hard check `fail` sets the overall status to `fail` and exit code 1.
|
|
9
|
+
- A heuristic (non-deterministic) advisory `warn` does not change or gate the overall status.
|
|
10
|
+
- A heuristic (non-deterministic) advisory `warn` does not change or gate the exit code.
|
|
11
|
+
|
|
12
|
+
This table is the interpretive key for a second operator: what each named
|
|
13
|
+
advisory measures and whether to act. Some `warn`s below are *adjudicated,
|
|
14
|
+
expected* states — treat them as "no action" until the referenced condition
|
|
15
|
+
changes.
|
|
16
|
+
|
|
17
|
+
| Advisory (name in output) | What it means | Action |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `state-db-schema` | state.db is missing required tables. | Re-run `akm bundle create`; a fresh/older DB was opened. |
|
|
20
|
+
| `state-db-round-trip` | Append/read probe against state.db failed. | Check disk/permissions on the state.db path; the store is unwritable. |
|
|
21
|
+
| `state-db-integrity` | state.db failed `PRAGMA integrity_check` (which, unlike `quick_check`, also compares every index with its table), or more than half its pages are free (reclaimable by VACUUM). | Back up state.db, then run `sqlite3 -readonly state.db ".dump" \| sqlite3 state.new.db`, verify `state.new.db` passes `integrity_check`, and swap it in; the freelist warning clears on its own on the next `akm improve` retention purge, which VACUUMs state.db above the same 50% threshold. |
|
|
22
|
+
| `task-log-backing` | task_history rows reference log files missing on disk. | Logs were pruned/moved out from under the DB; safe to ignore if intentional, else restore the log dir. |
|
|
23
|
+
| `active-runs` | A task run has exceeded the stale threshold (>15 min). | Inspect with `akm task history`; a lane is likely wedged — kill/re-run it. |
|
|
24
|
+
| `default-engine` | The configured general default agent, SDK, or LLM engine is missing or incomplete. | Correct `defaults.engine`; SDK operation requires the `opencode` binary on PATH (the npm SDK is an HTTP client and spawns `opencode serve`), while a fallback LLM is checked only when configured. |
|
|
25
|
+
| `model-map-files` | The installed or optional user `models.json` is missing, unreadable, or invalid. | Repair the installation for an installed-map failure; remove or correct the user overlay for a warning. |
|
|
26
|
+
| `selected-model-aliases` | A known selected alias lacks a mapping for its selected engine. Unknown model strings remain exact pass-through identifiers. | Add the missing alias/engine entry or select an exact model ID. |
|
|
27
|
+
| `default-llm-engine` | The independently configured LLM default is missing, incompatible, lacks a required credential, or (#914) its endpoint refuses the reachability probe. | Correct `defaults.llmEngine`, its connection, any symbolic credential binding, or the endpoint itself; an unreachable default is a hard `fail`. |
|
|
28
|
+
| `configured-engines` | Checks every explicitly configured engine and aggregates its deterministic availability, including (#914) reachability for `kind: "llm"` engines. | Repair engines whose safe status is `warn`; no configured engines yields `unknown`. |
|
|
29
|
+
| `active-improve-strategy` | An enabled process in the effective improve strategy cannot resolve its engine or required credential; evidence and the message name the resolved engine per process (#913), surfacing a strategy-level pin that shadows `defaults.llmEngine`. Derived from the same `resolveImprovePlan` credential check the real `improve` run uses (#957), so this reflects exactly what a run in this environment would skip. `warn` when some but not all enabled LLM-backed processes are unavailable; **`fail`** (#957) when EVERY enabled `capability: "llm"` process in the strategy is unavailable — the nightly run would be a total no-op, not a partial degradation. | Inspect the named unavailable process(es), then correct its process override, strategy triage engine, SDK fallback, or default LLM. A `fail` here means `akm improve --require-engines` would abort the same run outright; add that flag to the scheduled task once the credential is fixed to make future silent no-ops fail loudly instead. |
|
|
30
|
+
| `task-fail-rate` | ≥5% of scheduled task runs failed in the window (exit 143/70 recurring), or a single task_id fails at/above the same threshold. (#943) For `command`-kind (agent/LLM dispatch) failures specifically, `evidence.agentFailureReasonCounts` always carries a `detail.reason` breakdown (`timeout`, `non_zero_exit`, `spawn_failed`, …), and the warn message names the dominant reason — e.g. `(timeout-dominant: 9/12 command-task failures)` — when one reason is at least half of the counted command-task failures. | Triage as a bug: `akm task doctor`, inspect failing lane logs. For a native shell/script task, exit-143 = killed/timeout, exit-70 = internal error. For a `command`-kind (agent/LLM) task, read `detail.reason` from `akm task history` instead of the exit code — `timeout` means the dispatch's own deadline (not an outer process kill) expired; `non_zero_exit`/`spawn_failed`/`aborted`/etc. name the other failure shapes. |
|
|
31
|
+
| `data-dir-usage` | The data directory is more than 3× the live databases (`state.db` + `index.db` + `logs.db`), or one top-level subdirectory holds more than half of it; the message names that subdirectory with its size and share. | Look at the named subdirectory. `backups/tasks/` holds one snapshot per `akm migrate apply` run that rewrote a task file; everything under `backups/` is yours to prune. |
|
|
32
|
+
| `stash-git-exposure` | `env/` or `secrets/` assets are git-tracked **and** a remote is set — `git push` can leak keys. | `git rm --cached` the files, add `env/`+`secrets/` to `.gitignore` (a rule alone does not untrack). |
|
|
33
|
+
| `semantic-search-runtime` | Semantic search is blocked; often a configured remote embedding endpoint is down. | Restore the endpoint, or set `semanticSearchMode` to `off`, or drop `embedding.endpoint` to use the local model. |
|
|
34
|
+
| `session-extraction` | (#914) Derived from the `extract_sessions_seen` ledger for the last 7 days — not `improve_runs`, which the hook-driven `akm proposal extract --session-id ...` never writes. `unknown` when nothing was recorded; `warn` when every session in the window was skipped for an infrastructure reason (`llm_unavailable`, `read_failed`, `exception`, `locked_concurrent`), naming the reason and engine; otherwise `pass` with per-outcome counts. | An `unknown` machine may be deliberately not configured for extraction, or may have stopped harvesting — check for recent sessions. A `warn` names the broken engine/reason directly. |
|
|
35
|
+
| `pool-saturation` | <2% of the session pool was new — possible discovery/dedup bug. | Verify `akm proposal extract` still finds new sessions; a healthy steady state sits above 10%. |
|
|
36
|
+
| `auto-accept-validation` | Proposals passed the confidence gate but failed validation (bad frontmatter, truncation). | Review the affected pending proposals via `akm proposal list`; they were held, not lost. |
|
|
37
|
+
| `outcome-proxy-adequacy` | Retrieval proxy is *inverted* (corr < −0.3): popular assets are the most-needing-improvement. | Known WS-2 limitation; no live action — see plan §WS-2 / CONTEXT before tuning. |
|
|
38
|
+
| `outcome-proxy-dead` | Retrieval proxy is *dead* (\|corr\| < 0.1 at n≥500): outcome_score is noise. | **Adjudicated/expected** during the minting-shutdown re-baseline (12-D1); no action. |
|
|
39
|
+
| `salience-uniformity-collapse` | Gini across all positive, resolvable retrieval-salience values is below 0.08 — ranking no longer discriminates among assets with retrieval evidence. | Inspect the reported sample size and salience freshness; run `akm index` to refresh retrieval timestamps, then let the improve schedule recompute salience before tuning weights. |
|
|
40
|
+
| `enrichment-lane-minting` | Enrichment lanes minted new assets above threshold (5% warn / higher = fail). | Adjudicated against the ratified minting rules; act only if the share keeps climbing post-shutdown. |
|
|
41
|
+
| `improve-churn-ratio` | Accepted proposals rewrote the same few refs (ratio > 1.5) instead of covering the corpus. | Expected while coverage is low; watch the trend, do not retune on a single window. |
|
|
42
|
+
| `collapse-churn-detector` | R5 detector fired collapse/churn alerts (or `unknown` = no cycle rows yet). | Inspect recent collapse/churn cycle rows and the detector's advisory output before acting. |
|
|
43
|
+
| `thinking-control` | (#949) For every configured `kind: "llm"` engine with `enableThinking: false`, checks the window's recorded `llm_usage` for reasoning tokens. Passive: never issues its own completion. `unknown` when no engine sets `enableThinking: false`, or when a configured one made no calls in the window. | A `warn` names the engine that returned reasoning tokens — its endpoint, or a gateway in front of it, is not honoring the thinking-off control. Check the gateway/endpoint config; behind a gateway that drops `chat_template_kwargs` (Bifrost), set `reasoningEffort: "none"` on the engine, which such gateways pass through. |
|
|
44
|
+
| `cli-version` | (#950) Compares the installed akm-cli version against the latest GitHub release (the same source `akm upgrade` trusts). `--probe`-gated: `unknown` "not probed" with `--no-probe`; offline/rate-limited also degrades to `unknown`, never a false `warn`. | Run `akm upgrade` when a newer release is reported. An `unknown` result carries no staleness claim either way — check manually if it matters. |
|
|
45
|
+
| `engine-last-used` | (#950) For every engine bound to an enabled process in the active improve strategy, checks `llm_usage` for a call in the last 30 days (independent of `--since`). `unknown` when no engine is bound, or when no improve run has been recorded (started) in that window at all (a fresh install). | A `warn` names the idle engine and the process it is bound to. Configured, reachable, and credentialed is not the same as actually used — investigate why the bound process is not invoking it (disabled downstream, misrouted, or genuinely unused). |
|
|
46
|
+
| `scheduler-binary` | (#953) Reads the scheduler's recorded akm invocation for the installed tasks (the same binding `task sync`/`task doctor` already read — no crontab/launchd/schtasks text parsing) and runs it with `--version`, compared against the running CLI's version. `--probe`-gated: `unknown` "not probed" with `--no-probe`. `unknown` when no scheduled task is installed or the recorded binary cannot be executed. | A `warn` names both versions — upgrading akm through a different installer than the one active at the last `task sync` left the schedule pointed at the old binary; run `akm task sync` to rebind it. |
|
|
47
|
+
| `plugin-version` / `opencode-plugin-version` | (itlackey/akm#832,) `plugin-version` reports each installed Claude Code harness plugin's version and its declared `AKM_VERSION_RANGE` admission of the running CLI. `opencode-plugin-version` does the same for the OpenCode plugin's own bundled `akm-cli` (read from its `package.json`, never executed) — it runs in-process and shares the host's databases, so its lag matters the same way. Neither is `--probe`-gated. | A `warn` names the stale/out-of-range plugin and the update command (`claude plugin update <ref>` for the Claude plugin; update the OpenCode plugin for the bundled copy). |
|
|
48
|
+
|
|
49
|
+
> Adjudicated states (`outcome-proxy-dead`, `enrichment-lane-minting`)
|
|
50
|
+
> are the before/after instrument for the 12-D1 minting shutdown — do not "fix" them by retuning.
|
|
51
|
+
> When in doubt, prefer no action over panic-retuning (per the review-12 guard).
|
|
52
|
+
|
|
53
|
+
## Engine and model advisories
|
|
54
|
+
|
|
55
|
+
`selected-model-aliases` warns when a known selected alias is missing the selected engine mapping.
|
|
56
|
+
It checks explicit string model selections on sorted
|
|
57
|
+
configured engines against the merged installed/user model map. Unknown model
|
|
58
|
+
identifiers are exact pass-through values and are not reported as missing. An
|
|
59
|
+
invalid model map makes this check `unknown` with generic evidence rather than
|
|
60
|
+
copying parser text or authored values.
|
|
61
|
+
|
|
62
|
+
`configured-engines` covers every explicitly configured engine. It reuses the
|
|
63
|
+
same availability result as the default-engine projections and reports sorted
|
|
64
|
+
safe evidence containing only engine name and status. All available engines
|
|
65
|
+
pass; any unavailable engine warns; no explicitly configured engines is
|
|
66
|
+
`unknown`.
|
|
67
|
+
|
|
68
|
+
Agent checks inspect local binary availability; SDK checks inspect the
|
|
69
|
+
package/binary and any configured fallback. LLM checks (a `kind: "llm"`
|
|
70
|
+
runner, and an SDK runner's LLM fallback connection) additionally send a
|
|
71
|
+
real, bounded (3 s timeout) reachability probe (#914) — one `GET` against
|
|
72
|
+
the endpoint's `/models` route; any HTTP response counts, so a cold local
|
|
73
|
+
server is never asked to load a model — to `default-llm-engine`'s and
|
|
74
|
+
`configured-engines`' endpoints, one probe per distinct endpoint per
|
|
75
|
+
invocation (no cross-run cache, so a stale "reachable" verdict never lingers).
|
|
76
|
+
An unreachable endpoint is a hard `fail` for `default-llm-engine` (extraction
|
|
77
|
+
and improve depend on it directly) and a `warn` for every other engine that
|
|
78
|
+
resolves to it. Pass `--no-probe` to skip these probes entirely (offline or
|
|
79
|
+
air-gapped hosts) — every affected check then reports its prior,
|
|
80
|
+
credential-only verdict and notes that reachability was not probed.
|
|
81
|
+
|
|
82
|
+
Engine evidence names the endpoint and model of the probed connection so an
|
|
83
|
+
operator can tell which connection was checked; it never includes credential
|
|
84
|
+
values or provider output.
|
|
85
|
+
|
|
86
|
+
(#950) When a required `$VAR`-style credential is unavailable in the health
|
|
87
|
+
process's own shell, `default-llm-engine` and `configured-engines` also check
|
|
88
|
+
whether any `env/` asset defines a key by the same name. When one does, the
|
|
89
|
+
`warn` message and `evidence.suppliedByEnvAsset` name the env asset's ref
|
|
90
|
+
(e.g. `env/lab`) and point at `akm env run env/lab -- ...` — never the
|
|
91
|
+
variable name itself, which stays out of both the message and evidence (see
|
|
92
|
+
`tests/health-engine-probe.test.ts`). This is the common case where the
|
|
93
|
+
operator's real workflow already supplies the credential under an `env run`
|
|
94
|
+
wrapper; the check still `warn`s (the credential genuinely is unavailable in
|
|
95
|
+
*this* invocation's shell), just with an actionable next step instead of a
|
|
96
|
+
bare "unavailable".
|
|
97
|
+
|
|
98
|
+
`akm health` makes at most two network calls, both best-effort and silent on
|
|
99
|
+
failure: `plugin-version`'s `git ls-remote` (unconditional, predates
|
|
100
|
+
`--probe`) and `cli-version`'s GitHub-release lookup (gated behind
|
|
101
|
+
`--probe`/`--no-probe`, same flag as engine reachability). See
|
|
102
|
+
`src/commands/health/plugin-staleness.ts` and
|
|
103
|
+
`src/commands/health/version-drift.ts` for the discipline each follows.
|
|
104
|
+
|
|
105
|
+
The salience Gini guardrails are calibrated against distribution shape, not a
|
|
106
|
+
top-ranked quantile: near-uniform `0.49/0.51` scores produce about `0.01`, a
|
|
107
|
+
balanced `0.25/0.75` spread produces `0.25`, and one dominant score among nine
|
|
108
|
+
`0.01` scores produces about `0.82`. Read-only full-observation snapshots were
|
|
109
|
+
also stable inside the neutral `0.08..0.35` band: `0.2613` across 1,209 assets
|
|
110
|
+
on 2026-07-12 and `0.2506` across 1,454 non-missing assets on 2026-08-17.
|