SR-INFRA-009 — Layered Environments and Free-Tier Budget: System Requirements

By Engineering Team•October 25, 2026•5 min read
Metadata Details
System Name Layered environments on one account
Document ID SR-INFRA-009
Author Engineering Team
Status Draft — design only, nothing here is provisioned

Traces back to BRD-INFRA-009. Implements workspace rules 09 to 12. The account model replaces the separate-account requirement of SR-INFRA-004 SR-F-01, per ADR-INFRA-010. Requirement IDs repeat across SRs; cite them with the document ID.


1. Functional System Requirements

ID Description Traceability (BRD)
SR-F-01 (Four Layers) Setup has four layers, each a workspace folder under .devcontainer/ and a root module: bootstrap (<bootstrap-repo>), project setup (<setup-repo>), and the site repository’s nonprod and prod roots. A layer is applied only after the layer before it. BR-1.2
SR-F-02 (Bootstrap Layer) The bootstrap layer creates the one central private state bucket (live state under workloads/, retention-locked copies under history/) and the credential that the project-setup layer uses. It is run once by a person with the one hand-created bootstrap credential, using a local encrypted state first and then migrating the state into its bucket, per workspace rule 10 section 2. BR-1.2, BR-1.3
SR-F-03 (Project-Setup Layer) The project-setup layer creates, for each environment, a state-access credential limited to the central bucket and a deployer credential limited to that environment’s zone. Dev and prod must use different zones. It is applied by a person only. BR-1.2, BR-1.4
SR-F-04 (Environment Layers) The non-production and production layers each declare only their own workload resources: storage, hosting project, the site’s DNS records (apex and www) and routes. The domain’s mail records are not site resources and are declared with the zone (SR-F-13). Each has its own root module, state key and passphrase. BR-1.3, BR-1.4
SR-F-05 (One Account, Two Zones) Both environments live in one Cloudflare account. Production uses the apex of <domain>; non-production uses the apex of <test-domain>, a separate zone. Each zone has its own certificate and settings. The test domain is a separate registered domain, not a subdomain, because a subdomain is a record inside the production zone and zone-scoped permission would cover both environments; see ADR-INFRA-010. BR-1.1, BR-1.5
SR-F-06 (Per-Environment Resources) Each environment has its own storage bucket and its own Pages project. Names follow <project>-<environment>-... per SR-INFRA-007, with non-production mapped to the dev environment value. BR-1.4
SR-F-07 (Token Hierarchy) Each layer’s credential can create or change only the resources its module declares. The deployer credentials hold no permission to create credentials. Only the bootstrap and project-setup credentials may hold the token-management permission; their lifetimes are in SR-NF-08. BR-1.2, BR-1.3
SR-F-08 (Values as References) Every layer has its own vault, <project>-<environment>. A person’s run receives the layer’s values from its 1Password Environment through the host wrapper, and a workflow from the vault through that environment’s read-only service account, per SR-INFRA-002. No workspace holds a value in its environment, mounts or image. BR-1.3
SR-F-09 (Workspace Contents) Each .devcontainer/ folder carries the toolchain and the code of its own layer. There is no production workspace: production layers are applied only by GitHub Actions, and no container can apply production, per SR-INFRA-004 SR-F-03 and SR-F-06. BR-1.3
SR-F-10 (Registrar Nameserver Step) After the zone exists, the registrar’s nameserver records are changed by hand to the two nameservers the zone reports. The step is documented in internal docs/infra/ and verified by a successful zone activation check. It is not automated. BR-1.6
SR-F-13 (Mail Records With the Zone) The project-setup layer declares each zone’s mail records (MX with priority, SPF and DMARC TXT, DKIM CNAME) in email.tf of its module, from the input email_dns_records keyed by project, in each environment’s root. Names are relative to the zone, so no domain is written in code. Records are never proxied and carry a per-record TTL (1 for automatic, or 60 to 86400 seconds). They are applied in the same run as the zone, before the registrar nameserver step (SR-F-10), so the domain answers mail queries from the moment it is pointed at the provider. A record type other than MX, TXT or CNAME, an MX without a priority, a CNAME on the apex, or a project not in domains fails the plan. BR-1.7

2. Non-Functional & Security Requirements

ID Specification Traceability (BRD)
SR-NF-01 (Free-Tier Budget) The design stays within these limits, confirmed against the provider’s published free plan on 2026-10-25: R2 10 GB of storage and 1 million Class A operations a month; Pages 500 builds a month with unlimited bandwidth; Workers 100,000 requests a day; one rate-limit rule and five custom rules per zone; Universal SSL for the apex and one wildcard level. Any change that would pass a limit is recorded first. BR-1.1
SR-NF-02 (State Isolation) Each root module has its own state key under workloads/ in the central bucket and its own passphrase variable. A pipeline or workspace holds only its own module’s passphrase. BR-1.4
SR-NF-03 (Scope Limits Known) The non-production deployer credential is limited to the test zone, so it cannot edit production DNS. It can still deploy to any Pages project in the account, because Pages permission is account-scoped, and any state-access credential can overwrite any state in the central bucket, because R2 permission is per bucket and not per path. These limits are recorded, not hidden. BR-1.5
SR-NF-05 (Zone Settings Owned by Code) Each zone’s settings and rules are declared in the site’s shared module (SR-INFRA-008 SR-F-08). A change in the dashboard is drift: it is brought back into code or reverted, never left as a quick fix. BR-1.5
SR-NF-06 (No Cross-Layer Credential) A layer’s vault is read only by that layer’s runs: no names file, 1Password Environment or workflow reference of another layer points at it. BR-1.3
SR-NF-08 (Token Lifetimes) The hand-made bootstrap credential is short-lived and is deleted after its apply. The hand-made project-setup credential, and the state key pair of its run, are kept expired between runs, rolled right before a run with a short expiry, and expired right after. Personal credentials created in code are short-lived; pipeline credentials have a bounded lifetime that each project chooses to fit how often it releases, and every expiry is checked in the plan. A pipeline credential’s value never leaves the project-setup run: a person rolls each new one in the dashboard into the site’s vault for that environment, which the site’s workflows read through a read-only service account, so no repository writes into another. BR-1.3
SR-NF-09 (Setup Credential Scope for Mail) The hand-made project-setup credential holds DNS edit on the account’s zones, used only to create and change each zone’s mail records (SR-F-13). It holds no hosting, storage, firewall or zone-settings permission; the site’s own records stay with the site layer’s credentials. BR-1.3, BR-1.7