@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.
Files changed (158) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.kxm/README.md +39 -9
  3. package/CHANGELOG.md +23 -1
  4. package/README.md +147 -257
  5. package/SECURITY.md +21 -12
  6. package/docs/README.md +133 -54
  7. package/docs/adr/ADR-0002-browser-automation-steel-doks.md +24 -18
  8. package/docs/adr/ADR-0003-sqlite-only-store.md +100 -0
  9. package/docs/adr/ADR-0004-edge-identity-authentik.md +99 -0
  10. package/docs/adr/README.md +33 -0
  11. package/docs/concepts/architecture.md +262 -0
  12. package/docs/concepts/data-and-storage.md +194 -0
  13. package/docs/concepts/trust-model.md +153 -0
  14. package/docs/contracts/README.md +22 -14
  15. package/docs/contracts/effects-and-recovery.md +3 -0
  16. package/docs/contracts/migration.md +2 -2
  17. package/docs/contracts/routing.md +6 -5
  18. package/docs/contributing/assignment-runner.md +388 -0
  19. package/docs/contributing/ci-and-release.md +231 -0
  20. package/docs/contributing/development.md +362 -0
  21. package/docs/contributing/harness-routing-internals.md +192 -0
  22. package/docs/{packages.md → contributing/packages.md} +13 -15
  23. package/docs/{skills → contributing}/repo-work-delivery.md +20 -21
  24. package/docs/contributing/test-matrix.md +208 -0
  25. package/docs/{tui-components.md → contributing/tui-components.md} +30 -22
  26. package/docs/contributing/writing-docs.md +340 -0
  27. package/docs/glossary.md +471 -0
  28. package/docs/guides/agent-skills.md +137 -0
  29. package/docs/guides/browser-automation.md +160 -0
  30. package/docs/guides/context-and-memory.md +352 -0
  31. package/docs/guides/continuous-improvement.md +228 -0
  32. package/docs/guides/governed-skills.md +173 -0
  33. package/docs/guides/nous-providers.md +186 -0
  34. package/docs/guides/peer-messaging.md +304 -0
  35. package/docs/guides/pi-workers.md +219 -0
  36. package/docs/guides/provenance-gates.md +313 -0
  37. package/docs/guides/webhook-workflows.md +399 -0
  38. package/docs/kb/how-credentials-retrieved-safely.md +38 -12
  39. package/docs/kb/how-to-capture-and-annotate-section.md +15 -13
  40. package/docs/kb/how-to-connect-playwright-to-steel.md +16 -11
  41. package/docs/kb/how-to-recover-expired-session-or-orphan.md +26 -16
  42. package/docs/kb/how-to-resume-after-mfa.md +19 -11
  43. package/docs/kb/how-to-take-over-session.md +17 -13
  44. package/docs/kb/why-authentication-disappeared.md +22 -14
  45. package/docs/kb/why-automation-opened-different-browser.md +23 -14
  46. package/docs/kb/why-session-viewer-cannot-control.md +13 -12
  47. package/docs/operations/backup-and-restore.md +248 -0
  48. package/docs/operations/deploy.md +307 -0
  49. package/docs/operations/monitoring.md +209 -0
  50. package/docs/operations/runtime-sync.md +192 -0
  51. package/docs/operations/troubleshooting.md +266 -0
  52. package/docs/operations/upgrade.md +124 -0
  53. package/docs/prompts/browser-annotate-feedback.md +7 -7
  54. package/docs/prompts/browser-diagnose-recover.md +11 -10
  55. package/docs/prompts/browser-explore.md +7 -7
  56. package/docs/prompts/browser-repro-fix.md +7 -7
  57. package/docs/prompts/browser-start.md +12 -11
  58. package/docs/prompts/browser-takeover.md +8 -8
  59. package/docs/{cli-reference.md → reference/cli-reference.md} +88 -46
  60. package/docs/{config-reference.md → reference/config-reference.md} +159 -148
  61. package/docs/reference/configuration.md +299 -0
  62. package/docs/reference/harness-routing.md +508 -0
  63. package/docs/reference/http-api.md +203 -0
  64. package/docs/reference/tools.md +370 -0
  65. package/docs/{workflow-guide.md → reference/workflow-catalog.md} +92 -153
  66. package/docs/reference/workflow-definitions.md +286 -0
  67. package/docs/start/first-workflow.md +287 -0
  68. package/docs/start/install.md +146 -0
  69. package/docs/start/quickstart-claude-code.md +405 -0
  70. package/docs/start/quickstart-pi.md +213 -0
  71. package/docs/templates/README.md +78 -73
  72. package/docs/templates/adr.md +13 -13
  73. package/docs/templates/architecture.md +55 -71
  74. package/docs/templates/bug-fix.md +13 -16
  75. package/docs/templates/feature.md +14 -19
  76. package/docs/templates/handoff.md +44 -46
  77. package/docs/templates/postmortem.md +30 -43
  78. package/docs/templates/research.md +15 -20
  79. package/docs/templates/review.md +49 -50
  80. package/docs/templates/runbook.md +38 -30
  81. package/docs/templates/test-plan.md +16 -23
  82. package/docs/templates/test-report.md +14 -17
  83. package/examples/README.md +9 -5
  84. package/examples/provenance-workflow.json +1 -1
  85. package/examples/webhook-workflows/jira-development.json +59 -0
  86. package/examples/webhook-workflows/jira-issue-updated.json +12 -0
  87. package/examples/workflow-signal.ts +4 -5
  88. package/package.json +1 -1
  89. package/packages/core/tui/README.md +1 -1
  90. package/plugins/kxm/.claude-plugin/plugin.json +1 -1
  91. package/plugins/kxm/README.md +31 -32
  92. package/plugins/kxm/dist/claude-hook.js +11 -1
  93. package/plugins/kxm/dist/cli.js +164 -79
  94. package/plugins/kxm/dist/client.js +3 -1
  95. package/plugins/kxm/dist/core.js +11 -1
  96. package/plugins/kxm/dist/extension.js +45 -13
  97. package/plugins/kxm/dist/mcp-server.js +20 -4
  98. package/plugins/kxm/dist/runtime-supervisor.js +1 -3
  99. package/plugins/kxm/dist/runtime.js +18 -4
  100. package/plugins/kxm/dist/server.js +115 -20
  101. package/plugins/kxm/package.json +1 -1
  102. package/plugins/kxm/skills/kxm/references/protocol.md +3 -1
  103. package/plugins/kxm/skills/kxm-browser-auth/SKILL.md +1 -1
  104. package/plugins/kxm/skills/kxm-browser-diagnostics/SKILL.md +5 -5
  105. package/plugins/kxm/skills/kxm-browser-explore/SKILL.md +2 -2
  106. package/plugins/kxm/skills/kxm-browser-session/SKILL.md +10 -13
  107. package/plugins/kxm/skills/kxm-browser-takeover/SKILL.md +1 -1
  108. package/plugins/kxm/skills/kxm-browser-verify/SKILL.md +1 -1
  109. package/plugins/kxm/skills/kxm-context-memory/SKILL.md +13 -4
  110. package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +3 -1
  111. package/plugins/kxm/skills/kxm-mind-setup/SKILL.md +2 -1
  112. package/plugins/kxm/skills/kxm-project-setup/SKILL.md +31 -54
  113. package/plugins/kxm/skills/kxm-projects/SKILL.md +1 -1
  114. package/plugins/kxm/skills/kxm-protocol/SKILL.md +1 -1
  115. package/plugins/kxm/skills/kxm-routing-improve/SKILL.md +15 -7
  116. package/plugins/kxm/skills/kxm-runs/SKILL.md +11 -5
  117. package/plugins/kxm/skills/kxm-session/SKILL.md +1 -1
  118. package/plugins/kxm/skills/kxm-tasks/SKILL.md +9 -7
  119. package/plugins/kxm/skills/kxm-workflow/SKILL.md +10 -2
  120. package/plugins/kxm/src/cli/system.ts +1 -1
  121. package/plugins/kxm/src/cli/workflows.ts +12 -7
  122. package/plugins/kxm/src/cli.ts +22 -8
  123. package/plugins/kxm/src/client.ts +4 -0
  124. package/plugins/kxm/src/commands.ts +23 -1
  125. package/plugins/kxm/src/extension.ts +20 -14
  126. package/plugins/kxm/src/github-watch.ts +8 -5
  127. package/plugins/kxm/src/hub-env.ts +19 -1
  128. package/plugins/kxm/src/hub.ts +105 -21
  129. package/plugins/kxm/src/improve-sources.ts +2 -7
  130. package/plugins/kxm/src/init-guide-setup.ts +1 -1
  131. package/plugins/kxm/src/mcp-server.ts +9 -2
  132. package/plugins/kxm/src/modes.ts +1 -1
  133. package/plugins/kxm/src/runtime-store.ts +23 -0
  134. package/plugins/kxm/src/workflow.ts +70 -1
  135. package/schemas/README.md +1 -1
  136. package/scripts/smoke-multi-pi.mjs +5 -1
  137. package/docs/agent-communication-envelopes-and-gates.md +0 -553
  138. package/docs/agent-skills.md +0 -198
  139. package/docs/architecture.md +0 -245
  140. package/docs/assignment-runner.md +0 -264
  141. package/docs/browser-automation.md +0 -139
  142. package/docs/configuration.md +0 -437
  143. package/docs/continuous-improvement.md +0 -226
  144. package/docs/getting-started.md +0 -277
  145. package/docs/harness-routing.md +0 -616
  146. package/docs/kb/qa-authentik-authentication.md +0 -97
  147. package/docs/kb/qa-extension-install-and-hub-bootstrap.md +0 -85
  148. package/docs/kb/qa-hub-on-a-public-host.md +0 -48
  149. package/docs/kb/qa-sqlite-vs-duckdb.md +0 -35
  150. package/docs/kb/qa-what-the-hub-stores.md +0 -64
  151. package/docs/kxm-handbook.md +0 -1181
  152. package/docs/operations.md +0 -510
  153. package/docs/operator-pi-packages.md +0 -67
  154. package/docs/provenance-gates.md +0 -295
  155. package/docs/skills.md +0 -47
  156. package/docs/test-matrix.md +0 -132
  157. package/docs/troubleshooting.md +0 -322
  158. package/docs/webhook-workflows.md +0 -240
