# Commit Model

> **Status:** Draft 0.2, 2026-11-23. How the configuration changes and how AWS is brought into line: candidates, commit check, commit and convergence, resource and namespace state, waiting, commit confirmed, drift, rollback, adoption, deletion and replacement, reviewed commits, who may commit, and Git-sourced namespaces. Companion to [Tree Model](tree-model.md), [Rules](rules.md), and [Command Reference](command-reference.md).

# 1. Purpose

On a Junos device a commit is close to instantaneous and close to transactional: the new configuration is checked, activated, and in force. AWS is neither. Creating a database takes minutes, an API call can fail halfway through a batch, and anyone with console access can change a resource behind the control plane's back.

So Gravity Keep separates two things that Junos treats as one:

1. **The commit**, which is atomic. The active configuration moves from one version to the next in a single database transaction, or not at all.
2. **Convergence**, which is eventual. Reactors make AWS match the active configuration, resource by resource, and record what they did.

A commit is therefore a promise about what *should* be true. Its convergence record is the proof of what *is* true. Every command and rule below follows from keeping those two apart and honest.

# 2. The candidate

A session edits a **candidate**: the active configuration as of some commit (its **base**), plus the session's changes.

| Mode | Command | Behavior |
|---|---|---|
| Private (default) | `configure` | The session's own candidate. Others can't see it. At commit, changes are merged onto the latest active configuration. |
| Exclusive | `configure exclusive /tidewater/lending/prod` | As private, and it also locks the named subtree. Nobody else can commit beneath it until the session commits, exits, or the lock times out. |

