Skip to main content

Shared infrastructure (typed exceptions, central config, structured logging + tracing) for MGF projects

Project description

mgf-common

PyPI version Python versions License: MIT Typed: PEP 561

The cornerstone library for the Magogi ecosystem. Typed exceptions + layered configuration + structured logging + OTel + crash reporting + vault + process management — the pure-Python infrastructure every Magogi project needs, in one PEP 561 typed package. Framework adapters (FastAPI, Django, SQLAlchemy, Alembic, HTTP) ship as separate mgf-* sibling packages that depend on this cornerstone. The engineering standards + the federation contract live in the mgf-doc-standard sibling — mgf-common depends on it and surfaces the rules via mgf-common standards; see FEDERATION.md.

Status: pre-1.0 (current 0.42.0). API stable enough that four real consumers (vm-vmanager-app Qt desktop, inthewords Django, PlasmaMapper FastAPI, iosRecovery CLI) ship with it. Public names are experimental per AP-11; promoted to stable after one full MINOR cycle without a 🔴 Blocker filed against them.

If you depend on mgf-common, read FEDERATION.md first. It is the canonical contract — required docs layout, standards-conformance levels, federation-first principle, catch-up cadence, and feedback discipline. One page; you'll be aligned with the federation by the end of it.

Conformance: L3 per the standards in mgf-doc-standard (read any rule with mgf-common standards <topic>). As the cornerstone + reference implementation, every MUST and SHOULD rule applies here, with run-time enforcement wired up (audit-logs, redaction). The L1/L2/L3 contract is defined in FEDERATION.md §4.


Pick your starting point

The docs are organised by audience. Pick one:

If you are… Read
Evaluating mgf-common (right library for me?) docs/audience/shoppers.md
Building with it (already adopted) docs/audience/users.md
Contributing or designing alongside docs/audience/developers.md
A test/QA engineer docs/audience/qa.md
Cutting releases / running CI docs/audience/release.md
Doing a security review docs/audience/security.md
An AI agent (Claude or other) Run mgf-common agents — the canonical briefing (also in STARTHERE.md §"For the AI agent") — then docs/audience/ai-agents.md for the feedback-relay protocol

If you don't fit any of these neatly: docs/audience/README.md is the meta-routing index.

If you just want to try it: see docs/tutorial.md (zero → working app in ~30 minutes).


At a glance

import mgf.common as mc

with mc.bootstrap(app_name="myapp", app_version="1.0") as ctx:
    # identity + logging + OTel + excepthooks all wired transactionally
    do_work()
# Clean shutdown on context-exit; LIFO rollback on any startup failure.
from mgf.common.process import Service, AllOf, PortReady, LogLineReady

with Service(
    ["postgres", "-D", str(db_dir), "-p", str(port)],
    ready=AllOf([
        PortReady("127.0.0.1", port),
        LogLineReady(r"database system is ready"),
    ]),
    timeout_s=20.0,
) as svc:
    run_my_integration_tests(port=port)
# Service stopped + process group cascaded on context-exit.

More: docs/recipes/ (cookbook patterns) and PUBLIC_API.md (full surface).


Top-level files

File Purpose
STARTHERE.md Two-flow navigation hub (new project vs catching up an existing one)
FEEDBACK.md Living queue of consumer-filed feedback (the relay process driver)
CHANGELOG.md Per-release short-form (Keep-a-Changelog format)
PUBLIC_API.md Full public surface, table-form
PUBLIC_API.json Auto-generated machine-readable surface
SECURITY.md Vulnerability reporting policy (per SC-12)
CONTRIBUTING.md Dev setup + the four green gates + PR process

Consumers using it today

  • vm-vmanager-app — Qt desktop, libvirt VM toolkit (reference consumer; co-designed)
  • inthewords — Django web app (canonical web consumer)
  • PlasmaMapper — FastAPI multi-tenant platform (heaviest sibling adopter)
  • iosRecovery — CLI recovery tool (greenfield canary consumer)

See USERS.md §2 for the full federation roster, and FEDERATION.md for the cornerstone / sibling / consumer model.


License

MIT. 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

mgf_common-0.44.2.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

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

mgf_common-0.44.2-py3-none-any.whl (375.3 kB view details)

Uploaded Python 3

File details

Details for the file mgf_common-0.44.2.tar.gz.

File metadata

  • Download URL: mgf_common-0.44.2.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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 mgf_common-0.44.2.tar.gz
Algorithm Hash digest
SHA256 52361ccf2815149e832403461387d3d7d087a76ab93a47baa954c0c9f1e73d05
MD5 b18755ee24d52bf94c3b1e4948f4e10e
BLAKE2b-256 f0284d97b15859ae79697a82f33d38b55f0fd495c50f9f5234700a8f733e3f5e

See more details on using hashes here.

File details

Details for the file mgf_common-0.44.2-py3-none-any.whl.

File metadata

  • Download URL: mgf_common-0.44.2-py3-none-any.whl
  • Upload date:
  • Size: 375.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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 mgf_common-0.44.2-py3-none-any.whl
Algorithm Hash digest
SHA256 55e8c962e7c16cbb992a69a360492840a727049c6cd9232c4a13e92233dd3080
MD5 d7da9ca9235dcdf42233c5bcb19e881a
BLAKE2b-256 417e1429f412b201359c85c36b04109c4bace45cafa04dd2d3ec3c15ea896416

See more details on using hashes here.

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