package/SECURITY.md CHANGED
@@ -18,25 +18,32 @@ Do not include real credentials, private prompts, personal data, or unrelated re
18
18
 
19
19
  ## Security model
20
20
 
21
- The current hub provides:
21
+ This section summarizes KXM's security model. The [trust model](docs/concepts/trust-model.md) explains every credential, what it can reach, and where each boundary stops. [Data and storage](docs/concepts/data-and-storage.md) lists what each store keeps and how long.
22
+
23
+ The current hub and Runtime provide:
22
24
 
23
25
  - an administrative bearer token and optional per-project bearer tokens;
24
- - ephemeral per-agent keys for agent-specific operations;
25
- - project-scoped discovery and message visibility;
26
- - loopback binding by default;
27
- - refusal to bind beyond localhost without a token;
26
+ - per-agent keys, rotated at every registration, for agent-specific operations;
27
+ - hub credentials persisted with mode `0600` in the user state root, never in the project;
28
+ - project-scoped discovery, message visibility, and context requests;
29
+ - loopback binding by default, and refusal to bind beyond localhost without a token;
30
+ - a Runtime supervisor that listens only on `127.0.0.1` behind its own token;
31
+ - a Claude Code plugin whose MCP server and SessionStart hook never use the admin token;
28
32
  - bounded request bodies, message content, and hop counts;
29
33
  - per-agent request rate limiting and stable request IDs;
30
34
  - security response headers and generic public responses for internal errors;
31
35
  - SHA-256 HMAC verification and stable-delivery deduplication for webhook workflows;
32
36
  - attempt-bound peer-message provenance, unique-producer quorum, and explicit admin-only degradation for configured workflow requirements;
33
- - structured hub logs that omit prompt and reply bodies.
37
+ - a context authority ceiling per origin, so peer, tool, and external content can never grant instructions or policy;
38
+ - structured hub logs that omit prompt and reply bodies, and an allowlisted, redacted Runtime-to-hub sync.
34
39
 
35
40
  It does not currently provide:
36
41
 
37
- - per-user roles or external identity-provider integration;
38
- - durable encrypted storage;
42
+ - per-user roles or identity-provider integration inside the hub (hosted deployments authenticate browsers at a proxy; see [ADR-0004](docs/adr/ADR-0004-edge-identity-authentik.md));
43
+ - encryption of stored message bodies, prompts, evidence, or credentials;
39
44
  - end-to-end message encryption;
45
+ - signed session tokens: local tool policy is a guardrail, not an authorization boundary;
46
+ - isolation between processes that run as the same OS user;
40
47
  - public-internet hardening;
41
48
  - distributed denial-of-service protection;
42
49
  - guarantees that peer-provided content is safe or correct.
@@ -49,17 +56,19 @@ a new agent or reclaim an offline agent name and its durable ID in that project,
49
56
  so every holder of one shared project credential belongs to the same fully
50
57
  trusted provenance domain.
51
58
 
52
- Authentication does not make a mesh message trustworthy. Agents must retain their normal permission, tool, filesystem, and secret-handling controls.
59
+ Authentication does not make a peer message trustworthy. Agents must retain their normal permission, tool, filesystem, and secret-handling controls.
53
60
 
54
61
  ## Operator responsibilities
55
62
 
56
63
  - Keep the hub on loopback whenever possible.
57
64
  - Use a long random token and load it from a secret manager or protected environment.
58
- - Use distinct project tokens when different teams share one hub.
65
+ - Use distinct project tokens when different teams share one hub, and list every project in `KXM_PROJECT_TOKENS` so the admin token stops working on agent routes.
59
66
  - Reserve a distinct administrative token for admin routes; give agents only their explicit project token. Never give a workflow callback or peer the admin token.
