refactor(P57): contract surface redesign + rename + .yml repo-wide

Contract surface redesign:
- New top-level fields: id (3-6 char acronym → stack.name), name (full → stack.title),
  infrastructure (map keyed by module name, replaces module:)
- Drop uses: field (dead reference; version pin lives in CI workflow uses: line)
- Drop top-level module/inputs (now nested under infrastructure map)
- Per-module optional version (defaults to latest published from registry)
- Multi-module contracts: one file deploys N modules in one pipeline run,
  resource IDs namespaced with module name to avoid collisions
- stack.schema.json: add optional title field for display name

Rename:
- pipelines/deploy.yaml → pipelines/contract.yml (declarative spec, not a pipeline)
- pipelines/ci.yaml → pipelines/ci.yml
- All 44 .yaml files → .yml repo-wide (contracts, module examples, kyverno policies)
- .acdl/contract.yaml → .acdl/contract.yml

Resolver (core/contract_resolver.py):
- Rewrite resolve() to loop infrastructure map, default version to latest,
  merge module fragments into one stack with namespaced resource IDs
- _latest_version() picks highest non-deprecated from registry
- _namespace_resources() prefixes IDs + rewrites ref: expressions for multi-module
- Single-module path: unprefixed IDs (backward compatible)

Verification:
- 494 tests pass (0 contract-shape failures)
- Local E2E passes (contract → resolver → adapter → local ECS HTTP 200 → outbox)

---ci---
project: acdl
phase: 57
milestone: v1.10.2
status: execute
---/ci---
This commit is contained in:
Jon Chery
2026-07-27 21:37:40 +00:00
parent 7f36df5610
commit 031887ec56
127 changed files with 1597 additions and 1100 deletions
+21 -21
View File
@@ -15,14 +15,14 @@ from core.contract_resolver import resolve
SCHEMA = json.loads((ROOT / "schemas" / "contract.schema.json").read_text())
PER_ENV_CONTRACTS = [
"contracts/static-assets.dev.yaml",
"contracts/static-assets.qa.yaml",
"contracts/static-assets.prod.yaml",
"contracts/static-assets.dr.yaml",
"contracts/microservice.dev.yaml",
"contracts/microservice.qa.yaml",
"contracts/microservice.prod.yaml",
"contracts/microservice.dr.yaml",
"contracts/static-assets.dev.yml",
"contracts/static-assets.qa.yml",
"contracts/static-assets.prod.yml",
"contracts/static-assets.dr.yml",
"contracts/microservice.dev.yml",
"contracts/microservice.qa.yml",
"contracts/microservice.prod.yml",
"contracts/microservice.dr.yml",
]
@@ -35,26 +35,26 @@ def test_per_env_contract_validates_against_schema(rel):
@pytest.mark.parametrize("rel", PER_ENV_CONTRACTS)
def test_per_env_contract_resolves(rel):
stack = resolve(str(ROOT / rel))
assert stack["stack"]["name"] in ("static-assets", "microservice")
assert stack["stack"]["name"] in ("assets", "msvc")
def test_static_assets_dev_has_dev_environment():
c = yaml.safe_load((ROOT / "contracts/static-assets.dev.yaml").read_text())
c = yaml.safe_load((ROOT / "contracts/static-assets.dev.yml").read_text())
assert c["environment"] == "dev"
def test_static_assets_qa_has_qa_environment():
c = yaml.safe_load((ROOT / "contracts/static-assets.qa.yaml").read_text())
c = yaml.safe_load((ROOT / "contracts/static-assets.qa.yml").read_text())
assert c["environment"] == "qa"
def test_static_assets_prod_has_prod_environment():
c = yaml.safe_load((ROOT / "contracts/static-assets.prod.yaml").read_text())
c = yaml.safe_load((ROOT / "contracts/static-assets.prod.yml").read_text())
assert c["environment"] == "prod"
def test_static_assets_dr_has_dr_environment():
c = yaml.safe_load((ROOT / "contracts/static-assets.dr.yaml").read_text())
c = yaml.safe_load((ROOT / "contracts/static-assets.dr.yml").read_text())
assert c["environment"] == "dr"
@@ -67,21 +67,21 @@ def test_per_env_contracts_use_interpolation():
def test_per_env_qa_resolves_to_qa_bucket_name():
stack = resolve(str(ROOT / "contracts/static-assets.qa.yaml"))
stack = resolve(str(ROOT / "contracts/static-assets.qa.yml"))
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
assert s3["inputs"]["bucket_name"] == "acdl-qa-static-assets-000000000000-us-east-1"
assert s3["inputs"]["bucket_name"] == "acdl-qa-assets-000000000000-us-east-1"
def test_per_env_prod_resolves_to_prod_bucket_name():
stack = resolve(str(ROOT / "contracts/static-assets.prod.yaml"))
stack = resolve(str(ROOT / "contracts/static-assets.prod.yml"))
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
assert s3["inputs"]["bucket_name"] == "acdl-prod-static-assets-000000000000-us-east-1"
assert s3["inputs"]["bucket_name"] == "acdl-prod-assets-000000000000-us-east-1"
def test_default_dev_contract_still_works():
"""The existing contracts/static-assets.yaml remains the dev default."""
c = yaml.safe_load((ROOT / "contracts/static-assets.yaml").read_text())
"""The existing contracts/static-assets.yml remains the dev default."""
c = yaml.safe_load((ROOT / "contracts/static-assets.yml").read_text())
assert c["environment"] == "dev"
stack = resolve(str(ROOT / "contracts/static-assets.yaml"))
stack = resolve(str(ROOT / "contracts/static-assets.yml"))
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
assert s3["inputs"]["bucket_name"] == "acdl-dev-static-assets-000000000000-us-east-1"
assert s3["inputs"]["bucket_name"] == "acdl-dev-assets-000000000000-us-east-1"