jev-agent-tools 0.1.4 → 0.3.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 (180) hide show
  1. package/CHANGELOG.md +106 -1
  2. package/CONTRIBUTING.md +43 -0
  3. package/README.md +58 -17
  4. package/SECURITY.md +43 -0
  5. package/dist/adapters/analysis-context.js +75 -0
  6. package/dist/adapters/ask-files.js +198 -0
  7. package/dist/adapters/ask-proof.js +200 -0
  8. package/dist/adapters/ask-syntax.js +385 -0
  9. package/dist/adapters/canonical-path.js +17 -0
  10. package/dist/adapters/command.js +234 -0
  11. package/dist/adapters/docs.js +192 -0
  12. package/dist/adapters/evidence-context.js +119 -0
  13. package/dist/adapters/exec.js +207 -0
  14. package/dist/adapters/files.js +418 -0
  15. package/dist/adapters/find.js +150 -0
  16. package/dist/adapters/git-base.js +32 -0
  17. package/dist/adapters/git-inventory.js +71 -0
  18. package/dist/adapters/git.js +483 -0
  19. package/dist/adapters/locate-file.js +197 -0
  20. package/dist/adapters/output-lines.js +46 -0
  21. package/dist/adapters/private-storage.js +106 -0
  22. package/dist/adapters/risk-callers.js +429 -0
  23. package/dist/adapters/runner-version.js +78 -0
  24. package/dist/adapters/shell.js +92 -0
  25. package/dist/adapters/syntax.js +187 -0
  26. package/dist/adapters/test-inventory.js +139 -0
  27. package/dist/adapters/usage.js +20 -0
  28. package/dist/adapters/utf8.js +47 -0
  29. package/dist/configuration.js +267 -0
  30. package/dist/constants.js +140 -0
  31. package/dist/core/ask-closure.js +282 -0
  32. package/dist/core/ask-proof.js +1 -0
  33. package/dist/core/ask-references.js +278 -0
  34. package/dist/core/asks.js +507 -0
  35. package/dist/core/batches.js +65 -0
  36. package/dist/core/command-output.js +224 -0
  37. package/dist/core/diff.js +178 -0
  38. package/dist/core/docs.js +302 -0
  39. package/dist/core/find.js +108 -0
  40. package/dist/core/git.js +1 -0
  41. package/dist/core/imports.js +550 -0
  42. package/dist/core/integrity.js +45 -0
  43. package/dist/core/lexical.js +132 -0
  44. package/dist/core/locate.js +169 -0
  45. package/dist/core/output.js +137 -0
  46. package/dist/core/pointer.js +29 -0
  47. package/dist/core/result-report.js +302 -0
  48. package/dist/core/risk-callers.js +851 -0
  49. package/dist/core/runner-version.js +45 -0
  50. package/dist/core/secret-path.js +34 -0
  51. package/dist/core/sections.js +230 -0
  52. package/dist/core/state.js +51 -0
  53. package/dist/core/syntax.js +1 -0
  54. package/dist/core/test-commands.js +334 -0
  55. package/dist/core/test-coverage.js +74 -0
  56. package/dist/core/test-discovery.js +1382 -0
  57. package/dist/core/test-evidence.js +527 -0
  58. package/dist/core/test-state.js +81 -0
  59. package/dist/core/truncate.js +12 -0
  60. package/dist/core/units.js +349 -0
  61. package/dist/describe.js +23 -0
  62. package/dist/guide.js +33 -0
  63. package/dist/host.js +24 -0
  64. package/dist/jev/client.js +456 -0
  65. package/dist/jev/pool.js +54 -0
  66. package/dist/jev/types.js +1 -0
  67. package/dist/mcp/main.js +124 -0
  68. package/dist/mcp/protocol.js +210 -0
  69. package/dist/mcp/tools.js +129 -0
  70. package/dist/presets/docs.js +62 -0
  71. package/dist/presets/risk.js +179 -0
  72. package/dist/presets/spec.js +81 -0
  73. package/dist/presets/witnesses.js +249 -0
  74. package/dist/render.js +114 -0
  75. package/dist/report-schema.js +1356 -0
  76. package/dist/result-types.js +1 -0
  77. package/dist/result.js +3 -0
  78. package/dist/runtime.js +1 -0
  79. package/dist/session.js +147 -0
  80. package/dist/texts/ask-files.js +3 -0
  81. package/dist/texts/ask.js +4 -0
  82. package/dist/texts/check-diff.js +20 -0
  83. package/dist/texts/configuration.js +1 -0
  84. package/dist/texts/find.js +19 -0
  85. package/dist/texts/guide.js +3 -0
  86. package/dist/texts/instructions.js +72 -0
  87. package/dist/texts/locate.js +15 -0
  88. package/dist/texts/select-tests.js +4 -0
  89. package/dist/tools/ask-files.js +450 -0
  90. package/dist/tools/ask-schema.js +70 -0
  91. package/dist/tools/ask.js +1147 -0
  92. package/dist/tools/check-diff.js +594 -0
  93. package/dist/tools/docs-check.js +408 -0
  94. package/dist/tools/find.js +682 -0
  95. package/dist/tools/locate.js +602 -0
  96. package/dist/tools/review-report.js +230 -0
  97. package/dist/tools/select-tests.js +821 -0
  98. package/dist/tools/spec-check.js +263 -0
  99. package/docs/adr/0001-strict-typescript-pure-core-offline-tests.md +31 -0
  100. package/docs/adr/0002-one-http-protocol-across-hosts.md +17 -0
  101. package/docs/adr/0003-explicit-scope-conservative-automation.md +19 -0
  102. package/docs/adr/0004-compiled-typed-intents.md +19 -0
  103. package/docs/adr/0005-evidence-construction-before-judgment.md +19 -0
  104. package/docs/adr/0006-visible-uncertainty-constrained-controls.md +21 -0
  105. package/docs/adr/0007-bounded-evidence-visible-limits.md +21 -0
  106. package/docs/adr/0008-static-test-discovery-conservative-plans.md +19 -0
  107. package/docs/adr/0009-session-cache-requested-model-identity.md +17 -0
  108. package/docs/adr/0010-mcp-server-thin-host.md +23 -0
  109. package/docs/agent-instructions.md +120 -0
  110. package/docs/design.md +16 -4
  111. package/docs/mcp.md +233 -0
  112. package/docs/tools/jev_ask.md +8 -5
  113. package/docs/tools/jev_ask_files.md +2 -1
  114. package/docs/tools/jev_check_diff.md +4 -1
  115. package/docs/tools/jev_find_files.md +2 -1
  116. package/docs/tools/jev_locate_in_file.md +5 -0
  117. package/docs/tools/jev_select_tests.md +4 -1
  118. package/package.json +19 -4
  119. package/rules/jev-ask.md +22 -1
  120. package/server.json +57 -0
  121. package/src/adapters/ask-files.ts +11 -3
  122. package/src/adapters/ask-proof.ts +69 -11
  123. package/src/adapters/canonical-path.ts +18 -0
  124. package/src/adapters/command.ts +102 -36
  125. package/src/adapters/docs.ts +33 -14
  126. package/src/adapters/evidence-context.ts +169 -0
  127. package/src/adapters/exec.ts +226 -0
  128. package/src/adapters/files.ts +146 -16
  129. package/src/adapters/find.ts +37 -7
  130. package/src/adapters/git-base.ts +7 -1
  131. package/src/adapters/git.ts +61 -8
  132. package/src/adapters/locate-file.ts +51 -9
  133. package/src/adapters/private-storage.ts +155 -0
  134. package/src/adapters/risk-callers.ts +7 -2
  135. package/src/adapters/shell.ts +113 -0
  136. package/src/adapters/test-inventory.ts +12 -4
  137. package/src/configuration.ts +55 -14
  138. package/src/constants.ts +37 -5
  139. package/src/core/ask-references.ts +262 -146
  140. package/src/core/asks.ts +79 -7
  141. package/src/core/command-output.ts +17 -1
  142. package/src/core/import-boundaries.ts +8 -3
  143. package/src/core/locate.ts +8 -5
  144. package/src/core/output.ts +34 -0
  145. package/src/core/result-report.ts +410 -0
  146. package/src/core/secret-path.ts +37 -0
  147. package/src/core/state.ts +8 -1
  148. package/src/core/units.ts +3 -2
  149. package/src/host.ts +11 -0
  150. package/src/index.ts +3 -0
  151. package/src/jev/client.ts +66 -16
  152. package/src/jev/types.ts +24 -3
  153. package/src/mcp/main.ts +135 -0
  154. package/src/mcp/protocol.ts +332 -0
  155. package/src/mcp/tools.ts +179 -0
  156. package/src/render.ts +109 -0
  157. package/src/report-schema.ts +1380 -0
  158. package/src/result-types.ts +234 -0
  159. package/src/result.ts +4 -1
  160. package/src/runtime.ts +6 -0
  161. package/src/session.ts +59 -0
  162. package/src/setup.ts +13 -5
  163. package/src/texts/ask-files.ts +4 -1
  164. package/src/texts/ask.ts +8 -1
  165. package/src/texts/check-diff.ts +7 -4
  166. package/src/texts/find.ts +8 -2
  167. package/src/texts/guide.ts +8 -16
  168. package/src/texts/instructions.ts +98 -0
  169. package/src/texts/locate.ts +8 -2
  170. package/src/texts/run-end.ts +2 -2
  171. package/src/texts/select-tests.ts +4 -1
  172. package/src/tools/ask-files.ts +311 -18
  173. package/src/tools/ask.ts +722 -95
  174. package/src/tools/check-diff.ts +337 -31
  175. package/src/tools/docs-check.ts +241 -38
  176. package/src/tools/find.ts +389 -29
  177. package/src/tools/locate.ts +387 -25
  178. package/src/tools/review-report.ts +308 -0
  179. package/src/tools/select-tests.ts +484 -23
  180. package/src/tools/spec-check.ts +194 -19
