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.10.0.tar.gz (489.3 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.10.0-py3-none-any.whl (708.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: omnibase_spi-0.10.0.tar.gz
  • Upload date:
  • Size: 489.3 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.10.0.tar.gz
Algorithm Hash digest
SHA256 124b979163be545f17e5584cf0e1ebe08bf0fef19b20485ca0fb0ac323344b1e
MD5 1c9bcf4113e206ed197d3db8ebe09e47
BLAKE2b-256 789c8cb2094abfea4ef30c03dffc5d54987c1e5086ecde34514a0ee73450dec7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: omnibase_spi-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 708.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.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54e37a4395bac3792c4bf158f748c578b29c17e6b9970e32d6eb47bbf3c7592e
MD5 2815dd054a61806cabb075d19b9f149b
BLAKE2b-256 6d4c8fa813672521ff0ac444bb5f455be34ef217fbf0c4a4c3888669650b49b9

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