Skip to main content

ONEX Service Provider Interface - Protocol definitions

Project description

ONEX Service Provider Interface (omnibase_spi)

License: MIT Python 3.12+ Ruff Type checked: mypy Pre-commit Protocols Domains Version

Pure protocol interfaces for the ONEX framework with zero implementation dependencies.

Table of Contents

Quick Start

# Install with poetry
poetry add omnibase-spi

# Or with pip
pip install omnibase-spi
# Import node protocols
from omnibase_spi.protocols.nodes import (
    ProtocolNode,
    ProtocolComputeNode,
    ProtocolEffectNode,
    ProtocolReducerNode,
    ProtocolOrchestratorNode,
)

# Import handler protocol
from omnibase_spi.protocols.handlers import ProtocolHandler

# Import registry protocol
from omnibase_spi.protocols.registry import ProtocolHandlerRegistry

# Import contract compilers
from omnibase_spi.protocols.contracts import (
    ProtocolEffectContractCompiler,
    ProtocolWorkflowContractCompiler,
    ProtocolFSMContractCompiler,
)

# Import exception hierarchy
from omnibase_spi.exceptions import (
    SPIError,
    ProtocolHandlerError,
    ContractCompilerError,
    RegistryError,
)

V0.3.0 Highlights

  • Node Protocols: Complete node type hierarchy with ProtocolNode, ProtocolComputeNode, ProtocolEffectNode, ProtocolReducerNode, and ProtocolOrchestratorNode
  • Handler Protocol: ProtocolHandler with full lifecycle management (initialize, execute, shutdown)
  • Contract Compilers: Effect, Workflow, and FSM contract compilation protocols
  • Handler Registry: ProtocolHandlerRegistry for dependency injection and handler lookup
  • Exception Hierarchy: Structured SPIError base with specialized subclasses
  • 180+ Protocols: Comprehensive coverage across 23 specialized domains

Architecture

+-----------------------------------------------------------+
|                      Applications                          |
|               (omniagent, omniintelligence)                |
+-----------------------------+-----------------------------+
                              | uses
                              v
+-----------------------------------------------------------+
|                      omnibase_spi                          |
|            (Protocol Contracts, Exceptions)                |
|  - ProtocolNode, ProtocolComputeNode, ProtocolEffectNode   |
|  - ProtocolHandler, ProtocolHandlerRegistry                |
|  - Contract Compilers (Effect, Workflow, FSM)              |
+-----------------------------+-----------------------------+
                              | imports models
                              v
+-----------------------------------------------------------+
|                      omnibase_core                         |
|             (Pydantic Models, Core Types)                  |
+-----------------------------+-----------------------------+
                              | implemented by
                              v
+-----------------------------------------------------------+
|                      omnibase_infra                        |
|          (Handler Implementations, I/O)                    |
+-----------------------------------------------------------+

Related Repositories:

Dependency Rules:

  • SPI -> Core: allowed (runtime imports of models and contract types)
  • Core -> SPI: forbidden (no imports)
  • SPI -> Infra: forbidden (no imports, even transitively)
  • Infra -> SPI + Core: expected (implements behavior)

Repository Structure

src/omnibase_spi/
+-- protocols/
|   +-- nodes/               # Node type protocols
|   |   +-- base.py          #   ProtocolNode
|   |   +-- compute.py       #   ProtocolComputeNode
|   |   +-- effect.py        #   ProtocolEffectNode
|   |   +-- reducer.py       #   ProtocolReducerNode
|   |   +-- orchestrator.py  #   ProtocolOrchestratorNode
|   |   +-- legacy/          #   Deprecated protocols (removal in v0.5.0)
|   +-- handlers/            # Handler protocol
|   |   +-- protocol_handler.py
|   +-- contracts/           # Contract compiler protocols
|   |   +-- effect_compiler.py
|   |   +-- workflow_compiler.py
|   |   +-- fsm_compiler.py
|   +-- registry/            # Handler registry protocol
|   |   +-- handler_registry.py
|   +-- container/           # DI and service registry
|   +-- event_bus/           # Event bus protocols
|   +-- workflow_orchestration/  # Workflow protocols
|   +-- mcp/                 # MCP integration protocols
|   +-- [14 more domains]
+-- exceptions.py            # SPIError hierarchy
+-- py.typed                 # PEP 561 marker

Protocol Overview

The ONEX SPI provides 180+ protocols across 23 specialized domains:

Domain Protocols Description
Nodes 5 Node type hierarchy (Compute, Effect, Reducer, Orchestrator)
Handlers 1 Protocol handler with lifecycle management
Contracts 3 Contract compilers (Effect, Workflow, FSM)
Registry 1 Handler registry for DI
Container 21 Dependency injection, lifecycle management
Event Bus 13 Distributed messaging infrastructure
Workflow Orchestration 14 Event-driven FSM coordination
MCP Integration 15 Multi-subsystem tool coordination
Memory 15 Workflow state persistence
Core System 16 Logging, health monitoring, error handling
Plus 22 more domains 76+ Validation, networking, file handling, etc.