60
- - Protect and back up `.kxm/state/kxm.db` because it contains messages and agent credentials.
67
+ - Set `KXM_AUTH_TOKEN` to the project token for Pi sessions and Pi workers. Without it, the Pi extension falls back to the admin token saved on the hub's machine.
68
+ - Protect and back up `.kxm/state/kxm.db` because it contains message bodies and agent keys.
69
+ - Protect the user state root: `hub-env.json` holds the raw admin and project tokens, and the Runtime stores hold run prompts and event payloads.
61
70
  - Protect `.kxm/logs`; raw long-lived Pi process logs can contain model output, tool output, paths, and other sensitive operational data.
62
- - Keep secrets out of tracked `.kxm/config` and `.kxm/assets`; runtime logs, generated assets, and state must remain uncommitted.
71
+ - Keep secrets out of tracked `.kxm/*.yaml` configuration and `.kxm/assets`; runtime logs, generated assets, and state must remain uncommitted.
63
72
  - Store webhook secrets in dedicated environment variables through `secretEnv`; do not commit them in workflow JSON.
64
73
  - Use a separate `signalSecretEnv` for callbacks and never put credentials, private prompts, or sensitive incident details in a degradation reason.
65
74
  - Review every quorum degradation as a security-relevant decision. It must be declared by policy, limited to the current attempt, and followed by enough verified replies to meet the approved minimum.
