06 · Architecture
The most privileged system you run, held to the strictest standard.
Gravity Keep is built from Lambda, Step Functions, Postgres, API Gateway, and EventBridge, in a dedicated account, with no cluster to run. It describes itself in its own tree, and it can be rebuilt from outside itself if a bad commit breaks it.
The shape
Sessions, a store, a workflow, and reactors.
Gravity Keep is built as a Gravity Standard application called keep: its configuration store is a data domain, a commit's convergence is a business process compiled to Step Functions, and an approval is a human task. That choice matters for trust: the control plane with the most privilege in the company meets the same threat model and evidence as everything else.
gk-COMMIT-42-update.Sessions
A session is data, not a process.
A Lambda runs for fifteen minutes; a configuration session can last an afternoon. Each command is one WebSocket message handled by one short invocation that loads the session from Postgres, does the work, and saves it. Dropped connections reconnect with a token, and the person sees only the prompt.
The store
Every commit keeps its whole configuration.
Commits, statements with the commit that introduced and ended them, each commit's resolved configuration, observed state, drift, holds, and requests. The configuration as of any commit is a recorded fact, never a sum of changes. Every commit is also copied outside the control plane.
Convergence
Step Functions, so waiting is free.
Plan, then waves in a Map state limited per account and region, each action one Cloud Control request polled with a Wait state, so a twenty-minute database creation costs no Lambda time. Types Cloud Control handles badly, such as ACM certificates, get hand-written runners with the same contract.
Observing AWS
Events, a sweep, and an inventory.
An organization trail and an EventBridge rule in each account forward write events to a queue the reactor reads. The sweeper reads managed resources on a schedule. The inventory asks Resource Explorer what exists. An account that can't be read is marked unknown and alarms.
Accounts and credentials
Least privilege, generated from the tree.
- The control plane runs in a dedicated account, never the organization's management account.
- In each managed account it assumes a reactor role whose permissions are generated from the types that account's tree contains. An account with no databases grants no database permissions; adding a type updates the role first.
- The management account gets a separate, narrower role, and changes there are reviewed.
- There are no long-lived AWS credentials. People sign in with passkeys; pipelines sign with their execution roles.
- For a hard backstop, an SCP can deny deleting protected types to every principal except the reactor role, enforced by AWS itself.
Managing itself
Its own namespace, and a rescue outside it.
A seed CloudFormation stack creates the minimum. A reviewed commit adopts it into /tidewater/gravity-keep, and from then on the control plane manages itself, under protection, review, and commit confirmed for every change. That namespace is never sourced from Git, because it holds what a rollback runs through.
Rescue. A bad commit can break the thing that would fix it. At every converged commit to its own namespace, the control plane exports that namespace as a CloudFormation template and stores it outside itself. If it can't converge, a person deploys the last good template, and it comes back as it was. Any subtree can be exported the same way, which is also the way out.
Limits and threats
Designed around what AWS won't do.
| Limit | Effect on the design |
|---|---|
| Lambda runs 15 minutes at most | Sessions are data; long waits are Wait states |
| WebSockets close after 2 hours, or 10 idle | The client reconnects with its session token |
| CloudTrail takes minutes | Drift is found in minutes; the sweep covers the rest |
| Cloud Control rate limits | Concurrency limited per account and region |
| Resource Explorer lags, up to 36 hours | CloudTrail fills the gap; the index's age is shown |
| Threat | Main controls |
|---|---|
| A stolen session commits destructive changes | Reviewed production; destructive acknowledgment; retain by default; protect; passkeys |
| Forged or replayed events | Events are hints; the reactor reads state itself |
| A poisoned template | Versions resolved only at commit, digests recorded, every upgrade shown |
| A hold used to hide a change | Expiry, a total cap, alarms, and history |
| A secret leaks | Secrets by reference only, never stored, planned, or logged |
| The control plane breaks itself | Commit confirmed on its own namespace; rescue templates outside it |
The rules
Sessions, interfaces, and the control plane itself.
Sessions and interfaces
- CTL-041
A candidate is stored by the control plane, not the client, and survives the loss of its connection.
- CTL-042
Every CLI command is a call to the same API a pipeline uses, and there is no route to change configuration that bypasses it.
- CTL-043
An operational-mode command never changes AWS or the configuration, except a
requestcommand, which is authorized and recorded like a commit.
The control plane itself
- CTL-044
The control plane's own namespace is protected, reviewed, and requires
commit confirmedfor every change. - CTL-045
In each managed account the control plane acts through a role it assumes per action with only the permissions that account's tree needs, and it holds no long-lived credentials.
- CTL-046
If the control plane can't read an account, its resources are marked unknown rather than assumed stable, and an alarm fires.