Files
acdl/schemas/environment.schema.json
T
Jon Chery bee9d02f01 feat(P40): contract interpolation + environment JSON schema
---ci---
project: acdl
phase: 40
milestone: v1.9
status: execute
---/ci---

Phase 40 — contract-interpolation (REQ-103, REQ-104, D-081):

Interpolation:
- core/contract_resolver.py: _expand_vars(value, context) recursively
  expands ${env.<field>} + ${contract.<field>} tokens (dotted paths
  supported, e.g. ${env.state_backend.bucket}). Unknown tokens raise
  ValueError (fail loud). Expansion is post-schema-validation,
  pre-IR-resolution.
- resolve() accepts environment_override (D-088) — overrides the
  contract's environment field BEFORE schema validation so interpolation
  context is consistent.
- env context loaded via _load_env (self-contained, works as script +
  package import); 'environment' alias for env 'name' so
  ${env.environment} resolves.

Environment schema + bindings:
- schemas/environment.schema.json (draft 2020-12): name, account_id,
  region, state_backend, network, runner_role_arn, autonomy, confidence_threshold.
- core/environments/qa.json, prod.json, dr.json placeholder bindings
  (attested, thresholds 0.75/0.90/0.95, placeholder account_id with
  stderr warning at load).
- core/environment_check.py: load(env_name) helper + placeholder warning.

Sample contracts:
- contracts/static-assets.yaml + microservice.yaml use
  acdl-${env.environment}-${contract.module}-${env.account_id}-${env.region}
  naming pattern (region + account id + environment).

Tests: +35 (test_environment_schema.py, test_interpolation.py,
test_sample_contracts_interpolate.py). 406 passed; run_ci.sh green;
run_platform.sh --check-only green. Existing fixture-based tests
preserved (instance.json static fixtures unaffected).
2026-07-23 04:30:30 +00:00

58 lines
2.4 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://acdl.cloudinit.dev/schemas/environment.schema.json",
"title": "ACDL Platform-Managed Environment",
"description": "A named environment the platform owns (an AWS account or scoped partition, a network, a state backend, an IAM role surfaced to the consumer via ABAC). Selected by name in the contract's 'environment' field. The environment onboarding check (core/environment_check.py) loads the matching <name>.json; the contract resolver (core/contract_resolver.py) uses it as the 'env' context for ${env.<field>} interpolation.",
"type": "object",
"required": ["name", "account_id", "region", "state_backend", "network", "runner_role_arn", "autonomy", "confidence_threshold"],
"properties": {
"name": {
"type": "string",
"description": "The environment name (matches the filename without .json)."
},
"description": {
"type": "string",
"description": "Human-readable description."
},
"account_id": {
"type": "string",
"pattern": "^[0-9]{12}$",
"description": "The AWS account id (12 digits). The placeholder 000000000000 is allowed for unbound environments; environment_check emits a stderr warning when it appears for env != dev."
},
"region": {
"type": "string",
"description": "The AWS region (e.g. us-east-1)."
},
"state_backend": {
"type": "object",
"required": ["bucket", "lock_table"],
"properties": {
"bucket": {"type": "string", "description": "S3 state bucket name."},
"lock_table": {"type": "string", "description": "DynamoDB lock table name."}
}
},
"network": {
"type": "object",
"required": ["vpc_cidr", "azs"],
"properties": {
"vpc_cidr": {"type": "string", "description": "VPC CIDR block."},
"azs": {"type": "array", "items": {"type": "string"}, "description": "Availability zones."}
}
},
"runner_role_arn": {
"type": "string",
"description": "The IAM role ARN surfaced to the consumer's repo via ABAC."
},
"autonomy": {
"type": "string",
"enum": ["full", "attested"],
"description": "full = autonomous (dev); attested = HITL gates (qa/prod/dr)."
},
"confidence_threshold": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "The confidence gate threshold for this environment (dev 0.50, qa 0.75, prod 0.90, dr 0.95)."
}
}
}