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,951 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:vetra:ir:0.2",
4
+ "title": "Vetra Application Graph IR 0.2",
5
+ "description": "Contrato do ADR-001 com geração temporal definida no ADR-027. 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.2"},
9
+ "requires": {
10
+ "type": "array",
11
+ "items": {"enum": ["vetra.core", "vetra.live", "vetra.timestamps"]},
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
+ },
324
+ "privacy": {
325
+ "oneOf": [
326
+ {
327
+ "type": "object",
328
+ "properties": {"personal": {"const": false}},
329
+ "required": ["personal"],
330
+ "additionalProperties": false
331
+ },
332
+ {
333
+ "type": "object",
334
+ "properties": {"personal": {"const": true}, "classification": {"enum": ["personal", "sensitive"]}},
335
+ "required": ["personal", "classification"],
336
+ "additionalProperties": false
337
+ }
338
+ ]
339
+ },
340
+ "literal": {
341
+ "type": "object",
342
+ "properties": {"kind": {"const": "literal"}, "value": {"$ref": "#/$defs/json_value"}},
343
+ "required": ["kind", "value"],
344
+ "additionalProperties": false
345
+ },
346
+ "default": {
347
+ "oneOf": [
348
+ {"$ref": "#/$defs/literal"},
349
+ {
350
+ "type": "object",
351
+ "properties": {"kind": {"const": "context"}, "name": {"enum": ["current_actor", "current_tenant"]}},
352
+ "required": ["kind", "name"],
353
+ "additionalProperties": false
354
+ }
355
+ ]
356
+ },
357
+ "guard": {
358
+ "type": "object",
359
+ "properties": {
360
+ "value": {"type": "string", "minLength": 1},
361
+ "commands": {"type": "array", "items": {"$ref": "#/$defs/command_ref"}, "minItems": 1, "uniqueItems": true}
362
+ },
363
+ "required": ["value", "commands"],
364
+ "additionalProperties": false
365
+ },
366
+ "field": {
367
+ "type": "object",
368
+ "properties": {
369
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
370
+ "type": {"$ref": "#/$defs/type"},
371
+ "required": {"type": "boolean"},
372
+ "nullable": {"type": "boolean"},
373
+ "privacy": {"$ref": "#/$defs/privacy"},
374
+ "default": {"$ref": "#/$defs/default"},
375
+ "previous_names": {
376
+ "type": "array",
377
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
378
+ "minItems": 1,
379
+ "uniqueItems": true
380
+ },
381
+ "set_by": {"type": "array", "items": {"$ref": "#/$defs/command_ref"}, "minItems": 1, "uniqueItems": true},
382
+ "guarded": {"type": "array", "items": {"$ref": "#/$defs/guard"}, "minItems": 1, "uniqueItems": true},
383
+ "normalize": {"type": "array", "items": {"enum": ["downcase"]}, "minItems": 1, "uniqueItems": true},
384
+ "generate": {
385
+ "oneOf": [
386
+ {
387
+ "type": "object",
388
+ "properties": {"kind": {"const": "slug"}, "from": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}},
389
+ "required": ["kind", "from"],
390
+ "additionalProperties": false
391
+ },
392
+ {
393
+ "type": "object",
394
+ "properties": {"kind": {"const": "timestamp"}, "on": {"const": "create"}},
395
+ "required": ["kind", "on"],
396
+ "additionalProperties": false
397
+ }
398
+ ]
399
+ },
400
+ "constraints": {
401
+ "type": "object",
402
+ "properties": {
403
+ "min_length": {"type": "integer", "minimum": 0, "maximum": 9007199254740991},
404
+ "max_length": {"type": "integer", "minimum": 0, "maximum": 9007199254740991},
405
+ "unique": {"type": "boolean"}
406
+ },
407
+ "required": [],
408
+ "additionalProperties": false
409
+ }
410
+ },
411
+ "required": ["name", "type", "required", "nullable", "privacy"],
412
+ "additionalProperties": false,
413
+ "allOf": [
414
+ {
415
+ "if": {"properties": {"type": {"properties": {"name": {"const": "decimal"}}}}},
416
+ "then": {
417
+ "properties": {
418
+ "default": {
419
+ "properties": {
420
+ "value": {
421
+ "oneOf": [{"type": "string", "pattern": "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"}, {"type": "null"}]
422
+ }
423
+ }
424
+ }
425
+ }
426
+ }
427
+ },
428
+ {
429
+ "if": {"properties": {"type": {"properties": {"name": {"const": "money"}}}}},
430
+ "then": {
431
+ "properties": {
432
+ "default": {
433
+ "properties": {
434
+ "value": {
435
+ "oneOf": [
436
+ {
437
+ "type": "object",
438
+ "properties": {
439
+ "amount": {"type": "string", "pattern": "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"},
440
+ "currency": {"type": "string", "pattern": "^[A-Z]{3}$"}
441
+ },
442
+ "required": ["amount", "currency"],
443
+ "additionalProperties": false
444
+ },
445
+ {"type": "null"}
446
+ ]
447
+ }
448
+ }
449
+ }
450
+ }
451
+ }
452
+ },
453
+ {
454
+ "if": {"required": ["guarded"]},
455
+ "then": {"properties": {"type": {"properties": {"name": {"const": "enum"}}}}}
456
+ }
457
+ ]
458
+ },
459
+ "relation": {
460
+ "type": "object",
461
+ "properties": {
462
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
463
+ "kind": {"enum": ["belongs_to", "has_many", "many_to_many"]},
464
+ "target": {"$ref": "#/$defs/entity_ref"},
465
+ "same_tenant": {"type": "boolean"},
466
+ "local_fields": {
467
+ "type": "array",
468
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
469
+ "minItems": 1,
470
+ "uniqueItems": true
471
+ },
472
+ "target_fields": {
473
+ "type": "array",
474
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
475
+ "minItems": 1,
476
+ "uniqueItems": true
477
+ },
478
+ "through": {"$ref": "#/$defs/entity_ref"},
479
+ "include_on_create": {
480
+ "type": "array",
481
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
482
+ "minItems": 1,
483
+ "uniqueItems": true
484
+ }
485
+ },
486
+ "required": ["name", "kind", "target", "same_tenant", "local_fields", "target_fields"],
487
+ "additionalProperties": false
488
+ },
489
+ "operand": {
490
+ "oneOf": [
491
+ {"$ref": "#/$defs/literal"},
492
+ {
493
+ "type": "object",
494
+ "properties": {
495
+ "kind": {"enum": ["field", "actor", "input"]},
496
+ "path": {"type": "array", "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}, "minItems": 1}
497
+ },
498
+ "required": ["kind", "path"],
499
+ "additionalProperties": false
500
+ }
501
+ ]
502
+ },
503
+ "predicate": {
504
+ "oneOf": [
505
+ {
506
+ "type": "object",
507
+ "properties": {"op": {"enum": ["true", "false"]}},
508
+ "required": ["op"],
509
+ "additionalProperties": false
510
+ },
511
+ {
512
+ "type": "object",
513
+ "properties": {
514
+ "op": {"enum": ["eq", "in"]},
515
+ "left": {"$ref": "#/$defs/operand"},
516
+ "right": {"$ref": "#/$defs/operand"}
517
+ },
518
+ "required": ["op", "left", "right"],
519
+ "additionalProperties": false
520
+ },
521
+ {
522
+ "type": "object",
523
+ "properties": {
524
+ "op": {"enum": ["and", "or"]},
525
+ "terms": {"type": "array", "items": {"$ref": "#/$defs/predicate"}, "minItems": 1}
526
+ },
527
+ "required": ["op", "terms"],
528
+ "additionalProperties": false
529
+ },
530
+ {
531
+ "type": "object",
532
+ "properties": {"op": {"const": "not"}, "term": {"$ref": "#/$defs/predicate"}},
533
+ "required": ["op", "term"],
534
+ "additionalProperties": false
535
+ },
536
+ {
537
+ "type": "object",
538
+ "properties": {
539
+ "op": {"const": "exists"},
540
+ "relation": {"type": "array", "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}, "minItems": 1},
541
+ "where": {"$ref": "#/$defs/predicate"}
542
+ },
543
+ "required": ["op", "relation", "where"],
544
+ "additionalProperties": false
545
+ }
546
+ ]
547
+ },
548
+ "analysis": {
549
+ "type": "object",
550
+ "properties": {
551
+ "status": {"enum": ["complete", "incomplete"]},
552
+ "constants": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 0, "uniqueItems": true},
553
+ "dynamic": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 0, "uniqueItems": true}
554
+ },
555
+ "required": ["status", "constants", "dynamic"],
556
+ "additionalProperties": false
557
+ },
558
+ "implementation": {
559
+ "oneOf": [
560
+ {
561
+ "type": "object",
562
+ "properties": {
563
+ "kind": {"const": "builtin"},
564
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"}
565
+ },
566
+ "required": ["kind", "name"],
567
+ "additionalProperties": false
568
+ },
569
+ {
570
+ "type": "object",
571
+ "properties": {
572
+ "kind": {"const": "ruby"},
573
+ "ref": {"type": "string", "pattern": "^[a-z][a-z0-9_.]*#call$"},
574
+ "path": {
575
+ "type": "string",
576
+ "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\/$)[^\\u0000-\\u001f]+$"
577
+ },
578
+ "digest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
579
+ "analysis": {"$ref": "#/$defs/analysis"}
580
+ },
581
+ "required": ["kind", "ref", "path", "digest", "analysis"],
582
+ "additionalProperties": false
583
+ }
584
+ ]
585
+ },
586
+ "authorization": {
587
+ "type": "object",
588
+ "properties": {
589
+ "action": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
590
+ "entity": {"$ref": "#/$defs/entity_ref"},
591
+ "record": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"}
592
+ },
593
+ "required": ["action", "entity"],
594
+ "additionalProperties": false
595
+ },
596
+ "emission": {
597
+ "type": "object",
598
+ "properties": {
599
+ "event": {"$ref": "#/$defs/event_ref"},
600
+ "from": {"$ref": "#/$defs/entity_ref"},
601
+ "fields": {
602
+ "type": "array",
603
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
604
+ "minItems": 1,
605
+ "uniqueItems": true
606
+ }
607
+ },
608
+ "required": ["event", "from", "fields"],
609
+ "additionalProperties": false
610
+ },
611
+ "live": {
612
+ "type": "object",
613
+ "properties": {
614
+ "mode": {"enum": ["strict", "balanced"]},
615
+ "depends_on": {"type": "array", "items": {"$ref": "#/$defs/entity_ref"}, "minItems": 1, "uniqueItems": true}
616
+ },
617
+ "required": ["mode", "depends_on"],
618
+ "additionalProperties": false
619
+ },
620
+ "capability_config": {
621
+ "oneOf": [
622
+ {
623
+ "type": "object",
624
+ "properties": {
625
+ "type": {"const": "repository"},
626
+ "entity": {"$ref": "#/$defs/entity_ref"},
627
+ "access": {"enum": ["read", "read_write"]}
628
+ },
629
+ "required": ["type", "entity", "access"],
630
+ "additionalProperties": false
631
+ },
632
+ {
633
+ "type": "object",
634
+ "properties": {"type": {"const": "deterministic"}},
635
+ "required": ["type"],
636
+ "additionalProperties": false
637
+ },
638
+ {
639
+ "type": "object",
640
+ "properties": {
641
+ "type": {"const": "external"},
642
+ "idempotency_key": {"type": "boolean"},
643
+ "hosts": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 0, "uniqueItems": true},
644
+ "timeout_ms": {"type": "integer", "minimum": 1, "maximum": 9007199254740991}
645
+ },
646
+ "required": ["type", "idempotency_key", "hosts", "timeout_ms"],
647
+ "additionalProperties": false
648
+ },
649
+ {
650
+ "type": "object",
651
+ "properties": {"type": {"const": "sql"}, "access": {"enum": ["read", "read_write"]}},
652
+ "required": ["type", "access"],
653
+ "additionalProperties": false
654
+ }
655
+ ]
656
+ },
657
+ "index": {
658
+ "type": "object",
659
+ "properties": {
660
+ "name": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
661
+ "fields": {
662
+ "type": "array",
663
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
664
+ "minItems": 1,
665
+ "uniqueItems": true
666
+ },
667
+ "unique": {"type": "boolean"},
668
+ "where": {"$ref": "#/$defs/predicate"}
669
+ },
670
+ "required": ["name", "fields", "unique"],
671
+ "additionalProperties": false
672
+ },
673
+ "http_config": {
674
+ "type": "object",
675
+ "properties": {
676
+ "method": {"enum": ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]},
677
+ "path": {"type": "string", "pattern": "^/[^\\s]*$"}
678
+ },
679
+ "required": ["method", "path"],
680
+ "additionalProperties": false
681
+ },
682
+ "named_config": {
683
+ "type": "object",
684
+ "properties": {"name": {"type": "string", "minLength": 1}},
685
+ "required": ["name"],
686
+ "additionalProperties": false
687
+ },
688
+ "domain": {
689
+ "allOf": [
690
+ {"$ref": "#/$defs/node_base"},
691
+ {
692
+ "type": "object",
693
+ "properties": {
694
+ "kind": {"const": "domain"},
695
+ "depends_on": {
696
+ "oneOf": [
697
+ {"type": "null"},
698
+ {"type": "array", "items": {"$ref": "#/$defs/domain_ref"}, "minItems": 0, "uniqueItems": true}
699
+ ]
700
+ }
701
+ },
702
+ "required": ["kind", "depends_on"]
703
+ }
704
+ ],
705
+ "unevaluatedProperties": false
706
+ },
707
+ "entity": {
708
+ "allOf": [
709
+ {"$ref": "#/$defs/node_base"},
710
+ {
711
+ "type": "object",
712
+ "properties": {
713
+ "kind": {"const": "entity"},
714
+ "domain": {"$ref": "#/$defs/domain_ref"},
715
+ "storage": {
716
+ "type": "object",
717
+ "properties": {
718
+ "schema": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
719
+ "table": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
720
+ "primary_key": {
721
+ "type": "array",
722
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
723
+ "minItems": 1,
724
+ "uniqueItems": true
725
+ }
726
+ },
727
+ "required": ["schema", "table", "primary_key"],
728
+ "additionalProperties": false
729
+ },
730
+ "tenant": {"$ref": "#/$defs/tenant"},
731
+ "fields": {"type": "array", "items": {"$ref": "#/$defs/field"}, "minItems": 1, "uniqueItems": true},
732
+ "relations": {"type": "array", "items": {"$ref": "#/$defs/relation"}, "minItems": 0, "uniqueItems": true},
733
+ "indexes": {"type": "array", "items": {"$ref": "#/$defs/index"}, "minItems": 0, "uniqueItems": true},
734
+ "history": {"enum": ["none", "full"]},
735
+ "transitions": {
736
+ "type": "object",
737
+ "properties": {"enforce": {"enum": ["application", "db"]}},
738
+ "required": ["enforce"],
739
+ "additionalProperties": false
740
+ }
741
+ },
742
+ "required": ["kind", "domain", "storage", "tenant", "fields", "relations", "indexes", "history", "transitions"]
743
+ }
744
+ ],
745
+ "unevaluatedProperties": false
746
+ },
747
+ "contract": {
748
+ "allOf": [
749
+ {"$ref": "#/$defs/node_base"},
750
+ {
751
+ "type": "object",
752
+ "properties": {
753
+ "kind": {"const": "contract"},
754
+ "domain": {"$ref": "#/$defs/domain_ref"},
755
+ "fields": {"type": "array", "items": {"$ref": "#/$defs/field"}, "minItems": 0, "uniqueItems": true}
756
+ },
757
+ "required": ["kind", "domain", "fields"]
758
+ }
759
+ ],
760
+ "unevaluatedProperties": false
761
+ },
762
+ "command": {
763
+ "allOf": [
764
+ {"$ref": "#/$defs/node_base"},
765
+ {
766
+ "type": "object",
767
+ "properties": {
768
+ "kind": {"const": "command"},
769
+ "domain": {"$ref": "#/$defs/domain_ref"},
770
+ "input": {"$ref": "#/$defs/contract_ref"},
771
+ "output": {"$ref": "#/$defs/contract_ref"},
772
+ "authorize": {"$ref": "#/$defs/authorization"},
773
+ "uses": {"type": "array", "items": {"$ref": "#/$defs/capability_ref"}, "minItems": 0, "uniqueItems": true},
774
+ "implementation": {"$ref": "#/$defs/implementation"},
775
+ "unsafe_effect": {"type": "string", "minLength": 1},
776
+ "emits": {"type": "array", "items": {"$ref": "#/$defs/emission"}, "minItems": 0, "uniqueItems": true}
777
+ },
778
+ "required": ["kind", "domain", "input", "output", "authorize", "uses", "implementation", "emits"]
779
+ }
780
+ ],
781
+ "unevaluatedProperties": false
782
+ },
783
+ "query": {
784
+ "allOf": [
785
+ {"$ref": "#/$defs/node_base"},
786
+ {
787
+ "type": "object",
788
+ "properties": {
789
+ "kind": {"const": "query"},
790
+ "domain": {"$ref": "#/$defs/domain_ref"},
791
+ "input": {"$ref": "#/$defs/contract_ref"},
792
+ "output": {"$ref": "#/$defs/contract_ref"},
793
+ "authorize": {"$ref": "#/$defs/authorization"},
794
+ "uses": {"type": "array", "items": {"$ref": "#/$defs/capability_ref"}, "minItems": 0, "uniqueItems": true},
795
+ "implementation": {"$ref": "#/$defs/implementation"},
796
+ "unsafe_effect": {"type": "string", "minLength": 1},
797
+ "live": {"$ref": "#/$defs/live"}
798
+ },
799
+ "required": ["kind", "domain", "input", "output", "authorize", "uses", "implementation"]
800
+ }
801
+ ],
802
+ "unevaluatedProperties": false
803
+ },
804
+ "role": {
805
+ "allOf": [
806
+ {"$ref": "#/$defs/node_base"},
807
+ {
808
+ "type": "object",
809
+ "properties": {
810
+ "kind": {"const": "role"},
811
+ "domain": {"$ref": "#/$defs/domain_ref"},
812
+ "anonymous": {"type": "boolean"}
813
+ },
814
+ "required": ["kind", "domain", "anonymous"]
815
+ }
816
+ ],
817
+ "unevaluatedProperties": false
818
+ },
819
+ "policy": {
820
+ "allOf": [
821
+ {"$ref": "#/$defs/node_base"},
822
+ {
823
+ "type": "object",
824
+ "properties": {
825
+ "kind": {"const": "policy"},
826
+ "domain": {"$ref": "#/$defs/domain_ref"},
827
+ "role": {"$ref": "#/$defs/role_ref"},
828
+ "entity": {"$ref": "#/$defs/entity_ref"},
829
+ "actions": {
830
+ "type": "array",
831
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
832
+ "minItems": 1,
833
+ "uniqueItems": true
834
+ },
835
+ "fields": {
836
+ "oneOf": [
837
+ {"const": "*"},
838
+ {
839
+ "type": "array",
840
+ "items": {"type": "string", "pattern": "^[a-z][a-z0-9_]*$"},
841
+ "minItems": 0,
842
+ "uniqueItems": true
843
+ }
844
+ ]
845
+ },
846
+ "predicate": {"$ref": "#/$defs/predicate"},
847
+ "reads": {"type": "array", "items": {"$ref": "#/$defs/entity_ref"}, "minItems": 1, "uniqueItems": true}
848
+ },
849
+ "required": ["kind", "domain", "role", "entity", "actions", "fields", "predicate", "reads"]
850
+ }
851
+ ],
852
+ "unevaluatedProperties": false
853
+ },
854
+ "capability": {
855
+ "allOf": [
856
+ {"$ref": "#/$defs/node_base"},
857
+ {
858
+ "type": "object",
859
+ "properties": {
860
+ "kind": {"const": "capability"},
861
+ "domain": {"$ref": "#/$defs/domain_ref"},
862
+ "adapter": {"type": "string", "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"},
863
+ "retry_safe": {"type": "boolean"},
864
+ "simulation": {"enum": ["seeded", "memory", "none"]},
865
+ "config": {"$ref": "#/$defs/capability_config"}
866
+ },
867
+ "required": ["kind", "domain", "adapter", "retry_safe", "simulation", "config"]
868
+ }
869
+ ],
870
+ "unevaluatedProperties": false
871
+ },
872
+ "event": {
873
+ "allOf": [
874
+ {"$ref": "#/$defs/node_base"},
875
+ {
876
+ "type": "object",
877
+ "properties": {
878
+ "kind": {"const": "event"},
879
+ "domain": {"$ref": "#/$defs/domain_ref"},
880
+ "payload": {"$ref": "#/$defs/contract_ref"},
881
+ "version": {"type": "integer", "minimum": 1, "maximum": 9007199254740991},
882
+ "visibility": {"enum": ["internal", "public"]},
883
+ "consumer_required": {"type": "boolean"}
884
+ },
885
+ "required": ["kind", "domain", "payload", "version", "visibility", "consumer_required"]
886
+ }
887
+ ],
888
+ "unevaluatedProperties": false
889
+ },
890
+ "handler": {
891
+ "allOf": [
892
+ {"$ref": "#/$defs/node_base"},
893
+ {
894
+ "type": "object",
895
+ "properties": {
896
+ "kind": {"const": "handler"},
897
+ "domain": {"$ref": "#/$defs/domain_ref"},
898
+ "on": {"type": "array", "items": {"$ref": "#/$defs/event_ref"}, "minItems": 1, "uniqueItems": true},
899
+ "uses": {"type": "array", "items": {"$ref": "#/$defs/capability_ref"}, "minItems": 0, "uniqueItems": true},
900
+ "calls": {"type": "array", "items": {"$ref": "#/$defs/command_ref"}, "minItems": 0, "uniqueItems": true},
901
+ "idempotent_by": {"const": "event_id"},
902
+ "implementation": {"$ref": "#/$defs/implementation"},
903
+ "unsafe_effect": {"type": "string", "minLength": 1}
904
+ },
905
+ "required": ["kind", "domain", "on", "uses", "calls", "idempotent_by", "implementation"]
906
+ }
907
+ ],
908
+ "unevaluatedProperties": false
909
+ },
910
+ "route": {
911
+ "allOf": [
912
+ {"$ref": "#/$defs/node_base"},
913
+ {
914
+ "type": "object",
915
+ "properties": {
916
+ "kind": {"const": "route"},
917
+ "domain": {"$ref": "#/$defs/domain_ref"},
918
+ "surface": {"enum": ["http", "cli", "job", "webhook"]},
919
+ "target": {"oneOf": [{"$ref": "#/$defs/command_ref"}, {"$ref": "#/$defs/query_ref"}]},
920
+ "config": {"oneOf": [{"$ref": "#/$defs/http_config"}, {"$ref": "#/$defs/named_config"}]},
921
+ "idempotency": {"enum": ["optional", "required"]}
922
+ },
923
+ "required": ["kind", "domain", "surface", "target", "config", "idempotency"]
924
+ },
925
+ {
926
+ "if": {"properties": {"surface": {"enum": ["http", "webhook"]}}},
927
+ "then": {"properties": {"config": {"$ref": "#/$defs/http_config"}}},
928
+ "else": {"properties": {"config": {"$ref": "#/$defs/named_config"}}}
929
+ }
930
+ ],
931
+ "unevaluatedProperties": false
932
+ },
933
+ "dependency": {
934
+ "allOf": [
935
+ {"$ref": "#/$defs/node_base"},
936
+ {
937
+ "type": "object",
938
+ "properties": {
939
+ "kind": {"const": "dependency"},
940
+ "domain": {"$ref": "#/$defs/domain_ref"},
941
+ "name": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]*$"},
942
+ "version": {"type": "string", "minLength": 1},
943
+ "trust": {"enum": ["trusted", "restricted", "outside_guarantee", "unclassified"]}
944
+ },
945
+ "required": ["kind", "domain", "name", "version", "trust"]
946
+ }
947
+ ],
948
+ "unevaluatedProperties": false
949
+ }
950
+ }
951
+ }