coreason-manifest 0.9.0__tar.gz → 0.10.0__tar.gz

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 (26) hide show
  1. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/PKG-INFO +91 -29
  2. coreason_manifest-0.10.0/README.md +119 -0
  3. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/pyproject.toml +2 -2
  4. coreason_manifest-0.10.0/src/coreason_manifest/__init__.py +98 -0
  5. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/definitions/__init__.py +12 -1
  6. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/definitions/agent.py +95 -17
  7. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/definitions/audit.py +66 -7
  8. coreason_manifest-0.10.0/src/coreason_manifest/definitions/base.py +47 -0
  9. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/definitions/events.py +128 -97
  10. coreason_manifest-0.10.0/src/coreason_manifest/definitions/message.py +188 -0
  11. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/definitions/simulation.py +38 -9
  12. coreason_manifest-0.10.0/src/coreason_manifest/definitions/simulation_config.py +46 -0
  13. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/definitions/topology.py +104 -18
  14. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/recipes.py +31 -23
  15. {coreason_manifest-0.9.0/src/coreason_manifest/utils → coreason_manifest-0.10.0/src/coreason_manifest/schemas}/__init__.py +1 -5
  16. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/schemas/agent.schema.json +210 -8
  17. coreason_manifest-0.10.0/src/coreason_manifest/schemas/recipe.schema.json +813 -0
  18. coreason_manifest-0.10.0/src/coreason_manifest/utils/__init__.py +23 -0
  19. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/src/coreason_manifest/utils/logger.py +10 -0
  20. coreason_manifest-0.10.0/src/coreason_manifest/v1/__init__.py +15 -0
  21. coreason_manifest-0.9.0/README.md +0 -57
  22. coreason_manifest-0.9.0/src/coreason_manifest/__init__.py +0 -17
  23. coreason_manifest-0.9.0/src/coreason_manifest/definitions/message.py +0 -126
  24. coreason_manifest-0.9.0/src/coreason_manifest/schemas/__init__.py +0 -1
  25. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/LICENSE +0 -0
  26. {coreason_manifest-0.9.0 → coreason_manifest-0.10.0}/NOTICE +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coreason_manifest
3
- Version: 0.9.0
3
+ Version: 0.10.0
4
4
  Summary: This package is the definitive source of truth. If it isn't in the manifest, it doesn't exist. If it violates the manifest, it doesn't run.
5
5
  License: # The Prosperity Public License 3.0.0
6
6
 
@@ -87,17 +87,31 @@ The definitive source of truth for CoReason-AI Asset definitions. "The Blueprint
87
87
 
88
88
  ## Overview
89
89
 
90
- `coreason-manifest` acts as the validator for the "Agent Development Lifecycle" (ADLC). It ensures that every Agent produced meets strict GxP and security standards. If it isn't in the manifest, it doesn't exist. If it violates the manifest, it doesn't run.
90
+ `coreason-manifest` serves as the **Shared Kernel** for the Coreason ecosystem. It contains the canonical Pydantic definitions, schemas, and data structures for Agents, Workflows (Recipes), and Auditing.
91
+
92
+ It provides the **"Blueprint"** that all other services (Builder, Engine, Simulator) rely on. It focuses on strict typing, schema validation, and serialization, ensuring that if it isn't in the manifest, it doesn't exist.
91
93
 
92
94
  ## Features
93
95
 