@@ -0,0 +1,1356 @@
1
+ import { validateResultReport } from "./core/result-report.js";
2
+ /** Self-contained public JSON Schema; semantic ID/count checks live in result-report. */
3
+ const definitions = {
4
+ KnowledgeString: {
5
+ oneOf: [
6
+ {
7
+ type: "object",
8
+ properties: {
9
+ status: {
10
+ const: "known",
11
+ },
12
+ value: {
13
+ type: "string",
14
+ },
15
+ },
16
+ required: ["status", "value"],
17
+ additionalProperties: false,
18
+ },
19
+ {
20
+ type: "object",
21
+ properties: {
22
+ status: {
23
+ type: "string",
24
+ enum: ["unknown", "not_applicable", "not_collected"],
25
+ },
26
+ reason: {
27
+ type: "string",
28
+ },
29
+ },
30
+ required: ["status", "reason"],
31
+ additionalProperties: false,
32
+ },
33
+ ],
34
+ },
35
+ KnowledgeNumber: {
36
+ oneOf: [
37
+ {
38
+ type: "object",
39
+ properties: {
40
+ status: {
41
+ const: "known",
42
+ },
43
+ value: {
44
+ type: "integer",
45
+ minimum: 0,
46
+ },
47
+ },
48
+ required: ["status", "value"],
49
+ additionalProperties: false,
50
+ },
51
+ {
52
+ type: "object",
53
+ properties: {
54
+ status: {
55
+ type: "string",
56
+ enum: ["unknown", "not_applicable", "not_collected"],
57
+ },
58
+ reason: {
59
+ type: "string",
60
+ },
61
+ },
62
+ required: ["status", "reason"],
63
+ additionalProperties: false,
64
+ },
65
+ ],
66
+ },
67
+ KnowledgeBoolean: {
68
+ oneOf: [
69
+ {
70
+ type: "object",
71
+ properties: {
72
+ status: {
73
+ const: "known",
74
+ },
75
+ value: {
76
+ type: "boolean",
77
+ },
78
+ },
79
+ required: ["status", "value"],
80
+ additionalProperties: false,
81
+ },
82
+ {
83
+ type: "object",
84
+ properties: {
85
+ status: {
86
+ type: "string",
87
+ enum: ["unknown", "not_applicable", "not_collected"],
88
+ },
89
+ reason: {
90
+ type: "string",
91
+ },
92
+ },
93
+ required: ["status", "reason"],
94
+ additionalProperties: false,
95
+ },
96
+ ],
97
+ },
98
+ KnowledgeNullableNumber: {
99
+ oneOf: [
100
+ {
101
+ type: "object",
102
+ properties: {
103
+ status: {
104
+ const: "known",
105
+ },
106
+ value: {
107
+ type: ["number", "null"],
108
+ },
109
+ },
110
+ required: ["status", "value"],
111
+ additionalProperties: false,
112
+ },
113
+ {
114
+ type: "object",
115
+ properties: {
116
+ status: {
117
+ type: "string",
118
+ enum: ["unknown", "not_applicable", "not_collected"],
119
+ },
120
+ reason: {
121
+ type: "string",
122
+ },
123
+ },
124
+ required: ["status", "reason"],
125
+ additionalProperties: false,
126
+ },
127
+ ],
128
+ },
129
+ KnowledgeAuthority: {
130
+ oneOf: [
131
+ {
132
+ type: "object",
133
+ properties: {
134
+ status: {
135
+ const: "known",
136
+ },
137
+ value: {
138
+ $ref: "#/$defs/Authority",
139
+ },
140
+ },
141
+ required: ["status", "value"],
142
+ additionalProperties: false,
143
+ },
144
+ {
145
+ type: "object",
146
+ properties: {
147
+ status: {
148
+ type: "string",
149
+ enum: ["unknown", "not_applicable", "not_collected"],
150
+ },
151
+ reason: {
152
+ type: "string",
153
+ },
154
+ },
155
+ required: ["status", "reason"],
156
+ additionalProperties: false,
157
+ },
158
+ ],
159
+ },
160
+ KnowledgeEffectiveRoot: {
161
+ oneOf: [
162
+ {
163
+ type: "object",
164
+ properties: {
165
+ status: {
166
+ const: "known",
167
+ },
168
+ value: {
169
+ $ref: "#/$defs/EffectiveRoot",
170
+ },
171
+ },
172
+ required: ["status", "value"],
173
+ additionalProperties: false,
174
+ },
175
+ {
176
+ type: "object",
177
+ properties: {
178
+ status: {
179
+ type: "string",
180
+ enum: ["unknown", "not_applicable", "not_collected"],
181
+ },
182
+ reason: {
183
+ type: "string",
184
+ },
185
+ },
186
+ required: ["status", "reason"],
187
+ additionalProperties: false,
188
+ },
189
+ ],
190
+ },
191
+ KnowledgeProbability: {
192
+ oneOf: [
193
+ {
194
+ type: "object",
195
+ properties: {
196
+ status: {
197
+ const: "known",
198
+ },
199
+ value: {
200
+ type: "number",
201
+ minimum: 0,
202
+ maximum: 1,
203
+ },
204
+ },
205
+ required: ["status", "value"],
206
+ additionalProperties: false,
207
+ },
208
+ {
209
+ type: "object",
210
+ properties: {
211
+ status: {
212
+ type: "string",
213
+ enum: ["unknown", "not_applicable", "not_collected"],
214
+ },
215
+ reason: {
216
+ type: "string",
217
+ },
218
+ },
219
+ required: ["status", "reason"],
220
+ additionalProperties: false,
221
+ },
222
+ ],
223
+ },
224
+ KnowledgeCost: {
225
+ oneOf: [
226
+ {
227
+ type: "object",
228
+ properties: {
229
+ status: {
230
+ const: "known",
231
+ },
232
+ value: {
233
+ type: "number",
234
+ minimum: 0,
235
+ },
236
+ },
237
+ required: ["status", "value"],
238
+ additionalProperties: false,
239
+ },
240
+ {
241
+ type: "object",
242
+ properties: {
243
+ status: {
244
+ type: "string",
245
+ enum: ["unknown", "not_applicable", "not_collected"],
246
+ },
247
+ reason: {
248
+ type: "string",
249
+ },
250
+ },
251
+ required: ["status", "reason"],
252
+ additionalProperties: false,
253
+ },
254
+ ],
255
+ },
256
+ Authority: {
257
+ type: "object",
258
+ properties: {
259
+ path: {
260
+ type: "string",
261
+ },
262
+ origin: {
263
+ type: "string",
264
+ enum: ["host", "server"],
265
+ },
266
+ },
267
+ required: ["path", "origin"],
268
+ additionalProperties: false,
269
+ },
270
+ EffectiveRoot: {
271
+ type: "object",
272
+ properties: {
273
+ path: {
274
+ type: "string",
275
+ },
276
+ origin: {
277
+ type: "string",
278
+ enum: ["host", "server", "override"],
279
+ },
280
+ commonDir: {
281
+ $ref: "#/$defs/KnowledgeString",
282
+ },
283
+ },
284
+ required: ["path", "origin", "commonDir"],
285
+ additionalProperties: false,
286
+ },
287
+ Scope: {
288
+ oneOf: [
289
+ {
290
+ type: "object",
291
+ properties: {
292
+ kind: {
293
+ const: "call",
294
+ },
295
+ },
296
+ required: ["kind"],
297
+ additionalProperties: false,
298
+ },
299
+ {
300
+ type: "object",
301
+ properties: {
302
+ kind: {
303
+ const: "group",
304
+ },
305
+ groupIds: {
306
+ type: "array",
307
+ items: {
308
+ type: "string",
309
+ },
310
+ },
311
+ },
312
+ required: ["kind", "groupIds"],
313
+ additionalProperties: false,
314
+ },
315
+ {
316
+ type: "object",
317
+ properties: {
318
+ kind: {
319
+ const: "item",
320
+ },
321
+ itemIds: {
322
+ type: "array",
323
+ items: {
324
+ type: "string",
325
+ },
326
+ },
327
+ },
328
+ required: ["kind", "itemIds"],
329
+ additionalProperties: false,
330
+ },
331
+ {
332
+ type: "object",
333
+ properties: {
334
+ kind: {
335
+ const: "inventory",
336
+ },
337
+ inventoryIds: {
338
+ type: "array",
339
+ items: {
340
+ type: "string",
341
+ },
342
+ },
343
+ },
344
+ required: ["kind", "inventoryIds"],
345
+ additionalProperties: false,
346
+ },
347
+ ],
348
+ },
349
+ Criterion: {
350
+ type: "object",
351
+ properties: {
352
+ criterion: {
353
+ type: "string",
354
+ },
355
+ matches: {
356
+ $ref: "#/$defs/KnowledgeNumber",
357
+ },
358
+ outcome: {
359
+ type: "string",
360
+ enum: ["matched", "no_match", "outside_inventory", "not_evaluated"],
361
+ },
362
+ diagnosticIds: {
363
+ type: "array",
364
+ items: {
365
+ type: "string",
366
+ },
367
+ },
368
+ },
369
+ required: ["criterion", "matches", "outcome", "diagnosticIds"],
370
+ additionalProperties: false,
371
+ },
372
+ Inventory: {
373
+ type: "object",
374
+ properties: {
375
+ id: {
376
+ type: "string",
377
+ },
378
+ kind: {
379
+ type: "string",
380
+ enum: ["repository", "tests", "sections", "units"],
381
+ },
382
+ rules: {
383
+ type: "array",
384
+ items: {
385
+ type: "string",
386
+ },
387
+ },
388
+ restrictions: {
389
+ type: "array",
390
+ items: {
391
+ type: "string",
392
+ },
393
+ },
394
+ discovered: {
395
+ $ref: "#/$defs/KnowledgeNumber",
396
+ },
397
+ considered: {
398
+ $ref: "#/$defs/KnowledgeNumber",
399
+ },
400
+ scopeRestricted: {
401
+ type: "boolean",
402
+ },
403
+ criteria: {
404
+ type: "array",
405
+ items: {
406
+ $ref: "#/$defs/Criterion",
407
+ },
408
+ },
409
+ },
410
+ required: [
411
+ "id",
412
+ "kind",
413
+ "rules",
414
+ "restrictions",
415
+ "discovered",
416
+ "considered",
417
+ "scopeRestricted",
418
+ "criteria",
419
+ ],
420
+ additionalProperties: false,
421
+ },
422
+ Command: {
423
+ type: "object",
424
+ properties: {
425
+ execution: {
426
+ type: "string",
427
+ enum: [
428
+ "not_requested",
429
+ "unknown",
430
+ "not_started",
431
+ "started",
432
+ "finished",
433
+ ],
434
+ },
435
+ cwd: {
436
+ $ref: "#/$defs/KnowledgeString",
437
+ },
438
+ exitCode: {
439
+ $ref: "#/$defs/KnowledgeNullableNumber",
440
+ },
441
+ timedOut: {
442
+ $ref: "#/$defs/KnowledgeBoolean",
443
+ },
444
+ },
445
+ required: ["execution", "cwd", "exitCode", "timedOut"],
446
+ additionalProperties: false,
447
+ },
448
+ Context: {
449
+ type: "object",
450
+ properties: {
451
+ authority: {
452
+ $ref: "#/$defs/KnowledgeAuthority",
453
+ },
454
+ requestedRoot: {
455
+ $ref: "#/$defs/KnowledgeString",
456
+ },
457
+ effectiveRoot: {
458
+ $ref: "#/$defs/KnowledgeEffectiveRoot",
459
+ },
460
+ requestedBase: {
461
+ $ref: "#/$defs/KnowledgeString",
462
+ },
463
+ resolvedBase: {
464
+ $ref: "#/$defs/KnowledgeString",
465
+ },
466
+ inventories: {
467
+ type: "array",
468
+ items: {
469
+ $ref: "#/$defs/Inventory",
470
+ },
471
+ },
472
+ command: {
473
+ $ref: "#/$defs/Command",
474
+ },
475
+ },
476
+ required: [
477
+ "authority",
478
+ "requestedRoot",
479
+ "effectiveRoot",
480
+ "requestedBase",
481
+ "resolvedBase",
482
+ "inventories",
483
+ "command",
484
+ ],
485
+ additionalProperties: false,
486
+ },
487
+ Cause: {
488
+ type: "string",
489
+ enum: [
490
+ "invalid_arguments",
491
+ "internal_error",
492
+ "file_unavailable",
493
+ "git_failure",
494
+ "evidence_limit",
495
+ "invalid_root",
496
+ "invalid_base",
497
+ "forbidden_path",
498
+ "ignored_path",
499
+ "secret_pattern",
500
+ "symlink",
501
+ "binary_or_non_utf8",
502
+ "missing_required",
503
+ "empty_required",
504
+ "ambiguous_reference",
505
+ "reserved_key",
506
+ "evidence_too_large",
507
+ "group_too_large",
508
+ "call_budget",
509
+ "session_budget",
510
+ "provider_context_refusal",
511
+ "not_configured",
512
+ "service_unavailable",
513
+ "transport_failure",
514
+ "invalid_response",
515
+ "cancelled",
516
+ "collection_empty",
517
+ "no_changed_units",
518
+ "criteria_no_match",
519
+ "outside_inventory",
520
+ "collection_omitted",
521
+ "unsupported_syntax",
522
+ "unresolved_runner",
523
+ "dynamic_dependency",
524
+ "conservative_widening",
525
+ "control_failure",
526
+ "evidence_disagreement",
527
+ ],
528
+ },
529
+ Diagnostic: {
530
+ type: "object",
531
+ properties: {
532
+ id: {
533
+ type: "string",
534
+ },
535
+ cause: {
536
+ $ref: "#/$defs/Cause",
537
+ },
538
+ fact: {
539
+ type: "string",
540
+ },
541
+ target: {
542
+ $ref: "#/$defs/KnowledgeString",
543
+ },
544
+ origin: {
545
+ type: "string",
546
+ enum: [
547
+ "input",
548
+ "note",
549
+ "ask",
550
+ "control",
551
+ "collection",
552
+ "closure",
553
+ "runner",
554
+ "provider",
555
+ "budget",
556
+ ],
557
+ },
558
+ scope: {
559
+ $ref: "#/$defs/Scope",
560
+ },
561
+ effect: {
562
+ type: "string",
563
+ enum: ["blocking", "reservation"],
564
+ },
565
+ material: {
566
+ type: "boolean",
567
+ },
568
+ omittedMembers: {
569
+ type: "array",
570
+ items: {
571
+ type: "string",
572
+ },
573
+ },
574
+ memberCount: {
575
+ $ref: "#/$defs/KnowledgeNumber",
576
+ },
577
+ actionIds: {
578
+ type: "array",
579
+ items: {
580
+ type: "string",
581
+ },
582
+ },
583
+ },
584
+ required: [
585
+ "id",
586
+ "cause",
587
+ "fact",
588
+ "target",
589
+ "origin",
590
+ "scope",
591
+ "effect",
592
+ "material",
593
+ "omittedMembers",
594
+ "memberCount",
595
+ "actionIds",
596
+ ],
597
+ additionalProperties: false,
598
+ },
599
+ Action: {
600
+ type: "object",
601
+ properties: {
602
+ id: {
603
+ type: "string",
604
+ },
605
+ code: {
606
+ type: "string",
607
+ enum: [
608
+ "correct_context",
609
+ "correct_reference",
610
+ "provide_evidence",
611
+ "narrow_evidence",
612
+ "inspect_native",
613
+ "execute_plan",
614
+ "configure_client",
615
+ "recover_service",
616
+ "continue_without_judgment",
617
+ "none",
618
+ ],
619
+ },
620
+ target: {
621
+ $ref: "#/$defs/KnowledgeString",
622
+ },
623
+ scope: {
624
+ $ref: "#/$defs/Scope",
625
+ },
626
+ condition: {
627
+ type: "string",
628
+ },
629
+ instruction: {
630
+ type: "string",
631
+ },
632
+ repeatUnchanged: {
633
+ const: false,
634
+ },
635
+ },
636
+ required: [
637
+ "id",
638
+ "code",
639
+ "target",
640
+ "scope",
641
+ "condition",
642
+ "instruction",
643
+ "repeatUnchanged",
644
+ ],
645
+ additionalProperties: false,
646
+ },
647
+ RawValue: {
648
+ type: "object",
649
+ properties: {
650
+ label: {
651
+ type: "string",
652
+ },
653
+ value: {
654
+ type: ["string", "number", "boolean"],
655
+ },
656
+ probability: {
657
+ $ref: "#/$defs/KnowledgeProbability",
658
+ },
659
+ },
660
+ required: ["label", "value", "probability"],
661
+ additionalProperties: false,
662
+ },
663
+ Control: {
664
+ type: "object",
665
+ properties: {
666
+ id: {
667
+ type: "string",
668
+ },
669
+ kind: {
670
+ type: "string",
671
+ enum: ["cross_check", "order", "witness", "attribution", "integrity"],
672
+ },
673
+ source: {
674
+ type: "string",
675
+ enum: ["fresh", "cache", "static"],
676
+ },
677
+ outcome: {
678
+ type: "string",
679
+ },
680
+ rawValues: {
681
+ type: "array",
682
+ items: {
683
+ $ref: "#/$defs/RawValue",
684
+ },
685
+ },
686
+ },
687
+ required: ["id", "kind", "source", "outcome", "rawValues"],
688
+ additionalProperties: false,
689
+ },
690
+ Judgment: {
691
+ type: "object",
692
+ properties: {
693
+ band: {
694
+ type: "string",
695
+ enum: ["verdict", "unsure", "abstain"],
696
+ },
697
+ result: {
698
+ type: ["string", "number", "boolean"],
699
+ },
700
+ measure: {
701
+ type: "object",
702
+ properties: {
703
+ kind: {
704
+ type: "string",
705
+ enum: ["probability", "confidence"],
706
+ },
707
+ value: {
708
+ $ref: "#/$defs/KnowledgeProbability",
709
+ },
710
+ },
711
+ required: ["kind", "value"],
712
+ additionalProperties: false,
713
+ },
714
+ reason: {
715
+ type: "string",
716
+ },
717
+ uncalibrated: {
718
+ type: "boolean",
719
+ },
720
+ rawValues: {
721
+ type: "array",
722
+ items: {
723
+ $ref: "#/$defs/RawValue",
724
+ },
725
+ },
726
+ controls: {
727
+ type: "array",
728
+ items: {
729
+ $ref: "#/$defs/Control",
730
+ },
731
+ },
732
+ },
733
+ required: [
734
+ "band",
735
+ "result",
736
+ "measure",
737
+ "reason",
738
+ "uncalibrated",
739
+ "rawValues",
740
+ "controls",
741
+ ],
742
+ additionalProperties: false,
743
+ },
744
+ Evidence: {
745
+ type: "object",
746
+ properties: {
747
+ target: {
748
+ type: "string",
749
+ },
750
+ canonicalPath: {
751
+ $ref: "#/$defs/KnowledgeString",
752
+ },
753
+ aliases: {
754
+ type: "array",
755
+ items: {
756
+ type: "string",
757
+ },
758
+ },
759
+ side: {
760
+ type: "string",
761
+ enum: ["current", "before", "output", "state"],
762
+ },
763
+ revision: {
764
+ $ref: "#/$defs/KnowledgeString",
765
+ },
766
+ },
767
+ required: ["target", "canonicalPath", "aliases", "side", "revision"],
768
+ additionalProperties: false,
769
+ },
770
+ ItemCommon: {
771
+ type: "object",
772
+ properties: {
773
+ id: {
774
+ type: "string",
775
+ },
776
+ kind: {
777
+ type: "string",
778
+ enum: [
779
+ "claim",
780
+ "question",
781
+ "file_question",
782
+ "unit",
783
+ "section",
784
+ "requirement",
785
+ "scenario",
786
+ "entry",
787
+ "pointer",
788
+ ],
789
+ },
790
+ label: {
791
+ type: "string",
792
+ },
793
+ groupId: {
794
+ type: "string",
795
+ },
796
+ evidence: {
797
+ type: "array",
798
+ items: {
799
+ $ref: "#/$defs/Evidence",
800
+ },
801
+ },
802
+ diagnosticIds: {
803
+ type: "array",
804
+ items: {
805
+ type: "string",
806
+ },
807
+ },
808
+ actionIds: {
809
+ type: "array",
810
+ items: {
811
+ type: "string",
812
+ },
813
+ },
814
+ selection: {
815
+ type: "object",
816
+ properties: {
817
+ selected: {
818
+ type: "boolean",
819
+ },
820
+ reason: {
821
+ type: "string",
822
+ },
823
+ },
824
+ required: ["selected", "reason"],
825
+ additionalProperties: false,
826
+ },
827
+ },
828
+ required: [
829
+ "id",
830
+ "kind",
831
+ "label",
832
+ "groupId",
833
+ "evidence",
834
+ "diagnosticIds",
835
+ "actionIds",
836
+ ],
837
+ additionalProperties: false,
838
+ },
839
+ Item: {
840
+ oneOf: [
841
+ {
842
+ type: "object",
843
+ properties: {
844
+ id: {
845
+ type: "string",
846
+ },
847
+ kind: {
848
+ type: "string",
849
+ enum: [
850
+ "claim",
851
+ "question",
852
+ "file_question",
853
+ "unit",
854
+ "section",
855
+ "requirement",
856
+ "scenario",
857
+ "entry",
858
+ "pointer",
859
+ ],
860
+ },
861
+ label: {
862
+ type: "string",
863
+ },
864
+ groupId: {
865
+ type: "string",
866
+ },
867
+ evidence: {
868
+ type: "array",
869
+ items: {
870
+ $ref: "#/$defs/Evidence",
871
+ },
872
+ },
873
+ diagnosticIds: {
874
+ type: "array",
875
+ items: {
876
+ type: "string",
877
+ },
878
+ },
879
+ actionIds: {
880
+ type: "array",
881
+ items: {
882
+ type: "string",
883
+ },
884
+ },
885
+ selection: {
886
+ type: "object",
887
+ properties: {
888
+ selected: {
889
+ type: "boolean",
890
+ },
891
+ reason: {
892
+ type: "string",
893
+ },
894
+ },
895
+ required: ["selected", "reason"],
896
+ additionalProperties: false,
897
+ },
898
+ treatment: {
899
+ const: "judged",
900
+ },
901
+ source: {
902
+ type: "string",
903
+ enum: ["fresh", "cache"],
904
+ },
905
+ judgment: {
906
+ $ref: "#/$defs/Judgment",
907
+ },
908
+ },
909
+ required: [
910
+ "id",
911
+ "kind",
912
+ "label",
913
+ "groupId",
914
+ "evidence",
915
+ "diagnosticIds",
916
+ "actionIds",
917
+ "treatment",
918
+ "source",
919
+ "judgment",
920
+ ],
921
+ additionalProperties: false,
922
+ },
923
+ {
924
+ type: "object",
925
+ properties: {
926
+ id: {
927
+ type: "string",
928
+ },
929
+ kind: {
930
+ type: "string",
931
+ enum: [
932
+ "claim",
933
+ "question",
934
+ "file_question",
935
+ "unit",
936
+ "section",
937
+ "requirement",
938
+ "scenario",
939
+ "entry",
940
+ "pointer",
941
+ ],
942
+ },
943
+ label: {
944
+ type: "string",
945
+ },
946
+ groupId: {
947
+ type: "string",
948
+ },
949
+ evidence: {
950
+ type: "array",
951
+ items: {
952
+ $ref: "#/$defs/Evidence",
953
+ },
954
+ },
955
+ diagnosticIds: {
956
+ type: "array",
957
+ items: {
958
+ type: "string",
959
+ },
960
+ },
961
+ actionIds: {
962
+ type: "array",
963
+ items: {
964
+ type: "string",
965
+ },
966
+ },
967
+ selection: {
968
+ type: "object",
969
+ properties: {
970
+ selected: {
971
+ type: "boolean",
972
+ },
973
+ reason: {
974
+ type: "string",
975
+ },
976
+ },
977
+ required: ["selected", "reason"],
978
+ additionalProperties: false,
979
+ },
980
+ treatment: {
981
+ const: "not_judged",
982
+ },
983
+ source: {
984
+ const: "none",
985
+ },
986
+ },
987
+ required: [
988
+ "id",
989
+ "kind",
990
+ "label",
991
+ "groupId",
992
+ "evidence",
993
+ "diagnosticIds",
994
+ "actionIds",
995
+ "treatment",
996
+ "source",
997
+ ],
998
+ additionalProperties: false,
999
+ },
1000
+ {
1001
+ type: "object",
1002
+ properties: {
1003
+ id: {
1004
+ type: "string",
1005
+ },
1006
+ kind: {
1007
+ type: "string",
1008
+ enum: [
1009
+ "claim",
1010
+ "question",
1011
+ "file_question",
1012
+ "unit",
1013
+ "section",
1014
+ "requirement",
1015
+ "scenario",
1016
+ "entry",
1017
+ "pointer",
1018
+ ],
1019
+ },
1020
+ label: {
1021
+ type: "string",
1022
+ },
1023
+ groupId: {
1024
+ type: "string",
1025
+ },
1026
+ evidence: {
1027
+ type: "array",
1028
+ items: {
1029
+ $ref: "#/$defs/Evidence",
1030
+ },
1031
+ },
1032
+ diagnosticIds: {
1033
+ type: "array",
1034
+ items: {
1035
+ type: "string",
1036
+ },
1037
+ },
1038
+ actionIds: {
1039
+ type: "array",
1040
+ items: {
1041
+ type: "string",
1042
+ },
1043
+ },
1044
+ selection: {
1045
+ type: "object",
1046
+ properties: {
1047
+ selected: {
1048
+ type: "boolean",
1049
+ },
1050
+ reason: {
1051
+ type: "string",
1052
+ },
1053
+ },
1054
+ required: ["selected", "reason"],
1055
+ additionalProperties: false,
1056
+ },
1057
+ treatment: {
1058
+ const: "static",
1059
+ },
1060
+ source: {
1061
+ const: "none",
1062
+ },
1063
+ staticReason: {
1064
+ type: "string",
1065
+ },
1066
+ },
1067
+ required: [
1068
+ "id",
1069
+ "kind",
1070
+ "label",
1071
+ "groupId",
1072
+ "evidence",
1073
+ "diagnosticIds",
1074
+ "actionIds",
1075
+ "treatment",
1076
+ "source",
1077
+ "staticReason",
1078
+ ],
1079
+ additionalProperties: false,
1080
+ },
1081
+ ],
1082
+ },
1083
+ Accounting: {
1084
+ type: "object",
1085
+ properties: {
1086
+ toolInvocations: {
1087
+ const: 1,
1088
+ },
1089
+ httpAttempts: {
1090
+ type: "integer",
1091
+ minimum: 0,
1092
+ },
1093
+ questionsSent: {
1094
+ type: "integer",
1095
+ minimum: 0,
1096
+ },
1097
+ cacheHits: {
1098
+ type: "integer",
1099
+ minimum: 0,
1100
+ },
1101
+ cacheRequests: {
1102
+ type: "integer",
1103
+ minimum: 0,
1104
+ },
1105
+ requestedResults: {
1106
+ type: "object",
1107
+ properties: {
1108
+ total: {
1109
+ $ref: "#/$defs/KnowledgeNumber",
1110
+ },
1111
+ fresh: {
1112
+ type: "integer",
1113
+ minimum: 0,
1114
+ },
1115
+ cache: {
1116
+ type: "integer",
1117
+ minimum: 0,
1118
+ },
1119
+ notJudged: {
1120
+ type: "integer",
1121
+ minimum: 0,
1122
+ },
1123
+ static: {
1124
+ type: "integer",
1125
+ minimum: 0,
1126
+ },
1127
+ },
1128
+ required: ["total", "fresh", "cache", "notJudged", "static"],
1129
+ additionalProperties: false,
1130
+ },
1131
+ auxiliary: {
1132
+ type: "object",
1133
+ properties: {
1134
+ controls: {
1135
+ type: "object",
1136
+ properties: {
1137
+ fresh: {
1138
+ type: "integer",
1139
+ minimum: 0,
1140
+ },
1141
+ cache: {
1142
+ type: "integer",
1143
+ minimum: 0,
1144
+ },
1145
+ notJudged: {
1146
+ type: "integer",
1147
+ minimum: 0,
1148
+ },
1149
+ static: {
1150
+ type: "integer",
1151
+ minimum: 0,
1152
+ },
1153
+ },
1154
+ required: ["fresh", "cache", "notJudged", "static"],
1155
+ additionalProperties: false,
1156
+ },
1157
+ passages: {
1158
+ type: "object",
1159
+ properties: {
1160
+ fresh: {
1161
+ type: "integer",
1162
+ minimum: 0,
1163
+ },
1164
+ cache: {
1165
+ type: "integer",
1166
+ minimum: 0,
1167
+ },
1168
+ notJudged: {
1169
+ type: "integer",
1170
+ minimum: 0,
1171
+ },
1172
+ },
1173
+ required: ["fresh", "cache", "notJudged"],
1174
+ additionalProperties: false,
1175
+ },
1176
+ },
1177
+ required: ["controls", "passages"],
1178
+ additionalProperties: false,
1179
+ },
1180
+ costUsd: {
1181
+ $ref: "#/$defs/KnowledgeCost",
1182
+ },
1183
+ elapsedMs: {
1184
+ type: "number",
1185
+ minimum: 0,
1186
+ },
1187
+ },
1188
+ required: [
1189
+ "toolInvocations",
1190
+ "httpAttempts",
1191
+ "questionsSent",
1192
+ "cacheHits",
1193
+ "cacheRequests",
1194
+ "requestedResults",
1195
+ "auxiliary",
1196
+ "costUsd",
1197
+ "elapsedMs",
1198
+ ],
1199
+ additionalProperties: false,
1200
+ },
1201
+ Tool: {
1202
+ type: "string",
1203
+ enum: [
1204
+ "jev_ask",
1205
+ "jev_ask_files",
1206
+ "jev_check_diff",
1207
+ "jev_select_tests",
1208
+ "jev_find_files",
1209
+ "jev_locate_in_file",
1210
+ ],
1211
+ },
1212
+ Execution: {
1213
+ type: "string",
1214
+ enum: ["complete", "partial", "not_judged", "refused"],
1215
+ },
1216
+ ResultReportV1: {
1217
+ type: "object",
1218
+ properties: {
1219
+ schemaVersion: {
1220
+ const: 1,
1221
+ },
1222
+ tool: {
1223
+ $ref: "#/$defs/Tool",
1224
+ },
1225
+ execution: {
1226
+ $ref: "#/$defs/Execution",
1227
+ },
1228
+ context: {
1229
+ $ref: "#/$defs/Context",
1230
+ },
1231
+ items: {
1232
+ type: "array",
1233
+ items: {
1234
+ $ref: "#/$defs/Item",
1235
+ },
1236
+ },
1237
+ diagnostics: {
1238
+ type: "array",
1239
+ items: {
1240
+ $ref: "#/$defs/Diagnostic",
1241
+ },
1242
+ },
1243
+ actions: {
1244
+ type: "array",
1245
+ items: {
1246
+ $ref: "#/$defs/Action",
1247
+ },
1248
+ },
1249
+ accounting: {
1250
+ $ref: "#/$defs/Accounting",
1251
+ },
1252
+ },
1253
+ required: [
1254
+ "schemaVersion",
1255
+ "tool",
1256
+ "execution",
1257
+ "context",
1258
+ "items",
1259
+ "diagnostics",
1260
+ "actions",
1261
+ "accounting",
1262
+ ],
1263
+ additionalProperties: false,
1264
+ },
1265
+ McpStructuredResultV1: {
1266
+ type: "object",
1267
+ properties: {
1268
+ result: {
1269
+ $ref: "#/$defs/ResultReportV1",
1270
+ },
1271
+ },
1272
+ required: ["result"],
1273
+ additionalProperties: false,
1274
+ },
1275
+ };
1276
+ export const resultReportSchema = {
1277
+ ...definitions.ResultReportV1,
1278
+ $defs: definitions,
1279
+ };
1280
+ export const mcpStructuredResultSchema = {
1281
+ ...definitions.McpStructuredResultV1,
1282
+ $defs: definitions,
1283
+ };
1284
+ /** Validator for the closed, local-reference JSON Schema vocabulary emitted above. */
1285
+ function conforms(schema, value, root) {
1286
+ if (typeof schema.$ref === "string") {
1287
+ if (!schema.$ref.startsWith("#/$defs/"))
1288
+ return false;
1289
+ const definitions = root.$defs;
1290
+ const name = schema.$ref.slice("#/$defs/".length);
1291
+ const definition = Object.hasOwn(definitions, name)
1292
+ ? definitions[name]
1293
+ : undefined;
1294
+ return definition !== undefined && conforms(definition, value, root);
1295
+ }
1296
+ if (schema.oneOf)
1297
+ return (schema.oneOf.filter((branch) => conforms(branch, value, root)).length === 1);
1298
+ if (Object.hasOwn(schema, "const") && value !== schema.const)
1299
+ return false;
1300
+ if (schema.enum && !schema.enum.includes(value))
1301
+ return false;
1302
+ const types = Array.isArray(schema.type)
1303
+ ? schema.type
1304
+ : schema.type
1305
+ ? [schema.type]
1306
+ : [];
1307
+ if (types.length &&
1308
+ !types.some((type) => type === "null"
1309
+ ? value === null
1310
+ : type === "array"
1311
+ ? Array.isArray(value)
1312
+ : type === "object"
1313
+ ? value !== null &&
1314
+ typeof value === "object" &&
1315
+ !Array.isArray(value)
1316
+ : type === "integer"
1317
+ ? typeof value === "number" && Number.isInteger(value)
1318
+ : typeof value === type))
1319
+ return false;
1320
+ if (typeof value === "number" &&
1321
+ (!Number.isFinite(value) ||
1322
+ (typeof schema.minimum === "number" && value < schema.minimum) ||
1323
+ (typeof schema.maximum === "number" && value > schema.maximum)))
1324
+ return false;
1325
+ if (Array.isArray(value) && schema.items)
1326
+ return value.every((v) => conforms(schema.items, v, root));
1327
+ if (value !== null &&
1328
+ typeof value === "object" &&
1329
+ !Array.isArray(value) &&
1330
+ schema.properties) {
1331
+ const properties = schema.properties;
1332
+ const record = value;
1333
+ if (schema.required.some((key) => !Object.hasOwn(record, key)))
1334
+ return false;
1335
+ return Object.entries(record).every(([key, v]) => {
1336
+ const property = Object.hasOwn(properties, key)
1337
+ ? properties[key]
1338
+ : undefined;
1339
+ return property !== undefined
1340
+ ? conforms(property, v, root)
1341
+ : schema.additionalProperties !== false;
1342
+ });
1343
+ }
1344
+ return true;
1345
+ }
1346
+ export function isResultReport(value) {
1347
+ return (conforms(resultReportSchema, value, resultReportSchema) &&
1348
+ validateResultReport(value).length === 0);
1349
+ }
1350
+ export function isMcpStructuredResult(value) {
1351
+ if (!conforms(mcpStructuredResultSchema, value, mcpStructuredResultSchema))
1352
+ return false;
1353
+ // The schema above established the complete closed wrapper before this cast.
1354
+ const structured = value;
1355
+ return validateResultReport(structured.result).length === 0;
1356
+ }