← Gagarin CloudCONTENT HISTORY

Update to Gagarin Cloud

Snapshot Nov 30, 2026 · 00:25 UTC · version 1.27.0

Collection source: downloaded plugin package.

WHAT CHANGED

Instructions updated for gagarin

Skill instructions — Now says: volume, the size and the replica count all survive a deploy that forgets to mention them. Env is the one thing you must restate every time. | `gg metrics...

Observed in instructions or declared skills. Runtime behavior has not been tested.

Save Gagarin Cloud and check future changes in Following.

Up to 3 plugins free · no card required.

All fields and original values.

Skill instructions

Before

Nov 27, 2026 · 20:21 UTC

volume and the size all survive a deploy that forgets to mention them. Env is the one thing you must restate every time. | alerts (no gg command) | push-notify a member's own devices when a service goes down; the human turns it on wit...

After

Nov 30, 2026 · 00:25 UTC

volume, the size and the replica count all survive a deploy that forgets to mention them. Env is the one thing you must restate every time. | `gg metrics P[/SVC] [--window 1h\|24h\|7d\|30d]` | usage from real numbers: every service no...

Compare saved observations

Download comparison JSON

SKILL.md text changes

− removed · + added

--- before
+++ after
@@ -37,8 +37,8 @@
    credentials.** Connecting a database is that one call, not a call plus a
    deploy.
 7. **A deploy replaces the environment and nothing else.** Dependencies, the
-   domain, the volume and the size all survive a deploy that forgets to mention
-   them. Env is the one thing you must restate every time.
+   domain, the volume, the size and the replica count all survive a deploy that
+   forgets to mention them. Env is the one thing you must restate every time.
    **A credential never goes in a deploy env.** Env is for plain, single-service
    config: a port, a log level, a sibling's URL. A database password arrives
    with `gg deps add`; a third-party key is an `external` resource. See "What
@@ -91,9 +91,10 @@
 | `gg deps add P/SVC NAME...` / `deps ls` / `deps rm` | what a service may reach, and whose credentials it holds (`rm` needs a human) |
 | `gg domain add P/SVC [DOMAIN]` / `domain ls P` / `domain rm` | addresses on the internet |
 | `gg status PROJECT` | desired vs actual, addresses, sizes, today's cost |
+| `gg metrics P[/SVC] [--window 1h\|24h\|7d\|30d]` | usage from real numbers: every service now, or one service's last value (and when), average, peak and limit over a window. See Metrics |
 | `gg logs P/SVC` | recent logs |
 | `gg history P/SVC` / `gg rollback P/SVC [--to N]` | every deploy; put one back |
-| alerts (no gg command) | push-notify a member's own devices when a service goes down; the human turns it on with the switch at my.gagarin.cloud/projects/P/alerts, which also sends a test. See Alerts |
+| alerts (no gg command) | push-notify a member's own devices when a service goes down, runs short of memory, CPU or disk, or answers with 5xx; the human turns it on with the switch at my.gagarin.cloud/projects/P/alerts, which also sends a test. See Alerts |
 | `gg referral` | the account's invite link and code (once it has topped up), and who signed up through it and what it earned; in MCP, `referrals` |
 | `gg members P` / `gg share P EMAIL [--role viewer]` / `gg unshare P EMAIL` | who can reach it |
 | `gg transfer P EMAIL` | offer the project, and its bill, to a member (they accept by email) |
@@ -243,7 +244,7 @@
   replace one kind with the other on its own: run `brew uninstall gg` once,
   then install the cask.
 - Windows: `scoop bucket add gagarin https://github.com/gagarin-cloud/scoop-bucket`
-  then `scoop install gagarin/gg`, or `winget install Gagarin.gg`.
+  then `scoop install gagarin/gg`.
 - Any platform with a Go toolchain: `go install github.com/gagarin-cloud/gg@latest`
 
 If `go install` succeeds but the shell still cannot find `gg`, its bin directory
@@ -284,13 +285,13 @@
 unknown, check `gg version` and upgrade before concluding the command does not
 exist.** `gg version` also prints, on stderr, "gg vX is available (you have vY)"
 when you are behind (`GAGARIN_NO_UPDATE_CHECK=1` silences it). Upgrade with
-`gg upgrade`, which upgrades the way `gg` was installed: brew, scoop, winget and
+`gg upgrade`, which upgrades the way `gg` was installed: brew, scoop and
 `go install` are handed to that tool, script and archive installs replace
 themselves after checking the checksum, and `.deb`/`.rpm`/`.apk` installs print a
 `sudo` command for your human. `gg upgrade --dry-run` previews it. `gg upgrade`
 itself needs v0.54.0; on an older `gg` it does not exist, so use the per-manager
 command (`brew upgrade --cask gagarin-cloud/tap/gg`, `scoop update gg`,
-`winget upgrade Gagarin.gg`, `go install ...@latest`) or, for an installer or
+`go install ...@latest`) or, for an installer or
 archive install, have your human run the installer again as "Installing gg"
 says. Everything else documented here is present in gg
 v0.42.0 and later.
@@ -640,7 +641,8 @@
    is running, and what may reach what. Nothing to run, so this one is a
    sentence and a link.
 2. **Alerts.** Ask whether the human wants a push on their phone when the
-   service goes down, a deploy will not start, or a container keeps crashing.
+   service goes down, a deploy will not start, a container keeps crashing, or
+   one runs short of memory, CPU or disk.
    If yes, they open `https://my.gagarin.cloud/projects/<id>/alerts` on that
    phone and turn on "Notify me about this project", which allows notifications
    and opts them in at once; the same page sends a test. On an iPhone they add
@@ -793,9 +795,40 @@
   `gg status` says so and names the size to move to — or when you already know
   the workload: server-side-rendered Next.js, a JVM, a large in-process cache, a
   postgres a real application depends on. Do not reach for `l` speculatively.
+- **A postgres's size also sets its settings**: at most **60, 105 or 119
+  connections** at `s`, `m` or `l`, shared buffers of 128 MB, 512 MB or 1 GB,
+  and `work_mem` of 2, 2 or 4 MB. They are the platform's, not a flag; a query
+  that needs more sort memory runs `SET work_mem` for its own session. A
+  postgres created before 2026-11-17 keeps stock settings (100 connections)
+  until its next resize. If an app runs out of connections, pool them — or
+  move up a size.
 - `gg status` shows the size every service is running at, and the day's accrued
   cost at the bottom of the table.
 
+### Replicas
+
+A service runs one copy unless it says otherwise. `--replicas` on `gg deploy`
+or `gg ship` sets a fixed count, or a range the platform scales within on CPU:
+
+```
+gg deploy shop/web:8080 web:v3 --replicas 3     always three copies
+gg ship shop/api:4000 --replicas 1-5            one to five, by CPU load
+gg deploy shop/web:8080 web:v4 --replicas 1     back to one
+```
+
+- **Omitting `--replicas` keeps what the service has**, like `--size`.
+- **Every copy is billed at its size's rate while it runs.** A range bills its
+  minimum all the time and each extra copy only while it is up. At most five.
+- **Only a service without a volume.** A service with a volume always runs one
+  copy (`replicas_with_volume`); resources and jobs have no replicas. A
+  database does not get replicas or failover from this.
+- **More copies help CPU, not memory.** A service that is OOM-killed needs a
+  bigger size; one that is CPU-bound under load, or must stay up through a
+  node drain, wants `--replicas 2` or a range. Copies share nothing in memory,
+  so in-process sessions or caches must live in valkey or postgres first.
+- `gg status` adds a REPLICAS column once anything in the project may run more
+  than one.
+
 ### Volumes
 
 ```
@@ -805,7 +838,8 @@
 A directory that survives restarts. **Set once, at the deploy that creates the
 service**; a later deploy cannot move it or resize it, and asking is refused with
 `volume_immutable`. The default ceiling is 10 GB. A rollback across a change of
-volume is refused for the same reason.
+volume is refused for the same reason. It is writable by whatever user the image
+runs as, so an image with a non-root `USER` needs no chown or init step.
 
 Use this for anything stateful that has no resource type — see "Anything we do
 not have a type for".
@@ -2146,8 +2180,8 @@
 at once, and sends a test from the same page. Point the human there, on the
 phone they want the push on. Turning the switch off there opts them out.
 
-There is no gg command for alerts: talking the human through that page is your
-part. With the MCP server connected, `alerts` says whether the caller is opted
+There is no gg command for alerts (`gg metrics` is for the numbers, below):
+talking the human through that page is your part. With the MCP server connected, `alerts` says whether the caller is opted
 in, how many devices they have, and the last few notifications; `test_alerts`
 sends a test once they say it is on; each takes only the project. Opting in is
 per member, so one member turning alerts on does not turn them on for anyone
@@ -2161,13 +2195,45 @@
 when a service has been down for three minutes, when a deploy will not start
 (the previous revision keeps serving), and when a container crashes and
 restarts, once when it starts and once when it ends, never on repeat. The
-console keeps a 30-day feed of these notifications. There are no rules to
-choose. Offer alerts after a first deploy that a human cares about; do not turn
-them on without asking, because the notifications go to somebody.
+console keeps a 30-day feed of these notifications. Four more come from the
+metrics, each also once when it starts and once when it resolves: memory at 80%
+of its limit or more for 5 minutes (resolves under 75%); CPU at 80% of its
+limit or more for 10 minutes (resolves under 70%); a volume 85% full (resolves
+under 80%); and 5% or more of requests answered with 5xx over 5 minutes, with
+at least 20 requests (resolves under 2%). Tapping one of these opens that
+service's graphs. They are part of the same fixed set. There are no rules or
+thresholds to choose. Offer alerts after a first deploy that a human cares
+about; do not turn them on without asking, because the notifications go to somebody.
 
 The old ntfy alerts are gone: `--server`, `--topic` and `--token` no longer
 exist, and sending them is refused with `ntfy_removed`.
 
+## Metrics
+
+Every cluster keeps a metrics store, 30 days deep. For each service, and each
+resource (postgres, qdrant, iggy, rabbitmq, valkey), it holds CPU used against
+its limit (cores), memory against its limit (bytes), volume disk used against
+its size, CPU throttling (the share of periods), and network in and out
+(bytes/s); for a service with a public address, also requests/s, the share of
+5xx and p95 latency. Windows are `1h`, `24h`, `7d` and `30d`. A figure that was
+not measured is `null`: a service that just started, no volume, no address.
+Figures appear a minute or two after a service starts.
+
+- `gg metrics PROJECT` is a table of every service now: kind, CPU, memory,
+  disk, throttling and network, plus req/s, 5xx and p95 for the public ones.
+- `gg metrics PROJECT/SVC [--window 1h|24h|7d|30d]` gives the last value and
+  when it was taken, average, peak and limit for each figure over the window.
+- In MCP, `metrics` takes `{project, service?, window?}`: project-wide figures
+  now, or one service's last (with `last_at`)/avg/peak/limit per series over a
+  window. `window` without `service` is refused `window_needs_service`.
+- The console has a **Metrics** tab, `https://my.gagarin.cloud/projects/<id>/metrics`
+  (`?service=NAME&window=24h`).
+
+Use it to answer "why is it slow", "is it running out of memory" and "is the
+disk filling" from numbers rather than a guess. `gg status` stays the answer to
+"is it up". `metrics_unavailable` means the cluster has no metrics store or it
+did not answer: retry in a minute.
+
 ## Sharing a project
 
 A project has exactly one **owner** — the account that pays for it — plus any
@@ -2346,6 +2412,13 @@
 | `invalid_subscription` | the browser's push subscription was refused (not https, not a known push service, bad keys). The human re-enables notifications in the console |
 | `push_unconfigured` | the platform has no push keys yet. Nothing to fix on your side; tell the user |
 
+**Metrics**
+
+| code | what to do |
+|---|---|
+| `metrics_unavailable` | 503: the cluster has no metrics store, or it did not answer. Retry in a minute; `gg status` still shows what is running |
+| `no_such_service` | 404 on `gg metrics P/SVC` or `metrics`: that name is not a service here. `gg status` lists them |
+
 **Services, images and deploys**
 
 | code | what to do |
Full technical diff · 1 changed fields

changed /skill_md_contents

BEFORE
"---\nname: gagarin\ndescription: Deploy and operate applications on Gagarin with the gg CLI — ship a service from a Dockerfile, provision postgres, qdrant, valkey, iggy, rabbitmq, s3 or external-credential resources, wire what may reach what, put a service on the internet, give CI its own credential, start jobs from an application's own code with the Go, Node or Python SDK, read status and logs, roll back, tear things down, and keep what a session learned in the project's memory. Use whenever the user asks to deploy, host, run or operate an application, or mentions Gagarin or gg. Gagarin runs container images on managed infrastructure; the user never needs to know about Kubernetes, ingress, TLS, or the underlying cloud.\n---\n\n# Deploying with Gagarin\n\nGagarin runs your services. You drive it with the `gg` CLI, a thin wrapper over\nthe Gagarin API. There is exactly one way to change anything: call the API.\nThere is no manifest file and no config file. The one file you will commit is\na note of which project the repository is, and it changes nothing — see \"Which\nproject this repository is\".\n\nEverything below is the whole product. Read \"The ten rules\" and the command map\nfirst; they are the parts that stop you getting it wrong.\n\n## The ten rules\n\n1. **Everything is named for its project.** `shop` is a project; `shop/web` is a\n   service or a resource inside it. Nothing is inferred from the directory you\n   stand in. There is no default project to configure — a command that does not\n   name one is refused with the shape it should have had.\n2. **Every write is asynchronous, except `gg run`.** A command that exits zero\n   recorded a demand; it did not watch it come true. `gg status <project>` reads\n   the cluster and is the only thing that can answer \"is it up\". The one\n   exception is `gg run`, and it is an exception because a run *ends*: it waits,\n   prints what the run wrote, and exits with the script's own code. Nothing else\n   here has an end to wait for.\n3. **Gagarin runs images from its own registry only.** `gg ship` is build, push\n   and deploy fused; the three exist separately for CI. Somebody else's image\n   comes in with `gg registry copy`.\n4. **A service is private until `gg domain add`**, and a deploy can neither give\n   an address nor take one away.\n5. **A private service is default-denied.** Until the *caller* declares\n   `gg deps add`, its calls are dropped — which hangs, rather than failing fast.\n6. **`gg deps add <service> <resource>` opens the route *and* hands over the\n   credentials.** Connecting a database is that one call, not a call plus a\n   deploy.\n7. **A deploy replaces the environment and nothing else.** Dependencies, the\n   domain, the volume and the size all survive a deploy that forgets to mention\n   them. Env is the one thing you must restate every time.\n   **A credential never goes in a deploy env.** Env is for plain, single-service\n   config: a port, a log level, a sibling's URL. A database password arrives\n   with `gg deps add`; a third-party key is an `external` resource. See \"What\n   does not go in env\" below.\n   **And no secret value ever passes through your output** — not the\n   terminal, not this chat, not a summary or a commit. A command that takes one\n   reads it from a file (`--env-file`, `--input NAME=FILE`, `\"$(cat FILE)\"`),\n   never `K=value` typed on a command line; a command that produces one writes\n   it to a file or pipes it into the store it is for (`> .env.db`,\n   `| gh secret set`). Reach for `--names` before values. Never ask your human\n   to paste a secret into the chat.\n8. **If a resource type exists, use it** (`postgres`, `qdrant`, `valkey`,\n   `iggy`, `rabbitmq`, `s3`, `external`). If one does not, an ordinary service with a volume is the normal\n   path, not a workaround.\n9. **You can deploy; you cannot destroy.** Deleting anything, taking an address\n   away, withdrawing a dependency with `gg deps rm`, and handing a project over\n   with `gg transfer` all answer `approval_required` and email the account owner\n   a button, every time the approval window has lapsed, which approves only once\n   they are signed in. No flag grants this to an agent. Adding is always free: `gg deps add` and `gg domain add` need nobody.\n10. **Errors are meant to be branched on.** gg prints `[code] message` and\n    usually a `hint:` line. Act on the code, never on the prose.\n\n## Command map\n\n| | |\n|---|---|\n| `gg whoami` | which account this machine acts as — **run this first, always** |\n| `gg login` / `gg login --new` | get this machine access — relay the link and code, then run it again once approved |\n| `gg login --ref CODE` | the same, for a human a friend invited: the code (8 letters and digits) is added to the link so the new account is matched to the friend |\n| `gg creds` / `creds create --name N` / `creds revoke ID` | what has access; mint one for CI; take one away |\n| `gg registry login` | log docker in (CI, or docker installed after gg) |\n| `gg projects` | every project you can reach, and your role on it |\n| `gg init PROJECT` | create a project |\n| `gg ship P/SVC:PORT` | build the current directory, push it, run it — tagged with the commit when the tree is clean |\n| `gg build P/IMAGE[:TAG]` / `gg push P/IMAGE:TAG` / `gg deploy P/SVC:PORT IMAGE:TAG` | the same three steps apart, which is what CI wants |\n| `gg run P/JOB IMAGE:TAG` | run an image to completion as a job, wait, print what it wrote, exit with its code |\n| `gg run P/JOB IMAGE:TAG --schedule \"0 3 * * *\"` | run it on a schedule instead of now; returns at once |\n| the SDK (Go, Node, Python) | start runs from an application's own code — see \"From code: the SDK\" |\n| `gg registry copy P/IMAGE SOURCE` | bring an image you did not build into the project |\n| `gg resource add P/NAME TYPE` | provision postgres, qdrant, valkey, iggy, rabbitmq, s3 or external |\n| `gg resource add P/db postgres --ext vector --ext postgis` | the postgres extensions it should have, one `--ext` each — the whole set, every time you pass it |\n| `gg resource public P/NAME` | make an `s3` bucket listable and readable by anyone; `gg resource private P/NAME` undoes it |\n| `gg resource secrets P/NAME > .env.NAME` | its connection values, into a file for something outside the project — never printed |\n| `gg resource secrets P/NAME --names` | just the variable names it publishes, no values |\n| `gg resource rotate P/NAME` | new credentials, and everything holding them rolls |\n| `gg resource rotate P/NAME --set K=\"$(cat FILE)\"` | change one value an external publishes, keeping the rest; the value comes from a file |\n| `gg rollback P/NAME` | put a previous revision back — a service's deploy, or an external's values |\n| `gg connect P/NAME` | that resource on this machine, for as long as the command runs |\n| `gg resource backup` / `backups` / `restore P/NEW --source OLD` | postgres, qdrant and iggy recovery |\n| `gg deps add P/SVC NAME...` / `deps ls` / `deps rm` | what a service may reach, and whose credentials it holds (`rm` needs a human) |\n| `gg domain add P/SVC [DOMAIN]` / `domain ls P` / `domain rm` | addresses on the internet |\n| `gg status PROJECT` | desired vs actual, addresses, sizes, today's cost |\n| `gg logs P/SVC` | recent logs |\n| `gg history P/SVC` / `gg rollback P/SVC [--to N]` | every deploy; put one back |\n| alerts (no gg command) | push-notify a member's own devices when a service goes down; the human turns it on with the switch at my.gagarin.cloud/projects/P/alerts, which also sends a test. See Alerts |\n| `gg referral` | the account's invite link and code (once it has topped up), and who signed up through it and what it earned; in MCP, `referrals` |\n| `gg members P` / `gg share P EMAIL [--role viewer]` / `gg unshare P EMAIL` | who can reach it |\n| `gg transfer P EMAIL` | offer the project, and its bill, to a member (they accept by email) |\n| `gg destroy P` or `P/NAME` | delete a project, a service or a resource (needs a human) |\n| `gg eject P -o file.yaml` | the Kubernetes manifests, so you can leave (external and s3 keys are placeholders; `--with-secrets` includes them) |\n| `gg recipe snap P [--dry-run]` | publish a project as a recipe, owner only; `--version`, `--as`, `--source`, `--notes`. Dry run first |\n| `gg recipe show RECIPE[@VERSION]` / `recipe ls` | read a recipe (`--format json` for the manifest); the ones this account published |\n| `gg recipe install RECIPE[@VERSION] NEW_PROJECT --input NAME=FILE` | deploy a recipe into a new project, one env file per declared input |\n| `gg recipe diff P` / `recipe update P [--to V] [--force]` | what a newer version changes; apply it (removals need a human) |\n| `gg recipe rm RECIPE[@VERSION]` | delete a recipe or one version (needs a human) |\n| `gg version` | which gg this is |\n\nThree environment variables override the credential file, and exist for CI:\n`GAGARIN_TOKEN` (a credential), `GAGARIN_API` (control plane URL), and\n`GAGARIN_REGISTRY` (registry host). There is nothing else to export.\n\n## First moves in any session\n\nRun `gg whoami` before anything else. It answers three different questions at\nonce, and each has a different next step:\n\n| what happens | what it means | do this |\n|---|---|---|\n| the shell cannot find `gg` | not installed | see \"Installing gg\" — unless you already hold Gagarin MCP tools, in which case call `whoami` there and read \"If you cannot install gg\" for what they cannot do |\n| `[unauthorized]`, or it says there are no credentials | installed, no access | see \"Getting access\" |\n| it names an account | ready | carry on; `gg projects` says what already exists |\n\nThen read `.gagarin.json` at the repository root, if there is one — it says\nwhich project this repository already is — and `gg projects` before assuming a\nproject exists or that you may write to it. A `viewer` role means every deploy\nwill be refused, and that is worth knowing before the attempt rather than\nafter. Project names are unique only within one account, so two rows can share\na name — the id column tells them apart.\n\nOnce per session, before the first build or CI change, check the rest of the\ntoolchain — docker running, git, and `gh` or `glab` signed in — as \"What else\nthe machine should have\" describes. Only a stopped docker blocks a ship.\n\n## Which project this repository is: `.gagarin.json`\n\nGagarin infers nothing from the directory you stand in, and gg stopped guessing\nthe project from the directory's name on purpose: that made a command whose\ntarget was invisible in the command. So the repository carries a note instead,\nat its root, and you are the one who writes it:\n\n```json\n{ \"project\": { \"id\": \"3cnciet6\", \"name\": \"shop\" } }\n```\n\nWrite it once you have created the project or settled on an existing one.\nFive rules, each for a reason:\n\n- **It is a note for the next session, not configuration.** Nothing reads it —\n  not gg, not the MCP server, not the platform. You read it, and then you still\n  name the project in every command and every tool call, so the target stays\n  visible in the command.\n- **Identity only, never desired state.** The one other key is `\"tour\"`, the\n  onboarding steps the human has already been shown (see \"After the first\n  address\"). No services, ports, env or domains:\n  Gagarin holds those, and a copy in the repository would be the stale one. If\n  the file disagrees with `gg projects`, the API is right — fix the file and\n  tell the user.\n- **Prefer the id in calls.** Names are unique only within an account, so a\n  project shared with the user can carry the same name as one of their own;\n  the id cannot collide. Everything that takes a project name takes its id.\n- **Commit it.** The id is already public in every hostname and image path,\n  and a teammate's agent needs it as much as your next session does.\n- **Read it first**, before `gg projects` and before asking. If it is absent\n  and the user named no project, `gg projects` before `gg init` — the project\n  may already exist.\n\nWhere the id comes from: `gg init shop` prints `project shop created (id\n3cnciet6), runs in fr-par-1`; `gg projects` prints a row per project — name, id,\ncluster, role; and the first line of `gg status shop` reads\n`project shop  (id 3cnciet6)  fr-par-1`, ending with the cluster. None of them has a JSON flag; read the column.\n\n**A project has a place.** Each project runs on one cluster, chosen when it is\ncreated and never changed; `gg status` shows it (`fr-par-1`). It is part of the\nproject's generated addresses, `<service>-<project id>.<cluster>.apps.gagarin.cloud`\n(for example `web-3cnciet6.fr-par-1.apps.gagarin.cloud`), so never build one by\nhand from the id alone: read it from `gg status` or `gg domain ls`.\n\n## Project memory\n\nEvery project has a memory: small durable facts about the codebase that the\nnext session would otherwise have to rediscover — an overview, the\narchitecture, a decision and why it went that way, a convention, a gotcha, a\nhowto, a reference, the state of a piece of work. It is reachable only through\nGagarin's MCP server (see \"If you cannot install gg\"); there is no `gg` command\nfor it. Every memory tool takes the project, which is what `.gagarin.json` is\nfor.\n\n| tool | when |\n|---|---|\n| `memory_briefing` | first, when starting work on a project — a primer packed to a token budget |\n| `memory_search` | before exploring the code for something a past session may already have found |\n| `memory_get` / `memory_related` | one memory in full, by id or by key; what it links to |\n| `remember` | one durable fact per memory, in English |\n| `memory_update` | edit, pin, archive, confirm or dispute one |\n| `memory_link` / `memory_unlink` | say that two are related, or that they are not |\n| `memory_review` | housekeeping: likely duplicates, orphans, stale and disputed memories, how close the project is to its cap |\n\n- **Brief yourself before you read the code, and search before you go\n  looking.** That is what it is for. When you know the task, pass `focus` (what\n  you are about to work on) and `paths` (the files you will touch) to\n  `memory_briefing`, and the relevant memories come first.\n- **Give a fact that changes a `key`.** What is deployed now, the current\n  schema version: `remember` it as a `state` memory with a key such as\n  `deploy/current`, and the next `remember` with the same key replaces it and\n  keeps its links. Do not search for the old one and supersede it by hand.\n- **Say when a memory is right or wrong.** One you checked against the code or\n  the cluster gets `confirm: true`, which resets its age. One that proves wrong\n  gets `dispute: true` — it is marked ⚠ and ranks lower until someone confirms,\n  edits or archives it — or a fix, or an archive; do not leave it to mislead the\n  next session. A briefing that counts disputed memories, or a `remember` that\n  warns the project is near its cap, is the cue to call `memory_review` and tidy.\n- **Remember what a future session could not cheaply rediscover**: why a\n  decision went the way it did, a gotcha that cost time, where the deploy\n  differs from the obvious — which port, which Dockerfile quirk, which\n  variables the application insists on. Not what the repository already says,\n  not what is true only of this conversation, and **never a credential or a\n  secret** — not as a value, not in a tag. Title, body and source are\n  encrypted at rest with a key Gagarin holds; tags, file paths and kind are\n  not.\n- **A `remember` refused with a list of near-duplicates** is telling you the\n  fact is already there. Update or link those; do not reword it to get past\n  the check.\n- Reading needs `viewer` on the project; writing needs `editor`. Memories in\n  use are billed at $0.10 per 1,000 a month — a few cents for most projects —\n  and capped per project. Reading is free, and archiving a memory that is no\n  longer true stops it being counted, so archive rather than leave it stale.\n- **If the MCP server is not connected in this session, memory is simply\n  unavailable.** Carry on with `gg`; it is not an error, and nothing else\n  waits on it.\n\n## Installing gg\n\nIf your client is already connected to Gagarin's MCP server you may not need\n`gg` at all — read \"If you cannot install gg\" below first, because the one thing\nit cannot do is build an image, and that is often the whole task.\n\nUse a package manager the machine already has. You may run these yourself:\n\n- macOS: `brew install --cask gagarin-cloud/tap/gg`. It is a **cask**, not a\n  formula, and casks do not work on Linux. If `brew install\n  gagarin-cloud/tap/gg` (no `--cask`) put an older `gg` there, homebrew will not\n  replace one kind with the other on its own: run `brew uninstall gg` once,\n  then install the cask.\n- Windows: `scoop bucket add gagarin https://github.com/gagarin-cloud/scoop-bucket`\n  then `scoop install gagarin/gg`, or `winget install Gagarin.gg`.\n- Any platform with a Go toolchain: `go install github.com/gagarin-cloud/gg@latest`\n\nIf `go install` succeeds but the shell still cannot find `gg`, its bin directory\n(`go env GOPATH`/bin) is not on `PATH`. Say so and let the user fix their\nprofile; do not edit their shell configuration yourself.\n\nWith none of those, the install is the human's to run, not yours: **never\ndownload a script or a binary and run it.** Point them at the one-line installer\non https://gagarin.cloud (a shell one-liner on macOS and Linux, a PowerShell one\non Windows) and say what it does: it verifies the download against the release's\n`checksums.txt`, installs to `~/.local/bin` (Windows: `%LOCALAPPDATA%\\Programs\\gg`,\nadded to their `PATH`) without `sudo`, and never edits a shell profile. On Linux a\n`.deb`, `.rpm` or `.apk` from https://github.com/gagarin-cloud/gg/releases works\ntoo; installing one needs `sudo`, so that is theirs to run as well.\n\nIf `~/.local/bin` is not on `PATH`, the installer prints the `export` line to add.\nCall `gg` by its full path (`~/.local/bin/gg`) for the rest of your session and\ntell your human the line; do not edit their profile yourself.\n\nDo not download from a host you guessed, and do not carry on without `gg`.\n\n`gg` shells out to **docker** for `build`, `push` and `registry copy` (the last\nneeds `buildx`). Nothing else needs it. A machine with no docker can still\ndeploy an image that is already in the registry, roll back, and read state.\n\n**Run `docker info` before the first `gg ship`.** If it fails, ask your human to\nstart Docker Desktop, OrbStack or colima (or install one) and wait until\n`docker info` succeeds; do not start or install it yourself. gg v0.51.0 and\nlater check this before any request and refuse with `docker_not_installed`,\n`docker_not_running` or `docker_permission_denied`, each with the fix in its\nhint. Relay the hint; do not retry until the human says docker is up, and do not\nrun gg with `sudo` to get round a permission error.\n\nThis skill is not part of the binary. It lives in `gagarin-cloud/plugin` and\nis installed separately — in Claude Code, Codex and ChatGPT as a plugin,\nelsewhere with `npx skills add gagarin-cloud/plugin -g`. So it can\nbe newer than the `gg` you are holding: **if a command here is refused as\nunknown, check `gg version` and upgrade before concluding the command does not\nexist.** `gg version` also prints, on stderr, \"gg vX is available (you have vY)\"\nwhen you are behind (`GAGARIN_NO_UPDATE_CHECK=1` silences it). Upgrade with\n`gg upgrade`, which upgrades the way `gg` was installed: brew, scoop, winget and\n`go install` are handed to that tool, script and archive installs replace\nthemselves after checking the checksum, and `.deb`/`.rpm`/`.apk` installs print a\n`sudo` command for your human. `gg upgrade --dry-run` previews it. `gg upgrade`\nitself needs v0.54.0; on an older `gg` it does not exist, so use the per-manager\ncommand (`brew upgrade --cask gagarin-cloud/tap/gg`, `scoop update gg`,\n`winget upgrade Gagarin.gg`, `go install ...@latest`) or, for an installer or\narchive install, have your human run the installer again as \"Installing gg\"\nsays. Everything else documented here is present in gg\nv0.42.0 and later.\n\n## What else the machine should have\n\n`gg` itself shells out to one thing, docker. The rest of this skill leans on a\nfew more tools without checking for them, so check once, early, rather than\nmeeting each one as a failure halfway through a deploy:\n\n| tool | needed for | without it |\n|---|---|---|\n| `gg` | everything | see \"Installing gg\" |\n| `docker`, running | `gg ship`, `gg build`, `gg push` | deploy an image already in the registry; read state; roll back |\n| `docker buildx` | `gg registry copy` | bring the image in from a machine that has it |\n| `git` | committing `.gagarin.json`; `gg build` and `gg ship` tagging the image with the commit; knowing which forge the repository lives on | it all still deploys, but nothing ties an image to the source it came from, and the next session has no note of the project |\n| `gh` (GitHub) or `glab` (GitLab), signed in | putting a CI credential in the secret store without it touching disk or the transcript; watching the pipeline you wrote run | the human sets the secret in the web UI themselves, and you cannot see whether the first run went green |\n| `jq` | pulling one value out of `--format json` | read the JSON yourself; nothing in gg requires it |\n\nOnly the forge CLI that matches the repository matters: `git remote get-url\norigin` says whether it is GitHub or GitLab. Check what is there, and whether\nthe forge CLI is signed in, with:\n\n```\ncommand -v git docker gh glab jq\ndocker info >/dev/null 2>&1 && echo \"docker is up\"\ngit rev-parse --is-inside-work-tree && git remote get-url origin\ngh auth status        # or: glab auth status\n```\n\nWhat to do about a missing one:\n\n- **Do not install docker, git or a forge CLI yourself, and do not sign in for\n  your human.** Say which is missing, what it costs them, and the install\n  command for their platform (`brew install gh`, `winget install GitHub.cli`,\n  `sudo apt install gh`; `glab` the same way). `gh auth login` and `glab auth\n  login` are theirs to run, like `gg login`.\n- **Only docker blocks a ship.** Everything else degrades: say what is lost and\n  carry on with the task.\n- **Not a git repository** is not a failure either. Deploy it; then mention that\n  `.gagarin.json` only helps the next session if it is committed somewhere.\n\n## If you cannot install gg: the MCP server\n\nGagarin also answers MCP at `https://mcp.gagarin.cloud/mcp`. An MCP client —\nClaude Code, Claude Desktop, Cursor, Codex, ChatGPT — connects to that URL and\ninstalls nothing: your human signs in with GitHub or Google when the client\nasks for it, and no secret passes through you. It is this same API in another\nshape, so everything above still holds — the naming, the asynchrony, the\ndefault-denied graph, the human's approval before anything is destroyed.\n\n**It is a smaller surface than `gg`, and the gap is images.** Over MCP you can\ndeploy an image that is already in the registry, run a job, read status and\nlogs, declare dependencies, add an address, roll back, and manage resources,\npeople, credentials and the bill. Four things are deliberately absent:\n\n- **No build and no push.** `gg ship`, `gg build`, `gg push` and\n  `gg registry copy` shell out to docker where the source is, and a server on\n  the internet has neither your source tree nor your docker.\n- **No tunnel.** `gg connect` binds a port on *this* machine; there is no local\n  anything at the other end of an MCP call.\n- **No waiting for a job.** `run` answers the revision naming the run and\n  returns, as every other write does. `status` is the only place an exit code\n  appears.\n- **No list of resource types, sizes or scopes.** The engine owns those and its\n  refusals name them; a second copy here would be wrong the day one is added.\n\nSo: **if `gg` is installed, use it.** It does everything the MCP server does and\nthe four things it cannot. Reach for MCP when you cannot install a binary, or\nwhen the work is purely operational — reading state, rolling back, wiring deps,\nmanaging addresses. If a task needs an image built and you hold only MCP tools,\nsay so and install `gg` rather than reporting a deploy you were unable to make.\n\nThere is a third way into the same API, and it is for neither you nor a\nperson: **application code uses the SDK** (Go, Node, Python) — see \"From code:\nthe SDK\".\n\n## Getting access\n\n`gg login` is one command whether this is the first machine on a new account or\nthe fifth on an old one. There is no separate signup and no address to ask for:\nthe human signs in with GitHub or Google, and a new account starts with $5 on it\nand no card asked for.\n\n1. **`gg login`** prints a link and a code, remembers the request, and exits.\n2. **Give the user the link and the code as printed.** The link is the one to\n   open; the plain address and the code under it are the fallback for when the\n   link does not open. Say what they will do there: sign in with GitHub or\n   Google, check that the page shows the same code and this machine's name, and\n   approve. Then wait for them to tell you they have.\n3. **`gg login` again.** It collects the request the first run made — it does\n   not ask for a new one — stores the credential in\n   `~/.config/gagarin/credentials.json`, logs `docker` in to the registry, and\n   says which account this machine now acts as. Confirm with `gg whoami`.\n\nIf the second run fails:\n\n- `[authorization_pending]` — it waited a minute and nobody had approved yet.\n  It prints the link and code again: pass them on again if the user seems not to\n  have them, and once they say they approved, run `gg login` again. Do not run\n  it in a loop.\n- `[expired_token]` — nobody approved within fifteen minutes, and the request is\n  gone. Run `gg login` for a fresh link and pass it on straight away.\n- `[access_denied]` — the user declined on the page, and the request is gone.\n  Ask them why before running it again, and do not retry on your own.\n- `[github_account_too_new]` — the user signed in with a GitHub account under\n  30 days old, which Gagarin does not accept yet. The request is kept: tell them\n  to open the same link and choose **Continue with Google**, then run `gg login`\n  again once they say they approved.\n\n`gg login --new` throws away a request nobody approved and asks for a new code —\nfor when the user lost the link, or it was meant for a different account.\n\nDo not open the link yourself, and do not approve it on the user's behalf in a\nbrowser you control: the approval is theirs, and it is the only thing standing\nbetween an agent and an account. The account is whichever one they sign in to;\nif they use more than one, let them pick.\n\nThe moment an account is created it gets its balance and the address the\nprovider verified joins Gagarin's customer list; https://gagarin.cloud/privacy\nsays what that list is for.\n\nYou never handle the credential yourself. Do not read that file, do not echo it,\nand never ask the user for a token — if you find yourself wanting a secret to\nmake `gg` work, you are doing this wrong. The exceptions are CI and an\napplication that starts jobs, and each gets its own — \"Setting up CI\" below, and\n\"From code: the SDK\".\n\nIf `docker` was installed after Gagarin, `gg registry login` does that half on\nits own.\n\n## Setting up CI\n\n**Never run `gg login` in CI, and never copy this machine's credential into\nit.** A pipeline gets one of its own, minted from the one you already hold.\n\n### 1. Mint the credential\n\n`gg creds create --name \"github actions: acme/web\"` prints the secret to\n**stdout alone on its line**, and everything else to stderr. Never run it on\nits own, which would put the secret in your output: pipe it straight into the\nsecret store, so nothing touches disk or the transcript:\n\n```\ngh secret set GAGARIN_TOKEN --body \"$(gg creds create --name \"github actions: acme/web\" 2>/dev/null)\"\n```\n\nOn GitLab, the same with `glab`:\n\n```\nglab variable set GAGARIN_TOKEN --masked --value \"$(gg creds create --name \"gitlab ci: acme/web\" 2>/dev/null)\"\n```\n\n**Without `gh` or `glab` signed in, do not mint it yourself** — there is no way\nfrom here to a secret store that does not pass through your output. Ask your\nhuman to run `gg creds create --name \"…\"` in their own terminal and paste it\ninto the repository's CI settings, or to install and sign in to the forge CLI\nfirst.\n\nName it after where it will live. `gg creds` is a list somebody reads months\nlater deciding what is still wanted, and \"token\" tells them nothing then.\n\nWhat you just minted is **deliberately weaker than what you hold**:\n\n- It can deploy. **It cannot destroy** — a pipeline holding it cannot delete a\n  project, a service or a database, and no flag turns that on.\n- It **expires**: 90 days by default, 365 maximum, and there is no never.\n- It **cannot mint another**, so a leaked one cannot issue its own replacements\n  while you are busy revoking it.\n- It is **shown once**. Gagarin keeps a hash. Lose it and you revoke it and mint\n  another; no command reads one back.\n\n### 2. Give it to the pipeline\n\nCI reads `GAGARIN_TOKEN` from the environment and needs nothing else: no\n`gg login`, no credentials file, no home directory, no interactive anything.\n\n### 3. The workflow\n\nThe shape that matters: install gg, log docker in, publish on every commit,\nrelease on the ones you mean.\n\n```yaml\nname: deploy\non:\n  push:\n    branches: [main]\n\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n    env:\n      GAGARIN_TOKEN: ${{ secrets.GAGARIN_TOKEN }}\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: install gg\n        run: go install github.com/gagarin-cloud/gg@latest\n\n      - name: log docker in to the gagarin registry\n        run: gg registry login\n\n      - name: build and publish\n        run: gg build acme/web:${{ github.sha }} --push\n\n      - name: release\n        run: gg deploy acme/web:8080 web:${{ github.sha }} --env-file .env.production\n\n      - name: say what the cluster is doing\n        run: gg status acme\n```\n\nSix things about that are load-bearing:\n\n- **`gg registry login` is not optional.** `gg build --push`, `gg push` and\n  `gg registry copy` all shell out to docker, and docker has no idea what a\n  Gagarin credential is until that runs. The failure without it is a `401` out\n  of `docker push`, whose hint says exactly this.\n- **Tag with the commit, explicitly.** `gg build` with no tag uses the short\n  hash when the checkout is clean and the clock when it is not — and a\n  pipeline that generates a file or two before the build is not clean. Pass\n  `${{ github.sha }}` so the tag never depends on that: it is what makes a\n  deploy reproducible and a rollback explicable.\n- **`gg push` requires the tag** where `gg build` does not — a push moves\n  something that already exists, and \"whichever one I built last\" is not a name.\n- **The deploy step is separate on purpose.** Publishing on every commit and\n  releasing on some of them is the whole reason build, push and deploy are three\n  verbs. A workflow that only ever wants all three can run `gg ship` instead.\n- **`.env.production` is committed, so it holds no secrets.** It is config:\n  ports, log levels, sibling URLs. The keys the service needs are `external`\n  resources, created once with `gg resource add` and wired with `gg deps add`;\n  they survive every deploy CI makes, and CI never holds them. If you are about\n  to put a credential in a CI secret so the workflow can pass it with `--env`,\n  make it an external instead.\n- **`gg status` at the end is a report, not a gate.** The deploy returned when\n  the demand was recorded; the pod may still be pulling. Do not write a polling\n  loop in CI — if you want a gate, gate on your own health check against the\n  service's address.\n\nEverything else works identically in any CI: the token in the environment, `gg`\non the PATH, docker available if you build. GitLab, Buildkite and Cloud Build\nneed no special handling.\n\n**Watch the first run** if the forge CLI is there, once your human has pushed —\nthat push is theirs to make. Give `gh` the run's id, because without one it\nasks which run, and you cannot answer a prompt:\n\n```\nid=$(gh run list --workflow deploy.yml --limit 1 --json databaseId -q '.[0].databaseId')\ngh run watch \"$id\" --exit-status\ngh run view \"$id\" --log-failed        # only if it failed\n```\n\nOn GitLab, `glab ci status --live` follows the pipeline for the current branch\nand `glab ci trace <job>` prints a job's log. Then `gg status` for what the\ndeploy step actually did.\n\n### 4. Afterwards\n\n```\ngg creds              what has access, which are minted, when each expires\ngg creds revoke 7     immediately, and needing no approval\n```\n\nRevoking needs no human because taking access away is always safe — a machine\nyou no longer trust should not wait on an inbox. Rotate a CI credential by\nminting the new one, updating the secret, then revoking the old id.\n\nIf you are tempted to set `XDG_CONFIG_HOME` to a scratch directory and run\n`gg login` again for a second credential: that used to be the only way and it\nis not any more.\n\n## Recipe: an application from nothing\n\nThe end-to-end, in the order that avoids every window where something is broken.\n\n```\ngg init shop                                  once, per application\n\ngg resource add shop/db postgres --size m     the database, before the thing that needs it\ngg ship shop/api:8080 --deps db               builds ., pushes, runs it, and it\n                                              starts already holding DB_URL\ngg ship shop/web:3000 --env API=http://api:8080\ngg deps add shop/web api                      web may now call api\ngg domain add shop/web                        the one thing the browser opens\ngg status shop                                and only now tell the user a URL\n```\n\nNotes on each step, in the order they bite:\n\n- **After `gg init`, write `.gagarin.json`** with the id it printed, and commit\n  it — see \"Which project this repository is\". Skip `gg init` when the note or\n  `gg projects` says the project already exists.\n- **A Dockerfile per service.** Gagarin deploys images, so a service without one\n  cannot be deployed. Writing it is a normal part of this job. Do not set a\n  platform or architecture: Gagarin reports what its own nodes run, and gg builds\n  for that.\n- **Run `gg ship` from the directory holding that service's Dockerfile**, or\n  point `--context` at it — `gg ship shop/api:8080 --context ./api` from a\n  monorepo root. `--file` names the Dockerfile when it is not called that, or\n  lives outside the context directory.\n- **Commit before you ship, if you can.** With no tag given — and `gg ship`\n  never takes one — gg tags the image with the short hash of the commit\n  (`web:3f9c2ab`), so `gg history` says which code each revision ran and a\n  rollback names what it puts back. Only when the work tree is clean: any\n  modified or untracked file in the repository, inside the build context or\n  not, and it falls back to a clock tag (`web:1761830000`) and says so on\n  stderr. Ignored files do not count. No git or no repository is the clock too,\n  silently. Either way the tag is printed; read it from the output rather than\n  predicting it. Do not commit the user's work just to get a hash: ask, or\n  ship with the clock. (gg v0.55.0 and older always use the clock.)\n- **The number after the colon is the port the container listens on.** It\n  defaults to 8080. Say it anyway when you know it: a service answering on the\n  wrong port is a hang, not an error.\n- **`--deps db` on the first ship** means the pod never starts into a window\n  where it cannot reach the database and does not hold its password. On later\n  ships it is optional and harmless.\n- **Private services talk over `http://<service-name>:<port>`** — the service\n  name, no project prefix, no scheme guessing.\n- **`gg domain add` for the service the user's browser opens, and nothing else.**\n  Do not expose a database, a worker or an internal API \"so it can be tested\".\n  Ask the user before putting anything on the internet they did not ask to.\n- **`gg status` before you promise anything.** `gg ship` says nothing about where\n  a service answers, deliberately — an address exists as a string long before\n  anything is listening on it.\n\n### When to use the three steps instead\n\n```\ngg build  shop/web:v3 --context ./web    make an image, run nothing\ngg build  shop/web:v3 --push             ...and upload it in the same call\ngg push   shop/web:v3                    publish it, release nothing\ngg deploy shop/web:8080 web:v3           release one that already exists\n```\n\nThat is CI, and it is also the only way to run an image you did not just build —\none copied in with `gg registry copy`, or a tag somebody else pushed.\n\n## After the first address: show them around\n\nA first deploy that answers is where most people stop, and the three things that\nkeep a project healthy are one step past it. So once `gg status` shows the first\nservice answering, give the human its URL, and then offer one next step per\nturn, in this order:\n\n1. **The graph.** Point them at `https://my.gagarin.cloud/projects/<id>`: what\n   is running, and what may reach what. Nothing to run, so this one is a\n   sentence and a link.\n2. **Alerts.** Ask whether the human wants a push on their phone when the\n   service goes down, a deploy will not start, or a container keeps crashing.\n   If yes, they open `https://my.gagarin.cloud/projects/<id>/alerts` on that\n   phone and turn on \"Notify me about this project\", which allows notifications\n   and opts them in at once; the same page sends a test. On an iPhone they add\n   the console to the Home Screen first and open it from there. There is no gg\n   command for alerts. With the MCP server connected you may check with\n   `alerts` first, and send `test_alerts` once they say it is on.\n3. **Memory.** `remember` two or three facts this session would otherwise lose:\n   why that port, why that size, what the Dockerfile works around. Then tell\n   the human the project keeps them, and the next session starts from them.\n\nRules, each for a reason:\n\n- **One step per turn, one sentence and one action.** A wall of next steps\n  reads as homework, and the human came for an address.\n- **Stop when they say no or change the subject.** Do not bring a skipped step\n  back later in the same session.\n- **Alerts are the human's switch, not yours.** They reach a person's phone,\n  and only that person's browser can allow them.\n- **Skip what is done, and read \"done\" from state.** With the MCP server,\n  `alerts` says whether alerts are on and how many devices they reach; without\n  it, the human's answer is the state. `memory_briefing` says whether the\n  project already holds memories. What was said earlier in a conversation is\n  not state.\n- **Note what they have seen in `.gagarin.json`.** The graph leaves no trace you\n  can read back, so record each step as it happens: add its name to `\"tour\"`,\n  `{ \"project\": { … }, \"tour\": [\"graph\", \"alerts\", \"memory\"] }`. A step in the\n  list is not offered again, in this session or the next. Commit it with the\n  rest of the note.\n\n## Services\n\nA service is a container image that runs, with a port, a size, an environment,\noptionally a volume, whatever it is allowed to reach, and whatever addresses it\nanswers on. Only the first two of those are set by a deploy. An image that runs\nto completion instead of serving — a migration, a backfill — is a **job**, not a\nservice: see \"Jobs\" below, and do not deploy one as a service, because a\nservice that exits is restarted forever and reads as failing.\n\n### The environment\n\n```\ngg deploy shop/web:8080 web:v3 --env-file .env\ngg deploy shop/web:8080 web:v3 --env-file .env --env DEBUG=false\ngg ship   shop/web:8080 --env-file .env\n```\n\n- `--env-file` is **not** picked up automatically. If the user has a `.env` and\n  wants it used, pass the flag; never assume a file should be read.\n- Precedence: `--env` beats every file, later `--env-file` beats earlier ones,\n  and **a resource's injected variable beats all of it** (see \"Resources\").\n- There is **no interpolation**. `B=${A}` sets `B` to the literal `${A}`.\n- Env is **replaced on every deploy, not merged.** To remove a variable, deploy\n  without it. To keep one, keep passing it.\n- The file supplies **values only**. It cannot name services, set ports or say\n  what is public. If you find yourself wanting to put deployment structure in a\n  file, stop — Gagarin holds that itself.\n\nEnvironment is the one thing a deploy still replaces wholesale, because it is\npart of what a revision ran with and is what a rollback puts back. Everything\nelse that could be lost by forgetting to restate it has been moved out of a\ndeploy for exactly that reason.\n\n### What does not go in env\n\n**No secrets. Not an API key, not a password, not a token, not a connection\nstring with a password in it.** A deploy env is for configuration that is\nharmless to read and owned by this one service: `PORT`, `LOG_LEVEL`,\n`NODE_ENV`, `API=http://api:8080`. Anything that would hurt in the wrong hands\nbelongs on the graph instead:\n\n| it is | where it goes |\n|---|---|\n| a Gagarin database, cache, queue or bucket | `gg deps add P/SVC RESOURCE`. The credentials arrive by themselves, and are never copied into env |\n| a third-party key (Stripe, OpenAI, SMTP, a webhook secret) | `gg resource add P/NAME external --env-file .env.NAME`, then `gg deps add` |\n| config several services share, or that should change without a deploy | an `external` too, even when it is not secret |\n\nWhy a secret in a deploy env is the wrong place, every time:\n\n- **It is copied into every revision.** History keeps each deploy's env so a\n  rollback can put it back, so a key you rotated is still stored, alongside every\n  older one, for as long as those revisions exist.\n- **It cannot be changed on its own.** A deploy replaces the whole env, so\n  rotating one key means restating all of them, and the API will not hand them\n  back: `status` and `history` return the variable *names* (`env_keys`), never\n  the values. Whoever rotates it needs the full `.env` file, or deletes every\n  key they forget.\n- **It is a copy per service.** Three services using one key means three\n  deploys to rotate it, and the one you forget keeps authenticating with a\n  revoked key. An external is one row: `gg resource rotate --set` changes one\n  key, every holder is restarted, and `gg rollback P/NAME` undoes it.\n- **It lives in a file on someone's machine and in CI**, because it has to be\n  restated on every deploy. An external is stated once.\n\n**What you do as an agent:**\n\n- A credential for a service becomes an `external`, from a file your human\n  writes (see the external section). Do not ask for it in chat, do not pass it\n  with `--env`, and do not put it in a `.env` that a deploy reads.\n- If a `.env` you were asked to deploy with holds secrets, say so before\n  deploying, and offer to move them out. Do not quietly ship them, and do not\n  quietly drop them either: the service would start without them.\n- If a service already has a secret in its deploy env (`env_keys` in\n  `gg status` names it), say so and offer the move below. Do **not** try to\n  reconstruct its environment to redeploy: the values are not readable through\n  the API, and a guess deletes every key you leave out.\n\nMoving a secret out of a deploy env, without a moment where the service lacks\nit:\n\n```\ngg resource add shop/stripe external --env-file .env.stripe   # holds API_KEY\ngg deps add shop/web stripe          # web now also holds STRIPE_API_KEY\ngg deploy shop/web:8080 web:v3 --env-file .env   # the same .env, minus STRIPE_API_KEY\n```\n\nThe injected variable beats the deploy env, so the order is safe: `web` holds\nthe key the whole way through, and the last deploy only removes the stale copy.\nName the resource for how the application reads it: `stripe` with `API_KEY`\npublishes `STRIPE_API_KEY`. After the move, the old value is still stored in the\nhistory revisions that carried it. Rotate the key at the provider if it ever went\nanywhere it should not have.\n\n### Size\n\nEvery service and every resource runs at a size, and `s` is what you get if you\nsay nothing at creation.\n\n| | reserved | ceiling | price |\n|---|---|---|---|\n| `s` | 100m CPU / 256 MiB | 0.5 vCPU / 1 GB, shared | $10/month |\n| `m` | 1 vCPU / 2 GB | same — dedicated | $30/month |\n| `l` | 2 vCPU / 4 GB | same — dedicated | $60/month |\n\n```\ngg deploy shop/web:8080 web:v3 --size m\ngg ship shop/web:8080 --size m\ngg resource add shop/db postgres --size m\n```\n\n- **`s` is shared; `m` and `l` are dedicated.** An `s` service may burst to its\n  ceiling but is only guaranteed the reservation, which is why it costs a third\n  of `m`. An `m` or `l` reserves exactly what it is promised and is the last\n  thing evicted when a node runs short.\n- **Omitting `--size` keeps the size the service already has.** It does not reset\n  to `s`. Changing a size is therefore always deliberate.\n- **Changing a size restarts the service** — a new pod with new limits. Expect a\n  few seconds of downtime, and do not do it while something depends on it.\n- **Which to pick.** Start at `s`: it runs a small API, a worker, a static site,\n  a database you develop against. Move to `m` when something is OOM-killed —\n  `gg status` says so and names the size to move to — or when you already know\n  the workload: server-side-rendered Next.js, a JVM, a large in-process cache, a\n  postgres a real application depends on. Do not reach for `l` speculatively.\n- `gg status` shows the size every service is running at, and the day's accrued\n  cost at the bottom of the table.\n\n### Volumes\n\n```\ngg ship shop/db:5432 --volume /var/lib/postgresql/data --volume-size 20\n```\n\nA directory that survives restarts. **Set once, at the deploy that creates the\nservice**; a later deploy cannot move it or resize it, and asking is refused with\n`volume_immutable`. The default ceiling is 10 GB. A rollback across a change of\nvolume is refused for the same reason.\n\nUse this for anything stateful that has no resource type — see \"Anything we do\nnot have a type for\".\n\n## Jobs: what runs to completion\n\n```\ngg build shop/migrate:v3 --context ./migrations\ngg run   shop/migrate migrate:v3 --deps db --env-file .env\ngg run   shop/migrate migrate:v3 --detach        submit and return\ngg run   shop/migrate migrate:v3 --timeout 5m    stop it at five minutes\ngg run   shop/migrate migrate:v3 --ttl 30m       remove it half an hour after it ends\n```\n\nA job is a service that ends. It has an image, an environment, a size and a\nplace on the graph, and **no port, no address and no volume**: it listens on\nnothing, nothing can declare that it needs one, and it keeps nothing between\nruns. Durable data belongs in a resource the job reaches with `--deps`.\n\n- **`gg run` is the one command that waits.** It submits the run, follows it,\n  prints what the run wrote, and **exits with the script's own exit code**. Read\n  the code: zero means the script finished; anything else is the script's\n  failure, and the last line names it. `--detach` returns at once instead, and\n  `gg status` then reports how the run ended.\n- **Every `gg run` is one run**, recorded as a revision exactly like a deploy.\n  Running twice runs twice. `gg history` lists the runs; `gg rollback` runs an\n  earlier revision again.\n- **A run that fails is not retried**, and its exit code is reported once. Fix\n  the script and run again; the platform will not re-run a half-applied\n  migration on its own.\n- **A run is stopped at its timeout, which is sixty minutes unless you set\n  one.** `--timeout 5m` takes a Go duration (`45s`, `5m`, `1m30s`, `1h`) from\n  one second to sixty minutes, in whole seconds; over MCP it is\n  `timeout_seconds`, 1 to 3600. Left out, a job keeps the timeout its last run\n  was given, and a new job gets sixty minutes; to go back to the default, say\n  `60m` (or 3600) outright. The clock starts when the run gets a machine, not\n  when the script starts, so pulling the image uses some of it; waiting for a\n  machine uses none. A run that never gets a machine is given up on after its\n  timeout plus thirty minutes, and its status says nothing ran and nothing was\n  billed. At the deadline the run is sent SIGTERM, and killed thirty seconds\n  later if it is still running. `gg status` says so when that is why it ended:\n  \"the run was stopped at its timeout of 5 minutes, counted from when it got a\n  machine; gg run --timeout gives it up to 60 minutes\" (at the ceiling: \"...after\n  60 minutes, counted from when it got a machine, which is the most a job may\n  take\").\n  Something that needs longer than an hour is a service.\n- **A finished run is removed after its TTL, eight hours unless you set one.**\n  `--ttl 30m` takes a duration from one minute to eight hours; over MCP it is\n  `ttl_seconds`, 60 to 28800 (`invalid_ttl` outside that). Left out, a job keeps\n  the TTL it has, and a new job gets eight hours. It counts from when the run\n  **ended**, not from when it got a machine as the timeout does. On expiry a\n  one-shot job is deleted outright: its row, history and runs go, it leaves\n  `gg status`, and its name is free again (a reused name starts at revision 1).\n  `gg logs` still has what the run wrote while the job exists. So read the\n  outcome with `gg run` (which waits) or `gg status` before the TTL passes, and\n  there is nothing to `gg destroy` afterwards.\n- **Its image is any image in the project's space** — build one with\n  `gg build`, or run the service's own image with a different entrypoint baked\n  into a second Dockerfile. `gg run` does not build.\n- **A job is billed for the time it runs**, at its size, not for existing: by\n  the minute, from when its container starts. Waiting for a machine and pulling\n  the image are not billed. A hung run costs at most its timeout.\n- **A run can sit `pending` without being stuck.** With no machine yet, `gg\n  status` says \"waiting for a machine with room for it — the cluster adds one\n  within a few minutes unless it is at its limit; nothing is billed until it\n  starts\". Keep waiting; it is not a failure.\n- **Kinds do not change.** A name that is a job stays a job (`not_a_service`),\n  and a name that is a service cannot be run as a job (`not_a_job`). Give the\n  job its own name.\n\nUse a job for anything the user describes as \"run this once\" or \"run this\nbefore deploying\": migrations, seeds, imports, one-off reports. The shape for a\ndeploy that needs a migration first is two commands, in this order:\n\n```\ngg run    shop/migrate migrate:v3 --deps db     # exits non-zero if it failed: stop here\ngg deploy shop/api:8080 api:v3\n```\n\n### On a schedule\n\n```\ngg run shop/report report:v2 --schedule \"0 3 * * *\" --tz Europe/Berlin\ngg run shop/report report:v3                     next firing runs v3; schedule kept\ngg run shop/sync   sync:v1   --schedule \"*/5 * * * *\" --deps db\n```\n\nUse this for anything the user describes as \"every night\", \"every hour\", \"on\nMondays\": a nightly import, a report, a cleanup, a sync. It is still a job —\nsame image, environment, size, timeout and graph — with one more property.\n\n- **`--schedule` is five cron fields** (minute hour day-of-month month\n  day-of-week) **or a descriptor**: `@hourly`, `@daily`, `@weekly`, `@monthly`,\n  `@yearly`. It may fire as often as every minute. `@every` and a\n  `CRON_TZ=`/`TZ=` prefix are refused (`invalid_schedule`).\n- **`--tz` is the zone the schedule is read in**, an IANA name like\n  `Europe/Berlin`; UTC when left out. Ask the user which zone they mean when they\n  say \"at 3am\" — the default is UTC, not their laptop's zone.\n- **A scheduled `gg run` does not wait**, because nothing runs now: it prints\n  the schedule and the next firing and returns, whatever `--detach` says. There\n  is no exit code to read. `gg status` is how you learn how each firing ended.\n- **Each firing is a run** like any other: not retried when it fails, stopped\n  at its timeout, billed for the time it ran. A schedule waiting between\n  firings costs nothing. **Runs never overlap**: a firing that comes while the\n  previous run is still going is not started beside it — it waits, and starts\n  the moment that run ends; several firings missed that way start once. A job\n  that takes longer than its interval therefore runs back to back, not in\n  parallel.\n- **`gg run` again without `--schedule` keeps the schedule** and changes what\n  the next firing runs — the image, `--env`, `--size`, `--timeout`, `--ttl`. A firing\n  already going keeps what it started with. `--schedule` again changes when;\n  `--tz` alone changes the zone.\n- **`--schedule` on a one-shot job makes it scheduled**, between runs only:\n  while its run is still going it is refused `job_running`.\n- **A schedule cannot be removed.** `gg run` means \"run this\", so a\n  `--schedule off` would fire a run when all you wanted was for the schedule to\n  stop — the one thing the command could not avoid doing. To stop a scheduled\n  job, destroy it (a human approves) and, if it should still exist as a one-shot\n  job, run it again without `--schedule`. Do not look for a flag to pause or\n  clear a schedule; there is none.\n- **`--ttl` on a scheduled job applies to each firing**, counted from when it\n  ended, and the job stays: only that firing's run is removed. `gg status` still\n  reports the last firing, reading \"(removed after its ttl)\", and `gg logs` keeps\n  what it wrote.\n- **A failed firing alerts** whoever opted in to the project's alerts, once,\n  and a later firing that succeeds resolves it. Nobody else is watching a run\n  at three in the morning, so when you set up a schedule for someone who has\n  them off, suggest the switch at `https://my.gagarin.cloud/projects/P/alerts`.\n- Over MCP, `run` takes `schedule`, `time_zone` and `ttl_seconds`, and `status`\n  carries `schedule`, `time_zone` and `actual.schedule` (`next_at`,\n  `last_scheduled_at`, `suspended`).\n\n### From code: the SDK\n\n`gg run` is for a person or a pipeline, and `--schedule` for a clock. When\n**a program** decides that a job should run — on a request, a queue message, a\nuser's click — it starts the run with the SDK. **Never shell out to `gg` from an\napplication**: it would need gg installed in the image and a login on a machine\nnobody signs in to. The SDK is the same API as a library, in three languages,\neach with no runtime dependencies:\n\n```\nnpm install @gagarin-cloud/sdk              Node 18+, TypeScript types included\npip install gagarin                         Python 3.9+\ngo get github.com/gagarin-cloud/sdk/go      Go 1.22+\n```\n\nEach one reads `GAGARIN_TOKEN` (and `GAGARIN_API`, `GAGARIN_REGISTRY`) from the\nenvironment, exactly as gg does. The four job calls are `run` (submit; returns\nthe run's `revision` at once), `wait` (until that revision ends), `runAndWait`\n(both, which is `gg run`) and `logs`.\n\n```ts\nimport { Gagarin, GagarinError } from \"@gagarin-cloud/sdk\";\n\nconst gg = new Gagarin();\nconst name = `export-${id}`;                       // one name per run; see below\ntry {\n  const sub = await gg.jobs.run(\"shop\", name, {\n    image: \"export:v4\", env: { EXPORT_ID: id }, deps: [\"files\"], timeoutSeconds: 900,\n  });\n  const run = await gg.jobs.wait(\"shop\", name, sub.revision);\n  if (run.phase !== \"done\") { /* failed: run.exit_code, and gg.jobs.logs(\"shop\", name) */ }\n} catch (e) {\n  if (e instanceof GagarinError && e.code === \"payment_required\") { /* … */ }\n  throw e;\n}\n```\n\n```python\nfrom gagarin import Gagarin, GagarinError\n\ngg = Gagarin()\nres = gg.jobs.run_and_wait(\"shop\", f\"export-{id}\", image=\"export:v4\",\n                           env={\"EXPORT_ID\": id}, deps=[\"files\"], timeout_seconds=900)\nres.exit_code                                     # what gg run would exit with\n```\n\n```go\nc, err := gagarin.NewClient()   // import gagarin \"github.com/gagarin-cloud/sdk/go\"\nres, err := c.Jobs.RunAndWait(ctx, \"shop\", \"export-\"+id, gagarin.RunOptions{\n\tImage: \"export:v4\", Env: map[string]string{\"EXPORT_ID\": id},\n\tDeps: []string{\"files\"}, TimeoutSeconds: 900,\n})\nif gagarin.IsCode(err, \"payment_required\") { /* … */ }\nres.ExitCode()\n```\n\nEverything in \"Jobs\" above still holds, because it is the same call:\n\n- **The image must already be in the registry.** The SDK neither builds nor\n  pushes; `gg build` and `gg push` (or CI) put it there first. A bare\n  `repo:tag` is expanded to the project's registry space for you.\n- **`env` is the run's complete environment**, not merged with the last one;\n  leave it out and the run has none. **`deps` adds** to what the job already\n  declares. Both follow rule 7: no credential goes in `env` — a job reaches its\n  database or bucket through `deps`.\n- **The timeout is at most 3600 seconds and starts when the run gets a\n  machine.** Every call is a new run, billed for the time it runs.\n- **The TTL is `ttlSeconds` (Node), `ttl_seconds` (Python), `TTLSeconds` (Go)**,\n  60 to 28800 (`MIN_TTL_SECONDS`/`MAX_TTL_SECONDS`, `MinTTLSeconds`/`MaxTTLSeconds`\n  in Go); leave it out for the job's current one, eight hours on a new job. It\n  counts from when the run ended and then removes a one-shot job, so `wait` or\n  `runAndWait` and read the run (and `logs`) before it goes. After that, `get`\n  and `wait` on the name fail `not_found` (\"nothing named … in project …\"), which\n  looks the same as a job that never existed. A scheduled firing is the\n  exception: the job stays, and its last run reads `expired: true`\n  (`Expired` in Go) with phase, exit code and times intact.\n- **Refusals are a typed error carrying the API's `code`**, `message` and\n  fix hint: `GagarinError` in Node and Python, `*gagarin.Error` with\n  `gagarin.IsCode` in Go. Branch on the code, as in \"Error codes\".\n- **It does not destroy anything.** Destroying is a human's approval, and the\n  SDK leaves it out.\n\n**One name per run that may overlap another.** Starting a run on a job **stops\nthat job's run still going** — a new revision is what the job is now. So an\napplication that may start a second run before the first has ended must give\neach its own job name: a fixed prefix and a short id of the work (`export-7f3a`),\nnever raw user input, and within `^[a-z][a-z0-9-]{1,29}$`. If only a fixed number\nshould run at once, a name per lane (`export-1` … `export-4`) is the alternative,\nand the application must not start a lane that is busy. A `wait` on a run that a\nnewer one replaced fails with `superseded` (`gagarin.ErrSuperseded` in Go) —\nthe symptom of two runs sharing a name. A finished job costs nothing and\nremoves itself after its TTL, eight hours unless the run asks for less, which\nfrees its name; nothing needs `gg destroy`, so per-run names do not pile up.\n\n**The application needs a credential of its own**, minted the way CI's is and\ndelivered the way every other secret is — as an `external` resource, never in\n`--env`. Name the resource `gagarin` and the key `TOKEN`, and the service holds\nexactly the `GAGARIN_TOKEN` the SDK reads:\n\n```\nprintf 'TOKEN=%s\\n' \"$(gg creds create --name \"shop/api: starts jobs\" 2>/dev/null)\" > .env.gagarin\ngg resource add shop/gagarin external --env-file .env.gagarin\ngg deps add shop/api gagarin\nrm .env.gagarin\n```\n\nThe token never reaches the terminal or the transcript. Tell the user what it is:\n\n- **It can deploy and run anything in the account**, not only this project, and\n  it **cannot destroy**. Anyone who can read the service's environment holds it.\n- **It expires** — 90 days unless `--expires` says otherwise, 365 at most. Before\n  then, mint a new one the same way into `.env.gagarin` and\n  `gg resource rotate shop/gagarin --env-file .env.gagarin`; the service rolls with\n  it. Never `--set TOKEN=…`: that puts the token on a command line.\n- **`gg creds revoke ID` stops it**, and `gg creds` lists it under the name you\n  gave it.\n\n## Dependencies: what may reach what\n\nEvery service in a project is default-denied. A private service is reachable\nonly from services that have declared they need it, and **an undeclared call is\ndropped rather than refused** — it does not fail fast, it hangs until the client\ngives up, which for a database driver can be thirty seconds or forever.\n\n**A hang between two of your own services is a missing `gg deps` far more often\nthan it is a bug in the application.**\n\n```\ngg deps ls  shop/api            what it reaches today\ngg deps add shop/api db cache   and these as well\ngg deps rm  shop/api cache      and no longer that one (needs a human)\n```\n\n- **Withdrawing needs a human's approval; adding does not.** `gg deps rm` is\n  gated the way `gg destroy` and `gg domain rm` are: it answers\n  `approval_required` and emails the account owner a sentence naming the edge.\n  The asymmetry is the point — opening a path breaks nothing, and closing one\n  breaks something *silently*, because the calls that used to arrive are dropped\n  rather than refused. Ask the user before you request that approval, and tell\n  them what will stop being able to reach what.\n- **The direction matters.** The declaration goes on the *caller*. If `api`\n  queries `db`, it is `api` that needs `db`, never the other way round. Backwards\n  is refused, not quietly accepted.\n- **Reaching a resource also hands over its credentials.** `gg deps add shop/api\n  db` gives `api` `DB_URL`, `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD` and\n  `DB_DATABASE`, and the command prints which ones arrived. Connecting is this\n  one call; it used to be two, and that is no longer necessary.\n- **`--deps` on a deploy or a ship only ever adds.** It exists so a service that\n  cannot start without a database can be declared and deployed together.\n  Forgetting it on the next deploy changes nothing. Withdrawing is `gg deps rm`,\n  there and nowhere else. (If you are working from memory and reach for\n  `--needs`: it is gone. It replaced the whole set on every deploy, so a redeploy\n  that forgot it silently withdrew an edge — and because an undeclared call\n  hangs, the service did not break, it went quiet.)\n- **Public URLs are not covered by this.** One service calling another's public\n  `https://` address arrives the way a stranger's browser does and is allowed.\n  The guarantee is about private, in-project addresses.\n- **Withdrawing applies to new connections, not open ones.** `gg deps rm` closes\n  the path for anything that connects afterwards, but a client holding a\n  keep-alive connection — every HTTP client, every driver pool — keeps using it\n  until it reconnects. That is how Kubernetes network policy works. If you need\n  the old path gone now, redeploy the caller: a new pod has no old connections.\n- `gg destroy` on something another service still needs is refused, and names\n  what depends on it. `gg deps rm` that first.\n\n`gg status` ends every service's row with a REACHES column, so checking the\ngraph costs nothing — do it *before* you go debugging a hang.\n\n### Reaching the outside world\n\nOutbound is unrestricted, with one exception you need before you build on it:\n**the mail ports — 25, 465 and 587 — are blocked.** A connection to any of them\ntimes out, from every service, and it cannot be opened per-account.\n\nSo **do not build anything that speaks SMTP.** If the user wants their\napplication to send email, reach for a provider's HTTPS API — Resend, Postmark,\nSendGrid, SES, any of them. That is a normal way to send mail, not a workaround,\nand it is what Gagarin itself does. Prefer the provider's official SDK to\nhand-rolled HTTP.\n\nThe reason, if the user asks: a service that can open those ports can relay spam\nif it is ever compromised, and a hosting account that relays spam gets suspended\n— which would take every other project on the platform down with it.\n\nIf you find yourself debugging a hanging SMTP connection, stop. It is not the\nuser's code and it is not DNS. It is this.\n\n## Resources: what a project *has*\n\nA resource is provisioned rather than deployed. There is no image to choose, no\nversion to pass and no Dockerfile.\n\n```\ngg resource add shop/db postgres --size m --storage 20 --ext vector\ngg resource add shop/vectors qdrant\ngg resource add shop/cache valkey\ngg resource add shop/events iggy\ngg resource add shop/jobs rabbitmq\ngg resource add shop/files s3\ngg resource add shop/openai external --env-file .env.openai\n```\n\n| type | what it is | storage | backups |\n|---|---|---|---|\n| `postgres` | PostgreSQL 17, with the extensions you ask for (`vector`, `postgis`, …) | on a volume; survives restarts | nightly, kept 14 days |\n| `qdrant` | vector database, for retrieval | on a volume; survives restarts | nightly, kept 14 days |\n| `iggy` | Apache Iggy, a persistent message-streaming log | on a volume (10 GB unless `--storage`); survives restarts | nightly, kept 14 days — see the durability caveat |\n| `rabbitmq` | RabbitMQ 4.4.0 with the management plugin, a message broker for work queues | on a volume (10 GB unless `--storage`); durable queues and persistent messages survive restarts | **none** |\n| `valkey` | in-memory store, redis protocol | **none — a restart loses everything** | none, by design |\n| `s3` | an S3-compatible bucket, for files — private until `gg resource public` | **objects on durable storage; it runs nothing** | **none** |\n| `external` | a third-party API, run by nobody here | **none — it runs nothing at all** | nothing to back up |\n\nThe types are named for what actually runs, not for the products they stand in\nfor — an honesty you can pass on when somebody asks.\n\n- **`qdrant` is Qdrant**, Apache-licensed, and it is what an application does\n  retrieval against: embeddings in, nearest neighbours out. Three things about\n  it are unlike every other type, and all three will bite an agent that assumes\n  otherwise.\n  - **The credential is not in the URL.** `<NAME>_URL` is a bare\n    `http://vectors:6333`; the key arrives separately as `<NAME>_API_KEY` and\n    travels as an `api-key` header. Every client takes it as its own argument —\n    `QdrantClient(url=os.environ[\"VECTORS_URL\"], api_key=os.environ[\"VECTORS_API_KEY\"])`.\n  - **It answers on two ports.** `<NAME>_PORT` is 6333 (HTTP/REST) and\n    `<NAME>_GRPC_PORT` is 6334. The Python, JS, Java and .NET clients want the\n    URL; the official **Go and Rust clients speak only gRPC** and want the host\n    and 6334. Both are published so neither has to be guessed.\n  - **There is no MongoDB here, and no document store either.** If a user wants\n    documents rather than vectors, Gagarin has no type for it — run one as an\n    ordinary service with a volume.\n\n  - **Qdrant or `vector` on a postgres?** Both store embeddings. If the\n    application wants relational tables and embeddings in one database —\n    joined in one query, written in one transaction — ask for the `vector`\n    extension on its postgres (see \"Postgres extensions\" below). That is the\n    default for an application that already needs a postgres and adds\n    retrieval: one resource, one set of credentials, one backup. Reach for\n    `qdrant` when the vectors *are* the product — the search is what the\n    application is for, and it deserves a database of its own.\n\n  Gagarin ran a `ferretdb` type from 2026-09-04 to 2026-09-06 and it is **gone**:\n  it promised MongoDB compatibility and did not keep the promise past the simple\n  cases. There is no alias and no migration path. If a user names it, say it was\n  removed and offer the service-with-a-volume route.\n- **`iggy` is Apache Iggy**, Apache-licensed: a persistent message-streaming\n  log, what an application publishes events to and consumes from in order. One\n  pod, one volume (10 GB by default; `--storage` is accepted), private like every\n  resource, so it is reached only by services that declare it with `deps`.\n  - **It answers on two ports.** `<NAME>_PORT` is 8090, the TCP binary protocol\n    every Iggy SDK speaks, and `<NAME>_HTTP_PORT` is 3000, for REST. QUIC and\n    WebSocket are off.\n  - **The credential is in the URL.** `<NAME>_URL` is the connection string the\n    SDKs read, `iggy://root:<password>@events:8090` for a resource called\n    `events`; `_USER` is always `root`.\n  - **A backup can miss recent messages unless the topic is persisted.** The\n    backup is taken while the server keeps running, so only topics created with\n    `--durability persisted` are guaranteed complete. A topic with the default\n    durability may be missing its newest messages, the ones not yet flushed to\n    disk. Have producers create topics with `--durability persisted` for\n    anything the user would want back from a backup, and say so when you set one\n    up.\n- **`rabbitmq` is RabbitMQ** 4.4.0 with the management plugin: a message broker,\n  what an application publishes jobs to and workers consume from. One pod, one\n  volume at `/var/lib/rabbitmq` (10 GB by default; `--storage` is accepted),\n  private like every resource, so it is reached only by services that declare it\n  with `deps`. Add it, then let the worker reach it: `gg resource add shop/jobs\n  rabbitmq`, then `gg deps add shop/worker jobs`.\n  - **It answers on two ports.** `<NAME>_PORT` is 5672, AMQP, the protocol every\n    client speaks, and `<NAME>_HTTP_PORT` is 15672, the management UI and HTTP\n    API.\n  - **The credential is in the URL.** `<NAME>_URL` is\n    `amqp://app:<password>@jobs:5672/%2F` for a resource called `jobs` (the\n    `%2F` is the default vhost `/`), and it goes straight to the client: pika,\n    amqplib, amqp091-go, or a Celery `broker_url`. `_USER` is always `app`.\n  - **There are no backups.** `gg resource backup` answers `backup_unsupported`.\n    Unlike iggy, there is nothing to recommend that makes a backup complete,\n    because there is no backup. What survives a restart is only what is durable:\n    declare queues `durable` and publish messages `persistent` (delivery mode 2)\n    for anything the user wants to outlive the pod. A transient queue or message\n    is gone on a restart, which happens on a node drain, not only when somebody\n    asks.\n  - **Declare queues and exchanges from application code, at startup.** The\n    broker keeps no copy elsewhere, so a fresh one (a destroyed and re-added\n    resource, or a lost volume) must be rebuildable by just starting the\n    application. Declaring is idempotent when the arguments match, so every\n    producer and consumer can do it on every start. Do not create topology by\n    hand in the management UI and leave it there.\n  - **Choose it for work queues, routing and fan-out to workers**; choose\n    `iggy` for an append-only log that consumers replay from an offset. If the\n    user wants to re-read history, it is iggy; if each message is a job to be\n    done once and then forgotten, it is rabbitmq.\n- **`valkey` is a cache, not a database.** `--storage` is refused (`no_storage`)\n  rather than quietly ignored, and everything in it is gone when the pod restarts\n  — which happens on a node drain, not only when somebody asks. Do not put a\n  session store there that a user would notice losing, and do not tell anyone\n  their data is safe in it. Valkey is the BSD-licensed fork of Redis; `redis://`\n  URLs, `redis-cli` and every client library work unchanged.\n- **Storage can grow, never shrink.** Restate the resource with a bigger\n  `--storage` to raise the ceiling — `gg resource add shop/db postgres --storage\n  40` on an existing `db` grows it and changes nothing else. A smaller number is\n  refused with `volume_immutable`.\n- **One instance, one volume, no failover.** A size change or a restart is a\n  brief outage. There is no point-in-time recovery. Say that plainly if a user\n  asks whether their data is safe, rather than implying an SLA nobody is on the\n  hook for.\n- **A resource cannot be deployed over.** `gg deploy shop/db` against one is\n  refused with `not_a_service`, which is telling you the name is already a\n  database. Nor can a resource declare dependencies: it is reached, it does not\n  reach.\n- **A managed resource cannot be rolled back**, because Gagarin mints its\n  credentials and there is no earlier value of the user's to go back to. An\n  **external can** — its values are theirs — and `gg rollback P/NAME` is how a\n  config change is undone. See the external section below. An `s3` cannot\n  either, for the same reason.\n\n### Postgres extensions\n\nA `postgres` takes **extensions**: the set of postgres extensions the database\nshould have, named exactly as `CREATE EXTENSION` names them.\n\n```\ngg resource add shop/db postgres --ext vector --ext postgis    create it with both, or restate it\n```\n\nOver MCP it is the `extensions` list on `add_resource`; on the API it is the\n`extensions` field of the resource's PUT body,\n`{\"type\":\"postgres\",\"extensions\":[\"vector\",\"postgis\"]}`. `--ext` takes one name\nand is repeated, like `--deps` and `--env` — not a comma-separated list. The\nrules are the same everywhere:\n\n- **It is the whole set, not a delta.** `--ext vector` on a postgres that has\n  `vector` and `postgis` asks for postgis to go. To add one, restate every one it\n  already has plus the new one — `gg status` lists what it has.\n- **Leave it out and the extensions stay as they are**, exactly like `--size`.\n  An empty list (`[]`, or `--ext \"\"`) means none.\n- **Only a postgres has them.** `extensions` on any other type is refused with\n  `no_extensions`.\n- **On create, they exist before the database is first ready.** Adding one to\n  an existing postgres is **immediate, on the running server, with no\n  restart** — every postgres runs the same image with all of them compiled in.\n- **Dropping one asks no one** — the one removal that does not, because a drop\n  refuses rather than loses anything, so a drop that succeeds cost nothing.\n  **It is never CASCADE**: a column, an index, a view or a SQL-standard\n  function that uses the extension — a `vector` column, say — stops it. **And\n  it is refused while the extension's own tables hold the user's data**:\n  pg_cron's jobs (`cron.job`) and their run history, pg_partman's partition\n  config (`partman.part_config`), a spatial reference system the user added to\n  PostGIS's `spatial_ref_sys`. Nothing depends on those tables, so without the\n  guard a plain DROP would delete every scheduled job. Either refusal is\n  `extensions_failed` (HTTP 409), carrying postgres's own reason — \"column e\n  of table items depends on type vector\", or \"extension pg_cron holds 1 row(s)\n  of your data in cron.job; remove them first if losing them is what you\n  mean\". It is one transaction, so a refused change changes nothing — not the\n  extensions, and not the rest of what the command restated. To really drop\n  it, remove what is in the way first — and ask your human before deleting\n  their jobs or data to do it. A plpgsql function that uses the extension is\n  not tracked by postgres, so it breaks when next called; nothing is lost, and\n  adding the extension back mends it.\n- **Requirements are added for you.** Asking for `earthdistance` also gives\n  `cube`.\n- **Ask the platform; do not run `CREATE EXTENSION` by hand** for anything in\n  the catalogue below. `app` is a superuser in its own pod and *can*, but what\n  it creates that way is not recorded in `extensions`: the platform does not\n  know about it, the status does not show it, and nothing keeps it. Asking the\n  platform records it and keeps it.\n\n**The catalogue — everything `extensions` accepts:**\n\n| name | what it is for |\n|---|---|\n| `vector` | pgvector: vector columns with HNSW and IVFFlat indexes, for embeddings |\n| `postgis` | PostGIS: geometry and geography types, spatial indexes and functions (no raster) |\n| `pg_cron` | scheduled SQL, run by the database itself (jobs run in database `app`) |\n| `pg_partman` | partition management, created in schema `partman` |\n| `pgaudit` | audit logging to the resource's log (set `pgaudit.log` to turn it on) |\n\nPlus the contrib extensions that ship with postgres: `pg_stat_statements`,\n`pg_trgm`, `pgcrypto`, `uuid-ossp`, `citext`, `hstore`, `ltree`, `unaccent`,\n`fuzzystrmatch`, `btree_gin`, `btree_gist`, `cube`, `earthdistance` (adds\n`cube`), `intarray`, `tablefunc`, `amcheck`, `pg_buffercache`.\n\n- **\"pgvector\" is called `vector`.** That is its name in postgres, and asking\n  for `pgvector` is refused with a hint saying so. There is no pgvector\n  resource type: embeddings in a postgres are this extension.\n- **Not offered:** timescaledb (its licence forbids exactly a hosted service),\n  raster, `dblink`/`postgres_fdw`/`file_fdw`, untrusted languages. Any name\n  outside the catalogue is refused with `unknown_extension`, and the hint lists\n  every name that is offered.\n- Nothing else about the postgres changes: the same connection variables, sizes,\n  storage, price, rotation and nightly backups.\n\n### Connecting one: the single call\n\n```\ngg deps add shop/api db\n```\n\nThat declares the dependency **and** puts the database's connection variables in\n`api`'s environment. It prints what arrived:\n\n```\napi reaches db, and nothing else.\n\napi now holds DB_DATABASE, DB_HOST, DB_PASSWORD, DB_PORT, DB_URL, DB_USER\n  in its environment, from the resources it reaches. Values: gg resource secrets.\n```\n\nOr declare it on the deploy, so the service never starts without them:\n`gg deploy shop/api:8080 api:v3 --deps db`.\n\n**The variables are named after the resource, not the protocol** — the resource's\nown name, upper-cased with dashes as underscores, plus a suffix:\n\n| suffix | postgres | valkey | qdrant | iggy | rabbitmq |\n|---|---|---|---|---|---|\n| `<NAME>_URL` | `postgres://…?sslmode=disable` | `redis://:pass@…` | `http://vectors:6333` | `iggy://root:pass@events:8090` | `amqp://app:pass@jobs:5672/%2F` |\n| `<NAME>_HOST` | ✅ | ✅ | ✅ | ✅ | ✅ |\n| `<NAME>_PORT` | 5432 | 6379 | 6333 | 8090 | 5672 |\n| `<NAME>_GRPC_PORT` | — | — | 6334 | — | — |\n| `<NAME>_HTTP_PORT` | — | — | — | 3000 | 15672 |\n| `<NAME>_USER` | ✅ | — | — | `root` | `app` |\n| `<NAME>_PASSWORD` | ✅ | ✅ | — | ✅ | ✅ |\n| `<NAME>_API_KEY` | — | — | ✅ | — | — |\n| `<NAME>_DATABASE` | ✅ | — | — | — | — |\n\nAn `s3` bucket publishes none of these. It publishes five of its own:\n`<NAME>_ENDPOINT`, `<NAME>_REGION`, `<NAME>_BUCKET`, `<NAME>_ACCESS_KEY_ID` and\n`<NAME>_SECRET_ACCESS_KEY` — see its section below. While it is public it also\npublishes `<NAME>_PUBLIC_URL`.\n\nA postgres called `db` publishes `DB_URL`; one called `orders-db` publishes\n`ORDERS_DB_URL`; a valkey called `cache` publishes `CACHE_URL` and no\n`CACHE_USER`, because valkey has no users. A type omits the suffixes it has no\nanswer for rather than publishing them empty — so an absent `VECTORS_PASSWORD`\nis not a bug, it is a qdrant having no password. Two consequences, and both are\nthe point: a service can reach two databases without a collision, and there is\none vocabulary of suffixes rather than a different set per type.\n\n**These are not the names your framework expects, and that is deliberate.** There\nis no `DATABASE_URL`, no `PGHOST`, no `REDIS_URL`, no `QDRANT_URL` unless the\nresource happens to be called `qdrant`. The first thing to try is to have the\napplication read `DB_URL` — one line in the app, and nothing about it can go\nstale.\n\nIf you genuinely cannot change the application, read the value out and pass it\nunder the name it wants:\n\n```\ngg deploy shop/api:8080 api:v3 --deps db \\\n  --env DATABASE_URL=\"$(gg resource secrets shop/db --format json | jq -r .env.DB_URL)\"\n```\n\nNote what that is: **a copy**, and the only stale thing in the model. `$DB_URL`\nalone would not work — the injected variables exist inside the pod, not in the\nshell running `gg`. Say so rather than leaving a second copy of a password in a\ndeploy nobody remembers making.\n\nFour rules that follow, and each one fails quietly if you get it wrong:\n\n- **Injected variables outrank your own.** Set `DB_URL` on a deploy while the\n  service also reaches a resource called `db`, and the resource wins. It is the\n  one place something beats what a deploy said, and the reason is that only the\n  resource knows the real password.\n- **Nothing is copied into the stored environment.** The platform unions these in\n  every time it renders the pod, from the graph as it stands then. They cannot go\n  stale, no redeploy can forget them, and **a rollback restores the image and the\n  environment you deployed with, never an old password.** `gg deps rm` takes them\n  away just as surely.\n- **Holding the credentials is not enough.** The network policy is a separate\n  boundary from the environment. You cannot get the credentials without the\n  declaration that opens the route, so this is no longer a trap — but do not\n  conclude from a working password that the route is open for some *other*\n  service you did not declare.\n- **`gg resource secrets` is for reading the values from outside the graph** —\n  checking what an application is being handed, or wiring up a client that runs\n  outside Gagarin. The values name the in-project host, which this machine\n  cannot reach: to actually connect from here, `gg connect` opens a tunnel and\n  prints them rewritten for it. You do not need either to connect a service in\n  the same project. Treat the output as a live credential: do not echo it into\n  a chat, a commit, or a summary.\n- **`--names` when the question is \"what does it publish\"**, which it usually\n  is: what a bundle holds, or what a key is called before you change it. It\n  asks a different endpoint, so the values are not fetched rather than merely\n  not printed — nothing secret passes through you. `gg status` cannot answer\n  this: it prints `DB_*`, the prefix rule rather than the contents.\n\n```\ngg resource secrets shop/db --names         # just the names — reach for this first\ngg resource secrets shop/db > .env.db       # KEY=VALUE lines into a file, for --env-file\ngg resource secrets shop/db --format json | jq -r .env.DB_URL > db.url   # one value, into a file\n```\n\n### Meddling from this machine: `gg connect`\n\n```\ngg connect shop/db\n```\n\nA resource is not on the internet, and stays off it. When a human needs psql\nagainst the real database — a migration to babysit, a row to look at — this\nopens a tunnel from this machine and prints the same variables a service would\nhold, rewritten to point at 127.0.0.1:\n\n```\ndb is a postgres. The tunnel is up:\n\n  DB_HOST=127.0.0.1\n  DB_URL=postgres://app:…@127.0.0.1:5432/app?sslmode=disable\n  ...\n```\n\n- **It lasts exactly as long as the command.** Ctrl-C closes the tunnel and\n  every connection through it. Nothing is exposed, and there is nothing to\n  undo afterwards.\n- **It is for the machine gg runs on, never for services.** A service reaches\n  a resource by declaring it — `gg deps add shop/api db` — which needs no\n  tunnel and survives any command exiting. Do not leave `gg connect` running\n  as plumbing under an application.\n- **Every port the resource answers on gets a local end** — a qdrant tunnels\n  6333 and 6334 at once, an iggy 8090 and 3000, and a rabbitmq 5672 and\n  15672 (the management UI is then at `http://127.0.0.1:<local port>`). Each prefers its own number and quietly takes a free\n  one when that is busy; `--port` pins the primary, and is refused rather than\n  moved when the port is taken.\n- **An external is refused** (`not_tunnelable`), and an s3 is refused by `gg`\n  itself (\"publishes no port to tunnel to\"): nothing runs, so there is nothing\n  to tunnel to. Their values are `gg resource secrets`.\n- **The resource must be running.** A stopped one refuses with\n  `tunnel_unavailable`, and `gg status` says what it is waiting on.\n- The printed values are live credentials on a local port, and the same rule\n  as secrets applies: do not echo them into a chat, a commit, or a summary.\n\n### `external`: a third-party key as a node on the graph\n\nAn OpenAI account, a Stripe key, a bucket somewhere else. Not something Gagarin\nruns — something your services need a credential for.\n\n```\ngg resource add shop/openai external --env-file .env.openai\ngg deps add shop/bot openai\n```\n\nAn `.env.openai` holding `API_KEY` and `BASE_URL` makes `bot` hold\n`OPENAI_API_KEY` and `OPENAI_BASE_URL`. Same naming rule as every other type, so\n**write the keys without the prefix** — `API_KEY`, not `OPENAI_API_KEY`, which is\nrefused rather than doubled.\n\n**This is where every third-party credential goes. A deploy env is not an\nalternative.** Why not `--env OPENAI_API_KEY=…` on the deploy? Because a key on a\ndeploy is a copy. Three services using one key means three copies, rotating\nit means three deploys, and a deploy you forget leaves a service authenticating\nwith a revoked key. As a resource it is one row and rotating is one command.\n\n- **Use `--env-file`, not `--env`.** A key on the command line goes into the shell\n  history and into the transcript of every agent that ran the command. Ask your\n  human to write the key into `.env.NAME` themselves; do not ask for it in chat.\n  If they paste one anyway, write it to the file without repeating it, and tell\n  them it is now in this chat's history, so it should be rotated at the provider.\n- **Restating an external is refused** once it exists (`already_exists`). That\n  refusal is deliberate: restating from an old `.env` would roll the key\n  *backwards*, and the failure would be an authentication error nobody would\n  connect to the command they ran. Changing values is `gg resource rotate`, and\n  changing *one* of them is `gg resource rotate --set K=\"$(cat FILE)\"`, which\n  leaves the rest alone and keeps the value off the command line.\n- **It runs nothing.** No container, no port, no size, no storage, no backups,\n  nothing to become ready. `gg status` shows it as `◆` and leaves every\n  container column a dash; what it publishes is `gg resource secrets P/NAME\n  --names`.\n- **Declaring an external does NOT restrict egress.** This is the one thing not to\n  get wrong when you explain it. Everything in a project can already reach the\n  whole internet — the mail ports are the only exception. What the declaration\n  grants is the credentials and a line on the graph saying who uses them. It is\n  **not** a firewall: an undeclared service can still call `api.openai.com`, it\n  just has no key. `gg status` marks these edges `◆` for exactly this reason.\n- **What it is genuinely worth:** the project's dependencies become legible, and\n  destroying an external is refused while anything still declares it, so a key\n  cannot be dropped out from under a running service.\n\n### An external is also where shared config belongs\n\nNot only third-party credentials. **Anything several services read, or that\nchanges without a deploy, belongs in an external** — feature flags, a log level,\na region, an API base URL, a tuning constant.\n\n```\ngg resource add shop/config external --env-file .env.shared\ngg deps add shop/web config\ngg deps add shop/worker config          # both hold CONFIG_LOG_LEVEL\n\ngg resource rotate shop/config --set LOG_LEVEL=debug   # both roll, with the new value\ngg rollback shop/config                                # both roll back\n```\n\n**Why this beats `--env` on each deploy:** the same argument as for a key. An\nenv on a deploy is a copy, so two services sharing a setting is two copies that\ncan disagree, and changing it is two deploys with one you can forget. Resolved\nfrom the graph it is one row, one command, and every holder restarts.\n\n**The editing model is the sharper difference, and it is the one that decides\nthis for you.** A service's environment can be changed only by `gg deploy`, and\na deploy **replaces it wholesale** — every variable not restated is gone. That\nis deliberate, not an oversight: the revision records exactly what the service\nran with, which is what makes a rollback mean something. The cost is that\nchanging one variable requires having all of them.\n\n|  | service env | external |\n|---|---|---|\n| changed by | `gg deploy`, and only a deploy | `gg resource rotate` |\n| granularity | wholesale — anything omitted is **lost** | one key at a time |\n| needs the other values in hand | **yes** | no |\n| undo | `gg rollback P/SVC`, with the deploy | `gg rollback P/config` |\n\n**For you this is a hard edge, not an inconvenience.** Working without the\nproject's `.env` file — from the console's Agent tab, or any session handed a\ntask rather than a repository — you cannot safely change one variable on a\nservice. The only route is to read the whole environment back out of\n`gg history` and restate it, which drops anything you misread and pulls **every**\nvalue the service holds, secrets included, through your transcript.\n\n`gg resource rotate P/config --set KEY=value` has neither problem: it touches the\none key, needs nothing else in hand, and reads no other value. **So when a user\nasks you to change a setting and you do not have their env file, the answer is\nan external — and if the setting is currently in a deploy env, say so and offer\nto move it.**\n\nAnd to find out what a bundle holds before you change one key of it:\n\n```\ngg resource secrets shop/config --names      # names only; no values fetched\n```\n\nUse `--names` by default. Without it the command prints live credentials, and\nin your case that means into a transcript. `gg status` will not answer this\neither — it lists the resource and nothing about its contents.\n\nThe full lifecycle is there, which is what makes it safe to recommend:\n\n| | |\n|---|---|\n| set it | `gg resource add P/config external --env-file .env` |\n| change one value | `gg resource rotate P/config --set LOG_LEVEL=debug` |\n| remove one | `gg resource rotate P/config --unset REGION` |\n| see what it was | `gg history P/config` |\n| put it back | `gg rollback P/config [--to N]` |\n| see what keys it has | `gg resource secrets P/config --names` — no values fetched |\n| read the values | `gg resource secrets P/config` — live credentials; prefer `--names` |\n| who uses it | `gg status P` — and destroying it is refused while anyone does |\n\n**Where the line is.** Config *owned by one service* stays in its `gg deploy\n--env`, because that is the half a service rollback restores. Injected values\nare re-derived from the resources as they stand now — deliberately, so nobody is\never rolled back onto a rotated password — so `gg rollback shop/web` will not\nundo a config change. Undo it at the resource.\n\nThree properties to state when asked, because they are constraints and not\noversights:\n\n- **The prefix is not optional.** A resource named `config` publishes\n  `CONFIG_LOG_LEVEL`, never a bare `LOG_LEVEL`. Name the resource so the prefix\n  reads the way the application wants it.\n- **A dependent cannot override a value.** Injected beats the service's own env\n  of the same name. Two services needing different values is two resources.\n- **Every dependent gets every key** in the bundle. Split by audience, not by\n  topic: one resource per set of services that should hold the same things.\n\n### `s3`: a bucket for files\n\nUser uploads, generated files, ML artifacts, static assets an app serves\nitself. Gagarin's object storage, as an S3-compatible bucket that is private\nuntil you say otherwise.\n\n```\ngg resource add shop/files s3\ngg deps add shop/web files\n```\n\n`web` now holds `FILES_ENDPOINT`, `FILES_REGION`, `FILES_BUCKET`,\n`FILES_ACCESS_KEY_ID` and `FILES_SECRET_ACCESS_KEY` (same prefix rule as every\nother type). There is **no `_URL`, `_HOST`, `_PORT`, `_USER` or `_PASSWORD`** —\nan S3 client takes these five settings separately. Any S3 client library works\n(boto3, the AWS SDKs, …); **pass the endpoint and the region explicitly**, or it\nwill look for AWS. The endpoint is `https`.\n\n- **`--size`, `--storage` and `--env` are all refused** (`no_size`,\n  `no_storage`, `no_env`). A Gagarin without object storage configured answers\n  `object_storage_unavailable` (HTTP 501); report it.\n- **It runs nothing.** No pod, no port, no volume, no logs. Gagarin mints its\n  key, like postgres — unlike an external.\n- **A bucket is private by default.** Only its own key can read or write it;\n  another project's key cannot.\n- **`gg resource public P/NAME` makes the whole bucket listable and readable by\n  anyone**, no key needed. Writes still need the key. Every dependent then gets\n  `<NAME>_PUBLIC_URL` (`https://<bucket>.s3.fr-par.scw.cloud`) and is restarted\n  for it; `gg resource private P/NAME` undoes it and the variable goes away. Both\n  are idempotent, need the editor role and a deploy-scope credential, and\n  `publish_failed` changed nothing, so run it again. The public address also\n  shows in `gg status` among the project's domains.\n  - **Only make public what is genuinely meant to be public.** Listing exposes\n    every object name in the bucket, not just the ones the app links to, and\n    anything fetched while it was open stays fetched. User uploads that are\n    meant to stay private belong in a private bucket, served by the app (which\n    proxies them or hands out its own signed links). Ask the user before\n    running it.\n  - **Browsers on any site can read it.** Making a bucket public also sets a\n    CORS rule: any origin, `GET` and `HEAD` only, no credentials. So\n    `fetch()` of an object or the listing, web fonts, ES modules and\n    `<img crossorigin>` (and reading a canvas) work. It adds no exposure, since\n    a public object was already readable with curl, and writes still need the\n    key. `gg resource private` removes it. A bucket made public before this\n    existed gets it by running `gg resource public` again. The tenant cannot\n    set CORS itself.\n  - **Egress is not metered per bucket yet.** Say so to the user when a public\n    bucket is going to carry heavy traffic (a download host, a busy site's\n    images).\n- **Declaring it does NOT restrict the network.** It is reached over the\n  internet, not inside the cluster, so — exactly like an external — the\n  declaration hands over the key and nothing more. It is not a firewall. `gg\n  status` marks these edges `◇`.\n- **There are no backups.** Objects sit on durable storage but Gagarin takes no\n  copy, and `gg resource backup` answers `backup_unsupported`. If losing the\n  data would matter, keep a copy somewhere else.\n- **`gg connect` does not work**: it publishes no port, and `gg` says so. Read\n  the values with `gg resource secrets`.\n- **It costs $0.03 per GB-month** of what it actually holds, measured hourly,\n  rounded up to whole GB and prorated per minute. There is no running charge,\n  and requests and traffic are not billed.\n- **Not deployable, not rollback-able, no `gg domain`.** `gg deploy` over it is\n  `not_a_service`, as is `gg rollback` (Gagarin mints its key). Its public\n  address comes from `gg resource public`, not from a domain.\n- **Destroying it** needs the human's email approval, is refused while anything\n  still declares it, cuts the key off at once, and permanently deletes every\n  object shortly after.\n\nA bucket the user already has somewhere else is still an `external`.\n\n### Rotating credentials\n\n```\ngg resource rotate shop/db                                        a database\ngg resource rotate shop/openai --set API_KEY=\"$(cat new.key)\"     one of an external's values\ngg resource rotate shop/openai --env-file .env.new                all of them\n```\n\nEverything holding the old credential is restarted with the new one, and the\ncommand names what it rolled. Nothing but variable *names* is printed;\n`gg resource secrets` reads the values, into a file.\n\n**Who supplies the new value is the only difference between the types.** For\n`postgres`, `qdrant`, `valkey`, `iggy`, `rabbitmq` and `s3`, Gagarin mints one and `--env` is refused — a\npassword you chose is one the running server has never heard of. For an\n`external` the values are yours, so one of `--set`, `--unset`, `--env-file` or\n`--env` is required.\n\n**An external usually holds more than one value, and the two ways of changing\nthem mean different things. Reach for `--set`.**\n\n| | what it means |\n|---|---|\n| `--set K=V`, `--unset K` | change these, leave every other key exactly as it is |\n| `--env`, `--env-file` | the bundle is now precisely this; anything not in it **stops being published** |\n\n`--env API_KEY=sk-new` on an external that also holds `BASE_URL` takes `BASE_URL`\naway from every dependent. That is the correct meaning of that request — it is\nthe one to use after a provider migration where every value is new — and the\nwrong one for the far commoner job of replacing a single key. Reading the bundle\nback and restating it is not the answer either: that is the stale-file path, and\nit is how a key gets rolled backwards.\n\nThe command names what stopped being published, so a loss is visible at the\nmoment it happens rather than from a dependent that can no longer authenticate.\nThe two flags cannot be combined — they say the same thing in incompatible\nwords.\n\n`--unset` names a key **without** the resource's prefix, the way it was set:\n`--unset BASE_URL` on `shop/openai`, not `OPENAI_BASE_URL`. A key the resource\ndoes not publish is refused rather than quietly doing nothing, because a no-op\nreported as a success is how somebody believes a secret is gone when it is not.\n\n| type | what happens | cost |\n|---|---|---|\n| `postgres` | the running server is told immediately | none |\n| `qdrant` | the pod is replaced; the key is read at startup | a few seconds away; **the data survives** |\n| `iggy` | the running server is told the new root password first and it is recorded, then the pod restarts and dependents roll | a few seconds away; **nothing stored is lost**, a graceful stop flushes |\n| `rabbitmq` | the running server is told the new password first, then the pod restarts and dependents roll | a few seconds away; **nothing stored is lost** |\n| `valkey` | the pod is replaced; the password is read at startup | **the cache is emptied** |\n| `s3` | a new key is issued and recorded, dependents restart, then the old key is revoked at once | **not zero-downtime:** their S3 calls fail for the seconds the restart takes; **the objects survive** |\n| `external` | nothing of ours runs, so nothing of ours restarts | none |\n\n**An s3 rotation can revoke late.** If the answer says `old_credential_revoked:\nfalse`, the old key still works: tell the user, and run the rotation again — it\nrevokes the leftover key first.\n\n**If it fails, nothing changed.** The old credential is still in use and the\ncommand is safe to run again — say that, rather than leaving the user wondering\nwhat a half-failed rotation left behind. There is no half.\n\n**Rotate after a leak, and say so plainly.** If a key has been in a chat log, a\ncommit or a screenshot, this is the fix and it is one command. For an external,\nnote that Gagarin forgets the old value but cannot *revoke* it — that is a thing\nto do in the third party's own console, and the user has to do it.\n\n### Backup and recovery\n\nPostgres, qdrant and iggy are backed up nightly and kept fourteen days — postgres as a\n`pg_dump`, qdrant as a tar of its per-collection snapshots with the aliases\nbeside them.\n\n**An iggy backup is taken while the server keeps running.** Only topics created\nwith `--durability persisted` are guaranteed complete; a topic with the default\ndurability may be missing its newest messages, the ones not yet flushed to disk.\nRecommend `--durability persisted` for anything the user would want back. Valkey keeps nothing by design, an external has nothing here to\nkeep, and an s3 bucket is not copied: its objects are on durable storage, but\n`gg resource backup` answers `backup_unsupported`. A rabbitmq is in the same case: it is not backed up at all, so its\ndurability is only what survives a restart (durable queues, persistent messages).\n\n```\ngg resource backups shop/db     what is stored, newest last\ngg resource backup  shop/db     take one now — do this before a risky migration\n```\n\n**Any postgres backup restores into any postgres.** A dump carries its\nextensions and every postgres has every one available, so a database that used\n`vector` or `postgis` comes back with them; the restored resource's\n`extensions` are read back from the database. There is nothing to ask for\nbefore restoring.\n\n`gg resource backup` reads the database and writes an object; it is safe at any\ntime and the nightly schedule keeps running regardless.\n\n**A restore creates a NEW resource — it never overwrites an existing one.** That\nis the platform's rule, not a convention: the name you give must not exist yet,\nand the platform creates the resource itself, which is exactly why a restore\nneeds no human approval and can be reached for at three in the morning.\n\n```\ngg resource restore shop/db2 --source db   new resource, filled from db's newest dump\ngg deps add shop/api db2                   hands api DB2_URL and the rest\ngg deps rm  shop/api db                    and stop it reading the old one\n                                           (this one needs a human's click)\ngg destroy  shop/db                        once everything reads from db2 — the only\n                                           step that destroys data, and the only one\n                                           that asks a human\n```\n\n- **The variables change with the name.** `db2` publishes `DB2_URL`, not\n  `DB_URL`, so an application reading `DB_URL` finds nothing after the `deps rm`.\n  Either name the new resource what the old one was called — possible only once\n  the old one is destroyed — or expect to touch the application. This is the one\n  place the per-resource naming costs something, and it is worth knowing before\n  three in the morning.\n- The old resource **may already be destroyed** when you restore: its backups\n  outlive it by fourteen days and `--source db` still finds them.\n- `--backup <key>` from `gg resource backups` restores an exact point instead of\n  the newest.\n- **The platform does the restore, not the command.** It creates the new\n  resource as the backup's type — recorded with every backup, so there is\n  nothing to say even for a destroyed source — then starts it and pours the data\n  in on its own. `gg resource restore` waits and prints each step by default;\n  stopping it stops nothing. With `--no-wait` it returns at once, and `gg status`\n  shows the restore under the resource until it is done, or why it failed.\n  **Do not `deps add` anything to the new resource before it is done.**\n- A failed restore leaves a resource holding nothing worth keeping: destroy it\n  and restore again under a new name once the cause is fixed.\n- `gg resource backups shop/db` works on a destroyed resource too, and shows what\n  it left.\n\n### Anything we do not have a type for\n\nFour types will never cover everything. Run it as an ordinary service with a\nvolume:\n\n```\ngg registry copy shop/clickhouse clickhouse/clickhouse-server\ngg deploy shop/analytics:8123 clickhouse --volume /var/lib/clickhouse --volume-size 50\ngg deps add shop/api analytics\n```\n\nEverything else behaves the same way: a private address by name, a volume that\nsurvives restarts, and the same refusal to delete it while something still needs\nit. The only difference is who decides — for a resource the platform picks the\nimage, the version and the port and carries them; here you pick them, and\nupgrades, tuning and consequences are yours.\n\n**If a type exists, use the resource. If it does not, this is the normal path,\nnot a workaround.** Gagarin has no type for ClickHouse, Cassandra, DuckDB or a\ndocument store, and that is not an error.\n\nNever write a one-line Dockerfile that only says `FROM` in order to get an image\nin. `gg registry copy` is the same thing, done properly, and it copies every\narchitecture the source published rather than whatever your laptop cached.\n\n## Recipes: a project other people can deploy\n\nA recipe is a published snapshot of a project: its services, jobs, resources,\ndependencies and sizes. Anyone who has the recipe's 8-character id can deploy it\ninto a **new** project of their own. It is never installed into an existing\nproject. Its deploy page is `https://my.gagarin.cloud/deploy/<recipe-id>`, and\na publisher can put this badge in a README:\n\n```\n[![Deploy to Gagarin](https://gagarin.cloud/deploy-button.svg)](https://my.gagarin.cloud/deploy/<id>)\n```\n\nRecipes are not part of `.gagarin.json`. That file still only names the project.\n\n### Publishing: `gg recipe snap`\n\n```\ngg recipe snap shop --dry-run                       what would be published, and the floor\ngg recipe snap shop                                 publish, at the floor version\ngg recipe snap shop --version 1.2.0 --as shop-kit   pick the version and the name\ngg recipe snap shop --source https://github.com/acme/shop --notes \"faster checkout\"\n```\n\nOnly the project's owner can snap. **Run `--dry-run` first**, and show the user\nthe floor and what will be published before you publish. A recipe version is\nimmutable once it exists.\n\n**Env in a recipe never holds secrets.** Plain env on a service or a job is\ncopied as it is, so anything secret-shaped must not be there. Secrets belong in\nan `external` resource. A recipe keeps the external's variable names and never\ntheir values, and each name becomes an input the deployer supplies. If snap\nanswers `env_looks_secret`, it names the variables:\n\n```\ngg resource add shop/stripe external --env-file stripe.env\ngg deps add shop/api stripe\ngg deploy shop/api:8080 api:v3                      restate the env without them\ngg recipe snap shop                                 and snap again\n```\n\nDo not rename a variable to get past the check. Move the value to an external.\n\n### The floor\n\nEach snap has a lowest allowed version, worked out from the previous one:\n\n- a removal, a rename, a volume change or a type change forces a **major**\n- an addition, or a bigger monthly bill, forces at least a **minor**\n- anything else is free, and may be a patch\n\nOmit `--version` to take the floor. A version below it is refused\n`version_below_floor`, and the dry run prints the reasons.\n\n### Reading\n\n```\ngg recipe show a1b2c3d4                  the graph, inputs, monthly cost, deploy URL\ngg recipe show a1b2c3d4@1.2.0            one version\ngg recipe show a1b2c3d4 --format json    the manifest, for reading by a program\ngg recipe ls                             the recipes this account published\n```\n\n`show` works on any recipe id, not only your own. Read it before you install,\nand tell the user what it will cost and which inputs it wants.\n\n### Installing: `gg recipe install`\n\n```\ngg recipe install a1b2c3d4 shop --input stripe=stripe.env\ngg recipe install a1b2c3d4@1.2.0 shop --input stripe=stripe.env --input mail=mail.env\n```\n\nAlways a new project: `NEW_PROJECT` must not exist yet. Pass one `--input\nNAME=FILE` for every input the recipe declares, which `gg recipe show` lists.\nEach file is an env file. **Never put a value on the command line.** Ask the\nhuman for the values, write them to the file, make sure the file is\ngitignored, and delete it when the install finishes. gg refuses up front when a\ndeclared input has no `--input`, and it never prints what a file holds. The\ninstall copies the images into the new project, then starts everything. It ends\nwith the project's status, so follow the usual rule and read it before you\npromise a URL.\n\n### Updating\n\n```\ngg recipe diff shop                      what the newest version would change\ngg recipe diff shop --to 1.3.0\ngg recipe update shop                    apply it\ngg recipe update shop --to 1.3.0 --input mail=mail.env\ngg recipe update shop --force            overwrite what was changed by hand\n```\n\nAn update is the patch between two versions, not a reinstall. Always `diff`\nfirst and tell the user what changes. A new input needs its `--input` file, the\nsame as an install. An update that **removes** something needs a human's\napproval, like any destroy. If the project was changed by hand where the patch\nalso changes it, the update refuses with a conflict. Ask the user before you\npass `--force`, because it overwrites their change.\n\n### Removing\n\n```\ngg recipe rm a1b2c3d4@1.2.0              one version\ngg recipe rm a1b2c3d4                    the recipe, and every version\n```\n\nThis needs a human's approval, like every destroy: follow \"Destroying things\".\nProjects already installed from the recipe keep running.\n\n## Addresses\n\nA service is private until it is given an address, and one command gives it\neither kind:\n\n```\ngg domain add shop/web                     an address gagarin generates\ngg domain add shop/web shop.example.com    a name the user owns, as well\ngg domain ls  shop                         every address, and who each is waiting on\n```\n\nThe generated one is idempotent and instant: Gagarin holds the wildcard record\nand the wildcard certificate for the project's cluster, so there is nothing to coordinate and nobody to\nwait for.\n\n**A name the user owns is two steps, and only the first is Gagarin's.** The\ncommand makes the service answer for the name; making the name *resolve* here is\na DNS record the user creates at their registrar, and Gagarin cannot do it for\nthem. The command prints the exact record — pass it on verbatim rather than\nparaphrasing it.\n\n**Nothing is served over HTTPS on that name until the record exists.** Let's\nEncrypt proves control by fetching the domain over the internet, so a certificate\ncannot be ordered before DNS points here. That is the normal first state, not a\nfault: do not retry the command hoping it resolves, because the missing piece is\non their side. `gg status` says which of the two of you it is waiting on:\n\n| reading | who acts |\n|---|---|\n| waiting for DNS | **them** — the record does not exist at the zone's own nameservers |\n| DNS points elsewhere | **them** — it resolves, but not to Gagarin |\n| waiting for cache revalidation | **nobody** — the record is right; a resolver is still holding its old answer, and it clears within the zone's negative TTL |\n| issuing certificate | Gagarin — nothing for them to do |\n| ok | nobody |\n\nGagarin orders the certificate only once the zone's own nameservers point the name\nhere, so claiming a name before creating the record is harmless. On `waiting for\ncache revalidation`, do not touch the DNS record and do not retry; tell the user it\nclears by itself (often 15–60 minutes) and the certificate follows.\n\nThe generated address only ever reads `ok` or `issuing certificate`. It is never\nwaiting on the user, because there is nothing for them to do about it.\n\n- **A deploy never changes an address**, in either direction. Forgetting a flag\n  would otherwise take a live site down while the owner's DNS still looked right.\n- **Both addresses answer.** A service with a custom domain keeps its generated\n  one, so existing links do not break and there is something to test against\n  while DNS propagates.\n- **A custom domain brings the generated one with it.** Claiming a name for a\n  private service makes it public in the same call. Say out loud that you are\n  putting it on the internet.\n- **One domain, one service, across all of Gagarin.** A name somebody else holds\n  is refused, and the refusal does not say who holds it.\n- **A subdomain is told a CNAME to the cluster's name**, such as\n  `CNAME fr-par-1.apps.gagarin.cloud`, not to the old shared `apps.gagarin.cloud`.\n  Pass on the target the command prints; it depends on the project's cluster.\n- **An apex domain gets an A record, not a CNAME** — DNS does not permit a CNAME\n  at an apex. The command prints the right one; do not \"correct\" it.\n\n### Taking an address away\n\n```\ngg domain rm shop/web shop.example.com    release a name they own\ngg domain rm shop/web                     make the service private again\n```\n\n**Both need a human's approval, every time** — the same emailed click `gg\ndestroy` and `gg deps rm` need. This is destructive in the way deleting something is: what breaks\nis invisible from the terminal and obvious to whoever was using the address. Do\nnot run either unless the user asked for it in those words.\n\nReleasing the generated address while a custom name is still declared is refused\n(`domain_attached`) — that would leave their DNS pointing at a host Gagarin no\nlonger serves. Release the custom name first.\n\n## Reading state\n\n`gg status <project>` reports desired state and actual cluster state side by\nside. Trust it over your own memory of what you deployed: it reads the cluster,\nnot just the database.\n\n```\nproject shop  (id 7f3a9c2e)  fr-par-1\n\n     SERVICE  KIND      SIZE  READY  PORT  REACHES      IMAGE\n  ●  web      service   s     1/1    8080  api          web:1757030400\n  ●  └ https://web-7f3a9c2e.fr-par-1.apps.gagarin.cloud\n  ●  api      service   m     1/1    4000  db, openai◆  api:1757030112\n  ●  db       postgres  m     1/1    5432  —            postgres:17\n  ◆  openai   external  —     —      —     —            —\n  ◇  files    s3        —     —      —     —            —\n\n  ● running   ◆ external (runs nothing; declaring it grants its variables, not egress)\n  ◇ bucket (runs nothing; reached over the internet, so declaring it grants its key, not a network path)\n  $0.412 today so far\n```\n\nWhat to read, in the order it matters:\n\n1. **Lines beginning `!`, when there are any, come before the table because they\n   change what the table means.** There are two:\n   - **\"this project is suspended and nothing is running: …\"** — every service\n     shows `◌` and `0/0`, and writes are refused with `project_suspended`. If the\n     reason is credit, the user fixes it at https://my.gagarin.cloud/billing and\n     services restart by themselves within a few minutes. Anything else is a\n     decision Gagarin made, and only support can lift it — do not tell the user\n     to add credit, because it will not help. **Nothing has been deleted**: the\n     data, the addresses and the certificates are all still there.\n   - **\"the reconciler last ran … ago\"** — Gagarin reporting on itself. The rows\n     are still an accurate reading of the cluster, but nothing is closing the gap\n     between them and what was asked for. Tell the user; there is nothing an\n     agent can do from here.\n2. **The state mark.**\n   - `●` **running** — the cluster is running what was asked for, and something\n     answers on the declared port.\n   - `◐` **starting** — in flight: pulling, booting, waiting on an ingress. The\n     cluster has not given up and neither should you.\n   - `○` **failing** — either nothing is in the cluster at all, or Kubernetes has\n     stopped calling this a rollout in progress. Waiting will not fix it.\n   - `◌` **stopped** — the project is suspended. See the `!` line.\n   - `◆` **external** — runs nothing, so it has no state to be in.\n   - `◇` **bucket** — an `s3`: runs nothing either, and its edges read `files◇`.\n   - `✓` **done** — a job whose latest run finished with exit code 0. A job\n     whose run failed is `○`, and the line under the table gives its exit code.\n   - `◷` **scheduled** — a scheduled job that has not fired yet. Waiting, not\n     wrong: its line says when it fires next.\n3. **`◐` and `○` print the cluster's own explanation below the table.** Read it\n   before changing anything.\n4. **READY counts pods of the revision you asked for.** A redeploy that will not\n   start reads `0/1` even while the previous version is still serving traffic.\n   That is the honest number: the service is answering, but not with what you\n   shipped. For a job the cell is the latest run's phase instead — `done`,\n   `failed`, `running`, `pending` — its PORT is a dash, and the line under the\n   row says which run, when, how long, the exit code, and for a failed run the\n   cluster's reason: `○  └ run 4 failed 2 minutes ago after 3s, exit 2: the\n   container exited with code 2`. A scheduled job's cell also carries its\n   schedule (`⏱ 0 3 * * *`), and its line ends with when it fires next\n   (`· next in 21h`) or that the schedule is suspended with the project. A scheduled firing whose TTL\n   passed still shows, ending \"(removed after its ttl)\"; `gg logs` keeps its\n   output. A one-shot job past its TTL is not listed at all.\n5. **Addresses hang under their service**, marked `●` when there is nothing left\n   to do and `○` with who is holding it up when there is. An address that is fine\n   says nothing more than its own URL.\n6. **KIND and VOLUME columns appear only when the project has something to put in\n   them**; SIZE is always there.\n7. **The last line is the day's accrued cost**, in thousandths of a dollar.\n\nOther readers:\n\n```\ngg projects                 every project you can reach, its id, and your role\ngg logs shop/web            recent logs; needs a running pod (logs_unavailable if not).\n                            For a job: what its latest run wrote\ngg history shop/web         every deploy, newest first, the live one marked →\ngg deps ls shop/web         what it may reach\ngg domain ls shop           every address and its state\ngg creds                    every credential, the one you are using marked *\n```\n\nWhen somebody wants to understand how their services fit together, point them at\nthe project's page on https://my.gagarin.cloud — its right half is a live\ndependency graph. That is for the human; read the plain output yourself.\n\nDescribe services at the altitude Gagarin does: \"web is public on port 8080 at\n<url>; worker is private.\" Give every address a service answers on, not just one.\nDo not introduce Kubernetes vocabulary — namespaces, ingresses, pods and service\naccounts are not part of this model, and mentioning them is a regression.\n\n## Undoing a deploy\n\n```\ngg history  shop/web          revision numbers, images, when, and who —\n                              an image tagged with a short hash is that commit\ngg rollback shop/web          put the previous deploy back\ngg rollback shop/web --to 3   a particular revision\ngg rollback shop/config       put an external's previous values back\n```\n\n- **A rollback is a deploy.** It goes through the same write gate and is recorded\n  as a *new* revision naming the one it restored. Nothing leaves the history, so\n  changing your mind is another rollback rather than a lost record.\n- **It restores the image and the environment**, exactly as that revision had\n  them. A variable added since is gone afterwards.\n- **It does not restore the dependency graph, the domain or the volume.** Those\n  are standing declarations about the shape of the project rather than parts of\n  the artifact, and putting yesterday's image back says nothing about them.\n- **It never restores an old password.** Resource variables come from the graph\n  at pod-start, not from the revision.\n- **It is refused across a change of volume** (`volume_immutable`). Deploy the\n  configuration you want instead.\n\nPrefer a rollback to a corrective deploy when something you just shipped is\nbroken and you do not yet know why: one call, a state that provably ran, and the\nevidence left intact for afterwards.\n\n## Alerts\n\nA project can tell its members when something breaks. Alerts are Web Push\nnotifications from the console (https://my.gagarin.cloud), which is also a PWA.\nEach member opts in per project for themselves, viewers included, and the\nnotifications go only to that member's own devices. There is no topic, server\nor token to set up.\n\n**A human turns alerts on, in the console.** The project's Alerts tab,\n`https://my.gagarin.cloud/projects/P/alerts`, has one switch, \"Notify me about\nthis project\", which allows notifications on that device and opts the member in\nat once, and sends a test from the same page. Point the human there, on the\nphone they want the push on. Turning the switch off there opts them out.\n\nThere is no gg command for alerts: talking the human through that page is your\npart. With the MCP server connected, `alerts` says whether the caller is opted\nin, how many devices they have, and the last few notifications; `test_alerts`\nsends a test once they say it is on; each takes only the project. Opting in is\nper member, so one member turning alerts on does not turn them on for anyone\nelse.\n\n**An agent cannot add a device.** A device exists only once a human allows\nnotifications in a browser, at `https://my.gagarin.cloud/projects/P/alerts`. On\nan iPhone the app must first be added to the Home Screen (Share, then Add to\nHome Screen) and opened from there, or the browser will not offer push at all.\nIf the human has no device yet, hand them that page. Then they hear\nwhen a service has been down for three minutes, when a deploy will not start\n(the previous revision keeps serving), and when a container crashes and\nrestarts, once when it starts and once when it ends, never on repeat. The\nconsole keeps a 30-day feed of these notifications. There are no rules to\nchoose. Offer alerts after a first deploy that a human cares about; do not turn\nthem on without asking, because the notifications go to somebody.\n\nThe old ntfy alerts are gone: `--server`, `--topic` and `--token` no longer\nexist, and sending them is refused with `ntfy_removed`.\n\n## Sharing a project\n\nA project has exactly one **owner** — the account that pays for it — plus any\nnumber of editors and viewers.\n\n```\ngg members shop                     who can reach it, and as what\ngg share shop teammate@example.com  add an editor (the default)\ngg share shop them@example.com --role viewer\ngg unshare shop them@example.com\n```\n\nAn **editor** operates the project — deploy, delete individual services, manage\nthe roster — without paying for it. A **viewer** reads status, logs and the\nmember list, and nothing else. **Destroying a project is the owner's alone**:\nthat takes its data and its URL with it, and only the account paying can decide.\nOwnership is not on this list because it is the bill, not a role: it is not\ngranted here, it is offered and accepted — see below.\n\n- `gg share` with no `--role` grants **editor**, which can deploy over whatever\n  is running. If the user asked for \"read access\" or \"let them look at the logs\",\n  pass `--role viewer`.\n- Sharing with somebody who has never used Gagarin is allowed — the access waits\n  for them and lands the moment they sign in with a GitHub or Google account\n  whose verified email is that address. **Nothing is emailed to them**, so tell\n  the user to let them know; they get in by running `gg login` and approving it,\n  as in \"Getting access\".\n- **Ask before sharing.** Access to a project is the user's to give, not yours to\n  infer from a name in the conversation.\n\n## Handing a project over\n\nSharing gives access away. `gg transfer` gives away the **bill** — who pays for\nthe project from that moment on.\n\n```\ngg share shop them@example.com       first: they must already be a member\ngg transfer shop them@example.com    offer it; nothing changes yet\ngg transfer shop --withdraw          take the offer back\ngg members shop                      shows an offer that is standing\n```\n\nIt is an offer, never an assignment, and both halves need a human:\n\n1. The **owner** runs `gg transfer` and gets `approval_required` — they click a\n   button in their own inbox, signed in to Gagarin, and you run the same command\n   again. This is the\n   same human gate `gg destroy` uses, for the same reason: a handover cannot be\n   undone by the person who started it.\n2. The **recipient** gets an email and presses a button. Until they do, nothing\n   has changed and `gg members` still shows the old owner. **Tell the user this**\n   — a transfer that is \"done\" from the CLI is a transfer that has not happened.\n\nWhat happens when they accept: the project keeps its id, services, addresses,\ndata and history — **nothing restarts**. Usage is billed to the new owner from\nthat moment, and to the old owner up to it. The **previous owner becomes an\neditor**, so they keep operating it and stop paying for it; the new owner can\n`gg unshare` them like anyone else.\n\n- **Only the owner can offer**, and only to somebody already on the roster. Share\n  first.\n- If the recipient already has a project by that name, pass `--as NAME` — names\n  are unique within an account, and this is what the project is called in theirs.\n- The recipient's account has to be able to carry it: not suspended, has a card\n  or a balance, and under their project limit. The refusal comes back to the\n  owner with the fix in it — those are things the two of them sort out before\n  anybody clicks.\n- `gg unshare` on the person an offer was made to **withdraws the offer too** —\n  an offer only ever goes to a member, so taking the access away takes the offer\n  with it.\n- **Never offer a project the user has not explicitly asked you to hand over.**\n  This is the one command that ends with them not paying for something they no\n  longer own, and no amount of context makes it inferable.\n\n## Diagnosing\n\nStart from the symptom, not from the logs.\n\n| symptom | first suspect | what to run |\n|---|---|---|\n| a service never becomes ready | the declared port; the app binds elsewhere or on `127.0.0.1` | `gg status`, then redeploy on the port the app really binds |\n| `ImagePullBackOff` | the image is not there — a copy that never finished, or a tag that does not exist | `gg history`, then push or copy the image again |\n| the container starts and exits | a missing environment variable, or a crash | `gg logs shop/web` |\n| killed with no log output | out of memory | `gg status` names the size to move to |\n| one service hangs calling another | a missing `gg deps` edge — an undeclared call is dropped, not refused | `gg deps ls shop/api`, or the REACHES column |\n| a database driver times out | the same, or the app is not reading `<NAME>_URL` | `gg deps ls`, then `gg resource secrets` to see what it should hold |\n| you need to look inside the database itself | it is not on the internet, by design | `gg connect shop/db`, then psql or redis-cli against the printed URL |\n| an SMTP connection hangs | ports 25, 465 and 587 are blocked platform-wide | use a provider's HTTPS API; nothing to fix here |\n| a custom domain serves no HTTPS | DNS does not point here yet | `gg domain ls`; the record is the user's to create |\n| everything shows `◌` and `0/0` | the project is suspended | read the `!` line above the table |\n| `docker push` returns 401 in CI | docker was never logged in | `gg registry login` |\n\n**\"nothing is listening on port N\" is the common one**, and it is almost always\nthe port rather than the app. Gagarin asks the container every few seconds\nwhether anything accepts a connection on the port you declared, so a service that\nboots perfectly well and listens somewhere else never becomes ready. Many\nframeworks also default to `127.0.0.1`, which nothing outside the container can\nreach — they need `0.0.0.0`.\n\n**\"the previous revision is still serving\"** on a redeploy means the old version\nis up and answering. The user is not down. Fix the new revision and ship again;\ndo not tear anything down first.\n\n**Out of memory names its own fix**, in `gg status`:\n\n```\nthe container ran out of memory and was killed (it exceeded the 1Gi ceiling of\nsize s); try --size m, which gets 2Gi\n```\n\nRedeploy at the size it names. Do not retry unchanged — it will be killed again —\nand do not go hunting in the logs first, because a process the kernel killed for\nusing too much memory usually writes nothing about it. This is the one failure\nyou can resolve without asking the user anything, so resolve it.\n\nDo not poll in a tight loop, and do not tell the user something is live because a\ncommand exited zero.\n\n## Error codes\n\ngg prints failures as `[code] message`, usually with a `hint:` line under it.\n**Branch on the code.** The message is for the human.\n\n**Access and credentials**\n\n| code | what to do |\n|---|---|\n| `unauthorized` | this machine has no usable credential — run `gg whoami`, then \"Getting access\". Never ask the user for a token |\n| `insufficient_scope` | this credential does not carry that right; a browser session cannot deploy. Deploy from the CLI — the dashboard has no deploy button on purpose |\n| `cannot_delegate` | a minted credential tried to mint another. Mint it from the machine a human approved |\n| `name_required` | `gg creds create` with no `--name`. Name it after where it will live |\n| `invalid_expiry` | `--expires` outside 1–365 days. There is no never; omit it for 90 |\n| `name_too_long` | over 120 characters, and it appears in a list. Shorten it |\n| `approval_required` | a human must approve a deletion, a released address, a withdrawn dependency, or an ownership offer. The button is in their email, and it asks them to sign in first if they are not. Tell the user, pass on the code, wait, retry the same command. One click covers fifteen minutes, so a sequence of these needs one approval, not several |\n| `authorization_pending` | nobody has approved the `gg login` request yet. Relay the link again if needed; run `gg login` again once the user says they approved |\n| `expired_token` | the `gg login` request lived fifteen minutes and nobody approved it. Run it again and pass on the new link |\n| `access_denied` | the user declined `gg login` on the page. Ask them before running it again |\n| `github_account_too_new` | the user's GitHub account is under 30 days old. The `gg login` request is still good: they open the same link, choose Continue with Google, approve, and you run `gg login` again |\n| `invalid_email` | the address given to `gg share` or `gg transfer` is not one. Ask the user again; do not guess |\n\n**Projects and roles**\n\n| code | what to do |\n|---|---|\n| `project_not_found` | no such project, **or** you cannot reach it. `gg projects` lists what you can; `gg init` creates one; otherwise ask for a `gg share` |\n| `project_suspended` | the project accepts no writes; reads still work. Out of credit: the user adds some at https://my.gagarin.cloud/billing and it restarts itself. Anything else: only support can lift it — tell the user and stop |\n| `project_limit` | destroy one that is no longer needed, or the user writes to support@mail.gagarin.cloud |\n| `project_exists` | you already have one by that name. Names need only be unique within your account |\n| `invalid_name` | lowercase letters, digits, hyphens; start with a letter; 2–30 characters |\n| `insufficient_role` | you are a viewer here. Ask the owner or an editor for edit access; do not retry |\n| `owner_only` | only the paying account may do this. Tell the user to run it themselves; nobody can grant it |\n| `invalid_role` | roles are `editor` and `viewer`; `owner` is the account that pays |\n| `owner_not_a_member` | that address already owns the project; nothing to do |\n| `member_not_found` | `gg members <project>` shows who has access |\n\n**Handing a project over**\n\n| code | what to do |\n|---|---|\n| `not_a_member` | share it first: `gg share P EMAIL`, then offer it |\n| `already_owner` | they already own it; nothing to do |\n| `name_taken_there` | they have a project by that name. Re-run with `--as NAME` |\n| `recipient_suspended` | their account is stopped; they add credit, then you offer again |\n| `recipient_cannot_pay` | no card and no balance there; the project would be suspended on arrival. They fix it at https://my.gagarin.cloud/billing |\n| `recipient_project_limit` | their account is full; they destroy one, or write to support@mail.gagarin.cloud |\n| `no_offer` | nothing is pending. If it was accepted, the project is theirs and only they can offer it back |\n| `project_suspended` on a transfer | a project suspended in its own right cannot change hands. Only support can lift that |\n\n**Alerts**\n\n| code | what to do |\n|---|---|\n| `alerts_off` | `test_alerts` before alerts are on. The human turns them on with the switch at https://my.gagarin.cloud/projects/P/alerts |\n| `ntfy_removed` | alerts no longer go to ntfy; `server`, `topic` and `token` are refused. The human turns alerts on in the console |\n| `no_devices` | `test_alerts` and the caller has no device. The human allows notifications at https://my.gagarin.cloud/projects/P/alerts (iPhone: add the app to the Home Screen first) |\n| `invalid_subscription` | the browser's push subscription was refused (not https, not a known push service, bad keys). The human re-enables notifications in the console |\n| `push_unconfigured` | the platform has no push keys yet. Nothing to fix on your side; tell the user |\n\n**Services, images and deploys**\n\n| code | what to do |\n|---|---|\n| `image_required` | `gg push` one first, or use `gg ship` |\n| `docker_not_installed` | from gg itself, before any request: there is no `docker` (or, for `gg registry copy`, no `buildx`). Ask your human to install Docker Desktop, OrbStack or colima (Docker Engine on Linux). An image already in the registry needs no docker: `gg deploy` it |\n| `docker_not_running` | docker is installed but its daemon did not answer; the message names the socket. Ask your human to start it and run `gg ship` again once `docker info` succeeds |\n| `docker_permission_denied` | this user cannot reach the daemon (Linux). Ask your human to add the user to the `docker` group and log in again. Never run gg with `sudo` |\n| `image_not_yours` | the image is not in this project's registry space. Build or push into this project, or `gg registry copy` it in |\n| `invalid_digest` | pass what `docker push` reported, or leave it out |\n| `invalid_port` | set the port the container actually listens on |\n| `invalid_timeout` | `timeout_seconds` outside 1–3600. Give 1–3600 or leave it out |\n| `service_has_no_timeout` | `timeout_seconds` was given on a service rather than a job. Drop it; a service runs until it is replaced |\n| `invalid_ttl` | `ttl_seconds` outside 60–28800. Give 60–28800 or leave it out to keep the current one (28800 for a new job) |\n| `service_has_no_ttl` | `ttl_seconds` was given on a service rather than a job. Drop it; a service runs until it is replaced, only a job's finished runs expire |\n| `invalid_kind` | `kind` is absent for a service or `job` for a job; nothing else exists |\n| `job_has_no_port` / `job_has_no_volume` | drop the field: a job listens on nothing and keeps nothing. Durable data goes in a resource it reaches |\n| `not_a_job` | that name is a service; a job needs a name of its own |\n| `invalid_schedule` | five cron fields like `\"0 3 * * *\"`, or `@daily` and the like. Not `@every`, no `CRON_TZ=` — the zone is `--tz`. An empty one is refused too: a schedule cannot be removed, so destroy the job to stop it |\n| `invalid_time_zone` | an IANA name like `Europe/Berlin` or `UTC` — or a `--tz` given to a job with no schedule |\n| `service_has_no_schedule` | `--schedule`/`--tz` reached a service. A schedule is a job's: `gg run` |\n| `job_running` | a one-shot job was given a schedule while its run is going. Wait for it to end (`gg status`), or destroy the job |\n| `invalid_volume` | an absolute path inside the container, e.g. `/var/lib/postgresql/data` |\n| `volume_immutable` | a volume is set once and never moves or resizes. Keep it, or destroy the service and deploy again — which throws the data away |\n| `invalid_size` | sizes are `s`, `m`, `l`; the message names the account's cap |\n| `no_such_revision` | `gg history` lists the ones it had |\n| `nothing_to_roll_back_to` | deployed only once. Not a bad call, just nothing to do |\n| `not_a_service` | that name is a resource or a job — you tried to deploy a service over it, give it an address, or roll back a managed resource whose credentials Gagarin mints, s3 included (an external can be rolled back) |\n| `not_a_resource` | that name is a service. `gg status` shows which is which |\n\n**The graph**\n\n| code | what to do |\n|---|---|\n| `invalid_needs` / `invalid_deps` | a blank name, a service naming itself, or a job named as something to reach — a job listens on nothing. Correct them; `gg deps ls` shows what is declared |\n| `no_such_service` | a name in `gg deps add` or `--deps` is neither a service nor a resource here. `gg status` lists them; create it first |\n| `service_in_use` | something still declares it needs this. The refusal names what; `gg deps rm` that edge first — which needs its own approval, though the same click covers the destroy that follows |\n\n**Resources**\n\n| code | what to do |\n|---|---|\n| `no_such_resource` | `gg status <project>` lists what it has |\n| `unknown_resource_type` | `postgres`, `qdrant`, `valkey`, `iggy`, `rabbitmq`, `s3` or `external` |\n| `wrong_resource_type` | another type already holds that name. Destroy it — which throws its data away — or pick another name |\n| `invalid_storage` | 1 to 100 GB |\n| `no_extensions` | only a `postgres` takes extensions: drop `--ext` |\n| `unknown_extension` | not in the catalogue; the hint lists every name offered. `pgvector` is called `vector`. timescaledb is not offered |\n| `extensions_failed` | HTTP 409: postgres refused — usually dropping an extension a column still uses, or one whose own tables still hold the user's rows (pg_cron's jobs, say). The message is postgres's own reason. **Nothing changed**; remove what is in the way, then restate the set |\n| `no_storage` | this type has no volume (valkey, s3): drop `--storage` |\n| `no_size` | an external or an s3 runs nothing: drop `--size` |\n| `invalid_env` | write `API_KEY`, not `OPENAI_API_KEY` — the prefix is the resource's name |\n| `already_exists` | restating an external. `gg resource rotate` is how values change |\n| `env_required` | an external's values are the user's; pass `--set K=V` for one of them, `--env-file` for all |\n| `conflicting_env` | `--env`/`--env-file` replace the bundle and `--set`/`--unset` amend it: use one or the other |\n| `no_such_key` | that external does not publish the key named in `--unset`. `gg resource secrets` lists what it does — and the name goes in without the resource's prefix |\n| `no_env` | this type mints its own credentials (s3 included), so there is nothing to pass or amend; `gg resource secrets` reads them |\n| `object_storage_unavailable` | HTTP 501: this Gagarin has no object storage configured, so no `s3`. Report it to the user |\n| `not_a_bucket` | HTTP 409: only an `s3` can be made public. A service gets an address with `gg domain add` |\n| `publish_failed` | HTTP 502: **nothing changed** — retry `gg resource public` or `private` |\n| `rotate_failed` | **nothing changed** — the old credential still works. Check `gg status` for a resource that is not running, then retry |\n| `cannot_rotate` | no credentials recorded to replace; worth reporting as a bug |\n| `not_tunnelable` | an external runs nothing, so there is nothing to tunnel to; its values are `gg resource secrets` |\n| `tunnel_unavailable` | no running pod on the far end. `gg status` says why, then run `gg connect` again |\n\n**Backups**\n\n| code | what to do |\n|---|---|\n| `backup_unsupported` | only postgres, qdrant and iggy have backups; an s3 bucket is on durable storage but never copied, and a rabbitmq is not backed up at all (declare its queues from application code so a fresh broker can be rebuilt). If losing the data would matter, keep a copy elsewhere |\n| `backup_unconfigured` | this Gagarin runs without a backup bucket. Report it to the user |\n| `restore_name_taken` | a restore creates the resource it fills. Give it a name nothing has yet |\n| `backup_mismatch` | that key belongs to another project. Never restore across projects |\n| `backup_type_mismatch` | that key was written by no type that has backups — check it against `gg resource backups` |\n| `no_backups` | the nightly pass takes the first one; `gg resource backup` takes one now |\n| `backup_list_failed` / `backup_failed` | the resource must be running — check `gg status`, then retry once |\n\n**Addresses**\n\n| code | what to do |\n|---|---|\n| `invalid_domain` | a hostname the user owns: no scheme, no port, no path |\n| `domain_taken` | another service holds that name. The refusal does not say who |\n| `domain_attached` | release the custom names first, or their DNS points at a host that no longer answers |\n\n**The platform itself**\n\n| code | what to do |\n|---|---|\n| `apply_failed` | desired state saved, cluster update failed. Retry the same command; it is idempotent |\n| `cluster_error` / `internal_error` / `eject_failed` | not your call's fault. Report it to the user |\n| `logs_unavailable` | no running pod yet. Check `gg status` first |\n| `timeout` | retry once; if it persists, tell the user |\n| `rate_limited` | wait a minute. Never retry in a tight loop |\n| `body_too_large` | large values belong in a resource, not in a deploy call |\n| `no_such_route` | you are calling the API directly and got the path wrong. Use `gg`, the only supported client |\n\n## Destroying things\n\n```\ngg destroy shop        the project, and everything in it\ngg destroy shop/web    one service\ngg destroy shop/db     one resource, and its data\n```\n\nYou do not say which of the last two a name is; gg asks the platform, which\nalready knows.\n\n**This will be refused the first time, and that is not a bug.** Your credential\ncan deploy but not delete, so destroying anything — and the other irreversible\nacts, `gg domain rm` and `gg deps rm` — needs a human every time the approval\nwindow has lapsed. You get `approval_required`, and Gagarin emails the\naccount owner. Then:\n\n1. Tell the user what you are about to delete, and that you have asked them to\n   approve it by email — the button asks them to sign in to Gagarin first if\n   they are not. Pass on the code from the `fix_hint`.\n2. Wait for them to say they clicked it. Do not poll in a loop.\n3. Run the same command again.\n\n**Ask the user before *requesting* the approval**, not just before retrying — an\napproval email for a deletion they never asked for is alarming. Only a project's\nowner can destroy the project; an editor gets `owner_only`, and no amount of\napproval changes that, because the answer is \"ask the person paying for it\".\n\nIf a deploy went wrong, prefer fixing it with another `gg ship`. Destroying and\nrecreating a project loses its data and its URL.\n\n## Leaving\n\n```\ngg eject shop -o project.yaml\n```\n\nWrites the Kubernetes manifests for the whole project — namespace, and per\nservice its Deployment, Service, Ingress, NetworkPolicy, environment Secret and\nvolume claim. These are not a description of what Gagarin runs; they are the\nobjects it runs, so `kubectl apply -f` on any cluster with an ingress controller\nreproduces the project.\n\nOwner only, because the file holds every service's environment in the clear. It\nis written mode 0600 and you should treat it as a credential.\n\nThree things it deliberately does not contain, all explained in its own header:\nthe **images**, which are still in Gagarin's registry and have to be pulled and\npushed somewhere the user controls; the **registry pull secret**, which is a\nlive credential; and the values from any **external resource**, which are\nthird-party keys somebody else issued, and an **s3 bucket's** keys, which like an\nexternal's work from anywhere — they come out as a `REPLACE-ME` placeholder\nnaming the resource, and the header lists exactly which variables to fill in. Volume\nclaims come back empty — data has to be taken out of the running service.\n\nA minted credential — a database password — *is* in the file, and the asymmetry\nis the point: that password is only a risk against a database in the same file,\nand an export without it does not come up. A third-party key stays live wherever\nthe file ends up. `gg eject shop --with-secrets -o project.yaml` includes them,\nfor a migration happening now into a file that gets deleted; say what that means\nbefore running it with the flag.\n\nOffer this without being defensive when somebody asks what happens if Gagarin\ngoes away. It is a real answer and it is meant to be used.\n\n## Things Gagarin deliberately does not do\n\nNot missing features. Do not attempt them and do not suggest workarounds:\n\n- deploy from a git repository or a git URL\n- read deployment configuration from a file in the repo — `--env-file` supplies\n  values, and is the only file Gagarin will ever read\n- interpolate variables into each other\n- pull images from Docker Hub, GHCR or any registry other than Gagarin's at run\n  time (`gg registry copy` brings one in first)\n- expose Kubernetes, cloud provider or networking primitives\n- open the mail ports\n- infer a project from the current directory, or from anything else —\n  `.gagarin.json` included: you read that, Gagarin never does\n"
AFTER
"---\nname: gagarin\ndescription: Deploy and operate applications on Gagarin with the gg CLI — ship a service from a Dockerfile, provision postgres, qdrant, valkey, iggy, rabbitmq, s3 or external-credential resources, wire what may reach what, put a service on the internet, give CI its own credential, start jobs from an application's own code with the Go, Node or Python SDK, read status and logs, roll back, tear things down, and keep what a session learned in the project's memory. Use whenever the user asks to deploy, host, run or operate an application, or mentions Gagarin or gg. Gagarin runs container images on managed infrastructure; the user never needs to know about Kubernetes, ingress, TLS, or the underlying cloud.\n---\n\n# Deploying with Gagarin\n\nGagarin runs your services. You drive it with the `gg` CLI, a thin wrapper over\nthe Gagarin API. There is exactly one way to change anything: call the API.\nThere is no manifest file and no config file. The one file you will commit is\na note of which project the repository is, and it changes nothing — see \"Which\nproject this repository is\".\n\nEverything below is the whole product. Read \"The ten rules\" and the command map\nfirst; they are the parts that stop you getting it wrong.\n\n## The ten rules\n\n1. **Everything is named for its project.** `shop` is a project; `shop/web` is a\n   service or a resource inside it. Nothing is inferred from the directory you\n   stand in. There is no default project to configure — a command that does not\n   name one is refused with the shape it should have had.\n2. **Every write is asynchronous, except `gg run`.** A command that exits zero\n   recorded a demand; it did not watch it come true. `gg status <project>` reads\n   the cluster and is the only thing that can answer \"is it up\". The one\n   exception is `gg run`, and it is an exception because a run *ends*: it waits,\n   prints what the run wrote, and exits with the script's own code. Nothing else\n   here has an end to wait for.\n3. **Gagarin runs images from its own registry only.** `gg ship` is build, push\n   and deploy fused; the three exist separately for CI. Somebody else's image\n   comes in with `gg registry copy`.\n4. **A service is private until `gg domain add`**, and a deploy can neither give\n   an address nor take one away.\n5. **A private service is default-denied.** Until the *caller* declares\n   `gg deps add`, its calls are dropped — which hangs, rather than failing fast.\n6. **`gg deps add <service> <resource>` opens the route *and* hands over the\n   credentials.** Connecting a database is that one call, not a call plus a\n   deploy.\n7. **A deploy replaces the environment and nothing else.** Dependencies, the\n   domain, the volume, the size and the replica count all survive a deploy that\n   forgets to mention them. Env is the one thing you must restate every time.\n   **A credential never goes in a deploy env.** Env is for plain, single-service\n   config: a port, a log level, a sibling's URL. A database password arrives\n   with `gg deps add`; a third-party key is an `external` resource. See \"What\n   does not go in env\" below.\n   **And no secret value ever passes through your output** — not the\n   terminal, not this chat, not a summary or a commit. A command that takes one\n   reads it from a file (`--env-file`, `--input NAME=FILE`, `\"$(cat FILE)\"`),\n   never `K=value` typed on a command line; a command that produces one writes\n   it to a file or pipes it into the store it is for (`> .env.db`,\n   `| gh secret set`). Reach for `--names` before values. Never ask your human\n   to paste a secret into the chat.\n8. **If a resource type exists, use it** (`postgres`, `qdrant`, `valkey`,\n   `iggy`, `rabbitmq`, `s3`, `external`). If one does not, an ordinary service with a volume is the normal\n   path, not a workaround.\n9. **You can deploy; you cannot destroy.** Deleting anything, taking an address\n   away, withdrawing a dependency with `gg deps rm`, and handing a project over\n   with `gg transfer` all answer `approval_required` and email the account owner\n   a button, every time the approval window has lapsed, which approves only once\n   they are signed in. No flag grants this to an agent. Adding is always free: `gg deps add` and `gg domain add` need nobody.\n10. **Errors are meant to be branched on.** gg prints `[code] message` and\n    usually a `hint:` line. Act on the code, never on the prose.\n\n## Command map\n\n| | |\n|---|---|\n| `gg whoami` | which account this machine acts as — **run this first, always** |\n| `gg login` / `gg login --new` | get this machine access — relay the link and code, then run it again once approved |\n| `gg login --ref CODE` | the same, for a human a friend invited: the code (8 letters and digits) is added to the link so the new account is matched to the friend |\n| `gg creds` / `creds create --name N` / `creds revoke ID` | what has access; mint one for CI; take one away |\n| `gg registry login` | log docker in (CI, or docker installed after gg) |\n| `gg projects` | every project you can reach, and your role on it |\n| `gg init PROJECT` | create a project |\n| `gg ship P/SVC:PORT` | build the current directory, push it, run it — tagged with the commit when the tree is clean |\n| `gg build P/IMAGE[:TAG]` / `gg push P/IMAGE:TAG` / `gg deploy P/SVC:PORT IMAGE:TAG` | the same three steps apart, which is what CI wants |\n| `gg run P/JOB IMAGE:TAG` | run an image to completion as a job, wait, print what it wrote, exit with its code |\n| `gg run P/JOB IMAGE:TAG --schedule \"0 3 * * *\"` | run it on a schedule instead of now; returns at once |\n| the SDK (Go, Node, Python) | start runs from an application's own code — see \"From code: the SDK\" |\n| `gg registry copy P/IMAGE SOURCE` | bring an image you did not build into the project |\n| `gg resource add P/NAME TYPE` | provision postgres, qdrant, valkey, iggy, rabbitmq, s3 or external |\n| `gg resource add P/db postgres --ext vector --ext postgis` | the postgres extensions it should have, one `--ext` each — the whole set, every time you pass it |\n| `gg resource public P/NAME` | make an `s3` bucket listable and readable by anyone; `gg resource private P/NAME` undoes it |\n| `gg resource secrets P/NAME > .env.NAME` | its connection values, into a file for something outside the project — never printed |\n| `gg resource secrets P/NAME --names` | just the variable names it publishes, no values |\n| `gg resource rotate P/NAME` | new credentials, and everything holding them rolls |\n| `gg resource rotate P/NAME --set K=\"$(cat FILE)\"` | change one value an external publishes, keeping the rest; the value comes from a file |\n| `gg rollback P/NAME` | put a previous revision back — a service's deploy, or an external's values |\n| `gg connect P/NAME` | that resource on this machine, for as long as the command runs |\n| `gg resource backup` / `backups` / `restore P/NEW --source OLD` | postgres, qdrant and iggy recovery |\n| `gg deps add P/SVC NAME...` / `deps ls` / `deps rm` | what a service may reach, and whose credentials it holds (`rm` needs a human) |\n| `gg domain add P/SVC [DOMAIN]` / `domain ls P` / `domain rm` | addresses on the internet |\n| `gg status PROJECT` | desired vs actual, addresses, sizes, today's cost |\n| `gg metrics P[/SVC] [--window 1h\\|24h\\|7d\\|30d]` | usage from real numbers: every service now, or one service's last value (and when), average, peak and limit over a window. See Metrics |\n| `gg logs P/SVC` | recent logs |\n| `gg history P/SVC` / `gg rollback P/SVC [--to N]` | every deploy; put one back |\n| alerts (no gg command) | push-notify a member's own devices when a service goes down, runs short of memory, CPU or disk, or answers with 5xx; the human turns it on with the switch at my.gagarin.cloud/projects/P/alerts, which also sends a test. See Alerts |\n| `gg referral` | the account's invite link and code (once it has topped up), and who signed up through it and what it earned; in MCP, `referrals` |\n| `gg members P` / `gg share P EMAIL [--role viewer]` / `gg unshare P EMAIL` | who can reach it |\n| `gg transfer P EMAIL` | offer the project, and its bill, to a member (they accept by email) |\n| `gg destroy P` or `P/NAME` | delete a project, a service or a resource (needs a human) |\n| `gg eject P -o file.yaml` | the Kubernetes manifests, so you can leave (external and s3 keys are placeholders; `--with-secrets` includes them) |\n| `gg recipe snap P [--dry-run]` | publish a project as a recipe, owner only; `--version`, `--as`, `--source`, `--notes`. Dry run first |\n| `gg recipe show RECIPE[@VERSION]` / `recipe ls` | read a recipe (`--format json` for the manifest); the ones this account published |\n| `gg recipe install RECIPE[@VERSION] NEW_PROJECT --input NAME=FILE` | deploy a recipe into a new project, one env file per declared input |\n| `gg recipe diff P` / `recipe update P [--to V] [--force]` | what a newer version changes; apply it (removals need a human) |\n| `gg recipe rm RECIPE[@VERSION]` | delete a recipe or one version (needs a human) |\n| `gg version` | which gg this is |\n\nThree environment variables override the credential file, and exist for CI:\n`GAGARIN_TOKEN` (a credential), `GAGARIN_API` (control plane URL), and\n`GAGARIN_REGISTRY` (registry host). There is nothing else to export.\n\n## First moves in any session\n\nRun `gg whoami` before anything else. It answers three different questions at\nonce, and each has a different next step:\n\n| what happens | what it means | do this |\n|---|---|---|\n| the shell cannot find `gg` | not installed | see \"Installing gg\" — unless you already hold Gagarin MCP tools, in which case call `whoami` there and read \"If you cannot install gg\" for what they cannot do |\n| `[unauthorized]`, or it says there are no credentials | installed, no access | see \"Getting access\" |\n| it names an account | ready | carry on; `gg projects` says what already exists |\n\nThen read `.gagarin.json` at the repository root, if there is one — it says\nwhich project this repository already is — and `gg projects` before assuming a\nproject exists or that you may write to it. A `viewer` role means every deploy\nwill be refused, and that is worth knowing before the attempt rather than\nafter. Project names are unique only within one account, so two rows can share\na name — the id column tells them apart.\n\nOnce per session, before the first build or CI change, check the rest of the\ntoolchain — docker running, git, and `gh` or `glab` signed in — as \"What else\nthe machine should have\" describes. Only a stopped docker blocks a ship.\n\n## Which project this repository is: `.gagarin.json`\n\nGagarin infers nothing from the directory you stand in, and gg stopped guessing\nthe project from the directory's name on purpose: that made a command whose\ntarget was invisible in the command. So the repository carries a note instead,\nat its root, and you are the one who writes it:\n\n```json\n{ \"project\": { \"id\": \"3cnciet6\", \"name\": \"shop\" } }\n```\n\nWrite it once you have created the project or settled on an existing one.\nFive rules, each for a reason:\n\n- **It is a note for the next session, not configuration.** Nothing reads it —\n  not gg, not the MCP server, not the platform. You read it, and then you still\n  name the project in every command and every tool call, so the target stays\n  visible in the command.\n- **Identity only, never desired state.** The one other key is `\"tour\"`, the\n  onboarding steps the human has already been shown (see \"After the first\n  address\"). No services, ports, env or domains:\n  Gagarin holds those, and a copy in the repository would be the stale one. If\n  the file disagrees with `gg projects`, the API is right — fix the file and\n  tell the user.\n- **Prefer the id in calls.** Names are unique only within an account, so a\n  project shared with the user can carry the same name as one of their own;\n  the id cannot collide. Everything that takes a project name takes its id.\n- **Commit it.** The id is already public in every hostname and image path,\n  and a teammate's agent needs it as much as your next session does.\n- **Read it first**, before `gg projects` and before asking. If it is absent\n  and the user named no project, `gg projects` before `gg init` — the project\n  may already exist.\n\nWhere the id comes from: `gg init shop` prints `project shop created (id\n3cnciet6), runs in fr-par-1`; `gg projects` prints a row per project — name, id,\ncluster, role; and the first line of `gg status shop` reads\n`project shop  (id 3cnciet6)  fr-par-1`, ending with the cluster. None of them has a JSON flag; read the column.\n\n**A project has a place.** Each project runs on one cluster, chosen when it is\ncreated and never changed; `gg status` shows it (`fr-par-1`). It is part of the\nproject's generated addresses, `<service>-<project id>.<cluster>.apps.gagarin.cloud`\n(for example `web-3cnciet6.fr-par-1.apps.gagarin.cloud`), so never build one by\nhand from the id alone: read it from `gg status` or `gg domain ls`.\n\n## Project memory\n\nEvery project has a memory: small durable facts about the codebase that the\nnext session would otherwise have to rediscover — an overview, the\narchitecture, a decision and why it went that way, a convention, a gotcha, a\nhowto, a reference, the state of a piece of work. It is reachable only through\nGagarin's MCP server (see \"If you cannot install gg\"); there is no `gg` command\nfor it. Every memory tool takes the project, which is what `.gagarin.json` is\nfor.\n\n| tool | when |\n|---|---|\n| `memory_briefing` | first, when starting work on a project — a primer packed to a token budget |\n| `memory_search` | before exploring the code for something a past session may already have found |\n| `memory_get` / `memory_related` | one memory in full, by id or by key; what it links to |\n| `remember` | one durable fact per memory, in English |\n| `memory_update` | edit, pin, archive, confirm or dispute one |\n| `memory_link` / `memory_unlink` | say that two are related, or that they are not |\n| `memory_review` | housekeeping: likely duplicates, orphans, stale and disputed memories, how close the project is to its cap |\n\n- **Brief yourself before you read the code, and search before you go\n  looking.** That is what it is for. When you know the task, pass `focus` (what\n  you are about to work on) and `paths` (the files you will touch) to\n  `memory_briefing`, and the relevant memories come first.\n- **Give a fact that changes a `key`.** What is deployed now, the current\n  schema version: `remember` it as a `state` memory with a key such as\n  `deploy/current`, and the next `remember` with the same key replaces it and\n  keeps its links. Do not search for the old one and supersede it by hand.\n- **Say when a memory is right or wrong.** One you checked against the code or\n  the cluster gets `confirm: true`, which resets its age. One that proves wrong\n  gets `dispute: true` — it is marked ⚠ and ranks lower until someone confirms,\n  edits or archives it — or a fix, or an archive; do not leave it to mislead the\n  next session. A briefing that counts disputed memories, or a `remember` that\n  warns the project is near its cap, is the cue to call `memory_review` and tidy.\n- **Remember what a future session could not cheaply rediscover**: why a\n  decision went the way it did, a gotcha that cost time, where the deploy\n  differs from the obvious — which port, which Dockerfile quirk, which\n  variables the application insists on. Not what the repository already says,\n  not what is true only of this conversation, and **never a credential or a\n  secret** — not as a value, not in a tag. Title, body and source are\n  encrypted at rest with a key Gagarin holds; tags, file paths and kind are\n  not.\n- **A `remember` refused with a list of near-duplicates** is telling you the\n  fact is already there. Update or link those; do not reword it to get past\n  the check.\n- Reading needs `viewer` on the project; writing needs `editor`. Memories in\n  use are billed at $0.10 per 1,000 a month — a few cents for most projects —\n  and capped per project. Reading is free, and archiving a memory that is no\n  longer true stops it being counted, so archive rather than leave it stale.\n- **If the MCP server is not connected in this session, memory is simply\n  unavailable.** Carry on with `gg`; it is not an error, and nothing else\n  waits on it.\n\n## Installing gg\n\nIf your client is already connected to Gagarin's MCP server you may not need\n`gg` at all — read \"If you cannot install gg\" below first, because the one thing\nit cannot do is build an image, and that is often the whole task.\n\nUse a package manager the machine already has. You may run these yourself:\n\n- macOS: `brew install --cask gagarin-cloud/tap/gg`. It is a **cask**, not a\n  formula, and casks do not work on Linux. If `brew install\n  gagarin-cloud/tap/gg` (no `--cask`) put an older `gg` there, homebrew will not\n  replace one kind with the other on its own: run `brew uninstall gg` once,\n  then install the cask.\n- Windows: `scoop bucket add gagarin https://github.com/gagarin-cloud/scoop-bucket`\n  then `scoop install gagarin/gg`.\n- Any platform with a Go toolchain: `go install github.com/gagarin-cloud/gg@latest`\n\nIf `go install` succeeds but the shell still cannot find `gg`, its bin directory\n(`go env GOPATH`/bin) is not on `PATH`. Say so and let the user fix their\nprofile; do not edit their shell configuration yourself.\n\nWith none of those, the install is the human's to run, not yours: **never\ndownload a script or a binary and run it.** Point them at the one-line installer\non https://gagarin.cloud (a shell one-liner on macOS and Linux, a PowerShell one\non Windows) and say what it does: it verifies the download against the release's\n`checksums.txt`, installs to `~/.local/bin` (Windows: `%LOCALAPPDATA%\\Programs\\gg`,\nadded to their `PATH`) without `sudo`, and never edits a shell profile. On Linux a\n`.deb`, `.rpm` or `.apk` from https://github.com/gagarin-cloud/gg/releases works\ntoo; installing one needs `sudo`, so that is theirs to run as well.\n\nIf `~/.local/bin` is not on `PATH`, the installer prints the `export` line to add.\nCall `gg` by its full path (`~/.local/bin/gg`) for the rest of your session and\ntell your human the line; do not edit their profile yourself.\n\nDo not download from a host you guessed, and do not carry on without `gg`.\n\n`gg` shells out to **docker** for `build`, `push` and `registry copy` (the last\nneeds `buildx`). Nothing else needs it. A machine with no docker can still\ndeploy an image that is already in the registry, roll back, and read state.\n\n**Run `docker info` before the first `gg ship`.** If it fails, ask your human to\nstart Docker Desktop, OrbStack or colima (or install one) and wait until\n`docker info` succeeds; do not start or install it yourself. gg v0.51.0 and\nlater check this before any request and refuse with `docker_not_installed`,\n`docker_not_running` or `docker_permission_denied`, each with the fix in its\nhint. Relay the hint; do not retry until the human says docker is up, and do not\nrun gg with `sudo` to get round a permission error.\n\nThis skill is not part of the binary. It lives in `gagarin-cloud/plugin` and\nis installed separately — in Claude Code, Codex and ChatGPT as a plugin,\nelsewhere with `npx skills add gagarin-cloud/plugin -g`. So it can\nbe newer than the `gg` you are holding: **if a command here is refused as\nunknown, check `gg version` and upgrade before concluding the command does not\nexist.** `gg version` also prints, on stderr, \"gg vX is available (you have vY)\"\nwhen you are behind (`GAGARIN_NO_UPDATE_CHECK=1` silences it). Upgrade with\n`gg upgrade`, which upgrades the way `gg` was installed: brew, scoop and\n`go install` are handed to that tool, script and archive installs replace\nthemselves after checking the checksum, and `.deb`/`.rpm`/`.apk` installs print a\n`sudo` command for your human. `gg upgrade --dry-run` previews it. `gg upgrade`\nitself needs v0.54.0; on an older `gg` it does not exist, so use the per-manager\ncommand (`brew upgrade --cask gagarin-cloud/tap/gg`, `scoop update gg`,\n`go install ...@latest`) or, for an installer or\narchive install, have your human run the installer again as \"Installing gg\"\nsays. Everything else documented here is present in gg\nv0.42.0 and later.\n\n## What else the machine should have\n\n`gg` itself shells out to one thing, docker. The rest of this skill leans on a\nfew more tools without checking for them, so check once, early, rather than\nmeeting each one as a failure halfway through a deploy:\n\n| tool | needed for | without it |\n|---|---|---|\n| `gg` | everything | see \"Installing gg\" |\n| `docker`, running | `gg ship`, `gg build`, `gg push` | deploy an image already in the registry; read state; roll back |\n| `docker buildx` | `gg registry copy` | bring the image in from a machine that has it |\n| `git` | committing `.gagarin.json`; `gg build` and `gg ship` tagging the image with the commit; knowing which forge the repository lives on | it all still deploys, but nothing ties an image to the source it came from, and the next session has no note of the project |\n| `gh` (GitHub) or `glab` (GitLab), signed in | putting a CI credential in the secret store without it touching disk or the transcript; watching the pipeline you wrote run | the human sets the secret in the web UI themselves, and you cannot see whether the first run went green |\n| `jq` | pulling one value out of `--format json` | read the JSON yourself; nothing in gg requires it |\n\nOnly the forge CLI that matches the repository matters: `git remote get-url\norigin` says whether it is GitHub or GitLab. Check what is there, and whether\nthe forge CLI is signed in, with:\n\n```\ncommand -v git docker gh glab jq\ndocker info >/dev/null 2>&1 && echo \"docker is up\"\ngit rev-parse --is-inside-work-tree && git remote get-url origin\ngh auth status        # or: glab auth status\n```\n\nWhat to do about a missing one:\n\n- **Do not install docker, git or a forge CLI yourself, and do not sign in for\n  your human.** Say which is missing, what it costs them, and the install\n  command for their platform (`brew install gh`, `winget install GitHub.cli`,\n  `sudo apt install gh`; `glab` the same way). `gh auth login` and `glab auth\n  login` are theirs to run, like `gg login`.\n- **Only docker blocks a ship.** Everything else degrades: say what is lost and\n  carry on with the task.\n- **Not a git repository** is not a failure either. Deploy it; then mention that\n  `.gagarin.json` only helps the next session if it is committed somewhere.\n\n## If you cannot install gg: the MCP server\n\nGagarin also answers MCP at `https://mcp.gagarin.cloud/mcp`. An MCP client —\nClaude Code, Claude Desktop, Cursor, Codex, ChatGPT — connects to that URL and\ninstalls nothing: your human signs in with GitHub or Google when the client\nasks for it, and no secret passes through you. It is this same API in another\nshape, so everything above still holds — the naming, the asynchrony, the\ndefault-denied graph, the human's approval before anything is destroyed.\n\n**It is a smaller surface than `gg`, and the gap is images.** Over MCP you can\ndeploy an image that is already in the registry, run a job, read status and\nlogs, declare dependencies, add an address, roll back, and manage resources,\npeople, credentials and the bill. Four things are deliberately absent:\n\n- **No build and no push.** `gg ship`, `gg build`, `gg push` and\n  `gg registry copy` shell out to docker where the source is, and a server on\n  the internet has neither your source tree nor your docker.\n- **No tunnel.** `gg connect` binds a port on *this* machine; there is no local\n  anything at the other end of an MCP call.\n- **No waiting for a job.** `run` answers the revision naming the run and\n  returns, as every other write does. `status` is the only place an exit code\n  appears.\n- **No list of resource types, sizes or scopes.** The engine owns those and its\n  refusals name them; a second copy here would be wrong the day one is added.\n\nSo: **if `gg` is installed, use it.** It does everything the MCP server does and\nthe four things it cannot. Reach for MCP when you cannot install a binary, or\nwhen the work is purely operational — reading state, rolling back, wiring deps,\nmanaging addresses. If a task needs an image built and you hold only MCP tools,\nsay so and install `gg` rather than reporting a deploy you were unable to make.\n\nThere is a third way into the same API, and it is for neither you nor a\nperson: **application code uses the SDK** (Go, Node, Python) — see \"From code:\nthe SDK\".\n\n## Getting access\n\n`gg login` is one command whether this is the first machine on a new account or\nthe fifth on an old one. There is no separate signup and no address to ask for:\nthe human signs in with GitHub or Google, and a new account starts with $5 on it\nand no card asked for.\n\n1. **`gg login`** prints a link and a code, remembers the request, and exits.\n2. **Give the user the link and the code as printed.** The link is the one to\n   open; the plain address and the code under it are the fallback for when the\n   link does not open. Say what they will do there: sign in with GitHub or\n   Google, check that the page shows the same code and this machine's name, and\n   approve. Then wait for them to tell you they have.\n3. **`gg login` again.** It collects the request the first run made — it does\n   not ask for a new one — stores the credential in\n   `~/.config/gagarin/credentials.json`, logs `docker` in to the registry, and\n   says which account this machine now acts as. Confirm with `gg whoami`.\n\nIf the second run fails:\n\n- `[authorization_pending]` — it waited a minute and nobody had approved yet.\n  It prints the link and code again: pass them on again if the user seems not to\n  have them, and once they say they approved, run `gg login` again. Do not run\n  it in a loop.\n- `[expired_token]` — nobody approved within fifteen minutes, and the request is\n  gone. Run `gg login` for a fresh link and pass it on straight away.\n- `[access_denied]` — the user declined on the page, and the request is gone.\n  Ask them why before running it again, and do not retry on your own.\n- `[github_account_too_new]` — the user signed in with a GitHub account under\n  30 days old, which Gagarin does not accept yet. The request is kept: tell them\n  to open the same link and choose **Continue with Google**, then run `gg login`\n  again once they say they approved.\n\n`gg login --new` throws away a request nobody approved and asks for a new code —\nfor when the user lost the link, or it was meant for a different account.\n\nDo not open the link yourself, and do not approve it on the user's behalf in a\nbrowser you control: the approval is theirs, and it is the only thing standing\nbetween an agent and an account. The account is whichever one they sign in to;\nif they use more than one, let them pick.\n\nThe moment an account is created it gets its balance and the address the\nprovider verified joins Gagarin's customer list; https://gagarin.cloud/privacy\nsays what that list is for.\n\nYou never handle the credential yourself. Do not read that file, do not echo it,\nand never ask the user for a token — if you find yourself wanting a secret to\nmake `gg` work, you are doing this wrong. The exceptions are CI and an\napplication that starts jobs, and each gets its own — \"Setting up CI\" below, and\n\"From code: the SDK\".\n\nIf `docker` was installed after Gagarin, `gg registry login` does that half on\nits own.\n\n## Setting up CI\n\n**Never run `gg login` in CI, and never copy this machine's credential into\nit.** A pipeline gets one of its own, minted from the one you already hold.\n\n### 1. Mint the credential\n\n`gg creds create --name \"github actions: acme/web\"` prints the secret to\n**stdout alone on its line**, and everything else to stderr. Never run it on\nits own, which would put the secret in your output: pipe it straight into the\nsecret store, so nothing touches disk or the transcript:\n\n```\ngh secret set GAGARIN_TOKEN --body \"$(gg creds create --name \"github actions: acme/web\" 2>/dev/null)\"\n```\n\nOn GitLab, the same with `glab`:\n\n```\nglab variable set GAGARIN_TOKEN --masked --value \"$(gg creds create --name \"gitlab ci: acme/web\" 2>/dev/null)\"\n```\n\n**Without `gh` or `glab` signed in, do not mint it yourself** — there is no way\nfrom here to a secret store that does not pass through your output. Ask your\nhuman to run `gg creds create --name \"…\"` in their own terminal and paste it\ninto the repository's CI settings, or to install and sign in to the forge CLI\nfirst.\n\nName it after where it will live. `gg creds` is a list somebody reads months\nlater deciding what is still wanted, and \"token\" tells them nothing then.\n\nWhat you just minted is **deliberately weaker than what you hold**:\n\n- It can deploy. **It cannot destroy** — a pipeline holding it cannot delete a\n  project, a service or a database, and no flag turns that on.\n- It **expires**: 90 days by default, 365 maximum, and there is no never.\n- It **cannot mint another**, so a leaked one cannot issue its own replacements\n  while you are busy revoking it.\n- It is **shown once**. Gagarin keeps a hash. Lose it and you revoke it and mint\n  another; no command reads one back.\n\n### 2. Give it to the pipeline\n\nCI reads `GAGARIN_TOKEN` from the environment and needs nothing else: no\n`gg login`, no credentials file, no home directory, no interactive anything.\n\n### 3. The workflow\n\nThe shape that matters: install gg, log docker in, publish on every commit,\nrelease on the ones you mean.\n\n```yaml\nname: deploy\non:\n  push:\n    branches: [main]\n\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n    env:\n      GAGARIN_TOKEN: ${{ secrets.GAGARIN_TOKEN }}\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: install gg\n        run: go install github.com/gagarin-cloud/gg@latest\n\n      - name: log docker in to the gagarin registry\n        run: gg registry login\n\n      - name: build and publish\n        run: gg build acme/web:${{ github.sha }} --push\n\n      - name: release\n        run: gg deploy acme/web:8080 web:${{ github.sha }} --env-file .env.production\n\n      - name: say what the cluster is doing\n        run: gg status acme\n```\n\nSix things about that are load-bearing:\n\n- **`gg registry login` is not optional.** `gg build --push`, `gg push` and\n  `gg registry copy` all shell out to docker, and docker has no idea what a\n  Gagarin credential is until that runs. The failure without it is a `401` out\n  of `docker push`, whose hint says exactly this.\n- **Tag with the commit, explicitly.** `gg build` with no tag uses the short\n  hash when the checkout is clean and the clock when it is not — and a\n  pipeline that generates a file or two before the build is not clean. Pass\n  `${{ github.sha }}` so the tag never depends on that: it is what makes a\n  deploy reproducible and a rollback explicable.\n- **`gg push` requires the tag** where `gg build` does not — a push moves\n  something that already exists, and \"whichever one I built last\" is not a name.\n- **The deploy step is separate on purpose.** Publishing on every commit and\n  releasing on some of them is the whole reason build, push and deploy are three\n  verbs. A workflow that only ever wants all three can run `gg ship` instead.\n- **`.env.production` is committed, so it holds no secrets.** It is config:\n  ports, log levels, sibling URLs. The keys the service needs are `external`\n  resources, created once with `gg resource add` and wired with `gg deps add`;\n  they survive every deploy CI makes, and CI never holds them. If you are about\n  to put a credential in a CI secret so the workflow can pass it with `--env`,\n  make it an external instead.\n- **`gg status` at the end is a report, not a gate.** The deploy returned when\n  the demand was recorded; the pod may still be pulling. Do not write a polling\n  loop in CI — if you want a gate, gate on your own health check against the\n  service's address.\n\nEverything else works identically in any CI: the token in the environment, `gg`\non the PATH, docker available if you build. GitLab, Buildkite and Cloud Build\nneed no special handling.\n\n**Watch the first run** if the forge CLI is there, once your human has pushed —\nthat push is theirs to make. Give `gh` the run's id, because without one it\nasks which run, and you cannot answer a prompt:\n\n```\nid=$(gh run list --workflow deploy.yml --limit 1 --json databaseId -q '.[0].databaseId')\ngh run watch \"$id\" --exit-status\ngh run view \"$id\" --log-failed        # only if it failed\n```\n\nOn GitLab, `glab ci status --live` follows the pipeline for the current branch\nand `glab ci trace <job>` prints a job's log. Then `gg status` for what the\ndeploy step actually did.\n\n### 4. Afterwards\n\n```\ngg creds              what has access, which are minted, when each expires\ngg creds revoke 7     immediately, and needing no approval\n```\n\nRevoking needs no human because taking access away is always safe — a machine\nyou no longer trust should not wait on an inbox. Rotate a CI credential by\nminting the new one, updating the secret, then revoking the old id.\n\nIf you are tempted to set `XDG_CONFIG_HOME` to a scratch directory and run\n`gg login` again for a second credential: that used to be the only way and it\nis not any more.\n\n## Recipe: an application from nothing\n\nThe end-to-end, in the order that avoids every window where something is broken.\n\n```\ngg init shop                                  once, per application\n\ngg resource add shop/db postgres --size m     the database, before the thing that needs it\ngg ship shop/api:8080 --deps db               builds ., pushes, runs it, and it\n                                              starts already holding DB_URL\ngg ship shop/web:3000 --env API=http://api:8080\ngg deps add shop/web api                      web may now call api\ngg domain add shop/web                        the one thing the browser opens\ngg status shop                                and only now tell the user a URL\n```\n\nNotes on each step, in the order they bite:\n\n- **After `gg init`, write `.gagarin.json`** with the id it printed, and commit\n  it — see \"Which project this repository is\". Skip `gg init` when the note or\n  `gg projects` says the project already exists.\n- **A Dockerfile per service.** Gagarin deploys images, so a service without one\n  cannot be deployed. Writing it is a normal part of this job. Do not set a\n  platform or architecture: Gagarin reports what its own nodes run, and gg builds\n  for that.\n- **Run `gg ship` from the directory holding that service's Dockerfile**, or\n  point `--context` at it — `gg ship shop/api:8080 --context ./api` from a\n  monorepo root. `--file` names the Dockerfile when it is not called that, or\n  lives outside the context directory.\n- **Commit before you ship, if you can.** With no tag given — and `gg ship`\n  never takes one — gg tags the image with the short hash of the commit\n  (`web:3f9c2ab`), so `gg history` says which code each revision ran and a\n  rollback names what it puts back. Only when the work tree is clean: any\n  modified or untracked file in the repository, inside the build context or\n  not, and it falls back to a clock tag (`web:1761830000`) and says so on\n  stderr. Ignored files do not count. No git or no repository is the clock too,\n  silently. Either way the tag is printed; read it from the output rather than\n  predicting it. Do not commit the user's work just to get a hash: ask, or\n  ship with the clock. (gg v0.55.0 and older always use the clock.)\n- **The number after the colon is the port the container listens on.** It\n  defaults to 8080. Say it anyway when you know it: a service answering on the\n  wrong port is a hang, not an error.\n- **`--deps db` on the first ship** means the pod never starts into a window\n  where it cannot reach the database and does not hold its password. On later\n  ships it is optional and harmless.\n- **Private services talk over `http://<service-name>:<port>`** — the service\n  name, no project prefix, no scheme guessing.\n- **`gg domain add` for the service the user's browser opens, and nothing else.**\n  Do not expose a database, a worker or an internal API \"so it can be tested\".\n  Ask the user before putting anything on the internet they did not ask to.\n- **`gg status` before you promise anything.** `gg ship` says nothing about where\n  a service answers, deliberately — an address exists as a string long before\n  anything is listening on it.\n\n### When to use the three steps instead\n\n```\ngg build  shop/web:v3 --context ./web    make an image, run nothing\ngg build  shop/web:v3 --push             ...and upload it in the same call\ngg push   shop/web:v3                    publish it, release nothing\ngg deploy shop/web:8080 web:v3           release one that already exists\n```\n\nThat is CI, and it is also the only way to run an image you did not just build —\none copied in with `gg registry copy`, or a tag somebody else pushed.\n\n## After the first address: show them around\n\nA first deploy that answers is where most people stop, and the three things that\nkeep a project healthy are one step past it. So once `gg status` shows the first\nservice answering, give the human its URL, and then offer one next step per\nturn, in this order:\n\n1. **The graph.** Point them at `https://my.gagarin.cloud/projects/<id>`: what\n   is running, and what may reach what. Nothing to run, so this one is a\n   sentence and a link.\n2. **Alerts.** Ask whether the human wants a push on their phone when the\n   service goes down, a deploy will not start, a container keeps crashing, or\n   one runs short of memory, CPU or disk.\n   If yes, they open `https://my.gagarin.cloud/projects/<id>/alerts` on that\n   phone and turn on \"Notify me about this project\", which allows notifications\n   and opts them in at once; the same page sends a test. On an iPhone they add\n   the console to the Home Screen first and open it from there. There is no gg\n   command for alerts. With the MCP server connected you may check with\n   `alerts` first, and send `test_alerts` once they say it is on.\n3. **Memory.** `remember` two or three facts this session would otherwise lose:\n   why that port, why that size, what the Dockerfile works around. Then tell\n   the human the project keeps them, and the next session starts from them.\n\nRules, each for a reason:\n\n- **One step per turn, one sentence and one action.** A wall of next steps\n  reads as homework, and the human came for an address.\n- **Stop when they say no or change the subject.** Do not bring a skipped step\n  back later in the same session.\n- **Alerts are the human's switch, not yours.** They reach a person's phone,\n  and only that person's browser can allow them.\n- **Skip what is done, and read \"done\" from state.** With the MCP server,\n  `alerts` says whether alerts are on and how many devices they reach; without\n  it, the human's answer is the state. `memory_briefing` says whether the\n  project already holds memories. What was said earlier in a conversation is\n  not state.\n- **Note what they have seen in `.gagarin.json`.** The graph leaves no trace you\n  can read back, so record each step as it happens: add its name to `\"tour\"`,\n  `{ \"project\": { … }, \"tour\": [\"graph\", \"alerts\", \"memory\"] }`. A step in the\n  list is not offered again, in this session or the next. Commit it with the\n  rest of the note.\n\n## Services\n\nA service is a container image that runs, with a port, a size, an environment,\noptionally a volume, whatever it is allowed to reach, and whatever addresses it\nanswers on. Only the first two of those are set by a deploy. An image that runs\nto completion instead of serving — a migration, a backfill — is a **job**, not a\nservice: see \"Jobs\" below, and do not deploy one as a service, because a\nservice that exits is restarted forever and reads as failing.\n\n### The environment\n\n```\ngg deploy shop/web:8080 web:v3 --env-file .env\ngg deploy shop/web:8080 web:v3 --env-file .env --env DEBUG=false\ngg ship   shop/web:8080 --env-file .env\n```\n\n- `--env-file` is **not** picked up automatically. If the user has a `.env` and\n  wants it used, pass the flag; never assume a file should be read.\n- Precedence: `--env` beats every file, later `--env-file` beats earlier ones,\n  and **a resource's injected variable beats all of it** (see \"Resources\").\n- There is **no interpolation**. `B=${A}` sets `B` to the literal `${A}`.\n- Env is **replaced on every deploy, not merged.** To remove a variable, deploy\n  without it. To keep one, keep passing it.\n- The file supplies **values only**. It cannot name services, set ports or say\n  what is public. If you find yourself wanting to put deployment structure in a\n  file, stop — Gagarin holds that itself.\n\nEnvironment is the one thing a deploy still replaces wholesale, because it is\npart of what a revision ran with and is what a rollback puts back. Everything\nelse that could be lost by forgetting to restate it has been moved out of a\ndeploy for exactly that reason.\n\n### What does not go in env\n\n**No secrets. Not an API key, not a password, not a token, not a connection\nstring with a password in it.** A deploy env is for configuration that is\nharmless to read and owned by this one service: `PORT`, `LOG_LEVEL`,\n`NODE_ENV`, `API=http://api:8080`. Anything that would hurt in the wrong hands\nbelongs on the graph instead:\n\n| it is | where it goes |\n|---|---|\n| a Gagarin database, cache, queue or bucket | `gg deps add P/SVC RESOURCE`. The credentials arrive by themselves, and are never copied into env |\n| a third-party key (Stripe, OpenAI, SMTP, a webhook secret) | `gg resource add P/NAME external --env-file .env.NAME`, then `gg deps add` |\n| config several services share, or that should change without a deploy | an `external` too, even when it is not secret |\n\nWhy a secret in a deploy env is the wrong place, every time:\n\n- **It is copied into every revision.** History keeps each deploy's env so a\n  rollback can put it back, so a key you rotated is still stored, alongside every\n  older one, for as long as those revisions exist.\n- **It cannot be changed on its own.** A deploy replaces the whole env, so\n  rotating one key means restating all of them, and the API will not hand them\n  back: `status` and `history` return the variable *names* (`env_keys`), never\n  the values. Whoever rotates it needs the full `.env` file, or deletes every\n  key they forget.\n- **It is a copy per service.** Three services using one key means three\n  deploys to rotate it, and the one you forget keeps authenticating with a\n  revoked key. An external is one row: `gg resource rotate --set` changes one\n  key, every holder is restarted, and `gg rollback P/NAME` undoes it.\n- **It lives in a file on someone's machine and in CI**, because it has to be\n  restated on every deploy. An external is stated once.\n\n**What you do as an agent:**\n\n- A credential for a service becomes an `external`, from a file your human\n  writes (see the external section). Do not ask for it in chat, do not pass it\n  with `--env`, and do not put it in a `.env` that a deploy reads.\n- If a `.env` you were asked to deploy with holds secrets, say so before\n  deploying, and offer to move them out. Do not quietly ship them, and do not\n  quietly drop them either: the service would start without them.\n- If a service already has a secret in its deploy env (`env_keys` in\n  `gg status` names it), say so and offer the move below. Do **not** try to\n  reconstruct its environment to redeploy: the values are not readable through\n  the API, and a guess deletes every key you leave out.\n\nMoving a secret out of a deploy env, without a moment where the service lacks\nit:\n\n```\ngg resource add shop/stripe external --env-file .env.stripe   # holds API_KEY\ngg deps add shop/web stripe          # web now also holds STRIPE_API_KEY\ngg deploy shop/web:8080 web:v3 --env-file .env   # the same .env, minus STRIPE_API_KEY\n```\n\nThe injected variable beats the deploy env, so the order is safe: `web` holds\nthe key the whole way through, and the last deploy only removes the stale copy.\nName the resource for how the application reads it: `stripe` with `API_KEY`\npublishes `STRIPE_API_KEY`. After the move, the old value is still stored in the\nhistory revisions that carried it. Rotate the key at the provider if it ever went\nanywhere it should not have.\n\n### Size\n\nEvery service and every resource runs at a size, and `s` is what you get if you\nsay nothing at creation.\n\n| | reserved | ceiling | price |\n|---|---|---|---|\n| `s` | 100m CPU / 256 MiB | 0.5 vCPU / 1 GB, shared | $10/month |\n| `m` | 1 vCPU / 2 GB | same — dedicated | $30/month |\n| `l` | 2 vCPU / 4 GB | same — dedicated | $60/month |\n\n```\ngg deploy shop/web:8080 web:v3 --size m\ngg ship shop/web:8080 --size m\ngg resource add shop/db postgres --size m\n```\n\n- **`s` is shared; `m` and `l` are dedicated.** An `s` service may burst to its\n  ceiling but is only guaranteed the reservation, which is why it costs a third\n  of `m`. An `m` or `l` reserves exactly what it is promised and is the last\n  thing evicted when a node runs short.\n- **Omitting `--size` keeps the size the service already has.** It does not reset\n  to `s`. Changing a size is therefore always deliberate.\n- **Changing a size restarts the service** — a new pod with new limits. Expect a\n  few seconds of downtime, and do not do it while something depends on it.\n- **Which to pick.** Start at `s`: it runs a small API, a worker, a static site,\n  a database you develop against. Move to `m` when something is OOM-killed —\n  `gg status` says so and names the size to move to — or when you already know\n  the workload: server-side-rendered Next.js, a JVM, a large in-process cache, a\n  postgres a real application depends on. Do not reach for `l` speculatively.\n- **A postgres's size also sets its settings**: at most **60, 105 or 119\n  connections** at `s`, `m` or `l`, shared buffers of 128 MB, 512 MB or 1 GB,\n  and `work_mem` of 2, 2 or 4 MB. They are the platform's, not a flag; a query\n  that needs more sort memory runs `SET work_mem` for its own session. A\n  postgres created before 2026-11-17 keeps stock settings (100 connections)\n  until its next resize. If an app runs out of connections, pool them — or\n  move up a size.\n- `gg status` shows the size every service is running at, and the day's accrued\n  cost at the bottom of the table.\n\n### Replicas\n\nA service runs one copy unless it says otherwise. `--replicas` on `gg deploy`\nor `gg ship` sets a fixed count, or a range the platform scales within on CPU:\n\n```\ngg deploy shop/web:8080 web:v3 --replicas 3     always three copies\ngg ship shop/api:4000 --replicas 1-5            one to five, by CPU load\ngg deploy shop/web:8080 web:v4 --replicas 1     back to one\n```\n\n- **Omitting `--replicas` keeps what the service has**, like `--size`.\n- **Every copy is billed at its size's rate while it runs.** A range bills its\n  minimum all the time and each extra copy only while it is up. At most five.\n- **Only a service without a volume.** A service with a volume always runs one\n  copy (`replicas_with_volume`); resources and jobs have no replicas. A\n  database does not get replicas or failover from this.\n- **More copies help CPU, not memory.** A service that is OOM-killed needs a\n  bigger size; one that is CPU-bound under load, or must stay up through a\n  node drain, wants `--replicas 2` or a range. Copies share nothing in memory,\n  so in-process sessions or caches must live in valkey or postgres first.\n- `gg status` adds a REPLICAS column once anything in the project may run more\n  than one.\n\n### Volumes\n\n```\ngg ship shop/db:5432 --volume /var/lib/postgresql/data --volume-size 20\n```\n\nA directory that survives restarts. **Set once, at the deploy that creates the\nservice**; a later deploy cannot move it or resize it, and asking is refused with\n`volume_immutable`. The default ceiling is 10 GB. A rollback across a change of\nvolume is refused for the same reason. It is writable by whatever user the image\nruns as, so an image with a non-root `USER` needs no chown or init step.\n\nUse this for anything stateful that has no resource type — see \"Anything we do\nnot have a type for\".\n\n## Jobs: what runs to completion\n\n```\ngg build shop/migrate:v3 --context ./migrations\ngg run   shop/migrate migrate:v3 --deps db --env-file .env\ngg run   shop/migrate migrate:v3 --detach        submit and return\ngg run   shop/migrate migrate:v3 --timeout 5m    stop it at five minutes\ngg run   shop/migrate migrate:v3 --ttl 30m       remove it half an hour after it ends\n```\n\nA job is a service that ends. It has an image, an environment, a size and a\nplace on the graph, and **no port, no address and no volume**: it listens on\nnothing, nothing can declare that it needs one, and it keeps nothing between\nruns. Durable data belongs in a resource the job reaches with `--deps`.\n\n- **`gg run` is the one command that waits.** It submits the run, follows it,\n  prints what the run wrote, and **exits with the script's own exit code**. Read\n  the code: zero means the script finished; anything else is the script's\n  failure, and the last line names it. `--detach` returns at once instead, and\n  `gg status` then reports how the run ended.\n- **Every `gg run` is one run**, recorded as a revision exactly like a deploy.\n  Running twice runs twice. `gg history` lists the runs; `gg rollback` runs an\n  earlier revision again.\n- **A run that fails is not retried**, and its exit code is reported once. Fix\n  the script and run again; the platform will not re-run a half-applied\n  migration on its own.\n- **A run is stopped at its timeout, which is sixty minutes unless you set\n  one.** `--timeout 5m` takes a Go duration (`45s`, `5m`, `1m30s`, `1h`) from\n  one second to sixty minutes, in whole seconds; over MCP it is\n  `timeout_seconds`, 1 to 3600. Left out, a job keeps the timeout its last run\n  was given, and a new job gets sixty minutes; to go back to the default, say\n  `60m` (or 3600) outright. The clock starts when the run gets a machine, not\n  when the script starts, so pulling the image uses some of it; waiting for a\n  machine uses none. A run that never gets a machine is given up on after its\n  timeout plus thirty minutes, and its status says nothing ran and nothing was\n  billed. At the deadline the run is sent SIGTERM, and killed thirty seconds\n  later if it is still running. `gg status` says so when that is why it ended:\n  \"the run was stopped at its timeout of 5 minutes, counted from when it got a\n  machine; gg run --timeout gives it up to 60 minutes\" (at the ceiling: \"...after\n  60 minutes, counted from when it got a machine, which is the most a job may\n  take\").\n  Something that needs longer than an hour is a service.\n- **A finished run is removed after its TTL, eight hours unless you set one.**\n  `--ttl 30m` takes a duration from one minute to eight hours; over MCP it is\n  `ttl_seconds`, 60 to 28800 (`invalid_ttl` outside that). Left out, a job keeps\n  the TTL it has, and a new job gets eight hours. It counts from when the run\n  **ended**, not from when it got a machine as the timeout does. On expiry a\n  one-shot job is deleted outright: its row, history and runs go, it leaves\n  `gg status`, and its name is free again (a reused name starts at revision 1).\n  `gg logs` still has what the run wrote while the job exists. So read the\n  outcome with `gg run` (which waits) or `gg status` before the TTL passes, and\n  there is nothing to `gg destroy` afterwards.\n- **Its image is any image in the project's space** — build one with\n  `gg build`, or run the service's own image with a different entrypoint baked\n  into a second Dockerfile. `gg run` does not build.\n- **A job is billed for the time it runs**, at its size, not for existing: by\n  the minute, from when its container starts. Waiting for a machine and pulling\n  the image are not billed. A hung run costs at most its timeout.\n- **A run can sit `pending` without being stuck.** With no machine yet, `gg\n  status` says \"waiting for a machine with room for it — the cluster adds one\n  within a few minutes unless it is at its limit; nothing is billed until it\n  starts\". Keep waiting; it is not a failure.\n- **Kinds do not change.** A name that is a job stays a job (`not_a_service`),\n  and a name that is a service cannot be run as a job (`not_a_job`). Give the\n  job its own name.\n\nUse a job for anything the user describes as \"run this once\" or \"run this\nbefore deploying\": migrations, seeds, imports, one-off reports. The shape for a\ndeploy that needs a migration first is two commands, in this order:\n\n```\ngg run    shop/migrate migrate:v3 --deps db     # exits non-zero if it failed: stop here\ngg deploy shop/api:8080 api:v3\n```\n\n### On a schedule\n\n```\ngg run shop/report report:v2 --schedule \"0 3 * * *\" --tz Europe/Berlin\ngg run shop/report report:v3                     next firing runs v3; schedule kept\ngg run shop/sync   sync:v1   --schedule \"*/5 * * * *\" --deps db\n```\n\nUse this for anything the user describes as \"every night\", \"every hour\", \"on\nMondays\": a nightly import, a report, a cleanup, a sync. It is still a job —\nsame image, environment, size, timeout and graph — with one more property.\n\n- **`--schedule` is five cron fields** (minute hour day-of-month month\n  day-of-week) **or a descriptor**: `@hourly`, `@daily`, `@weekly`, `@monthly`,\n  `@yearly`. It may fire as often as every minute. `@every` and a\n  `CRON_TZ=`/`TZ=` prefix are refused (`invalid_schedule`).\n- **`--tz` is the zone the schedule is read in**, an IANA name like\n  `Europe/Berlin`; UTC when left out. Ask the user which zone they mean when they\n  say \"at 3am\" — the default is UTC, not their laptop's zone.\n- **A scheduled `gg run` does not wait**, because nothing runs now: it prints\n  the schedule and the next firing and returns, whatever `--detach` says. There\n  is no exit code to read. `gg status` is how you learn how each firing ended.\n- **Each firing is a run** like any other: not retried when it fails, stopped\n  at its timeout, billed for the time it ran. A schedule waiting between\n  firings costs nothing. **Runs never overlap**: a firing that comes while the\n  previous run is still going is not started beside it — it waits, and starts\n  the moment that run ends; several firings missed that way start once. A job\n  that takes longer than its interval therefore runs back to back, not in\n  parallel.\n- **`gg run` again without `--schedule` keeps the schedule** and changes what\n  the next firing runs — the image, `--env`, `--size`, `--timeout`, `--ttl`. A firing\n  already going keeps what it started with. `--schedule` again changes when;\n  `--tz` alone changes the zone.\n- **`--schedule` on a one-shot job makes it scheduled**, between runs only:\n  while its run is still going it is refused `job_running`.\n- **A schedule cannot be removed.** `gg run` means \"run this\", so a\n  `--schedule off` would fire a run when all you wanted was for the schedule to\n  stop — the one thing the command could not avoid doing. To stop a scheduled\n  job, destroy it (a human approves) and, if it should still exist as a one-shot\n  job, run it again without `--schedule`. Do not look for a flag to pause or\n  clear a schedule; there is none.\n- **`--ttl` on a scheduled job applies to each firing**, counted from when it\n  ended, and the job stays: only that firing's run is removed. `gg status` still\n  reports the last firing, reading \"(removed after its ttl)\", and `gg logs` keeps\n  what it wrote.\n- **A failed firing alerts** whoever opted in to the project's alerts, once,\n  and a later firing that succeeds resolves it. Nobody else is watching a run\n  at three in the morning, so when you set up a schedule for someone who has\n  them off, suggest the switch at `https://my.gagarin.cloud/projects/P/alerts`.\n- Over MCP, `run` takes `schedule`, `time_zone` and `ttl_seconds`, and `status`\n  carries `schedule`, `time_zone` and `actual.schedule` (`next_at`,\n  `last_scheduled_at`, `suspended`).\n\n### From code: the SDK\n\n`gg run` is for a person or a pipeline, and `--schedule` for a clock. When\n**a program** decides that a job should run — on a request, a queue message, a\nuser's click — it starts the run with the SDK. **Never shell out to `gg` from an\napplication**: it would need gg installed in the image and a login on a machine\nnobody signs in to. The SDK is the same API as a library, in three languages,\neach with no runtime dependencies:\n\n```\nnpm install @gagarin-cloud/sdk              Node 18+, TypeScript types included\npip install gagarin                         Python 3.9+\ngo get github.com/gagarin-cloud/sdk/go      Go 1.22+\n```\n\nEach one reads `GAGARIN_TOKEN` (and `GAGARIN_API`, `GAGARIN_REGISTRY`) from the\nenvironment, exactly as gg does. The four job calls are `run` (submit; returns\nthe run's `revision` at once), `wait` (until that revision ends), `runAndWait`\n(both, which is `gg run`) and `logs`.\n\n```ts\nimport { Gagarin, GagarinError } from \"@gagarin-cloud/sdk\";\n\nconst gg = new Gagarin();\nconst name = `export-${id}`;                       // one name per run; see below\ntry {\n  const sub = await gg.jobs.run(\"shop\", name, {\n    image: \"export:v4\", env: { EXPORT_ID: id }, deps: [\"files\"], timeoutSeconds: 900,\n  });\n  const run = await gg.jobs.wait(\"shop\", name, sub.revision);\n  if (run.phase !== \"done\") { /* failed: run.exit_code, and gg.jobs.logs(\"shop\", name) */ }\n} catch (e) {\n  if (e instanceof GagarinError && e.code === \"payment_required\") { /* … */ }\n  throw e;\n}\n```\n\n```python\nfrom gagarin import Gagarin, GagarinError\n\ngg = Gagarin()\nres = gg.jobs.run_and_wait(\"shop\", f\"export-{id}\", image=\"export:v4\",\n                           env={\"EXPORT_ID\": id}, deps=[\"files\"], timeout_seconds=900)\nres.exit_code                                     # what gg run would exit with\n```\n\n```go\nc, err := gagarin.NewClient()   // import gagarin \"github.com/gagarin-cloud/sdk/go\"\nres, err := c.Jobs.RunAndWait(ctx, \"shop\", \"export-\"+id, gagarin.RunOptions{\n\tImage: \"export:v4\", Env: map[string]string{\"EXPORT_ID\": id},\n\tDeps: []string{\"files\"}, TimeoutSeconds: 900,\n})\nif gagarin.IsCode(err, \"payment_required\") { /* … */ }\nres.ExitCode()\n```\n\nEverything in \"Jobs\" above still holds, because it is the same call:\n\n- **The image must already be in the registry.** The SDK neither builds nor\n  pushes; `gg build` and `gg push` (or CI) put it there first. A bare\n  `repo:tag` is expanded to the project's registry space for you.\n- **`env` is the run's complete environment**, not merged with the last one;\n  leave it out and the run has none. **`deps` adds** to what the job already\n  declares. Both follow rule 7: no credential goes in `env` — a job reaches its\n  database or bucket through `deps`.\n- **The timeout is at most 3600 seconds and starts when the run gets a\n  machine.** Every call is a new run, billed for the time it runs.\n- **The TTL is `ttlSeconds` (Node), `ttl_seconds` (Python), `TTLSeconds` (Go)**,\n  60 to 28800 (`MIN_TTL_SECONDS`/`MAX_TTL_SECONDS`, `MinTTLSeconds`/`MaxTTLSeconds`\n  in Go); leave it out for the job's current one, eight hours on a new job. It\n  counts from when the run ended and then removes a one-shot job, so `wait` or\n  `runAndWait` and read the run (and `logs`) before it goes. After that, `get`\n  and `wait` on the name fail `not_found` (\"nothing named … in project …\"), which\n  looks the same as a job that never existed. A scheduled firing is the\n  exception: the job stays, and its last run reads `expired: true`\n  (`Expired` in Go) with phase, exit code and times intact.\n- **Refusals are a typed error carrying the API's `code`**, `message` and\n  fix hint: `GagarinError` in Node and Python, `*gagarin.Error` with\n  `gagarin.IsCode` in Go. Branch on the code, as in \"Error codes\".\n- **It does not destroy anything.** Destroying is a human's approval, and the\n  SDK leaves it out.\n\n**One name per run that may overlap another.** Starting a run on a job **stops\nthat job's run still going** — a new revision is what the job is now. So an\napplication that may start a second run before the first has ended must give\neach its own job name: a fixed prefix and a short id of the work (`export-7f3a`),\nnever raw user input, and within `^[a-z][a-z0-9-]{1,29}$`. If only a fixed number\nshould run at once, a name per lane (`export-1` … `export-4`) is the alternative,\nand the application must not start a lane that is busy. A `wait` on a run that a\nnewer one replaced fails with `superseded` (`gagarin.ErrSuperseded` in Go) —\nthe symptom of two runs sharing a name. A finished job costs nothing and\nremoves itself after its TTL, eight hours unless the run asks for less, which\nfrees its name; nothing needs `gg destroy`, so per-run names do not pile up.\n\n**The application needs a credential of its own**, minted the way CI's is and\ndelivered the way every other secret is — as an `external` resource, never in\n`--env`. Name the resource `gagarin` and the key `TOKEN`, and the service holds\nexactly the `GAGARIN_TOKEN` the SDK reads:\n\n```\nprintf 'TOKEN=%s\\n' \"$(gg creds create --name \"shop/api: starts jobs\" 2>/dev/null)\" > .env.gagarin\ngg resource add shop/gagarin external --env-file .env.gagarin\ngg deps add shop/api gagarin\nrm .env.gagarin\n```\n\nThe token never reaches the terminal or the transcript. Tell the user what it is:\n\n- **It can deploy and run anything in the account**, not only this project, and\n  it **cannot destroy**. Anyone who can read the service's environment holds it.\n- **It expires** — 90 days unless `--expires` says otherwise, 365 at most. Before\n  then, mint a new one the same way into `.env.gagarin` and\n  `gg resource rotate shop/gagarin --env-file .env.gagarin`; the service rolls with\n  it. Never `--set TOKEN=…`: that puts the token on a command line.\n- **`gg creds revoke ID` stops it**, and `gg creds` lists it under the name you\n  gave it.\n\n## Dependencies: what may reach what\n\nEvery service in a project is default-denied. A private service is reachable\nonly from services that have declared they need it, and **an undeclared call is\ndropped rather than refused** — it does not fail fast, it hangs until the client\ngives up, which for a database driver can be thirty seconds or forever.\n\n**A hang between two of your own services is a missing `gg deps` far more often\nthan it is a bug in the application.**\n\n```\ngg deps ls  shop/api            what it reaches today\ngg deps add shop/api db cache   and these as well\ngg deps rm  shop/api cache      and no longer that one (needs a human)\n```\n\n- **Withdrawing needs a human's approval; adding does not.** `gg deps rm` is\n  gated the way `gg destroy` and `gg domain rm` are: it answers\n  `approval_required` and emails the account owner a sentence naming the edge.\n  The asymmetry is the point — opening a path breaks nothing, and closing one\n  breaks something *silently*, because the calls that used to arrive are dropped\n  rather than refused. Ask the user before you request that approval, and tell\n  them what will stop being able to reach what.\n- **The direction matters.** The declaration goes on the *caller*. If `api`\n  queries `db`, it is `api` that needs `db`, never the other way round. Backwards\n  is refused, not quietly accepted.\n- **Reaching a resource also hands over its credentials.** `gg deps add shop/api\n  db` gives `api` `DB_URL`, `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD` and\n  `DB_DATABASE`, and the command prints which ones arrived. Connecting is this\n  one call; it used to be two, and that is no longer necessary.\n- **`--deps` on a deploy or a ship only ever adds.** It exists so a service that\n  cannot start without a database can be declared and deployed together.\n  Forgetting it on the next deploy changes nothing. Withdrawing is `gg deps rm`,\n  there and nowhere else. (If you are working from memory and reach for\n  `--needs`: it is gone. It replaced the whole set on every deploy, so a redeploy\n  that forgot it silently withdrew an edge — and because an undeclared call\n  hangs, the service did not break, it went quiet.)\n- **Public URLs are not covered by this.** One service calling another's public\n  `https://` address arrives the way a stranger's browser does and is allowed.\n  The guarantee is about private, in-project addresses.\n- **Withdrawing applies to new connections, not open ones.** `gg deps rm` closes\n  the path for anything that connects afterwards, but a client holding a\n  keep-alive connection — every HTTP client, every driver pool — keeps using it\n  until it reconnects. That is how Kubernetes network policy works. If you need\n  the old path gone now, redeploy the caller: a new pod has no old connections.\n- `gg destroy` on something another service still needs is refused, and names\n  what depends on it. `gg deps rm` that first.\n\n`gg status` ends every service's row with a REACHES column, so checking the\ngraph costs nothing — do it *before* you go debugging a hang.\n\n### Reaching the outside world\n\nOutbound is unrestricted, with one exception you need before you build on it:\n**the mail ports — 25, 465 and 587 — are blocked.** A connection to any of them\ntimes out, from every service, and it cannot be opened per-account.\n\nSo **do not build anything that speaks SMTP.** If the user wants their\napplication to send email, reach for a provider's HTTPS API — Resend, Postmark,\nSendGrid, SES, any of them. That is a normal way to send mail, not a workaround,\nand it is what Gagarin itself does. Prefer the provider's official SDK to\nhand-rolled HTTP.\n\nThe reason, if the user asks: a service that can open those ports can relay spam\nif it is ever compromised, and a hosting account that relays spam gets suspended\n— which would take every other project on the platform down with it.\n\nIf you find yourself debugging a hanging SMTP connection, stop. It is not the\nuser's code and it is not DNS. It is this.\n\n## Resources: what a project *has*\n\nA resource is provisioned rather than deployed. There is no image to choose, no\nversion to pass and no Dockerfile.\n\n```\ngg resource add shop/db postgres --size m --storage 20 --ext vector\ngg resource add shop/vectors qdrant\ngg resource add shop/cache valkey\ngg resource add shop/events iggy\ngg resource add shop/jobs rabbitmq\ngg resource add shop/files s3\ngg resource add shop/openai external --env-file .env.openai\n```\n\n| type | what it is | storage | backups |\n|---|---|---|---|\n| `postgres` | PostgreSQL 17, with the extensions you ask for (`vector`, `postgis`, …) | on a volume; survives restarts | nightly, kept 14 days |\n| `qdrant` | vector database, for retrieval | on a volume; survives restarts | nightly, kept 14 days |\n| `iggy` | Apache Iggy, a persistent message-streaming log | on a volume (10 GB unless `--storage`); survives restarts | nightly, kept 14 days — see the durability caveat |\n| `rabbitmq` | RabbitMQ 4.4.0 with the management plugin, a message broker for work queues | on a volume (10 GB unless `--storage`); durable queues and persistent messages survive restarts | **none** |\n| `valkey` | in-memory store, redis protocol | **none — a restart loses everything** | none, by design |\n| `s3` | an S3-compatible bucket, for files — private until `gg resource public` | **objects on durable storage; it runs nothing** | **none** |\n| `external` | a third-party API, run by nobody here | **none — it runs nothing at all** | nothing to back up |\n\nThe types are named for what actually runs, not for the products they stand in\nfor — an honesty you can pass on when somebody asks.\n\n- **`qdrant` is Qdrant**, Apache-licensed, and it is what an application does\n  retrieval against: embeddings in, nearest neighbours out. Three things about\n  it are unlike every other type, and all three will bite an agent that assumes\n  otherwise.\n  - **The credential is not in the URL.** `<NAME>_URL` is a bare\n    `http://vectors:6333`; the key arrives separately as `<NAME>_API_KEY` and\n    travels as an `api-key` header. Every client takes it as its own argument —\n    `QdrantClient(url=os.environ[\"VECTORS_URL\"], api_key=os.environ[\"VECTORS_API_KEY\"])`.\n  - **It answers on two ports.** `<NAME>_PORT` is 6333 (HTTP/REST) and\n    `<NAME>_GRPC_PORT` is 6334. The Python, JS, Java and .NET clients want the\n    URL; the official **Go and Rust clients speak only gRPC** and want the host\n    and 6334. Both are published so neither has to be guessed.\n  - **There is no MongoDB here, and no document store either.** If a user wants\n    documents rather than vectors, Gagarin has no type for it — run one as an\n    ordinary service with a volume.\n\n  - **Qdrant or `vector` on a postgres?** Both store embeddings. If the\n    application wants relational tables and embeddings in one database —\n    joined in one query, written in one transaction — ask for the `vector`\n    extension on its postgres (see \"Postgres extensions\" below). That is the\n    default for an application that already needs a postgres and adds\n    retrieval: one resource, one set of credentials, one backup. Reach for\n    `qdrant` when the vectors *are* the product — the search is what the\n    application is for, and it deserves a database of its own.\n\n  Gagarin ran a `ferretdb` type from 2026-09-04 to 2026-09-06 and it is **gone**:\n  it promised MongoDB compatibility and did not keep the promise past the simple\n  cases. There is no alias and no migration path. If a user names it, say it was\n  removed and offer the service-with-a-volume route.\n- **`iggy` is Apache Iggy**, Apache-licensed: a persistent message-streaming\n  log, what an application publishes events to and consumes from in order. One\n  pod, one volume (10 GB by default; `--storage` is accepted), private like every\n  resource, so it is reached only by services that declare it with `deps`.\n  - **It answers on two ports.** `<NAME>_PORT` is 8090, the TCP binary protocol\n    every Iggy SDK speaks, and `<NAME>_HTTP_PORT` is 3000, for REST. QUIC and\n    WebSocket are off.\n  - **The credential is in the URL.** `<NAME>_URL` is the connection string the\n    SDKs read, `iggy://root:<password>@events:8090` for a resource called\n    `events`; `_USER` is always `root`.\n  - **A backup can miss recent messages unless the topic is persisted.** The\n    backup is taken while the server keeps running, so only topics created with\n    `--durability persisted` are guaranteed complete. A topic with the default\n    durability may be missing its newest messages, the ones not yet flushed to\n    disk. Have producers create topics with `--durability persisted` for\n    anything the user would want back from a backup, and say so when you set one\n    up.\n- **`rabbitmq` is RabbitMQ** 4.4.0 with the management plugin: a message broker,\n  what an application publishes jobs to and workers consume from. One pod, one\n  volume at `/var/lib/rabbitmq` (10 GB by default; `--storage` is accepted),\n  private like every resource, so it is reached only by services that declare it\n  with `deps`. Add it, then let the worker reach it: `gg resource add shop/jobs\n  rabbitmq`, then `gg deps add shop/worker jobs`.\n  - **It answers on two ports.** `<NAME>_PORT` is 5672, AMQP, the protocol every\n    client speaks, and `<NAME>_HTTP_PORT` is 15672, the management UI and HTTP\n    API.\n  - **The credential is in the URL.** `<NAME>_URL` is\n    `amqp://app:<password>@jobs:5672/%2F` for a resource called `jobs` (the\n    `%2F` is the default vhost `/`), and it goes straight to the client: pika,\n    amqplib, amqp091-go, or a Celery `broker_url`. `_USER` is always `app`.\n  - **There are no backups.** `gg resource backup` answers `backup_unsupported`.\n    Unlike iggy, there is nothing to recommend that makes a backup complete,\n    because there is no backup. What survives a restart is only what is durable:\n    declare queues `durable` and publish messages `persistent` (delivery mode 2)\n    for anything the user wants to outlive the pod. A transient queue or message\n    is gone on a restart, which happens on a node drain, not only when somebody\n    asks.\n  - **Declare queues and exchanges from application code, at startup.** The\n    broker keeps no copy elsewhere, so a fresh one (a destroyed and re-added\n    resource, or a lost volume) must be rebuildable by just starting the\n    application. Declaring is idempotent when the arguments match, so every\n    producer and consumer can do it on every start. Do not create topology by\n    hand in the management UI and leave it there.\n  - **Choose it for work queues, routing and fan-out to workers**; choose\n    `iggy` for an append-only log that consumers replay from an offset. If the\n    user wants to re-read history, it is iggy; if each message is a job to be\n    done once and then forgotten, it is rabbitmq.\n- **`valkey` is a cache, not a database.** `--storage` is refused (`no_storage`)\n  rather than quietly ignored, and everything in it is gone when the pod restarts\n  — which happens on a node drain, not only when somebody asks. Do not put a\n  session store there that a user would notice losing, and do not tell anyone\n  their data is safe in it. Valkey is the BSD-licensed fork of Redis; `redis://`\n  URLs, `redis-cli` and every client library work unchanged.\n- **Storage can grow, never shrink.** Restate the resource with a bigger\n  `--storage` to raise the ceiling — `gg resource add shop/db postgres --storage\n  40` on an existing `db` grows it and changes nothing else. A smaller number is\n  refused with `volume_immutable`.\n- **One instance, one volume, no failover.** A size change or a restart is a\n  brief outage. There is no point-in-time recovery. Say that plainly if a user\n  asks whether their data is safe, rather than implying an SLA nobody is on the\n  hook for.\n- **A resource cannot be deployed over.** `gg deploy shop/db` against one is\n  refused with `not_a_service`, which is telling you the name is already a\n  database. Nor can a resource declare dependencies: it is reached, it does not\n  reach.\n- **A managed resource cannot be rolled back**, because Gagarin mints its\n  credentials and there is no earlier value of the user's to go back to. An\n  **external can** — its values are theirs — and `gg rollback P/NAME` is how a\n  config change is undone. See the external section below. An `s3` cannot\n  either, for the same reason.\n\n### Postgres extensions\n\nA `postgres` takes **extensions**: the set of postgres extensions the database\nshould have, named exactly as `CREATE EXTENSION` names them.\n\n```\ngg resource add shop/db postgres --ext vector --ext postgis    create it with both, or restate it\n```\n\nOver MCP it is the `extensions` list on `add_resource`; on the API it is the\n`extensions` field of the resource's PUT body,\n`{\"type\":\"postgres\",\"extensions\":[\"vector\",\"postgis\"]}`. `--ext` takes one name\nand is repeated, like `--deps` and `--env` — not a comma-separated list. The\nrules are the same everywhere:\n\n- **It is the whole set, not a delta.** `--ext vector` on a postgres that has\n  `vector` and `postgis` asks for postgis to go. To add one, restate every one it\n  already has plus the new one — `gg status` lists what it has.\n- **Leave it out and the extensions stay as they are**, exactly like `--size`.\n  An empty list (`[]`, or `--ext \"\"`) means none.\n- **Only a postgres has them.** `extensions` on any other type is refused with\n  `no_extensions`.\n- **On create, they exist before the database is first ready.** Adding one to\n  an existing postgres is **immediate, on the running server, with no\n  restart** — every postgres runs the same image with all of them compiled in.\n- **Dropping one asks no one** — the one removal that does not, because a drop\n  refuses rather than loses anything, so a drop that succeeds cost nothing.\n  **It is never CASCADE**: a column, an index, a view or a SQL-standard\n  function that uses the extension — a `vector` column, say — stops it. **And\n  it is refused while the extension's own tables hold the user's data**:\n  pg_cron's jobs (`cron.job`) and their run history, pg_partman's partition\n  config (`partman.part_config`), a spatial reference system the user added to\n  PostGIS's `spatial_ref_sys`. Nothing depends on those tables, so without the\n  guard a plain DROP would delete every scheduled job. Either refusal is\n  `extensions_failed` (HTTP 409), carrying postgres's own reason — \"column e\n  of table items depends on type vector\", or \"extension pg_cron holds 1 row(s)\n  of your data in cron.job; remove them first if losing them is what you\n  mean\". It is one transaction, so a refused change changes nothing — not the\n  extensions, and not the rest of what the command restated. To really drop\n  it, remove what is in the way first — and ask your human before deleting\n  their jobs or data to do it. A plpgsql function that uses the extension is\n  not tracked by postgres, so it breaks when next called; nothing is lost, and\n  adding the extension back mends it.\n- **Requirements are added for you.** Asking for `earthdistance` also gives\n  `cube`.\n- **Ask the platform; do not run `CREATE EXTENSION` by hand** for anything in\n  the catalogue below. `app` is a superuser in its own pod and *can*, but what\n  it creates that way is not recorded in `extensions`: the platform does not\n  know about it, the status does not show it, and nothing keeps it. Asking the\n  platform records it and keeps it.\n\n**The catalogue — everything `extensions` accepts:**\n\n| name | what it is for |\n|---|---|\n| `vector` | pgvector: vector columns with HNSW and IVFFlat indexes, for embeddings |\n| `postgis` | PostGIS: geometry and geography types, spatial indexes and functions (no raster) |\n| `pg_cron` | scheduled SQL, run by the database itself (jobs run in database `app`) |\n| `pg_partman` | partition management, created in schema `partman` |\n| `pgaudit` | audit logging to the resource's log (set `pgaudit.log` to turn it on) |\n\nPlus the contrib extensions that ship with postgres: `pg_stat_statements`,\n`pg_trgm`, `pgcrypto`, `uuid-ossp`, `citext`, `hstore`, `ltree`, `unaccent`,\n`fuzzystrmatch`, `btree_gin`, `btree_gist`, `cube`, `earthdistance` (adds\n`cube`), `intarray`, `tablefunc`, `amcheck`, `pg_buffercache`.\n\n- **\"pgvector\" is called `vector`.** That is its name in postgres, and asking\n  for `pgvector` is refused with a hint saying so. There is no pgvector\n  resource type: embeddings in a postgres are this extension.\n- **Not offered:** timescaledb (its licence forbids exactly a hosted service),\n  raster, `dblink`/`postgres_fdw`/`file_fdw`, untrusted languages. Any name\n  outside the catalogue is refused with `unknown_extension`, and the hint lists\n  every name that is offered.\n- Nothing else about the postgres changes: the same connection variables, sizes,\n  storage, price, rotation and nightly backups.\n\n### Connecting one: the single call\n\n```\ngg deps add shop/api db\n```\n\nThat declares the dependency **and** puts the database's connection variables in\n`api`'s environment. It prints what arrived:\n\n```\napi reaches db, and nothing else.\n\napi now holds DB_DATABASE, DB_HOST, DB_PASSWORD, DB_PORT, DB_URL, DB_USER\n  in its environment, from the resources it reaches. Values: gg resource secrets.\n```\n\nOr declare it on the deploy, so the service never starts without them:\n`gg deploy shop/api:8080 api:v3 --deps db`.\n\n**The variables are named after the resource, not the protocol** — the resource's\nown name, upper-cased with dashes as underscores, plus a suffix:\n\n| suffix | postgres | valkey | qdrant | iggy | rabbitmq |\n|---|---|---|---|---|---|\n| `<NAME>_URL` | `postgres://…?sslmode=disable` | `redis://:pass@…` | `http://vectors:6333` | `iggy://root:pass@events:8090` | `amqp://app:pass@jobs:5672/%2F` |\n| `<NAME>_HOST` | ✅ | ✅ | ✅ | ✅ | ✅ |\n| `<NAME>_PORT` | 5432 | 6379 | 6333 | 8090 | 5672 |\n| `<NAME>_GRPC_PORT` | — | — | 6334 | — | — |\n| `<NAME>_HTTP_PORT` | — | — | — | 3000 | 15672 |\n| `<NAME>_USER` | ✅ | — | — | `root` | `app` |\n| `<NAME>_PASSWORD` | ✅ | ✅ | — | ✅ | ✅ |\n| `<NAME>_API_KEY` | — | — | ✅ | — | — |\n| `<NAME>_DATABASE` | ✅ | — | — | — | — |\n\nAn `s3` bucket publishes none of these. It publishes five of its own:\n`<NAME>_ENDPOINT`, `<NAME>_REGION`, `<NAME>_BUCKET`, `<NAME>_ACCESS_KEY_ID` and\n`<NAME>_SECRET_ACCESS_KEY` — see its section below. While it is public it also\npublishes `<NAME>_PUBLIC_URL`.\n\nA postgres called `db` publishes `DB_URL`; one called `orders-db` publishes\n`ORDERS_DB_URL`; a valkey called `cache` publishes `CACHE_URL` and no\n`CACHE_USER`, because valkey has no users. A type omits the suffixes it has no\nanswer for rather than publishing them empty — so an absent `VECTORS_PASSWORD`\nis not a bug, it is a qdrant having no password. Two consequences, and both are\nthe point: a service can reach two databases without a collision, and there is\none vocabulary of suffixes rather than a different set per type.\n\n**These are not the names your framework expects, and that is deliberate.** There\nis no `DATABASE_URL`, no `PGHOST`, no `REDIS_URL`, no `QDRANT_URL` unless the\nresource happens to be called `qdrant`. The first thing to try is to have the\napplication read `DB_URL` — one line in the app, and nothing about it can go\nstale.\n\nIf you genuinely cannot change the application, read the value out and pass it\nunder the name it wants:\n\n```\ngg deploy shop/api:8080 api:v3 --deps db \\\n  --env DATABASE_URL=\"$(gg resource secrets shop/db --format json | jq -r .env.DB_URL)\"\n```\n\nNote what that is: **a copy**, and the only stale thing in the model. `$DB_URL`\nalone would not work — the injected variables exist inside the pod, not in the\nshell running `gg`. Say so rather than leaving a second copy of a password in a\ndeploy nobody remembers making.\n\nFour rules that follow, and each one fails quietly if you get it wrong:\n\n- **Injected variables outrank your own.** Set `DB_URL` on a deploy while the\n  service also reaches a resource called `db`, and the resource wins. It is the\n  one place something beats what a deploy said, and the reason is that only the\n  resource knows the real password.\n- **Nothing is copied into the stored environment.** The platform unions these in\n  every time it renders the pod, from the graph as it stands then. They cannot go\n  stale, no redeploy can forget them, and **a rollback restores the image and the\n  environment you deployed with, never an old password.** `gg deps rm` takes them\n  away just as surely.\n- **Holding the credentials is not enough.** The network policy is a separate\n  boundary from the environment. You cannot get the credentials without the\n  declaration that opens the route, so this is no longer a trap — but do not\n  conclude from a working password that the route is open for some *other*\n  service you did not declare.\n- **`gg resource secrets` is for reading the values from outside the graph** —\n  checking what an application is being handed, or wiring up a client that runs\n  outside Gagarin. The values name the in-project host, which this machine\n  cannot reach: to actually connect from here, `gg connect` opens a tunnel and\n  prints them rewritten for it. You do not need either to connect a service in\n  the same project. Treat the output as a live credential: do not echo it into\n  a chat, a commit, or a summary.\n- **`--names` when the question is \"what does it publish\"**, which it usually\n  is: what a bundle holds, or what a key is called before you change it. It\n  asks a different endpoint, so the values are not fetched rather than merely\n  not printed — nothing secret passes through you. `gg status` cannot answer\n  this: it prints `DB_*`, the prefix rule rather than the contents.\n\n```\ngg resource secrets shop/db --names         # just the names — reach for this first\ngg resource secrets shop/db > .env.db       # KEY=VALUE lines into a file, for --env-file\ngg resource secrets shop/db --format json | jq -r .env.DB_URL > db.url   # one value, into a file\n```\n\n### Meddling from this machine: `gg connect`\n\n```\ngg connect shop/db\n```\n\nA resource is not on the internet, and stays off it. When a human needs psql\nagainst the real database — a migration to babysit, a row to look at — this\nopens a tunnel from this machine and prints the same variables a service would\nhold, rewritten to point at 127.0.0.1:\n\n```\ndb is a postgres. The tunnel is up:\n\n  DB_HOST=127.0.0.1\n  DB_URL=postgres://app:…@127.0.0.1:5432/app?sslmode=disable\n  ...\n```\n\n- **It lasts exactly as long as the command.** Ctrl-C closes the tunnel and\n  every connection through it. Nothing is exposed, and there is nothing to\n  undo afterwards.\n- **It is for the machine gg runs on, never for services.** A service reaches\n  a resource by declaring it — `gg deps add shop/api db` — which needs no\n  tunnel and survives any command exiting. Do not leave `gg connect` running\n  as plumbing under an application.\n- **Every port the resource answers on gets a local end** — a qdrant tunnels\n  6333 and 6334 at once, an iggy 8090 and 3000, and a rabbitmq 5672 and\n  15672 (the management UI is then at `http://127.0.0.1:<local port>`). Each prefers its own number and quietly takes a free\n  one when that is busy; `--port` pins the primary, and is refused rather than\n  moved when the port is taken.\n- **An external is refused** (`not_tunnelable`), and an s3 is refused by `gg`\n  itself (\"publishes no port to tunnel to\"): nothing runs, so there is nothing\n  to tunnel to. Their values are `gg resource secrets`.\n- **The resource must be running.** A stopped one refuses with\n  `tunnel_unavailable`, and `gg status` says what it is waiting on.\n- The printed values are live credentials on a local port, and the same rule\n  as secrets applies: do not echo them into a chat, a commit, or a summary.\n\n### `external`: a third-party key as a node on the graph\n\nAn OpenAI account, a Stripe key, a bucket somewhere else. Not something Gagarin\nruns — something your services need a credential for.\n\n```\ngg resource add shop/openai external --env-file .env.openai\ngg deps add shop/bot openai\n```\n\nAn `.env.openai` holding `API_KEY` and `BASE_URL` makes `bot` hold\n`OPENAI_API_KEY` and `OPENAI_BASE_URL`. Same naming rule as every other type, so\n**write the keys without the prefix** — `API_KEY`, not `OPENAI_API_KEY`, which is\nrefused rather than doubled.\n\n**This is where every third-party credential goes. A deploy env is not an\nalternative.** Why not `--env OPENAI_API_KEY=…` on the deploy? Because a key on a\ndeploy is a copy. Three services using one key means three copies, rotating\nit means three deploys, and a deploy you forget leaves a service authenticating\nwith a revoked key. As a resource it is one row and rotating is one command.\n\n- **Use `--env-file`, not `--env`.** A key on the command line goes into the shell\n  history and into the transcript of every agent that ran the command. Ask your\n  human to write the key into `.env.NAME` themselves; do not ask for it in chat.\n  If they paste one anyway, write it to the file without repeating it, and tell\n  them it is now in this chat's history, so it should be rotated at the provider.\n- **Restating an external is refused** once it exists (`already_exists`). That\n  refusal is deliberate: restating from an old `.env` would roll the key\n  *backwards*, and the failure would be an authentication error nobody would\n  connect to the command they ran. Changing values is `gg resource rotate`, and\n  changing *one* of them is `gg resource rotate --set K=\"$(cat FILE)\"`, which\n  leaves the rest alone and keeps the value off the command line.\n- **It runs nothing.** No container, no port, no size, no storage, no backups,\n  nothing to become ready. `gg status` shows it as `◆` and leaves every\n  container column a dash; what it publishes is `gg resource secrets P/NAME\n  --names`.\n- **Declaring an external does NOT restrict egress.** This is the one thing not to\n  get wrong when you explain it. Everything in a project can already reach the\n  whole internet — the mail ports are the only exception. What the declaration\n  grants is the credentials and a line on the graph saying who uses them. It is\n  **not** a firewall: an undeclared service can still call `api.openai.com`, it\n  just has no key. `gg status` marks these edges `◆` for exactly this reason.\n- **What it is genuinely worth:** the project's dependencies become legible, and\n  destroying an external is refused while anything still declares it, so a key\n  cannot be dropped out from under a running service.\n\n### An external is also where shared config belongs\n\nNot only third-party credentials. **Anything several services read, or that\nchanges without a deploy, belongs in an external** — feature flags, a log level,\na region, an API base URL, a tuning constant.\n\n```\ngg resource add shop/config external --env-file .env.shared\ngg deps add shop/web config\ngg deps add shop/worker config          # both hold CONFIG_LOG_LEVEL\n\ngg resource rotate shop/config --set LOG_LEVEL=debug   # both roll, with the new value\ngg rollback shop/config                                # both roll back\n```\n\n**Why this beats `--env` on each deploy:** the same argument as for a key. An\nenv on a deploy is a copy, so two services sharing a setting is two copies that\ncan disagree, and changing it is two deploys with one you can forget. Resolved\nfrom the graph it is one row, one command, and every holder restarts.\n\n**The editing model is the sharper difference, and it is the one that decides\nthis for you.** A service's environment can be changed only by `gg deploy`, and\na deploy **replaces it wholesale** — every variable not restated is gone. That\nis deliberate, not an oversight: the revision records exactly what the service\nran with, which is what makes a rollback mean something. The cost is that\nchanging one variable requires having all of them.\n\n|  | service env | external |\n|---|---|---|\n| changed by | `gg deploy`, and only a deploy | `gg resource rotate` |\n| granularity | wholesale — anything omitted is **lost** | one key at a time |\n| needs the other values in hand | **yes** | no |\n| undo | `gg rollback P/SVC`, with the deploy | `gg rollback P/config` |\n\n**For you this is a hard edge, not an inconvenience.** Working without the\nproject's `.env` file — from the console's Agent tab, or any session handed a\ntask rather than a repository — you cannot safely change one variable on a\nservice. The only route is to read the whole environment back out of\n`gg history` and restate it, which drops anything you misread and pulls **every**\nvalue the service holds, secrets included, through your transcript.\n\n`gg resource rotate P/config --set KEY=value` has neither problem: it touches the\none key, needs nothing else in hand, and reads no other value. **So when a user\nasks you to change a setting and you do not have their env file, the answer is\nan external — and if the setting is currently in a deploy env, say so and offer\nto move it.**\n\nAnd to find out what a bundle holds before you change one key of it:\n\n```\ngg resource secrets shop/config --names      # names only; no values fetched\n```\n\nUse `--names` by default. Without it the command prints live credentials, and\nin your case that means into a transcript. `gg status` will not answer this\neither — it lists the resource and nothing about its contents.\n\nThe full lifecycle is there, which is what makes it safe to recommend:\n\n| | |\n|---|---|\n| set it | `gg resource add P/config external --env-file .env` |\n| change one value | `gg resource rotate P/config --set LOG_LEVEL=debug` |\n| remove one | `gg resource rotate P/config --unset REGION` |\n| see what it was | `gg history P/config` |\n| put it back | `gg rollback P/config [--to N]` |\n| see what keys it has | `gg resource secrets P/config --names` — no values fetched |\n| read the values | `gg resource secrets P/config` — live credentials; prefer `--names` |\n| who uses it | `gg status P` — and destroying it is refused while anyone does |\n\n**Where the line is.** Config *owned by one service* stays in its `gg deploy\n--env`, because that is the half a service rollback restores. Injected values\nare re-derived from the resources as they stand now — deliberately, so nobody is\never rolled back onto a rotated password — so `gg rollback shop/web` will not\nundo a config change. Undo it at the resource.\n\nThree properties to state when asked, because they are constraints and not\noversights:\n\n- **The prefix is not optional.** A resource named `config` publishes\n  `CONFIG_LOG_LEVEL`, never a bare `LOG_LEVEL`. Name the resource so the prefix\n  reads the way the application wants it.\n- **A dependent cannot override a value.** Injected beats the service's own env\n  of the same name. Two services needing different values is two resources.\n- **Every dependent gets every key** in the bundle. Split by audience, not by\n  topic: one resource per set of services that should hold the same things.\n\n### `s3`: a bucket for files\n\nUser uploads, generated files, ML artifacts, static assets an app serves\nitself. Gagarin's object storage, as an S3-compatible bucket that is private\nuntil you say otherwise.\n\n```\ngg resource add shop/files s3\ngg deps add shop/web files\n```\n\n`web` now holds `FILES_ENDPOINT`, `FILES_REGION`, `FILES_BUCKET`,\n`FILES_ACCESS_KEY_ID` and `FILES_SECRET_ACCESS_KEY` (same prefix rule as every\nother type). There is **no `_URL`, `_HOST`, `_PORT`, `_USER` or `_PASSWORD`** —\nan S3 client takes these five settings separately. Any S3 client library works\n(boto3, the AWS SDKs, …); **pass the endpoint and the region explicitly**, or it\nwill look for AWS. The endpoint is `https`.\n\n- **`--size`, `--storage` and `--env` are all refused** (`no_size`,\n  `no_storage`, `no_env`). A Gagarin without object storage configured answers\n  `object_storage_unavailable` (HTTP 501); report it.\n- **It runs nothing.** No pod, no port, no volume, no logs. Gagarin mints its\n  key, like postgres — unlike an external.\n- **A bucket is private by default.** Only its own key can read or write it;\n  another project's key cannot.\n- **`gg resource public P/NAME` makes the whole bucket listable and readable by\n  anyone**, no key needed. Writes still need the key. Every dependent then gets\n  `<NAME>_PUBLIC_URL` (`https://<bucket>.s3.fr-par.scw.cloud`) and is restarted\n  for it; `gg resource private P/NAME` undoes it and the variable goes away. Both\n  are idempotent, need the editor role and a deploy-scope credential, and\n  `publish_failed` changed nothing, so run it again. The public address also\n  shows in `gg status` among the project's domains.\n  - **Only make public what is genuinely meant to be public.** Listing exposes\n    every object name in the bucket, not just the ones the app links to, and\n    anything fetched while it was open stays fetched. User uploads that are\n    meant to stay private belong in a private bucket, served by the app (which\n    proxies them or hands out its own signed links). Ask the user before\n    running it.\n  - **Browsers on any site can read it.** Making a bucket public also sets a\n    CORS rule: any origin, `GET` and `HEAD` only, no credentials. So\n    `fetch()` of an object or the listing, web fonts, ES modules and\n    `<img crossorigin>` (and reading a canvas) work. It adds no exposure, since\n    a public object was already readable with curl, and writes still need the\n    key. `gg resource private` removes it. A bucket made public before this\n    existed gets it by running `gg resource public` again. The tenant cannot\n    set CORS itself.\n  - **Egress is not metered per bucket yet.** Say so to the user when a public\n    bucket is going to carry heavy traffic (a download host, a busy site's\n    images).\n- **Declaring it does NOT restrict the network.** It is reached over the\n  internet, not inside the cluster, so — exactly like an external — the\n  declaration hands over the key and nothing more. It is not a firewall. `gg\n  status` marks these edges `◇`.\n- **There are no backups.** Objects sit on durable storage but Gagarin takes no\n  copy, and `gg resource backup` answers `backup_unsupported`. If losing the\n  data would matter, keep a copy somewhere else.\n- **`gg connect` does not work**: it publishes no port, and `gg` says so. Read\n  the values with `gg resource secrets`.\n- **It costs $0.03 per GB-month** of what it actually holds, measured hourly,\n  rounded up to whole GB and prorated per minute. There is no running charge,\n  and requests and traffic are not billed.\n- **Not deployable, not rollback-able, no `gg domain`.** `gg deploy` over it is\n  `not_a_service`, as is `gg rollback` (Gagarin mints its key). Its public\n  address comes from `gg resource public`, not from a domain.\n- **Destroying it** needs the human's email approval, is refused while anything\n  still declares it, cuts the key off at once, and permanently deletes every\n  object shortly after.\n\nA bucket the user already has somewhere else is still an `external`.\n\n### Rotating credentials\n\n```\ngg resource rotate shop/db                                        a database\ngg resource rotate shop/openai --set API_KEY=\"$(cat new.key)\"     one of an external's values\ngg resource rotate shop/openai --env-file .env.new                all of them\n```\n\nEverything holding the old credential is restarted with the new one, and the\ncommand names what it rolled. Nothing but variable *names* is printed;\n`gg resource secrets` reads the values, into a file.\n\n**Who supplies the new value is the only difference between the types.** For\n`postgres`, `qdrant`, `valkey`, `iggy`, `rabbitmq` and `s3`, Gagarin mints one and `--env` is refused — a\npassword you chose is one the running server has never heard of. For an\n`external` the values are yours, so one of `--set`, `--unset`, `--env-file` or\n`--env` is required.\n\n**An external usually holds more than one value, and the two ways of changing\nthem mean different things. Reach for `--set`.**\n\n| | what it means |\n|---|---|\n| `--set K=V`, `--unset K` | change these, leave every other key exactly as it is |\n| `--env`, `--env-file` | the bundle is now precisely this; anything not in it **stops being published** |\n\n`--env API_KEY=sk-new` on an external that also holds `BASE_URL` takes `BASE_URL`\naway from every dependent. That is the correct meaning of that request — it is\nthe one to use after a provider migration where every value is new — and the\nwrong one for the far commoner job of replacing a single key. Reading the bundle\nback and restating it is not the answer either: that is the stale-file path, and\nit is how a key gets rolled backwards.\n\nThe command names what stopped being published, so a loss is visible at the\nmoment it happens rather than from a dependent that can no longer authenticate.\nThe two flags cannot be combined — they say the same thing in incompatible\nwords.\n\n`--unset` names a key **without** the resource's prefix, the way it was set:\n`--unset BASE_URL` on `shop/openai`, not `OPENAI_BASE_URL`. A key the resource\ndoes not publish is refused rather than quietly doing nothing, because a no-op\nreported as a success is how somebody believes a secret is gone when it is not.\n\n| type | what happens | cost |\n|---|---|---|\n| `postgres` | the running server is told immediately | none |\n| `qdrant` | the pod is replaced; the key is read at startup | a few seconds away; **the data survives** |\n| `iggy` | the running server is told the new root password first and it is recorded, then the pod restarts and dependents roll | a few seconds away; **nothing stored is lost**, a graceful stop flushes |\n| `rabbitmq` | the running server is told the new password first, then the pod restarts and dependents roll | a few seconds away; **nothing stored is lost** |\n| `valkey` | the pod is replaced; the password is read at startup | **the cache is emptied** |\n| `s3` | a new key is issued and recorded, dependents restart, then the old key is revoked at once | **not zero-downtime:** their S3 calls fail for the seconds the restart takes; **the objects survive** |\n| `external` | nothing of ours runs, so nothing of ours restarts | none |\n\n**An s3 rotation can revoke late.** If the answer says `old_credential_revoked:\nfalse`, the old key still works: tell the user, and run the rotation again — it\nrevokes the leftover key first.\n\n**If it fails, nothing changed.** The old credential is still in use and the\ncommand is safe to run again — say that, rather than leaving the user wondering\nwhat a half-failed rotation left behind. There is no half.\n\n**Rotate after a leak, and say so plainly.** If a key has been in a chat log, a\ncommit or a screenshot, this is the fix and it is one command. For an external,\nnote that Gagarin forgets the old value but cannot *revoke* it — that is a thing\nto do in the third party's own console, and the user has to do it.\n\n### Backup and recovery\n\nPostgres, qdrant and iggy are backed up nightly and kept fourteen days — postgres as a\n`pg_dump`, qdrant as a tar of its per-collection snapshots with the aliases\nbeside them.\n\n**An iggy backup is taken while the server keeps running.** Only topics created\nwith `--durability persisted` are guaranteed complete; a topic with the default\ndurability may be missing its newest messages, the ones not yet flushed to disk.\nRecommend `--durability persisted` for anything the user would want back. Valkey keeps nothing by design, an external has nothing here to\nkeep, and an s3 bucket is not copied: its objects are on durable storage, but\n`gg resource backup` answers `backup_unsupported`. A rabbitmq is in the same case: it is not backed up at all, so its\ndurability is only what survives a restart (durable queues, persistent messages).\n\n```\ngg resource backups shop/db     what is stored, newest last\ngg resource backup  shop/db     take one now — do this before a risky migration\n```\n\n**Any postgres backup restores into any postgres.** A dump carries its\nextensions and every postgres has every one available, so a database that used\n`vector` or `postgis` comes back with them; the restored resource's\n`extensions` are read back from the database. There is nothing to ask for\nbefore restoring.\n\n`gg resource backup` reads the database and writes an object; it is safe at any\ntime and the nightly schedule keeps running regardless.\n\n**A restore creates a NEW resource — it never overwrites an existing one.** That\nis the platform's rule, not a convention: the name you give must not exist yet,\nand the platform creates the resource itself, which is exactly why a restore\nneeds no human approval and can be reached for at three in the morning.\n\n```\ngg resource restore shop/db2 --source db   new resource, filled from db's newest dump\ngg deps add shop/api db2                   hands api DB2_URL and the rest\ngg deps rm  shop/api db                    and stop it reading the old one\n                                           (this one needs a human's click)\ngg destroy  shop/db                        once everything reads from db2 — the only\n                                           step that destroys data, and the only one\n                                           that asks a human\n```\n\n- **The variables change with the name.** `db2` publishes `DB2_URL`, not\n  `DB_URL`, so an application reading `DB_URL` finds nothing after the `deps rm`.\n  Either name the new resource what the old one was called — possible only once\n  the old one is destroyed — or expect to touch the application. This is the one\n  place the per-resource naming costs something, and it is worth knowing before\n  three in the morning.\n- The old resource **may already be destroyed** when you restore: its backups\n  outlive it by fourteen days and `--source db` still finds them.\n- `--backup <key>` from `gg resource backups` restores an exact point instead of\n  the newest.\n- **The platform does the restore, not the command.** It creates the new\n  resource as the backup's type — recorded with every backup, so there is\n  nothing to say even for a destroyed source — then starts it and pours the data\n  in on its own. `gg resource restore` waits and prints each step by default;\n  stopping it stops nothing. With `--no-wait` it returns at once, and `gg status`\n  shows the restore under the resource until it is done, or why it failed.\n  **Do not `deps add` anything to the new resource before it is done.**\n- A failed restore leaves a resource holding nothing worth keeping: destroy it\n  and restore again under a new name once the cause is fixed.\n- `gg resource backups shop/db` works on a destroyed resource too, and shows what\n  it left.\n\n### Anything we do not have a type for\n\nFour types will never cover everything. Run it as an ordinary service with a\nvolume:\n\n```\ngg registry copy shop/clickhouse clickhouse/clickhouse-server\ngg deploy shop/analytics:8123 clickhouse --volume /var/lib/clickhouse --volume-size 50\ngg deps add shop/api analytics\n```\n\nEverything else behaves the same way: a private address by name, a volume that\nsurvives restarts, and the same refusal to delete it while something still needs\nit. The only difference is who decides — for a resource the platform picks the\nimage, the version and the port and carries them; here you pick them, and\nupgrades, tuning and consequences are yours.\n\n**If a type exists, use the resource. If it does not, this is the normal path,\nnot a workaround.** Gagarin has no type for ClickHouse, Cassandra, DuckDB or a\ndocument store, and that is not an error.\n\nNever write a one-line Dockerfile that only says `FROM` in order to get an image\nin. `gg registry copy` is the same thing, done properly, and it copies every\narchitecture the source published rather than whatever your laptop cached.\n\n## Recipes: a project other people can deploy\n\nA recipe is a published snapshot of a project: its services, jobs, resources,\ndependencies and sizes. Anyone who has the recipe's 8-character id can deploy it\ninto a **new** project of their own. It is never installed into an existing\nproject. Its deploy page is `https://my.gagarin.cloud/deploy/<recipe-id>`, and\na publisher can put this badge in a README:\n\n```\n[![Deploy to Gagarin](https://gagarin.cloud/deploy-button.svg)](https://my.gagarin.cloud/deploy/<id>)\n```\n\nRecipes are not part of `.gagarin.json`. That file still only names the project.\n\n### Publishing: `gg recipe snap`\n\n```\ngg recipe snap shop --dry-run                       what would be published, and the floor\ngg recipe snap shop                                 publish, at the floor version\ngg recipe snap shop --version 1.2.0 --as shop-kit   pick the version and the name\ngg recipe snap shop --source https://github.com/acme/shop --notes \"faster checkout\"\n```\n\nOnly the project's owner can snap. **Run `--dry-run` first**, and show the user\nthe floor and what will be published before you publish. A recipe version is\nimmutable once it exists.\n\n**Env in a recipe never holds secrets.** Plain env on a service or a job is\ncopied as it is, so anything secret-shaped must not be there. Secrets belong in\nan `external` resource. A recipe keeps the external's variable names and never\ntheir values, and each name becomes an input the deployer supplies. If snap\nanswers `env_looks_secret`, it names the variables:\n\n```\ngg resource add shop/stripe external --env-file stripe.env\ngg deps add shop/api stripe\ngg deploy shop/api:8080 api:v3                      restate the env without them\ngg recipe snap shop                                 and snap again\n```\n\nDo not rename a variable to get past the check. Move the value to an external.\n\n### The floor\n\nEach snap has a lowest allowed version, worked out from the previous one:\n\n- a removal, a rename, a volume change or a type change forces a **major**\n- an addition, or a bigger monthly bill, forces at least a **minor**\n- anything else is free, and may be a patch\n\nOmit `--version` to take the floor. A version below it is refused\n`version_below_floor`, and the dry run prints the reasons.\n\n### Reading\n\n```\ngg recipe show a1b2c3d4                  the graph, inputs, monthly cost, deploy URL\ngg recipe show a1b2c3d4@1.2.0            one version\ngg recipe show a1b2c3d4 --format json    the manifest, for reading by a program\ngg recipe ls                             the recipes this account published\n```\n\n`show` works on any recipe id, not only your own. Read it before you install,\nand tell the user what it will cost and which inputs it wants.\n\n### Installing: `gg recipe install`\n\n```\ngg recipe install a1b2c3d4 shop --input stripe=stripe.env\ngg recipe install a1b2c3d4@1.2.0 shop --input stripe=stripe.env --input mail=mail.env\n```\n\nAlways a new project: `NEW_PROJECT` must not exist yet. Pass one `--input\nNAME=FILE` for every input the recipe declares, which `gg recipe show` lists.\nEach file is an env file. **Never put a value on the command line.** Ask the\nhuman for the values, write them to the file, make sure the file is\ngitignored, and delete it when the install finishes. gg refuses up front when a\ndeclared input has no `--input`, and it never prints what a file holds. The\ninstall copies the images into the new project, then starts everything. It ends\nwith the project's status, so follow the usual rule and read it before you\npromise a URL.\n\n### Updating\n\n```\ngg recipe diff shop                      what the newest version would change\ngg recipe diff shop --to 1.3.0\ngg recipe update shop                    apply it\ngg recipe update shop --to 1.3.0 --input mail=mail.env\ngg recipe update shop --force            overwrite what was changed by hand\n```\n\nAn update is the patch between two versions, not a reinstall. Always `diff`\nfirst and tell the user what changes. A new input needs its `--input` file, the\nsame as an install. An update that **removes** something needs a human's\napproval, like any destroy. If the project was changed by hand where the patch\nalso changes it, the update refuses with a conflict. Ask the user before you\npass `--force`, because it overwrites their change.\n\n### Removing\n\n```\ngg recipe rm a1b2c3d4@1.2.0              one version\ngg recipe rm a1b2c3d4                    the recipe, and every version\n```\n\nThis needs a human's approval, like every destroy: follow \"Destroying things\".\nProjects already installed from the recipe keep running.\n\n## Addresses\n\nA service is private until it is given an address, and one command gives it\neither kind:\n\n```\ngg domain add shop/web                     an address gagarin generates\ngg domain add shop/web shop.example.com    a name the user owns, as well\ngg domain ls  shop                         every address, and who each is waiting on\n```\n\nThe generated one is idempotent and instant: Gagarin holds the wildcard record\nand the wildcard certificate for the project's cluster, so there is nothing to coordinate and nobody to\nwait for.\n\n**A name the user owns is two steps, and only the first is Gagarin's.** The\ncommand makes the service answer for the name; making the name *resolve* here is\na DNS record the user creates at their registrar, and Gagarin cannot do it for\nthem. The command prints the exact record — pass it on verbatim rather than\nparaphrasing it.\n\n**Nothing is served over HTTPS on that name until the record exists.** Let's\nEncrypt proves control by fetching the domain over the internet, so a certificate\ncannot be ordered before DNS points here. That is the normal first state, not a\nfault: do not retry the command hoping it resolves, because the missing piece is\non their side. `gg status` says which of the two of you it is waiting on:\n\n| reading | who acts |\n|---|---|\n| waiting for DNS | **them** — the record does not exist at the zone's own nameservers |\n| DNS points elsewhere | **them** — it resolves, but not to Gagarin |\n| waiting for cache revalidation | **nobody** — the record is right; a resolver is still holding its old answer, and it clears within the zone's negative TTL |\n| issuing certificate | Gagarin — nothing for them to do |\n| ok | nobody |\n\nGagarin orders the certificate only once the zone's own nameservers point the name\nhere, so claiming a name before creating the record is harmless. On `waiting for\ncache revalidation`, do not touch the DNS record and do not retry; tell the user it\nclears by itself (often 15–60 minutes) and the certificate follows.\n\nThe generated address only ever reads `ok` or `issuing certificate`. It is never\nwaiting on the user, because there is nothing for them to do about it.\n\n- **A deploy never changes an address**, in either direction. Forgetting a flag\n  would otherwise take a live site down while the owner's DNS still looked right.\n- **Both addresses answer.** A service with a custom domain keeps its generated\n  one, so existing links do not break and there is something to test against\n  while DNS propagates.\n- **A custom domain brings the generated one with it.** Claiming a name for a\n  private service makes it public in the same call. Say out loud that you are\n  putting it on the internet.\n- **One domain, one service, across all of Gagarin.** A name somebody else holds\n  is refused, and the refusal does not say who holds it.\n- **A subdomain is told a CNAME to the cluster's name**, such as\n  `CNAME fr-par-1.apps.gagarin.cloud`, not to the old shared `apps.gagarin.cloud`.\n  Pass on the target the command prints; it depends on the project's cluster.\n- **An apex domain gets an A record, not a CNAME** — DNS does not permit a CNAME\n  at an apex. The command prints the right one; do not \"correct\" it.\n\n### Taking an address away\n\n```\ngg domain rm shop/web shop.example.com    release a name they own\ngg domain rm shop/web                     make the service private again\n```\n\n**Both need a human's approval, every time** — the same emailed click `gg\ndestroy` and `gg deps rm` need. This is destructive in the way deleting something is: what breaks\nis invisible from the terminal and obvious to whoever was using the address. Do\nnot run either unless the user asked for it in those words.\n\nReleasing the generated address while a custom name is still declared is refused\n(`domain_attached`) — that would leave their DNS pointing at a host Gagarin no\nlonger serves. Release the custom name first.\n\n## Reading state\n\n`gg status <project>` reports desired state and actual cluster state side by\nside. Trust it over your own memory of what you deployed: it reads the cluster,\nnot just the database.\n\n```\nproject shop  (id 7f3a9c2e)  fr-par-1\n\n     SERVICE  KIND      SIZE  READY  PORT  REACHES      IMAGE\n  ●  web      service   s     1/1    8080  api          web:1757030400\n  ●  └ https://web-7f3a9c2e.fr-par-1.apps.gagarin.cloud\n  ●  api      service   m     1/1    4000  db, openai◆  api:1757030112\n  ●  db       postgres  m     1/1    5432  —            postgres:17\n  ◆  openai   external  —     —      —     —            —\n  ◇  files    s3        —     —      —     —            —\n\n  ● running   ◆ external (runs nothing; declaring it grants its variables, not egress)\n  ◇ bucket (runs nothing; reached over the internet, so declaring it grants its key, not a network path)\n  $0.412 today so far\n```\n\nWhat to read, in the order it matters:\n\n1. **Lines beginning `!`, when there are any, come before the table because they\n   change what the table means.** There are two:\n   - **\"this project is suspended and nothing is running: …\"** — every service\n     shows `◌` and `0/0`, and writes are refused with `project_suspended`. If the\n     reason is credit, the user fixes it at https://my.gagarin.cloud/billing and\n     services restart by themselves within a few minutes. Anything else is a\n     decision Gagarin made, and only support can lift it — do not tell the user\n     to add credit, because it will not help. **Nothing has been deleted**: the\n     data, the addresses and the certificates are all still there.\n   - **\"the reconciler last ran … ago\"** — Gagarin reporting on itself. The rows\n     are still an accurate reading of the cluster, but nothing is closing the gap\n     between them and what was asked for. Tell the user; there is nothing an\n     agent can do from here.\n2. **The state mark.**\n   - `●` **running** — the cluster is running what was asked for, and something\n     answers on the declared port.\n   - `◐` **starting** — in flight: pulling, booting, waiting on an ingress. The\n     cluster has not given up and neither should you.\n   - `○` **failing** — either nothing is in the cluster at all, or Kubernetes has\n     stopped calling this a rollout in progress. Waiting will not fix it.\n   - `◌` **stopped** — the project is suspended. See the `!` line.\n   - `◆` **external** — runs nothing, so it has no state to be in.\n   - `◇` **bucket** — an `s3`: runs nothing either, and its edges read `files◇`.\n   - `✓` **done** — a job whose latest run finished with exit code 0. A job\n     whose run failed is `○`, and the line under the table gives its exit code.\n   - `◷` **scheduled** — a scheduled job that has not fired yet. Waiting, not\n     wrong: its line says when it fires next.\n3. **`◐` and `○` print the cluster's own explanation below the table.** Read it\n   before changing anything.\n4. **READY counts pods of the revision you asked for.** A redeploy that will not\n   start reads `0/1` even while the previous version is still serving traffic.\n   That is the honest number: the service is answering, but not with what you\n   shipped. For a job the cell is the latest run's phase instead — `done`,\n   `failed`, `running`, `pending` — its PORT is a dash, and the line under the\n   row says which run, when, how long, the exit code, and for a failed run the\n   cluster's reason: `○  └ run 4 failed 2 minutes ago after 3s, exit 2: the\n   container exited with code 2`. A scheduled job's cell also carries its\n   schedule (`⏱ 0 3 * * *`), and its line ends with when it fires next\n   (`· next in 21h`) or that the schedule is suspended with the project. A scheduled firing whose TTL\n   passed still shows, ending \"(removed after its ttl)\"; `gg logs` keeps its\n   output. A one-shot job past its TTL is not listed at all.\n5. **Addresses hang under their service**, marked `●` when there is nothing left\n   to do and `○` with who is holding it up when there is. An address that is fine\n   says nothing more than its own URL.\n6. **KIND and VOLUME columns appear only when the project has something to put in\n   them**; SIZE is always there.\n7. **The last line is the day's accrued cost**, in thousandths of a dollar.\n\nOther readers:\n\n```\ngg projects                 every project you can reach, its id, and your role\ngg logs shop/web            recent logs; needs a running pod (logs_unavailable if not).\n                            For a job: what its latest run wrote\ngg history shop/web         every deploy, newest first, the live one marked →\ngg deps ls shop/web         what it may reach\ngg domain ls shop           every address and its state\ngg creds                    every credential, the one you are using marked *\n```\n\nWhen somebody wants to understand how their services fit together, point them at\nthe project's page on https://my.gagarin.cloud — its right half is a live\ndependency graph. That is for the human; read the plain output yourself.\n\nDescribe services at the altitude Gagarin does: \"web is public on port 8080 at\n<url>; worker is private.\" Give every address a service answers on, not just one.\nDo not introduce Kubernetes vocabulary — namespaces, ingresses, pods and service\naccounts are not part of this model, and mentioning them is a regression.\n\n## Undoing a deploy\n\n```\ngg history  shop/web          revision numbers, images, when, and who —\n                              an image tagged with a short hash is that commit\ngg rollback shop/web          put the previous deploy back\ngg rollback shop/web --to 3   a particular revision\ngg rollback shop/config       put an external's previous values back\n```\n\n- **A rollback is a deploy.** It goes through the same write gate and is recorded\n  as a *new* revision naming the one it restored. Nothing leaves the history, so\n  changing your mind is another rollback rather than a lost record.\n- **It restores the image and the environment**, exactly as that revision had\n  them. A variable added since is gone afterwards.\n- **It does not restore the dependency graph, the domain or the volume.** Those\n  are standing declarations about the shape of the project rather than parts of\n  the artifact, and putting yesterday's image back says nothing about them.\n- **It never restores an old password.** Resource variables come from the graph\n  at pod-start, not from the revision.\n- **It is refused across a change of volume** (`volume_immutable`). Deploy the\n  configuration you want instead.\n\nPrefer a rollback to a corrective deploy when something you just shipped is\nbroken and you do not yet know why: one call, a state that provably ran, and the\nevidence left intact for afterwards.\n\n## Alerts\n\nA project can tell its members when something breaks. Alerts are Web Push\nnotifications from the console (https://my.gagarin.cloud), which is also a PWA.\nEach member opts in per project for themselves, viewers included, and the\nnotifications go only to that member's own devices. There is no topic, server\nor token to set up.\n\n**A human turns alerts on, in the console.** The project's Alerts tab,\n`https://my.gagarin.cloud/projects/P/alerts`, has one switch, \"Notify me about\nthis project\", which allows notifications on that device and opts the member in\nat once, and sends a test from the same page. Point the human there, on the\nphone they want the push on. Turning the switch off there opts them out.\n\nThere is no gg command for alerts (`gg metrics` is for the numbers, below):\ntalking the human through that page is your part. With the MCP server connected, `alerts` says whether the caller is opted\nin, how many devices they have, and the last few notifications; `test_alerts`\nsends a test once they say it is on; each takes only the project. Opting in is\nper member, so one member turning alerts on does not turn them on for anyone\nelse.\n\n**An agent cannot add a device.** A device exists only once a human allows\nnotifications in a browser, at `https://my.gagarin.cloud/projects/P/alerts`. On\nan iPhone the app must first be added to the Home Screen (Share, then Add to\nHome Screen) and opened from there, or the browser will not offer push at all.\nIf the human has no device yet, hand them that page. Then they hear\nwhen a service has been down for three minutes, when a deploy will not start\n(the previous revision keeps serving), and when a container crashes and\nrestarts, once when it starts and once when it ends, never on repeat. The\nconsole keeps a 30-day feed of these notifications. Four more come from the\nmetrics, each also once when it starts and once when it resolves: memory at 80%\nof its limit or more for 5 minutes (resolves under 75%); CPU at 80% of its\nlimit or more for 10 minutes (resolves under 70%); a volume 85% full (resolves\nunder 80%); and 5% or more of requests answered with 5xx over 5 minutes, with\nat least 20 requests (resolves under 2%). Tapping one of these opens that\nservice's graphs. They are part of the same fixed set. There are no rules or\nthresholds to choose. Offer alerts after a first deploy that a human cares\nabout; do not turn them on without asking, because the notifications go to somebody.\n\nThe old ntfy alerts are gone: `--server`, `--topic` and `--token` no longer\nexist, and sending them is refused with `ntfy_removed`.\n\n## Metrics\n\nEvery cluster keeps a metrics store, 30 days deep. For each service, and each\nresource (postgres, qdrant, iggy, rabbitmq, valkey), it holds CPU used against\nits limit (cores), memory against its limit (bytes), volume disk used against\nits size, CPU throttling (the share of periods), and network in and out\n(bytes/s); for a service with a public address, also requests/s, the share of\n5xx and p95 latency. Windows are `1h`, `24h`, `7d` and `30d`. A figure that was\nnot measured is `null`: a service that just started, no volume, no address.\nFigures appear a minute or two after a service starts.\n\n- `gg metrics PROJECT` is a table of every service now: kind, CPU, memory,\n  disk, throttling and network, plus req/s, 5xx and p95 for the public ones.\n- `gg metrics PROJECT/SVC [--window 1h|24h|7d|30d]` gives the last value and\n  when it was taken, average, peak and limit for each figure over the window.\n- In MCP, `metrics` takes `{project, service?, window?}`: project-wide figures\n  now, or one service's last (with `last_at`)/avg/peak/limit per series over a\n  window. `window` without `service` is refused `window_needs_service`.\n- The console has a **Metrics** tab, `https://my.gagarin.cloud/projects/<id>/metrics`\n  (`?service=NAME&window=24h`).\n\nUse it to answer \"why is it slow\", \"is it running out of memory\" and \"is the\ndisk filling\" from numbers rather than a guess. `gg status` stays the answer to\n\"is it up\". `metrics_unavailable` means the cluster has no metrics store or it\ndid not answer: retry in a minute.\n\n## Sharing a project\n\nA project has exactly one **owner** — the account that pays for it — plus any\nnumber of editors and viewers.\n\n```\ngg members shop                     who can reach it, and as what\ngg share shop teammate@example.com  add an editor (the default)\ngg share shop them@example.com --role viewer\ngg unshare shop them@example.com\n```\n\nAn **editor** operates the project — deploy, delete individual services, manage\nthe roster — without paying for it. A **viewer** reads status, logs and the\nmember list, and nothing else. **Destroying a project is the owner's alone**:\nthat takes its data and its URL with it, and only the account paying can decide.\nOwnership is not on this list because it is the bill, not a role: it is not\ngranted here, it is offered and accepted — see below.\n\n- `gg share` with no `--role` grants **editor**, which can deploy over whatever\n  is running. If the user asked for \"read access\" or \"let them look at the logs\",\n  pass `--role viewer`.\n- Sharing with somebody who has never used Gagarin is allowed — the access waits\n  for them and lands the moment they sign in with a GitHub or Google account\n  whose verified email is that address. **Nothing is emailed to them**, so tell\n  the user to let them know; they get in by running `gg login` and approving it,\n  as in \"Getting access\".\n- **Ask before sharing.** Access to a project is the user's to give, not yours to\n  infer from a name in the conversation.\n\n## Handing a project over\n\nSharing gives access away. `gg transfer` gives away the **bill** — who pays for\nthe project from that moment on.\n\n```\ngg share shop them@example.com       first: they must already be a member\ngg transfer shop them@example.com    offer it; nothing changes yet\ngg transfer shop --withdraw          take the offer back\ngg members shop                      shows an offer that is standing\n```\n\nIt is an offer, never an assignment, and both halves need a human:\n\n1. The **owner** runs `gg transfer` and gets `approval_required` — they click a\n   button in their own inbox, signed in to Gagarin, and you run the same command\n   again. This is the\n   same human gate `gg destroy` uses, for the same reason: a handover cannot be\n   undone by the person who started it.\n2. The **recipient** gets an email and presses a button. Until they do, nothing\n   has changed and `gg members` still shows the old owner. **Tell the user this**\n   — a transfer that is \"done\" from the CLI is a transfer that has not happened.\n\nWhat happens when they accept: the project keeps its id, services, addresses,\ndata and history — **nothing restarts**. Usage is billed to the new owner from\nthat moment, and to the old owner up to it. The **previous owner becomes an\neditor**, so they keep operating it and stop paying for it; the new owner can\n`gg unshare` them like anyone else.\n\n- **Only the owner can offer**, and only to somebody already on the roster. Share\n  first.\n- If the recipient already has a project by that name, pass `--as NAME` — names\n  are unique within an account, and this is what the project is called in theirs.\n- The recipient's account has to be able to carry it: not suspended, has a card\n  or a balance, and under their project limit. The refusal comes back to the\n  owner with the fix in it — those are things the two of them sort out before\n  anybody clicks.\n- `gg unshare` on the person an offer was made to **withdraws the offer too** —\n  an offer only ever goes to a member, so taking the access away takes the offer\n  with it.\n- **Never offer a project the user has not explicitly asked you to hand over.**\n  This is the one command that ends with them not paying for something they no\n  longer own, and no amount of context makes it inferable.\n\n## Diagnosing\n\nStart from the symptom, not from the logs.\n\n| symptom | first suspect | what to run |\n|---|---|---|\n| a service never becomes ready | the declared port; the app binds elsewhere or on `127.0.0.1` | `gg status`, then redeploy on the port the app really binds |\n| `ImagePullBackOff` | the image is not there — a copy that never finished, or a tag that does not exist | `gg history`, then push or copy the image again |\n| the container starts and exits | a missing environment variable, or a crash | `gg logs shop/web` |\n| killed with no log output | out of memory | `gg status` names the size to move to |\n| one service hangs calling another | a missing `gg deps` edge — an undeclared call is dropped, not refused | `gg deps ls shop/api`, or the REACHES column |\n| a database driver times out | the same, or the app is not reading `<NAME>_URL` | `gg deps ls`, then `gg resource secrets` to see what it should hold |\n| you need to look inside the database itself | it is not on the internet, by design | `gg connect shop/db`, then psql or redis-cli against the printed URL |\n| an SMTP connection hangs | ports 25, 465 and 587 are blocked platform-wide | use a provider's HTTPS API; nothing to fix here |\n| a custom domain serves no HTTPS | DNS does not point here yet | `gg domain ls`; the record is the user's to create |\n| everything shows `◌` and `0/0` | the project is suspended | read the `!` line above the table |\n| `docker push` returns 401 in CI | docker was never logged in | `gg registry login` |\n\n**\"nothing is listening on port N\" is the common one**, and it is almost always\nthe port rather than the app. Gagarin asks the container every few seconds\nwhether anything accepts a connection on the port you declared, so a service that\nboots perfectly well and listens somewhere else never becomes ready. Many\nframeworks also default to `127.0.0.1`, which nothing outside the container can\nreach — they need `0.0.0.0`.\n\n**\"the previous revision is still serving\"** on a redeploy means the old version\nis up and answering. The user is not down. Fix the new revision and ship again;\ndo not tear anything down first.\n\n**Out of memory names its own fix**, in `gg status`:\n\n```\nthe container ran out of memory and was killed (it exceeded the 1Gi ceiling of\nsize s); try --size m, which gets 2Gi\n```\n\nRedeploy at the size it names. Do not retry unchanged — it will be killed again —\nand do not go hunting in the logs first, because a process the kernel killed for\nusing too much memory usually writes nothing about it. This is the one failure\nyou can resolve without asking the user anything, so resolve it.\n\nDo not poll in a tight loop, and do not tell the user something is live because a\ncommand exited zero.\n\n## Error codes\n\ngg prints failures as `[code] message`, usually with a `hint:` line under it.\n**Branch on the code.** The message is for the human.\n\n**Access and credentials**\n\n| code | what to do |\n|---|---|\n| `unauthorized` | this machine has no usable credential — run `gg whoami`, then \"Getting access\". Never ask the user for a token |\n| `insufficient_scope` | this credential does not carry that right; a browser session cannot deploy. Deploy from the CLI — the dashboard has no deploy button on purpose |\n| `cannot_delegate` | a minted credential tried to mint another. Mint it from the machine a human approved |\n| `name_required` | `gg creds create` with no `--name`. Name it after where it will live |\n| `invalid_expiry` | `--expires` outside 1–365 days. There is no never; omit it for 90 |\n| `name_too_long` | over 120 characters, and it appears in a list. Shorten it |\n| `approval_required` | a human must approve a deletion, a released address, a withdrawn dependency, or an ownership offer. The button is in their email, and it asks them to sign in first if they are not. Tell the user, pass on the code, wait, retry the same command. One click covers fifteen minutes, so a sequence of these needs one approval, not several |\n| `authorization_pending` | nobody has approved the `gg login` request yet. Relay the link again if needed; run `gg login` again once the user says they approved |\n| `expired_token` | the `gg login` request lived fifteen minutes and nobody approved it. Run it again and pass on the new link |\n| `access_denied` | the user declined `gg login` on the page. Ask them before running it again |\n| `github_account_too_new` | the user's GitHub account is under 30 days old. The `gg login` request is still good: they open the same link, choose Continue with Google, approve, and you run `gg login` again |\n| `invalid_email` | the address given to `gg share` or `gg transfer` is not one. Ask the user again; do not guess |\n\n**Projects and roles**\n\n| code | what to do |\n|---|---|\n| `project_not_found` | no such project, **or** you cannot reach it. `gg projects` lists what you can; `gg init` creates one; otherwise ask for a `gg share` |\n| `project_suspended` | the project accepts no writes; reads still work. Out of credit: the user adds some at https://my.gagarin.cloud/billing and it restarts itself. Anything else: only support can lift it — tell the user and stop |\n| `project_limit` | destroy one that is no longer needed, or the user writes to support@mail.gagarin.cloud |\n| `project_exists` | you already have one by that name. Names need only be unique within your account |\n| `invalid_name` | lowercase letters, digits, hyphens; start with a letter; 2–30 characters |\n| `insufficient_role` | you are a viewer here. Ask the owner or an editor for edit access; do not retry |\n| `owner_only` | only the paying account may do this. Tell the user to run it themselves; nobody can grant it |\n| `invalid_role` | roles are `editor` and `viewer`; `owner` is the account that pays |\n| `owner_not_a_member` | that address already owns the project; nothing to do |\n| `member_not_found` | `gg members <project>` shows who has access |\n\n**Handing a project over**\n\n| code | what to do |\n|---|---|\n| `not_a_member` | share it first: `gg share P EMAIL`, then offer it |\n| `already_owner` | they already own it; nothing to do |\n| `name_taken_there` | they have a project by that name. Re-run with `--as NAME` |\n| `recipient_suspended` | their account is stopped; they add credit, then you offer again |\n| `recipient_cannot_pay` | no card and no balance there; the project would be suspended on arrival. They fix it at https://my.gagarin.cloud/billing |\n| `recipient_project_limit` | their account is full; they destroy one, or write to support@mail.gagarin.cloud |\n| `no_offer` | nothing is pending. If it was accepted, the project is theirs and only they can offer it back |\n| `project_suspended` on a transfer | a project suspended in its own right cannot change hands. Only support can lift that |\n\n**Alerts**\n\n| code | what to do |\n|---|---|\n| `alerts_off` | `test_alerts` before alerts are on. The human turns them on with the switch at https://my.gagarin.cloud/projects/P/alerts |\n| `ntfy_removed` | alerts no longer go to ntfy; `server`, `topic` and `token` are refused. The human turns alerts on in the console |\n| `no_devices` | `test_alerts` and the caller has no device. The human allows notifications at https://my.gagarin.cloud/projects/P/alerts (iPhone: add the app to the Home Screen first) |\n| `invalid_subscription` | the browser's push subscription was refused (not https, not a known push service, bad keys). The human re-enables notifications in the console |\n| `push_unconfigured` | the platform has no push keys yet. Nothing to fix on your side; tell the user |\n\n**Metrics**\n\n| code | what to do |\n|---|---|\n| `metrics_unavailable` | 503: the cluster has no metrics store, or it did not answer. Retry in a minute; `gg status` still shows what is running |\n| `no_such_service` | 404 on `gg metrics P/SVC` or `metrics`: that name is not a service here. `gg status` lists them |\n\n**Services, images and deploys**\n\n| code | what to do |\n|---|---|\n| `image_required` | `gg push` one first, or use `gg ship` |\n| `docker_not_installed` | from gg itself, before any request: there is no `docker` (or, for `gg registry copy`, no `buildx`). Ask your human to install Docker Desktop, OrbStack or colima (Docker Engine on Linux). An image already in the registry needs no docker: `gg deploy` it |\n| `docker_not_running` | docker is installed but its daemon did not answer; the message names the socket. Ask your human to start it and run `gg ship` again once `docker info` succeeds |\n| `docker_permission_denied` | this user cannot reach the daemon (Linux). Ask your human to add the user to the `docker` group and log in again. Never run gg with `sudo` |\n| `image_not_yours` | the image is not in this project's registry space. Build or push into this project, or `gg registry copy` it in |\n| `invalid_digest` | pass what `docker push` reported, or leave it out |\n| `invalid_port` | set the port the container actually listens on |\n| `invalid_timeout` | `timeout_seconds` outside 1–3600. Give 1–3600 or leave it out |\n| `service_has_no_timeout` | `timeout_seconds` was given on a service rather than a job. Drop it; a service runs until it is replaced |\n| `invalid_ttl` | `ttl_seconds` outside 60–28800. Give 60–28800 or leave it out to keep the current one (28800 for a new job) |\n| `service_has_no_ttl` | `ttl_seconds` was given on a service rather than a job. Drop it; a service runs until it is replaced, only a job's finished runs expire |\n| `invalid_kind` | `kind` is absent for a service or `job` for a job; nothing else exists |\n| `job_has_no_port` / `job_has_no_volume` | drop the field: a job listens on nothing and keeps nothing. Durable data goes in a resource it reaches |\n| `not_a_job` | that name is a service; a job needs a name of its own |\n| `invalid_schedule` | five cron fields like `\"0 3 * * *\"`, or `@daily` and the like. Not `@every`, no `CRON_TZ=` — the zone is `--tz`. An empty one is refused too: a schedule cannot be removed, so destroy the job to stop it |\n| `invalid_time_zone` | an IANA name like `Europe/Berlin` or `UTC` — or a `--tz` given to a job with no schedule |\n| `service_has_no_schedule` | `--schedule`/`--tz` reached a service. A schedule is a job's: `gg run` |\n| `job_running` | a one-shot job was given a schedule while its run is going. Wait for it to end (`gg status`), or destroy the job |\n| `invalid_volume` | an absolute path inside the container, e.g. `/var/lib/postgresql/data` |\n| `volume_immutable` | a volume is set once and never moves or resizes. Keep it, or destroy the service and deploy again — which throws the data away |\n| `invalid_size` | sizes are `s`, `m`, `l`; the message names the account's cap |\n| `no_such_revision` | `gg history` lists the ones it had |\n| `nothing_to_roll_back_to` | deployed only once. Not a bad call, just nothing to do |\n| `not_a_service` | that name is a resource or a job — you tried to deploy a service over it, give it an address, or roll back a managed resource whose credentials Gagarin mints, s3 included (an external can be rolled back) |\n| `not_a_resource` | that name is a service. `gg status` shows which is which |\n\n**The graph**\n\n| code | what to do |\n|---|---|\n| `invalid_needs` / `invalid_deps` | a blank name, a service naming itself, or a job named as something to reach — a job listens on nothing. Correct them; `gg deps ls` shows what is declared |\n| `no_such_service` | a name in `gg deps add` or `--deps` is neither a service nor a resource here. `gg status` lists them; create it first |\n| `service_in_use` | something still declares it needs this. The refusal names what; `gg deps rm` that edge first — which needs its own approval, though the same click covers the destroy that follows |\n\n**Resources**\n\n| code | what to do |\n|---|---|\n| `no_such_resource` | `gg status <project>` lists what it has |\n| `unknown_resource_type` | `postgres`, `qdrant`, `valkey`, `iggy`, `rabbitmq`, `s3` or `external` |\n| `wrong_resource_type` | another type already holds that name. Destroy it — which throws its data away — or pick another name |\n| `invalid_storage` | 1 to 100 GB |\n| `no_extensions` | only a `postgres` takes extensions: drop `--ext` |\n| `unknown_extension` | not in the catalogue; the hint lists every name offered. `pgvector` is called `vector`. timescaledb is not offered |\n| `extensions_failed` | HTTP 409: postgres refused — usually dropping an extension a column still uses, or one whose own tables still hold the user's rows (pg_cron's jobs, say). The message is postgres's own reason. **Nothing changed**; remove what is in the way, then restate the set |\n| `no_storage` | this type has no volume (valkey, s3): drop `--storage` |\n| `no_size` | an external or an s3 runs nothing: drop `--size` |\n| `invalid_env` | write `API_KEY`, not `OPENAI_API_KEY` — the prefix is the resource's name |\n| `already_exists` | restating an external. `gg resource rotate` is how values change |\n| `env_required` | an external's values are the user's; pass `--set K=V` for one of them, `--env-file` for all |\n| `conflicting_env` | `--env`/`--env-file` replace the bundle and `--set`/`--unset` amend it: use one or the other |\n| `no_such_key` | that external does not publish the key named in `--unset`. `gg resource secrets` lists what it does — and the name goes in without the resource's prefix |\n| `no_env` | this type mints its own credentials (s3 included), so there is nothing to pass or amend; `gg resource secrets` reads them |\n| `object_storage_unavailable` | HTTP 501: this Gagarin has no object storage configured, so no `s3`. Report it to the user |\n| `not_a_bucket` | HTTP 409: only an `s3` can be made public. A service gets an address with `gg domain add` |\n| `publish_failed` | HTTP 502: **nothing changed** — retry `gg resource public` or `private` |\n| `rotate_failed` | **nothing changed** — the old credential still works. Check `gg status` for a resource that is not running, then retry |\n| `cannot_rotate` | no credentials recorded to replace; worth reporting as a bug |\n| `not_tunnelable` | an external runs nothing, so there is nothing to tunnel to; its values are `gg resource secrets` |\n| `tunnel_unavailable` | no running pod on the far end. `gg status` says why, then run `gg connect` again |\n\n**Backups**\n\n| code | what to do |\n|---|---|\n| `backup_unsupported` | only postgres, qdrant and iggy have backups; an s3 bucket is on durable storage but never copied, and a rabbitmq is not backed up at all (declare its queues from application code so a fresh broker can be rebuilt). If losing the data would matter, keep a copy elsewhere |\n| `backup_unconfigured` | this Gagarin runs without a backup bucket. Report it to the user |\n| `restore_name_taken` | a restore creates the resource it fills. Give it a name nothing has yet |\n| `backup_mismatch` | that key belongs to another project. Never restore across projects |\n| `backup_type_mismatch` | that key was written by no type that has backups — check it against `gg resource backups` |\n| `no_backups` | the nightly pass takes the first one; `gg resource backup` takes one now |\n| `backup_list_failed` / `backup_failed` | the resource must be running — check `gg status`, then retry once |\n\n**Addresses**\n\n| code | what to do |\n|---|---|\n| `invalid_domain` | a hostname the user owns: no scheme, no port, no path |\n| `domain_taken` | another service holds that name. The refusal does not say who |\n| `domain_attached` | release the custom names first, or their DNS points at a host that no longer answers |\n\n**The platform itself**\n\n| code | what to do |\n|---|---|\n| `apply_failed` | desired state saved, cluster update failed. Retry the same command; it is idempotent |\n| `cluster_error` / `internal_error` / `eject_failed` | not your call's fault. Report it to the user |\n| `logs_unavailable` | no running pod yet. Check `gg status` first |\n| `timeout` | retry once; if it persists, tell the user |\n| `rate_limited` | wait a minute. Never retry in a tight loop |\n| `body_too_large` | large values belong in a resource, not in a deploy call |\n| `no_such_route` | you are calling the API directly and got the path wrong. Use `gg`, the only supported client |\n\n## Destroying things\n\n```\ngg destroy shop        the project, and everything in it\ngg destroy shop/web    one service\ngg destroy shop/db     one resource, and its data\n```\n\nYou do not say which of the last two a name is; gg asks the platform, which\nalready knows.\n\n**This will be refused the first time, and that is not a bug.** Your credential\ncan deploy but not delete, so destroying anything — and the other irreversible\nacts, `gg domain rm` and `gg deps rm` — needs a human every time the approval\nwindow has lapsed. You get `approval_required`, and Gagarin emails the\naccount owner. Then:\n\n1. Tell the user what you are about to delete, and that you have asked them to\n   approve it by email — the button asks them to sign in to Gagarin first if\n   they are not. Pass on the code from the `fix_hint`.\n2. Wait for them to say they clicked it. Do not poll in a loop.\n3. Run the same command again.\n\n**Ask the user before *requesting* the approval**, not just before retrying — an\napproval email for a deletion they never asked for is alarming. Only a project's\nowner can destroy the project; an editor gets `owner_only`, and no amount of\napproval changes that, because the answer is \"ask the person paying for it\".\n\nIf a deploy went wrong, prefer fixing it with another `gg ship`. Destroying and\nrecreating a project loses its data and its URL.\n\n## Leaving\n\n```\ngg eject shop -o project.yaml\n```\n\nWrites the Kubernetes manifests for the whole project — namespace, and per\nservice its Deployment, Service, Ingress, NetworkPolicy, environment Secret and\nvolume claim. These are not a description of what Gagarin runs; they are the\nobjects it runs, so `kubectl apply -f` on any cluster with an ingress controller\nreproduces the project.\n\nOwner only, because the file holds every service's environment in the clear. It\nis written mode 0600 and you should treat it as a credential.\n\nThree things it deliberately does not contain, all explained in its own header:\nthe **images**, which are still in Gagarin's registry and have to be pulled and\npushed somewhere the user controls; the **registry pull secret**, which is a\nlive credential; and the values from any **external resource**, which are\nthird-party keys somebody else issued, and an **s3 bucket's** keys, which like an\nexternal's work from anywhere — they come out as a `REPLACE-ME` placeholder\nnaming the resource, and the header lists exactly which variables to fill in. Volume\nclaims come back empty — data has to be taken out of the running service.\n\nA minted credential — a database password — *is* in the file, and the asymmetry\nis the point: that password is only a risk against a database in the same file,\nand an export without it does not come up. A third-party key stays live wherever\nthe file ends up. `gg eject shop --with-secrets -o project.yaml` includes them,\nfor a migration happening now into a file that gets deleted; say what that means\nbefore running it with the flag.\n\nOffer this without being defensive when somebody asks what happens if Gagarin\ngoes away. It is a real answer and it is meant to be used.\n\n## Things Gagarin deliberately does not do\n\nNot missing features. Do not attempt them and do not suggest workarounds:\n\n- deploy from a git repository or a git URL\n- read deployment configuration from a file in the repo — `--env-file` supplies\n  values, and is the only file Gagarin will ever read\n- interpolate variables into each other\n- pull images from Docker Hub, GHCR or any registry other than Gagarin's at run\n  time (`gg registry copy` brings one in first)\n- expose Kubernetes, cloud provider or networking primitives\n- open the mail ports\n- infer a project from the current directory, or from anything else —\n  `.gagarin.json` included: you read that, Gagarin never does\n"
Full snapshot data
{
  "description": "Deploy and operate applications on Gagarin with the gg CLI — ship a service from a Dockerfile, provision postgres, qdrant, valkey, iggy, rabbitmq, s3 or external-credential resources, wire what may reach what, put a service on the internet, give CI its own credential, start jobs from an application's own code with the Go, Node or Python SDK, read status and logs, roll back, tear things down, and keep what a session learned in the project's memory. Use whenever the user asks to deploy, host, run or operate an application, or mentions Gagarin or gg. Gagarin runs container images on managed infrastructure; the user never needs to know about Kubernetes, ingress, TLS, or the underlying cloud.",
  "included_files": [],
  "name": "gagarin",
  "skill_md_contents": "---\nname: gagarin\ndescription: Deploy and operate applications on Gagarin with the gg CLI — ship a service from a Dockerfile, provision postgres, qdrant, valkey, iggy, rabbitmq, s3 or external-credential resources, wire what may reach what, put a service on the internet, give CI its own credential, start jobs from an application's own code with the Go, Node or Python SDK, read status and logs, roll back, tear things down, and keep what a session learned in the project's memory. Use whenever the user asks to deploy, host, run or operate an application, or mentions Gagarin or gg. Gagarin runs container images on managed infrastructure; the user never needs to know about Kubernetes, ingress, TLS, or the underlying cloud.\n---\n\n# Deploying with Gagarin\n\nGagarin runs your services. You drive it with the `gg` CLI, a thin wrapper over\nthe Gagarin API. There is exactly one way to change anything: call the API.\nThere is no manifest file and no config file. The one file you will commit is\na note of which project the repository is, and it changes nothing — see \"Which\nproject this repository is\".\n\nEverything below is the whole product. Read \"The ten rules\" and the command map\nfirst; they are the parts that stop you getting it wrong.\n\n## The ten rules\n\n1. **Everything is named for its project.** `shop` is a project; `shop/web` is a\n   service or a resource inside it. Nothing is inferred from the directory you\n   stand in. There is no default project to configure — a command that does not\n   name one is refused with the shape it should have had.\n2. **Every write is asynchronous, except `gg run`.** A command that exits zero\n   recorded a demand; it did not watch it come true. `gg status <project>` reads\n   the cluster and is the only thing that can answer \"is it up\". The one\n   exception is `gg run`, and it is an exception because a run *ends*: it waits,\n   prints what the run wrote, and exits with the script's own code. Nothing else\n   here has an end to wait for.\n3. **Gagarin runs images from its own registry only.** `gg ship` is build, push\n   and deploy fused; the three exist separately for CI. Somebody else's image\n   comes in with `gg registry copy`.\n4. **A service is private until `gg domain add`**, and a deploy can neither give\n   an address nor take one away.\n5. **A private service is default-denied.** Until the *caller* declares\n   `gg deps add`, its calls are dropped — which hangs, rather than failing fast.\n6. **`gg deps add <service> <resource>` opens the route *and* hands over the\n   credentials.** Connecting a database is that one call, not a call plus a\n   deploy.\n7. **A deploy replaces the environment and nothing else.** Dependencies, the\n   domain, the volume, the size and the replica count all survive a deploy that\n   forgets to mention them. Env is the one thing you must restate every time.\n   **A credential never goes in a deploy env.** Env is for plain, single-service\n   config: a port, a log level, a sibling's URL. A database password arrives\n   with `gg deps add`; a third-party key is an `external` resource. See \"What\n   does not go in env\" below.\n   **And no secret value ever passes through your output** — not the\n   terminal, not this chat, not a summary or a commit. A command that takes one\n   reads it from a file (`--env-file`, `--input NAME=FILE`, `\"$(cat FILE)\"`),\n   never `K=value` typed on a command line; a command that produces one writes\n   it to a file or pipes it into the store it is for (`> .env.db`,\n   `| gh secret set`). Reach for `--names` before values. Never ask your human\n   to paste a secret into the chat.\n8. **If a resource type exists, use it** (`postgres`, `qdrant`, `valkey`,\n   `iggy`, `rabbitmq`, `s3`, `external`). If one does not, an ordinary service with a volume is the normal\n   path, not a workaround.\n9. **You can deploy; you cannot destroy.** Deleting anything, taking an address\n   away, withdrawing a dependency with `gg deps rm`, and handing a project over\n   with `gg transfer` all answer `approval_required` and email the account owner\n   a button, every time the approval window has lapsed, which approves only once\n   they are signed in. No flag grants this to an agent. Adding is always free: `gg deps add` and `gg domain add` need nobody.\n10. **Errors are meant to be branched on.** gg prints `[code] message` and\n    usually a `hint:` line. Act on the code, never on the prose.\n\n## Command map\n\n| | |\n|---|---|\n| `gg whoami` | which account this machine acts as — **run this first, always** |\n| `gg login` / `gg login --new` | get this machine access — relay the link and code, then run it again once approved |\n| `gg login --ref CODE` | the same, for a human a friend invited: the code (8 letters and digits) is added to the link so the new account is matched to the friend |\n| `gg creds` / `creds create --name N` / `creds revoke ID` | what has access; mint one for CI; take one away |\n| `gg registry login` | log docker in (CI, or docker installed after gg) |\n| `gg projects` | every project you can reach, and your role on it |\n| `gg init PROJECT` | create a project |\n| `gg ship P/SVC:PORT` | build the current directory, push it, run it — tagged with the commit when the tree is clean |\n| `gg build P/IMAGE[:TAG]` / `gg push P/IMAGE:TAG` / `gg deploy P/SVC:PORT IMAGE:TAG` | the same three steps apart, which is what CI wants |\n| `gg run P/JOB IMAGE:TAG` | run an image to completion as a job, wait, print what it wrote, exit with its code |\n| `gg run P/JOB IMAGE:TAG --schedule \"0 3 * * *\"` | run it on a schedule instead of now; returns at once |\n| the SDK (Go, Node, Python) | start runs from an application's own code — see \"From code: the SDK\" |\n| `gg registry copy P/IMAGE SOURCE` | bring an image you did not build into the project |\n| `gg resource add P/NAME TYPE` | provision postgres, qdrant, valkey, iggy, rabbitmq, s3 or external |\n| `gg resource add P/db postgres --ext vector --ext postgis` | the postgres extensions it should have, one `--ext` each — the whole set, every time you pass it |\n| `gg resource public P/NAME` | make an `s3` bucket listable and readable by anyone; `gg resource private P/NAME` undoes it |\n| `gg resource secrets P/NAME > .env.NAME` | its connection values, into a file for something outside the project — never printed |\n| `gg resource secrets P/NAME --names` | just the variable names it publishes, no values |\n| `gg resource rotate P/NAME` | new credentials, and everything holding them rolls |\n| `gg resource rotate P/NAME --set K=\"$(cat FILE)\"` | change one value an external publishes, keeping the rest; the value comes from a file |\n| `gg rollback P/NAME` | put a previous revision back — a service's deploy, or an external's values |\n| `gg connect P/NAME` | that resource on this machine, for as long as the command runs |\n| `gg resource backup` / `backups` / `restore P/NEW --source OLD` | postgres, qdrant and iggy recovery |\n| `gg deps add P/SVC NAME...` / `deps ls` / `deps rm` | what a service may reach, and whose credentials it holds (`rm` needs a human) |\n| `gg domain add P/SVC [DOMAIN]` / `domain ls P` / `domain rm` | addresses on the internet |\n| `gg status PROJECT` | desired vs actual, addresses, sizes, today's cost |\n| `gg metrics P[/SVC] [--window 1h\\|24h\\|7d\\|30d]` | usage from real numbers: every service now, or one service's last value (and when), average, peak and limit over a window. See Metrics |\n| `gg logs P/SVC` | recent logs |\n| `gg history P/SVC` / `gg rollback P/SVC [--to N]` | every deploy; put one back |\n| alerts (no gg command) | push-notify a member's own devices when a service goes down, runs short of memory, CPU or disk, or answers with 5xx; the human turns it on with the switch at my.gagarin.cloud/projects/P/alerts, which also sends a test. See Alerts |\n| `gg referral` | the account's invite link and code (once it has topped up), and who signed up through it and what it earned; in MCP, `referrals` |\n| `gg members P` / `gg share P EMAIL [--role viewer]` / `gg unshare P EMAIL` | who can reach it |\n| `gg transfer P EMAIL` | offer the project, and its bill, to a member (they accept by email) |\n| `gg destroy P` or `P/NAME` | delete a project, a service or a resource (needs a human) |\n| `gg eject P -o file.yaml` | the Kubernetes manifests, so you can leave (external and s3 keys are placeholders; `--with-secrets` includes them) |\n| `gg recipe snap P [--dry-run]` | publish a project as a recipe, owner only; `--version`, `--as`, `--source`, `--notes`. Dry run first |\n| `gg recipe show RECIPE[@VERSION]` / `recipe ls` | read a recipe (`--format json` for the manifest); the ones this account published |\n| `gg recipe install RECIPE[@VERSION] NEW_PROJECT --input NAME=FILE` | deploy a recipe into a new project, one env file per declared input |\n| `gg recipe diff P` / `recipe update P [--to V] [--force]` | what a newer version changes; apply it (removals need a human) |\n| `gg recipe rm RECIPE[@VERSION]` | delete a recipe or one version (needs a human) |\n| `gg version` | which gg this is |\n\nThree environment variables override the credential file, and exist for CI:\n`GAGARIN_TOKEN` (a credential), `GAGARIN_API` (control plane URL), and\n`GAGARIN_REGISTRY` (registry host). There is nothing else to export.\n\n## First moves in any session\n\nRun `gg whoami` before anything else. It answers three different questions at\nonce, and each has a different next step:\n\n| what happens | what it means | do this |\n|---|---|---|\n| the shell cannot find `gg` | not installed | see \"Installing gg\" — unless you already hold Gagarin MCP tools, in which case call `whoami` there and read \"If you cannot install gg\" for what they cannot do |\n| `[unauthorized]`, or it says there are no credentials | installed, no access | see \"Getting access\" |\n| it names an account | ready | carry on; `gg projects` says what already exists |\n\nThen read `.gagarin.json` at the repository root, if there is one — it says\nwhich project this repository already is — and `gg projects` before assuming a\nproject exists or that you may write to it. A `viewer` role means every deploy\nwill be refused, and that is worth knowing before the attempt rather than\nafter. Project names are unique only within one account, so two rows can share\na name — the id column tells them apart.\n\nOnce per session, before the first build or CI change, check the rest of the\ntoolchain — docker running, git, and `gh` or `glab` signed in — as \"What else\nthe machine should have\" describes. Only a stopped docker blocks a ship.\n\n## Which project this repository is: `.gagarin.json`\n\nGagarin infers nothing from the directory you stand in, and gg stopped guessing\nthe project from the directory's name on purpose: that made a command whose\ntarget was invisible in the command. So the repository carries a note instead,\nat its root, and you are the one who writes it:\n\n```json\n{ \"project\": { \"id\": \"3cnciet6\", \"name\": \"shop\" } }\n```\n\nWrite it once you have created the project or settled on an existing one.\nFive rules, each for a reason:\n\n- **It is a note for the next session, not configuration.** Nothing reads it —\n  not gg, not the MCP server, not the platform. You read it, and then you still\n  name the project in every command and every tool call, so the target stays\n  visible in the command.\n- **Identity only, never desired state.** The one other key is `\"tour\"`, the\n  onboarding steps the human has already been shown (see \"After the first\n  address\"). No services, ports, env or domains:\n  Gagarin holds those, and a copy in the repository would be the stale one. If\n  the file disagrees with `gg projects`, the API is right — fix the file and\n  tell the user.\n- **Prefer the id in calls.** Names are unique only within an account, so a\n  project shared with the user can carry the same name as one of their own;\n  the id cannot collide. Everything that takes a project name takes its id.\n- **Commit it.** The id is already public in every hostname and image path,\n  and a teammate's agent needs it as much as your next session does.\n- **Read it first**, before `gg projects` and before asking. If it is absent\n  and the user named no project, `gg projects` before `gg init` — the project\n  may already exist.\n\nWhere the id comes from: `gg init shop` prints `project shop created (id\n3cnciet6), runs in fr-par-1`; `gg projects` prints a row per project — name, id,\ncluster, role; and the first line of `gg status shop` reads\n`project shop  (id 3cnciet6)  fr-par-1`, ending with the cluster. None of them has a JSON flag; read the column.\n\n**A project has a place.** Each project runs on one cluster, chosen when it is\ncreated and never changed; `gg status` shows it (`fr-par-1`). It is part of the\nproject's generated addresses, `<service>-<project id>.<cluster>.apps.gagarin.cloud`\n(for example `web-3cnciet6.fr-par-1.apps.gagarin.cloud`), so never build one by\nhand from the id alone: read it from `gg status` or `gg domain ls`.\n\n## Project memory\n\nEvery project has a memory: small durable facts about the codebase that the\nnext session would otherwise have to rediscover — an overview, the\narchitecture, a decision and why it went that way, a convention, a gotcha, a\nhowto, a reference, the state of a piece of work. It is reachable only through\nGagarin's MCP server (see \"If you cannot install gg\"); there is no `gg` command\nfor it. Every memory tool takes the project, which is what `.gagarin.json` is\nfor.\n\n| tool | when |\n|---|---|\n| `memory_briefing` | first, when starting work on a project — a primer packed to a token budget |\n| `memory_search` | before exploring the code for something a past session may already have found |\n| `memory_get` / `memory_related` | one memory in full, by id or by key; what it links to |\n| `remember` | one durable fact per memory, in English |\n| `memory_update` | edit, pin, archive, confirm or dispute one |\n| `memory_link` / `memory_unlink` | say that two are related, or that they are not |\n| `memory_review` | housekeeping: likely duplicates, orphans, stale and disputed memories, how close the project is to its cap |\n\n- **Brief yourself before you read the code, and search before you go\n  looking.** That is what it is for. When you know the task, pass `focus` (what\n  you are about to work on) and `paths` (the files you will touch) to\n  `memory_briefing`, and the relevant memories come first.\n- **Give a fact that changes a `key`.** What is deployed now, the current\n  schema version: `remember` it as a `state` memory with a key such as\n  `deploy/current`, and the next `remember` with the same key replaces it and\n  keeps its links. Do not search for the old one and supersede it by hand.\n- **Say when a memory is right or wrong.** One you checked against the code or\n  the cluster gets `confirm: true`, which resets its age. One that proves wrong\n  gets `dispute: true` — it is marked ⚠ and ranks lower until someone confirms,\n  edits or archives it — or a fix, or an archive; do not leave it to mislead the\n  next session. A briefing that counts disputed memories, or a `remember` that\n  warns the project is near its cap, is the cue to call `memory_review` and tidy.\n- **Remember what a future session could not cheaply rediscover**: why a\n  decision went the way it did, a gotcha that cost time, where the deploy\n  differs from the obvious — which port, which Dockerfile quirk, which\n  variables the application insists on. Not what the repository already says,\n  not what is true only of this conversation, and **never a credential or a\n  secret** — not as a value, not in a tag. Title, body and source are\n  encrypted at rest with a key Gagarin holds; tags, file paths and kind are\n  not.\n- **A `remember` refused with a list of near-duplicates** is telling you the\n  fact is already there. Update or link those; do not reword it to get past\n  the check.\n- Reading needs `viewer` on the project; writing needs `editor`. Memories in\n  use are billed at $0.10 per 1,000 a month — a few cents for most projects —\n  and capped per project. Reading is free, and archiving a memory that is no\n  longer true stops it being counted, so archive rather than leave it stale.\n- **If the MCP server is not connected in this session, memory is simply\n  unavailable.** Carry on with `gg`; it is not an error, and nothing else\n  waits on it.\n\n## Installing gg\n\nIf your client is already connected to Gagarin's MCP server you may not need\n`gg` at all — read \"If you cannot install gg\" below first, because the one thing\nit cannot do is build an image, and that is often the whole task.\n\nUse a package manager the machine already has. You may run these yourself:\n\n- macOS: `brew install --cask gagarin-cloud/tap/gg`. It is a **cask**, not a\n  formula, and casks do not work on Linux. If `brew install\n  gagarin-cloud/tap/gg` (no `--cask`) put an older `gg` there, homebrew will not\n  replace one kind with the other on its own: run `brew uninstall gg` once,\n  then install the cask.\n- Windows: `scoop bucket add gagarin https://github.com/gagarin-cloud/scoop-bucket`\n  then `scoop install gagarin/gg`.\n- Any platform with a Go toolchain: `go install github.com/gagarin-cloud/gg@latest`\n\nIf `go install` succeeds but the shell still cannot find `gg`, its bin directory\n(`go env GOPATH`/bin) is not on `PATH`. Say so and let the user fix their\nprofile; do not edit their shell configuration yourself.\n\nWith none of those, the install is the human's to run, not yours: **never\ndownload a script or a binary and run it.** Point them at the one-line installer\non https://gagarin.cloud (a shell one-liner on macOS and Linux, a PowerShell one\non Windows) and say what it does: it verifies the download against the release's\n`checksums.txt`, installs to `~/.local/bin` (Windows: `%LOCALAPPDATA%\\Programs\\gg`,\nadded to their `PATH`) without `sudo`, and never edits a shell profile. On Linux a\n`.deb`, `.rpm` or `.apk` from https://github.com/gagarin-cloud/gg/releases works\ntoo; installing one needs `sudo`, so that is theirs to run as well.\n\nIf `~/.local/bin` is not on `PATH`, the installer prints the `export` line to add.\nCall `gg` by its full path (`~/.local/bin/gg`) for the rest of your session and\ntell your human the line; do not edit their profile yourself.\n\nDo not download from a host you guessed, and do not carry on without `gg`.\n\n`gg` shells out to **docker** for `build`, `push` and `registry copy` (the last\nneeds `buildx`). Nothing else needs it. A machine with no docker can still\ndeploy an image that is already in the registry, roll back, and read state.\n\n**Run `docker info` before the first `gg ship`.** If it fails, ask your human to\nstart Docker Desktop, OrbStack or colima (or install one) and wait until\n`docker info` succeeds; do not start or install it yourself. gg v0.51.0 and\nlater check this before any request and refuse with `docker_not_installed`,\n`docker_not_running` or `docker_permission_denied`, each with the fix in its\nhint. Relay the hint; do not retry until the human says docker is up, and do not\nrun gg with `sudo` to get round a permission error.\n\nThis skill is not part of the binary. It lives in `gagarin-cloud/plugin` and\nis installed separately — in Claude Code, Codex and ChatGPT as a plugin,\nelsewhere with `npx skills add gagarin-cloud/plugin -g`. So it can\nbe newer than the `gg` you are holding: **if a command here is refused as\nunknown, check `gg version` and upgrade before concluding the command does not\nexist.** `gg version` also prints, on stderr, \"gg vX is available (you have vY)\"\nwhen you are behind (`GAGARIN_NO_UPDATE_CHECK=1` silences it). Upgrade with\n`gg upgrade`, which upgrades the way `gg` was installed: brew, scoop and\n`go install` are handed to that tool, script and archive installs replace\nthemselves after checking the checksum, and `.deb`/`.rpm`/`.apk` installs print a\n`sudo` command for your human. `gg upgrade --dry-run` previews it. `gg upgrade`\nitself needs v0.54.0; on an older `gg` it does not exist, so use the per-manager\ncommand (`brew upgrade --cask gagarin-cloud/tap/gg`, `scoop update gg`,\n`go install ...@latest`) or, for an installer or\narchive install, have your human run the installer again as \"Installing gg\"\nsays. Everything else documented here is present in gg\nv0.42.0 and later.\n\n## What else the machine should have\n\n`gg` itself shells out to one thing, docker. The rest of this skill leans on a\nfew more tools without checking for them, so check once, early, rather than\nmeeting each one as a failure halfway through a deploy:\n\n| tool | needed for | without it |\n|---|---|---|\n| `gg` | everything | see \"Installing gg\" |\n| `docker`, running | `gg ship`, `gg build`, `gg push` | deploy an image already in the registry; read state; roll back |\n| `docker buildx` | `gg registry copy` | bring the image in from a machine that has it |\n| `git` | committing `.gagarin.json`; `gg build` and `gg ship` tagging the image with the commit; knowing which forge the repository lives on | it all still deploys, but nothing ties an image to the source it came from, and the next session has no note of the project |\n| `gh` (GitHub) or `glab` (GitLab), signed in | putting a CI credential in the secret store without it touching disk or the transcript; watching the pipeline you wrote run | the human sets the secret in the web UI themselves, and you cannot see whether the first run went green |\n| `jq` | pulling one value out of `--format json` | read the JSON yourself; nothing in gg requires it |\n\nOnly the forge CLI that matches the repository matters: `git remote get-url\norigin` says whether it is GitHub or GitLab. Check what is there, and whether\nthe forge CLI is signed in, with:\n\n```\ncommand -v git docker gh glab jq\ndocker info >/dev/null 2>&1 && echo \"docker is up\"\ngit rev-parse --is-inside-work-tree && git remote get-url origin\ngh auth status        # or: glab auth status\n```\n\nWhat to do about a missing one:\n\n- **Do not install docker, git or a forge CLI yourself, and do not sign in for\n  your human.** Say which is missing, what it costs them, and the install\n  command for their platform (`brew install gh`, `winget install GitHub.cli`,\n  `sudo apt install gh`; `glab` the same way). `gh auth login` and `glab auth\n  login` are theirs to run, like `gg login`.\n- **Only docker blocks a ship.** Everything else degrades: say what is lost and\n  carry on with the task.\n- **Not a git repository** is not a failure either. Deploy it; then mention that\n  `.gagarin.json` only helps the next session if it is committed somewhere.\n\n## If you cannot install gg: the MCP server\n\nGagarin also answers MCP at `https://mcp.gagarin.cloud/mcp`. An MCP client —\nClaude Code, Claude Desktop, Cursor, Codex, ChatGPT — connects to that URL and\ninstalls nothing: your human signs in with GitHub or Google when the client\nasks for it, and no secret passes through you. It is this same API in another\nshape, so everything above still holds — the naming, the asynchrony, the\ndefault-denied graph, the human's approval before anything is destroyed.\n\n**It is a smaller surface than `gg`, and the gap is images.** Over MCP you can\ndeploy an image that is already in the registry, run a job, read status and\nlogs, declare dependencies, add an address, roll back, and manage resources,\npeople, credentials and the bill. Four things are deliberately absent:\n\n- **No build and no push.** `gg ship`, `gg build`, `gg push` and\n  `gg registry copy` shell out to docker where the source is, and a server on\n  the internet has neither your source tree nor your docker.\n- **No tunnel.** `gg connect` binds a port on *this* machine; there is no local\n  anything at the other end of an MCP call.\n- **No waiting for a job.** `run` answers the revision naming the run and\n  returns, as every other write does. `status` is the only place an exit code\n  appears.\n- **No list of resource types, sizes or scopes.** The engine owns those and its\n  refusals name them; a second copy here would be wrong the day one is added.\n\nSo: **if `gg` is installed, use it.** It does everything the MCP server does and\nthe four things it cannot. Reach for MCP when you cannot install a binary, or\nwhen the work is purely operational — reading state, rolling back, wiring deps,\nmanaging addresses. If a task needs an image built and you hold only MCP tools,\nsay so and install `gg` rather than reporting a deploy you were unable to make.\n\nThere is a third way into the same API, and it is for neither you nor a\nperson: **application code uses the SDK** (Go, Node, Python) — see \"From code:\nthe SDK\".\n\n## Getting access\n\n`gg login` is one command whether this is the first machine on a new account or\nthe fifth on an old one. There is no separate signup and no address to ask for:\nthe human signs in with GitHub or Google, and a new account starts with $5 on it\nand no card asked for.\n\n1. **`gg login`** prints a link and a code, remembers the request, and exits.\n2. **Give the user the link and the code as printed.** The link is the one to\n   open; the plain address and the code under it are the fallback for when the\n   link does not open. Say what they will do there: sign in with GitHub or\n   Google, check that the page shows the same code and this machine's name, and\n   approve. Then wait for them to tell you they have.\n3. **`gg login` again.** It collects the request the first run made — it does\n   not ask for a new one — stores the credential in\n   `~/.config/gagarin/credentials.json`, logs `docker` in to the registry, and\n   says which account this machine now acts as. Confirm with `gg whoami`.\n\nIf the second run fails:\n\n- `[authorization_pending]` — it waited a minute and nobody had approved yet.\n  It prints the link and code again: pass them on again if the user seems not to\n  have them, and once they say they approved, run `gg login` again. Do not run\n  it in a loop.\n- `[expired_token]` — nobody approved within fifteen minutes, and the request is\n  gone. Run `gg login` for a fresh link and pass it on straight away.\n- `[access_denied]` — the user declined on the page, and the request is gone.\n  Ask them why before running it again, and do not retry on your own.\n- `[github_account_too_new]` — the user signed in with a GitHub account under\n  30 days old, which Gagarin does not accept yet. The request is kept: tell them\n  to open the same link and choose **Continue with Google**, then run `gg login`\n  again once they say they approved.\n\n`gg login --new` throws away a request nobody approved and asks for a new code —\nfor when the user lost the link, or it was meant for a different account.\n\nDo not open the link yourself, and do not approve it on the user's behalf in a\nbrowser you control: the approval is theirs, and it is the only thing standing\nbetween an agent and an account. The account is whichever one they sign in to;\nif they use more than one, let them pick.\n\nThe moment an account is created it gets its balance and the address the\nprovider verified joins Gagarin's customer list; https://gagarin.cloud/privacy\nsays what that list is for.\n\nYou never handle the credential yourself. Do not read that file, do not echo it,\nand never ask the user for a token — if you find yourself wanting a secret to\nmake `gg` work, you are doing this wrong. The exceptions are CI and an\napplication that starts jobs, and each gets its own — \"Setting up CI\" below, and\n\"From code: the SDK\".\n\nIf `docker` was installed after Gagarin, `gg registry login` does that half on\nits own.\n\n## Setting up CI\n\n**Never run `gg login` in CI, and never copy this machine's credential into\nit.** A pipeline gets one of its own, minted from the one you already hold.\n\n### 1. Mint the credential\n\n`gg creds create --name \"github actions: acme/web\"` prints the secret to\n**stdout alone on its line**, and everything else to stderr. Never run it on\nits own, which would put the secret in your output: pipe it straight into the\nsecret store, so nothing touches disk or the transcript:\n\n```\ngh secret set GAGARIN_TOKEN --body \"$(gg creds create --name \"github actions: acme/web\" 2>/dev/null)\"\n```\n\nOn GitLab, the same with `glab`:\n\n```\nglab variable set GAGARIN_TOKEN --masked --value \"$(gg creds create --name \"gitlab ci: acme/web\" 2>/dev/null)\"\n```\n\n**Without `gh` or `glab` signed in, do not mint it yourself** — there is no way\nfrom here to a secret store that does not pass through your output. Ask your\nhuman to run `gg creds create --name \"…\"` in their own terminal and paste it\ninto the repository's CI settings, or to install and sign in to the forge CLI\nfirst.\n\nName it after where it will live. `gg creds` is a list somebody reads months\nlater deciding what is still wanted, and \"token\" tells them nothing then.\n\nWhat you just minted is **deliberately weaker than what you hold**:\n\n- It can deploy. **It cannot destroy** — a pipeline holding it cannot delete a\n  project, a service or a database, and no flag turns that on.\n- It **expires**: 90 days by default, 365 maximum, and there is no never.\n- It **cannot mint another**, so a leaked one cannot issue its own replacements\n  while you are busy revoking it.\n- It is **shown once**. Gagarin keeps a hash. Lose it and you revoke it and mint\n  another; no command reads one back.\n\n### 2. Give it to the pipeline\n\nCI reads `GAGARIN_TOKEN` from the environment and needs nothing else: no\n`gg login`, no credentials file, no home directory, no interactive anything.\n\n### 3. The workflow\n\nThe shape that matters: install gg, log docker in, publish on every commit,\nrelease on the ones you mean.\n\n```yaml\nname: deploy\non:\n  push:\n    branches: [main]\n\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n    env:\n      GAGARIN_TOKEN: ${{ secrets.GAGARIN_TOKEN }}\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: install gg\n        run: go install github.com/gagarin-cloud/gg@latest\n\n      - name: log docker in to the gagarin registry\n        run: gg registry login\n\n      - name: build and publish\n        run: gg build acme/web:${{ github.sha }} --push\n\n      - name: release\n        run: gg deploy acme/web:8080 web:${{ github.sha }} --env-file .env.production\n\n      - name: say what the cluster is doing\n        run: gg status acme\n```\n\nSix things about that are load-bearing:\n\n- **`gg registry login` is not optional.** `gg build --push`, `gg push` and\n  `gg registry copy` all shell out to docker, and docker has no idea what a\n  Gagarin credential is until that runs. The failure without it is a `401` out\n  of `docker push`, whose hint says exactly this.\n- **Tag with the commit, explicitly.** `gg build` with no tag uses the short\n  hash when the checkout is clean and the clock when it is not — and a\n  pipeline that generates a file or two before the build is not clean. Pass\n  `${{ github.sha }}` so the tag never depends on that: it is what makes a\n  deploy reproducible and a rollback explicable.\n- **`gg push` requires the tag** where `gg build` does not — a push moves\n  something that already exists, and \"whichever one I built last\" is not a name.\n- **The deploy step is separate on purpose.** Publishing on every commit and\n  releasing on some of them is the whole reason build, push and deploy are three\n  verbs. A workflow that only ever wants all three can run `gg ship` instead.\n- **`.env.production` is committed, so it holds no secrets.** It is config:\n  ports, log levels, sibling URLs. The keys the service needs are `external`\n  resources, created once with `gg resource add` and wired with `gg deps add`;\n  they survive every deploy CI makes, and CI never holds them. If you are about\n  to put a credential in a CI secret so the workflow can pass it with `--env`,\n  make it an external instead.\n- **`gg status` at the end is a report, not a gate.** The deploy returned when\n  the demand was recorded; the pod may still be pulling. Do not write a polling\n  loop in CI — if you want a gate, gate on your own health check against the\n  service's address.\n\nEverything else works identically in any CI: the token in the environment, `gg`\non the PATH, docker available if you build. GitLab, Buildkite and Cloud Build\nneed no special handling.\n\n**Watch the first run** if the forge CLI is there, once your human has pushed —\nthat push is theirs to make. Give `gh` the run's id, because without one it\nasks which run, and you cannot answer a prompt:\n\n```\nid=$(gh run list --workflow deploy.yml --limit 1 --json databaseId -q '.[0].databaseId')\ngh run watch \"$id\" --exit-status\ngh run view \"$id\" --log-failed        # only if it failed\n```\n\nOn GitLab, `glab ci status --live` follows the pipeline for the current branch\nand `glab ci trace <job>` prints a job's log. Then `gg status` for what the\ndeploy step actually did.\n\n### 4. Afterwards\n\n```\ngg creds              what has access, which are minted, when each expires\ngg creds revoke 7     immediately, and needing no approval\n```\n\nRevoking needs no human because taking access away is always safe — a machine\nyou no longer trust should not wait on an inbox. Rotate a CI credential by\nminting the new one, updating the secret, then revoking the old id.\n\nIf you are tempted to set `XDG_CONFIG_HOME` to a scratch directory and run\n`gg login` again for a second credential: that used to be the only way and it\nis not any more.\n\n## Recipe: an application from nothing\n\nThe end-to-end, in the order that avoids every window where something is broken.\n\n```\ngg init shop                                  once, per application\n\ngg resource add shop/db postgres --size m     the database, before the thing that needs it\ngg ship shop/api:8080 --deps db               builds ., pushes, runs it, and it\n                                              starts already holding DB_URL\ngg ship shop/web:3000 --env API=http://api:8080\ngg deps add shop/web api                      web may now call api\ngg domain add shop/web                        the one thing the browser opens\ngg status shop                                and only now tell the user a URL\n```\n\nNotes on each step, in the order they bite:\n\n- **After `gg init`, write `.gagarin.json`** with the id it printed, and commit\n  it — see \"Which project this repository is\". Skip `gg init` when the note or\n  `gg projects` says the project already exists.\n- **A Dockerfile per service.** Gagarin deploys images, so a service without one\n  cannot be deployed. Writing it is a normal part of this job. Do not set a\n  platform or architecture: Gagarin reports what its own nodes run, and gg builds\n  for that.\n- **Run `gg ship` from the directory holding that service's Dockerfile**, or\n  point `--context` at it — `gg ship shop/api:8080 --context ./api` from a\n  monorepo root. `--file` names the Dockerfile when it is not called that, or\n  lives outside the context directory.\n- **Commit before you ship, if you can.** With no tag given — and `gg ship`\n  never takes one — gg tags the image with the short hash of the commit\n  (`web:3f9c2ab`), so `gg history` says which code each revision ran and a\n  rollback names what it puts back. Only when the work tree is clean: any\n  modified or untracked file in the repository, inside the build context or\n  not, and it falls back to a clock tag (`web:1761830000`) and says so on\n  stderr. Ignored files do not count. No git or no repository is the clock too,\n  silently. Either way the tag is printed; read it from the output rather than\n  predicting it. Do not commit the user's work just to get a hash: ask, or\n  ship with the clock. (gg v0.55.0 and older always use the clock.)\n- **The number after the colon is the port the container listens on.** It\n  defaults to 8080. Say it anyway when you know it: a service answering on the\n  wrong port is a hang, not an error.\n- **`--deps db` on the first ship** means the pod never starts into a window\n  where it cannot reach the database and does not hold its password. On later\n  ships it is optional and harmless.\n- **Private services talk over `http://<service-name>:<port>`** — the service\n  name, no project prefix, no scheme guessing.\n- **`gg domain add` for the service the user's browser opens, and nothing else.**\n  Do not expose a database, a worker or an internal API \"so it can be tested\".\n  Ask the user before putting anything on the internet they did not ask to.\n- **`gg status` before you promise anything.** `gg ship` says nothing about where\n  a service answers, deliberately — an address exists as a string long before\n  anything is listening on it.\n\n### When to use the three steps instead\n\n```\ngg build  shop/web:v3 --context ./web    make an image, run nothing\ngg build  shop/web:v3 --push             ...and upload it in the same call\ngg push   shop/web:v3                    publish it, release nothing\ngg deploy shop/web:8080 web:v3           release one that already exists\n```\n\nThat is CI, and it is also the only way to run an image you did not just build —\none copied in with `gg registry copy`, or a tag somebody else pushed.\n\n## After the first address: show them around\n\nA first deploy that answers is where most people stop, and the three things that\nkeep a project healthy are one step past it. So once `gg status` shows the first\nservice answering, give the human its URL, and then offer one next step per\nturn, in this order:\n\n1. **The graph.** Point them at `https://my.gagarin.cloud/projects/<id>`: what\n   is running, and what may reach what. Nothing to run, so this one is a\n   sentence and a link.\n2. **Alerts.** Ask whether the human wants a push on their phone when the\n   service goes down, a deploy will not start, a container keeps crashing, or\n   one runs short of memory, CPU or disk.\n   If yes, they open `https://my.gagarin.cloud/projects/<id>/alerts` on that\n   phone and turn on \"Notify me about this project\", which allows notifications\n   and opts them in at once; the same page sends a test. On an iPhone they add\n   the console to the Home Screen first and open it from there. There is no gg\n   command for alerts. With the MCP server connected you may check with\n   `alerts` first, and send `test_alerts` once they say it is on.\n3. **Memory.** `remember` two or three facts this session would otherwise lose:\n   why that port, why that size, what the Dockerfile works around. Then tell\n   the human the project keeps them, and the next session starts from them.\n\nRules, each for a reason:\n\n- **One step per turn, one sentence and one action.** A wall of next steps\n  reads as homework, and the human came for an address.\n- **Stop when they say no or change the subject.** Do not bring a skipped step\n  back later in the same session.\n- **Alerts are the human's switch, not yours.** They reach a person's phone,\n  and only that person's browser can allow them.\n- **Skip what is done, and read \"done\" from state.** With the MCP server,\n  `alerts` says whether alerts are on and how many devices they reach; without\n  it, the human's answer is the state. `memory_briefing` says whether the\n  project already holds memories. What was said earlier in a conversation is\n  not state.\n- **Note what they have seen in `.gagarin.json`.** The graph leaves no trace you\n  can read back, so record each step as it happens: add its name to `\"tour\"`,\n  `{ \"project\": { … }, \"tour\": [\"graph\", \"alerts\", \"memory\"] }`. A step in the\n  list is not offered again, in this session or the next. Commit it with the\n  rest of the note.\n\n## Services\n\nA service is a container image that runs, with a port, a size, an environment,\noptionally a volume, whatever it is allowed to reach, and whatever addresses it\nanswers on. Only the first two of those are set by a deploy. An image that runs\nto completion instead of serving — a migration, a backfill — is a **job**, not a\nservice: see \"Jobs\" below, and do not deploy one as a service, because a\nservice that exits is restarted forever and reads as failing.\n\n### The environment\n\n```\ngg deploy shop/web:8080 web:v3 --env-file .env\ngg deploy shop/web:8080 web:v3 --env-file .env --env DEBUG=false\ngg ship   shop/web:8080 --env-file .env\n```\n\n- `--env-file` is **not** picked up automatically. If the user has a `.env` and\n  wants it used, pass the flag; never assume a file should be read.\n- Precedence: `--env` beats every file, later `--env-file` beats earlier ones,\n  and **a resource's injected variable beats all of it** (see \"Resources\").\n- There is **no interpolation**. `B=${A}` sets `B` to the literal `${A}`.\n- Env is **replaced on every deploy, not merged.** To remove a variable, deploy\n  without it. To keep one, keep passing it.\n- The file supplies **values only**. It cannot name services, set ports or say\n  what is public. If you find yourself wanting to put deployment structure in a\n  file, stop — Gagarin holds that itself.\n\nEnvironment is the one thing a deploy still replaces wholesale, because it is\npart of what a revision ran with and is what a rollback puts back. Everything\nelse that could be lost by forgetting to restate it has been moved out of a\ndeploy for exactly that reason.\n\n### What does not go in env\n\n**No secrets. Not an API key, not a password, not a token, not a connection\nstring with a password in it.** A deploy env is for configuration that is\nharmless to read and owned by this one service: `PORT`, `LOG_LEVEL`,\n`NODE_ENV`, `API=http://api:8080`. Anything that would hurt in the wrong hands\nbelongs on the graph instead:\n\n| it is | where it goes |\n|---|---|\n| a Gagarin database, cache, queue or bucket | `gg deps add P/SVC RESOURCE`. The credentials arrive by themselves, and are never copied into env |\n| a third-party key (Stripe, OpenAI, SMTP, a webhook secret) | `gg resource add P/NAME external --env-file .env.NAME`, then `gg deps add` |\n| config several services share, or that should change without a deploy | an `external` too, even when it is not secret |\n\nWhy a secret in a deploy env is the wrong place, every time:\n\n- **It is copied into every revision.** History keeps each deploy's env so a\n  rollback can put it back, so a key you rotated is still stored, alongside every\n  older one, for as long as those revisions exist.\n- **It cannot be changed on its own.** A deploy replaces the whole env, so\n  rotating one key means restating all of them, and the API will not hand them\n  back: `status` and `history` return the variable *names* (`env_keys`), never\n  the values. Whoever rotates it needs the full `.env` file, or deletes every\n  key they forget.\n- **It is a copy per service.** Three services using one key means three\n  deploys to rotate it, and the one you forget keeps authenticating with a\n  revoked key. An external is one row: `gg resource rotate --set` changes one\n  key, every holder is restarted, and `gg rollback P/NAME` undoes it.\n- **It lives in a file on someone's machine and in CI**, because it has to be\n  restated on every deploy. An external is stated once.\n\n**What you do as an agent:**\n\n- A credential for a service becomes an `external`, from a file your human\n  writes (see the external section). Do not ask for it in chat, do not pass it\n  with `--env`, and do not put it in a `.env` that a deploy reads.\n- If a `.env` you were asked to deploy with holds secrets, say so before\n  deploying, and offer to move them out. Do not quietly ship them, and do not\n  quietly drop them either: the service would start without them.\n- If a service already has a secret in its deploy env (`env_keys` in\n  `gg status` names it), say so and offer the move below. Do **not** try to\n  reconstruct its environment to redeploy: the values are not readable through\n  the API, and a guess deletes every key you leave out.\n\nMoving a secret out of a deploy env, without a moment where the service lacks\nit:\n\n```\ngg resource add shop/stripe external --env-file .env.stripe   # holds API_KEY\ngg deps add shop/web stripe          # web now also holds STRIPE_API_KEY\ngg deploy shop/web:8080 web:v3 --env-file .env   # the same .env, minus STRIPE_API_KEY\n```\n\nThe injected variable beats the deploy env, so the order is safe: `web` holds\nthe key the whole way through, and the last deploy only removes the stale copy.\nName the resource for how the application reads it: `stripe` with `API_KEY`\npublishes `STRIPE_API_KEY`. After the move, the old value is still stored in the\nhistory revisions that carried it. Rotate the key at the provider if it ever went\nanywhere it should not have.\n\n### Size\n\nEvery service and every resource runs at a size, and `s` is what you get if you\nsay nothing at creation.\n\n| | reserved | ceiling | price |\n|---|---|---|---|\n| `s` | 100m CPU / 256 MiB | 0.5 vCPU / 1 GB, shared | $10/month |\n| `m` | 1 vCPU / 2 GB | same — dedicated | $30/month |\n| `l` | 2 vCPU / 4 GB | same — dedicated | $60/month |\n\n```\ngg deploy shop/web:8080 web:v3 --size m\ngg ship shop/web:8080 --size m\ngg resource add shop/db postgres --size m\n```\n\n- **`s` is shared; `m` and `l` are dedicated.** An `s` service may burst to its\n  ceiling but is only guaranteed the reservation, which is why it costs a third\n  of `m`. An `m` or `l` reserves exactly what it is promised and is the last\n  thing evicted when a node runs short.\n- **Omitting `--size` keeps the size the service already has.** It does not reset\n  to `s`. Changing a size is therefore always deliberate.\n- **Changing a size restarts the service** — a new pod with new limits. Expect a\n  few seconds of downtime, and do not do it while something depends on it.\n- **Which to pick.** Start at `s`: it runs a small API, a worker, a static site,\n  a database you develop against. Move to `m` when something is OOM-killed —\n  `gg status` says so and names the size to move to — or when you already know\n  the workload: server-side-rendered Next.js, a JVM, a large in-process cache, a\n  postgres a real application depends on. Do not reach for `l` speculatively.\n- **A postgres's size also sets its settings**: at most **60, 105 or 119\n  connections** at `s`, `m` or `l`, shared buffers of 128 MB, 512 MB or 1 GB,\n  and `work_mem` of 2, 2 or 4 MB. They are the platform's, not a flag; a query\n  that needs more sort memory runs `SET work_mem` for its own session. A\n  postgres created before 2026-11-17 keeps stock settings (100 connections)\n  until its next resize. If an app runs out of connections, pool them — or\n  move up a size.\n- `gg status` shows the size every service is running at, and the day's accrued\n  cost at the bottom of the table.\n\n### Replicas\n\nA service runs one copy unless it says otherwise. `--replicas` on `gg deploy`\nor `gg ship` sets a fixed count, or a range the platform scales within on CPU:\n\n```\ngg deploy shop/web:8080 web:v3 --replicas 3     always three copies\ngg ship shop/api:4000 --replicas 1-5            one to five, by CPU load\ngg deploy shop/web:8080 web:v4 --replicas 1     back to one\n```\n\n- **Omitting `--replicas` keeps what the service has**, like `--size`.\n- **Every copy is billed at its size's rate while it runs.** A range bills its\n  minimum all the time and each extra copy only while it is up. At most five.\n- **Only a service without a volume.** A service with a volume always runs one\n  copy (`replicas_with_volume`); resources and jobs have no replicas. A\n  database does not get replicas or failover from this.\n- **More copies help CPU, not memory.** A service that is OOM-killed needs a\n  bigger size; one that is CPU-bound under load, or must stay up through a\n  node drain, wants `--replicas 2` or a range. Copies share nothing in memory,\n  so in-process sessions or caches must live in valkey or postgres first.\n- `gg status` adds a REPLICAS column once anything in the project may run more\n  than one.\n\n### Volumes\n\n```\ngg ship shop/db:5432 --volume /var/lib/postgresql/data --volume-size 20\n```\n\nA directory that survives restarts. **Set once, at the deploy that creates the\nservice**; a later deploy cannot move it or resize it, and asking is refused with\n`volume_immutable`. The default ceiling is 10 GB. A rollback across a change of\nvolume is refused for the same reason. It is writable by whatever user the image\nruns as, so an image with a non-root `USER` needs no chown or init step.\n\nUse this for anything stateful that has no resource type — see \"Anything we do\nnot have a type for\".\n\n## Jobs: what runs to completion\n\n```\ngg build shop/migrate:v3 --context ./migrations\ngg run   shop/migrate migrate:v3 --deps db --env-file .env\ngg run   shop/migrate migrate:v3 --detach        submit and return\ngg run   shop/migrate migrate:v3 --timeout 5m    stop it at five minutes\ngg run   shop/migrate migrate:v3 --ttl 30m       remove it half an hour after it ends\n```\n\nA job is a service that ends. It has an image, an environment, a size and a\nplace on the graph, and **no port, no address and no volume**: it listens on\nnothing, nothing can declare that it needs one, and it keeps nothing between\nruns. Durable data belongs in a resource the job reaches with `--deps`.\n\n- **`gg run` is the one command that waits.** It submits the run, follows it,\n  prints what the run wrote, and **exits with the script's own exit code**. Read\n  the code: zero means the script finished; anything else is the script's\n  failure, and the last line names it. `--detach` returns at once instead, and\n  `gg status` then reports how the run ended.\n- **Every `gg run` is one run**, recorded as a revision exactly like a deploy.\n  Running twice runs twice. `gg history` lists the runs; `gg rollback` runs an\n  earlier revision again.\n- **A run that fails is not retried**, and its exit code is reported once. Fix\n  the script and run again; the platform will not re-run a half-applied\n  migration on its own.\n- **A run is stopped at its timeout, which is sixty minutes unless you set\n  one.** `--timeout 5m` takes a Go duration (`45s`, `5m`, `1m30s`, `1h`) from\n  one second to sixty minutes, in whole seconds; over MCP it is\n  `timeout_seconds`, 1 to 3600. Left out, a job keeps the timeout its last run\n  was given, and a new job gets sixty minutes; to go back to the default, say\n  `60m` (or 3600) outright. The clock starts when the run gets a machine, not\n  when the script starts, so pulling the image uses some of it; waiting for a\n  machine uses none. A run that never gets a machine is given up on after its\n  timeout plus thirty minutes, and its status says nothing ran and nothing was\n  billed. At the deadline the run is sent SIGTERM, and killed thirty seconds\n  later if it is still running. `gg status` says so when that is why it ended:\n  \"the run was stopped at its timeout of 5 minutes, counted from when it got a\n  machine; gg run --timeout gives it up to 60 minutes\" (at the ceiling: \"...after\n  60 minutes, counted from when it got a machine, which is the most a job may\n  take\").\n  Something that needs longer than an hour is a service.\n- **A finished run is removed after its TTL, eight hours unless you set one.**\n  `--ttl 30m` takes a duration from one minute to eight hours; over MCP it is\n  `ttl_seconds`, 60 to 28800 (`invalid_ttl` outside that). Left out, a job keeps\n  the TTL it has, and a new job gets eight hours. It counts from when the run\n  **ended**, not from when it got a machine as the timeout does. On expiry a\n  one-shot job is deleted outright: its row, history and runs go, it leaves\n  `gg status`, and its name is free again (a reused name starts at revision 1).\n  `gg logs` still has what the run wrote while the job exists. So read the\n  outcome with `gg run` (which waits) or `gg status` before the TTL passes, and\n  there is nothing to `gg destroy` afterwards.\n- **Its image is any image in the project's space** — build one with\n  `gg build`, or run the service's own image with a different entrypoint baked\n  into a second Dockerfile. `gg run` does not build.\n- **A job is billed for the time it runs**, at its size, not for existing: by\n  the minute, from when its container starts. Waiting for a machine and pulling\n  the image are not billed. A hung run costs at most its timeout.\n- **A run can sit `pending` without being stuck.** With no machine yet, `gg\n  status` says \"waiting for a machine with room for it — the cluster adds one\n  within a few minutes unless it is at its limit; nothing is billed until it\n  starts\". Keep waiting; it is not a failure.\n- **Kinds do not change.** A name that is a job stays a job (`not_a_service`),\n  and a name that is a service cannot be run as a job (`not_a_job`). Give the\n  job its own name.\n\nUse a job for anything the user describes as \"run this once\" or \"run this\nbefore deploying\": migrations, seeds, imports, one-off reports. The shape for a\ndeploy that needs a migration first is two commands, in this order:\n\n```\ngg run    shop/migrate migrate:v3 --deps db     # exits non-zero if it failed: stop here\ngg deploy shop/api:8080 api:v3\n```\n\n### On a schedule\n\n```\ngg run shop/report report:v2 --schedule \"0 3 * * *\" --tz Europe/Berlin\ngg run shop/report report:v3                     next firing runs v3; schedule kept\ngg run shop/sync   sync:v1   --schedule \"*/5 * * * *\" --deps db\n```\n\nUse this for anything the user describes as \"every night\", \"every hour\", \"on\nMondays\": a nightly import, a report, a cleanup, a sync. It is still a job —\nsame image, environment, size, timeout and graph — with one more property.\n\n- **`--schedule` is five cron fields** (minute hour day-of-month month\n  day-of-week) **or a descriptor**: `@hourly`, `@daily`, `@weekly`, `@monthly`,\n  `@yearly`. It may fire as often as every minute. `@every` and a\n  `CRON_TZ=`/`TZ=` prefix are refused (`invalid_schedule`).\n- **`--tz` is the zone the schedule is read in**, an IANA name like\n  `Europe/Berlin`; UTC when left out. Ask the user which zone they mean when they\n  say \"at 3am\" — the default is UTC, not their laptop's zone.\n- **A scheduled `gg run` does not wait**, because nothing runs now: it prints\n  the schedule and the next firing and returns, whatever `--detach` says. There\n  is no exit code to read. `gg status` is how you learn how each firing ended.\n- **Each firing is a run** like any other: not retried when it fails, stopped\n  at its timeout, billed for the time it ran. A schedule waiting between\n  firings costs nothing. **Runs never overlap**: a firing that comes while the\n  previous run is still going is not started beside it — it waits, and starts\n  the moment that run ends; several firings missed that way start once. A job\n  that takes longer than its interval therefore runs back to back, not in\n  parallel.\n- **`gg run` again without `--schedule` keeps the schedule** and changes what\n  the next firing runs — the image, `--env`, `--size`, `--timeout`, `--ttl`. A firing\n  already going keeps what it started with. `--schedule` again changes when;\n  `--tz` alone changes the zone.\n- **`--schedule` on a one-shot job makes it scheduled**, between runs only:\n  while its run is still going it is refused `job_running`.\n- **A schedule cannot be removed.** `gg run` means \"run this\", so a\n  `--schedule off` would fire a run when all you wanted was for the schedule to\n  stop — the one thing the command could not avoid doing. To stop a scheduled\n  job, destroy it (a human approves) and, if it should still exist as a one-shot\n  job, run it again without `--schedule`. Do not look for a flag to pause or\n  clear a schedule; there is none.\n- **`--ttl` on a scheduled job applies to each firing**, counted from when it\n  ended, and the job stays: only that firing's run is removed. `gg status` still\n  reports the last firing, reading \"(removed after its ttl)\", and `gg logs` keeps\n  what it wrote.\n- **A failed firing alerts** whoever opted in to the project's alerts, once,\n  and a later firing that succeeds resolves it. Nobody else is watching a run\n  at three in the morning, so when you set up a schedule for someone who has\n  them off, suggest the switch at `https://my.gagarin.cloud/projects/P/alerts`.\n- Over MCP, `run` takes `schedule`, `time_zone` and `ttl_seconds`, and `status`\n  carries `schedule`, `time_zone` and `actual.schedule` (`next_at`,\n  `last_scheduled_at`, `suspended`).\n\n### From code: the SDK\n\n`gg run` is for a person or a pipeline, and `--schedule` for a clock. When\n**a program** decides that a job should run — on a request, a queue message, a\nuser's click — it starts the run with the SDK. **Never shell out to `gg` from an\napplication**: it would need gg installed in the image and a login on a machine\nnobody signs in to. The SDK is the same API as a library, in three languages,\neach with no runtime dependencies:\n\n```\nnpm install @gagarin-cloud/sdk              Node 18+, TypeScript types included\npip install gagarin                         Python 3.9+\ngo get github.com/gagarin-cloud/sdk/go      Go 1.22+\n```\n\nEach one reads `GAGARIN_TOKEN` (and `GAGARIN_API`, `GAGARIN_REGISTRY`) from the\nenvironment, exactly as gg does. The four job calls are `run` (submit; returns\nthe run's `revision` at once), `wait` (until that revision ends), `runAndWait`\n(both, which is `gg run`) and `logs`.\n\n```ts\nimport { Gagarin, GagarinError } from \"@gagarin-cloud/sdk\";\n\nconst gg = new Gagarin();\nconst name = `export-${id}`;                       // one name per run; see below\ntry {\n  const sub = await gg.jobs.run(\"shop\", name, {\n    image: \"export:v4\", env: { EXPORT_ID: id }, deps: [\"files\"], timeoutSeconds: 900,\n  });\n  const run = await gg.jobs.wait(\"shop\", name, sub.revision);\n  if (run.phase !== \"done\") { /* failed: run.exit_code, and gg.jobs.logs(\"shop\", name) */ }\n} catch (e) {\n  if (e instanceof GagarinError && e.code === \"payment_required\") { /* … */ }\n  throw e;\n}\n```\n\n```python\nfrom gagarin import Gagarin, GagarinError\n\ngg = Gagarin()\nres = gg.jobs.run_and_wait(\"shop\", f\"export-{id}\", image=\"export:v4\",\n                           env={\"EXPORT_ID\": id}, deps=[\"files\"], timeout_seconds=900)\nres.exit_code                                     # what gg run would exit with\n```\n\n```go\nc, err := gagarin.NewClient()   // import gagarin \"github.com/gagarin-cloud/sdk/go\"\nres, err := c.Jobs.RunAndWait(ctx, \"shop\", \"export-\"+id, gagarin.RunOptions{\n\tImage: \"export:v4\", Env: map[string]string{\"EXPORT_ID\": id},\n\tDeps: []string{\"files\"}, TimeoutSeconds: 900,\n})\nif gagarin.IsCode(err, \"payment_required\") { /* … */ }\nres.ExitCode()\n```\n\nEverything in \"Jobs\" above still holds, because it is the same call:\n\n- **The image must already be in the registry.** The SDK neither builds nor\n  pushes; `gg build` and `gg push` (or CI) put it there first. A bare\n  `repo:tag` is expanded to the project's registry space for you.\n- **`env` is the run's complete environment**, not merged with the last one;\n  leave it out and the run has none. **`deps` adds** to what the job already\n  declares. Both follow rule 7: no credential goes in `env` — a job reaches its\n  database or bucket through `deps`.\n- **The timeout is at most 3600 seconds and starts when the run gets a\n  machine.** Every call is a new run, billed for the time it runs.\n- **The TTL is `ttlSeconds` (Node), `ttl_seconds` (Python), `TTLSeconds` (Go)**,\n  60 to 28800 (`MIN_TTL_SECONDS`/`MAX_TTL_SECONDS`, `MinTTLSeconds`/`MaxTTLSeconds`\n  in Go); leave it out for the job's current one, eight hours on a new job. It\n  counts from when the run ended and then removes a one-shot job, so `wait` or\n  `runAndWait` and read the run (and `logs`) before it goes. After that, `get`\n  and `wait` on the name fail `not_found` (\"nothing named … in project …\"), which\n  looks the same as a job that never existed. A scheduled firing is the\n  exception: the job stays, and its last run reads `expired: true`\n  (`Expired` in Go) with phase, exit code and times intact.\n- **Refusals are a typed error carrying the API's `code`**, `message` and\n  fix hint: `GagarinError` in Node and Python, `*gagarin.Error` with\n  `gagarin.IsCode` in Go. Branch on the code, as in \"Error codes\".\n- **It does not destroy anything.** Destroying is a human's approval, and the\n  SDK leaves it out.\n\n**One name per run that may overlap another.** Starting a run on a job **stops\nthat job's run still going** — a new revision is what the job is now. So an\napplication that may start a second run before the first has ended must give\neach its own job name: a fixed prefix and a short id of the work (`export-7f3a`),\nnever raw user input, and within `^[a-z][a-z0-9-]{1,29}$`. If only a fixed number\nshould run at once, a name per lane (`export-1` … `export-4`) is the alternative,\nand the application must not start a lane that is busy. A `wait` on a run that a\nnewer one replaced fails with `superseded` (`gagarin.ErrSuperseded` in Go) —\nthe symptom of two runs sharing a name. A finished job costs nothing and\nremoves itself after its TTL, eight hours unless the run asks for less, which\nfrees its name; nothing needs `gg destroy`, so per-run names do not pile up.\n\n**The application needs a credential of its own**, minted the way CI's is and\ndelivered the way every other secret is — as an `external` resource, never in\n`--env`. Name the resource `gagarin` and the key `TOKEN`, and the service holds\nexactly the `GAGARIN_TOKEN` the SDK reads:\n\n```\nprintf 'TOKEN=%s\\n' \"$(gg creds create --name \"shop/api: starts jobs\" 2>/dev/null)\" > .env.gagarin\ngg resource add shop/gagarin external --env-file .env.gagarin\ngg deps add shop/api gagarin\nrm .env.gagarin\n```\n\nThe token never reaches the terminal or the transcript. Tell the user what it is:\n\n- **It can deploy and run anything in the account**, not only this project, and\n  it **cannot destroy**. Anyone who can read the service's environment holds it.\n- **It expires** — 90 days unless `--expires` says otherwise, 365 at most. Before\n  then, mint a new one the same way into `.env.gagarin` and\n  `gg resource rotate shop/gagarin --env-file .env.gagarin`; the service rolls with\n  it. Never `--set TOKEN=…`: that puts the token on a command line.\n- **`gg creds revoke ID` stops it**, and `gg creds` lists it under the name you\n  gave it.\n\n## Dependencies: what may reach what\n\nEvery service in a project is default-denied. A private service is reachable\nonly from services that have declared they need it, and **an undeclared call is\ndropped rather than refused** — it does not fail fast, it hangs until the client\ngives up, which for a database driver can be thirty seconds or forever.\n\n**A hang between two of your own services is a missing `gg deps` far more often\nthan it is a bug in the application.**\n\n```\ngg deps ls  shop/api            what it reaches today\ngg deps add shop/api db cache   and these as well\ngg deps rm  shop/api cache      and no longer that one (needs a human)\n```\n\n- **Withdrawing needs a human's approval; adding does not.** `gg deps rm` is\n  gated the way `gg destroy` and `gg domain rm` are: it answers\n  `approval_required` and emails the account owner a sentence naming the edge.\n  The asymmetry is the point — opening a path breaks nothing, and closing one\n  breaks something *silently*, because the calls that used to arrive are dropped\n  rather than refused. Ask the user before you request that approval, and tell\n  them what will stop being able to reach what.\n- **The direction matters.** The declaration goes on the *caller*. If `api`\n  queries `db`, it is `api` that needs `db`, never the other way round. Backwards\n  is refused, not quietly accepted.\n- **Reaching a resource also hands over its credentials.** `gg deps add shop/api\n  db` gives `api` `DB_URL`, `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD` and\n  `DB_DATABASE`, and the command prints which ones arrived. Connecting is this\n  one call; it used to be two, and that is no longer necessary.\n- **`--deps` on a deploy or a ship only ever adds.** It exists so a service that\n  cannot start without a database can be declared and deployed together.\n  Forgetting it on the next deploy changes nothing. Withdrawing is `gg deps rm`,\n  there and nowhere else. (If you are working from memory and reach for\n  `--needs`: it is gone. It replaced the whole set on every deploy, so a redeploy\n  that forgot it silently withdrew an edge — and because an undeclared call\n  hangs, the service did not break, it went quiet.)\n- **Public URLs are not covered by this.** One service calling another's public\n  `https://` address arrives the way a stranger's browser does and is allowed.\n  The guarantee is about private, in-project addresses.\n- **Withdrawing applies to new connections, not open ones.** `gg deps rm` closes\n  the path for anything that connects afterwards, but a client holding a\n  keep-alive connection — every HTTP client, every driver pool — keeps using it\n  until it reconnects. That is how Kubernetes network policy works. If you need\n  the old path gone now, redeploy the caller: a new pod has no old connections.\n- `gg destroy` on something another service still needs is refused, and names\n  what depends on it. `gg deps rm` that first.\n\n`gg status` ends every service's row with a REACHES column, so checking the\ngraph costs nothing — do it *before* you go debugging a hang.\n\n### Reaching the outside world\n\nOutbound is unrestricted, with one exception you need before you build on it:\n**the mail ports — 25, 465 and 587 — are blocked.** A connection to any of them\ntimes out, from every service, and it cannot be opened per-account.\n\nSo **do not build anything that speaks SMTP.** If the user wants their\napplication to send email, reach for a provider's HTTPS API — Resend, Postmark,\nSendGrid, SES, any of them. That is a normal way to send mail, not a workaround,\nand it is what Gagarin itself does. Prefer the provider's official SDK to\nhand-rolled HTTP.\n\nThe reason, if the user asks: a service that can open those ports can relay spam\nif it is ever compromised, and a hosting account that relays spam gets suspended\n— which would take every other project on the platform down with it.\n\nIf you find yourself debugging a hanging SMTP connection, stop. It is not the\nuser's code and it is not DNS. It is this.\n\n## Resources: what a project *has*\n\nA resource is provisioned rather than deployed. There is no image to choose, no\nversion to pass and no Dockerfile.\n\n```\ngg resource add shop/db postgres --size m --storage 20 --ext vector\ngg resource add shop/vectors qdrant\ngg resource add shop/cache valkey\ngg resource add shop/events iggy\ngg resource add shop/jobs rabbitmq\ngg resource add shop/files s3\ngg resource add shop/openai external --env-file .env.openai\n```\n\n| type | what it is | storage | backups |\n|---|---|---|---|\n| `postgres` | PostgreSQL 17, with the extensions you ask for (`vector`, `postgis`, …) | on a volume; survives restarts | nightly, kept 14 days |\n| `qdrant` | vector database, for retrieval | on a volume; survives restarts | nightly, kept 14 days |\n| `iggy` | Apache Iggy, a persistent message-streaming log | on a volume (10 GB unless `--storage`); survives restarts | nightly, kept 14 days — see the durability caveat |\n| `rabbitmq` | RabbitMQ 4.4.0 with the management plugin, a message broker for work queues | on a volume (10 GB unless `--storage`); durable queues and persistent messages survive restarts | **none** |\n| `valkey` | in-memory store, redis protocol | **none — a restart loses everything** | none, by design |\n| `s3` | an S3-compatible bucket, for files — private until `gg resource public` | **objects on durable storage; it runs nothing** | **none** |\n| `external` | a third-party API, run by nobody here | **none — it runs nothing at all** | nothing to back up |\n\nThe types are named for what actually runs, not for the products they stand in\nfor — an honesty you can pass on when somebody asks.\n\n- **`qdrant` is Qdrant**, Apache-licensed, and it is what an application does\n  retrieval against: embeddings in, nearest neighbours out. Three things about\n  it are unlike every other type, and all three will bite an agent that assumes\n  otherwise.\n  - **The credential is not in the URL.** `<NAME>_URL` is a bare\n    `http://vectors:6333`; the key arrives separately as `<NAME>_API_KEY` and\n    travels as an `api-key` header. Every client takes it as its own argument —\n    `QdrantClient(url=os.environ[\"VECTORS_URL\"], api_key=os.environ[\"VECTORS_API_KEY\"])`.\n  - **It answers on two ports.** `<NAME>_PORT` is 6333 (HTTP/REST) and\n    `<NAME>_GRPC_PORT` is 6334. The Python, JS, Java and .NET clients want the\n    URL; the official **Go and Rust clients speak only gRPC** and want the host\n    and 6334. Both are published so neither has to be guessed.\n  - **There is no MongoDB here, and no document store either.** If a user wants\n    documents rather than vectors, Gagarin has no type for it — run one as an\n    ordinary service with a volume.\n\n  - **Qdrant or `vector` on a postgres?** Both store embeddings. If the\n    application wants relational tables and embeddings in one database —\n    joined in one query, written in one transaction — ask for the `vector`\n    extension on its postgres (see \"Postgres extensions\" below). That is the\n    default for an application that already needs a postgres and adds\n    retrieval: one resource, one set of credentials, one backup. Reach for\n    `qdrant` when the vectors *are* the product — the search is what the\n    application is for, and it deserves a database of its own.\n\n  Gagarin ran a `ferretdb` type from 2026-09-04 to 2026-09-06 and it is **gone**:\n  it promised MongoDB compatibility and did not keep the promise past the simple\n  cases. There is no alias and no migration path. If a user names it, say it was\n  removed and offer the service-with-a-volume route.\n- **`iggy` is Apache Iggy**, Apache-licensed: a persistent message-streaming\n  log, what an application publishes events to and consumes from in order. One\n  pod, one volume (10 GB by default; `--storage` is accepted), private like every\n  resource, so it is reached only by services that declare it with `deps`.\n  - **It answers on two ports.** `<NAME>_PORT` is 8090, the TCP binary protocol\n    every Iggy SDK speaks, and `<NAME>_HTTP_PORT` is 3000, for REST. QUIC and\n    WebSocket are off.\n  - **The credential is in the URL.** `<NAME>_URL` is the connection string the\n    SDKs read, `iggy://root:<password>@events:8090` for a resource called\n    `events`; `_USER` is always `root`.\n  - **A backup can miss recent messages unless the topic is persisted.** The\n    backup is taken while the server keeps running, so only topics created with\n    `--durability persisted` are guaranteed complete. A topic with the default\n    durability may be missing its newest messages, the ones not yet flushed to\n    disk. Have producers create topics with `--durability persisted` for\n    anything the user would want back from a backup, and say so when you set one\n    up.\n- **`rabbitmq` is RabbitMQ** 4.4.0 with the management plugin: a message broker,\n  what an application publishes jobs to and workers consume from. One pod, one\n  volume at `/var/lib/rabbitmq` (10 GB by default; `--storage` is accepted),\n  private like every resource, so it is reached only by services that declare it\n  with `deps`. Add it, then let the worker reach it: `gg resource add shop/jobs\n  rabbitmq`, then `gg deps add shop/worker jobs`.\n  - **It answers on two ports.** `<NAME>_PORT` is 5672, AMQP, the protocol every\n    client speaks, and `<NAME>_HTTP_PORT` is 15672, the management UI and HTTP\n    API.\n  - **The credential is in the URL.** `<NAME>_URL` is\n    `amqp://app:<password>@jobs:5672/%2F` for a resource called `jobs` (the\n    `%2F` is the default vhost `/`), and it goes straight to the client: pika,\n    amqplib, amqp091-go, or a Celery `broker_url`. `_USER` is always `app`.\n  - **There are no backups.** `gg resource backup` answers `backup_unsupported`.\n    Unlike iggy, there is nothing to recommend that makes a backup complete,\n    because there is no backup. What survives a restart is only what is durable:\n    declare queues `durable` and publish messages `persistent` (delivery mode 2)\n    for anything the user wants to outlive the pod. A transient queue or message\n    is gone on a restart, which happens on a node drain, not only when somebody\n    asks.\n  - **Declare queues and exchanges from application code, at startup.** The\n    broker keeps no copy elsewhere, so a fresh one (a destroyed and re-added\n    resource, or a lost volume) must be rebuildable by just starting the\n    application. Declaring is idempotent when the arguments match, so every\n    producer and consumer can do it on every start. Do not create topology by\n    hand in the management UI and leave it there.\n  - **Choose it for work queues, routing and fan-out to workers**; choose\n    `iggy` for an append-only log that consumers replay from an offset. If the\n    user wants to re-read history, it is iggy; if each message is a job to be\n    done once and then forgotten, it is rabbitmq.\n- **`valkey` is a cache, not a database.** `--storage` is refused (`no_storage`)\n  rather than quietly ignored, and everything in it is gone when the pod restarts\n  — which happens on a node drain, not only when somebody asks. Do not put a\n  session store there that a user would notice losing, and do not tell anyone\n  their data is safe in it. Valkey is the BSD-licensed fork of Redis; `redis://`\n  URLs, `redis-cli` and every client library work unchanged.\n- **Storage can grow, never shrink.** Restate the resource with a bigger\n  `--storage` to raise the ceiling — `gg resource add shop/db postgres --storage\n  40` on an existing `db` grows it and changes nothing else. A smaller number is\n  refused with `volume_immutable`.\n- **One instance, one volume, no failover.** A size change or a restart is a\n  brief outage. There is no point-in-time recovery. Say that plainly if a user\n  asks whether their data is safe, rather than implying an SLA nobody is on the\n  hook for.\n- **A resource cannot be deployed over.** `gg deploy shop/db` against one is\n  refused with `not_a_service`, which is telling you the name is already a\n  database. Nor can a resource declare dependencies: it is reached, it does not\n  reach.\n- **A managed resource cannot be rolled back**, because Gagarin mints its\n  credentials and there is no earlier value of the user's to go back to. An\n  **external can** — its values are theirs — and `gg rollback P/NAME` is how a\n  config change is undone. See the external section below. An `s3` cannot\n  either, for the same reason.\n\n### Postgres extensions\n\nA `postgres` takes **extensions**: the set of postgres extensions the database\nshould have, named exactly as `CREATE EXTENSION` names them.\n\n```\ngg resource add shop/db postgres --ext vector --ext postgis    create it with both, or restate it\n```\n\nOver MCP it is the `extensions` list on `add_resource`; on the API it is the\n`extensions` field of the resource's PUT body,\n`{\"type\":\"postgres\",\"extensions\":[\"vector\",\"postgis\"]}`. `--ext` takes one name\nand is repeated, like `--deps` and `--env` — not a comma-separated list. The\nrules are the same everywhere:\n\n- **It is the whole set, not a delta.** `--ext vector` on a postgres that has\n  `vector` and `postgis` asks for postgis to go. To add one, restate every one it\n  already has plus the new one — `gg status` lists what it has.\n- **Leave it out and the extensions stay as they are**, exactly like `--size`.\n  An empty list (`[]`, or `--ext \"\"`) means none.\n- **Only a postgres has them.** `extensions` on any other type is refused with\n  `no_extensions`.\n- **On create, they exist before the database is first ready.** Adding one to\n  an existing postgres is **immediate, on the running server, with no\n  restart** — every postgres runs the same image with all of them compiled in.\n- **Dropping one asks no one** — the one removal that does not, because a drop\n  refuses rather than loses anything, so a drop that succeeds cost nothing.\n  **It is never CASCADE**: a column, an index, a view or a SQL-standard\n  function that uses the extension — a `vector` column, say — stops it. **And\n  it is refused while the extension's own tables hold the user's data**:\n  pg_cron's jobs (`cron.job`) and their run history, pg_partman's partition\n  config (`partman.part_config`), a spatial reference system the user added to\n  PostGIS's `spatial_ref_sys`. Nothing depends on those tables, so without the\n  guard a plain DROP would delete every scheduled job. Either refusal is\n  `extensions_failed` (HTTP 409), carrying postgres's own reason — \"column e\n  of table items depends on type vector\", or \"extension pg_cron holds 1 row(s)\n  of your data in cron.job; remove them first if losing them is what you\n  mean\". It is one transaction, so a refused change changes nothing — not the\n  extensions, and not the rest of what the command restated. To really drop\n  it, remove what is in the way first — and ask your human before deleting\n  their jobs or data to do it. A plpgsql function that uses the extension is\n  not tracked by postgres, so it breaks when next called; nothing is lost, and\n  adding the extension back mends it.\n- **Requirements are added for you.** Asking for `earthdistance` also gives\n  `cube`.\n- **Ask the platform; do not run `CREATE EXTENSION` by hand** for anything in\n  the catalogue below. `app` is a superuser in its own pod and *can*, but what\n  it creates that way is not recorded in `extensions`: the platform does not\n  know about it, the status does not show it, and nothing keeps it. Asking the\n  platform records it and keeps it.\n\n**The catalogue — everything `extensions` accepts:**\n\n| name | what it is for |\n|---|---|\n| `vector` | pgvector: vector columns with HNSW and IVFFlat indexes, for embeddings |\n| `postgis` | PostGIS: geometry and geography types, spatial indexes and functions (no raster) |\n| `pg_cron` | scheduled SQL, run by the database itself (jobs run in database `app`) |\n| `pg_partman` | partition management, created in schema `partman` |\n| `pgaudit` | audit logging to the resource's log (set `pgaudit.log` to turn it on) |\n\nPlus the contrib extensions that ship with postgres: `pg_stat_statements`,\n`pg_trgm`, `pgcrypto`, `uuid-ossp`, `citext`, `hstore`, `ltree`, `unaccent`,\n`fuzzystrmatch`, `btree_gin`, `btree_gist`, `cube`, `earthdistance` (adds\n`cube`), `intarray`, `tablefunc`, `amcheck`, `pg_buffercache`.\n\n- **\"pgvector\" is called `vector`.** That is its name in postgres, and asking\n  for `pgvector` is refused with a hint saying so. There is no pgvector\n  resource type: embeddings in a postgres are this extension.\n- **Not offered:** timescaledb (its licence forbids exactly a hosted service),\n  raster, `dblink`/`postgres_fdw`/`file_fdw`, untrusted languages. Any name\n  outside the catalogue is refused with `unknown_extension`, and the hint lists\n  every name that is offered.\n- Nothing else about the postgres changes: the same connection variables, sizes,\n  storage, price, rotation and nightly backups.\n\n### Connecting one: the single call\n\n```\ngg deps add shop/api db\n```\n\nThat declares the dependency **and** puts the database's connection variables in\n`api`'s environment. It prints what arrived:\n\n```\napi reaches db, and nothing else.\n\napi now holds DB_DATABASE, DB_HOST, DB_PASSWORD, DB_PORT, DB_URL, DB_USER\n  in its environment, from the resources it reaches. Values: gg resource secrets.\n```\n\nOr declare it on the deploy, so the service never starts without them:\n`gg deploy shop/api:8080 api:v3 --deps db`.\n\n**The variables are named after the resource, not the protocol** — the resource's\nown name, upper-cased with dashes as underscores, plus a suffix:\n\n| suffix | postgres | valkey | qdrant | iggy | rabbitmq |\n|---|---|---|---|---|---|\n| `<NAME>_URL` | `postgres://…?sslmode=disable` | `redis://:pass@…` | `http://vectors:6333` | `iggy://root:pass@events:8090` | `amqp://app:pass@jobs:5672/%2F` |\n| `<NAME>_HOST` | ✅ | ✅ | ✅ | ✅ | ✅ |\n| `<NAME>_PORT` | 5432 | 6379 | 6333 | 8090 | 5672 |\n| `<NAME>_GRPC_PORT` | — | — | 6334 | — | — |\n| `<NAME>_HTTP_PORT` | — | — | — | 3000 | 15672 |\n| `<NAME>_USER` | ✅ | — | — | `root` | `app` |\n| `<NAME>_PASSWORD` | ✅ | ✅ | — | ✅ | ✅ |\n| `<NAME>_API_KEY` | — | — | ✅ | — | — |\n| `<NAME>_DATABASE` | ✅ | — | — | — | — |\n\nAn `s3` bucket publishes none of these. It publishes five of its own:\n`<NAME>_ENDPOINT`, `<NAME>_REGION`, `<NAME>_BUCKET`, `<NAME>_ACCESS_KEY_ID` and\n`<NAME>_SECRET_ACCESS_KEY` — see its section below. While it is public it also\npublishes `<NAME>_PUBLIC_URL`.\n\nA postgres called `db` publishes `DB_URL`; one called `orders-db` publishes\n`ORDERS_DB_URL`; a valkey called `cache` publishes `CACHE_URL` and no\n`CACHE_USER`, because valkey has no users. A type omits the suffixes it has no\nanswer for rather than publishing them empty — so an absent `VECTORS_PASSWORD`\nis not a bug, it is a qdrant having no password. Two consequences, and both are\nthe point: a service can reach two databases without a collision, and there is\none vocabulary of suffixes rather than a different set per type.\n\n**These are not the names your framework expects, and that is deliberate.** There\nis no `DATABASE_URL`, no `PGHOST`, no `REDIS_URL`, no `QDRANT_URL` unless the\nresource happens to be called `qdrant`. The first thing to try is to have the\napplication read `DB_URL` — one line in the app, and nothing about it can go\nstale.\n\nIf you genuinely cannot change the application, read the value out and pass it\nunder the name it wants:\n\n```\ngg deploy shop/api:8080 api:v3 --deps db \\\n  --env DATABASE_URL=\"$(gg resource secrets shop/db --format json | jq -r .env.DB_URL)\"\n```\n\nNote what that is: **a copy**, and the only stale thing in the model. `$DB_URL`\nalone would not work — the injected variables exist inside the pod, not in the\nshell running `gg`. Say so rather than leaving a second copy of a password in a\ndeploy nobody remembers making.\n\nFour rules that follow, and each one fails quietly if you get it wrong:\n\n- **Injected variables outrank your own.** Set `DB_URL` on a deploy while the\n  service also reaches a resource called `db`, and the resource wins. It is the\n  one place something beats what a deploy said, and the reason is that only the\n  resource knows the real password.\n- **Nothing is copied into the stored environment.** The platform unions these in\n  every time it renders the pod, from the graph as it stands then. They cannot go\n  stale, no redeploy can forget them, and **a rollback restores the image and the\n  environment you deployed with, never an old password.** `gg deps rm` takes them\n  away just as surely.\n- **Holding the credentials is not enough.** The network policy is a separate\n  boundary from the environment. You cannot get the credentials without the\n  declaration that opens the route, so this is no longer a trap — but do not\n  conclude from a working password that the route is open for some *other*\n  service you did not declare.\n- **`gg resource secrets` is for reading the values from outside the graph** —\n  checking what an application is being handed, or wiring up a client that runs\n  outside Gagarin. The values name the in-project host, which this machine\n  cannot reach: to actually connect from here, `gg connect` opens a tunnel and\n  prints them rewritten for it. You do not need either to connect a service in\n  the same project. Treat the output as a live credential: do not echo it into\n  a chat, a commit, or a summary.\n- **`--names` when the question is \"what does it publish\"**, which it usually\n  is: what a bundle holds, or what a key is called before you change it. It\n  asks a different endpoint, so the values are not fetched rather than merely\n  not printed — nothing secret passes through you. `gg status` cannot answer\n  this: it prints `DB_*`, the prefix rule rather than the contents.\n\n```\ngg resource secrets shop/db --names         # just the names — reach for this first\ngg resource secrets shop/db > .env.db       # KEY=VALUE lines into a file, for --env-file\ngg resource secrets shop/db --format json | jq -r .env.DB_URL > db.url   # one value, into a file\n```\n\n### Meddling from this machine: `gg connect`\n\n```\ngg connect shop/db\n```\n\nA resource is not on the internet, and stays off it. When a human needs psql\nagainst the real database — a migration to babysit, a row to look at — this\nopens a tunnel from this machine and prints the same variables a service would\nhold, rewritten to point at 127.0.0.1:\n\n```\ndb is a postgres. The tunnel is up:\n\n  DB_HOST=127.0.0.1\n  DB_URL=postgres://app:…@127.0.0.1:5432/app?sslmode=disable\n  ...\n```\n\n- **It lasts exactly as long as the command.** Ctrl-C closes the tunnel and\n  every connection through it. Nothing is exposed, and there is nothing to\n  undo afterwards.\n- **It is for the machine gg runs on, never for services.** A service reaches\n  a resource by declaring it — `gg deps add shop/api db` — which needs no\n  tunnel and survives any command exiting. Do not leave `gg connect` running\n  as plumbing under an application.\n- **Every port the resource answers on gets a local end** — a qdrant tunnels\n  6333 and 6334 at once, an iggy 8090 and 3000, and a rabbitmq 5672 and\n  15672 (the management UI is then at `http://127.0.0.1:<local port>`). Each prefers its own number and quietly takes a free\n  one when that is busy; `--port` pins the primary, and is refused rather than\n  moved when the port is taken.\n- **An external is refused** (`not_tunnelable`), and an s3 is refused by `gg`\n  itself (\"publishes no port to tunnel to\"): nothing runs, so there is nothing\n  to tunnel to. Their values are `gg resource secrets`.\n- **The resource must be running.** A stopped one refuses with\n  `tunnel_unavailable`, and `gg status` says what it is waiting on.\n- The printed values are live credentials on a local port, and the same rule\n  as secrets applies: do not echo them into a chat, a commit, or a summary.\n\n### `external`: a third-party key as a node on the graph\n\nAn OpenAI account, a Stripe key, a bucket somewhere else. Not something Gagarin\nruns — something your services need a credential for.\n\n```\ngg resource add shop/openai external --env-file .env.openai\ngg deps add shop/bot openai\n```\n\nAn `.env.openai` holding `API_KEY` and `BASE_URL` makes `bot` hold\n`OPENAI_API_KEY` and `OPENAI_BASE_URL`. Same naming rule as every other type, so\n**write the keys without the prefix** — `API_KEY`, not `OPENAI_API_KEY`, which is\nrefused rather than doubled.\n\n**This is where every third-party credential goes. A deploy env is not an\nalternative.** Why not `--env OPENAI_API_KEY=…` on the deploy? Because a key on a\ndeploy is a copy. Three services using one key means three copies, rotating\nit means three deploys, and a deploy you forget leaves a service authenticating\nwith a revoked key. As a resource it is one row and rotating is one command.\n\n- **Use `--env-file`, not `--env`.** A key on the command line goes into the shell\n  history and into the transcript of every agent that ran the command. Ask your\n  human to write the key into `.env.NAME` themselves; do not ask for it in chat.\n  If they paste one anyway, write it to the file without repeating it, and tell\n  them it is now in this chat's history, so it should be rotated at the provider.\n- **Restating an external is refused** once it exists (`already_exists`). That\n  refusal is deliberate: restating from an old `.env` would roll the key\n  *backwards*, and the failure would be an authentication error nobody would\n  connect to the command they ran. Changing values is `gg resource rotate`, and\n  changing *one* of them is `gg resource rotate --set K=\"$(cat FILE)\"`, which\n  leaves the rest alone and keeps the value off the command line.\n- **It runs nothing.** No container, no port, no size, no storage, no backups,\n  nothing to become ready. `gg status` shows it as `◆` and leaves every\n  container column a dash; what it publishes is `gg resource secrets P/NAME\n  --names`.\n- **Declaring an external does NOT restrict egress.** This is the one thing not to\n  get wrong when you explain it. Everything in a project can already reach the\n  whole internet — the mail ports are the only exception. What the declaration\n  grants is the credentials and a line on the graph saying who uses them. It is\n  **not** a firewall: an undeclared service can still call `api.openai.com`, it\n  just has no key. `gg status` marks these edges `◆` for exactly this reason.\n- **What it is genuinely worth:** the project's dependencies become legible, and\n  destroying an external is refused while anything still declares it, so a key\n  cannot be dropped out from under a running service.\n\n### An external is also where shared config belongs\n\nNot only third-party credentials. **Anything several services read, or that\nchanges without a deploy, belongs in an external** — feature flags, a log level,\na region, an API base URL, a tuning constant.\n\n```\ngg resource add shop/config external --env-file .env.shared\ngg deps add shop/web config\ngg deps add shop/worker config          # both hold CONFIG_LOG_LEVEL\n\ngg resource rotate shop/config --set LOG_LEVEL=debug   # both roll, with the new value\ngg rollback shop/config                                # both roll back\n```\n\n**Why this beats `--env` on each deploy:** the same argument as for a key. An\nenv on a deploy is a copy, so two services sharing a setting is two copies that\ncan disagree, and changing it is two deploys with one you can forget. Resolved\nfrom the graph it is one row, one command, and every holder restarts.\n\n**The editing model is the sharper difference, and it is the one that decides\nthis for you.** A service's environment can be changed only by `gg deploy`, and\na deploy **replaces it wholesale** — every variable not restated is gone. That\nis deliberate, not an oversight: the revision records exactly what the service\nran with, which is what makes a rollback mean something. The cost is that\nchanging one variable requires having all of them.\n\n|  | service env | external |\n|---|---|---|\n| changed by | `gg deploy`, and only a deploy | `gg resource rotate` |\n| granularity | wholesale — anything omitted is **lost** | one key at a time |\n| needs the other values in hand | **yes** | no |\n| undo | `gg rollback P/SVC`, with the deploy | `gg rollback P/config` |\n\n**For you this is a hard edge, not an inconvenience.** Working without the\nproject's `.env` file — from the console's Agent tab, or any session handed a\ntask rather than a repository — you cannot safely change one variable on a\nservice. The only route is to read the whole environment back out of\n`gg history` and restate it, which drops anything you misread and pulls **every**\nvalue the service holds, secrets included, through your transcript.\n\n`gg resource rotate P/config --set KEY=value` has neither problem: it touches the\none key, needs nothing else in hand, and reads no other value. **So when a user\nasks you to change a setting and you do not have their env file, the answer is\nan external — and if the setting is currently in a deploy env, say so and offer\nto move it.**\n\nAnd to find out what a bundle holds before you change one key of it:\n\n```\ngg resource secrets shop/config --names      # names only; no values fetched\n```\n\nUse `--names` by default. Without it the command prints live credentials, and\nin your case that means into a transcript. `gg status` will not answer this\neither — it lists the resource and nothing about its contents.\n\nThe full lifecycle is there, which is what makes it safe to recommend:\n\n| | |\n|---|---|\n| set it | `gg resource add P/config external --env-file .env` |\n| change one value | `gg resource rotate P/config --set LOG_LEVEL=debug` |\n| remove one | `gg resource rotate P/config --unset REGION` |\n| see what it was | `gg history P/config` |\n| put it back | `gg rollback P/config [--to N]` |\n| see what keys it has | `gg resource secrets P/config --names` — no values fetched |\n| read the values | `gg resource secrets P/config` — live credentials; prefer `--names` |\n| who uses it | `gg status P` — and destroying it is refused while anyone does |\n\n**Where the line is.** Config *owned by one service* stays in its `gg deploy\n--env`, because that is the half a service rollback restores. Injected values\nare re-derived from the resources as they stand now — deliberately, so nobody is\never rolled back onto a rotated password — so `gg rollback shop/web` will not\nundo a config change. Undo it at the resource.\n\nThree properties to state when asked, because they are constraints and not\noversights:\n\n- **The prefix is not optional.** A resource named `config` publishes\n  `CONFIG_LOG_LEVEL`, never a bare `LOG_LEVEL`. Name the resource so the prefix\n  reads the way the application wants it.\n- **A dependent cannot override a value.** Injected beats the service's own env\n  of the same name. Two services needing different values is two resources.\n- **Every dependent gets every key** in the bundle. Split by audience, not by\n  topic: one resource per set of services that should hold the same things.\n\n### `s3`: a bucket for files\n\nUser uploads, generated files, ML artifacts, static assets an app serves\nitself. Gagarin's object storage, as an S3-compatible bucket that is private\nuntil you say otherwise.\n\n```\ngg resource add shop/files s3\ngg deps add shop/web files\n```\n\n`web` now holds `FILES_ENDPOINT`, `FILES_REGION`, `FILES_BUCKET`,\n`FILES_ACCESS_KEY_ID` and `FILES_SECRET_ACCESS_KEY` (same prefix rule as every\nother type). There is **no `_URL`, `_HOST`, `_PORT`, `_USER` or `_PASSWORD`** —\nan S3 client takes these five settings separately. Any S3 client library works\n(boto3, the AWS SDKs, …); **pass the endpoint and the region explicitly**, or it\nwill look for AWS. The endpoint is `https`.\n\n- **`--size`, `--storage` and `--env` are all refused** (`no_size`,\n  `no_storage`, `no_env`). A Gagarin without object storage configured answers\n  `object_storage_unavailable` (HTTP 501); report it.\n- **It runs nothing.** No pod, no port, no volume, no logs. Gagarin mints its\n  key, like postgres — unlike an external.\n- **A bucket is private by default.** Only its own key can read or write it;\n  another project's key cannot.\n- **`gg resource public P/NAME` makes the whole bucket listable and readable by\n  anyone**, no key needed. Writes still need the key. Every dependent then gets\n  `<NAME>_PUBLIC_URL` (`https://<bucket>.s3.fr-par.scw.cloud`) and is restarted\n  for it; `gg resource private P/NAME` undoes it and the variable goes away. Both\n  are idempotent, need the editor role and a deploy-scope credential, and\n  `publish_failed` changed nothing, so run it again. The public address also\n  shows in `gg status` among the project's domains.\n  - **Only make public what is genuinely meant to be public.** Listing exposes\n    every object name in the bucket, not just the ones the app links to, and\n    anything fetched while it was open stays fetched. User uploads that are\n    meant to stay private belong in a private bucket, served by the app (which\n    proxies them or hands out its own signed links). Ask the user before\n    running it.\n  - **Browsers on any site can read it.** Making a bucket public also sets a\n    CORS rule: any origin, `GET` and `HEAD` only, no credentials. So\n    `fetch()` of an object or the listing, web fonts, ES modules and\n    `<img crossorigin>` (and reading a canvas) work. It adds no exposure, since\n    a public object was already readable with curl, and writes still need the\n    key. `gg resource private` removes it. A bucket made public before this\n    existed gets it by running `gg resource public` again. The tenant cannot\n    set CORS itself.\n  - **Egress is not metered per bucket yet.** Say so to the user when a public\n    bucket is going to carry heavy traffic (a download host, a busy site's\n    images).\n- **Declaring it does NOT restrict the network.** It is reached over the\n  internet, not inside the cluster, so — exactly like an external — the\n  declaration hands over the key and nothing more. It is not a firewall. `gg\n  status` marks these edges `◇`.\n- **There are no backups.** Objects sit on durable storage but Gagarin takes no\n  copy, and `gg resource backup` answers `backup_unsupported`. If losing the\n  data would matter, keep a copy somewhere else.\n- **`gg connect` does not work**: it publishes no port, and `gg` says so. Read\n  the values with `gg resource secrets`.\n- **It costs $0.03 per GB-month** of what it actually holds, measured hourly,\n  rounded up to whole GB and prorated per minute. There is no running charge,\n  and requests and traffic are not billed.\n- **Not deployable, not rollback-able, no `gg domain`.** `gg deploy` over it is\n  `not_a_service`, as is `gg rollback` (Gagarin mints its key). Its public\n  address comes from `gg resource public`, not from a domain.\n- **Destroying it** needs the human's email approval, is refused while anything\n  still declares it, cuts the key off at once, and permanently deletes every\n  object shortly after.\n\nA bucket the user already has somewhere else is still an `external`.\n\n### Rotating credentials\n\n```\ngg resource rotate shop/db                                        a database\ngg resource rotate shop/openai --set API_KEY=\"$(cat new.key)\"     one of an external's values\ngg resource rotate shop/openai --env-file .env.new                all of them\n```\n\nEverything holding the old credential is restarted with the new one, and the\ncommand names what it rolled. Nothing but variable *names* is printed;\n`gg resource secrets` reads the values, into a file.\n\n**Who supplies the new value is the only difference between the types.** For\n`postgres`, `qdrant`, `valkey`, `iggy`, `rabbitmq` and `s3`, Gagarin mints one and `--env` is refused — a\npassword you chose is one the running server has never heard of. For an\n`external` the values are yours, so one of `--set`, `--unset`, `--env-file` or\n`--env` is required.\n\n**An external usually holds more than one value, and the two ways of changing\nthem mean different things. Reach for `--set`.**\n\n| | what it means |\n|---|---|\n| `--set K=V`, `--unset K` | change these, leave every other key exactly as it is |\n| `--env`, `--env-file` | the bundle is now precisely this; anything not in it **stops being published** |\n\n`--env API_KEY=sk-new` on an external that also holds `BASE_URL` takes `BASE_URL`\naway from every dependent. That is the correct meaning of that request — it is\nthe one to use after a provider migration where every value is new — and the\nwrong one for the far commoner job of replacing a single key. Reading the bundle\nback and restating it is not the answer either: that is the stale-file path, and\nit is how a key gets rolled backwards.\n\nThe command names what stopped being published, so a loss is visible at the\nmoment it happens rather than from a dependent that can no longer authenticate.\nThe two flags cannot be combined — they say the same thing in incompatible\nwords.\n\n`--unset` names a key **without** the resource's prefix, the way it was set:\n`--unset BASE_URL` on `shop/openai`, not `OPENAI_BASE_URL`. A key the resource\ndoes not publish is refused rather than quietly doing nothing, because a no-op\nreported as a success is how somebody believes a secret is gone when it is not.\n\n| type | what happens | cost |\n|---|---|---|\n| `postgres` | the running server is told immediately | none |\n| `qdrant` | the pod is replaced; the key is read at startup | a few seconds away; **the data survives** |\n| `iggy` | the running server is told the new root password first and it is recorded, then the pod restarts and dependents roll | a few seconds away; **nothing stored is lost**, a graceful stop flushes |\n| `rabbitmq` | the running server is told the new password first, then the pod restarts and dependents roll | a few seconds away; **nothing stored is lost** |\n| `valkey` | the pod is replaced; the password is read at startup | **the cache is emptied** |\n| `s3` | a new key is issued and recorded, dependents restart, then the old key is revoked at once | **not zero-downtime:** their S3 calls fail for the seconds the restart takes; **the objects survive** |\n| `external` | nothing of ours runs, so nothing of ours restarts | none |\n\n**An s3 rotation can revoke late.** If the answer says `old_credential_revoked:\nfalse`, the old key still works: tell the user, and run the rotation again — it\nrevokes the leftover key first.\n\n**If it fails, nothing changed.** The old credential is still in use and the\ncommand is safe to run again — say that, rather than leaving the user wondering\nwhat a half-failed rotation left behind. There is no half.\n\n**Rotate after a leak, and say so plainly.** If a key has been in a chat log, a\ncommit or a screenshot, this is the fix and it is one command. For an external,\nnote that Gagarin forgets the old value but cannot *revoke* it — that is a thing\nto do in the third party's own console, and the user has to do it.\n\n### Backup and recovery\n\nPostgres, qdrant and iggy are backed up nightly and kept fourteen days — postgres as a\n`pg_dump`, qdrant as a tar of its per-collection snapshots with the aliases\nbeside them.\n\n**An iggy backup is taken while the server keeps running.** Only topics created\nwith `--durability persisted` are guaranteed complete; a topic with the default\ndurability may be missing its newest messages, the ones not yet flushed to disk.\nRecommend `--durability persisted` for anything the user would want back. Valkey keeps nothing by design, an external has nothing here to\nkeep, and an s3 bucket is not copied: its objects are on durable storage, but\n`gg resource backup` answers `backup_unsupported`. A rabbitmq is in the same case: it is not backed up at all, so its\ndurability is only what survives a restart (durable queues, persistent messages).\n\n```\ngg resource backups shop/db     what is stored, newest last\ngg resource backup  shop/db     take one now — do this before a risky migration\n```\n\n**Any postgres backup restores into any postgres.** A dump carries its\nextensions and every postgres has every one available, so a database that used\n`vector` or `postgis` comes back with them; the restored resource's\n`extensions` are read back from the database. There is nothing to ask for\nbefore restoring.\n\n`gg resource backup` reads the database and writes an object; it is safe at any\ntime and the nightly schedule keeps running regardless.\n\n**A restore creates a NEW resource — it never overwrites an existing one.** That\nis the platform's rule, not a convention: the name you give must not exist yet,\nand the platform creates the resource itself, which is exactly why a restore\nneeds no human approval and can be reached for at three in the morning.\n\n```\ngg resource restore shop/db2 --source db   new resource, filled from db's newest dump\ngg deps add shop/api db2                   hands api DB2_URL and the rest\ngg deps rm  shop/api db                    and stop it reading the old one\n                                           (this one needs a human's click)\ngg destroy  shop/db                        once everything reads from db2 — the only\n                                           step that destroys data, and the only one\n                                           that asks a human\n```\n\n- **The variables change with the name.** `db2` publishes `DB2_URL`, not\n  `DB_URL`, so an application reading `DB_URL` finds nothing after the `deps rm`.\n  Either name the new resource what the old one was called — possible only once\n  the old one is destroyed — or expect to touch the application. This is the one\n  place the per-resource naming costs something, and it is worth knowing before\n  three in the morning.\n- The old resource **may already be destroyed** when you restore: its backups\n  outlive it by fourteen days and `--source db` still finds them.\n- `--backup <key>` from `gg resource backups` restores an exact point instead of\n  the newest.\n- **The platform does the restore, not the command.** It creates the new\n  resource as the backup's type — recorded with every backup, so there is\n  nothing to say even for a destroyed source — then starts it and pours the data\n  in on its own. `gg resource restore` waits and prints each step by default;\n  stopping it stops nothing. With `--no-wait` it returns at once, and `gg status`\n  shows the restore under the resource until it is done, or why it failed.\n  **Do not `deps add` anything to the new resource before it is done.**\n- A failed restore leaves a resource holding nothing worth keeping: destroy it\n  and restore again under a new name once the cause is fixed.\n- `gg resource backups shop/db` works on a destroyed resource too, and shows what\n  it left.\n\n### Anything we do not have a type for\n\nFour types will never cover everything. Run it as an ordinary service with a\nvolume:\n\n```\ngg registry copy shop/clickhouse clickhouse/clickhouse-server\ngg deploy shop/analytics:8123 clickhouse --volume /var/lib/clickhouse --volume-size 50\ngg deps add shop/api analytics\n```\n\nEverything else behaves the same way: a private address by name, a volume that\nsurvives restarts, and the same refusal to delete it while something still needs\nit. The only difference is who decides — for a resource the platform picks the\nimage, the version and the port and carries them; here you pick them, and\nupgrades, tuning and consequences are yours.\n\n**If a type exists, use the resource. If it does not, this is the normal path,\nnot a workaround.** Gagarin has no type for ClickHouse, Cassandra, DuckDB or a\ndocument store, and that is not an error.\n\nNever write a one-line Dockerfile that only says `FROM` in order to get an image\nin. `gg registry copy` is the same thing, done properly, and it copies every\narchitecture the source published rather than whatever your laptop cached.\n\n## Recipes: a project other people can deploy\n\nA recipe is a published snapshot of a project: its services, jobs, resources,\ndependencies and sizes. Anyone who has the recipe's 8-character id can deploy it\ninto a **new** project of their own. It is never installed into an existing\nproject. Its deploy page is `https://my.gagarin.cloud/deploy/<recipe-id>`, and\na publisher can put this badge in a README:\n\n```\n[![Deploy to Gagarin](https://gagarin.cloud/deploy-button.svg)](https://my.gagarin.cloud/deploy/<id>)\n```\n\nRecipes are not part of `.gagarin.json`. That file still only names the project.\n\n### Publishing: `gg recipe snap`\n\n```\ngg recipe snap shop --dry-run                       what would be published, and the floor\ngg recipe snap shop                                 publish, at the floor version\ngg recipe snap shop --version 1.2.0 --as shop-kit   pick the version and the name\ngg recipe snap shop --source https://github.com/acme/shop --notes \"faster checkout\"\n```\n\nOnly the project's owner can snap. **Run `--dry-run` first**, and show the user\nthe floor and what will be published before you publish. A recipe version is\nimmutable once it exists.\n\n**Env in a recipe never holds secrets.** Plain env on a service or a job is\ncopied as it is, so anything secret-shaped must not be there. Secrets belong in\nan `external` resource. A recipe keeps the external's variable names and never\ntheir values, and each name becomes an input the deployer supplies. If snap\nanswers `env_looks_secret`, it names the variables:\n\n```\ngg resource add shop/stripe external --env-file stripe.env\ngg deps add shop/api stripe\ngg deploy shop/api:8080 api:v3                      restate the env without them\ngg recipe snap shop                                 and snap again\n```\n\nDo not rename a variable to get past the check. Move the value to an external.\n\n### The floor\n\nEach snap has a lowest allowed version, worked out from the previous one:\n\n- a removal, a rename, a volume change or a type change forces a **major**\n- an addition, or a bigger monthly bill, forces at least a **minor**\n- anything else is free, and may be a patch\n\nOmit `--version` to take the floor. A version below it is refused\n`version_below_floor`, and the dry run prints the reasons.\n\n### Reading\n\n```\ngg recipe show a1b2c3d4                  the graph, inputs, monthly cost, deploy URL\ngg recipe show a1b2c3d4@1.2.0            one version\ngg recipe show a1b2c3d4 --format json    the manifest, for reading by a program\ngg recipe ls                             the recipes this account published\n```\n\n`show` works on any recipe id, not only your own. Read it before you install,\nand tell the user what it will cost and which inputs it wants.\n\n### Installing: `gg recipe install`\n\n```\ngg recipe install a1b2c3d4 shop --input stripe=stripe.env\ngg recipe install a1b2c3d4@1.2.0 shop --input stripe=stripe.env --input mail=mail.env\n```\n\nAlways a new project: `NEW_PROJECT` must not exist yet. Pass one `--input\nNAME=FILE` for every input the recipe declares, which `gg recipe show` lists.\nEach file is an env file. **Never put a value on the command line.** Ask the\nhuman for the values, write them to the file, make sure the file is\ngitignored, and delete it when the install finishes. gg refuses up front when a\ndeclared input has no `--input`, and it never prints what a file holds. The\ninstall copies the images into the new project, then starts everything. It ends\nwith the project's status, so follow the usual rule and read it before you\npromise a URL.\n\n### Updating\n\n```\ngg recipe diff shop                      what the newest version would change\ngg recipe diff shop --to 1.3.0\ngg recipe update shop                    apply it\ngg recipe update shop --to 1.3.0 --input mail=mail.env\ngg recipe update shop --force            overwrite what was changed by hand\n```\n\nAn update is the patch between two versions, not a reinstall. Always `diff`\nfirst and tell the user what changes. A new input needs its `--input` file, the\nsame as an install. An update that **removes** something needs a human's\napproval, like any destroy. If the project was changed by hand where the patch\nalso changes it, the update refuses with a conflict. Ask the user before you\npass `--force`, because it overwrites their change.\n\n### Removing\n\n```\ngg recipe rm a1b2c3d4@1.2.0              one version\ngg recipe rm a1b2c3d4                    the recipe, and every version\n```\n\nThis needs a human's approval, like every destroy: follow \"Destroying things\".\nProjects already installed from the recipe keep running.\n\n## Addresses\n\nA service is private until it is given an address, and one command gives it\neither kind:\n\n```\ngg domain add shop/web                     an address gagarin generates\ngg domain add shop/web shop.example.com    a name the user owns, as well\ngg domain ls  shop                         every address, and who each is waiting on\n```\n\nThe generated one is idempotent and instant: Gagarin holds the wildcard record\nand the wildcard certificate for the project's cluster, so there is nothing to coordinate and nobody to\nwait for.\n\n**A name the user owns is two steps, and only the first is Gagarin's.** The\ncommand makes the service answer for the name; making the name *resolve* here is\na DNS record the user creates at their registrar, and Gagarin cannot do it for\nthem. The command prints the exact record — pass it on verbatim rather than\nparaphrasing it.\n\n**Nothing is served over HTTPS on that name until the record exists.** Let's\nEncrypt proves control by fetching the domain over the internet, so a certificate\ncannot be ordered before DNS points here. That is the normal first state, not a\nfault: do not retry the command hoping it resolves, because the missing piece is\non their side. `gg status` says which of the two of you it is waiting on:\n\n| reading | who acts |\n|---|---|\n| waiting for DNS | **them** — the record does not exist at the zone's own nameservers |\n| DNS points elsewhere | **them** — it resolves, but not to Gagarin |\n| waiting for cache revalidation | **nobody** — the record is right; a resolver is still holding its old answer, and it clears within the zone's negative TTL |\n| issuing certificate | Gagarin — nothing for them to do |\n| ok | nobody |\n\nGagarin orders the certificate only once the zone's own nameservers point the name\nhere, so claiming a name before creating the record is harmless. On `waiting for\ncache revalidation`, do not touch the DNS record and do not retry; tell the user it\nclears by itself (often 15–60 minutes) and the certificate follows.\n\nThe generated address only ever reads `ok` or `issuing certificate`. It is never\nwaiting on the user, because there is nothing for them to do about it.\n\n- **A deploy never changes an address**, in either direction. Forgetting a flag\n  would otherwise take a live site down while the owner's DNS still looked right.\n- **Both addresses answer.** A service with a custom domain keeps its generated\n  one, so existing links do not break and there is something to test against\n  while DNS propagates.\n- **A custom domain brings the generated one with it.** Claiming a name for a\n  private service makes it public in the same call. Say out loud that you are\n  putting it on the internet.\n- **One domain, one service, across all of Gagarin.** A name somebody else holds\n  is refused, and the refusal does not say who holds it.\n- **A subdomain is told a CNAME to the cluster's name**, such as\n  `CNAME fr-par-1.apps.gagarin.cloud`, not to the old shared `apps.gagarin.cloud`.\n  Pass on the target the command prints; it depends on the project's cluster.\n- **An apex domain gets an A record, not a CNAME** — DNS does not permit a CNAME\n  at an apex. The command prints the right one; do not \"correct\" it.\n\n### Taking an address away\n\n```\ngg domain rm shop/web shop.example.com    release a name they own\ngg domain rm shop/web                     make the service private again\n```\n\n**Both need a human's approval, every time** — the same emailed click `gg\ndestroy` and `gg deps rm` need. This is destructive in the way deleting something is: what breaks\nis invisible from the terminal and obvious to whoever was using the address. Do\nnot run either unless the user asked for it in those words.\n\nReleasing the generated address while a custom name is still declared is refused\n(`domain_attached`) — that would leave their DNS pointing at a host Gagarin no\nlonger serves. Release the custom name first.\n\n## Reading state\n\n`gg status <project>` reports desired state and actual cluster state side by\nside. Trust it over your own memory of what you deployed: it reads the cluster,\nnot just the database.\n\n```\nproject shop  (id 7f3a9c2e)  fr-par-1\n\n     SERVICE  KIND      SIZE  READY  PORT  REACHES      IMAGE\n  ●  web      service   s     1/1    8080  api          web:1757030400\n  ●  └ https://web-7f3a9c2e.fr-par-1.apps.gagarin.cloud\n  ●  api      service   m     1/1    4000  db, openai◆  api:1757030112\n  ●  db       postgres  m     1/1    5432  —            postgres:17\n  ◆  openai   external  —     —      —     —            —\n  ◇  files    s3        —     —      —     —            —\n\n  ● running   ◆ external (runs nothing; declaring it grants its variables, not egress)\n  ◇ bucket (runs nothing; reached over the internet, so declaring it grants its key, not a network path)\n  $0.412 today so far\n```\n\nWhat to read, in the order it matters:\n\n1. **Lines beginning `!`, when there are any, come before the table because they\n   change what the table means.** There are two:\n   - **\"this project is suspended and nothing is running: …\"** — every service\n     shows `◌` and `0/0`, and writes are refused with `project_suspended`. If the\n     reason is credit, the user fixes it at https://my.gagarin.cloud/billing and\n     services restart by themselves within a few minutes. Anything else is a\n     decision Gagarin made, and only support can lift it — do not tell the user\n     to add credit, because it will not help. **Nothing has been deleted**: the\n     data, the addresses and the certificates are all still there.\n   - **\"the reconciler last ran … ago\"** — Gagarin reporting on itself. The rows\n     are still an accurate reading of the cluster, but nothing is closing the gap\n     between them and what was asked for. Tell the user; there is nothing an\n     agent can do from here.\n2. **The state mark.**\n   - `●` **running** — the cluster is running what was asked for, and something\n     answers on the declared port.\n   - `◐` **starting** — in flight: pulling, booting, waiting on an ingress. The\n     cluster has not given up and neither should you.\n   - `○` **failing** — either nothing is in the cluster at all, or Kubernetes has\n     stopped calling this a rollout in progress. Waiting will not fix it.\n   - `◌` **stopped** — the project is suspended. See the `!` line.\n   - `◆` **external** — runs nothing, so it has no state to be in.\n   - `◇` **bucket** — an `s3`: runs nothing either, and its edges read `files◇`.\n   - `✓` **done** — a job whose latest run finished with exit code 0. A job\n     whose run failed is `○`, and the line under the table gives its exit code.\n   - `◷` **scheduled** — a scheduled job that has not fired yet. Waiting, not\n     wrong: its line says when it fires next.\n3. **`◐` and `○` print the cluster's own explanation below the table.** Read it\n   before changing anything.\n4. **READY counts pods of the revision you asked for.** A redeploy that will not\n   start reads `0/1` even while the previous version is still serving traffic.\n   That is the honest number: the service is answering, but not with what you\n   shipped. For a job the cell is the latest run's phase instead — `done`,\n   `failed`, `running`, `pending` — its PORT is a dash, and the line under the\n   row says which run, when, how long, the exit code, and for a failed run the\n   cluster's reason: `○  └ run 4 failed 2 minutes ago after 3s, exit 2: the\n   container exited with code 2`. A scheduled job's cell also carries its\n   schedule (`⏱ 0 3 * * *`), and its line ends with when it fires next\n   (`· next in 21h`) or that the schedule is suspended with the project. A scheduled firing whose TTL\n   passed still shows, ending \"(removed after its ttl)\"; `gg logs` keeps its\n   output. A one-shot job past its TTL is not listed at all.\n5. **Addresses hang under their service**, marked `●` when there is nothing left\n   to do and `○` with who is holding it up when there is. An address that is fine\n   says nothing more than its own URL.\n6. **KIND and VOLUME columns appear only when the project has something to put in\n   them**; SIZE is always there.\n7. **The last line is the day's accrued cost**, in thousandths of a dollar.\n\nOther readers:\n\n```\ngg projects                 every project you can reach, its id, and your role\ngg logs shop/web            recent logs; needs a running pod (logs_unavailable if not).\n                            For a job: what its latest run wrote\ngg history shop/web         every deploy, newest first, the live one marked →\ngg deps ls shop/web         what it may reach\ngg domain ls shop           every address and its state\ngg creds                    every credential, the one you are using marked *\n```\n\nWhen somebody wants to understand how their services fit together, point them at\nthe project's page on https://my.gagarin.cloud — its right half is a live\ndependency graph. That is for the human; read the plain output yourself.\n\nDescribe services at the altitude Gagarin does: \"web is public on port 8080 at\n<url>; worker is private.\" Give every address a service answers on, not just one.\nDo not introduce Kubernetes vocabulary — namespaces, ingresses, pods and service\naccounts are not part of this model, and mentioning them is a regression.\n\n## Undoing a deploy\n\n```\ngg history  shop/web          revision numbers, images, when, and who —\n                              an image tagged with a short hash is that commit\ngg rollback shop/web          put the previous deploy back\ngg rollback shop/web --to 3   a particular revision\ngg rollback shop/config       put an external's previous values back\n```\n\n- **A rollback is a deploy.** It goes through the same write gate and is recorded\n  as a *new* revision naming the one it restored. Nothing leaves the history, so\n  changing your mind is another rollback rather than a lost record.\n- **It restores the image and the environment**, exactly as that revision had\n  them. A variable added since is gone afterwards.\n- **It does not restore the dependency graph, the domain or the volume.** Those\n  are standing declarations about the shape of the project rather than parts of\n  the artifact, and putting yesterday's image back says nothing about them.\n- **It never restores an old password.** Resource variables come from the graph\n  at pod-start, not from the revision.\n- **It is refused across a change of volume** (`volume_immutable`). Deploy the\n  configuration you want instead.\n\nPrefer a rollback to a corrective deploy when something you just shipped is\nbroken and you do not yet know why: one call, a state that provably ran, and the\nevidence left intact for afterwards.\n\n## Alerts\n\nA project can tell its members when something breaks. Alerts are Web Push\nnotifications from the console (https://my.gagarin.cloud), which is also a PWA.\nEach member opts in per project for themselves, viewers included, and the\nnotifications go only to that member's own devices. There is no topic, server\nor token to set up.\n\n**A human turns alerts on, in the console.** The project's Alerts tab,\n`https://my.gagarin.cloud/projects/P/alerts`, has one switch, \"Notify me about\nthis project\", which allows notifications on that device and opts the member in\nat once, and sends a test from the same page. Point the human there, on the\nphone they want the push on. Turning the switch off there opts them out.\n\nThere is no gg command for alerts (`gg metrics` is for the numbers, below):\ntalking the human through that page is your part. With the MCP server connected, `alerts` says whether the caller is opted\nin, how many devices they have, and the last few notifications; `test_alerts`\nsends a test once they say it is on; each takes only the project. Opting in is\nper member, so one member turning alerts on does not turn them on for anyone\nelse.\n\n**An agent cannot add a device.** A device exists only once a human allows\nnotifications in a browser, at `https://my.gagarin.cloud/projects/P/alerts`. On\nan iPhone the app must first be added to the Home Screen (Share, then Add to\nHome Screen) and opened from there, or the browser will not offer push at all.\nIf the human has no device yet, hand them that page. Then they hear\nwhen a service has been down for three minutes, when a deploy will not start\n(the previous revision keeps serving), and when a container crashes and\nrestarts, once when it starts and once when it ends, never on repeat. The\nconsole keeps a 30-day feed of these notifications. Four more come from the\nmetrics, each also once when it starts and once when it resolves: memory at 80%\nof its limit or more for 5 minutes (resolves under 75%); CPU at 80% of its\nlimit or more for 10 minutes (resolves under 70%); a volume 85% full (resolves\nunder 80%); and 5% or more of requests answered with 5xx over 5 minutes, with\nat least 20 requests (resolves under 2%). Tapping one of these opens that\nservice's graphs. They are part of the same fixed set. There are no rules or\nthresholds to choose. Offer alerts after a first deploy that a human cares\nabout; do not turn them on without asking, because the notifications go to somebody.\n\nThe old ntfy alerts are gone: `--server`, `--topic` and `--token` no longer\nexist, and sending them is refused with `ntfy_removed`.\n\n## Metrics\n\nEvery cluster keeps a metrics store, 30 days deep. For each service, and each\nresource (postgres, qdrant, iggy, rabbitmq, valkey), it holds CPU used against\nits limit (cores), memory against its limit (bytes), volume disk used against\nits size, CPU throttling (the share of periods), and network in and out\n(bytes/s); for a service with a public address, also requests/s, the share of\n5xx and p95 latency. Windows are `1h`, `24h`, `7d` and `30d`. A figure that was\nnot measured is `null`: a service that just started, no volume, no address.\nFigures appear a minute or two after a service starts.\n\n- `gg metrics PROJECT` is a table of every service now: kind, CPU, memory,\n  disk, throttling and network, plus req/s, 5xx and p95 for the public ones.\n- `gg metrics PROJECT/SVC [--window 1h|24h|7d|30d]` gives the last value and\n  when it was taken, average, peak and limit for each figure over the window.\n- In MCP, `metrics` takes `{project, service?, window?}`: project-wide figures\n  now, or one service's last (with `last_at`)/avg/peak/limit per series over a\n  window. `window` without `service` is refused `window_needs_service`.\n- The console has a **Metrics** tab, `https://my.gagarin.cloud/projects/<id>/metrics`\n  (`?service=NAME&window=24h`).\n\nUse it to answer \"why is it slow\", \"is it running out of memory\" and \"is the\ndisk filling\" from numbers rather than a guess. `gg status` stays the answer to\n\"is it up\". `metrics_unavailable` means the cluster has no metrics store or it\ndid not answer: retry in a minute.\n\n## Sharing a project\n\nA project has exactly one **owner** — the account that pays for it — plus any\nnumber of editors and viewers.\n\n```\ngg members shop                     who can reach it, and as what\ngg share shop teammate@example.com  add an editor (the default)\ngg share shop them@example.com --role viewer\ngg unshare shop them@example.com\n```\n\nAn **editor** operates the project — deploy, delete individual services, manage\nthe roster — without paying for it. A **viewer** reads status, logs and the\nmember list, and nothing else. **Destroying a project is the owner's alone**:\nthat takes its data and its URL with it, and only the account paying can decide.\nOwnership is not on this list because it is the bill, not a role: it is not\ngranted here, it is offered and accepted — see below.\n\n- `gg share` with no `--role` grants **editor**, which can deploy over whatever\n  is running. If the user asked for \"read access\" or \"let them look at the logs\",\n  pass `--role viewer`.\n- Sharing with somebody who has never used Gagarin is allowed — the access waits\n  for them and lands the moment they sign in with a GitHub or Google account\n  whose verified email is that address. **Nothing is emailed to them**, so tell\n  the user to let them know; they get in by running `gg login` and approving it,\n  as in \"Getting access\".\n- **Ask before sharing.** Access to a project is the user's to give, not yours to\n  infer from a name in the conversation.\n\n## Handing a project over\n\nSharing gives access away. `gg transfer` gives away the **bill** — who pays for\nthe project from that moment on.\n\n```\ngg share shop them@example.com       first: they must already be a member\ngg transfer shop them@example.com    offer it; nothing changes yet\ngg transfer shop --withdraw          take the offer back\ngg members shop                      shows an offer that is standing\n```\n\nIt is an offer, never an assignment, and both halves need a human:\n\n1. The **owner** runs `gg transfer` and gets `approval_required` — they click a\n   button in their own inbox, signed in to Gagarin, and you run the same command\n   again. This is the\n   same human gate `gg destroy` uses, for the same reason: a handover cannot be\n   undone by the person who started it.\n2. The **recipient** gets an email and presses a button. Until they do, nothing\n   has changed and `gg members` still shows the old owner. **Tell the user this**\n   — a transfer that is \"done\" from the CLI is a transfer that has not happened.\n\nWhat happens when they accept: the project keeps its id, services, addresses,\ndata and history — **nothing restarts**. Usage is billed to the new owner from\nthat moment, and to the old owner up to it. The **previous owner becomes an\neditor**, so they keep operating it and stop paying for it; the new owner can\n`gg unshare` them like anyone else.\n\n- **Only the owner can offer**, and only to somebody already on the roster. Share\n  first.\n- If the recipient already has a project by that name, pass `--as NAME` — names\n  are unique within an account, and this is what the project is called in theirs.\n- The recipient's account has to be able to carry it: not suspended, has a card\n  or a balance, and under their project limit. The refusal comes back to the\n  owner with the fix in it — those are things the two of them sort out before\n  anybody clicks.\n- `gg unshare` on the person an offer was made to **withdraws the offer too** —\n  an offer only ever goes to a member, so taking the access away takes the offer\n  with it.\n- **Never offer a project the user has not explicitly asked you to hand over.**\n  This is the one command that ends with them not paying for something they no\n  longer own, and no amount of context makes it inferable.\n\n## Diagnosing\n\nStart from the symptom, not from the logs.\n\n| symptom | first suspect | what to run |\n|---|---|---|\n| a service never becomes ready | the declared port; the app binds elsewhere or on `127.0.0.1` | `gg status`, then redeploy on the port the app really binds |\n| `ImagePullBackOff` | the image is not there — a copy that never finished, or a tag that does not exist | `gg history`, then push or copy the image again |\n| the container starts and exits | a missing environment variable, or a crash | `gg logs shop/web` |\n| killed with no log output | out of memory | `gg status` names the size to move to |\n| one service hangs calling another | a missing `gg deps` edge — an undeclared call is dropped, not refused | `gg deps ls shop/api`, or the REACHES column |\n| a database driver times out | the same, or the app is not reading `<NAME>_URL` | `gg deps ls`, then `gg resource secrets` to see what it should hold |\n| you need to look inside the database itself | it is not on the internet, by design | `gg connect shop/db`, then psql or redis-cli against the printed URL |\n| an SMTP connection hangs | ports 25, 465 and 587 are blocked platform-wide | use a provider's HTTPS API; nothing to fix here |\n| a custom domain serves no HTTPS | DNS does not point here yet | `gg domain ls`; the record is the user's to create |\n| everything shows `◌` and `0/0` | the project is suspended | read the `!` line above the table |\n| `docker push` returns 401 in CI | docker was never logged in | `gg registry login` |\n\n**\"nothing is listening on port N\" is the common one**, and it is almost always\nthe port rather than the app. Gagarin asks the container every few seconds\nwhether anything accepts a connection on the port you declared, so a service that\nboots perfectly well and listens somewhere else never becomes ready. Many\nframeworks also default to `127.0.0.1`, which nothing outside the container can\nreach — they need `0.0.0.0`.\n\n**\"the previous revision is still serving\"** on a redeploy means the old version\nis up and answering. The user is not down. Fix the new revision and ship again;\ndo not tear anything down first.\n\n**Out of memory names its own fix**, in `gg status`:\n\n```\nthe container ran out of memory and was killed (it exceeded the 1Gi ceiling of\nsize s); try --size m, which gets 2Gi\n```\n\nRedeploy at the size it names. Do not retry unchanged — it will be killed again —\nand do not go hunting in the logs first, because a process the kernel killed for\nusing too much memory usually writes nothing about it. This is the one failure\nyou can resolve without asking the user anything, so resolve it.\n\nDo not poll in a tight loop, and do not tell the user something is live because a\ncommand exited zero.\n\n## Error codes\n\ngg prints failures as `[code] message`, usually with a `hint:` line under it.\n**Branch on the code.** The message is for the human.\n\n**Access and credentials**\n\n| code | what to do |\n|---|---|\n| `unauthorized` | this machine has no usable credential — run `gg whoami`, then \"Getting access\". Never ask the user for a token |\n| `insufficient_scope` | this credential does not carry that right; a browser session cannot deploy. Deploy from the CLI — the dashboard has no deploy button on purpose |\n| `cannot_delegate` | a minted credential tried to mint another. Mint it from the machine a human approved |\n| `name_required` | `gg creds create` with no `--name`. Name it after where it will live |\n| `invalid_expiry` | `--expires` outside 1–365 days. There is no never; omit it for 90 |\n| `name_too_long` | over 120 characters, and it appears in a list. Shorten it |\n| `approval_required` | a human must approve a deletion, a released address, a withdrawn dependency, or an ownership offer. The button is in their email, and it asks them to sign in first if they are not. Tell the user, pass on the code, wait, retry the same command. One click covers fifteen minutes, so a sequence of these needs one approval, not several |\n| `authorization_pending` | nobody has approved the `gg login` request yet. Relay the link again if needed; run `gg login` again once the user says they approved |\n| `expired_token` | the `gg login` request lived fifteen minutes and nobody approved it. Run it again and pass on the new link |\n| `access_denied` | the user declined `gg login` on the page. Ask them before running it again |\n| `github_account_too_new` | the user's GitHub account is under 30 days old. The `gg login` request is still good: they open the same link, choose Continue with Google, approve, and you run `gg login` again |\n| `invalid_email` | the address given to `gg share` or `gg transfer` is not one. Ask the user again; do not guess |\n\n**Projects and roles**\n\n| code | what to do |\n|---|---|\n| `project_not_found` | no such project, **or** you cannot reach it. `gg projects` lists what you can; `gg init` creates one; otherwise ask for a `gg share` |\n| `project_suspended` | the project accepts no writes; reads still work. Out of credit: the user adds some at https://my.gagarin.cloud/billing and it restarts itself. Anything else: only support can lift it — tell the user and stop |\n| `project_limit` | destroy one that is no longer needed, or the user writes to support@mail.gagarin.cloud |\n| `project_exists` | you already have one by that name. Names need only be unique within your account |\n| `invalid_name` | lowercase letters, digits, hyphens; start with a letter; 2–30 characters |\n| `insufficient_role` | you are a viewer here. Ask the owner or an editor for edit access; do not retry |\n| `owner_only` | only the paying account may do this. Tell the user to run it themselves; nobody can grant it |\n| `invalid_role` | roles are `editor` and `viewer`; `owner` is the account that pays |\n| `owner_not_a_member` | that address already owns the project; nothing to do |\n| `member_not_found` | `gg members <project>` shows who has access |\n\n**Handing a project over**\n\n| code | what to do |\n|---|---|\n| `not_a_member` | share it first: `gg share P EMAIL`, then offer it |\n| `already_owner` | they already own it; nothing to do |\n| `name_taken_there` | they have a project by that name. Re-run with `--as NAME` |\n| `recipient_suspended` | their account is stopped; they add credit, then you offer again |\n| `recipient_cannot_pay` | no card and no balance there; the project would be suspended on arrival. They fix it at https://my.gagarin.cloud/billing |\n| `recipient_project_limit` | their account is full; they destroy one, or write to support@mail.gagarin.cloud |\n| `no_offer` | nothing is pending. If it was accepted, the project is theirs and only they can offer it back |\n| `project_suspended` on a transfer | a project suspended in its own right cannot change hands. Only support can lift that |\n\n**Alerts**\n\n| code | what to do |\n|---|---|\n| `alerts_off` | `test_alerts` before alerts are on. The human turns them on with the switch at https://my.gagarin.cloud/projects/P/alerts |\n| `ntfy_removed` | alerts no longer go to ntfy; `server`, `topic` and `token` are refused. The human turns alerts on in the console |\n| `no_devices` | `test_alerts` and the caller has no device. The human allows notifications at https://my.gagarin.cloud/projects/P/alerts (iPhone: add the app to the Home Screen first) |\n| `invalid_subscription` | the browser's push subscription was refused (not https, not a known push service, bad keys). The human re-enables notifications in the console |\n| `push_unconfigured` | the platform has no push keys yet. Nothing to fix on your side; tell the user |\n\n**Metrics**\n\n| code | what to do |\n|---|---|\n| `metrics_unavailable` | 503: the cluster has no metrics store, or it did not answer. Retry in a minute; `gg status` still shows what is running |\n| `no_such_service` | 404 on `gg metrics P/SVC` or `metrics`: that name is not a service here. `gg status` lists them |\n\n**Services, images and deploys**\n\n| code | what to do |\n|---|---|\n| `image_required` | `gg push` one first, or use `gg ship` |\n| `docker_not_installed` | from gg itself, before any request: there is no `docker` (or, for `gg registry copy`, no `buildx`). Ask your human to install Docker Desktop, OrbStack or colima (Docker Engine on Linux). An image already in the registry needs no docker: `gg deploy` it |\n| `docker_not_running` | docker is installed but its daemon did not answer; the message names the socket. Ask your human to start it and run `gg ship` again once `docker info` succeeds |\n| `docker_permission_denied` | this user cannot reach the daemon (Linux). Ask your human to add the user to the `docker` group and log in again. Never run gg with `sudo` |\n| `image_not_yours` | the image is not in this project's registry space. Build or push into this project, or `gg registry copy` it in |\n| `invalid_digest` | pass what `docker push` reported, or leave it out |\n| `invalid_port` | set the port the container actually listens on |\n| `invalid_timeout` | `timeout_seconds` outside 1–3600. Give 1–3600 or leave it out |\n| `service_has_no_timeout` | `timeout_seconds` was given on a service rather than a job. Drop it; a service runs until it is replaced |\n| `invalid_ttl` | `ttl_seconds` outside 60–28800. Give 60–28800 or leave it out to keep the current one (28800 for a new job) |\n| `service_has_no_ttl` | `ttl_seconds` was given on a service rather than a job. Drop it; a service runs until it is replaced, only a job's finished runs expire |\n| `invalid_kind` | `kind` is absent for a service or `job` for a job; nothing else exists |\n| `job_has_no_port` / `job_has_no_volume` | drop the field: a job listens on nothing and keeps nothing. Durable data goes in a resource it reaches |\n| `not_a_job` | that name is a service; a job needs a name of its own |\n| `invalid_schedule` | five cron fields like `\"0 3 * * *\"`, or `@daily` and the like. Not `@every`, no `CRON_TZ=` — the zone is `--tz`. An empty one is refused too: a schedule cannot be removed, so destroy the job to stop it |\n| `invalid_time_zone` | an IANA name like `Europe/Berlin` or `UTC` — or a `--tz` given to a job with no schedule |\n| `service_has_no_schedule` | `--schedule`/`--tz` reached a service. A schedule is a job's: `gg run` |\n| `job_running` | a one-shot job was given a schedule while its run is going. Wait for it to end (`gg status`), or destroy the job |\n| `invalid_volume` | an absolute path inside the container, e.g. `/var/lib/postgresql/data` |\n| `volume_immutable` | a volume is set once and never moves or resizes. Keep it, or destroy the service and deploy again — which throws the data away |\n| `invalid_size` | sizes are `s`, `m`, `l`; the message names the account's cap |\n| `no_such_revision` | `gg history` lists the ones it had |\n| `nothing_to_roll_back_to` | deployed only once. Not a bad call, just nothing to do |\n| `not_a_service` | that name is a resource or a job — you tried to deploy a service over it, give it an address, or roll back a managed resource whose credentials Gagarin mints, s3 included (an external can be rolled back) |\n| `not_a_resource` | that name is a service. `gg status` shows which is which |\n\n**The graph**\n\n| code | what to do |\n|---|---|\n| `invalid_needs` / `invalid_deps` | a blank name, a service naming itself, or a job named as something to reach — a job listens on nothing. Correct them; `gg deps ls` shows what is declared |\n| `no_such_service` | a name in `gg deps add` or `--deps` is neither a service nor a resource here. `gg status` lists them; create it first |\n| `service_in_use` | something still declares it needs this. The refusal names what; `gg deps rm` that edge first — which needs its own approval, though the same click covers the destroy that follows |\n\n**Resources**\n\n| code | what to do |\n|---|---|\n| `no_such_resource` | `gg status <project>` lists what it has |\n| `unknown_resource_type` | `postgres`, `qdrant`, `valkey`, `iggy`, `rabbitmq`, `s3` or `external` |\n| `wrong_resource_type` | another type already holds that name. Destroy it — which throws its data away — or pick another name |\n| `invalid_storage` | 1 to 100 GB |\n| `no_extensions` | only a `postgres` takes extensions: drop `--ext` |\n| `unknown_extension` | not in the catalogue; the hint lists every name offered. `pgvector` is called `vector`. timescaledb is not offered |\n| `extensions_failed` | HTTP 409: postgres refused — usually dropping an extension a column still uses, or one whose own tables still hold the user's rows (pg_cron's jobs, say). The message is postgres's own reason. **Nothing changed**; remove what is in the way, then restate the set |\n| `no_storage` | this type has no volume (valkey, s3): drop `--storage` |\n| `no_size` | an external or an s3 runs nothing: drop `--size` |\n| `invalid_env` | write `API_KEY`, not `OPENAI_API_KEY` — the prefix is the resource's name |\n| `already_exists` | restating an external. `gg resource rotate` is how values change |\n| `env_required` | an external's values are the user's; pass `--set K=V` for one of them, `--env-file` for all |\n| `conflicting_env` | `--env`/`--env-file` replace the bundle and `--set`/`--unset` amend it: use one or the other |\n| `no_such_key` | that external does not publish the key named in `--unset`. `gg resource secrets` lists what it does — and the name goes in without the resource's prefix |\n| `no_env` | this type mints its own credentials (s3 included), so there is nothing to pass or amend; `gg resource secrets` reads them |\n| `object_storage_unavailable` | HTTP 501: this Gagarin has no object storage configured, so no `s3`. Report it to the user |\n| `not_a_bucket` | HTTP 409: only an `s3` can be made public. A service gets an address with `gg domain add` |\n| `publish_failed` | HTTP 502: **nothing changed** — retry `gg resource public` or `private` |\n| `rotate_failed` | **nothing changed** — the old credential still works. Check `gg status` for a resource that is not running, then retry |\n| `cannot_rotate` | no credentials recorded to replace; worth reporting as a bug |\n| `not_tunnelable` | an external runs nothing, so there is nothing to tunnel to; its values are `gg resource secrets` |\n| `tunnel_unavailable` | no running pod on the far end. `gg status` says why, then run `gg connect` again |\n\n**Backups**\n\n| code | what to do |\n|---|---|\n| `backup_unsupported` | only postgres, qdrant and iggy have backups; an s3 bucket is on durable storage but never copied, and a rabbitmq is not backed up at all (declare its queues from application code so a fresh broker can be rebuilt). If losing the data would matter, keep a copy elsewhere |\n| `backup_unconfigured` | this Gagarin runs without a backup bucket. Report it to the user |\n| `restore_name_taken` | a restore creates the resource it fills. Give it a name nothing has yet |\n| `backup_mismatch` | that key belongs to another project. Never restore across projects |\n| `backup_type_mismatch` | that key was written by no type that has backups — check it against `gg resource backups` |\n| `no_backups` | the nightly pass takes the first one; `gg resource backup` takes one now |\n| `backup_list_failed` / `backup_failed` | the resource must be running — check `gg status`, then retry once |\n\n**Addresses**\n\n| code | what to do |\n|---|---|\n| `invalid_domain` | a hostname the user owns: no scheme, no port, no path |\n| `domain_taken` | another service holds that name. The refusal does not say who |\n| `domain_attached` | release the custom names first, or their DNS points at a host that no longer answers |\n\n**The platform itself**\n\n| code | what to do |\n|---|---|\n| `apply_failed` | desired state saved, cluster update failed. Retry the same command; it is idempotent |\n| `cluster_error` / `internal_error` / `eject_failed` | not your call's fault. Report it to the user |\n| `logs_unavailable` | no running pod yet. Check `gg status` first |\n| `timeout` | retry once; if it persists, tell the user |\n| `rate_limited` | wait a minute. Never retry in a tight loop |\n| `body_too_large` | large values belong in a resource, not in a deploy call |\n| `no_such_route` | you are calling the API directly and got the path wrong. Use `gg`, the only supported client |\n\n## Destroying things\n\n```\ngg destroy shop        the project, and everything in it\ngg destroy shop/web    one service\ngg destroy shop/db     one resource, and its data\n```\n\nYou do not say which of the last two a name is; gg asks the platform, which\nalready knows.\n\n**This will be refused the first time, and that is not a bug.** Your credential\ncan deploy but not delete, so destroying anything — and the other irreversible\nacts, `gg domain rm` and `gg deps rm` — needs a human every time the approval\nwindow has lapsed. You get `approval_required`, and Gagarin emails the\naccount owner. Then:\n\n1. Tell the user what you are about to delete, and that you have asked them to\n   approve it by email — the button asks them to sign in to Gagarin first if\n   they are not. Pass on the code from the `fix_hint`.\n2. Wait for them to say they clicked it. Do not poll in a loop.\n3. Run the same command again.\n\n**Ask the user before *requesting* the approval**, not just before retrying — an\napproval email for a deletion they never asked for is alarming. Only a project's\nowner can destroy the project; an editor gets `owner_only`, and no amount of\napproval changes that, because the answer is \"ask the person paying for it\".\n\nIf a deploy went wrong, prefer fixing it with another `gg ship`. Destroying and\nrecreating a project loses its data and its URL.\n\n## Leaving\n\n```\ngg eject shop -o project.yaml\n```\n\nWrites the Kubernetes manifests for the whole project — namespace, and per\nservice its Deployment, Service, Ingress, NetworkPolicy, environment Secret and\nvolume claim. These are not a description of what Gagarin runs; they are the\nobjects it runs, so `kubectl apply -f` on any cluster with an ingress controller\nreproduces the project.\n\nOwner only, because the file holds every service's environment in the clear. It\nis written mode 0600 and you should treat it as a credential.\n\nThree things it deliberately does not contain, all explained in its own header:\nthe **images**, which are still in Gagarin's registry and have to be pulled and\npushed somewhere the user controls; the **registry pull secret**, which is a\nlive credential; and the values from any **external resource**, which are\nthird-party keys somebody else issued, and an **s3 bucket's** keys, which like an\nexternal's work from anywhere — they come out as a `REPLACE-ME` placeholder\nnaming the resource, and the header lists exactly which variables to fill in. Volume\nclaims come back empty — data has to be taken out of the running service.\n\nA minted credential — a database password — *is* in the file, and the asymmetry\nis the point: that password is only a risk against a database in the same file,\nand an export without it does not come up. A third-party key stays live wherever\nthe file ends up. `gg eject shop --with-secrets -o project.yaml` includes them,\nfor a migration happening now into a file that gets deleted; say what that means\nbefore running it with the flag.\n\nOffer this without being defensive when somebody asks what happens if Gagarin\ngoes away. It is a real answer and it is meant to be used.\n\n## Things Gagarin deliberately does not do\n\nNot missing features. Do not attempt them and do not suggest workarounds:\n\n- deploy from a git repository or a git URL\n- read deployment configuration from a file in the repo — `--env-file` supplies\n  values, and is the only file Gagarin will ever read\n- interpolate variables into each other\n- pull images from Docker Hub, GHCR or any registry other than Gagarin's at run\n  time (`gg registry copy` brings one in first)\n- expose Kubernetes, cloud provider or networking primitives\n- open the mail ports\n- infer a project from the current directory, or from anything else —\n  `.gagarin.json` included: you read that, Gagarin never does\n"
}

SHA-256 of public snapshot: 5a1937a992e3d4867c01b0ad3749dd8b4fcf4ea17dea9ab1acc4266d659886a4