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
+22 -17
View File
@@ -2,9 +2,9 @@
# scripts/run_platform.sh - the ACDL platform pipeline.
#
# Usage:
# run_platform.sh <contract.yaml> (full e2e with AWS)
# run_platform.sh --check-only [contract.yaml] (offline, no AWS/Checkov/DynamoDB)
# run_platform.sh --plan-only <contract.yaml> (AWS plan only, no Checkov/outbox)
# run_platform.sh <contract.yml> (full e2e with AWS)
# run_platform.sh --check-only [contract.yml] (offline, no AWS/Checkov/DynamoDB)
# run_platform.sh --plan-only <contract.yml> (AWS plan only, no Checkov/outbox)
#
# Modes:
# --check-only (offline, no AWS/Checkov/DynamoDB — for CI)
@@ -29,7 +29,7 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# Capture the caller's CWD before we cd to ROOT. The reusable deploy workflow
# invokes this script from the CONSUMER repo's workspace root with a relative
# contract path (e.g. .acdl/contract.yaml); the contract must resolve against
# contract path (e.g. .acdl/contract.yml); the contract must resolve against
# the consumer repo, not the platform repo (platform/). Without this, the
# `[ -f "$CONTRACT" ]` check below looks for the contract inside the platform
# repo and fails (P0 fix — see docs/CONSUMER_GUIDE.md Step 4).
@@ -89,9 +89,9 @@ fi
# Default contract for --check-only (CI uses this)
if [ -z "$CONTRACT" ]; then
if [ "$CHECK_ONLY" = "1" ]; then
CONTRACT="contracts/static-assets.yaml"
CONTRACT="contracts/static-assets.yml"
else
echo "FAIL: contract file required (usage: run_platform.sh <contract.yaml>)" >&2
echo "FAIL: contract file required (usage: run_platform.sh <contract.yml>)" >&2
exit 1
fi
fi
@@ -102,7 +102,7 @@ fail() { echo "FAIL: $*" >&2; exit 1; }
# No AWS credentials, no Checkov, no DynamoDB. Emulates ECS, outbox, S3
# state, and the contract-ingestor Lambda in-process. Exits 0 on success.
if [ "$LOCAL_TIER" = "1" ]; then
[ -n "$CONTRACT" ] || CONTRACT="contracts/microservice.yaml"
[ -n "$CONTRACT" ] || CONTRACT="contracts/microservice.yml"
echo "=== ACDL Local Emulating Tier (D-092) ==="
echo "contract: $CONTRACT (no AWS credentials required)"
echo ""
@@ -156,7 +156,7 @@ import json, yaml, jsonschema
schema = json.load(open('schemas/contract.schema.json'))
contract = yaml.safe_load(open('$CONTRACT'))
jsonschema.validate(contract, schema)
print(f'contract: module={contract[\"module\"]} env={contract[\"environment\"]} inputs={list(contract.get(\"inputs\",{}).keys())}')
print(f'contract: id={contract[\"id\"]} env={contract[\"environment\"]} modules={list(contract.get(\"infrastructure\",{}).keys())}')
"
# Decommission mode: validate change request, disable deletion protection, zero counts
@@ -164,7 +164,7 @@ if [ "$DECOMMISSION" = "1" ]; then
echo ""
echo "=== Decommission Step 1: validate change request against CMDB ==="
[ -n "$CHANGE_REQUEST_ID" ] || fail "change request ID required for decommission mode"
CONSUMER_REPO="${GITHUB_REPOSITORY:-$(python3 -c "import yaml; c=yaml.safe_load(open('$CONTRACT')); print(c.get('module','unknown'))" 2>/dev/null || echo 'unknown')}"
CONSUMER_REPO="${GITHUB_REPOSITORY:-$(python3 -c "import yaml; c=yaml.safe_load(open('$CONTRACT')); print(c.get('id','unknown'))" 2>/dev/null || echo 'unknown')}"
python3 -c "
import json, sys
sys.path.insert(0, '$ROOT')
@@ -462,22 +462,27 @@ for name, spec in outputs.items():
})
# Build the uptime contract
uptime_contract = {
'uses': 'acdl/pipelines/deploy.yaml@v1.8',
'module': 'uptime',
'id': 'uptime',
'name': 'uptime-monitoring',
'environment': 'dev',
'inputs': {
'region': 'us-east-1',
'feature_flag_enabled': True,
'monitored_endpoints': endpoints,
'infrastructure': {
'uptime': {
'version': '1.0.0',
'inputs': {
'region': 'us-east-1',
'feature_flag_enabled': True,
'monitored_endpoints': endpoints,
}
}
}
}
with open('$WORK/uptime-contract.yaml', 'w') as f:
with open('$WORK/uptime-contract.yml', 'w') as f:
yaml.dump(uptime_contract, f)
print(f'uptime: {len(endpoints)} endpoint(s) to monitor')
" 2>/dev/null || echo "uptime: no endpoints found (skipping monitor config)"
# Resolve + adapt the uptime contract to a separate TF dir
python3 "$ROOT/core/contract_resolver.py" "$WORK/uptime-contract.yaml" "$WORK/uptime-stack.json" 2>/dev/null || true
python3 "$ROOT/core/contract_resolver.py" "$WORK/uptime-contract.yml" "$WORK/uptime-stack.json" 2>/dev/null || true
python3 "$ROOT/adapters/terraform/adapter.py" "$WORK/uptime-stack.json" "$UPTIME_DIR" 2>/dev/null || true
if [ "$DEPLOY_UPTIME" = "1" ] && [ -f "$UPTIME_DIR/main.tf" ]; then