@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.
Files changed (227) hide show
  1. package/.claude-plugin/marketplace.json +19 -0
  2. package/.kxm/README.md +14 -0
  3. package/.kxm/assets/README.md +5 -0
  4. package/.kxm/assets/retrospectives/README.md +5 -0
  5. package/.kxm/config/README.md +5 -0
  6. package/.kxm/config/agents.json +43 -0
  7. package/.kxm/config/env.example +56 -0
  8. package/.kxm/config/update.example.yaml +9 -0
  9. package/.kxm/config/workflows/fix.json +160 -0
  10. package/.kxm/config/workflows/jira-development.json +116 -0
  11. package/.kxm/config/workflows/provenance-quorum.json +150 -0
  12. package/.kxm/config/workflows/v04-dogfood.json +72 -0
  13. package/CHANGELOG.md +465 -0
  14. package/LICENSE +21 -0
  15. package/README.md +306 -0
  16. package/SECURITY.md +72 -0
  17. package/docs/README.md +48 -0
  18. package/docs/agent-communication-envelopes-and-gates.md +553 -0
  19. package/docs/architecture.md +242 -0
  20. package/docs/assignment-runner.md +241 -0
  21. package/docs/configuration.md +361 -0
  22. package/docs/continuous-improvement.md +114 -0
  23. package/docs/getting-started.md +253 -0
  24. package/docs/kxm-handbook.md +1090 -0
  25. package/docs/operations.md +205 -0
  26. package/docs/provenance-gates.md +291 -0
  27. package/docs/skills.md +45 -0
  28. package/docs/templates/README.md +95 -0
  29. package/docs/templates/adr.md +88 -0
  30. package/docs/templates/architecture.md +120 -0
  31. package/docs/templates/bug-fix.md +109 -0
  32. package/docs/templates/feature.md +108 -0
  33. package/docs/templates/handoff.md +72 -0
  34. package/docs/templates/postmortem.md +77 -0
  35. package/docs/templates/research.md +100 -0
  36. package/docs/templates/review.md +85 -0
  37. package/docs/templates/runbook.md +73 -0
  38. package/docs/templates/test-plan.md +87 -0
  39. package/docs/templates/test-report.md +72 -0
  40. package/docs/test-matrix.md +121 -0
  41. package/docs/troubleshooting.md +249 -0
  42. package/docs/vnext/README.md +62 -0
  43. package/docs/vnext/architecture.md +185 -0
  44. package/docs/vnext/effects-and-recovery.md +172 -0
  45. package/docs/vnext/lifecycles.md +235 -0
  46. package/docs/vnext/migration.md +220 -0
  47. package/docs/vnext/routing.md +184 -0
  48. package/docs/vnext/synchronization.md +172 -0
  49. package/docs/vnext/terminology.md +240 -0
  50. package/docs/vnext/validation.md +335 -0
  51. package/docs/webhook-workflows.md +240 -0
  52. package/docs/workflow-guide.md +1150 -0
  53. package/examples/README.md +102 -0
  54. package/examples/provenance-workflow.json +40 -0
  55. package/examples/requester.ts +30 -0
  56. package/examples/reviewer-agent.ts +29 -0
  57. package/examples/roundtrip.ts +46 -0
  58. package/examples/vnext/.kxm/agents/coordinator.yaml +16 -0
  59. package/examples/vnext/.kxm/agents/critic-1.yaml +16 -0
  60. package/examples/vnext/.kxm/agents/critic-2.yaml +15 -0
  61. package/examples/vnext/.kxm/agents/critic-3.yaml +15 -0
  62. package/examples/vnext/.kxm/agents/implementer.yaml +15 -0
  63. package/examples/vnext/.kxm/agents/planner.yaml +13 -0
  64. package/examples/vnext/.kxm/agents/reproducer.yaml +15 -0
  65. package/examples/vnext/.kxm/agents/reviewer.yaml +15 -0
  66. package/examples/vnext/.kxm/gates.yaml +8 -0
  67. package/examples/vnext/.kxm/models/critic-claude.yaml +11 -0
  68. package/examples/vnext/.kxm/models/critic-gemini.yaml +11 -0
  69. package/examples/vnext/.kxm/models/critic-grok.yaml +12 -0
  70. package/examples/vnext/.kxm/models/implementation.yaml +14 -0
  71. package/examples/vnext/.kxm/models/primary.yaml +17 -0
  72. package/examples/vnext/.kxm/prices.yaml +111 -0
  73. package/examples/vnext/.kxm/project/env.yaml +7 -0
  74. package/examples/vnext/.kxm/project.yaml +32 -0
  75. package/examples/vnext/.kxm/repo/repo.yaml +8 -0
  76. package/examples/vnext/.kxm/workflows/default.yaml +92 -0
  77. package/examples/vnext/.kxm/workflows/fix.yaml +376 -0
  78. package/examples/vnext/.kxm/workflows/improve.yaml +57 -0
  79. package/examples/vnext/README.md +53 -0
  80. package/examples/vnext/records/assignment-result-recorded.json +63 -0
  81. package/examples/vnext/records/assignment-result.json +46 -0
  82. package/examples/vnext/records/context-candidate.json +42 -0
  83. package/examples/vnext/records/delivery-manifest.json +66 -0
  84. package/examples/vnext/records/effect-uncertainty-resolved-sync.json +67 -0
  85. package/examples/vnext/records/effect-uncertainty-resolved.json +62 -0
  86. package/examples/vnext/records/run-created.json +54 -0
  87. package/examples/vnext/records/sync-event.json +65 -0
  88. package/examples/vnext/repositories/api/.kxm/repo/env.yaml +7 -0
  89. package/examples/vnext/repositories/api/.kxm/repo/repo.yaml +8 -0
  90. package/examples/vnext/repositories/web/.kxm/repo/repo.yaml +8 -0
  91. package/examples/workflow-signal.ts +63 -0
  92. package/package.json +129 -0
  93. package/plugins/kxm/.claude-plugin/plugin.json +73 -0
  94. package/plugins/kxm/.mcp.json +19 -0
  95. package/plugins/kxm/README.md +93 -0
  96. package/plugins/kxm/dist/cli.js +42853 -0
  97. package/plugins/kxm/dist/client.js +416 -0
  98. package/plugins/kxm/dist/core.js +1823 -0
  99. package/plugins/kxm/dist/extension.js +3797 -0
  100. package/plugins/kxm/dist/mcp-server.js +17104 -0
  101. package/plugins/kxm/dist/runtime.js +23361 -0
  102. package/plugins/kxm/dist/server.js +13640 -0
  103. package/plugins/kxm/dist/vnext-runtime-supervisor.js +21109 -0
  104. package/plugins/kxm/package.json +12 -0
  105. package/plugins/kxm/skills/kxm/SKILL.md +97 -0
  106. package/plugins/kxm/skills/kxm/references/protocol.md +103 -0
  107. package/plugins/kxm/skills/kxm-session/SKILL.md +53 -0
  108. package/plugins/kxm/src/arbiter.ts +355 -0
  109. package/plugins/kxm/src/artifacts-exist.ts +62 -0
  110. package/plugins/kxm/src/autocomplete.ts +236 -0
  111. package/plugins/kxm/src/cli.ts +3707 -0
  112. package/plugins/kxm/src/client.ts +614 -0
  113. package/plugins/kxm/src/commands.ts +1063 -0
  114. package/plugins/kxm/src/config.ts +290 -0
  115. package/plugins/kxm/src/context/providers.ts +101 -0
  116. package/plugins/kxm/src/context-packet.ts +332 -0
  117. package/plugins/kxm/src/context.ts +499 -0
  118. package/plugins/kxm/src/core.ts +6 -0
  119. package/plugins/kxm/src/database.ts +563 -0
  120. package/plugins/kxm/src/diagnostics.ts +184 -0
  121. package/plugins/kxm/src/envelope.ts +118 -0
  122. package/plugins/kxm/src/extension.ts +895 -0
  123. package/plugins/kxm/src/external-effects.ts +299 -0
  124. package/plugins/kxm/src/github-watch.ts +255 -0
  125. package/plugins/kxm/src/hub-binding.ts +160 -0
  126. package/plugins/kxm/src/hub.ts +2502 -0
  127. package/plugins/kxm/src/improve.ts +383 -0
  128. package/plugins/kxm/src/inbox.ts +10 -0
  129. package/plugins/kxm/src/kxm-install-kind.ts +113 -0
  130. package/plugins/kxm/src/kxm-update-config.ts +39 -0
  131. package/plugins/kxm/src/kxm-update.ts +238 -0
  132. package/plugins/kxm/src/local-snapshot.ts +406 -0
  133. package/plugins/kxm/src/logger.ts +198 -0
  134. package/plugins/kxm/src/mcp-server.ts +143 -0
  135. package/plugins/kxm/src/memory.ts +385 -0
  136. package/plugins/kxm/src/nous-pi.ts +287 -0
  137. package/plugins/kxm/src/nous-provider.ts +729 -0
  138. package/plugins/kxm/src/price-calc.ts +87 -0
  139. package/plugins/kxm/src/prices.ts +121 -0
  140. package/plugins/kxm/src/protocol.ts +172 -0
  141. package/plugins/kxm/src/recovery.ts +211 -0
  142. package/plugins/kxm/src/redact.ts +26 -0
  143. package/plugins/kxm/src/retrospective.ts +400 -0
  144. package/plugins/kxm/src/routing.ts +830 -0
  145. package/plugins/kxm/src/runtime.ts +9 -0
  146. package/plugins/kxm/src/server.ts +117 -0
  147. package/plugins/kxm/src/session-work.ts +571 -0
  148. package/plugins/kxm/src/session.ts +184 -0
  149. package/plugins/kxm/src/skills.ts +535 -0
  150. package/plugins/kxm/src/state.ts +326 -0
  151. package/plugins/kxm/src/store.ts +637 -0
  152. package/plugins/kxm/src/studio-layout.ts +268 -0
  153. package/plugins/kxm/src/suggest.ts +162 -0
  154. package/plugins/kxm/src/task-manager.ts +244 -0
  155. package/plugins/kxm/src/telemetry.ts +116 -0
  156. package/plugins/kxm/src/tui.ts +1046 -0
  157. package/plugins/kxm/src/vnext-bindings.ts +403 -0
  158. package/plugins/kxm/src/vnext-config.ts +1646 -0
  159. package/plugins/kxm/src/vnext-engine-artifacts.ts +86 -0
  160. package/plugins/kxm/src/vnext-engine-command.ts +533 -0
  161. package/plugins/kxm/src/vnext-engine-compile.ts +722 -0
  162. package/plugins/kxm/src/vnext-engine-evidence.ts +273 -0
  163. package/plugins/kxm/src/vnext-engine-fold.ts +1400 -0
  164. package/plugins/kxm/src/vnext-engine-gate-records.ts +583 -0
  165. package/plugins/kxm/src/vnext-engine-plan.ts +717 -0
  166. package/plugins/kxm/src/vnext-engine.ts +2458 -0
  167. package/plugins/kxm/src/vnext-gate-hash.ts +10 -0
  168. package/plugins/kxm/src/vnext-harness.ts +1142 -0
  169. package/plugins/kxm/src/vnext-init.ts +430 -0
  170. package/plugins/kxm/src/vnext-migrate.ts +1848 -0
  171. package/plugins/kxm/src/vnext-oneshot-producer.ts +424 -0
  172. package/plugins/kxm/src/vnext-permission.ts +936 -0
  173. package/plugins/kxm/src/vnext-pi-producer.ts +628 -0
  174. package/plugins/kxm/src/vnext-repair.ts +1094 -0
  175. package/plugins/kxm/src/vnext-runtime-owner.ts +320 -0
  176. package/plugins/kxm/src/vnext-runtime-store.ts +1560 -0
  177. package/plugins/kxm/src/vnext-runtime-supervisor.ts +586 -0
  178. package/plugins/kxm/src/vnext-runtime.ts +663 -0
  179. package/plugins/kxm/src/vnext-template.ts +247 -0
  180. package/plugins/kxm/src/wiki.ts +313 -0
  181. package/plugins/kxm/src/workflow.ts +1548 -0
  182. package/schemas/vnext/README.md +46 -0
  183. package/schemas/vnext/agent.schema.json +40 -0
  184. package/schemas/vnext/assignment-result.schema.json +66 -0
  185. package/schemas/vnext/backup-manifest.schema.json +89 -0
  186. package/schemas/vnext/candidate.schema.json +109 -0
  187. package/schemas/vnext/common.schema.json +422 -0
  188. package/schemas/vnext/context-candidate.schema.json +76 -0
  189. package/schemas/vnext/context-packet.schema.json +192 -0
  190. package/schemas/vnext/delivery-manifest.schema.json +159 -0
  191. package/schemas/vnext/environment.schema.json +66 -0
  192. package/schemas/vnext/gate-registry.schema.json +109 -0
  193. package/schemas/vnext/handoff-manifest.schema.json +146 -0
  194. package/schemas/vnext/init-operation.schema.json +61 -0
  195. package/schemas/vnext/local-repository-bindings.schema.json +30 -0
  196. package/schemas/vnext/memory-record.schema.json +45 -0
  197. package/schemas/vnext/migration-decision.schema.json +26 -0
  198. package/schemas/vnext/migration-plan.schema.json +123 -0
  199. package/schemas/vnext/migration-receipt.schema.json +52 -0
  200. package/schemas/vnext/model.schema.json +42 -0
  201. package/schemas/vnext/permission-diff.schema.json +57 -0
  202. package/schemas/vnext/prices.schema.json +115 -0
  203. package/schemas/vnext/project.schema.json +85 -0
  204. package/schemas/vnext/repository.schema.json +24 -0
  205. package/schemas/vnext/run-event.schema.json +460 -0
  206. package/schemas/vnext/session-brief.schema.json +153 -0
  207. package/schemas/vnext/sync-event.schema.json +234 -0
  208. package/schemas/vnext/template-provenance.schema.json +38 -0
  209. package/schemas/vnext/workflow.schema.json +248 -0
  210. package/scripts/assignment-run.d.mts +354 -0
  211. package/scripts/assignment-run.mjs +4451 -0
  212. package/scripts/build-runtime.mjs +56 -0
  213. package/scripts/check-generated.mjs +77 -0
  214. package/scripts/check-versions.mjs +34 -0
  215. package/scripts/emit-codex-artifacts.d.mts +9 -0
  216. package/scripts/emit-codex-artifacts.mjs +91 -0
  217. package/scripts/harness-run.d.mts +83 -0
  218. package/scripts/harness-run.mjs +2095 -0
  219. package/scripts/kxm-hub.mjs +105 -0
  220. package/scripts/kxm-publish-npm.mjs +327 -0
  221. package/scripts/kxm-release-github.mjs +472 -0
  222. package/scripts/kxm-runtime-supervisor.mjs +7 -0
  223. package/scripts/kxm-worker.mjs +1127 -0
  224. package/scripts/kxm.mjs +27 -0
  225. package/scripts/roster-policy.d.mts +20 -0
  226. package/scripts/roster-policy.mjs +161 -0
  227. package/scripts/smoke-multi-pi.mjs +479 -0
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.kxm.dev/vnext/repository.schema.json",
4
+ "title": "KXM repository-scoped definition",
5
+ "type": "object",
6
+ "required": ["schema", "projectId", "repositoryId"],
7
+ "properties": {
8
+ "schema": { "const": "kxm.repository.v1" },
9
+ "projectId": { "$ref": "common.schema.json#/$defs/opaqueId" },
10
+ "repositoryId": { "$ref": "common.schema.json#/$defs/identifier" },
11
+ "description": { "type": "string", "maxLength": 2000 },
12
+ "ecosystems": {
13
+ "type": "array",
14
+ "items": { "$ref": "common.schema.json#/$defs/identifier" },
15
+ "uniqueItems": true,
16
+ "maxItems": 16
17
+ },
18
+ "classification": {
19
+ "enum": ["public", "internal", "sensitive"]
20
+ },
21
+ "defaultAccess": { "$ref": "common.schema.json#/$defs/repositoryAccess" }
22
+ },
23
+ "additionalProperties": false
24
+ }
@@ -0,0 +1,460 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.kxm.dev/vnext/run-event.schema.json",
4
+ "title": "KXM local run event",
5
+ "type": "object",
6
+ "required": [
7
+ "schema",
8
+ "eventId",
9
+ "eventType",
10
+ "projectId",
11
+ "runId",
12
+ "homeRuntimeId",
13
+ "sequence",
14
+ "occurredAt",
15
+ "recordedAt",
16
+ "monotonicNs",
17
+ "configRevision",
18
+ "memoryRevision",
19
+ "executorPolicyRevision",
20
+ "toolPolicyRevision",
21
+ "payload"
22
+ ],
23
+ "properties": {
24
+ "schema": { "const": "kxm.run-event.v1" },
25
+ "eventId": { "$ref": "common.schema.json#/$defs/opaqueId" },
26
+ "eventType": { "$ref": "common.schema.json#/$defs/runEventType" },
27
+ "projectId": { "$ref": "common.schema.json#/$defs/opaqueId" },
28
+ "runId": { "$ref": "common.schema.json#/$defs/opaqueId" },
29
+ "homeRuntimeId": { "$ref": "common.schema.json#/$defs/opaqueId" },
30
+ "sequence": { "type": "integer", "minimum": 1 },
31
+ "commandId": { "$ref": "common.schema.json#/$defs/opaqueId" },
32
+ "occurredAt": { "$ref": "common.schema.json#/$defs/timestamp" },
33
+ "recordedAt": { "$ref": "common.schema.json#/$defs/timestamp" },
34
+ "monotonicNs": { "$ref": "common.schema.json#/$defs/monotonicNs" },
35
+ "configRevision": { "$ref": "common.schema.json#/$defs/sha256" },
36
+ "memoryRevision": { "$ref": "common.schema.json#/$defs/opaqueId" },
37
+ "executorPolicyRevision": { "$ref": "common.schema.json#/$defs/sha256" },
38
+ "toolPolicyRevision": { "$ref": "common.schema.json#/$defs/sha256" },
39
+ "payload": { "$ref": "#/$defs/payload" },
40
+ "protectedPayload": {
41
+ "type": "object",
42
+ "required": ["id", "classification", "hash"],
43
+ "properties": {
44
+ "id": { "$ref": "common.schema.json#/$defs/opaqueId" },
45
+ "classification": { "enum": ["project", "sensitive", "secret"] },
46
+ "hash": { "$ref": "common.schema.json#/$defs/sha256" }
47
+ },
48
+ "additionalProperties": false
49
+ }
50
+ },
51
+ "allOf": [
52
+ {
53
+ "if": { "properties": { "eventType": { "const": "run.created" } }, "required": ["eventType"] },
54
+ "then": {
55
+ "properties": {
56
+ "payload": {
57
+ "type": "object",
58
+ "required": ["workflowId", "status", "promptHash", "repositoryIds", "executorIds"]
59
+ }
60
+ }
61
+ }
62
+ },
63
+ {
64
+ "if": { "properties": { "eventType": { "const": "run.status_changed" } }, "required": ["eventType"] },
65
+ "then": {
66
+ "properties": {
67
+ "payload": { "type": "object", "required": ["status"] }
68
+ }
69
+ }
70
+ },
71
+ {
72
+ "if": {
73
+ "properties": {
74
+ "eventType": { "const": "run.status_changed" },
75
+ "payload": { "type": "object", "properties": { "status": { "const": "preparing" } }, "required": ["status"] }
76
+ },
77
+ "required": ["eventType", "payload"]
78
+ },
79
+ "then": {
80
+ "properties": {
81
+ "payload": { "type": "object", "required": ["status", "runPlanHash"] }
82
+ }
83
+ }
84
+ },
85
+ {
86
+ "if": { "properties": { "eventType": { "const": "run.cancel_requested" } }, "required": ["eventType"] },
87
+ "then": {
88
+ "properties": {
89
+ "payload": { "type": "object", "required": ["actor", "reason"] }
90
+ }
91
+ }
92
+ },
93
+ {
94
+ "if": { "properties": { "eventType": { "const": "step.entered" } }, "required": ["eventType"] },
95
+ "then": {
96
+ "properties": {
97
+ "payload": { "type": "object", "required": ["stepId", "stepAttempt", "status"] }
98
+ }
99
+ }
100
+ },
101
+ {
102
+ "if": { "properties": { "eventType": { "const": "step.status_changed" } }, "required": ["eventType"] },
103
+ "then": {
104
+ "properties": {
105
+ "payload": { "type": "object", "required": ["stepId", "status", "previousStatus"] }
106
+ }
107
+ }
108
+ },
109
+ {
110
+ "if": { "properties": { "eventType": { "const": "step.outcome_recorded" } }, "required": ["eventType"] },
111
+ "then": {
112
+ "properties": {
113
+ "payload": { "type": "object", "required": ["stepId", "stepAttempt", "outcome"] }
114
+ }
115
+ }
116
+ },
117
+ {
118
+ "if": { "properties": { "eventType": { "const": "step.transitioned" } }, "required": ["eventType"] },
119
+ "then": {
120
+ "properties": {
121
+ "payload": { "type": "object", "required": ["fromStepId", "outcome"] }
122
+ }
123
+ }
124
+ },
125
+ {
126
+ "if": { "properties": { "eventType": { "const": "assignment.created" } }, "required": ["eventType"] },
127
+ "then": {
128
+ "properties": {
129
+ "payload": { "type": "object", "required": ["assignmentId", "stepId", "stepAttempt", "status"] }
130
+ }
131
+ }
132
+ },
133
+ {
134
+ "if": { "properties": { "eventType": { "enum": ["assignment.accepted", "assignment.executing"] } }, "required": ["eventType"] },
135
+ "then": {
136
+ "properties": {
137
+ "payload": { "type": "object", "required": ["assignmentId", "status"] }
138
+ }
139
+ }
140
+ },
141
+ {
142
+ "if": { "properties": { "eventType": { "const": "assignment.dispatched" } }, "required": ["eventType"] },
143
+ "then": {
144
+ "properties": {
145
+ "payload": { "type": "object", "required": ["assignmentId", "capabilityHash", "status"] }
146
+ }
147
+ }
148
+ },
149
+ {
150
+ "if": { "properties": { "eventType": { "const": "assignment.result_recorded" } }, "required": ["eventType"] },
151
+ "then": {
152
+ "properties": {
153
+ "payload": {
154
+ "type": "object",
155
+ "required": ["assignmentId", "resultClass"],
156
+ "allOf": [
157
+ {
158
+ "if": { "properties": { "resultClass": { "const": "outcome" } }, "required": ["resultClass"] },
159
+ "then": { "required": ["outcome"] }
160
+ },
161
+ {
162
+ "if": {
163
+ "properties": { "resultClass": { "enum": ["outcome_unknown", "producer_rejected", "cancelled"] } },
164
+ "required": ["resultClass"]
165
+ },
166
+ "then": { "not": { "required": ["outcome"] } }
167
+ }
168
+ ]
169
+ }
170
+ }
171
+ }
172
+ },
173
+ {
174
+ "if": { "properties": { "eventType": { "const": "assignment.terminal" } }, "required": ["eventType"] },
175
+ "then": {
176
+ "properties": {
177
+ "payload": { "type": "object", "required": ["assignmentId", "outcome", "status"] }
178
+ }
179
+ }
180
+ },
181
+ {
182
+ "if": { "properties": { "eventType": { "const": "attempt.created" } }, "required": ["eventType"] },
183
+ "then": {
184
+ "properties": {
185
+ "payload": { "type": "object", "required": ["attemptId", "assignmentId", "status"] }
186
+ }
187
+ }
188
+ },
189
+ {
190
+ "if": { "properties": { "eventType": { "const": "attempt.status_changed" } }, "required": ["eventType"] },
191
+ "then": {
192
+ "properties": {
193
+ "payload": { "type": "object", "required": ["attemptId", "status"] }
194
+ }
195
+ }
196
+ },
197
+ {
198
+ "if": {
199
+ "properties": {
200
+ "eventType": {
201
+ "enum": [
202
+ "effect.intent_recorded",
203
+ "effect.dispatched",
204
+ "effect.observed",
205
+ "effect.receipt_recorded",
206
+ "effect.settled",
207
+ "effect.blocked_uncertain",
208
+ "effect.uncertainty_resolved"
209
+ ]
210
+ }
211
+ },
212
+ "required": ["eventType"]
213
+ },
214
+ "then": {
215
+ "properties": {
216
+ "payload": { "type": "object", "required": ["effect"] }
217
+ }
218
+ }
219
+ },
220
+ {
221
+ "if": {
222
+ "properties": {
223
+ "eventType": { "enum": ["effect.intent_recorded", "effect.dispatched"] },
224
+ "payload": {
225
+ "type": "object",
226
+ "properties": {
227
+ "effect": {
228
+ "type": "object",
229
+ "properties": {
230
+ "policy": {
231
+ "type": "object",
232
+ "properties": { "sharedMutable": { "const": true } },
233
+ "required": ["sharedMutable"]
234
+ }
235
+ },
236
+ "required": ["policy"]
237
+ }
238
+ },
239
+ "required": ["effect"]
240
+ }
241
+ },
242
+ "required": ["eventType", "payload"]
243
+ },
244
+ "then": {
245
+ "properties": {
246
+ "payload": { "type": "object", "required": ["lease"] }
247
+ }
248
+ }
249
+ },
250
+ {
251
+ "if": { "properties": { "eventType": { "const": "effect.uncertainty_resolved" } }, "required": ["eventType"] },
252
+ "then": {
253
+ "properties": {
254
+ "payload": { "type": "object", "required": ["effect", "resolvedBy", "resolutionAction", "reason", "suppliedRefs"] }
255
+ }
256
+ }
257
+ },
258
+ {
259
+ "if": { "properties": { "eventType": { "const": "approval.recorded" } }, "required": ["eventType"] },
260
+ "then": {
261
+ "properties": {
262
+ "payload": { "type": "object", "required": ["actor", "outcome", "suppliedRefs"] }
263
+ }
264
+ }
265
+ },
266
+ {
267
+ "if": { "properties": { "eventType": { "enum": ["lease.acquired", "lease.released", "lease.lost"] } }, "required": ["eventType"] },
268
+ "then": {
269
+ "properties": {
270
+ "payload": { "type": "object", "required": ["lease"] }
271
+ }
272
+ }
273
+ },
274
+ {
275
+ "if": { "properties": { "eventType": { "const": "routing.attempt.recorded" } }, "required": ["eventType"] },
276
+ "then": {
277
+ "properties": {
278
+ "payload": { "type": "object", "required": ["routing"] }
279
+ }
280
+ }
281
+ }
282
+ ],
283
+ "additionalProperties": false,
284
+ "$defs": {
285
+ "repositorySnapshot": {
286
+ "type": "object",
287
+ "required": ["repositoryId", "baseCommit", "contentSnapshotHash"],
288
+ "properties": {
289
+ "repositoryId": { "$ref": "common.schema.json#/$defs/identifier" },
290
+ "baseCommit": { "$ref": "common.schema.json#/$defs/gitCommit" },
291
+ "contentSnapshotHash": { "$ref": "common.schema.json#/$defs/sha256" },
292
+ "sourceState": { "enum": ["clean", "dirty-snapshot"] }
293
+ },
294
+ "additionalProperties": false
295
+ },
296
+ "effect": {
297
+ "type": "object",
298
+ "required": ["id", "policy"],
299
+ "properties": {
300
+ "id": { "$ref": "common.schema.json#/$defs/opaqueId" },
301
+ "policy": { "$ref": "common.schema.json#/$defs/effectPolicy" },
302
+ "idempotencyKeyHash": { "$ref": "common.schema.json#/$defs/sha256" }
303
+ },
304
+ "allOf": [
305
+ {
306
+ "if": {
307
+ "properties": {
308
+ "policy": {
309
+ "type": "object",
310
+ "properties": { "class": { "const": "external-idempotent" } },
311
+ "required": ["class"]
312
+ }
313
+ },
314
+ "required": ["policy"]
315
+ },
316
+ "then": { "required": ["idempotencyKeyHash"] }
317
+ }
318
+ ],
319
+ "additionalProperties": false
320
+ },
321
+ "payload": {
322
+ "type": "object",
323
+ "properties": {
324
+ "workflowId": { "$ref": "common.schema.json#/$defs/identifier" },
325
+ "displayTitle": { "type": "string", "minLength": 1, "maxLength": 200 },
326
+ "promptHash": { "$ref": "common.schema.json#/$defs/sha256" },
327
+ "runPlanHash": { "$ref": "common.schema.json#/$defs/sha256" },
328
+ "capabilityHash": { "$ref": "common.schema.json#/$defs/sha256" },
329
+ "resultClass": { "enum": ["outcome", "outcome_unknown", "producer_rejected", "cancelled"] },
330
+ "status": { "$ref": "common.schema.json#/$defs/lifecycleStatus" },
331
+ "previousStatus": { "$ref": "common.schema.json#/$defs/lifecycleStatus" },
332
+ "outcome": { "$ref": "common.schema.json#/$defs/identifier" },
333
+ "summary": { "type": "string", "maxLength": 32000 },
334
+ "reason": { "type": "string", "maxLength": 4000 },
335
+ "resolution": { "type": "string", "maxLength": 4000 },
336
+ "stepId": { "$ref": "common.schema.json#/$defs/identifier" },
337
+ "stepAttempt": { "type": "integer", "minimum": 1 },
338
+ "fromStepId": { "$ref": "common.schema.json#/$defs/identifier" },
339
+ "toStepId": { "$ref": "common.schema.json#/$defs/identifier" },
340
+ "assignmentId": { "$ref": "common.schema.json#/$defs/opaqueId" },
341
+ "attemptId": { "$ref": "common.schema.json#/$defs/opaqueId" },
342
+ "agentId": { "$ref": "common.schema.json#/$defs/identifier" },
343
+ "instanceNo": { "type": "integer", "minimum": 1, "maximum": 64 },
344
+ "scopeEpoch": { "type": "integer", "minimum": 1 },
345
+ "executor": { "$ref": "common.schema.json#/$defs/executorResolution" },
346
+ "executorIds": {
347
+ "type": "array",
348
+ "items": { "$ref": "common.schema.json#/$defs/identifier" },
349
+ "minItems": 0,
350
+ "maxItems": 16
351
+ },
352
+ "executors": {
353
+ "type": "array",
354
+ "items": { "$ref": "common.schema.json#/$defs/executorResolution" },
355
+ "minItems": 1,
356
+ "maxItems": 16
357
+ },
358
+ "repositoryIds": {
359
+ "type": "array",
360
+ "items": { "$ref": "common.schema.json#/$defs/identifier" },
361
+ "minItems": 0,
362
+ "maxItems": 64
363
+ },
364
+ "model": { "$ref": "common.schema.json#/$defs/modelResolution" },
365
+ "repositories": {
366
+ "type": "array",
367
+ "items": { "$ref": "#/$defs/repositorySnapshot" },
368
+ "maxItems": 64
369
+ },
370
+ "effect": { "$ref": "#/$defs/effect" },
371
+ "receipt": { "$ref": "common.schema.json#/$defs/receipt" },
372
+ "evidenceRefs": {
373
+ "type": "array",
374
+ "items": { "$ref": "common.schema.json#/$defs/evidenceRef" },
375
+ "maxItems": 64
376
+ },
377
+ "artifacts": {
378
+ "type": "array",
379
+ "items": { "$ref": "common.schema.json#/$defs/artifactRef" },
380
+ "maxItems": 64
381
+ },
382
+ "timing": { "$ref": "common.schema.json#/$defs/timing" },
383
+ "usage": { "$ref": "common.schema.json#/$defs/usage" },
384
+ "error": { "$ref": "common.schema.json#/$defs/errorSummary" },
385
+ "actor": { "$ref": "common.schema.json#/$defs/actor" },
386
+ "resolvedBy": { "$ref": "common.schema.json#/$defs/actor" },
387
+ "resolutionAction": {
388
+ "enum": ["mark-completed", "confirm-absent-and-retry", "compensate-and-retry", "mark-failed", "cancel"]
389
+ },
390
+ "suppliedRefs": {
391
+ "type": "array",
392
+ "items": { "$ref": "common.schema.json#/$defs/evidenceRef" },
393
+ "maxItems": 64
394
+ },
395
+ "lease": { "$ref": "common.schema.json#/$defs/lease" },
396
+ "candidateId": { "$ref": "common.schema.json#/$defs/opaqueId" },
397
+ "counts": {
398
+ "type": "object",
399
+ "propertyNames": { "$ref": "common.schema.json#/$defs/identifier" },
400
+ "additionalProperties": { "type": "integer", "minimum": 0 },
401
+ "maxProperties": 32
402
+ },
403
+ "routing": { "$ref": "#/$defs/routingRecordV2" }
404
+ },
405
+ "additionalProperties": false
406
+ },
407
+ "routingRecordV2": {
408
+ "type": "object",
409
+ "required": [
410
+ "schema",
411
+ "recordedAt",
412
+ "project",
413
+ "runId",
414
+ "stepId",
415
+ "assignmentId",
416
+ "attemptId",
417
+ "harness",
418
+ "provider",
419
+ "requestedModel",
420
+ "effectiveModel",
421
+ "behavioralSha256",
422
+ "latencyMs",
423
+ "costBasis",
424
+ "retries"
425
+ ],
426
+ "properties": {
427
+ "schema": { "const": "kxm.routing-record.v2" },
428
+ "recordedAt": { "$ref": "common.schema.json#/$defs/timestamp" },
429
+ "project": { "type": "string" },
430
+ "runId": { "type": "string" },
431
+ "stepId": { "type": "string" },
432
+ "assignmentId": { "type": "string" },
433
+ "attemptId": { "type": "string" },
434
+ "harness": { "type": "string" },
435
+ "provider": { "type": "string" },
436
+ "requestedModel": { "type": "string" },
437
+ "effectiveModel": { "type": "string" },
438
+ "thinking": { "type": "string" },
439
+ "agentRole": { "type": "string" },
440
+ "behavioralSha256": { "$ref": "common.schema.json#/$defs/sha256" },
441
+ "contextTokens": { "type": ["integer", "null"], "minimum": 0 },
442
+ "tokensIn": { "type": ["integer", "null"], "minimum": 0 },
443
+ "tokensOut": { "type": ["integer", "null"], "minimum": 0 },
444
+ "cacheReadTokens": { "type": ["integer", "null"], "minimum": 0 },
445
+ "cacheWriteTokens": { "type": ["integer", "null"], "minimum": 0 },
446
+ "latencyMs": { "type": "number", "minimum": 0 },
447
+ "costBasis": { "enum": ["metered", "unmetered", "unknown"] },
448
+ "costUsd": { "type": ["number", "null"], "minimum": 0 },
449
+ "priceRef": { "type": ["string", "null"] },
450
+ "verifierOutcome": { "enum": ["passed", "warning", "failed"] },
451
+ "finalOutcome": { "type": "string" },
452
+ "retries": { "type": "integer", "minimum": 0 },
453
+ "transitions": { "type": "integer", "minimum": 0 },
454
+ "humanInterventions": { "type": "integer", "minimum": 0 },
455
+ "providerMetadata": { "type": "object" }
456
+ },
457
+ "additionalProperties": false
458
+ }
459
+ }
460
+ }
@@ -0,0 +1,153 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.kxm.dev/vnext/session-brief.schema.json",
4
+ "title": "KXM session brief",
5
+ "type": "object",
6
+ "required": [
7
+ "schema",
8
+ "generatedAt",
9
+ "staleSeconds",
10
+ "source",
11
+ "hub",
12
+ "stats",
13
+ "tasks",
14
+ "plans",
15
+ "statusLine",
16
+ "widgetLines"
17
+ ],
18
+ "properties": {
19
+ "schema": {
20
+ "const": "kxm.session-brief.v1"
21
+ },
22
+ "generatedAt": {
23
+ "$ref": "common.schema.json#/$defs/timestamp"
24
+ },
25
+ "staleSeconds": {
26
+ "type": "number",
27
+ "minimum": 0
28
+ },
29
+ "source": {
30
+ "type": "string",
31
+ "enum": ["legacy", "vnext", "both"]
32
+ },
33
+ "hub": {
34
+ "type": "object",
35
+ "required": ["state", "evidence"],
36
+ "properties": {
37
+ "state": {
38
+ "type": "string",
39
+ "enum": ["on", "off", "unknown"]
40
+ },
41
+ "evidence": {
42
+ "type": "string",
43
+ "enum": ["probed", "bound", "cached", "unconfigured", "process", "timeout"]
44
+ },
45
+ "online": {
46
+ "type": "boolean"
47
+ },
48
+ "url": {
49
+ "type": "string"
50
+ }
51
+ }
52
+ },
53
+ "cost": {
54
+ "type": "string"
55
+ },
56
+ "sessionToken": {
57
+ "type": "string"
58
+ },
59
+ "stats": {
60
+ "type": "object",
61
+ "required": ["activeTasks", "waitingTasks", "planCount", "inbox", "runTotal"],
62
+ "properties": {
63
+ "activeTasks": {
64
+ "type": "integer",
65
+ "minimum": 0
66
+ },
67
+ "waitingTasks": {
68
+ "type": "integer",
69
+ "minimum": 0
70
+ },
71
+ "planCount": {
72
+ "type": "integer",
73
+ "minimum": 0
74
+ },
75
+ "inbox": {
76
+ "type": "integer",
77
+ "minimum": 0
78
+ },
79
+ "runTotal": {
80
+ "type": "integer",
81
+ "minimum": 0
82
+ },
83
+ "latestPlan": {
84
+ "type": "string"
85
+ }
86
+ }
87
+ },
88
+ "tasks": {
89
+ "type": "array",
90
+ "items": {
91
+ "type": "object",
92
+ "required": ["kind", "id", "runId", "label", "detail", "prompt"],
93
+ "properties": {
94
+ "kind": {
95
+ "const": "task"
96
+ },
97
+ "id": {
98
+ "type": "string"
99
+ },
100
+ "runId": {
101
+ "type": "string"
102
+ },
103
+ "label": {
104
+ "type": "string"
105
+ },
106
+ "detail": {
107
+ "type": "string"
108
+ },
109
+ "prompt": {
110
+ "type": "string"
111
+ }
112
+ }
113
+ }
114
+ },
115
+ "plans": {
116
+ "type": "array",
117
+ "items": {
118
+ "type": "object",
119
+ "required": ["kind", "id", "runId", "label", "detail", "prompt"],
120
+ "properties": {
121
+ "kind": {
122
+ "const": "plan"
123
+ },
124
+ "id": {
125
+ "type": "string"
126
+ },
127
+ "runId": {
128
+ "type": "string"
129
+ },
130
+ "label": {
131
+ "type": "string"
132
+ },
133
+ "detail": {
134
+ "type": "string"
135
+ },
136
+ "prompt": {
137
+ "type": "string"
138
+ }
139
+ }
140
+ }
141
+ },
142
+ "statusLine": {
143
+ "type": "string",
144
+ "maxLength": 80
145
+ },
146
+ "widgetLines": {
147
+ "type": "array",
148
+ "items": {
149
+ "type": "string"
150
+ }
151
+ }
152
+ }
153
+ }