@kontextmind/kxm 0.7.94 → 0.7.96

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 (140) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.kxm/README.md +39 -9
  3. package/CHANGELOG.md +1 -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 +152 -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 +364 -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 +265 -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} +83 -41
  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/package.json +2 -2
  88. package/packages/core/tui/README.md +1 -1
  89. package/plugins/kxm/.claude-plugin/plugin.json +1 -1
  90. package/plugins/kxm/README.md +31 -32
  91. package/plugins/kxm/dist/cli.js +5 -5
  92. package/plugins/kxm/dist/mcp-server.js +1 -1
  93. package/plugins/kxm/dist/runtime.js +1 -1
  94. package/plugins/kxm/package.json +1 -1
  95. package/plugins/kxm/skills/kxm/references/protocol.md +3 -1
  96. package/plugins/kxm/skills/kxm-browser-auth/SKILL.md +1 -1
  97. package/plugins/kxm/skills/kxm-browser-diagnostics/SKILL.md +5 -5
  98. package/plugins/kxm/skills/kxm-browser-explore/SKILL.md +2 -2
  99. package/plugins/kxm/skills/kxm-browser-session/SKILL.md +10 -13
  100. package/plugins/kxm/skills/kxm-browser-takeover/SKILL.md +1 -1
  101. package/plugins/kxm/skills/kxm-browser-verify/SKILL.md +1 -1
  102. package/plugins/kxm/skills/kxm-context-memory/SKILL.md +13 -4
  103. package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +3 -1
  104. package/plugins/kxm/skills/kxm-mind-setup/SKILL.md +2 -1
  105. package/plugins/kxm/skills/kxm-project-setup/SKILL.md +31 -54
  106. package/plugins/kxm/skills/kxm-projects/SKILL.md +1 -1
  107. package/plugins/kxm/skills/kxm-protocol/SKILL.md +1 -1
  108. package/plugins/kxm/skills/kxm-routing-improve/SKILL.md +15 -7
  109. package/plugins/kxm/skills/kxm-runs/SKILL.md +11 -5
  110. package/plugins/kxm/skills/kxm-session/SKILL.md +1 -1
  111. package/plugins/kxm/skills/kxm-tasks/SKILL.md +9 -7
  112. package/plugins/kxm/skills/kxm-workflow/SKILL.md +10 -2
  113. package/plugins/kxm/src/cli/system.ts +1 -1
  114. package/plugins/kxm/src/cli.ts +3 -3
  115. package/plugins/kxm/src/init-guide-setup.ts +1 -1
  116. package/plugins/kxm/src/mcp-server.ts +1 -1
  117. package/plugins/kxm/src/modes.ts +1 -1
  118. package/schemas/README.md +1 -1
  119. package/docs/agent-communication-envelopes-and-gates.md +0 -553
  120. package/docs/agent-skills.md +0 -198
  121. package/docs/architecture.md +0 -245
  122. package/docs/assignment-runner.md +0 -264
  123. package/docs/browser-automation.md +0 -139
  124. package/docs/configuration.md +0 -437
  125. package/docs/continuous-improvement.md +0 -226
  126. package/docs/getting-started.md +0 -277
  127. package/docs/harness-routing.md +0 -616
  128. package/docs/kb/qa-authentik-authentication.md +0 -97
  129. package/docs/kb/qa-extension-install-and-hub-bootstrap.md +0 -85
  130. package/docs/kb/qa-hub-on-a-public-host.md +0 -48
  131. package/docs/kb/qa-sqlite-vs-duckdb.md +0 -35
  132. package/docs/kb/qa-what-the-hub-stores.md +0 -64
  133. package/docs/kxm-handbook.md +0 -1181
  134. package/docs/operations.md +0 -510
  135. package/docs/operator-pi-packages.md +0 -67
  136. package/docs/provenance-gates.md +0 -295
  137. package/docs/skills.md +0 -47
  138. package/docs/test-matrix.md +0 -132
  139. package/docs/troubleshooting.md +0 -293
  140. package/docs/webhook-workflows.md +0 -240
