Architecture — Secure Infrastructure Workspace

By Engineering Team•November 15, 2026•8 min read

This is the architecture chosen in ADR-INFRA-012 and ADR-INFRA-013, built from the scripts under .devcontainer/shared/ in the workspace repository. Requirement IDs refer to SR-INFRA-010 unless stated.

The pattern is the same for any provider. The diagrams show the Cloudflare implementation, the first one built: only the provider allowlist, the provider’s resources and the state endpoint change for another provider.

This page covers the pieces and their boundaries. The other architecture pages cover the rest:


1. System context

System context: the maintainer and the AI assistant use the workspace, which depends on 1Password, GitHub, Cloudflare and the Claude model API

Actor or system Relationship to the workspace
Maintainer Edits code and runs non-production and account-level changes from a dev container. Reviews, merges and dispatches the production workflows on GitHub. The only person who approves a secret release.
AI assistant (Claude Code) Edits code inside a dev container. Never receives a secret value, and cannot start the engine with one (SR-INFRA-004 SR-F-02).
1Password The one secret store. Values are released by op run on the host after Touch ID, into one command (SR-INFRA-002).
GitHub Holds the repositories and runs the production workflows. Production changes only from main (SR-INFRA-004 SR-F-06).
Cloudflare The provider: the state bucket, DNS zones, Pages projects and media buckets. Non-production is applied from a dev container, production from GitHub Actions.
Claude model API Where the assistant sends its requests, over HTTPS. It sees the code the assistant reads, never a released value.

2. Containers

Containers: the host runs VS Code, 1Password and the host scripts; three dev containers for non-production and account-level work; GitHub holds the repositories and production workflows; the Cloudflare account holds the state bucket, zones, Pages projects and media buckets

Host machine

Component Responsibility
VS Code Opens a dev container. The editor runs inside it, as vscode.
1Password (app and CLI) Holds every secret. op run resolves references or a 1Password Environment into the environment of one child command, after Touch ID. Nothing is exported or written to disk.
tofu-in-container.sh Starts the engine inside a running dev container as deployer, passing each variable by name only, so no value appears on a command line or in docker inspect. Refuses a production folder before any value is released, and refuses apply unless asked. (SR-F-03, SR-F-04)
state-history-copy.sh After a person’s apply, makes a server-side copy of the encrypted state under history/. (SR-F-13)

Dev containers

One container per layer or site environment, each holding only the repositories named in its start command (SR-F-12). All are built from the same shared scripts, with the assistant installed under the managed policy.

Container Applies Values come from
L1 bootstrap The account’s first layer (shared): state bucket and account alerts A hand-made, short-lived credential (SR-INFRA-005)
L2 project setup The non-production half of the layer that creates zones and per-project access That layer’s 1Password Environment
Site non-production One site’s non-production infrastructure (L3) That site’s non-production 1Password Environment
(no production container) — Production is applied only by GitHub Actions. tofu-guard refuses INFRA_ENVIRONMENT=prod and any prod folder in every container. (SR-F-11)

A container pushes code to GitHub and applies non-production to the provider. It never holds a production value.

GitHub

Component Responsibility
Repositories One per layer, and one per site.
infra.yml Plans, and on request applies, a site’s infrastructure (L3, L4) for one commit of main and one environment, only when a person starts it, non-production first.
app.yml Builds and deploys a site for one commit of main and one environment, only when a person starts it, non-production first.
setup-prod.yml Applies the production half of the project setup layer (L2), on a manual dispatch from main, and copies its state to history/.

Each workflow reads its values from its environment’s vault through a read-only service account, never from a person (SR-INFRA-002 SR-F-09). No workflow runs on a schedule. The steps are in Production Release and the site’s GitHub Workflow Architecture.

Cloudflare account

Component Responsibility
State bucket (R2) Private. Every layer’s encrypted state under workloads/, and retention-locked copies under history/.
Zones, DNS, WAF, TLS One zone per site and environment, with its records, firewall rules and TLS settings.
Pages projects One per site and environment.
Media buckets (R2) One per site and environment, served through the zone.

3. Inside one dev container

Dev container components: the vscode user runs the editor, the assistant and git with a secret scan; root-owned files hold the managed policy, tofu-guard and the provider allowlist; the deployer user holds the private work copy, the OpenTofu engine and its plugins

The container has three zones of ownership. harden-user.sh runs last at build and stops the build if vscode still has administrator rights afterwards.

Component Owner Responsibility
VS Code server vscode The editor and every extension. No administrator rights, no secret, cannot read deployer data. (SR-F-01, SR-F-02)
Claude Code vscode The assistant. Every tool call is checked against the managed policy. A claude shell function always starts it at the workspace root.
git and pre-commit vscode, hook root-owned A system-wide pre-commit hook runs gitleaks on every commit in every repository in the container. A commit is refused if gitleaks is missing.
Workspace and project repositories Volume The workspace repository and the repositories this container cloned. deployer reads them through membership of the vscode group, and never runs from them: the guard copies the project first.
Managed policy (/etc/claude-code) root Built from the reviewed .claude/settings.json. Hooks run from root-owned copies, hooks and permission rules from user, project and local settings are ignored, and bypass mode is disabled. Editing the workspace file inside the container changes nothing until a rebuild. (SR-F-10)
tofu-guard (/usr/local/bin) root The only way the engine runs. Checks the environment, copies the project, checks the copy and lock file, then starts the engine. (SR-F-05 to SR-F-09)
Allowlist and tofurc (/etc/tofu-guard) root The providers allowed, and an engine configuration that downloads only those, directly from the registry, with no local mirror folder.
Private work copy deployer The checked copy of the project the engine runs from. An edit made in the workspace after the check never reaches the run. (SR-F-06)
OpenTofu engine deployer Runs with the released values in its environment only. Talks to the provider API and the state bucket.
Plugins and data folder deployer Provider plugins, module cache and saved plans, readable by deployer only. (SR-F-02)

4. Where the assistant stops

Attempt Stopped by
Read an environment file or key material Env-guard hook and managed deny rules (SR-F-10)
Read the engine’s environment or deployer files Separate user, private folders (SR-F-02)
Run docker exec or docker inspect Managed deny rules (SR-F-10)
Change the guard, allowlist or policy Root-owned files, rebuild after review (SR-F-05)
Turn off a hook with a project or user setting Managed-only hooks and permission rules (SR-F-10)
Commit a secret Root-owned pre-commit hook with gitleaks
Edit code after the check Check runs on a private copy (SR-F-06)
Add a provisioner or an unlisted provider Guard refuses (SR-F-07, SR-F-09)
Redirect the provider to another host Guard refuses base_url and the matching environment variable (SR-F-07, SR-F-08)
Reach production No production container. tofu-guard refuses any production run, and production is changed only by reviewed GitHub Actions workflows (SR-F-11)