coreason-manifest 0.9.0__py3-none-any.whl → 0.12.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 (30) hide show
  1. coreason_manifest/__init__.py +47 -13
  2. coreason_manifest/common.py +64 -0
  3. coreason_manifest/governance.py +83 -0
  4. coreason_manifest/schemas/__init__.py +9 -1
  5. coreason_manifest/schemas/coreason-v2.schema.json +462 -0
  6. coreason_manifest/utils/__init__.py +10 -0
  7. coreason_manifest/utils/logger.py +10 -0
  8. coreason_manifest/v2/__init__.py +1 -0
  9. coreason_manifest/v2/governance.py +144 -0
  10. coreason_manifest/v2/io.py +132 -0
  11. coreason_manifest/v2/resolver.py +67 -0
  12. coreason_manifest/v2/spec/__init__.py +1 -0
  13. coreason_manifest/v2/spec/contracts.py +34 -0
  14. coreason_manifest/v2/spec/definitions.py +196 -0
  15. coreason_manifest/v2/validator.py +48 -0
  16. {coreason_manifest-0.9.0.dist-info → coreason_manifest-0.12.0.dist-info}/METADATA +68 -29
  17. coreason_manifest-0.12.0.dist-info/RECORD +20 -0
  18. {coreason_manifest-0.9.0.dist-info → coreason_manifest-0.12.0.dist-info}/WHEEL +1 -1
  19. coreason_manifest/definitions/__init__.py +0 -49
  20. coreason_manifest/definitions/agent.py +0 -292
  21. coreason_manifest/definitions/audit.py +0 -122
  22. coreason_manifest/definitions/events.py +0 -392
  23. coreason_manifest/definitions/message.py +0 -126
  24. coreason_manifest/definitions/simulation.py +0 -50
  25. coreason_manifest/definitions/topology.py +0 -255
  26. coreason_manifest/recipes.py +0 -76
  27. coreason_manifest/schemas/agent.schema.json +0 -849
  28. coreason_manifest-0.9.0.dist-info/RECORD +0 -18
  29. {coreason_manifest-0.9.0.dist-info → coreason_manifest-0.12.0.dist-info}/licenses/LICENSE +0 -0
  30. {coreason_manifest-0.9.0.dist-info → coreason_manifest-0.12.0.dist-info}/licenses/NOTICE +0 -0
@@ -1,17 +1,51 @@
1
- from .definitions.agent import AgentDefinition
2
- from .definitions.audit import AuditLog
3
- from .definitions.simulation import SimulationScenario, SimulationStep, SimulationTrace
4
- from .definitions.topology import Edge, Node, Topology
5
- from .recipes import RecipeManifest
1
+ # Copyright (c) 2025 CoReason, Inc.
2
+ #
3
+ # This software is proprietary and dual-licensed.
4
+ # Licensed under the Prosperity Public License 3.0 (the "License").
5
+ # A copy of the license is available at https://prosperitylicense.com/versions/3.0.0
6
+ # For details, see the LICENSE file.
7
+ # Commercial use beyond a 30-day trial requires a separate license.
8
+ #
9
+ # Source Code: https://github.com/CoReason-AI/coreason-manifest
10
+
11
+ from .v2.io import dump_to_yaml, load_from_yaml
12
+ from .v2.spec.contracts import InterfaceDefinition, PolicyDefinition, StateDefinition
13
+ from .v2.spec.definitions import (
14
+ AgentDefinition,
15
+ AgentStep,
16
+ CouncilStep,
17
+ LogicStep,
18
+ ManifestMetadata,
19
+ ManifestV2,
20
+ Step,
21
+ SwitchStep,
22
+ ToolDefinition,
23
+ Workflow,
24
+ )
25
+
26
+ __version__ = "0.12.0"
27
+
28
+ Manifest = ManifestV2
29
+ Recipe = ManifestV2
30
+ load = load_from_yaml
31
+ dump = dump_to_yaml
6
32
 
