Compare commits

..

6 Commits

Author SHA1 Message Date
Jon Chery 5a3ab5e86b ship: phase-13 l1-catalog-for-ecs (v1.2.3)
---ci---
project: acdl
phase: 13
milestone: v1.2
status: shipped
release:
  tag: v1.2.3
requirements:
  covered: [REQ-31]
---/ci---

Phase 13 shipped: 6 ECS L1s + adapter generalization. REQ-31 verified.
- 6 new IR-typed L1s: l1-vpc, l1-ecs-cluster, l1-ecs-service, l1-iam-role, l1-alb, l1-ecr.
- Registry updated (8 entries: 7 L1s + l2-static-asset).
- Adapter generalized: TYPE_MAP (12 IR types) + INPUT_MAP + OUTPUT_MAP (table-driven).
- S3 regression: v1.1 spike l1-s3 produces byte-identical main.tf.
Phase 14 (l2-microservice-and-contract-schema) next.
2026-07-21 21:05:52 +00:00
Jon Chery 4ed2542ecf docs(P13): plan-as-execute + verify (v1.2.3)
---ci---
project: acdl
phase: 13
milestone: v1.2
status: verify
verdict: VERIFIED
requirements:
  covered: [REQ-31]
---/ci---

Phase 13 plan-as-execute + verify. scripts/verify_phase13.sh green.
6 ECS L1s authored + registered (l1-vpc, l1-ecs-cluster, l1-ecs-service,
l1-iam-role, l1-alb, l1-ecr). Adapter generalized to table-driven
TYPE_MAP (12 IR types) + INPUT_MAP + OUTPUT_MAP. S3 regression: the v1.1
spike l1-s3 produces byte-identical main.tf. Ready to ship v1.2.3.
2026-07-21 21:05:48 +00:00
Jon Chery 4c8de8e962 docs(P12): post-ship traceability + roadmap update (v1.2.2)
---ci---
project: acdl
phase: 12
milestone: v1.2
status: shipped
---/ci---

Post-ship: ROADMAP.md Phase 12 -> complete (v1.2.2); REQUIREMENTS.md
REQ-30 -> complete (v1.2.2).
2026-07-21 21:02:08 +00:00
Jon Chery 599db2e80d ship: phase-12 nfr-harden-and-simplify (v1.2.2)
---ci---
project: acdl
phase: 12
milestone: v1.2
status: shipped
release:
  tag: v1.2.2
requirements:
  covered: [REQ-30]
---/ci---

Phase 12 shipped: NFR harden + simplify. REQ-30 verified.
- run_spike_*.sh consolidated -> run_platform.sh (D-048, --plan-only flag).
- spike_runner_policy.json expanded for ECS (least-privilege, ready for Phase 15).
- Bootstrap idempotency documented.
- P1-1 closed: no live AWS key IDs in .ciagent/.
- P1-B closed: PERSONAS.md stale platform/ path fixed.
Phase 13 (l1-catalog-for-ecs) next.
2026-07-21 21:01:57 +00:00
Jon Chery 0fea29cdbb docs(P12): plan-as-execute + verify (v1.2.2)
---ci---
project: acdl
phase: 12
milestone: v1.2
status: verify
verdict: VERIFIED
requirements:
  covered: [REQ-30]
---/ci---

Phase 12 plan-as-execute + verify. scripts/verify_phase12.sh green (22
assertions). All Wave 1 + Wave 2 tasks complete:
- T-12.1: run_spike_*.sh -> run_platform.sh (D-048, --plan-only flag)
- T-12.2: spike_runner_policy.json expanded (ECS + ECR + ELB + IAM + EC2)
- T-12.3: idempotency documented in bootstrap scripts
- T-12.4: P1-1 redacted (no live AWS key IDs in .ciagent/)
- T-12.5: P1-B fixed (PERSONAS.md platform/registry -> modules-ir/registry.json)
Subagent confirmed run_platform.sh --plan-only runs against real AWS, exit 0.
Ready to ship v1.2.2.
2026-07-21 21:01:51 +00:00
Jon Chery 7ee57aa6c7 docs(P11): post-ship traceability + roadmap update (v1.2.1)
---ci---
project: acdl
phase: 11
milestone: v1.2
status: shipped
---/ci---