@@ -0,0 +1,313 @@
1
+ # Peer provenance and quorum gates
2
+
3
+ Peer provenance gates let a [webhook workflow](webhook-workflows.md) require replies from a named, snapshotted set of agents before a stage can pass. The hub, not the coordinator, derives the producer identity, reply status, workflow scope, and content hashes from its own durable message records. Use this feature when a gate means "two eligible reviewers replied for this exact review attempt", never as proof that the reviews are true, independent, high quality, or free from collusion.
4
+
5
+ ## Before you begin
6
+
7
+ - A hub that loads webhook workflow definitions, as described in [Run webhook workflows](webhook-workflows.md).
8
+ - A coordinator and every eligible peer connected to the same hub project, for example as [supervised Pi workers](pi-workers.md).
9
+ - The hub's admin token, only if you plan to approve a degraded quorum.
10
+
11
+ ## How a quorum gate works
12
+
13
+ The coordinator asks eligible peers through the hub with a workflow context, and the hub checks every cited reply before it counts unique producers.
14
+
15
+ ```mermaid
16
+ sequenceDiagram
17
+ participant C as Coordinator
18
+ participant Hub as KXM hub
19
+ participant A as reviewer-claude
20
+ participant B as reviewer-grok
21
+ participant Op as Operator (admin token)
22
+ C->>Hub: kxm_fanout with workflowContext
23
+ Hub->>Hub: authorize run, stage, requirement, attempt
24
+ Hub->>A: bound request
25
+ Hub->>B: bound request
26
+ A->>Hub: reply
27
+ B->>Hub: reply
28
+ C->>Hub: kxm_workflow_checkpoint with evidenceRefs
29
+ Hub->>Hub: verify producer, context, attempt, replied status
30
+ alt unique producers reach minProducers
31
+ Hub-->>C: stage passes
32
+ else too few producers and the policy allows degradation
33
+ Op->>Hub: kxm gate degrade for this attempt only
34
+ C->>Hub: checkpoint again with the verified replies
35
+ Hub-->>C: stage passes, marked degraded
36
+ end
37
+ ```
38
+
39
+ ## What is bound and verified
40
+
41
+ At workflow start, every `eligibleAgents` selector is resolved to a durable agent ID and name, and the resolved set is copied into the run. The start fails closed if an agent is unknown, a selector resolves to the coordinator, or fewer unique agents resolve than `minProducers` requires.
42
+
43
+ For a peer request to count, the assigned coordinator must send it to an eligible producer with an exact `workflowContext`:
44
+
45
+ ```json
46
+ {
47
+ "runId": "<run-id>",
48
+ "stageId": "review",
49
+ "requirementKey": "independent peer reviews",
50
+ "attempt": 1
51
+ }
52
+ ```
53
+
54
+ The hub authorizes the context against the current run, active stage, canonical requirement key, 1-based attempt, coordinator identity, project, and target. It stores the canonical context and binds the message's correlation ID to the run. A caller cannot turn an ordinary or old message into workflow evidence by choosing an idempotency prefix or correlation ID.
55
+
56
+ At checkpoint or wait, the coordinator cites message IDs instead of describing the replies itself:
57
+
58
+ ```json
59
+ {
60
+ "evidenceRefs": {
61
+ "independent peer reviews": {
62
+ "messageIds": ["<reviewer-a-message-id>", "<reviewer-b-message-id>"]
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ The hub accepts only durable `replied` messages with non-empty replies, coherent timestamps, the exact immutable context, the same project and coordinator, an eligible producer, and the run's correlation ID. Each reference accepts 1 to 16 message IDs. [Quorum](../glossary.md#quorum) counts unique stable producer IDs, not messages, so duplicate replies from one producer count once. Missing, pending, cancelled, expired, wrong-attempt, cross-run, cross-stage, cross-project, coordinator-authored, and ineligible messages fail closed.
69
+
70
+ After verification, the run stores a metadata-only snapshot containing:
71
+
72
+ - the message ID and the stable producer ID and name;
73
+ - the exact run, stage, requirement, and attempt context;
74
+ - the `replied` status and lifecycle timestamps;
75
+ - SHA-256 hashes of the request and the reply;
76
+ - the verification timestamp.
77
+
78
+ The snapshot contains no request or reply body. It stays with the workflow run after the source message passes the terminal-message retention limit and is purged. The hashes show which content the hub observed during verification; they do not reveal the content or prove it correct.
79
+
80
+ Retrospective quorum summaries are attempt-specific. For a passed or failed stage they report the terminal attempt; for an active stage they report the current attempt. Stored references from an earlier retry never inflate the applied producer count.
81
+
82
+ > [!NOTE]
83
+ > Stored records carry the schema IDs `pi-mesh.workflow-message-context.v1`, `pi-mesh.verified-peer-evidence.v1`, `pi-mesh.workflow-degradation-approval.v1`, and `pi-mesh.retrospective.v1`. These are legacy IDs kept for compatibility with existing stores and exports.
84
+
85
+ ## Configure a policy
86
+
87
+ `evidencePolicies` ([evidence policies](../glossary.md#evidence-policy)) keys must match canonical entries in `requiredEvidence`. Only the `peer-reply` policy and the `replied` status are supported.
88
+
89
+ | Field | Constraint |
90
+ |---|---|
91
+ | `kind` | Exact value `peer-reply` |
92
+ | `minProducers` | Integer from 1 through 8, and no greater than the selector count |
93
+ | `eligibleAgents` | 1 to 16 non-empty, case-insensitively unique names or IDs. Must not name the workflow's coordinator. |
94
+ | `acceptedStatuses` | Exact array `["replied"]`; omitting it uses the same value |
95
+ | `degradation.minProducers` | Optional integer, at least 1 and lower than `minProducers` |
96
+
97
+ ```json
98
+ {
99
+ "id": "review",
100
+ "label": "Independent review",
101
+ "instructions": "Collect independent reviews, resolve contradictions, and record the decision.",
102
+ "requiredEvidence": [
103
+ "independent peer reviews",
104
+ "coordinator decision"
105
+ ],
106
+ "evidencePolicies": {
107
+ "independent peer reviews": {
108
+ "kind": "peer-reply",
109
+ "minProducers": 2,
110
+ "eligibleAgents": ["reviewer-claude", "reviewer-grok"],
111
+ "acceptedStatuses": ["replied"],
112
+ "degradation": {
113
+ "minProducers": 1
114
+ }
115
+ }
116
+ },
117
+ "maxAttempts": 3,
118
+ "area": "gates"
119
+ }
120
+ ```
121
+
122
+ `kxm gate validate` rejects a policy that names the coordinator and warns when `degradation.minProducers` is below 2, because one producer could then satisfy the degraded quorum.
123
+
124
+ Register the coordinator and every eligible peer at least once before starting the workflow. Names are resolved once, at run creation; later configuration edits do not rewrite an active run's eligible-producer snapshot.
125
+
126
+ The complete command-first example is [`examples/provenance-workflow.json`](../../examples/provenance-workflow.json). It uses project `provenance-demo`, coordinator `coordinator`, and the two eligible reviewers `reviewer-claude` and `reviewer-grok`.
127
+
128
+ ## Execute a strict quorum
129
+
130
+ Run these commands from a KXM source checkout, or copy `examples/provenance-workflow.json` from the npm package. Start the hub with separate administrative and project credentials, and with the workflow-start secret that the definition names in `secretEnv`:
131
+
132
+ ```bash
133
+ export KXM_AUTH_TOKEN="replace-with-the-admin-token"
134
+ export KXM_PROJECT_TOKENS='{"provenance-demo":"replace-with-the-project-token"}'
135
+ export KXM_WORKFLOW_SECRET="replace-with-the-workflow-start-secret"
136
+ export KXM_WEBHOOK_WORKFLOWS_FILE=examples/provenance-workflow.json
137
+ kxm hub start
138
+ ```
139
+
140
+ <details><summary>PowerShell</summary>
141
+
142
+ ```powershell
143
+ $env:KXM_AUTH_TOKEN = "replace-with-the-admin-token"
144
+ $env:KXM_PROJECT_TOKENS = '{"provenance-demo":"replace-with-the-project-token"}'
145
+ $env:KXM_WORKFLOW_SECRET = "replace-with-the-workflow-start-secret"
146
+ $env:KXM_WEBHOOK_WORKFLOWS_FILE = "examples/provenance-workflow.json"
147
+ kxm hub start
148
+ ```
149
+
150
+ </details>
151
+
152
+ > [!WARNING]
153
+ > `KXM_PROJECT_TOKENS` replaces the hub's saved project-token map; it does not merge. This example starts a hub that knows only this project. On a hub that already serves other projects, build the full map with the merge command in [Set up a new project](../start/quickstart-claude-code.md#3-start-the-hub).
154
+
155
+ Give the coordinator and the peer workers only the project token, and start all three before you start the workflow. Run each worker in its own terminal:
156
+
157
+ ```bash
158
+ export KXM_AUTH_TOKEN="replace-with-the-project-token"
159
+ kxm agent worker --name coordinator --project provenance-demo --model <coordinator-model> --session-isolation workflow
160
+ kxm agent worker --name reviewer-claude --project provenance-demo --model <reviewer-a-model> --tools read,grep,find,ls --session-isolation workflow
161
+ kxm agent worker --name reviewer-grok --project provenance-demo --model <reviewer-b-model> --tools read,grep,find,ls --session-isolation workflow
162
+ ```
163
+
164
+ <details><summary>PowerShell</summary>
165
+
166
+ ```powershell
167
+ $env:KXM_AUTH_TOKEN = "replace-with-the-project-token"
168
+ kxm agent worker --name coordinator --project provenance-demo --model <coordinator-model> --session-isolation workflow
169
+ kxm agent worker --name reviewer-claude --project provenance-demo --model <reviewer-a-model> --tools read,grep,find,ls --session-isolation workflow
170
+ kxm agent worker --name reviewer-grok --project provenance-demo --model <reviewer-b-model> --tools read,grep,find,ls --session-isolation workflow
171
+ ```
172
+
173
+ </details>
174
+
175
+ > [!IMPORTANT]
176
+ > The reviewer names are labels. Choose every Pi model with [Harness routing](../reference/harness-routing.md), for example `openrouter/qwen/qwen3-coder-plus` and `openrouter/z-ai/glm-5.3-flash` for two reviewers from different vendors. A worker refuses a model whose vendor has its own native harness, such as Anthropic or xAI, with `pi_native_impersonation_blocked`. To use such a model as a reviewer, connect its native harness under the same agent name instead, for example the Claude Code plugin as `reviewer-claude`.
177
+
178
+ In an operator terminal, supply the workflow-start secret, validate the definition, and create a run:
179
+
180
+ ```bash
181
+ export KXM_WORKFLOW_SECRET="replace-with-the-workflow-start-secret"
182
+ kxm gate validate --file examples/provenance-workflow.json
183
+ kxm workflow start provenance-review --payload '{"task":{"id":"DEMO-1","summary":"Review the proposed change"}}'
184
+ kxm workflow list
185
+ ```
186
+
187
+ Expected output of the first two commands:
188
+
189
+ ```text
190
+ validated 1 workflow(s) from file with 1 warning(s)
191
+ started workflow run_1b2e4b65c6494f9fa1ddaa7ac4323335
192
+ ```
193
+
194
+ The warning is the expected one for this example's one-producer degradation floor.
195
+
196
+ The coordinator gets the run ID in its durable prompt. It reads the run, calculates the current attempt as `stage.attempts + 1`, and fans out once with one shared context:
197
+
198
+ ```json
199
+ {
200
+ "targets": ["reviewer-claude", "reviewer-grok"],
201
+ "content": "Review this change independently. Return findings with evidence.",
202
+ "idempotencyKeyPrefix": "provenance-review:<run-id>:review:1",
203
+ "workflowContext": {
204
+ "runId": "<run-id>",
205
+ "stageId": "review",
206
+ "requirementKey": "independent peer reviews",
207
+ "attempt": 1
208
+ }
209
+ }
210
+ ```
211
+
212
+ `idempotencyKeyPrefix` makes an exact transport retry safe; it does not create provenance. If the local wait ends first, the coordinator keeps the returned message IDs and follows up with `kxm_get` or `kxm_await`, or repeats the exact call; it never replaces pending work with a new prefix. After both requests are `replied`, it checkpoints with their message IDs and ordinary evidence for the non-peer requirement:
213
+
214
+ ```json
215
+ {
216
+ "runId": "<run-id>",
217
+ "stageId": "review",
218
+ "status": "passed",
219
+ "summary": "Compared both reviews and resolved the material contradiction.",
220
+ "evidence": {
221
+ "coordinator decision": "decision:docs/review-decision.md"
222
+ },
223
+ "evidenceRefs": {
224
+ "independent peer reviews": {
225
+ "messageIds": ["<reviewer-a-message-id>", "<reviewer-b-message-id>"]
226
+ }
227
+ }
228
+ }
229
+ ```
230
+
231
+ Caller-authored `evidence` strings never satisfy a requirement that declares a peer policy. `warning` and `failed` checkpoints cannot submit `evidenceRefs`. After either result consumes an attempt, send fresh peer requests with the new attempt number; old references cannot satisfy the retry.
232
+
233
+ ## Degrade only through an explicit admin decision
234
+
235
+ Degradation is optional and must be declared in the policy before the run starts. A peer, the coordinator, a webhook, and a signed callback cannot approve it. Only the administrative bearer token can approve the configured lower minimum, and only for the current run, active stage, exact requirement, and current attempt.
236
+
237
+ Inspect the requested action, then approve it with a non-secret reason:
238
+
239
+ ```bash
240
+ export KXM_AUTH_TOKEN="replace-with-the-admin-token"
241
+ kxm gate --dry-run --json degrade <run-id> review \
242
+ --requirement "independent peer reviews" \
243
+ --reason "reviewer-grok provider outage incident-482"
244
+ kxm gate degrade <run-id> review \
245
+ --requirement "independent peer reviews" \
246
+ --reason "reviewer-grok provider outage incident-482"
247
+ ```
248
+
249
+ <details><summary>PowerShell</summary>
250
+
251
+ ```powershell
252
+ $env:KXM_AUTH_TOKEN = "replace-with-the-admin-token"
253
+ kxm gate --dry-run --json degrade <run-id> review `
254
+ --requirement "independent peer reviews" `
255
+ --reason "reviewer-grok provider outage incident-482"
256
+ kxm gate degrade <run-id> review `
257
+ --requirement "independent peer reviews" `
258
+ --reason "reviewer-grok provider outage incident-482"
259
+ ```
260
+
261
+ </details>
262
+
263
+ Approval does not pass the stage. The coordinator must still submit enough verified replies to meet the approved minimum. Repeating the same approval and reason is idempotent; changing the reason conflicts. The approval cannot be reused by a later attempt.
264
+
265
+ A passed degraded stage is marked as degraded. Its retrospective contains the configured and effective minimums, the eligible-producer snapshot, verified message metadata, hashes, timestamps, and the explicit admin approval. The hub writes the retrospective when the run ends; regenerate it with:
266
+
267
+ ```bash
268
+ kxm workflow export <run-id>
269
+ ```
270
+
271
+ The JSON keeps its existing schema and adds optional `evidenceAudit` and `degradedStageIds` fields. Consumers that do not know these fields can keep reading the document.
272
+
273
+ ## Trust boundary
274
+
275
+ This mechanism proves provenance only inside the hub credential boundary:
276
+
277
+ - a project-token holder can register a new agent, or reclaim an offline agent name and its durable ID, in that project;
278
+ - an agent key binds identity-specific operations after registration;
279
+ - the hub verifies durable routing and message state, not model internals;
280
+ - two agent names or two configured models do not prove independent operators, independent inference, non-collusion, correctness, or approval authority.
281
+
282
+ Even when the gate reports two unique stable producer IDs, describe the result only as "the hub verified two eligible routed replies for this workflow attempt." Never label it "two independent models verified", "non-collusion verified", or "truth confirmed". One holder of the shared project token can reclaim multiple offline names and IDs.
283
+
284
+ Use a distinct administrative token, distinct project tokens per trust domain, least-privilege webhook and callback secrets, protected `.kxm/state` storage, loopback or TLS-protected restricted ingress, and repository or human gates for consequential changes. Treat peer replies as untrusted technical input even when they satisfy quorum, and put every holder of one project token inside the same fully trusted provenance domain. [Trust model](../concepts/trust-model.md) maps every credential.
285
+
286
+ ## Compatibility and retention
287
+
288
+ Workflow context, policies, verified snapshots, and approvals are fields inside the hub's JSON records for messages and workflow runs, so they add no tables. Older workflow histories stay readable only while the hub store keeps the same schema version: a release that changes that version refuses the old store, and KXM never migrates it (see [Upgrade KXM](../operations/upgrade.md#understand-schema-changes)).
289
+
290
+ Legacy string or keyed evidence stays valid for requirements without a peer policy. It deliberately cannot satisfy a declared peer policy. Before every upgrade, back up the hub with `kxm backup` ([Back up and restore KXM](../operations/backup-and-restore.md)), finish or inspect active runs, and validate workflow definitions before restarting the hub. A finished run, with its snapshots, is deleted 7 days after it ends, so export retrospectives you need to keep.
291
+
292
+ ## Troubleshooting
293
+
294
+ | Message | Cause | Fix |
295
+ |---|---|---|
296
+ | `workflow context is not assigned to this coordinator` | The sender is not the run's coordinator, or the run ID is wrong. | Send from the coordinator named in the definition. |
297
+ | `workflow context does not reference the active stage` | The stage is not the current one, or the run is waiting. | Use `currentStage` from `kxm_workflow_get`. |
298
+ | `workflow context attempt <n> does not match active attempt <m>` | Stale attempt number. | Use `stage.attempts + 1`. |
299
+ | `target <name> is not eligible for workflow evidence <key>` | The peer is not in the resolved eligible set. | Send only to the run's eligible producers. |
300
+ | `correlationId must match workflowContext.runId` | A different correlation ID was supplied. | Omit it, or set it to the run ID. |
301
+ | `peer evidence message <id> is not a replied message for run <run-id>` | The reply is still pending, or the message is from another run. | Wait for the reply with `kxm_get` or `kxm_await`. |
302
+ | `stage <id> is missing required evidence: <key>` | Too few unique verified producers, or only caller text was supplied. | Cite enough replied message IDs in `evidenceRefs`. |
303
+ | `requirement <key> does not permit degraded quorum` | The policy declares no `degradation`. | Change the definition for future runs; the current run cannot degrade. |
304
+ | `degradation was already approved for <key> attempt <n>` | An approval exists with a different reason. | Reuse the original reason, or leave the approval as is. |
305
+ | `invalid administrative authentication token`, or HTTP `503` | A project token was used, or the hub has no admin token configured. | Use the admin token; start the hub with `KXM_AUTH_TOKEN`. |
306
+
307
+ ## Next steps
308
+
309
+ - Build and start the workflow that holds the gate: [Run webhook workflows](webhook-workflows.md)
310
+ - Send and track the peer requests: [Message peer agents](peer-messaging.md)
311
+ - Run the coordinator and reviewers unattended: [Run supervised Pi workers](pi-workers.md)
312
+ - Every definition field: [Workflow definition reference](../reference/workflow-definitions.md)
313
+ - How authority works for context and memory: [Context and memory](context-and-memory.md)