7
33
  __all__ = [
34
+ "Manifest",
35
+ "Recipe",
36
+ "load",
37
+ "dump",
38
+ "__version__",
39
+ "ManifestMetadata",
40
+ "AgentStep",
41
+ "Workflow",
8
42
  "AgentDefinition",
9
- "Topology",
10
- "Node",
11
- "Edge",
12
- "SimulationScenario",
13
- "SimulationTrace",
14
- "SimulationStep",
15
- "AuditLog",
16
- "RecipeManifest",
43
+ "ToolDefinition",
44
+ "Step",
45
+ "LogicStep",
46
+ "SwitchStep",
47
+ "CouncilStep",
48
+ "InterfaceDefinition",
49
+ "StateDefinition",
50
+ "PolicyDefinition",
17
51
  ]
@@ -0,0 +1,64 @@
1
+ # Copyright (c) 2025 CoReason, Inc.
2
+ #
3
+ # This software is proprietary and dual-licensed.
4
+ # Licensed under the Prosperity Public License 3.0 (the "License").
5
+ # A copy of the license is available at https://prosperitylicense.com/versions/3.0.0
6
+ # For details, see the LICENSE file.
7
+ # Commercial use beyond a 30-day trial requires a separate license.
8
+ #
9
+ # Source Code: https://github.com/CoReason-AI/coreason-manifest
10
+
11
+ from enum import Enum
12
+ from typing import Any, Dict
13
+
14
+ from pydantic import AnyUrl, BaseModel, ConfigDict, PlainSerializer
15
+ from typing_extensions import Annotated
16
+
17
+
18
+ class CoReasonBaseModel(BaseModel):
19
+ """Base model for all CoReason Pydantic models with enhanced serialization.
20
+
21
+ This base class addresses JSON serialization challenges in Pydantic v2 (e.g., UUID, datetime)
22
+ by providing standardized methods (`dump`, `to_json`) with optimal configuration.
23
+
24
+ For a detailed rationale, see `docs/coreason_base_model_rationale.md`.
25
+ """
26
+
27
+ model_config = ConfigDict(populate_by_name=True)
28
+
29
+ def dump(self, **kwargs: Any) -> Dict[str, Any]:
30
+ """Serialize the model to a JSON-compatible dictionary.
31
+
32
+ Uses mode='json' to ensure types like UUID and datetime are serialized to strings.
33
+ Defaults to by_alias=True and exclude_none=True.
34
+ """
35
+ # Set defaults but allow overrides
36
+ kwargs.setdefault("mode", "json")
37
+ kwargs.setdefault("by_alias", True)
38
+ kwargs.setdefault("exclude_none", True)
39
+ return self.model_dump(**kwargs)
40
+
41
+ def to_json(self, **kwargs: Any) -> str:
42
+ """Serialize the model to a JSON string.
43
+
44
+ Defaults to by_alias=True and exclude_none=True.
45
+ """
46
+ # Set defaults but allow overrides
47
+ kwargs.setdefault("by_alias", True)
48
+ kwargs.setdefault("exclude_none", True)
49
+ return self.model_dump_json(**kwargs)
50
+
51
+
52
+ # Strict URI type that serializes to string
53
+ StrictUri = Annotated[
54
+ AnyUrl,
55
+ PlainSerializer(lambda x: str(x), return_type=str),
56
+ ]
57
+
58
+
59
+ class ToolRiskLevel(str, Enum):
60
+ """Risk level for the tool."""
61
+
62
+ SAFE = "safe"
63
+ STANDARD = "standard"
64
+ CRITICAL = "critical"
@@ -0,0 +1,83 @@
1
+ # Copyright (c) 2025 CoReason, Inc.
2
+ #
3
+ # This software is proprietary and dual-licensed.
4
+ # Licensed under the Prosperity Public License 3.0 (the "License").
5
+ # A copy of the license is available at https://prosperitylicense.com/versions/3.0.0
6
+ # For details, see the LICENSE file.
7
+ # Commercial use beyond a 30-day trial requires a separate license.
8
+ #
9
+ # Source Code: https://github.com/CoReason-AI/coreason-manifest
10
+
11
+ """Governance and Policy Enforcement module for Coreason Agents.
12
+
13
+ This module provides tools to validate an AgentDefinition against a set of organizational rules.
14
+ """
15
+
16
+ from typing import List, Optional
17
+
18
+ from pydantic import ConfigDict, Field
19
+
20
+ from coreason_manifest.common import CoReasonBaseModel, ToolRiskLevel
21
+
22
+
23
+ class GovernanceConfig(CoReasonBaseModel):
24
+ """Configuration for governance rules.
25
+
26
+ Attributes:
27
+ allowed_domains: List of allowed domains for tool URIs.
28
+ max_risk_level: Maximum allowed risk level for tools.
29
+ require_auth_for_critical_tools: Whether authentication is required for agents using CRITICAL tools.
30
+ allow_inline_tools: Whether to allow inline tool definitions (which lack risk scoring).
31
+ allow_custom_logic: Whether to allow LogicNodes and conditional Edges with custom code.
32
+ strict_url_validation: Enforce strict, normalized URL validation.
33
+ """
34
+
35
+ model_config = ConfigDict(extra="forbid", frozen=True)
36
+
37
+ allowed_domains: Optional[List[str]] = Field(
38
+ None, description="If provided, all Tool URIs must match one of these domains."
39
+ )
40
+ max_risk_level: Optional[ToolRiskLevel] = Field(
41
+ None, description="If provided, no tool can exceed this risk level."
42
+ )
43
+ require_auth_for_critical_tools: bool = Field(
44
+ True,
45
+ description="If an agent uses a CRITICAL tool, agent.metadata.requires_auth must be True.",
46
+ )
47
+ allow_inline_tools: bool = Field(
48
+ True, description="Whether to allow inline tool definitions (which lack risk scoring)."
49
+ )
50
+ allow_custom_logic: bool = Field(
51
+ False, description="Whether to allow LogicNodes and conditional Edges with custom code."
52
+ )
53
+ strict_url_validation: bool = Field(True, description="Enforce strict, normalized URL validation.")
54
+
55
+
56
+ class ComplianceViolation(CoReasonBaseModel):
57
+ """Details of a compliance violation.
58
+
59
+ Attributes:
60
+ rule: Name of the rule broken.
61
+ message: Human readable details.
62
+ component_id: Name of the tool or component causing the issue.
63
+ """
64
+
65
+ model_config = ConfigDict(extra="forbid", frozen=True)
66
+
67
+ rule: str = Field(..., description="Name of the rule broken, e.g., 'domain_restriction'.")
68
+ message: str = Field(..., description="Human readable details.")
69
+ component_id: Optional[str] = Field(None, description="Name of the tool or component causing the issue.")
70
+
71
+
72
+ class ComplianceReport(CoReasonBaseModel):
73
+ """Report of compliance checks.
74
+
75
+ Attributes:
76
+ passed: Whether the agent passed all checks.
77
+ violations: List of violations found.
78
+ """
79
+
80
+ model_config = ConfigDict(extra="forbid", frozen=True)
81
+
82
+ passed: bool = Field(..., description="Whether the agent passed all checks.")
83
+ violations: List[ComplianceViolation] = Field(default_factory=list, description="List of violations found.")
@@ -1 +1,9 @@
1
- # Prosperity-3.0
1
+ # Copyright (c) 2025 CoReason, Inc.
2
+ #
3
+ # This software is proprietary and dual-licensed.
4
+ # Licensed under the Prosperity Public License 3.0 (the "License").
5
+ # A copy of the license is available at https://prosperitylicense.com/versions/3.0.0
6
+ # For details, see the LICENSE file.
7
+ # Commercial use beyond a 30-day trial requires a separate license.
8
+ #
9
+ # Source Code: https://github.com/CoReason-AI/coreason-manifest
@@ -0,0 +1,462 @@
1
+ {
2
+ "$defs": {
3
+ "AgentStep": {
4
+ "additionalProperties": false,
5
+ "description": "A step that executes an AI Agent.",
6
+ "properties": {
7
+ "id": {
8
+ "description": "Unique identifier for the step.",
9
+ "title": "Id",
10
+ "type": "string"
11
+ },
12
+ "inputs": {
13
+ "additionalProperties": true,
14
+ "description": "Input arguments for the step.",
15
+ "title": "Inputs",
16
+ "type": "object"
17
+ },
18
+ "x-design": {
19
+ "anyOf": [
20
+ {
21
+ "$ref": "#/$defs/DesignMetadata"
22
+ },
23
+ {
24
+ "type": "null"
25
+ }
26
+ ],
27
+ "default": null,
28
+ "description": "UI metadata."
29
+ },
30
+ "type": {
31
+ "const": "agent",
32
+ "default": "agent",
33
+ "title": "Type",
34
+ "type": "string"
35
+ },
36
+ "agent": {
37
+ "description": "Reference to an Agent definition (by ID or name).",
38
+ "title": "Agent",
39
+ "type": "string"
40
+ },
41
+ "next": {
42
+ "anyOf": [
43
+ {
44
+ "type": "string"
45
+ },
46
+ {
47
+ "type": "null"
48
+ }
49
+ ],
50
+ "default": null,
51
+ "description": "ID of the next step to execute.",
52
+ "title": "Next"
53
+ },
54
+ "system_prompt": {
55
+ "anyOf": [
56
+ {
57
+ "type": "string"
58
+ },
59
+ {
60
+ "type": "null"
61
+ }
62
+ ],
63
+ "default": null,
64
+ "description": "Optional override for system prompt.",
65
+ "title": "System Prompt"
66
+ }
67
+ },
68
+ "required": [
69
+ "id",
70
+ "agent"
71
+ ],
72
+ "title": "AgentStep",
73
+ "type": "object"
74
+ },
75
+ "CouncilStep": {
76
+ "additionalProperties": false,
77
+ "description": "A step that involves multiple voters/agents.",
78
+ "properties": {
79
+ "id": {
80
+ "description": "Unique identifier for the step.",
81
+ "title": "Id",
82
+ "type": "string"
83
+ },
84
+ "inputs": {
85
+ "additionalProperties": true,
86
+ "description": "Input arguments for the step.",
87
+ "title": "Inputs",
88
+ "type": "object"
89
+ },
90
+ "x-design": {
91
+ "anyOf": [
92
+ {
93
+ "$ref": "#/$defs/DesignMetadata"
94
+ },
95
+ {
96
+ "type": "null"
97
+ }
98
+ ],
99
+ "default": null,
100
+ "description": "UI metadata."
101
+ },
102
+ "type": {
103
+ "const": "council",
104
+ "default": "council",
105
+ "title": "Type",
106
+ "type": "string"
107
+ },
108
+ "voters": {
109
+ "description": "List of voters (Agent IDs).",
110
+ "items": {
111
+ "type": "string"
112
+ },
113
+ "title": "Voters",
114
+ "type": "array"
115
+ },
116
+ "strategy": {
117
+ "default": "consensus",
118
+ "description": "Voting strategy (e.g., consensus, majority).",
119
+ "title": "Strategy",
120
+ "type": "string"
121
+ },
122
+ "next": {
123
+ "anyOf": [
124
+ {
125
+ "type": "string"
126
+ },
127
+ {
128
+ "type": "null"
129
+ }
130
+ ],
131
+ "default": null,
132
+ "description": "ID of the next step to execute.",
133
+ "title": "Next"
134
+ }
135
+ },
136
+ "required": [
137
+ "id",
138
+ "voters"
139
+ ],
140
+ "title": "CouncilStep",
141
+ "type": "object"
142
+ },
143
+ "DesignMetadata": {
144
+ "additionalProperties": false,
145
+ "description": "UI-specific metadata for the visual builder.",
146
+ "properties": {
147
+ "x": {
148
+ "description": "X coordinate on the canvas.",
149
+ "title": "X",
150
+ "type": "number"
151
+ },
152
+ "y": {
153
+ "description": "Y coordinate on the canvas.",
154
+ "title": "Y",
155
+ "type": "number"
156
+ },
157
+ "icon": {
158
+ "anyOf": [
159
+ {
160
+ "type": "string"
161
+ },
162
+ {
163
+ "type": "null"
164
+ }
165
+ ],
166
+ "default": null,
167
+ "description": "Icon name or URL.",
168
+ "title": "Icon"
169
+ },
170
+ "color": {
171
+ "anyOf": [
172
+ {
173
+ "type": "string"
174
+ },
175
+ {
176
+ "type": "null"
177
+ }
178
+ ],
179
+ "default": null,
180
+ "description": "Color code (hex/name).",
181
+ "title": "Color"
182
+ },
183
+ "label": {
184
+ "anyOf": [
185
+ {
186
+ "type": "string"
187
+ },
188
+ {
189
+ "type": "null"
190
+ }
191
+ ],
192
+ "default": null,
193
+ "description": "Display label.",
194
+ "title": "Label"
195
+ },
196
+ "zoom": {
197
+ "anyOf": [
198
+ {
199
+ "type": "number"
200
+ },
201
+ {
202
+ "type": "null"
203
+ }
204
+ ],
205
+ "default": null,
206
+ "description": "Zoom level.",
207
+ "title": "Zoom"
208
+ },
209
+ "collapsed": {
210
+ "default": false,
211
+ "description": "Whether the node is collapsed in UI.",
212
+ "title": "Collapsed",
213
+ "type": "boolean"
214
+ }
215
+ },
216
+ "required": [
217
+ "x",
218
+ "y"
219
+ ],
220
+ "title": "DesignMetadata",
221
+ "type": "object"
222
+ },
223
+ "LogicStep": {
224
+ "additionalProperties": false,
225
+ "description": "A step that executes custom logic.",
226
+ "properties": {
227
+ "id": {
228
+ "description": "Unique identifier for the step.",
229
+ "title": "Id",
230
+ "type": "string"
231
+ },
232
+ "inputs": {
233
+ "additionalProperties": true,
234
+ "description": "Input arguments for the step.",
235
+ "title": "Inputs",
236
+ "type": "object"
237
+ },
238
+ "x-design": {
239
+ "anyOf": [
240
+ {
241
+ "$ref": "#/$defs/DesignMetadata"
242
+ },
243
+ {
244
+ "type": "null"
245
+ }
246
+ ],
247
+ "default": null,
248
+ "description": "UI metadata."
249
+ },
250
+ "type": {
251
+ "const": "logic",
252
+ "default": "logic",
253
+ "title": "Type",
254
+ "type": "string"
255
+ },
256
+ "code": {
257
+ "description": "Python code or reference to logic to execute.",
258
+ "title": "Code",
259
+ "type": "string"
260
+ },
261
+ "next": {
262
+ "anyOf": [
263
+ {
264
+ "type": "string"
265
+ },
266
+ {
267
+ "type": "null"
268
+ }
269
+ ],
270
+ "default": null,
271
+ "description": "ID of the next step to execute.",
272
+ "title": "Next"
273
+ }
274
+ },
275
+ "required": [
276
+ "id",
277
+ "code"
278
+ ],
279
+ "title": "LogicStep",
280
+ "type": "object"
281
+ },
282
+ "ManifestMetadata": {
283
+ "additionalProperties": true,
284
+ "description": "Metadata for the manifest.",
285
+ "properties": {
286
+ "name": {
287
+ "description": "Human-readable name of the workflow/agent.",
288
+ "title": "Name",
289
+ "type": "string"
290
+ },
291
+ "x-design": {
292
+ "anyOf": [
293
+ {
294
+ "$ref": "#/$defs/DesignMetadata"
295
+ },
296
+ {
297
+ "type": "null"
298
+ }
299
+ ],
300
+ "default": null,
301
+ "description": "UI metadata."
302
+ }
303
+ },
304
+ "required": [
305
+ "name"
306
+ ],
307
+ "title": "ManifestMetadata",
308
+ "type": "object"
309
+ },
310
+ "SwitchStep": {
311
+ "additionalProperties": false,
312
+ "description": "A step that routes execution based on conditions.",
313
+ "properties": {
314
+ "id": {
315
+ "description": "Unique identifier for the step.",
316
+ "title": "Id",
317
+ "type": "string"
318
+ },
319
+ "inputs": {
320
+ "additionalProperties": true,
321
+ "description": "Input arguments for the step.",
322
+ "title": "Inputs",
323
+ "type": "object"
324
+ },
325
+ "x-design": {
326
+ "anyOf": [
327
+ {
328
+ "$ref": "#/$defs/DesignMetadata"
329
+ },
330
+ {
331
+ "type": "null"
332
+ }
333
+ ],
334
+ "default": null,
335
+ "description": "UI metadata."
336
+ },
337
+ "type": {
338
+ "const": "switch",
339
+ "default": "switch",
340
+ "title": "Type",
341
+ "type": "string"
342
+ },
343
+ "cases": {
344
+ "additionalProperties": {
345
+ "type": "string"
346
+ },
347
+ "description": "Dictionary of condition expressions to Step IDs.",
348
+ "title": "Cases",
349
+ "type": "object"
350
+ },
351
+ "default": {
352
+ "anyOf": [
353
+ {
354
+ "type": "string"
355
+ },
356
+ {
357
+ "type": "null"
358
+ }
359
+ ],
360
+ "default": null,
361
+ "description": "Default Step ID if no cases match.",
362
+ "title": "Default"
363
+ }
364
+ },
365
+ "required": [
366
+ "id",
367
+ "cases"
368
+ ],
369
+ "title": "SwitchStep",
370
+ "type": "object"
371
+ },
372
+ "Workflow": {
373
+ "additionalProperties": false,
374
+ "description": "Defines the execution topology.",
375
+ "properties": {
376
+ "start": {
377
+ "description": "ID of the starting step.",
378
+ "title": "Start",
379
+ "type": "string"
380
+ },
381
+ "steps": {
382
+ "additionalProperties": {
383
+ "description": "Polymorphic step definition.",
384
+ "discriminator": {
385
+ "mapping": {
386
+ "agent": "#/$defs/AgentStep",
387
+ "council": "#/$defs/CouncilStep",
388
+ "logic": "#/$defs/LogicStep",
389
+ "switch": "#/$defs/SwitchStep"
390
+ },
391
+ "propertyName": "type"
392
+ },
393
+ "oneOf": [
394
+ {
395
+ "$ref": "#/$defs/AgentStep"
396
+ },
397
+ {
398
+ "$ref": "#/$defs/LogicStep"
399
+ },
400
+ {
401
+ "$ref": "#/$defs/CouncilStep"
402
+ },
403
+ {
404
+ "$ref": "#/$defs/SwitchStep"
405
+ }
406
+ ]
407
+ },
408
+ "description": "Dictionary of all steps indexed by ID.",
409
+ "title": "Steps",
410
+ "type": "object"
411
+ }
412
+ },
413
+ "required": [
414
+ "start",
415
+ "steps"
416
+ ],
417
+ "title": "Workflow",
418
+ "type": "object"
419
+ }
420
+ },
421
+ "additionalProperties": false,
422
+ "description": "Root object for Coreason Manifest V2.",
423
+ "properties": {
424
+ "apiVersion": {
425
+ "const": "coreason.ai/v2",
426
+ "default": "coreason.ai/v2",
427
+ "description": "API Version.",
428
+ "title": "Apiversion",
429
+ "type": "string"
430
+ },
431
+ "kind": {
432
+ "description": "Kind of the object.",
433
+ "enum": [
434
+ "Recipe",
435
+ "Agent"
436
+ ],
437
+ "title": "Kind",
438
+ "type": "string"
439
+ },
440
+ "metadata": {
441
+ "$ref": "#/$defs/ManifestMetadata",
442
+ "description": "Metadata including name and design info."
443
+ },
444
+ "definitions": {
445
+ "additionalProperties": true,
446
+ "description": "Reusable definitions.",
447
+ "title": "Definitions",
448
+ "type": "object"
449
+ },
450
+ "workflow": {
451
+ "$ref": "#/$defs/Workflow",
452
+ "description": "The main workflow topology."
453
+ }
454
+ },
455
+ "required": [
456
+ "kind",
457
+ "metadata",
458
+ "workflow"
459
+ ],
460
+ "title": "ManifestV2",
461
+ "type": "object"
462
+ }
@@ -1,3 +1,13 @@
1
+ # Copyright (c) 2025 CoReason, Inc.
2
+ #
3
+ # This software is proprietary and dual-licensed.
4
+ # Licensed under the Prosperity Public License 3.0 (the "License").
5
+ # A copy of the license is available at https://prosperitylicense.com/versions/3.0.0
6
+ # For details, see the LICENSE file.
7
+ # Commercial use beyond a 30-day trial requires a separate license.
8
+ #
9
+ # Source Code: https://github.com/CoReason-AI/coreason-manifest
10
+
1
11
  # Copyright (c) 2025 CoReason, Inc.
2
12
  #
3
13
  # This software is proprietary and dual-licensed.