@aikdna/kdna-core 0.17.0 → 0.18.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.
@@ -0,0 +1,748 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/aikdna/kdna/specs/judgment-trace-1.schema.json",
4
+ "title": "KDNA JudgmentTrace 1.0",
5
+ "description": "Authoritative strict terminal evidence for ConsumptionPlan 1.0 Capsule 2 / Agent Host 2 execution. This is not interchangeable with historical trace schemas.",
6
+ "type": "object",
7
+ "required": [
8
+ "type",
9
+ "trace_version",
10
+ "trace_id",
11
+ "plan_ref",
12
+ "parent_trace_id",
13
+ "timestamp",
14
+ "overall_status",
15
+ "runtime_contract",
16
+ "asset_identity",
17
+ "digest_evidence",
18
+ "capsule_delivery_evidence",
19
+ "projection_actual",
20
+ "host_receipt",
21
+ "execution",
22
+ "budget",
23
+ "result_ref",
24
+ "errors",
25
+ "warnings"
26
+ ],
27
+ "additionalProperties": false,
28
+ "properties": {
29
+ "type": { "const": "kdna.judgment.trace" },
30
+ "trace_version": { "const": "1.0.0" },
31
+ "trace_id": { "type": "string", "pattern": "^trace_[0-9a-f]{16}$" },
32
+ "plan_ref": { "$ref": "#/$defs/planRef" },
33
+ "parent_trace_id": {
34
+ "oneOf": [{ "type": "string", "pattern": "^trace_[0-9a-f]{16}$" }, { "type": "null" }]
35
+ },
36
+ "timestamp": { "type": "string", "format": "date-time" },
37
+ "overall_status": {
38
+ "enum": ["execution_completed", "blocked", "execution_failed", "cancelled", "timed_out"]
39
+ },
40
+ "runtime_contract": { "$ref": "#/$defs/runtimeContract" },
41
+ "asset_identity": { "$ref": "#/$defs/assetIdentity" },
42
+ "digest_evidence": {
43
+ "$ref": "https://github.com/aikdna/kdna/specs/digest-evidence.schema.json"
44
+ },
45
+ "capsule_delivery_evidence": { "$ref": "#/$defs/capsuleDeliveryEvidence" },
46
+ "projection_actual": { "$ref": "#/$defs/projectionActual" },
47
+ "host_receipt": {
48
+ "oneOf": [
49
+ {
50
+ "$ref": "https://github.com/aikdna/kdna/specs/agent-host-2-receipt.schema.json"
51
+ },
52
+ { "type": "null" }
53
+ ]
54
+ },
55
+ "execution": { "$ref": "#/$defs/execution" },
56
+ "budget": { "$ref": "#/$defs/budgetEvidence" },
57
+ "result_ref": {
58
+ "oneOf": [{ "$ref": "#/$defs/resultRef" }, { "type": "null" }]
59
+ },
60
+ "errors": {
61
+ "type": "array",
62
+ "items": { "$ref": "#/$defs/issue" }
63
+ },
64
+ "warnings": {
65
+ "type": "array",
66
+ "items": { "type": "string" }
67
+ }
68
+ },
69
+ "allOf": [
70
+ {
71
+ "if": {
72
+ "properties": {
73
+ "overall_status": {
74
+ "enum": ["execution_completed", "execution_failed", "cancelled", "timed_out"]
75
+ }
76
+ },
77
+ "required": ["overall_status"]
78
+ },
79
+ "then": {
80
+ "properties": {
81
+ "runtime_contract": {
82
+ "properties": {
83
+ "negotiation_state": { "const": "selected" },
84
+ "selected_capsule_version": { "const": "2.0" },
85
+ "selected_host_protocol": { "const": "kdna.agent-host/2" },
86
+ "issue_code": { "type": "null" }
87
+ }
88
+ },
89
+ "digest_evidence": {
90
+ "properties": {
91
+ "asset": { "$ref": "#/$defs/successfulDigest" },
92
+ "content": { "$ref": "#/$defs/successfulDigest" },
93
+ "runtime_entry_set": { "$ref": "#/$defs/successfulDigest" }
94
+ }
95
+ },
96
+ "capsule_delivery_evidence": {
97
+ "properties": { "host_boundary_comparison": { "const": "matched" } }
98
+ },
99
+ "host_receipt": {
100
+ "$ref": "https://github.com/aikdna/kdna/specs/agent-host-2-receipt.schema.json"
101
+ },
102
+ "projection_actual": {
103
+ "properties": {
104
+ "profile": { "type": "string" },
105
+ "capsule_delivery_digest": { "$ref": "#/$defs/sha256" },
106
+ "profile_deviated_from_plan": { "type": "boolean" }
107
+ }
108
+ },
109
+ "budget": {
110
+ "properties": {
111
+ "actual": {
112
+ "properties": { "projection_chars": { "type": "integer", "minimum": 0 } }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ },
119
+ {
120
+ "if": {
121
+ "properties": { "overall_status": { "const": "execution_completed" } },
122
+ "required": ["overall_status"]
123
+ },
124
+ "then": {
125
+ "properties": {
126
+ "host_receipt": {
127
+ "properties": {
128
+ "runtime_receipt": {
129
+ "properties": { "provider_execution_status": { "const": "completed" } }
130
+ },
131
+ "outcome": { "type": "object" }
132
+ }
133
+ },
134
+ "execution": {
135
+ "properties": {
136
+ "delivery_status": { "const": "correlated_response" },
137
+ "execution_status": { "const": "completed" }
138
+ }
139
+ },
140
+ "budget": {
141
+ "properties": {
142
+ "comparison": {
143
+ "properties": {
144
+ "overall": { "enum": ["within_limit", "not_observed"] }
145
+ }
146
+ }
147
+ }
148
+ },
149
+ "result_ref": { "$ref": "#/$defs/resultRef" },
150
+ "errors": { "maxItems": 0 }
151
+ }
152
+ }
153
+ },
154
+ {
155
+ "if": {
156
+ "properties": { "overall_status": { "const": "blocked" } },
157
+ "required": ["overall_status"]
158
+ },
159
+ "then": {
160
+ "properties": {
161
+ "runtime_contract": {
162
+ "properties": {
163
+ "negotiation_state": { "enum": ["selected", "blocked", "not_started"] }
164
+ }
165
+ },
166
+ "capsule_delivery_evidence": {
167
+ "properties": {
168
+ "host_boundary_comparison": {
169
+ "enum": ["mismatched", "not_delivered", "not_observed", "unavailable"]
170
+ }
171
+ }
172
+ },
173
+ "host_receipt": {
174
+ "oneOf": [
175
+ { "type": "null" },
176
+ {
177
+ "allOf": [
178
+ {
179
+ "$ref": "https://github.com/aikdna/kdna/specs/agent-host-2-receipt.schema.json"
180
+ },
181
+ {
182
+ "properties": {
183
+ "runtime_receipt": {
184
+ "properties": {
185
+ "capsule_delivery_comparison": { "const": "mismatched" },
186
+ "provider_execution_status": { "const": "not_started" }
187
+ }
188
+ },
189
+ "outcome": { "type": "null" }
190
+ }
191
+ }
192
+ ]
193
+ }
194
+ ]
195
+ },
196
+ "execution": {
197
+ "properties": {
198
+ "delivery_status": {
199
+ "enum": ["not_delivered", "rejected_before_execution"]
200
+ },
201
+ "execution_status": { "const": "not_started" }
202
+ }
203
+ },
204
+ "result_ref": { "type": "null" },
205
+ "errors": { "minItems": 1 }
206
+ }
207
+ }
208
+ },
209
+ {
210
+ "if": {
211
+ "properties": { "overall_status": { "const": "execution_failed" } },
212
+ "required": ["overall_status"]
213
+ },
214
+ "then": {
215
+ "properties": {
216
+ "host_receipt": {
217
+ "properties": {
218
+ "runtime_receipt": {
219
+ "properties": { "provider_execution_status": { "const": "failed" } }
220
+ },
221
+ "outcome": { "type": "null" }
222
+ }
223
+ },
224
+ "execution": {
225
+ "properties": {
226
+ "delivery_status": { "const": "correlated_response" },
227
+ "execution_status": { "const": "failed" }
228
+ }
229
+ },
230
+ "result_ref": { "type": "null" },
231
+ "errors": { "minItems": 1 }
232
+ }
233
+ }
234
+ },
235
+ {
236
+ "if": {
237
+ "properties": { "overall_status": { "const": "cancelled" } },
238
+ "required": ["overall_status"]
239
+ },
240
+ "then": {
241
+ "properties": {
242
+ "host_receipt": {
243
+ "properties": {
244
+ "runtime_receipt": {
245
+ "properties": { "provider_execution_status": { "const": "cancelled" } }
246
+ },
247
+ "outcome": { "type": "null" }
248
+ }
249
+ },
250
+ "execution": {
251
+ "properties": {
252
+ "delivery_status": { "const": "correlated_response" },
253
+ "execution_status": { "const": "cancelled" }
254
+ }
255
+ },
256
+ "result_ref": { "type": "null" },
257
+ "errors": { "minItems": 1 }
258
+ }
259
+ }
260
+ },
261
+ {
262
+ "if": {
263
+ "properties": { "overall_status": { "const": "timed_out" } },
264
+ "required": ["overall_status"]
265
+ },
266
+ "then": {
267
+ "properties": {
268
+ "host_receipt": {
269
+ "properties": {
270
+ "runtime_receipt": {
271
+ "properties": { "provider_execution_status": { "const": "timed_out" } }
272
+ },
273
+ "outcome": { "type": "null" }
274
+ }
275
+ },
276
+ "execution": {
277
+ "properties": {
278
+ "delivery_status": { "const": "correlated_response" },
279
+ "execution_status": { "const": "timed_out" }
280
+ }
281
+ },
282
+ "budget": {
283
+ "properties": {
284
+ "comparison": {
285
+ "properties": {
286
+ "elapsed_ms": { "const": "exceeded" },
287
+ "overall": { "const": "exceeded" }
288
+ }
289
+ }
290
+ }
291
+ },
292
+ "result_ref": { "type": "null" },
293
+ "errors": { "minItems": 1 }
294
+ }
295
+ }
296
+ }
297
+ ],
298
+ "$defs": {
299
+ "sha256": {
300
+ "type": "string",
301
+ "pattern": "^sha256:[0-9a-f]{64}$"
302
+ },
303
+ "assetId": {
304
+ "type": "string",
305
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*(:[a-zA-Z0-9_.-]+)+$"
306
+ },
307
+ "semver": {
308
+ "type": "string",
309
+ "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+([+-].+)?$"
310
+ },
311
+ "planRef": {
312
+ "type": "object",
313
+ "required": ["plan_id", "plan_digest_profile", "plan_digest", "comparison"],
314
+ "additionalProperties": false,
315
+ "properties": {
316
+ "plan_id": { "type": "string", "pattern": "^plan_[0-9a-f]{16}$" },
317
+ "plan_digest_profile": { "const": "kdna-consumption-plan-jcs-v1" },
318
+ "plan_digest": { "$ref": "#/$defs/sha256" },
319
+ "comparison": { "const": "matched" }
320
+ }
321
+ },
322
+ "runtimeContract": {
323
+ "type": "object",
324
+ "required": [
325
+ "plan_capsule_versions",
326
+ "core_capsule_versions",
327
+ "plan_host_protocols",
328
+ "host_capabilities",
329
+ "negotiation_state",
330
+ "selected_capsule_version",
331
+ "selected_host_protocol",
332
+ "issue_code"
333
+ ],
334
+ "additionalProperties": false,
335
+ "properties": {
336
+ "plan_capsule_versions": {
337
+ "type": "array",
338
+ "prefixItems": [{ "const": "2.0" }],
339
+ "minItems": 1,
340
+ "maxItems": 1
341
+ },
342
+ "core_capsule_versions": {
343
+ "type": "array",
344
+ "minItems": 1,
345
+ "uniqueItems": true,
346
+ "items": { "enum": ["2.0", "1.0"] }
347
+ },
348
+ "plan_host_protocols": {
349
+ "type": "array",
350
+ "prefixItems": [{ "const": "kdna.agent-host/2" }],
351
+ "minItems": 1,
352
+ "maxItems": 1
353
+ },
354
+ "host_capabilities": {
355
+ "$ref": "https://github.com/aikdna/kdna/specs/agent-host-capabilities-1.schema.json"
356
+ },
357
+ "negotiation_state": { "enum": ["selected", "blocked", "not_started"] },
358
+ "selected_capsule_version": {
359
+ "type": ["string", "null"],
360
+ "enum": ["2.0", null]
361
+ },
362
+ "selected_host_protocol": {
363
+ "type": ["string", "null"],
364
+ "enum": ["kdna.agent-host/2", null]
365
+ },
366
+ "issue_code": {
367
+ "type": ["string", "null"],
368
+ "enum": [
369
+ "KDNA_CAPSULE_VERSION_UNSUPPORTED",
370
+ "KDNA_HOST_PROTOCOL_UNSUPPORTED",
371
+ "KDNA_HOST_CAPSULE_PAIR_UNSUPPORTED",
372
+ null
373
+ ]
374
+ }
375
+ },
376
+ "allOf": [
377
+ {
378
+ "if": {
379
+ "properties": { "negotiation_state": { "const": "selected" } },
380
+ "required": ["negotiation_state"]
381
+ },
382
+ "then": {
383
+ "properties": {
384
+ "selected_capsule_version": { "const": "2.0" },
385
+ "selected_host_protocol": { "const": "kdna.agent-host/2" },
386
+ "issue_code": { "type": "null" }
387
+ }
388
+ },
389
+ "else": {
390
+ "properties": {
391
+ "selected_capsule_version": { "type": "null" },
392
+ "selected_host_protocol": { "type": "null" }
393
+ }
394
+ }
395
+ },
396
+ {
397
+ "if": {
398
+ "properties": { "negotiation_state": { "const": "blocked" } },
399
+ "required": ["negotiation_state"]
400
+ },
401
+ "then": { "properties": { "issue_code": { "type": "string" } } }
402
+ },
403
+ {
404
+ "if": {
405
+ "properties": { "negotiation_state": { "const": "not_started" } },
406
+ "required": ["negotiation_state"]
407
+ },
408
+ "then": { "properties": { "issue_code": { "type": "null" } } }
409
+ }
410
+ ]
411
+ },
412
+ "assetIdentity": {
413
+ "type": "object",
414
+ "required": ["asset_id", "asset_uid", "version", "judgment_version", "access"],
415
+ "additionalProperties": false,
416
+ "properties": {
417
+ "asset_id": { "$ref": "#/$defs/assetId" },
418
+ "asset_uid": { "type": "string", "format": "uri" },
419
+ "version": { "$ref": "#/$defs/semver" },
420
+ "judgment_version": { "$ref": "#/$defs/semver" },
421
+ "access": { "enum": ["public", "licensed", "remote"] }
422
+ }
423
+ },
424
+ "successfulDigest": {
425
+ "type": "object",
426
+ "required": ["value", "basis", "comparison"],
427
+ "additionalProperties": false,
428
+ "properties": {
429
+ "value": { "$ref": "#/$defs/sha256" },
430
+ "basis": { "type": "string" },
431
+ "comparison": {
432
+ "type": "object",
433
+ "required": ["state", "against", "expected", "source"],
434
+ "additionalProperties": false,
435
+ "properties": {
436
+ "state": { "enum": ["matched", "not_compared"] },
437
+ "against": { "type": ["string", "null"] },
438
+ "expected": {
439
+ "oneOf": [{ "$ref": "#/$defs/sha256" }, { "type": "null" }]
440
+ },
441
+ "source": { "type": ["string", "null"] }
442
+ }
443
+ }
444
+ }
445
+ },
446
+ "capsuleDeliveryEvidence": {
447
+ "type": "object",
448
+ "required": [
449
+ "basis",
450
+ "observed",
451
+ "sender_computed",
452
+ "host_recomputed",
453
+ "host_echoed",
454
+ "delivered_capsule_version",
455
+ "host_boundary_comparison",
456
+ "request_id"
457
+ ],
458
+ "additionalProperties": false,
459
+ "properties": {
460
+ "basis": { "const": "kdna-capsule-jcs-v1" },
461
+ "observed": {
462
+ "oneOf": [{ "$ref": "#/$defs/sha256" }, { "type": "null" }]
463
+ },
464
+ "sender_computed": { "type": "boolean" },
465
+ "host_recomputed": {
466
+ "oneOf": [{ "$ref": "#/$defs/sha256" }, { "type": "null" }]
467
+ },
468
+ "host_echoed": {
469
+ "oneOf": [{ "$ref": "#/$defs/sha256" }, { "type": "null" }]
470
+ },
471
+ "delivered_capsule_version": {
472
+ "type": ["string", "null"],
473
+ "enum": ["2.0", null]
474
+ },
475
+ "host_boundary_comparison": {
476
+ "enum": ["matched", "mismatched", "not_delivered", "not_observed", "unavailable"]
477
+ },
478
+ "request_id": {
479
+ "oneOf": [{ "type": "string", "pattern": "^host_[0-9a-f]{24}$" }, { "type": "null" }]
480
+ }
481
+ },
482
+ "allOf": [
483
+ {
484
+ "if": {
485
+ "properties": { "host_boundary_comparison": { "const": "matched" } },
486
+ "required": ["host_boundary_comparison"]
487
+ },
488
+ "then": {
489
+ "properties": {
490
+ "observed": { "$ref": "#/$defs/sha256" },
491
+ "sender_computed": { "const": true },
492
+ "host_recomputed": { "$ref": "#/$defs/sha256" },
493
+ "host_echoed": { "$ref": "#/$defs/sha256" },
494
+ "delivered_capsule_version": { "const": "2.0" },
495
+ "request_id": { "type": "string", "pattern": "^host_[0-9a-f]{24}$" }
496
+ }
497
+ }
498
+ },
499
+ {
500
+ "if": {
501
+ "properties": { "host_boundary_comparison": { "const": "mismatched" } },
502
+ "required": ["host_boundary_comparison"]
503
+ },
504
+ "then": {
505
+ "properties": {
506
+ "observed": { "$ref": "#/$defs/sha256" },
507
+ "sender_computed": { "const": true },
508
+ "host_recomputed": { "$ref": "#/$defs/sha256" },
509
+ "host_echoed": { "$ref": "#/$defs/sha256" },
510
+ "delivered_capsule_version": { "const": "2.0" },
511
+ "request_id": { "type": "string", "pattern": "^host_[0-9a-f]{24}$" }
512
+ }
513
+ }
514
+ },
515
+ {
516
+ "if": {
517
+ "properties": { "host_boundary_comparison": { "const": "not_observed" } },
518
+ "required": ["host_boundary_comparison"]
519
+ },
520
+ "then": {
521
+ "properties": {
522
+ "observed": { "$ref": "#/$defs/sha256" },
523
+ "sender_computed": { "const": true },
524
+ "host_recomputed": { "type": "null" },
525
+ "host_echoed": { "type": "null" },
526
+ "delivered_capsule_version": { "const": "2.0" },
527
+ "request_id": { "type": "string", "pattern": "^host_[0-9a-f]{24}$" }
528
+ }
529
+ }
530
+ },
531
+ {
532
+ "if": {
533
+ "properties": {
534
+ "host_boundary_comparison": {
535
+ "enum": ["not_delivered", "unavailable"]
536
+ }
537
+ },
538
+ "required": ["host_boundary_comparison"]
539
+ },
540
+ "then": {
541
+ "properties": {
542
+ "host_recomputed": { "type": "null" },
543
+ "host_echoed": { "type": "null" },
544
+ "delivered_capsule_version": { "type": "null" },
545
+ "request_id": { "type": "null" }
546
+ }
547
+ }
548
+ },
549
+ {
550
+ "if": {
551
+ "properties": { "host_boundary_comparison": { "const": "unavailable" } },
552
+ "required": ["host_boundary_comparison"]
553
+ },
554
+ "then": {
555
+ "properties": {
556
+ "observed": { "type": "null" },
557
+ "sender_computed": { "const": false }
558
+ }
559
+ }
560
+ }
561
+ ]
562
+ },
563
+ "projectionActual": {
564
+ "type": "object",
565
+ "required": ["profile", "capsule_delivery_digest", "profile_deviated_from_plan"],
566
+ "additionalProperties": false,
567
+ "properties": {
568
+ "profile": {
569
+ "type": ["string", "null"],
570
+ "enum": ["index", "compact", "scenario", "full", null]
571
+ },
572
+ "capsule_delivery_digest": {
573
+ "oneOf": [{ "$ref": "#/$defs/sha256" }, { "type": "null" }]
574
+ },
575
+ "profile_deviated_from_plan": { "type": ["boolean", "null"] }
576
+ }
577
+ },
578
+ "execution": {
579
+ "type": "object",
580
+ "required": [
581
+ "delivery_status",
582
+ "semantic_consumption",
583
+ "execution_status",
584
+ "conformance_status",
585
+ "model_identity"
586
+ ],
587
+ "additionalProperties": false,
588
+ "properties": {
589
+ "delivery_status": {
590
+ "enum": ["correlated_response", "rejected_before_execution", "not_delivered"]
591
+ },
592
+ "semantic_consumption": { "$ref": "#/$defs/semanticConsumption" },
593
+ "execution_status": {
594
+ "enum": ["completed", "not_started", "failed", "cancelled", "timed_out"]
595
+ },
596
+ "conformance_status": { "const": "not_evaluated" },
597
+ "model_identity": { "$ref": "#/$defs/modelIdentity" }
598
+ }
599
+ },
600
+ "semanticConsumption": {
601
+ "type": "object",
602
+ "required": ["state", "basis"],
603
+ "additionalProperties": false,
604
+ "properties": {
605
+ "state": { "const": "not_observed" },
606
+ "basis": { "type": "null" }
607
+ }
608
+ },
609
+ "modelIdentity": {
610
+ "type": "object",
611
+ "required": ["value", "basis"],
612
+ "additionalProperties": false,
613
+ "properties": {
614
+ "value": { "type": ["string", "null"], "minLength": 1 },
615
+ "basis": { "enum": ["host_reported", "not_observed"] }
616
+ },
617
+ "allOf": [
618
+ {
619
+ "if": {
620
+ "properties": { "basis": { "const": "host_reported" } },
621
+ "required": ["basis"]
622
+ },
623
+ "then": { "properties": { "value": { "type": "string", "minLength": 1 } } },
624
+ "else": { "properties": { "value": { "type": "null" } } }
625
+ }
626
+ ]
627
+ },
628
+ "budgetEvidence": {
629
+ "type": "object",
630
+ "required": ["limits", "actual", "comparison"],
631
+ "additionalProperties": false,
632
+ "properties": {
633
+ "limits": {
634
+ "$ref": "https://github.com/aikdna/kdna/specs/consumption-plan-1.schema.json#/$defs/budget"
635
+ },
636
+ "actual": { "$ref": "#/$defs/budgetActual" },
637
+ "comparison": { "$ref": "#/$defs/budgetComparison" }
638
+ }
639
+ },
640
+ "budgetActual": {
641
+ "type": "object",
642
+ "required": [
643
+ "projection_chars",
644
+ "task_chars",
645
+ "elapsed_ms",
646
+ "elapsed_basis",
647
+ "tokens_used",
648
+ "model_calls",
649
+ "usage_basis"
650
+ ],
651
+ "additionalProperties": false,
652
+ "properties": {
653
+ "projection_chars": {
654
+ "oneOf": [{ "type": "integer", "minimum": 0 }, { "type": "null" }]
655
+ },
656
+ "task_chars": { "type": "integer", "minimum": 0 },
657
+ "elapsed_ms": {
658
+ "oneOf": [{ "type": "integer", "minimum": 0 }, { "type": "null" }]
659
+ },
660
+ "elapsed_basis": { "enum": ["host_monotonic", "not_observed"] },
661
+ "tokens_used": {
662
+ "oneOf": [{ "type": "integer", "minimum": 0 }, { "type": "null" }]
663
+ },
664
+ "model_calls": {
665
+ "oneOf": [{ "type": "integer", "minimum": 0 }, { "type": "null" }]
666
+ },
667
+ "usage_basis": { "enum": ["host_reported", "not_observed"] }
668
+ },
669
+ "allOf": [
670
+ {
671
+ "if": {
672
+ "properties": { "elapsed_basis": { "const": "host_monotonic" } },
673
+ "required": ["elapsed_basis"]
674
+ },
675
+ "then": {
676
+ "properties": { "elapsed_ms": { "type": "integer", "minimum": 0 } }
677
+ },
678
+ "else": { "properties": { "elapsed_ms": { "type": "null" } } }
679
+ },
680
+ {
681
+ "if": {
682
+ "properties": { "usage_basis": { "const": "host_reported" } },
683
+ "required": ["usage_basis"]
684
+ },
685
+ "then": {
686
+ "properties": {
687
+ "tokens_used": { "type": "integer", "minimum": 0 },
688
+ "model_calls": { "type": "integer", "minimum": 0 }
689
+ }
690
+ },
691
+ "else": {
692
+ "properties": {
693
+ "tokens_used": { "type": "null" },
694
+ "model_calls": { "type": "null" }
695
+ }
696
+ }
697
+ }
698
+ ]
699
+ },
700
+ "budgetComparison": {
701
+ "type": "object",
702
+ "required": [
703
+ "projection_chars",
704
+ "task_chars",
705
+ "elapsed_ms",
706
+ "tokens_used",
707
+ "model_calls",
708
+ "overall"
709
+ ],
710
+ "additionalProperties": false,
711
+ "properties": {
712
+ "projection_chars": { "enum": ["within_limit", "exceeded", "not_observed"] },
713
+ "task_chars": { "enum": ["within_limit", "exceeded"] },
714
+ "elapsed_ms": { "enum": ["within_limit", "exceeded", "not_observed"] },
715
+ "tokens_used": {
716
+ "enum": ["within_limit", "exceeded", "not_limited", "not_observed"]
717
+ },
718
+ "model_calls": {
719
+ "enum": ["within_limit", "exceeded", "not_limited", "not_observed"]
720
+ },
721
+ "overall": { "enum": ["within_limit", "exceeded", "not_observed"] }
722
+ }
723
+ },
724
+ "resultRef": {
725
+ "type": "object",
726
+ "required": ["shape", "result_digest", "basis", "stored"],
727
+ "additionalProperties": false,
728
+ "properties": {
729
+ "shape": { "const": "structured_judgment" },
730
+ "result_digest": { "$ref": "#/$defs/sha256" },
731
+ "basis": { "const": "kdna-result-jcs-v1" },
732
+ "stored": { "type": "boolean" }
733
+ }
734
+ },
735
+ "issue": {
736
+ "type": "object",
737
+ "required": ["code", "message", "phase"],
738
+ "additionalProperties": false,
739
+ "properties": {
740
+ "code": { "type": "string", "minLength": 1 },
741
+ "message": { "type": "string", "minLength": 1 },
742
+ "phase": {
743
+ "enum": ["plan", "negotiation", "load", "budget", "delivery", "host", "execution"]
744
+ }
745
+ }
746
+ }
747
+ }
748
+ }