- **Conflicts are found, never overwritten** ([CTL-021](rules.md#candidate-and-commit)). If a newer commit changed a statement the session also changed, `commit` stops and names each conflict. `update` brings the newer commit into the candidate, keeping the session's changes where they don't conflict, and the person resolves the rest. This is the Standard's optimistic concurrency, applied to configuration.
- **A candidate outlives its connection.** It is stored in Postgres, keyed to the session, so a dropped WebSocket or a closed laptop loses nothing. `configure` in a new connection offers to resume ([architecture 3](architecture.md#3-sessions)).
- **Candidates expire** after seven days without an edit. An expired candidate is kept for thirty days and can be restored with `load candidate <session>`.
- `rollback 0` discards the session's changes, as in Junos.

# 3. Commit check

`commit check` does everything a commit would verify, and plans, without committing ([CTL-022](rules.md#candidate-and-commit)). It runs in this order, and a later step runs only when the earlier ones pass:

1. **Syntax and schema.** Every statement parses. Every property exists in its type's schema, with a value of the right type, enumeration, pattern, and length. Required properties are present.
2. **Tree.** Names are valid. Placement resolves for each resource's scope. Templates resolve to a published version within the constraint, re-resolved only where the commit changes the applying namespace ([tree-model 6.1](tree-model.md#61-version-constraints)), with a digest that matches any earlier record of that version, and their parameters are within bounds.
3. **Resolution.** Every value is resolved by the order in [tree-model 9](tree-model.md#9-how-a-value-is-resolved). Every guardrail holds.
4. **References.** Every reference resolves. The dependency graph has no cycle.
5. **Authority.** The person or pipeline may commit beneath every changed path ([CTL-036](rules.md#access-and-governance)). A review and `commit confirmed` are required wherever the commit **reaches**, not only where it edits: every namespace whose resolved configuration it changes counts, so a default changed at `/tidewater` that alters a production resource needs that production namespace's review. Reaching a reviewed namespace from above always means a second person's approval (a commit request), even when the namespace is Git-sourced, because its source governs only its own statements ([CTL-073](rules.md#access-and-governance), [section 10](#10-reviewed-commits)).
6. **Plan.** The difference between the resolved candidate and the **latest observed state** of every affected resource, as a list of actions.

The plan is grouped so the consequential lines are hard to miss:

```
[edit /tidewater/lending/prod]
eric@tidewater# commit check
configuration check succeeds
plan against observed state as of 2026-11-21 20:41:07 CST:
  create   3   /tidewater/lending/prod/intake/{iam.role/exec, logs.log-group/logs, lambda.function/fn}
  update   1   /tidewater/lending/prod/s3.bucket/documents  (lifecycle-configuration)
  replace  0
  delete   0
  retain   0
  drift    1   /tidewater/lending/prod/s3.bucket/documents  versioning-configuration status: Suspended (configured Enabled)
review   required: commit mode reviewed at /tidewater/lending/prod
```

A plan reports drift on the resources it touches, because committing will also correct it.

When a commit reaches beyond the namespace it edits, the plan opens with its **reach**, counted by the environment each affected resource is bound to, so a change high in the tree can't look like a small one:

```
reach    /tidewater defaults logs.log-group retention-in-days 400 -> 731
         affects 214 resources: dev 61, staging 58, production 95
review   required: reaches /tidewater/lending/prod, /tidewater/payments/prod, /tidewater/support/prod (commit mode reviewed)
``` It lists every template version the commit would move before the plan, so a range that picked up a new version is never a surprise.

Each create, replace, and delete shows the time it usually takes for its type when that is more than a minute (`create rds.db-instance/main  about 15m`), so a person knows before committing whether to wait with `and-wait` or walk away.

# 4. Commit and convergence

`commit` runs commit check again, then writes the new active configuration in one transaction and gives it the next number: `COMMIT-42`. The commit records its author, method, comment, base, source, the difference, and the check result ([CTL-024](rules.md#candidate-and-commit)).

**The commit is asynchronous.** `commit` returns as soon as the new configuration is written, with its number and what convergence will do. AWS work that takes minutes (a database, a certificate waiting for validation, a CloudFront distribution) runs in the background, and the tree shows its state while it does ([section 4.2](#42-resource-state)). A person who wants to stay until it is done uses `commit and-wait`; a pipeline uses `wait` ([section 4.5](#45-waiting)).

**Convergence starts at once.** It is a Business Process compiled to Step Functions ([architecture 5](architecture.md#5-convergence)).

## 4.1 Convergence

1. Compute the actions: compare the resolved active configuration with the latest observed state of each affected resource.
2. Order them by the reference graph. Creates and updates go outward from what is referenced. Deletes go the other way.
3. For each action in order: re-read the resource's current state, recompute the action against it, call Cloud Control API, wait for the request to finish, and read the result back.
4. Record how each action ended (`stable`, `failed`, or `superseded`) in the commit's convergence record, and update each resource's state.

- **Convergence always works toward the latest active configuration**, never toward an old one. Because every action is recomputed from state just before it runs, a superseded commit can't undo a newer one ([CTL-025](rules.md#convergence)).
- **One AWS request at a time per resource** ([CTL-059](rules.md#convergence)). If COMMIT-48 changes a database's instance class while COMMIT-47 is still creating it, the update waits for the create to finish and is then recomputed from what AWS holds. A request is never cancelled halfway, because AWS can't be trusted to leave a cancelled resource in a known state.
- **A converging limit for each type** ([CTL-064](rules.md#convergence)). Some AWS work takes minutes and some takes days: an ACM certificate waits for DNS validation for up to 72 hours. The type table gives each type a limit, and a create or update still `converging` when it runs out becomes `failed` with the reason. `converging` never means forever.
- **Waiting on a reference is not a failure.** A function that references a database's endpoint is `converging`, waiting on the database, until the database is stable. Only when the database fails does the function stop being attempted.
- **Retries are bounded.** Each action is retried with backoff up to a fixed number of times, then marked `failed` ([CTL-026](rules.md#convergence)). A failed convergence is never retried silently in a loop. It waits for a person's next commit or for `request reconcile`.
- **A failed convergence does not roll back automatically**, except under commit confirmed. Partial progress is real progress: the person fixes forward with a new commit or rolls back with `rollback 1` ([section 7](#7-rollback)). Commit check states this before every commit with more than one resource.

## 4.2 Resource state

Every managed resource is in exactly one of five states, each shown with a short reason ([CTL-060](rules.md#convergence)). A state says **who has to act**, so a person reading the tree knows what to do.

| State | Meaning | Who acts | Reasons shown |
|---|---|---|---|
| `stable` | Observed state matches the resolved configuration | Nobody | |
| `converging` | The control plane has work in hand and will finish it on its own | The control plane | creating, updating, or deleting (with the commit and elapsed time); pending validation (a certificate); waiting on a referenced resource; correcting drift (with who made the change); queued behind a request in flight |
| `drifted` | Observed differs from configured, and the control plane won't correct it on its own | A person: commit, reconcile, or release the hold | `report` policy; an active hold; remediation stopped for fighting; a missing stateful resource; an `observed` namespace |
| `failed` | The control plane tried and couldn't | A person: fix forward or roll back | AWS refused (with the error); retries ran out; blocked by a referenced resource that failed |
| `unknown` | The control plane can't read the resource's account, so it can't say ([CTL-046](rules.md#the-control-plane-itself)) | A person: restore access | the account and the error |

```
eric@tidewater> show status /tidewater/lending/prod/east
acm.certificate/cdn                  converging   pending validation (DNS, 4m)
route53.record-set/cdn-validation    stable
cloudfront.distribution/site         converging   waiting on acm.certificate/cdn
rds.db-instance/main                 converging   creating (COMMIT-47, 6m, about 15m expected)
lambda.function/fn                   converging   waiting on rds.db-instance/main
ec2.security-group/intake            converging   correcting drift (sam@tidewater.com, console)
s3.bucket/documents                  drifted      hold 3, until 00:41
cloudwatch.alarm/errors              failed       blocked by lambda.function/fn
```

Under `remediate`, a console change goes straight to `converging`: it is being dealt with, and the reason says it was drift. So **`drifted` always means the difference stays until a person acts**, and that is the state worth alarming on ([CTL-061](rules.md#drift)). Drift is still recorded as an event every time, whoever corrects it, so `show drift` and the corrections history show what happened even when the state never said `drifted`.

## 4.3 Namespace state

A namespace shows the **worst** state of everything beneath it, in this order: `unknown`, `failed`, `drifted`, `converging`, `stable`, and counts of the rest. `unknown` comes first because the control plane can't vouch for anything beneath it.

```
eric@tidewater> show status /tidewater/lending
/tidewater/lending                  failed       1 failed, 1 drifted, 3 converging
  /tidewater/lending/dev            stable
  /tidewater/lending/prod           failed       1 failed, 1 drifted, 3 converging
    /tidewater/lending/prod/east    failed       1 failed, 1 drifted, 3 converging
    /tidewater/lending/prod/west    stable
```

`show configuration | display status` prints the tree with each resource's state and reason as a `##` note, the way `display inheritance` shows where values came from.

## 4.4 Commit state

A commit's state is about the commit, not the tree: a commit *converges*, a resource *is stable*.

| Commit state | Meaning |
|---|---|
| `converging` | Some of its actions are still running or waiting. |
| `converged` | Every action ended with the resource `stable`. |
| `failed` | At least one action failed or was blocked, and the rest ended stable. |
| `superseded` | A newer commit took over before this one finished. |
| `pending-confirmation` | Converged under `commit confirmed`, waiting to be confirmed ([section 5](#5-commit-confirmed)). |
| `reverted` | Not confirmed in time, or reverted by `request revert`, by a later commit. |

## 4.5 Waiting

`commit` doesn't wait for AWS. Three commands do, for when someone or something needs the result before going on:

| Command | Waits until |
|---|---|
| `commit and-wait` (configuration mode, like `commit and-quit`) | The commit's convergence finishes. `commit confirmed 10 and-wait` waits, then starts the timer, as usual |
| `wait commit <n> [timeout <d>]` | Every resource the commit affected is `stable`, or the commit fails or is superseded |
| `wait <path> [timeout <d>]` | Everything beneath the path is `stable`, whatever made it otherwise. For a release that depends on another team's database |

| Exit code | Meaning |
|---|---|
| 0 | Stable |
| 1 | Failed |
| 2 | Timed out while something was still `converging`, `drifted`, or `unknown` |
| 3 | Superseded by a newer commit (`wait commit` only); wait on the path instead if the newest state is what matters |

A `drifted` or `unknown` resource never counts as stable, so a wait on one times out rather than passing ([CTL-062](rules.md#convergence)). The default timeout is one hour. `monitor commit` and `monitor drift` remain the way to watch progress as it happens; `wait` is the way to depend on it.

# 5. Commit confirmed

`commit confirmed 10` commits as usual and starts a ten-minute timer **when convergence finishes**, not when the commit lands, because AWS work can outlast a short timer. If the person does not confirm before the timer runs out, the control plane reverts: it commits the previous configuration, as `COMMIT-n+1`, authored by `gravity-keep` on behalf of the original author, with the comment `automatic revert of COMMIT-n: not confirmed` ([CTL-027](rules.md#candidate-and-commit)).

- **Confirm** with `commit` (with or without further changes), or `commit check`, as in Junos.
- **If convergence fails**, the revert happens at once. The point of commit confirmed is to get back to a known working state.
- **Destructive changes are refused** under commit confirmed ([CTL-028](rules.md#candidate-and-commit)). Recommitting can't bring back the data of a stateful resource or the identity of an identity-bearing one, so a commit that can't be undone can't promise to undo itself.
- While a commit is pending confirmation, other commits beneath the same namespaces are refused, so the revert restores exactly what it should.
- Under a reviewed namespace the same protection is `commit request confirmed <minutes>`: the commit happens on approval, and the **author** confirms it, because the author is the one about to check that it works.
- **Policy can make it automatic.** `policy commit confirmed required [ ec2.security-group wafv2.web-acl ec2.network-acl iam.role ] minutes 10;` makes any commit from a session or a commit request whose plan touches a listed type a `commit confirmed 10`, without the person typing it. Commit check says so: `confirmation  required by policy at /tidewater: 10 minutes, by eric`.
- **Loads from a Git source are never confirmed** ([CTL-027](rules.md#candidate-and-commit)). Commit confirmed is a dead-man's switch: it needs a person at a terminal who is about to check the change. A merged pull request has no such person, because whoever merged it has moved on by the time it converges. The pull request confirms the intent; a bad Git change is rolled back with `request revert` ([section 12.2](#122-rolling-back-a-git-change)).

This is the protection network engineers rely on when a change might cut off their own access: a WAF rule that blocks the office, a security group that drops the bastion, an IAM change that removes the control plane's own permission to fix it. Review doesn't replace it: in [session 5](samples/session-05-commit-confirmed.md) the approver read the typo and approved it, and the timer is what got the office back.

# 6. Drift

**Drift** is a managed property whose observed value differs from its resolved configured value, after both are normalised as the type table says ([tree-model 4.2](tree-model.md#42-comparing-values)). Unmanaged properties are never drift ([tree-model 4](tree-model.md#4-resources-and-types)), and neither are `create` or `destroy` values or write-only properties ([tree-model 4.1](tree-model.md#41-lifecycle-phases), [4.3](tree-model.md#43-secrets-and-write-only-properties)).

**How drift is found** ([CTL-030](rules.md#drift)):

- **From events.** CloudTrail delivers write management events to EventBridge. A rule routes each event for a managed account to the reactor queue. The reactor finds the resources the event names, **reads their current state from AWS**, and compares. The event is only a hint about where to look. Its contents are never trusted as the new state.
- **From the sweep.** On a schedule (hourly by default, per namespace policy), the control plane reads every **managed** resource and compares. The sweep catches anything an event missed. Its cost grows with the tree, not with AWS, because it never lists types looking for things it doesn't manage; finding those is the inventory's job ([section 8.1](#81-the-inventory)).
- **From convergence.** Every action reads state before it acts.

The control plane's own changes also arrive as CloudTrail events. They need no special handling: the reactor reads the resource, finds it stable, and does nothing.

**What happens next** depends on the namespace's `policy drift`:

| Policy | On drift | Typical use |
|---|---|---|
| `remediate` | The reactor pulls the resource back to its configuration and records a **correction** against the active commit, naming who made the change, from CloudTrail. The owner is notified. | Default. Production. |
| `report` | The drift is recorded and the owner notified. Nothing changes until a commit or `request reconcile`. | During a migration from Terraform, or for teams learning the tool. |

A namespace whose `policy ownership` is `learning` doesn't remediate or report drift: it writes changes made outside a commit into the tree ([section 8.3](#83-learning)).

Under `remediate`, a drifted resource shows as `converging` while it is corrected; under `report`, it shows as `drifted` until someone acts ([section 4.2](#42-resource-state)).

**When AWS made the change.** CloudTrail marks changes that an AWS service made itself, such as Application Auto Scaling or RDS maintenance. The drift reason names it (`changed by AWS (application-autoscaling)`), and when such a resource is stopped for fighting, the alarm suggests moving the property into `create`, because the usual cause is a property AWS is meant to own (CTLQ-026).

Three cases are handled more carefully, whatever the policy:

- **A resource that keeps drifting.** If the same resource is corrected more than three times in an hour, remediation stops for that resource and an alarm fires ([CTL-032](rules.md#drift)). Someone or something is fighting the control plane, and a person needs to find out what.
- **A missing stateful resource.** If a stateful resource (a bucket, a database, a table, a key) is found missing, it is **reported, never recreated**, even under `remediate` ([CTL-031](rules.md#drift)). Recreating an empty database in place of a deleted one hides the loss. A person decides, with a commit.
- **A hold.** `request hold` suspends remediation beneath a path for an emergency change made outside a commit ([section 6.1](#61-holds)).

## 6.1 Holds

`request hold /tidewater/lending/prod duration 2h reason "INC-2291: widening SG for vendor diagnostics"` suspends remediation beneath the path. A hold is the break-glass route: it is always available to anyone granted `hold`, and it is never silent ([CTL-033](rules.md#drift)).

- **Drift is still observed and recorded** while a hold lasts. Held resources show as `drifted`, with the hold as the reason.
- **Warnings before it ends.** Thirty and ten minutes before a hold ends, its holder, the namespace's owners, and the hold's notification channels are told exactly what will be pulled back, and how to keep it or get more time. The same notice appears at the top of the holder's open sessions, and `show holds` shows the time left.

  ```
  Hold 3 on /tidewater/lending/prod/east/intake ends in 30 minutes (00:41).
    will be pulled back:
      ec2.security-group/intake-lambda  security-group-egress - { tcp 8443 203.0.113.0/24 }  (sam, console, 22:43)
    keep it:    request hold capture 3
    more time:  request hold extend 3 duration 1h reason "..."
  ```

- **Extensions, up to a total.** `request hold extend <id> duration <d> reason "<text>"` may be run any number of times, by anyone granted `hold`, so the original holder needn't be awake. Each extension needs its own reason and is no longer than the policy's maximum hold (four hours by default), and all of them together stop at the policy's total (24 hours by default). Past the total, the change is captured or pulled back; a hold can't quietly become a permanent change.
- **Capture keeps a held change** ([CTL-075](rules.md#drift)). `request hold capture <id> [resource <path>]` reads the observed values of the held drift (all of it, or one resource's) and writes them as desired state, the way `adopt` does. In a direct namespace they land in the person's candidate, ready to commit; in a reviewed namespace they become a commit request, so a second person still approves; beneath a Git source they are printed as a fragment for a pull request, and the person extends the hold to cover the review.
- **At expiry, only what wasn't committed is pulled back.** Remediation resumes, and anything still different from the configuration is corrected.
- **A hold with nothing left to pull back ends itself.** Once every held change has been committed, by capture or by hand, the hold ends early, with a notice and a history entry. That changes no configuration; it only ends a suspension with no work left.
- Holds are listed in `show holds` and are part of history, with every extension, capture, and reason.

# 7. Rollback

`rollback <n>` in configuration mode replaces the candidate with the active configuration as of `n` commits ago. `rollback 0` discards the session's own changes. `rollback commit 41` names a commit directly. The person reviews with `show | compare` and commits, so **a rollback is a new commit**, and history stays a straight line ([CTL-029](rules.md#ownership-and-deletion)).

Rollback restores **configuration**. It cannot restore data, and commit check says so for every affected stateful resource:

```
plan against observed state as of 2026-11-21 21:02:44 CST:
  create   1   /tidewater/lending/dev/s3.bucket/scratch
               note: this resource was deleted by COMMIT-38; it will be created empty, and its objects are not restored
  re-adopt 1   /tidewater/lending/dev/rds.db-instance/main
               note: retained by COMMIT-38 and still present; it returns to the tree unchanged
```

**`request revert commit <n>`** is the fast route back, from operational mode, for anyone granted `revert` ([CTL-058](rules.md#candidate-and-commit)), such as on-call. It commits, at once, the configuration from before COMMIT-n beneath the paths COMMIT-n changed. It is refused if a later commit changed those paths, because then it would undo more than one change; use `rollback` and review the result instead. A revert needs no second person even beneath a reviewed namespace, because it restores a configuration that was already reviewed, but its plan is shown, a destructive plan needs `acknowledge destructive <count>`, and an alarm fires to the namespace's owners, as for a hold.

A stateful resource that was **retained** when it left the tree is still in AWS, tagged as retained. Rolling back to a configuration that includes it **re-adopts** it rather than creating a new one, so a rollback after a retained deletion loses nothing.

A Git-sourced namespace is rolled back in Git, by reverting the file and loading it. A rollback of a parent leaves Git-sourced subtrees as they are, and commit check lists them ([CTL-052](rules.md#sources)).

# 8. Supervision: bringing resources in and letting them go

A resource is **supervised** when it is in the tree. Four operations move resources across that line, and the first three bring knowledge from AWS into the tree:

| Operation | Direction | Scope | Started by |
|---|---|---|---|
| **Adopt** | In | One named resource | A person |
| **Explore** | In | A targeted area, searched once | A person |
| **Learn** | In | A namespace's area, as activity happens | CloudTrail, continuously |
| **Evict** | Out | Resources or a whole branch, left running in AWS | A person |

None of them creates or deletes anything in AWS. Bringing a resource in changes nothing but its tags; letting it go removes only those tags.

An **area** is always a namespace's placement (its accounts and regions, by inheritance), optionally narrowed by types, regions, and tags. Explore takes the filters as arguments; learning reads them from the namespace's policy.

**Unmanaged resources are never changed or deleted** ([CTL-035](rules.md#ownership-and-deletion)), whatever the policy says. The control plane does not own what it was not given.

## 8.1 The inventory

The control plane keeps a list of what exists in every managed account and region, so that each resource is either **in the tree** or **unmanaged** ([CTL-034](rules.md#ownership-and-deletion)). The list needs only what a resource is (its ARN, type, region, and tags), not its properties, so it comes from an **inventory source** rather than from Cloud Control ([CTL-076](rules.md#ownership-and-deletion)):

- **The requirement:** a source that lists every resource of every type it covers, in every managed account and region, at least daily. Each implementation chooses it and records the choice as a `DESIGN-nnn`.
- **The default: AWS Resource Explorer**, with an aggregator index for the organization, set up by a delegated administrator. It has no charge of its own (the services it calls may charge for their list calls), and one search covers every account. It is eventually consistent, and AWS says replication can take up to 36 hours, so CloudTrail create events fill the gap until the next search.
- **AWS Config**, where a company already runs it, may be the inventory source instead, and its change notifications may feed the reactor queue as hints, like CloudTrail events (CTLQ-030). Gravity Keep never requires it, because it charges for every configuration item it records.
- **Coverage is stated, never assumed.** No source covers every type. `show unmanaged` lists the types the inventory source doesn't cover in each area, so "nothing is unknown" means nothing is unknown silently.

`show unmanaged <path>` lists what is in the namespace's area but not in the tree. Resources tagged `managed-by terraform`, or with a CloudFormation stack tag, are listed as managed by that tool.

## 8.2 Adopt and explore

**Adoption** brings one existing resource into the tree without replacing it:

```
eric@tidewater# adopt arn:aws:s3:::tidewater-legacy-documents at /tidewater/lending/prod name legacy-documents
reading arn:aws:s3:::tidewater-legacy-documents ... done
added to candidate: /tidewater/lending/prod/s3.bucket/legacy-documents (14 properties from observed state)
review with: show resource s3.bucket legacy-documents
```

**Explore** does the same for everything unmanaged in a targeted area:

```
[edit /tidewater/legacy]
eric@tidewater# explore types [ s3.bucket lambda.function iam.role ] regions [ us-east-2 ] tags { team lending; }
searching the inventory (Resource Explorer, indexed as of 2026-12-04 08:00) ... 23 unmanaged resources
reading 23 resources through Cloud Control ... done
added to candidate beneath /tidewater/legacy:
  s3.bucket        9   lambda.function   8   iam.role   6
not covered by the inventory in this area: none of the requested types
review with: show | compare
```

- Both write the resources' current properties into the **candidate**, each with `adopt-from` and a name taken from the resource's own name, made valid. The person removes what they don't want, then commits. Nothing is adopted until the commit.
- Explore needs at least one narrowing filter beyond the namespace's placement, unless the person adds `all`, so that a search of a whole account is a deliberate choice. It reports what the inventory doesn't cover, and how old its index is.
- Beneath a Git source there is no candidate to write to: both print the resources as a fragment for a pull request ([tree-model 11.2](tree-model.md#112-what-a-git-source-allows-and-refuses)).
- **An adopting commit makes no change to AWS** apart from tags ([CTL-035](rules.md#ownership-and-deletion)). If the namespace's defaults or guardrails would change a resource, commit check reports it and the commit is refused. The person either sets the resource's own statements to match what exists, or adopts first and changes it in a second commit. Say it, then do it. In an `observed` or `learning` namespace the commit is not refused: a guardrail the resource violates is recorded as a **finding**, because reporting reality is the point.
- Adoption into an `owned` or `learning` namespace adds the `managed-by` and `gravity-path` tags. Adoption into an `observed` namespace changes nothing at all, which is how Gravity Keep watches resources that Terraform still owns ([adoption-path 1](adoption-path.md#1-observe)). Ownership moves to Gravity Keep only after Terraform's state no longer holds the resource ([adoption-path 2](adoption-path.md#2-own)).

## 8.3 Learning

A namespace with `policy ownership learning` is filled in by activity in its area ([CTL-077](rules.md#ownership-and-deletion)):

```
namespace sandbox {
    placement { account 111100000090; }
    policy {
        ownership learning;
        learn { types [ s3.bucket lambda.function iam.role logs.log-group dynamodb.table sqs.queue sns.topic ]; }
    }
}
```

- **Commits still change AWS**, as in an `owned` namespace. What differs is what happens to changes made outside a commit: a resource created in the area is adopted, a change to a supervised resource is written into its statements, and a resource deleted in AWS is removed from the tree. Each is a commit authored by `gravity-keep`, crediting the identity CloudTrail names; beneath a reviewed namespace it is a commit request instead.
- Learning writes every observed managed property onto the resource itself, so a default or a fixed guardrail value never changes what was learned. A guardrail the resource violates is recorded as a finding, not a failure, so learning never stalls.
- CloudTrail tells learning about new resources within minutes; the inventory catches any it missed at the next search.
- **One learner per area.** Commit check refuses two learning namespaces whose areas overlap, unless their type or tag filters keep them apart, so a new resource lands in exactly one place. Anything no learner claims stays on the unmanaged list.
- Learning is not allowed beneath a Git source, because its changes would have nowhere to be written but the file ([CTL-052](rules.md#sources)).

`ownership` therefore has three settings:

| `policy ownership` | Commits change AWS | Changes outside a commit |
|---|---|---|
| `owned` | Yes | Remediated, or reported, by `policy drift` |
| `learning` | Yes | Written into the tree |
| `observed` | No | Reported; nothing is ever changed, including tags |

## 8.4 Evict

**Eviction** takes resources out of supervision and leaves them running in AWS ([CTL-078](rules.md#ownership-and-deletion)). It is the opposite of adoption, and the way out for a team moving a branch to another tool, or handing resources to another company.

```
[edit /tidewater]
eric@tidewater# evict /tidewater/support/prod/reporting
removed from candidate: 14 resources beneath /tidewater/support/prod/reporting, to be evicted

eric@tidewater# commit check
plan against observed state as of 2026-12-04 10:15:02 CST:
  evict   14   /tidewater/support/prod/reporting/*   (left in AWS; managed-by and gravity-path tags removed)
  references  none from the rest of the tree
```

- An evicted resource is untagged and listed as unmanaged. It is never deleted, snapshotted, or changed otherwise, so eviction needs no destructive acknowledgment.
- `evict <path> [types [ ... ]] [tags { ... }]` takes a resource, a whole branch, or a filtered part of one. A reference from what stays in the tree to what is evicted fails commit check, as any reference out of the tree does ([CTL-020](rules.md#references)).
- A protected resource or namespace can't be evicted until its protection is removed, as for deletion ([CTL-048](rules.md#ownership-and-deletion)).
- **Beneath a Git source,** removing a resource from the file deletes it, subject to its deletion policy. To evict instead, a first pull request sets `destroy { deletion evict; }` on the resources, and a second removes them; the deletion follows the `destroy` block of the last commit that held them ([CTL-070](rules.md#resources-and-types)).
- An evicted resource that is still in AWS is re-adopted, not recreated, by a rollback to a configuration that includes it.

# 9. Deletion and replacement

Removing a resource from the tree, or changing a create-only property, is a **destructive** change when the resource is **stateful** or **identity-bearing** ([CTL-074](rules.md#candidate-and-commit)). Both are columns of the type table ([tree-model 4](tree-model.md#4-resources-and-types)).

- **Stateful** types hold data that recreating can't bring back: `s3.bucket`, `rds.db-instance`, `rds.db-cluster`, `dynamodb.table`, `kms.key`, `efs.file-system`, `logs.log-group`, `secretsmanager.secret`, `ecr.repository`, `ec2.volume`, `backup.backup-vault`, `route53.hosted-zone`, `ec2.eip`, and others added by recorded decision. A hosted zone and an Elastic IP are on the list for what others hold rather than what they store: a new zone gets new name servers, so the parent domain's delegation (often at a registrar outside AWS) stops working, and a new address is missing from every partner's allowlist. Losing either is as costly as losing data, and keeping one is harmless, so they are retained by default.
- **Identity-bearing** types have an identity that others hold and recreating can't restore, even under the same name. An IAM role's unique ID is what every resource policy naming it actually stores, in any account, so after a delete those policies show an orphaned ID that a new role of the same name doesn't match. A security group's `sg-` ID is held by rules in other groups, by the network interfaces of unmanaged resources, and by peered accounts. A CloudFront distribution's or an API's generated domain name is held by DNS and clients outside the tree.

Inside the tree, recreating an identity-bearing resource mostly heals itself: references re-resolve to the new ID, and an orphaned ID in a key or bucket policy shows as drift that remediation rewrites. Outside the tree nothing heals, and commit check can't see who is there, so it says so:

```
  delete   1   /tidewater/lending/dev/intake/iam.role/exec   (identity-bearing: unique ID)
               4 references in the tree will be updated; holders outside the tree can't be found
```

A type whose identity only the tree holds (a WAF rule group referenced only by a web ACL in the tree) is not identity-bearing, so the list stays short.

| When a stateful resource leaves the tree | Under `deletion` (the resource's `destroy` block, else `policy deletion`) |
|---|---|
| It stays in AWS, untagged from its path and tagged `gravity-retained <commit>`, and is listed in `show retained` | `retain` (default) |
| A final snapshot or backup is taken, then it is deleted | `snapshot` (types that support it) |
| It is deleted | `delete` |
| It stays in AWS with Gravity Keep's tags removed, and is listed as unmanaged, as if evicted ([section 8.4](#84-evict)) | `evict` |

A KMS key is never deleted at once. Its deletion is scheduled with a waiting period, its `pending-window-in-days` destroy value, thirty days by default and the longest AWS allows, and can be cancelled by a rollback within that time. Every deletion follows the resource's `destroy` block as it stood in the last commit that held it ([tree-model 4.1](tree-model.md#41-lifecycle-phases)).

- **Destructive changes need acknowledgment** ([CTL-028](rules.md#candidate-and-commit)). Commit check lists them under `delete` and `replace`. `commit` refuses them unless the person types `commit acknowledge destructive <count>`, where the count matches the plan. A pipeline must pass the same acknowledgment in its load request, so nobody deletes a database by accident in either route.
- **Protected resources** can't be deleted, moved, or renamed in any commit while `protect` is set ([tree-model 8](tree-model.md#8-bindings-policy-and-access)). Removing `protect` is its own commit.
- **Replacement** creates the new resource before deleting the old one when the type allows two to exist side by side, and deletes first only when it must (a fixed name). Delete-first is shown as such in the plan.
- **A resource built from an early attribute** (a certificate's validation record) is still needed after the resource it came from is stable: ACM uses the record to renew the certificate. Commit check warns when a commit deletes one while the resource it came from stays.
- **Moves don't replace by accident.** A template that derives a physical name from `${namespace}` (a role named after its function) would otherwise replace the role when the namespace moves or is renamed. Because the name is an inherited create-only value, it applies only to new resources ([CTL-071](rules.md#resources-and-types)): the existing role keeps its name and identity, and commit check notes the difference.
- **Other** resources (functions, alarms, policies, rule groups) are simply deleted when removed, and need no acknowledgment. Identity-bearing ones that aren't stateful (roles, security groups) are deleted too, not retained, because a role left behind is a risk of its own, but only with acknowledgment.

# 10. Reviewed commits

A namespace with `policy commit mode reviewed` accepts a change in one of two ways ([CTL-038](rules.md#access-and-governance)):

1. **From its Git source.** The namespace is Git-sourced ([tree-model 11](tree-model.md#11-sources)), and its branch requires a reviewed pull request to merge. A pipeline runs `load source` at the merged commit, then `commit`. The commit records the repository, branch, file, and commit SHA. This is how the Standard's "infrastructure applied by pipeline only" is kept for production.
2. **By a second person**, when the namespace is sourced in the control plane. A session runs `commit request comment "..."`. The request freezes the difference against its base. Another person with `approve` runs `request commit approve 17` from operational mode, sees the same difference and a fresh plan, and the request becomes a commit. The approver can never be the author. If the base has moved and the request no longer merges cleanly, approval is refused and the author runs `update`.

Both routes end in the same kind of commit. The history says which route was taken.

# 11. Who commits

| Author | How | Examples |
|---|---|---|
| A person | Signs in with SSO (passkeys at minimum), opens a session, commits | Interactive work in dev namespaces; approvals |
| A pipeline | Its execution role calls the API, loads its namespace's Git source, commits | Production changes; application releases that change infrastructure |
| The control plane | Itself, always naming on whose behalf | Automatic reverts, requested reverts (and their Git revert commits), learning, expiring candidates |

Every commit has exactly one author and, where it acts for someone, the person it acts for ([CTL-039](rules.md#audit-and-history)). There is no anonymous change, and there is no change outside a commit, apart from remediation corrections, which are recorded against the active commit with the CloudTrail identity they reversed.

# 12. Git-sourced namespaces

A Git-sourced namespace ([tree-model 11](tree-model.md#11-sources)) goes through the same commit check, commit, and convergence as any other. Only the way its candidate is made differs, and three things that are simple in a session need a rule when the desired state is held in Git.

## 12.1 Loading

```
gkeep tidewater load source /tidewater/lending/prod at 9f3c2e1
```

`load source` reads the declared file at the named commit (the branch head if none is named) and replaces the subtree with it in a candidate. Before anything else, the control plane checks that the commit is on the declared branch and descends from the last commit it loaded or wrote ([CTL-053](rules.md#sources)). Then commit check runs as usual. The commit records the repository, branch, file, the commit loaded, and the one it moved forward from.

A load that changes nothing still commits nothing: it moves the recorded Git commit forward and says so.

## 12.2 Rolling back a Git change

A Git change isn't confirmed by a timer ([section 5](#5-commit-confirmed)), so getting back from a bad one has to be quick. The ordinary route (a revert pull request, a review, a merge, and a pipeline that builds and passes staging) can take an hour while the office is locked out.

So on-call runs `request revert commit 47` ([section 7](#7-rollback)). The control plane commits the reverted configuration at once, then makes **its one write to Git** ([CTL-054](rules.md#sources)): a revert commit on the declared branch, authored by `gravity-keep` on behalf of the person who asked, with the message `revert of COMMIT-47 by request of sam`. That commit becomes the one later loads must descend from, so the next release can't bring the bad change straight back, and the fix is an ordinary pull request from there.

Because the rollback runs through the control plane, the pipeline roles, and the source connector, none of those can be Git-sourced ([CTL-057](rules.md#sources)). They live in the control plane's own namespace, under `commit confirmed`.

If the write fails (branch protection refuses it, or the revert conflicts with something merged since), the namespace is **out of step**. The tree is correct and Git is not. `show sources` lists it, an alarm fires, and loads are refused until a person, in a session, loads with `acknowledge out-of-step`, having fixed the file. Commit check shows plainly whether the reverted change is coming back.

## 12.3 Break glass

A Git-sourced namespace can't be changed in a session, even in an emergency. For AWS, a hold is still the route ([section 6](#6-drift)). For the desired state itself, a person with `commit` at the parent removes the source (`delete source prod`) in a commit, under the parent's review rules. That raises an alarm like a hold, and from then on the namespace is edited in sessions until a matching file is merged and the source declared again ([CTL-055](rules.md#sources)).

## 12.4 The copy outside the control plane

Whatever its source, every commit's resolved configuration is written outside the control plane ([CTL-056](rules.md#sources), [architecture 12](architecture.md#12-sources-and-export)). For a Git-sourced namespace the file is already there. For a namespace sourced in the control plane, this copy is the record a person can read without the control plane running. A copy is marked as an export and is never loaded as a source, so it can't become a second writer.

# 13. Questions

| # | Question | Leaning |
|---|---|---|
| CTLQ-008 | **Commit confirmed timer start.** Starting the timer at convergence protects slow changes, but leaves the person waiting for a long create. Should the timer start at commit for commits that only update existing resources? | Start at convergence always. One rule is easier to trust than two. |
| CTLQ-009 | **Correction limit.** Is three corrections an hour the right point to stop remediating on a fighting resource, and should it be set per namespace? | Fixed at three for the prototype; make it policy only if real cases need it. |
| CTLQ-010 | **Scheduled commits.** Junos has `commit at`. Is a commit scheduled for a maintenance window useful, or is that the pipeline's job? | Leave to the pipeline. A scheduled commit is a change nobody is watching. |
| CTLQ-011 | **Cross-namespace transactions.** Two independent subtrees committed together converge independently. Is a "converge together or not at all" grouping ever needed? | No. AWS can't provide it, and pretending would break the honesty in section 1. |
| CTLQ-020 | **Trusting branch protection.** Should the control plane check through the Git host's API that the loaded commit came through a merged pull request with an approval from someone other than its author, or trust the branch's protection rules? | Trust branch protection for the prototype, and record the pull request number when the host supplies it. Check approvals later, as the Standard's pipelines do. |
| CTLQ-021 | **Who loads.** A pipeline runs `load source` today. Should the control plane instead load on a webhook when the branch moves? | Keep the pipeline. It is where a company's delivery process already lives, and where any checks of its own (a Gravity Standard permit, for example) already run. |
| CTLQ-023 | **Rolling back a Git change on an alarm.** Should a Git-sourced namespace be able to say "revert the last load if these alarms fire within 15 minutes of convergence", the way CodeDeploy rolls back a deployment? | Not in the prototype. It needs a decision about which alarms count; `request revert` covers the need until then. |
| CTLQ-024 | **Attributes available before a resource is finished.** An ACM certificate stays pending until its DNS validation record exists, and that record's value comes from the pending certificate, so strict reference ordering would deadlock. | **Resolved 2026-11-23.** The certificate is one resource that stays `converging` (pending validation) until issued, within a 72-hour converging limit. Its validation records are ordinary `route53.record-set` leaves that read the certificate's **early attributes**, listed in the type table, so they are created at once ([tree-model 7](tree-model.md#7-references), CTL-063). Anything that reads the certificate's ARN waits for it to be stable. `acm.certificate` has a hand-written runner, because Cloud Control's create doesn't return until issuance. The certificate type's own `domain-validation-options` with a hosted zone remains allowed when the zone is in the same account. |
| CTLQ-026 | **AWS's own changes and the fighting limit.** Should corrections of changes an AWS service made count towards the three-an-hour limit (CTL-032)? | Yes, still count them, so a misconfigured property is found quickly rather than corrected all day; the alarm then names AWS and suggests `create`. |
| CTLQ-027 | **Permits for changes that reach a binding from above.** A default changed at `/tidewater` alters resources beneath every application's binding. Should the commit need each bound application's permit? | **Withdrawn 2026-11-23.** Gravity Keep doesn't check development permits at all ([CTL-037](rules.md#access-and-governance), retired). Changes that reach a namespace from above are governed by its review and confirmation (CTL-073). |
| CTLQ-028 | **Update options.** Some types take options about how a change is applied rather than what the value is: RDS `apply-immediately`, ECS `force-new-deployment`. Should a resource be able to state them? | Later. Nothing in the prototype needs them; add them to the type table when a type does. |
| CTLQ-029 | **Finding who uses an identity.** Some types can tell commit check who still uses them: a security group's network interfaces, a role's last-used time, a key's grants. Should the type table name an "in use" check per type, so "holders outside the tree can't be found" becomes a list? | Later, per type, as runners are. Start with security groups, where AWS can list every network interface that uses one. |
