Skip to main content

Reusable architecture metamodel and validators

Project description

architecture-metamodel

This repository is the standalone Python metamodel package for architecture governance across projects.

It is a library repository, not a downstream architecture-instance repository. Downstream repos are expected to import this package to validate their own architecture-instance YAML artifacts.

Authority Model

The authoritative machine-readable metamodel now lives under src/architecture_metamodel/.

  • The supported public contact surface is architecture_metamodel.api.
  • The Python package is the canonical source of truth for element schemas, declarative policy, parsing, graph behavior, validation, and derived-artifact generation.
  • Markdown, YAML, and PlantUML artifacts in metamodel/ are generated downstream artifacts, not hand-maintained structural sources.

Package Layout

src/architecture_metamodel/
  api.py
  enums.py
  issues.py
  aliases.py
  metadata/
  elements/
  rules/
  parsing/
  graph/
  validation/
  generation/
  tools/

Key organization rules:

  • api.py The only supported public API surface.
  • rules/ Declarative metamodel policy such as inverse relationships, target-type policy, required relationships, and recommended metadata.
  • metadata/ Shared reusable metadata blocks.
  • elements/ One module per metamodel element type.
  • parsing/ Canonical element registry and payload parsing.
  • graph/ Architecture graph container and YAML loading.
  • validation/ Executable validation passes and orchestration.
  • generation/ Deterministic derived-artifact generators for Markdown, PlantUML, and YAML reference outputs.
  • tools/ CLI-oriented tooling built on the canonical package API.

Generated Artifacts

Generated reference artifacts live under metamodel/:

  • metamodel/architecture_metamodel.md
  • metamodel/architecture_metamodel_overview.puml
  • metamodel/architecture_element_template.yaml
  • metamodel/architecture_valid_example.yaml

Generated public API documentation lives under docs/:

  • docs/public_api.md

These files are generated from the authoritative Python package and are clearly marked as generated.

Install

For local development:

python -m pip install -e ".[dev]"

For downstream-consumer usage:

python -m pip install architecture-metamodel

Quickstart

Validate a downstream architecture directory through the supported public API:

from architecture_metamodel.api import ArchitectureLoadError, validate_architecture_with_report

try:
    report = validate_architecture_with_report("architecture/instance_architecture")
except ArchitectureLoadError as exc:
    raise SystemExit(exc.to_dict())

if report.failed:
    raise SystemExit("\n".join(report.to_lines()))

print(report.overall_status)
print(report.to_json())

Validate a single YAML file:

from architecture_metamodel.api import validate_architecture_with_report

report = validate_architecture_with_report("architecture/instance_architecture/architecture.yaml")

Run the CLI validator:

architecture-validate path/to/architecture
architecture-validate path/to/architecture --format json

The CLI prints:

  • overall PASS / FAIL
  • total error and warning counts
  • successful validation checks
  • failed validation checks with issue detail

Stable exit codes:

  • 0 for validation pass
  • 1 for validation fail
  • 2 for load/input failure
  • 3 for unexpected adapter failure

Use the module entrypoint if preferred:

python -m architecture_metamodel.tools.validate_architecture path/to/architecture

A consumer-oriented example script is available at examples/consumer_validate.py.

The supported public API now provides a structured validation summary for downstream consumers:

  • report.overall_status
  • report.successful_checks
  • report.failed_checks
  • report.issues
  • report.to_lines()
  • report.to_dict()
  • report.to_json()
  • report.passed / report.failed

Load/input failures are raised as explicit exceptions instead of being returned as validation reports:

  • ArchitecturePathNotFoundError
  • ArchitecturePathTypeError
  • EmptyArchitectureError
  • NoArchitectureInputsError
  • ArchitectureParseError

Generated API reference:

  • see docs/public_api.md for the supported exports from architecture_metamodel.api
  • see docs/consumer_usage.md for API, CLI, and GitHub Action usage guidance

Generate all derived artifacts:

architecture-generate

Check whether generated artifacts are stale:

architecture-generate --check

