Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- name: test
run: go test ./...

- name: verify conformance corpus
run: go run ./cmd/openiac-conformance verify

- name: build CLI
run: go build -o bin/openiac ./cmd/openiac

Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GO ?= go
BIN := bin/openiac
PLAYGROUND := playground

.PHONY: all build test vet fmt tidy wasm playground clean hooks
.PHONY: all build test vet fmt tidy wasm playground clean hooks conformance-inputs conformance-verify conformance-lock

all: build

Expand All @@ -26,6 +26,18 @@ hooks:
git config core.hooksPath .githooks
chmod +x .githooks/commit-msg scripts/check-commit-message.sh

# Refresh the conformance input corpus from the configured public sources.
conformance-inputs:
$(GO) run ./cmd/openiac-conformance collect -v

# Check that the committed corpus matches its lock and attribution.
conformance-verify:
$(GO) run ./cmd/openiac-conformance verify

# Regenerate the lock and attribution from the committed fixture tree.
conformance-lock:
$(GO) run ./cmd/openiac-conformance lock

# Build the browser playground. Copies wasm_exec.js from the local toolchain,
# which lives in a different directory depending on the Go version.
wasm:
Expand Down
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,38 @@ Add it to [`pkg/mappings/aws.json`](pkg/mappings/aws.json), rebuild, done.

---

## 🧪 Conformance Corpus

The transpiler is tested against real Terraform, not hand-written examples. The
repository vendors **853 modules** (6,471 files, ~23 MiB) from the Terraform
Registry and public GitHub repositories. Every fixture pins the resolved upstream
commit, records the input-tree hash, carries the upstream license and is scanned
for executables and credentials before it enters the tree. CI re-verifies the
tree, its lock and the generated attribution on every pull request.

```bash
make conformance-inputs # refresh from configured sources
make conformance-verify # check the committed tree and lock
make conformance-lock # regenerate the lock and attribution
cat conformance/corpus.lock.json # aggregate counts and tree hash
```

| Tier | Count | Purpose |
|:--|--:|:--|
| `smoke` | 20 | Smallest basic modules, for every pull request |
| `core` | 0 | Resources, variables and outputs only |
| `advanced` | 487 | Data sources, locals, expressions, `count`/`for_each` |
| `modules` | 346 | Module composition |

Every basic module was small enough to enter `smoke`, so `core` is currently
empty. Tier is metadata rather than a directory, and both the smoke set and the
other tiers are derived deterministically; CI rejects a hand-edited tier.

See [docs/CONFORMANCE.md](docs/CONFORMANCE.md) for the L0–L4 oracle design and
[conformance/README.md](conformance/README.md) for provenance and regeneration.

---

## 🗺️ Timeline

| Milestone | Date | Highlights | State |
Expand All @@ -342,7 +374,13 @@ Oct 2026 Nov 2026 Dec 2026 Q1 2027 Q2 2027 2027+

```text
OpenIaC/
├── cmd/openiac/ CLI entry point
├── cmd/
│ ├── openiac/ CLI entry point
│ └── openiac-conformance/ Corpus collector and harness CLI
├── conformance/
│ ├── fixtures/ Vendored Terraform inputs with provenance
│ └── collection/ Source seeds, caps and license allowlist
├── internal/conformance/ Collector and conformance layers
├── pkg/
│ ├── ir/ Universal graph + topological sort
│ ├── parsers/hcl/ HCL2 → IR
Expand Down
863 changes: 863 additions & 0 deletions THIRD_PARTY.md

Large diffs are not rendered by default.

188 changes: 188 additions & 0 deletions cmd/openiac-conformance/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
// Command openiac-conformance maintains the conformance corpus.
package main

import (
"context"
"flag"
"fmt"
"os"
"os/exec"
"os/signal"
"strings"
"syscall"

"github.com/be-thomas/openiac/internal/conformance/collect"
)

func main() {
if len(os.Args) < 2 {
usage()
os.Exit(2)
}
switch os.Args[1] {
case "collect":
if err := runCollect(os.Args[2:]); err != nil {
fmt.Fprintln(os.Stderr, "openiac-conformance:", err)
os.Exit(1)
}
case "verify":
if err := runVerify(os.Args[2:]); err != nil {
fmt.Fprintln(os.Stderr, "openiac-conformance:", err)
os.Exit(1)
}
case "lock":
if err := runLock(os.Args[2:]); err != nil {
fmt.Fprintln(os.Stderr, "openiac-conformance:", err)
os.Exit(1)
}
case "-h", "--help", "help":
usage()
default:
fmt.Fprintf(os.Stderr, "unknown command %q\n", os.Args[1])
usage()
os.Exit(2)
}
}

func usage() {
fmt.Fprint(os.Stderr, `usage: openiac-conformance <collect|verify|lock> [flags]