package/docs/README.md CHANGED
@@ -1,58 +1,137 @@
1
- # Documentation
2
-
3
- This documentation is organized by task. Start with the guide that matches what you are trying to accomplish.
4
-
5
- | Guide | Audience | Purpose |
6
- |---|---|---|
7
- | [KXM Handbook](kxm-handbook.md) | Operators, Pi users, and Claude Code users | Wiki-ready installation, configuration, and complete feature guide |
8
- | [Getting started](getting-started.md) | Pi and Claude Code users | Complete the first successful multi-agent exchange |
9
- | [Configuration](configuration.md) | Users and operators | Understand every supported setting and default |
10
- | [CLI reference](cli-reference.md) | Operators and agent authors | Every `kxm` command and subcommand with options, JSON output, and examples |
11
- | [Configuration file reference](config-reference.md) | Project and workflow authors | Every `.kxm` file schema field by field, with validated examples and a worked two-step project |
12
- | [Native harness or OpenRouter](harness-routing.md) | Operators choosing models | Decide which route runs a model reachable both natively and through an aggregator, and confirm which route a config line uses |
13
- | [Architecture](architecture.md) | Maintainers and integrators | Learn the component boundaries and message lifecycle |
14
- | [Terminal components](tui-components.md) | Maintainers and integrators | The reusable panel kit behind `kxm dash` and every configuration surface |
15
- | [Packages and workspaces](packages.md) | Maintainers | Workspace layout, Nx targets, Bun task running, and the layer gate |
16
- | [Agent Skills](agent-skills.md) | Users and integrators | Comprehensive skill suite covering all KXM commands with progressive disclosure |
17
- | [Browser automation](browser-automation.md) | Developers and operators | Self-hosted Steel on DOKS, agent-browser, Playwright, pass-cli, and human takeover. See the [knowledge base](browser-automation.md#knowledge-base) and [prompt templates](browser-automation.md#prompt-templates) |
18
- | [Skills](skills.md) | Operators and skill authors | Governed candidate lifecycle; also the [repository work delivery](skills/repo-work-delivery.md) skill |
19
- | [Operations](operations.md) | Hub operators | Run, monitor, secure, and recover the service |
20
- | [Troubleshooting](troubleshooting.md) | Everyone | Diagnose common installation and delivery failures |
21
- | [Test matrix](test-matrix.md) | Users and maintainers | Map features and use cases to automated evidence |
22
- | [Webhook workflows](webhook-workflows.md) | Automation owners | Start durable work from Jira or another signed webhook |
23
- | [Peer provenance and quorum gates](provenance-gates.md) | Workflow authors and security reviewers | Require durable replies from eligible peer identities without overstating the trust guarantee |
24
- | [Continuous improvement](continuous-improvement.md) | Product and engineering leads | Turn run evidence into reviewed workflow improvements |
25
- | [Workflow guide](workflow-guide.md) | Workflow designers and operators | Area -> Workflow -> Stage -> Role taxonomy with documentation slugs, dated research candidates, and selection policy |
26
- | [Templates](templates/README.md) | Workflow authors | Markdown templates for features, ADRs, reviews, runbooks, and related artifacts |
27
- | [Agent Envelopes & Quality Gates](agent-communication-envelopes-and-gates.md) | Multi-agent workflow engineers | Production communication envelopes, quality gates, and work loops |
28
- | [Assignment runner](assignment-runner.md) | Maintainers and developers | Native developer assignments, deterministic witness verification, and multi-vendor dual-critic acceptance |
29
- | [This host's Pi packages](operator-pi-packages.md) | Maintainers on this development host | Snapshot of operator `pi list` packages and file extensions; not a KXM install requirement |
30
- | [KXM contract package](contracts/README.md) | Maintainers and reviewers | Review the accepted local-first target architecture and implementation contracts |
31
-
32
- Project-level policies live at the repository root:
1
+ # KXM documentation
33
2
 
34
- - [Contributing](../CONTRIBUTING.md)
35
- - [Security](../SECURITY.md)
36
- - [Changelog](../CHANGELOG.md)
3
+ KXM connects coding agents through a durable, authenticated [hub](glossary.md#hub) and runs workflows in a local [Runtime](glossary.md#runtime). Start with a quick start, use the guides for tasks, and use the reference for exact commands, files, tools and endpoints. The [glossary](glossary.md) defines every term these pages use.
4
+
5
+ **Groups:** [Start here](#start-here) · [Guides](#guides) · [Reference](#reference) · [Concepts](#concepts) · [Operations](#operations) · [Contributing](#contributing)
6
+
7
+ ## Start here
8
+
9
+ | Page | For | What you get |
10
+ |---|---|---|
11
+ | [Install KXM](start/install.md) | Everyone | The `kxm` CLI from npm, the Claude Code plugin, the Pi package, or a source checkout |
12
+ | [Quick start: Claude Code](start/quickstart-claude-code.md) | Claude Code users | A new or existing project connected to a local hub, and how to update the CLI and plugin |
13
+ | [Run your first workflow](start/first-workflow.md) | Project owners | A workflow written, trust-reviewed, run and driven to a verified receipt |
14
+ | [Quick start: Pi](start/quickstart-pi.md) | Pi users | Two Pi agents, or Pi and Claude Code, exchanging peer requests |
15
+ | [Glossary](glossary.md) | Everyone | Every KXM term, including the ones that are easy to confuse |
16
+
17
+ ## Guides
18
+
19
+ | Page | For | What you get |
20
+ |---|---|---|
21
+ | [Message peer agents](guides/peer-messaging.md) | Agent users | Send, await, fan out, cancel and reply; delivery modes, TTL and idempotency |
22
+ | [Run supervised Pi workers](guides/pi-workers.md) | Operators | Long-lived Pi agents with fallbacks, tool allowlists and one session per workflow run |
23
+ | [Run webhook workflows](guides/webhook-workflows.md) | Automation owners | Signed starts from Jira, GitHub or any webhook, durable waits and signed callbacks |
24
+ | [Peer provenance and quorum gates](guides/provenance-gates.md) | Workflow authors, security reviewers | Stages that require hub-verified replies from eligible peers |
25
+ | [Context and memory](guides/context-and-memory.md) | Agent users, project owners | Context packets, recall, temporal state, episodes, the wiki and Git memory |
26
+ | [Continuous improvement](guides/continuous-improvement.md) | Leads, workflow authors | Journals, retrospectives, improvement reports and coded-repeat candidates |
27
+ | [Governed skills](guides/governed-skills.md) | Operators, skill authors | The candidate, evaluation, promotion and rejection lifecycle |
28
+ | [Agent skills](guides/agent-skills.md) | Users of any harness | The bundled `SKILL.md` suite and how each harness loads it |
29
+ | [Browser automation](guides/browser-automation.md) | Developers, operators | Steel browser sessions, Playwright, safe credentials and human takeover |
30
+ | [Nous providers](guides/nous-providers.md) | Pi operators | Opt-in Nous Portal models for Pi agents |
31
+
32
+ ### Browser knowledge base
33
+
34
+ | Page | For | What you get |
35
+ |---|---|---|
36
+ | [How are credentials retrieved without exposing them to the model?](kb/how-credentials-retrieved-safely.md) | Browser operators | How agents log in without the model seeing secrets |
37
+ | [How do I capture a UI section and annotate changes for an agent?](kb/how-to-capture-and-annotate-section.md) | Browser operators | Send an agent a marked-up UI section to change |
38
+ | [How do I connect Playwright to the existing Steel session?](kb/how-to-connect-playwright-to-steel.md) | Browser operators | Attach Playwright to an existing Steel session |
39
+ | [How do I recover an expired session or remove an orphaned browser?](kb/how-to-recover-expired-session-or-orphan.md) | Browser operators | Restore a session or remove an orphaned browser |
40
+ | [How does an agent resume after MFA?](kb/how-to-resume-after-mfa.md) | Browser operators | Continue agent work after a person completes MFA |
41
+ | [How do I take over a browser session to log in?](kb/how-to-take-over-session.md) | Browser operators | Log in by hand inside an agent's browser session |
42
+ | [Why did authentication disappear?](kb/why-authentication-disappeared.md) | Browser operators | Causes and fixes for a lost login |
43
+ | [Why did automation open a different browser?](kb/why-automation-opened-different-browser.md) | Browser operators | Causes and fixes when a local browser opens instead of the Steel session |
44
+ | [Why can I view a session but not control it?](kb/why-session-viewer-cannot-control.md) | Browser operators | Why the viewer shows the stream but not your clicks, and what to use instead |
45
+
46
+ ### Browser prompt templates
47
+
48
+ | Page | For | What you get |
49
+ |---|---|---|
50
+ | [Task template: start browser work in a KXM project](prompts/browser-start.md) | Agent operators | A prompt that opens browser work in a KXM project |
51
+ | [Task template: explore an application with an authenticated session](prompts/browser-explore.md) | Agent operators | A prompt for exploring with an authenticated session |
52
+ | [Task template: reproduce a UI bug and produce a Playwright regression test](prompts/browser-repro-fix.md) | Agent operators | A prompt that ends in a Playwright regression test |
53
+ | [Task template: capture UI section annotations and send changes to an agent](prompts/browser-annotate-feedback.md) | Agent operators | A prompt that turns section annotations into changes |
54
+ | [Task template: request human authentication and resume afterward](prompts/browser-takeover.md) | Agent operators | A prompt that asks a person to log in, then resumes |
55
+ | [Task template: diagnose and recover a failed browser session](prompts/browser-diagnose-recover.md) | Agent operators | A prompt for a failed browser session |
56
+
57
+ ## Reference
58
+
59
+ | Page | For | What you get |
60
+ |---|---|---|
61
+ | [KXM CLI reference](reference/cli-reference.md) | Operators, agent authors | Every `kxm` command with its options, output and examples |
62
+ | [KXM configuration file reference](reference/config-reference.md) | Project and workflow authors | Every `.kxm` file field by field, the workspace layout and configuration layers |
63
+ | [Environment variables and limits](reference/configuration.md) | Operators | Environment variables, limits and defaults for the hub, agents and workers |
64
+ | [Harness routing: native harness or Pi aggregator](reference/harness-routing.md) | Operators choosing models | Native harness or Pi route for a model, admission, and how to check the route used |
65
+ | [Agent tools reference](reference/tools.md) | Agent authors | The `kxm_*` MCP and Pi tools, `/kxm` commands, plugin hooks and plugin options |
66
+ | [Hub HTTP API reference](reference/http-api.md) | Integrators, operators | Hub endpoints for health, metrics, operations, messages, webhooks, signals, leases and sync |
67
+ | [Workflow definition reference](reference/workflow-definitions.md) | Workflow authors | Webhook definition fields, evidence policies and `kxm.workflow.v1` steps |
68
+ | [Workflow catalog](reference/workflow-catalog.md) | Workflow designers | The area, workflow, stage and role taxonomy, with the docs each workflow relies on |
69
+ | [KXM Claude Code plugin](../plugins/kxm/README.md) | Claude Code users | Plugin options, tokens, the SessionStart hook, tools, channel mode and fixes |
70
+
71
+ ## Concepts
72
+
73
+ | Page | For | What you get |
74
+ |---|---|---|
75
+ | [Architecture](concepts/architecture.md) | Integrators, maintainers | The components, message and workflow lifecycles, and KXM's limits |
76
+ | [Trust model](concepts/trust-model.md) | Operators, security reviewers | Who holds which credential, project boundaries, and what provenance proves |
77
+ | [Data and storage](concepts/data-and-storage.md) | Operators, security reviewers | What each store holds, where it lives and how long it is kept |
78
+ | [Architecture decision records](adr/README.md) | Maintainers | The decision records: [browser automation](adr/ADR-0002-browser-automation-steel-doks.md), [SQLite-only store](adr/ADR-0003-sqlite-only-store.md), [edge identity](adr/ADR-0004-edge-identity-authentik.md) |
79
+ | [KXM contract package](contracts/README.md) | Maintainers, reviewers | The normative specifications for the local-first architecture, listed below |
80
+
81
+ ### Contracts
82
+
83
+ | Page | For | What you get |
84
+ |---|---|---|
85
+ | [ADR-001: Local Runtime, project authority, and aggregate hub](contracts/architecture.md) | Maintainers | The architecture decision the contracts implement |
86
+ | [Canonical terminology](contracts/terminology.md) | All contributors | The normative definitions the [glossary](glossary.md) builds on |
87
+ | [Durable lifecycles](contracts/lifecycles.md) | Maintainers | Run, step, assignment, attempt, effect and delivery states |
88
+ | [Effects, idempotency, and recovery](contracts/effects-and-recovery.md) | Maintainers | Effect classes, the crash matrix, `blocked_uncertain` and recovery rules |
89
+ | [Hub synchronization contract](contracts/synchronization.md) | Maintainers | What the Runtime sends the hub, and how the hub accepts it |
90
+ | [Routing and cost telemetry](contracts/routing.md) | Maintainers | Routing records, cost bases and the routing report |
91
+ | [Configuration and contract validation](contracts/validation.md) | Maintainers | The YAML parser profile, the validation pipeline, schema evolution and the gate registry |
92
+ | [Migration and compatibility](contracts/migration.md) | Maintainers, operators | What KXM refuses rather than converts, and why |
93
+
94
+ ## Operations
95
+
96
+ | Page | For | What you get |
97
+ |---|---|---|
98
+ | [Deploy KXM](operations/deploy.md) | Hub operators | Deployment classes, supervision, and hosted per-tenant hubs behind a proxy |
99
+ | [Monitor KXM](operations/monitoring.md) | Hub operators | `kxm dash`, health and readiness, metrics, logs and alerts |
100
+ | [Back up and restore KXM](operations/backup-and-restore.md) | Hub operators | `kxm backup` and `kxm restore`, the state roots, and a stopped-hub recipe |
101
+ | [Upgrade KXM](operations/upgrade.md) | Operators | `kxm update`, the plugin reinstall, rollback and schema ceilings |
102
+ | [Operate Runtime sync and leases](operations/runtime-sync.md) | Operators | The Runtime-to-hub outbox, refusals, `kxm runtime sync-retry` and leases |
103
+ | [Troubleshoot KXM](operations/troubleshooting.md) | Everyone | Symptoms, causes and fixes, grouped by area |
104
+
105
+ ## Contributing
106
+
107
+ | Page | For | What you get |
108
+ |---|---|---|
109
+ | [Develop KXM](contributing/development.md) | Contributors | Setup, build and verify, packaging, and the repository layout |
110
+ | [CI and release](contributing/ci-and-release.md) | Maintainers | What CI runs on each change and how releases ship |
111
+ | [Write KXM documentation](contributing/writing-docs.md) | Contributors | The style rules, the page template and the docs checks |
112
+ | [Test matrix](contributing/test-matrix.md) | Maintainers | Features and use cases mapped to automated evidence |
113
+ | [Assignment runner](contributing/assignment-runner.md) | Maintainers | Developer assignments, witness verification and dual-critic acceptance |
114
+ | [Packages and workspaces](contributing/packages.md) | Maintainers | Workspace layout, Nx targets, Bun task running and the layer gate |
115
+ | [KXM terminal components](contributing/tui-components.md) | Maintainers, integrators | The panel kit behind `kxm dash` |
116
+ | [Repository work delivery skill](contributing/repo-work-delivery.md) | Contributors | The repository-local skill for delivering a change |
117
+ | [Artifact templates](templates/README.md) | Workflow authors | Document templates and where workflows use them |
118
+
119
+ The templates: [feature](templates/feature.md) · [bug fix](templates/bug-fix.md) · [ADR](templates/adr.md) · [architecture](templates/architecture.md) · [research](templates/research.md) · [review](templates/review.md) · [test plan](templates/test-plan.md) · [test report](templates/test-report.md) · [runbook](templates/runbook.md) · [postmortem](templates/postmortem.md) · [handoff](templates/handoff.md).
37
120
 
38
121
  ## Documentation principles
39
122
 
40
- - Put the shortest successful path before optional details.
41
- - Use the product terms **hub**, **agent**, **peer**, **project**, **request**, and **reply** consistently.
42
- - Distinguish verified behavior from planned behavior; `docs/contracts` is a planned normative target until activation.
43
- - Distinguish durable single-node delivery from clustering and exactly-once execution.
44
- - Update the relevant guide in the same change that modifies user-visible behavior.
45
-
46
- ## Which docs each workflow relies on
47
-
48
- Cross-reference only. Guide slugs imply no runtime config, admission, schema, or
49
- CLI behavior.
50
-
51
- | Workflow slug | Primary docs |
52
- |---|---|
53
- | `build-feature` | [Getting started](getting-started.md), [Configuration](configuration.md), [Architecture](architecture.md), [Test matrix](test-matrix.md) |
54
- | `refactor-repair-regressions` | [Architecture](architecture.md), [Test matrix](test-matrix.md), [Troubleshooting](troubleshooting.md), [Provenance gates](provenance-gates.md) |
55
- | `stabilize-flaky-tests` | [Test matrix](test-matrix.md), [Operations](operations.md), [Troubleshooting](troubleshooting.md) |
56
- | `design-software-system` | [Architecture](architecture.md), [Configuration](configuration.md), [KXM contracts](contracts/README.md) |
57
- | `investigate-incident` | [Operations](operations.md), [Troubleshooting](troubleshooting.md), [Webhook workflows](webhook-workflows.md) |
58
- | `patch-vulnerability` | [Provenance gates](provenance-gates.md), [Operations](operations.md), [Configuration](configuration.md) |
123
+ - **Shortest path first.** Each page opens with what it helps you do; the working path comes before options and background.
124
+ - **Current behavior only.** Pages describe what the code does today, with no release numbers in prose. Planned behavior lives in [contracts](contracts/README.md) and [decisions](adr/README.md), marked as planned. Changes are recorded in the [changelog](../CHANGELOG.md).
125
+ - **Honest boundaries.** Wherever a feature could be over-read, the page says what is not guaranteed: single node, at-least-once delivery, no sandboxing, provenance rather than truth.
126
+ - **One vocabulary.** Pages use the [glossary](glossary.md) terms and qualify overloaded words such as run, session, gate, skill and project.
127
+ - **Bash first.** Examples show Bash; PowerShell appears only where the syntax differs.
128
+ - **Docs change with code.** A change to user-visible behavior updates the relevant page in the same pull request. [Write KXM documentation](contributing/writing-docs.md) has the full style guide.
129
+
130
+ ## Related
131
+
132
+ - [Project README](../README.md)
133
+ - [Contributing](../CONTRIBUTING.md)
134
+ - [Security policy](../SECURITY.md)
135
+ - [Code of conduct](../CODE_OF_CONDUCT.md)
136
+ - [Changelog](../CHANGELOG.md)
137
+ - [License](../LICENSE)
@@ -2,7 +2,7 @@
2
2
  schema: "kxm.doc.v1"
3
3
  id: "ADR-0002"
4
4
  type: "adr"
5
- title: "Self-Hosted Steel on DOKS for Reusable Browser Automation and Human Takeover"
5
+ title: "Self-hosted Steel on DOKS for reusable browser automation and human takeover"
6
6
  project: "kxm"
7
7
  status: "accepted"
8
8
  owner: "@operator"
@@ -12,7 +12,7 @@ authority: "decision"
12
12
  confidence: "verified"
13
13
  summary: "Adopt self-hosted Steel on DigitalOcean Kubernetes (DOKS) with agent-browser and Playwright as KXM's primary browser automation infrastructure."
14
14
  tags: ["architecture", "decision", "browser", "steel", "doks", "playwright"]
15
- related: ["docs/browser-automation.md", "docs/agent-skills.md"]
15
+ related: ["docs/guides/browser-automation.md", "docs/guides/agent-skills.md"]
16
16
  details:
17
17
  decision_drivers:
18
18
  - "Eliminate per-minute SaaS browser provider costs"
@@ -23,9 +23,9 @@ details:
23
23
  superseded_by: null
24
24
  ---
25
25
 
26
- # ADR-0002: Self-Hosted Steel on DOKS for Reusable Browser Automation
26
+ # ADR-0002: Self-hosted Steel on DOKS for reusable browser automation
27
27
 
28
- ## Context & Problem Statement
28
+ ## Context and problem statement
29
29
 
30
30
  AI coding agents and orchestration workflows in KXM require browser interaction for UI exploration, DOM mapping, bug reproduction, and end-to-end regression testing. Existing approaches suffered from three core issues:
31
31
 
@@ -33,40 +33,40 @@ AI coding agents and orchestration workflows in KXM require browser interaction
33
33
  2. **Disconnected Human Takeover**: When login challenges, MFA prompts, or CAPTCHAs occur, local or headless cloud browsers cannot easily hand the live session over to a human operator and seamlessly resume without destroying session state.
34
34
  3. **Tool Fragmentation**: Exploratory navigation needs a fast, token-efficient terminal CLI (`agent-browser`), while testing needs durable, assertion-rich frameworks (`Playwright`).
35
35
 
36
- ## Decision Drivers
36
+ ## Decision drivers
37
37
 
38
- 1. **Operating Cost Control**: Keep infrastructure expenses predictable by utilizing our existing DigitalOcean Kubernetes Service (DOKS) cluster (`k8s-agentic-hub`).
38
+ 1. **Operating Cost Control**: Keep infrastructure expenses predictable by utilizing the maintainers' existing DigitalOcean Kubernetes Service (DOKS) cluster.
39
39
  2. **Unified Same-Session Takeover**: Enable a human to interact with the exact same browser tab and session state during authentication gates before handing control back to the agent.
40
40
  3. **Dual Automation Interfaces**: Support `agent-browser` for discovery and `Playwright` for permanent regression tests over standard Chrome DevTools Protocol (CDP).
41
41
  4. **Authoritative Credential Management**: Ensure `pass-cli` remains the exclusive source of truth for secrets and API keys.
42
42
 
43
- ## Considered Options
43
+ ## Considered options
44
44
 
45
45
  - **Option A**: Self-hosted Steel (`steel-dev/steel-browser`) deployed on DOKS with Ingress-NGINX and TLS.
46
46
  - **Option B**: Paid SaaS browser providers (e.g., Browserbase, Steel Cloud).
47
47
  - **Option C**: Local headless Chrome instances spawned on developer workstations.
48
48
 
49
- ## Evaluation & Tradeoff Matrix
49
+ ## Evaluation and trade-offs
50
50
 
51
- ### Option A: Self-hosted Steel on DOKS (Chosen)
51
+ ### Option A: self-hosted Steel on DOKS (chosen)
52
52
 
53
53
  - **Good, because**: Zero marginal per-session fees; fully self-hosted on our Kubernetes cluster.
54
54
  - **Good, because**: Built-in REST API, CDP WebSocket proxy, and live session viewer UI (`/ui`).
55
- - **Good, because**: Both `Playwright` and `agent-browser` connect seamlessly over standard CDP (`wss://steel.kontextmind.com/v1/devtools`).
55
+ - **Good, because**: Both `Playwright` and `agent-browser` connect seamlessly over standard CDP (`wss://<steel-host>/v1/devtools`).
56
56
  - **Good, because**: Dedicated shared memory (`/dev/shm`) and resource limits prevent workstation degradation.
57
57
  - **Bad, because**: Requires managing Kubernetes deployment and periodic orphaned session sweeping.
58
58
 
59
- ### Option B: Paid SaaS Browser Provider
59
+ ### Option B: a paid SaaS browser provider
60
60
 
61
61
  - **Good, because**: Managed scaling and proxy pools.
62
62
  - **Bad, because**: Violates the core cost-efficiency constraint; introduces recurring credit card charges and third-party data transmission risks.
63
63
 
64
- ### Option C: Local Chrome Instances
64
+ ### Option C: local Chrome instances
65
65
 
66
66
  - **Good, because**: No cluster deployment needed.
67
67
  - **Bad, because**: High workstation memory and CPU pressure; fragile cross-platform headless setups; cannot easily share live debug sessions across multi-agent environments.
68
68
 
69
- ## Decision Outcome
69
+ ## Decision outcome
70
70
 
71
71
  **Chosen Option**: **Option A (Self-hosted Steel on DOKS)**.
72
72
 
@@ -74,14 +74,14 @@ AI coding agents and orchestration workflows in KXM require browser interaction
74
74
 
75
75
  ```text
76
76
  ┌─────────────────────────────────────────────────────────────┐
77
- │ KXM Agent / Herdr │
77
+ │ KXM agent │
78
78
  │ (kxm-browser-session, kxm-browser-takeover, pass-cli) │
79
79
  └───────────────┬─────────────────────────────┬───────────────┘
80
80
  │ REST API (create/release) │ CDP WebSocket
81
81
  ▼ ▼
82
82
  ┌─────────────────────────────────────────────────────────────┐
83
83
  │ DigitalOcean Kubernetes (DOKS) │
84
- │ https://steel.kontextmind.com │
84
+ │ https://<steel-host> │
85
85
  │ │
86
86
  │ ┌─────────────────────┐ ┌────────────────────────┐ │
87
87
  │ │ Steel API & CDP │◄─────►│ Chromium Sandbox │ │
@@ -96,8 +96,14 @@ AI coding agents and orchestration workflows in KXM require browser interaction
96
96
  └─────────────────────────────────────────────────────────────┘
97
97
  ```
98
98
 
99
- ## Confirmation & Verification Strategy
99
+ ## Confirmation and verification
100
100
 
101
- - **Verification**: Health endpoint `https://steel.kontextmind.com/v1/health` verified with HTTP 200 and Let's Encrypt TLS.
101
+ - **Verification**: Health endpoint `$STEEL_API_URL/v1/health` verified with HTTP 200 and Let's Encrypt TLS.
102
102
  - **Integration Test**: `test/core/browser.test.ts` validates session lifecycle, CDP endpoint formatting, takeover transitions, and secret redaction.
103
- - **Security Check**: `pass-cli` verified as the authoritative store for `STEEL_API_KEY` under vault `AI Provider Keys`.
103
+ - **Security Check**: `pass-cli` verified as the authoritative store for `STEEL_API_KEY` in the operators' password manager.
104
+
105
+ ## Related
106
+
107
+ - [Browser automation](../guides/browser-automation.md)
108
+ - [Agent skills](../guides/agent-skills.md)
109
+ - [Architecture decision records](README.md)
@@ -0,0 +1,100 @@
1
+ ---
2
+ schema: "kxm.doc.v1"
3
+ id: "ADR-0003"
4
+ type: "adr"
5
+ title: "SQLite as the only store"
6
+ project: "kxm"
7
+ status: "accepted"
8
+ owner: "@operator"
9
+ created: "2026-09-17"
10
+ updated: "2026-09-23"
11
+ authority: "decision"
12
+ confidence: "verified"
13
+ summary: "Every KXM store is a local SQLite database owned by one process; DuckDB and database servers are rejected as the system of record."
14
+ tags: ["architecture", "decision", "storage", "sqlite"]
15
+ related: ["docs/concepts/data-and-storage.md", "docs/concepts/architecture.md", "docs/contracts/architecture.md"]
16
+ details:
17
+ decision_drivers:
18
+ - "Many small durable reads and writes owned by one process"
19
+ - "No native dependencies in any install"
20
+ - "Must run in Node.js and in Pi's embedded Bun runtime"
21
+ - "Single-node deployment with no clustering or failover"
22
+ supersedes: null
23
+ superseded_by: null
24
+ ---
25
+
26
+ # ADR-0003: SQLite as the only store
27
+
28
+ ## Status
29
+
30
+ Accepted. This record replaces the research note "Storage engine: SQLite vs DuckDB".
31
+
32
+ ## Context
33
+
34
+ KXM persists state in three places: the hub store (agents, messages, workflow runs, the journal, context, leases, and sync events), the Runtime registry, and one Runtime event store per project. All three are written by a single owning process and read by a few local readers.
35
+
36
+ The question came up whether KXM should use DuckDB. The premise was inverted: KXM already used SQLite everywhere, and no DuckDB code existed. The real question was whether DuckDB, or any other engine, should become the system of record.
37
+
38
+ The workload has a clear shape:
39
+
40
+ - **Transactional, not analytical.** Sending, delivering, and replying to messages, advancing cursors, appending run events, and moving run state are small point reads and writes by ID.
41
+ - **One owner per database.** The hub owns its file, and the Runtime owns the registry and each event store. KXM's production boundary is one process per database, with no clustering, leader election, or shared-state failover.
42
+ - **Two JavaScript runtimes.** The CLI, hub, and Runtime run on Node.js. The Pi extension runs inside Pi's embedded Bun runtime, which has no `node:sqlite`.
43
+
44
+ ## Decision drivers
45
+
46
+ 1. Match the storage engine to a small-write, single-writer workload.
47
+ 2. Add no native dependency to any install and no build step.
48
+ 3. Run unchanged in Node.js and in Bun.
49
+ 4. Keep the single-node boundary simple to operate, back up, and restore.
50
+
51
+ ## Considered options
52
+
53
+ - **Option A: SQLite.** Node's built-in `node:sqlite`, with `bun:sqlite` as the fallback inside Pi.
54
+ - **Option B: DuckDB** as the primary store.
55
+ - **Option C: a separate database server**, such as PostgreSQL.
56
+
57
+ ### Option A: SQLite (chosen)
58
+
59
+ - Good, because its design center is embedded, transactional, single-writer storage with point queries, which is KXM's workload.
60
+ - Good, because the supported Node.js versions and Bun ship it built in: no native dependency and no build step.
61
+ - Good, because WAL mode gives concurrent local readers while one process writes.
62
+ - Bad, because one database cannot be shared by several hub processes. KXM accepts that; it is the single-node boundary.
63
+
64
+ ### Option B: DuckDB
65
+
66
+ - Good, because it is fast at analytical scans over large, columnar datasets.
67
+ - Bad, because that is the wrong workload for a message bus and an event log, and its concurrency model does not improve on SQLite's single writer.
68
+ - Bad, because it adds a large native dependency to every install for no transactional benefit.
69
+
70
+ ### Option C: a separate database server
71
+
72
+ - Good, because it could serve several hub processes.
73
+ - Bad, because it adds a service to install, secure, and back up, which contradicts a local-first tool that runs on one machine.
74
+ - Bad, because KXM does not cluster hubs, so the extra capability would go unused.
75
+
76
+ ## Decision
77
+
78
+ Every KXM store is a SQLite database owned by exactly one process:
79
+
80
+ - The hub store, the Runtime registry, and each Runtime event store use `STRICT` tables and record their schema version in `user_version`.
81
+ - Every store opens in WAL mode with a busy timeout, `synchronous=NORMAL`, and foreign keys on, and refuses a database or sidecar that is a symbolic link.
82
+ - A store whose version is older or newer than the running build is refused, not migrated. The owner recreates it after the operator deletes it.
83
+
84
+ ## Consequences
85
+
86
+ - KXM installs anywhere a supported Node.js runs, with no database service to operate.
87
+ - A backup is a consistent file copy made with SQLite's `VACUUM INTO`, with no dump format to maintain.
88
+ - Scaling out means running more independent hubs, one per trust domain, not more processes per hub.
89
+ - Upgrading across a store version discards that store's history unless the operator backs it up first. [Data and storage](../concepts/data-and-storage.md#schema-versions-refuse-do-not-migrate) describes the procedure.
90
+
91
+ ### Where a columnar engine could fit later
92
+
93
+ Analytics over exported, append-only data, such as routing and cost reports, could outgrow SQLite queries. The right shape then is a periodic export to a separate DuckDB file used read-only for analysis. It would never become the hub's or the Runtime's system of record.
94
+
95
+ ## Related
96
+
97
+ - [Data and storage](../concepts/data-and-storage.md)
98
+ - [Architecture](../concepts/architecture.md)
99
+ - [ADR-001: Local Runtime, project authority, and aggregate hub](../contracts/architecture.md)
100
+ - [Architecture decision records](README.md)
@@ -0,0 +1,99 @@
1
+ ---
2
+ schema: "kxm.doc.v1"
3
+ id: "ADR-0004"
4
+ type: "adr"
5
+ title: "Edge identity with Authentik; the hub owns no browser identity"
6
+ project: "kxm"
7
+ status: "accepted"
8
+ owner: "@operator"
9
+ created: "2026-09-17"
10
+ updated: "2026-09-23"
11
+ authority: "decision"
12
+ confidence: "reviewed"
13
+ summary: "For a hosted, one-tenant-per-box deployment, Authentik authenticates browsers at the reverse proxy and a portal backend calls the loopback hub with existing machine credentials. Hub-side JWT verification and a token broker are rejected, not deferred."
14
+ tags: ["architecture", "decision", "hosting", "authentik", "oidc", "auth"]
15
+ related: ["docs/concepts/trust-model.md", "docs/operations/deploy.md", "docs/concepts/architecture.md"]
16
+ details:
17
+ decision_drivers:
18
+ - "One tenant per box, not one hub for many unrelated users"
19
+ - "Keep the hub's machine credentials and loopback default unchanged"
20
+ - "A browser-path outage must not stop authorized machine clients"
21
+ - "No new identity code inside the hub"
22
+ supersedes: null
23
+ superseded_by: null
24
+ ---
25
+
26
+ # ADR-0004: Edge identity with Authentik; the hub owns no browser identity
27
+
28
+ ## Status
29
+
30
+ Accepted on 2026-09-20. This record replaces the research note "Authentik (OIDC) for user, role, and agent authentication". Options 2 and 3 below were the recommendation for about a month before this decision; they are recorded as rejected, not deferred.
31
+
32
+ ## Context
33
+
34
+ KXM is hosted as **one tenant per box**: each tenant gets its own hub and Runtime on a dedicated machine, behind a web portal. Browsers need real user authentication for that portal. The question was where user identity should live.
35
+
36
+ The hub knows three machine credentials, and none carries a user, role, or group:
37
+
38
+ 1. **The admin token** (`KXM_AUTH_TOKEN`), generated and saved by `kxm hub start` when absent. It gates admin routes such as `/metrics`, the operations stream, quorum degradation, and state promotion.
39
+ 2. **Project tokens** (`KXM_PROJECT_TOKENS`), a static map read at startup. Every agent route checks the caller's project token.
40
+ 3. **Agent keys**, minted at registration and rotated at every reconnect. An agent record has no owner or principal field.
41
+
42
+ The hub binds loopback by default and refuses to bind beyond loopback without an admin token. Roles and tool policies are not hub-authenticated: the role sent with a context request only selects a context budget and journal categories, and tool policy comes from unsigned, locally minted session tokens. No OIDC, JWT, or JWKS code exists in KXM.
43
+
44
+ ## Decision drivers
45
+
46
+ 1. The deployment is one tenant per box, not one shared hub for many unrelated users.
47
+ 2. Machine clients (agents, the Runtime, and the portal backend) already authenticate with working credentials.
48
+ 3. A failure on the browser path must deny browsers without stopping authorized machine clients.
49
+ 4. The hub should not gain an identity subsystem, a network dependency at authentication time, or a token store.
50
+
51
+ ## Considered options
52
+
53
+ 1. **Forward authentication at the reverse proxy.** An Authentik proxy outpost authenticates browser sessions at the tenant's existing proxy. The hub is unchanged.
54
+ 2. **Hub-side JWT verification.** The hub would accept Authentik-issued tokens, verify them against the issuer's keys, and map group claims to admin and project scope.
55
+ 3. **A token broker.** A new service or hub route would accept an Authentik ID token and mint per-user project tokens and signed session tokens with tool policies derived from groups.
56
+
57
+ ### Option 1: forward authentication at the proxy (chosen)
58
+
59
+ - Good, because it is configuration only: no hub code changes.
60
+ - Good, because the hub keeps its token check, and a non-loopback bind still requires a token, so the proxy cannot make the hub anonymous.
61
+ - Good, because an Authentik outage denies browsers but leaves machine clients working.
62
+ - Bad, because the hub records no per-user identity. The portal must keep its own user audit.
63
+ - Bad, because a misconfigured proxy that injects the admin token for every signed-in user would make every user a hub administrator.
64
+
65
+ ### Option 2: hub-side JWT verification (rejected)
66
+
67
+ - Good, because hub writes could carry a real user principal.
68
+ - Bad, because it adds discovery, key caching, clock-skew handling, and algorithm restrictions to the hub, plus a network dependency at authentication time that must fail closed.
69
+ - Bad, because clients would need token refresh, since access tokens expire.
70
+
71
+ ### Option 3: a token broker (rejected)
72
+
73
+ - Good, because agents and people would share one identity source.
74
+ - Bad, because project tokens are static at startup, so per-user tokens would need a dynamic token store in the hub.
75
+ - Bad, because a broker-issued session token means nothing until session tokens are signed and verified, which they are not.
76
+ - Bad, because it touches token storage, signing, and revocation at once.
77
+
78
+ ## Decision
79
+
80
+ Authentik authenticates and authorizes browsers at each tenant's reverse proxy, on the portal's routes. The portal's server-side backend calls the loopback hub and Runtime supervisor with the machine credentials that already work. The hub binds loopback, exposes no public listener, and never receives or interprets a browser identity header.
81
+
82
+ These stay exactly as they are: the admin-token requirement for a non-loopback bind, the generated and saved admin token, project tokens read at startup, and loopback convenience for local use.
83
+
84
+ Hub-side JWT verification, mapping groups to tool policies, token signing, dynamic per-user token stores, and OAuth client-credentials or device-flow login for agents are **rejected, not deferred**. Reopening any of them requires a new written decision that names what the portal boundary cannot do, such as per-user attribution of hub writes inside KXM, which per-box tenancy does not need.
85
+
86
+ ## Consequences
87
+
88
+ - Per-user identity, authorization, and audit belong to the portal and the proxy, not to KXM.
89
+ - Never configure the proxy to add the admin token to every authenticated request. The portal backend holds hub credentials server-side.
90
+ - Agents keep authenticating with project tokens. Holders of one project token remain one trust domain, as the [trust model](../concepts/trust-model.md) describes.
91
+ - Session tokens remain unsigned local tool-policy hints, not identity.
92
+ - One hardening item stays open and is not a hosting prerequisite: the Studio mutation endpoint compares its session token with a plain string comparison and should use a timing-safe one.
93
+
94
+ ## Related
95
+
96
+ - [Trust model](../concepts/trust-model.md)
97
+ - [Deploy KXM](../operations/deploy.md)
98
+ - [Architecture](../concepts/architecture.md)
99
+ - [Architecture decision records](README.md)
@@ -0,0 +1,33 @@
1
+ # Architecture decision records
2
+
3
+ An architecture decision record (ADR) captures one significant decision about KXM: the context, the options considered, what was chosen, and what follows from it. Read these when you want to know why KXM works the way it does, or before you propose to change one of these decisions.
4
+
5
+ ## Index
6
+
7
+ | ADR | Decision | Status | Date |
8
+ |---|---|---|---|
9
+ | [ADR-001](../contracts/architecture.md) | Local Runtime, project authority, and aggregate hub | Accepted target | — |
10
+ | [ADR-0002](ADR-0002-browser-automation-steel-doks.md) | Self-hosted Steel for reusable browser automation and human takeover | Accepted | 2026-09-14 |
11
+ | [ADR-0003](ADR-0003-sqlite-only-store.md) | SQLite as the only store | Accepted | 2026-09-17 |
12
+ | [ADR-0004](ADR-0004-edge-identity-authentik.md) | Edge identity with Authentik; the hub owns no browser identity | Accepted | 2026-09-20 |
13
+
14
+ ADR-001 is the original decision record for the local Runtime. It lives with the contracts in [`docs/contracts/architecture.md`](../contracts/architecture.md) because it is the root of those contracts, and it keeps its original three-digit number. Records in this directory continue the sequence from 0002. There is no ADR-0001.
15
+
16
+ > [!NOTE]
17
+ > ADR-001 is an accepted target. It describes the intended split between the Runtime and the hub, and parts of it are not implemented yet. [Architecture](../concepts/architecture.md) describes what the current build does.
18
+
19
+ ## Write a new ADR
20
+
21
+ 1. Take the next free number and name the file `ADR-<number>-<short-slug>.md`.
22
+ 2. Start it with the same `kxm.doc.v1` front matter as the existing records, with `type: "adr"` and `authority: "decision"`.
23
+ 3. Include these sections: Status, Context, Decision drivers, Considered options, Decision, and Consequences, and end with Related.
24
+ 4. Record rejected options with the reason they were rejected, so the next reader does not reopen them without new information.
25
+ 5. When a decision replaces an earlier one, set `supersedes` and `superseded_by` in both records instead of editing the old decision.
26
+ 6. Add a row to the index above.
27
+
28
+ ## Related
29
+
30
+ - [Architecture](../concepts/architecture.md)
31
+ - [Trust model](../concepts/trust-model.md)
32
+ - [Data and storage](../concepts/data-and-storage.md)
33
+ - [Contracts](../contracts/README.md)