@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,354 @@
1
+ export const ASSIGNMENT_SCHEMA: "kxm.assignment.v1";
2
+ export const PLAN_POINTER_SCHEMA: "kxm.plan-pointer.v1";
3
+ export const PLAN_POINTER_FILENAME: "plan-current.json";
4
+ export const COMPLETION_SCHEMA: "kxm.assignment-completion.v1";
5
+ export const REFUSAL_SCHEMA: "kxm.assignment-refusal.v1";
6
+ export const ASSIGNMENT_DISPATCH_SCHEMA: "kxm.assignment-dispatch.v1";
7
+ export const TELEMETRY_SCHEMA: "kxm.telemetry.v1";
8
+ export const RECORDING_RESOLUTION_SCHEMA: "kxm.assignment-recording-resolution.v1";
9
+ export const RUNNER_CODES: readonly string[];
10
+ export const VERIFY_WITNESS_ID: "verify";
11
+ export const VALIDATE_CI_WITNESS_ID: "validate-ci";
12
+ export const WITNESS_IDS: readonly string[];
13
+ export const FIXED_GATES: Readonly<{
14
+ verify: readonly ["npm", "run", "verify"];
15
+ "validate-ci": readonly ["npm", "run", "validate:ci"];
16
+ }>;
17
+ export const WITNESS_SCHEMA: "kxm.assignment-witness.v1";
18
+ export const WITNESS_LATEST_SCHEMA: "kxm.assignment-witness-latest.v1";
19
+ export const WITNESS_RESULTS: readonly string[];
20
+ export const WITNESS_CODES: readonly string[];
21
+ export const ACCEPTED_SCHEMA: "kxm.task-accepted.v1";
22
+ export const ACCEPTED_FILENAME: "accepted.json";
23
+ export const ACCEPTED_NOTE: string;
24
+ export const REQUIRED_ACCEPT_CRITICS: Readonly<Record<string, Readonly<{
25
+ harness: string;
26
+ model: string;
27
+ role: string;
28
+ }>>>;
29
+ export function resolveRequiredCritics(policy: unknown): Readonly<Record<string, Readonly<{
30
+ harness: string;
31
+ model: string;
32
+ role: string;
33
+ vendor: string;
34
+ route_id?: string;
35
+ }>>>;
36
+ export function getRosterPolicy(deps?: Record<string, unknown>): unknown;
37
+ export const ASSIGNMENT_KINDS: readonly string[];
38
+ export const KIND_ROLES: Readonly<Record<string, string>>;
39
+ export const REVIEW_KINDS: readonly string[];
40
+ export const WRITER_KINDS: readonly string[];
41
+ export const CLEAN_BASE_KINDS: readonly string[];
42
+ export const READ_MECHANISMS: Readonly<Record<string, string>>;
43
+
44
+ export interface ValidatedAssignmentGit {
45
+ readonly head: string;
46
+ readonly index_tree: string;
47
+ readonly clean: boolean;
48
+ }
49
+
50
+ export interface ValidatedAssignment {
51
+ readonly schema: "kxm.assignment.v1";
52
+ readonly task_id: string;
53
+ readonly assignment_id: string;
54
+ readonly rework_of?: string;
55
+ readonly kind: string;
56
+ readonly role: string;
57
+ readonly harness: string;
58
+ readonly model: string;
59
+ readonly effort: string;
60
+ readonly permission: string;
61
+ readonly cwd: string;
62
+ readonly task_dir: string;
63
+ readonly record_dir: string;
64
+ readonly base: Readonly<{ kind: "clean"; commit: string } | { kind: "staged"; commit: string; index_tree: string }>;
65
+ readonly plan_ref: Readonly<
66
+ | { kind: "current"; path: string; sha256: string; pointer_path: string; generation: number }
67
+ | { kind: "bootstrap"; reason: string }
68
+ >;
69
+ readonly inputs: readonly Readonly<{ path: string; sha256: string }>[];
70
+ readonly contract: Readonly<{
71
+ boundary: string;
72
+ deliverables: readonly string[];
73
+ witness: Readonly<{ id: string }>;
74
+ deferred: readonly string[];
75
+ }>;
76
+ readonly output_dir: string;
77
+ readonly requested_output_dir?: string;
78
+ readonly timeout_ms?: number;
79
+ readonly max_turns?: number;
80
+ readonly git: ValidatedAssignmentGit;
81
+ }
82
+
83
+ export function validateAssignmentManifest(manifest: unknown, deps?: {
84
+ spawnSync?: typeof import("node:child_process").spawnSync;
85
+ existsSync?: typeof import("node:fs").existsSync;
86
+ readFileSync?: typeof import("node:fs").readFileSync;
87
+ realpathSync?: typeof import("node:fs").realpathSync;
88
+ lstatSync?: typeof import("node:fs").lstatSync;
89
+ statSync?: typeof import("node:fs").statSync;
90
+ rosterPolicy?: unknown;
91
+ loadTrustedRosterPolicy?: () => unknown;
92
+ }): ValidatedAssignment;
93
+
94
+ export interface AssignmentCompletion {
95
+ readonly schema: "kxm.assignment-completion.v1";
96
+ readonly task_id: string;
97
+ readonly assignment_id: string;
98
+ readonly rework_of?: string;
99
+ readonly kind: string;
100
+ readonly role: string;
101
+ readonly manifest: Readonly<{ sha256: string }>;
102
+ readonly prompt: Readonly<{ sha256: string }>;
103
+ readonly plan: Readonly<
104
+ | { kind: "current"; path: string; sha256: string; pointer_path: string; generation: number }
105
+ | { kind: "bootstrap"; reason: string }
106
+ >;
107
+ readonly route: Readonly<{
108
+ harness: string;
109
+ model: string;
110
+ effort: string;
111
+ permission: string;
112
+ role: string;
113
+ }>;
114
+ readonly binding: Readonly<{
115
+ task_dir: string;
116
+ cwd: string;
117
+ record_dir: string;
118
+ output_dir: string;
119
+ }>;
120
+ readonly invocation: "thrown" | "returned";
121
+ readonly candidate: Readonly<
122
+ | { status: "recorded"; head: string; index_tree: string; clean: boolean }
123
+ | { status: "unknown"; code: string }
124
+ >;
125
+ readonly recording: Readonly<
126
+ | { status: "ok" }
127
+ | {
128
+ status: "failed";
129
+ steps: Readonly<{
130
+ candidate_snapshot: "ok" | "failed" | "skipped";
131
+ sidecars: "ok" | "failed" | "skipped";
132
+ routing_record: "ok" | "failed" | "skipped";
133
+ telemetry: "ok" | "failed" | "skipped";
134
+ }>;
135
+ code: string;
136
+ }
137
+ >;
138
+ readonly transport: Readonly<Record<string, unknown>>;
139
+ readonly usage: Readonly<Record<string, unknown>>;
140
+ readonly model_claim?: Readonly<Record<string, unknown>>;
141
+ readonly sidecars: Readonly<Record<string, Readonly<{ path: string; bytes: number }>>>;
142
+ readonly verification: Readonly<{ status: "not-run" }>;
143
+ readonly critic: Readonly<
144
+ | {
145
+ kind: "none";
146
+ reason: "not-review" | "transport-not-completed" | "candidate-unknown" | "candidate-changed" | "no-verdict";
147
+ }
148
+ | { kind: "review"; verdict: "PASS" | "BLOCK"; judged_tree: string; role: string }
149
+ >;
150
+ readonly attribution: Readonly<{ status: "unclassified" }>;
151
+ }
152
+
153
+ export function assignmentOutputSchema(kind: string): Record<string, unknown>;
154
+ export function renderAssignmentPrompt(validated: ValidatedAssignment, deps?: {
155
+ existsSync?: typeof import("node:fs").existsSync;
156
+ readFileSync?: typeof import("node:fs").readFileSync;
157
+ statSync?: typeof import("node:fs").statSync;
158
+ }): string;
159
+ export function assignmentTelemetryPath(outputDir: string): string;
160
+ export function appendAssignmentTelemetry(completion: object, outputDir: string, deps?: object): boolean;
161
+ export function runAssignment(manifest: unknown, deps?: Record<string, unknown>): Promise<AssignmentCompletion>;
162
+ export function observeAssignment(outputDir: string, deps?: Record<string, unknown>): Promise<boolean>;
163
+
164
+ export interface AssignmentWitnessReceipt {
165
+ readonly schema: "kxm.assignment-witness.v1";
166
+ readonly receipt_id: string;
167
+ readonly task_id: string;
168
+ readonly assignment_id: string;
169
+ readonly kind?: string;
170
+ readonly recordedAt: string;
171
+ readonly manifest: Readonly<{ path: string; sha256: string }>;
172
+ readonly completion: Readonly<{ path: string; sha256: string }>;
173
+ readonly plan: Readonly<
174
+ | { kind: "current"; path?: string; sha256?: string; pointer_path?: string; generation?: number }
175
+ | { kind: "bootstrap"; reason?: string }
176
+ >;
177
+ readonly binding: Readonly<{
178
+ task_dir: string;
179
+ cwd: string;
180
+ record_dir: string;
181
+ }>;
182
+ readonly candidate: Readonly<{
183
+ before?: Readonly<{ head: string; index_tree: string; clean: boolean } | { status: "unknown"; code: string }>;
184
+ after?: Readonly<{ head: string; index_tree: string; clean: boolean } | { status: "unknown"; code: string }>;
185
+ }>;
186
+ readonly gates: readonly Readonly<{
187
+ id: string;
188
+ argv: readonly string[];
189
+ shell: false;
190
+ cwd: string;
191
+ exitCode: number | null;
192
+ signal: string | null;
193
+ timedOut: boolean;
194
+ durationMs: number;
195
+ log: Readonly<{ path: string; bytes: number }>;
196
+ }>[];
197
+ readonly result: "passed" | "failed" | "refused";
198
+ readonly code?: string;
199
+ readonly startedAt: string;
200
+ readonly finishedAt: string;
201
+ readonly durationMs: number;
202
+ readonly path?: string;
203
+ readonly sha256?: string;
204
+ }
205
+
206
+ export function witnessAssignment(recordDir: string, deps?: Record<string, unknown>): Promise<AssignmentWitnessReceipt>;
207
+
208
+ export interface TaskAccepted {
209
+ readonly schema: "kxm.task-accepted.v1";
210
+ readonly task_id: string;
211
+ readonly commit: string;
212
+ readonly tree: string;
213
+ readonly writer: Readonly<{
214
+ assignment_id: string;
215
+ record_dir: string;
216
+ kind: string;
217
+ completion: Readonly<{ path: string; sha256: string }>;
218
+ manifest: Readonly<{ path: string; sha256: string }>;
219
+ receipt: Readonly<{ id: string; path: string; sha256: string }>;
220
+ }>;
221
+ readonly plan: Readonly<{
222
+ kind: "current";
223
+ path: string;
224
+ sha256: string;
225
+ pointer_path: string;
226
+ generation: number;
227
+ }>;
228
+ readonly critics: readonly Readonly<{
229
+ kind: string;
230
+ role: string;
231
+ harness: string;
232
+ model: string;
233
+ assignment_id: string;
234
+ record_dir: string;
235
+ completion: Readonly<{ path: string; sha256: string }>;
236
+ verdict: "PASS";
237
+ judged_tree: string;
238
+ }>[];
239
+ readonly acceptedAt: string;
240
+ readonly observed: Readonly<{
241
+ pr?: Readonly<{ id: string; validated: false }>;
242
+ ci?: Readonly<{ id: string; validated: false }>;
243
+ }>;
244
+ readonly note: string;
245
+ readonly path?: string;
246
+ readonly sha256?: string;
247
+ }
248
+
249
+ export function acceptAssignment(request: {
250
+ taskDir: string;
251
+ commit: string;
252
+ recordDir: string;
253
+ critics: readonly string[];
254
+ observedPr?: string;
255
+ observedCi?: string;
256
+ }, deps?: Record<string, unknown>): Promise<TaskAccepted>;
257
+
258
+ export interface AssignmentRecordingResolution {
259
+ readonly schema: "kxm.assignment-recording-resolution.v1";
260
+ readonly task_id: string;
261
+ readonly assignment_id: string;
262
+ readonly resolvedAt?: string;
263
+ readonly completion_sha256: string;
264
+ readonly steps: Readonly<{
265
+ candidate_snapshot: "ok" | "failed" | "skipped";
266
+ sidecars: "ok" | "failed" | "skipped";
267
+ routing_record: "ok" | "failed" | "skipped";
268
+ telemetry: "ok" | "failed" | "skipped";
269
+ }>;
270
+ }
271
+
272
+ export function main(argv?: string[], io?: {
273
+ stdin: NodeJS.ReadableStream;
274
+ stdout: NodeJS.WritableStream;
275
+ stderr: NodeJS.WritableStream;
276
+ spawnSync?: typeof import("node:child_process").spawnSync;
277
+ env?: NodeJS.ProcessEnv;
278
+ now?: () => number;
279
+ }): Promise<AssignmentCompletion | AssignmentRecordingResolution | AssignmentWitnessReceipt | TaskAccepted | CostObservationReceipt | AttributionPointer | ReturnType<typeof changeReport> | ReturnType<typeof writeCurrentPlan>>;
280
+
281
+ export const COST_OBSERVATION_SCHEMA: "kxm.cost-observation.v1";
282
+ export const ATTRIBUTION_SCHEMA: "kxm.assignment-attribution.v1";
283
+ export const ATTRIBUTION_CLASSES: readonly string[];
284
+ export interface CostObservation {
285
+ schema: "kxm.cost-observation.v1";
286
+ task_id: string;
287
+ assignment_id: string;
288
+ kind: string;
289
+ route: { harness: string; provider: string; model: string; effort: string };
290
+ status: "completed" | "failed" | "interrupted" | "unknown";
291
+ timing: { started_at: string | null; finished_at: string | null; latency_ms: number | null };
292
+ usage: {
293
+ input_tokens: number | null;
294
+ output_tokens: number | null;
295
+ cache_read_tokens: number | null;
296
+ cache_write_tokens: number | null;
297
+ reasoning_tokens: number | null;
298
+ context_tokens: number | null;
299
+ token_basis: "cumulative";
300
+ cost_basis: "provider-reported" | "list" | "unmetered" | "unknown";
301
+ cost_usd: number | null;
302
+ estimate_usd: number | null;
303
+ partial: boolean;
304
+ };
305
+ sources: Array<{ path: string; sha256: string }>;
306
+ note: string;
307
+ accounting: { included: boolean; reason: string };
308
+ cost_only: true;
309
+ rework: boolean | null;
310
+ rework_of?: string;
311
+ }
312
+ export interface CostObservationReceipt {
313
+ schema: "kxm.cost-observation.v1";
314
+ task_id: string;
315
+ assignment_id: string;
316
+ cost_only: true;
317
+ path: string;
318
+ sha256: string;
319
+ }
320
+ export interface AttributionPointer {
321
+ schema: "kxm.assignment-attribution.v1";
322
+ id: string;
323
+ classification: "orchestration" | "model" | "environment" | "unclassified";
324
+ sha256: string;
325
+ }
326
+ export function observeAssignmentCost(request: { taskDir: string; observation: CostObservation }, deps?: Record<string, unknown>): CostObservationReceipt;
327
+ export function attributeAssignment(request: { taskDir: string; recordDir: string; classification: string; explanation: string }, deps?: Record<string, unknown>): AttributionPointer;
328
+
329
+ export const CHANGE_REPORT_SCHEMA: "kxm.change-report.v1";
330
+ export function changeReport(request: { taskDir: string }, deps?: Record<string, unknown>): {
331
+ schema: "kxm.change-report.v1";
332
+ task_id: string;
333
+ assignments: Array<Record<string, any>>;
334
+ totals: Record<string, any>;
335
+ ignored: Array<{ name: string; reason: string }>;
336
+ issues: Array<Record<string, string>>;
337
+ acceptance: Record<string, any> | null;
338
+ effort_observations: Array<Record<string, any>>;
339
+ ranking: "not-ranked";
340
+ orchestration_usage: "unavailable";
341
+ };
342
+ export function writeCurrentPlan(request: {
343
+ taskDir: string; plan: string; sha256: string; baseCommit: string; expectedGeneration: number; settledDecisions?: string[];
344
+ }, deps?: Record<string, unknown>): {
345
+ schema: "kxm.plan-pointer.v1";
346
+ task_id: string;
347
+ generation: number;
348
+ plan_path: string;
349
+ plan_sha256: string;
350
+ base_commit: string;
351
+ settled_decisions: string[];
352
+ supersedes: Array<Record<string, unknown>>;
353
+ updated_at: string;
354
+ };