Metadata-Version: 2.4
Name: coreason_manifest
Version: 0.10.0
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.
License: # The Prosperity Public License 3.0.0
         
         Contributor: CoReason, Inc.
         
         Source Code: https://github.com/CoReason-AI/coreason_manifest
         
         ## Purpose
         
         This license allows you to use and share this software for noncommercial purposes for free and to try this software for commercial purposes for thirty days.
         
         ## Agreement
         
         In order to receive this license, you have to agree to its rules.  Those rules are both obligations under that agreement and conditions to your license.  Don't do anything with this software that triggers a rule you can't or won't follow.
         
         ## Notices
         
         Make sure everyone who gets a copy of any part of this software from you, with or without changes, also gets the text of this license and the contributor and source code lines above.
         
         ## Commercial Trial
         
         Limit your use of this software for commercial purposes to a thirty-day trial period.  If you use this software for work, your company gets one trial period for all personnel, not one trial per person.
         
         ## Contributions Back
         
         Developing feedback, changes, or additions that you contribute back to the contributor on the terms of a standardized public software license such as [the Blue Oak Model License 1.0.0](https://blueoakcouncil.org/license/1.0.0), [the Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html), [the MIT license](https://spdx.org/licenses/MIT.html), or [the two-clause BSD license](https://spdx.org/licenses/BSD-2-Clause.html) doesn't count as use for a commercial purpose.
         
         ## Personal Uses
         
         Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, doesn't count as use for a commercial purpose.
         
         ## Noncommercial Organizations
         
         Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution doesn't count as use for a commercial purpose regardless of the source of funding or obligations resulting from the funding.
         
         ## Defense
         
         Don't make any legal claim against anyone accusing this software, with or without changes, alone or with other technology, of infringing any patent.
         
         ## Copyright
         
         The contributor licenses you to do everything with this software that would otherwise infringe their copyright in it.
         
         ## Patent
         
         The contributor licenses you to do everything with this software that would otherwise infringe any patents they can license or become able to license.
         
         ## Reliability
         
         The contributor can't revoke this license.
         
         ## Excuse
         
         You're excused for unknowingly breaking [Notices](#notices) if you take all practical steps to comply within thirty days of learning you broke the rule.
         
         ## No Liability
         
         ***As far as the law allows, this software comes as is, without any warranty or condition, and the contributor won't be liable to anyone for any damages related to this software or this license, under any kind of legal claim.***
License-File: LICENSE
License-File: NOTICE
Author: Gowtham A Rao
Author-email: gowtham.rao@coreason.ai
Requires-Python: >=3.12
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Dist: coreason-identity (>=0.4.1,<0.5.0)
Requires-Dist: loguru (>=0.7.2,<0.8.0)
Requires-Dist: pydantic (>=2.12.5,<3.0.0)
Requires-Dist: pyyaml (>=6.0.3,<7.0.0)
Project-URL: Documentation, https://github.com/CoReason-AI/coreason_manifest
Project-URL: Homepage, https://github.com/CoReason-AI/coreason_manifest
Project-URL: Repository, https://github.com/CoReason-AI/coreason_manifest
Description-Content-Type: text/markdown

# Coreason Manifest

The definitive source of truth for CoReason-AI Asset definitions. "The Blueprint."

[![License: Prosperity 3.0](https://img.shields.io/badge/license-Prosperity%203.0-blue)](https://github.com/CoReason-AI/coreason-manifest)
[![Build Status](https://github.com/CoReason-AI/coreason-manifest/actions/workflows/ci.yml/badge.svg)](https://github.com/CoReason-AI/coreason-manifest/actions)
[![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)
[![Documentation](https://img.shields.io/badge/docs-product_requirements-informational)](docs/product_requirements.md)

## Overview

`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.

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.

## Features

*   **Open Agent Specification (OAS):** Strict Pydantic models for Agent definitions (`AgentDefinition`).
*   **Strict Typing:** Enforces type safety and immutable structures for critical interfaces.
*   **Enhanced Serialization:** Includes `CoReasonBaseModel` to ensure consistent JSON serialization of complex types like `UUID` and `datetime`.
*   **Event Protocol:** Defines the `GraphEvent` and `CloudEvent` structures for real-time communication.
*   **Simulation Schemas:** Provides standard models for `SimulationScenario`, `AdversaryProfile`, and `SimulationTrace`.
*   **Audit & Compliance:** Defines the `AuditLog` structure for tamper-evident record keeping.
*   **Ergonomic Factory Methods:** Simplified construction of `ChatMessage` and `GenAIOperation`.
*   **Token Arithmetic:** Support for `+` and `+=` operators on `GenAITokenUsage`.
*   **Flexible Tooling:** `ToolCallRequestPart` accepts JSON strings with automatic parsing.
*   **Enhanced Tracing:** `ReasoningTrace` includes flexible metadata for execution state.

## Serialization & Base Model

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`.

*   Use `.dump()` to get a JSON-compatible dictionary (where UUIDs/datetimes are strings).
*   Use `.to_json()` to get a JSON string.

For a detailed rationale, see [docs/coreason_base_model_rationale.md](docs/coreason_base_model_rationale.md).

## Installation

```bash
pip install coreason-manifest
```

## Usage

This library is used to define and validate Agent configurations programmatically.

```python
import uuid
from datetime import datetime, timezone
from coreason_manifest.definitions.agent import (
    AgentDefinition,
    AgentMetadata,
    AgentInterface,
    AgentRuntimeConfig,
    ModelConfig,
    AgentDependencies,
    ToolRequirement,
    ToolRiskLevel,
    PolicyConfig,
    ObservabilityConfig,
    TraceLevel
)

# 1. Define Metadata
metadata = AgentMetadata(
    id=uuid.uuid4(),
    version="1.0.0",  # Strict SemVer
    name="Research Agent",
    author="Coreason AI",
    created_at=datetime.now(timezone.utc)
)

# 2. Instantiate Agent
agent = AgentDefinition(
    metadata=metadata,
    interface=AgentInterface(
        inputs={"topic": {"type": "string"}},
        outputs={"summary": {"type": "string"}}
    ),
    config=AgentRuntimeConfig(
        model_config=ModelConfig(
            model="gpt-4",
            temperature=0.0,
            system_prompt="You are a helpful assistant."
        )
    ),
    dependencies=AgentDependencies(
        tools=[
            ToolRequirement(
                uri="mcp://search-service/google",
                hash="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",  # Valid SHA256
                scopes=["search:read"],
                risk_level=ToolRiskLevel.STANDARD
            )
        ],
        libraries=("pandas==2.0.0",)
    ),
    policy=PolicyConfig(
        budget_caps={"total_cost": 5.0}
    ),
    observability=ObservabilityConfig(
        trace_level=TraceLevel.FULL,
        retention_policy="90_days"
    ),
    # Mandatory Integrity Hash
    integrity_hash="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
)

print(f"Agent '{agent.metadata.name}' definition created and validated.")
```

For full details, see the [Usage Documentation](docs/usage.md).

## Documentation

*   [Frontend Integration](docs/frontend_integration.md): Communicating with the Coreason Engine.
*   [Simulation Architecture](docs/simulation_architecture.md): Details on ATIF compatibility and GAIA scenarios.
*   [Audit & Compliance](docs/audit_compliance.md): Details on EU AI Act compliance, Chain of Custody, and Integrity Hashing.

