carlos / platform Public

docs+copy: narrow config receipt claims, rewrite the retry recipe

Luna's copy pass, applied as proposed except where the rulings keep the
original: "version %s, was %s", the term direct-bucket, and the docs
heading (now "has not changed"; no anchor pins it). The receipt sentence
is narrowed instead of taking Luna's "every write" wording, which is the
claim the review found too wide.

Docs (round 1, P2-5, P2-6): the recipe baselines and re-reads with the
one carlos env list --json, keeps the first digests on every retry and
never combines two listings. Effective --json re-encodes known fields; a
matching version means the same bytes, not that nobody wrote; exec
delivery, direct-bucket writes and older consoles print no receipt.

secrets help: the versions paragraph stands on its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 6780905b25101d0484f06d387391eab3a0834722 parent 5e766b3
5 files changed, +75 −58
  • apimode.go +1 −1
  • apimode_test.go +2 −2
  • appconfig_cli.go +18 −16
  • docs/site/cli.md +50 −35
  • internal/console/apiconfig.go +4 −4
diff --git a/apimode.go b/apimode.go
index b98525408..1375e5846 100644
--- a/apimode.go
+++ b/apimode.go
@@ -3066,7 +3066,7 @@ func versionMismatchFromBody(status int, body []byte) error {
}
_ = json.Unmarshal(body, &e)
if e.Error == "" {
- e.Error = fmt.Sprintf("the config is not at the version you sent, so nothing was written (status %d)", status)
+ e.Error = fmt.Sprintf("the bundle is not at the version you sent, so nothing was written (status %d)", status)
}
return &apiVersionMismatch{Message: e.Error, Version: e.Version}
}
diff --git a/apimode_test.go b/apimode_test.go
index 1894a7cd6..c1671aefe 100644
--- a/apimode_test.go
+++ b/apimode_test.go
@@ -4292,8 +4292,8 @@ func TestEnvSet412ExitsWithVersionMismatch(t *testing.T) {
for _, tc := range []struct {
name, body, wantVersion string
}{
- {"with version", `{"error":"the config is not at the version you sent, so nothing was written. read it again before you retry","version":"cv1:cccc"}`, "cv1:cccc"},
- {"read failed, no version", `{"error":"the config is not at the version you sent, so nothing was written. read it again before you retry"}`, ""},
+ {"with version", `{"error":"the bundle is not at the version you sent, so nothing was written. read it again before you retry","version":"cv1:cccc"}`, "cv1:cccc"},
+ {"read failed, no version", `{"error":"the bundle is not at the version you sent, so nothing was written. read it again before you retry"}`, ""},
} {
t.Run(tc.name, func(t *testing.T) {
ts, _ := configWireStub(t, "cv1:aaaa", func(w http.ResponseWriter, _ []byte) {
diff --git a/appconfig_cli.go b/appconfig_cli.go
index 909dbd46c..d08625650 100644
--- a/appconfig_cli.go
+++ b/appconfig_cli.go
@@ -180,7 +180,7 @@ commands:
unset --app <a> [--environment <name>] [--if-version <v>] KEY [KEY2 ...] remove config vars
list --app <a> [--environment <name>] [--digests] [--json] list an app's config vars and the bundle's version
effective --app <a> --host <h> [--json] show what one route gets from each config layer
- digest --kind env --value <v> print a plain var's digest, to check a receipt
+ digest --kind env --value <v> print a plain var's digest for comparison
digest --kind secret --envelope-file <path> [--sealed-to <fp>] print a secret's digest from the envelope that was sent
environments --app <a> list an app's named environment bundles
exec-delivery --app <a> [--environment <name>] file|off|inherit opt one bundle's TCP-addr exec routes into config delivery
@@ -221,21 +221,21 @@ the agent can only request that pass, not write /etc or restart units
itself. It never restarts a box's shared edge service, only the one app's
own delivery.
-every bundle has a version, which changes whenever its stored contents do,
-and every var has a digest, which changes whenever that var does. list
-shows the version, and --digests adds the digests. set and unset print
-what they changed and the version after. --if-version <v> writes only if
-the bundle is still at version v ("none" if it must not exist yet);
-otherwise nothing is written, the current version is printed and carlos
-exits with code 4. --if-version needs a console.
+every bundle has a version, which changes whenever its contents change,
+and every var has a digest, which changes whenever that var changes. list
+shows the version, and --digests adds the digests. set and unset print a
+receipt with what changed and the version after. --if-version <v> writes
+only if the bundle is still at version v ("none" if it must not exist
+yet). otherwise nothing is written, the current version is printed and
+carlos exits with code 4. --if-version needs a console
effective shows, for one route, each key, the layer it comes from (default,
environment or overlay) and the lower layers it hides. it works through a
console only.
digest computes a digest locally. for a secret, pass the envelope that was
-sent and, with --sealed-to, the fingerprint it was sealed to: both are part
-of the stored var, and secrets set fills in sealed_to.
+sent and, with --sealed-to, the fingerprint of the key it was sealed to.
+both are part of the stored var, and secrets set fills in sealed_to
adopt, release and fork are an account owner's acts, through a logged-in
console only: an environment a team scope owns is standalone (it never
@@ -650,7 +650,7 @@ func runEnvList(args []string) {
app := appFlag(fs, "")
environment := environmentFlag(fs, "named environment bundle to list (omit for the default bundle)")
digests := fs.Bool("digests", false, "add each var's digest")
- asJSON := fs.Bool("json", false, "print the bundle as JSON, with its version and every digest")
+ asJSON := fs.Bool("json", false, "print the bundle as JSON, including its version and every digest")
acctRaw, acctIDRaw, acctOf := accountFlags(fs)
consoleFlag := consoleOption(fs, "console origin to work through (API mode only; default: the only logged-in one)")
fs.Usage = flagUsage(fs, "")
@@ -1044,9 +1044,11 @@ it's set in this terminal's own environment, otherwise the console's own
served public key (Config.SecretsPub) if it has one — CARLOS_SECRETS_KEY
(the PRIVATE half) never leaves the box holding it either way.
genkey and fingerprint are always local, in both modes.
+
versions, digests and --if-version work as for "carlos env". a secret's
-digest is taken over its sealed envelope, so it says nothing about the value
-and changes every time the secret is set, even to the same value.
+digest is computed from its sealed envelope, so it reveals nothing about the
+value and changes every time the secret is set, even to the same value
+
for an app placed on a fleet the console serves the fleet's own key, so leave
CARLOS_SECRETS_PUBKEY unset. register that key with "carlos fleets secrets-key".
`
@@ -1455,7 +1457,7 @@ func runSecretsList(args []string) {
app := appFlag(fs, "")
environment := environmentFlag(fs, "named environment bundle to list (omit for the default bundle)")
digests := fs.Bool("digests", false, "add each secret's digest")
- asJSON := fs.Bool("json", false, "print the bundle's secrets as JSON, with its version and every digest")
+ asJSON := fs.Bool("json", false, "print the bundle's secrets as JSON, including its version and every digest")
acctRaw, acctIDRaw, acctOf := accountFlags(fs)
consoleFlag := consoleOption(fs, "console origin to work through (API mode only; default: the only logged-in one)")
fs.Usage = flagUsage(fs, "")
@@ -1732,7 +1734,7 @@ const (
digestCopyEnvOnly = "--envelope-file and --sealed-to are for --kind secret"
digestCopyNeedEnvelope = "--kind secret needs --envelope-file"
digestCopySecretNoValue = "--value is for --kind env. for a secret, pass the sealed envelope with --envelope-file"
- digestCopyEmptyEnvelope = "%s is empty. it should hold the envelope that was sent"
+ digestCopyEmptyEnvelope = "%s is empty. it should contain the envelope that was sent"
)
// envDigest is appconfig.Digest of the var the flags describe: exactly the
@@ -1776,7 +1778,7 @@ func runEnvDigest(args []string) {
fs := flag.NewFlagSet("env digest", flag.ExitOnError)
kind := fs.String("kind", "", `"env" for a plain var, "secret" for a sealed one`)
value := fs.String("value", "", "the plain var's value (--kind env)")
- envelopeFile := fs.String("envelope-file", "", "a file holding the sealed envelope that was sent (--kind secret)")
+ envelopeFile := fs.String("envelope-file", "", "a file containing the sealed envelope that was sent (--kind secret)")
sealedTo := fs.String("sealed-to", "", "the fingerprint the secret was sealed to, as sent in sealed_to (--kind secret). carlos secrets set always sends one")
fs.Usage = flagUsage(fs, "usage: carlos env digest --kind env --value <v>\n or: carlos env digest --kind secret --envelope-file <path> [--sealed-to <fp>]")
fs.Parse(args)
diff --git a/docs/site/cli.md b/docs/site/cli.md
index ba4a241d4..fee028e60 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -987,8 +987,8 @@ the root pass will refuse is reported as blocked with the reason.
#### Config versions and digests
-Every bundle has a version, and every var in it has a digest. They answer
-the question "has this changed since I last looked?" without you comparing
+Every bundle has a version, and every var in it has a digest. They let you
+check whether something changed since you last looked, without comparing
values by eye.
A version looks like `cv1:` followed by a hash of the bundle as it is stored.
@@ -997,7 +997,8 @@ the bundle gives a new one. A bundle that has never been written has the
version `none`, which is different from a bundle that exists and holds no
vars. A version can come back: set a var to B and then back to A, and the
bundle returns to its first version, because the stored bytes are the same
-again.
+again. So a version that matches the one you read means the bundle holds the
+same bytes, not that nobody wrote to it in between.
A digest looks like `vd1:` followed by a hash of one var as it is stored. For
a plain var that is its value, so the digest changes when the value does. For
@@ -1009,7 +1010,9 @@ it holds.
`carlos env list` prints the version in its header line, and `--digests` adds
a `DIGEST` column. `carlos secrets list --digests` prints key names and
digests, still no values. `--json` always carries the version and every
-digest.
+digest. `carlos env list --json` carries every var in the bundle, plain vars
+with their values and secrets with their digests only, all from one read, so
+the version it prints is the version of everything it lists.
```sh
carlos env list --app shop --digests
@@ -1028,8 +1031,8 @@ treat the value: do not paste digests of plain vars into a report, ticket or
channel that reaches more people than the value would. A secret's digest does
not have this problem.
-`carlos env digest` computes a digest on your machine, with no console call,
-so you can compare it with the digest a listing shows. The receipt a write
+`carlos env digest` computes a digest on your machine without contacting a
+console, so you can compare it with the digest in a listing. The receipt a write
prints does not carry digests.
```sh
@@ -1049,12 +1052,14 @@ from (`FROM`) and any lower layers that also set it, in a `HIDES` column. The
`VALUE` column shows a plain var's value when it comes from the default or
environment layer. It is blank for secrets and for values from the platform's
per-instance overlay. Use it when a var you set does not seem to take effect:
-it will say if a higher layer is covering it. `--json` prints the console's answer as it is. It shows the
-stored layers only. Values set on the box itself, such as an exec route's
+it will say if a higher layer is covering it. `--json` prints the console's
+answer as JSON: the fields this version of `carlos` knows, under the
+console's names. A field added by a newer console is left out. It shows only
+the stored layers. Values set on the box itself, such as an exec route's
own `<host>.env`, are not in the bucket and are not shown. It works through
a console, not in direct-bucket mode.
-#### Writing only if the bundle has not moved
+#### Writing only if the bundle has not changed
`carlos env set`, `carlos env unset`, `carlos secrets set` and `carlos
secrets unset` take `--if-version <v>`. The write happens only if the bundle
@@ -1066,26 +1071,30 @@ only if the bundle does not exist yet.
carlos env set --app shop --if-version cv1:3f0c… FEATURE_X=on
```
-If the bundle has moved, nothing is written, the command prints the current
+If the bundle has changed, nothing is written, the command prints the current
version and exits with code 4. Every other failure exits 1, so a script can
-tell "read again and decide" from "something is broken". The check is made by
-the console against the store, so it holds even if someone else writes at the
-same moment. For that reason `--if-version` needs a console: in direct-bucket
-mode it is refused before anything is written. A console whose store cannot
-make that guarantee refuses it too.
+tell "read again and decide" from "something is broken". The console makes the
+check where the bundle is stored, so it still holds if someone else writes at
+the same moment. For that reason `--if-version` needs a console. In
+direct-bucket mode it is refused before anything is written. A console that
+cannot make this guarantee refuses it too. An `--if-version` that is given
+but empty, as with an unset shell variable, is refused too, rather than read
+as no precondition.
With no `--if-version`, a write behaves as it always did.
-Every write through a console prints a receipt of what the console stored
-(a direct-bucket write prints none): the names it set
-(`set:`), the names it removed (`removed:`), and any names you asked to
-remove that were not there (`not there:`), followed by the version after the
-write and the version before. If the write changed nothing, because every
+A `set` or `unset` through a console prints a receipt of what was stored: the
+names it set (`set:`), the names it removed (`removed:`), and any names you
+asked to remove that were not there (`not there:`), followed by the version
+after the write and the version before. Some writes print no receipt: a
+direct-bucket write, `carlos env exec-delivery`, and any write through a
+console too old to send one. If the write changed nothing, because every
value was already what you sent, it says so and prints the version the bundle
is still at. A write to a named environment also tells you if the default
-bundle changed while it ran. The two bundles are separate objects, so the
-console can report that but cannot prevent it; whether it matters is for you
-to decide. `--if-version` covers the bundle you wrote to, not the default.
+bundle changed while it ran, or that the console could not read the default
+to compare. The two bundles are separate objects, so the console can report
+that but cannot prevent it; whether it matters is for you to decide.
+`--if-version` covers the bundle you wrote to, not the default.
A receipt describes what is stored. It does not say that a process has
picked the config up. That is a separate question, and the restart notice
@@ -1100,15 +1109,18 @@ happened and try again safely. Take the app `shop` and a script that adds
`AGENT_ISSUER` and `AGENT_TEAM`, and must leave `DATABASE_URL` and
`LOG_LEVEL` as they are.
-1. **Baseline.** Read the bundle and keep its version and the digest of each
- key the script must preserve.
+1. **Baseline.** Read the bundle once and keep its version and the digest of
+ each key the script must preserve.
```sh
- carlos env list --app shop --digests --json
+ carlos env list --app shop --json
```
- Keep `version`, and the `digest` of `LOG_LEVEL`. Do the same with `carlos
- secrets list --app shop --digests --json` for `DATABASE_URL`.
+ This one listing carries every var, plain and secret, and the version of
+ exactly those bytes. Keep `version`, and the `digest` of `LOG_LEVEL` and
+ of `DATABASE_URL`. Take the baseline from this single read. Do not
+ combine `carlos env list` with `carlos secrets list`: they are two reads,
+ and someone can write between them.
2. **Write.** Pass the baseline version as `--if-version` and set only the
new keys.
@@ -1125,8 +1137,10 @@ happened and try again safely. Take the app `shop` and a script that adds
shows for the key.
4. **If the answer was lost, or the write was refused with exit code 4,
- read again** and compare the bundle with your baseline. Exactly one of
- these applies to any read, and the first that matches wins:
+ read again** with the same single `carlos env list --app shop --json`,
+ and compare that one listing with your baseline. Keep the digests from
+ step 1 for every retry; only the version comes from the new read. Exactly
+ one of these applies to any read, and the first that matches wins:
- A preserved key has a different digest from the baseline, or is gone.
Stop. Something else changed what the script promised to leave alone.
@@ -1135,7 +1149,8 @@ happened and try again safely. Take the app `shop` and a script that adds
with the digest of what you sent. The write landed. You are done.
- Every preserved key matches the baseline, and no new key is present.
The write did not land and nothing you care about moved. Retry from step
- 2 with `--if-version` set to the version you just read.
+ 2 with `--if-version` set to the version of this same listing, never one
+ from another read.
- Every preserved key matches the baseline, but the new keys are only
partly there, or one has a different digest or a different kind. Stop.
Another writer touched the keys this script was adding. Do not
@@ -1154,8 +1169,8 @@ check seals and sends for itself.
### carlos secrets
-The same shape as `carlos env`, sealed. `list` prints key names and never
-values.
+The same commands as `carlos env`, with sealed values. `list` prints key
+names and never values.
```sh
carlos secrets set --app hello STRIPE_KEY=sk_live_example
@@ -1178,8 +1193,8 @@ In direct-bucket mode, `carlos secrets set` refuses for any account that owns a
Versions, digests and `--if-version` work as they do for `carlos env`, see
[Config versions and digests](#config-versions-and-digests). A secret's digest
-is taken over its sealed envelope, so it says nothing about the value and
-changes every time the secret is set, even to the same value.
+is computed from its sealed envelope, so it reveals nothing about the value
+and changes every time the secret is set, even to the same value.
An empty value is refused rather than stored. A command substitution that
produced nothing looks exactly like a real value at the point you type it, and
diff --git a/internal/console/apiconfig.go b/internal/console/apiconfig.go
index 76b4472c9..7320e7de0 100644
--- a/internal/console/apiconfig.go
+++ b/internal/console/apiconfig.go
@@ -535,14 +535,14 @@ func (s *Server) handleAPIConfigPut(w http.ResponseWriter, r *http.Request) {
// exec_delivery is a second CAS write (below), and one
// precondition cannot guard two writes.
jsonError(w, http.StatusBadRequest,
- "if_version cannot cover exec_delivery, which is a separate write. send exec_delivery in a request of its own")
+ "if_version cannot cover exec_delivery. send exec_delivery in a request of its own")
return
}
if !release.HasAtomicConditionalPut(s.cfg.Releases) {
// The guarantee is the store's to keep (R2-2): a DirStore checks
// the etag under a mutex one process holds, so a conditional
// write there would promise what it cannot keep.
- jsonError(w, http.StatusBadRequest, "conditional writes need a store that supports them")
+ jsonError(w, http.StatusBadRequest, "conditional writes are not supported here")
return
}
if team && ifVersion == appconfig.VersionNone {
@@ -559,7 +559,7 @@ func (s *Server) handleAPIConfigPut(w http.ResponseWriter, r *http.Request) {
// write behaves exactly as it always has.
if k := configSetAndUnset(keys, req.Unset); k != "" {
jsonError(w, http.StatusBadRequest,
- fmt.Sprintf("%s is in both set and unset, which a write with if_version does not accept. send it in one of them", k))
+ fmt.Sprintf("%s is in both set and unset. a write with if_version accepts it in only one of them", k))
return
}
}
@@ -1152,7 +1152,7 @@ func (s *Server) configReceiptReread(ctx context.Context, acct, app, envName str
// written either way.
func (s *Server) configPreconditionFailed(w http.ResponseWriter, r *http.Request, ctx context.Context, what, acct, app, envName string, tv *teamView, err error) {
log.Printf("console: %s: %v", what, err)
- out := map[string]any{"error": "the config is not at the version you sent, so nothing was written. read it again before you retry"}
+ out := map[string]any{"error": "the bundle is not at the version you sent, so nothing was written. read it again before you retry"}
l, rerr := appconfig.LoadLayer(ctx, s.cfg.Releases, appconfig.BundleKey(acct, app, envName), app)
switch {
case rerr != nil: