code60-transmission-server 0.0.0-stage → 0.1.0-staging.2
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/LICENSE +180 -0
- package/README.engine.md +401 -0
- package/README.md +291 -2
- package/dist/src/broker/filesystem.js +385 -0
- package/dist/src/broker/index.js +734 -0
- package/dist/src/broker/native/README.md +192 -0
- package/dist/src/broker/native/build.js +43 -0
- package/dist/src/broker/native/fs-helper.c +529 -0
- package/dist/src/broker/native/git-helper.c +205 -0
- package/dist/src/broker/policy.js +149 -0
- package/dist/src/broker/startup-lock.js +14 -0
- package/dist/src/broker/types.js +11 -0
- package/dist/src/cli/daemon.js +365 -0
- package/dist/src/cli/helpers.js +104 -0
- package/dist/src/cli/main.js +180 -0
- package/dist/src/config/deployment.js +163 -0
- package/dist/src/config/documents.js +29 -0
- package/dist/src/config/profile-validation.js +123 -0
- package/dist/src/config/schema-graph.js +237 -0
- package/dist/src/config/schema-loader.js +185 -0
- package/dist/src/config/validation-pool.js +105 -0
- package/dist/src/config/validation-protocol.js +1 -0
- package/dist/src/config/validation-worker.js +106 -0
- package/dist/src/config/workflow-language.js +9 -0
- package/dist/src/config/workflow-schema.json +534 -0
- package/dist/src/config/workflow-types.js +1 -0
- package/dist/src/config/workflow-validation.js +95 -0
- package/dist/src/engine/budgets.js +50 -0
- package/dist/src/engine/clocks.js +27 -0
- package/dist/src/engine/commands.js +441 -0
- package/dist/src/engine/contracts.js +11 -0
- package/dist/src/engine/drain-state.js +31 -0
- package/dist/src/engine/effective-permissions.js +120 -0
- package/dist/src/engine/instruction-pins.js +205 -0
- package/dist/src/engine/retries.js +50 -0
- package/dist/src/engine/state.js +1 -0
- package/dist/src/engine/timing.js +23 -0
- package/dist/src/engine/tool-observations.js +87 -0
- package/dist/src/engine/workflow-engine.js +1807 -0
- package/dist/src/main.js +25 -0
- package/dist/src/mcp/catalog.js +71 -0
- package/dist/src/mcp/main.js +24 -0
- package/dist/src/mcp/server.js +104 -0
- package/dist/src/runtime/codex-app-server.js +91 -0
- package/dist/src/runtime/containment.js +82 -0
- package/dist/src/runtime/engine-driver.js +212 -0
- package/dist/src/runtime/json-line-writer.js +192 -0
- package/dist/src/runtime/pinned-instruction-sources.js +24 -0
- package/dist/src/runtime/protocol-client.js +264 -0
- package/dist/src/runtime/protocol-pool.js +183 -0
- package/dist/src/runtime/protocol-projection.js +393 -0
- package/dist/src/runtime/protocol-types.js +1 -0
- package/dist/src/runtime/protocol-worker.js +18 -0
- package/dist/src/runtime/provider-bridge.js +288 -0
- package/dist/src/runtime/provider-credentials.js +41 -0
- package/dist/src/runtime/provider-transport.js +404 -0
- package/dist/src/runtime/runtime-broker.js +213 -0
- package/dist/src/runtime/workspace-instructions.js +120 -0
- package/dist/src/runtime/workspace-view.js +74 -0
- package/dist/src/server/api-contract.json +11078 -0
- package/dist/src/server/api-types.js +1 -0
- package/dist/src/server/application.js +38 -0
- package/dist/src/server/auth.js +67 -0
- package/dist/src/server/broker-handlers.js +242 -0
- package/dist/src/server/control-plane.js +50 -0
- package/dist/src/server/deployment.js +237 -0
- package/dist/src/server/errors.js +22 -0
- package/dist/src/server/history-handlers.js +113 -0
- package/dist/src/server/http.js +124 -0
- package/dist/src/server/paging.js +56 -0
- package/dist/src/server/publication.js +119 -0
- package/dist/src/server/tool-event-handler.js +77 -0
- package/dist/src/server/workspace-handlers.js +34 -0
- package/dist/src/storage/coordinator.js +224 -0
- package/dist/src/storage/startup-lock.js +71 -0
- package/dist/src/storage/store.js +167 -0
- package/dist/src/tools/check-worker.js +81 -0
- package/dist/src/tools/checks.js +106 -0
- package/dist/src/tools/dns.js +248 -0
- package/dist/src/tools/http-contract.js +38 -0
- package/dist/src/tools/http.js +358 -0
- package/dist/src/tools/index.js +177 -0
- package/dist/src/tools/worker-check.js +73 -0
- package/dist/src/workspaces/git.js +227 -0
- package/dist/src/workspaces/index.js +715 -0
- package/examples/deployment.local.json +22 -0
- package/package.json +68 -4
- package/scripts/postinstall.mjs +25 -0
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "Agentic Workflow YAML",
|
|
4
|
+
"$comment": "Structural workflow validation. Embedded schemas require companion validation; no defaults are inserted.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"kind": {
|
|
8
|
+
"const": "Workflow"
|
|
9
|
+
},
|
|
10
|
+
"version": {
|
|
11
|
+
"const": "1"
|
|
12
|
+
},
|
|
13
|
+
"metadata": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"name": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"minLength": 1
|
|
19
|
+
},
|
|
20
|
+
"description": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": [
|
|
25
|
+
"name"
|
|
26
|
+
],
|
|
27
|
+
"additionalProperties": false
|
|
28
|
+
},
|
|
29
|
+
"types": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"propertyNames": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"pattern": "^[A-Za-z_][A-Za-z0-9_-]*$"
|
|
34
|
+
},
|
|
35
|
+
"additionalProperties": {
|
|
36
|
+
"type": [
|
|
37
|
+
"object",
|
|
38
|
+
"boolean"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"config": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"properties": {
|
|
45
|
+
"timeout": {
|
|
46
|
+
"$ref": "#/$defs/timeout"
|
|
47
|
+
},
|
|
48
|
+
"schema-fetch": {
|
|
49
|
+
"$ref": "#/$defs/schemaFetch"
|
|
50
|
+
},
|
|
51
|
+
"infrastructure-retries": {
|
|
52
|
+
"type": "integer",
|
|
53
|
+
"minimum": 0,
|
|
54
|
+
"default": 3,
|
|
55
|
+
"description": "Retries after an initial infrastructure failure before charging an attempt."
|
|
56
|
+
},
|
|
57
|
+
"verification-retries": {
|
|
58
|
+
"type": "integer",
|
|
59
|
+
"minimum": 0,
|
|
60
|
+
"default": 3,
|
|
61
|
+
"description": "Engine retries after an initial unsuccessful verification operation; not retries of semantic rejection."
|
|
62
|
+
},
|
|
63
|
+
"pause-grace-period": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"pattern": "^[1-9][0-9]*(ms|s|m|h|d)$",
|
|
66
|
+
"default": "60s",
|
|
67
|
+
"description": "Global graceful-pause wait before operator attention; server default 30s. Expiry does not force-stop tools or mark the run paused."
|
|
68
|
+
},
|
|
69
|
+
"agent-profiles": {
|
|
70
|
+
"$ref": "#/$defs/AgentProfileBindings"
|
|
71
|
+
},
|
|
72
|
+
"approval-timeout": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"pattern": "^[1-9][0-9]*(ms|s|m|h|d)$",
|
|
75
|
+
"default": "24h",
|
|
76
|
+
"description": "Wall-clock approval/unused-grant expiry; continues through all pauses, bounded by applicable deadlines."
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"required": [],
|
|
80
|
+
"additionalProperties": false
|
|
81
|
+
},
|
|
82
|
+
"steps": {
|
|
83
|
+
"type": "array",
|
|
84
|
+
"minItems": 1,
|
|
85
|
+
"items": {
|
|
86
|
+
"$ref": "#/$defs/step"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"instruction-resources": {
|
|
90
|
+
"type": "array",
|
|
91
|
+
"items": {
|
|
92
|
+
"$ref": "#/$defs/InstructionResource"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"required": [
|
|
97
|
+
"kind",
|
|
98
|
+
"version",
|
|
99
|
+
"metadata",
|
|
100
|
+
"steps"
|
|
101
|
+
],
|
|
102
|
+
"additionalProperties": false,
|
|
103
|
+
"$defs": {
|
|
104
|
+
"schemaFetch": {
|
|
105
|
+
"$comment": "Workflow-wide fetch timing settings. Defaults describe runtime behavior; validation does not insert them.",
|
|
106
|
+
"type": "object",
|
|
107
|
+
"properties": {
|
|
108
|
+
"timeout": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"pattern": "^[1-9][0-9]*(ms|s|m|h|d)$",
|
|
111
|
+
"default": "30s",
|
|
112
|
+
"description": "Total elapsed-time limit per schema fetch attempt, including connection and complete download."
|
|
113
|
+
},
|
|
114
|
+
"retry-delays": {
|
|
115
|
+
"type": "array",
|
|
116
|
+
"items": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"pattern": "^[1-9][0-9]*(ms|s|m|h|d)$"
|
|
119
|
+
},
|
|
120
|
+
"minItems": 2,
|
|
121
|
+
"maxItems": 2,
|
|
122
|
+
"default": [
|
|
123
|
+
"1s",
|
|
124
|
+
"2s"
|
|
125
|
+
],
|
|
126
|
+
"description": "Delays before attempts two and three, respectively."
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"additionalProperties": false
|
|
130
|
+
},
|
|
131
|
+
"artifact": {
|
|
132
|
+
"oneOf": [
|
|
133
|
+
{
|
|
134
|
+
"type": "object",
|
|
135
|
+
"properties": {
|
|
136
|
+
"$ref": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"pattern": "^(?:#/types/[A-Za-z_][A-Za-z0-9_-]*|[^/#?:\\\\\\r\\n][^#?:\\\\\\r\\n]*(?:#[^#\\r\\n]*)?)$"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"required": [
|
|
142
|
+
"$ref"
|
|
143
|
+
],
|
|
144
|
+
"additionalProperties": false
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"type": "object",
|
|
148
|
+
"not": {
|
|
149
|
+
"required": [
|
|
150
|
+
"$ref"
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"type": "boolean"
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"timeout": {
|
|
160
|
+
"type": "object",
|
|
161
|
+
"properties": {
|
|
162
|
+
"duration": {
|
|
163
|
+
"type": "string",
|
|
164
|
+
"pattern": "^[1-9][0-9]*(ms|s|m|h|d)$"
|
|
165
|
+
},
|
|
166
|
+
"on-timeout": {
|
|
167
|
+
"enum": [
|
|
168
|
+
"fail",
|
|
169
|
+
"block"
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"required": [
|
|
174
|
+
"duration",
|
|
175
|
+
"on-timeout"
|
|
176
|
+
],
|
|
177
|
+
"additionalProperties": false
|
|
178
|
+
},
|
|
179
|
+
"workerTimeout": {
|
|
180
|
+
"type": "object",
|
|
181
|
+
"properties": {
|
|
182
|
+
"duration": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"pattern": "^[1-9][0-9]*(ms|s|m|h|d)$"
|
|
185
|
+
},
|
|
186
|
+
"on-timeout": {
|
|
187
|
+
"const": "reset-session",
|
|
188
|
+
"description": "Exhaustion prepares required handoff and resets if possible; otherwise blocks for decision."
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"required": [
|
|
192
|
+
"duration",
|
|
193
|
+
"on-timeout"
|
|
194
|
+
],
|
|
195
|
+
"additionalProperties": false
|
|
196
|
+
},
|
|
197
|
+
"step": {
|
|
198
|
+
"type": "object",
|
|
199
|
+
"properties": {
|
|
200
|
+
"id": {
|
|
201
|
+
"type": "string",
|
|
202
|
+
"pattern": "^[A-Za-z_][A-Za-z0-9_-]*$"
|
|
203
|
+
},
|
|
204
|
+
"name": {
|
|
205
|
+
"type": "string"
|
|
206
|
+
},
|
|
207
|
+
"execution": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"properties": {
|
|
210
|
+
"max-session-resets": {
|
|
211
|
+
"type": "integer",
|
|
212
|
+
"minimum": 0
|
|
213
|
+
},
|
|
214
|
+
"max-attempts-per-session": {
|
|
215
|
+
"type": "integer",
|
|
216
|
+
"minimum": 1
|
|
217
|
+
},
|
|
218
|
+
"git-reset-on-session-reset": {
|
|
219
|
+
"type": "boolean",
|
|
220
|
+
"default": false
|
|
221
|
+
},
|
|
222
|
+
"session": {
|
|
223
|
+
"type": "object",
|
|
224
|
+
"properties": {
|
|
225
|
+
"timeout": {
|
|
226
|
+
"$ref": "#/$defs/workerTimeout"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"required": [],
|
|
230
|
+
"additionalProperties": false
|
|
231
|
+
},
|
|
232
|
+
"submission-interval": {
|
|
233
|
+
"type": "object",
|
|
234
|
+
"properties": {
|
|
235
|
+
"duration": {
|
|
236
|
+
"type": "string",
|
|
237
|
+
"pattern": "^[1-9][0-9]*(ms|s|m|h|d)$"
|
|
238
|
+
},
|
|
239
|
+
"on-timeout": {
|
|
240
|
+
"const": "block",
|
|
241
|
+
"default": "block"
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
"required": [
|
|
245
|
+
"duration"
|
|
246
|
+
],
|
|
247
|
+
"additionalProperties": false,
|
|
248
|
+
"description": "Time until first/next submission, excluding verification. Restarts after every submission; expiry blocks for a decision."
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
"required": [
|
|
252
|
+
"max-session-resets"
|
|
253
|
+
],
|
|
254
|
+
"additionalProperties": false,
|
|
255
|
+
"anyOf": [
|
|
256
|
+
{
|
|
257
|
+
"required": [
|
|
258
|
+
"max-attempts-per-session"
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"required": [
|
|
263
|
+
"session"
|
|
264
|
+
],
|
|
265
|
+
"properties": {
|
|
266
|
+
"session": {
|
|
267
|
+
"required": [
|
|
268
|
+
"timeout"
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
},
|
|
275
|
+
"exitArtifact": {
|
|
276
|
+
"type": "object",
|
|
277
|
+
"properties": {
|
|
278
|
+
"schema": {
|
|
279
|
+
"$ref": "#/$defs/artifact"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"required": [
|
|
283
|
+
"schema"
|
|
284
|
+
],
|
|
285
|
+
"additionalProperties": false
|
|
286
|
+
},
|
|
287
|
+
"exitCriteria": {
|
|
288
|
+
"type": "object",
|
|
289
|
+
"properties": {
|
|
290
|
+
"deterministic": {
|
|
291
|
+
"type": "object",
|
|
292
|
+
"properties": {
|
|
293
|
+
"checks": {
|
|
294
|
+
"type": "array",
|
|
295
|
+
"items": {
|
|
296
|
+
"type": "string",
|
|
297
|
+
"minLength": 1
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
"required": [],
|
|
302
|
+
"additionalProperties": false
|
|
303
|
+
},
|
|
304
|
+
"semantic": {
|
|
305
|
+
"type": "object",
|
|
306
|
+
"properties": {
|
|
307
|
+
"criteria": {
|
|
308
|
+
"type": "array",
|
|
309
|
+
"items": {
|
|
310
|
+
"type": "string",
|
|
311
|
+
"minLength": 1
|
|
312
|
+
},
|
|
313
|
+
"minItems": 1
|
|
314
|
+
},
|
|
315
|
+
"verifier": {
|
|
316
|
+
"type": "object",
|
|
317
|
+
"properties": {
|
|
318
|
+
"session": {
|
|
319
|
+
"const": "ephemeral"
|
|
320
|
+
},
|
|
321
|
+
"max-attempts": {
|
|
322
|
+
"type": "integer",
|
|
323
|
+
"minimum": 1
|
|
324
|
+
},
|
|
325
|
+
"timeout": {
|
|
326
|
+
"$ref": "#/$defs/timeout"
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
"required": [
|
|
330
|
+
"session"
|
|
331
|
+
],
|
|
332
|
+
"additionalProperties": false,
|
|
333
|
+
"anyOf": [
|
|
334
|
+
{
|
|
335
|
+
"required": [
|
|
336
|
+
"max-attempts"
|
|
337
|
+
]
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"required": [
|
|
341
|
+
"timeout"
|
|
342
|
+
]
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
"required": [
|
|
348
|
+
"criteria",
|
|
349
|
+
"verifier"
|
|
350
|
+
],
|
|
351
|
+
"additionalProperties": false
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
"required": [],
|
|
355
|
+
"additionalProperties": false
|
|
356
|
+
},
|
|
357
|
+
"handoffArtifact": {
|
|
358
|
+
"type": "object",
|
|
359
|
+
"properties": {
|
|
360
|
+
"schema": {
|
|
361
|
+
"$ref": "#/$defs/artifact"
|
|
362
|
+
},
|
|
363
|
+
"historyLimit": {
|
|
364
|
+
"type": "integer",
|
|
365
|
+
"minimum": 0
|
|
366
|
+
},
|
|
367
|
+
"independent-handoff": {
|
|
368
|
+
"type": "boolean"
|
|
369
|
+
},
|
|
370
|
+
"max-attempts": {
|
|
371
|
+
"type": "integer",
|
|
372
|
+
"minimum": 1
|
|
373
|
+
},
|
|
374
|
+
"timeout": {
|
|
375
|
+
"$ref": "#/$defs/timeout"
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
"required": [
|
|
379
|
+
"schema",
|
|
380
|
+
"historyLimit",
|
|
381
|
+
"independent-handoff"
|
|
382
|
+
],
|
|
383
|
+
"additionalProperties": false,
|
|
384
|
+
"allOf": [
|
|
385
|
+
{
|
|
386
|
+
"if": {
|
|
387
|
+
"properties": {
|
|
388
|
+
"independent-handoff": {
|
|
389
|
+
"const": true
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
"required": [
|
|
393
|
+
"independent-handoff"
|
|
394
|
+
]
|
|
395
|
+
},
|
|
396
|
+
"then": {
|
|
397
|
+
"anyOf": [
|
|
398
|
+
{
|
|
399
|
+
"required": [
|
|
400
|
+
"max-attempts"
|
|
401
|
+
]
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"required": [
|
|
405
|
+
"timeout"
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
]
|
|
409
|
+
},
|
|
410
|
+
"else": {
|
|
411
|
+
"not": {
|
|
412
|
+
"required": [
|
|
413
|
+
"timeout"
|
|
414
|
+
]
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
},
|
|
420
|
+
"timeout": {
|
|
421
|
+
"$ref": "#/$defs/timeout"
|
|
422
|
+
},
|
|
423
|
+
"agent-profiles": {
|
|
424
|
+
"$ref": "#/$defs/AgentProfileBindings"
|
|
425
|
+
},
|
|
426
|
+
"instructions": {
|
|
427
|
+
"type": "array",
|
|
428
|
+
"items": {
|
|
429
|
+
"$ref": "#/$defs/InstructionSource"
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
"required": [
|
|
434
|
+
"id",
|
|
435
|
+
"execution",
|
|
436
|
+
"exitArtifact",
|
|
437
|
+
"exitCriteria"
|
|
438
|
+
],
|
|
439
|
+
"additionalProperties": false
|
|
440
|
+
},
|
|
441
|
+
"AgentProfileBindings": {
|
|
442
|
+
"type": "object",
|
|
443
|
+
"properties": {
|
|
444
|
+
"worker": {
|
|
445
|
+
"$ref": "#/$defs/Id"
|
|
446
|
+
},
|
|
447
|
+
"verifier": {
|
|
448
|
+
"$ref": "#/$defs/Id"
|
|
449
|
+
},
|
|
450
|
+
"handoff": {
|
|
451
|
+
"$ref": "#/$defs/Id"
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
"required": [],
|
|
455
|
+
"additionalProperties": false,
|
|
456
|
+
"description": "Complete profile-version IDs, never mutable profile IDs or field overrides. Workflow defaults < run defaults < step bindings; overlay references by role, never merge profile contents. Required roles are checked after resolving the workflow.",
|
|
457
|
+
"minProperties": 1
|
|
458
|
+
},
|
|
459
|
+
"InstructionSource": {
|
|
460
|
+
"oneOf": [
|
|
461
|
+
{
|
|
462
|
+
"type": "object",
|
|
463
|
+
"properties": {
|
|
464
|
+
"kind": {
|
|
465
|
+
"const": "inline"
|
|
466
|
+
},
|
|
467
|
+
"text": {
|
|
468
|
+
"type": "string",
|
|
469
|
+
"minLength": 1
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
"required": [
|
|
473
|
+
"kind",
|
|
474
|
+
"text"
|
|
475
|
+
],
|
|
476
|
+
"additionalProperties": false
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"type": "object",
|
|
480
|
+
"properties": {
|
|
481
|
+
"kind": {
|
|
482
|
+
"const": "file"
|
|
483
|
+
},
|
|
484
|
+
"location": {
|
|
485
|
+
"type": "string",
|
|
486
|
+
"enum": [
|
|
487
|
+
"package",
|
|
488
|
+
"workspace"
|
|
489
|
+
]
|
|
490
|
+
},
|
|
491
|
+
"path": {
|
|
492
|
+
"$ref": "#/$defs/RelativePath"
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
"required": [
|
|
496
|
+
"kind",
|
|
497
|
+
"location",
|
|
498
|
+
"path"
|
|
499
|
+
],
|
|
500
|
+
"additionalProperties": false
|
|
501
|
+
}
|
|
502
|
+
],
|
|
503
|
+
"description": "Ordered UTF-8 user/project instruction source. No URL, automatic discovery or templating. Workspace paths are relative to the managed root; package paths are relative to the owning profile/workflow package."
|
|
504
|
+
},
|
|
505
|
+
"InstructionResource": {
|
|
506
|
+
"type": "object",
|
|
507
|
+
"properties": {
|
|
508
|
+
"path": {
|
|
509
|
+
"$ref": "#/$defs/RelativePath"
|
|
510
|
+
},
|
|
511
|
+
"content": {
|
|
512
|
+
"type": "string"
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
"required": [
|
|
516
|
+
"path",
|
|
517
|
+
"content"
|
|
518
|
+
],
|
|
519
|
+
"additionalProperties": false,
|
|
520
|
+
"description": "UTF-8 instruction file embedded in the immutable source package. Paths must be unique. Not an artifact JSON/YAML schema."
|
|
521
|
+
},
|
|
522
|
+
"RelativePath": {
|
|
523
|
+
"type": "string",
|
|
524
|
+
"minLength": 1,
|
|
525
|
+
"pattern": "^(?!/)(?![A-Za-z][A-Za-z0-9+.-]*:)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))[^\\\\\\r\\n]+(?<!/)$"
|
|
526
|
+
},
|
|
527
|
+
"Id": {
|
|
528
|
+
"type": "string",
|
|
529
|
+
"minLength": 1,
|
|
530
|
+
"maxLength": 128,
|
|
531
|
+
"pattern": "^[A-Za-z0-9_-]+$"
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { workflowLanguageSchema } from './workflow-language.js';
|
|
2
|
+
import { decodeDocument } from './documents.js';
|
|
3
|
+
import { buildSchemaGraph } from './schema-graph.js';
|
|
4
|
+
/** Trusted pure work: invoke ONLY inside a bounded validation worker. */
|
|
5
|
+
export function validateWorkflow(input, checks, ajv, remote = []) {
|
|
6
|
+
const report = { valid: false, issues: [], unresolvedReferences: [], validationLevel: 'structural' };
|
|
7
|
+
const add = (path, code, message) => report.issues.push({ severity: 'error', path, code, message });
|
|
8
|
+
let parsed;
|
|
9
|
+
try {
|
|
10
|
+
parsed = decodeDocument(input.source.content, input.source.format);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
add('/source/content', 'invalid_document', 'Workflow must be acyclic JSON-compatible data with unique string keys.');
|
|
14
|
+
return { report };
|
|
15
|
+
}
|
|
16
|
+
const validate = ajv.compile(workflowLanguageSchema());
|
|
17
|
+
if (!validate(parsed)) {
|
|
18
|
+
for (const error of validate.errors ?? [])
|
|
19
|
+
add(error.instancePath, error.keyword, error.message ?? 'Workflow structure is invalid.');
|
|
20
|
+
return { report };
|
|
21
|
+
}
|
|
22
|
+
const definition = parsed;
|
|
23
|
+
const ids = new Set();
|
|
24
|
+
const instructions = new Map();
|
|
25
|
+
for (const [index, resource] of (definition['instruction-resources'] ?? []).entries()) {
|
|
26
|
+
if (instructions.has(resource.path))
|
|
27
|
+
add(`/instruction-resources/${index}/path`, 'duplicate_path', 'Instruction resource paths must be unique.');
|
|
28
|
+
instructions.set(resource.path, resource.content);
|
|
29
|
+
}
|
|
30
|
+
for (const [index, step] of definition.steps.entries()) {
|
|
31
|
+
if (ids.has(step.id))
|
|
32
|
+
add(`/steps/${index}/id`, 'duplicate_step_id', 'Step IDs must be unique.');
|
|
33
|
+
ids.add(step.id);
|
|
34
|
+
for (const name of step.exitCriteria.deterministic?.checks ?? [])
|
|
35
|
+
if (!checks.includes(name))
|
|
36
|
+
add(`/steps/${index}/exitCriteria/deterministic/checks`, 'unknown_check', 'A required named check is not installed.');
|
|
37
|
+
for (const [position, source] of (step.instructions ?? []).entries())
|
|
38
|
+
if (source.kind === 'file') {
|
|
39
|
+
if (source.location === 'package' && !instructions.has(source.path))
|
|
40
|
+
add(`/steps/${index}/instructions/${position}`, 'missing_package_source', 'Packaged step instruction source is missing.');
|
|
41
|
+
if (source.location === 'workspace')
|
|
42
|
+
report.unresolvedReferences.push(`workspace:${source.path}`);
|
|
43
|
+
}
|
|
44
|
+
const bindings = { ...definition.config?.['agent-profiles'], ...step['agent-profiles'] };
|
|
45
|
+
const roles = ['worker'];
|
|
46
|
+
if (step.exitCriteria.semantic?.criteria.length)
|
|
47
|
+
roles.push('verifier');
|
|
48
|
+
if (step.handoffArtifact?.['independent-handoff'])
|
|
49
|
+
roles.push('handoff');
|
|
50
|
+
for (const role of roles)
|
|
51
|
+
if (!bindings[role])
|
|
52
|
+
report.unresolvedReferences.push(`profile:${step.id}:${role}`);
|
|
53
|
+
}
|
|
54
|
+
let graph;
|
|
55
|
+
try {
|
|
56
|
+
graph = buildSchemaGraph(definition, input, remote);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
add('/schemas', 'invalid_schema_graph', 'Schema identities or references are invalid.');
|
|
60
|
+
return { report, definition };
|
|
61
|
+
}
|
|
62
|
+
for (const issue of graph.errors)
|
|
63
|
+
add(issue.path, issue.code, issue.message);
|
|
64
|
+
report.unresolvedReferences.push(...graph.unresolvedRemote);
|
|
65
|
+
for (const resource of graph.resources) {
|
|
66
|
+
const schema = resource.schema;
|
|
67
|
+
if (typeof schema !== 'boolean' && (schema === null || typeof schema !== 'object' || Array.isArray(schema)))
|
|
68
|
+
continue;
|
|
69
|
+
try {
|
|
70
|
+
if (!ajv.validateSchema(schema))
|
|
71
|
+
for (const error of ajv.errors ?? [])
|
|
72
|
+
add('/schemas', error.keyword, error.message ?? 'Schema syntax is invalid.');
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
add('/schemas', 'invalid_schema', 'Schema syntax or dialect is unsupported.');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!graph.errors.length && !graph.unresolvedRemote.length) {
|
|
79
|
+
try {
|
|
80
|
+
for (const resource of graph.resources) {
|
|
81
|
+
if (typeof resource.schema === 'boolean' || (resource.schema !== null && typeof resource.schema === 'object' && !Array.isArray(resource.schema)))
|
|
82
|
+
ajv.addSchema(resource.schema, resource.uri);
|
|
83
|
+
}
|
|
84
|
+
for (const root of graph.roots)
|
|
85
|
+
ajv.compile({ $ref: root.uri });
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
add('/schemas', 'invalid_schema_graph', 'The complete schema graph cannot be compiled.');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
report.valid = !report.issues.some(issue => issue.severity === 'error');
|
|
92
|
+
report.unresolvedReferences = [...new Set(report.unresolvedReferences)];
|
|
93
|
+
report.validationLevel = 'local_references';
|
|
94
|
+
return { report, definition, graph };
|
|
95
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ApiError } from '../server/errors.js';
|
|
2
|
+
import { durationMs } from './timing.js';
|
|
3
|
+
export function limitsFor(step, role, override = {}) {
|
|
4
|
+
const value = {};
|
|
5
|
+
const bounds = role === 'worker' ? { count: step.execution['max-attempts-per-session'], timeout: step.execution.session?.timeout?.duration } :
|
|
6
|
+
role === 'verifier' ? { count: step.exitCriteria.semantic?.verifier['max-attempts'], timeout: step.exitCriteria.semantic?.verifier.timeout?.duration } :
|
|
7
|
+
{ count: step.handoffArtifact?.['max-attempts'], timeout: step.handoffArtifact?.timeout?.duration };
|
|
8
|
+
if (bounds.count !== undefined)
|
|
9
|
+
value.maxSubmissions = bounds.count;
|
|
10
|
+
if (bounds.timeout !== undefined)
|
|
11
|
+
value.executionTimeLimit = bounds.timeout;
|
|
12
|
+
if (role === 'worker') {
|
|
13
|
+
if (override.workerMaxSubmissions !== undefined)
|
|
14
|
+
value.maxSubmissions = override.workerMaxSubmissions;
|
|
15
|
+
if (override.workerExecutionTimeLimit !== undefined)
|
|
16
|
+
value.executionTimeLimit = override.workerExecutionTimeLimit;
|
|
17
|
+
}
|
|
18
|
+
else
|
|
19
|
+
Object.assign(value, role === 'verifier' ? override.verifierLimits : override.handoffLimits);
|
|
20
|
+
if (value.maxSubmissions === undefined && value.executionTimeLimit === undefined)
|
|
21
|
+
throw new ApiError(422, 'unbounded_session', 'Every selected session role requires an explicit finite count or execution budget.');
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
export function validateIncrease(run, execution, step, current, increase, worker) {
|
|
25
|
+
const larger = (next, previous) => {
|
|
26
|
+
if (next !== undefined && (previous === undefined || !Number.isSafeInteger(next) || next <= previous))
|
|
27
|
+
throw new ApiError(422, 'budget_not_increased', 'Budget changes must be strictly larger absolute maxima.');
|
|
28
|
+
};
|
|
29
|
+
const longer = (next, previous) => larger(next === undefined ? undefined : durationMs(next), previous === undefined ? undefined : durationMs(previous));
|
|
30
|
+
const workerLimits = worker?.limits ?? limitsFor(step, 'worker', current);
|
|
31
|
+
larger(increase.maxSessionResets, execution.maxSessionResets);
|
|
32
|
+
larger(increase.workerMaxSubmissions, workerLimits.maxSubmissions);
|
|
33
|
+
longer(increase.workerExecutionTimeLimit, workerLimits.executionTimeLimit);
|
|
34
|
+
larger(increase.infrastructureRetries, run.policy.infrastructureRetries ?? 3);
|
|
35
|
+
larger(increase.verificationRetries, run.policy.verificationRetries ?? 3);
|
|
36
|
+
longer(increase.submissionInterval, current.submissionInterval ?? step.execution['submission-interval']?.duration);
|
|
37
|
+
for (const role of ['verifier', 'handoff']) {
|
|
38
|
+
const next = role === 'verifier' ? increase.verifierLimits : increase.handoffLimits;
|
|
39
|
+
if (!next)
|
|
40
|
+
continue;
|
|
41
|
+
const previous = limitsFor(step, role, current);
|
|
42
|
+
larger(next.maxSubmissions, previous.maxSubmissions);
|
|
43
|
+
longer(next.executionTimeLimit, previous.executionTimeLimit);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function mergeIncrease(current, increase) {
|
|
47
|
+
return { ...current, ...increase,
|
|
48
|
+
...(current.verifierLimits || increase.verifierLimits ? { verifierLimits: { ...current.verifierLimits, ...increase.verifierLimits } } : {}),
|
|
49
|
+
...(current.handoffLimits || increase.handoffLimits ? { handoffLimits: { ...current.handoffLimits, ...increase.handoffLimits } } : {}) };
|
|
50
|
+
}
|