Enforces structural integrity across the entire CoReason ecosystem
Project description
coreason-validator
Enforces structural integrity across the entire CoReason ecosystem.
Overview
coreason-validator acts as the Single Source of Truth for all data structures (Agents, Tests, Topologies, Messages). It provides "Schemas-as-Code" definitions and validation logic to check assets before they are processed, ensuring structural soundness.
In a GxP environment, "Implicit Trust" is a vulnerability. Component A must never assume Component B sent valid data. This library ensures that what is about to happen is structurally sound.
Key Features
- Schema Registry: A collection of immutable Pydantic Models defining valid assets.
- Static Analyzer: A validation engine that runs on static files (JSON/YAML) with rich error reporting.
- Runtime Guard: A lightweight validation function for dynamic payloads with microsecond latency.
- Integrity Hasher: Provides canonical hashing to ensure file integrity and GxP compliance.
- Frontend Bridge: Exports JSON Schemas to keep the UI in sync with the backend.
Documentation
For detailed documentation, please refer to the docs/ directory or the hosted site:
Architecture
The library implements the Define-Check-Hash Loop:
- Define: Schemas as strict Python classes (Pydantic V2).
- Check: Shift-left validation locally and at runtime.
- Hash: Canonical hashing of the validated structure for GxP integrity.
See Architecture for more details.
Getting Started
Prerequisites
- Python 3.12+
- Poetry
Installation
- Clone the repository:
git clone https://github.com/CoReason-AI/coreason_validator.git cd coreason_validator
- Install dependencies:
poetry install
Usage
CLI Quick Start
The package exposes a CLI tool coreason-val for validation and schema operations.
Validate a File
To validate a YAML or JSON file against its schema (schema type is auto-detected):
poetry run coreason-val check path/to/file.yaml
Example:
poetry run coreason-val check samples/agent_config.yaml
Export JSON Schemas
To export the canonical JSON Schemas for use in other systems (e.g., Frontend forms):
poetry run coreason-val export ./schemas_out
This will generate agent.schema.json, bec.schema.json, etc., in the specified directory.
Python API
For deep integration, import coreason_validator directly.
from coreason_validator import validate_file, validate_object
# Validate a file
result = validate_file("path/to/agent.yaml")
if result.is_valid:
print("Valid!")
else:
print(f"Errors: {result.errors}")
# Validate an object (Runtime)
data = {"name": "my-agent", "version": "1.0.0"}
try:
model = validate_object(data, "agent")
print(f"Canonical Hash: {model.canonical_hash()}")
except Exception as e:
print(f"Validation failed: {e}")
Development
- Run the linter:
poetry run pre-commit run --all-files
- Run the tests:
poetry run pytest
- Build documentation:
poetry run mkdocs build
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coreason_validator-0.5.1.tar.gz.
File metadata
- Download URL: coreason_validator-0.5.1.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c457a2c384d8dd534a1b0a064b496bb2914f6fff5f45847b25ff6b94579e11b4
|
|
| MD5 |
79c747aa4aedf67dbf514c16b619d42f
|
|
| BLAKE2b-256 |
9a361093880a5e3151f9ec359a8b290a548373df2c67cb9cac1583160611a8f0
|
Provenance
The following attestation bundles were made for coreason_validator-0.5.1.tar.gz:
Publisher:
publish.yml on CoReason-AI/coreason-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_validator-0.5.1.tar.gz -
Subject digest:
c457a2c384d8dd534a1b0a064b496bb2914f6fff5f45847b25ff6b94579e11b4 - Sigstore transparency entry: 868043716
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-validator@df2bae1c11cef98dace4eb22319c40be54b024f2 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@df2bae1c11cef98dace4eb22319c40be54b024f2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file coreason_validator-0.5.1-py3-none-any.whl.
File metadata
- Download URL: coreason_validator-0.5.1-py3-none-any.whl
- Upload date:
- Size: 29.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
435e30e5b07a27a921551d985f5174d5438b609b7a6ce62a841bbbd7473c9e68
|
|
| MD5 |
82c2ca0385786c5cc4a7486f8eb81781
|
|
| BLAKE2b-256 |
ea5334d4e2e80f8bfc03603b7e0382e86ec40d6917d6868fe40133111173b516
|
Provenance
The following attestation bundles were made for coreason_validator-0.5.1-py3-none-any.whl:
Publisher:
publish.yml on CoReason-AI/coreason-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_validator-0.5.1-py3-none-any.whl -
Subject digest:
435e30e5b07a27a921551d985f5174d5438b609b7a6ce62a841bbbd7473c9e68 - Sigstore transparency entry: 868043753
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-validator@df2bae1c11cef98dace4eb22319c40be54b024f2 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@df2bae1c11cef98dace4eb22319c40be54b024f2 -
Trigger Event:
release
-
Statement type: