@ebowwa/logic-spec 1.0.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.
package/schema.json ADDED
@@ -0,0 +1,409 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://spec.logic.dev/v1.0/logic-schema.json",
4
+ "title": "Logic Specification",
5
+ "description": "Schema for logic.yaml - language-agnostic logic specification",
6
+ "type": "object",
7
+ "required": ["meta", "inputs", "outputs", "logic"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "meta": {
11
+ "type": "object",
12
+ "required": ["spec_version", "name", "version"],
13
+ "additionalProperties": false,
14
+ "properties": {
15
+ "spec_version": {
16
+ "type": "string",
17
+ "pattern": "^\\d+\\.\\d+$",
18
+ "description": "Logic spec version (e.g., '1.0')"
19
+ },
20
+ "name": {
21
+ "type": "string",
22
+ "minLength": 1,
23
+ "maxLength": 128,
24
+ "pattern": "^[a-z][a-z0-9_-]*$",
25
+ "description": "Module/system name (kebab-case)"
26
+ },
27
+ "version": {
28
+ "type": "string",
29
+ "pattern": "^\\d+\\.\\d+\\.\\d+(-[a-z0-9]+)?$",
30
+ "description": "Semantic version"
31
+ },
32
+ "description": {
33
+ "type": "string",
34
+ "maxLength": 500
35
+ },
36
+ "language_target": {
37
+ "type": "string",
38
+ "default": "any"
39
+ },
40
+ "author": {
41
+ "type": "string"
42
+ },
43
+ "license": {
44
+ "type": "string"
45
+ }
46
+ }
47
+ },
48
+
49
+ "inputs": {
50
+ "type": "array",
51
+ "minItems": 1,
52
+ "items": {
53
+ "$ref": "#/definitions/ioDefinition"
54
+ }
55
+ },
56
+
57
+ "outputs": {
58
+ "type": "array",
59
+ "minItems": 1,
60
+ "items": {
61
+ "$ref": "#/definitions/ioDefinition"
62
+ }
63
+ },
64
+
65
+ "types": {
66
+ "type": "object",
67
+ "additionalProperties": {
68
+ "$ref": "#/definitions/typeDefinition"
69
+ }
70
+ },
71
+
72
+ "logic": {
73
+ "type": "array",
74
+ "minItems": 1,
75
+ "items": {
76
+ "$ref": "#/definitions/logicBlock"
77
+ }
78
+ },
79
+
80
+ "state": {
81
+ "$ref": "#/definitions/stateMachine"
82
+ },
83
+
84
+ "flows": {
85
+ "type": "array",
86
+ "items": {
87
+ "$ref": "#/definitions/flow"
88
+ }
89
+ },
90
+
91
+ "failures": {
92
+ "type": "array",
93
+ "items": {
94
+ "$ref": "#/definitions/failure"
95
+ }
96
+ },
97
+
98
+ "constraints": {
99
+ "$ref": "#/definitions/constraints"
100
+ },
101
+
102
+ "dependencies": {
103
+ "type": "array",
104
+ "items": {
105
+ "$ref": "#/definitions/dependency"
106
+ }
107
+ },
108
+
109
+ "observability": {
110
+ "$ref": "#/definitions/observability"
111
+ },
112
+
113
+ "tests": {
114
+ "type": "array",
115
+ "items": {
116
+ "$ref": "#/definitions/test"
117
+ }
118
+ }
119
+ },
120
+
121
+ "definitions": {
122
+ "ioDefinition": {
123
+ "type": "object",
124
+ "required": ["name", "type"],
125
+ "additionalProperties": false,
126
+ "properties": {
127
+ "name": {
128
+ "type": "string",
129
+ "pattern": "^[a-z][a-z0-9_]*$"
130
+ },
131
+ "type": {
132
+ "type": "string"
133
+ },
134
+ "required": {
135
+ "type": "boolean",
136
+ "default": true
137
+ },
138
+ "default": {},
139
+ "description": {
140
+ "type": "string"
141
+ },
142
+ "schema": {
143
+ "type": "object"
144
+ },
145
+ "validation": {
146
+ "type": "object",
147
+ "properties": {
148
+ "min": { "type": "number" },
149
+ "max": { "type": "number" },
150
+ "pattern": { "type": "string" },
151
+ "enum": {
152
+ "type": "array",
153
+ "items": { "type": "string" }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ },
159
+
160
+ "typeDefinition": {
161
+ "type": "object",
162
+ "properties": {
163
+ "description": { "type": "string" },
164
+ "fields": {
165
+ "type": "object",
166
+ "additionalProperties": { "type": "string" }
167
+ },
168
+ "enum": {
169
+ "type": "array",
170
+ "items": { "type": "string" },
171
+ "minItems": 1
172
+ },
173
+ "generic": {
174
+ "type": "array",
175
+ "items": { "type": "string" }
176
+ }
177
+ }
178
+ },
179
+
180
+ "logicBlock": {
181
+ "type": "object",
182
+ "required": ["id", "type", "input", "output", "algorithm"],
183
+ "additionalProperties": false,
184
+ "properties": {
185
+ "id": {
186
+ "type": "string",
187
+ "pattern": "^[a-z][a-z0-9_]*$"
188
+ },
189
+ "type": {
190
+ "type": "string",
191
+ "enum": ["transform", "validate", "compute", "decision", "aggregate", "inference", "query"]
192
+ },
193
+ "description": {
194
+ "type": "string"
195
+ },
196
+ "input": {
197
+ "oneOf": [
198
+ { "type": "string" },
199
+ { "type": "array", "items": { "type": "string" } }
200
+ ]
201
+ },
202
+ "output": {
203
+ "type": "string"
204
+ },
205
+ "algorithm": {
206
+ "type": "string",
207
+ "minLength": 1
208
+ },
209
+ "complexity": {
210
+ "type": "string",
211
+ "pattern": "^O\\([^)]+\\)$"
212
+ }
213
+ }
214
+ },
215
+
216
+ "stateMachine": {
217
+ "type": "object",
218
+ "required": ["initial", "transitions"],
219
+ "additionalProperties": false,
220
+ "properties": {
221
+ "initial": { "type": "string" },
222
+ "persist": { "type": "boolean", "default": false },
223
+ "states": {
224
+ "type": "object",
225
+ "additionalProperties": {
226
+ "type": "object",
227
+ "properties": {
228
+ "description": { "type": "string" }
229
+ }
230
+ }
231
+ },
232
+ "transitions": {
233
+ "type": "array",
234
+ "items": {
235
+ "type": "object",
236
+ "required": ["from", "to", "trigger"],
237
+ "properties": {
238
+ "from": {
239
+ "oneOf": [
240
+ { "type": "string" },
241
+ { "type": "array", "items": { "type": "string" } }
242
+ ]
243
+ },
244
+ "to": { "type": "string" },
245
+ "trigger": { "type": "string" },
246
+ "action": { "type": "string" },
247
+ "guard": { "type": "string" }
248
+ }
249
+ }
250
+ }
251
+ }
252
+ },
253
+
254
+ "flow": {
255
+ "type": "object",
256
+ "required": ["name", "steps"],
257
+ "additionalProperties": false,
258
+ "properties": {
259
+ "name": { "type": "string" },
260
+ "description": { "type": "string" },
261
+ "steps": {
262
+ "type": "array",
263
+ "items": { "type": "string" },
264
+ "minItems": 1
265
+ },
266
+ "parallel": { "type": "boolean", "default": false },
267
+ "timeout_ms": { "type": "number", "minimum": 0 },
268
+ "retry": {
269
+ "type": "object",
270
+ "properties": {
271
+ "count": { "type": "number", "minimum": 0 },
272
+ "backoff": {
273
+ "type": "string",
274
+ "enum": ["linear", "exponential"]
275
+ },
276
+ "delay_ms": { "type": "number", "minimum": 0 }
277
+ }
278
+ }
279
+ }
280
+ },
281
+
282
+ "failure": {
283
+ "type": "object",
284
+ "required": ["code", "condition"],
285
+ "additionalProperties": false,
286
+ "properties": {
287
+ "code": {
288
+ "type": "string",
289
+ "pattern": "^E\\d{3}$"
290
+ },
291
+ "condition": { "type": "string" },
292
+ "severity": {
293
+ "type": "string",
294
+ "enum": ["critical", "error", "warning", "info"],
295
+ "default": "error"
296
+ },
297
+ "recovery": {
298
+ "type": "object",
299
+ "properties": {
300
+ "strategy": {
301
+ "type": "string",
302
+ "enum": ["retry", "fallback", "escalate", "ignore"]
303
+ },
304
+ "retry_count": { "type": "number", "minimum": 0 },
305
+ "fallback_to": { "type": "string" }
306
+ }
307
+ },
308
+ "message": { "type": "string" }
309
+ }
310
+ },
311
+
312
+ "constraints": {
313
+ "type": "object",
314
+ "properties": {
315
+ "latency_max_ms": { "type": "number", "minimum": 0 },
316
+ "throughput_min_rps": { "type": "number", "minimum": 0 },
317
+ "memory_limit_mb": { "type": "number", "minimum": 0 },
318
+ "cpu_limit_percent": { "type": "number", "minimum": 0, "maximum": 100 },
319
+ "availability_percent": { "type": "number", "minimum": 0, "maximum": 100 },
320
+ "data_retention_days": { "type": "number", "minimum": 0 }
321
+ }
322
+ },
323
+
324
+ "dependency": {
325
+ "type": "object",
326
+ "required": ["name", "type"],
327
+ "additionalProperties": false,
328
+ "properties": {
329
+ "name": { "type": "string" },
330
+ "type": {
331
+ "type": "string",
332
+ "enum": ["database", "cache", "queue", "external_service", "service", "api"]
333
+ },
334
+ "contract": { "type": "string" },
335
+ "required": { "type": "boolean", "default": true },
336
+ "endpoint": { "type": "string" },
337
+ "timeout_ms": { "type": "number", "minimum": 0 },
338
+ "auth": { "type": "string" }
339
+ }
340
+ },
341
+
342
+ "observability": {
343
+ "type": "object",
344
+ "properties": {
345
+ "metrics": {
346
+ "type": "array",
347
+ "items": {
348
+ "type": "object",
349
+ "required": ["name", "type"],
350
+ "properties": {
351
+ "name": { "type": "string" },
352
+ "type": {
353
+ "type": "string",
354
+ "enum": ["counter", "gauge", "histogram"]
355
+ },
356
+ "unit": { "type": "string" },
357
+ "labels": {
358
+ "type": "array",
359
+ "items": { "type": "string" }
360
+ }
361
+ }
362
+ }
363
+ },
364
+ "logs": {
365
+ "type": "object",
366
+ "properties": {
367
+ "level": {
368
+ "type": "string",
369
+ "enum": ["debug", "info", "warn", "error"]
370
+ },
371
+ "include": {
372
+ "type": "array",
373
+ "items": { "type": "string" }
374
+ },
375
+ "exclude": {
376
+ "type": "array",
377
+ "items": { "type": "string" }
378
+ }
379
+ }
380
+ },
381
+ "traces": {
382
+ "type": "object",
383
+ "properties": {
384
+ "enabled": { "type": "boolean" },
385
+ "sample_rate": {
386
+ "type": "number",
387
+ "minimum": 0,
388
+ "maximum": 1
389
+ }
390
+ }
391
+ }
392
+ }
393
+ },
394
+
395
+ "test": {
396
+ "type": "object",
397
+ "required": ["name", "given", "expect"],
398
+ "additionalProperties": false,
399
+ "properties": {
400
+ "name": { "type": "string" },
401
+ "description": { "type": "string" },
402
+ "given": { "type": "object" },
403
+ "when": { "type": "string" },
404
+ "expect": { "type": "object" },
405
+ "timeout_ms": { "type": "number", "minimum": 0 }
406
+ }
407
+ }
408
+ }
409
+ }