94
- * **Open Agent Specification (OAS) Validation:** Parses and validates agent definitions against a strict schema.
95
- * **Compliance Enforcement:** Uses Open Policy Agent (OPA) / Rego to enforce complex business rules and allowlists.
96
- * **Integrity Verification:** Calculates and verifies SHA256 hashes of the agent's source code to prevent tampering.
97
- * **Automatic Schema Generation:** Inspects Python functions to generate Agent Interfaces, automatically handling `UserContext` injection.
98
- * **Dependency Pinning:** Enforces strict version pinning for all library dependencies.
99
- * **Trusted Bill of Materials (TBOM):** Validates libraries against an approved list.
100
- * **Compliance Microservice:** Can be run as a standalone API server (Service C) for centralized validation.
96
+ * **Open Agent Specification (OAS):** Strict Pydantic models for Agent definitions (`AgentDefinition`).
97
+ * **Strict Typing:** Enforces type safety and immutable structures for critical interfaces.
98
+ * **Enhanced Serialization:** Includes `CoReasonBaseModel` to ensure consistent JSON serialization of complex types like `UUID` and `datetime`.
99
+ * **Event Protocol:** Defines the `GraphEvent` and `CloudEvent` structures for real-time communication.
100
+ * **Simulation Schemas:** Provides standard models for `SimulationScenario`, `AdversaryProfile`, and `SimulationTrace`.
101
+ * **Audit & Compliance:** Defines the `AuditLog` structure for tamper-evident record keeping.
102
+ * **Ergonomic Factory Methods:** Simplified construction of `ChatMessage` and `GenAIOperation`.
103
+ * **Token Arithmetic:** Support for `+` and `+=` operators on `GenAITokenUsage`.
104
+ * **Flexible Tooling:** `ToolCallRequestPart` accepts JSON strings with automatic parsing.
105
+ * **Enhanced Tracing:** `ReasoningTrace` includes flexible metadata for execution state.
106
+
107
+ ## Serialization & Base Model
108
+
109
+ All core definitions (`AgentDefinition`, `RecipeManifest`, `GraphTopology`, `AuditLog`) inherit from `CoReasonBaseModel`. This provides a consistent interface for serialization, solving common Pydantic v2 issues with `UUID` and `datetime`.
110
+
111
+ * Use `.dump()` to get a JSON-compatible dictionary (where UUIDs/datetimes are strings).
112
+ * Use `.to_json()` to get a JSON string.
113
+
114
+ For a detailed rationale, see [docs/coreason_base_model_rationale.md](docs/coreason_base_model_rationale.md).
101
115
 
102
116
  ## Installation
103
117
 
@@ -107,30 +121,78 @@ pip install coreason-manifest
107
121
 
108
122
  ## Usage
109
123
 
110
- `coreason-manifest` supports two modes: **Library (CLI)** and **Server (Microservice)**.
111
-
112
- ### 1. Library Usage
113
-
114
- Use the python library to validate local agent files and verify source integrity.
124
+ This library is used to define and validate Agent configurations programmatically.
115
125
 
116
126
  ```python
117
- from coreason_manifest import ManifestEngine, ManifestConfig
118
-
119
- # Initialize and Validate
120
- config = ManifestConfig(policy_path="./policies/compliance.rego")
121
- engine = ManifestEngine(config)
122
- agent_def = engine.load_and_validate("agent.yaml", "./src")
123
- ```
124
-
125
- ### 2. Server Mode
126
-
127
- Run the package as a FastAPI server to provide a centralized compliance API.
128
-
129
- ```bash
130
- uvicorn coreason_manifest.server:app --host 0.0.0.0 --port 8000
127
+ import uuid
128
+ from datetime import datetime, timezone
129
+ from coreason_manifest.definitions.agent import (
130
+ AgentDefinition,
131
+ AgentMetadata,
132
+ AgentInterface,
133
+ AgentRuntimeConfig,
134
+ ModelConfig,
135
+ AgentDependencies,
136
+ ToolRequirement,
137
+ ToolRiskLevel,
138
+ PolicyConfig,
139
+ ObservabilityConfig,
140
+ TraceLevel
141
+ )
142
+
143
+ # 1. Define Metadata
144
+ metadata = AgentMetadata(
145
+ id=uuid.uuid4(),
146
+ version="1.0.0", # Strict SemVer
147
+ name="Research Agent",
148
+ author="Coreason AI",
149
+ created_at=datetime.now(timezone.utc)
150
+ )
151
+
152
+ # 2. Instantiate Agent
153
+ agent = AgentDefinition(
154
+ metadata=metadata,
155
+ interface=AgentInterface(
156
+ inputs={"topic": {"type": "string"}},
157
+ outputs={"summary": {"type": "string"}}
158
+ ),
159
+ config=AgentRuntimeConfig(
160
+ model_config=ModelConfig(
161
+ model="gpt-4",
162
+ temperature=0.0,
163
+ system_prompt="You are a helpful assistant."
164
+ )
165
+ ),
166
+ dependencies=AgentDependencies(
167
+ tools=[
168
+ ToolRequirement(
169
+ uri="mcp://search-service/google",
170
+ hash="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", # Valid SHA256
171
+ scopes=["search:read"],
172
+ risk_level=ToolRiskLevel.STANDARD
173
+ )
174
+ ],
175
+ libraries=("pandas==2.0.0",)
176
+ ),
177
+ policy=PolicyConfig(
178
+ budget_caps={"total_cost": 5.0}
179
+ ),
180
+ observability=ObservabilityConfig(
181
+ trace_level=TraceLevel.FULL,
182
+ retention_policy="90_days"
183
+ ),
184
+ # Mandatory Integrity Hash
185
+ integrity_hash="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
186
+ )
187
+
188
+ print(f"Agent '{agent.metadata.name}' definition created and validated.")
131
189
  ```
