@onereach/state-machine-contracts 0.0.0-stage → 1.0.0-framework.12
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/README.md +455 -2
- package/dist/index.d.mts +741 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -0
- package/dist/json-schemas/CreateStateMachineInstanceRequestSchema.json +64 -0
- package/dist/json-schemas/CreateStateMachineTemplateSchema.json +203 -0
- package/dist/json-schemas/ExecuteStateMachineFunctionRequestSchema.json +38 -0
- package/dist/json-schemas/FunctionImplementationSchema.json +55 -0
- package/dist/json-schemas/FunctionKindSchema.json +8 -0
- package/dist/json-schemas/JsonSchemaSchema.json +7 -0
- package/dist/json-schemas/ObjectJsonSchemaSchema.json +16 -0
- package/dist/json-schemas/StateMachineFunctionDefinitionSchema.json +140 -0
- package/dist/json-schemas/StateMachineInstanceSchema.json +99 -0
- package/dist/json-schemas/StateMachineTemplateBindingSchema.json +26 -0
- package/dist/json-schemas/StateMachineTemplateSchema.json +203 -0
- package/dist/schemas/index.d.mts +732 -0
- package/dist/schemas/index.d.mts.map +1 -0
- package/dist/schemas/index.mjs +2 -0
- package/dist/schemas/index.mjs.map +1 -0
- package/package.json +59 -3
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "Request to create an instance; the store resolves its template and assigns persisted lifecycle fields.",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"id",
|
|
8
|
+
"template"
|
|
9
|
+
],
|
|
10
|
+
"properties": {
|
|
11
|
+
"id": {
|
|
12
|
+
"description": "Unique identifier of the instance.",
|
|
13
|
+
"minLength": 1,
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"template": {
|
|
17
|
+
"description": "Template reference to resolve during creation, not a persisted revision binding.",
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"type": "object",
|
|
20
|
+
"required": [
|
|
21
|
+
"id"
|
|
22
|
+
],
|
|
23
|
+
"properties": {
|
|
24
|
+
"id": {
|
|
25
|
+
"description": "Unique identifier of the template.",
|
|
26
|
+
"minLength": 1,
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"version": {
|
|
30
|
+
"description": "Logical application version of the template. Optional because the template may have no version.",
|
|
31
|
+
"type": "string"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"state": {
|
|
36
|
+
"description": "Optional initial state override. The store clones it, or the resolved template initial state when omitted, and validates it against the template state schema.",
|
|
37
|
+
"additionalProperties": true,
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": {}
|
|
40
|
+
},
|
|
41
|
+
"metadata": {
|
|
42
|
+
"description": "Optional application-defined metadata about the instance. Arbitrary keys are preserved.",
|
|
43
|
+
"additionalProperties": true,
|
|
44
|
+
"type": "object",
|
|
45
|
+
"properties": {}
|
|
46
|
+
},
|
|
47
|
+
"retention": {
|
|
48
|
+
"description": "Instance-owned retention policy, independent of execution callers and application state.",
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"type": "object",
|
|
51
|
+
"required": [
|
|
52
|
+
"ttlMs"
|
|
53
|
+
],
|
|
54
|
+
"properties": {
|
|
55
|
+
"ttlMs": {
|
|
56
|
+
"description": "Sliding expiration duration in milliseconds, renewed on successful persisted updates. Zero means no expiration.",
|
|
57
|
+
"minimum": 0,
|
|
58
|
+
"maximum": 9007199254740991,
|
|
59
|
+
"type": "integer"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -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
|
+
],
|
|
116
|
+
"properties": {
|
|
117
|
+
"runtime": {
|
|
118
|
+
"description": "Runtime used to execute the implementation.",
|
|
119
|
+
"const": "javascript",
|
|
120
|
+
"type": "string"
|
|
121
|
+
},
|
|
122
|
+
"abi": {
|
|
123
|
+
"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.",
|
|
124
|
+
"examples": [
|
|
125
|
+
"async function(input, state, ctx) {\n // implementation.code\n}"
|
|
126
|
+
],
|
|
127
|
+
"const": "state-machine-function-v1",
|
|
128
|
+
"type": "string"
|
|
129
|
+
},
|
|
130
|
+
"format": {
|
|
131
|
+
"description": "Source format: the body of an async function, not a complete function declaration.",
|
|
132
|
+
"const": "async-function-body",
|
|
133
|
+
"type": "string"
|
|
134
|
+
},
|
|
135
|
+
"code": {
|
|
136
|
+
"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.",
|
|
137
|
+
"examples": [
|
|
138
|
+
"const x = await ctx.foo(input);\nstate.foo = x;\nreturn x;"
|
|
139
|
+
],
|
|
140
|
+
"minLength": 1,
|
|
141
|
+
"type": "string"
|
|
142
|
+
},
|
|
143
|
+
"capabilities": {
|
|
144
|
+
"description": "Capability names requested by the implementation. Creation defaults an omitted list to [].",
|
|
145
|
+
"type": "array",
|
|
146
|
+
"items": {
|
|
147
|
+
"description": "Name of a capability requested by the implementation.",
|
|
148
|
+
"type": "string"
|
|
149
|
+
},
|
|
150
|
+
"default": []
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "Execution request envelope; instance lookup and function-specific input validation occur later.",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"instance",
|
|
8
|
+
"functionName",
|
|
9
|
+
"input"
|
|
10
|
+
],
|
|
11
|
+
"properties": {
|
|
12
|
+
"instance": {
|
|
13
|
+
"description": "Reference identifying the instance on which to execute the function.",
|
|
14
|
+
"additionalProperties": false,
|
|
15
|
+
"type": "object",
|
|
16
|
+
"required": [
|
|
17
|
+
"id"
|
|
18
|
+
],
|
|
19
|
+
"properties": {
|
|
20
|
+
"id": {
|
|
21
|
+
"description": "Unique identifier of the instance.",
|
|
22
|
+
"minLength": 1,
|
|
23
|
+
"type": "string"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"functionName": {
|
|
28
|
+
"description": "Name of the function to invoke on the resolved instance template.",
|
|
29
|
+
"minLength": 1,
|
|
30
|
+
"maxLength": 64,
|
|
31
|
+
"pattern": "^[a-zA-Z0-9_-]{1,64}$",
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"input": {
|
|
35
|
+
"description": "Opaque function input, preserved without transformation. The prepared template validates it against the selected function input schema before implementation execution."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "Executable JavaScript implementation and its execution requirements.",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"runtime",
|
|
8
|
+
"abi",
|
|
9
|
+
"format",
|
|
10
|
+
"code",
|
|
11
|
+
"capabilities"
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"runtime": {
|
|
15
|
+
"description": "Runtime used to execute the implementation.",
|
|
16
|
+
"const": "javascript",
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"abi": {
|
|
20
|
+
"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.",
|
|
21
|
+
"examples": [
|
|
22
|
+
"async function(input, state, ctx) {\n // implementation.code\n}"
|
|
23
|
+
],
|
|
24
|
+
"const": "state-machine-function-v1",
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"format": {
|
|
28
|
+
"description": "Source format: the body of an async function, not a complete function declaration.",
|
|
29
|
+
"const": "async-function-body",
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"code": {
|
|
33
|
+
"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.",
|
|
34
|
+
"examples": [
|
|
35
|
+
"const x = await ctx.foo(input);\nstate.foo = x;\nreturn x;"
|
|
36
|
+
],
|
|
37
|
+
"minLength": 1,
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
"capabilities": {
|
|
41
|
+
"description": "Capability names requested by the implementation. Required in canonical definitions.",
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"description": "Name of a capability requested by the implementation.",
|
|
45
|
+
"type": "string"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"timeoutMs": {
|
|
49
|
+
"description": "Optional execution timeout in milliseconds, expressed as a positive safe integer.",
|
|
50
|
+
"minimum": 1,
|
|
51
|
+
"maximum": 9007199254740991,
|
|
52
|
+
"type": "integer"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "Opaque object-form JSON Schema. Core preserves all keywords and checks only that the value is an object. The injected schema compiler is responsible for validating the dialect, keywords, and references. Boolean schemas are excluded.",
|
|
4
|
+
"additionalProperties": true,
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {}
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "Opaque object-form JSON Schema with an explicit type of object. Other keywords are preserved, not interpreted by core. The injected schema compiler is responsible for validating the dialect, keywords, and references.",
|
|
4
|
+
"additionalProperties": true,
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"type"
|
|
8
|
+
],
|
|
9
|
+
"properties": {
|
|
10
|
+
"type": {
|
|
11
|
+
"description": "Explicit root instance type required for state and function-input schemas.",
|
|
12
|
+
"const": "object",
|
|
13
|
+
"type": "string"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "Named state-machine function, including its input/output contracts and executable implementation.",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"name",
|
|
8
|
+
"kind",
|
|
9
|
+
"inputSchema",
|
|
10
|
+
"implementation"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"name": {
|
|
14
|
+
"description": "Function name, unique within the template. Must contain 1–64 ASCII letters, digits, underscores, or hyphens.",
|
|
15
|
+
"minLength": 1,
|
|
16
|
+
"maxLength": 64,
|
|
17
|
+
"pattern": "^[a-zA-Z0-9_-]{1,64}$",
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"description": {
|
|
21
|
+
"description": "Optional human-readable explanation of the function.",
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"kind": {
|
|
25
|
+
"description": "Function classification: queries read state; mutations may update state.",
|
|
26
|
+
"enum": [
|
|
27
|
+
"query",
|
|
28
|
+
"mutation"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"inputSchema": {
|
|
32
|
+
"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.",
|
|
33
|
+
"additionalProperties": true,
|
|
34
|
+
"type": "object",
|
|
35
|
+
"required": [
|
|
36
|
+
"type"
|
|
37
|
+
],
|
|
38
|
+
"properties": {
|
|
39
|
+
"type": {
|
|
40
|
+
"description": "Explicit root instance type required for state and function-input schemas.",
|
|
41
|
+
"const": "object",
|
|
42
|
+
"type": "string"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"outputSchema": {
|
|
47
|
+
"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.",
|
|
48
|
+
"additionalProperties": true,
|
|
49
|
+
"type": "object",
|
|
50
|
+
"properties": {}
|
|
51
|
+
},
|
|
52
|
+
"implementation": {
|
|
53
|
+
"description": "Executable JavaScript implementation and its execution requirements.",
|
|
54
|
+
"additionalProperties": false,
|
|
55
|
+
"type": "object",
|
|
56
|
+
"required": [
|
|
57
|
+
"runtime",
|
|
58
|
+
"abi",
|
|
59
|
+
"format",
|
|
60
|
+
"code",
|
|
61
|
+
"capabilities"
|
|
62
|
+
],
|
|
63
|
+
"properties": {
|
|
64
|
+
"runtime": {
|
|
65
|
+
"description": "Runtime used to execute the implementation.",
|
|
66
|
+
"const": "javascript",
|
|
67
|
+
"type": "string"
|
|
68
|
+
},
|
|
69
|
+
"abi": {
|
|
70
|
+
"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.",
|
|
71
|
+
"examples": [
|
|
72
|
+
"async function(input, state, ctx) {\n // implementation.code\n}"
|
|
73
|
+
],
|
|
74
|
+
"const": "state-machine-function-v1",
|
|
75
|
+
"type": "string"
|
|
76
|
+
},
|
|
77
|
+
"format": {
|
|
78
|
+
"description": "Source format: the body of an async function, not a complete function declaration.",
|
|
79
|
+
"const": "async-function-body",
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"code": {
|
|
83
|
+
"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.",
|
|
84
|
+
"examples": [
|
|
85
|
+
"const x = await ctx.foo(input);\nstate.foo = x;\nreturn x;"
|
|
86
|
+
],
|
|
87
|
+
"minLength": 1,
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"capabilities": {
|
|
91
|
+
"description": "Capability names requested by the implementation. Required in canonical definitions.",
|
|
92
|
+
"type": "array",
|
|
93
|
+
"items": {
|
|
94
|
+
"description": "Name of a capability requested by the implementation.",
|
|
95
|
+
"type": "string"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"timeoutMs": {
|
|
99
|
+
"description": "Optional execution timeout in milliseconds, expressed as a positive safe integer.",
|
|
100
|
+
"minimum": 1,
|
|
101
|
+
"maximum": 9007199254740991,
|
|
102
|
+
"type": "integer"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"annotations": {
|
|
107
|
+
"description": "Optional descriptive hints about the function, not additional schema validation rules.",
|
|
108
|
+
"additionalProperties": false,
|
|
109
|
+
"type": "object",
|
|
110
|
+
"properties": {
|
|
111
|
+
"exposeAsTool": {
|
|
112
|
+
"description": "Whether tool adapters may advertise this function. Omission means true. Controls discovery only, not execution authorization.",
|
|
113
|
+
"type": "boolean"
|
|
114
|
+
},
|
|
115
|
+
"pure": {
|
|
116
|
+
"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.",
|
|
117
|
+
"type": "boolean"
|
|
118
|
+
},
|
|
119
|
+
"idempotent": {
|
|
120
|
+
"description": "Whether the function is declared to be idempotent.",
|
|
121
|
+
"type": "boolean"
|
|
122
|
+
},
|
|
123
|
+
"destructive": {
|
|
124
|
+
"description": "Whether the function is declared to perform destructive operations.",
|
|
125
|
+
"type": "boolean"
|
|
126
|
+
},
|
|
127
|
+
"deprecated": {
|
|
128
|
+
"description": "Whether use of this function is deprecated.",
|
|
129
|
+
"type": "boolean"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"metadata": {
|
|
134
|
+
"description": "Optional application-defined metadata about the function. Arbitrary keys are preserved.",
|
|
135
|
+
"additionalProperties": true,
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "Persisted state-machine instance, pinned to a template revision and tracking its current state.",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"schemaVersion",
|
|
8
|
+
"id",
|
|
9
|
+
"template",
|
|
10
|
+
"retention",
|
|
11
|
+
"state",
|
|
12
|
+
"sequence",
|
|
13
|
+
"createdAt",
|
|
14
|
+
"updatedAt"
|
|
15
|
+
],
|
|
16
|
+
"properties": {
|
|
17
|
+
"schemaVersion": {
|
|
18
|
+
"description": "Version of the persisted instance format, not the logical instance sequence.",
|
|
19
|
+
"const": 2,
|
|
20
|
+
"type": "number"
|
|
21
|
+
},
|
|
22
|
+
"id": {
|
|
23
|
+
"description": "Unique identifier of the instance.",
|
|
24
|
+
"minLength": 1,
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"template": {
|
|
28
|
+
"description": "Template identity and storage revision bound to a state-machine instance.",
|
|
29
|
+
"additionalProperties": false,
|
|
30
|
+
"type": "object",
|
|
31
|
+
"required": [
|
|
32
|
+
"id",
|
|
33
|
+
"revision"
|
|
34
|
+
],
|
|
35
|
+
"properties": {
|
|
36
|
+
"id": {
|
|
37
|
+
"description": "Unique identifier of the template.",
|
|
38
|
+
"minLength": 1,
|
|
39
|
+
"type": "string"
|
|
40
|
+
},
|
|
41
|
+
"version": {
|
|
42
|
+
"description": "Logical application version of the template. Optional because the template may have no version.",
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
"revision": {
|
|
46
|
+
"description": "Storage-driver revision of the template used to create this instance. Pins execution to that revision so changing a stored template cannot silently change instance behavior.",
|
|
47
|
+
"minLength": 1,
|
|
48
|
+
"type": "string"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"retention": {
|
|
53
|
+
"description": "Instance-owned retention policy, independent of execution callers and application state.",
|
|
54
|
+
"additionalProperties": false,
|
|
55
|
+
"type": "object",
|
|
56
|
+
"required": [
|
|
57
|
+
"ttlMs"
|
|
58
|
+
],
|
|
59
|
+
"properties": {
|
|
60
|
+
"ttlMs": {
|
|
61
|
+
"description": "Sliding expiration duration in milliseconds, renewed on successful persisted updates. Zero means no expiration.",
|
|
62
|
+
"minimum": 0,
|
|
63
|
+
"maximum": 9007199254740991,
|
|
64
|
+
"type": "integer"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"state": {
|
|
69
|
+
"description": "Current instance state, validated against the bound template's stateSchema during execution and storage operations.",
|
|
70
|
+
"additionalProperties": true,
|
|
71
|
+
"type": "object",
|
|
72
|
+
"properties": {}
|
|
73
|
+
},
|
|
74
|
+
"sequence": {
|
|
75
|
+
"description": "Logical instance version. Increased for every successful persisted update; independent of the storage-driver revision.",
|
|
76
|
+
"minimum": 0,
|
|
77
|
+
"maximum": 9007199254740991,
|
|
78
|
+
"type": "integer"
|
|
79
|
+
},
|
|
80
|
+
"createdAt": {
|
|
81
|
+
"format": "date-time",
|
|
82
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?Z$",
|
|
83
|
+
"type": "string",
|
|
84
|
+
"description": "Date and time the instance was created, as an ISO 8601 UTC datetime ending in Z."
|
|
85
|
+
},
|
|
86
|
+
"updatedAt": {
|
|
87
|
+
"format": "date-time",
|
|
88
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?Z$",
|
|
89
|
+
"type": "string",
|
|
90
|
+
"description": "Date and time the instance was last updated, as an ISO 8601 UTC datetime ending in Z."
|
|
91
|
+
},
|
|
92
|
+
"metadata": {
|
|
93
|
+
"description": "Optional application-defined metadata about the instance. Arbitrary keys are preserved.",
|
|
94
|
+
"additionalProperties": true,
|
|
95
|
+
"type": "object",
|
|
96
|
+
"properties": {}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "Template identity and storage revision bound to a state-machine instance.",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"id",
|
|
8
|
+
"revision"
|
|
9
|
+
],
|
|
10
|
+
"properties": {
|
|
11
|
+
"id": {
|
|
12
|
+
"description": "Unique identifier of the template.",
|
|
13
|
+
"minLength": 1,
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"version": {
|
|
17
|
+
"description": "Logical application version of the template. Optional because the template may have no version.",
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"revision": {
|
|
21
|
+
"description": "Storage-driver revision of the template used to create this instance. Pins execution to that revision so changing a stored template cannot silently change instance behavior.",
|
|
22
|
+
"minLength": 1,
|
|
23
|
+
"type": "string"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|