Run release-oriented smoke checks:

architecture-release-check

This command builds a local wheel, installs it into a temporary consumer virtual environment, then exercises:

  • the supported public API from the installed package
  • the installed architecture-validate console script
  • the actual composite action definition in action.yml

Run categorized system tests and generate the markdown report artifact:

architecture-system-test run-all --json-dir test_reports/json --output-dir test_reports

Local Workflow

  • Make structural changes in Python under src/architecture_metamodel/.
  • Regenerate artifacts with architecture-generate.
  • Run the test suite with python -m unittest discover -s tests.
  • The categorized release-hardening test stack includes unit, integration, API contract, architectural boundary, and surface consistency coverage.
  • Run release smoke checks with architecture-release-check.
  • Optionally install pre-commit and enable the local hook:
python -m pre_commit install

The included pre-commit configuration runs the same repo-owned generation command used elsewhere.

CI Enforcement

GitHub Actions is split into three explicit workflows:

  • development.yml Runs on branch pushes, skips version-tag release behavior, and keeps feedback lighter by running:
    • artifact currency
    • unit tests
    • API contract tests
    • architectural boundary tests
  • pull-request.yml Runs on pull requests targeting main and acts as the full merge gate by running:
    • artifact currency
    • unit tests
    • integration tests
    • API contract tests
    • architectural boundary tests
    • surface consistency tests
    • markdown system-test report aggregation
    • architecture-release-check
  • release.yml Runs on version tag pushes matching v*, preserves the full validation/reporting path, and is explicitly validate-only. No package publication runs in this repository’s release workflow.

These workflows do not embed generation or validation logic beyond invoking the same repo-owned commands used locally.

Downstream Repository Consumption

Downstream architecture-instance repositories should treat this repo as an importable governing library.

Expected usage pattern:

  • install or depend on architecture-metamodel
  • author instance YAML in the downstream repo
  • invoke the library validator through the API or CLI
  • do not copy or fork the metamodel structure into the downstream repo as a separate source of truth

Example:

from architecture_metamodel.api import validate_architecture_with_report

report = validate_architecture_with_report("architecture/instance_architecture")
if report.failed:
    raise SystemExit("\n".join(report.to_lines()))

Scope of This Repository

This repository now owns:

  • the authoritative Python metamodel
  • declarative metamodel policy
  • validation behavior
  • deterministic generation of reference artifacts for this repo

This repository does not own:

  • downstream architecture-instance repositories
  • downstream repo-specific CI policy
  • downstream repo-local copies of the metamodel structure

Future Direction

Structural changes should originate in the Python models and propagate outward through generation. Future enhancements should continue to treat src/architecture_metamodel/ as the authority and the files in metamodel/ as deterministic derived outputs.

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

architecture_metamodel-1.0.1.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

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

architecture_metamodel-1.0.1-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

Details for the file architecture_metamodel-1.0.1.tar.gz.

File metadata

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

File hashes

Hashes for architecture_metamodel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e3c637dd7cd3c2bfa02d5d704210aa0bf682ddb956b3568d682bed9c02fe2a9f
MD5 5b3b4ddea0c2d68654e1e1ead66106e4
BLAKE2b-256 f75b91cb2617c2062978bdd15010209a39496d37eb57220325f52ea7c08e2159

See more details on using hashes here.

Provenance

The following attestation bundles were made for architecture_metamodel-1.0.1.tar.gz:

Publisher: release.yml on ndbach/architecture-metamodel

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

File details

Details for the file architecture_metamodel-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for architecture_metamodel-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5146423c33832fe593b99f1c70d0258821fa20997ec3fc295dc43885f171e6d4
MD5 26b2654e3de9a2ac780578ac9753d39e
BLAKE2b-256 b3ff7b35718b7cd6a8a7cf4e6ea2005c2c56bb051286d689dd202858a8d82464

See more details on using hashes here.

Provenance

The following attestation bundles were made for architecture_metamodel-1.0.1-py3-none-any.whl:

Publisher: release.yml on ndbach/architecture-metamodel

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