hexastack-core 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hexastack_core-0.0.0/PKG-INFO +162 -0
- hexastack_core-0.0.0/README.md +146 -0
- hexastack_core-0.0.0/pyproject.toml +84 -0
- hexastack_core-0.0.0/pyproject.toml.orig +87 -0
- hexastack_core-0.0.0/src/hexastack_core/__init__.py +10 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/__init__.py +43 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/ai/__init__.py +11 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/ai/in_memory.py +196 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/cache/__init__.py +9 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/cache/in_memory.py +90 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/clock/__init__.py +9 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/clock/in_memory.py +80 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/feature_flags/__init__.py +7 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/feature_flags/config.py +235 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/feature_flags/in_memory.py +150 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/logging/__init__.py +11 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/logging/in_memory.py +161 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/logging/standard.py +106 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/repository/__init__.py +9 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/repository/in_memory.py +142 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/unit_of_work/__init__.py +9 -0
- hexastack_core-0.0.0/src/hexastack_core/adapters/unit_of_work/in_memory.py +76 -0
- hexastack_core-0.0.0/src/hexastack_core/domain/__init__.py +35 -0
- hexastack_core-0.0.0/src/hexastack_core/domain/command.py +9 -0
- hexastack_core-0.0.0/src/hexastack_core/domain/event.py +9 -0
- hexastack_core-0.0.0/src/hexastack_core/domain/exceptions.py +74 -0
- hexastack_core-0.0.0/src/hexastack_core/domain/feature_flags.py +81 -0
- hexastack_core-0.0.0/src/hexastack_core/domain/generic.py +12 -0
- hexastack_core-0.0.0/src/hexastack_core/domain/query.py +9 -0
- hexastack_core-0.0.0/src/hexastack_core/domain/result.py +48 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/__init__.py +53 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/autodiscovery.py +80 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/bootstrap.py +223 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/config.py +66 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/decorators.py +78 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/registries/__init__.py +25 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/registries/config.py +79 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/registries/exception.py +24 -0
- hexastack_core-0.0.0/src/hexastack_core/infra/registries/generic.py +239 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/__init__.py +35 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/ai.py +93 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/bootstrap.py +48 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/cache.py +101 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/clock.py +35 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/feature_flags.py +149 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/logging.py +54 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/presenter.py +22 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/repository.py +53 -0
- hexastack_core-0.0.0/src/hexastack_core/ports/unit_of_work.py +93 -0
- hexastack_core-0.0.0/src/hexastack_core/py.typed +0 -0
- hexastack_core-0.0.0/src/hexastack_core/testing/__init__.py +43 -0
- hexastack_core-0.0.0/src/hexastack_core/testing/architecture.py +88 -0
- hexastack_core-0.0.0/src/hexastack_core/testing/flags.py +58 -0
- hexastack_core-0.0.0/src/hexastack_core/testing/harness.py +82 -0
- hexastack_core-0.0.0/src/hexastack_core/testing/hypothesis.py +89 -0
- hexastack_core-0.0.0/src/hexastack_core/testing/isolation.py +43 -0
- hexastack_core-0.0.0/src/hexastack_core/testing/synthetic.py +130 -0
- hexastack_core-0.0.0/src/hexastack_core/utils/__init__.py +21 -0
- hexastack_core-0.0.0/src/hexastack_core/utils/context.py +110 -0
- hexastack_core-0.0.0/src/hexastack_core/utils/inspection.py +98 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: hexastack-core
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author: Richard West
|
|
6
|
+
Author-email: Richard West <dopplereffect.us@gmail.com>
|
|
7
|
+
Requires-Dist: pydantic>=2.13.4
|
|
8
|
+
Requires-Dist: rodi>=2.1.0
|
|
9
|
+
Requires-Dist: faker>=33.0.0 ; extra == 'testing'
|
|
10
|
+
Requires-Dist: hypothesis>=6.100.0 ; extra == 'testing'
|
|
11
|
+
Requires-Dist: inline-snapshot>=0.35.4 ; extra == 'testing'
|
|
12
|
+
Requires-Dist: pytest-archon>=0.0.7 ; extra == 'testing'
|
|
13
|
+
Requires-Python: >=3.13
|
|
14
|
+
Provides-Extra: testing
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# hexastack-core
|
|
18
|
+
|
|
19
|
+
> The foundational kernel of Hexastack: dependency injection, abstract ports, domain abstractions, configuration registry, and the modular bootstrap lifecycle.
|
|
20
|
+
|
|
21
|
+
[](https://www.python.org/downloads/)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. Overview & Capabilities
|
|
26
|
+
|
|
27
|
+
`hexastack-core` serves as the zero-dependency (excluding `pydantic` and `rodi`) microkernel for all Hexastack packages. It establishes:
|
|
28
|
+
|
|
29
|
+
- **Dependency Injection Engine**: Powered by `rodi`, managing service lifecycles (singleton, scoped, transient).
|
|
30
|
+
- **Feature Flag Port & Providers**: Vendor-agnostic feature toggling (`FeatureFlagPort`, `EvaluationContext`, `ConfigFeatureFlagAdapter`, `InMemoryFeatureFlagAdapter`) with multi-tenant and ambient `UserContext` targeting.
|
|
31
|
+
- **Core Domain Primitives**: Generic `Result[T, E]`, generic types, and standard exception hierarchies (`HexastackError`, `ConfigurationError`, `MissingDependencyError`).
|
|
32
|
+
- **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`).
|
|
33
|
+
- **Configuration & Type Registries**: Type-safe Pydantic configuration parsing from TOML (`ConfigRegistry`) and generic type registries (`GenericTypeRegistry`).
|
|
34
|
+
- **Three-Phase Bootstrap Engine**: Deterministic orchestration of Phase 1 config registration, Phase 2 container assembly, and Phase 3 reflective scanning.
|
|
35
|
+
- **Testing & Quality Toolkit**:
|
|
36
|
+
- `assert_clean_architecture(...)`: Hexagonal architecture boundary verification powered by `pytest-archon`.
|
|
37
|
+
- `create_test_runtime(...)`: Lightweight in-memory DI test harness and doubles (`TestRuntime`).
|
|
38
|
+
- `cqrs_strategy(...)`: Hypothesis property-based fuzzing strategy generator for Pydantic/dataclass CQRS models.
|
|
39
|
+
- Feature flag testing: `@parametrize_flags`, `flag_scope`, `@require_feature`, and `@require_extra`.
|
|
40
|
+
- **Context Utilities**: Async-safe correlation ID and context variable management (`get_correlation_id`, `set_correlation_id`, `UserContext`).
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2. Package Anatomy & Key Components
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
hexastack_core/
|
|
48
|
+
├── domain/ # Result[T, E], HexastackError, Entity, ValueObject, EvaluationContext
|
|
49
|
+
├── ports/ # Repository, UnitOfWork, BootstrapperPort, LoggerPort, PresenterPort, FeatureFlagPort
|
|
50
|
+
├── adapters/ # InMemoryRepository, InMemoryUnitOfWork, InMemoryFeatureFlagAdapter, ConfigFeatureFlagAdapter
|
|
51
|
+
├── infra/ # Bootstrap engine, ConfigRegistry, GenericTypeRegistry, decorators
|
|
52
|
+
├── testing/ # assert_clean_architecture, create_test_runtime, cqrs_strategy, flag_scope, isolation
|
|
53
|
+
└── utils/ # Context variable utilities, reflection helpers
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Key Exports
|
|
57
|
+
|
|
58
|
+
| Category | Exports |
|
|
59
|
+
|---|---|
|
|
60
|
+
| **Bootstrap** | `bootstrap`, `BootstrapContext`, `BootstrapResult`, `scan_modules` |
|
|
61
|
+
| **Config** | `ConfigRegistry`, `HexastackConfig`, `HexastackCoreConfig`, `@config_section` |
|
|
62
|
+
| **Context** | `get_correlation_id`, `set_correlation_id`, `correlation_scope`, `UserContext` |
|
|
63
|
+
| **Domain** | `Result`, `Ok`, `Err`, `HexastackError`, `ConfigurationError`, `MissingDependencyError`, `EntityNotFoundError` |
|
|
64
|
+
| **Feature Flags** | `EvaluationContext`, `FlagEvaluationDetails`, `InMemoryFeatureFlagAdapter`, `ConfigFeatureFlagAdapter` |
|
|
65
|
+
| **Ports** | `BootstrapperPort`, `Repository`, `AsyncRepository`, `UnitOfWork`, `AsyncUnitOfWork`, `LoggerPort`, `PresenterPort`, `FeatureFlagPort` |
|
|
66
|
+
| **Registries** | `GenericTypeRegistry`, `ExceptionRegistry` |
|
|
67
|
+
| **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` |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 3. Monorepo & Sibling Relationships
|
|
72
|
+
|
|
73
|
+
```mermaid
|
|
74
|
+
graph TD
|
|
75
|
+
subgraph SiblingPackages ["Dependent Sibling Packages"]
|
|
76
|
+
CQRS["hexastack-cqrs"]
|
|
77
|
+
LOG["hexastack-logging"]
|
|
78
|
+
DB["hexastack-db"]
|
|
79
|
+
FASTAPI["hexastack-fastapi"]
|
|
80
|
+
GRAPHQL["hexastack-graphql"]
|
|
81
|
+
MCP["hexastack-mcp"]
|
|
82
|
+
GRPC["hexastack-grpc"]
|
|
83
|
+
CLI["hexastack-cli"]
|
|
84
|
+
UMBRELLA["hexastack"]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
subgraph CoreKernel ["hexastack-core"]
|
|
88
|
+
DI["rodi.Container"]
|
|
89
|
+
BOOT["Bootstrap Engine"]
|
|
90
|
+
PORTS["Abstract Ports (UoW, Repo, Logger)"]
|
|
91
|
+
CONF["ConfigRegistry"]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
CQRS -->|implements BootstrapperPort, uses rodi| CoreKernel
|
|
95
|
+
LOG -->|implements LoggerPort & BootstrapperPort| CoreKernel
|
|
96
|
+
DB -->|implements Repository & UnitOfWork ports| CoreKernel
|
|
97
|
+
FASTAPI -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
98
|
+
GRAPHQL -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
99
|
+
MCP -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
100
|
+
GRPC -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
101
|
+
CLI -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
102
|
+
UMBRELLA -->|orchestrates bootstrap| CoreKernel
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Explicit Dependencies (Direct)
|
|
106
|
+
- `pydantic>=2.13.4`: Schema validation and config parsing.
|
|
107
|
+
- `rodi>=2.1.0`: Fast, lightweight dependency injection container.
|
|
108
|
+
|
|
109
|
+
### Implied / Behavioral Relationships (DI-Mediated)
|
|
110
|
+
- **Provides Ports**: Defines `UnitOfWorkPort` and `Repository` implemented by `hexastack-db`.
|
|
111
|
+
- **Provides Telemetry Contract**: Defines `LoggerPort` implemented by `hexastack-logging`.
|
|
112
|
+
- **Provides Bootstrap Framework**: All siblings expose extension entry points implementing `BootstrapperPort`.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 4. Installation
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Standalone installation
|
|
120
|
+
pip install hexastack-core
|
|
121
|
+
|
|
122
|
+
# Via umbrella package
|
|
123
|
+
pip install hexastack
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 5. Configuration Reference
|
|
129
|
+
|
|
130
|
+
Configuration schemas are registered under `[hexastack]`:
|
|
131
|
+
|
|
132
|
+
```toml
|
|
133
|
+
[hexastack]
|
|
134
|
+
app_name = "my-application"
|
|
135
|
+
environment = "production" # "development", "staging", "production", "test"
|
|
136
|
+
debug = false
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 6. Quickstart Example
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from hexastack_core.infra.bootstrap import bootstrap
|
|
145
|
+
from hexastack_core.ports.bootstrap import BootstrapperPort, BootstrapContext
|
|
146
|
+
from hexastack_core.domain.result import Ok, Err, Result
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# 1. Implement a custom extension
|
|
150
|
+
class ServiceBootstrapper(BootstrapperPort):
|
|
151
|
+
name = "custom_service"
|
|
152
|
+
order = 10
|
|
153
|
+
|
|
154
|
+
def configure(self, context: BootstrapContext) -> None:
|
|
155
|
+
context.container.add_instance("Service Configured", declared_class=str)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# 2. Run deterministic bootstrap
|
|
159
|
+
result = bootstrap(bootstrappers=[ServiceBootstrapper()], auto_discover=False)
|
|
160
|
+
value = result.container.get(str)
|
|
161
|
+
print(value) # "Service Configured"
|
|
162
|
+
```
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# hexastack-core
|
|
2
|
+
|
|
3
|
+
> The foundational kernel of Hexastack: dependency injection, abstract ports, domain abstractions, configuration registry, and the modular bootstrap lifecycle.
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Overview & Capabilities
|
|
10
|
+
|
|
11
|
+
`hexastack-core` serves as the zero-dependency (excluding `pydantic` and `rodi`) microkernel for all Hexastack packages. It establishes:
|
|
12
|
+
|
|
13
|
+
- **Dependency Injection Engine**: Powered by `rodi`, managing service lifecycles (singleton, scoped, transient).
|
|
14
|
+
- **Feature Flag Port & Providers**: Vendor-agnostic feature toggling (`FeatureFlagPort`, `EvaluationContext`, `ConfigFeatureFlagAdapter`, `InMemoryFeatureFlagAdapter`) with multi-tenant and ambient `UserContext` targeting.
|
|
15
|
+
- **Core Domain Primitives**: Generic `Result[T, E]`, generic types, and standard exception hierarchies (`HexastackError`, `ConfigurationError`, `MissingDependencyError`).
|
|
16
|
+
- **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`).
|
|
17
|
+
- **Configuration & Type Registries**: Type-safe Pydantic configuration parsing from TOML (`ConfigRegistry`) and generic type registries (`GenericTypeRegistry`).
|
|
18
|
+
- **Three-Phase Bootstrap Engine**: Deterministic orchestration of Phase 1 config registration, Phase 2 container assembly, and Phase 3 reflective scanning.
|
|
19
|
+
- **Testing & Quality Toolkit**:
|
|
20
|
+
- `assert_clean_architecture(...)`: Hexagonal architecture boundary verification powered by `pytest-archon`.
|
|
21
|
+
- `create_test_runtime(...)`: Lightweight in-memory DI test harness and doubles (`TestRuntime`).
|
|
22
|
+
- `cqrs_strategy(...)`: Hypothesis property-based fuzzing strategy generator for Pydantic/dataclass CQRS models.
|
|
23
|
+
- Feature flag testing: `@parametrize_flags`, `flag_scope`, `@require_feature`, and `@require_extra`.
|
|
24
|
+
- **Context Utilities**: Async-safe correlation ID and context variable management (`get_correlation_id`, `set_correlation_id`, `UserContext`).
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. Package Anatomy & Key Components
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
hexastack_core/
|
|
32
|
+
├── domain/ # Result[T, E], HexastackError, Entity, ValueObject, EvaluationContext
|
|
33
|
+
├── ports/ # Repository, UnitOfWork, BootstrapperPort, LoggerPort, PresenterPort, FeatureFlagPort
|
|
34
|
+
├── adapters/ # InMemoryRepository, InMemoryUnitOfWork, InMemoryFeatureFlagAdapter, ConfigFeatureFlagAdapter
|
|
35
|
+
├── infra/ # Bootstrap engine, ConfigRegistry, GenericTypeRegistry, decorators
|
|
36
|
+
├── testing/ # assert_clean_architecture, create_test_runtime, cqrs_strategy, flag_scope, isolation
|
|
37
|
+
└── utils/ # Context variable utilities, reflection helpers
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Key Exports
|
|
41
|
+
|
|
42
|
+
| Category | Exports |
|
|
43
|
+
|---|---|
|
|
44
|
+
| **Bootstrap** | `bootstrap`, `BootstrapContext`, `BootstrapResult`, `scan_modules` |
|
|
45
|
+
| **Config** | `ConfigRegistry`, `HexastackConfig`, `HexastackCoreConfig`, `@config_section` |
|
|
46
|
+
| **Context** | `get_correlation_id`, `set_correlation_id`, `correlation_scope`, `UserContext` |
|
|
47
|
+
| **Domain** | `Result`, `Ok`, `Err`, `HexastackError`, `ConfigurationError`, `MissingDependencyError`, `EntityNotFoundError` |
|
|
48
|
+
| **Feature Flags** | `EvaluationContext`, `FlagEvaluationDetails`, `InMemoryFeatureFlagAdapter`, `ConfigFeatureFlagAdapter` |
|
|
49
|
+
| **Ports** | `BootstrapperPort`, `Repository`, `AsyncRepository`, `UnitOfWork`, `AsyncUnitOfWork`, `LoggerPort`, `PresenterPort`, `FeatureFlagPort` |
|
|
50
|
+
| **Registries** | `GenericTypeRegistry`, `ExceptionRegistry` |
|
|
51
|
+
| **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` |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 3. Monorepo & Sibling Relationships
|
|
56
|
+
|
|
57
|
+
```mermaid
|
|
58
|
+
graph TD
|
|
59
|
+
subgraph SiblingPackages ["Dependent Sibling Packages"]
|
|
60
|
+
CQRS["hexastack-cqrs"]
|
|
61
|
+
LOG["hexastack-logging"]
|
|
62
|
+
DB["hexastack-db"]
|
|
63
|
+
FASTAPI["hexastack-fastapi"]
|
|
64
|
+
GRAPHQL["hexastack-graphql"]
|
|
65
|
+
MCP["hexastack-mcp"]
|
|
66
|
+
GRPC["hexastack-grpc"]
|
|
67
|
+
CLI["hexastack-cli"]
|
|
68
|
+
UMBRELLA["hexastack"]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
subgraph CoreKernel ["hexastack-core"]
|
|
72
|
+
DI["rodi.Container"]
|
|
73
|
+
BOOT["Bootstrap Engine"]
|
|
74
|
+
PORTS["Abstract Ports (UoW, Repo, Logger)"]
|
|
75
|
+
CONF["ConfigRegistry"]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
CQRS -->|implements BootstrapperPort, uses rodi| CoreKernel
|
|
79
|
+
LOG -->|implements LoggerPort & BootstrapperPort| CoreKernel
|
|
80
|
+
DB -->|implements Repository & UnitOfWork ports| CoreKernel
|
|
81
|
+
FASTAPI -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
82
|
+
GRAPHQL -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
83
|
+
MCP -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
84
|
+
GRPC -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
85
|
+
CLI -->|implements BootstrapperPort, consumes DI| CoreKernel
|
|
86
|
+
UMBRELLA -->|orchestrates bootstrap| CoreKernel
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Explicit Dependencies (Direct)
|
|
90
|
+
- `pydantic>=2.13.4`: Schema validation and config parsing.
|
|
91
|
+
- `rodi>=2.1.0`: Fast, lightweight dependency injection container.
|
|
92
|
+
|
|
93
|
+
### Implied / Behavioral Relationships (DI-Mediated)
|
|
94
|
+
- **Provides Ports**: Defines `UnitOfWorkPort` and `Repository` implemented by `hexastack-db`.
|
|
95
|
+
- **Provides Telemetry Contract**: Defines `LoggerPort` implemented by `hexastack-logging`.
|
|
96
|
+
- **Provides Bootstrap Framework**: All siblings expose extension entry points implementing `BootstrapperPort`.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 4. Installation
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Standalone installation
|
|
104
|
+
pip install hexastack-core
|
|
105
|
+
|
|
106
|
+
# Via umbrella package
|
|
107
|
+
pip install hexastack
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 5. Configuration Reference
|
|
113
|
+
|
|
114
|
+
Configuration schemas are registered under `[hexastack]`:
|
|
115
|
+
|
|
116
|
+
```toml
|
|
117
|
+
[hexastack]
|
|
118
|
+
app_name = "my-application"
|
|
119
|
+
environment = "production" # "development", "staging", "production", "test"
|
|
120
|
+
debug = false
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 6. Quickstart Example
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from hexastack_core.infra.bootstrap import bootstrap
|
|
129
|
+
from hexastack_core.ports.bootstrap import BootstrapperPort, BootstrapContext
|
|
130
|
+
from hexastack_core.domain.result import Ok, Err, Result
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# 1. Implement a custom extension
|
|
134
|
+
class ServiceBootstrapper(BootstrapperPort):
|
|
135
|
+
name = "custom_service"
|
|
136
|
+
order = 10
|
|
137
|
+
|
|
138
|
+
def configure(self, context: BootstrapContext) -> None:
|
|
139
|
+
context.container.add_instance("Service Configured", declared_class=str)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# 2. Run deterministic bootstrap
|
|
143
|
+
result = bootstrap(bootstrappers=[ServiceBootstrapper()], auto_discover=False)
|
|
144
|
+
value = result.container.get(str)
|
|
145
|
+
print(value) # "Service Configured"
|
|
146
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "hexastack-core"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
description = "Add your description here"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"pydantic>=2.13.4",
|
|
9
|
+
"rodi>=2.1.0",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[[project.authors]]
|
|
13
|
+
name = "Richard West"
|
|
14
|
+
email = "dopplereffect.us@gmail.com"
|
|
15
|
+
|
|
16
|
+
[project.optional-dependencies]
|
|
17
|
+
testing = [
|
|
18
|
+
"faker>=33.0.0",
|
|
19
|
+
"hypothesis>=6.100.0",
|
|
20
|
+
"inline-snapshot>=0.35.4",
|
|
21
|
+
"pytest-archon>=0.0.7",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["uv_build>=0.12.3,<0.13.0"]
|
|
26
|
+
build-backend = "uv_build"
|
|
27
|
+
|
|
28
|
+
[tool.importlinter]
|
|
29
|
+
root_packages = ["hexastack_core"]
|
|
30
|
+
|
|
31
|
+
[[tool.importlinter.contracts]]
|
|
32
|
+
name = "Hexagonal architecture layer hierarchy"
|
|
33
|
+
type = "layers"
|
|
34
|
+
containers = ["hexastack_core"]
|
|
35
|
+
layers = [
|
|
36
|
+
"adapters",
|
|
37
|
+
"ports",
|
|
38
|
+
"domain",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[[tool.importlinter.contracts]]
|
|
42
|
+
name = "Forbidden imports for domain"
|
|
43
|
+
type = "forbidden"
|
|
44
|
+
source_modules = ["hexastack_core.domain"]
|
|
45
|
+
forbidden_modules = [
|
|
46
|
+
"hexastack_core.ports",
|
|
47
|
+
"hexastack_core.adapters",
|
|
48
|
+
"hexastack_core.infra",
|
|
49
|
+
"hexastack_core.testing",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[[tool.importlinter.contracts]]
|
|
53
|
+
name = "Forbidden imports for ports"
|
|
54
|
+
type = "forbidden"
|
|
55
|
+
source_modules = ["hexastack_core.ports"]
|
|
56
|
+
forbidden_modules = [
|
|
57
|
+
"hexastack_core.adapters",
|
|
58
|
+
"hexastack_core.infra",
|
|
59
|
+
"hexastack_core.testing",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[[tool.importlinter.contracts]]
|
|
63
|
+
name = "Forbidden imports for adapters"
|
|
64
|
+
type = "forbidden"
|
|
65
|
+
source_modules = ["hexastack_core.adapters"]
|
|
66
|
+
forbidden_modules = ["hexastack_core.testing"]
|
|
67
|
+
|
|
68
|
+
[[tool.importlinter.contracts]]
|
|
69
|
+
name = "Forbidden imports for infra"
|
|
70
|
+
type = "forbidden"
|
|
71
|
+
source_modules = ["hexastack_core.infra"]
|
|
72
|
+
forbidden_modules = ["hexastack_core.testing"]
|
|
73
|
+
|
|
74
|
+
[[tool.importlinter.contracts]]
|
|
75
|
+
name = "Forbidden imports for utils"
|
|
76
|
+
type = "forbidden"
|
|
77
|
+
source_modules = ["hexastack_core.utils"]
|
|
78
|
+
forbidden_modules = [
|
|
79
|
+
"hexastack_core.domain",
|
|
80
|
+
"hexastack_core.ports",
|
|
81
|
+
"hexastack_core.adapters",
|
|
82
|
+
"hexastack_core.infra",
|
|
83
|
+
"hexastack_core.testing",
|
|
84
|
+
]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "hexastack-core"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
description = "Add your description here"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Richard West", email = "dopplereffect.us@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.13"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"pydantic>=2.13.4",
|
|
12
|
+
"rodi>=2.1.0",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.optional-dependencies]
|
|
16
|
+
testing = [
|
|
17
|
+
"faker>=33.0.0",
|
|
18
|
+
"hypothesis>=6.100.0",
|
|
19
|
+
"inline-snapshot>=0.35.4",
|
|
20
|
+
"pytest-archon>=0.0.7",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[build-system]
|
|
24
|
+
requires = ["uv_build>=0.12.3,<0.13.0"]
|
|
25
|
+
build-backend = "uv_build"
|
|
26
|
+
|
|
27
|
+
[tool.importlinter]
|
|
28
|
+
root_packages = ["hexastack_core"]
|
|
29
|
+
|
|
30
|
+
[[tool.importlinter.contracts]]
|
|
31
|
+
name = "Hexagonal architecture layer hierarchy"
|
|
32
|
+
type = "layers"
|
|
33
|
+
containers = ["hexastack_core"]
|
|
34
|
+
layers = [
|
|
35
|
+
"adapters",
|
|
36
|
+
"ports",
|
|
37
|
+
"domain",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[[tool.importlinter.contracts]]
|
|
41
|
+
name = "Forbidden imports for domain"
|
|
42
|
+
type = "forbidden"
|
|
43
|
+
source_modules = ["hexastack_core.domain"]
|
|
44
|
+
forbidden_modules = [
|
|
45
|
+
"hexastack_core.ports",
|
|
46
|
+
"hexastack_core.adapters",
|
|
47
|
+
"hexastack_core.infra",
|
|
48
|
+
"hexastack_core.testing",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[[tool.importlinter.contracts]]
|
|
52
|
+
name = "Forbidden imports for ports"
|
|
53
|
+
type = "forbidden"
|
|
54
|
+
source_modules = ["hexastack_core.ports"]
|
|
55
|
+
forbidden_modules = [
|
|
56
|
+
"hexastack_core.adapters",
|
|
57
|
+
"hexastack_core.infra",
|
|
58
|
+
"hexastack_core.testing",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[[tool.importlinter.contracts]]
|
|
62
|
+
name = "Forbidden imports for adapters"
|
|
63
|
+
type = "forbidden"
|
|
64
|
+
source_modules = ["hexastack_core.adapters"]
|
|
65
|
+
forbidden_modules = [
|
|
66
|
+
"hexastack_core.testing",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[[tool.importlinter.contracts]]
|
|
70
|
+
name = "Forbidden imports for infra"
|
|
71
|
+
type = "forbidden"
|
|
72
|
+
source_modules = ["hexastack_core.infra"]
|
|
73
|
+
forbidden_modules = [
|
|
74
|
+
"hexastack_core.testing",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
[[tool.importlinter.contracts]]
|
|
78
|
+
name = "Forbidden imports for utils"
|
|
79
|
+
type = "forbidden"
|
|
80
|
+
source_modules = ["hexastack_core.utils"]
|
|
81
|
+
forbidden_modules = [
|
|
82
|
+
"hexastack_core.domain",
|
|
83
|
+
"hexastack_core.ports",
|
|
84
|
+
"hexastack_core.adapters",
|
|
85
|
+
"hexastack_core.infra",
|
|
86
|
+
"hexastack_core.testing",
|
|
87
|
+
]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from hexastack_core.adapters.ai import (
|
|
2
|
+
InMemoryLlmProvider,
|
|
3
|
+
InMemoryVectorStore,
|
|
4
|
+
LlmCallRecord,
|
|
5
|
+
)
|
|
6
|
+
from hexastack_core.adapters.cache import (
|
|
7
|
+
AsyncInMemoryCache,
|
|
8
|
+
InMemoryCache,
|
|
9
|
+
)
|
|
10
|
+
from hexastack_core.adapters.clock import (
|
|
11
|
+
FrozenClock,
|
|
12
|
+
InMemoryClock,
|
|
13
|
+
)
|
|
14
|
+
from hexastack_core.adapters.logging import (
|
|
15
|
+
InMemoryLogger,
|
|
16
|
+
LogEntry,
|
|
17
|
+
StandardLogger,
|
|
18
|
+
)
|
|
19
|
+
from hexastack_core.adapters.repository import (
|
|
20
|
+
AsyncInMemoryRepository,
|
|
21
|
+
InMemoryRepository,
|
|
22
|
+
)
|
|
23
|
+
from hexastack_core.adapters.unit_of_work import (
|
|
24
|
+
AsyncInMemoryUnitOfWork,
|
|
25
|
+
InMemoryUnitOfWork,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"AsyncInMemoryCache",
|
|
30
|
+
"AsyncInMemoryRepository",
|
|
31
|
+
"AsyncInMemoryUnitOfWork",
|
|
32
|
+
"FrozenClock",
|
|
33
|
+
"InMemoryCache",
|
|
34
|
+
"InMemoryClock",
|
|
35
|
+
"InMemoryLlmProvider",
|
|
36
|
+
"InMemoryLogger",
|
|
37
|
+
"InMemoryRepository",
|
|
38
|
+
"InMemoryUnitOfWork",
|
|
39
|
+
"InMemoryVectorStore",
|
|
40
|
+
"LlmCallRecord",
|
|
41
|
+
"LogEntry",
|
|
42
|
+
"StandardLogger",
|
|
43
|
+
]
|