carlos / platform Public

canary retire: cut the operator door to a follow-up branch (#1634)

Round 1 (Astra, Fable) found the operator door blind to unmanaged hand
routes on other boxes: box reports name an app only for rollout-managed
routes. Per 8a3d302 (option 2), it moves to a follow-up branch that adds
that report field first. This branch keeps the member door and the
digests mark, now for accounts the console has, after the repair text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev e1c5bbda8901959523cd4e3e2964bd8b252ce2ba parent 4b92bfb
15 files changed, +88 −500
  • canary_retire.go +2 −50
  • canary_retire_test.go +11 −65
  • channels_digests.go +15 −11
  • commands.go +3 −5
  • docs/parity.md +0 −1
  • docs/site/cli.md +4 −19
  • internal/console/apidigests.go +8 −8
  • internal/console/apilinks_test.go +5 −6
  • internal/console/canary_retire.go +21 −170
  • internal/console/canary_retire_test.go +19 −135
  • internal/console/claim_invariant_fixtures_test.go +0 −1
  • internal/console/claim_invariant_probes_nonapp_test.go +0 −24
  • internal/console/routedecls.go +0 −3
  • internal/console/testdata/claim-authority-sites.txt +0 −1
  • parity/parity.tsv +0 −1
diff --git a/canary_retire.go b/canary_retire.go
index eff191f66..5ee44cb95 100644
--- a/canary_retire.go
+++ b/canary_retire.go
@@ -1,7 +1,7 @@
package main
-// `carlos canary retire` and `carlos channels retire` (#1634): deleting a
-// canary/<name> channel pointer that nothing follows, through a console.
+// `carlos canary retire` (#1634): deleting a canary/<name> channel pointer
+// that nothing follows, through a console.
// The console does every check (no follower by registry, record or box
// report; the app still for 15 minutes; the pointer unchanged since it was
// read) and deletes only the pointer, never a shipped release.
@@ -21,8 +21,6 @@ const (
textCanaryRetired = "%s's pointer is gone. Its releases are kept"
textCanaryRetireNeedName = "carlos canary retire: --name <n> is required"
textRetireNeedsConsole = "carlos %s works through a console, and this shell is in direct bucket mode. Unset CARLOS_DEPLOYMENT_BUCKET and CARLOS_DEPLOYMENT_DIR, then run carlos auth login --console <url>"
- textChannelsRetireUsage = "usage: carlos channels retire --account-id <sqid> --app <a> canary/<name>"
- textChannelsRetired = "%s of %s/%s: its pointer is gone. Its releases are kept"
)
// canaryRetire asks the console to retire canary/<name> of app, and
@@ -44,20 +42,6 @@ func (s *apiSession) canaryRetire(ctx context.Context, a apiAcct, app, name stri
return out.Channel, nil
}
-// systemChannelRetire asks the console to retire channel of acct/app, an
-// app the console has no row for (the operator door).
-func (s *apiSession) systemChannelRetire(ctx context.Context, acct, app, channel string) error {
- status, body, err := s.postJSON(ctx, "/api/cli/system/channels/retire",
- map[string]string{"account": acct, "app": app, "channel": channel})
- if err != nil {
- return err
- }
- if status != http.StatusOK {
- return apiErrorFromBody(status, body)
- }
- return nil
-}
-
// runCanaryRetire is `carlos canary retire --app <a> --name <n>`: the
// console's Retire button, from the CLI. canary rm deletes the instance;
// this deletes the channel it followed, once nothing does.
@@ -91,35 +75,3 @@ func runCanaryRetire(args []string) error {
mutedf(stdout, textCanaryRetired, channel)
return nil
}
-
-// runChannelsRetire is `carlos channels retire --account-id <sqid> --app
-// <a> canary/<name>`: a platform operator retires a canary pointer of an
-// app the console has no row for (the repair listing names such a line "no
-// app on this console"). The console refuses an app it has, one in the
-// trash, one with instance records, and any channel outside canary/*.
-func runChannelsRetire(args []string) error {
- fs := flag.NewFlagSet("channels retire", flag.ExitOnError)
- acct := fs.String("account-id", "", "the account's sqid, as the repair listing prints it")
- app := fs.String("app", "", "the app, as the repair listing prints it")
- consoleFlag := consoleOption(fs, "console origin (default: the only logged-in one)")
- fs.Usage = flagUsage(fs, "")
- fs.Parse(args)
- if *acct == "" || *app == "" || fs.NArg() != 1 {
- return errors.New(textChannelsRetireUsage)
- }
- channel := fs.Arg(0)
- sess, err := resolveMode(*consoleFlag)
- if err != nil {
- return err
- }
- if sess == nil {
- return fmt.Errorf(textRetireNeedsConsole, "channels retire")
- }
- printUsing(stdout, sess)
- if err := sess.systemChannelRetire(context.Background(), *acct, *app, channel); err != nil {
- return err
- }
- fmt.Fprintf(stdout, "%s %s\n", colorFor(stdout).ok("retired"), channel)
- mutedf(stdout, textChannelsRetired, channel, *acct, *app)
- return nil
-}
diff --git a/canary_retire_test.go b/canary_retire_test.go
index 5185cb18e..5477e8704 100644
--- a/canary_retire_test.go
+++ b/canary_retire_test.go
@@ -65,85 +65,31 @@ func TestCanaryRetireAPIMode(t *testing.T) {
}
}
-// Direct bucket mode has no console to check followers, so both verbs
-// refuse rather than touch the bucket.
-func TestRetireVerbsRefuseDirectBucketMode(t *testing.T) {
+// Direct bucket mode has no console to check followers, so the verb
+// refuses rather than touch the bucket.
+func TestCanaryRetireRefusesDirectBucketMode(t *testing.T) {
useTempCredentials(t)
clearDeploymentEnv(t)
t.Setenv("CARLOS_DEPLOYMENT_DIR", t.TempDir())
if err := runCanaryRetire([]string{"--app", "shop", "--name", "rc"}); err == nil || !strings.Contains(err.Error(), "direct bucket mode") {
t.Fatalf("canary retire in direct bucket mode = %v", err)
}
- if err := runChannelsRetire([]string{"--account-id", "bab", "--app", "old", "canary/rc"}); err == nil || !strings.Contains(err.Error(), "direct bucket mode") {
- t.Fatalf("channels retire in direct bucket mode = %v", err)
- }
}
-// `carlos channels retire` posts account, app and channel to the operator
-// door, exactly as the repair listing's line names them.
-func TestChannelsRetireAPIMode(t *testing.T) {
- useTempCredentials(t)
- clearDeploymentEnv(t)
- var posted map[string]string
- ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path != "/api/cli/system/channels/retire" || r.Method != http.MethodPost {
- t.Errorf("request = %s %s", r.Method, r.URL.Path)
- }
- json.NewDecoder(r.Body).Decode(&posted)
- json.NewEncoder(w).Encode(map[string]string{"result": "retired", "channel": "canary/old"})
- }))
- defer ts.Close()
- loginTo(t, ts.URL, "vicky@keymail.dev")
- out := captureStdout(t)
-
- if err := runChannelsRetire([]string{"--account-id", "bab", "--app", "old", "canary/old"}); err != nil {
- t.Fatalf("retire: %v", err)
- }
- want := map[string]string{"account": "bab", "app": "old", "channel": "canary/old"}
- if fmt.Sprint(posted) != fmt.Sprint(want) {
- t.Fatalf("posted %v, want %v", posted, want)
- }
- if line := fmt.Sprintf(textChannelsRetired, "canary/old", "bab", "old"); !strings.Contains(out.String(), line) {
- t.Fatalf("output lacks %q:\n%s", line, out.String())
- }
- posted = nil
- for _, args := range [][]string{
- {"--app", "old", "canary/old"},
- {"--account-id", "bab", "canary/old"},
- {"--account-id", "bab", "--app", "old"},
- } {
- if err := runChannelsRetire(args); err == nil || err.Error() != textChannelsRetireUsage {
- t.Fatalf("channels retire %v = %v, want the usage", args, err)
- }
- }
- if posted != nil {
- t.Fatalf("an incomplete retire posted %v", posted)
- }
-}
-
-// The repair listing names the operator door for a canary head of an app
-// the console has no row for, and only for that: a record line or a
-// non-canary head of such an app keeps its repair.
-func TestRepairCellNamesTheRetireForNoAppCanaries(t *testing.T) {
+// A line of an app the console has no app for keeps its repair, with the
+// mark after it; a line of an app the console has is unchanged.
+func TestRepairCellMarksAppsWithNoRow(t *testing.T) {
head := apiDigestRepair{Account: "bab", App: "old", Channel: "canary/rc", Version: "v1", NoRecord: true, NoApp: true}
- if got, want := repairCell(head), fmt.Sprintf(textRepairNoApp, "bab", "old", "canary/rc"); got != want {
- t.Fatalf("no-app canary head = %q, want %q", got, want)
- }
- if !strings.HasPrefix(repairCell(head), "no app on this console: carlos channels retire --account-id bab --app old canary/rc") {
- t.Fatalf("the line does not name the command to run: %q", repairCell(head))
- }
- stable := head
- stable.Channel = "stable"
- if got := repairCell(stable); got != textRepairNoRecord {
- t.Fatalf("no-app stable head = %q, want the ordinary repair", got)
+ if got, want := repairCell(head), textRepairNoRecord+" (no app on this console)"; got != want {
+ t.Fatalf("no-app head = %q, want %q", got, want)
}
rec := apiDigestRepair{Account: "bab", App: "old", Version: "v1", Record: true, NoApp: true}
- if got := repairCell(rec); got != textRepairRecordUnbound {
- t.Fatalf("no-app record line = %q, want the ordinary repair", got)
+ if got, want := repairCell(rec), textRepairRecordUnbound+" (no app on this console)"; got != want {
+ t.Fatalf("no-app record line = %q, want %q", got, want)
}
live := head
live.NoApp = false
if got := repairCell(live); got != textRepairNoRecord {
- t.Fatalf("a canary head of an app with a row = %q", got)
+ t.Fatalf("a head of an app with a row = %q", got)
}
}
diff --git a/channels_digests.go b/channels_digests.go
index c251efb93..bdbb4e996 100644
--- a/channels_digests.go
+++ b/channels_digests.go
@@ -63,9 +63,9 @@ const (
textRepairUnknown = "this console does not list repairs: upgrade it, or ask the bucket directly"
)
-// A canary head of an app the console has no row for (#1634), reviewed by
-// Luna under delegation (2026-12-01).
-const textRepairNoApp = "no app on this console: carlos channels retire --account-id %s --app %s %s"
+// The mark after a line's repair when the console has no app for it
+// (#1634). Not yet through copy review.
+const textRepairNoApp = "%s (no app on this console)"
// apiDigestRepair is a channel whose head a fresh or replaced box would
// refuse: Unbound (not bound to its account: the pointer names none, or the
@@ -91,8 +91,8 @@ type apiDigestRepair struct {
Grant string `json:"grant,omitempty"`
GrantMintedAt string `json:"grant_minted_at,omitempty"`
// NoApp is a line of an app the console has no row for, live or in the
- // trash (#1634); an older console, and the direct-store report, never
- // set it.
+ // trash, under an account it has (#1634); an older console, and the
+ // direct-store report, never set it.
NoApp bool `json:"no_app,omitempty"`
}
@@ -111,14 +111,18 @@ type apiPointerDigests struct {
// A record is repaired by authorizing its version: promoting a head's
// version again writes no record.
//
-// A canary head of an app the console has no row for names the operator
-// door that retires it instead: the console's member doors cannot promote
-// or authorize for an app it has no row for, and a canary that nothing
-// follows is better removed than repaired (#1634).
+// A line of an app the console has no row for keeps its repair and says so
+// after it (#1634): no member door reaches such an app.
func repairCell(r apiDigestRepair) string {
+ if r.NoApp {
+ return fmt.Sprintf(textRepairNoApp, repairText(r))
+ }
+ return repairText(r)
+}
+
+// repairText is repairCell's repair, before any mark.
+func repairText(r apiDigestRepair) string {
switch {
- case r.NoApp && !r.Record && strings.HasPrefix(r.Channel, release.RungCanary+"/"):
- return fmt.Sprintf(textRepairNoApp, r.Account, r.App, r.Channel)
case r.Record && r.Unread:
return fmt.Sprintf(textRepairRecordRetry, r.Error)
case r.Record && r.NoBuild:
diff --git a/commands.go b/commands.go
index 62763010b..20777fdfc 100644
--- a/commands.go
+++ b/commands.go
@@ -303,9 +303,9 @@ func runRegistryChildTop(args []string) {
}
}
-// channelsCommand is `carlos channels`, moved from main's switch: three
-// sub-verbs, resign and digests (#253) and retire (#1634), and bare
-// `carlos channels` (any other word or flag too) still lists, the `carlos releases retention`
+// channelsCommand is `carlos channels`, moved from main's switch: two
+// sub-verbs, resign and digests (#253), and bare `carlos channels` (any
+// other word or flag too) still lists, the `carlos releases retention`
// precedent. The sub-verbs returned from main() before the update hint, so
// they skip it.
func channelsCommand() *clireg.Node {
@@ -318,8 +318,6 @@ func channelsCommand() *clireg.Node {
// digests' on|off counts only as its first argument
// (runChannelsDigests): an enum positional of this raw leaf.
noHint(rawErr("digests", clireg.Operator, runChannelsDigests)),
- // retire: a canary pointer of an app with no console row (#1634).
- noHint(rawErr("retire", clireg.Operator, runChannelsRetire)),
},
DefaultLeaf: &clireg.Node{Audience: cust, Run: clireg.RawArgs(runChannels)},
DefaultOn: clireg.OnAbsent | clireg.OnFlag | clireg.OnWord,
diff --git a/docs/parity.md b/docs/parity.md
index e10e0afaf..c7639c2f5 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -459,7 +459,6 @@ Discussion #1536.
| op-upstreams | operator | `instances set-upstreams`<br>`instances create [--addr]` | | TCP backends are set by an operator. |
| op-digests | operator | `channels digests [on, off]` | | The digest signing switch. |
| channels-digests | operator | `channels digests [report]` | | Operator only: the report needs a system operator (apiSystemRoller). Shows which channel pointers are digest-signed. |
-| channels-retire | operator | `channels retire` | | Operator only. Requires a system operator (apiSystemRoller). Retires a canary pointer of an app with no console row, which no member door reaches. |
| op-releases-authorize | operator | `releases authorize` | | Signs a promotion record for an old build. |
| op-relay-rotate | operator | `relay rotate` | | Rotates a region's relay master. |
| op-move-lost | operator | `move resolve [--declare-lost]` | | Declares a box lost in the middle of a move. |
diff --git a/docs/site/cli.md b/docs/site/cli.md
index a2e5c8a1d..c8ba0a8bd 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -1035,25 +1035,10 @@ Shows whether channel pointers carry manifest digests, and lists the channels th
carlos channels digests
```
-A canary line for an app with no entry in the console (it was shipped
-straight to the bucket and never added, or was left behind when a deletion
-did not finish) says “no app on this console” and gives the command that
-removes it.
-
-### carlos channels retire
-
-For platform operators. Deletes a `canary/<name>` channel of an app the
-console has no app for, which `carlos canary retire` cannot reach. Copy the
-command from the `carlos channels digests` line.
-
-```sh
-carlos channels retire --account-id bab --app shop canary/new-queue
-```
-
-It refuses if the console has the app, even in the trash, if the app has any
-instance record, or if any host follows the channel, including a route added
-by hand on a box. It retires `canary/<name>` channels only, and never deletes
-shipped releases.
+A line for an app with no entry in the console (it was shipped straight to
+the bucket and never added, or was left behind when a deletion did not
+finish) ends with “(no app on this console)”. The console’s own commands
+cannot reach such an app.
### carlos pipeline
diff --git a/internal/console/apidigests.go b/internal/console/apidigests.go
index 072f3f6b0..9d7c8c5ce 100644
--- a/internal/console/apidigests.go
+++ b/internal/console/apidigests.go
@@ -308,9 +308,9 @@ type digestRepRow struct {
Grant string `json:"grant,omitempty"`
GrantMintedAt string `json:"grant_minted_at,omitempty"`
// NoApp is a line of an app this console has no row for, live or in
- // the trash: shipped straight to the bucket and never adopted, or left
- // by a purge that did not finish (#1634). The CLI names the operator
- // door that retires such an app's canary pointers.
+ // the trash, under an account it has: shipped straight to the bucket
+ // and never adopted, or left by a purge that did not finish (#1634).
+ // The CLI says so beside the repair, since no member door reaches it.
NoApp bool `json:"no_app,omitempty"`
}
@@ -395,13 +395,13 @@ func (s *Server) walkDigestAccount(ctx context.Context, sqid string, bucketOnly
}
// digestNoApp answers, per app of the account sqid, whether this console
-// has no row for it, live or trashed (digestRepRow.NoApp). An account the
-// console does not have has no app rows. A lookup that fails answers false:
-// the label only adds a hint, and a wrong one would send an operator to a
-// door that refuses anyway.
+// has no row for it, live or trashed (digestRepRow.NoApp). Only an account
+// the console has is labelled: a bucket-only account's row already says so
+// (BucketOnly), and the console can tell nothing about its apps. A lookup
+// that fails answers false: the label only adds a hint.
func (s *Server) digestNoApp(ctx context.Context, sqid string, bucketOnly bool) func(app string) bool {
if bucketOnly {
- return func(string) bool { return true }
+ return func(string) bool { return false }
}
a, err := s.store.AccountBySqid(sqid)
if err != nil || a == nil {
diff --git a/internal/console/apilinks_test.go b/internal/console/apilinks_test.go
index 135455892..a03d4c98e 100644
--- a/internal/console/apilinks_test.go
+++ b/internal/console/apilinks_test.go
@@ -495,12 +495,11 @@ var linkedBodyAppDoors = map[string]string{
"POST /a/{sqid}/domains/buy/check": "the app only travels on to step 2's preselection; the search writes nothing",
"POST /a/{sqid}/fleets/{fleet}/place": "placeAppTarget refuses a linked app with LD-C11",
// Cannot act on a linked app.
- "POST /a/{sqid}/trash/restore": "acts only on a trashed row; linked rows are never trashed",
- "POST /a/{sqid}/trash/delete": "acts only on a trashed row; linked rows are never trashed",
- "POST /a/{sqid}/services/new": "mints a credential scoped to the app; every door the credential reaches is an {app} door the policy guards",
- "POST /api/cli/services/{account}": "mints a credential scoped to the app; every door the credential reaches is an {app} door the policy guards",
- "POST /api/cli/link/publications": "the home console's own publish of a home app through its link; no serving-side app",
- "POST /api/cli/system/channels/retire": "acts only on an app with no row, live or trashed (orphanRefusal, asked again under the app lock); a linked app is a live row",
+ "POST /a/{sqid}/trash/restore": "acts only on a trashed row; linked rows are never trashed",
+ "POST /a/{sqid}/trash/delete": "acts only on a trashed row; linked rows are never trashed",
+ "POST /a/{sqid}/services/new": "mints a credential scoped to the app; every door the credential reaches is an {app} door the policy guards",
+ "POST /api/cli/services/{account}": "mints a credential scoped to the app; every door the credential reaches is an {app} door the policy guards",
+ "POST /api/cli/link/publications": "the home console's own publish of a home app through its link; no serving-side app",
}
// TestLinkedPolicyCoversBodyAppDoors finds every declared non-link route
diff --git a/internal/console/canary_retire.go b/internal/console/canary_retire.go
index cdb0ca7b1..adedfd3d8 100644
--- a/internal/console/canary_retire.go
+++ b/internal/console/canary_retire.go
@@ -1,16 +1,16 @@
package console
// Retiring a canary: deleting a canary/<name> channel pointer that nothing
-// follows (#1634). Three doors share one guard and one delete:
+// follows (#1634). Two doors share one guard and one delete:
//
// - the browser's Retire button on an app's Releases tab
// (handleRetireCanary);
// - `carlos canary retire`, the same act for a member over the CLI API
-// (handleAPIRetireCanary);
-// - `carlos channels retire`, a platform operator's door for a canary
-// pointer left in the bucket under an app this console has no row for
-// (handleAPISystemRetireChannel): an app shipped straight to the bucket
-// and never adopted, or one whose purge did not finish.
+// (handleAPIRetireCanary).
+//
+// An app this console has no row for is out of reach of both: an
+// operator door for it waits on box reports that name every route's app
+// and channel, since its followers have no records to go by.
//
// Shipped releases are never touched: a retire un-points, it never deletes
// bits. Every door fails CLOSED: "could not check who follows this channel"
@@ -34,19 +34,15 @@ import (
// The CLI doors' answers (#1634). Reviewed by Luna under delegation
// (2026-12-01).
const (
- textRetireBadName = "%q is not a canary name"
- textRetireBadChannel = "%q is not a canary channel: only canary/<name> channels can be retired"
- textRetireNoBucket = "no deployment bucket on this host, so this console cannot retire a canary"
- textRetireNoCanary = "%s has no canary named %s"
- textRetireFollowed = "canary %s still has a host (%s) following it. Delete that instance or move it to another channel, then retire the canary"
- textRetireUnsettled = "%s was not retired: an instance of %s changed in the last 15 minutes, a box has not reported, or the canary changed while it was checked. Nothing was deleted. Try again in 15 minutes"
- textRetireCheck = "could not check what follows %s, so nothing was deleted. Try again"
- textRetireStore = "could not read the deployment bucket, so nothing was deleted. Try again"
- textRetireFailed = "retiring %s failed, so it may still be there. Try again"
- textRetireHasApp = "%s/%s is an app on this console: use carlos canary retire --account %s --app %s --name %s"
- textRetireTrashed = "%s/%s is in the trash: restore it and retire the canary, or let the purge remove it"
- textRetireHasRecords = "%s/%s still has instance records in the deployment bucket, so its channels are not retired here"
- textRetireActivity = "retired canary %s (cli)"
+ textRetireBadName = "%q is not a canary name"
+ textRetireNoBucket = "no deployment bucket on this host, so this console cannot retire a canary"
+ textRetireNoCanary = "%s has no canary named %s"
+ textRetireFollowed = "canary %s still has a host (%s) following it. Delete that instance or move it to another channel, then retire the canary"
+ textRetireUnsettled = "%s was not retired: an instance of %s changed in the last 15 minutes, a box has not reported, or the canary changed while it was checked. Nothing was deleted. Try again in 15 minutes"
+ textRetireCheck = "could not check what follows %s, so nothing was deleted. Try again"
+ textRetireStore = "could not read the deployment bucket, so nothing was deleted. Try again"
+ textRetireFailed = "retiring %s failed, so it may still be there. Try again"
+ textRetireActivity = "retired canary %s (cli)"
)
// errNoCanary is checkCanaryRetire's answer when the channel has no pointer.
@@ -121,11 +117,10 @@ func (s *Server) checkCanaryRetire(ctx context.Context, acct, app, channel strin
}
// deleteRetiredCanary deletes the pointer c read, under the app lock, inside
-// mutate (the door's app mutation). recheck, when not nil, runs under the
-// lock first: the operator door asks there again that the app has no row.
-// A change to the app's records or to the pointer since the check is an
-// error wrapping errRetireUnsettled, and nothing is deleted.
-func (s *Server) deleteRetiredCanary(ctx context.Context, c *canaryRetireCheck, mutate func(context.Context, func(context.Context) error) error, recheck func(context.Context) error) error {
+// mutate (the door's app mutation). A change to the app's records or to the
+// pointer since the check is an error wrapping errRetireUnsettled, and
+// nothing is deleted.
+func (s *Server) deleteRetiredCanary(ctx context.Context, c *canaryRetireCheck, mutate func(context.Context, func(context.Context) error) error) error {
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
// The app lock from the re-list through the delete: every console
@@ -138,11 +133,6 @@ func (s *Server) deleteRetiredCanary(ctx context.Context, c *canaryRetireCheck,
if h := s.retireBeforeDeleteHook; h != nil {
h()
}
- if recheck != nil {
- if err := recheck(ctx); err != nil {
- return err
- }
- }
after, err := s.recordStamps(ctx, c.acct, c.app)
if err != nil {
return err
@@ -186,15 +176,6 @@ func (s *Server) appRetireMutation(acct *Account, app string) func(context.Conte
}
}
-// orphanRetireMutation is deleteRetiredCanary's mutate for an app this
-// console has no row for: no demo claim can hold an app with no row, so
-// the bucket's app mutation alone, as the relay's per-app walks take it.
-func (s *Server) orphanRetireMutation(acct, app string) func(context.Context, func(context.Context) error) error {
- return func(ctx context.Context, fn func(context.Context) error) error {
- return release.WithAppMutation(ctx, s.cfg.Releases, acct, app, "canary-retire-orphan", fn)
- }
-}
-
// handleRetireCanary removes a canary's channel pointer from the browser.
// Shipped releases are untouched: retirement un-points, it never deletes
// bits.
@@ -263,7 +244,7 @@ func (s *Server) handleRetireCanary(w http.ResponseWriter, r *http.Request) {
s.confirmRetireCanary(w, r, addr, raw, acct, role, app, name)
return
}
- err = s.deleteRetiredCanary(r.Context(), chk, s.appRetireMutation(acct, app), nil)
+ err = s.deleteRetiredCanary(r.Context(), chk, s.appRetireMutation(acct, app))
if errors.Is(err, errRetireUnsettled) {
log.Printf("console: retire %s %s: %v", app, channel, err)
back("err", "Could not verify no hosts follow this channel — try again.")
@@ -343,7 +324,7 @@ func (s *Server) handleAPIRetireCanary(w http.ResponseWriter, r *http.Request) {
if writeRetireRefusal(w, err, acct.Sqid, app, channel) {
return
}
- err = s.deleteRetiredCanary(r.Context(), chk, s.appRetireMutation(acct, app), nil)
+ err = s.deleteRetiredCanary(r.Context(), chk, s.appRetireMutation(acct, app))
if errors.Is(err, errRetireUnsettled) {
writeRetireRefusal(w, err, acct.Sqid, app, channel)
return
@@ -357,133 +338,3 @@ func (s *Server) handleAPIRetireCanary(w http.ResponseWriter, r *http.Request) {
Detail: fmt.Sprintf(textRetireActivity, req.Name)})
writeJSON(w, http.StatusOK, map[string]string{"result": "retired", "channel": channel})
}
-
-// errNoAppRow is the operator door's recheck failing: the app gained a
-// console row, a trash marker or a record while the retire was checked.
-var errNoAppRow = errors.New("the app is no longer without a row")
-
-// orphanRefusal is the operator door's precondition: acct/app has no live
-// or trashed console row, no trash marker and no instance or sidecar
-// record. It answers the refusal's status and sentence, or 0 when the app
-// is an orphan. Anything it cannot read refuses.
-func (s *Server) orphanRefusal(ctx context.Context, acct, app, name string) (int, string, error) {
- a, err := s.store.AccountBySqid(acct)
- if err != nil {
- return http.StatusInternalServerError, fmt.Sprintf(textRetireCheck, release.RungCanary+"/"+name), err
- }
- if a != nil {
- live, err := s.store.HasAppInContext(ctx, a.ID, app)
- if err != nil {
- return http.StatusInternalServerError, fmt.Sprintf(textRetireCheck, release.RungCanary+"/"+name), err
- }
- if live {
- return http.StatusConflict, fmt.Sprintf(textRetireHasApp, acct, app, acct, app, name), nil
- }
- trashed, err := s.store.HasTrashedAppInContext(ctx, a.ID, app)
- if err != nil {
- return http.StatusInternalServerError, fmt.Sprintf(textRetireCheck, release.RungCanary+"/"+name), err
- }
- if trashed {
- return http.StatusConflict, fmt.Sprintf(textRetireTrashed, acct, app), nil
- }
- }
- tomb, err := release.ReadAppTombstone(ctx, s.cfg.Releases, acct, app)
- if err != nil {
- return http.StatusBadGateway, textRetireStore, err
- }
- if tomb != nil {
- return http.StatusConflict, fmt.Sprintf(textRetireTrashed, acct, app), nil
- }
- stamps, err := s.recordStamps(ctx, acct, app)
- if err != nil {
- return http.StatusBadGateway, textRetireStore, err
- }
- if len(stamps) > 0 {
- return http.StatusConflict, fmt.Sprintf(textRetireHasRecords, acct, app), nil
- }
- return 0, "", nil
-}
-
-// handleAPISystemRetireChannel is POST /api/cli/system/channels/retire,
-// `carlos channels retire --account-id <sqid> --app <a> canary/<name>`
-// (#1634): a platform operator retires a canary pointer of an app this
-// console has no row for, which no member door can reach. canary/* only: a
-// bucket-only app's other channels may still be served by hand routes,
-// and retiring those is not what this door is for.
-//
-// It refuses an app with a live or trashed console row (the member door
-// and the trash own those), a trash marker in the bucket, any instance or
-// sidecar record, and any follower by registry or box report (the same
-// guard as the member door, whose box-report rule sees hand routes). It
-// asks the row and marker again under the app lock, deletes with CAS, and
-// writes a platform audit row.
-func (s *Server) handleAPISystemRetireChannel(w http.ResponseWriter, r *http.Request) {
- addr, _, ok := s.apiSystemRoller(w, r)
- if !ok {
- return
- }
- if !s.systemBucket(w) {
- return
- }
- p, _ := principalFrom(r.Context())
- if !s.allowWrite(p, time.Now()) {
- jsonError(w, http.StatusTooManyRequests, textTooManyRequests)
- return
- }
- var req struct {
- Account string `json:"account"`
- App string `json:"app"`
- Channel string `json:"channel"`
- }
- if !readJSON(w, r, &req) {
- return
- }
- if !release.ValidAccount(req.Account) || !release.ValidApp(req.App) {
- jsonError(w, http.StatusBadRequest, "name an account sqid and an app")
- return
- }
- if !validRetireChannel(req.Channel) {
- jsonError(w, http.StatusBadRequest, fmt.Sprintf(textRetireBadChannel, req.Channel))
- return
- }
- if len(s.cfg.Key) == 0 {
- jsonError(w, http.StatusServiceUnavailable, textNoReleaseKey)
- return
- }
- acct, app, channel := req.Account, req.App, req.Channel
- name := strings.TrimPrefix(channel, release.RungCanary+"/")
- ctx := r.Context()
- if status, msg, err := s.orphanRefusal(ctx, acct, app, name); status != 0 {
- if err != nil {
- log.Printf("console: api system retire %s/%s %s: %v", acct, app, channel, err)
- }
- jsonError(w, status, msg)
- return
- }
- chk, err := s.checkCanaryRetire(ctx, acct, app, channel)
- if writeRetireRefusal(w, err, acct, app, channel) {
- return
- }
- mutate := s.orphanRetireMutation(acct, app)
- recheck := func(ctx context.Context) error {
- if status, _, err := s.orphanRefusal(ctx, acct, app, name); status != 0 {
- if err != nil {
- return err
- }
- return fmt.Errorf("%w: %w", errRetireUnsettled, errNoAppRow)
- }
- return nil
- }
- err = s.deleteRetiredCanary(ctx, chk, mutate, recheck)
- if errors.Is(err, errRetireUnsettled) {
- writeRetireRefusal(w, err, acct, app, channel)
- return
- }
- if err != nil {
- log.Printf("console: api system retire %s/%s %s: %v", acct, app, channel, err)
- jsonError(w, http.StatusBadGateway, fmt.Sprintf(textRetireFailed, channel))
- return
- }
- s.auditSystem(addr, "canary-retire-orphan", fmt.Sprintf("retired %s of %s/%s, an app not on this console (cli)", channel, acct, app))
- writeJSON(w, http.StatusOK, map[string]string{"result": "retired", "channel": channel})
-}
diff --git a/internal/console/canary_retire_test.go b/internal/console/canary_retire_test.go
index d76ed4dff..9887c74f3 100644
--- a/internal/console/canary_retire_test.go
+++ b/internal/console/canary_retire_test.go
@@ -13,22 +13,16 @@ import (
"time"
"github.com/carlosframework/platform/internal/provision"
- "github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
)
-// The CLI retire doors (#1634): `carlos canary retire` for a member, and
-// `carlos channels retire` for an operator retiring a canary pointer of an
-// app the console has no row for.
+// The CLI retire door (#1634): `carlos canary retire` for a member, and
+// the repair listing's mark on an app the console has no row for.
func retireURL(tb *twoBoxes, app string) string {
return tb.fx.ts.URL + "/api/cli/apps/" + tb.sqid + "/" + app + "/canary/retire"
}
-func orphanRetireURL(tb *twoBoxes) string {
- return tb.fx.ts.URL + "/api/cli/system/channels/retire"
-}
-
func pointerExists(t *testing.T, tb *twoBoxes, app, channel string) bool {
t.Helper()
_, _, err := tb.fx.rel.Get(context.Background(), release.ChannelKey(tb.sqid, app, channel))
@@ -132,133 +126,10 @@ func TestAPIRetireCanaryFailsClosed(t *testing.T) {
}
}
-// The operator door: an app with no console row ("old", shipped straight
-// to the bucket) loses its canary pointer only when no box reports a host
-// of it (a hand route), and then only that pointer; the platform audit
-// names it.
-func TestAPISystemRetireChannel(t *testing.T) {
- tb := newTwoBoxes(t)
- settledApp(t, tb)
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "canary/rc")
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "stable")
- body := `{"account":"` + tb.sqid + `","app":"old","channel":"canary/rc"}`
-
- // A hand route of "old" on box B, which no record names: the box
- // report holds the retire.
- if err := tb.regB.Upsert(registry.Route{Host: "hand.old.example.com", Kind: "instance", App: "old", Account: tb.sqid,
- Channel: "canary/rc", Version: "v1", Provisioned: true, Hibernate: true, Status: "ready",
- Socket: "/run/carlos/hand-old.sock"}); err != nil {
- t.Fatal(err)
- }
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
- tb.fx.srv.boxReports.expire()
- status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token, body)
- if status != http.StatusConflict || !strings.Contains(out, "a box has not reported") || !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatalf("orphan retire with a hand route on box B = %d %s", status, out)
- }
-
- if err := tb.regB.Delete("hand.old.example.com"); err != nil {
- t.Fatal(err)
- }
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
- tb.fx.srv.boxReports.expire()
- status, _, out = rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token, body)
- if status != http.StatusOK {
- t.Fatalf("orphan retire = %d %s", status, out)
- }
- if pointerExists(t, tb, "old", "canary/rc") {
- t.Fatal("the orphan's canary pointer is still there")
- }
- if !pointerExists(t, tb, "old", "stable") {
- t.Fatal("the orphan retire took another channel with it")
- }
- if _, err := release.GetManifest(context.Background(), tb.fx.rel, tb.sqid, "old", "v1"); err != nil {
- t.Fatalf("orphan retire touched a shipped release: %v", err)
- }
- found := false
- for _, e := range roleAudits(t, tb.fx) {
- found = found || (e.Action == "canary-retire-orphan" && strings.Contains(e.Detail, "canary/rc of "+tb.sqid+"/old"))
- }
- if !found {
- t.Fatal("no platform audit row for the orphan retire")
- }
-}
-
-// Every refusal of the operator door, each leaving the pointer in place: a
-// channel outside canary/*, an app the console has (the member door's), an
-// app in the trash, an app with instance records, and a member who is not
-// a platform operator.
-func TestAPISystemRetireChannelRefusals(t *testing.T) {
- tb := newTwoBoxes(t)
- settledApp(t, tb)
- ctx := context.Background()
- shipAndPromote(t, tb.fx, tb.sqid, "shop", "v4", "canary/rc")
- for _, app := range []string{"old", "binned", "recorded"} {
- shipAndPromote(t, tb.fx, tb.sqid, app, "v1", "canary/rc")
- }
- if err := release.TrashApp(ctx, tb.fx.rel, tb.sqid, "binned", "paul@keymail.dev", time.Now()); err != nil {
- t.Fatal(err)
- }
- if err := provision.CreateRecord(ctx, tb.fx.rel, provision.Record{Schema: 1, Host: "x.recorded.example.com", Slug: "x",
- App: "recorded", Account: tb.sqid, Pool: "shop", Region: "uk", Channel: "stable", CreatedAt: time.Now()}); err != nil {
- t.Fatal(err)
- }
- post := func(token, app, channel string) (int, string) {
- body, _ := json.Marshal(map[string]string{"account": tb.sqid, "app": app, "channel": channel})
- status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), token, string(body))
- return status, out
- }
- cases := []struct {
- app, channel string
- status int
- says string
- }{
- {"old", "stable", http.StatusBadRequest, "is not a canary channel"},
- {"shop", "canary/rc", http.StatusConflict, "carlos canary retire --account " + tb.sqid + " --app shop --name rc"},
- {"binned", "canary/rc", http.StatusConflict, "is in the trash"},
- {"recorded", "canary/rc", http.StatusConflict, "still has instance records"},
- }
- for _, c := range cases {
- status, out := post(tb.token, c.app, c.channel)
- if status != c.status || !strings.Contains(out, c.says) {
- t.Fatalf("orphan retire of %s %s = %d %s, want %d saying %q", c.app, c.channel, status, out, c.status, c.says)
- }
- }
- for _, app := range []string{"shop", "binned", "recorded"} {
- if !pointerExists(t, tb, app, "canary/rc") {
- t.Fatalf("a refused retire deleted %s's canary/rc", app)
- }
- }
- member := cliToken(t, tb.fx, "alice@keymail.dev", "code-orphan-member")
- if status, out := post(member, "old", "canary/rc"); status != http.StatusNotFound {
- t.Fatalf("orphan retire by a non-operator = %d %s, want 404", status, out)
- }
- if !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatal("a non-operator retired the orphan's canary")
- }
-}
-
-// A console row created for the app while the retire was being checked
-// (an owner adopting the name) refuses the delete under the lock.
-func TestAPISystemRetireChannelRefusesAnAppCreatedDuringTheCheck(t *testing.T) {
- tb := newTwoBoxes(t)
- settledApp(t, tb)
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "canary/rc")
- tb.fx.srv.retireBeforeDeleteHook = func() {
- if _, err := tb.fx.st.CreateAppIn(5151, "old", "paul@keymail.dev", time.Now()); err != nil {
- t.Error(err)
- }
- }
- status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token,
- `{"account":"`+tb.sqid+`","app":"old","channel":"canary/rc"}`)
- if status != http.StatusConflict || !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatalf("orphan retire with an app created during the check = %d %s", status, out)
- }
-}
-
// The repair listing marks a line of an app the console has no row for
-// (no_app), so the CLI can name the operator door; an app with a row is
-// not marked.
+// (no_app) under an account it has; an app with a row is not marked, and
+// neither is an account only the bucket holds, which the console can tell
+// nothing about.
func TestSystemDigestsDoorMarksAppsWithNoRow(t *testing.T) {
fx := newDigestsFixture(t)
ctx := context.Background()
@@ -297,7 +168,7 @@ func TestSystemDigestsDoorMarksAppsWithNoRow(t *testing.T) {
want := map[string]bool{
release.OpsAccount + "/km/canary/x": false,
release.OpsAccount + "/direct/canary/y": true,
- "zqx/shop/canary/z": true,
+ "zqx/shop/canary/z": false,
}
for k, v := range want {
if noApp, ok := got[k]; !ok || noApp != v {
@@ -305,3 +176,16 @@ func TestSystemDigestsDoorMarksAppsWithNoRow(t *testing.T) {
}
}
}
+
+// The member door is a person's act: a service credential of the account
+// never reaches it, and the pointer stays.
+func TestAPIRetireCanaryRefusesServiceCredentials(t *testing.T) {
+ fx := newDigestsFixture(t)
+ st, out := postRaw(t, fx.ts.URL+"/api/cli/apps/bab/km/canary/retire", map[string]string{"name": "x"}, fx.serviceToken)
+ if st != http.StatusNotFound && st != http.StatusForbidden {
+ t.Fatalf("a service credential reached canary retire: %d %s", st, out)
+ }
+ if _, _, err := fx.store.Get(context.Background(), release.ChannelKey(release.OpsAccount, "km", "canary/x")); err != nil {
+ t.Fatalf("canary/x after a refused retire: %v", err)
+ }
+}
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go
index 9e4c5c9e2..5f8717bd2 100644
--- a/internal/console/claim_invariant_fixtures_test.go
+++ b/internal/console/claim_invariant_fixtures_test.go
@@ -1725,7 +1725,6 @@ var claimFixtures = map[string]claimFixture{
"route POST /api/cli/system/antivirus": claimNonApp("the deployment scanning switch (system/antivirus.json)"),
"route POST /api/cli/system/layout": claimNonApp("the deployment layout intent (control/layout.json)"),
"route POST /api/cli/system/activation/cancel": claimNonApp("cancels an unpublished system activation"),
- "route POST /api/cli/system/channels/retire": claimNonApp("operator retire of a canary pointer of an app with no console row; the delete runs inside the bucket's own app mutation (release.WithAppMutation), classified exactly by the mutation boundary"),
"route POST /api/cli/system/pointer-digests": claimNonApp("operator switch: writes or removes each account's root-signed pointer digest marker (releases/<acct>/pointer-digests), classified exactly by the mutation boundary"),
"route POST /api/cli/system/hold": claimNonApp("rewrites the platform system pointer's per-box update holds"),
"route POST /api/cli/system/hold/release": claimNonApp("removes a per-box update hold from the platform system pointer"),
diff --git a/internal/console/claim_invariant_probes_nonapp_test.go b/internal/console/claim_invariant_probes_nonapp_test.go
index 978c064b0..4c1538820 100644
--- a/internal/console/claim_invariant_probes_nonapp_test.go
+++ b/internal/console/claim_invariant_probes_nonapp_test.go
@@ -15,7 +15,6 @@ import (
"net/http"
"net/http/httptest"
"net/url"
- "os"
"strconv"
"strings"
"testing"
@@ -1325,29 +1324,6 @@ var claimNonAppProbes = map[string]claimProbe{
return ""
},
},
- // An app shipped straight to the bucket under bab with no console row:
- // its canary pointer is the one the operator door may retire (#1634).
- "route POST /api/cli/system/channels/retire": {
- setup: func(t *testing.T, cx *claimCase) {
- ctx := context.Background()
- m := release.Manifest{Schema: 1, App: "orphan", Version: "v1", Kind: "binary", BuiltAt: "2026-10-01T10:00:00Z",
- Artifacts: map[string]release.Artifact{"linux-amd64": {File: "orphan"}}}
- if err := release.Ship(ctx, cx.rel, "bab", m, map[string][]byte{"linux-amd64": []byte("binary v1")}); err != nil {
- t.Fatal(err)
- }
- if err := release.Promote(ctx, cx.rel, cx.priv, "bab", "orphan", "canary/old", "v1"); err != nil {
- t.Fatal(err)
- }
- },
- do: claimAPIReply(http.MethodPost, "/api/cli/system/channels/retire", `{"account":"bab","app":"orphan","channel":"canary/old"}`),
- body: []string{`"channel":"canary/old"`},
- effect: func(t *testing.T, cx *claimCase, r claimReply) string {
- if _, _, err := cx.rel.Get(context.Background(), release.ChannelKey("bab", "orphan", "canary/old")); !errors.Is(err, os.ErrNotExist) {
- return "the orphan's canary/old pointer is still there"
- }
- return ""
- },
- },
"route POST /api/cli/system/pointer-digests": {
do: claimAPIReply(http.MethodPost, "/api/cli/system/pointer-digests", `{"on":true,"accounts":["bab"]}`),
body: []string{`"account":"bab","on":true`},
diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go
index e0616af22..fdc4f36a8 100644
--- a/internal/console/routedecls.go
+++ b/internal/console/routedecls.go
@@ -1301,9 +1301,6 @@ var routeDecls = []routeDecl{
{Pattern: "GET /api/cli/system/hosts-used/status", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIHostsUsedStatus},
{Pattern: "GET /api/cli/system/pointer-digests", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemPointerDigests},
{Pattern: "POST /api/cli/system/pointer-digests", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemPointerDigests},
- // `carlos channels retire` (#1634): a canary pointer of an app with no
- // row on this console. apiSystemRoller, like pointer digests.
- {Pattern: "POST /api/cli/system/channels/retire", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemRetireChannel},
// The anonymous demos (apidemo.go): registered on a console with demos
// on or one in demo box mode (gateDemo).
diff --git a/internal/console/testdata/claim-authority-sites.txt b/internal/console/testdata/claim-authority-sites.txt
index 3a603a14f..c21243ba7 100644
--- a/internal/console/testdata/claim-authority-sites.txt
+++ b/internal/console/testdata/claim-authority-sites.txt
@@ -72,7 +72,6 @@ claim_app_admission.go|initializeBackfillClaimAppAdmission|w.EnrollBackfillApp(c
claim_app_admission.go|reserveClaimAppAdmission|w.EnrollNewApp(ctx, acct.Sqid, app)
claim_app_enroll.go|insertClaimAppRow|s.claimEnrollmentContext(ctx, acct, app, appID)
claim_app_enroll.go|insertClaimAppRow|w.EnrollNewApp(ctx, acct.Sqid, app)
-canary_retire.go|orphanRetireMutation|release.WithAppMutation(ctx, s.cfg.Releases, acct, app, "canary-retire-orphan", fn)
claim_app_mutation.go|claimAppCall|release.WithAppMutation(ctx, s.cfg.Releases, acct.Sqid, app, action, func(callCtx context.Context) error { var callErr error result, callErr = call(callCtx) return callErr })
claim_create.go|beginClaimCreate|a.Control.RegisterStart(ctx, acct.Sqid, app, appID, id, registration, time.Now())
claim_mail_admitter.go|AcquireClaimMailGate|g.w.AcquireMailGate(ctx, hostops.MailGateOwner(owner), hostops.MailGateScope(scope))
diff --git a/parity/parity.tsv b/parity/parity.tsv
index 55701e6a3..d857c528f 100644
--- a/parity/parity.tsv
+++ b/parity/parity.tsv
@@ -228,7 +228,6 @@ op-instance-policy operator operator apps set [--egress-allow,--size] ; instance
op-upstreams operator operator instances set-upstreams ; instances create [--addr] TCP backends are set by an operator.
op-digests operator operator channels digests [on, off] The digest signing switch.
channels-digests operator operator channels digests [report] Operator only: the report needs a system operator (apiSystemRoller). Shows which channel pointers are digest-signed.
-channels-retire operator operator channels retire Operator only. Requires a system operator (apiSystemRoller). Retires a canary pointer of an app with no console row, which no member door reaches.
op-releases-authorize operator operator releases authorize Signs a promotion record for an old build.
op-relay-rotate operator operator relay rotate Rotates a region's relay master.
op-move-lost operator operator move resolve [--declare-lost] Declares a box lost in the middle of a move.