Skip to main content

hexastack-core

The foundational kernel of Hexastack: dependency injection, abstract ports, domain abstractions, configuration registry, and the modular bootstrap lifecycle.

Python 3.13+


1. Overview & Capabilities

hexastack-core serves as the zero-dependency (excluding pydantic and rodi) microkernel for all Hexastack packages. It establishes:

  • Dependency Injection Engine: Powered by rodi, managing service lifecycles (singleton, scoped, transient).
  • Feature Flag Port & Providers: Vendor-agnostic feature toggling (FeatureFlagPort, EvaluationContext, ConfigFeatureFlagAdapter, InMemoryFeatureFlagAdapter) with multi-tenant and ambient UserContext targeting.
  • Core Domain Primitives: Generic Result[T, E], generic types, and standard exception hierarchies (HexastackError, ConfigurationError, MissingDependencyError).
  • Core Port Contracts: Standard abstract protocols and ABCs for repositories (Repository[E, ID]), unit of work (UnitOfWork), logging (LoggerPort), presenters (PresenterPort), feature flags (FeatureFlagPort), and bootstrappers (BootstrapperPort).
  • Configuration & Type Registries: Type-safe Pydantic configuration parsing from TOML (ConfigRegistry) and generic type registries (GenericTypeRegistry).
  • Three-Phase Bootstrap Engine: Deterministic orchestration of Phase 1 config registration, Phase 2 container assembly, and Phase 3 reflective scanning.
  • Testing & Quality Toolkit:
    • assert_clean_architecture(...): Hexagonal architecture boundary verification powered by pytest-archon.
    • create_test_runtime(...): Lightweight in-memory DI test harness and doubles (TestRuntime).
    • cqrs_strategy(...): Hypothesis property-based fuzzing strategy generator for Pydantic/dataclass CQRS models.
    • Feature flag testing: @parametrize_flags, flag_scope, @require_feature, and @require_extra.
  • Context Utilities: Async-safe correlation ID and context variable management (get_correlation_id, set_correlation_id, UserContext).

2. Package Anatomy & Key Components

hexastack_core/
├── domain/          # Result[T, E], HexastackError, Entity, ValueObject, EvaluationContext
├── ports/           # Repository, UnitOfWork, BootstrapperPort, LoggerPort, PresenterPort, FeatureFlagPort
├── adapters/        # InMemoryRepository, InMemoryUnitOfWork, InMemoryFeatureFlagAdapter, ConfigFeatureFlagAdapter
├── infra/           # Bootstrap engine, ConfigRegistry, GenericTypeRegistry, decorators
├── testing/         # assert_clean_architecture, create_test_runtime, cqrs_strategy, flag_scope, isolation
└── utils/           # Context variable utilities, reflection helpers

Key Exports

Category Exports
Bootstrap bootstrap, BootstrapContext, BootstrapResult, scan_modules
Config ConfigRegistry, HexastackConfig, HexastackCoreConfig, @config_section
Context get_correlation_id, set_correlation_id, correlation_scope, UserContext
Domain Result, Ok, Err, HexastackError, ConfigurationError, MissingDependencyError, EntityNotFoundError
Feature Flags EvaluationContext, FlagEvaluationDetails, InMemoryFeatureFlagAdapter, ConfigFeatureFlagAdapter
Ports BootstrapperPort, Repository, AsyncRepository, UnitOfWork, AsyncUnitOfWork, LoggerPort, PresenterPort, FeatureFlagPort
Registries GenericTypeRegistry, ExceptionRegistry
Testing assert_clean_architecture, create_test_runtime, TestRuntime, cqrs_strategy, faker_strategy, flag_scope, generate_synthetic_payload, isolate_registries, parametrize_flags, @require_extra, @require_feature, seeded_faker

3. Monorepo & Sibling Relationships

graph TD
    subgraph SiblingPackages ["Dependent Sibling Packages"]
        CQRS["hexastack-cqrs"]
        LOG["hexastack-logging"]
        DB["hexastack-db"]
        FASTAPI["hexastack-fastapi"]
        GRAPHQL["hexastack-graphql"]
        MCP["hexastack-mcp"]
        GRPC["hexastack-grpc"]
        CLI["hexastack-cli"]
        UMBRELLA["hexastack"]
    end

    subgraph CoreKernel ["hexastack-core"]
        DI["rodi.Container"]
        BOOT["Bootstrap Engine"]
        PORTS["Abstract Ports (UoW, Repo, Logger)"]
        CONF["ConfigRegistry"]
    end

    CQRS -->|implements BootstrapperPort, uses rodi| CoreKernel
    LOG -->|implements LoggerPort & BootstrapperPort| CoreKernel
    DB -->|implements Repository & UnitOfWork ports| CoreKernel
    FASTAPI -->|implements BootstrapperPort, consumes DI| CoreKernel
    GRAPHQL -->|implements BootstrapperPort, consumes DI| CoreKernel
    MCP -->|implements BootstrapperPort, consumes DI| CoreKernel
    GRPC -->|implements BootstrapperPort, consumes DI| CoreKernel
    CLI -->|implements BootstrapperPort, consumes DI| CoreKernel
    UMBRELLA -->|orchestrates bootstrap| CoreKernel

Explicit Dependencies (Direct)

  • pydantic>=2.13.4: Schema validation and config parsing.
  • rodi>=2.1.0: Fast, lightweight dependency injection container.

Implied / Behavioral Relationships (DI-Mediated)

  • Provides Ports: Defines UnitOfWorkPort and Repository implemented by hexastack-db.
  • Provides Telemetry Contract: Defines LoggerPort implemented by hexastack-logging.
  • Provides Bootstrap Framework: All siblings expose extension entry points implementing BootstrapperPort.

4. Installation

# Standalone installation
pip install hexastack-core

# Via umbrella package
pip install hexastack

5. Configuration Reference

Configuration schemas are registered under [hexastack]:

[hexastack]
app_name = "my-application"
environment = "production" # "development", "staging", "production", "test"
debug = false

6. Quickstart Example

from hexastack_core.infra.bootstrap import bootstrap
from hexastack_core.ports.bootstrap import BootstrapperPort, BootstrapContext
from hexastack_core.domain.result import Ok, Err, Result


# 1. Implement a custom extension
class ServiceBootstrapper(BootstrapperPort):
    name = "custom_service"
    order = 10

    def configure(self, context: BootstrapContext) -> None:
        context.container.add_instance("Service Configured", declared_class=str)


# 2. Run deterministic bootstrap
result = bootstrap(bootstrappers=[ServiceBootstrapper()], auto_discover=False)
value = result.container.get(str)
print(value)  # "Service Configured"

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hexastack_core-0.0.0.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

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

hexastack_core-0.0.0-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file hexastack_core-0.0.0.tar.gz.

File metadata

  • Download URL: hexastack_core-0.0.0.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hexastack_core-0.0.0.tar.gz
Algorithm Hash digest
SHA256 8964e07c15c88804064a9ed9b5d4fb984d9807427c6e7efb9a0b08cc6c9cb945
MD5 afc8001a8c4dec2d0a65964e356c8dd5
BLAKE2b-256 462355727642d1a7761a0808b7f03c932d15436c322a6f750d1c81799a89e813

See more details on using hashes here.

File details

Details for the file hexastack_core-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: hexastack_core-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 53.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hexastack_core-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c09c754cf3b02a93636a27b9db84f807a24ec75301201df23b621659d431e9d
MD5 d31291286f25e237bedebff2a534c0ad
BLAKE2b-256 71201cd9501d551d591a5d678cbc2178fa76a1cb8ca39035f4f28855504393ed

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 files

Supported by

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