Skip to main content

MXM configuration loader and context resolver

Project description

mxm-config

Version License Python Checked with pyright

Purpose

mxm-config provides deterministic configuration resolution for Money Ex Machina (MXM) applications.

It resolves configuration from an external configuration store using a RuntimeIdentity, applies a fixed layering model, and returns a transparent and reproducible configuration view for the running application.

mxm-config is responsible for configuration resolution only.

It does not manage secrets, discover runtime identity, or own configuration storage.

Installation

pip install mxm-config

Usage

Loading configuration

from pathlib import Path

from mxm.config import load_config
from mxm.types import RuntimeIdentity

identity = RuntimeIdentity(
    app="mxm-moneymachine",
    environment="dev",
    machine="bridge",
    substrate="local-process",
    role="marketdata",
)

cfg = load_config(
    identity=identity,
    store_root=Path("~/mxm-config-store").expanduser(),
)

print(cfg.parameters.refresh_interval)
print(cfg.paths.output)

Using the default config store

from mxm.config import load_config

cfg = load_config(identity=identity)

By default, mxm-config resolves configuration from:

~/mxm-config-store

Design Principles

Separation of Concerns

Configuration, secrets, and runtime identity are separate concerns.

mxm-runtime
    discovers RuntimeIdentity

mxm-config
    resolves configuration

mxm-secrets
    resolves secrets

Determinism

Configuration resolution follows a fixed precedence order.

The same RuntimeIdentity and configuration store will always produce the same resolved configuration.

Transparency

Configuration is stored as plain YAML files.

Layer selection and merge order are explicit and inspectable.

Composability

Each configuration layer expresses a single concern.

Applications compose behavior through layering rather than duplication.

Configuration Store

mxm-config resolves configuration from an external configuration store.

The configuration store is the authoritative source of configuration data.

A typical store layout is:

mxm-config-store/
└── apps/
    └── <app_id>/
        ├── default.yaml
        ├── environment.yaml
        ├── machine.yaml
        ├── substrate.yaml
        └── role.yaml

The configuration store contains configuration data only.

Configuration resolution semantics belong to mxm-config.

Runtime Identity

Configuration selection is driven by a RuntimeIdentity.

RuntimeIdentity
├── app
├── environment
├── machine
├── substrate
└── role

Each identity dimension selects a configuration layer from the store.

Configuration Layers

Configuration is resolved by merging the following layers (lowest → highest precedence):

  1. default.yaml
  2. environment.yaml
  3. machine.yaml
  4. substrate.yaml
  5. role.yaml
  6. explicit overrides

For a runtime identity:

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

the resolver selects:

default.yaml
environment.yaml["dev"]
machine.yaml["bridge"]
substrate.yaml["local-process"]
role.yaml["marketdata"]

and merges them in order.

Python API

Loading configuration

cfg = load_config(
    identity=identity,
    store_root=Path("~/mxm-config-store"),
)

Explicit overrides

cfg = load_config(
    identity=identity,
    overrides={
        "parameters.refresh_interval": 60,
    },
)

Command-Line Interface

mxm-config --help

Example:

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

Development

make check

This runs:

  • Ruff (lint + import sorting)
  • Black (format check)
  • Isort (consistency check)
  • Pyright (type checking)
  • Pytest (tests)

Testing

make test

Tests run in isolated temporary directories and use temporary configuration stores.

Roadmap

  • Schema validation
  • Configuration provenance reporting
  • Configuration hashing
  • Layer introspection and diagnostics
  • RuntimeContext integration

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_config-0.6.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

mxm_config-0.6.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file mxm_config-0.6.0.tar.gz.

File metadata

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

File hashes

Hashes for mxm_config-0.6.0.tar.gz
Algorithm Hash digest
SHA256 4914064c28b1cf3f14d71e0971aab2e7aeb43a3b764a1cb17f8354cb76d9b21c
MD5 e789fd27db145a98c4219efa3b64e8f8
BLAKE2b-256 e530b4608626c7838c335ed0db7c2bb730d2a6611883428a5e9f0eaccc1adf9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_config-0.6.0.tar.gz:

Publisher: release.yml on moneyexmachina/mxm-config

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_config-0.6.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for mxm_config-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a3041bfb130f3b6a02fcd7cf9efa2d20e532522b8dd77952cb1e7ee4e27a556
MD5 26f860c3476b6fb38691b8a490829a13
BLAKE2b-256 908b16e478161f57ce525056d762c39e776fbcfb5120eaf500ceb0ca2a34d2e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_config-0.6.0-py3-none-any.whl:

Publisher: release.yml on moneyexmachina/mxm-config

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