# Gravity Keep Rules

> **Status:** Draft 0.2, 2026-11-23. Every Gravity Keep rule in one place. Each rule is one plain, testable sentence, and carries a stable `CTL-nnn` ID that is never reused or renumbered. The documents that explain each rule are linked from its section. Where a rule here and the Gravity Standard appear to conflict, the Standard wins and the conflict is raised with a person.

An AI assistant working with Gravity Keep **must not** weaken, drop, or reinterpret a rule. It may strengthen an implementation at any time.

# Tree

Explained in [tree-model 2](tree-model.md#2-namespaces).

- **CTL-001:** A namespace name is lower-case letters, digits, and hyphens, starts with a letter, is at most 40 characters, and never contains a dot.
- **CTL-002:** A control plane has exactly one tree, and every managed resource has exactly one path in it.
- **CTL-003:** The company names the top of the tree; the fixed vocabulary (`placement`, `defaults`, `guardrails`, `binding`, `policy`, `access`, `source`, `templates`, `template`, `apply`, `resource`, `namespace`) appears only inside a namespace.
- **CTL-004:** A namespace's behavior comes only from its statements and those it inherits, never from its name.
- **CTL-005:** A namespace holds only namespaces, resources, and the fixed vocabulary, and an empty namespace is removed at commit.
- **CTL-006:** Moving or renaming a namespace never replaces a resource beneath it; only the `gravity-path` tag changes.

# Placement

Explained in [tree-model 3](tree-model.md#3-placement).

- **CTL-007:** `organization`, `account`, `region`, and `zone` are inherited down the tree until a namespace or resource sets them again.
- **CTL-008:** A resource's placement resolves to everything its type's scope needs (global, regional, zonal, or organization), or commit check fails.
- **CTL-009:** A zone is always written as an Availability Zone ID, never a zone name.

# Resources and types

Explained in [tree-model 4](tree-model.md#4-resources-and-types).

- **CTL-010:** A resource type is a CloudFormation registry type, written as its derived alias, and its property names and attribute names are derived mechanically from its schema.
- **CTL-011:** Only properties stated on the resource or supplied by a default, guardrail, or template are managed, down to sub-properties inside nested blocks, and only managed properties can drift.
- **CTL-066:** A statement on a resource belongs to one phase: inside `create` it is applied only when the resource is created or replaced and never compared afterwards; outside any phase block it is maintained and held; inside `destroy` it is used only when the resource is deleted. `create` may appear on a resource, in a template, or in defaults, never in guardrails or for a property a guardrail above names.
- **CTL-070:** Destroy values are never compared and never cause an update; a resource's `destroy` block overrides its namespace's deletion policy, guardrails may restrict it, and a deletion follows the `destroy` block in the last commit that held the resource.
- **CTL-071:** A create-only property whose value is inherited from a default or a template applies only to resources created after it; changing it never replaces an existing resource.
- **CTL-067:** Configured and observed values are compared only after the normaliser the type table names for the property, chosen from a fixed, published set.
- **CTL-068:** A secret reaches AWS only by reference to a secret store, read at the moment of the call, and never appears in the tree, the store, a Git source or export, a plan, or a log.
- **CTL-069:** A write-only property is compared with a hash of what the control plane last sent, and is sent again only when its configured value or its secret's version changes.

# Defaults and guardrails

Explained in [tree-model 5](tree-model.md#5-defaults-and-guardrails) and [tree-model 9](tree-model.md#9-how-a-value-is-resolved).

- **CTL-012:** A default applies only where nothing nearer has set the property.
- **CTL-013:** A value is resolved from the template body, then defaults from the root down, then the resource's own statements, then fixed-value guardrails, and the source of every resolved value can be shown.
- **CTL-014:** Nothing beneath a guardrail may weaken it, and a conflict with a guardrail fails commit check and names the guardrail's path.
- **CTL-015:** Every taggable managed resource carries `managed-by gravity-keep` and `gravity-path <namespace path>`, and neither can be overridden.
- **CTL-016:** A boundary that must hold even for calls made outside Gravity Keep is also expressed as an AWS Organizations policy in the tree.
- **CTL-072:** An audit guardrail never fails a commit and never changes a resource; each violation is a finding, and it becomes a guardrail only by a commit.

# Templates

Explained in [tree-model 6](tree-model.md#6-templates).

- **CTL-017:** A template is referenced by name and a version constraint in Terraform's syntax, never copied into the tree.
- **CTL-065:** A version constraint is resolved only by a commit that changes the namespace applying it, or by `update templates`, to the newest matching version; the commit records each resolved version and digest, `rollback` and `request revert` restore the recorded versions without resolving again, and a version whose digest has changed fails commit check.
- **CTL-018:** A template substitutes declared, typed parameters and has no loops, conditionals, or functions.
- **CTL-019:** A template's resources appear at ordinary paths in the namespace that applies it, and which template supplied each one can be shown.

# References

Explained in [tree-model 7](tree-model.md#7-references).

- **CTL-020:** A reference resolves to a resource in the tree, references are the only way to express a dependency, and a cycle fails commit check.
- **CTL-063:** A reference waits until the resource it references is `stable`, except a reference to an attribute the type table marks early, which waits only until that value is known; list entries are referenced by key, never by position.

# Candidate and commit

Explained in [commit-model 2 to 5](commit-model.md#2-the-candidate) and [commit-model 9](commit-model.md#9-deletion-and-replacement).

- **CTL-021:** When a newer commit changed a statement the candidate also changed, commit stops and names the conflict, and nothing is overwritten.
- **CTL-022:** A commit runs every step of commit check, and a configuration that fails any step is never committed.
- **CTL-023:** The active configuration changes only by commit.
- **CTL-024:** A commit is atomic, numbered, and immutable, and records its author, method, comment, base, source, difference, and check result.
- **CTL-027:** A commit from a session or a commit request is made as `commit confirmed` when the person asks for it or when policy requires it for a type in its plan, and if it is not confirmed before its timer ends, or its convergence fails, it is reverted by a new commit that restores the previous configuration. A load from a Git source is never made as `commit confirmed`.
- **CTL-028:** A destructive change is committed only with an acknowledgment whose count matches the plan, and never under `commit confirmed`.
- **CTL-074:** Deleting or replacing a resource is destructive when its type is stateful or identity-bearing in the type table; an identity-bearing type is one whose identity others hold and recreating can't restore.
- **CTL-058:** `request revert` restores the configuration from before one commit beneath the paths it changed, is refused if a later commit changed those paths, is granted to directory groups as `revert`, and raises an alarm.

# Convergence

Explained in [commit-model 4](commit-model.md#4-commit-and-convergence).

- **CTL-025:** Convergence always works toward the latest active configuration, and every action is recomputed from the resource's current state just before it runs.
- **CTL-026:** Each convergence action is retried a bounded number of times with backoff, and then recorded as failed with an alarm to the resource's owner.
- **CTL-059:** A resource has at most one AWS request in flight; an action from a newer commit waits for it to finish and is then recomputed from current state.
- **CTL-060:** Every managed resource is in exactly one state, `stable`, `converging`, `drifted`, `failed`, or `unknown`, shown with its reason, and a namespace shows the worst state beneath it in the order unknown, failed, drifted, converging, stable.
- **CTL-062:** A wait succeeds only when everything it waits on is `stable`; `drifted` and `unknown` never count as stable.
- **CTL-064:** Every type has a converging limit in the type table, and a create or update still `converging` when it runs out is `failed`.

# Drift

Explained in [commit-model 6](commit-model.md#6-drift).

- **CTL-030:** A change event only says where to look; the reactor reads current state from AWS, and a scheduled sweep reads every managed resource whether or not an event arrived.
- **CTL-031:** A missing stateful resource is reported and never recreated automatically.
- **CTL-032:** A resource corrected more than three times in one hour stops being remediated, and an alarm fires.
- **CTL-033:** A hold suspends remediation beneath one path for a stated reason; it warns before it ends, naming what will be pulled back; each extension has its own reason and its own limit, and all of them stop at the policy's total; at expiry only what wasn't committed is pulled back; and every step is recorded in history.
- **CTL-075:** A held change is kept only by committing it, by capture or by hand, through the namespace's own route (a commit, a commit request, or a Git pull request), and a hold whose held changes are all committed ends itself.
- **CTL-061:** Every drift is recorded; a drifted resource the control plane is correcting is shown as `converging`, and a resource is `drifted` only when the control plane won't correct it on its own.

# Ownership and deletion

Explained in [commit-model 7 to 9](commit-model.md#7-rollback).

- **CTL-029:** A rollback is a new commit, and its plan states every stateful resource whose data it cannot restore.
- **CTL-034:** Every resource of a type the inventory source covers, in a managed account and region, is either in the tree or listed as unmanaged, and the types it doesn't cover are listed too.
- **CTL-076:** The list of what exists comes from an inventory source that covers every managed account and region at least daily, chosen by each implementation; reading managed resources stays with Cloud Control and the reactor.
- **CTL-077:** A `learning` namespace writes resources created, changed, or deleted in its area outside a commit into the tree, as commits (or commit requests beneath a reviewed namespace) crediting the identity CloudTrail names; learning areas never overlap, and learning is never allowed beneath a Git source.
- **CTL-078:** Eviction removes resources from the tree and their Gravity Keep tags from AWS, and changes nothing else; it never deletes.
- **CTL-079:** Adopt and explore only add to a candidate (or print a fragment beneath a Git source), so nothing is supervised until a commit; explore needs a filter narrower than the namespace's placement, or an explicit `all`.
- **CTL-035:** An unmanaged resource is never changed or deleted, and a commit that adopts a resource changes nothing in AWS but its tags.
- **CTL-047:** A stateful resource removed from the tree is retained unless its `destroy` block or its namespace's deletion policy says otherwise, and a KMS key's deletion is always scheduled, never immediate.
- **CTL-049:** A resource in an `observed` namespace is compared and its drift reported, but it is never changed, including its tags.
- **CTL-048:** A protected namespace or resource can't be deleted, moved, or renamed until a separate commit removes its protection.

# Access and governance

Explained in [tree-model 8](tree-model.md#8-bindings-policy-and-access) and [commit-model 10](commit-model.md#10-reviewed-commits).

- **CTL-036:** Who may view, edit, commit, approve, adopt, hold, and revert beneath a namespace is granted to directory groups, never to named people, and is enforced by Verified Permissions on every API call.
- **CTL-037:** (retired 2026-11-23) Gravity Keep does not check Gravity Standard development permits. A company that uses permits checks them where the Standard puts them, in the pipeline before it commits.
- **CTL-038:** A reviewed namespace accepts a commit only from its Git source, recorded by repository and commit, or, when it is sourced in the control plane, from a commit request approved by someone other than its author.
- **CTL-073:** A commit needs the review and `commit confirmed` that every namespace whose resolved configuration it changes requires, not only the namespaces it edits; reaching a reviewed namespace from above needs a second person's approval, whatever that namespace's source.

# Sources

Explained in [tree-model 11](tree-model.md#11-sources) and [commit-model 12](commit-model.md#12-git-sourced-namespaces).

- **CTL-050:** Every namespace has exactly one source, the control plane or one file on one branch of one Git repository, and a source covers the namespace's whole subtree.
- **CTL-051:** A namespace's source is declared by its parent, and a Git source file can't contain a `source` statement.
- **CTL-052:** Beneath a Git-sourced namespace the configuration changes only by loading its declared file at a commit on its declared branch; session edits, other loads, commit requests, rollback, eviction by command, and `ownership learning` are refused.
- **CTL-053:** A Git source is loaded only at a commit that is on its declared branch and descends from the last commit the control plane loaded from it or wrote to it.
- **CTL-054:** The control plane writes to a Git source only to record a revert made by `request revert`; if that write fails, the namespace is out of step and its next load must be made by a person who acknowledges it.
- **CTL-055:** Declaring or removing a source is a commit at the parent; declaring a Git source is refused unless the file resolves to the namespace's active configuration, and removing one raises an alarm.
- **CTL-056:** Every commit's resolved configuration is written to a store outside the control plane, and a file written there is never loaded as a source.
- **CTL-057:** The control plane's own namespace, which holds the pipeline roles and everything the Git route depends on, is always sourced in the control plane.

# Audit and history

Explained in [commit-model 11](commit-model.md#11-who-commits).

- **CTL-039:** Every change to the configuration has exactly one author and, when the author acts for someone, names that person.
- **CTL-040:** Commit history, convergence records, corrections, holds, and adoptions are kept for at least as long as the longest retention any bound application declares, and are never edited.

# Sessions and interfaces

Explained in [command-reference](command-reference.md) and [architecture 3](architecture.md#3-sessions).

- **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 `request` command, which is authorized and recorded like a commit.

# The control plane itself

Explained in [architecture 7](architecture.md#7-managing-itself).

- **CTL-044:** The control plane's own namespace is protected, reviewed, and requires `commit confirmed` for 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.
