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.pyThe 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.mdmetamodel/architecture_metamodel_overview.pumlmetamodel/architecture_element_template.yamlmetamodel/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:
0for validation pass1for validation fail2for load/input failure3for 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_statusreport.successful_checksreport.failed_checksreport.issuesreport.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:
ArchitecturePathNotFoundErrorArchitecturePathTypeErrorEmptyArchitectureErrorNoArchitectureInputsErrorArchitectureParseError
Generated API reference:
- see
docs/public_api.mdfor the supported exports fromarchitecture_metamodel.api - see
docs/consumer_usage.mdfor 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-validateconsole 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.ymlRuns 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.ymlRuns on pull requests targetingmainand 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.ymlRuns on version tag pushes matchingv*, 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file architecture_metamodel-0.1.0.tar.gz.
File metadata
- Download URL: architecture_metamodel-0.1.0.tar.gz
- Upload date:
- Size: 37.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6167f7e91c111075ab2df53095dec01a1acf1823047b4cf8ba41238b9dbaffd
|
|
| MD5 |
9209582c132890465a069e34ccfe9034
|
|
| BLAKE2b-256 |
8d8a2e2691fe75580bc51bddc1a144fd75bec35e0db07abba47a5cffac13b15e
|
File details
Details for the file architecture_metamodel-0.1.0-py3-none-any.whl.
File metadata
- Download URL: architecture_metamodel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 58.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac6b8edf0df4c09ad30e9ea9d24eb9a21d3c13bf7d7f10604349e5c8b8e87aa6
|
|
| MD5 |
87a8e4fbba4c56cee57442b464e6817a
|
|
| BLAKE2b-256 |
67cf30530039d7553ea63a12da6a8a522ff74b3b7c878f76961738cb6aadc8d3
|