collect downloads upstream modules and rewrites the fixture tree.

-config string sources file (default conformance/collection/sources.json)
-out string fixture tree (default conformance/fixtures)
-lock string lock file (default conformance/corpus.lock.json)
-third-party string attribution file (default THIRD_PARTY.md)
-report string run report (default .cache/conformance/collect-report.json)
-limit int override registry module cap
-pages int override registry page cap
-min-downloads int override registry popularity floor
-workers int concurrent downloads (default 6)
-v verbose progress

verify checks the committed tree against its lock, attribution and fixture
metadata. It never writes or uses the network.

-config string sources file (default conformance/collection/sources.json)
-out string fixture tree (default conformance/fixtures)
-lock string lock file (default conformance/corpus.lock.json)
-third-party string attribution file (default THIRD_PARTY.md)

lock rewrites the lock and attribution from the fixture tree. It never writes
to the fixture tree and never uses the network.

-config string sources file (default conformance/collection/sources.json)
-out string fixture tree (default conformance/fixtures)
-lock string lock file (default conformance/corpus.lock.json)
-third-party string attribution file (default THIRD_PARTY.md)
`)
}

func runCollect(args []string) error {
fs := flag.NewFlagSet("collect", flag.ExitOnError)
configPath := fs.String("config", "conformance/collection/sources.json", "sources file")
out := fs.String("out", "conformance/fixtures", "fixture tree")
lock := fs.String("lock", "conformance/corpus.lock.json", "lock file")
thirdParty := fs.String("third-party", "THIRD_PARTY.md", "attribution file")
report := fs.String("report", ".cache/conformance/collect-report.json", "run report")
limit := fs.Int("limit", 0, "override registry module cap")
pages := fs.Int("pages", 0, "override registry page cap")
minDownloads := fs.Int("min-downloads", 0, "override registry popularity floor")
workers := fs.Int("workers", 6, "concurrent downloads")
verbose := fs.Bool("v", false, "verbose progress")
if err := fs.Parse(args); err != nil {
return err
}

cfg, err := collect.LoadConfig(*configPath)
if err != nil {
return err
}
if *limit > 0 {
cfg.Registry.MaxModules = *limit
}
if *pages > 0 {
cfg.Registry.MaxPages = *pages
}
if *minDownloads > 0 {
cfg.Registry.MinDownloads = *minDownloads
}

logf := func(string, ...any) {}
if *verbose {
logf = collect.Logf
}
client := collect.NewClient(githubToken())
c := collect.New(cfg, client, collect.Options{
OutDir: *out,
LockPath: *lock,
ThirdPartyPath: *thirdParty,
ReportPath: *report,
Workers: *workers,
Logf: logf,
})

ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
if err := c.Run(ctx); err != nil {
return err
}
fmt.Println(collect.Summary(c.Report()))
return nil
}

func runVerify(args []string) error {
fs := flag.NewFlagSet("verify", flag.ExitOnError)
configPath := fs.String("config", "conformance/collection/sources.json", "sources file")
out := fs.String("out", "conformance/fixtures", "fixture tree")
lock := fs.String("lock", "conformance/corpus.lock.json", "lock file")
thirdParty := fs.String("third-party", "THIRD_PARTY.md", "attribution file")
if err := fs.Parse(args); err != nil {
return err
}
cfg, err := collect.LoadConfig(*configPath)
if err != nil {
return err
}
res, err := collect.Verify(*out, *lock, *thirdParty, cfg)
if err != nil {
return err
}
fmt.Printf("verified %d fixtures, %d files, %d bytes\n", res.Fixtures, res.Files, res.Bytes)
return nil
}

func runLock(args []string) error {
fs := flag.NewFlagSet("lock", flag.ExitOnError)
configPath := fs.String("config", "conformance/collection/sources.json", "sources file")
out := fs.String("out", "conformance/fixtures", "fixture tree")
lock := fs.String("lock", "conformance/corpus.lock.json", "lock file")
thirdParty := fs.String("third-party", "THIRD_PARTY.md", "attribution file")
if err := fs.Parse(args); err != nil {
return err
}
cfg, err := collect.LoadConfig(*configPath)
if err != nil {
return err
}
l, err := collect.RefreshAggregates(*out, *lock, *thirdParty, cfg)
if err != nil {
return err
}
fmt.Printf("lock: %d fixtures, %d files, %d bytes, tree %s\n",
l.FixtureCount, l.FileCount, l.TotalBytes, l.TreeSHA256)
return nil
}

func githubToken() string {
for _, key := range []string{"GITHUB_TOKEN", "GH_TOKEN"} {
if v := strings.TrimSpace(os.Getenv(key)); v != "" {
return v
}
}
out, err := exec.Command("gh", "auth", "token").Output()
if err != nil {
return ""
}
return strings.TrimSpace(string(out))
}
Loading
Loading