@kontextmind/kxm 0.6.0
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 +19 -0
- package/.kxm/README.md +14 -0
- package/.kxm/assets/README.md +5 -0
- package/.kxm/assets/retrospectives/README.md +5 -0
- package/.kxm/config/README.md +5 -0
- package/.kxm/config/agents.json +43 -0
- package/.kxm/config/env.example +56 -0
- package/.kxm/config/update.example.yaml +9 -0
- package/.kxm/config/workflows/fix.json +160 -0
- package/.kxm/config/workflows/jira-development.json +116 -0
- package/.kxm/config/workflows/provenance-quorum.json +150 -0
- package/.kxm/config/workflows/v04-dogfood.json +72 -0
- package/CHANGELOG.md +465 -0
- package/LICENSE +21 -0
- package/README.md +306 -0
- package/SECURITY.md +72 -0
- package/docs/README.md +48 -0
- package/docs/agent-communication-envelopes-and-gates.md +553 -0
- package/docs/architecture.md +242 -0
- package/docs/assignment-runner.md +241 -0
- package/docs/configuration.md +361 -0
- package/docs/continuous-improvement.md +114 -0
- package/docs/getting-started.md +253 -0
- package/docs/kxm-handbook.md +1090 -0
- package/docs/operations.md +205 -0
- package/docs/provenance-gates.md +291 -0
- package/docs/skills.md +45 -0
- package/docs/templates/README.md +95 -0
- package/docs/templates/adr.md +88 -0
- package/docs/templates/architecture.md +120 -0
- package/docs/templates/bug-fix.md +109 -0
- package/docs/templates/feature.md +108 -0
- package/docs/templates/handoff.md +72 -0
- package/docs/templates/postmortem.md +77 -0
- package/docs/templates/research.md +100 -0
- package/docs/templates/review.md +85 -0
- package/docs/templates/runbook.md +73 -0
- package/docs/templates/test-plan.md +87 -0
- package/docs/templates/test-report.md +72 -0
- package/docs/test-matrix.md +121 -0
- package/docs/troubleshooting.md +249 -0
- package/docs/vnext/README.md +62 -0
- package/docs/vnext/architecture.md +185 -0
- package/docs/vnext/effects-and-recovery.md +172 -0
- package/docs/vnext/lifecycles.md +235 -0
- package/docs/vnext/migration.md +220 -0
- package/docs/vnext/routing.md +184 -0
- package/docs/vnext/synchronization.md +172 -0
- package/docs/vnext/terminology.md +240 -0
- package/docs/vnext/validation.md +335 -0
- package/docs/webhook-workflows.md +240 -0
- package/docs/workflow-guide.md +1150 -0
- package/examples/README.md +102 -0
- package/examples/provenance-workflow.json +40 -0
- package/examples/requester.ts +30 -0
- package/examples/reviewer-agent.ts +29 -0
- package/examples/roundtrip.ts +46 -0
- package/examples/vnext/.kxm/agents/coordinator.yaml +16 -0
- package/examples/vnext/.kxm/agents/critic-1.yaml +16 -0
- package/examples/vnext/.kxm/agents/critic-2.yaml +15 -0
- package/examples/vnext/.kxm/agents/critic-3.yaml +15 -0
- package/examples/vnext/.kxm/agents/implementer.yaml +15 -0
- package/examples/vnext/.kxm/agents/planner.yaml +13 -0
- package/examples/vnext/.kxm/agents/reproducer.yaml +15 -0
- package/examples/vnext/.kxm/agents/reviewer.yaml +15 -0
- package/examples/vnext/.kxm/gates.yaml +8 -0
- package/examples/vnext/.kxm/models/critic-claude.yaml +11 -0
- package/examples/vnext/.kxm/models/critic-gemini.yaml +11 -0
- package/examples/vnext/.kxm/models/critic-grok.yaml +12 -0
- package/examples/vnext/.kxm/models/implementation.yaml +14 -0
- package/examples/vnext/.kxm/models/primary.yaml +17 -0
- package/examples/vnext/.kxm/prices.yaml +111 -0
- package/examples/vnext/.kxm/project/env.yaml +7 -0
- package/examples/vnext/.kxm/project.yaml +32 -0
- package/examples/vnext/.kxm/repo/repo.yaml +8 -0
- package/examples/vnext/.kxm/workflows/default.yaml +92 -0
- package/examples/vnext/.kxm/workflows/fix.yaml +376 -0
- package/examples/vnext/.kxm/workflows/improve.yaml +57 -0
- package/examples/vnext/README.md +53 -0
- package/examples/vnext/records/assignment-result-recorded.json +63 -0
- package/examples/vnext/records/assignment-result.json +46 -0
- package/examples/vnext/records/context-candidate.json +42 -0
- package/examples/vnext/records/delivery-manifest.json +66 -0
- package/examples/vnext/records/effect-uncertainty-resolved-sync.json +67 -0
- package/examples/vnext/records/effect-uncertainty-resolved.json +62 -0
- package/examples/vnext/records/run-created.json +54 -0
- package/examples/vnext/records/sync-event.json +65 -0
- package/examples/vnext/repositories/api/.kxm/repo/env.yaml +7 -0
- package/examples/vnext/repositories/api/.kxm/repo/repo.yaml +8 -0
- package/examples/vnext/repositories/web/.kxm/repo/repo.yaml +8 -0
- package/examples/workflow-signal.ts +63 -0
- package/package.json +129 -0
- package/plugins/kxm/.claude-plugin/plugin.json +73 -0
- package/plugins/kxm/.mcp.json +19 -0
- package/plugins/kxm/README.md +93 -0
- package/plugins/kxm/dist/cli.js +42853 -0
- package/plugins/kxm/dist/client.js +416 -0
- package/plugins/kxm/dist/core.js +1823 -0
- package/plugins/kxm/dist/extension.js +3797 -0
- package/plugins/kxm/dist/mcp-server.js +17104 -0
- package/plugins/kxm/dist/runtime.js +23361 -0
- package/plugins/kxm/dist/server.js +13640 -0
- package/plugins/kxm/dist/vnext-runtime-supervisor.js +21109 -0
- package/plugins/kxm/package.json +12 -0
- package/plugins/kxm/skills/kxm/SKILL.md +97 -0
- package/plugins/kxm/skills/kxm/references/protocol.md +103 -0
- package/plugins/kxm/skills/kxm-session/SKILL.md +53 -0
- package/plugins/kxm/src/arbiter.ts +355 -0
- package/plugins/kxm/src/artifacts-exist.ts +62 -0
- package/plugins/kxm/src/autocomplete.ts +236 -0
- package/plugins/kxm/src/cli.ts +3707 -0
- package/plugins/kxm/src/client.ts +614 -0
- package/plugins/kxm/src/commands.ts +1063 -0
- package/plugins/kxm/src/config.ts +290 -0
- package/plugins/kxm/src/context/providers.ts +101 -0
- package/plugins/kxm/src/context-packet.ts +332 -0
- package/plugins/kxm/src/context.ts +499 -0
- package/plugins/kxm/src/core.ts +6 -0
- package/plugins/kxm/src/database.ts +563 -0
- package/plugins/kxm/src/diagnostics.ts +184 -0
- package/plugins/kxm/src/envelope.ts +118 -0
- package/plugins/kxm/src/extension.ts +895 -0
- package/plugins/kxm/src/external-effects.ts +299 -0
- package/plugins/kxm/src/github-watch.ts +255 -0
- package/plugins/kxm/src/hub-binding.ts +160 -0
- package/plugins/kxm/src/hub.ts +2502 -0
- package/plugins/kxm/src/improve.ts +383 -0
- package/plugins/kxm/src/inbox.ts +10 -0
- package/plugins/kxm/src/kxm-install-kind.ts +113 -0
- package/plugins/kxm/src/kxm-update-config.ts +39 -0
- package/plugins/kxm/src/kxm-update.ts +238 -0
- package/plugins/kxm/src/local-snapshot.ts +406 -0
- package/plugins/kxm/src/logger.ts +198 -0
- package/plugins/kxm/src/mcp-server.ts +143 -0
- package/plugins/kxm/src/memory.ts +385 -0
- package/plugins/kxm/src/nous-pi.ts +287 -0
- package/plugins/kxm/src/nous-provider.ts +729 -0
- package/plugins/kxm/src/price-calc.ts +87 -0
- package/plugins/kxm/src/prices.ts +121 -0
- package/plugins/kxm/src/protocol.ts +172 -0
- package/plugins/kxm/src/recovery.ts +211 -0
- package/plugins/kxm/src/redact.ts +26 -0
- package/plugins/kxm/src/retrospective.ts +400 -0
- package/plugins/kxm/src/routing.ts +830 -0
- package/plugins/kxm/src/runtime.ts +9 -0
- package/plugins/kxm/src/server.ts +117 -0
- package/plugins/kxm/src/session-work.ts +571 -0
- package/plugins/kxm/src/session.ts +184 -0
- package/plugins/kxm/src/skills.ts +535 -0
- package/plugins/kxm/src/state.ts +326 -0
- package/plugins/kxm/src/store.ts +637 -0
- package/plugins/kxm/src/studio-layout.ts +268 -0
- package/plugins/kxm/src/suggest.ts +162 -0
- package/plugins/kxm/src/task-manager.ts +244 -0
- package/plugins/kxm/src/telemetry.ts +116 -0
- package/plugins/kxm/src/tui.ts +1046 -0
- package/plugins/kxm/src/vnext-bindings.ts +403 -0
- package/plugins/kxm/src/vnext-config.ts +1646 -0
- package/plugins/kxm/src/vnext-engine-artifacts.ts +86 -0
- package/plugins/kxm/src/vnext-engine-command.ts +533 -0
- package/plugins/kxm/src/vnext-engine-compile.ts +722 -0
- package/plugins/kxm/src/vnext-engine-evidence.ts +273 -0
- package/plugins/kxm/src/vnext-engine-fold.ts +1400 -0
- package/plugins/kxm/src/vnext-engine-gate-records.ts +583 -0
- package/plugins/kxm/src/vnext-engine-plan.ts +717 -0
- package/plugins/kxm/src/vnext-engine.ts +2458 -0
- package/plugins/kxm/src/vnext-gate-hash.ts +10 -0
- package/plugins/kxm/src/vnext-harness.ts +1142 -0
- package/plugins/kxm/src/vnext-init.ts +430 -0
- package/plugins/kxm/src/vnext-migrate.ts +1848 -0
- package/plugins/kxm/src/vnext-oneshot-producer.ts +424 -0
- package/plugins/kxm/src/vnext-permission.ts +936 -0
- package/plugins/kxm/src/vnext-pi-producer.ts +628 -0
- package/plugins/kxm/src/vnext-repair.ts +1094 -0
- package/plugins/kxm/src/vnext-runtime-owner.ts +320 -0
- package/plugins/kxm/src/vnext-runtime-store.ts +1560 -0
- package/plugins/kxm/src/vnext-runtime-supervisor.ts +586 -0
- package/plugins/kxm/src/vnext-runtime.ts +663 -0
- package/plugins/kxm/src/vnext-template.ts +247 -0
- package/plugins/kxm/src/wiki.ts +313 -0
- package/plugins/kxm/src/workflow.ts +1548 -0
- package/schemas/vnext/README.md +46 -0
- package/schemas/vnext/agent.schema.json +40 -0
- package/schemas/vnext/assignment-result.schema.json +66 -0
- package/schemas/vnext/backup-manifest.schema.json +89 -0
- package/schemas/vnext/candidate.schema.json +109 -0
- package/schemas/vnext/common.schema.json +422 -0
- package/schemas/vnext/context-candidate.schema.json +76 -0
- package/schemas/vnext/context-packet.schema.json +192 -0
- package/schemas/vnext/delivery-manifest.schema.json +159 -0
- package/schemas/vnext/environment.schema.json +66 -0
- package/schemas/vnext/gate-registry.schema.json +109 -0
- package/schemas/vnext/handoff-manifest.schema.json +146 -0
- package/schemas/vnext/init-operation.schema.json +61 -0
- package/schemas/vnext/local-repository-bindings.schema.json +30 -0
- package/schemas/vnext/memory-record.schema.json +45 -0
- package/schemas/vnext/migration-decision.schema.json +26 -0
- package/schemas/vnext/migration-plan.schema.json +123 -0
- package/schemas/vnext/migration-receipt.schema.json +52 -0
- package/schemas/vnext/model.schema.json +42 -0
- package/schemas/vnext/permission-diff.schema.json +57 -0
- package/schemas/vnext/prices.schema.json +115 -0
- package/schemas/vnext/project.schema.json +85 -0
- package/schemas/vnext/repository.schema.json +24 -0
- package/schemas/vnext/run-event.schema.json +460 -0
- package/schemas/vnext/session-brief.schema.json +153 -0
- package/schemas/vnext/sync-event.schema.json +234 -0
- package/schemas/vnext/template-provenance.schema.json +38 -0
- package/schemas/vnext/workflow.schema.json +248 -0
- package/scripts/assignment-run.d.mts +354 -0
- package/scripts/assignment-run.mjs +4451 -0
- package/scripts/build-runtime.mjs +56 -0
- package/scripts/check-generated.mjs +77 -0
- package/scripts/check-versions.mjs +34 -0
- package/scripts/emit-codex-artifacts.d.mts +9 -0
- package/scripts/emit-codex-artifacts.mjs +91 -0
- package/scripts/harness-run.d.mts +83 -0
- package/scripts/harness-run.mjs +2095 -0
- package/scripts/kxm-hub.mjs +105 -0
- package/scripts/kxm-publish-npm.mjs +327 -0
- package/scripts/kxm-release-github.mjs +472 -0
- package/scripts/kxm-runtime-supervisor.mjs +7 -0
- package/scripts/kxm-worker.mjs +1127 -0
- package/scripts/kxm.mjs +27 -0
- package/scripts/roster-policy.d.mts +20 -0
- package/scripts/roster-policy.mjs +161 -0
- package/scripts/smoke-multi-pi.mjs +479 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Operations guide
|
|
2
|
+
|
|
3
|
+
This guide covers the production envelope for one KXM hub and one SQLite database.
|
|
4
|
+
|
|
5
|
+
## Deployment classification
|
|
6
|
+
|
|
7
|
+
Version `0.4.x` is designed for local workstations and controlled trusted-team hosts. It provides durable restart recovery, project authentication, signed webhook workflows, traffic limits, health signals, metrics, structured logs, and graceful shutdown.
|
|
8
|
+
|
|
9
|
+
It is not a clustered or multi-tenant control plane. Run one writer for each database. Do not place a load balancer across independent hubs and expect shared presence or delivery.
|
|
10
|
+
|
|
11
|
+
## Start and stop
|
|
12
|
+
|
|
13
|
+
```powershell
|
|
14
|
+
$env:KXM_HOST = "127.0.0.1"
|
|
15
|
+
$env:KXM_AUTH_TOKEN = "replace-with-a-long-random-token"
|
|
16
|
+
$env:KXM_WORKSPACE_DIR = "D:\work\product\.kxm"
|
|
17
|
+
kxm hub start
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
These operator commands assume the packed release CLI installation from
|
|
21
|
+
[Getting started](getting-started.md#install-the-operator-command). From a
|
|
22
|
+
source clone, use `npm run hub` instead.
|
|
23
|
+
|
|
24
|
+
Stop with `Ctrl+C` or `SIGTERM`. The hub stops accepting connections, closes SSE streams, waits for active HTTP connections, and closes SQLite.
|
|
25
|
+
|
|
26
|
+
For unattended service, use a supervisor that sets a stable working directory, injects secrets, captures stdout, restarts after failure, and allows at least five seconds for graceful shutdown.
|
|
27
|
+
|
|
28
|
+
Run each long-lived coordinator with `kxm agent worker --name <stable-name> --project <project> [--model <provider/model>] [--fallback-models <provider/model,...>] [--tools <name,...>]` under a separate service-manager unit. Use distinct worktrees for concurrent writers, explicit CPU and memory limits, and restart throttling outside the built-in bounded backoff. Enforce role ownership with the Pi tool allowlist: omit `bash`, `edit`, and `write` from read-only reviewers, even if their prompt also says not to edit. The worker launches Pi RPC mode and retains the most recent session unless configured otherwise. Use `--fresh-start` for a clean first session that may still resume after a later provider failure; reserve `--no-continue` for a worker that must never resume. For release verification, configure the [exact extension and skill sets](configuration.md#long-lived-worker-settings), including every required provider extension; configured categories disable discovery and fail closed on invalid paths. `kxm hub stop` writes a generation-matched control request; the worker asks Pi RPC to abort, waits for confirmation and state flush, and only force-stops the process tree after the bounded drain deadline. A final provider error leaves the inbound hub message delivered, gracefully restarts Pi, rotates to an unused fallback model, and preserves the session; Pi's own automatic retries always finish first. A tool that exceeds `KXM_WORKER_TOOL_TIMEOUT_MS` follows the same durable restart path without changing models. If `--continue` reports an invalid tool-result session, the worker retries once fresh, journals a redacted recovery envelope, and injects a bounded resume instruction for the durable run and stage. Do not copy `pi-agent-*.log` into journals or retrospectives.
|
|
29
|
+
|
|
30
|
+
### Workflow-specific Pi sessions
|
|
31
|
+
|
|
32
|
+
Workflow isolation is opt-in during the upgrade-compatible release because the new scoped default directory cannot safely infer which pre-upgrade shared Pi session belonged to a worker. Enable it explicitly for coordinators and peers that may receive durable workflow work:
|
|
33
|
+
|
|
34
|
+
```powershell
|
|
35
|
+
kxm agent worker --name coordinator --project product --session-isolation workflow
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Ordinary peer and operator messages reuse the worker's stable `default` Pi history. Each canonical workflow run uses `.kxm/state/pi-sessions/<workerKey>/runs/<runId>/`; only one Pi RPC child exists at a time. A route-change lifecycle event (`worker_session_routed`) is expected and does not consume restart budget or apply crash backoff. `worker_session_evicted` records bounded LRU cleanup. `worker_session_state_recovered` means a malformed binding manifest was quarantined and routing restarted safely at `default`; inspect the protected `.corrupt-*` file and workflow journal before deleting it. `worker_session_request_rejected` indicates a stale, malformed, mismatched-generation, or mismatched-source request and should be investigated if it repeats.
|
|
39
|
+
|
|
40
|
+
Back up workflow model histories only if local Pi context is part of your recovery policy; authoritative workflow stages, evidence, and decisions remain in `kxm.db`, assets, and Git. Never use a Pi JSONL as the sole system of record. The first isolated launch starts fresh scoped storage; the previous shared Pi history remains available only in `off` mode and is not copied because a shared directory may contain several agents' sessions. To disable isolation temporarily, stop the exact worker cleanly and restart it with `--session-isolation off`; do not run isolated and shared supervisors concurrently under the same agent identity. Returning to `workflow` resumes the binding recorded in the manifest, subject to the configured retention bound.
|
|
41
|
+
|
|
42
|
+
For GitHub-backed waits, run `kxm gate github watch` as a separate command. The hub does not poll GitHub. Success, failure, cancellation, and timeout produce the exact signed signal for the waiting run/stage/key; timeout exits `4` after posting `failed`.
|
|
43
|
+
|
|
44
|
+
## Live observer dashboard
|
|
45
|
+
|
|
46
|
+
Run the read-only dashboard against the active workspace:
|
|
47
|
+
|
|
48
|
+
```powershell
|
|
49
|
+
kxm --workspace D:\work\product\.kxm dash
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The dashboard uses Pi's `@earendil-works/pi-tui` renderer. With the administrative `KXM_AUTH_TOKEN`, it subscribes to `/v1/ops/events` and refreshes the project-scoped `/v1/ops/snapshot` on each SSE wakeup, keeping agent, open-message, and workflow metadata live without timer polling. Both endpoints omit request/reply bodies. Local process claims remain a local read-only snapshot. If the operations endpoints are unavailable or the supplied credential is project-scoped rather than administrative, the dashboard requests a hub-enforced presence-only agent SSE stream plus local SQLite metadata. It refuses an older/unmarked stream that cannot guarantee this metadata-only mode. Observer registrations are excluded from the dashboard's displayed agent table and counts; they remain ordinary authenticated hub identities while connected.
|
|
53
|
+
|
|
54
|
+
| Key | Action |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `1`–`6` | Agents, Tasks, Workflows, Plans, Inbox, or Procs |
|
|
57
|
+
| `Tab` / `]` | Next tab |
|
|
58
|
+
| `[` | Previous tab |
|
|
59
|
+
| `←` / `→` | List pane / detail pane |
|
|
60
|
+
| `↑` / `↓` | Select |
|
|
61
|
+
| `PgUp` / `PgDn` | Scroll |
|
|
62
|
+
| `h` | Toggle help |
|
|
63
|
+
| `q` | Quit |
|
|
64
|
+
|
|
65
|
+
In a non-interactive shell, `kxm dash` prints one ANSI-free snapshot and exits.
|
|
66
|
+
Use `kxm hub view --json` instead when a machine-readable result is required.
|
|
67
|
+
|
|
68
|
+
## Real multi-Pi release smoke
|
|
69
|
+
|
|
70
|
+
The opt-in release smoke requires two distinct models that already pass `pi auth check`. It creates a temporary workspace, launches two real Pi RPC workers, and verifies discovery, request/reply, fanout, durable identity plus a post-restart exchange, journal persistence, checkpoint completion, and cleanup.
|
|
71
|
+
|
|
72
|
+
PowerShell:
|
|
73
|
+
|
|
74
|
+
```powershell
|
|
75
|
+
$env:KXM_SMOKE = "1"
|
|
76
|
+
$env:KXM_SMOKE_MODELS = "xai/grok-4.6,anthropic/claude-sonnet-4-5"
|
|
77
|
+
node scripts/smoke-multi-pi.mjs
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
POSIX shell:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
KXM_SMOKE=1 KXM_SMOKE_MODELS='xai/grok-4.6,anthropic/claude-sonnet-4-5' node scripts/smoke-multi-pi.mjs
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
For GitHub Actions, smoke runs on the ARC scale set `kontextmind-doks`. Set
|
|
87
|
+
the GitHub repository variable `KXM_SMOKE_RUNNER` (a readiness latch, not a
|
|
88
|
+
process environment variable) exactly to `kontextmind-doks` and
|
|
89
|
+
`KXM_SMOKE_MODELS` to the two model IDs. Any other value skips the job. A
|
|
90
|
+
manual dispatch can override the model variable with its `models` input.
|
|
91
|
+
Readiness means Pi credentials are provisioned to ephemeral ARC pods and
|
|
92
|
+
pass `pi auth check`, not general CI readiness. Credentials are never
|
|
93
|
+
workflow inputs. The variable is currently unset, so the workflow is
|
|
94
|
+
intentionally disabled.
|
|
95
|
+
|
|
96
|
+
## Health, readiness, and metrics
|
|
97
|
+
|
|
98
|
+
| Endpoint | Authentication | Meaning |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `GET /health` | None | Process is accepting HTTP and reports online agents |
|
|
101
|
+
| `GET /ready` | None | Storage responds and the hub is ready for traffic |
|
|
102
|
+
| `GET /metrics` | Administrative token outside loopback | Prometheus text metrics |
|
|
103
|
+
| `GET /v1/ops/snapshot?project=<name>` | Administrative token | Project-scoped agent, open-message, and workflow metadata; no bodies |
|
|
104
|
+
| `GET /v1/ops/events?project=<name>` | Administrative token | Metadata-only SSE wakeups for live dashboard refresh |
|
|
105
|
+
|
|
106
|
+
Use `/ready` for service traffic and `/health` for liveness. Metrics include online agents, retained messages, requests, errors, registrations, sends, replies, cancellations, expiries, purges, workflow waits, external signals, wait timeouts, and explicit workflow quorum degradations.
|
|
107
|
+
|
|
108
|
+
Structured JSON logs are written to `.kxm/logs/kxm-hub.jsonl` and mirrored to stdout. They include request IDs and event metadata but omit prompt and reply bodies. Worker lifecycle events use `.kxm/logs/kxm-worker-<project>-<agent>-<identity>.jsonl`; raw headless Pi stdout and stderr use `.kxm/logs/pi-agent-<project>-<agent>-<identity>.log` and may contain sensitive model or tool output. The collision-resistant suffix separates exact project/agent owners even when display names sanitize identically. Useful hub events include `agent_registered`, `agent_resumed`, `agent_stale`, `message_sent`, `message_replied`, `message_cancelled`, `message_expired`, `message_purged`, `webhook_workflow_started`, `workflow_checkpoint`, `workflow_degradation_approved`, `workflow_wait_started`, `workflow_signal_received`, `workflow_wait_timed_out`, `workflow_journal_recorded`, and `request_error`.
|
|
109
|
+
|
|
110
|
+
Runtime logs are ignored by Git. Ship them to an approved collector, restrict file access, and apply retention or rotation outside the process before unattended use. Never commit them as workflow evidence; reference a protected log location or sanitized asset instead.
|
|
111
|
+
|
|
112
|
+
Recommended alerts:
|
|
113
|
+
|
|
114
|
+
- readiness fails for more than one minute;
|
|
115
|
+
- errors or rate-limit responses rise unexpectedly;
|
|
116
|
+
- the process restarts repeatedly;
|
|
117
|
+
- retained-message count grows despite the retention policy;
|
|
118
|
+
- free disk space approaches the database's expected growth margin.
|
|
119
|
+
- webhook signature rejections, repeated provider retries, premature workflow settlement, or attempt exhaustion increase.
|
|
120
|
+
- waiting-run count or workflow wait timeouts rise beyond the expected external-system latency.
|
|
121
|
+
- quorum degradation approvals occur outside a declared incident or change window.
|
|
122
|
+
|
|
123
|
+
## Backup and restore
|
|
124
|
+
|
|
125
|
+
SQLite runs in WAL mode. The safest simple backup is a coordinated copy while the hub is stopped:
|
|
126
|
+
|
|
127
|
+
1. Stop the hub gracefully.
|
|
128
|
+
2. Copy `.kxm/state/kxm.db` to protected backup storage.
|
|
129
|
+
3. Keep the backup with the application version and configuration used to create it.
|
|
130
|
+
4. Restart the hub and confirm `/ready` returns `ok: true`.
|
|
131
|
+
|
|
132
|
+
For online backups, use a SQLite-aware backup tool or snapshot the database, `-wal`, and `-shm` files consistently. A plain copy of only `kxm.db` while the service is writing may omit committed WAL data.
|
|
133
|
+
|
|
134
|
+
To restore, stop the hub, preserve the current files for rollback, place the restored database at `.kxm/state/kxm.db` or the configured `KXM_DATA_PATH`, and start the same or newer compatible release. The runtime refuses a database whose schema version is newer than it supports.
|
|
135
|
+
|
|
136
|
+
Test restoration periodically. A backup that has never been restored is not a verified recovery path.
|
|
137
|
+
|
|
138
|
+
## Upgrade and rollback
|
|
139
|
+
|
|
140
|
+
1. Back up the database and record the current package version.
|
|
141
|
+
2. Run `npm ci` for the target checkout.
|
|
142
|
+
3. Stop the old hub gracefully.
|
|
143
|
+
4. Start the new version against the database and verify `/ready`, `/metrics`, and a test round trip.
|
|
144
|
+
5. Restart agents only if their clients do not reconnect automatically.
|
|
145
|
+
|
|
146
|
+
For rollback, stop the new version and restore both the earlier application and its pre-upgrade database backup. Do not open a newer-schema database with an older runtime.
|
|
147
|
+
|
|
148
|
+
Peer provenance fields do not bump the current SQLite schema version 2; they are
|
|
149
|
+
additive fields in existing JSON records. That avoids a destructive migration,
|
|
150
|
+
but it does not replace the backup and rollback steps above. Verified
|
|
151
|
+
metadata-only snapshots remain in workflow runs after their source messages are
|
|
152
|
+
purged by terminal retention, so include workflow data in retention and privacy
|
|
153
|
+
reviews.
|
|
154
|
+
|
|
155
|
+
## Network and secret security
|
|
156
|
+
|
|
157
|
+
Loopback is the safest default. Before binding elsewhere, configure an administrative token, assign project tokens, terminate TLS at a trusted proxy, restrict inbound networks, disable proxy buffering for `/v1/events`, and protect the SQLite directory.
|
|
158
|
+
|
|
159
|
+
The database is not encrypted by the application. Use encrypted storage when messages require encryption at rest. Rotate a disclosed token and reconnect affected agents. Never expose the hub directly to the public internet.
|
|
160
|
+
|
|
161
|
+
## Capacity and failure behavior
|
|
162
|
+
|
|
163
|
+
The service uses one Node.js process, long-lived SSE connections, and one SQLite writer. Measure concurrent agents, request rate, event-loop delay, database size, disk latency, and reconnect frequency for your workload. The in-memory rate-limit ledger resets after process restart.
|
|
164
|
+
|
|
165
|
+
| Failure | Behavior | Recovery |
|
|
166
|
+
|---|---|---|
|
|
167
|
+
| Agent exits | Marked offline after the stale threshold | Restart with the same name to resume its ID |
|
|
168
|
+
| SSE drops | Client reconnects while heartbeats continue | Check network and proxy buffering if repeated |
|
|
169
|
+
| Hub or worker exits | SQLite keeps agents and messages; session binding manifests keep the active Pi scope | Restart; agents reconnect and queued or delivered work replays by the same message ID in the bound Pi session |
|
|
170
|
+
| Token rotates | Requests fail authentication | Restart agents with the new project token |
|
|
171
|
+
| Disk unavailable | Readiness or writes fail | Restore storage, then verify database integrity and readiness |
|
|
172
|
+
| Duplicate live name | Registration returns HTTP 409 | Stop the old session or choose another name |
|
|
173
|
+
| External callback is lost | Run stays `waiting` until its deadline | Retry with the same delivery ID or investigate the provider before timeout |
|
|
174
|
+
| External wait expires | Run and active stage fail; journal records the timeout and the coordinator receives a terminal notification | Fix delivery/routing, review side effects, then start a new safe workflow delivery |
|
|
175
|
+
| Pi executable cannot spawn | Worker records the process error and applies its normal restart/backoff limit | Repair `PATH` or `KXM_PI_COMMAND`; confirm the worker exits nonzero when retries are exhausted |
|
|
176
|
+
| Session binding manifest is corrupt | Worker quarantines it and starts the stable default binding without trusting a guessed run | Inspect `worker_session_state_recovered`, the `.corrupt-*` manifest, `kxm.db`, and workflow journal; re-drive unfinished work from durable message IDs |
|
|
177
|
+
| Session route request is rejected | Candidate remains queued; wrong-scope acknowledgement never occurs | Check worker generation, active scope, canonical run ID, state-directory permissions, and repeated `worker_session_request_rejected` logs |
|
|
178
|
+
|
|
179
|
+
Durable transport does not make peer execution exactly once. Use idempotent tasks and stable message idempotency keys, and store important artifacts in Git or another system of record.
|
|
180
|
+
|
|
181
|
+
## Remaining scale boundaries
|
|
182
|
+
|
|
183
|
+
Broader deployments need shared state and coordination, external identity and fine-grained authorization, distributed traffic controls, defined service-level objectives, load and chaos testing, and a formal long-term schema migration strategy.
|
|
184
|
+
|
|
185
|
+
## v0.5 context/state storage
|
|
186
|
+
|
|
187
|
+
The hub database (schema version 3) carries `context_items` alongside
|
|
188
|
+
agents, messages, workflow runs, and the journal. Temporal state, knowledge
|
|
189
|
+
records, and their audit trails live in the same SQLite file and upgrade in
|
|
190
|
+
place from v0.4 databases.
|
|
191
|
+
|
|
192
|
+
- **Backup and restore**: include the hub database file and, if used, the
|
|
193
|
+
`.kxm/skills/` and `.kxm/knowledge/` trees. The wiki is a compiled view and
|
|
194
|
+
can be regenerated (`kxm context wiki-compile`); skills history and state
|
|
195
|
+
records are authoritative and must be backed up.
|
|
196
|
+
- **Recovery after restart**: runs, journal entries, transitions, captured
|
|
197
|
+
oracles, and plan hashes reload from SQLite; temporal `asOf` queries are
|
|
198
|
+
deterministic against the restored validity windows.
|
|
199
|
+
- **Project isolation**: context/state/skill operations are project-scoped.
|
|
200
|
+
Agents authenticate to their own project; administrative operations require
|
|
201
|
+
the hub token. Cross-project context requests fail closed
|
|
202
|
+
(`context_isolation_violation`).
|
|
203
|
+
- **Rollback**: schema downgrades are not supported (a newer database refuses
|
|
204
|
+
to open on an older runtime). Restore a database backup taken before the
|
|
205
|
+
upgrade instead.
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Peer provenance and quorum gates
|
|
2
|
+
|
|
3
|
+
Peer provenance gates let a workflow require replies from a named, snapshotted
|
|
4
|
+
set of agents before a stage can pass. The hub—not the coordinator—derives the
|
|
5
|
+
producer identity, reply status, workflow scope, and content hashes from the
|
|
6
|
+
durable message record.
|
|
7
|
+
|
|
8
|
+
Use this feature when a gate means “two eligible reviewers replied for this
|
|
9
|
+
exact review attempt.” Do not describe it as proof that the reviews are true,
|
|
10
|
+
independent, high quality, or free from collusion.
|
|
11
|
+
|
|
12
|
+
## What is bound and verified
|
|
13
|
+
|
|
14
|
+
At workflow start, every `eligibleAgents` selector is resolved to a durable
|
|
15
|
+
agent ID and name. The resolved set is copied into the run. The start fails
|
|
16
|
+
closed if an agent is unknown, the coordinator is selected, or fewer unique
|
|
17
|
+
agents resolve than `minProducers` requires.
|
|
18
|
+
|
|
19
|
+
For a peer request to count, the assigned coordinator must send it to an
|
|
20
|
+
eligible producer with an exact `workflowContext`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"runId": "run_123",
|
|
25
|
+
"stageId": "review",
|
|
26
|
+
"requirementKey": "independent peer reviews",
|
|
27
|
+
"attempt": 1
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The hub authorizes the context against the current run, active stage, canonical
|
|
32
|
+
requirement key, 1-based attempt, coordinator identity, project, and target.
|
|
33
|
+
It stores the canonical `pi-mesh.workflow-message-context.v1` context and binds
|
|
34
|
+
the message correlation ID to the run. A caller cannot turn an ordinary or old
|
|
35
|
+
message into workflow evidence by choosing an idempotency prefix or correlation
|
|
36
|
+
ID.
|
|
37
|
+
|
|
38
|
+
At checkpoint or wait, the coordinator cites message IDs rather than describing
|
|
39
|
+
the replies itself:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"evidenceRefs": {
|
|
44
|
+
"independent peer reviews": {
|
|
45
|
+
"messageIds": ["msg_reviewer_a", "msg_reviewer_b"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The hub accepts only durable `replied` messages with non-empty replies, coherent
|
|
52
|
+
timestamps, the exact immutable context, the same project and coordinator, an
|
|
53
|
+
eligible producer, and the run correlation ID. Quorum counts unique stable
|
|
54
|
+
producer IDs, not messages. Duplicate replies from one producer still count as
|
|
55
|
+
one producer. Missing, pending, cancelled, expired, wrong-attempt, cross-run,
|
|
56
|
+
cross-stage, cross-project, coordinator-authored, and ineligible messages fail
|
|
57
|
+
closed.
|
|
58
|
+
|
|
59
|
+
After verification, the run stores a metadata-only snapshot containing:
|
|
60
|
+
|
|
61
|
+
- message ID and stable producer ID/name;
|
|
62
|
+
- exact run, stage, requirement, and attempt context;
|
|
63
|
+
- `replied` status and lifecycle timestamps;
|
|
64
|
+
- SHA-256 hashes of the request and reply;
|
|
65
|
+
- the verification timestamp.
|
|
66
|
+
|
|
67
|
+
The snapshot contains no request or reply body. It remains with the workflow
|
|
68
|
+
run after the source message reaches the terminal-message retention limit and
|
|
69
|
+
is purged. The hashes show which content the hub observed during verification;
|
|
70
|
+
they do not reveal the content or prove its correctness.
|
|
71
|
+
|
|
72
|
+
Retrospective quorum summaries are attempt-specific. For a passed or failed
|
|
73
|
+
stage they report the terminal attempt; for an active stage they report the
|
|
74
|
+
current attempt. Stored references from an earlier retry never inflate the
|
|
75
|
+
applied producer count.
|
|
76
|
+
|
|
77
|
+
## Configure a policy
|
|
78
|
+
|
|
79
|
+
`evidencePolicies` keys must match canonical entries in `requiredEvidence`.
|
|
80
|
+
Only the `peer-reply` policy and `replied` status are currently supported.
|
|
81
|
+
|
|
82
|
+
| Field | Constraint |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `kind` | Exact value `peer-reply` |
|
|
85
|
+
| `minProducers` | Integer from 1 through 8 and no greater than the selector count |
|
|
86
|
+
| `eligibleAgents` | 1–16 non-empty, case-insensitively unique names or IDs |
|
|
87
|
+
| `acceptedStatuses` | Exact array `["replied"]`; omission uses the same value |
|
|
88
|
+
| `degradation.minProducers` | Optional integer at least 1 and lower than `minProducers` |
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"id": "review",
|
|
93
|
+
"label": "Independent review",
|
|
94
|
+
"instructions": "Collect independent reviews, resolve contradictions, and record the decision.",
|
|
95
|
+
"requiredEvidence": [
|
|
96
|
+
"independent peer reviews",
|
|
97
|
+
"coordinator decision"
|
|
98
|
+
],
|
|
99
|
+
"evidencePolicies": {
|
|
100
|
+
"independent peer reviews": {
|
|
101
|
+
"kind": "peer-reply",
|
|
102
|
+
"minProducers": 2,
|
|
103
|
+
"eligibleAgents": ["reviewer-claude", "reviewer-grok"],
|
|
104
|
+
"acceptedStatuses": ["replied"],
|
|
105
|
+
"degradation": {
|
|
106
|
+
"minProducers": 1
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"maxAttempts": 3,
|
|
111
|
+
"area": "gates"
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Register the coordinator and every eligible peer at least once before starting
|
|
116
|
+
the workflow. Names are resolved once at run creation; later configuration edits
|
|
117
|
+
do not rewrite an active run's eligible-producer snapshot.
|
|
118
|
+
|
|
119
|
+
The complete command-first example is
|
|
120
|
+
[`examples/provenance-workflow.json`](../examples/provenance-workflow.json).
|
|
121
|
+
It uses project `provenance-demo`, coordinator `coordinator`, and the two
|
|
122
|
+
eligible reviewers `reviewer-claude` and `reviewer-grok`.
|
|
123
|
+
|
|
124
|
+
## Execute a strict quorum
|
|
125
|
+
|
|
126
|
+
Start with separate project and administrative credentials:
|
|
127
|
+
|
|
128
|
+
```powershell
|
|
129
|
+
$env:KXM_AUTH_TOKEN = "replace-with-the-admin-token"
|
|
130
|
+
$env:KXM_PROJECT_TOKENS = '{"provenance-demo":"replace-with-the-project-token"}'
|
|
131
|
+
$env:KXM_WEBHOOK_WORKFLOWS_FILE = "examples/provenance-workflow.json"
|
|
132
|
+
kxm hub start
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Give the coordinator and peer workers only the project token. Start all three
|
|
136
|
+
before starting the workflow:
|
|
137
|
+
|
|
138
|
+
```powershell
|
|
139
|
+
$env:KXM_AUTH_TOKEN = "replace-with-the-project-token"
|
|
140
|
+
kxm agent worker --name coordinator --project provenance-demo --session-isolation workflow
|
|
141
|
+
kxm agent worker --name reviewer-claude --project provenance-demo --model anthropic/claude-opus-4-6 --session-isolation workflow
|
|
142
|
+
kxm agent worker --name reviewer-grok --project provenance-demo --model xai/grok-4.6 --session-isolation workflow
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
In an operator terminal, supply the workflow-start secret and create a run:
|
|
146
|
+
|
|
147
|
+
```powershell
|
|
148
|
+
$env:KXM_WORKFLOW_SECRET = "replace-with-the-workflow-start-secret"
|
|
149
|
+
kxm gate validate --file examples/provenance-workflow.json
|
|
150
|
+
kxm workflow start provenance-review --payload '{"task":{"id":"DEMO-1","summary":"Review the proposed change"}}'
|
|
151
|
+
kxm workflow list
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The coordinator gets the run ID in its durable prompt. It should read the run,
|
|
155
|
+
calculate the current attempt as `stage.attempts + 1`, and fan out with one
|
|
156
|
+
shared context:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"targets": ["reviewer-claude", "reviewer-grok"],
|
|
161
|
+
"content": "Review this change independently. Return findings with evidence.",
|
|
162
|
+
"idempotencyKeyPrefix": "review-attempt-1",
|
|
163
|
+
"workflowContext": {
|
|
164
|
+
"runId": "run_123",
|
|
165
|
+
"stageId": "review",
|
|
166
|
+
"requirementKey": "independent peer reviews",
|
|
167
|
+
"attempt": 1
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`idempotencyKeyPrefix` makes an exact transport retry safe; it does not create
|
|
173
|
+
provenance. After both results are `replied`, checkpoint with their returned
|
|
174
|
+
message IDs and ordinary evidence for the non-peer requirement:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"runId": "run_123",
|
|
179
|
+
"stageId": "review",
|
|
180
|
+
"status": "passed",
|
|
181
|
+
"summary": "Compared both reviews and resolved the material contradiction.",
|
|
182
|
+
"evidence": {
|
|
183
|
+
"coordinator decision": "decision:docs/review-decision.md"
|
|
184
|
+
},
|
|
185
|
+
"evidenceRefs": {
|
|
186
|
+
"independent peer reviews": {
|
|
187
|
+
"messageIds": ["msg_reviewer_a", "msg_reviewer_b"]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Caller-authored `evidence` strings never satisfy a requirement that declares a
|
|
194
|
+
peer policy. `warning` and `failed` checkpoints cannot submit `evidenceRefs`.
|
|
195
|
+
After either result consumes an attempt, send fresh peer requests with the new
|
|
196
|
+
attempt number; old references cannot satisfy the retry.
|
|
197
|
+
|
|
198
|
+
## Degrade only through an explicit admin decision
|
|
199
|
+
|
|
200
|
+
Degradation is optional and must be declared in the policy before the run
|
|
201
|
+
starts. A peer, coordinator, webhook, and signed callback cannot approve it.
|
|
202
|
+
Only the administrative bearer token can approve the configured lower minimum,
|
|
203
|
+
and only for the current run, active stage, exact requirement, and current
|
|
204
|
+
attempt.
|
|
205
|
+
|
|
206
|
+
Inspect the requested action, then approve it with a non-secret reason:
|
|
207
|
+
|
|
208
|
+
```powershell
|
|
209
|
+
$env:KXM_AUTH_TOKEN = "replace-with-the-admin-token"
|
|
210
|
+
kxm gate --dry-run --json degrade run_123 review `
|
|
211
|
+
--requirement "independent peer reviews" `
|
|
212
|
+
--reason "reviewer-grok provider outage incident-482"
|
|
213
|
+
kxm gate degrade run_123 review `
|
|
214
|
+
--requirement "independent peer reviews" `
|
|
215
|
+
--reason "reviewer-grok provider outage incident-482"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Approval does not pass the stage. The coordinator must still submit enough
|
|
219
|
+
verified replies to meet the approved minimum. Repeating the same approval and
|
|
220
|
+
reason is idempotent; changing the reason conflicts. The approval cannot be
|
|
221
|
+
reused by a later attempt.
|
|
222
|
+
|
|
223
|
+
A passed degraded stage is marked as degraded. Its retrospective contains the
|
|
224
|
+
configured and effective minima, eligible-producer snapshot, verified message
|
|
225
|
+
metadata, hashes, timestamps, and the explicit admin approval. Export it with:
|
|
226
|
+
|
|
227
|
+
```powershell
|
|
228
|
+
kxm workflow export run_123
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The JSON keeps the existing `pi-mesh.retrospective.v1` schema and adds optional
|
|
232
|
+
`evidenceAudit` and `degradedStageIds` fields. Consumers that do not know these
|
|
233
|
+
fields can continue reading the v1 document.
|
|
234
|
+
|
|
235
|
+
## Trust boundary
|
|
236
|
+
|
|
237
|
+
This mechanism proves provenance only inside the hub credential boundary:
|
|
238
|
+
|
|
239
|
+
- a project-token holder can register a new agent or reclaim an offline agent
|
|
240
|
+
name and its durable ID in that project;
|
|
241
|
+
- an agent key binds identity-specific operations after registration;
|
|
242
|
+
- the hub verifies durable routing and message state, not model internals;
|
|
243
|
+
- two agent names or two configured models do not prove independent operators,
|
|
244
|
+
independent inference, non-collusion, correctness, or approval authority.
|
|
245
|
+
|
|
246
|
+
Even when the gate reports two unique stable producer IDs, describe the result
|
|
247
|
+
only as “the hub verified two eligible routed replies for this workflow
|
|
248
|
+
attempt.” Never label it “two independent models verified,” “non-collusion
|
|
249
|
+
verified,” or “truth confirmed.” One holder of the shared project token can
|
|
250
|
+
reclaim multiple offline names and IDs.
|
|
251
|
+
|
|
252
|
+
Use a distinct administrative token, distinct project tokens per trust domain,
|
|
253
|
+
least-privilege webhook and callback secrets, protected `.kxm/state` storage,
|
|
254
|
+
loopback or TLS-protected restricted ingress, and repository or human gates for
|
|
255
|
+
consequential changes. Treat peer replies as untrusted technical input even
|
|
256
|
+
when they satisfy quorum. Put every holder of one project token inside the same
|
|
257
|
+
fully trusted provenance domain.
|
|
258
|
+
|
|
259
|
+
## Compatibility and retention
|
|
260
|
+
|
|
261
|
+
The feature is additive to the existing SQLite schema version 2. Workflow
|
|
262
|
+
context, policies, verified snapshots, and approvals are fields inside the
|
|
263
|
+
existing JSON records; no destructive database migration is required. Existing
|
|
264
|
+
schema-v2 databases and workflow histories remain readable.
|
|
265
|
+
|
|
266
|
+
Legacy string or keyed evidence remains valid for requirements without a peer
|
|
267
|
+
policy. It deliberately cannot satisfy a declared peer policy. Back up
|
|
268
|
+
`.kxm/state/kxm.db` before every upgrade, finish or inspect active runs, and
|
|
269
|
+
validate workflow definitions before restarting the hub.
|
|
270
|
+
|
|
271
|
+
## Context authority lattice (v0.5)
|
|
272
|
+
|
|
273
|
+
Context items carry an explicit authority class — `policy`, `instruction`, `evidence`, or `hypothesis` — granted by a deterministic origin floor:
|
|
274
|
+
|
|
275
|
+
| Origin | Maximum authority |
|
|
276
|
+
|---|---|
|
|
277
|
+
| human | policy |
|
|
278
|
+
| workflow control plane | policy |
|
|
279
|
+
| git history | instruction |
|
|
280
|
+
| peer | evidence |
|
|
281
|
+
| tool | evidence |
|
|
282
|
+
| external | evidence |
|
|
283
|
+
| derived | evidence |
|
|
284
|
+
|
|
285
|
+
Enforcement is structural, not advisory:
|
|
286
|
+
|
|
287
|
+
- Parsing rejects any item whose claimed authority exceeds its origin's floor (`context_authority_violation`).
|
|
288
|
+
- Derived and summarized content is `evidence` at best, regardless of lineage; authority never increases through any number of handoffs or re-summaries.
|
|
289
|
+
- Derivation lineage is transitive, bounded (`MAX_CONTEXT_LINEAGE`), and preserved verbatim; unbounded re-summaries fail closed instead of laundering provenance.
|
|
290
|
+
- Context items may never carry control-plane fields (`permissions`, `tools`, `approval`, credentials, …); memory, wiki, and skill content can inform behavior but never expand tool permissions or approval scope.
|
|
291
|
+
- Superseded and rejected records are excluded from summarization lineage: dead records are not evidence of current truth.
|
package/docs/skills.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Skill candidate lifecycle
|
|
2
|
+
|
|
3
|
+
KXM turns verified episodes and lessons into reusable Agent Skills through a governed lifecycle. Runtime experience never becomes promoted skill content automatically, and promoted skills never grant tool or permission authority.
|
|
4
|
+
|
|
5
|
+
## Lifecycle
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
verified episode(s) → skill candidate → static/provenance review
|
|
9
|
+
→ sandbox execution → protected functional + safety eval
|
|
10
|
+
→ promote / quarantine / reject
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Storage
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
.kxm/skills/
|
|
17
|
+
├── candidates/<id>/SKILL.md + metadata.json
|
|
18
|
+
├── promoted/<id>/SKILL.md + metadata.json
|
|
19
|
+
├── quarantined/<id>/SKILL.md + metadata.json
|
|
20
|
+
└── history/<id>.jsonl
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Skill IDs are content-addressed (`<slug>.<hash-prefix>`): changed behavior means changed content means a new candidate. Identical resubmissions are rejected as duplicates.
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
- A candidate must cite at least one source run, journal entry, or evidence receipt.
|
|
28
|
+
- Candidate metadata records explicit cross-model/cross-harness compatibility (`harness`, `models`).
|
|
29
|
+
- Promotion requires passing `static-review`, `sandbox`, `functional`, and `safety` evaluations, durable evidence references, and a decision by someone other than the author.
|
|
30
|
+
- A failed functional or safety evaluation quarantines the candidate automatically; the evaluator records the decision and a human may later reject fully.
|
|
31
|
+
- Rejected and quarantined candidates remain queryable in `history/` for future learning.
|
|
32
|
+
- Promoted skills are hash-pinned and immutable: `kxm skills verify` detects out-of-band edits (`skill_integrity_violation`), and behavior changes require a new candidate/eval cycle (optionally `supersedes`-linked).
|
|
33
|
+
- Skill content is redacted of secret material at creation; evaluation details are redacted and bounded.
|
|
34
|
+
- Optimization evaluations (skillopt/WikiSkill-style) are a gated hook, disabled unless explicitly enabled.
|
|
35
|
+
|
|
36
|
+
## CLI
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
kxm skills create --file SKILL.md --name <name> --created-by <id> --harness pi --models <models> --run <ids> --journal <ids>
|
|
40
|
+
kxm skills evaluate <id> --kind static-review|sandbox|functional|safety --evaluator <version> [--fail]
|
|
41
|
+
kxm skills promote <id> --decided-by <id> --evidence <refs>
|
|
42
|
+
kxm skills reject <id> --decided-by <id>
|
|
43
|
+
kxm skills list --state candidate|promoted|quarantined|rejected
|
|
44
|
+
kxm skills verify <id> --state promoted
|
|
45
|
+
```
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# KXM Documentation Templates & Workflow Integration Guide
|
|
2
|
+
|
|
3
|
+
This directory contains standardized Markdown documentation templates adapted for KXM multi-agent orchestration, the 5-layer memory architecture, and the workflow taxonomy defined in [`docs/workflow-guide.md`](../workflow-guide.md).
|
|
4
|
+
|
|
5
|
+
## Core Principles
|
|
6
|
+
|
|
7
|
+
1. **Markdown + YAML Frontmatter + Mermaid:** Standardized metadata for automated indexing by the Context Arbiter, paired with human-readable text and conservative Mermaid diagrams.
|
|
8
|
+
|
|
9
|
+
2. **Separation of Concerns:** Keep **what should happen** (Feature / Architecture / Test Plan), **what was decided** (ADR), and **what actually happened** (Test Report / Witness Receipt / Postmortem) distinct.
|
|
10
|
+
|
|
11
|
+
3. **Immutable Evidence Chains:** Every test or review report must reference an exact commit pin (`git rev-parse HEAD`), deterministic branch (`kxm/run-<id>-<description>`), and content-addressed artifact reference (`artifact:<path>@sha256:<digest>`).
|
|
12
|
+
|
|
13
|
+
4. **Context Arbiter Integration:** Frontmatter fields (`authority`, `confidence`, `summary`, `tags`) directly inform token budgeting and relevance pruning in `kxm.context-packet.v2`.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Template Directory
|
|
18
|
+
|
|
19
|
+
| Template | File | Primary Workflow Stage | Key Outputs |
|
|
20
|
+
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| **Feature Specification** | [`feature.md`](feature.md) | Stage 1: Requirements & Scope | Observable behavior, acceptance criteria table, user flow diagram. |
|
|
23
|
+
|
|
24
|
+
| **Research Brief** | [`research.md`](research.md) | Stage 1: Discovery & Spike | Falsifiable hypotheses, evidence register, option comparison matrix. |
|
|
25
|
+
| **Bug Investigation & Fix** | [`bug-fix.md`](bug-fix.md) | Stages 1–3: Repro, Fix, Verify | Repro before oracle, sequenceDiagram, exact test command, before/after evidence. |
|
|
26
|
+
|
|
27
|
+
| **Architecture Design** | [`architecture.md`](architecture.md) | Stage 1: Architecture & System Design | Trust boundaries, component ownership, runtime scenarios, failure modes. |
|
|
28
|
+
| **Architecture Decision Record (ADR)** | [`adr.md`](adr.md) | Ongoing: Technical Decisions | Decision drivers, considered options with pros/cons, consequences, revisit triggers. |
|
|
29
|
+
|
|
30
|
+
| **Test Plan** | [`test-plan.md`](test-plan.md) | Stage 2: Verification Design | Risk-to-coverage matrix, test cases, environment prerequisites, entry/exit criteria. |
|
|
31
|
+
| **Test Execution Report** | [`test-report.md`](test-report.md) | Stage 3: Witness Verification | Exact build/commit, execution timestamps, case outcomes, coverage diff. |
|
|
32
|
+
|
|
33
|
+
| **Dual-Critic Review Report** | [`review.md`](review.md) | Stage 4: Critic Quorum | Independent Fable (arch) and Astra/Sol (CLI) findings, severity, quorum verdict. |
|
|
34
|
+
| **Structured Handoff Manifest** | [`handoff.md`](handoff.md) | Inter-stage transitions | `kxm.handoff-manifest.v1` mapping, baseCommit, candidateTreeHash, deliverables. |
|
|
35
|
+
|
|
36
|
+
| **Operational Runbook** | [`runbook.md`](runbook.md) | Reliability & Ops | Diagnosis steps, safe mitigation commands, rollback triggers, escalation paths. |
|
|
37
|
+
| **Incident Postmortem** | [`postmortem.md`](postmortem.md) | Post-incident Retrospective | Timeline of events, root cause analysis, preventive action items. |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Workflow Guide Integration Matrix
|
|
42
|
+
|
|
43
|
+
The 12 templates map directly across the 7 Areas and 22 Workflows in [`docs/workflow-guide.md`](../workflow-guide.md):
|
|
44
|
+
|
|
45
|
+
```mermaid
|
|
46
|
+
flowchart TD
|
|
47
|
+
subgraph PlanStage ["1. Planning & Design"]
|
|
48
|
+
F["feature.md"]
|
|
49
|
+
R["research.md"]
|
|
50
|
+
A["architecture.md"]
|
|
51
|
+
ADR["adr.md"]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
subgraph ExecStage ["2. Implementation & Testing"]
|
|
55
|
+
B["bug-fix.md"]
|
|
56
|
+
TP["test-plan.md"]
|
|
57
|
+
H1["handoff.md (Plan -> Write)"]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
subgraph VerifyStage ["3. Verification & Review"]
|
|
61
|
+
TR["test-report.md (Witness)"]
|
|
62
|
+
REV["review.md (Dual Critics)"]
|
|
63
|
+
H2["handoff.md (Write -> Critic)"]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
subgraph OpsStage ["4. Operations & Maintenance"]
|
|
67
|
+
RB["runbook.md"]
|
|
68
|
+
PM["postmortem.md"]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
PlanStage --> ExecStage
|
|
72
|
+
ExecStage --> VerifyStage
|
|
73
|
+
VerifyStage --> OpsStage
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Mapping by Area
|
|
78
|
+
|
|
79
|
+
1. **Software Engineering (`software-engineering`)**
|
|
80
|
+
- `feature-delivery`: [`feature.md`](feature.md) $\rightarrow$ [`architecture.md`](architecture.md) $\rightarrow$ [`test-plan.md`](test-plan.md) $\rightarrow$ [`review.md`](review.md).
|
|
81
|
+
- `bug-investigation`: [`bug-fix.md`](bug-fix.md) with mandatory reproduction test before oracle.
|
|
82
|
+
- `refactoring-migration`: [`architecture.md`](architecture.md) + [`adr.md`](adr.md) + [`test-report.md`](test-report.md).
|
|
83
|
+
|
|
84
|
+
2. **Design & Experience (`design-experience`)**
|
|
85
|
+
- `ui-ux-design-system`: [`feature.md`](feature.md) (user flows) + [`review.md`](review.md) (a11y audits).
|
|
86
|
+
|
|
87
|
+
3. **Data & Analytics (`data-analytics`)**
|
|
88
|
+
- `data-pipeline-etl`: [`architecture.md`](architecture.md) (data flows, contracts) + [`runbook.md`](runbook.md).
|
|
89
|
+
|
|
90
|
+
4. **Research & Strategy (`research-strategy`)**
|
|
91
|
+
- `technology-evaluation` / `market-research`: [`research.md`](research.md) with evidence registers and confidence bounds.
|
|
92
|
+
|
|
93
|
+
5. **Security & Reliability (`security-reliability`)**
|
|
94
|
+
- `vulnerability-audit`: [`review.md`](review.md) (threat model) + [`bug-fix.md`](bug-fix.md).
|
|
95
|
+
- `incident-response`: [`runbook.md`](runbook.md) (triage/mitigation) $\rightarrow$ [`postmortem.md`](postmortem.md) (blameless retrospective).
|