Post-ship: ROADMAP.md Phase 11 -> complete (v1.2.1); REQUIREMENTS.md
REQ-29 -> complete (v1.2.1).
2026-07-21 20:58:01 +00:00
31 changed files with 1194 additions and 150 deletions
+1 -1
View File
@@ -208,7 +208,7 @@ All 45 ci-block commits close the block with `---/ci---` (the documented closing
| ID | Item | Severity | File / location | Fix |
|----|------|----------|-----------------|-----|
| **P1-1** (carried-forward from REVIEW.md) | Two AWS access key IDs (`AKIAYOZHMKZ7RK26N66W` rotated spike key, `AKIAYOZHMKZ772SINHFX` deactivated root key) appear in `.ciagent/VERIFY.md` Phase 09 narrative. **Public identifiers, not secret pairs.** They live in the `.ciagent/` audit narrative, not in any executable code path. | P1 (non-blocking) | `.ciagent/VERIFY.md` Phase 09 narrative | Replace with placeholders `AKIA…SPIKE` / `AKIA…ROOT-DEACTIVATED` in a v1.2 redaction pass. |
| **P1-1** (carried-forward from REVIEW.md) | Two AWS access key IDs (`AKIA…SPIKE` rotated spike key, `AKIA…ROOT-DEACTIVATED` deactivated root key) appeared in `.ciagent/VERIFY.md` Phase 09 narrative. **Public identifiers, not secret pairs.** They lived in the `.ciagent/` audit narrative, not in any executable code path. | P1 (non-blocking) | `.ciagent/VERIFY.md` Phase 09 narrative (v1.1) | **Redacted in v1.2 Phase 12** to placeholders `AKIA…SPIKE` / `AKIA…ROOT-DEACTIVATED` across `.ciagent/RESEARCH.md`, `PROJECT.md`, `REVIEW.md`, `AUDIT.md`. The original VERIFY.md instances were overwritten by Phase 11's VERIFY.md. |
| **P1-A** (audit-new) | `config.json` line 8 `"status": "specify"` is stale — the milestone is `complete` (v1.2.0 shipped). | P1 (non-blocking) | `.ciagent/config.json:8` | Update to `"status": "complete"` (or `"shipped"`) in v1.2 cleanup. |
| **P1-B** (audit-new) | `PERSONAS.md` territory paths (lines 7, 38, 47, 56, 80, 109) reference the stale `platform/...` prefix instead of the renamed `acdl_platform/...`. The rename happened in Phase 08 prep (commit 727c873). The verification toolchain line 7 also has the stale `platform/**/*.py` glob. Non-blocking: each PLAN.md overrides the toolchain per-phase, and territories are descriptive (enforcement mode = `warn`). | P1 (non-blocking) | `.ciagent/PERSONAS.md` lines 7, 38, 47, 56, 80, 109 | Replace `platform/` with `acdl_platform/` in v1.2 cleanup. |
| **P1-C** (audit-new, observation) | 3 pre-specify upstream-doc ingestion commits (`52665b8 Add docs/architecture.md`, `7614c41 Add docs/vision.md`, `b84a8a2 Update docs/architecture.md`) carry no `---ci---` block. They predate the v1.1 specify stage (each is an ancestor of the specify commit 288607b). They fall inside the `v1.1.0..HEAD` audit range only because the `v1.1.0` tag is placed at the v1.0 Phase 05 traceability commit (58adf9e) rather than the v1.0 complete commit (80ac975). | P1 (non-blocking, process note) | tag placement + run.md | Document in run.md that the milestone-complete tag should be placed on the milestone-complete commit to exclude the transition-window commits from the next milestone's audit range. No file change needed for v1.1; v1.2 should pick the tag placement deliberately. |
+1 -1
View File
@@ -44,7 +44,7 @@ verification_toolchain:
- **Phase-specific:** false
- **Frameworks:** terraform, aws-iam, aws-s3, aws-dynamodb, oidc, json-schema
- **Constraints:** ir-is-substrate-agnostic, adapter-is-only-substrate-specific-code, state-in-s3+dynamodb-single-region, oidc-only-no-long-lived-keys (waiver D-034 for bootstrap), terraform-plan-only-in-spike
- **Territory:** `adapters/terraform/**`, `modules-ir/**`, `terraform/**` (state backend, provider config), `platform/registry/**`
- **Territory:** `adapters/terraform/**`, `modules-ir/**`, `terraform/**` (state backend, provider config), `modules-ir/registry.json`
- **Reason:** Owns the Target Stack IR, the L1/L2 IR-typed modules, the Terraform adapter, the AWS OIDC bootstrap, and the state backend. The IR is substrate-agnostic; the adapter is the only substrate-specific code (the binding constraint per §12).
### security-engineer (custom)
+47 -33
View File
@@ -1,49 +1,63 @@
---
phase: 11
name: v1.2-research-and-readme
phase: 13
name: l1-catalog-for-ecs
milestone: v1.2
requirements: [REQ-29]
type: docs
branch: phase/11-v1.2-research-and-readme
requirements: [REQ-31]
type: feat
branch: phase/13-l1-catalog-for-ecs
---
# Phase 11v1.2-research-and-readme (v1.2) PLAN
# Phase 13l1-catalog-for-ecs (v1.2) PLAN
## Goal
Re-evaluate go-gitea/gitea#36988 (OIDC); audit the v1.1 spike for NFR gaps
+ simplification opportunities; rewrite README.md to reflect v1.1 complete
+ the actual platform flow + v1.2 objective.
Author six IR-typed L1 modules for an ECS Fargate microservice and expand
the Terraform adapter's `TYPE_MAP` to compile them. Each L1 has an
`interface.json` valid against `schemas/ir.schema.json`, is registered in
`modules-ir/registry.json`, and produces a valid `terraform plan`
fragment via the adapter. The adapter must be generalized from
S3-specific to handle arbitrary IR types via the TYPE_MAP + per-type
input/output maps.
## Tasks (single wave — docs territory)
## Tasks
### T-11.1 — RESEARCH.md v1.2 addendum (REQ-29)
- TARGET 9: #36988 re-check → D-047 (extend D-039 waiver).
- TARGET 10: NFR audit of spike (IAM, idempotency, error handling, P1-1, stale paths).
- TARGET 11: Simplification opportunities (script consolidation D-048).
- TARGET 12: README rewrite plan.
- TARGET 13: ECS L1 catalog scoping (D-049) for Phase 13.
- Decisions surfaced: D-047, D-048, D-049.
- Territory: `.ciagent/RESEARCH.md`
### Wave 1 — Generalize the adapter (T-13.1, backend-engineer)
### T-11.2 — README.md rewrite (REQ-29)
- Status section: v1.2 active, v1.1 complete (tag v1.2.0), v1.0 archived.
- "How the platform works": the spike flow diagram + the IR commitments claim.
- "What's different in v1.2": 6 L1s, l2-microservice, terraform apply, consumer repo, run_platform.sh, NFR hardening.
- "How to run": prerequisites, bootstrap, rotate, run_spike_e2e.sh, demo.
- Repo layout table (refreshed Status column).
- Environments table (dev/qa/prod/dr + status).
- Credentials section (D-034 closed, D-039/D-047 waiver, #36988 link).
- Territory: `README.md`
Expand `adapters/terraform/adapter.py`:
- `TYPE_MAP`: add all 9 new IR types (aws:ec2:vpc, aws:ec2:subnet, aws:ec2:routetable, aws:ecs:cluster, aws:ecs:service, aws:ecs:task_definition, aws:iam:role, aws:elbv2:loadbalancer, aws:elbv2:listener, aws:elbv2:targetgroup, aws:ecr:repository).
- Replace S3-specific `_emit_resource` with a generic emitter using `TYPE_MAP` + `INPUT_MAP` (IR input → TF arg, default identity) + `OUTPUT_MAP` (IR output → TF attr).
- String inputs quoted; numbers/booleans bare.
- Keep S3 behavior identical (v1.1 spike regression check).
- Keep `providers.tf` + `terraform.tf` as-is.
### Wave 2 — 6 L1 modules + registry (T-13.2, backend-engineer, D-049)
Create under `modules-ir/l1/`: `l1-vpc`, `l1-ecs-cluster`, `l1-ecs-service`, `l1-iam-role`, `l1-alb`, `l1-ecr`. Each with `interface.json` + `README.md`. Register all 6 in `modules-ir/registry.json` at 1.0.0.
| L1 | IR type(s) | Terraform resource | Key inputs | Key outputs |
|----|-----------|-------------------|-----------|------------|
| l1-vpc | aws:ec2:vpc, aws:ec2:subnet, aws:ec2:routetable | aws_vpc, aws_subnet, aws_route_table, aws_internet_gateway, aws_route | cidr, azs | vpc_id, subnet_ids, igw_id |
| l1-ecs-cluster | aws:ecs:cluster | aws_ecs_cluster | name | cluster_arn, cluster_id |
| l1-ecs-service | aws:ecs:service, aws:ecs:task_definition | aws_ecs_service, aws_ecs_task_definition | image, port, cpu, memory, env, cluster_arn, subnets, sg, lb_target_group | service_arn, task_def_arn |
| l1-iam-role | aws:iam:role | aws_iam_role, aws_iam_role_policy_attachment | role_name, assume_role_policy, managed_policies | role_arn, role_id |
| l1-alb | aws:elbv2:loadbalancer, aws:elbv2:listener, aws:elbv2:targetgroup | aws_lb, aws_lb_listener, aws_lb_target_group | name, subnets, sg, port, protocol | lb_arn, listener_arn, target_group_arn |
| l1-ecr | aws:ecr:repository | aws_ecr_repository | name | repository_url, repository_arn |
Multi-resource L1s (vpc, ecs-service, alb): `interface.json` declares the group's inputs/outputs + a `resources` array listing the IR types it emits.
### Wave 3 — Verify (T-13.3)
For each L1: adapter + `terraform validate` on the generated TF (syntax check; full AWS plan is Phase 15). v1.1 spike regression: `l1-s3` still adapts correctly.
## Verification
- `grep -c "v1.2" README.md` ≥ 5 (v1.2 referenced throughout).
- `grep "v1.1 (active)" README.md` returns nothing (no stale framing).
- `.ciagent/RESEARCH.md` has a "## v1.2 Research Addendum" section.
- D-047/D-048/D-049 present in the addendum's decisions table.
- `scripts/verify_phase11.sh` (authored in the verify step).
- All 6 `interface.json` validate against `schemas/ir.schema.json`.
- `modules-ir/registry.json` lists all 6 at 1.0.0.
- `adapter.py` `TYPE_MAP` has all new IR types.
- v1.1 spike `l1-s3` regression: adapter output unchanged.
- Each L1's adapter output passes `terraform validate`.
- `scripts/verify_phase13.sh`.
## Ship
Merge `phase/11-v1.2-research-and-readme``main` (--no-ff). Tag `v1.2.1`.
Merge `phase/13-l1-catalog-for-ecs``main` (--no-ff). Tag `v1.2.3`.
+1 -1
View File
@@ -231,7 +231,7 @@ decisions:
| ID | Decision | Rationale | Outcome |
|----|----------|-----------|---------|
| D-034 | Temporary long-lived AWS key (waiver) used once in Phase 08 to bootstrap the state backend + IAM user; rotated/deactivated immediately after | §12.5 forbids long-lived creds; the bootstrap needed one `aws iam` call before the spike user + rotated key could take over | Spike achieves real `terraform plan` against AWS without violating the locked target after bootstrap. **CLOSED 2026-07-21: root key `AKIAYOZHMKZ772SINHFX` deactivated by the user in the AWS IAM console (verified — `InvalidClientTokenId`); the spike uses the rotated `acdl-spike-runner` key per D-039.** |
| D-034 | Temporary long-lived AWS key (waiver) used once in Phase 08 to bootstrap the state backend + IAM user; rotated/deactivated immediately after | §12.5 forbids long-lived creds; the bootstrap needed one `aws iam` call before the spike user + rotated key could take over | Spike achieves real `terraform plan` against AWS without violating the locked target after bootstrap. **CLOSED 2026-07-21: root key `AKIA…ROOT-DEACTIVATED` deactivated by the user in the AWS IAM console (verified — `InvalidClientTokenId`); the spike uses the rotated `acdl-spike-runner` key per D-039. Key ID redacted in v1.2 Phase 12 (P1-1).** |
| D-035 | Milestone version = `v1.1` (feature), ship tag `v1.2.0` | Real platform is a breaking reframing of the demo, but treated as the next incremental milestone per user choice; ship.md: feature milestone → next minor | Tag `v1.2.0` on milestone COMPLETE |
| D-036 | Spike picks `l1-s3` + `l2-static-asset` | Simplest real AWS resource (no IAM/network deps); smallest real `terraform plan`; proves the IR + adapter end-to-end | Spike scope fixed |
| D-037 | Demo archived to `demo/` (not deleted) | Preserves the working v1.0 demo as intent reference; new platform layout under `platform/`, `schemas/`, `adapters/`, `terraform/`, `modules-ir/` | No churn on demo code; clean separation |
+2 -2
View File
@@ -166,8 +166,8 @@
| Requirement | Phase | Status |
|-------------|-------|--------|
| REQ-29 | 11 | planned |
| REQ-30 | 12 | planned |
| REQ-29 | 11 | complete (v1.2.1) |
| REQ-30 | 12 | complete (v1.2.2) |
| REQ-31 | 13 | planned |
| REQ-32 | 14 | planned |
| REQ-33 | 15 | planned |
+6 -5
View File
@@ -1395,11 +1395,12 @@ good. `run_spike_plan.sh` uses `set -u` + inline exits — adequate. The
consolidated `run_platform.sh` should use `set -euo pipefail` + `fail()`
for uniform strictness.
**P1-1 redaction target**: `.ciagent/VERIFY.md` lines 9396, 170 reference
two AWS access key IDs (`AKIAYOZHMKZ7RK26N66W` rotated spike key,
`AKIAYOZHMKZ772SINHFX` deactivated root key). Public identifiers, not
secret pairs, in the audit narrative not executable code. **Phase 12
redacts** them to `AKIA…SPIKE` / `AKIA…ROOT-DEACTIVATED`.
**P1-1 redaction target (Phase 12 — DONE)**: the v1.1 `.ciagent/` audit
narrative referenced two AWS access key IDs (`AKIA…SPIKE` rotated spike
key, `AKIA…ROOT-DEACTIVATED` deactivated root key). Public identifiers,
not secret pairs, in the audit narrative not executable code. **Phase 12
redacted** them to `AKIA…SPIKE` / `AKIA…ROOT-DEACTIVATED` across
`.ciagent/RESEARCH.md`, `PROJECT.md`, `REVIEW.md`, `AUDIT.md`.
**P1-B stale paths**: `.ciagent/PERSONAS.md` line 47 still has
`platform/registry/**` (the rest were fixed at `ab69d10`). **Phase 12
+4 -4
View File
@@ -132,10 +132,10 @@ secrets in commits. All clean.
### P1 (carried-forward, NOT auto-fixed)
- **P1-1:** The `.ciagent/VERIFY.md` Phase 09 narrative contains two AWS access
key IDs — `AKIAYOZHMKZ7RK26N66W` (the rotated spike key id) and
`AKIAYOZHMKZ772SINHFX` (the deactivated root key id). Confirmed still present
(`grep -c` returns 2). These are **public identifiers, not secret pairs**;
- **P1-1:** The `.ciagent/VERIFY.md` Phase 09 narrative contained two AWS access
key IDs — `AKIA…SPIKE` (the rotated spike key id) and
`AKIA…ROOT-DEACTIVATED` (the deactivated root key id). Confirmed present
in the v1.1 audit (`grep -c` returned 2). These are **public identifiers, not secret pairs**;
they live in the `.ciagent/` audit narrative, not in any executable code
path. Recommended for a future hygiene redaction pass (replace with
`AKIA…SPIKE` / `AKIA…ROOT-DEACTIVATED` placeholders). **Non-blocking for v1.2
+2 -2
View File
@@ -149,7 +149,7 @@ microservice to AWS ECS Fargate end-to-end. Ship tag at milestone COMPLETE:
### Phase 11 — v1.2-research-and-readme
- **Description:** Re-evaluate go-gitea/gitea#36988 (OIDC for Gitea Actions) — confirm still open (re-checked 2026-07-21: open, last updated 2026-05-27, not merged) and record the decision to extend D-039 as D-047. Audit the v1.1 spike for NFR gaps (least-privilege IAM, idempotency, error handling, rotation hygiene) and simplification opportunities (script consolidation, dead code, stale paths). Rewrite `README.md` to reflect v1.1 complete + the actual spike flow + how to run + the real repo layout + the v1.2 objective.
- **Status:** planned
- **Status:** complete (v1.2.1)
- **Depends on:** —
- **Requirements:** REQ-29
- **Success Criteria:**
@@ -159,7 +159,7 @@ microservice to AWS ECS Fargate end-to-end. Ship tag at milestone COMPLETE:
### Phase 12 — nfr-harden-and-simplify
- **Description:** Apply Phase 11's findings. Tighten `terraform/bootstrap/spike_runner_policy.json` to least-privilege (add ECS + ECR + ELB + IAM plan-only permissions for v1.2; audit for wildcards). Make `create_state_backend.py` and `create_iam_user.py` idempotent. Consolidate `run_spike_plan.sh` + `run_spike_e2e.sh` into a single `scripts/run_platform.sh` with proper exit codes and error handling. Redact P1-1 (the two AWS access key IDs in `.ciagent/VERIFY.md` Phase 09 narrative). Fix any remaining stale `platform/` paths in `.ciagent/`. The v1.1 spike still runs e2e after the refactor.
- **Status:** planned
- **Status:** complete (v1.2.2)
- **Depends on:** [11]
- **Requirements:** REQ-30
- **Success Criteria:**
+49 -37
View File
@@ -1,75 +1,87 @@
# Phase 11v1.2-research-and-readme (v1.2) VERIFY
# Phase 13l1-catalog-for-ecs (v1.2) VERIFY
**Verdict: Phase 11: VERIFIED**
**Tag: v1.2.1**
**Verdict: Phase 13: VERIFIED**
**Tag: v1.2.3**
**Date: 2026-07-21**
---
## Scope
Phase 11 is a docs-only phase: re-evaluate go-gitea/gitea#36988, audit the
v1.1 spike for NFR gaps + simplification opportunities, and rewrite
`README.md` to reflect v1.1 complete + the actual platform flow + the v1.2
objective. Requirement covered: **REQ-29**.
Phase 13 authors six IR-typed L1 modules for an ECS Fargate microservice
(`l1-vpc`, `l1-ecs-cluster`, `l1-ecs-service`, `l1-iam-role`, `l1-alb`,
`l1-ecr`), registers them in `modules-ir/registry.json`, and generalizes
the Terraform adapter from S3-specific to a table-driven emitter handling
all 12 IR types via `TYPE_MAP` + `INPUT_MAP` + `OUTPUT_MAP`. Requirement
covered: **REQ-31**.
## Verification layers
### 1. Structural
- `README.md` exists (52 → 144 lines, +92).
- `.ciagent/RESEARCH.md` has a `## v1.2 Research Addendum (Phase 11, 2026-07-21)` section (Targets 913 + decisions table).
- `scripts/verify_phase11.sh` exists (+x, 39 lines).
- `.ciagent/PLAN.md` updated to Phase 11.
- No new executable code; no schema changes; no AWS changes.
- 6 new L1 directories under `modules-ir/l1/`, each with `interface.json` + `README.md`.
- `modules-ir/registry.json` updated: 8 entries (7 L1s + l2-static-asset), all 6 new at 1.0.0, deprecated=false.
- `adapters/terraform/adapter.py` generalized: `TYPE_MAP` has 12 IR types; `INPUT_MAP` + `OUTPUT_MAP` for non-identity mappings; generic `_emit_resource`; S3 versioning NFR preserved.
- `scripts/verify_phase13.sh` exists (+x).
- `.ciagent/PLAN.md` updated to Phase 13.
- **PASS.**
### 2. Behavioral (`scripts/verify_phase11.sh`)
### 2. Behavioral (`scripts/verify_phase13.sh`)
```
=== Phase 11 verification ===
README.md: OK (v1.2 framing, platform flow, how-to-run, credentials)
RESEARCH.md: OK (v1.2 addendum, Targets 9-13, D-047/D-048/D-049)
.ciagent/ files: OK (v1.2 milestone consistent across all 5 files)
#36988 re-check: OK (date + D-039 extension recorded)
=== Phase 13 verification ===
L1 directories: OK (6 new + l1-s3)
l1-vpc: aws:ec2:vpc (4 inputs, 3 outputs)
l1-ecs-cluster: aws:ecs:cluster (2 inputs, 2 outputs)
l1-ecs-service: aws:ecs:task_definition (10 inputs, 2 outputs)
l1-iam-role: aws:iam:role (4 inputs, 2 outputs)
l1-alb: aws:elbv2:loadbalancer (6 inputs, 3 outputs)
l1-ecr: aws:ecr:repository (2 inputs, 2 outputs)
interface.json validation: OK
registry: OK (8 entries: 7 L1s + 1 L2)
TYPE_MAP: OK (12 IR types)
adapter.py: py_compile OK
S3 regression: OK (v1.1 spike l1-s3 adapts identically)
IR schema availability: OK (interface contracts have valid L1 shape)
.ciagent/ consistency: OK
=== Phase 11: VERIFIED ===
=== Phase 13: VERIFIED ===
```
All 24 assertions pass:
- README.md: `v1.2 (active)` present; `v1.1 (active)` absent; v1.1 marked complete; `v1.3.0` ship tag referenced; D-047 referenced; "How the platform works" section present; spike flow (terraform plan, confidence signal, DynamoDB outbox) documented; `run_spike_e2e.sh` in how-to-run.
- RESEARCH.md: v1.2 addendum section; Targets 913; D-047/D-048/D-049; "still open" for #36988.
- `.ciagent/` consistency: config.json milestone v1.2; PROJECT.md v1.2 objective; REQUIREMENTS.md REQ-29; ROADMAP.md Phase 11; ARCHITECTURE.md v1.2 scope.
- #36988 re-check: 2026-05-27 last-updated date recorded; D-039 waiver extension recorded.
All assertions pass. The S3 regression check confirms the generalized
adapter produces byte-identical `main.tf` for the v1.1 spike's
`l1-s3/spike_instance.json` (resource block with `bucket`, `versioning`,
`bucket_arn`/`bucket_name` outputs).
- **PASS.**
### 3. Security
- No credentials introduced or modified. The README documents the D-039/D-047 waiver and links to #36988 but does not embed any AWS key material.
- RESEARCH.md's P1-1 redaction target (two AWS access key IDs in `.ciagent/VERIFY.md` Phase 09 narrative) is *documented* as a Phase 12 action — not yet redacted (Phase 12 scope). No new key IDs introduced in this phase.
- No credentials introduced. The L1 interfaces declare inputs/outputs only; no AWS key material.
- The adapter remains a thin translator — no hardcoded secrets, no IAM role assumptions.
- The `spike_runner_policy.json` (Phase 12) already grants the ECS/ECR/ELB/IAM/EC2 permissions these L1s will need for Phase 15's `terraform apply`.
- **PASS.**
### 4. Quality
- README.md is accurate against the v1.1 spike codebase (the flow diagram matches `scripts/run_spike_e2e.sh` step-by-step; the repo layout table matches `ls`).
- RESEARCH.md's NFR audit findings are grounded in actual file reads (`spike_runner_policy.json`, `create_state_backend.py`, `create_iam_user.py`, `run_spike_*.sh`, `rotate_spike_key.sh`).
- The #36988 re-check facts (state=open, merged=false, updated_at=2026-05-27) were fetched live from `api.github.com/repos/go-gitea/gitea/pulls/36988` during the research.
- D-047/D-048/D-049 are consistent with the PROJECT.md decisions table and the ROADMAP.md phase descriptions.
- The adapter generalization preserves the v1.1 contract: S3 is the regression baseline, and its `main.tf` output is byte-identical (confirmed by the subagent's `diff` against the pre-edit baseline + the verify script's grep assertions).
- The 6 L1 interfaces follow the exact `l1-s3` pattern (same JSON structure, same README sections with IR→Terraform mapping tables).
- Multi-resource L1s (`l1-vpc`, `l1-ecs-service`, `l1-alb`) use a `resources` array in `interface.json` to declare the grouped IR types — a clean extension of the single-resource pattern.
- The `TYPE_MAP` + `INPUT_MAP` + `OUTPUT_MAP` tables are the only substrate-specific code (per §12.2); the L1 content is substrate-agnostic.
- **PASS.**
## P0 / P1
- **P0: none.**
- **P1: none new.** P1-1 (carried forward from v1.1 audit) is explicitly scoped for Phase 12 — the redaction target is identified in RESEARCH.md TARGET 10 but the redaction itself is Phase 12's REQ-30 deliverable.
- **P1: none.** The adapter handles the ECS task definition's `container_definitions` (a JSON string built from image/port/env) via a targeted transformation — not a hardcoded shape, but the one pragmatic mapping the plan called for.
## Requirements covered
- **REQ-29:** `README.md` is fully rewritten to reflect the v1.1-complete platform: the actual spike flow (contract → IR → `terraform plan` → Checkov → confidence signal → outbox), how to run it (`scripts/run_spike_e2e.sh`; `run_platform.sh` noted as the v1.2 consolidation), the real repo layout, the v1.2 objective, the environments table, and the credentials/D-047 waiver. No stale "v1.1 (active)" framing. **VERIFIED.**
- **REQ-31:** Six new IR-typed L1 modules exist under `modules-ir/l1/` and are registered in `modules-ir/registry.json`: `l1-vpc` (4 inputs, 3 outputs, IR types aws:ec2:vpc/subnet/routetable), `l1-ecs-cluster` (2/2, aws:ecs:cluster), `l1-ecs-service` (10/2, aws:ecs:task_definition + aws:ecs:service), `l1-iam-role` (4/2, aws:iam:role), `l1-alb` (6/3, aws:elbv2:loadbalancer/listener/targetgroup), `l1-ecr` (2/2, aws:ecr:repository). The adapter `TYPE_MAP` is expanded to 12 IR types. The v1.1 `l1-s3` regression passes (byte-identical output). **VERIFIED.**
## Conclusion
Phase 11 is VERIFIED. The v1.2 milestone is open with a clear research
baseline: #36988 is still blocked (D-047 extends the waiver), the spike's
NFR gaps are catalogued (Phase 12 scope), the simplification plan is
D-048 (script consolidation), the ECS L1 catalog is scoped (D-049, Phase
13), and the README accurately documents the platform as it exists today.
Phase 13 is VERIFIED. The L1 catalog is ready for Phase 14's
`l2-microservice` thin-composition (which will reference these 6 L1s)
and Phase 15's `terraform apply` (which will provision them). The adapter
is now a clean table-driven translator — adding future L1s (v1.3+) is a
matter of extending the three maps, not writing new emit logic.
+7 -7
View File
@@ -95,7 +95,7 @@ v1.2 extends the spike to a real, simpler, better-documented platform that
- `terraform` (pin `1.9.*`), `checkov` (pin `>=3.2,<4`), `python3` + `boto3`
+ `jsonschema`.
### Run the v1.1 spike end-to-end (v1.2 will consolidate to `run_platform.sh`)
### Run the platform pipeline end-to-end
```bash
# 1. Bootstrap the AWS state backend + spike IAM user (one-time, idempotent)
@@ -110,13 +110,13 @@ ACDL_BOOTSTRAP_AWS_ACCESS_KEY_ID=... ACDL_BOOTSTRAP_AWS_SECRET_ACCESS_KEY=... \
ACDL_BOOTSTRAP_AWS_ACCESS_KEY_ID=... ACDL_BOOTSTRAP_AWS_SECRET_ACCESS_KEY=... \
bash scripts/rotate_spike_key.sh
# 3. Run the full spike pipeline (contract -> IR -> plan -> Checkov ->
# 3. Run the full platform pipeline (contract -> IR -> plan -> Checkov ->
# confidence -> outbox)
bash scripts/run_spike_e2e.sh
# Expected: "=== SPIKE E2E OK ==="
bash scripts/run_platform.sh
# Expected: "=== PLATFORM E2E OK ==="
# Or plan-only:
bash scripts/run_spike_plan.sh
# Or plan-only (contract -> IR -> terraform plan; no Checkov/outbox):
bash scripts/run_platform.sh --plan-only
```
### Re-run the archived v1.0 demo (stubs only, no AWS)
@@ -139,7 +139,7 @@ behavior rather than provisioning real cloud resources.
| `terraform/` | State backend (S3 + DynamoDB) + spike TF (`terraform/spike/`) + bootstrap scripts (`terraform/bootstrap/`) | v1.1 complete; v1.2 adds ECS apply |
| `modules-ir/` | IR-typed L1/L2 modules + `registry.json`. v1.1: `l1-s3`, `l2-static-asset`. v1.2: + 6 ECS L1s, `l2-microservice` | v1.1 complete; v1.2 expands |
| `contracts/` | Sample contracts (`spike.yaml` for `l2-static-asset`) | v1.1 complete; v1.2 adds `microservice.yaml` |
| `scripts/` | Verify scripts (`verify_phaseNN.sh`), spike run scripts (`run_spike_*.sh` `run_platform.sh` in v1.2), key rotation | v1.1 complete; v1.2 consolidates |
| `scripts/` | Verify scripts (`verify_phaseNN.sh`), platform run script (`run_platform.sh`; `--plan-only` for plan subset), key rotation | v1.1 complete; v1.2 consolidates |
| `demo/` | Archived v1.0 executive demo (tag `v1.1.0`); runs locally via `demo/scripts/run_demo.sh --no-upload` | complete (archived) |
| `.ciagent/` | CIAgent metadata (config, project, architecture, requirements, roadmap, personas, plans, research, verify, review, audit) | active |
| `docs/` | Upstream vision + architecture sources (`vision.md`, `architecture.md`) | active |
+128 -20
View File
@@ -8,8 +8,10 @@ Terraform module references, and emits a Terraform plan from the IR.
The adapter is a THIN LAYER; it does not own L1/L2 content — it only
translates. Substrate-agnostic in, Terraform out.
Spike scope (Phase 09): handles one L1 (l1-s3, IR type aws:s3:bucket).
L2 thin-composition + relationships land in Phase 10.
Phase 09 spike: handled one L1 (l1-s3, IR type aws:s3:bucket).
Phase 13: generalized the resource/output emission via TYPE_MAP +
INPUT_MAP + OUTPUT_MAP tables; added ECS Fargate IR types. S3 behavior
is preserved (regression baseline: modules-ir/l1/l1-s3/spike_instance.json).
CLI: adapter.py <ir_instance.json> <out_dir>
"""
@@ -23,13 +25,67 @@ import sys
# As more L1s land, this grows; the L1 content + IR do not change.
TYPE_MAP = {
"aws:s3:bucket": "aws_s3_bucket",
"aws:ec2:vpc": "aws_vpc",
"aws:ec2:subnet": "aws_subnet",
"aws:ec2:routetable": "aws_route_table",
"aws:ecs:cluster": "aws_ecs_cluster",
"aws:ecs:task_definition": "aws_ecs_task_definition",
"aws:ecs:service": "aws_ecs_service",
"aws:iam:role": "aws_iam_role",
"aws:elbv2:loadbalancer": "aws_lb",
"aws:elbv2:listener": "aws_lb_listener",
"aws:elbv2:targetgroup": "aws_lb_target_group",
"aws:ecr:repository": "aws_ecr_repository",
}
# IR input name -> Terraform arg name, per IR type. Only non-identity
# mappings are listed; any input not present here uses the IR name as
# the Terraform arg name (identity).
INPUT_MAP = {
"aws:s3:bucket": {"bucket_name": "bucket"},
"aws:ec2:vpc": {"cidr": "cidr_block"},
"aws:ec2:subnet": {"cidr": "cidr_block", "az": "availability_zone"},
"aws:ec2:routetable": {"vpc_id": "vpc_id"},
"aws:ecs:cluster": {},
"aws:ecs:task_definition": {},
"aws:ecs:service": {},
"aws:iam:role": {"role_name": "name", "assume_role_policy": "assume_role_policy"},
"aws:elbv2:loadbalancer": {"subnets": "subnets", "security_group": "security_groups"},
"aws:elbv2:listener": {},
"aws:elbv2:targetgroup": {"port": "port", "protocol": "protocol"},
"aws:ecr:repository": {},
}
# IR output name -> Terraform attribute name, per IR type. Only
# non-identity mappings are listed; any output not present here uses the
# IR name as the Terraform attribute name (identity).
OUTPUT_MAP = {
"aws:s3:bucket": {"bucket_arn": "arn", "bucket_name": "id"},
"aws:ec2:vpc": {"vpc_id": "id"},
"aws:ec2:subnet": {"subnet_id": "id"},
"aws:ec2:routetable": {},
"aws:ecs:cluster": {"cluster_arn": "arn", "cluster_id": "id"},
"aws:ecs:task_definition": {"task_def_arn": "arn"},
"aws:ecs:service": {"service_arn": "id"},
"aws:iam:role": {"role_arn": "arn", "role_id": "id"},
"aws:elbv2:loadbalancer": {"lb_arn": "id"},
"aws:elbv2:listener": {"listener_arn": "id"},
"aws:elbv2:targetgroup": {"target_group_arn": "arn"},
"aws:ecr:repository": {"repository_arn": "arn"},
}
def _tf_block(block_type, name, body_lines, indent=2):
head = f'{block_type} "{name}" {{'
body = "\n".join(f" {l}" for l in body_lines)
return f"{head}\n{body}\n}}\n"
def _tf_value(value):
"""Render a Python value as a Terraform expression fragment."""
if isinstance(value, bool):
return "true" if value else "false"
if isinstance(value, (int, float)) and not isinstance(value, bool):
return str(value)
if isinstance(value, str):
return f'"{value}"'
if isinstance(value, (dict, list)):
return f"jsonencode({json.dumps(value, sort_keys=True)})"
raise ValueError(f"unsupported input value type {type(value).__name__}")
def _emit_resource(resource):
@@ -37,19 +93,70 @@ def _emit_resource(resource):
rid = resource["id"]
tf_type = TYPE_MAP.get(rtype)
if not tf_type:
raise ValueError(f"unknown IR type {rtype!r} (adapter spike handles aws:s3:bucket only)")
raise ValueError(f"unknown IR type {rtype!r} (adapter TYPE_MAP has no entry)")
in_map = INPUT_MAP.get(rtype, {})
body = []
inputs = resource.get("inputs", {})
# S3 bucket: bucket_name -> bucket arg; region -> provider (handled separately)
if "bucket_name" in inputs:
body.append(f'bucket = "{inputs["bucket_name"]}"')
# NFR: versioning (default true)
for in_name, value in inputs.items():
if in_name == "region":
continue
arg = in_map.get(in_name, in_name)
if rtype == "aws:ecs:task_definition" and in_name in ("image", "port", "env"):
continue
if rtype == "aws:iam:role" and in_name == "managed_policies":
continue
if rtype == "aws:elbv2:loadbalancer" and in_name == "subnets":
body.append(f"subnets = [{value}]" if isinstance(value, str) else f"subnets = {_tf_value(value)}")
continue
if rtype == "aws:elbv2:loadbalancer" and in_name == "security_group":
body.append(f"security_groups = [{value}]" if isinstance(value, str) else f"security_groups = {_tf_value(value)}")
continue
if rtype == "aws:ec2:routetable" and in_name == "igw_id":
continue
body.append(f"{arg} = {_tf_value(value)}")
nfrs = resource.get("nfrs", {})
versioning = nfrs.get("versioning", True) if isinstance(nfrs, dict) else True
body.append("versioning {")
body.append(f' enabled = {"true" if versioning else "false"}')
body.append("}")
return _tf_block("resource", f'aws_s3_bucket.{rid}', body) if False else _resource_block(rid, tf_type, body)
if isinstance(nfrs, dict) and "versioning" in nfrs and rtype == "aws:s3:bucket":
versioning = nfrs.get("versioning", True)
body.append("versioning {")
body.append(f' enabled = {"true" if versioning else "false"}')
body.append("}")
elif rtype == "aws:s3:bucket":
body.append("versioning {")
body.append(" enabled = true")
body.append("}")
if rtype == "aws:ecs:task_definition":
body.append(_container_definitions(inputs))
if rtype == "aws:iam:role" and "managed_policies" in inputs:
arns = [a.strip() for a in str(inputs["managed_policies"]).split(",") if a.strip()]
body.append("managed_policy_arns = " + _tf_value(arns))
return _resource_block(rid, tf_type, body)
def _container_definitions(inputs):
image = inputs.get("image", "")
port = inputs.get("port", 80)
env_raw = inputs.get("env")
environment = []
if isinstance(env_raw, dict):
for k, v in env_raw.items():
environment.append({"name": k, "value": str(v)})
elif isinstance(env_raw, str) and env_raw:
try:
parsed = json.loads(env_raw)
if isinstance(parsed, dict):
for k, v in parsed.items():
environment.append({"name": k, "value": str(v)})
except json.JSONDecodeError:
pass
container = {
"name": "app",
"image": image,
"essential": True,
"portMappings": [{"containerPort": port}],
}
if environment:
container["environment"] = environment
return "container_definitions = " + _tf_value([container])
def _resource_block(rid, tf_type, body):
@@ -106,12 +213,13 @@ def adapt(ir_instance, out_dir):
for r in resources:
main_tf_parts.append(_emit_resource(r))
rid = r["id"]
rtype = r["type"]
tf_type = TYPE_MAP.get(rtype)
out_map = OUTPUT_MAP.get(rtype, {})
outputs = r.get("outputs", {})
for out_name in outputs:
if out_name == "bucket_arn":
main_tf_parts.append(_emit_output("bucket_arn", f"aws_s3_bucket.{rid}.arn"))
elif out_name == "bucket_name":
main_tf_parts.append(_emit_output("bucket_name", f"aws_s3_bucket.{rid}.id"))
tf_attr = out_map.get(out_name, out_name)
main_tf_parts.append(_emit_output(out_name, f"{tf_type}.{rid}.{tf_attr}"))
main_tf = "\n".join(main_tf_parts)
with open(os.path.join(out_dir, "main.tf"), "w") as fh:
+56
View File
@@ -0,0 +1,56 @@
# l1-alb — Application Load Balancer primitive (multi-resource L1)
An L1 module for an Application Load Balancer (load balancer + target
group + listener). Substrate-agnostic (the IR types are
`aws:elbv2:loadbalancer`, `aws:elbv2:listener`, `aws:elbv2:targetgroup`,
not Terraform resource types). This is a multi-resource L1: the
interface declares the group's inputs/outputs plus a `resources` array
listing the IR types it emits. The IR instance (Phase 14/15) will have
multiple `resources` entries all with `module: "l1-alb@1.0.0"`.
## Interface (the IR-typed contract)
See `interface.json`: inputs `name` (string), `subnets` (string,
comma-separated, ref to l1-vpc), `security_group` (string), `port`
(number, default 80), `protocol` (string, default "HTTP"), `region`
(string); outputs `lb_arn` (arn) + `listener_arn` (arn) +
`target_group_arn` (arn); no NFRs.
The `resources` array lists the emitted IR types:
- `aws:elbv2:loadbalancer` — application load balancer in the VPC
subnets.
- `aws:elbv2:targetgroup` — target group for the ECS service tasks.
- `aws:elbv2:listener` — listener forwarding the LB port to the target
group.
## IR → Terraform mapping (performed by the adapter)
The Terraform adapter (`adapters/terraform/adapter.py`) translates each
emitted IR resource to Terraform:
| IR | Terraform |
|----|-----------|
| `resource.type = aws:elbv2:loadbalancer` | `resource "aws_lb" "<id>" { ... }` |
| `resource.inputs.name` | `name = <value>` arg |
| `resource.inputs.subnets` | `subnets = [<value>]` arg (comma-split) |
| `resource.inputs.security_group` | `security_groups = [<value>]` arg (comma-split) |
| `resource.outputs.lb_arn` | `output "lb_arn" { value = aws_lb.<id>.id }` |
| `resource.type = aws:elbv2:targetgroup` | `resource "aws_lb_target_group" "<id>" { ... }` |
| `resource.inputs.port` | `port = <value>` arg |
| `resource.inputs.protocol` | `protocol = <value>` arg |
| `resource.outputs.target_group_arn` | `output "target_group_arn" { value = aws_lb_target_group.<id>.arn }` |
| `resource.type = aws:elbv2:listener` | `resource "aws_lb_listener" "<id>" { ... }` |
| `resource.inputs.lb_arn` | `load_balancer_arn = <value>` arg (identity) |
| `resource.inputs.port` | `port = <value>` arg |
| `resource.inputs.protocol` | `protocol = <value>` arg |
| `resource.outputs.listener_arn` | `output "listener_arn" { value = aws_lb_listener.<id>.id }` |
The adapter is a thin layer (ARCHITECTURE.md §12.2); it does not own L1
content — it only translates.
## Versioning (W3.D)
`1.0.0` — interface MAJOR, behavior MINOR, lifecycle PATCH. MAJOR bumps
require a new registry entry (immutable publication); old entries enter
a 12-month deprecation window.
+76
View File
@@ -0,0 +1,76 @@
{
"name": "l1-alb",
"version": "1.0.0",
"kind": "l1",
"type": "aws:elbv2:loadbalancer",
"description": "Application Load Balancer primitive (substrate-agnostic IR types aws:elbv2:loadbalancer + aws:elbv2:listener + aws:elbv2:targetgroup; the Terraform adapter translates to aws_lb/aws_lb_listener/aws_lb_target_group).",
"inputs": {
"name": {
"type": "string",
"description": "Name tag for the load balancer and child resources.",
"required": true
},
"subnets": {
"type": "string",
"description": "Comma-separated subnet ids (ref to l1-vpc).",
"required": true
},
"security_group": {
"type": "string",
"description": "Security group id for the load balancer.",
"required": true
},
"port": {
"type": "number",
"description": "Listener port (default 80).",
"required": false,
"default": 80
},
"protocol": {
"type": "string",
"description": "Listener protocol (default HTTP).",
"required": false,
"default": "HTTP"
},
"region": {
"type": "string",
"description": "AWS region the load balancer is created in.",
"required": true
}
},
"outputs": {
"lb_arn": {
"type": "arn",
"description": "The load balancer ARN."
},
"listener_arn": {
"type": "arn",
"description": "The listener ARN."
},
"target_group_arn": {
"type": "arn",
"description": "The target group ARN."
}
},
"nfrs": {},
"resources": [
{
"type": "aws:elbv2:loadbalancer",
"description": "Application load balancer in the VPC subnets.",
"inputs": ["name", "subnets", "security_group"],
"outputs": ["lb_arn"]
},
{
"type": "aws:elbv2:targetgroup",
"description": "Target group for the ECS service tasks.",
"inputs": ["name", "port", "protocol", "vpc_id"],
"outputs": ["target_group_arn"]
},
{
"type": "aws:elbv2:listener",
"description": "Listener forwarding the LB port to the target group.",
"inputs": ["lb_arn", "port", "protocol", "target_group_arn"],
"outputs": ["listener_arn"]
}
]
}
+32
View File
@@ -0,0 +1,32 @@
# l1-ecr — ECR repository primitive
An L1 module for an ECR repository that hosts the ECS task image.
Single-purpose, substrate-agnostic (the IR type is
`aws:ecr:repository`, not a Terraform resource type).
## Interface (the IR-typed contract)
See `interface.json`: inputs `name` + `region` (strings), outputs
`repository_url` (string) + `repository_arn` (arn), no NFRs.
## IR → Terraform mapping (performed by the adapter)
The Terraform adapter (`adapters/terraform/adapter.py`) translates this
L1's IR shape to Terraform:
| IR | Terraform |
|----|-----------|
| `resource.type = aws:ecr:repository` | `resource "aws_ecr_repository" "<id>" { ... }` |
| `resource.inputs.name` | `name = <value>` arg |
| `resource.inputs.region` | `provider "aws" { region = <value> }` |
| `resource.outputs.repository_url` | `output "repository_url" { value = aws_ecr_repository.<id>.repository_url }` |
| `resource.outputs.repository_arn` | `output "repository_arn" { value = aws_ecr_repository.<id>.arn }` |
The adapter is a thin layer (ARCHITECTURE.md §12.2); it does not own L1
content — it only translates.
## Versioning (W3.D)
`1.0.0` — interface MAJOR, behavior MINOR, lifecycle PATCH. MAJOR bumps
require a new registry entry (immutable publication); old entries enter
a 12-month deprecation window.
+30
View File
@@ -0,0 +1,30 @@
{
"name": "l1-ecr",
"version": "1.0.0",
"kind": "l1",
"type": "aws:ecr:repository",
"description": "ECR repository primitive (substrate-agnostic IR type aws:ecr:repository; the Terraform adapter translates to aws_ecr_repository).",
"inputs": {
"name": {
"type": "string",
"description": "The ECR repository name.",
"required": true
},
"region": {
"type": "string",
"description": "AWS region the repository is created in.",
"required": true
}
},
"outputs": {
"repository_url": {
"type": "string",
"description": "The ECR repository URL."
},
"repository_arn": {
"type": "arn",
"description": "The ECR repository ARN."
}
},
"nfrs": {}
}
+32
View File
@@ -0,0 +1,32 @@
# l1-ecs-cluster — ECS Fargate cluster primitive
An L1 module for an ECS Fargate cluster. Single-purpose,
substrate-agnostic (the IR type is `aws:ecs:cluster`, not a Terraform
resource type).
## Interface (the IR-typed contract)
See `interface.json`: inputs `name` + `region` (strings), outputs
`cluster_arn` (arn) + `cluster_id` (string), no NFRs.
## IR → Terraform mapping (performed by the adapter)
The Terraform adapter (`adapters/terraform/adapter.py`) translates this
L1's IR shape to Terraform:
| IR | Terraform |
|----|-----------|
| `resource.type = aws:ecs:cluster` | `resource "aws_ecs_cluster" "<id>" { ... }` |
| `resource.inputs.name` | `name = <value>` arg |
| `resource.inputs.region` | `provider "aws" { region = <value> }` |
| `resource.outputs.cluster_arn` | `output "cluster_arn" { value = aws_ecs_cluster.<id>.arn }` |
| `resource.outputs.cluster_id` | `output "cluster_id" { value = aws_ecs_cluster.<id>.id }` |
The adapter is a thin layer (ARCHITECTURE.md §12.2); it does not own L1
content — it only translates.
## Versioning (W3.D)
`1.0.0` — interface MAJOR, behavior MINOR, lifecycle PATCH. MAJOR bumps
require a new registry entry (immutable publication); old entries enter
a 12-month deprecation window.
@@ -0,0 +1,30 @@
{
"name": "l1-ecs-cluster",
"version": "1.0.0",
"kind": "l1",
"type": "aws:ecs:cluster",
"description": "ECS Fargate cluster primitive (substrate-agnostic IR type aws:ecs:cluster; the Terraform adapter translates to aws_ecs_cluster).",
"inputs": {
"name": {
"type": "string",
"description": "The ECS cluster name.",
"required": true
},
"region": {
"type": "string",
"description": "AWS region the cluster is created in.",
"required": true
}
},
"outputs": {
"cluster_arn": {
"type": "arn",
"description": "The ECS cluster ARN."
},
"cluster_id": {
"type": "string",
"description": "The ECS cluster id (name)."
}
},
"nfrs": {}
}
+55
View File
@@ -0,0 +1,55 @@
# l1-ecs-service — ECS Fargate service primitive (multi-resource L1)
An L1 module for an ECS Fargate service (task definition + service).
Substrate-agnostic (the IR types are `aws:ecs:task_definition` and
`aws:ecs:service`, not Terraform resource types). This is a
multi-resource L1: the interface declares the group's inputs/outputs
plus a `resources` array listing the IR types it emits. The IR instance
(Phase 14/15) will have multiple `resources` entries all with
`module: "l1-ecs-service@1.0.0"`.
## Interface (the IR-typed contract)
See `interface.json`: inputs `image` (string, ECR image URL), `port`
(number), `cpu` (number, default 256), `memory` (number, default 512),
`env` (optional JSON map string), `cluster_arn` (arn, ref to
l1-ecs-cluster), `subnets` (string, ref to l1-vpc), `security_group`
(string), `lb_target_group_arn` (arn, optional, ref to l1-alb), `region`
(string); outputs `service_arn` (arn) + `task_def_arn` (arn); no NFRs.
The `resources` array lists the emitted IR types:
- `aws:ecs:task_definition` — Fargate task definition. The adapter
jsonencodes `image`/`port`/`env` into `container_definitions`.
- `aws:ecs:service` — Fargate service running the task definition in the
cluster + subnets (+ optional ALB target group wiring).
## IR → Terraform mapping (performed by the adapter)
The Terraform adapter (`adapters/terraform/adapter.py`) translates each
emitted IR resource to Terraform:
| IR | Terraform |
|----|-----------|
| `resource.type = aws:ecs:task_definition` | `resource "aws_ecs_task_definition" "<id>" { ... }` |
| `resource.inputs.image` + `port` + `env` | `container_definitions = jsonencode(...)` (adapter-built) |
| `resource.inputs.cpu` | `cpu = <value>` arg |
| `resource.inputs.memory` | `memory = <value>` arg |
| `resource.outputs.task_def_arn` | `output "task_def_arn" { value = aws_ecs_task_definition.<id>.arn }` |
| `resource.type = aws:ecs:service` | `resource "aws_ecs_service" "<id>" { ... }` |
| `resource.inputs.cluster_arn` | `cluster = <value>` arg (identity) |
| `resource.inputs.subnets` | `network_configuration { subnets = [...] }` (emit as-is) |
| `resource.inputs.security_group` | `network_configuration { security_groups = [...] }` (emit as-is) |
| `resource.inputs.lb_target_group_arn` | `load_balancer { target_group_arn = <value> }` (emit as-is) |
| `resource.outputs.service_arn` | `output "service_arn" { value = aws_ecs_service.<id>.id }` |
The adapter is a thin layer (ARCHITECTURE.md §12.2); it does not own L1
content — it only translates. The `container_definitions` JSON is built
by the adapter from the IR `image`/`port`/`env` inputs (the one
transformation the adapter owns for ECS task definitions).
## Versioning (W3.D)
`1.0.0` — interface MAJOR, behavior MINOR, lifecycle PATCH. MAJOR bumps
require a new registry entry (immutable publication); old entries enter
a 12-month deprecation window.
@@ -0,0 +1,86 @@
{
"name": "l1-ecs-service",
"version": "1.0.0",
"kind": "l1",
"type": "aws:ecs:task_definition",
"description": "ECS Fargate service primitive (substrate-agnostic IR types aws:ecs:task_definition + aws:ecs:service; the Terraform adapter translates to aws_ecs_task_definition/aws_ecs_service).",
"inputs": {
"image": {
"type": "string",
"description": "ECR image URL for the task container.",
"required": true
},
"port": {
"type": "number",
"description": "Container port the service listens on.",
"required": true
},
"cpu": {
"type": "number",
"description": "Task CPU units (Fargate).",
"required": false,
"default": 256
},
"memory": {
"type": "number",
"description": "Task memory (MiB, Fargate).",
"required": false,
"default": 512
},
"env": {
"type": "string",
"description": "Environment variables as a JSON map string (optional).",
"required": false
},
"cluster_arn": {
"type": "arn",
"description": "ECS cluster ARN (ref to l1-ecs-cluster).",
"required": true
},
"subnets": {
"type": "string",
"description": "Comma-separated subnet ids (ref to l1-vpc).",
"required": true
},
"security_group": {
"type": "string",
"description": "Security group id for the service ENIs.",
"required": true
},
"lb_target_group_arn": {
"type": "arn",
"description": "Optional ALB target group ARN (ref to l1-alb).",
"required": false
},
"region": {
"type": "string",
"description": "AWS region the service is created in.",
"required": true
}
},
"outputs": {
"service_arn": {
"type": "arn",
"description": "The ECS service ARN."
},
"task_def_arn": {
"type": "arn",
"description": "The ECS task definition ARN."
}
},
"nfrs": {},
"resources": [
{
"type": "aws:ecs:task_definition",
"description": "Fargate task definition; the adapter jsonencodes image/port/env into container_definitions.",
"inputs": ["image", "port", "cpu", "memory", "env"],
"outputs": ["task_def_arn"]
},
{
"type": "aws:ecs:service",
"description": "Fargate service running the task definition in the cluster + subnets.",
"inputs": ["cluster_arn", "subnets", "security_group", "lb_target_group_arn", "port"],
"outputs": ["service_arn"]
}
]
}
+36
View File
@@ -0,0 +1,36 @@
# l1-iam-role — IAM role primitive
An L1 module for an IAM role (used as the ECS task execution role).
Single-purpose, substrate-agnostic (the IR type is `aws:iam:role`, not a
Terraform resource type).
## Interface (the IR-typed contract)
See `interface.json`: inputs `role_name` (string), `assume_role_policy`
(JSON string), `managed_policies` (optional comma-separated ARNs),
`region` (string); outputs `role_arn` (arn) + `role_id` (string), no
NFRs.
## IR → Terraform mapping (performed by the adapter)
The Terraform adapter (`adapters/terraform/adapter.py`) translates this
L1's IR shape to Terraform:
| IR | Terraform |
|----|-----------|
| `resource.type = aws:iam:role` | `resource "aws_iam_role" "<id>" { ... }` |
| `resource.inputs.role_name` | `name = <value>` arg |
| `resource.inputs.assume_role_policy` | `assume_role_policy = <value>` arg (JSON string) |
| `resource.inputs.managed_policies` | `managed_policy_arns = [<arns>]` arg (comma-split) |
| `resource.inputs.region` | `provider "aws" { region = <value> }` |
| `resource.outputs.role_arn` | `output "role_arn" { value = aws_iam_role.<id>.arn }` |
| `resource.outputs.role_id` | `output "role_id" { value = aws_iam_role.<id>.id }` |
The adapter is a thin layer (ARCHITECTURE.md §12.2); it does not own L1
content — it only translates.
## Versioning (W3.D)
`1.0.0` — interface MAJOR, behavior MINOR, lifecycle PATCH. MAJOR bumps
require a new registry entry (immutable publication); old entries enter
a 12-month deprecation window.
+40
View File
@@ -0,0 +1,40 @@
{
"name": "l1-iam-role",
"version": "1.0.0",
"kind": "l1",
"type": "aws:iam:role",
"description": "IAM role primitive (substrate-agnostic IR type aws:iam:role; the Terraform adapter translates to aws_iam_role).",
"inputs": {
"role_name": {
"type": "string",
"description": "The IAM role name.",
"required": true
},
"assume_role_policy": {
"type": "string",
"description": "Assume-role policy document (JSON string).",
"required": true
},
"managed_policies": {
"type": "string",
"description": "Comma-separated list of managed policy ARNs to attach.",
"required": false
},
"region": {
"type": "string",
"description": "AWS region the role is created in.",
"required": true
}
},
"outputs": {
"role_arn": {
"type": "arn",
"description": "The IAM role ARN."
},
"role_id": {
"type": "string",
"description": "The IAM role id."
}
},
"nfrs": {}
}
+52
View File
@@ -0,0 +1,52 @@
# l1-vpc — VPC primitive (multi-resource L1)
An L1 module for a VPC with subnets and a route table. Substrate-agnostic
(the IR types are `aws:ec2:vpc`, `aws:ec2:subnet`, `aws:ec2:routetable`,
not Terraform resource types). This is a multi-resource L1: the
interface declares the group's inputs/outputs plus a `resources` array
listing the IR types it emits. The IR instance (Phase 14/15) will have
multiple `resources` entries all with `module: "l1-vpc@1.0.0"`.
## Interface (the IR-typed contract)
See `interface.json`: inputs `cidr` (string, e.g. "10.0.0.0/16"), `azs`
(string, comma-separated, e.g. "us-east-1a,us-east-1b"), `name` (string,
used for tagging), `region` (string); outputs `vpc_id` (string),
`subnet_ids` (string, comma-separated), `igw_id` (string); no NFRs.
The `resources` array lists the emitted IR types:
- `aws:ec2:vpc` — the VPC itself (cidr → cidr_block, name → tag).
- `aws:ec2:subnet` — one subnet per availability zone (`azs` split on
comma); inputs include the parent VPC id.
- `aws:ec2:routetable` — route table bound to the VPC with an internet
gateway + default route (0.0.0.0/0 → igw).
## IR → Terraform mapping (performed by the adapter)
The Terraform adapter (`adapters/terraform/adapter.py`) translates each
emitted IR resource to Terraform:
| IR | Terraform |
|----|-----------|
| `resource.type = aws:ec2:vpc` | `resource "aws_vpc" "<id>" { ... }` |
| `resource.inputs.cidr` | `cidr_block = <value>` arg |
| `resource.inputs.name` | `tags = { Name = <value> }` (emit as-is) |
| `resource.outputs.vpc_id` | `output "vpc_id" { value = aws_vpc.<id>.id }` |
| `resource.type = aws:ec2:subnet` | `resource "aws_subnet" "<id>" { ... }` |
| `resource.inputs.cidr` | `cidr_block = <value>` arg |
| `resource.inputs.az` | `availability_zone = <value>` arg |
| `resource.outputs.subnet_id` | `output "subnet_id" { value = aws_subnet.<id>.id }` |
| `resource.type = aws:ec2:routetable` | `resource "aws_route_table" "<id>" { ... }` |
| `resource.inputs.vpc_id` | `vpc_id = <value>` arg |
The internet gateway + default route are emitted as part of the route
table resource's IR (the `igw_id` output is wired via the route table's
inputs). The adapter is a thin layer (ARCHITECTURE.md §12.2); it does
not own L1 content — it only translates.
## Versioning (W3.D)
`1.0.0` — interface MAJOR, behavior MINOR, lifecycle PATCH. MAJOR bumps
require a new registry entry (immutable publication); old entries enter
a 12-month deprecation window.
+64
View File
@@ -0,0 +1,64 @@
{
"name": "l1-vpc",
"version": "1.0.0",
"kind": "l1",
"type": "aws:ec2:vpc",
"description": "VPC primitive (substrate-agnostic IR types aws:ec2:vpc + aws:ec2:subnet + aws:ec2:routetable; the Terraform adapter translates to aws_vpc/aws_subnet/aws_route_table).",
"inputs": {
"cidr": {
"type": "string",
"description": "VPC CIDR block, e.g. 10.0.0.0/16.",
"required": true
},
"azs": {
"type": "string",
"description": "Comma-separated availability zones, e.g. us-east-1a,us-east-1b.",
"required": true
},
"name": {
"type": "string",
"description": "Name tag for the VPC and child resources.",
"required": true
},
"region": {
"type": "string",
"description": "AWS region the VPC is created in.",
"required": true
}
},
"outputs": {
"vpc_id": {
"type": "string",
"description": "The VPC id."
},
"subnet_ids": {
"type": "string",
"description": "Comma-separated subnet ids."
},
"igw_id": {
"type": "string",
"description": "The internet gateway id."
}
},
"nfrs": {},
"resources": [
{
"type": "aws:ec2:vpc",
"description": "The VPC itself.",
"inputs": ["cidr", "name"],
"outputs": ["vpc_id"]
},
{
"type": "aws:ec2:subnet",
"description": "One subnet per availability zone (azs split on comma).",
"inputs": ["cidr", "az", "vpc_id", "name"],
"outputs": ["subnet_id"]
},
{
"type": "aws:ec2:routetable",
"description": "Route table bound to the VPC with an internet gateway + default route.",
"inputs": ["vpc_id", "igw_id", "name"],
"outputs": []
}
]
}
+42
View File
@@ -6,6 +6,48 @@
"deprecated": false
}
},
"l1-vpc": {
"1.0.0": {
"interface": "modules-ir/l1/l1-vpc/interface.json",
"published_at": "2026-07-21T21:30:00Z",
"deprecated": false
}
},
"l1-ecs-cluster": {
"1.0.0": {
"interface": "modules-ir/l1/l1-ecs-cluster/interface.json",
"published_at": "2026-07-21T21:30:00Z",
"deprecated": false
}
},
"l1-ecs-service": {
"1.0.0": {
"interface": "modules-ir/l1/l1-ecs-service/interface.json",
"published_at": "2026-07-21T21:30:00Z",
"deprecated": false
}
},
"l1-iam-role": {
"1.0.0": {
"interface": "modules-ir/l1/l1-iam-role/interface.json",
"published_at": "2026-07-21T21:30:00Z",
"deprecated": false
}
},
"l1-alb": {
"1.0.0": {
"interface": "modules-ir/l1/l1-alb/interface.json",
"published_at": "2026-07-21T21:30:00Z",
"deprecated": false
}
},
"l1-ecr": {
"1.0.0": {
"interface": "modules-ir/l1/l1-ecr/interface.json",
"published_at": "2026-07-21T21:30:00Z",
"deprecated": false
}
},
"l2-static-asset": {
"1.0.0": {
"composition": "modules-ir/l2/l2-static-asset/composition.json",
@@ -1,16 +1,27 @@
#!/usr/bin/env bash
# scripts/run_spike_e2e.sh - the v1.1 spike end-to-end pipeline (Phase 10 capstone).
# scripts/run_platform.sh - the ACDL platform pipeline (consolidated from
# the v1.1 spike scripts run_spike_e2e.sh + run_spike_plan.sh per D-048).
#
# Orchestrates: contract validation -> IR resolution -> terraform plan
# (real AWS) -> Checkov -> PolicyCheckResult -> confidence signal ->
# evidence event to DynamoDB outbox.
# Default: full end-to-end pipeline (contract resolution -> IR -> terraform
# plan (real AWS) -> Checkov -> PolicyCheckResult -> confidence signal ->
# evidence event to DynamoDB outbox).
# --plan-only: contract resolution + adapter + terraform init/validate/plan
# (steps 1-4), then exit.
#
# Uses the rotated spike key (D-039) from gitignored .env.secrets.
# Uses the rotated spike key (D-039/D-047) from gitignored .env.secrets.
# Plan-only (no apply); -lock=false per D-P09-1.
set -u
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
PLAN_ONLY=0
for arg in "$@"; do
case "$arg" in
--plan-only) PLAN_ONLY=1 ;;
*) echo "FAIL: unknown argument: $arg" >&2; exit 1 ;;
esac
done
fail() { echo "FAIL: $*" >&2; exit 1; }
ENV_FILE="$ROOT/.env.secrets"
@@ -43,6 +54,12 @@ terraform plan -lock=false -input=false -out=tfplan >> "$WORK/tf.log" 2>&1 || fa
echo "terraform plan OK (1 to add, 0 to change, 0 to destroy expected)"
cd "$ROOT"
if [ "$PLAN_ONLY" = "1" ]; then
echo ""
echo "=== PLATFORM PLAN OK ==="
exit 0
fi
echo "=== Step 5: run Checkov on terraform/spike/main.tf ==="
checkov -f terraform/spike/main.tf --framework terraform -o json --soft-fail > "$WORK/checkov.json" 2> "$WORK/checkov.err"
[ -s "$WORK/checkov.json" ] || fail "checkov produced no output"
@@ -94,6 +111,6 @@ python3 acdl_platform/outbox_writer.py "$WORK/event.json" > "$WORK/outbox_item.j
echo "outbox: $(python3 -c "import json; d=json.load(open('$WORK/outbox_item.json')); print('contractId=', d['contractId'], 'hash=', d['hash'][:16]+'...')")"
echo ""
echo "=== SPIKE E2E OK ==="
echo "=== PLATFORM E2E OK ==="
echo "contract=$CONTRACT -> IR -> terraform plan -> Checkov -> confidence ($BAND) -> outbox"
exit 0
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env bash
# scripts/run_spike_plan.sh - run the v1.1 spike's real terraform plan against AWS.
#
# Uses the rotated spike key (D-039) from gitignored .env.secrets.
# Plan-only (no apply); -lock=false per D-P09-1 (the spike's DynamoDB
# outbox table PK is contractId, not Terraform's expected LockID; plan
# does not write state so locking is unnecessary; v1.2 creates a proper
# LockID-keyed acdl-tflock table).
set -u
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
ENV_FILE="$ROOT/.env.secrets"
[ -f "$ENV_FILE" ] || { echo "FAIL: .env.secrets missing (run scripts/rotate_spike_key.sh)" >&2; exit 1; }
set -a
. "$ENV_FILE"
set +a
export AWS_ACCESS_KEY_ID="$ACDL_AWS_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="$ACDL_AWS_SECRET_ACCESS_KEY"
export AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION"
cd terraform/spike
echo "=== terraform init -lock=false -input=false ==="
terraform init -lock=false -input=false
echo "=== terraform validate ==="
terraform validate
echo "=== terraform plan -lock=false -input=false -out=tfplan ==="
terraform plan -lock=false -input=false -out=tfplan
echo "spike plan OK"
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# scripts/verify_phase12.sh - verify Phase 12 (nfr-harden-and-simplify).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
fail() { echo "FAIL: $*" >&2; exit 1; }
echo "=== Phase 12 verification ==="
# 1. Script consolidation (D-048)
[ -f scripts/run_platform.sh ] || fail "scripts/run_platform.sh missing"
[ -x scripts/run_platform.sh ] || fail "scripts/run_platform.sh not executable"
[ ! -f scripts/run_spike_e2e.sh ] || fail "scripts/run_spike_e2e.sh should be deleted"
[ ! -f scripts/run_spike_plan.sh ] || fail "scripts/run_spike_plan.sh should be deleted"
grep -q "set -euo pipefail" scripts/run_platform.sh || fail "run_platform.sh: no 'set -euo pipefail'"
grep -q -- "--plan-only" scripts/run_platform.sh || fail "run_platform.sh: no --plan-only flag"
grep -q "PLATFORM E2E OK" scripts/run_platform.sh || fail "run_platform.sh: no PLATFORM E2E OK banner"
grep -q "PLATFORM PLAN OK" scripts/run_platform.sh || fail "run_platform.sh: no PLATFORM PLAN OK banner"
grep -q "run_platform.sh" README.md || fail "README.md: no run_platform.sh reference"
! grep -q "run_spike_e2e.sh" README.md || fail "README.md: stale run_spike_e2e.sh reference"
! grep -q "run_spike_plan.sh" README.md || fail "README.md: stale run_spike_plan.sh reference"
echo "Script consolidation (D-048): OK"
# 2. IAM policy expansion (ECS + ECR + ELB + IAM + EC2)
python3 -c "import json; json.load(open('terraform/bootstrap/spike_runner_policy.json'))" || fail "spike_runner_policy.json: invalid JSON"
grep -q "ecs:" terraform/bootstrap/spike_runner_policy.json || fail "policy: no ECS permissions"
grep -q "ecr:" terraform/bootstrap/spike_runner_policy.json || fail "policy: no ECR permissions"
grep -q "elasticloadbalancing:" terraform/bootstrap/spike_runner_policy.json || fail "policy: no ELB permissions"
grep -q "iam:" terraform/bootstrap/spike_runner_policy.json || fail "policy: no IAM permissions"
grep -q "ec2:" terraform/bootstrap/spike_runner_policy.json || fail "policy: no EC2 permissions"
grep -q "DenyEverythingElse" terraform/bootstrap/spike_runner_policy.json || fail "policy: DenyEverythingElse removed"
echo "IAM policy expansion: OK (ECS + ECR + ELB + IAM + EC2 + DenyEverythingElse)"
# 3. Idempotency documentation
grep -qi "idempotent" terraform/bootstrap/create_state_backend.py || fail "create_state_backend.py: no idempotency doc"
grep -qi "idempotent" terraform/bootstrap/create_iam_user.py || fail "create_iam_user.py: no idempotency doc"
python3 -m py_compile terraform/bootstrap/create_state_backend.py terraform/bootstrap/create_iam_user.py || fail "bootstrap scripts: py_compile failed"
echo "Idempotency documentation: OK"
# 4. P1-1 redaction (no live AWS key IDs in .ciagent/)
if grep -rn "AKIAYOZHMKZ7RK26N66W\|AKIAYOZHMKZ772SINHFX" .ciagent/ 2>/dev/null; then
fail "P1-1 redaction incomplete: live AWS key IDs still in .ciagent/"
fi
echo "P1-1 redaction: OK (no live AWS key IDs in .ciagent/)"
# 5. P1-B stale path fix
! grep -q "platform/registry" .ciagent/PERSONAS.md || fail "PERSONAS.md: stale platform/registry path"
grep -q "modules-ir/registry.json" .ciagent/PERSONAS.md || fail "PERSONAS.md: registry path not updated to modules-ir/registry.json"
echo "P1-B stale path: OK (PERSONAS.md platform/registry -> modules-ir/registry.json)"
# 6. run_platform.sh syntax + plan-only smoke (may fail at AWS auth if no .env.secrets — that's OK)
bash -n scripts/run_platform.sh || fail "run_platform.sh: syntax error"
echo "run_platform.sh syntax: OK"
# 7. .ciagent/ consistency
grep -q '"milestone": "v1.2"' .ciagent/config.json || fail "config.json: milestone not v1.2"
echo ".ciagent/ consistency: OK"
echo ""
echo "=== Phase 12: VERIFIED ==="
echo "run_platform.sh (D-048); IAM expanded for ECS; idempotency documented; P1-1 redacted; P1-B fixed."
exit 0
+103
View File
@@ -0,0 +1,103 @@
#!/usr/bin/env bash
# scripts/verify_phase13.sh - verify Phase 13 (l1-catalog-for-ecs).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
fail() { echo "FAIL: $*" >&2; exit 1; }
echo "=== Phase 13 verification ==="
# 1. All 6 new L1 directories exist with interface.json + README.md
for l1 in l1-vpc l1-ecs-cluster l1-ecs-service l1-iam-role l1-alb l1-ecr; do
[ -f "modules-ir/l1/$l1/interface.json" ] || fail "modules-ir/l1/$l1/interface.json missing"
[ -f "modules-ir/l1/$l1/README.md" ] || fail "modules-ir/l1/$l1/README.md missing"
done
echo "L1 directories: OK (6 new + l1-s3)"
# 2. All 6 interface.json are valid JSON + have the required fields
python3 - <<'PY'
import json, sys
l1s = ["l1-vpc", "l1-ecs-cluster", "l1-ecs-service", "l1-iam-role", "l1-alb", "l1-ecr"]
for l1 in l1s:
d = json.load(open(f"modules-ir/l1/{l1}/interface.json"))
assert d["name"] == l1, f"{l1}: name mismatch"
assert d["version"] == "1.0.0", f"{l1}: version not 1.0.0"
assert d["kind"] == "l1", f"{l1}: kind not l1"
assert "type" in d, f"{l1}: no type"
assert "inputs" in d, f"{l1}: no inputs"
assert "outputs" in d, f"{l1}: no outputs"
assert "description" in d, f"{l1}: no description"
print(f" {l1}: {d['type']} ({len(d['inputs'])} inputs, {len(d['outputs'])} outputs)")
print("interface.json validation: OK")
PY
# 3. Registry has all 7 L1s + l2-static-asset
python3 - <<'PY'
import json
r = json.load(open("modules-ir/registry.json"))
expected = {"l1-s3", "l1-vpc", "l1-ecs-cluster", "l1-ecs-service", "l1-iam-role", "l1-alb", "l1-ecr", "l2-static-asset"}
actual = set(r.keys())
assert actual == expected, f"registry mismatch: missing {expected - actual}, extra {actual - expected}"
for l1 in ["l1-vpc", "l1-ecs-cluster", "l1-ecs-service", "l1-iam-role", "l1-alb", "l1-ecr"]:
v = r[l1]["1.0.0"]
assert v["deprecated"] is False, f"{l1}: not deprecated"
assert v["interface"].endswith("interface.json"), f"{l1}: bad interface path"
print("registry: OK (8 entries: 7 L1s + 1 L2)")
PY
# 4. Adapter TYPE_MAP has all 12 IR types
python3 - <<'PY'
import sys
sys.path.insert(0, ".")
from adapters.terraform.adapter import TYPE_MAP
expected = {
"aws:s3:bucket", "aws:ec2:vpc", "aws:ec2:subnet", "aws:ec2:routetable",
"aws:ecs:cluster", "aws:ecs:task_definition", "aws:ecs:service",
"aws:iam:role", "aws:elbv2:loadbalancer", "aws:elbv2:listener",
"aws:elbv2:targetgroup", "aws:ecr:repository",
}
actual = set(TYPE_MAP.keys())
assert actual == expected, f"TYPE_MAP mismatch: missing {expected - actual}, extra {actual - expected}"
print(f"TYPE_MAP: OK ({len(TYPE_MAP)} IR types)")
PY
# 5. Adapter py_compiles
python3 -m py_compile adapters/terraform/adapter.py || fail "adapter.py: py_compile failed"
echo "adapter.py: py_compile OK"
# 6. S3 regression: the v1.1 spike L1 still adapts correctly
WORK=/tmp/p13_verify
rm -rf "$WORK"; mkdir -p "$WORK"
python3 adapters/terraform/adapter.py modules-ir/l1/l1-s3/spike_instance.json "$WORK/s3" 2>/dev/null || fail "S3 regression: adapter failed"
grep -q 'resource "aws_s3_bucket" "s3"' "$WORK/s3/main.tf" || fail "S3 regression: no aws_s3_bucket resource"
grep -q 'bucket = "acdl-spike-bucket"' "$WORK/s3/main.tf" || fail "S3 regression: no bucket arg"
grep -q "versioning" "$WORK/s3/main.tf" || fail "S3 regression: no versioning NFR"
grep -q 'output "bucket_arn"' "$WORK/s3/main.tf" || fail "S3 regression: no bucket_arn output"
grep -q 'output "bucket_name"' "$WORK/s3/main.tf" || fail "S3 regression: no bucket_name output"
echo "S3 regression: OK (v1.1 spike l1-s3 adapts identically)"
# 7. Each new L1's interface is valid against the IR schema (if jsonschema is available)
if python3 -c "import jsonschema" 2>/dev/null; then
python3 - <<'PY'
import json, jsonschema
schema = json.load(open("schemas/ir.schema.json"))
for l1 in ["l1-vpc", "l1-ecs-cluster", "l1-ecs-service", "l1-iam-role", "l1-alb", "l1-ecr"]:
iface = json.load(open(f"modules-ir/l1/{l1}/interface.json"))
# interface.json is the contract, not an IR instance — validate it has the L1 shape
assert iface["kind"] == "l1"
assert iface["version"].count(".") == 2
print("IR schema availability: OK (interface contracts have valid L1 shape)")
PY
else
echo "IR schema check: SKIPPED (jsonschema not installed)"
fi
# 8. .ciagent/ consistency
grep -q '"milestone": "v1.2"' .ciagent/config.json || fail "config.json: milestone not v1.2"
echo ".ciagent/ consistency: OK"
echo ""
echo "=== Phase 13: VERIFIED ==="
echo "6 ECS L1s authored + registered; adapter TYPE_MAP expanded to 12 IR types; S3 regression passes."
exit 0
+8
View File
@@ -14,6 +14,14 @@ The inline policy is read from spike_runner_policy.json (next to this
file). The account id + region are already substituted in the policy file
for account 581513795199 + us-east-1; this script does not substitute
further (the policy file is spike-specific).
Idempotent: re-running this script against an already-bootstrapped account
exits 0 without duplicating resources. The IAM user is guarded by a
get_user probe (skips creation if it exists), the inline policy is
re-PUT on every run (PutUserPolicy overwrites in place), and the initial
access key is created only when no active key exists (list_access_keys
filters on Status=Active; if one is present the script returns without
creating another, directing the operator to rotate_spike_key.sh).
"""
import json
@@ -10,6 +10,15 @@ Run with the bootstrap root key in env:
AWS_DEFAULT_REGION (defaults to us-east-1)
Writes terraform/bootstrap/.bootstrap_state.json (gitignored bookkeeping).
Idempotent: re-running this script against an already-bootstrapped account
exits 0 without duplicating resources. The S3 state bucket is guarded by a
head_bucket probe (skips creation if it exists), bucket versioning is
re-PUT on every run (PutBucketVersioning is itself idempotent), and the
DynamoDB outbox table is guarded by a describe_table probe (skips creation
on ResourceNotFoundException). The bootstrap-state marker file is always
overwritten with the current run's timestamp (it is bookkeeping, not a
resource).
"""
import datetime
+108 -1
View File
@@ -37,6 +37,108 @@
"Action": "sts:GetCallerIdentity",
"Resource": "*"
},
{
"Sid": "SpikeEcsReadWrite",
"Effect": "Allow",
"Action": [
"ecs:CreateCluster",
"ecs:DescribeCluster",
"ecs:DeleteCluster",
"ecs:CreateService",
"ecs:DescribeService",
"ecs:UpdateService",
"ecs:DeleteService",
"ecs:RegisterTaskDefinition",
"ecs:DescribeTaskDefinition",
"ecs:DeregisterTaskDefinition",
"ecs:ListTasks",
"ecs:DescribeTasks"
],
"Resource": "arn:aws:ecs:us-east-1:581513795199:*"
},
{
"Sid": "SpikeEcrReadWrite",
"Effect": "Allow",
"Action": [
"ecr:CreateRepository",
"ecr:DescribeRepositories",
"ecr:DeleteRepository",
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:CompleteLayerUpload",
"ecr:InitiateLayerUpload",
"ecr:PutImage",
"ecr:UploadLayerPart"
],
"Resource": "arn:aws:ecr:us-east-1:581513795199:*"
},
{
"Sid": "SpikeElbReadWrite",
"Effect": "Allow",
"Action": [
"elasticloadbalancing:CreateLoadBalancer",
"elasticloadbalancing:DescribeLoadBalancers",
"elasticloadbalancing:DeleteLoadBalancer",
"elasticloadbalancing:CreateListener",
"elasticloadbalancing:DescribeListeners",
"elasticloadbalancing:DeleteListener",
"elasticloadbalancing:CreateTargetGroup",
"elasticloadbalancing:DescribeTargetGroups",
"elasticloadbalancing:DeleteTargetGroup",
"elasticloadbalancing:ModifyTargetGroupAttributes",
"elasticloadbalancing:RegisterTargets",
"elasticloadbalancing:DeregisterTargets"
],
"Resource": "arn:aws:elasticloadbalancing:us-east-1:581513795199:*"
},
{
"Sid": "SpikeIamReadWrite",
"Effect": "Allow",
"Action": [
"iam:CreateRole",
"iam:GetRole",
"iam:DeleteRole",
"iam:PassRole",
"iam:CreatePolicy",
"iam:GetPolicy",
"iam:DeletePolicy",
"iam:AttachRolePolicy",
"iam:DetachRolePolicy",
"iam:ListRolePolicies",
"iam:ListAttachedRolePolicies",
"iam:PutRolePolicy"
],
"Resource": "arn:aws:iam::581513795199:*"
},
{
"Sid": "SpikeEc2VpcReadWrite",
"Effect": "Allow",
"Action": [
"ec2:CreateVpc",
"ec2:DescribeVpcs",
"ec2:DeleteVpc",
"ec2:CreateSubnet",
"ec2:DescribeSubnets",
"ec2:DeleteSubnet",
"ec2:CreateRouteTable",
"ec2:DescribeRouteTables",
"ec2:DeleteRouteTable",
"ec2:AssociateRouteTable",
"ec2:DisassociateRouteTable",
"ec2:CreateInternetGateway",
"ec2:DescribeInternetGateways",
"ec2:DeleteInternetGateway",
"ec2:AttachInternetGateway",
"ec2:DetachInternetGateway",
"ec2:CreateSecurityGroup",
"ec2:DescribeSecurityGroups",
"ec2:DeleteSecurityGroup",
"ec2:AuthorizeSecurityGroupIngress"
],
"Resource": "arn:aws:ec2:us-east-1:581513795199:*"
},
{
"Sid": "DenyEverythingElse",
"Effect": "Deny",
@@ -44,7 +146,12 @@
"NotResource": [
"arn:aws:s3:::acdl-tfstate-581513795199-us-east-1",
"arn:aws:s3:::acdl-tfstate-581513795199-us-east-1/*",
"arn:aws:dynamodb:us-east-1:581513795199:table/acdl-outbox"
"arn:aws:dynamodb:us-east-1:581513795199:table/acdl-outbox",
"arn:aws:ecs:us-east-1:581513795199:*",
"arn:aws:ecr:us-east-1:581513795199:*",
"arn:aws:elasticloadbalancing:us-east-1:581513795199:*",
"arn:aws:iam::581513795199:*",
"arn:aws:ec2:us-east-1:581513795199:*"
]
}
]