132
190
 
133
191
  For full details, see the [Usage Documentation](docs/usage.md).
134
192
 
135
- For detailed requirements and architecture, please refer to the [Product Requirements](docs/product_requirements.md) or [Requirements](docs/requirements.md).
193
+ ## Documentation
194
+
195
+ * [Frontend Integration](docs/frontend_integration.md): Communicating with the Coreason Engine.
196
+ * [Simulation Architecture](docs/simulation_architecture.md): Details on ATIF compatibility and GAIA scenarios.
197
+ * [Audit & Compliance](docs/audit_compliance.md): Details on EU AI Act compliance, Chain of Custody, and Integrity Hashing.
136
198
 
@@ -0,0 +1,119 @@
1
+ # Coreason Manifest
2
+
3
+ The definitive source of truth for CoReason-AI Asset definitions. "The Blueprint."
4
+
5
+ [![License: Prosperity 3.0](https://img.shields.io/badge/license-Prosperity%203.0-blue)](https://github.com/CoReason-AI/coreason-manifest)
6
+ [![Build Status](https://github.com/CoReason-AI/coreason-manifest/actions/workflows/ci.yml/badge.svg)](https://github.com/CoReason-AI/coreason-manifest/actions)
7
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
8
+ [![Documentation](https://img.shields.io/badge/docs-product_requirements-informational)](docs/product_requirements.md)
9
+
10
+ ## Overview
11
+
12
+ `coreason-manifest` serves as the **Shared Kernel** for the Coreason ecosystem. It contains the canonical Pydantic definitions, schemas, and data structures for Agents, Workflows (Recipes), and Auditing.
13
+
14
+ It provides the **"Blueprint"** that all other services (Builder, Engine, Simulator) rely on. It focuses on strict typing, schema validation, and serialization, ensuring that if it isn't in the manifest, it doesn't exist.
15
+
16
+ ## Features
17
+
18
+ * **Open Agent Specification (OAS):** Strict Pydantic models for Agent definitions (`AgentDefinition`).
19
+ * **Strict Typing:** Enforces type safety and immutable structures for critical interfaces.
20
+ * **Enhanced Serialization:** Includes `CoReasonBaseModel` to ensure consistent JSON serialization of complex types like `UUID` and `datetime`.
21
+ * **Event Protocol:** Defines the `GraphEvent` and `CloudEvent` structures for real-time communication.
22
+ * **Simulation Schemas:** Provides standard models for `SimulationScenario`, `AdversaryProfile`, and `SimulationTrace`.
23
+ * **Audit & Compliance:** Defines the `AuditLog` structure for tamper-evident record keeping.
24
+ * **Ergonomic Factory Methods:** Simplified construction of `ChatMessage` and `GenAIOperation`.
25
+ * **Token Arithmetic:** Support for `+` and `+=` operators on `GenAITokenUsage`.
26
+ * **Flexible Tooling:** `ToolCallRequestPart` accepts JSON strings with automatic parsing.
27
+ * **Enhanced Tracing:** `ReasoningTrace` includes flexible metadata for execution state.
28
+
29
+ ## Serialization & Base Model
30
+
31
+ All core definitions (`AgentDefinition`, `RecipeManifest`, `GraphTopology`, `AuditLog`) inherit from `CoReasonBaseModel`. This provides a consistent interface for serialization, solving common Pydantic v2 issues with `UUID` and `datetime`.
32
+
33
+ * Use `.dump()` to get a JSON-compatible dictionary (where UUIDs/datetimes are strings).
34
+ * Use `.to_json()` to get a JSON string.
35
+
36
+ For a detailed rationale, see [docs/coreason_base_model_rationale.md](docs/coreason_base_model_rationale.md).
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ pip install coreason-manifest
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ This library is used to define and validate Agent configurations programmatically.
47
+
48
+ ```python
49
+ import uuid
50
+ from datetime import datetime, timezone
51
+ from coreason_manifest.definitions.agent import (
52
+ AgentDefinition,
53
+ AgentMetadata,
54
+ AgentInterface,
55
+ AgentRuntimeConfig,
56
+ ModelConfig,
57
+ AgentDependencies,
58
+ ToolRequirement,
59
+ ToolRiskLevel,
60
+ PolicyConfig,
61
+ ObservabilityConfig,
62
+ TraceLevel
63
+ )
64
+
65
+ # 1. Define Metadata
66
+ metadata = AgentMetadata(
67
+ id=uuid.uuid4(),
68
+ version="1.0.0", # Strict SemVer
69
+ name="Research Agent",
70
+ author="Coreason AI",
71
+ created_at=datetime.now(timezone.utc)
72
+ )
73
+
74
+ # 2. Instantiate Agent
75
+ agent = AgentDefinition(
76
+ metadata=metadata,
77
+ interface=AgentInterface(
78
+ inputs={"topic": {"type": "string"}},
79
+ outputs={"summary": {"type": "string"}}
80
+ ),
81
+ config=AgentRuntimeConfig(
82
+ model_config=ModelConfig(
83
+ model="gpt-4",
84
+ temperature=0.0,
85
+ system_prompt="You are a helpful assistant."
86
+ )
87
+ ),
88
+ dependencies=AgentDependencies(
89
+ tools=[
90
+ ToolRequirement(
91
+ uri="mcp://search-service/google",
92
+ hash="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", # Valid SHA256
93
+ scopes=["search:read"],
94
+ risk_level=ToolRiskLevel.STANDARD
95
+ )
96
+ ],
97
+ libraries=("pandas==2.0.0",)
98
+ ),
99
+ policy=PolicyConfig(
100
+ budget_caps={"total_cost": 5.0}
101
+ ),
102
+ observability=ObservabilityConfig(
103
+ trace_level=TraceLevel.FULL,
104
+ retention_policy="90_days"
105
+ ),
106
+ # Mandatory Integrity Hash
107
+ integrity_hash="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
108
+ )
109
+
110
+ print(f"Agent '{agent.metadata.name}' definition created and validated.")
111
+ ```
112
+
113
+ For full details, see the [Usage Documentation](docs/usage.md).
114
+
115
+ ## Documentation
116
+
117
+ * [Frontend Integration](docs/frontend_integration.md): Communicating with the Coreason Engine.
118
+ * [Simulation Architecture](docs/simulation_architecture.md): Details on ATIF compatibility and GAIA scenarios.
119
+ * [Audit & Compliance](docs/audit_compliance.md): Details on EU AI Act compliance, Chain of Custody, and Integrity Hashing.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "coreason_manifest"
3
- version = "0.9.0"
3
+ version = "0.10.0"
4
4
  description = "This package is the definitive source of truth. If it isn't in the manifest, it doesn't exist. If it violates the manifest, it doesn't run."
5
5
  authors = ["Gowtham A Rao <gowtham.rao@coreason.ai>"]
6
6
  license = "Prosperity-3.0"
@@ -32,7 +32,7 @@ build-backend = "poetry.core.masonry.api"
32
32
 
33
33
  [project]
34
34
  name = "coreason_manifest"
35
- version = "0.9.0"
35
+ version = "0.10.0"
36
36
  description = "This package is the definitive source of truth. If it isn't in the manifest, it doesn't exist. If it violates the manifest, it doesn't run."
37
37
  readme = "README.md"
38
38
  requires-python = ">=3.12"
@@ -0,0 +1,98 @@
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 .definitions.agent import AgentDefinition, Persona
12
+ from .definitions.audit import AuditLog
13
+ from .definitions.events import (
14
+ ArtifactGenerated,
15
+ CloudEvent,
16
+ CouncilVote,
17
+ EdgeTraversed,
18
+ GraphEvent,
19
+ GraphEventArtifactGenerated,
20
+ GraphEventCouncilVote,
21
+ GraphEventEdgeActive,
22
+ GraphEventError,
23
+ GraphEventNodeDone,
24
+ GraphEventNodeInit,
25
+ GraphEventNodeRestored,
26
+ GraphEventNodeSkipped,
27
+ GraphEventNodeStart,
28
+ GraphEventNodeStream,
29
+ NodeCompleted,
30
+ NodeInit,
31
+ NodeRestored,
32
+ NodeSkipped,
33
+ NodeStarted,
34
+ NodeStream,
35
+ WorkflowError,
36
+ migrate_graph_event_to_cloud_event,
37
+ )
38
+ from .definitions.simulation import (
39
+ SimulationMetrics,
40
+ SimulationScenario,
41
+ SimulationStep,
42
+ SimulationTrace,
43
+ StepType,
44
+ )
45
+ from .definitions.simulation_config import AdversaryProfile, ChaosConfig, SimulationRequest
46
+ from .definitions.topology import (
47
+ AgentNode,
48
+ Edge,
49
+ GraphTopology,
50
+ Node,
51
+ StateDefinition,
52
+ Topology,
53
+ )
54
+ from .recipes import RecipeManifest
55
+
56
+ __all__ = [
57
+ "AgentDefinition",
58
+ "Persona",
59
+ "Topology",
60
+ "GraphTopology",
61
+ "Node",
62
+ "AgentNode",
63
+ "Edge",
64
+ "StateDefinition",
65
+ "GraphEvent",
66
+ "CloudEvent",
67
+ "GraphEventNodeInit",
68
+ "GraphEventNodeStart",
69
+ "GraphEventNodeDone",
70
+ "GraphEventNodeStream",
71
+ "GraphEventNodeSkipped",
72
+ "GraphEventNodeRestored",
73
+ "GraphEventEdgeActive",
74
+ "GraphEventCouncilVote",
75
+ "GraphEventError",
76
+ "GraphEventArtifactGenerated",
77
+ "NodeInit",
78
+ "NodeStarted",
79
+ "NodeCompleted",
80
+ "NodeStream",
81
+ "NodeSkipped",
82
+ "NodeRestored",
83
+ "WorkflowError",
84
+ "CouncilVote",
85
+ "ArtifactGenerated",
86
+ "EdgeTraversed",
87
+ "migrate_graph_event_to_cloud_event",
88
+ "SimulationScenario",
89
+ "SimulationTrace",
90
+ "SimulationStep",
91
+ "SimulationMetrics",
92
+ "StepType",
93
+ "AdversaryProfile",
94
+ "ChaosConfig",
95
+ "SimulationRequest",
96
+ "AuditLog",
97
+ "RecipeManifest",
98
+ ]
@@ -1,4 +1,14 @@
1
- from .agent import AgentDefinition, AgentRuntimeConfig
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 .agent import AgentDefinition, AgentRuntimeConfig, Persona
2
12
  from .events import (
3
13
  ArtifactGenerated,
4
14
  ArtifactGeneratedPayload,
@@ -26,6 +36,7 @@ from .events import (
26
36
  __all__ = [
27
37
  "AgentRuntimeConfig",
28
38
  "AgentDefinition",
39
+ "Persona",
29
40
  "GraphEvent",
30
41
  "NodeInit",
31
42
  "NodeStarted",
@@ -1,4 +1,13 @@
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
10
+
2
11
  """Pydantic models for the Coreason Manifest system.
3
12
 
4
13
  These models define the structure and validation rules for the Agent Manifest
@@ -10,13 +19,12 @@ from __future__ import annotations
10
19
  from datetime import datetime
11
20
  from enum import Enum
12
21
  from types import MappingProxyType
13
- from typing import Any, Dict, List, Mapping, Optional, Tuple
22
+ from typing import Any, Dict, List, Literal, Mapping, Optional, Tuple, Union
14
23
  from uuid import UUID
15
24
 
16
25
  from pydantic import (
17
26
  AfterValidator,
18
27
  AnyUrl,
19
- BaseModel,
20
28
  ConfigDict,
21
29
  Field,
22
30
  PlainSerializer,
@@ -25,7 +33,8 @@ from pydantic import (
25
33
  )
26
34
  from typing_extensions import Annotated
27
35
 
28
- from coreason_manifest.definitions.topology import Edge, Node
36
+ from coreason_manifest.definitions.base import CoReasonBaseModel
37
+ from coreason_manifest.definitions.topology import Edge, Node, validate_edge_integrity
29
38
 
30
39
  # SemVer Regex pattern (simplified for standard SemVer)
31
40
  # Modified to accept optional 'v' or 'V' prefix (multiple allowed) for input normalization
@@ -72,7 +81,7 @@ StrictUri = Annotated[
72
81
  ]
73
82
 
74
83
 
75
- class AgentMetadata(BaseModel):
84
+ class AgentMetadata(CoReasonBaseModel):
76
85
  """Metadata for the Agent.
77
86
 
78
87
  Attributes:
@@ -93,7 +102,23 @@ class AgentMetadata(BaseModel):
93
102
  requires_auth: bool = Field(default=False, description="Whether the agent requires user authentication.")
94
103
 
95
104
 
96
- class AgentInterface(BaseModel):
105
+ class Persona(CoReasonBaseModel):
106
+ """Definition of an Agent Persona.
107
+
108
+ Attributes:
109
+ name: Name of the persona.
110
+ description: Description of the persona.
111
+ directives: List of specific instructions or directives.
112
+ """
113
+
114
+ model_config = ConfigDict(extra="forbid", frozen=True)
115
+
116
+ name: str = Field(..., description="Name of the persona.")
117
+ description: str = Field(..., description="Description of the persona.")
118
+ directives: List[str] = Field(..., description="List of specific instructions or directives.")
119
+
120
+
121
+ class AgentInterface(CoReasonBaseModel):
97
122
  """Interface definition for the Agent.
98
123
 
99
124
  Attributes:
@@ -108,21 +133,25 @@ class AgentInterface(BaseModel):
108
133
  injected_params: List[str] = Field(default_factory=list, description="List of parameters injected by the system.")
109
134
 
110
135
 
111
- class ModelConfig(BaseModel):
136
+ class ModelConfig(CoReasonBaseModel):
112
137
  """LLM Configuration parameters.
113
138
 
114
139
  Attributes:
115
140
  model: The LLM model identifier.
116
141
  temperature: Temperature for generation.
142
+ system_prompt: The default system prompt/persona for the agent.
143
+ persona: The full persona definition (name, description, directives).
117
144
  """
118
145
 
119
146
  model_config = ConfigDict(extra="forbid", frozen=True)
120
147
 
121
148
  model: str = Field(..., description="The LLM model identifier.")
122
149
  temperature: float = Field(..., ge=0.0, le=2.0, description="Temperature for generation.")
150
+ system_prompt: Optional[str] = Field(None, description="The default system prompt/persona for the agent.")
151
+ persona: Optional[Persona] = Field(None, description="The full persona definition (name, description, directives).")
123
152
 
124
153
 
125
- class AgentRuntimeConfig(BaseModel):
154
+ class AgentRuntimeConfig(CoReasonBaseModel):
126
155
  """Configuration of the Agent execution.
127
156
 
128
157
  Attributes:
@@ -134,10 +163,36 @@ class AgentRuntimeConfig(BaseModel):
134
163
 
135
164
  model_config = ConfigDict(extra="forbid", frozen=True)
136
165
 
137
- nodes: List[Node] = Field(..., description="A collection of execution units.")
138
- edges: List[Edge] = Field(..., description="Directed connections defining control flow.")
139
- entry_point: str = Field(..., description="The ID of the starting node.")
166
+ nodes: List[Node] = Field(default_factory=list, description="A collection of execution units.")
167
+ edges: List[Edge] = Field(default_factory=list, description="Directed connections defining control flow.")
168
+ entry_point: Optional[str] = Field(None, description="The ID of the starting node.")
140
169
  llm_config: ModelConfig = Field(..., alias="model_config", description="Specific LLM parameters.")
170
+ system_prompt: Optional[str] = Field(None, description="The global system prompt/instruction for the agent.")
171
+
172
+ @model_validator(mode="after")
173
+ def validate_topology_or_atomic(self) -> AgentRuntimeConfig:
174
+ """Ensure valid configuration: either a Graph or an Atomic Agent."""
175
+ has_nodes = len(self.nodes) > 0
176
+ has_entry = self.entry_point is not None
177
+
178
+ if has_nodes:
179
+ if not has_entry:
180
+ raise ValueError("Graph execution requires an 'entry_point'.")
181
+ else:
182
+ # Atomic Agent: Must have a system prompt (either global or in model_config)
183
+ has_global_prompt = self.system_prompt is not None
184
+ has_model_prompt = self.llm_config.system_prompt is not None
185
+
186
+ if not (has_global_prompt or has_model_prompt):
187
+ raise ValueError("Atomic Agents require a system_prompt (global or in model_config).")
188
+
189
+ return self
190
+
191
+ @model_validator(mode="after")
192
+ def validate_topology_integrity(self) -> AgentRuntimeConfig:
193
+ """Ensure that edges connect existing nodes."""
194
+ validate_edge_integrity(self.nodes, self.edges)
195
+ return self
141
196
 
142
197
  @field_validator("nodes")
143
198
  @classmethod
@@ -174,7 +229,7 @@ class ToolRiskLevel(str, Enum):
174
229
  CRITICAL = "critical"
175
230
 
176
231
 
177
- class ToolRequirement(BaseModel):
232
+ class ToolRequirement(CoReasonBaseModel):
178
233
  """Requirement for an MCP tool.
179
234
 
180
235
  Attributes:
@@ -194,7 +249,25 @@ class ToolRequirement(BaseModel):
194
249
  risk_level: ToolRiskLevel = Field(..., description="The risk level of the tool.")
195
250
 
196
251
 
197
- class AgentDependencies(BaseModel):
252
+ class InlineToolDefinition(CoReasonBaseModel):
253
+ """Definition of an inline tool.
254
+
255
+ Attributes:
256
+ name: Name of the tool.
257
+ description: Description of the tool.
258
+ parameters: JSON Schema of parameters.
259
+ type: The type of the tool (must be 'function').
260
+ """
261
+
262
+ model_config = ConfigDict(extra="forbid", frozen=True)
263
+
264
+ name: str = Field(..., description="Name of the tool.")
265
+ description: str = Field(..., description="Description of the tool.")
266
+ parameters: Dict[str, Any] = Field(..., description="JSON Schema of parameters.")
267
+ type: Literal["function"] = Field("function", description="The type of the tool (must be 'function').")
268
+
269
+
270
+ class AgentDependencies(CoReasonBaseModel):
198
271
  """External dependencies for the Agent.
199
272
 
200
273
  Attributes:
@@ -204,13 +277,15 @@ class AgentDependencies(BaseModel):
204
277
 
205
278
  model_config = ConfigDict(extra="forbid", frozen=True)
206
279
 
207
- tools: List[ToolRequirement] = Field(default_factory=list, description="List of MCP tool requirements.")
280
+ tools: List[Union[ToolRequirement, InlineToolDefinition]] = Field(
281
+ default_factory=list, description="List of MCP tool requirements."
282
+ )
208
283
  libraries: Tuple[str, ...] = Field(
209
284
  default_factory=tuple, description="List of Python packages required (if code execution is allowed)."
210
285
  )
211
286
 
212
287
 
213
- class PolicyConfig(BaseModel):
288
+ class PolicyConfig(CoReasonBaseModel):
214
289
  """Governance policy configuration.
215
290
 
216
291
  Attributes:
@@ -234,7 +309,7 @@ class TraceLevel(str, Enum):
234
309
  NONE = "none"
235
310
 
236
311
 
237
- class ObservabilityConfig(BaseModel):
312
+ class ObservabilityConfig(CoReasonBaseModel):
238
313
  """Observability configuration.
239
314
 
240
315
  Attributes:
@@ -250,7 +325,7 @@ class ObservabilityConfig(BaseModel):
250
325
  encryption_key_id: Optional[str] = Field(None, description="Optional ID of the key used for log encryption.")
251
326
 
252
327
 
253
- class AgentDefinition(BaseModel):
328
+ class AgentDefinition(CoReasonBaseModel):
254
329
  """The Root Object for the CoReason Agent Manifest.
255
330
 
256
331
  Attributes:
@@ -277,6 +352,9 @@ class AgentDefinition(BaseModel):
277
352
  dependencies: AgentDependencies
278
353
  policy: Optional[PolicyConfig] = Field(None, description="Governance policy configuration.")
279
354
  observability: Optional[ObservabilityConfig] = Field(None, description="Observability configuration.")
355
+ custom_metadata: Optional[Dict[str, Any]] = Field(
356
+ None, description="Container for arbitrary metadata extensions without breaking validation."
357
+ )
280
358
  integrity_hash: str = Field(
281
359
  ...,
282
360
  pattern=r"^[a-fA-F0-9]{64}$",