carlos / platform Public

Fleet public routes Task 11 fix round 1: an unplace leaves no fleet behind, C08 only where requests miss the fleet, route_held cleaned

Controller rulings on Task 11:

1. An unplace clears a fleet placement from the app's own non-forward
   rows on the console's box (clearLegacyPlacement, through
   registry.SetPlacement(host, ""), which skips a forward row), before the
   records. A place onto a fleet still writes no row. appPlacement, the
   startup backfill and fleetPlacedApps fall back to the rows through
   legacyFleetFromRoutes, which skips forward rows. After an unplace a new
   instance inherits no fleet and the backfill writes none, with a legacy
   hand row and a forward row present. TestBackfillAppPlacementsKeepsAConcurrentPlace
   passes again.
2. FPR-C08 is not shown for a legacy row of the same app placed on the
   record's own fleet whose raw account is the record's or empty: the
   fleet arm serves it there. Another fleet, or another account's app of
   the same name, still shows it.
3. The CLI prints route_held only through cleanConsoleText (cleanPlace's
   rule from region_labels.go with a 512-byte bound).
4. Spec §4.7 states the fleet page and Fleet tab lag as a limitation.

9B8: placeAppTarget re-pinned. Census card unchanged (no unit, same seal);
§7 updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev f68b4fae51df2a365bc1dcc6e022a188a5855649 parent 724f537
12 files changed, +261 −25
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +40 −1
  • instances_cli.go +9 −4
  • instances_cli_refusals_test.go +24 −0
  • internal/console/apiinstances.go +9 −1
  • internal/console/fleetforward_test.go +87 −0
  • internal/console/fleets.go +53 −9
  • internal/console/fleetsecretskey.go +1 −1
  • internal/console/regionfacts.go +20 −0
  • internal/console/sealkey.go +3 −3
  • internal/console/view.go +1 −0
  • internal/provision/fleet_public_routes_census_test.go +6 −2
  • region_labels.go +8 −4

CI failed — run details

Intent

Human

