console: refuse stateless on an unlabelled multi-box fleet record
#1008: an instance record placed on a fleet but tied to no box (no fleet_box, no replica assignment) is served by every box of the fleet, and the coordinator door refuses it on a fleet with more than one active box, so a stateless build of it can never wake. On Tito staging that took tito-id down for 16 minutes once a box restart stopped the stateful copy that had kept serving. Refused up front, with the same rule as the door: - a --stateless ship, before the upload (apicli ship meta); - any publication of a stateless build (copiesPublicationRefusal, now before the explicit-copies early return, so apps that never set a count are judged too): promote, rollback, channel, pin; - copies above 1 (copiesRefusal's count path). A fleet whose boxes or an inventory that can't be read answers 503. This changes one earlier rule on purpose: a stateless publication now reads the instance inventory, and an unreadable inventory refuses it with a retry instead of publishing unchecked (TestCopiesPublicationEvidence updated). Witness TestStatelessRefusedOnUnlabelledMultiBoxRecord: ship, promote and copies refused on a two-box fleet; one-box and labelled controls admitted. The refusal text is SR-5-C01, a draft awaiting Paul's copy review before release.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md+1 −0internal/console/apicli.go+8 −0internal/console/appcopies.go+75 −8internal/console/copiespublication.go+11 −4internal/console/copiespublication_test.go+9 −3internal/console/copiesunlabelled_test.go+80 −0
CI failed — run details
Intent
<cross-session-message from="uds:/run/user/1001/cc-socks/1637415.sock" from-name="platform-23" from-mode="bypass"> Coordination check from platform-23: are you working on Tito staging (console.staging.platform.tito.io) today, especially the titogo box dorothy-sailing? Paul approved a nesting rehearsal there (program plan W1a on branch plan-tito-nesting-moves, decisions on carlos/platform #1005): `carlos system layout migrate --box dorothy-sailing`, an hour's grace, then checks and a rehearsed revert. It does not touch the classic fleet boxes box-1/box-2 (#1008). If you're mid-change on dorothy-sailing or rolling staging, tell me and I'll wait; otherwise I'll start in about 30 minutes. </cross-session-message>
<task-notification> <task-id>b0vi0teoh</task-id> <tool-use-id>toolu_01WpLkHTGvwjtkutQoiRgbra</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/b0vi0teoh.output</output-file> <status>completed</status> <summary>Background command "List the failing console tests" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 220 g CO₂e (27,775,441 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on stateless-unlabelled-guard, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md| index 266232099..dcf31a9f3 100644 |
| --- a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md |
| +++ b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md |
| @@ -166,3 +166,4 @@ copy too. Internal wire enums are not an excuse to expose unreviewed text. |
| | SR-4-C92 | internal/activator/replicadeploy.go | the new copy's configuration was not written on its box in time, so it did not start. existing copies keep serving | approved (controller; Luna house rules) (drill 1 round 2) | |
| | SR-4-C93 | docs/site/stateless-replicas.md | An app that creates its own instance.key or report.token file must take those values from a shared source, its configuration or its environment, or run one copy. The platform gives every copy the same CARLOS_INSTANCE_KEY, but it cannot stop each copy of an app from writing a different file of its own. | approved (controller; Luna house rules) (drill 1 round 2, A3 restriction) | |
| | SR-4-C94 | docs/site/stateless-replicas.md | When a copy switches, its old build stops once the new one serves. A response still streaming from the old build when it stops is cut, as when a box stops. Websockets on the old build disconnect and their clients reconnect to a healthy copy. | approved (controller; Luna house rules) (drill 3, H4) | |
| +| SR-5-C01 | internal/console/appcopies.go | <host> is not tied to one box of fleet <fleet>, and that fleet has more than one box. a release without a local database needs that first, so keep this app on a release with a local database for now | DRAFT, awaiting Paul's copy review (#1008; refused at ship, at any publication of a stateless build, and at copies above 1) | |
diff --git a/internal/console/apicli.go b/internal/console/apicli.go| index 4cc2af184..c9536ef81 100644 |
| --- a/internal/console/apicli.go |
| +++ b/internal/console/apicli.go |
| @@ -2339,6 +2339,14 @@ func (s *Server) handleAPIShip(w http.ResponseWriter, r *http.Request) { |
| jsonError(w, http.StatusBadRequest, err.Error()) |
| return |
| } |
| + // A stateless build an instance of this app could never wake is |
| + // refused before anything is uploaded (#1008). |
| + if meta.Stateless && !meta.Hibernate { |
| + if ref := s.unlabelledFleetRefusal(r.Context(), acct, app); ref != nil { |
| + writeDoorRefusal(w, ref) |
| + return |
| + } |
| + } |
| if refuseBadSwap(w, meta.Swap) { |
| return |
| } |
diff --git a/internal/console/appcopies.go b/internal/console/appcopies.go| index 30b29a4f6..ffc6ae94a 100644 |
| --- a/internal/console/appcopies.go |
| +++ b/internal/console/appcopies.go |
| @@ -21,14 +21,16 @@ import ( |
| const ( |
| copiesStopping = "copies are still stopping on other boxes. wait for that to finish before selecting a release with a local database" |
| - copiesBounds = "copies must be a whole number of at least 1" |
| - copiesCapacity = "%d copies need %d eligible boxes. this fleet has %d" |
| - copiesRelease = "more than one copy requires a stateless, always-on release. set --copies 1 before selecting this release" |
| - copiesFloor = "copies above 1 need every fleet box and the console on %s or later. update them and try again" |
| - copiesUnread = "could not check every instance, release and fleet box, so the copy count was left unchanged. try again" |
| - copiesManaged = "more than one copy is available for platform-managed instances on an owned fleet only" |
| - copiesMoving = "this instance has an import or move in progress. finish it before changing the copy count" |
| - copiesOverlap = "more than one copy needs a release and app policy that let each copy switch builds while its old build keeps serving. change them first" |
| + // copiesUnlabelled (#1008, draft for copy review): host, fleet. |
| + copiesUnlabelled = "%s is not tied to one box of fleet %s, and that fleet has more than one box. a release without a local database needs that first, so keep this app on a release with a local database for now" |
| + copiesBounds = "copies must be a whole number of at least 1" |
| + copiesCapacity = "%d copies need %d eligible boxes. this fleet has %d" |
| + copiesRelease = "more than one copy requires a stateless, always-on release. set --copies 1 before selecting this release" |
| + copiesFloor = "copies above 1 need every fleet box and the console on %s or later. update them and try again" |
| + copiesUnread = "could not check every instance, release and fleet box, so the copy count was left unchanged. try again" |
| + copiesManaged = "more than one copy is available for platform-managed instances on an owned fleet only" |
| + copiesMoving = "this instance has an import or move in progress. finish it before changing the copy count" |
| + copiesOverlap = "more than one copy needs a release and app policy that let each copy switch builds while its old build keeps serving. change them first" |
| // copy SR-4-C85 (#511 drill 1, R19) |
| copiesSize = "%d copies need %d boxes with room for size %s. this fleet has %d. choose a smaller size" |
| // copy SR-4-C91 (#511 drill 1 round 1, Astra A2) |
| @@ -213,6 +215,9 @@ func (s *Server) copiesRefusal(ctx context.Context, acct *Account, app string, n |
| if err != nil { |
| return unread() |
| } |
| + if ref := unlabelledFleetRecordRefusal(reg, recs); ref != nil { |
| + return ref |
| + } |
| // A durable create allocation may publish its body during recovery. |
| // Do not admit a larger count while that record is still pending. |
| allocations, err := s.store.PendingLifetimesForApp(acct.Sqid, app) |
| @@ -424,3 +429,65 @@ func (s *Server) copiesSizeRefusal(ctx context.Context, acct *Account, app strin |
| } |
| return nil |
| } |
| + |
| +// unlabelledFleetRefusal refuses a release without a local database, or |
| +// more than one copy, for an app with a live instance whose record is |
| +// placed on a fleet but tied to no box (no fleet_box, no replica |
| +// assignment) while that fleet has more than one active box (#1008). Every |
| +// box of the fleet serves such a record (provision ownsRecord), and the |
| +// console's coordinator door accepts it only on a one-box fleet |
| +// (replicaFleetRecord's sole-box rule), refusing every box otherwise: a |
| +// stateless build of it could never wake. Refused here, before anything is |
| +// published, rather than left to fail at the next wake. |
| +func (s *Server) unlabelledFleetRefusal(ctx context.Context, acct *Account, app string) *doorRefusal { |
| + recs, err := placeRecords(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), acct.Sqid, app) |
| + if err != nil { |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: copiesUnread} |
| + } |
| + if !anyUnlabelledFleetRecord(recs) { |
| + return nil |
| + } |
| + reg, err := s.openPassRegistry() |
| + if err != nil { |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: copiesUnread} |
| + } |
| + return unlabelledFleetRecordRefusal(reg, recs) |
| +} |
| + |
| +func anyUnlabelledFleetRecord(recs []provision.Record) bool { |
| + for _, rec := range recs { |
| + if _, onFleet := registry.FleetPlacement(rec.Region); onFleet && !rec.Retired && rec.FleetBox == "" && rec.ReplicaAssignment == nil { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// unlabelledFleetRecordRefusal is unlabelledFleetRefusal's judgment over |
| +// records already read. A fleet whose boxes can't be read answers 503. |
| +func unlabelledFleetRecordRefusal(reg consoleRegistry, recs []provision.Record) *doorRefusal { |
| + active := map[string]int{} |
| + for _, rec := range recs { |
| + fleet, onFleet := registry.FleetPlacement(rec.Region) |
| + if !onFleet || rec.Retired || rec.FleetBox != "" || rec.ReplicaAssignment != nil { |
| + continue |
| + } |
| + n, seen := active[fleet] |
| + if !seen { |
| + boxes, err := reg.ListFleetBoxes(fleet) |
| + if err != nil { |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: copiesUnread} |
| + } |
| + for _, box := range boxes { |
| + if box.Status == "active" { |
| + n++ |
| + } |
| + } |
| + active[fleet] = n |
| + } |
| + if n > 1 { |
| + return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(copiesUnlabelled, rec.Host, fleet)} |
| + } |
| + } |
| + return nil |
| +} |
diff --git a/internal/console/copiespublication.go b/internal/console/copiespublication.go| index 0040d113e..e95f46085 100644 |
| --- a/internal/console/copiespublication.go |
| +++ b/internal/console/copiespublication.go |
| @@ -147,15 +147,22 @@ func (s *Server) copiesPublicationRefusal(ctx context.Context, acct *Account, ap |
| if ship && target != nil && !target.Hibernate { |
| return nil |
| } |
| - cfg, err := s.copiesDefault(ctx, acct.Sqid, app) |
| - if err == nil && !cfg.explicit { |
| - return nil |
| - } |
| if target == nil && ver != "" { |
| target, _ = memoize(ctx, "stateless-manifest:"+release.ManifestKey(acct.Sqid, app, ver), func() (*release.Manifest, error) { |
| return release.GetManifest(ctx, s.cfg.Releases, acct.Sqid, app, ver) |
| }) |
| } |
| + // Whatever the app's copies: a stateless build an instance of it could |
| + // never wake is refused before it is published (#1008). |
| + if safeCopiesTarget(target) { |
| + if ref := s.unlabelledFleetRefusal(ctx, acct, app); ref != nil { |
| + return ref |
| + } |
| + } |
| + cfg, err := s.copiesDefault(ctx, acct.Sqid, app) |
| + if err == nil && !cfg.explicit { |
| + return nil |
| + } |
| if err != nil { |
| if safeCopiesTarget(target) { |
| return nil |
diff --git a/internal/console/copiespublication_test.go b/internal/console/copiespublication_test.go| index ba4544803..dc226cda1 100644 |
| --- a/internal/console/copiespublication_test.go |
| +++ b/internal/console/copiespublication_test.go |
| @@ -175,7 +175,10 @@ func TestCopiesPublicationEvidence(t *testing.T) { |
| {"unread config unsafe", false, false, "config", 503}, |
| {"unread config safe", false, true, "config", 200}, |
| {"unread inventory unsafe", true, false, "record", 503}, |
| - {"unread inventory safe", true, true, "record", 200}, |
| + // A stateless target reads the inventory for #1008's guard (an |
| + // unlabelled record on a multi-box fleet), and an unreadable one |
| + // refuses with a retry rather than publish unchecked. |
| + {"unread inventory safe", true, true, "record", 503}, |
| } { |
| t.Run(tc.name, func(t *testing.T) { |
| fx, token := copiesWorld(t) |
| @@ -210,8 +213,11 @@ func TestCopiesPublicationEvidence(t *testing.T) { |
| if counter.gets[cfgKey] != 1 { |
| t.Fatalf("config GETs=%d, want exactly one", counter.gets[cfgKey]) |
| } |
| - if (!tc.explicit || tc.safe) && counter.gets[recKey] != 0 { |
| - t.Fatal("legacy/safe target read assignments") |
| + if !tc.explicit && !tc.safe && counter.gets[recKey] != 0 { |
| + t.Fatal("legacy target read assignments") |
| + } |
| + if tc.safe && tc.failure != "record" && counter.gets[recKey] == 0 { |
| + t.Fatal("stateless target published without reading the inventory (#1008)") |
| } |
| }) |
| } |
diff --git a/internal/console/copiesunlabelled_test.go b/internal/console/copiesunlabelled_test.go| new file mode 100644 |
| index 000000000..6920fbfb1 |
| --- /dev/null |
| +++ b/internal/console/copiesunlabelled_test.go |
| @@ -0,0 +1,80 @@ |
| +package console |
| + |
| +import ( |
| + "fmt" |
| + "strings" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| +) |
| + |
| +// TestStatelessRefusedOnUnlabelledMultiBoxRecord (#1008): an instance whose |
| +// record is on a fleet but tied to no box (no fleet_box, no replica |
| +// assignment) is served by every box of the fleet, and the coordinator door |
| +// refuses it on a fleet with more than one active box, so a stateless build |
| +// of it could never wake. A --stateless ship, a stateless promote and |
| +// copies above 1 are refused up front. Controls: the same record on a |
| +// one-box fleet, and labelled records on the two-box fleet, are admitted. |
| +func TestStatelessRefusedOnUnlabelledMultiBoxRecord(t *testing.T) { |
| + type world struct { |
| + name string |
| + setup func(t *testing.T, fx *consoleFixture) |
| + refused bool |
| + } |
| + unlabel := func(t *testing.T, fx *consoleFixture) { |
| + placementEdit(t, fx, "a.example.com", func(r *provision.Record) { r.FleetBox, r.FleetBoxAt = "", "" }) |
| + } |
| + worlds := []world{ |
| + {"unlabelled on a two-box fleet", unlabel, true}, |
| + {"unlabelled on a one-box fleet", func(t *testing.T, fx *consoleFixture) { |
| + unlabel(t, fx) |
| + // b.example.com moves to pi-1 so the fleet's one active box |
| + // still holds every labelled record. |
| + placementEdit(t, fx, "b.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + reg := openTestReg(t, fx) |
| + defer reg.Close() |
| + if err := reg.SetFleetBoxStatus("pi", "pi-2", "detached"); err != nil { |
| + t.Fatal(err) |
| + } |
| + }, false}, |
| + {"labelled on a two-box fleet", func(*testing.T, *consoleFixture) {}, false}, |
| + } |
| + want := fmt.Sprintf(copiesUnlabelled, "a.example.com", "pi") |
| + for _, w := range worlds { |
| + for _, door := range []string{"ship", "promote", "copies"} { |
| + if door == "copies" && strings.Contains(w.name, "one-box") { |
| + continue // two copies need two boxes: a capacity refusal, not this one |
| + } |
| + t.Run(w.name+"/"+door, func(t *testing.T) { |
| + fx, token := copiesWorld(t) |
| + w.setup(t, fx) |
| + var code int |
| + var out string |
| + switch door { |
| + case "ship": |
| + var body map[string]any |
| + code, body = postShip(t, fx.ts.URL+"/api/cli/apps/"+fx.sqid+"/shop/releases", token, []shipPart{metaStateless(t, "v3"), {name: "linux-amd64", body: tinyProgramForConsole(t, "example.com/shop")}}) |
| + out = fmt.Sprint(body) |
| + case "promote": |
| + code, out = copiesCall(t, fx, token, copiesDoor{"promote", "POST", "/promote", `{"channel":"canary/new","version":"v2"}`}) |
| + case "copies": |
| + code, out = copiesPut(t, fx, token, `{"copies":2}`) |
| + } |
| + if w.refused { |
| + if code != 409 || !strings.Contains(out, want) { |
| + t.Fatalf("%s: %d %s, want 409 %q", door, code, out, want) |
| + } |
| + return |
| + } |
| + if code >= 300 || strings.Contains(out, "is not tied to one box") { |
| + t.Fatalf("%s admitted world refused: %d %s", door, code, out) |
| + } |
| + }) |
| + } |
| + } |
| +} |
| + |
| +func metaStateless(t *testing.T, version string) shipPart { |
| + t.Helper() |
| + return shipPart{name: "meta", body: []byte(`{"version":"` + version + `","kind":"binary","stateless":true}`)} |
| +} |