flowspec2 1.0.0__py3-none-any.whl

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.
Files changed (92) hide show
  1. flowspec2/__init__.py +105 -0
  2. flowspec2/authoring/__init__.py +275 -0
  3. flowspec2/authoring/authoring-evidence-signature.schema.json +34 -0
  4. flowspec2/authoring/authoring-evidence.schema.json +455 -0
  5. flowspec2/authoring/authoring-operational-evidence.schema.json +160 -0
  6. flowspec2/authoring/benchmark.py +1409 -0
  7. flowspec2/authoring/corpus/await_correction.case.json +220 -0
  8. flowspec2/authoring/corpus/flowspec2.ctk.json +769 -0
  9. flowspec2/authoring/corpus/gated_derive.case.json +100 -0
  10. flowspec2/authoring/corpus/linear.case.json +55 -0
  11. flowspec2/authoring/corpus/manifest.json +31 -0
  12. flowspec2/authoring/corpus/subflow.case.json +66 -0
  13. flowspec2/authoring/corpus/terminal.case.json +94 -0
  14. flowspec2/authoring/corpus.py +307 -0
  15. flowspec2/authoring/ctk.py +836 -0
  16. flowspec2/authoring/detached_signature.py +120 -0
  17. flowspec2/authoring/evidence.py +311 -0
  18. flowspec2/authoring/evidence_signature.py +187 -0
  19. flowspec2/authoring/evidence_verification.py +229 -0
  20. flowspec2/authoring/gemini.py +215 -0
  21. flowspec2/authoring/operational-corpus.json +61 -0
  22. flowspec2/authoring/operational.py +956 -0
  23. flowspec2/authoring/operational_providers.py +167 -0
  24. flowspec2/authoring/presentation_review.py +1013 -0
  25. flowspec2/authoring/presentation_review_signature.py +305 -0
  26. flowspec2/authoring/projection.py +299 -0
  27. flowspec2/authoring/provider_prompt.py +83 -0
  28. flowspec2/backends/__init__.py +82 -0
  29. flowspec2/backends/http.py +189 -0
  30. flowspec2/checker.py +238 -0
  31. flowspec2/cli.py +789 -0
  32. flowspec2/cli_parser.py +345 -0
  33. flowspec2/clock.py +23 -0
  34. flowspec2/compat/__init__.py +47 -0
  35. flowspec2/compat/models.py +82 -0
  36. flowspec2/compat/open_workflow.py +616 -0
  37. flowspec2/compat/rasa.py +19 -0
  38. flowspec2/compat/rasa_export.py +876 -0
  39. flowspec2/compat/rasa_import.py +992 -0
  40. flowspec2/compat/rasa_shared.py +270 -0
  41. flowspec2/compat/schemas/open-workflow-conversation-1.schema.json +138 -0
  42. flowspec2/compat/schemas/vendor/open-workflow-1.0.3.LICENSE +201 -0
  43. flowspec2/compat/schemas/vendor/open-workflow-1.0.3.provenance.json +13 -0
  44. flowspec2/compat/schemas/vendor/open-workflow-1.0.3.workflow.yaml +1956 -0
  45. flowspec2/compat/tool_profiles.py +149 -0
  46. flowspec2/compat/yaml.py +147 -0
  47. flowspec2/compiler.py +957 -0
  48. flowspec2/compiler_contracts.py +17 -0
  49. flowspec2/compiler_resume_contracts.py +594 -0
  50. flowspec2/compiler_schema_relations.py +1830 -0
  51. flowspec2/compiler_tool_contracts.py +245 -0
  52. flowspec2/compiler_value_contracts.py +447 -0
  53. flowspec2/derive.py +32 -0
  54. flowspec2/diagnostics.py +94 -0
  55. flowspec2/domains.py +489 -0
  56. flowspec2/experimental/__init__.py +57 -0
  57. flowspec2/experimental/flowspec-3-draft.schema.json +923 -0
  58. flowspec2/experimental/v3-preview-loss-policy.json +161 -0
  59. flowspec2/experimental/v3_lowering.py +928 -0
  60. flowspec2/experimental/v3_preview.py +2460 -0
  61. flowspec2/flowspec-2.schema.json +635 -0
  62. flowspec2/interactive.py +300 -0
  63. flowspec2/ir.py +1459 -0
  64. flowspec2/json_codec.py +120 -0
  65. flowspec2/llm.py +366 -0
  66. flowspec2/models.py +121 -0
  67. flowspec2/nodes.py +1537 -0
  68. flowspec2/observability.py +151 -0
  69. flowspec2/predicates.py +89 -0
  70. flowspec2/profiles.py +118 -0
  71. flowspec2/py.typed +0 -0
  72. flowspec2/runtime.py +1059 -0
  73. flowspec2/schema.py +54 -0
  74. flowspec2/schema_contracts.py +203 -0
  75. flowspec2/semantic_derive_contracts.py +530 -0
  76. flowspec2/semantic_path_contracts.py +528 -0
  77. flowspec2/semantic_predicate_contracts.py +355 -0
  78. flowspec2/semantic_schema_contracts.py +137 -0
  79. flowspec2/semantic_source_contracts.py +21 -0
  80. flowspec2/semantic_state_contracts.py +450 -0
  81. flowspec2/semantic_support.py +40 -0
  82. flowspec2/semantics.py +410 -0
  83. flowspec2/state_migration.py +1034 -0
  84. flowspec2/subflows/__init__.py +1117 -0
  85. flowspec2/subflows/address.py +328 -0
  86. flowspec2/subflows/identification.py +1031 -0
  87. flowspec2/tools.py +1154 -0
  88. flowspec2-1.0.0.dist-info/METADATA +482 -0
  89. flowspec2-1.0.0.dist-info/RECORD +92 -0
  90. flowspec2-1.0.0.dist-info/WHEEL +4 -0
  91. flowspec2-1.0.0.dist-info/entry_points.txt +2 -0
  92. flowspec2-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,455 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://wllsena.github.io/flowspec2/schemas/authoring-benchmark-evidence-2.json",
