Skip to main content

Runtime identity discovery and runtime context construction for Money Ex Machina.

Project description

mxm-runtime

Version License Python Checked with pyright

Runtime discovery, configuration-driven service construction, and RuntimeContext assembly for the Money Ex Machina ecosystem.

mxm-runtime is responsible for constructing the operational environment in which MXM applications execute.

It discovers runtime characteristics, loads and resolves configuration, constructs configured services, and assembles them into a single RuntimeContext.

Purpose

MXM applications require more than configuration files.

They require an operational environment:

Who am I?
Where am I running?
Which configuration applies?
Which services are available?
Where should data and artefacts live?

mxm-runtime answers these questions.

It exists to separate:

application code

from:

runtime discovery
configuration loading
service construction
deployment concerns
context assembly

Applications should not:

  • discover machine characteristics,
  • determine deployment substrate,
  • load configuration directly,
  • construct service APIs,
  • or reason about deployment topology.

Instead, applications receive a configured RuntimeContext:

context = build_runtime_context(
    identity=runtime_identity,
)

and consume the services and resources provided by that context.

Architecture

mxm-runtime acts as the runtime constructor layer of the MXM architecture.

RuntimeIdentity
    ↓
mxm-config
    ↓
Configuration Resolution
    ↓
Service Construction
    ↓
RuntimeContext
    ↓
Application

The package owns runtime construction.

It does not own configuration semantics or secret resolution semantics.

Those responsibilities belong to:

mxm-config

and:

mxm-secrets

respectively.

Core Concepts

RuntimeIdentity

Represents the operational identity of a running process.

Example:

app          mxm-moneymachine
environment  dev
machine      bridge
substrate    local-process
role         marketdata

Runtime identity determines which configuration layers are selected and which services are constructed.

Machine

A machine identifies a machine-specific configuration profile.

Examples:

bridge
monolith
wildling
scribe

Machine values are derived from operating-system characteristics and are used to select machine-specific configuration.

They are configuration selectors rather than unique hardware identifiers.

Substrate

Represents the execution substrate.

Examples:

local-process
docker

Substrate allows runtime construction to adapt to deployment environment differences.

RuntimeContext

Represents the fully constructed operational environment.

Current fields:

RuntimeContext(
    identity=...,
    config=...,
    secrets=...,
)

Future versions may additionally materialise:

paths
databases
reference data services
storage services
execution services
reporting services

Applications are expected to consume runtime services through RuntimeContext.

Runtime Construction Flow

Runtime construction follows the sequence:

RuntimeIdentity
    ↓
load_config(...)
    ↓
Configuration Views
    ↓
Service Construction
    ↓
RuntimeContext

For example:

context = build_runtime_context(
    identity=identity,
)

which currently materialises:

configuration
secret services

and returns a configured RuntimeContext.

Runtime Discovery

mxm-runtime provides discovery utilities for determining runtime characteristics.

Examples:

machine = discover_machine()
substrate = discover_substrate()

These functions derive MXM runtime selectors from operating-system facts.

The resulting values are suitable for configuration resolution and runtime construction.

Relationship To mxm-config

mxm-config owns:

configuration storage
configuration loading
configuration merging
configuration views

mxm-runtime consumes configuration and constructs runtime services from it.

Example:

RuntimeIdentity
    ↓
mxm-config
    ↓
MXMConfig
    ↓
RuntimeContext

Relationship To mxm-secrets

mxm-secrets owns:

secret references
authorization
resolution
retrieval

mxm-runtime constructs configured secret services and makes them available through RuntimeContext.

Applications are expected to consume:

context.secrets

rather than constructing SecretsApi instances directly.

Installation

pip install mxm-runtime

Usage

Construct a RuntimeContext:

from mxm.runtime import build_runtime_context

context = build_runtime_context(
    identity=identity,
)

Access configured services:

api_key = context.secrets.get_secret(
    "databento_api_key",
    identity=context.identity,
)

Design Principles

  • Explicit runtime identity Runtime identity is always represented explicitly.

  • Configuration-driven construction Runtime behaviour is determined through configuration rather than hardcoded wiring.

  • Separation of concerns Discovery, configuration, resolution, construction, and application logic remain separate.

  • Strict typing Fully Pyright-clean and PEP 561 compliant.

  • Minimal implicit behaviour Runtime construction is deterministic and inspectable.

  • Composable services Runtime services are assembled from independent packages.

Development

poetry install

make check

Run the RuntimeContext smoke test:

poetry run python scripts/smoke_runtime_context.py

Status

Current release status:

Runtime Identity Discovery Complete
RuntimeContext Construction Complete
Service Expansion In Progress

Current RuntimeContext materialises:

configuration
secrets

Additional services will be added incrementally.

License

MIT License. See LICENSE.

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

mxm_runtime-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

mxm_runtime-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file mxm_runtime-0.1.0.tar.gz.

File metadata

  • Download URL: mxm_runtime-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mxm_runtime-0.1.0.tar.gz
Algorithm Hash digest
SHA256 336ac26d794a8ca9e08c7ca246edfa85307c681501fb47ada60fb9dac86f81cb
MD5 aa436d9e363f97a66714d702f02bb428
BLAKE2b-256 e425369e8d9d2429ffb12cfb90673ed3cbf4e1e5e8beca7fbe960bfda28da07f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_runtime-0.1.0.tar.gz:

Publisher: release.yml on moneyexmachina/mxm-runtime

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mxm_runtime-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mxm_runtime-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mxm_runtime-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ace86b2bd8fae0b3475725b83a3f9f9153d5a63c9d58de78835e2e9f77a594b
MD5 920a9aa6a70fc2640c0b2602e37cafcb
BLAKE2b-256 d3e9e71647dda7756e26124b206c3427bc9592f42fa042288f5a2d2b35dfae26

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_runtime-0.1.0-py3-none-any.whl:

Publisher: release.yml on moneyexmachina/mxm-runtime

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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