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:
+14
-14
@@ -24,21 +24,21 @@ def test_expand_env_dotted_path():
|
||||
assert _expand_vars("${env.state_backend.bucket}", ctx) == "acdl-dev-state"
|
||||
|
||||
|
||||
def test_expand_contract_module():
|
||||
ctx = {"env": {}, "contract": {"module": "static-assets"}}
|
||||
assert _expand_vars("${contract.module}", ctx) == "static-assets"
|
||||
def test_expand_contract_id():
|
||||
ctx = {"env": {}, "contract": {"id": "assets"}}
|
||||
assert _expand_vars("${contract.id}", ctx) == "assets"
|
||||
|
||||
|
||||
def test_expand_contract_dotted_path():
|
||||
ctx = {"env": {}, "contract": {"inputs": {"bucket_name": "acdl-x"}}}
|
||||
assert _expand_vars("${contract.inputs.bucket_name}", ctx) == "acdl-x"
|
||||
ctx = {"env": {}, "contract": {"infrastructure": {"s3": {"inputs": {"bucket_name": "acdl-x"}}}}}
|
||||
assert _expand_vars("${contract.infrastructure.s3.inputs.bucket_name}", ctx) == "acdl-x"
|
||||
|
||||
|
||||
def test_expand_nested_in_string():
|
||||
ctx = {"env": {"environment": "dev", "account_id": "000000000000", "region": "us-east-1"},
|
||||
"contract": {"module": "static-assets"}}
|
||||
result = _expand_vars("acdl-${env.environment}-${contract.module}-${env.account_id}-${env.region}", ctx)
|
||||
assert result == "acdl-dev-static-assets-000000000000-us-east-1"
|
||||
"contract": {"id": "assets"}}
|
||||
result = _expand_vars("acdl-${env.environment}-${contract.id}-${env.account_id}-${env.region}", ctx)
|
||||
assert result == "acdl-dev-assets-000000000000-us-east-1"
|
||||
|
||||
|
||||
def test_expand_recursive_in_dict():
|
||||
@@ -81,24 +81,24 @@ def test_expand_non_string_passthrough():
|
||||
|
||||
def test_resolve_static_assets_expands_bucket_name():
|
||||
"""Resolving the sample contract produces the interpolated bucket name."""
|
||||
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"
|
||||
assert s3["inputs"]["region"] == "us-east-1"
|
||||
|
||||
|
||||
def test_resolve_microservice_expands_bucket_name():
|
||||
stack = resolve(str(ROOT / "contracts" / "microservice.yaml"))
|
||||
stack = resolve(str(ROOT / "contracts" / "microservice.yml"))
|
||||
# The microservice L2 wires bucket_name to vpc.inputs.cidr (legacy wire);
|
||||
# the interpolated value is a valid CIDR-like string. The key assertion
|
||||
# is that resolution succeeds with interpolation (no unresolved tokens).
|
||||
assert stack["stack"]["name"] == "microservice"
|
||||
assert stack["stack"]["name"] == "msvc"
|
||||
|
||||
|
||||
def test_resolve_with_environment_override_uses_overridden_env():
|
||||
"""D-088: environment_override changes the interpolation context."""
|
||||
stack = resolve(str(ROOT / "contracts" / "static-assets.yaml"),
|
||||
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"),
|
||||
environment_override="qa")
|
||||
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
||||
# qa env: environment=qa, account_id=000000000000, region=us-east-1
|
||||
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"
|
||||
Reference in New Issue
Block a user