Gravity Keep

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.

People and pipelines reach the session API over WebSocket and HTTPS. The API stores candidates and commits in Postgres and starts the Converge workflow, whose action runner calls Cloud Control in each managed account through a reactor role. CloudTrail events from each account reach an EventBridge bus and a queue that the reactor reads; a sweeper and an inventory search feed the same queue. PEOPLE AND PIPELINES gkeep / browser pipeline CONTROL PLANE ACCOUNT API GatewayWebSocket + HTTPS session Lambdassessions are data Postgrestree, commits Step FunctionsConverge, Revert action runnerone request each EventBridge bus+ SQS queue, DLQ reactorcompare, act sweeper, inventoryon a schedule source connectorGit, reverts EACH MANAGED ACCOUNT reactor roleleast privilege, per account AWS resourcesvia Cloud Control API CloudTrail + rulewrite events forwarded
Every call the action runner makes uses a role session named for its commit, so CloudTrail in every account shows which commit caused each change: 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.

LimitEffect on the design
Lambda runs 15 minutes at mostSessions are data; long waits are Wait states
WebSockets close after 2 hours, or 10 idleThe client reconnects with its session token
CloudTrail takes minutesDrift is found in minutes; the sweep covers the rest
Cloud Control rate limitsConcurrency limited per account and region
Resource Explorer lags, up to 36 hoursCloudTrail fills the gap; the index's age is shown
ThreatMain controls
A stolen session commits destructive changesReviewed production; destructive acknowledgment; retain by default; protect; passkeys
Forged or replayed eventsEvents are hints; the reactor reads state itself
A poisoned templateVersions resolved only at commit, digests recorded, every upgrade shown
A hold used to hide a changeExpiry, a total cap, alarms, and history
A secret leaksSecrets by reference only, never stored, planned, or logged
The control plane breaks itselfCommit confirmed on its own namespace; rescue templates outside it

The rules

Sessions, interfaces, and the control plane itself.

Sessions and interfaces

  1. CTL-041

    A candidate is stored by the control plane, not the client, and survives the loss of its connection.

  2. 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.

  3. CTL-043

    An operational-mode command never changes AWS or the configuration, except a request command, which is authorized and recorded like a commit.

The control plane itself

  1. CTL-044

    The control plane's own namespace is protected, reviewed, and requires commit confirmed for every change.

  2. 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.

  3. CTL-046

    If the control plane can't read an account, its resources are marked unknown rather than assumed stable, and an alarm fires.