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.6.1.tar.gz (461.6 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.6.1-py3-none-any.whl (650.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: omnibase_spi-0.6.1.tar.gz
  • Upload date:
  • Size: 461.6 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.6.1.tar.gz
Algorithm Hash digest
SHA256 9009e609ea711b4e2f747e6d11ae15b781565be3de58e985dc4c112999739634
MD5 9427ed6eeb3370d93c18a57c00559d2d
BLAKE2b-256 187297462e633300a1e52eda44de274540678c3ea120e19acad5e2eb62af87d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: omnibase_spi-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 650.0 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.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b1da2f0c0d6c31e26af9f61116ceb094bcf11ae824ce62124bc0076f48d45fb
MD5 b116103a094ab403fe368f4a82df6da0
BLAKE2b-256 f2749fe46a2c2d3ce227232ed6740e1ac27ec50a98b31cab36a29f4d7b47e799

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