vetra 0.1.0.pre.alpha.4

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,961 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:vetra:ir:0.3",
4
+ "title": "Vetra Application Graph IR 0.3",
5
+ "description": "Contrato do ADR-001 com geração temporal do ADR-027 e retornos estruturados do ADR-028. Forma estrutural; referências, tipos de literais, manifesto, digest e demais invariantes exigem validação semântica.",
6
+ "type": "object",
7
+ "properties": {
8
+ "ir_version": {"const": "0.3"},
9
+ "requires": {
10
+ "type": "array",
11
+ "items": {"enum": ["vetra.core", "vetra.live", "vetra.timestamps", "vetra.structured_outputs"]},
12
+ "minItems": 1,
13
+ "uniqueItems": true,
14
+ "contains": {"const": "vetra.core"}
15
+ },
16
+ "producer": {
17
+ "type": "object",
18
+ "properties": {
19
+ "name": {"const": "vetra"},
20
+ "version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$"},
21
+ "ruby_version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"}
22
+ },
23
+ "required": ["name", "version", "ruby_version"],
24
+ "additionalProperties": false
25
+ },
26
+ "app": {
27
+ "type": "object",
28
+ "properties": {
29
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
30
+ "tenant": {"$ref": "#/$defs/tenant"},
31
+ "currency": {"type": "string", "pattern": "^[A-Z]{3}$"},
32
+ "locale": {"type": "string", "minLength": 1}
33
+ },
34
+ "required": ["name", "tenant", "currency", "locale"],
35
+ "additionalProperties": false
36
+ },
37
+ "inputs": {"type": "array", "items": {"$ref": "#/$defs/input_file"}, "minItems": 1, "uniqueItems": true},
38
+ "nodes": {
39
+ "type": "array",
40
+ "items": {
41
+ "oneOf": [
42
+ {"$ref": "#/$defs/domain"},
43
+ {"$ref": "#/$defs/entity"},
44
+ {"$ref": "#/$defs/contract"},
45
+ {"$ref": "#/$defs/command"},
46
+ {"$ref": "#/$defs/query"},
47
+ {"$ref": "#/$defs/role"},
48
+ {"$ref": "#/$defs/policy"},
49
+ {"$ref": "#/$defs/capability"},
50
+ {"$ref": "#/$defs/event"},
51
+ {"$ref": "#/$defs/handler"},
52
+ {"$ref": "#/$defs/route"},
53
+ {"$ref": "#/$defs/dependency"}
54
+ ]
55
+ },
56
+ "minItems": 1,
57
+ "uniqueItems": true
58
+ },
59
+ "digest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
60
+ "annotations": {"$ref": "#/$defs/annotations"}
61
+ },
62
+ "required": ["ir_version", "requires", "producer", "app", "inputs", "nodes", "digest"],
63
+ "additionalProperties": false,
64
+ "$defs": {
65
+ "domain_ref": {
66
+ "type": "object",
67
+ "properties": {"kind": {"const": "domain"}, "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}},
68
+ "required": ["kind", "id"],
69
+ "additionalProperties": false
70
+ },
71
+ "entity_ref": {
72
+ "type": "object",
73
+ "properties": {
74
+ "kind": {"const": "entity"},
75
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
76
+ },
77
+ "required": ["kind", "id"],
78
+ "additionalProperties": false
79
+ },
80
+ "contract_ref": {
81
+ "type": "object",
82
+ "properties": {
83
+ "kind": {"const": "contract"},
84
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
85
+ },
86
+ "required": ["kind", "id"],
87
+ "additionalProperties": false
88
+ },
89
+ "command_ref": {
90
+ "type": "object",
91
+ "properties": {
92
+ "kind": {"const": "command"},
93
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
94
+ },
95
+ "required": ["kind", "id"],
96
+ "additionalProperties": false
97
+ },
98
+ "query_ref": {
99
+ "type": "object",
100
+ "properties": {
101
+ "kind": {"const": "query"},
102
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
103
+ },
104
+ "required": ["kind", "id"],
105
+ "additionalProperties": false
106
+ },
107
+ "role_ref": {
108
+ "type": "object",
109
+ "properties": {
110
+ "kind": {"const": "role"},
111
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
112
+ },
113
+ "required": ["kind", "id"],
114
+ "additionalProperties": false
115
+ },
116
+ "policy_ref": {
117
+ "type": "object",
118
+ "properties": {
119
+ "kind": {"const": "policy"},
120
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
121
+ },
122
+ "required": ["kind", "id"],
123
+ "additionalProperties": false
124
+ },
125
+ "capability_ref": {
126
+ "type": "object",
127
+ "properties": {
128
+ "kind": {"const": "capability"},
129
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
130
+ },
131
+ "required": ["kind", "id"],
132
+ "additionalProperties": false
133
+ },
134
+ "event_ref": {
135
+ "type": "object",
136
+ "properties": {
137
+ "kind": {"const": "event"},
138
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
139
+ },
140
+ "required": ["kind", "id"],
141
+ "additionalProperties": false
142
+ },
143
+ "handler_ref": {
144
+ "type": "object",
145
+ "properties": {
146
+ "kind": {"const": "handler"},
147
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
148
+ },
149
+ "required": ["kind", "id"],
150
+ "additionalProperties": false
151
+ },
152
+ "route_ref": {
153
+ "type": "object",
154
+ "properties": {
155
+ "kind": {"const": "route"},
156
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
157
+ },
158
+ "required": ["kind", "id"],
159
+ "additionalProperties": false
160
+ },
161
+ "dependency_ref": {
162
+ "type": "object",
163
+ "properties": {
164
+ "kind": {"const": "dependency"},
165
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
166
+ },
167
+ "required": ["kind", "id"],
168
+ "additionalProperties": false
169
+ },
170
+ "json_value": {
171
+ "oneOf": [
172
+ {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991},
173
+ {"type": "string"},
174
+ {"type": "boolean"},
175
+ {"type": "null"},
176
+ {"type": "array", "items": {"$ref": "#/$defs/json_value"}},
177
+ {"type": "object", "additionalProperties": {"$ref": "#/$defs/json_value"}}
178
+ ]
179
+ },
180
+ "reference": {
181
+ "type": "object",
182
+ "properties": {
183
+ "kind": {
184
+ "enum": [
185
+ "domain",
186
+ "entity",
187
+ "contract",
188
+ "command",
189
+ "query",
190
+ "role",
191
+ "policy",
192
+ "capability",
193
+ "event",
194
+ "handler",
195
+ "route",
196
+ "dependency"
197
+ ]
198
+ },
199
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)*$"}
200
+ },
201
+ "required": ["kind", "id"],
202
+ "additionalProperties": false
203
+ },
204
+ "source": {
205
+ "type": "object",
206
+ "properties": {
207
+ "path": {
208
+ "type": "string",
209
+ "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\/$)[^\\u0000-\\u001f]+$"
210
+ },
211
+ "line": {"type": "integer", "minimum": 1, "maximum": 9007199254740991}
212
+ },
213
+ "required": ["path", "line"],
214
+ "additionalProperties": false
215
+ },
216
+ "input_file": {
217
+ "type": "object",
218
+ "properties": {
219
+ "path": {
220
+ "type": "string",
221
+ "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\/$)[^\\u0000-\\u001f]+$"
222
+ },
223
+ "digest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"}
224
+ },
225
+ "required": ["path", "digest"],
226
+ "additionalProperties": false
227
+ },
228
+ "tenant": {
229
+ "oneOf": [
230
+ {"type": "null"},
231
+ {
232
+ "type": "object",
233
+ "properties": {
234
+ "entity": {"$ref": "#/$defs/entity_ref"},
235
+ "field": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}
236
+ },
237
+ "required": ["entity", "field"],
238
+ "additionalProperties": false
239
+ }
240
+ ]
241
+ },
242
+ "annotations": {
243
+ "type": "object",
244
+ "propertyNames": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"},
245
+ "additionalProperties": {"$ref": "#/$defs/json_value"}
246
+ },
247
+ "node_base": {
248
+ "type": "object",
249
+ "properties": {
250
+ "id": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)*$"},
251
+ "kind": {
252
+ "enum": [
253
+ "domain",
254
+ "entity",
255
+ "contract",
256
+ "command",
257
+ "query",
258
+ "role",
259
+ "policy",
260
+ "capability",
261
+ "event",
262
+ "handler",
263
+ "route",
264
+ "dependency"
265
+ ]
266
+ },
267
+ "source": {"$ref": "#/$defs/source"},
268
+ "generated_from": {"$ref": "#/$defs/reference"},
269
+ "previous_ids": {
270
+ "type": "array",
271
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)*$"},
272
+ "minItems": 1,
273
+ "uniqueItems": true
274
+ },
275
+ "annotations": {"$ref": "#/$defs/annotations"}
276
+ },
277
+ "required": ["id", "kind", "source"]
278
+ },
279
+ "type": {
280
+ "oneOf": [
281
+ {
282
+ "type": "object",
283
+ "properties": {"name": {"enum": ["string", "text", "email", "boolean", "integer", "date", "timestamp", "json"]}},
284
+ "required": ["name"],
285
+ "additionalProperties": false
286
+ },
287
+ {
288
+ "type": "object",
289
+ "properties": {"name": {"const": "id"}, "entity": {"$ref": "#/$defs/entity_ref"}},
290
+ "required": ["name"],
291
+ "additionalProperties": false
292
+ },
293
+ {
294
+ "type": "object",
295
+ "properties": {
296
+ "name": {"const": "enum"},
297
+ "values": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1, "uniqueItems": true},
298
+ "groups": {
299
+ "type": "object",
300
+ "propertyNames": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
301
+ "additionalProperties": {
302
+ "type": "array",
303
+ "items": {"type": "string", "minLength": 1},
304
+ "minItems": 1,
305
+ "uniqueItems": true
306
+ }
307
+ }
308
+ },
309
+ "required": ["name", "values"],
310
+ "additionalProperties": false
311
+ },
312
+ {
313
+ "type": "object",
314
+ "properties": {
315
+ "name": {"enum": ["decimal", "money"]},
316
+ "precision": {"type": "integer", "minimum": 1, "maximum": 1000},
317
+ "scale": {"type": "integer", "minimum": 0, "maximum": 1000}
318
+ },
319
+ "required": ["name", "precision", "scale"],
320
+ "additionalProperties": false
321
+ },
322
+ {
323
+ "type": "object",
324
+ "properties": {
325
+ "name": {"enum": ["record", "collection"]},
326
+ "contract": {"$ref": "#/$defs/contract_ref"}
327
+ },
328
+ "required": ["name", "contract"],
329
+ "additionalProperties": false
330
+ }
331
+ ]
332
+ },
333
+ "privacy": {
334
+ "oneOf": [
335
+ {
336
+ "type": "object",
337
+ "properties": {"personal": {"const": false}},
338
+ "required": ["personal"],
339
+ "additionalProperties": false
340
+ },
341
+ {
342
+ "type": "object",
343
+ "properties": {"personal": {"const": true}, "classification": {"enum": ["personal", "sensitive"]}},
344
+ "required": ["personal", "classification"],
345
+ "additionalProperties": false
346
+ }
347
+ ]
348
+ },
349
+ "literal": {
350
+ "type": "object",
351
+ "properties": {"kind": {"const": "literal"}, "value": {"$ref": "#/$defs/json_value"}},
352
+ "required": ["kind", "value"],
353
+ "additionalProperties": false
354
+ },
355
+ "default": {
356
+ "oneOf": [
357
+ {"$ref": "#/$defs/literal"},
358
+ {
359
+ "type": "object",
360
+ "properties": {"kind": {"const": "context"}, "name": {"enum": ["current_actor", "current_tenant"]}},
361
+ "required": ["kind", "name"],
362
+ "additionalProperties": false
363
+ }
364
+ ]
365
+ },
366
+ "guard": {
367
+ "type": "object",
368
+ "properties": {
369
+ "value": {"type": "string", "minLength": 1},
370
+ "commands": {"type": "array", "items": {"$ref": "#/$defs/command_ref"}, "minItems": 1, "uniqueItems": true}
371
+ },
372
+ "required": ["value", "commands"],
373
+ "additionalProperties": false
374
+ },
375
+ "field": {
376
+ "type": "object",
377
+ "properties": {
378
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
379
+ "type": {"$ref": "#/$defs/type"},
380
+ "required": {"type": "boolean"},
381
+ "nullable": {"type": "boolean"},
382
+ "privacy": {"$ref": "#/$defs/privacy"},
383
+ "default": {"$ref": "#/$defs/default"},
384
+ "previous_names": {
385
+ "type": "array",
386
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
387
+ "minItems": 1,
388
+ "uniqueItems": true
389
+ },
390
+ "set_by": {"type": "array", "items": {"$ref": "#/$defs/command_ref"}, "minItems": 1, "uniqueItems": true},
391
+ "guarded": {"type": "array", "items": {"$ref": "#/$defs/guard"}, "minItems": 1, "uniqueItems": true},
392
+ "normalize": {"type": "array", "items": {"enum": ["downcase"]}, "minItems": 1, "uniqueItems": true},
393
+ "generate": {
394
+ "oneOf": [
395
+ {
396
+ "type": "object",
397
+ "properties": {"kind": {"const": "slug"}, "from": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}},
398
+ "required": ["kind", "from"],
399
+ "additionalProperties": false
400
+ },
401
+ {
402
+ "type": "object",
403
+ "properties": {"kind": {"const": "timestamp"}, "on": {"const": "create"}},
404
+ "required": ["kind", "on"],
405
+ "additionalProperties": false
406
+ }
407
+ ]
408
+ },
409
+ "constraints": {
410
+ "type": "object",
411
+ "properties": {
412
+ "min_length": {"type": "integer", "minimum": 0, "maximum": 9007199254740991},
413
+ "max_length": {"type": "integer", "minimum": 0, "maximum": 9007199254740991},
414
+ "unique": {"type": "boolean"}
415
+ },
416
+ "required": [],
417
+ "additionalProperties": false
418
+ }
419
+ },
420
+ "required": ["name", "type", "required", "nullable", "privacy"],
421
+ "additionalProperties": false,
422
+ "allOf": [
423
+ {
424
+ "if": {"properties": {"type": {"properties": {"name": {"const": "decimal"}}}}},
425
+ "then": {
426
+ "properties": {
427
+ "default": {
428
+ "properties": {
429
+ "value": {
430
+ "oneOf": [{"type": "string", "pattern": "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"}, {"type": "null"}]
431
+ }
432
+ }
433
+ }
434
+ }
435
+ }
436
+ },
437
+ {
438
+ "if": {"properties": {"type": {"properties": {"name": {"const": "money"}}}}},
439
+ "then": {
440
+ "properties": {
441
+ "default": {
442
+ "properties": {
443
+ "value": {
444
+ "oneOf": [
445
+ {
446
+ "type": "object",
447
+ "properties": {
448
+ "amount": {"type": "string", "pattern": "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"},
449
+ "currency": {"type": "string", "pattern": "^[A-Z]{3}$"}
450
+ },
451
+ "required": ["amount", "currency"],
452
+ "additionalProperties": false
453
+ },
454
+ {"type": "null"}
455
+ ]
456
+ }
457
+ }
458
+ }
459
+ }
460
+ }
461
+ },
462
+ {
463
+ "if": {"required": ["guarded"]},
464
+ "then": {"properties": {"type": {"properties": {"name": {"const": "enum"}}}}}
465
+ }
466
+ ]
467
+ },
468
+ "relation": {
469
+ "type": "object",
470
+ "properties": {
471
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
472
+ "kind": {"enum": ["belongs_to", "has_many", "many_to_many"]},
473
+ "target": {"$ref": "#/$defs/entity_ref"},
474
+ "same_tenant": {"type": "boolean"},
475
+ "local_fields": {
476
+ "type": "array",
477
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
478
+ "minItems": 1,
479
+ "uniqueItems": true
480
+ },
481
+ "target_fields": {
482
+ "type": "array",
483
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
484
+ "minItems": 1,
485
+ "uniqueItems": true
486
+ },
487
+ "through": {"$ref": "#/$defs/entity_ref"},
488
+ "include_on_create": {
489
+ "type": "array",
490
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
491
+ "minItems": 1,
492
+ "uniqueItems": true
493
+ }
494
+ },
495
+ "required": ["name", "kind", "target", "same_tenant", "local_fields", "target_fields"],
496
+ "additionalProperties": false
497
+ },
498
+ "operand": {
499
+ "oneOf": [
500
+ {"$ref": "#/$defs/literal"},
501
+ {
502
+ "type": "object",
503
+ "properties": {
504
+ "kind": {"enum": ["field", "actor", "input"]},
505
+ "path": {"type": "array", "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}, "minItems": 1}
506
+ },
507
+ "required": ["kind", "path"],
508
+ "additionalProperties": false
509
+ }
510
+ ]
511
+ },
512
+ "predicate": {
513
+ "oneOf": [
514
+ {
515
+ "type": "object",
516
+ "properties": {"op": {"enum": ["true", "false"]}},
517
+ "required": ["op"],
518
+ "additionalProperties": false
519
+ },
520
+ {
521
+ "type": "object",
522
+ "properties": {
523
+ "op": {"enum": ["eq", "in"]},
524
+ "left": {"$ref": "#/$defs/operand"},
525
+ "right": {"$ref": "#/$defs/operand"}
526
+ },
527
+ "required": ["op", "left", "right"],
528
+ "additionalProperties": false
529
+ },
530
+ {
531
+ "type": "object",
532
+ "properties": {
533
+ "op": {"enum": ["and", "or"]},
534
+ "terms": {"type": "array", "items": {"$ref": "#/$defs/predicate"}, "minItems": 1}
535
+ },
536
+ "required": ["op", "terms"],
537
+ "additionalProperties": false
538
+ },
539
+ {
540
+ "type": "object",
541
+ "properties": {"op": {"const": "not"}, "term": {"$ref": "#/$defs/predicate"}},
542
+ "required": ["op", "term"],
543
+ "additionalProperties": false
544
+ },
545
+ {
546
+ "type": "object",
547
+ "properties": {
548
+ "op": {"const": "exists"},
549
+ "relation": {"type": "array", "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}, "minItems": 1},
550
+ "where": {"$ref": "#/$defs/predicate"}
551
+ },
552
+ "required": ["op", "relation", "where"],
553
+ "additionalProperties": false
554
+ }
555
+ ]
556
+ },
557
+ "analysis": {
558
+ "type": "object",
559
+ "properties": {
560
+ "status": {"enum": ["complete", "incomplete"]},
561
+ "constants": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 0, "uniqueItems": true},
562
+ "dynamic": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 0, "uniqueItems": true}
563
+ },
564
+ "required": ["status", "constants", "dynamic"],
565
+ "additionalProperties": false
566
+ },
567
+ "implementation": {
568
+ "oneOf": [
569
+ {
570
+ "type": "object",
571
+ "properties": {
572
+ "kind": {"const": "builtin"},
573
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
574
+ },
575
+ "required": ["kind", "name"],
576
+ "additionalProperties": false
577
+ },
578
+ {
579
+ "type": "object",
580
+ "properties": {
581
+ "kind": {"const": "ruby"},
582
+ "ref": {"type": "string", "pattern": "^[a-z][a-z0-9_.]*#call$"},
583
+ "path": {
584
+ "type": "string",
585
+ "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\/$)[^\\u0000-\\u001f]+$"
586
+ },
587
+ "digest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
588
+ "analysis": {"$ref": "#/$defs/analysis"}
589
+ },
590
+ "required": ["kind", "ref", "path", "digest", "analysis"],
591
+ "additionalProperties": false
592
+ }
593
+ ]
594
+ },
595
+ "authorization": {
596
+ "type": "object",
597
+ "properties": {
598
+ "action": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
599
+ "entity": {"$ref": "#/$defs/entity_ref"},
600
+ "record": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}
601
+ },
602
+ "required": ["action", "entity"],
603
+ "additionalProperties": false
604
+ },
605
+ "emission": {
606
+ "type": "object",
607
+ "properties": {
608
+ "event": {"$ref": "#/$defs/event_ref"},
609
+ "from": {"$ref": "#/$defs/entity_ref"},
610
+ "fields": {
611
+ "type": "array",
612
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
613
+ "minItems": 1,
614
+ "uniqueItems": true
615
+ }
616
+ },
617
+ "required": ["event", "from", "fields"],
618
+ "additionalProperties": false
619
+ },
620
+ "live": {
621
+ "type": "object",
622
+ "properties": {
623
+ "mode": {"enum": ["strict", "balanced"]},
624
+ "depends_on": {"type": "array", "items": {"$ref": "#/$defs/entity_ref"}, "minItems": 1, "uniqueItems": true}
625
+ },
626
+ "required": ["mode", "depends_on"],
627
+ "additionalProperties": false
628
+ },
629
+ "capability_config": {
630
+ "oneOf": [
631
+ {
632
+ "type": "object",
633
+ "properties": {
634
+ "type": {"const": "repository"},
635
+ "entity": {"$ref": "#/$defs/entity_ref"},
636
+ "access": {"enum": ["read", "read_write"]}
637
+ },
638
+ "required": ["type", "entity", "access"],
639
+ "additionalProperties": false
640
+ },
641
+ {
642
+ "type": "object",
643
+ "properties": {"type": {"const": "deterministic"}},
644
+ "required": ["type"],
645
+ "additionalProperties": false
646
+ },
647
+ {
648
+ "type": "object",
649
+ "properties": {
650
+ "type": {"const": "external"},
651
+ "idempotency_key": {"type": "boolean"},
652
+ "hosts": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 0, "uniqueItems": true},
653
+ "timeout_ms": {"type": "integer", "minimum": 1, "maximum": 9007199254740991}
654
+ },
655
+ "required": ["type", "idempotency_key", "hosts", "timeout_ms"],
656
+ "additionalProperties": false
657
+ },
658
+ {
659
+ "type": "object",
660
+ "properties": {"type": {"const": "sql"}, "access": {"enum": ["read", "read_write"]}},
661
+ "required": ["type", "access"],
662
+ "additionalProperties": false
663
+ }
664
+ ]
665
+ },
666
+ "index": {
667
+ "type": "object",
668
+ "properties": {
669
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
670
+ "fields": {
671
+ "type": "array",
672
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
673
+ "minItems": 1,
674
+ "uniqueItems": true
675
+ },
676
+ "unique": {"type": "boolean"},
677
+ "where": {"$ref": "#/$defs/predicate"}
678
+ },
679
+ "required": ["name", "fields", "unique"],
680
+ "additionalProperties": false
681
+ },
682
+ "http_config": {
683
+ "type": "object",
684
+ "properties": {
685
+ "method": {"enum": ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]},
686
+ "path": {"type": "string", "pattern": "^/[^\\s]*$"}
687
+ },
688
+ "required": ["method", "path"],
689
+ "additionalProperties": false
690
+ },
691
+ "named_config": {
692
+ "type": "object",
693
+ "properties": {"name": {"type": "string", "minLength": 1}},
694
+ "required": ["name"],
695
+ "additionalProperties": false
696
+ },
697
+ "domain": {
698
+ "allOf": [
699
+ {"$ref": "#/$defs/node_base"},
700
+ {
701
+ "type": "object",
702
+ "properties": {
703
+ "kind": {"const": "domain"},
704
+ "depends_on": {
705
+ "oneOf": [
706
+ {"type": "null"},
707
+ {"type": "array", "items": {"$ref": "#/$defs/domain_ref"}, "minItems": 0, "uniqueItems": true}
708
+ ]
709
+ }
710
+ },
711
+ "required": ["kind", "depends_on"]
712
+ }
713
+ ],
714
+ "unevaluatedProperties": false
715
+ },
716
+ "entity": {
717
+ "allOf": [
718
+ {"$ref": "#/$defs/node_base"},
719
+ {
720
+ "type": "object",
721
+ "properties": {
722
+ "kind": {"const": "entity"},
723
+ "domain": {"$ref": "#/$defs/domain_ref"},
724
+ "storage": {
725
+ "type": "object",
726
+ "properties": {
727
+ "schema": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
728
+ "table": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
729
+ "primary_key": {
730
+ "type": "array",
731
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
732
+ "minItems": 1,
733
+ "uniqueItems": true
734
+ }
735
+ },
736
+ "required": ["schema", "table", "primary_key"],
737
+ "additionalProperties": false
738
+ },
739
+ "tenant": {"$ref": "#/$defs/tenant"},
740
+ "fields": {"type": "array", "items": {"$ref": "#/$defs/field"}, "minItems": 1, "uniqueItems": true},
741
+ "relations": {"type": "array", "items": {"$ref": "#/$defs/relation"}, "minItems": 0, "uniqueItems": true},
742
+ "indexes": {"type": "array", "items": {"$ref": "#/$defs/index"}, "minItems": 0, "uniqueItems": true},
743
+ "history": {"enum": ["none", "full"]},
744
+ "transitions": {
745
+ "type": "object",
746
+ "properties": {"enforce": {"enum": ["application", "db"]}},
747
+ "required": ["enforce"],
748
+ "additionalProperties": false
749
+ }
750
+ },
751
+ "required": ["kind", "domain", "storage", "tenant", "fields", "relations", "indexes", "history", "transitions"]
752
+ }
753
+ ],
754
+ "unevaluatedProperties": false
755
+ },
756
+ "contract": {
757
+ "allOf": [
758
+ {"$ref": "#/$defs/node_base"},
759
+ {
760
+ "type": "object",
761
+ "properties": {
762
+ "kind": {"const": "contract"},
763
+ "domain": {"$ref": "#/$defs/domain_ref"},
764
+ "collection": {"const": true},
765
+ "fields": {"type": "array", "items": {"$ref": "#/$defs/field"}, "minItems": 0, "uniqueItems": true}
766
+ },
767
+ "required": ["kind", "domain", "fields"]
768
+ }
769
+ ],
770
+ "unevaluatedProperties": false
771
+ },
772
+ "command": {
773
+ "allOf": [
774
+ {"$ref": "#/$defs/node_base"},
775
+ {
776
+ "type": "object",
777
+ "properties": {
778
+ "kind": {"const": "command"},
779
+ "domain": {"$ref": "#/$defs/domain_ref"},
780
+ "input": {"$ref": "#/$defs/contract_ref"},
781
+ "output": {"$ref": "#/$defs/contract_ref"},
782
+ "authorize": {"$ref": "#/$defs/authorization"},
783
+ "uses": {"type": "array", "items": {"$ref": "#/$defs/capability_ref"}, "minItems": 0, "uniqueItems": true},
784
+ "implementation": {"$ref": "#/$defs/implementation"},
785
+ "unsafe_effect": {"type": "string", "minLength": 1},
786
+ "emits": {"type": "array", "items": {"$ref": "#/$defs/emission"}, "minItems": 0, "uniqueItems": true}
787
+ },
788
+ "required": ["kind", "domain", "input", "output", "authorize", "uses", "implementation", "emits"]
789
+ }
790
+ ],
791
+ "unevaluatedProperties": false
792
+ },
793
+ "query": {
794
+ "allOf": [
795
+ {"$ref": "#/$defs/node_base"},
796
+ {
797
+ "type": "object",
798
+ "properties": {
799
+ "kind": {"const": "query"},
800
+ "domain": {"$ref": "#/$defs/domain_ref"},
801
+ "input": {"$ref": "#/$defs/contract_ref"},
802
+ "output": {"$ref": "#/$defs/contract_ref"},
803
+ "authorize": {"$ref": "#/$defs/authorization"},
804
+ "uses": {"type": "array", "items": {"$ref": "#/$defs/capability_ref"}, "minItems": 0, "uniqueItems": true},
805
+ "implementation": {"$ref": "#/$defs/implementation"},
806
+ "unsafe_effect": {"type": "string", "minLength": 1},
807
+ "live": {"$ref": "#/$defs/live"}
808
+ },
809
+ "required": ["kind", "domain", "input", "output", "authorize", "uses", "implementation"]
810
+ }
811
+ ],
812
+ "unevaluatedProperties": false
813
+ },
814
+ "role": {
815
+ "allOf": [
816
+ {"$ref": "#/$defs/node_base"},
817
+ {
818
+ "type": "object",
819
+ "properties": {
820
+ "kind": {"const": "role"},
821
+ "domain": {"$ref": "#/$defs/domain_ref"},
822
+ "anonymous": {"type": "boolean"}
823
+ },
824
+ "required": ["kind", "domain", "anonymous"]
825
+ }
826
+ ],
827
+ "unevaluatedProperties": false
828
+ },
829
+ "policy": {
830
+ "allOf": [
831
+ {"$ref": "#/$defs/node_base"},
832
+ {
833
+ "type": "object",
834
+ "properties": {
835
+ "kind": {"const": "policy"},
836
+ "domain": {"$ref": "#/$defs/domain_ref"},
837
+ "role": {"$ref": "#/$defs/role_ref"},
838
+ "entity": {"$ref": "#/$defs/entity_ref"},
839
+ "actions": {
840
+ "type": "array",
841
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
842
+ "minItems": 1,
843
+ "uniqueItems": true
844
+ },
845
+ "fields": {
846
+ "oneOf": [
847
+ {"const": "*"},
848
+ {
849
+ "type": "array",
850
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
851
+ "minItems": 0,
852
+ "uniqueItems": true
853
+ }
854
+ ]
855
+ },
856
+ "predicate": {"$ref": "#/$defs/predicate"},
857
+ "reads": {"type": "array", "items": {"$ref": "#/$defs/entity_ref"}, "minItems": 1, "uniqueItems": true}
858
+ },
859
+ "required": ["kind", "domain", "role", "entity", "actions", "fields", "predicate", "reads"]
860
+ }
861
+ ],
862
+ "unevaluatedProperties": false
863
+ },
864
+ "capability": {
865
+ "allOf": [
866
+ {"$ref": "#/$defs/node_base"},
867
+ {
868
+ "type": "object",
869
+ "properties": {
870
+ "kind": {"const": "capability"},
871
+ "domain": {"$ref": "#/$defs/domain_ref"},
872
+ "adapter": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"},
873
+ "retry_safe": {"type": "boolean"},
874
+ "simulation": {"enum": ["seeded", "memory", "none"]},
875
+ "config": {"$ref": "#/$defs/capability_config"}
876
+ },
877
+ "required": ["kind", "domain", "adapter", "retry_safe", "simulation", "config"]
878
+ }
879
+ ],
880
+ "unevaluatedProperties": false
881
+ },
882
+ "event": {
883
+ "allOf": [
884
+ {"$ref": "#/$defs/node_base"},
885
+ {
886
+ "type": "object",
887
+ "properties": {
888
+ "kind": {"const": "event"},
889
+ "domain": {"$ref": "#/$defs/domain_ref"},
890
+ "payload": {"$ref": "#/$defs/contract_ref"},
891
+ "version": {"type": "integer", "minimum": 1, "maximum": 9007199254740991},
892
+ "visibility": {"enum": ["internal", "public"]},
893
+ "consumer_required": {"type": "boolean"}
894
+ },
895
+ "required": ["kind", "domain", "payload", "version", "visibility", "consumer_required"]
896
+ }
897
+ ],
898
+ "unevaluatedProperties": false
899
+ },
900
+ "handler": {
901
+ "allOf": [
902
+ {"$ref": "#/$defs/node_base"},
903
+ {
904
+ "type": "object",
905
+ "properties": {
906
+ "kind": {"const": "handler"},
907
+ "domain": {"$ref": "#/$defs/domain_ref"},
908
+ "on": {"type": "array", "items": {"$ref": "#/$defs/event_ref"}, "minItems": 1, "uniqueItems": true},
909
+ "uses": {"type": "array", "items": {"$ref": "#/$defs/capability_ref"}, "minItems": 0, "uniqueItems": true},
910
+ "calls": {"type": "array", "items": {"$ref": "#/$defs/command_ref"}, "minItems": 0, "uniqueItems": true},
911
+ "idempotent_by": {"const": "event_id"},
912
+ "implementation": {"$ref": "#/$defs/implementation"},
913
+ "unsafe_effect": {"type": "string", "minLength": 1}
914
+ },
915
+ "required": ["kind", "domain", "on", "uses", "calls", "idempotent_by", "implementation"]
916
+ }
917
+ ],
918
+ "unevaluatedProperties": false
919
+ },
920
+ "route": {
921
+ "allOf": [
922
+ {"$ref": "#/$defs/node_base"},
923
+ {
924
+ "type": "object",
925
+ "properties": {
926
+ "kind": {"const": "route"},
927
+ "domain": {"$ref": "#/$defs/domain_ref"},
928
+ "surface": {"enum": ["http", "cli", "job", "webhook"]},
929
+ "target": {"oneOf": [{"$ref": "#/$defs/command_ref"}, {"$ref": "#/$defs/query_ref"}]},
930
+ "config": {"oneOf": [{"$ref": "#/$defs/http_config"}, {"$ref": "#/$defs/named_config"}]},
931
+ "idempotency": {"enum": ["optional", "required"]}
932
+ },
933
+ "required": ["kind", "domain", "surface", "target", "config", "idempotency"]
934
+ },
935
+ {
936
+ "if": {"properties": {"surface": {"enum": ["http", "webhook"]}}},
937
+ "then": {"properties": {"config": {"$ref": "#/$defs/http_config"}}},
938
+ "else": {"properties": {"config": {"$ref": "#/$defs/named_config"}}}
939
+ }
940
+ ],
941
+ "unevaluatedProperties": false
942
+ },
943
+ "dependency": {
944
+ "allOf": [
945
+ {"$ref": "#/$defs/node_base"},
946
+ {
947
+ "type": "object",
948
+ "properties": {
949
+ "kind": {"const": "dependency"},
950
+ "domain": {"$ref": "#/$defs/domain_ref"},
951
+ "name": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]*$"},
952
+ "version": {"type": "string", "minLength": 1},
953
+ "trust": {"enum": ["trusted", "restricted", "outside_guarantee", "unclassified"]}
954
+ },
955
+ "required": ["kind", "domain", "name", "version", "trust"]
956
+ }
957
+ ],
958
+ "unevaluatedProperties": false
959
+ }
960
+ }
961
+ }