carlos / platform Public

channels digests: box-report evidence for no-app lines; no delete (#1634)

Per 8a3d302 (option B, after Astra invoked the stopping rule in round 2):
the operator delete is cut. Box reports are snapshots, so they cannot
prove nothing runs an app at the moment of a delete; that needs a
retiring marker boxes honour and acknowledge, a separate design.

What ships: box reports' route_channels (unchanged from round 2), and
carlos channels digests now lists, for each app marked "no app on this
console", which boxes last reported running it, on which channel, and how
old each report is, or which boxes cannot say. Read-only; nothing acts on
it. The door, its route, CLI verb, locks and fixtures are reverted to
main. Copy by Luna under delegation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev fc0d4f25edc91bd929f448ad1fa664e11e6b2a8a parent 9ceba94
25 files changed, +339 −955
  • canary_retire.go +2 −51
  • canary_retire_test.go +45 −54
  • channels_digests.go +81 −10
  • commands.go +3 −5
  • docs/parity.md +0 −1
  • docs/site/cli.md +8 −22
  • internal/console/apidigests.go +45 −2
  • internal/console/apilinks_test.go +5 −6
  • internal/console/canary_retire.go +10 −274
  • internal/console/canary_retire_orphan_test.go +0 −396
  • internal/console/claim_app_enroll.go +0 −10
  • internal/console/claim_invariant_fixtures_test.go +0 −9
  • internal/console/claim_invariant_test.go +0 −2
  • internal/console/digests_noapp_test.go +111 −0
  • internal/console/remoteinstances.go +25 −67
  • internal/console/remoteinstances_round5_test.go +1 −3
  • internal/console/routedecls.go +0 −3
  • internal/console/svcroutes_test.go +2 −5
  • internal/console/testdata/claim-authority-sites.txt +0 −1
  • internal/console/testdata/claim-routes.txt +0 −1
  • internal/provision/canary_retire_orphan_1634_census_test.go +0 −28
  • internal/provision/plan9_b8_census_test.go +1 −1
  • parity/cli.tsv +0 −1
  • parity/parity.tsv +0 −1
  • testdata/clireg-golden.jsonl +0 −2
diff --git a/canary_retire.go b/canary_retire.go
index e999d59c3..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.
@@ -20,8 +20,6 @@ import (
const (
textCanaryRetired = "%s's pointer is gone. Its releases are kept"
textCanaryRetireNeedName = "carlos canary retire: --name <n> is required"
- 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"
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>"
)
@@ -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,36 +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 the command on
-// such a line). The console refuses an account it does not have, an app it
-// has, one in the trash, one with instance records, a route of the app on
-// any box, a box that cannot say, 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 a1329217f..82acd35d9 100644
--- a/canary_retire_test.go
+++ b/canary_retire_test.go
@@ -7,6 +7,7 @@ import (
"net/http/httptest"
"strings"
"testing"
+ "time"
)
// `carlos canary retire` posts the name to the member door and prints the
@@ -79,7 +80,7 @@ func TestCanaryRetireRefusesDirectBucketMode(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: "stable", Version: "v1", NoRecord: true, NoApp: true}
+ head := apiDigestRepair{Account: "bab", App: "old", Channel: "canary/rc", Version: "v1", NoRecord: true, NoApp: true}
if got, want := repairCell(head), textRepairNoRecord+" (no app on this console)"; got != want {
t.Fatalf("no-app head = %q, want %q", got, want)
}
@@ -94,71 +95,61 @@ func TestRepairCellMarksAppsWithNoRow(t *testing.T) {
}
}
-// `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) {
+// The digests listing prints what the box reports say about each app with
+// no console entry: the boxes that last reported running it, the ones that
+// cannot say, or that none reports it; and that reports are snapshots.
+func TestChannelsDigestsPrintsNoAppEvidence(t *testing.T) {
useTempCredentials(t)
clearDeploymentEnv(t)
- var posted map[string]string
+ now := time.Now().UTC()
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"})
+ json.NewEncoder(w).Encode(map[string]any{
+ "accounts": []map[string]any{{"account": "bab", "on": true, "since": "2026-10-07T00:00:00Z"}},
+ "repairs": []map[string]any{
+ {"account": "bab", "app": "old", "channel": "canary/rc", "version": "v1", "no_record": true, "no_app": true},
+ {"account": "bab", "app": "gone", "channel": "canary/x", "version": "v1", "no_record": true, "no_app": true},
+ },
+ "no_app": []map[string]any{
+ {"account": "bab", "app": "old", "complete": true, "boxes": 3,
+ "running": []map[string]any{{"box": "box-a", "channel": "canary/rc", "at": now.Add(-4 * time.Minute).Format(time.RFC3339)}},
+ "silent": []map[string]any{{"box": "box-b", "at": now.Add(-3 * time.Hour).Format(time.RFC3339)}}},
+ {"account": "bab", "app": "gone", "complete": true, "boxes": 3},
+ },
+ })
}))
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 := runChannelsDigests(nil); err != nil {
+ t.Fatalf("digests: %v", err)
+ }
+ for _, want := range []string{
+ textNoAppHeader,
+ fmt.Sprintf(textNoAppRunning, "bab", "old", "box-a", "canary/rc", "4m"),
+ fmt.Sprintf(textNoAppSilent, "bab", "old", "box-b", "3h"),
+ fmt.Sprintf(textNoAppNone, "bab", "gone", 3),
+ textNoAppSnapshot,
} {
- if err := runChannelsRetire(args); err == nil || err.Error() != textChannelsRetireUsage {
- t.Fatalf("channels retire %v = %v, want the usage", args, err)
+ if !strings.Contains(out.String(), want) {
+ t.Fatalf("listing lacks %q:\n%s", want, out.String())
}
}
- if posted != nil {
- t.Fatalf("an incomplete retire posted %v", posted)
+ if strings.Contains(out.String(), fmt.Sprintf(textNoAppNone, "bab", "old", 3)) {
+ t.Fatalf("an app a box runs was also said to run nowhere:\n%s", out.String())
}
}
-// Direct bucket mode has no console to ask the box reports, so the
-// operator verb refuses rather than touch the bucket.
-func TestChannelsRetireRefusesDirectBucketMode(t *testing.T) {
- useTempCredentials(t)
- clearDeploymentEnv(t)
- t.Setenv("CARLOS_DEPLOYMENT_DIR", t.TempDir())
- 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)
- }
-}
-
-// A canary head of an app with no console row names the operator command
-// after the mark; a stable head or a record line of such an app keeps
-// only the mark.
-func TestRepairCellNamesTheRetireForNoAppCanaries(t *testing.T) {
- head := apiDigestRepair{Account: "bab", App: "old", Channel: "canary/rc", Version: "v1", NoRecord: true, NoApp: true}
- want := textRepairNoRecord + " (no app on this console). If no box runs it, remove it with carlos channels retire --account-id bab --app old canary/rc"
- if got := repairCell(head); got != want {
- t.Fatalf("no-app canary head = %q, want %q", got, want)
- }
- stable := head
- stable.Channel = "stable"
- if got := repairCell(stable); got != textRepairNoRecord+" (no app on this console)" {
- t.Fatalf("no-app stable head = %q", got)
+func TestReportAge(t *testing.T) {
+ now := time.Date(2026, 12, 2, 12, 0, 0, 0, time.UTC)
+ for at, want := range map[string]string{
+ now.Add(-20 * time.Second).Format(time.RFC3339): "<1m",
+ now.Add(-4 * time.Minute).Format(time.RFC3339): "4m",
+ now.Add(-3 * time.Hour).Format(time.RFC3339): "3h",
+ now.Add(-50 * time.Hour).Format(time.RFC3339): "2d",
+ "not a time": "not a time",
+ } {
+ if got := reportAge(at, now); got != want {
+ t.Errorf("reportAge(%q) = %q, want %q", at, got, want)
+ }
}
}
diff --git a/channels_digests.go b/channels_digests.go
index 74c27ca49..8a1fe8084 100644
--- a/channels_digests.go
+++ b/channels_digests.go
@@ -67,10 +67,6 @@ const (
// (#1634), reviewed by Luna under delegation (2026-12-01).
const textRepairNoApp = "%s (no app on this console)"
-// A canary head of such an app also names the operator command that
-// removes it (#1634), reviewed by Luna under delegation (2026-12-02).
-const textRepairNoAppRetire = "%s (no app on this console). If no box runs it, remove it with carlos channels retire --account-id %s --app %s %s"
-
// 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
// key grant it was signed under names none) or NoRecord (no digest and no
@@ -108,6 +104,85 @@ type apiPointerDigests struct {
// Repairs is nil when the console predates the listing, never empty
// for that reason: an empty list is a clean answer.
Repairs *[]apiDigestRepair `json:"repairs"`
+ // NoApp is, per app the repair listing marks "no app on this console",
+ // what the box reports say about it (#1634). Absent from an older
+ // console and from the direct-store report.
+ NoApp []apiNoAppEvidence `json:"no_app"`
+}
+
+// apiNoAppEvidence is one app's box-report evidence: how many reports were
+// read and whether all were, the reports naming a route of the app, and
+// the reports that cannot say which apps their box runs.
+type apiNoAppEvidence struct {
+ Account string `json:"account"`
+ App string `json:"app"`
+ Complete bool `json:"complete"`
+ Boxes int `json:"boxes"`
+ Running []apiBoxReported `json:"running"`
+ Silent []apiBoxReported `json:"silent"`
+}
+
+type apiBoxReported struct {
+ Box string `json:"box"`
+ Channel string `json:"channel"`
+ At string `json:"at"`
+}
+
+// The no-app evidence lines (#1634), reviewed by Luna under delegation
+// (2026-12-02).
+const (
+ textNoAppHeader = "Apps with no entry on this console, based on the boxes' last reports:"
+ textNoAppNone = " %s/%s: no box reports running it (%d box reports read)"
+ textNoAppRunning = " %s/%s: box %s last reported it running on %s (report %s old)"
+ textNoAppSilent = " %s/%s: box %s reported an older CARLOS version that cannot say which apps it runs (report %s old)"
+ textNoAppIncomplete = " %s/%s: not every box report could be read"
+ textNoAppSnapshot = "Box reports are snapshots, written every few minutes; a box with no report for a day is no longer listed."
+)
+
+// printNoAppEvidence prints what the box reports say about each app the
+// repair listing marks "no app on this console" (#1634): which boxes last
+// reported running it, on which channel, and how old each report is. It is
+// evidence for the operator, never a verdict, and nothing acts on it.
+func printNoAppEvidence(rep apiPointerDigests, now time.Time) {
+ if len(rep.NoApp) == 0 {
+ return
+ }
+ fmt.Fprintln(stdout, textNoAppHeader)
+ for _, e := range rep.NoApp {
+ if !e.Complete {
+ fmt.Fprintf(stdout, textNoAppIncomplete+"\n", e.Account, e.App)
+ }
+ for _, r := range e.Running {
+ fmt.Fprintf(stdout, textNoAppRunning+"\n", e.Account, e.App, r.Box, r.Channel, reportAge(r.At, now))
+ }
+ for _, r := range e.Silent {
+ fmt.Fprintf(stdout, textNoAppSilent+"\n", e.Account, e.App, r.Box, reportAge(r.At, now))
+ }
+ if e.Complete && len(e.Running) == 0 && len(e.Silent) == 0 {
+ fmt.Fprintf(stdout, textNoAppNone+"\n", e.Account, e.App, e.Boxes)
+ }
+ }
+ mutedf(stdout, textNoAppSnapshot)
+}
+
+// reportAge is how long ago a report's RFC 3339 time was, coarsely: <1m,
+// minutes, hours under two days, then days. A time that does not parse is
+// printed as sent.
+func reportAge(at string, now time.Time) string {
+ t, err := time.Parse(time.RFC3339, at)
+ if err != nil {
+ return at
+ }
+ d := now.Sub(t)
+ switch {
+ case d < time.Minute:
+ return "<1m"
+ case d < time.Hour:
+ return fmt.Sprintf("%dm", int(d.Minutes()))
+ case d < 48*time.Hour:
+ return fmt.Sprintf("%dh", int(d.Hours()))
+ }
+ return fmt.Sprintf("%dd", int(d.Hours())/24)
}
// repairCell is the repair a line needs. A head can need both: the
@@ -116,13 +191,8 @@ type apiPointerDigests struct {
// version again writes no record.
//
// 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. A canary head of
-// one also names the operator door that removes it, which refuses while
-// any box runs a route of the app.
+// after it (#1634): no member door reaches such an app.
func repairCell(r apiDigestRepair) string {
- if r.NoApp && !r.Record && strings.HasPrefix(r.Channel, release.RungCanary+"/") {
- return fmt.Sprintf(textRepairNoAppRetire, repairText(r), r.Account, r.App, r.Channel)
- }
if r.NoApp {
return fmt.Sprintf(textRepairNoApp, repairText(r))
}
@@ -437,6 +507,7 @@ func runChannelsDigests(args []string) error {
}
}
printRepairs(rep, failed, scope)
+ printNoAppEvidence(rep, time.Now())
switch {
case len(rep.Channels) > 0:
w := newTable(stdout)
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 0448bf4d4..d82e9f510 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -1038,28 +1038,14 @@ carlos channels digests
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. A canary line also gives the
-`carlos channels retire` command that removes the channel.
-
-### carlos channels retire
-
-For platform operators. This command deletes a `canary/<name>` channel of an
-app with no entry in the console, 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 asks every box which apps it runs, including routes added by hand, and
-refuses if any box runs the app on any channel, if any box runs a CARLOS
-version too old to report which apps it serves, or if any report cannot be
-read. A box that has stopped reporting still counts by its last report until
-a day has passed, just as it does on every fleet page. It also
-refuses if the console runs host claims, if the console has the app even in
-the trash, if the app has any instance record, or if the account is not on
-the console. It retires `canary/<name>` channels only, and never deletes
-shipped releases.
+cannot reach such an app.
+
+Below the list, box reports are listed for each such app: which boxes
+last reported running it, the channel each reported, and the age of each
+report. Boxes running a CARLOS version too old to identify their apps are
+listed separately. Reports are snapshots written every few minutes. This is
+evidence of what the boxes reported, not proof that nothing runs the app
+now. Nothing deletes channels for these apps yet.
### carlos pipeline
diff --git a/internal/console/apidigests.go b/internal/console/apidigests.go
index 9d7c8c5ce..aa76c9b40 100644
--- a/internal/console/apidigests.go
+++ b/internal/console/apidigests.go
@@ -256,13 +256,14 @@ func (s *Server) handleAPISystemPointerDigests(w http.ResponseWriter, r *http.Re
})
}
wg.Wait()
- acctRows, chRows, repRows := []digestAcctRow{}, []digestChRow{}, []digestRepRow{}
+ acctRows, chRows, repRows, noAppRows := []digestAcctRow{}, []digestChRow{}, []digestRepRow{}, []digestNoAppRow{}
for _, wk := range walks {
acctRows = append(acctRows, wk.row)
chRows = append(chRows, wk.channels...)
repRows = append(repRows, wk.repairs...)
+ noAppRows = append(noAppRows, wk.noApp...)
}
- writeJSON(w, http.StatusOK, map[string]any{"accounts": acctRows, "channels": chRows, "repairs": repRows})
+ writeJSON(w, http.StatusOK, map[string]any{"accounts": acctRows, "channels": chRows, "repairs": repRows, "no_app": noAppRows})
}
// digestWalkers is how many accounts the pointer digests report walks at once.
@@ -327,6 +328,44 @@ type digestAccountWalk struct {
row digestAcctRow
channels []digestChRow
repairs []digestRepRow
+ noApp []digestNoAppRow
+}
+
+// digestNoAppRow is what the box reports say about one app the console has
+// no row for and the repair listing names (#1634): read-only evidence for
+// the operator, never a verdict. Boxes is how many reports were read and
+// Complete whether all were; Running is each report naming a route of the
+// app; Silent each report that cannot say which apps its box runs. A box
+// that stopped reporting counts by its last report until the status
+// listing drops it a day later; At says how old each report is.
+type digestNoAppRow struct {
+ Account string `json:"account"`
+ App string `json:"app"`
+ Complete bool `json:"complete"`
+ Boxes int `json:"boxes"`
+ Running []digestBoxReport `json:"running,omitempty"`
+ Silent []digestBoxReport `json:"silent,omitempty"`
+}
+
+// digestBoxReport is one box's report in a digestNoAppRow.
+type digestBoxReport struct {
+ Box string `json:"box"`
+ Channel string `json:"channel,omitempty"`
+ At string `json:"at"`
+}
+
+// digestNoAppEvidence is digestNoAppRow for acct/app from the box reports
+// (remoteFacts, the pages' cached read: this is a report, not a decision).
+func (s *Server) digestNoAppEvidence(ctx context.Context, acct, app string) digestNoAppRow {
+ r := s.remoteFacts(ctx, acct, app).running()
+ row := digestNoAppRow{Account: acct, App: app, Complete: r.complete, Boxes: r.boxes}
+ for _, br := range r.running {
+ row.Running = append(row.Running, digestBoxReport{Box: br.box, Channel: br.rc.Channel, At: br.at.UTC().Format(time.RFC3339)})
+ }
+ for _, b := range r.silent {
+ row.Silent = append(row.Silent, digestBoxReport{Box: b.box, At: b.at.UTC().Format(time.RFC3339)})
+ }
+ return row
}
// walkDigestAccount reads one account's marker and every app's channels
@@ -351,6 +390,7 @@ func (s *Server) walkDigestAccount(ctx context.Context, sqid string, bucketOnly
noApp := s.digestNoApp(ctx, sqid, bucketOnly)
for _, app := range apps {
orphan := noApp(app)
+ listed := len(wk.repairs)
states, _, err := release.DigestReport(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid, app)
if err != nil {
row.Error = err.Error()
@@ -390,6 +430,9 @@ func (s *Server) walkDigestAccount(ctx context.Context, sqid string, bucketOnly
wk.repairs = append(wk.repairs, digestRepRow{Account: sqid, App: app, Version: rec.Version, Record: true, Error: rec.Err,
Unread: rec.Unread, NoBuild: rec.NoBuild, Grant: rec.Grant, GrantMintedAt: grantMinted(rec.Grant, rec.GrantMintedAt), NoApp: orphan})
}
+ if orphan && len(wk.repairs) > listed {
+ wk.noApp = append(wk.noApp, s.digestNoAppEvidence(ctx, sqid, app))
+ }
}
return wk
}
diff --git a/internal/console/apilinks_test.go b/internal/console/apilinks_test.go
index e9a4ea842..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 last under the lock a claim's insert takes); 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 de3dd2b70..c60992917 100644
--- a/internal/console/canary_retire.go
+++ b/internal/console/canary_retire.go
@@ -1,17 +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 of an app this console has no row for
-// (handleAPISystemRetireChannel). Such an app has no records to name
-// its followers, so the door also asks every box report which apps it
-// runs routes of (status BoxMetrics.RouteChannels).
+// (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"
@@ -46,30 +45,6 @@ const (
textRetireActivity = "retired canary %s (cli)"
)
-// The operator door's answers (#1634). Reviewed by Luna under delegation
-// (2026-12-02).
-const (
- textRetireBadChannel = "%q is not a canary channel: only canary/<name> channels can be retired"
- textRetireBadTarget = "provide a valid account sqid and a valid app"
- textRetireNoAccount = "account %s is not on this console, so it cannot check whether %s is still in use"
- 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"
- textRetireHostClaims = "this console runs host claims, so it cannot retire a channel for an app with no row"
- textRetireReports = "not every box report could be read, so nothing was deleted. Try again"
- textRetireSilent = "box %s runs a CARLOS version too old to report which apps it serves, so nothing was deleted. Retire the canary once every box runs this release"
- textRetireRoute = "box %s still runs a route of %s/%s (channel %s), so nothing was deleted"
-)
-
-// The box-report refusals added in round 1 of branch 1 (#1634). Reviewed by
-// Luna under delegation (2026-12-02).
-const (
- textRetireNoReports = "no box report was found, so nothing was deleted. Try again once every box has reported"
- textRetireSilentDark = "box %s stopped reporting at %s on a CARLOS version too old to report which apps it serves, so nothing was deleted. Retire the canary once that box reports again with this release, or a day after its last report"
- textRetireRouteDark = "box %s stopped reporting at %s after running a route of %s/%s (channel %s), so nothing was deleted. Retire the canary once that box reports again without it, or a day after its last report"
- textRetireOrphanDone = "retired %s of %s/%s, an app not on this console (cli)"
-)
-
// errNoCanary is checkCanaryRetire's answer when the channel has no pointer.
var errNoCanary = errors.New("no such canary")
@@ -144,10 +119,8 @@ 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). A change to the app's records or to the
// pointer since the check is an error wrapping errRetireUnsettled, and
-// nothing is deleted. guard, when not nil, runs last before the delete and
-// its release after it: the operator door asks there, under the lock a
-// claim's app row insert takes, that the app still has no row.
-func (s *Server) deleteRetiredCanary(ctx context.Context, c *canaryRetireCheck, mutate func(context.Context, func(context.Context) error) error, guard func(context.Context) (func(), error)) error {
+// 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
@@ -175,13 +148,6 @@ func (s *Server) deleteRetiredCanary(ctx context.Context, c *canaryRetireCheck,
}
return fmt.Errorf("%w: the canary's pointer changed during the check", errRetireUnsettled)
}
- if guard != nil {
- done, err := guard(ctx)
- if err != nil {
- return err
- }
- defer done()
- }
// Delete exactly the pointer read above: a promotion since then
// conflicts, and the retire is refused rather than deleting bytes
// this check never saw.
@@ -278,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.")
@@ -364,7 +330,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
@@ -378,233 +344,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})
}
-
-// orphanRefusedError is the operator door's no-row precondition failing,
-// with the status and sentence the door answers.
-type orphanRefusedError struct {
- status int
- msg string
- err error // the read that failed, when one did
-}
-
-func (e *orphanRefusedError) Error() string {
- if e.err != nil {
- return e.msg + ": " + e.err.Error()
- }
- return e.msg
-}
-
-// orphanRefusal is the operator door's precondition: acct is an account
-// this console has, and acct/app has no live or trashed console row, no
-// trash marker and no instance or sidecar record. Anything it cannot read
-// refuses. nil when the app is an orphan the door may act on.
-func (s *Server) orphanRefusal(ctx context.Context, acct, app, name string) *orphanRefusedError {
- channel := release.RungCanary + "/" + name
- a, err := s.store.AccountBySqid(acct)
- if err != nil {
- return &orphanRefusedError{http.StatusInternalServerError, fmt.Sprintf(textRetireCheck, channel), err}
- }
- if a == nil {
- // An account only the bucket holds: the console has no deletion
- // evidence for it (recentRecordDeletion), so it never says unused.
- return &orphanRefusedError{status: http.StatusConflict, msg: fmt.Sprintf(textRetireNoAccount, acct, app)}
- }
- live, err := s.store.HasAppInContext(ctx, a.ID, app)
- if err != nil {
- return &orphanRefusedError{http.StatusInternalServerError, fmt.Sprintf(textRetireCheck, channel), err}
- }
- if live {
- return &orphanRefusedError{status: http.StatusConflict, msg: fmt.Sprintf(textRetireHasApp, acct, app, acct, app, name)}
- }
- trashed, err := s.store.HasTrashedAppInContext(ctx, a.ID, app)
- if err != nil {
- return &orphanRefusedError{http.StatusInternalServerError, fmt.Sprintf(textRetireCheck, channel), err}
- }
- if trashed {
- return &orphanRefusedError{status: http.StatusConflict, msg: fmt.Sprintf(textRetireTrashed, acct, app)}
- }
- tomb, err := release.ReadAppTombstone(ctx, s.cfg.Releases, acct, app)
- if err != nil {
- return &orphanRefusedError{http.StatusBadGateway, textRetireStore, err}
- }
- if tomb != nil {
- return &orphanRefusedError{status: http.StatusConflict, msg: fmt.Sprintf(textRetireTrashed, acct, app)}
- }
- stamps, err := s.recordStamps(ctx, acct, app)
- if err != nil {
- return &orphanRefusedError{http.StatusBadGateway, textRetireStore, err}
- }
- if len(stamps) > 0 {
- return &orphanRefusedError{status: http.StatusConflict, msg: fmt.Sprintf(textRetireHasRecords, acct, app)}
- }
- return nil
-}
-
-// 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. The
-// door refuses up front where that mutation needs an app id (host claims).
-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)
- }
-}
-
-// writeRouteAbsence answers the box-report refusal, and reports whether err
-// was one.
-func writeRouteAbsence(w http.ResponseWriter, err error, acct, app string) bool {
- var e *routeAbsenceError
- if !errors.As(err, &e) {
- return false
- }
- at := e.At.UTC().Format(time.RFC3339)
- switch {
- case e.Incomplete:
- jsonError(w, http.StatusConflict, textRetireReports)
- case e.NoReports:
- jsonError(w, http.StatusConflict, textRetireNoReports)
- case e.Silent && e.Stale:
- jsonError(w, http.StatusConflict, fmt.Sprintf(textRetireSilentDark, e.Box, at))
- case e.Silent:
- jsonError(w, http.StatusConflict, fmt.Sprintf(textRetireSilent, e.Box))
- case e.Stale:
- jsonError(w, http.StatusConflict, fmt.Sprintf(textRetireRouteDark, e.Box, at, acct, app, e.Channel))
- default:
- jsonError(w, http.StatusConflict, fmt.Sprintf(textRetireRoute, e.Box, acct, app, e.Channel))
- }
- return true
-}
-
-// routeAbsenceNow reads every box report now (retireFacts) and answers
-// routeAbsence on it; a report listing that fails is a routeAbsenceError
-// too, since it cannot show absence.
-func (s *Server) routeAbsenceNow(ctx context.Context, acct, app string) error {
- f, err := s.retireFacts(ctx, acct, app)
- if err != nil {
- log.Printf("console: api system retire %s/%s: box reports: %v", acct, app, err)
- return &routeAbsenceError{Incomplete: true}
- }
- return f.routeAbsence()
-}
-
-// 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.
-//
-// The app has no records to name its followers, so beside the member
-// door's guard it asks every box report, read now (routeAbsenceNow): every
-// report read, every box's last report naming the apps it runs routes of
-// (managed or not, so a hand-made named-unit route counts; a box that has
-// stopped reporting counts by its last report until the status listing
-// drops it a day later), and no route of the app on any box. It asks
-// again, last, under the name lock. It refuses an account the console
-// does not have, an app with a live or trashed row, a trash marker, any
-// instance or sidecar record, and a console running host claims, whose
-// app mutation needs an app id an app with no row does not have. It asks
-// the no-row precondition again last, under the app lock and the lock a
-// claim's row insert takes, 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, textRetireBadTarget)
- 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
- }
- if _, gated := s.cfg.Releases.(release.AppMutationRunner); gated {
- jsonError(w, http.StatusConflict, textRetireHostClaims)
- return
- }
- acct, app, channel := req.Account, req.App, req.Channel
- name := strings.TrimPrefix(channel, release.RungCanary+"/")
- ctx := r.Context()
- if ref := s.orphanRefusal(ctx, acct, app, name); ref != nil {
- if ref.err != nil {
- log.Printf("console: api system retire %s/%s %s: %v", acct, app, channel, ref.err)
- }
- jsonError(w, ref.status, ref.msg)
- return
- }
- chk, err := s.checkCanaryRetire(ctx, acct, app, channel)
- if writeRetireRefusal(w, err, acct, app, channel) {
- return
- }
- if err := s.routeAbsenceNow(ctx, acct, app); writeRouteAbsence(w, err, acct, app) {
- log.Printf("console: api system retire %s/%s %s: %v", acct, app, channel, err)
- return
- }
- // The last no-row check and the delete hold the app's name lock, which
- // a claim's row insert takes too (createClaimAppRow), so an owner
- // adopting the name lands wholly before or after them. It is taken after
- // the app lock deleteRetiredCanary holds: the console's lock order.
- guard := func(ctx context.Context) (func(), error) {
- a, err := s.store.AccountBySqid(acct)
- if err != nil || a == nil {
- return nil, &orphanRefusedError{http.StatusInternalServerError, fmt.Sprintf(textRetireCheck, channel), err}
- }
- unlock := s.store.lockAppNames(appNameKey{a.ID, app})
- if ref := s.orphanRefusal(ctx, acct, app, name); ref != nil {
- unlock()
- return nil, ref
- }
- // The box reports again, read now: a hand route that appeared on
- // some box since the first read is in its latest report. A route
- // made after this read and before the delete is outside any lock
- // the console has; its box's next adopt pass finds no head and
- // keeps serving what it runs.
- if err := s.routeAbsenceNow(ctx, acct, app); err != nil {
- unlock()
- return nil, err
- }
- return unlock, nil
- }
- err = s.deleteRetiredCanary(ctx, chk, s.orphanRetireMutation(acct, app), guard)
- var ref *orphanRefusedError
- switch {
- case writeRouteAbsence(w, err, acct, app):
- log.Printf("console: api system retire %s/%s %s: %v", acct, app, channel, err)
- return
- case errors.As(err, &ref):
- if ref.err != nil {
- log.Printf("console: api system retire %s/%s %s: %v", acct, app, channel, ref.err)
- }
- jsonError(w, ref.status, ref.msg)
- return
- case errors.Is(err, errRetireUnsettled):
- writeRetireRefusal(w, err, acct, app, channel)
- return
- case 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(textRetireOrphanDone, channel, acct, app))
- writeJSON(w, http.StatusOK, map[string]string{"result": "retired", "channel": channel})
-}
diff --git a/internal/console/canary_retire_orphan_test.go b/internal/console/canary_retire_orphan_test.go
deleted file mode 100644
index 2e908d3ba..000000000
--- a/internal/console/canary_retire_orphan_test.go
+++ /dev/null
@@ -1,396 +0,0 @@
-package console
-
-import (
- "context"
- "encoding/json"
- "net/http"
- "os"
- "path/filepath"
- "strings"
- "testing"
- "time"
-
- "github.com/carlosframework/platform/internal/provision"
- "github.com/carlosframework/platform/internal/registry"
- "github.com/carlosframework/platform/internal/release"
- "github.com/carlosframework/platform/internal/status"
-)
-
-// The operator's channel retire (#1634): `carlos channels retire` for a
-// canary pointer of an app the console has no row for.
-
-func orphanRetireURL(tb *twoBoxes) string {
- return tb.fx.ts.URL + "/api/cli/system/channels/retire"
-}
-
-func orphanBody(tb *twoBoxes, app, channel string) string {
- b, _ := json.Marshal(map[string]string{"account": tb.sqid, "app": app, "channel": channel})
- return string(b)
-}
-
-// writeRawBox writes a box report as given, for a box this test cannot
-// build through CollectBox: a binary from before route channels, or one
-// that stopped reporting.
-func writeRawBox(t *testing.T, tb *twoBoxes, b status.Box) {
- t.Helper()
- if err := status.WriteBox(context.Background(), tb.fx.rel, b); err != nil {
- t.Fatal(err)
- }
- tb.fx.srv.boxReports.expire()
-}
-
-// The operator door deletes an orphan's canary pointer only once no box
-// report names any route of the app, and then only that pointer: a
-// named-unit hand route on box B, which has no rollout entry and so was
-// invisible to the member door's box check, holds the retire. Then the
-// pointer goes, the app's other channel and its releases stay, and 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")
-
- if err := tb.regB.Upsert(registry.Route{Host: "unit.old.example.com", Kind: "instance", App: "old", Account: tb.sqid,
- Channel: "canary/rc", Version: "v1", Unit: "old-worker", Status: "ready"}); 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, orphanBody(tb, "old", "canary/rc"))
- if status != http.StatusConflict || !strings.Contains(out, "still runs a route of "+tb.sqid+"/old (channel canary/rc)") || !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatalf("orphan retire with a named-unit route of the app on box B = %d %s", status, out)
- }
-
- if err := tb.regB.Delete("unit.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, orphanBody(tb, "old", "canary/rc"))
- 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")
- }
-}
-
-// A route of the app on ANY channel holds the retire, not only one on the
-// channel being retired: an app still running somewhere is not an orphan.
-func TestAPISystemRetireChannelRefusesARouteOnAnotherChannel(t *testing.T) {
- tb := newTwoBoxes(t)
- settledApp(t, tb)
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "canary/rc")
- if err := tb.regB.Upsert(registry.Route{Host: "backed.old.example.com", Kind: "instance", App: "old", Account: tb.sqid,
- Backing: registry.BackingUnit, Status: "ready"}); 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, orphanBody(tb, "old", "canary/rc"))
- if status != http.StatusConflict || !strings.Contains(out, "(channel stable)") || !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatalf("orphan retire with a stable route of the app = %d %s", status, out)
- }
-}
-
-// Box reports that cannot say hold the retire: a fresh box on a binary
-// from before route channels, and a box that stopped reporting whose last
-// report could not say or named the app. A stopped box whose last report
-// said and named no route of the app does not, and nor does a report the
-// status listing no longer lists (written more than a day ago).
-func TestAPISystemRetireChannelNeedsEveryBoxToSay(t *testing.T) {
- tb := newTwoBoxes(t)
- settledApp(t, tb)
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "canary/rc")
- post := func() (int, string) {
- status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token, orphanBody(tb, "old", "canary/rc"))
- return status, out
- }
-
- old := status.Box{GeneratedAt: time.Now().UTC(), Label: status.Label("box-old"), Metrics: &status.BoxMetrics{Release: "v0.44.2"}}
- writeRawBox(t, tb, old)
- if st, out := post(); st != http.StatusConflict || !strings.Contains(out, "box "+old.Label+" runs a CARLOS version too old to report") {
- t.Fatalf("orphan retire with a box on an older binary = %d %s", st, out)
- }
-
- old.GeneratedAt = time.Now().Add(-2 * time.Hour).UTC()
- writeRawBox(t, tb, old)
- if st, out := post(); st != http.StatusConflict || !strings.Contains(out, "box "+old.Label+" stopped reporting at") || !strings.Contains(out, "too old to report") {
- t.Fatalf("orphan retire with a stopped box whose last report cannot say = %d %s", st, out)
- }
-
- old.Metrics = &status.BoxMetrics{RouteChannelsReported: true,
- RouteChannels: []status.RouteChannel{{Account: tb.sqid, App: "old", Channel: "canary/rc"}}}
- writeRawBox(t, tb, old)
- if st, out := post(); st != http.StatusConflict || !strings.Contains(out, "after running a route of "+tb.sqid+"/old (channel canary/rc)") {
- t.Fatalf("orphan retire with a stopped box that last ran the app = %d %s", st, out)
- }
- if !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatal("a refused retire deleted the pointer")
- }
-
- // The same report, last written more than a day ago: the status
- // listing no longer lists it, as no fleet view does.
- ageReport(t, tb, old.Label, 25*time.Hour)
- if st, out := post(); st != http.StatusOK {
- t.Fatalf("orphan retire with that box's report past the listing horizon = %d %s", st, out)
- }
-}
-
-// ageReport backdates box's report object, as if it was last written ago.
-func ageReport(t *testing.T, tb *twoBoxes, box string, ago time.Duration) {
- t.Helper()
- at := time.Now().Add(-ago)
- path := filepath.Join(tb.fx.rel.(*deletableStore).root, "status", "boxes", box+".json")
- if err := os.Chtimes(path, at, at); err != nil {
- t.Fatal(err)
- }
- tb.fx.srv.boxReports.expire()
-}
-
-// A stopped box whose last report said, and named no route of the app,
-// does not hold the retire.
-func TestAPISystemRetireChannelPassesAStoppedBoxThatNamedNothing(t *testing.T) {
- tb := newTwoBoxes(t)
- settledApp(t, tb)
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "canary/rc")
- writeRawBox(t, tb, status.Box{GeneratedAt: time.Now().Add(-2 * time.Hour).UTC(), Label: status.Label("box-gone"),
- Metrics: &status.BoxMetrics{RouteChannelsReported: true,
- RouteChannels: []status.RouteChannel{{Account: tb.sqid, App: "shop", Channel: "stable"}}}})
- if status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token, orphanBody(tb, "old", "canary/rc")); status != http.StatusOK {
- t.Fatalf("orphan retire = %d %s", status, out)
- }
-}
-
-// With no box report at all, nothing shows absence: refused.
-func TestAPISystemRetireChannelRefusesWithNoReports(t *testing.T) {
- tb := newTwoBoxes(t)
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "canary/rc")
- status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token, orphanBody(tb, "old", "canary/rc"))
- if status != http.StatusConflict || !strings.Contains(out, "no box report was found") || !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatalf("orphan retire with no box reports = %d %s", status, out)
- }
-}
-
-// The door reads box reports past the pages' cache: a route reported a
-// moment ago holds the retire even while the cache still holds the
-// earlier, empty word.
-func TestAPISystemRetireChannelReadsReportsNow(t *testing.T) {
- tb := newTwoBoxes(t)
- settledApp(t, tb)
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "canary/rc")
- if err := tb.fx.srv.remoteFacts(context.Background(), tb.sqid, "old").routeAbsence(); err != nil {
- t.Fatalf("fixture: the warmed cache already names the app: %v", err)
- }
- if err := tb.regB.Upsert(registry.Route{Host: "unit.old.example.com", Kind: "instance", App: "old", Account: tb.sqid,
- Channel: "canary/rc", Unit: "old-worker", Status: "ready"}); err != nil {
- t.Fatal(err)
- }
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096) // no boxReports.expire()
- status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token, orphanBody(tb, "old", "canary/rc"))
- if status != http.StatusConflict || !strings.Contains(out, "still runs a route of") || !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatalf("orphan retire against a cached empty report = %d %s", status, out)
- }
-}
-
-// A route reported while the retire runs, after its first read of the
-// box reports, is seen by the read it makes again last, under the lock.
-func TestAPISystemRetireChannelReadsReportsAgainLast(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.regB.Upsert(registry.Route{Host: "unit.old.example.com", Kind: "instance", App: "old", Account: tb.sqid,
- Channel: "canary/rc", Unit: "old-worker", Status: "ready"}); err != nil {
- t.Error(err)
- }
- report(t, tb.fx.rel, tb.regB, "box-b", "uk", time.Now(), nil, 4096)
- }
- status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token, orphanBody(tb, "old", "canary/rc"))
- if status != http.StatusConflict || !strings.Contains(out, "still runs a route of") || !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatalf("orphan retire with a route reported mid-retire = %d %s", status, out)
- }
-}
-
-// insertDuringDelete runs during inside the conditional delete of key:
-// the moment the retire's last checks have passed and its locks are held.
-type insertDuringDelete struct {
- *deletableStore
- key string
- during func()
-}
-
-func (s *insertDuringDelete) DeleteIfMatch(ctx context.Context, key, etag string) error {
- if key == s.key {
- s.during()
- }
- return s.deletableStore.DeleteIfMatch(ctx, key, etag)
-}
-
-// The retire holds the app's name lock through its delete: a claim's row
-// insert started at the moment of the delete waits until the retire is
-// done, so an adoption cannot land between the last check and the delete.
-func TestAPISystemRetireChannelHoldsTheNameLockThroughTheDelete(t *testing.T) {
- tb := newTwoBoxes(t)
- settledApp(t, tb)
- shipAndPromote(t, tb.fx, tb.sqid, "old", "v1", "canary/rc")
- acct, err := tb.fx.st.AccountBySqid(tb.sqid)
- if err != nil || acct == nil {
- t.Fatalf("account: %v", err)
- }
- inserted := make(chan error, 1)
- ds := tb.fx.rel.(*deletableStore)
- tb.fx.srv.cfg.Releases = &insertDuringDelete{deletableStore: ds, key: release.ChannelKey(tb.sqid, "old", "canary/rc"), during: func() {
- go func() {
- _, err := tb.fx.srv.insertClaimAppRow(context.Background(), acct, "old", func(st *Store) (bool, error) {
- return st.CreateAppIn(acct.ID, "old", "paul@keymail.dev", time.Now())
- }, nil)
- inserted <- err
- }()
- select {
- case err := <-inserted:
- t.Errorf("an app row insert landed while the retire held the name lock: %v", err)
- case <-time.After(200 * time.Millisecond):
- }
- }}
- if status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), tb.token, orphanBody(tb, "old", "canary/rc")); status != http.StatusOK {
- t.Fatalf("orphan retire = %d %s", status, out)
- }
- if err := <-inserted; err != nil {
- t.Fatal(err)
- }
-}
-
-// 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), a
-// console row in the trash with no bucket marker, a bucket trash marker,
-// an app with instance records, an account the console does not have, 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", "rowbinned", "binned", "recorded"} {
- shipAndPromote(t, tb.fx, tb.sqid, app, "v1", "canary/rc")
- }
- if _, err := tb.fx.st.CreateAppIn(5151, "rowbinned", "paul@keymail.dev", time.Now()); err != nil {
- t.Fatal(err)
- }
- if err := tb.fx.st.TrashAppRow(5151, "rowbinned", time.Now()); err != nil {
- t.Fatal(err)
- }
- 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)
- }
- const stranger = "zqx"
- shipAndPromote(t, tb.fx, stranger, "old", "v1", "canary/rc")
- post := func(token, acct, app, channel string) (int, string) {
- body, _ := json.Marshal(map[string]string{"account": acct, "app": app, "channel": channel})
- status, _, out := rawReq(t, http.MethodPost, orphanRetireURL(tb), token, string(body))
- return status, out
- }
- cases := []struct {
- acct, app, channel string
- status int
- says string
- }{
- {tb.sqid, "old", "stable", http.StatusBadRequest, "is not a canary channel"},
- {tb.sqid, "shop", "canary/rc", http.StatusConflict, "use carlos canary retire --account " + tb.sqid + " --app shop --name rc"},
- {tb.sqid, "rowbinned", "canary/rc", http.StatusConflict, "is in the trash"},
- {tb.sqid, "binned", "canary/rc", http.StatusConflict, "is in the trash"},
- {tb.sqid, "recorded", "canary/rc", http.StatusConflict, "still has instance records"},
- {stranger, "old", "canary/rc", http.StatusConflict, "account zqx is not on this console"},
- }
- for _, c := range cases {
- status, out := post(tb.token, c.acct, c.app, c.channel)
- if status != c.status || !strings.Contains(out, c.says) {
- t.Fatalf("orphan retire of %s/%s %s = %d %s, want %d saying %q", c.acct, c.app, c.channel, status, out, c.status, c.says)
- }
- }
- for _, app := range []string{"shop", "rowbinned", "binned", "recorded"} {
- if !pointerExists(t, tb, app, "canary/rc") {
- t.Fatalf("a refused retire deleted %s's canary/rc", app)
- }
- }
- if _, _, err := tb.fx.rel.Get(ctx, release.ChannelKey(stranger, "old", "canary/rc")); err != nil {
- t.Fatalf("a refused retire deleted the bucket-only account's pointer: %v", err)
- }
- member := cliToken(t, tb.fx, "alice@keymail.dev", "code-orphan-member")
- if status, out := post(member, tb.sqid, "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 after the first no-row check (an
-// owner adopting the name) is seen by the last one, under the lock, and
-// the refusal names the real cause.
-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, orphanBody(tb, "old", "canary/rc"))
- if status != http.StatusConflict || !strings.Contains(out, "is an app on this console") || !pointerExists(t, tb, "old", "canary/rc") {
- t.Fatalf("orphan retire with an app created during the check = %d %s", status, out)
- }
-}
-
-// The claim's row insert waits for the app's name lock, which the retire
-// holds through its delete, so an adoption cannot land between the last
-// check and the delete.
-func TestClaimRowInsertWaitsForTheOrphanRetire(t *testing.T) {
- tb := newTwoBoxes(t)
- acct, err := tb.fx.st.AccountBySqid(tb.sqid)
- if err != nil || acct == nil {
- t.Fatalf("account: %v", err)
- }
- unlock := tb.fx.st.lockAppNames(appNameKey{acct.ID, "old"})
- inserted := make(chan error, 1)
- go func() {
- _, err := tb.fx.srv.insertClaimAppRow(context.Background(), acct, "old", func(st *Store) (bool, error) {
- return st.CreateAppIn(acct.ID, "old", "paul@keymail.dev", time.Now())
- }, nil)
- inserted <- err
- }()
- select {
- case err := <-inserted:
- t.Fatalf("the insert did not wait for the retire's lock: %v", err)
- case <-time.After(200 * time.Millisecond):
- }
- if live, _ := tb.fx.st.HasAppIn(acct.ID, "old"); live {
- t.Fatal("a row was inserted while the retire held the lock")
- }
- unlock()
- if err := <-inserted; err != nil {
- t.Fatal(err)
- }
- if live, _ := tb.fx.st.HasAppIn(acct.ID, "old"); !live {
- t.Fatal("no row after the lock was released")
- }
-}
diff --git a/internal/console/claim_app_enroll.go b/internal/console/claim_app_enroll.go
index ca80432cb..e365ab6c1 100644
--- a/internal/console/claim_app_enroll.go
+++ b/internal/console/claim_app_enroll.go
@@ -79,16 +79,6 @@ func (s *Server) insertClaimAppRow(ctx context.Context, acct *Account, app strin
return false, err
}
}
- // The operator's channel retire of an app with no row holds the
- // name lock from its last no-row check through its delete (#1634),
- // so an owner adopting the name lands wholly before or after it.
- // With clear set, createClaimAppRow already holds that same mutex
- // (policyLock is the name lock) through the insert; without it,
- // this takes it. Under host claims that door refuses, so only this
- // branch takes it. No insert passed here takes it itself.
- if clear == nil {
- defer s.store.lockAppNames(appNameKey{acct.ID, app})()
- }
return insert(s.store)
}
w, err := s.claimControl()
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go
index 3678d580f..5f8717bd2 100644
--- a/internal/console/claim_invariant_fixtures_test.go
+++ b/internal/console/claim_invariant_fixtures_test.go
@@ -1041,15 +1041,6 @@ var claimFixtures = map[string]claimFixture{
status: http.StatusConflict,
msg: copyLinkedHostClaim,
}},
- // The operator's channel retire of an app with no row (#1634): its
- // bucket mutation needs an app id such an app does not have under host
- // claims, so it refuses before any store read.
- "route POST /api/cli/system/channels/retire": {refused: &claimRefusalFixture{
- apps: claimRefs("bab/titogo"),
- do: claimRefusedAPI(http.MethodPost, "/api/cli/system/channels/retire", `{"account":"bab","app":"orphan","channel":"canary/old"}`),
- status: http.StatusConflict,
- msg: textRetireHostClaims,
- }},
"route POST /api/cli/system/shares/stop": {refused: &claimRefusalFixture{
apps: claimRefs("bab/titogo"),
do: claimRefusedAPI(http.MethodPost, "/api/cli/system/shares/stop", `{"host":"titogo.bab.apps.example.com"}`),
diff --git a/internal/console/claim_invariant_test.go b/internal/console/claim_invariant_test.go
index fc8e85f1c..ff810e20b 100644
--- a/internal/console/claim_invariant_test.go
+++ b/internal/console/claim_invariant_test.go
@@ -137,8 +137,6 @@ var claimUnsupported = map[string]string{
"which no claim operation covers; all four doors refuse after apiAccountApp and before they read the store record",
claimRenameUnsupportedMsg: "rename rewrites the app's identity (SQL rows, prefixes, admission key); " +
"no operation gates the old and new names together, so every rename is refused",
- textRetireHostClaims: "the operator's channel retire acts on an app with no row, whose app mutation needs an app id only a row " +
- "or an admission gives (#1634); it refuses after its operator gate and before it reads anything",
claimTransferUnsupportedMsg: "account transfer rewrites the app's identity under another account; " +
"no operation gates both, so every transfer is refused",
claimMoveResolveUnavailableMsg: "the operator's door out of a stuck move (CARLOS_MOVES_PHASE1) has only its gate until " +
diff --git a/internal/console/digests_noapp_test.go b/internal/console/digests_noapp_test.go
new file mode 100644
index 000000000..b923d6f73
--- /dev/null
+++ b/internal/console/digests_noapp_test.go
@@ -0,0 +1,111 @@
+package console
+
+import (
+ "context"
+ "crypto/ed25519"
+ "encoding/base64"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// The box-report evidence about apps with no console row (#1634): the fold
+// keeps every listed box's last word, fresh or stopped, and running picks
+// the reports that name the app and the ones that cannot say.
+func TestAppFactsRunningKeepsEveryBoxsLastWord(t *testing.T) {
+ now := time.Date(2026, 12, 2, 12, 0, 0, 0, time.UTC)
+ said := func(rcs ...status.RouteChannel) *status.BoxMetrics {
+ return &status.BoxMetrics{RouteChannelsReported: true, RouteChannels: rcs}
+ }
+ boxes := []status.Box{
+ {Label: "fresh-runs", GeneratedAt: now.Add(-time.Minute), Metrics: said(status.RouteChannel{Account: "bab", App: "old", Channel: "canary/rc"})},
+ {Label: "stopped-runs", GeneratedAt: now.Add(-3 * time.Hour), Metrics: said(status.RouteChannel{Account: "bab", App: "old", Channel: "stable"})},
+ {Label: "fresh-other", GeneratedAt: now.Add(-time.Minute), Metrics: said(status.RouteChannel{Account: "bab", App: "shop", Channel: "canary/rc"})},
+ {Label: "other-account", GeneratedAt: now.Add(-time.Minute), Metrics: said(status.RouteChannel{Account: "bdq", App: "old", Channel: "canary/rc"})},
+ {Label: "old-binary", GeneratedAt: now.Add(-time.Minute), Metrics: &status.BoxMetrics{Release: "v0.44.2"}},
+ {Label: "no-metrics", GeneratedAt: now.Add(-2 * time.Hour)},
+ }
+ f := appFacts{acct: "bab", app: "old", reports: foldFleetReports(boxes, true, now)}
+ r := f.running()
+ if !r.complete || r.boxes != len(boxes) {
+ t.Fatalf("complete %v, boxes %d", r.complete, r.boxes)
+ }
+ var running, silent []string
+ for _, br := range r.running {
+ running = append(running, fmt.Sprintf("%s %s stale=%v", br.box, br.rc.Channel, br.stale))
+ }
+ for _, b := range r.silent {
+ silent = append(silent, fmt.Sprintf("%s stale=%v", b.box, b.stale))
+ }
+ if got, want := fmt.Sprint(running), "[fresh-runs canary/rc stale=false stopped-runs stable stale=true]"; got != want {
+ t.Fatalf("running = %s, want %s", got, want)
+ }
+ if got, want := fmt.Sprint(silent), "[no-metrics stale=true old-binary stale=false]"; got != want {
+ t.Fatalf("silent = %s, want %s", got, want)
+ }
+}
+
+// The digests report carries the evidence for an app the repair listing
+// marks "no app on this console", and none for an app the console has.
+func TestSystemDigestsDoorCarriesNoAppEvidence(t *testing.T) {
+ fx := newDigestsFixture(t)
+ ctx := context.Background()
+ unbound := func(app, channel string) {
+ t.Helper()
+ legacy := release.ChannelPointer{Schema: 1, App: app, Channel: channel, Version: "v1", PromotedAt: time.Date(2026, 6, 1, 0, 0, 0, 0, time.UTC)}
+ payload, _ := json.MarshalIndent(legacy, "", " ")
+ b64 := base64.StdEncoding.EncodeToString(payload)
+ wire, _ := json.Marshal(map[string]string{"payload": b64, "sig": base64.StdEncoding.EncodeToString(ed25519.Sign(fx.priv, []byte(b64)))})
+ key := release.ChannelKey(release.OpsAccount, app, channel)
+ _, etag, _ := fx.store.Get(ctx, key)
+ if _, err := fx.store.Put(ctx, key, wire, etag); err != nil {
+ t.Fatal(err)
+ }
+ }
+ unbound("km", "canary/x")
+ unbound("direct", "canary/y")
+ now := time.Now().UTC()
+ for _, b := range []status.Box{
+ {Label: "runs-it", GeneratedAt: now, Metrics: &status.BoxMetrics{RouteChannelsReported: true,
+ RouteChannels: []status.RouteChannel{{Account: release.OpsAccount, App: "direct", Channel: "canary/y"}}}},
+ {Label: "cannot-say", GeneratedAt: now, Metrics: &status.BoxMetrics{Release: "v0.44.2"}},
+ } {
+ if err := status.WriteBox(ctx, fx.store, b); err != nil {
+ t.Fatal(err)
+ }
+ }
+ st, out := getRaw(t, fx.ts.URL+"/api/cli/system/pointer-digests", fx.operator)
+ if st != http.StatusOK {
+ t.Fatalf("report: %d %s", st, out)
+ }
+ var rep struct {
+ NoApp []struct {
+ Account, App string
+ Complete bool
+ Boxes int
+ Running []struct{ Box, Channel, At string }
+ Silent []struct{ Box, At string }
+ } `json:"no_app"`
+ }
+ if err := json.Unmarshal([]byte(out), &rep); err != nil {
+ t.Fatalf("report body %s: %v", out, err)
+ }
+ if len(rep.NoApp) != 1 {
+ t.Fatalf("no_app = %+v, want one entry, for direct only\n%s", rep.NoApp, out)
+ }
+ e := rep.NoApp[0]
+ if e.Account != release.OpsAccount || e.App != "direct" || !e.Complete || e.Boxes != 2 {
+ t.Fatalf("no_app entry = %+v", e)
+ }
+ if len(e.Running) != 1 || e.Running[0].Box != "runs-it" || e.Running[0].Channel != "canary/y" || e.Running[0].At == "" {
+ t.Fatalf("running = %+v", e.Running)
+ }
+ if len(e.Silent) != 1 || e.Silent[0].Box != "cannot-say" {
+ t.Fatalf("silent = %+v", e.Silent)
+ }
+}
diff --git a/internal/console/remoteinstances.go b/internal/console/remoteinstances.go
index 882de316d..7edddb171 100644
--- a/internal/console/remoteinstances.go
+++ b/internal/console/remoteinstances.go
@@ -261,7 +261,7 @@ type fleetReports struct {
// not (status BoxMetrics.RouteChannels, #1634); silent is each listed
// box whose last report cannot say (no Metrics, or a binary from before
// RouteChannelsReported). A stale box counts by its last report too: it
- // may come back still running what it ran. Only routeAbsence reads them.
+ // may come back still running what it ran. Only running reads them.
boxes int
routes []boxRoute
silent []boxSeen
@@ -364,17 +364,6 @@ func (s *Server) remoteFacts(ctx context.Context, acct, app string) appFacts {
return appFacts{acct: acct, app: app, reports: foldFleetReports(boxes, complete, time.Now())}
}
-// retireFacts is remoteFacts read now, past the pages' minute-long cache:
-// the operator's channel retire (#1634) decides a delete on it, so a report
-// written a moment ago must count. A listing that fails is an error.
-func (s *Server) retireFacts(ctx context.Context, acct, app string) (appFacts, error) {
- boxes, complete, err := loadBoxesConcurrently(ctx, s.cfg.Releases)
- if err != nil {
- return appFacts{}, err
- }
- return appFacts{acct: acct, app: app, reports: foldFleetReports(boxes, complete, time.Now())}, nil
-}
-
// host is the one box report about rec's host that may be joined to it, or
// nil. Identity is the record plus a report entry naming the same account
// and app, generated after the record was created: a report naming another
@@ -404,65 +393,34 @@ func (f appFacts) host(rec provision.Record) *hostReport {
// complete is whether every box's report was read.
func (f appFacts) complete() bool { return f.reports.complete }
-// routeAbsenceError is routeAbsence's answer when the box reports cannot
-// show that no box runs a route of the app. Incomplete and NoReports stand
-// alone; otherwise Box's last report, written At (Stale when the box has
-// stopped reporting), either cannot say which apps it runs (Silent) or
-// names a route of the app on Channel.
-type routeAbsenceError struct {
- Incomplete bool // not every box report could be read
- NoReports bool // no box has reported at all
- Silent bool
- Channel string
- Box string
- At time.Time
- Stale bool
-}
-
-func (e *routeAbsenceError) Error() string {
- switch {
- case e.Incomplete:
- return "not every box report could be read"
- case e.NoReports:
- return "no box report was found"
- case e.Silent:
- return "box " + e.Box + " does not report its routes' apps"
- }
- return "box " + e.Box + " runs a route of the app on " + e.Channel
-}
-
-// routeAbsence reports whether the box reports show that no box runs any
-// route of acct/app, on any channel, managed or not (#1634): nil only when
-// every report listed was read, there is at least one, every box's last
-// report says which apps it runs, and none names the app. A box that has
-// stopped reporting counts by its last report, since it may come back
-// running what it ran. Which reports are listed is the status listing's
-// rule (status.LoadBoxesComplete): a box silent for longer than its
-// one-day horizon is taken as gone, as every fleet view takes it.
-// Anything else is a *routeAbsenceError; boxes are taken in label order,
-// so the answer is stable.
-func (f appFacts) routeAbsence() error {
+// appRunning is what the box reports say about acct/app's routes (#1634):
+// how many reports were read and whether all were, each report naming a
+// route of the app, and each report that cannot say which apps its box
+// runs. A box that has stopped reporting counts by its last report, until
+// the status listing drops it a day after (status.LoadBoxesComplete).
+// Read-only evidence: it shows what the boxes said, never that nothing
+// runs the app now, since a report is a snapshot.
+type appRunning struct {
+ complete bool
+ boxes int
+ running []boxRoute
+ silent []boxSeen
+}
+
+// running is appRunning for f's app, boxes in label order.
+func (f appFacts) running() appRunning {
r := f.reports
- if !r.complete {
- return &routeAbsenceError{Incomplete: true}
- }
- if r.boxes == 0 {
- return &routeAbsenceError{NoReports: true}
- }
- silent := slices.SortedFunc(slices.Values(r.silent), func(a, b boxSeen) int { return cmp.Compare(a.box, b.box) })
- if len(silent) > 0 {
- s := silent[0]
- return &routeAbsenceError{Silent: true, Box: s.box, At: s.at, Stale: s.stale}
- }
- routes := slices.SortedFunc(slices.Values(r.routes), func(a, b boxRoute) int {
- return cmp.Or(cmp.Compare(a.box, b.box), cmp.Compare(a.rc.Channel, b.rc.Channel))
- })
- for _, br := range routes {
+ out := appRunning{complete: r.complete, boxes: r.boxes}
+ for _, br := range r.routes {
if br.rc.Account == f.acct && br.rc.App == f.app {
- return &routeAbsenceError{Channel: br.rc.Channel, Box: br.box, At: br.at, Stale: br.stale}
+ out.running = append(out.running, br)
}
}
- return nil
+ slices.SortFunc(out.running, func(a, b boxRoute) int {
+ return cmp.Or(cmp.Compare(a.box, b.box), cmp.Compare(a.rc.Channel, b.rc.Channel))
+ })
+ out.silent = slices.SortedFunc(slices.Values(r.silent), func(a, b boxSeen) int { return cmp.Compare(a.box, b.box) })
+ return out
}
// seen reports whether any fresh box report names host at all, whoever it
diff --git a/internal/console/remoteinstances_round5_test.go b/internal/console/remoteinstances_round5_test.go
index 13132542f..974f061ce 100644
--- a/internal/console/remoteinstances_round5_test.go
+++ b/internal/console/remoteinstances_round5_test.go
@@ -27,9 +27,7 @@ import (
// joins reports for a remote host itself fails here.
func TestRemoteFactsOneAccessor(t *testing.T) {
allowed := map[string]map[string]bool{
- // retireFacts is remoteFacts read past the cache, for the operator's
- // channel retire (#1634), which decides a delete on it.
- "foldFleetReports": {"remoteFacts": true, "retireFacts": true},
+ "foldFleetReports": {"remoteFacts": true},
"pageBoxReports": {"remoteFacts": true, "handleApp": true},
"byHost": {"foldFleetReports": true, "host": true, "seen": true, "unrecorded": 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/svcroutes_test.go b/internal/console/svcroutes_test.go
index 23f44da5d..dbfdadb24 100644
--- a/internal/console/svcroutes_test.go
+++ b/internal/console/svcroutes_test.go
@@ -401,9 +401,6 @@ var closedDoors = []string{
// root-signed, the same cut as the update doors.
"GET /api/cli/system/pointer-digests",
"POST /api/cli/system/pointer-digests",
- // The channel retire of an app with no row (#1634): an operator's
- // deployment-wide act, the same cut as pointer digests.
- "POST /api/cli/system/channels/retire",
// The hostname history's status (nearest-region never-reuse): an
// operator's deployment-wide view, the same cut.
"GET /api/cli/system/hosts-used/status",
@@ -1949,8 +1946,8 @@ func walkClosedDoors(t *testing.T, fx *consoleFixture, tok string) {
}
seen++
}
- if seen != len(closedDoors) || seen != 125 {
- t.Errorf("walked %d closed doors, want all %d (and 125 today: three domain purchase doors, two domain transfer doors, the account's domains list, four saved-contact doors, the domain point door, the transfer resolve door, two managed admission doors, the fleet show door, two managed configuration doors, three environment ownership doors, instance-token, three door-key doors, the routes door, the regional placements write, instances-manifest, the app update policy, sidecars-manifest, the route-channel move, three instance update settings doors, two db replica doors, the forwarded db read, seven fleets, the instance label door, the fleet secrets key door, the two person link doors (list and unlink), the share mint, the operator's share stop, the six home link doors, four services, two email credentials, email pause, the build probe, the swap policy, the copy count, the interactive setting, the interactive session door, two app policy doors, two app region doors, the live tenancy read, the layout read, the activation-cancel door, eleven system doors, three deployment-wide antivirus, the PDF status door, the media status door, three platform geoip doors, two pointer digest doors, the operator channel retire (#1634), the hostname history status, the channel resign, the canary retire (#1634), two release authorize doors, four store-entitlement doors, the store versioning setter, two account plan doors, three platform grant doors, two billing problem doors, the billing revenue and payments doors, the billing house door, three account subdomain doors, the subdomain inventory, the two certificate import doors (#1429), the two platform update hold doors (#1442), and the claimed source door)",
+ if seen != len(closedDoors) || seen != 124 {
+ t.Errorf("walked %d closed doors, want all %d (and 124 today: three domain purchase doors, two domain transfer doors, the account's domains list, four saved-contact doors, the domain point door, the transfer resolve door, two managed admission doors, the fleet show door, two managed configuration doors, three environment ownership doors, instance-token, three door-key doors, the routes door, the regional placements write, instances-manifest, the app update policy, sidecars-manifest, the route-channel move, three instance update settings doors, two db replica doors, the forwarded db read, seven fleets, the instance label door, the fleet secrets key door, the two person link doors (list and unlink), the share mint, the operator's share stop, the six home link doors, four services, two email credentials, email pause, the build probe, the swap policy, the copy count, the interactive setting, the interactive session door, two app policy doors, two app region doors, the live tenancy read, the layout read, the activation-cancel door, eleven system doors, three deployment-wide antivirus, the PDF status door, the media status door, three platform geoip doors, two pointer digest doors, the hostname history status, the channel resign, the canary retire (#1634), two release authorize doors, four store-entitlement doors, the store versioning setter, two account plan doors, three platform grant doors, two billing problem doors, the billing revenue and payments doors, the billing house door, three account subdomain doors, the subdomain inventory, the two certificate import doors (#1429), the two platform update hold doors (#1442), and the claimed source door)",
seen, len(closedDoors))
}
}
diff --git a/internal/console/testdata/claim-authority-sites.txt b/internal/console/testdata/claim-authority-sites.txt
index 0bfeedbc9..a20f26bb5 100644
--- a/internal/console/testdata/claim-authority-sites.txt
+++ b/internal/console/testdata/claim-authority-sites.txt
@@ -164,4 +164,3 @@ hacapacity_observe.go|dirPage|os.Open(filepath.Join(s.directory, filepath.FromSl
demo_claim_seed.go|publishDemoClaimSeed|os.Open(path)
managedseed.go|openManagedSeed|o.Open(ctx, key)
oplegal.go|legalFoldLogo|files[0].Open()
-canary_retire.go|orphanRetireMutation|release.WithAppMutation(ctx, s.cfg.Releases, acct, app, "canary-retire-orphan", fn)
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt
index 5540ce5b3..8b36b19e3 100644
--- a/internal/console/testdata/claim-routes.txt
+++ b/internal/console/testdata/claim-routes.txt
@@ -403,7 +403,6 @@ route POST /api/cli/system/hold/release
route POST /api/cli/system/layout
route POST /api/cli/system/legacy-routes
route POST /api/cli/system/lifetimes/cutover
-route POST /api/cli/system/channels/retire
route POST /api/cli/system/pointer-digests
route POST /api/cli/system/rollback
route POST /api/cli/system/seeds-floor
diff --git a/internal/provision/canary_retire_orphan_1634_census_test.go b/internal/provision/canary_retire_orphan_1634_census_test.go
deleted file mode 100644
index 06e4ca324..000000000
--- a/internal/provision/canary_retire_orphan_1634_census_test.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package provision
-
-// canaryRetireOrphan1634WriteCensusInventory is the operator channel
-// retire's review of the record-write census (#1634, branch 1). The route
-// table gains POST /api/cli/system/channels/retire, a route pattern, never
-// a record key. The door deletes one canary pointer, conditional on the
-// etag its check read, and writes no record; the box report's new route
-// channels name no record key. Kinds and class unchanged, only the digest
-// moves.
-func canaryRetireOrphan1634WriteCensusInventory() []censusEntry {
- entries := append([]censusEntry(nil), privateStoreScan1653WriteCensusInventory()...)
- reviewed := []censusEntry{
- {"internal/console/routedecls.go", "var routeDecls", "key-site", "lit:instances,lit:sidecars", "1e780cfb91e3284ba4e97af4fae1823cce31519ac4753a9b621c2d0bc6cce172"},
- }
- for _, r := range reviewed {
- replaced := false
- for i, e := range entries {
- if e.File == r.File && e.Unit == r.Unit {
- entries[i], replaced = r, true
- break
- }
- }
- if !replaced {
- entries = append(entries, r)
- }
- }
- return entries
-}
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index d9694934a..2c2b4e86e 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) {
if len(got) < 100 {
t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root)
}
- inventory := canaryRetireOrphan1634WriteCensusInventory()
+ inventory := privateStoreScan1653WriteCensusInventory()
problems := append(censusDiff(inventory, got), censusPolicy(inventory)...)
if len(problems) > 0 {
t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n "))
diff --git a/parity/cli.tsv b/parity/cli.tsv
index 54a98e9e2..54e7092dd 100644
--- a/parity/cli.tsv
+++ b/parity/cli.tsv
@@ -52,7 +52,6 @@ canary rm customer - - - - -
channels customer - - - - -
channels digests operator - - - - -
channels resign customer - - - - -
-channels retire operator - - - - -
config destinations add customer - - - - -
config destinations default customer - - - - -
config destinations list customer - - - - -
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.
diff --git a/testdata/clireg-golden.jsonl b/testdata/clireg-golden.jsonl
index a30c92321..8a42b65cc 100644
--- a/testdata/clireg-golden.jsonl
+++ b/testdata/clireg-golden.jsonl
@@ -156,8 +156,6 @@
{"case":"channels digests | -h","argv":["channels","digests","-h"],"exit":0,"stdout":"","stderr":"usage: carlos channels digests [flags]\nflags:\n --account-id <value> an account sqid; repeat for several (direct-store: required for on and off; without it, checks every account in the bucket)\n --console <string> console origin (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"}
{"case":"channels resign | --zz-unknown-flag","argv":["channels","resign","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos channels resign [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --console <string> console origin to resign through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --yes sign without asking\n"}
{"case":"channels resign | -h","argv":["channels","resign","-h"],"exit":0,"stdout":"","stderr":"usage: carlos channels resign [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --console <string> console origin to resign through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --yes sign without asking\n"}
-{"case":"channels retire | --zz-unknown-flag","argv":["channels","retire","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos channels retire [flags]\nflags:\n --account-id <string> the account's sqid, as the repair listing prints it\n --app <string> the app, as the repair listing prints it\n --console <string> console origin (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"}
-{"case":"channels retire | -h","argv":["channels","retire","-h"],"exit":0,"stdout":"","stderr":"usage: carlos channels retire [flags]\nflags:\n --account-id <string> the account's sqid, as the repair listing prints it\n --app <string> the app, as the repair listing prints it\n --console <string> console origin (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"}
{"case":"channels | --help","argv":["channels","--help"],"exit":0,"stdout":"","stderr":"usage: carlos channels [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --console <string> console origin to read through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n"}
{"case":"channels | --zz-unknown-flag","argv":["channels","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos channels [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --console <string> console origin to read through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n"}
{"case":"channels | -h","argv":["channels","-h"],"exit":0,"stdout":"","stderr":"usage: carlos channels [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --console <string> console origin to read through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n"}