Substrate Core Contracts
This reference describes the public API in cerebel-substrate-core.
Public exports
Section titled “Public exports”Runtime contracts:
- SubstrateLifecycleState
- SubstrateHandle
- Substrate
- SubstrateLauncher
Launch-domain contracts:
- LauncherBackend
- SubstrateLifecyclePolicy
- SubstrateLaunchTarget
- SubstrateLaunch
- SubstrateDomain
- SubstrateRef
LauncherBackend
Section titled “LauncherBackend”Accepted values:
- inprocess
- shell
- container
- remote
Meaning: execution backend used by launcher infrastructure to invoke package launch target.
SubstrateLifecyclePolicy
Section titled “SubstrateLifecyclePolicy”Accepted values:
- dynamic
- static
Meaning: orchestration lifecycle mode for a substrate domain entry.
SubstrateLifecycleState
Section titled “SubstrateLifecycleState”Accepted values:
- starting
- ready
- degraded
- stopped
Meaning: observed runtime lifecycle state of a launched substrate instance.
Models
Section titled “Models”SubstrateLaunchTarget
Section titled “SubstrateLaunchTarget”Fields:
| Field | Type | Required | Constraints |
|---|---|---|---|
| module-path | str | yes | non-empty |
| symbol-name | str | yes | non-empty |
Purpose: import target that resolves the package launch callable.
SubstrateLaunch
Section titled “SubstrateLaunch”Fields:
| Field | Type | Required |
|---|---|---|
| launcher | LauncherBackend | yes |
| target | SubstrateLaunchTarget | yes |
SubstrateDomain
Section titled “SubstrateDomain”Fields:
| Field | Type | Required | Constraints |
|---|---|---|---|
| kind | str | yes | non-empty |
| definition-id | str | yes | non-empty |
| description | str | yes | non-empty |
| lifecycle-policy | SubstrateLifecyclePolicy | yes | enum |
| launch | SubstrateLaunch | yes | strict object |
| metadata | mapping | no | defaults to {} |
| body | str | no | defaults to “” |
SubstrateRef
Section titled “SubstrateRef”Fields:
| Field | Type | Required | Constraints |
|---|---|---|---|
| definition-id | str | yes | non-empty |
| ref | str | yes | non-empty |
SubstrateHandle
Section titled “SubstrateHandle”Fields:
| Field | Type | Required |
|---|---|---|
| definition_id | str | yes |
| instance_id | str | yes |
| healthy | bool | yes |
| lifecycle_state | SubstrateLifecycleState | yes |
Behavior:
- strict extra field rejection
- frozen model
- id property aliases instance_id
Runtime base class
Section titled “Runtime base class”Substrate
Section titled “Substrate”Constructor:
def __init__(self, *, definition_id: str, instance_id: str | None = None) -> NoneAbstract method:
def handle(self) -> SubstrateHandleRuntime methods:
- health() -> bool
- readiness() -> bool
- shutdown() -> None
Readiness rule:
- true only when healthy is true and lifecycle state is ready.
Shutdown rule:
- shutdown sets healthy false and lifecycle state stopped.
Launcher interface
Section titled “Launcher interface”SubstrateLauncher
Section titled “SubstrateLauncher”Launch signature:
def launch(self, domain: SubstrateDomain) -> SubstrateContract:
- accepts one substrate-domain config object
- returns one instantiated substrate runtime
Validation behavior
Section titled “Validation behavior”All domain contracts are strict and frozen:
- unknown fields rejected
- required text fields must be non-blank
- enum values must match exactly