<task-notification> <task-id>a4c17b74700baa3f2</task-id> <tool-use-id>toolu_011EnyvWPNk3bSXdgEqHq4oR</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a4c17b74700baa3f2.output</output-file> <status>completed</status> <summary>Agent "Implement Task 11: console" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status: NEEDS_CONTEXT.** Task 11 is built and committed, but one existing test now fails because of a real regression that needs your ruling: `TestBackfillAppPlacementsKeepsAConcurrentPlace/an_unplace`. **Commit:** `724f5379` on top of `a3e9803a`, not pushed. **Tests:** - The Step 2 command (plus the reason-cell, health and tenancy tests) passes for `./internal/console` and `.`. - Every new test failed at base for the right reason, and 7 of 7 mutations were caught. - `TestPlan9B8RecordWriteCensus` passes, and build, vet, gofmt and the darwin, windows and linux/arm64 cross-builds are clean. - The census card shows no unit for this task (root envelope only, seal unchanged). I recorded that in spec §7. **What was done:** - **`apps place`:** it no longer stamps rows, and `consoleRegistry` loses `SetPlacement`. - **Health:** a forward row no longer counts as the instance's local row, so health comes from the fleet box (`fleetHealth`). - **REASON:** the instance list carries `route_held` (the C08 sentence, written in `apiinstances.go` because the copy gate reads that file), and the CLI's REASON cell shows it after a config refusal and before a rollout reason. - **Census:** both 9B8 re-pins are added. - **Migrations:** I migrated the three tests from the R3 sweep, plus three more it missed: `TestPlaceRefusesARootfsKindApp`, `TestACreateWaitsForAPlaceInFlight` and `TestFleetPagePlaceFormPlacesApp`. **The ruling needed:** an unplace writes an empty placement column, which looks the same as "never placed". Two readers then fall back to the app's rows: - `appPlacement`, which new instances use to inherit placement; - the startup backfill (`sealkey.go:212`), which writes the column. Unplace used to stamp the rows back to empty. Now any fleet-placed row the app still has makes both readers return the old fleet: a legacy hand row (permanently), or its forward row until the hub's next pass. So a new instance can land on the old fleet, and a console restart writes the old fleet back. The three options: - **A (my recommendation):** on unplace only, clear the fleet from the app's non-forward rows, and have both readers skip forward rows. Cost: it breaks the brief's literal "no longer calls `SetPlacement`" for the unplace case. - **B:** make the store tell an unplace from "never placed". Cost: a store change and a migration. - **C:** drop the row fallback and the backfill. Cost: needs proof the backfill has run on every deployment. I left the failing subtest as is so the fix round sees it. **Other concerns:** 1. **C08 can be false.** Ruling P-3 counts any non-forward row as holding the host. But a legacy row of the same app placed on the same fleet (like railsdemo's hand row) is still served through the edge's fleet path, so requests do reach the fleet while REASON says they don't. I followed P-3 and Review Focus 1. 2. **Fleet page and account Fleet tab lag:** they read rows, so after a place they show the app as unplaced until the hub's passes run. For a host held by a hand row, they never show it as placed. 3. **Raw text in the CLI:** it prints the console's `route_held` sentence as sent, with no terminal sanitising. 4. **Accidental full console run:** a `-run` path didn't resolve outside the sandbox, so the whole console package ran once. Its only other failures were unrelated: the control-plane tests fail on the worktree's VCS-status error, and one plan9 seal test timed out under load and passes alone. The full report, including mutation details and the census reconciliation, is at `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/.superpowers/sdd/2026-10-30-fleet-public-routes/task-11-report.md`.</result> <usage><subagent_tokens>246810</subagent_tokens><tool_uses>98</tool_uses><duration_ms>1873923</duration_ms></usage> </task-notification>

Attributed to this commit: 39.4 g CO₂e (5,051,565 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-fleet-public-routes, 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/specs/2026-10-29-fleet-public-routes-design.md b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
index 1a9d8449f..cf663973c 100644
--- a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
+++ b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
@@ -594,6 +594,35 @@ their removal is approved per row.
rows (`fleets.go:817-829`) (Q5, fixed), so no new legacy placed row is
made.
+As built (Task 11, controller rulings): a place onto a fleet writes no
+row. An unplace writes one thing to rows: it clears a fleet placement from
+the app's own non-forward rows on the console's box
+(`clearLegacyPlacement`, through `registry.SetPlacement(host, "")`, whose
+statement skips a forward row), before the records. The reason is the
+store's placement column: an unplace writes `""`, which is also "never
+placed", and `appPlacement` (instance create's inheritance), the startup
+backfill (`sealkey.go` `backfillAppPlacements`) and `fleetPlacedApps` then
+fall back to the rows. Those three read the rows through
+`legacyFleetFromRoutes`, which skips forward rows: a forward row follows a
+record already placed and is never a legacy placement. Without both, an
+unplaced app would get its old fleet back from a legacy row, or from its
+forward row until the hub's next pass retires it. Unplacing an app whose
+legacy row is served through the fleet arm stops that, as an unplace
+always has.
+
+The held-host REASON (FPR-C08) is shown only where the row at the host
+does not take requests toward the record's own fleet: a legacy row of the
+same app whose `Region` is the record's fleet and whose raw `Account` is
+the record's or empty is served there by the fleet arm
+(`edge.FleetServeEligible`), so it shows none.
+
+A stated limitation: the console's fleet page (placed apps, and the apps
+its form offers) and the account Fleet tab read the rows. After a place,
+an app shows as not placed until the hub's passes have run (two passes
+from the platform, §4.6: seconds on the change index), and an app whose
+host another row holds never shows as placed there; `instances list`
+names that case (FPR-C08). Accepted (controller ruling, Task 11).
+
### 4.8 Request policy: enforced once, at the hub; the gate at the fleet edge **(R1-2, R1-3)**
Rate limit, plan throttle, lapse page, upgrades. Enforcement for a
@@ -1304,6 +1333,15 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
`forwardHeldReason` and `handleAPIInstanceList`, and `view.go`'s
`consoleRegistry` (which loses `SetPlacement`), are outside the root
scope; the two 9B8 units are re-pinned (below). Nothing to reconcile.
+ Task 11 fix round 1 (controller rulings): the root package adds
+ `region_labels.go` `cleanConsoleText` (`cleanPlace`'s rule with a bound;
+ `cleanPlace` now calls it) and `reasonCell` prints `route_held` through
+ it; neither has a read site, so the card is unchanged (no unit, seal
+ `78b7e7e3...`). The console gains `clearLegacyPlacement` (an unplace's
+ row write through `SetPlacement`, which `consoleRegistry` carries again)
+ and `legacyFleetFromRoutes` (read by `appPlacement`, the backfill and
+ `fleetPlacedApps`), outside the root scope; `placeAppTarget`'s 9B8
+ digest is re-pinned again.
Root's own row readers (adopt, capability, named units, restart, stage,
rootfs, `layoutReversalIncomplete`) change no code and select by
@@ -1333,7 +1371,8 @@ the forward phase reads the same record keys and writes only the
registry);
Task 11 `fleets.go` `Server.placeAppTarget` (record-writer,
`key:RecordsPrefix,key:SetRecordRegion`, unchanged: the row-stamping loop
-is gone, the record walk is as before) and `apiinstances.go`
+is gone, an unplace clears legacy rows first (fix round 1), the record
+walk is as before) and `apiinstances.go`
`Server.handleAPIInstanceList` (key-site, `lit:instances`, unchanged:
`route_held` from the registry listing instance health already read; no
new bucket read or write).
diff --git a/instances_cli.go b/instances_cli.go
index b0f5b3768..f69079cb6 100644
--- a/instances_cli.go
+++ b/instances_cli.go
@@ -677,20 +677,25 @@ func configRefusalReason(r apiInstanceRecord) string {
return ""
}
+// routeHeldMaxBytes bounds the held-host sentence the CLI will print: FPR-C08
+// with the longest fleet name fits several times over.
+const routeHeldMaxBytes = 512
+
// plainReasonWord is what a config refusal's reason word may look like.
var plainReasonWord = regexp.MustCompile(`^[a-z0-9_]{1,40}$`)
// reasonCell is the REASON column: a config refusal first (it is why the
// instance is not running), then a held host (another route on the hub holds
// the instance's name, so requests do not reach its fleet; the console's
-// FPR-C08 sentence), then a rollout reason (a failure hold outranks a
-// preference), else the settings reason.
+// FPR-C08 sentence, printed only when cleanConsoleText finds it fit for a
+// terminal), then a rollout reason (a failure hold outranks a preference),
+// else the settings reason.
func reasonCell(r apiInstanceRecord) string {
if s := configRefusalReason(r); s != "" {
return s
}
- if r.RouteHeld != "" {
- return r.RouteHeld
+ if s := cleanConsoleText(r.RouteHeld, routeHeldMaxBytes); s != "" {
+ return s
}
if s := rolloutReason(r.Rollout); s != "" {
return s
diff --git a/instances_cli_refusals_test.go b/instances_cli_refusals_test.go
index ebf010d12..d76320aab 100644
--- a/instances_cli_refusals_test.go
+++ b/instances_cli_refusals_test.go
@@ -88,3 +88,27 @@ func TestReasonCellNamesTheHeldHost(t *testing.T) {
t.Fatalf("the table has no held-host reason:\n%s", out.String())
}
}
+
+// Controller ruling 3: route_held is console text, printed only when it is
+// fit for a terminal (cleanConsoleText, cleanPlace's rule): one with a
+// control character or an escape is not printed, and the cell falls
+// through to what it would say without it.
+func TestReasonCellCleansTheHeldHost(t *testing.T) {
+ for _, c := range []struct {
+ name, body, want string
+ }{
+ {"an escape", "{\"host\":\"shop.example.com\",\"route_held\":\"held \\u001b[31mred\"}", ""},
+ {"a newline", "{\"host\":\"shop.example.com\",\"route_held\":\"held\\nforged line\"}", ""},
+ {"a bidi override", "{\"host\":\"shop.example.com\",\"route_held\":\"held \\u202e\"}", ""},
+ {"falls through to the rollout reason", "{\"host\":\"shop.example.com\",\"route_held\":\"\\u0007\",\"rollout\":{\"installed\":\"v2\",\"serving\":\"v1\",\"awake\":true,\"held_by\":\"v2\"}}",
+ "held: build v2 failed on this box"},
+ } {
+ var r apiInstanceRecord
+ if err := json.Unmarshal([]byte(c.body), &r); err != nil {
+ t.Fatalf("%s: decode %s: %v", c.name, c.body, err)
+ }
+ if got := reasonCell(r); got != c.want {
+ t.Errorf("%s: reasonCell = %q, want %q", c.name, got, c.want)
+ }
+ }
+}
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index aad52cd8b..53acdedad 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -275,7 +275,12 @@ type instanceListRecord struct {
// mints nothing there (spec §4.3 step 4, §4.7), so requests for the host do
// not reach the fleet through a forward row. The console's box is the hub
// (plan ruling P-3), so its own registry is the answer; no box reports it.
-// No row, or a forward row, is not held.
+// No row, or a forward row, is not held. Nor is a legacy row of the same
+// app placed on the record's own fleet whose raw account is the record's or
+// empty (controller ruling 2): the edge serves it toward that fleet
+// (edge.FleetServeEligible), so requests do reach it. Another account's
+// row of an app of the same name is not served toward a fleet the record's
+// account owns, and is held.
func forwardHeldReason(rows map[string]registry.Route, rec provision.Record) string {
fleet, placed := registry.FleetPlacement(rec.Region)
if !placed {
@@ -285,6 +290,9 @@ func forwardHeldReason(rows map[string]registry.Route, rec provision.Record) str
if !ok || rt.IsForward() {
return ""
}
+ if rt.App == rec.App && rt.Region == rec.Region && (rt.Account == "" || rt.Account == rec.Account) {
+ return ""
+ }
return fmt.Sprintf("another route on the router holds this name, so requests do not reach fleet %s. the deployment's operator can remove that route", fleet)
}
diff --git a/internal/console/fleetforward_test.go b/internal/console/fleetforward_test.go
index c63fa1c28..53a694b78 100644
--- a/internal/console/fleetforward_test.go
+++ b/internal/console/fleetforward_test.go
@@ -176,6 +176,10 @@ func TestFleetInstanceHealthIgnoresTheForwardRow(t *testing.T) {
// whose host a row that is not a forward row holds on the hub carries
// route_held, FPR-C08 naming its fleet; the CLI's REASON shows it. A forward
// row at the host, no row, or a record not placed on a fleet carries none.
+// Nor does a legacy row of the same app and account placed on the record's
+// own fleet (controller ruling 2): the edge serves it toward that fleet, so
+// requests do reach it. The same row on another fleet, or another
+// account's row of an app of the same name on this fleet, is held.
// The sentence is the caller's own and names nothing of the holder: a row
// another account holds at the caller's host reads the same, and its app
// and account appear nowhere in the answer.
@@ -191,6 +195,9 @@ func TestInstanceListNamesTheHeldHost(t *testing.T) {
fwd := fprRecord(t, fx, "fwd", home, created)
fprRecord(t, fx, "none", home, created)
platform := fprRecord(t, fx, "platform", "", created)
+ legacy := fprRecord(t, fx, "legacy", home, created)
+ elsewhere := fprRecord(t, fx, "elsewhere", home, created)
+ namesake := fprRecord(t, fx, "namesake", home, created)
reg := openTestReg(t, fx)
for _, rt := range []registry.Route{
// A hand row of the app's own (carlos add), never placed.
@@ -199,6 +206,12 @@ func TestInstanceListNamesTheHeldHost(t *testing.T) {
{Host: foreign.Host, Slug: "foreign", Kind: "instance", App: "blogk3x", Account: "k3x", Channel: "stable", Status: "ready"},
// The platform record's own row.
{Host: platform.Host, Slug: "platform", Kind: "instance", App: "shop", Account: fx.sqid, Channel: "stable", Status: "ready"},
+ // A legacy row of the app placed on the record's own fleet: served toward it.
+ {Host: legacy.Host, Slug: "legacy", Kind: "instance", App: "shop", Account: fx.sqid, Region: home, Channel: "r10-proxy", Status: "ready"},
+ // The same, placed on another fleet.
+ {Host: elsewhere.Host, Slug: "elsewhere", Kind: "instance", App: "shop", Account: fx.sqid, Region: registry.PlacementTarget("away"), Channel: "r10-proxy", Status: "ready"},
+ // Another account's app of the same name, placed on this fleet.
+ {Host: namesake.Host, Slug: "namesake", Kind: "instance", App: "shop", Account: "k3x", Region: home, Channel: "stable", Status: "ready"},
} {
if err := reg.Upsert(rt); err != nil {
t.Fatal(err)
@@ -212,6 +225,7 @@ func TestInstanceListNamesTheHeldHost(t *testing.T) {
held := fmt.Sprintf(fprHeldWords, "home")
for slug, want := range map[string]string{
"hand": held, "foreign": held, "fwd": "", "none": "", "platform": "",
+ "legacy": "", "elsewhere": held, "namesake": held,
} {
row, ok := rows[fprHost(slug)]
if !ok {
@@ -227,3 +241,76 @@ func TestInstanceListNamesTheHeldHost(t *testing.T) {
}
}
}
+
+// Controller ruling 1 (Task 11 review): an unplace leaves no fleet behind.
+// The placement column is "" both for an app never placed and for one
+// unplaced, and appPlacement and the startup backfill read the app's rows
+// when it is "". So an unplace clears the fleet from the app's own
+// non-forward rows on the console's box (a legacy hand row here), and both
+// readers skip forward rows, which follow the records and are never a
+// legacy placement. After the unplace, a new instance inherits no fleet and
+// the backfill writes none, while the forward row is still there (the hub's
+// next pass retires it). The forward row itself is not the console's to
+// write: it stays as it was.
+func TestUnplaceLeavesNoFleetBehind(t *testing.T) {
+ fx := newConsoleFixture(t)
+ if _, err := fx.st.CreateAppIn(OpsAccountID, "shop", "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ enableInstances(t, fx, "shop", provision.Manifest{Schema: 1, App: "shop", Domain: "example.com",
+ Channel: "stable", Regions: []string{"ie"}, Seed: []string{"seed"}})
+ home := registry.PlacementTarget("home")
+ reg := openTestReg(t, fx)
+ t.Cleanup(func() { reg.Close() })
+ // A legacy placed hand row (carlos add, then an older apps place).
+ if err := reg.Upsert(registry.Route{Host: fprHost("hand"), Slug: "hand", Kind: "instance", App: "shop",
+ Account: fx.sqid, Region: home, Channel: "stable", Status: "ready"}); err != nil {
+ t.Fatal(err)
+ }
+ fwd := provision.Record{Host: fprHost("fwd"), Slug: "fwd", App: "shop", Account: fx.sqid, Region: home, Channel: "stable"}
+ fprForward(t, reg, fwd)
+ fwdBefore, err := reg.Get(fwd.Host)
+ if err != nil || fwdBefore == nil {
+ t.Fatalf("fixture forward row: %v", err)
+ }
+ token := cliToken(t, fx, "paul@keymail.dev", "code-fpr-unplace")
+ if st, body := postJSON(t, fleetsURL(fx, fx.sqid)+"/new",
+ map[string]string{"name": "home", "bucket": "home-data"}, token); st != http.StatusOK {
+ t.Fatalf("create fleet = %d %v", st, body)
+ }
+ if st, body := postJSON(t, placeURL(fx, "shop"), map[string]string{"target": home}, token); st != http.StatusOK {
+ t.Fatalf("place = %d %v", st, body)
+ }
+ if rt, _ := reg.Get(fprHost("hand")); rt == nil || rt.Region != home {
+ t.Fatalf("a place stamped the hand row: %+v", rt)
+ }
+
+ if st, body := postJSON(t, placeURL(fx, "shop"), map[string]string{"target": ""}, token); st != http.StatusOK {
+ t.Fatalf("unplace = %d %v", st, body)
+ }
+ if rt, err := reg.Get(fprHost("hand")); err != nil || rt == nil || rt.Region != "" {
+ t.Errorf("after the unplace the hand row is %+v %v, want Region \"\"", rt, err)
+ }
+ if rt, err := reg.Get(fwd.Host); err != nil || rt == nil || *rt != *fwdBefore {
+ t.Errorf("the unplace wrote the forward row:\n got %+v %v\nwant %+v", rt, err, fwdBefore)
+ }
+
+ code, _, out := rawReq(t, http.MethodPost, instancesURL(fx, fx.sqid, "shop"), token, `{"host":"fresh.example.com","region":"ie"}`)
+ if code != http.StatusCreated {
+ t.Fatalf("create after the unplace = %d %s", code, out)
+ }
+ var rec provision.Record
+ if err := json.Unmarshal([]byte(out), &rec); err != nil {
+ t.Fatal(err)
+ }
+ if rec.Region != "ie" {
+ t.Errorf("a new instance after the unplace has Region %q, want ie: it inherited a fleet", rec.Region)
+ }
+
+ if err := fx.srv.backfillAppPlacements(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ if got, err := fx.st.AppPlacement(OpsAccountID, "shop"); err != nil || got != "" {
+ t.Errorf("the backfill after the unplace wrote placement %q %v, want \"\"", got, err)
+ }
+}
diff --git a/internal/console/fleets.go b/internal/console/fleets.go
index ed3e2ddc8..e3211ab6b 100644
--- a/internal/console/fleets.go
+++ b/internal/console/fleets.go
@@ -612,7 +612,7 @@ func (s *Server) appPlacement(reg consoleRegistry, acct *Account, app string) (s
if err != nil {
return "", err
}
- return fleetFromRoutes(routes, acct.Sqid, app), nil
+ return legacyFleetFromRoutes(routes, acct.Sqid, app), nil
}
// staleSealedRefusal is FSK-C47: a move refused because the app has sealed
@@ -669,14 +669,18 @@ const placeInstancesFailed = "could not update this app's instances — try agai
// would stay filed under its old region forever, silently exempt from a
// placement change the caller was just told succeeded.
//
-// It writes no registry row (fleet public routes spec §4.7, ruling Q5).
-// The rows follow the records: each box's instance pass retires the row
-// of a record that left its scope and mints the row of one that entered
-// it, and on the console's box (the hub) the forward phase mints the
-// app's forward row once the instance row is gone. A row this function
-// stamped would be a placed row that no pass minted and none retires, so
-// it stamps none, and a row at the host that is not a forward row is left
-// as it is and named on the instance list (FPR-C08, forwardHeldReason).
+// A place onto a fleet writes no registry row (fleet public routes spec
+// §4.7, ruling Q5). The rows follow the records: each box's instance pass
+// retires the row of a record that left its scope and mints the row of one
+// that entered it, and on the console's box (the hub) the forward phase
+// mints the app's forward row once the instance row is gone. A row this
+// function stamped would be a placed row that no pass minted and none
+// retires, so it stamps none, and a row at the host that is not a forward
+// row is left as it is and named on the instance list (FPR-C08,
+// forwardHeldReason). An unplace writes one thing to rows: it clears a
+// legacy fleet placement from the app's non-forward rows
+// (clearLegacyPlacement), before the records, so the empty column it
+// writes cannot be read back as the old fleet from those rows.
//
// A console with no deployment bucket configured (cfg.Releases == nil)
// refuses the whole request: it has no records to stamp.
@@ -829,6 +833,11 @@ func (s *Server) placeAppTarget(ctx context.Context, acct *Account, app, target
log.Printf("console: place %s/%s: set placement: %v", acct.Sqid, app, err)
return http.StatusInternalServerError, "could not record placement — try again"
}
+ if target == "" {
+ if status, msg := clearLegacyPlacement(reg, acct.Sqid, app); status != 0 {
+ return status, msg
+ }
+ }
ctx, cancel := context.WithTimeout(ctx, instanceStoreTimeout)
defer cancel()
@@ -874,6 +883,41 @@ func (s *Server) placeAppTarget(ctx context.Context, acct *Account, app, target
return 0, ""
}
+// clearLegacyPlacement is an unplace's one row write (controller ruling 1):
+// every non-forward row of sqid/app on the console's box whose Region names
+// a fleet loses it (registry.SetPlacement(host, ""), whose statement skips a
+// forward row). The column an unplace writes is "", which appPlacement and
+// the startup backfill read as "never placed" and then fall back to the
+// rows (legacyFleetFromRoutes), so a legacy placed row left as it was would
+// hand the app its old fleet back. A place onto a fleet writes no row, and
+// neither does this for a row that is not fleet-placed or is a forward row,
+// which the hub's pass retires. A row that became a forward row after the
+// listing is left to the hub (ErrForwardRow).
+func clearLegacyPlacement(reg consoleRegistry, sqid, app string) (int, string) {
+ routes, err := reg.List()
+ if err != nil {
+ log.Printf("console: place %s/%s: list routes: %v", sqid, app, err)
+ return http.StatusBadGateway, "could not read the app's routes — try again"
+ }
+ for _, rt := range routes {
+ if rt.IsForward() || rt.Account != sqid || rt.App != app {
+ continue
+ }
+ if _, placed := registry.FleetPlacement(rt.Region); !placed {
+ continue
+ }
+ switch err := reg.SetPlacement(rt.Host, ""); {
+ case err == nil, errors.Is(err, registry.ErrForwardRow):
+ case errors.Is(err, registry.ErrRuntimePlacement):
+ return http.StatusConflict, rootfsPlaceWords
+ default:
+ log.Printf("console: place %s/%s: clear the placement of %s: %v", sqid, app, rt.Host, err)
+ return http.StatusBadGateway, "could not update every route — try again"
+ }
+ }
+ return 0, ""
+}
+
// handleAPIPlace answers `carlos apps place`: the bearer-authenticated door
// onto placeAppTarget. Everything that makes placement CORRECT lives in that
// function (see its doc comment); what belongs here is the CLI API's own
diff --git a/internal/console/fleetsecretskey.go b/internal/console/fleetsecretskey.go
index ff72a8616..548f47942 100644
--- a/internal/console/fleetsecretskey.go
+++ b/internal/console/fleetsecretskey.go
@@ -331,7 +331,7 @@ func (s *Server) fleetPlacedApps(acct *Account, fleet string) ([]string, error)
}
listed = true
}
- placed = fleetFromRoutes(routes, acct.Sqid, app)
+ placed = legacyFleetFromRoutes(routes, acct.Sqid, app)
}
if placed == target {
out = append(out, app)
diff --git a/internal/console/regionfacts.go b/internal/console/regionfacts.go
index c93c769b8..fd02869aa 100644
--- a/internal/console/regionfacts.go
+++ b/internal/console/regionfacts.go
@@ -107,6 +107,26 @@ func (f appRegionFacts) SourceSentence() string {
return ""
}
+// legacyFleetFromRoutes is the placement an app placed by an older build
+// carries only in its rows: fleetFromRoutes over the rows that can carry
+// one. A forward row is skipped (fleet public routes, controller ruling 1):
+// the hub mints it from a record already placed, and retires it only on its
+// next pass after the record leaves the fleet, so it is never a legacy
+// placement, and reading it after an unplace would hand the app its old
+// fleet back. appPlacement, the startup backfill and fleetPlacedApps read
+// this; the display readers keep fleetFromRoutes.
+func legacyFleetFromRoutes(routes []registry.Route, sqid, app string) string {
+ for _, rt := range routes {
+ if rt.IsForward() || rt.Account != sqid || rt.App != app {
+ continue
+ }
+ if _, ok := registry.FleetPlacement(rt.Region); ok {
+ return rt.Region
+ }
+ }
+ return ""
+}
+
// fleetFromRoutes is appPlacement's legacy fallback over rows already
// listed: the first fleet placement among sqid/app's rows, compared on the
// raw account column exactly as appPlacement always has (fleets.go).
diff --git a/internal/console/sealkey.go b/internal/console/sealkey.go
index ae6f322dc..26bf69a1a 100644
--- a/internal/console/sealkey.go
+++ b/internal/console/sealkey.go
@@ -198,7 +198,7 @@ func (s *Server) deploymentSealKey() (*ecdh.PublicKey, error) {
// backfillAppPlacements writes the placement column from routes for every
// live app whose column is empty and whose routes say fleet/<f>
-// (fleetFromRoutes), so the column becomes the one authority (spec §5.2 step
+// (legacyFleetFromRoutes, which skips forward rows), so the column becomes the one authority (spec §5.2 step
// 2). It does not change any answer appPlacement gives: appPlacement already
// falls back to the same routes for those apps. That is why it need not
// finish before the first seal (plan ruling R-1).
@@ -241,7 +241,7 @@ func (s *Server) backfillAppPlacements(ctx context.Context) error {
errs = append(errs, fmt.Errorf("%s/%s: %w", acct.Sqid, app, err))
continue
}
- if placed != "" || fleetFromRoutes(routes, acct.Sqid, app) == "" {
+ if placed != "" || legacyFleetFromRoutes(routes, acct.Sqid, app) == "" {
continue
}
if backfillPlacementBeforeWrite != nil {
@@ -277,7 +277,7 @@ func (s *Server) backfillApp(ctx context.Context, reg consoleRegistry, acct Acco
if err != nil {
return "", err
}
- target := fleetFromRoutes(routes, acct.Sqid, app)
+ target := legacyFleetFromRoutes(routes, acct.Sqid, app)
if target == "" {
return "", nil
}
diff --git a/internal/console/view.go b/internal/console/view.go
index ba0072064..233b9986d 100644
--- a/internal/console/view.go
+++ b/internal/console/view.go
@@ -528,6 +528,7 @@ type consoleRegistry interface {
List() ([]registry.Route, error)
ListAliases() ([]registry.RouteAlias, error)
ListPaths() ([]registry.RoutePath, error)
+ SetPlacement(string, string) error
CreateFleet(registry.Fleet) (bool, error)
GetFleet(string) (*registry.Fleet, error)
ListFleets() ([]registry.Fleet, error)
diff --git a/internal/provision/fleet_public_routes_census_test.go b/internal/provision/fleet_public_routes_census_test.go
index 6a5c6da66..d77a830ac 100644
--- a/internal/provision/fleet_public_routes_census_test.go
+++ b/internal/provision/fleet_public_routes_census_test.go
@@ -67,6 +67,10 @@ package provision
// ErrRuntimePlacement arm) is gone (spec §4.7, ruling Q5). The record
// walk is unchanged: the same RecordsPrefix listing and the same
// SetRecordRegion per record, under the same locks and refusals.
+// Fix round 1 (controller ruling 1): an unplace calls
+// clearLegacyPlacement before the record walk, which clears a fleet
+// placement from the app's non-forward rows (registry only). Same
+// keys, no new bucket write.
// - internal/console/apiinstances.go Server.handleAPIInstanceList
// (key-site): it takes the registry listing instanceHealth already read
// and sets route_held (FPR-C08, forwardHeldReason) on each of the
@@ -85,8 +89,8 @@ func fleetPublicRoutesWriteCensusInventory() []censusEntry {
{"internal/provision/reconcile.go", "Reconcile", "key-site", "key:ParseRecordKey,key:RecordKey,lit:instances", "7944b6b6dccd5c1cf621d09ed168608d941a9bcdeeedbcff6ad3e202ac00087f"},
// Task 10 fix round 2: a colliding host's journal waits; the same record key.
{"internal/provision/seedreconcile.go", "journalPass", "key-site", "key:RecordKey", "1df98e12c38c3913318c4f0d6ac6b6219b484c86cd2f307588e5a2c8dce9acd4"},
- // Task 11: apps place stamps the records and no row; the same record walk.
- {"internal/console/fleets.go", "Server.placeAppTarget", "record-writer", "key:RecordsPrefix,key:SetRecordRegion", "67f152302313b22acef49cc53484c7af6f02302a89e801459e95899d1d8f90f5"},
+ // Task 11 (fix round 1: an unplace clears legacy rows first): the same record walk.
+ {"internal/console/fleets.go", "Server.placeAppTarget", "record-writer", "key:RecordsPrefix,key:SetRecordRegion", "122d7b01f3d7cd1e9e6a61fee4f46f7b7d9f88b95d9af8831031e2a31da04551"},
// Task 11: route_held from the registry listing; the same record listing.
{"internal/console/apiinstances.go", "Server.handleAPIInstanceList", "key-site", "lit:instances", "117d18b80409bccbb3e608b49effae4413dcf0ed561a4e18e7e9d28c6e3cef90"},
}
diff --git a/region_labels.go b/region_labels.go
index 0eb129cc7..57d73f9ff 100644
--- a/region_labels.go
+++ b/region_labels.go
@@ -13,11 +13,15 @@ import (
// move phrase fit many times over.
const placeMaxBytes = 128
-// cleanPlace is a label the console sent, fit to print: valid UTF-8, at most
-// placeMaxBytes, every rune printable (no control characters, escapes or
+// cleanPlace is a label the console sent, fit to print: cleanConsoleText
+// at placeMaxBytes.
+func cleanPlace(s string) string { return cleanConsoleText(s, placeMaxBytes) }
+
+// cleanConsoleText is text the console sent, fit to print: valid UTF-8, at
+// most max bytes, every rune printable (no control characters, escapes or
// bidi overrides). Anything else is "", and the caller prints its fallback.
-func cleanPlace(s string) string {
- if s == "" || len(s) > placeMaxBytes || !utf8.ValidString(s) {
+func cleanConsoleText(s string, max int) string {
+ if s == "" || len(s) > max || !utf8.ValidString(s) {
return ""
}
for _, r := range s {