Key Features

  • Zero Implementation Dependencies - Pure protocol contracts only
  • Runtime Type Safety - Full @runtime_checkable protocol support
  • Dependency Injection - Sophisticated service lifecycle management
  • Event-Driven Architecture - Event sourcing and workflow orchestration
  • Multi-Subsystem Coordination - MCP integration and distributed tooling
  • Enterprise Features - Health monitoring, metrics, circuit breakers

Exception Hierarchy

SPIError                          # Base exception for all SPI errors
+-- ProtocolHandlerError          # Handler execution errors
|   +-- HandlerInitializationError  # Handler failed to initialize
+-- ContractCompilerError         # Contract compilation/validation errors
+-- RegistryError                 # Handler registry operation errors
+-- ProtocolNotImplementedError   # Missing protocol implementation
+-- InvalidProtocolStateError     # Lifecycle state violations

Protocol Design Guidelines

Protocol Definition Pattern

from typing import Protocol, runtime_checkable
from omnibase_core.models.compute import ModelComputeInput, ModelComputeOutput

@runtime_checkable
class ProtocolComputeNode(Protocol):
    """Compute node for pure transformations."""

    @property
    def is_deterministic(self) -> bool:
        """Whether this node produces deterministic output."""
        ...

    async def execute(self, input_data: ModelComputeInput) -> ModelComputeOutput:
        """Execute the compute operation."""
        ...

Protocol Requirements

Every protocol must:

  1. Inherit from typing.Protocol
  2. Have @runtime_checkable decorator
  3. Use ... (ellipsis) for method bodies
  4. Import Core models for type hints (allowed at runtime)
  5. Have docstrings with Args/Returns/Raises

Development

# Install dependencies
poetry install

# Run tests
poetry run pytest

# Run single test file
poetry run pytest tests/path/to/test_file.py

# Run single test
poetry run pytest tests/path/to/test_file.py::test_name -v

# Type checking
poetry run mypy src/

# Strict type checking (target for CI)
poetry run mypy src/ --strict

# Format code
poetry run black src/ tests/
poetry run isort src/ tests/

# Lint
poetry run ruff check src/ tests/

# Build package
poetry build

# Run standalone validators (stdlib only, no dependencies)
python scripts/validation/run_all_validations.py
python scripts/validation/run_all_validations.py --strict --verbose

# Individual validators
python scripts/validation/validate_naming_patterns.py src/
python scripts/validation/validate_namespace_isolation.py
python scripts/validation/validate_architecture.py --verbose

# Pre-commit hooks
pre-commit run --all-files
pre-commit run validate-naming-patterns --all-files
pre-commit run validate-namespace-isolation-new --all-files

Namespace Isolation

This SPI package maintains complete namespace isolation to prevent circular dependencies:

Rule Status
from omnibase_spi.protocols.* import ... Allowed
from omnibase_core.* import ... Allowed
from omnibase_infra.* import ... Forbidden
Pydantic models in SPI Forbidden (use Core)

Contributing

We welcome contributions! Please see our Contributing Guide for development guidelines.

# Clone the repository
git clone https://github.com/OmniNode-ai/omnibase_spi.git
cd omnibase_spi

# Install dependencies
poetry install

# Run validation
poetry run pre-commit run --all-files

Documentation

See the Glossary for definitions of SPI-specific terms like Protocol, Handler, Node, and Contract.

See Also

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support


Made with care by the OmniNode Team

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

omnibase_spi-0.7.0.tar.gz (481.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omnibase_spi-0.7.0-py3-none-any.whl (694.3 kB view details)

Uploaded Python 3

File details

Details for the file omnibase_spi-0.7.0.tar.gz.

File metadata

  • Download URL: omnibase_spi-0.7.0.tar.gz
  • Upload date:
  • Size: 481.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Darwin/24.6.0

File hashes

Hashes for omnibase_spi-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f973a4d5025a604928bcb052915cba6db50607fb505424b0f3111315b69235a3
MD5 2f98ed24d5893232d2accad079abb77f
BLAKE2b-256 659c1e52b593e6aa6a52d835a3f642ea4a4746cd71bbd51d0e2c001100a805d3

See more details on using hashes here.

File details

Details for the file omnibase_spi-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: omnibase_spi-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 694.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Darwin/24.6.0

File hashes

Hashes for omnibase_spi-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b062ba21af8b8b83c3e3120c235fb048ed4fc4643171f4bee2e8254b7a31896f
MD5 696722109fa13c352fd16351fa4acf79
BLAKE2b-256 922c5f7f7b1f29a8c18caa258505918bfc213efdcb727d0cfa28e953fbdc1794

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page