4
+ "title": "FlowSpec2 authoring benchmark evidence",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "format",
9
+ "package_version",
10
+ "repository_revision",
11
+ "benchmark",
12
+ "corpus",
13
+ "profile",
14
+ "source_adapter",
15
+ "provider",
16
+ "captures",
17
+ "report",
18
+ "digest"
19
+ ],
20
+ "properties": {
21
+ "format": {
22
+ "const": "flowspec2/authoring-benchmark-evidence@3"
23
+ },
24
+ "package_version": {
25
+ "type": "string",
26
+ "minLength": 1
27
+ },
28
+ "repository_revision": {
29
+ "type": "string",
30
+ "minLength": 1
31
+ },
32
+ "benchmark": {
33
+ "$ref": "#/$defs/benchmark"
34
+ },
35
+ "corpus": {
36
+ "$ref": "#/$defs/corpus"
37
+ },
38
+ "profile": {
39
+ "$ref": "#/$defs/profile"
40
+ },
41
+ "source_adapter": {
42
+ "$ref": "#/$defs/sourceAdapter"
43
+ },
44
+ "provider": {
45
+ "$ref": "#/$defs/provider"
46
+ },
47
+ "captures": {
48
+ "type": "array",
49
+ "minItems": 1,
50
+ "items": {
51
+ "$ref": "#/$defs/capture"
52
+ }
53
+ },
54
+ "report": {
55
+ "$ref": "#/$defs/report"
56
+ },
57
+ "digest": {
58
+ "$ref": "#/$defs/digest"
59
+ }
60
+ },
61
+ "$defs": {
62
+ "identifier": {
63
+ "type": "string",
64
+ "pattern": "^[a-z0-9][a-z0-9_-]*$"
65
+ },
66
+ "nonEmptyString": {
67
+ "type": "string",
68
+ "minLength": 1
69
+ },
70
+ "digest": {
71
+ "type": "string",
72
+ "pattern": "^[0-9a-f]{64}$"
73
+ },
74
+ "benchmark": {
75
+ "type": "object",
76
+ "additionalProperties": false,
77
+ "required": [
78
+ "max_correction_rounds"
79
+ ],
80
+ "properties": {
81
+ "max_correction_rounds": {
82
+ "type": "integer",
83
+ "minimum": 0
84
+ }
85
+ }
86
+ },
87
+ "corpus": {
88
+ "type": "object",
89
+ "additionalProperties": false,
90
+ "required": [
91
+ "format",
92
+ "case_format",
93
+ "identifier",
94
+ "digest",
95
+ "case_identifiers"
96
+ ],
97
+ "properties": {
98
+ "format": {
99
+ "const": "flowspec2/authoring-corpus@3"
100
+ },
101
+ "case_format": {
102
+ "const": "flowspec2/authoring-case@3"
103
+ },
104
+ "identifier": {
105
+ "$ref": "#/$defs/identifier"
106
+ },
107
+ "digest": {
108
+ "$ref": "#/$defs/digest"
109
+ },
110
+ "case_identifiers": {
111
+ "type": "array",
112
+ "minItems": 1,
113
+ "uniqueItems": true,
114
+ "items": {
115
+ "$ref": "#/$defs/identifier"
116
+ }
117
+ }
118
+ }
119
+ },
120
+ "profile": {
121
+ "type": "object",
122
+ "additionalProperties": false,
123
+ "required": [
124
+ "identifier",
125
+ "digest"
126
+ ],
127
+ "properties": {
128
+ "identifier": {
129
+ "$ref": "#/$defs/nonEmptyString"
130
+ },
131
+ "digest": {
132
+ "$ref": "#/$defs/digest"
133
+ }
134
+ }
135
+ },
136
+ "sourceAdapter": {
137
+ "type": "object",
138
+ "additionalProperties": false,
139
+ "required": [
140
+ "format",
141
+ "implementation",
142
+ "version"
143
+ ],
144
+ "properties": {
145
+ "format": {
146
+ "const": "flowspec/2"
147
+ },
148
+ "implementation": {
149
+ "const": "FlowSpec2JsonAdapter"
150
+ },
151
+ "version": {
152
+ "const": "1"
153
+ }
154
+ }
155
+ },
156
+ "provider": {
157
+ "type": "object",
158
+ "additionalProperties": false,
159
+ "required": [
160
+ "identifier",
161
+ "model",
162
+ "sdk",
163
+ "sdk_version",
164
+ "prompt_format",
165
+ "prompt_digest",
166
+ "generation_configuration"
167
+ ],
168
+ "properties": {
169
+ "identifier": {
170
+ "$ref": "#/$defs/identifier"
171
+ },
172
+ "model": {
173
+ "$ref": "#/$defs/nonEmptyString"
174
+ },
175
+ "sdk": {
176
+ "$ref": "#/$defs/nonEmptyString"
177
+ },
178
+ "sdk_version": {
179
+ "$ref": "#/$defs/nonEmptyString"
180
+ },
181
+ "prompt_format": {
182
+ "$ref": "#/$defs/nonEmptyString"
183
+ },
184
+ "prompt_digest": {
185
+ "$ref": "#/$defs/digest"
186
+ },
187
+ "generation_configuration": {
188
+ "type": "object"
189
+ }
190
+ }
191
+ },
192
+ "capture": {
193
+ "type": "object",
194
+ "additionalProperties": false,
195
+ "required": [
196
+ "case_identifier",
197
+ "correction_round",
198
+ "authored_source",
199
+ "source_sha256",
200
+ "effective_model_version"
201
+ ],
202
+ "properties": {
203
+ "case_identifier": {
204
+ "$ref": "#/$defs/identifier"
205
+ },
206
+ "correction_round": {
207
+ "type": "integer",
208
+ "minimum": 0
209
+ },
210
+ "authored_source": {
211
+ "type": "string"
212
+ },
213
+ "source_sha256": {
214
+ "$ref": "#/$defs/digest"
215
+ },
216
+ "effective_model_version": {
217
+ "oneOf": [
218
+ {
219
+ "type": "string",
220
+ "minLength": 1
221
+ },
222
+ {
223
+ "type": "null"
224
+ }
225
+ ]
226
+ }
227
+ }
228
+ },
229
+ "report": {
230
+ "type": "object",
231
+ "additionalProperties": false,
232
+ "required": [
233
+ "benchmark_identifier",
234
+ "format_identifier",
235
+ "profile_identifier",
236
+ "successful_cases",
237
+ "total_cases",
238
+ "total_attempts",
239
+ "total_correction_rounds",
240
+ "token_proxy",
241
+ "case_results"
242
+ ],
243
+ "properties": {
244
+ "benchmark_identifier": {
245
+ "$ref": "#/$defs/identifier"
246
+ },
247
+ "format_identifier": {
248
+ "const": "flowspec/2"
249
+ },
250
+ "profile_identifier": {
251
+ "$ref": "#/$defs/nonEmptyString"
252
+ },
253
+ "successful_cases": {
254
+ "type": "integer",
255
+ "minimum": 0
256
+ },
257
+ "total_cases": {
258
+ "type": "integer",
259
+ "minimum": 1
260
+ },
261
+ "total_attempts": {
262
+ "type": "integer",
263
+ "minimum": 1
264
+ },
265
+ "total_correction_rounds": {
266
+ "type": "integer",
267
+ "minimum": 0
268
+ },
269
+ "token_proxy": {
270
+ "type": "object",
271
+ "additionalProperties": false,
272
+ "required": [
273
+ "method",
274
+ "bytes_per_unit"
275
+ ],
276
+ "properties": {
277
+ "method": {
278
+ "const": "utf8_byte_quartets"
279
+ },
280
+ "bytes_per_unit": {
281
+ "const": 4
282
+ }
283
+ }
284
+ },
285
+ "case_results": {
286
+ "type": "array",
287
+ "minItems": 1,
288
+ "items": {
289
+ "$ref": "#/$defs/caseResult"
290
+ }
291
+ }
292
+ }
293
+ },
294
+ "caseResult": {
295
+ "type": "object",
296
+ "additionalProperties": false,
297
+ "required": [
298
+ "case_identifier",
299
+ "feature_tags",
300
+ "format_identifier",
301
+ "succeeded",
302
+ "correction_rounds",
303
+ "attempts"
304
+ ],
305
+ "properties": {
306
+ "case_identifier": {
307
+ "$ref": "#/$defs/identifier"
308
+ },
309
+ "feature_tags": {
310
+ "type": "array",
311
+ "uniqueItems": true,
312
+ "items": {
313
+ "$ref": "#/$defs/nonEmptyString"
314
+ }
315
+ },
316
+ "format_identifier": {
317
+ "const": "flowspec/2"
318
+ },
319
+ "succeeded": {
320
+ "type": "boolean"
321
+ },
322
+ "correction_rounds": {
323
+ "type": "integer",
324
+ "minimum": 0
325
+ },
326
+ "attempts": {
327
+ "type": "array",
328
+ "minItems": 1,
329
+ "items": {
330
+ "$ref": "#/$defs/attempt"
331
+ }
332
+ }
333
+ }
334
+ },
335
+ "attempt": {
336
+ "type": "object",
337
+ "additionalProperties": false,
338
+ "required": [
339
+ "correction_round",
340
+ "source_sha256",
341
+ "raw_source_bytes",
342
+ "canonical_source_bytes",
343
+ "token_proxy_units",
344
+ "compilation",
345
+ "succeeded",
346
+ "diagnostics"
347
+ ],
348
+ "properties": {
349
+ "correction_round": {
350
+ "type": "integer",
351
+ "minimum": 0
352
+ },
353
+ "source_sha256": {
354
+ "$ref": "#/$defs/digest"
355
+ },
356
+ "raw_source_bytes": {
357
+ "type": "integer",
358
+ "minimum": 0
359
+ },
360
+ "canonical_source_bytes": {
361
+ "oneOf": [
362
+ {
363
+ "type": "integer",
364
+ "minimum": 0
365
+ },
366
+ {
367
+ "type": "null"
368
+ }
369
+ ]
370
+ },
371
+ "token_proxy_units": {
372
+ "oneOf": [
373
+ {
374
+ "type": "integer",
375
+ "minimum": 0
376
+ },
377
+ {
378
+ "type": "null"
379
+ }
380
+ ]
381
+ },
382
+ "compilation": {
383
+ "enum": [
384
+ "not_requested",
385
+ "skipped",
386
+ "succeeded",
387
+ "failed"
388
+ ]
389
+ },
390
+ "succeeded": {
391
+ "type": "boolean"
392
+ },
393
+ "diagnostics": {
394
+ "type": "array",
395
+ "items": {
396
+ "$ref": "#/$defs/diagnostic"
397
+ }
398
+ }
399
+ }
400
+ },
401
+ "diagnostic": {
402
+ "type": "object",
403
+ "additionalProperties": false,
404
+ "required": [
405
+ "code",
406
+ "severity",
407
+ "path",
408
+ "message"
409
+ ],
410
+ "properties": {
411
+ "code": {
412
+ "$ref": "#/$defs/nonEmptyString"
413
+ },
414
+ "severity": {
415
+ "enum": [
416
+ "warning",
417
+ "error"
418
+ ]
419
+ },
420
+ "path": {
421
+ "type": "string",
422
+ "pattern": "^$|^/"
423
+ },
424
+ "message": {
425
+ "$ref": "#/$defs/nonEmptyString"
426
+ },
427
+ "related_locations": {
428
+ "type": "array",
429
+ "items": {
430
+ "$ref": "#/$defs/diagnosticLocation"
431
+ }
432
+ },
433
+ "suggested_fix": {
434
+ "$ref": "#/$defs/nonEmptyString"
435
+ }
436
+ }
437
+ },
438
+ "diagnosticLocation": {
439
+ "type": "object",
440
+ "additionalProperties": false,
441
+ "required": [
442
+ "path"
443
+ ],
444
+ "properties": {
445
+ "path": {
446
+ "type": "string",
447
+ "pattern": "^$|^/"
448
+ },
449
+ "message": {
450
+ "$ref": "#/$defs/nonEmptyString"
451
+ }
452
+ }
453
+ }
454
+ }
455
+ }
@@ -0,0 +1,160 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://wllsena.github.io/flowspec2/schemas/authoring-operational-evidence-2.json",
4
+ "title": "FlowSpec2 report-only authoring operational evidence",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "format",
9
+ "classification",
10
+ "package_version",
11
+ "repository_revision",
12
+ "benchmark_evidence_digest",
13
+ "corpus",
14
+ "provider",
15
+ "catalog",
16
+ "captures",
17
+ "matched_probes",
18
+ "total_probes",
19
+ "all_matched",
20
+ "digest"
21
+ ],
22
+ "properties": {
23
+ "format": {"const": "flowspec2/authoring-operational-evidence@2"},
24
+ "classification": {"const": "report_only"},
25
+ "package_version": {"type": "string", "minLength": 1},
26
+ "repository_revision": {"type": "string", "minLength": 1},
27
+ "benchmark_evidence_digest": {"$ref": "#/$defs/digest"},
28
+ "corpus": {"$ref": "#/$defs/corpus"},
29
+ "provider": {"$ref": "#/$defs/provider"},
30
+ "catalog": {"$ref": "#/$defs/catalog"},
31
+ "captures": {
32
+ "type": "array",
33
+ "minItems": 1,
34
+ "items": {"$ref": "#/$defs/capture"}
35
+ },
36
+ "matched_probes": {"type": "integer", "minimum": 0},
37
+ "total_probes": {"type": "integer", "minimum": 1},
38
+ "all_matched": {"type": "boolean"},
39
+ "digest": {"$ref": "#/$defs/digest"}
40
+ },
41
+ "$defs": {
42
+ "identifier": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_-]*$"},
43
+ "digest": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
44
+ "corpus": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "required": ["format", "probe_format", "identifier", "digest", "probe_identifiers"],
48
+ "properties": {
49
+ "format": {"const": "flowspec2/operational-corpus@2"},
50
+ "probe_format": {"const": "flowspec2/operational-probe@2"},
51
+ "identifier": {"const": "flowspec2_reference_operational"},
52
+ "digest": {"$ref": "#/$defs/digest"},
53
+ "probe_identifiers": {
54
+ "type": "array",
55
+ "minItems": 1,
56
+ "uniqueItems": true,
57
+ "items": {"$ref": "#/$defs/identifier"}
58
+ }
59
+ }
60
+ },
61
+ "provider": {
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "required": [
65
+ "identifier",
66
+ "model",
67
+ "sdk",
68
+ "sdk_version",
69
+ "prompt_format",
70
+ "prompt_digest",
71
+ "generation_configuration"
72
+ ],
73
+ "properties": {
74
+ "identifier": {"$ref": "#/$defs/identifier"},
75
+ "model": {"type": "string", "minLength": 1},
76
+ "sdk": {"type": "string", "minLength": 1},
77
+ "sdk_version": {"type": "string", "minLength": 1},
78
+ "prompt_format": {"const": "flowspec2/operational-structured-output@1"},
79
+ "prompt_digest": {"$ref": "#/$defs/digest"},
80
+ "generation_configuration": {"type": "object"}
81
+ }
82
+ },
83
+ "catalog": {
84
+ "type": "object",
85
+ "additionalProperties": false,
86
+ "required": ["source_closure", "digest"],
87
+ "properties": {
88
+ "source_closure": {
89
+ "type": "array",
90
+ "minItems": 1,
91
+ "items": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "required": ["case_identifier", "correction_round", "source_sha256"],
95
+ "properties": {
96
+ "case_identifier": {"$ref": "#/$defs/identifier"},
97
+ "correction_round": {"type": "integer", "minimum": 0},
98
+ "source_sha256": {"$ref": "#/$defs/digest"}
99
+ }
100
+ }
101
+ },
102
+ "digest": {"$ref": "#/$defs/digest"}
103
+ }
104
+ },
105
+ "request": {
106
+ "type": "object",
107
+ "additionalProperties": false,
108
+ "required": ["system_instruction", "prompt", "response_schema"],
109
+ "properties": {
110
+ "system_instruction": {"type": "string", "minLength": 1},
111
+ "prompt": {"type": "string", "minLength": 1},
112
+ "response_schema": {"type": "object"}
113
+ }
114
+ },
115
+ "capture": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "required": [
119
+ "probe_identifier",
120
+ "pair_identifier",
121
+ "subject_mode",
122
+ "operation",
123
+ "authoring_case_identifier",
124
+ "correction_round",
125
+ "source_sha256",
126
+ "subject_pointer",
127
+ "subject_sha256",
128
+ "request",
129
+ "expected_output",
130
+ "raw_output",
131
+ "raw_output_sha256",
132
+ "parsed_output",
133
+ "effective_model_version",
134
+ "matched",
135
+ "diagnostic"
136
+ ],
137
+ "properties": {
138
+ "probe_identifier": {"$ref": "#/$defs/identifier"},
139
+ "pair_identifier": {"$ref": "#/$defs/identifier"},
140
+ "subject_mode": {"enum": ["authored", "counterfactual"]},
141
+ "operation": {"enum": ["route", "extract"]},
142
+ "authoring_case_identifier": {"$ref": "#/$defs/identifier"},
143
+ "correction_round": {"type": "integer", "minimum": 0},
144
+ "source_sha256": {"$ref": "#/$defs/digest"},
145
+ "subject_pointer": {"type": "string", "pattern": "^/"},
146
+ "subject_sha256": {"$ref": "#/$defs/digest"},
147
+ "request": {"$ref": "#/$defs/request"},
148
+ "expected_output": {},
149
+ "raw_output": {"type": "string"},
150
+ "raw_output_sha256": {"$ref": "#/$defs/digest"},
151
+ "parsed_output": {},
152
+ "effective_model_version": {"type": ["string", "null"]},
153
+ "matched": {"type": "boolean"},
154
+ "diagnostic": {
155
+ "enum": [null, "invalid_json", "schema_mismatch", "semantic_mismatch"]
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }