@kontextmind/kxm 0.7.95 → 0.7.97
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/.claude-plugin/marketplace.json +1 -1
- package/.kxm/README.md +39 -9
- package/CHANGELOG.md +23 -1
- package/README.md +147 -257
- package/SECURITY.md +21 -12
- package/docs/README.md +133 -54
- package/docs/adr/ADR-0002-browser-automation-steel-doks.md +24 -18
- package/docs/adr/ADR-0003-sqlite-only-store.md +100 -0
- package/docs/adr/ADR-0004-edge-identity-authentik.md +99 -0
- package/docs/adr/README.md +33 -0
- package/docs/concepts/architecture.md +262 -0
- package/docs/concepts/data-and-storage.md +194 -0
- package/docs/concepts/trust-model.md +153 -0
- package/docs/contracts/README.md +22 -14
- package/docs/contracts/effects-and-recovery.md +3 -0
- package/docs/contracts/migration.md +2 -2
- package/docs/contracts/routing.md +6 -5
- package/docs/contributing/assignment-runner.md +388 -0
- package/docs/contributing/ci-and-release.md +231 -0
- package/docs/contributing/development.md +362 -0
- package/docs/contributing/harness-routing-internals.md +192 -0
- package/docs/{packages.md → contributing/packages.md} +13 -15
- package/docs/{skills → contributing}/repo-work-delivery.md +20 -21
- package/docs/contributing/test-matrix.md +208 -0
- package/docs/{tui-components.md → contributing/tui-components.md} +30 -22
- package/docs/contributing/writing-docs.md +340 -0
- package/docs/glossary.md +471 -0
- package/docs/guides/agent-skills.md +137 -0
- package/docs/guides/browser-automation.md +160 -0
- package/docs/guides/context-and-memory.md +352 -0
- package/docs/guides/continuous-improvement.md +228 -0
- package/docs/guides/governed-skills.md +173 -0
- package/docs/guides/nous-providers.md +186 -0
- package/docs/guides/peer-messaging.md +304 -0
- package/docs/guides/pi-workers.md +219 -0
- package/docs/guides/provenance-gates.md +313 -0
- package/docs/guides/webhook-workflows.md +399 -0
- package/docs/kb/how-credentials-retrieved-safely.md +38 -12
- package/docs/kb/how-to-capture-and-annotate-section.md +15 -13
- package/docs/kb/how-to-connect-playwright-to-steel.md +16 -11
- package/docs/kb/how-to-recover-expired-session-or-orphan.md +26 -16
- package/docs/kb/how-to-resume-after-mfa.md +19 -11
- package/docs/kb/how-to-take-over-session.md +17 -13
- package/docs/kb/why-authentication-disappeared.md +22 -14
- package/docs/kb/why-automation-opened-different-browser.md +23 -14
- package/docs/kb/why-session-viewer-cannot-control.md +13 -12
- package/docs/operations/backup-and-restore.md +248 -0
- package/docs/operations/deploy.md +307 -0
- package/docs/operations/monitoring.md +209 -0
- package/docs/operations/runtime-sync.md +192 -0
- package/docs/operations/troubleshooting.md +266 -0
- package/docs/operations/upgrade.md +124 -0
- package/docs/prompts/browser-annotate-feedback.md +7 -7
- package/docs/prompts/browser-diagnose-recover.md +11 -10
- package/docs/prompts/browser-explore.md +7 -7
- package/docs/prompts/browser-repro-fix.md +7 -7
- package/docs/prompts/browser-start.md +12 -11
- package/docs/prompts/browser-takeover.md +8 -8
- package/docs/{cli-reference.md → reference/cli-reference.md} +88 -46
- package/docs/{config-reference.md → reference/config-reference.md} +159 -148
- package/docs/reference/configuration.md +299 -0
- package/docs/reference/harness-routing.md +508 -0
- package/docs/reference/http-api.md +203 -0
- package/docs/reference/tools.md +370 -0
- package/docs/{workflow-guide.md → reference/workflow-catalog.md} +92 -153
- package/docs/reference/workflow-definitions.md +286 -0
- package/docs/start/first-workflow.md +287 -0
- package/docs/start/install.md +146 -0
- package/docs/start/quickstart-claude-code.md +405 -0
- package/docs/start/quickstart-pi.md +213 -0
- package/docs/templates/README.md +78 -73
- package/docs/templates/adr.md +13 -13
- package/docs/templates/architecture.md +55 -71
- package/docs/templates/bug-fix.md +13 -16
- package/docs/templates/feature.md +14 -19
- package/docs/templates/handoff.md +44 -46
- package/docs/templates/postmortem.md +30 -43
- package/docs/templates/research.md +15 -20
- package/docs/templates/review.md +49 -50
- package/docs/templates/runbook.md +38 -30
- package/docs/templates/test-plan.md +16 -23
- package/docs/templates/test-report.md +14 -17
- package/examples/README.md +9 -5
- package/examples/provenance-workflow.json +1 -1
- package/examples/webhook-workflows/jira-development.json +59 -0
- package/examples/webhook-workflows/jira-issue-updated.json +12 -0
- package/examples/workflow-signal.ts +4 -5
- package/package.json +1 -1
- package/packages/core/tui/README.md +1 -1
- package/plugins/kxm/.claude-plugin/plugin.json +1 -1
- package/plugins/kxm/README.md +31 -32
- package/plugins/kxm/dist/claude-hook.js +11 -1
- package/plugins/kxm/dist/cli.js +164 -79
- package/plugins/kxm/dist/client.js +3 -1
- package/plugins/kxm/dist/core.js +11 -1
- package/plugins/kxm/dist/extension.js +45 -13
- package/plugins/kxm/dist/mcp-server.js +20 -4
- package/plugins/kxm/dist/runtime-supervisor.js +1 -3
- package/plugins/kxm/dist/runtime.js +18 -4
- package/plugins/kxm/dist/server.js +115 -20
- package/plugins/kxm/package.json +1 -1
- package/plugins/kxm/skills/kxm/references/protocol.md +3 -1
- package/plugins/kxm/skills/kxm-browser-auth/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-browser-diagnostics/SKILL.md +5 -5
- package/plugins/kxm/skills/kxm-browser-explore/SKILL.md +2 -2
- package/plugins/kxm/skills/kxm-browser-session/SKILL.md +10 -13
- package/plugins/kxm/skills/kxm-browser-takeover/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-browser-verify/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-context-memory/SKILL.md +13 -4
- package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +3 -1
- package/plugins/kxm/skills/kxm-mind-setup/SKILL.md +2 -1
- package/plugins/kxm/skills/kxm-project-setup/SKILL.md +31 -54
- package/plugins/kxm/skills/kxm-projects/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-protocol/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-routing-improve/SKILL.md +15 -7
- package/plugins/kxm/skills/kxm-runs/SKILL.md +11 -5
- package/plugins/kxm/skills/kxm-session/SKILL.md +1 -1
- package/plugins/kxm/skills/kxm-tasks/SKILL.md +9 -7
- package/plugins/kxm/skills/kxm-workflow/SKILL.md +10 -2
- package/plugins/kxm/src/cli/system.ts +1 -1
- package/plugins/kxm/src/cli/workflows.ts +12 -7
- package/plugins/kxm/src/cli.ts +22 -8
- package/plugins/kxm/src/client.ts +4 -0
- package/plugins/kxm/src/commands.ts +23 -1
- package/plugins/kxm/src/extension.ts +20 -14
- package/plugins/kxm/src/github-watch.ts +8 -5
- package/plugins/kxm/src/hub-env.ts +19 -1
- package/plugins/kxm/src/hub.ts +105 -21
- package/plugins/kxm/src/improve-sources.ts +2 -7
- package/plugins/kxm/src/init-guide-setup.ts +1 -1
- package/plugins/kxm/src/mcp-server.ts +9 -2
- package/plugins/kxm/src/modes.ts +1 -1
- package/plugins/kxm/src/runtime-store.ts +23 -0
- package/plugins/kxm/src/workflow.ts +70 -1
- package/schemas/README.md +1 -1
- package/scripts/smoke-multi-pi.mjs +5 -1
- package/docs/agent-communication-envelopes-and-gates.md +0 -553
- package/docs/agent-skills.md +0 -198
- package/docs/architecture.md +0 -245
- package/docs/assignment-runner.md +0 -264
- package/docs/browser-automation.md +0 -139
- package/docs/configuration.md +0 -437
- package/docs/continuous-improvement.md +0 -226
- package/docs/getting-started.md +0 -277
- package/docs/harness-routing.md +0 -616
- package/docs/kb/qa-authentik-authentication.md +0 -97
- package/docs/kb/qa-extension-install-and-hub-bootstrap.md +0 -85
- package/docs/kb/qa-hub-on-a-public-host.md +0 -48
- package/docs/kb/qa-sqlite-vs-duckdb.md +0 -35
- package/docs/kb/qa-what-the-hub-stores.md +0 -64
- package/docs/kxm-handbook.md +0 -1181
- package/docs/operations.md +0 -510
- package/docs/operator-pi-packages.md +0 -67
- package/docs/provenance-gates.md +0 -295
- package/docs/skills.md +0 -47
- package/docs/test-matrix.md +0 -132
- package/docs/troubleshooting.md +0 -322
- package/docs/webhook-workflows.md +0 -240
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Quick start: Pi
|
|
2
|
+
|
|
3
|
+
This tutorial connects two Pi agents through a KXM [hub](../glossary.md#hub) and has one ask the other for a review. It takes about ten minutes once Node.js, Git and Pi are installed. At the end, a planner and a reviewer exchange a durable request, and you can add Claude Code to the same project.
|
|
4
|
+
|
|
5
|
+
## Before you begin
|
|
6
|
+
|
|
7
|
+
- Node.js 22.19 or newer on the 22.x line, or Node.js 24 or newer, and Git.
|
|
8
|
+
- Pi, signed in to a model provider. Install it with `npm install --global @earendil-works/pi-coding-agent`; the [Pi documentation](https://pi.dev/docs/latest) covers sign-in.
|
|
9
|
+
- A Git repository for the project, and three terminals.
|
|
10
|
+
|
|
11
|
+
Every agent in one project uses the same hub URL, project key and project token, and each needs a unique name. The hub's admin token stays with you, the operator; no agent gets it.
|
|
12
|
+
|
|
13
|
+
## 1. Install
|
|
14
|
+
|
|
15
|
+
Install the `kxm` CLI with npm, and the KXM package into Pi:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --global --omit=peer @kontextmind/kxm
|
|
19
|
+
pi install git:github.com/kontextmind/kxm@main
|
|
20
|
+
kxm --version
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`kxm --version` prints the installed version. The Pi package adds the KXM extension and skills to Pi but does not put `kxm` on your `PATH`; only the npm install does. [Install KXM](install.md) covers other options.
|
|
24
|
+
|
|
25
|
+
## 2. Initialize the project
|
|
26
|
+
|
|
27
|
+
In the first terminal, before you start Pi or a hub in this repository:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cd <your-repo>
|
|
31
|
+
kxm init --name "<display-name>"
|
|
32
|
+
printf '%s\n' '.kxm/state/' '.kxm/logs/' '.kxm/backups/' >> .gitignore
|
|
33
|
+
git add .gitignore .kxm
|
|
34
|
+
git commit -m "Add KXM project configuration"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`kxm init` prints `initialized KXM project at <repo-root>`. It writes the project's agents, gates and a default workflow under `.kxm/`, and no ignore rules, so the second command adds them.
|
|
38
|
+
|
|
39
|
+
> [!NOTE]
|
|
40
|
+
> In an interactive terminal, `kxm init` offers to install shell completion and to add workflow-guide agents for the harnesses you have signed in to. Both are safe to decline. Set `KXM_SKIP_COMPLETION_PROMPT=1` and `KXM_SKIP_GUIDE_SETUP_PROMPT=1` to skip them.
|
|
41
|
+
|
|
42
|
+
## 3. Start the hub
|
|
43
|
+
|
|
44
|
+
In the second terminal, from the repository root, create a token for the project `demo` and start the hub. The commands keep any projects the hub already saved:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# The user state root is KXM_STATE_HOME when set; the default below is for macOS.
|
|
48
|
+
# On Linux, use "${XDG_STATE_HOME:-$HOME/.local/state}/kxm/hub-env.json" instead.
|
|
49
|
+
HUB_ENV="${KXM_STATE_HOME:-$HOME/Library/Application Support/KXM}/hub-env.json"
|
|
50
|
+
export KXM_NEW_PROJECT_TOKEN="$(openssl rand -hex 32)"
|
|
51
|
+
export KXM_PROJECT_TOKENS="$(node -e '
|
|
52
|
+
const fs = require("node:fs");
|
|
53
|
+
const [file, project] = process.argv.slice(1);
|
|
54
|
+
const saved = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, "utf8")).projectTokens ?? {} : {};
|
|
55
|
+
saved[project] = process.env.KXM_NEW_PROJECT_TOKEN;
|
|
56
|
+
process.stdout.write(JSON.stringify(saved));
|
|
57
|
+
' "$HUB_ENV" demo)"
|
|
58
|
+
kxm hub start
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
<details><summary>PowerShell</summary>
|
|
62
|
+
|
|
63
|
+
```powershell
|
|
64
|
+
$bytes = New-Object byte[] 32
|
|
65
|
+
[Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
|
|
66
|
+
$env:KXM_NEW_PROJECT_TOKEN = ($bytes | ForEach-Object { $_.ToString('x2') }) -join ''
|
|
67
|
+
$stateRoot = if ($env:KXM_STATE_HOME) { $env:KXM_STATE_HOME } else { Join-Path $env:LOCALAPPDATA 'KXM' }
|
|
68
|
+
$hubEnv = Join-Path $stateRoot 'hub-env.json'
|
|
69
|
+
$env:KXM_PROJECT_TOKENS = node -e "const fs=require('node:fs');const [f,p]=process.argv.slice(1);const s=fs.existsSync(f)?JSON.parse(fs.readFileSync(f,'utf8')).projectTokens??{}:{};s[p]=process.env.KXM_NEW_PROJECT_TOKEN;process.stdout.write(JSON.stringify(s))" $hubEnv 'demo'
|
|
70
|
+
kxm hub start
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
</details>
|
|
74
|
+
|
|
75
|
+
Expected output:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
kxm hub: using newly generated KXM_AUTH_TOKEN from <state-root>/hub-env.json
|
|
79
|
+
kxm hub listening at http://127.0.0.1:7331; storage=<repo-root>/.kxm/state/kxm.db; auth=token
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Keep this terminal open. The hub generates its admin token on the first start and saves it, with the project tokens, in `hub-env.json`. `KXM_PROJECT_TOKENS` replaces the saved project map rather than adding to it, which is why the command starts from the saved map.
|
|
83
|
+
|
|
84
|
+
> [!TIP]
|
|
85
|
+
> The Pi extension can start a hub for you: with the default `hub.autoStart: background`, it reuses a healthy bound hub or starts a detached one. This tutorial starts the hub by hand so that you create the project token yourself.
|
|
86
|
+
|
|
87
|
+
## 4. Bind this machine to the hub
|
|
88
|
+
|
|
89
|
+
In the first terminal:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
kxm hub bind http://127.0.0.1:7331
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Expected output:
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
bound hub http://127.0.0.1:7331 · loopback · health=on
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 5. Confirm the session
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
kxm hub view
|
|
105
|
+
kxm session status
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Expected output:
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
hub health=true ready=true · loopback hub
|
|
112
|
+
1 session claim(s), 0 recovery envelope(s)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The hub is healthy and ready, and its process is the one session claim.
|
|
116
|
+
|
|
117
|
+
## 6. Start the planner
|
|
118
|
+
|
|
119
|
+
Still in the first terminal, give the agent the project token, which the command reads from `hub-env.json` without printing it, and an identity:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
HUB_ENV="${KXM_STATE_HOME:-$HOME/Library/Application Support/KXM}/hub-env.json"
|
|
123
|
+
export KXM_AUTH_TOKEN="$(node -e 'process.stdout.write(JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8")).projectTokens[process.argv[2]] ?? "")' "$HUB_ENV" demo)"
|
|
124
|
+
export KXM_SERVER_URL=http://127.0.0.1:7331
|
|
125
|
+
export KXM_PROJECT=demo
|
|
126
|
+
export KXM_AGENT_NAME=planner
|
|
127
|
+
export KXM_AGENT_PURPOSE="Plans work and coordinates handoffs"
|
|
128
|
+
pi
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
<details><summary>PowerShell</summary>
|
|
132
|
+
|
|
133
|
+
```powershell
|
|
134
|
+
$stateRoot = if ($env:KXM_STATE_HOME) { $env:KXM_STATE_HOME } else { Join-Path $env:LOCALAPPDATA 'KXM' }
|
|
135
|
+
$env:KXM_AUTH_TOKEN = (Get-Content -Raw (Join-Path $stateRoot 'hub-env.json') | ConvertFrom-Json).projectTokens.'demo'
|
|
136
|
+
$env:KXM_SERVER_URL = "http://127.0.0.1:7331"
|
|
137
|
+
$env:KXM_PROJECT = "demo"
|
|
138
|
+
$env:KXM_AGENT_NAME = "planner"
|
|
139
|
+
$env:KXM_AGENT_PURPOSE = "Plans work and coordinates handoffs"
|
|
140
|
+
pi
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
</details>
|
|
144
|
+
|
|
145
|
+
Pi reports `Connected to the KXM hub as planner`. In Pi, run:
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
/kxm hub
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Expected output:
|
|
152
|
+
|
|
153
|
+
```text
|
|
154
|
+
kxm hub view: health=ok; planner; 1 online agent(s)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
> [!NOTE]
|
|
158
|
+
> Without `KXM_AUTH_TOKEN`, the extension signs in with the project token saved for this project on this machine, and never with the saved admin token. With neither, it reports the fix and stays offline. Set the project token so that each agent holds only its own project's credential.
|
|
159
|
+
|
|
160
|
+
## 7. Start the reviewer and send a request
|
|
161
|
+
|
|
162
|
+
In the third terminal, run the `HUB_ENV`, `KXM_AUTH_TOKEN`, `KXM_SERVER_URL` and `KXM_PROJECT` lines from step 6, then set a different identity and start Pi:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
export KXM_AGENT_NAME=reviewer
|
|
166
|
+
export KXM_AGENT_PURPOSE="Reviews plans and code for correctness risks"
|
|
167
|
+
pi
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
In the planner's Pi session, ask:
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
Use the kxm skill. List peers, ask reviewer to examine the current plan for
|
|
174
|
+
its three highest correctness risks, and wait for the response.
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The planner calls `kxm_list`, `kxm_send` and `kxm_await`. The reviewer's Pi receives the request as a new turn, and the extension returns that turn's final response as the reply. The planner then shows the reviewer's answer.
|
|
178
|
+
|
|
179
|
+
The hub stores the request as a durable record that moves from `queued` to `delivered` to `replied`, so it survives a hub restart. `kxm_await` waits at most 60 seconds; a slower reply stays pending, and the planner can check it later with `kxm_get`. [Message peer agents](../guides/peer-messaging.md) covers fanout, cancellation and delivery modes.
|
|
180
|
+
|
|
181
|
+
## 8. Add Claude Code (optional)
|
|
182
|
+
|
|
183
|
+
Claude Code can join the same project. Install the plugin as in [Quick start: Claude Code](quickstart-claude-code.md#5-install-the-plugin), with `project` set to `demo`, a unique `agent_name` such as `claude-reviewer`, and `auth_token` left blank on this machine. Then ask Claude to call `kxm_list`: the planner and the reviewer appear.
|
|
184
|
+
|
|
185
|
+
## Your first useful topology
|
|
186
|
+
|
|
187
|
+
Start with two or three agents that have clear, separate jobs:
|
|
188
|
+
|
|
189
|
+
| Role | Good responsibilities |
|
|
190
|
+
|---|---|
|
|
191
|
+
| Planner | Break down work, define ownership, collect results |
|
|
192
|
+
| Builder | Implement one bounded change |
|
|
193
|
+
| Reviewer | Check correctness, tests, security or documentation |
|
|
194
|
+
|
|
195
|
+
KXM does not coordinate file ownership. Do not let two agents edit the same files in one checkout: use separate Git worktrees, or give one agent write ownership.
|
|
196
|
+
|
|
197
|
+
## Troubleshooting
|
|
198
|
+
|
|
199
|
+
| Message or symptom | Cause | Fix |
|
|
200
|
+
|---|---|---|
|
|
201
|
+
| `agent name already active in project: <name>` | Another live Pi agent in the project uses the name | Set a different `KXM_AGENT_NAME` and restart Pi |
|
|
202
|
+
| `/kxm hub` prints `no agent connected` | The extension could not register | Check `KXM_SERVER_URL`, `KXM_PROJECT` and `KXM_AUTH_TOKEN`, then restart Pi |
|
|
203
|
+
| `invalid project authentication token` | `KXM_AUTH_TOKEN` is not the hub's token for `KXM_PROJECT` | Read the token again as in step 6 |
|
|
204
|
+
| `kxm init` prints `legacy state is not migrated by this build` | Pi or a hub ran here before `kxm init` | See [Check the project](quickstart-claude-code.md#check-the-project) |
|
|
205
|
+
|
|
206
|
+
[Troubleshooting](../operations/troubleshooting.md) covers workers, sessions and the hub.
|
|
207
|
+
|
|
208
|
+
## Next steps
|
|
209
|
+
|
|
210
|
+
- Keep Pi agents running unattended: [Run supervised Pi workers](../guides/pi-workers.md)
|
|
211
|
+
- Run a workflow end to end: [Run your first workflow](first-workflow.md)
|
|
212
|
+
- Send, fan out and cancel requests: [Message peer agents](../guides/peer-messaging.md)
|
|
213
|
+
- Hub and agent settings: [Environment variables and limits](../reference/configuration.md)
|
package/docs/templates/README.md
CHANGED
|
@@ -1,95 +1,100 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
# Artifact templates
|
|
2
|
+
|
|
3
|
+
These templates give the artifacts a KXM workflow produces a common shape:
|
|
4
|
+
feature specifications, research briefs, bug reports, architecture designs,
|
|
5
|
+
decision records, test plans and reports, reviews, handoffs, runbooks and
|
|
6
|
+
postmortems. Agents and people fill them in during a run. For a human-facing
|
|
7
|
+
docs page, use the page template in
|
|
8
|
+
[Write KXM documentation](../contributing/writing-docs.md) instead.
|
|
9
|
+
|
|
10
|
+
## Principles
|
|
11
|
+
|
|
12
|
+
1. **Markdown, YAML frontmatter and Mermaid.** The frontmatter carries metadata
|
|
13
|
+
for indexing, the body stays readable, and diagrams are plain Mermaid.
|
|
14
|
+
2. **Keep plans, decisions and outcomes apart.** What should happen (feature,
|
|
15
|
+
architecture, test plan), what was decided (ADR), and what actually happened
|
|
16
|
+
(test report, witness receipt, postmortem) are separate artifacts.
|
|
17
|
+
3. **Pin every piece of evidence.** A test or review report cites an exact
|
|
18
|
+
commit (`git rev-parse HEAD`), a branch such as
|
|
19
|
+
`kxm/run-<run-id>-<description>`, and content-addressed artifacts written as
|
|
20
|
+
`artifact:<path>@sha256:<digest>`.
|
|
21
|
+
4. **Use the context vocabulary.** The `authority`, `confidence`, `summary` and
|
|
22
|
+
`tags` fields use the same values as KXM context items, so an indexer can
|
|
23
|
+
weigh an artifact. No KXM code reads this frontmatter today, and no JSON
|
|
24
|
+
Schema validates `kxm.doc.v1` yet.
|
|
25
|
+
|
|
26
|
+
## Templates
|
|
27
|
+
|
|
28
|
+
| Template | Use it for | Stage | Key outputs |
|
|
21
29
|
|---|---|---|---|
|
|
22
|
-
|
|
|
23
|
-
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Workflow Guide Integration Matrix
|
|
42
|
-
|
|
43
|
-
The 11 templates map directly across the 7 Areas and 22 Workflows in [`docs/workflow-guide.md`](../workflow-guide.md):
|
|
30
|
+
| [Feature specification](feature.md) | A new capability | Requirements and scope | Observable behavior, acceptance criteria, user flow |
|
|
31
|
+
| [Research brief](research.md) | A spike or evaluation | Discovery | Falsifiable hypotheses, evidence register, option comparison |
|
|
32
|
+
| [Bug investigation and fix](bug-fix.md) | A defect | Reproduce, fix, verify | Failing reproduction first, exact test command, before and after evidence |
|
|
33
|
+
| [Architecture design](architecture.md) | A system or subsystem | Design | Trust boundaries, component ownership, failure modes |
|
|
34
|
+
| [Architecture decision record](adr.md) | A technical decision | Any | Drivers, options with trade-offs, consequences, revisit triggers |
|
|
35
|
+
| [Test plan](test-plan.md) | Verification design | Before implementation | Risk-to-coverage matrix, test cases, entry and exit criteria |
|
|
36
|
+
| [Test execution report](test-report.md) | A witness run | Verification | Exact commit, case outcomes, coverage |
|
|
37
|
+
| [Dual-critic review](review.md) | Independent review | Review | Findings by severity, `PASS` or `BLOCK` per critic |
|
|
38
|
+
| [Handoff manifest](handoff.md) | A stage transition | Between stages | `kxm.handoff-manifest.v1` fields, base commit, deliverables |
|
|
39
|
+
| [Operational runbook](runbook.md) | Diagnosis and mitigation | Operations | Triage steps, safe commands, rollback, escalation |
|
|
40
|
+
| [Incident postmortem](postmortem.md) | A blameless retrospective | After an incident | Timeline, root cause, corrective actions |
|
|
41
|
+
|
|
42
|
+
## How the templates fit a workflow
|
|
43
|
+
|
|
44
|
+
Planning artifacts feed implementation and testing, which feed verification and
|
|
45
|
+
review; runbooks and postmortems cover operations.
|
|
44
46
|
|
|
45
47
|
```mermaid
|
|
46
48
|
flowchart TD
|
|
47
|
-
subgraph
|
|
49
|
+
subgraph Plan ["1. Plan and design"]
|
|
48
50
|
F["feature.md"]
|
|
49
51
|
R["research.md"]
|
|
50
52
|
A["architecture.md"]
|
|
51
53
|
ADR["adr.md"]
|
|
52
54
|
end
|
|
53
55
|
|
|
54
|
-
subgraph
|
|
56
|
+
subgraph Build ["2. Implement and test"]
|
|
55
57
|
B["bug-fix.md"]
|
|
56
58
|
TP["test-plan.md"]
|
|
57
|
-
H1["handoff.md (
|
|
59
|
+
H1["handoff.md (plan to write)"]
|
|
58
60
|
end
|
|
59
61
|
|
|
60
|
-
subgraph
|
|
61
|
-
TR["test-report.md (
|
|
62
|
-
REV["review.md (
|
|
63
|
-
H2["handoff.md (
|
|
62
|
+
subgraph Verify ["3. Verify and review"]
|
|
63
|
+
TR["test-report.md (witness)"]
|
|
64
|
+
REV["review.md (two critics)"]
|
|
65
|
+
H2["handoff.md (write to review)"]
|
|
64
66
|
end
|
|
65
67
|
|
|
66
|
-
subgraph
|
|
68
|
+
subgraph Operate ["4. Operate"]
|
|
67
69
|
RB["runbook.md"]
|
|
68
70
|
PM["postmortem.md"]
|
|
69
71
|
end
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
Plan -->|approved plan| Build
|
|
74
|
+
Build -->|candidate| Verify
|
|
75
|
+
Verify -->|accepted change| Operate
|
|
75
76
|
```
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
78
|
+
## Templates by workflow
|
|
79
|
+
|
|
80
|
+
The slugs below come from the [workflow catalog](../reference/workflow-catalog.md).
|
|
81
|
+
They are documentation identifiers only; they imply no runtime configuration.
|
|
82
|
+
|
|
83
|
+
| Area | Workflow | Templates |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| Software engineering | `build-feature` | `feature.md`, then `architecture.md`, `test-plan.md`, `review.md` |
|
|
86
|
+
| Software engineering | `refactor-repair-regressions` | `architecture.md`, `adr.md`, `test-report.md` |
|
|
87
|
+
| Software engineering | `stabilize-flaky-tests` | `bug-fix.md` with a failing reproduction first, then `test-report.md` |
|
|
88
|
+
| Software engineering | `design-software-system` | `architecture.md`, `adr.md` |
|
|
89
|
+
| Software engineering | `maintain-documentation` | `review.md` for the accuracy audit |
|
|
90
|
+
| Design and experience | `build-design-system`, `audit-visual-accessibility` | `feature.md` for user flows, `review.md` for accessibility findings |
|
|
91
|
+
| Data and analytics | `analyze-dataset`, `query-business-intelligence` | `research.md` for the evidence register, `architecture.md` for data flows |
|
|
92
|
+
| Research and strategy | `prepare-decision-brief` | `research.md`, then `adr.md` for the decision |
|
|
93
|
+
| Security and reliability | `patch-vulnerability` | `review.md` for the threat model, `bug-fix.md` for the fix |
|
|
94
|
+
| Security and reliability | `investigate-incident` | `runbook.md` for triage, then `postmortem.md` |
|
|
95
|
+
|
|
96
|
+
## Related
|
|
97
|
+
|
|
98
|
+
- [Write KXM documentation](../contributing/writing-docs.md): the docs page template and style rules
|
|
99
|
+
- [Workflow catalog](../reference/workflow-catalog.md): workflow and role slugs
|
|
100
|
+
- [Assignment runner](../contributing/assignment-runner.md): witness, critics and acceptance in the KXM repository
|
package/docs/templates/adr.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
schema: "kxm.doc.v1"
|
|
3
3
|
id: "ADR-0001"
|
|
4
4
|
type: "adr"
|
|
5
|
-
title: "
|
|
5
|
+
title: "ADR-<nnnn>: <decision title>"
|
|
6
6
|
project: "kxm"
|
|
7
7
|
status: "proposed" # proposed | accepted | superseded | deprecated | rejected
|
|
8
8
|
owner: "@owner"
|
|
@@ -19,13 +19,13 @@ details:
|
|
|
19
19
|
superseded_by: null
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
# ADR-0001: <Title of
|
|
22
|
+
# ADR-0001: <Title of architecture decision>
|
|
23
23
|
|
|
24
|
-
## Context
|
|
24
|
+
## Context and problem statement
|
|
25
25
|
|
|
26
26
|
<Describe the technical context, operational dilemma, or architectural friction. What forces are compelling this decision?>
|
|
27
27
|
|
|
28
|
-
## Decision
|
|
28
|
+
## Decision drivers
|
|
29
29
|
|
|
30
30
|
1. **Driver 1:** <e.g., Eliminate native compilation failures across Node versions>
|
|
31
31
|
|
|
@@ -33,7 +33,7 @@ details:
|
|
|
33
33
|
|
|
34
34
|
3. **Driver 3:** <e.g., Maintain fail-closed security invariants without loopback bypasses>
|
|
35
35
|
|
|
36
|
-
## Considered
|
|
36
|
+
## Considered options
|
|
37
37
|
|
|
38
38
|
- **Option A:** <Name of Option A>
|
|
39
39
|
|
|
@@ -41,9 +41,9 @@ details:
|
|
|
41
41
|
|
|
42
42
|
- **Option C:** <Name of Option C>
|
|
43
43
|
|
|
44
|
-
## Evaluation
|
|
44
|
+
## Evaluation and tradeoff matrix
|
|
45
45
|
|
|
46
|
-
### Option A: <
|
|
46
|
+
### Option A: <name of option A>
|
|
47
47
|
|
|
48
48
|
- **Good, because:** <Advantage 1>
|
|
49
49
|
|
|
@@ -53,33 +53,33 @@ details:
|
|
|
53
53
|
|
|
54
54
|
- **Bad, because:** <Drawback 2>
|
|
55
55
|
|
|
56
|
-
### Option B: <
|
|
56
|
+
### Option B: <name of option B>
|
|
57
57
|
|
|
58
58
|
- **Good, because:** <Advantage 1>
|
|
59
59
|
|
|
60
60
|
- **Bad, because:** <Drawback 1>
|
|
61
61
|
|
|
62
|
-
## Decision
|
|
62
|
+
## Decision outcome
|
|
63
63
|
|
|
64
64
|
**Chosen Option:** **Option A**, because <comprehensive justification referencing drivers>.
|
|
65
65
|
|
|
66
|
-
### Positive
|
|
66
|
+
### Positive consequences
|
|
67
67
|
|
|
68
68
|
- <Favorable outcome 1>
|
|
69
69
|
|
|
70
70
|
- <Favorable outcome 2>
|
|
71
71
|
|
|
72
|
-
### Negative
|
|
72
|
+
### Negative consequences and accepted tradeoffs
|
|
73
73
|
|
|
74
74
|
- <Technical debt, limitation, or operational overhead incurred>
|
|
75
75
|
|
|
76
|
-
## Confirmation
|
|
76
|
+
## Confirmation and verification strategy
|
|
77
77
|
|
|
78
78
|
- **Verification Gate:** <Exact test suite or contract check enforcing this decision>
|
|
79
79
|
|
|
80
80
|
- **Enforcement Mechanism:** <Linter, type-check, or CI rule that prevents regressions>
|
|
81
81
|
|
|
82
|
-
## Revisit
|
|
82
|
+
## Revisit conditions
|
|
83
83
|
|
|
84
84
|
This decision should be formally re-evaluated if:
|
|
85
85
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
schema: "kxm.doc.v1"
|
|
3
3
|
id: "ARCH-0001"
|
|
4
4
|
type: "architecture"
|
|
5
|
-
title: "
|
|
5
|
+
title: "Architecture: <system or subsystem>"
|
|
6
6
|
project: "kxm"
|
|
7
7
|
status: "draft" # draft | in_review | approved | superseded | archived
|
|
8
8
|
owner: "@owner"
|
|
@@ -18,103 +18,87 @@ details:
|
|
|
18
18
|
baseline_commit: "<git-sha>"
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
# Architecture: <
|
|
21
|
+
# Architecture: <system or subsystem name>
|
|
22
22
|
|
|
23
|
-
## Purpose
|
|
23
|
+
## Purpose and scope
|
|
24
24
|
|
|
25
|
-
- **
|
|
25
|
+
- **Mission:** <What capability does this subsystem deliver?>
|
|
26
|
+
- **Callers:** <Who interacts with it: operators, agents, workers, external webhooks?>
|
|
27
|
+
- **State of this document:** <Current, proposed, or target architecture. Say which.>
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- **Architecture State:** <Explicitly state whether this document reflects current, proposed, or target architecture>
|
|
30
|
-
|
|
31
|
-
## Goals, Quality Attributes & Constraints
|
|
32
|
-
|
|
33
|
-
| Goal / Constraint | Business or Technical Driver | Measurement Metric / Hard Boundary |
|
|
29
|
+
## Goals, quality attributes and constraints
|
|
34
30
|
|
|
31
|
+
| Goal or constraint | Driver | Measure or hard boundary |
|
|
35
32
|
|---|---|---|
|
|
36
|
-
| Fail-
|
|
33
|
+
| Fail-closed security | Prevent privilege escalation | Missing or wrong credentials are refused; no loopback bypass |
|
|
34
|
+
| Deterministic replay | Forensic debugging and audit | Folding the event log reproduces the same state |
|
|
35
|
+
| <Latency or throughput goal> | <Operator responsiveness> | <For example, p50 dispatch under 200 ms> |
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
| Low Latency Dispatch | Operator responsiveness | Sub-200ms dispatch P50 |
|
|
37
|
+
## Context and trust boundaries
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
External requests pass a credential check before they reach the subsystem, which
|
|
40
|
+
owns its durable state.
|
|
42
41
|
|
|
43
42
|
```mermaid
|
|
44
43
|
flowchart TB
|
|
45
|
-
subgraph External ["Untrusted
|
|
46
|
-
Caller["Operator
|
|
44
|
+
subgraph External ["Untrusted perimeter"]
|
|
45
|
+
Caller["Operator, webhook sender or CI"]
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
subgraph
|
|
50
|
-
|
|
48
|
+
subgraph Auth ["Trust boundary"]
|
|
49
|
+
Check["Credential check (admin, project or session)"]
|
|
51
50
|
end
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
%% Replace these labels with your own components and store.
|
|
53
|
+
subgraph Internal ["Subsystem"]
|
|
54
|
+
Engine["Core component"]
|
|
55
|
+
Context["Supporting component"]
|
|
56
|
+
Store[("Durable store, for example .kxm/state/kxm.db")]
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
Caller -->|
|
|
60
|
-
|
|
61
|
-
Engine
|
|
62
|
-
Engine
|
|
63
|
-
|
|
59
|
+
Caller -->|request and credential| Check
|
|
60
|
+
Check -->|authorized call| Engine
|
|
61
|
+
Engine -->|reads| Context
|
|
62
|
+
Engine -->|writes| Store
|
|
64
63
|
```
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
## Component Responsibilities & Ownership
|
|
69
|
-
|
|
70
|
-
| Component | Responsibility | Public Interface / Contract | Owned State / Tables | Team / Role Owner |
|
|
71
|
-
|
|
72
|
-
|---|---|---|---|---|
|
|
73
|
-
| Workflow Engine | DAG scheduling & loop transitions | `KxmEngine.drive()` | `run_events`, `workflow_runs` | Engine Lead |
|
|
74
|
-
|
|
75
|
-
| Context Arbiter | Token budgeting & context compilation | `arbitrate()` | In-memory pool + Git memory | Memory Lead |
|
|
76
|
-
| External Effects Ledger | CAS leasing & idempotency | `ExternalEffectsLedger` | `external_effects` | Platform Lead |
|
|
77
|
-
|
|
78
|
-
## Runtime Execution Scenarios
|
|
79
|
-
|
|
80
|
-
### 1. Happy Path Dispatch & Settlement
|
|
81
|
-
|
|
82
|
-
1. Step dispatch compiles `FormalContextPacket` (`kxm.context-packet.v2`).
|
|
83
|
-
|
|
84
|
-
2. Worker executes in isolated branch `kxm/run-<id>-<description>`.
|
|
85
|
-
|
|
86
|
-
3. Worker submits `kxm.handoff-manifest.v1` with witness receipt.
|
|
87
|
-
|
|
88
|
-
4. Engine commits transition and notifies critics.
|
|
89
|
-
|
|
90
|
-
### 2. Failure & Rework Path
|
|
91
|
-
|
|
92
|
-
1. Critic issues structured rejection findings with blocker severity.
|
|
93
|
-
|
|
94
|
-
2. Engine transitions step to `rejected_rework_required`.
|
|
95
|
-
|
|
96
|
-
3. Attempts counter increments; router dispatches to next eligible writer.
|
|
65
|
+
## Component responsibilities
|
|
97
66
|
|
|
98
|
-
|
|
67
|
+
| Component | Responsibility | Public interface | Owned state |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| <Runtime engine> | <Schedules steps, attempts and transitions> | <`KxmRunScheduler`> | <`events`, `runs`, `run_state` in the Runtime event store> |
|
|
70
|
+
| <Context arbiter> | <Assembles role-aware packets within a budget> | <`arbitrate()`> | <None; reads context items and Git memory> |
|
|
71
|
+
| <Hub store> | <Messages, workflow runs and leases> | <HTTP API> | <`messages`, `workflow_runs`, `leases` in `kxm.db`> |
|
|
99
72
|
|
|
100
|
-
|
|
73
|
+
## Runtime scenarios
|
|
101
74
|
|
|
102
|
-
|
|
75
|
+
### Happy path
|
|
103
76
|
|
|
104
|
-
|
|
77
|
+
1. <Step dispatch builds a context packet for the target role.>
|
|
78
|
+
2. <The worker runs on its own branch, for example `kxm/run-<run-id>-<description>`.>
|
|
79
|
+
3. <The worker returns a structured result with its witness evidence.>
|
|
80
|
+
4. <The engine records the transition and hands off to the critics.>
|
|
105
81
|
|
|
106
|
-
|
|
82
|
+
### Failure and rework
|
|
107
83
|
|
|
108
|
-
|
|
84
|
+
1. <How a failed attempt or a critic block is recorded.>
|
|
85
|
+
2. <Which transition, retry budget, or human action decides what runs next.>
|
|
86
|
+
3. <What stops the loop: a budget, a terminal status, or an operator.>
|
|
109
87
|
|
|
110
|
-
|
|
88
|
+
## Data contracts, storage and invariants
|
|
111
89
|
|
|
112
|
-
- **
|
|
90
|
+
- **Source of truth:** <store and schema, for example SQLite through `node:sqlite`>
|
|
91
|
+
- **Durability settings:** <for example WAL, a 5-second busy timeout, `synchronous = NORMAL`>
|
|
92
|
+
- **Naming invariants:** <branch, ID, or path conventions the subsystem relies on>
|
|
93
|
+
- **Pinning:** <which revisions are pinned per run, and what is never read from a mutable `HEAD`>
|
|
113
94
|
|
|
114
|
-
|
|
95
|
+
## Security and isolation
|
|
115
96
|
|
|
116
|
-
|
|
97
|
+
- **Credentials:** <which credentials the subsystem accepts and what each may do>
|
|
98
|
+
- **Process isolation:** <how child processes are bounded: stdio frames, output caps, process groups>
|
|
99
|
+
- **Concurrency control:** <locks or leases that serialize shared mutations>
|
|
100
|
+
- **Not guaranteed:** <for example exactly-once external effects, or sandboxing>
|
|
117
101
|
|
|
118
|
-
|
|
102
|
+
## Architectural decisions
|
|
119
103
|
|
|
120
|
-
-
|
|
104
|
+
- `ADR-<nnnn>: <title>`: link each record in [`docs/adr/`](../adr/README.md).
|