@onereach/state-machine-contracts 0.0.0-stage → 1.0.0-framework.13

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,203 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "description": "Persisted state-machine template defining shared state, initial state, and available functions.",
4
+ "additionalProperties": false,
5
+ "type": "object",
6
+ "required": [
7
+ "schemaVersion",
8
+ "id",
9
+ "stateSchema",
10
+ "initialState",
11
+ "functions"
12
+ ],
13
+ "properties": {
14
+ "schemaVersion": {
15
+ "description": "Version of the persisted template format, not the logical application version.",
16
+ "const": 1,
17
+ "type": "number"
18
+ },
19
+ "id": {
20
+ "description": "Unique identifier of the template.",
21
+ "minLength": 1,
22
+ "type": "string"
23
+ },
24
+ "version": {
25
+ "description": "Optional logical application version. This is different from a storage-driver revision.",
26
+ "type": "string"
27
+ },
28
+ "description": {
29
+ "description": "Optional human-readable explanation of the state machine.",
30
+ "type": "string"
31
+ },
32
+ "stateSchema": {
33
+ "description": "Object-form JSON Schema shared by every function to validate instance state. Core checks its shape only; the injected schema compiler validates and compiles its constraints.",
34
+ "additionalProperties": true,
35
+ "type": "object",
36
+ "required": [
37
+ "type"
38
+ ],
39
+ "properties": {
40
+ "type": {
41
+ "description": "Explicit root instance type required for state and function-input schemas.",
42
+ "const": "object",
43
+ "type": "string"
44
+ }
45
+ }
46
+ },
47
+ "initialState": {
48
+ "description": "Default state used when creating an instance without an explicit state override. Must satisfy stateSchema when the template is prepared.",
49
+ "additionalProperties": true,
50
+ "type": "object",
51
+ "properties": {}
52
+ },
53
+ "functions": {
54
+ "description": "Functions available on instances of this template. Names must be unique; the template parser enforces this semantic rule.",
55
+ "type": "array",
56
+ "items": {
57
+ "description": "Named state-machine function, including its input/output contracts and executable implementation.",
58
+ "additionalProperties": false,
59
+ "type": "object",
60
+ "required": [
61
+ "name",
62
+ "kind",
63
+ "inputSchema",
64
+ "implementation"
65
+ ],
66
+ "properties": {
67
+ "name": {
68
+ "description": "Function name, unique within the template. Must contain 1–64 ASCII letters, digits, underscores, or hyphens.",
69
+ "minLength": 1,
70
+ "maxLength": 64,
71
+ "pattern": "^[a-zA-Z0-9_-]{1,64}$",
72
+ "type": "string"
73
+ },
74
+ "description": {
75
+ "description": "Optional human-readable explanation of the function.",
76
+ "type": "string"
77
+ },
78
+ "kind": {
79
+ "description": "Function classification: queries read state; mutations may update state.",
80
+ "enum": [
81
+ "query",
82
+ "mutation"
83
+ ]
84
+ },
85
+ "inputSchema": {
86
+ "description": "Object-form JSON Schema for input, the first implementation argument. Core checks its shape only; the injected schema compiler validates and compiles its constraints.",
87
+ "additionalProperties": true,
88
+ "type": "object",
89
+ "required": [
90
+ "type"
91
+ ],
92
+ "properties": {
93
+ "type": {
94
+ "description": "Explicit root instance type required for state and function-input schemas.",
95
+ "const": "object",
96
+ "type": "string"
97
+ }
98
+ }
99
+ },
100
+ "outputSchema": {
101
+ "description": "Optional object-form JSON Schema for the returned value. If omitted, no output schema validator is prepared. Core checks its shape only; the injected schema compiler validates and compiles its constraints.",
102
+ "additionalProperties": true,
103
+ "type": "object",
104
+ "properties": {}
105
+ },
106
+ "implementation": {
107
+ "description": "Executable JavaScript implementation and its execution requirements.",
108
+ "additionalProperties": false,
109
+ "type": "object",
110
+ "required": [
111
+ "runtime",
112
+ "abi",
113
+ "format",
114
+ "code",
115
+ "capabilities"
116
+ ],
117
+ "properties": {
118
+ "runtime": {
119
+ "description": "Runtime used to execute the implementation.",
120
+ "const": "javascript",
121
+ "type": "string"
122
+ },
123
+ "abi": {
124
+ "description": "Calling convention: async function(input, state, ctx). The stored implementation.code runs as its body. The arguments are function input, instance state, and the execution context, in that order.",
125
+ "examples": [
126
+ "async function(input, state, ctx) {\n // implementation.code\n}"
127
+ ],
128
+ "const": "state-machine-function-v1",
129
+ "type": "string"
130
+ },
131
+ "format": {
132
+ "description": "Source format: the body of an async function, not a complete function declaration.",
133
+ "const": "async-function-body",
134
+ "type": "string"
135
+ },
136
+ "code": {
137
+ "description": "JavaScript async-function body. Do not wrap it in async function(...) { ... }. The body can await context operations, access input and state, and return the function result.",
138
+ "examples": [
139
+ "const x = await ctx.foo(input);\nstate.foo = x;\nreturn x;"
140
+ ],
141
+ "minLength": 1,
142
+ "type": "string"
143
+ },
144
+ "capabilities": {
145
+ "description": "Capability names requested by the implementation. Required in canonical definitions.",
146
+ "type": "array",
147
+ "items": {
148
+ "description": "Name of a capability requested by the implementation.",
149
+ "type": "string"
150
+ }
151
+ },
152
+ "timeoutMs": {
153
+ "description": "Optional execution timeout in milliseconds, expressed as a positive safe integer.",
154
+ "minimum": 1,
155
+ "maximum": 9007199254740991,
156
+ "type": "integer"
157
+ }
158
+ }
159
+ },
160
+ "annotations": {
161
+ "description": "Optional descriptive hints about the function, not additional schema validation rules.",
162
+ "additionalProperties": false,
163
+ "type": "object",
164
+ "properties": {
165
+ "exposeAsTool": {
166
+ "description": "Whether tool adapters may advertise this function. Omission means true. Controls discovery only, not execution authorization.",
167
+ "type": "boolean"
168
+ },
169
+ "pure": {
170
+ "description": "Author declaration of context-free execution using only input/state and local computation, without external effects. When true, allows an explicitly configured backend to select isolated execution; false or omission retains trusted execution. Not a purity proof, security sandbox, idempotency declaration, or permission to retry.",
171
+ "type": "boolean"
172
+ },
173
+ "idempotent": {
174
+ "description": "Whether the function is declared to be idempotent.",
175
+ "type": "boolean"
176
+ },
177
+ "destructive": {
178
+ "description": "Whether the function is declared to perform destructive operations.",
179
+ "type": "boolean"
180
+ },
181
+ "deprecated": {
182
+ "description": "Whether use of this function is deprecated.",
183
+ "type": "boolean"
184
+ }
185
+ }
186
+ },
187
+ "metadata": {
188
+ "description": "Optional application-defined metadata about the function. Arbitrary keys are preserved.",
189
+ "additionalProperties": true,
190
+ "type": "object",
191
+ "properties": {}
192
+ }
193
+ }
194
+ }
195
+ },
196
+ "metadata": {
197
+ "description": "Optional application-defined metadata about the template. Arbitrary keys are preserved.",
198
+ "additionalProperties": true,
199
+ "type": "object",
200
+ "properties": {}
201
+ }
202
+ }
203
+ }