carlos / platform Public

Fleet public routes Task 11: the console reads forward rows right

apps place (placeAppTarget) stamps the app's records and no registry row
(spec §4.7, ruling Q5): the row-stamping loop and its dead
ErrRuntimePlacement arm are gone, and consoleRegistry loses SetPlacement.
The passes converge the rows from the records.

Instance health treats a forward row on the hub as not local, so a
fleet-placed instance keeps the fleet's answer (fleetHealth) instead of
the forward row's (preflight 1.19).

The instance list carries route_held, FPR-C08 naming the fleet, on the
caller's own fleet-placed record whose host a non-forward row holds on
the console's box (plan ruling P-3; forwardHeldReason). The CLI's REASON
cell shows it after a config refusal and before a rollout reason.
FPR-C08 is added to fleetRoutesCopyBuilt.

Step 0 migrations: TestPlaceStampsRoutesAndInstances becomes
TestPlaceStampsInstancesNotRoutes; assertPlacement drops its route loop;
TestAccountFleetActiveFlipsWithPlacement runs two hub passes (preflight
1.13); TestPlaceRefusesARootfsKindApp, TestACreateWaitsForAPlaceInFlight
and TestFleetPagePlaceFormPlacesApp no longer expect stamped rows.

9B8 re-pins: placeAppTarget and handleAPIInstanceList. Census card: no
unit for this task (root envelope only), recorded in spec §7.

Known red: TestBackfillAppPlacementsKeepsAConcurrentPlace/an_unplace.
An unplace writes an empty placement column, which appPlacement's route
fallback and the startup backfill read as "never placed", and the app's
fleet-shaped rows are no longer stamped back. Needs a ruling (report).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 724f537981b52917dcce815e7aea5da7c0569077 parent a3e9803
13 files changed, +478 −106
  • apimode.go +5 −0
  • approved_fleet_routes_copy_test.go +1 −1
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +17 −2
  • instances_cli.go +6 −1
  • instances_cli_refusals_test.go +33 −0
  • internal/console/accountfleet_test.go +50 −3
  • internal/console/apiinstances.go +47 −8
  • internal/console/fleetforward_test.go +229 −0
  • internal/console/fleets.go +24 −54
  • internal/console/fleets_test.go +37 −29
  • internal/console/rootfs_move_test.go +13 −7
  • internal/console/view.go +0 −1
  • internal/provision/fleet_public_routes_census_test.go +16 −0

Intent

Human

<task-notification> <task-id>abf645273bf670e4a</task-id> <tool-use-id>toolu_012pZW1sHa9jWoSkqbtvXkgS</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/abf645273bf670e4a.output</output-file> <status>completed</status> <summary>Agent "Implement Task 10: forward phase" 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: DONE.** Fix round 2 is in commit a3e9803a, on top of ff553a48. Not pushed. **The fix:** when the phase is armed (`FleetOwners` set), the row at a host that both an in-scope record and a fleet record name now stays exactly as it is on every path of the instance pass. Dormant, both of the changes below behave as today. - **Import journal:** `journalPass` takes a new parameter, the colliding hosts. For such a host it neither finishes nor rolls back the journal, so no rollback, no redone record write and no cleared gate. The journal row stays and one line per host per pass says it is waiting. - **Removal phase:** I found a second path the review didn't name. Retirement could still delete the row when the in-scope app was in the trash, or when the row's own record was gone. The removal phase now keeps a colliding host's row. Its record scan also had to carry the fleet records, or it couldn't see the collision; the new test caught that. **What happens to a waiting import:** the row stays as the swap left it, the journal row stays, and the record keeps its seed state (for example aborted). Nothing times it out: - The console's seeds sweep only abandons imports still awaiting or checking an upload. - The sweep also skips any host two records hold, which a colliding host is. - So an aborted import is not finished by the console either. A committed import keeps its gate closed until the collision ends. The next pass after the collision is gone resolves the journal as today. **Tests:** two new tests, each with an armed and a dormant case: - `TestForwardCollisionLeavesAnImportJournal`: armed, an aborted in-progress import at a colliding host leaves the row and the journal unchanged and runs no rollback step. Dormant, today's rollback runs. - `TestForwardCollisionKeepsTheRowOfATrashedApp`: armed, the row is kept. Dormant, it is retired. Both failed before the fix and pass after. All 4 mutations were caught. The whole `internal/provision` package passes except `TestPlan14RootReadCensus`, which failed before this task too (it waits for Task 14's overlay). `TestPlan9B8RecordWriteCensus` passes. Build, vet and gofmt are clean, and the cross-builds ran once and passed. The fix report now includes the raw output for the failing run, the passing run, the mutations, the targeted run and the whole package. **Census:** - `Reconcile` and `journalPass` are re-pinned in the record-write inventory, with class and kinds unchanged. - `make census-card` now shows `Reconcile` as `sites`: the removal guard reads `Account`, `App`, and `Host` twice. - `journalPass` is a changed unit spec §7 did not list (`sites`: `Host` twice, `SeedID`). - Both are recorded in §7. The seal is unchanged. **Left as is:** outside the instance pass, the domains pass's whole-app trash loop can still delete a trashed app's row at a colliding host. That pass runs on the housekeeper only, and this task doesn't change it. The report is appended to `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/.superpowers/sdd/2026-10-30-fleet-public-routes/task-10-report.md`.</result> <usage><subagent_tokens>317491</subagent_tokens><tool_uses>22</tool_uses><duration_ms>375533</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>b2r89rrfb</task-id> <tool-use-id>toolu_01MAN4dzd3namNfk1CPbrsLi</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/b2r89rrfb.output</output-file> <status>completed</status> <summary>Background command "Run the scoped Astra re-review of Task 10 round 2" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 9.76 g CO₂e (1,244,811 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/apimode.go b/apimode.go
index cde2e8943..0f0d248bf 100644
--- a/apimode.go
+++ b/apimode.go
@@ -3452,6 +3452,11 @@ type apiInstanceRecord struct {
// absent from an older console and for an instance no box refuses.
ConfigRefusal *apiConfigRefusal `json:"config_refusal,omitempty"`
RefusalsCapped bool `json:"refusals_capped,omitempty"`
+ // RouteHeld is the console's held-host sentence (FPR-C08): the record
+ // is placed on a fleet and another route on the hub holds its host, so
+ // requests do not reach the fleet. Absent from an older console and for
+ // every other instance.
+ RouteHeld string `json:"route_held,omitempty"`
}
// apiConfigRefusal mirrors the console's configRefusalView
diff --git a/approved_fleet_routes_copy_test.go b/approved_fleet_routes_copy_test.go
index 23c77e2bc..c2d4a9842 100644
--- a/approved_fleet_routes_copy_test.go
+++ b/approved_fleet_routes_copy_test.go
@@ -44,7 +44,7 @@ var fleetRoutesCopyStatuses = []string{"pending", "approved", "struck"}
// row is approved. Task 3 builds the CLI refusal (FPR-C01); Task 8 the floor
// rows (FPR-C02 to FPR-C05); Task 9 the fleet-create barrier (FPR-C06,
// FPR-C07); Task 11 the REASON cell (FPR-C08).
-var fleetRoutesCopyBuilt = []string{"FPR-C01", "FPR-C02", "FPR-C03", "FPR-C04", "FPR-C05", "FPR-C06", "FPR-C07"}
+var fleetRoutesCopyBuilt = []string{"FPR-C01", "FPR-C02", "FPR-C03", "FPR-C04", "FPR-C05", "FPR-C06", "FPR-C07", "FPR-C08"}
func mustParseFleetRoutesRecord(t *testing.T) []copyRow {
t.Helper()
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 f0ffd337e..1a9d8449f 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
@@ -1294,6 +1294,17 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
release identities skipped): console code only, card and seal
unchanged.
+ Task 11's card: no unit, seal unchanged (`78b7e7e3...`). The root
+ package changes `instances_cli.go` `reasonCell` (the held-host branch)
+ and `apimode.go` `apiInstanceRecord` (the `route_held` field). Neither
+ has a read site (they read a decoded console answer, no registry
+ struct, file or environment), so they move only the `.` envelope, which
+ this list already re-pins; the copy gate gains `fleetRoutesCopyBuilt` +=
+ FPR-C08. The console's `placeAppTarget`, `instanceHealth`,
+ `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.
+
Root's own row readers (adopt, capability, named units, restart, stage,
rootfs, `layoutReversalIncomplete`) change no code and select by
`Kind == "instance"`, `IsSidecar()`, `Unit`, `Runtime`, `Backing`,
@@ -1320,8 +1331,12 @@ and its fix round 1 re-pins `runRoute` again and `runRouteHibernate`
(key-site, `key:ParseRecordKey,key:RecordKey,lit:instances`, unchanged:
the forward phase reads the same record keys and writes only the
registry);
-Task 11 `fleets.go` `Server.placeAppTarget` and `apiinstances.go`
-`Server.handleAPIInstanceList`.
+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`
+`Server.handleAPIInstanceList` (key-site, `lit:instances`, unchanged:
+`route_held` from the registry listing instance health already read; no
+new bucket read or write).
Reviewer: Astra, verdict on #280.
diff --git a/instances_cli.go b/instances_cli.go
index 3f5ea5d8b..b0f5b3768 100644
--- a/instances_cli.go
+++ b/instances_cli.go
@@ -681,12 +681,17 @@ func configRefusalReason(r apiInstanceRecord) string {
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 rollout reason (a failure hold outranks a
+// 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.
func reasonCell(r apiInstanceRecord) string {
if s := configRefusalReason(r); s != "" {
return s
}
+ if r.RouteHeld != "" {
+ return r.RouteHeld
+ }
if s := rolloutReason(r.Rollout); s != "" {
return s
}
diff --git a/instances_cli_refusals_test.go b/instances_cli_refusals_test.go
index b83c5691f..ebf010d12 100644
--- a/instances_cli_refusals_test.go
+++ b/instances_cli_refusals_test.go
@@ -55,3 +55,36 @@ func TestInstancesListPrintsTheRefusalReason(t *testing.T) {
t.Fatalf("the list lacks the refusal:\n%s", out.String())
}
}
+
+// The REASON cell of a held host (fleet public routes spec §4.3 step 4;
+// FPR-C08): the console's route_held sentence shows after a config refusal
+// and before a rollout reason, and reaches the table.
+func TestReasonCellNamesTheHeldHost(t *testing.T) {
+ const held = "another route on the router holds this name, so requests do not reach fleet home. the deployment's operator can remove that route"
+ for _, c := range []struct {
+ name, body, want string
+ }{
+ {"held", `{"host":"shop.example.com","route_held":"` + held + `"}`, held},
+ {"a config refusal outranks it", `{"host":"shop.example.com","route_held":"` + held + `","config_refusal":{"reason":"store_error"}}`,
+ "config refused: store_error. run journalctl -u carlos-edge and check for config guard lines"},
+ {"it outranks a rollout reason", `{"host":"shop.example.com","route_held":"` + held + `","rollout":{"installed":"v2","serving":"v1","awake":true,"held_by":"v2"}}`, held},
+ {"an older console", `{"host":"shop.example.com"}`, ""},
+ } {
+ 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)
+ }
+ }
+ var r apiInstanceRecord
+ if err := json.Unmarshal([]byte(`{"host":"shop.example.com","route_held":"`+held+`"}`), &r); err != nil {
+ t.Fatal(err)
+ }
+ var out bytes.Buffer
+ printInstancesList(&out, []apiInstanceRecord{r})
+ if !strings.Contains(out.String(), held) {
+ t.Fatalf("the table has no held-host reason:\n%s", out.String())
+ }
+}
diff --git a/internal/console/accountfleet_test.go b/internal/console/accountfleet_test.go
index 800664bb0..0b7cab8de 100644
--- a/internal/console/accountfleet_test.go
+++ b/internal/console/accountfleet_test.go
@@ -12,14 +12,17 @@ package console
// apps run on the shared one.
import (
+ "bytes"
"context"
"errors"
+ "log"
"net/http"
"path/filepath"
"strings"
"testing"
"time"
+ "github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/status"
)
@@ -174,17 +177,44 @@ func TestAccountFleetSharedCardFromFleetJSON(t *testing.T) {
// fleet, false once every one of them is placed on a fleet of its own. An
// account told "your apps run here" when they do not is the failure this
// test exists to prevent.
+//
+// apps place stamps the record and no row (fleet public routes spec §4.7);
+// the console box's instance pass converges the row, as the hub's would.
+// From the platform onto a fleet takes it two passes (spec §4.6, preflight
+// 1.13): the first leaves the instance row at the host to the forward phase
+// (held, logged once) and retires it as its record left the pass's scope;
+// the second mints the forward row the card counts as placed.
func TestAccountFleetActiveFlipsWithPlacement(t *testing.T) {
fx, token := fleetFixture(t, "code-acctfleet-active")
+ ctx := context.Background()
+ if err := provision.CreateRecord(ctx, fx.rel, provision.Record{Schema: 1, Host: "kass.example.dev",
+ Slug: "kass", App: "kass", Account: fx.sqid, Channel: "stable", CreatedAt: time.Now().UTC()}); err != nil {
+ t.Fatal(err)
+ }
reg := openTestReg(t, fx)
+ t.Cleanup(func() { reg.Close() })
if err := reg.Upsert(registry.Route{
- Host: "kass.example.dev", Kind: "instance", App: "kass", Account: fx.sqid,
+ Host: "kass.example.dev", Slug: "kass", Kind: "instance", App: "kass", Account: fx.sqid,
+ Channel: "stable", Status: "ready", Provisioned: true,
}); err != nil {
t.Fatal(err)
}
+ cfg := provision.ReconcileConfig{DataDir: t.TempDir(),
+ FleetOwners: func() (map[string]string, error) { return map[string]string{"acme": fx.sqid}, nil }}
+ pass := func(n string) {
+ t.Helper()
+ if err := provision.Reconcile(ctx, fx.rel, reg, cfg); err != nil {
+ t.Fatalf("%s: %v", n, err)
+ }
+ }
+ // The record's own row, kept by its pass.
+ pass("pass before the place")
+ if rt, err := reg.Get("kass.example.dev"); err != nil || rt == nil || rt.Kind != "instance" || !rt.Provisioned {
+ t.Fatalf("before the place: row = %+v %v, want the record's instance row", rt, err)
+ }
acct := fixtureAccount(fx)
- card, _, _, _ := fx.srv.assembleAccountFleet(context.Background(), acct)
+ card, _, _, _ := fx.srv.assembleAccountFleet(ctx, acct)
if !card.Active || card.PlatformApps != 1 {
t.Fatalf("unplaced route: Active=%v PlatformApps=%d, want true/1", card.Active, card.PlatformApps)
}
@@ -197,7 +227,24 @@ func TestAccountFleetActiveFlipsWithPlacement(t *testing.T) {
t.Fatalf("place = %d %v, want 200", st, body)
}
- card, own, _, _ := fx.srv.assembleAccountFleet(context.Background(), acct)
+ var logs bytes.Buffer
+ prev := log.Writer()
+ log.SetOutput(&logs)
+ t.Cleanup(func() { log.SetOutput(prev) })
+ pass("pass 1")
+ log.SetOutput(prev)
+ if rt, err := reg.Get("kass.example.dev"); err != nil || rt != nil {
+ t.Fatalf("after pass 1: row = %+v %v, want none (instance row retired, forward row not yet minted)", rt, err)
+ }
+ if n := strings.Count(logs.String(), "provision: forward kass.example.dev: not minted: another row holds the host"); n != 1 {
+ t.Errorf("pass 1: held host logged %d times, want once", n)
+ }
+ pass("pass 2")
+ if rt, err := reg.Get("kass.example.dev"); err != nil || rt == nil || !rt.IsForward() || rt.Region != "fleet/acme" {
+ t.Fatalf("after pass 2: row = %+v %v, want the forward row on fleet/acme", rt, err)
+ }
+
+ card, own, _, _ := fx.srv.assembleAccountFleet(ctx, acct)
if card.Active || card.PlatformApps != 0 {
t.Fatalf("every route placed: Active=%v PlatformApps=%d, want false/0", card.Active, card.PlatformApps)
}
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index 4a46e84de..aad52cd8b 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -30,6 +30,7 @@ import (
"context"
"encoding/json"
"errors"
+ "fmt"
"log"
"net/http"
"os"
@@ -259,6 +260,32 @@ type instanceListRecord struct {
// (memberEgressView). Absent when no fresh box reports one, which is
// most hosts: a host with no allow and nothing to say is not reported.
Egress *memberEgress `json:"egress,omitempty"`
+ // RouteHeld is FPR-C08 naming the record's fleet when the record is
+ // placed on a fleet and a row that is not a forward row holds its host
+ // on the console's box, the hub (forwardHeldReason; fleet public routes
+ // spec §4.3 step 4, plan ruling P-3). The CLI's REASON cell shows it.
+ // It is set only on the caller's own record and says nothing of the
+ // row that holds the host. Absent otherwise.
+ RouteHeld string `json:"route_held,omitempty"`
+}
+
+// forwardHeldReason is FPR-C08 for rec, or "": rec is placed on a fleet and
+// rows (the console box's registry, by host) holds a row at its host that is
+// not a forward row. The hub's forward phase leaves such a row as it is and
+// 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.
+func forwardHeldReason(rows map[string]registry.Route, rec provision.Record) string {
+ fleet, placed := registry.FleetPlacement(rec.Region)
+ if !placed {
+ return ""
+ }
+ rt, ok := rows[rec.Host]
+ if !ok || rt.IsForward() {
+ 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)
}
// memberEgress is a host's egress read-back as a member sees it on the
@@ -333,7 +360,15 @@ func memberEgressView(h status.HostEgress, ok bool) *memberEgress {
// twice over: OwnerAppMetrics' allowlist is exactly the hosts and stamped
// units it is handed, so a foreign unit name reaching unitByHost would widen
// the metrics view past the caller's own app.
-func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) map[string]string {
+//
+// A forward row (fleet public routes spec §4.2) is not local: the hub only
+// passes the host's requests to the fleet, so a fleet-placed record with a
+// forward row here takes its word as a record with no row here does, from
+// the boxes that report it and then fleetHealth.
+//
+// rows is the registry listing by host, for the held-host reason
+// (forwardHeldReason); nil when it could not be read.
+func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) (health map[string]string, rows map[string]registry.Route) {
out := make(map[string]string, len(recs))
for _, rec := range recs {
out[rec.Host] = "Setting up"
@@ -342,17 +377,17 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma
// A console with no registry configured cannot know any route's
// state; opening "" would hand sqlite a throwaway temp DB and answer
// the same "Setting up" a page later, having created a file for it.
- return out
+ return out, nil
}
reg, err := openRegistry(s.cfg.Registry)
if err != nil {
log.Printf("console: api instances health: registry %s: %v", s.cfg.Registry, err)
- return out
+ return out, nil
}
routes, err := reg.List()
if err != nil {
log.Printf("console: api instances health: registry list: %v", err)
- return out
+ return out, nil
}
byHost := make(map[string]registry.Route, len(routes))
for _, rt := range routes {
@@ -368,6 +403,9 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma
if !ok {
continue // no route minted yet: the record stays "Setting up"
}
+ if rt.IsForward() {
+ continue // not local: the remote join below answers for it
+ }
// A row stamped to another app or account is not this record's route.
// The box's own reconcile pass says so — it refuses to converge such
// a row ("exists but was not minted by this pass — leaving it
@@ -408,7 +446,7 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma
}
var pending []remoteWord
for _, rec := range recs {
- if _, local := byHost[rec.Host]; local {
+ if rt, local := byHost[rec.Host]; local && !rt.IsForward() {
continue
}
if !loaded {
@@ -473,7 +511,7 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma
for h, word := range s.healthByHost(ctx, routeFor, sinceByHost) {
out[h] = word
}
- return out
+ return out, byHost
}
// fleetHealth fills in, from join, the health of each record placed on a
@@ -1236,7 +1274,7 @@ func (s *Server) handleAPIInstanceList(w http.ResponseWriter, r *http.Request) {
limit = n
}
}
- health := s.instanceHealth(ctx, recs)
+ health, rows := s.instanceHealth(ctx, recs)
fleetHealth(health, recs, join, acct.Sqid, app)
counts := map[string]int{}
matched := make([]instanceListRecord, 0, len(recs))
@@ -1264,7 +1302,8 @@ func (s *Server) handleAPIInstanceList(w http.ResponseWriter, r *http.Request) {
SettingsDefault: provision.EffectiveUpdates(rec, policy).Default(),
RegionName: regionlabel.ForRecord(rec, home, names).Text,
MovePhrase: regionlabel.MovePhrase(rec, home, names),
- Egress: join.egressFor(rec.Host, acct.Sqid, app)})
+ Egress: join.egressFor(rec.Host, acct.Sqid, app),
+ RouteHeld: forwardHeldReason(rows, rec)})
}
total := len(matched)
// provision.ListRecords returns records host-sorted and nothing above
diff --git a/internal/console/fleetforward_test.go b/internal/console/fleetforward_test.go
new file mode 100644
index 000000000..c63fa1c28
--- /dev/null
+++ b/internal/console/fleetforward_test.go
@@ -0,0 +1,229 @@
+package console
+
+// The console reads forward rows right (fleet public routes plan Task 11,
+// spec §4.3 step 4, §4.7): `apps place` stamps the records and no row, a
+// fleet-placed instance's health is the fleet's answer and not the hub's
+// forward row's, and the instance list names a host another route holds on
+// the hub (FPR-C08).
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// fprHeldWords is FPR-C08 as the deck writes it.
+const fprHeldWords = "another route on the router holds this name, so requests do not reach fleet %s. the deployment's operator can remove that route"
+
+// fprHost is a host of app shop under example.com.
+func fprHost(slug string) string { return slug + ".shop.example.com" }
+
+// fprRecord creates a record of app shop in the fixture's account.
+func fprRecord(t *testing.T, fx *consoleFixture, slug, region string, created time.Time) provision.Record {
+ t.Helper()
+ rec := provision.Record{Schema: 1, Host: fprHost(slug), Slug: slug, App: "shop", Account: fx.sqid,
+ Region: region, Channel: "stable", CreatedAt: created, CreatedBy: "paul@keymail.dev"}
+ if err := provision.CreateRecord(context.Background(), fx.rel, rec); err != nil {
+ t.Fatal(err)
+ }
+ return rec
+}
+
+// fprForward writes the hub's forward row for rec, as the forward phase
+// would mint it.
+func fprForward(t *testing.T, reg *registry.Registry, rec provision.Record) {
+ t.Helper()
+ if err := reg.PutForward(registry.Route{Host: rec.Host, Kind: registry.KindForward, Slug: rec.Slug,
+ App: rec.App, Account: rec.Account, Region: rec.Region, Channel: rec.Channel}); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// fprListed is the instance list's rows by host, each as its raw keys.
+func fprListed(t *testing.T, fx *consoleFixture, token string) (map[string]map[string]json.RawMessage, string) {
+ t.Helper()
+ code, _, out := rawReq(t, http.MethodGet, fx.ts.URL+"/api/cli/apps/"+fx.sqid+"/shop/instances", token, "")
+ if code != http.StatusOK {
+ t.Fatalf("list = %d %s", code, out)
+ }
+ var list struct {
+ Instances []map[string]json.RawMessage `json:"instances"`
+ }
+ if err := json.Unmarshal([]byte(out), &list); err != nil {
+ t.Fatal(err)
+ }
+ rows := map[string]map[string]json.RawMessage{}
+ for _, r := range list.Instances {
+ var host string
+ if err := json.Unmarshal(r["host"], &host); err != nil {
+ t.Fatal(err)
+ }
+ rows[host] = r
+ }
+ return rows, out
+}
+
+// fprString is one string key of a listed row, "" when absent.
+func fprString(t *testing.T, row map[string]json.RawMessage, key string) string {
+ t.Helper()
+ raw, ok := row[key]
+ if !ok {
+ return ""
+ }
+ var s string
+ if err := json.Unmarshal(raw, &s); err != nil {
+ t.Fatalf("%s = %s: %v", key, raw, err)
+ }
+ return s
+}
+
+// Spec §4.7, ruling Q5: `apps place` stamps the app's records and writes no
+// registry row. The console box's instance row of shop keeps its Region and
+// every other column; another app's row is untouched; the record moves.
+func TestPlaceNoLongerStampsRows(t *testing.T) {
+ fx, token := fleetFixture(t, "code-fpr-place")
+ if _, err := fx.st.CreateAppIn(OpsAccountID, "shop", "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ reg := openTestReg(t, fx)
+ t.Cleanup(func() { reg.Close() })
+ rows := []registry.Route{
+ {Host: fprHost("one"), Slug: "one", Kind: "instance", App: "shop", Account: fx.sqid, Region: "uk",
+ Channel: "stable", Status: "ready", Provisioned: true},
+ {Host: "blog.example.com", Slug: "blog", Kind: "instance", App: "blog", Account: fx.sqid, Region: "uk",
+ Channel: "stable", Status: "ready"},
+ }
+ before := map[string]registry.Route{}
+ for _, rt := range rows {
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ got, err := reg.Get(rt.Host)
+ if err != nil || got == nil {
+ t.Fatalf("fixture row %s: %v", rt.Host, err)
+ }
+ before[rt.Host] = *got
+ }
+ fprRecord(t, fx, "one", "uk", time.Now().UTC())
+ 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": "fleet/home"}, token); st != http.StatusOK {
+ t.Fatalf("place = %d %v, want 200", st, body)
+ }
+
+ for host, want := range before {
+ got, err := reg.Get(host)
+ if err != nil || got == nil {
+ t.Fatalf("row %s after place: %v", host, err)
+ }
+ if *got != want {
+ t.Errorf("row %s changed by apps place:\n got %+v\nwant %+v", host, *got, want)
+ }
+ }
+ got, err := provision.GetRecord(context.Background(), fx.rel, fx.sqid, "shop", fprHost("one"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got.Region != "fleet/home" {
+ t.Fatalf("record Region = %q, want fleet/home", got.Region)
+ }
+}
+
+// Spec §4.4 (console), preflight 1.19: a forward row on the hub is not the
+// instance's local row. With it present, a fleet-placed record's health is
+// the fleet answer, fleetHealth's word from the fleet box's rollout report:
+// Running for the host the box reports awake, and unknown for the host no
+// box reports. Read as local, the forward row would answer for both.
+func TestFleetInstanceHealthIgnoresTheForwardRow(t *testing.T) {
+ fx := newConsoleFixture(t)
+ if _, err := fx.st.CreateAppIn(OpsAccountID, "shop", "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ now := time.Now().UTC()
+ created := now.Add(-10 * time.Second)
+ reported := fprRecord(t, fx, "one", registry.PlacementTarget("home"), created)
+ quiet := fprRecord(t, fx, "two", registry.PlacementTarget("home"), created)
+ reg := openTestReg(t, fx)
+ fprForward(t, reg, reported)
+ fprForward(t, reg, quiet)
+ reg.Close()
+ writeFleetRolloutBox(t, fx, "home", fx.sqid, "box-1", now, &status.RolloutReport{Hosts: map[string]status.HostRollout{
+ reported.Host: {Account: fx.sqid, App: "shop", Installed: "v1", Awake: true},
+ }}, nil)
+ token := cliToken(t, fx, "paul@keymail.dev", "code-fpr-health")
+
+ got := listHealth(t, fx, token, "shop")
+ if got[reported.Host] != "Running" {
+ t.Errorf("reported host health = %q, want Running (the fleet box's answer)", got[reported.Host])
+ }
+ if got[quiet.Host] != healthUnknown {
+ t.Errorf("unreported host health = %q, want %q", got[quiet.Host], healthUnknown)
+ }
+}
+
+// Spec §4.3 step 4, plan ruling P-3, Review Focus 1: a fleet-placed record
+// 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.
+// 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.
+func TestInstanceListNamesTheHeldHost(t *testing.T) {
+ fx := newConsoleFixture(t)
+ if _, err := fx.st.CreateAppIn(OpsAccountID, "shop", "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ created := time.Now().UTC().Add(-10 * time.Second)
+ home := registry.PlacementTarget("home")
+ hand := fprRecord(t, fx, "hand", home, created)
+ foreign := fprRecord(t, fx, "foreign", home, created)
+ fwd := fprRecord(t, fx, "fwd", home, created)
+ fprRecord(t, fx, "none", home, created)
+ platform := fprRecord(t, fx, "platform", "", created)
+ reg := openTestReg(t, fx)
+ for _, rt := range []registry.Route{
+ // A hand row of the app's own (carlos add), never placed.
+ {Host: hand.Host, Slug: "hand", Kind: "instance", App: "shop", Account: fx.sqid, Channel: "r10-proxy", Status: "ready"},
+ // Another account's row at the caller's host.
+ {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"},
+ } {
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ }
+ fprForward(t, reg, fwd)
+ reg.Close()
+ token := cliToken(t, fx, "paul@keymail.dev", "code-fpr-held")
+
+ rows, body := fprListed(t, fx, token)
+ held := fmt.Sprintf(fprHeldWords, "home")
+ for slug, want := range map[string]string{
+ "hand": held, "foreign": held, "fwd": "", "none": "", "platform": "",
+ } {
+ row, ok := rows[fprHost(slug)]
+ if !ok {
+ t.Fatalf("%s not listed: %s", slug, body)
+ }
+ if got := fprString(t, row, "route_held"); got != want {
+ t.Errorf("%s route_held = %q, want %q", slug, got, want)
+ }
+ }
+ for _, leak := range []string{"blogk3x", `"k3x"`} {
+ if strings.Contains(body, leak) {
+ t.Errorf("the list names the holder (%s): %s", leak, body)
+ }
+ }
+}
diff --git a/internal/console/fleets.go b/internal/console/fleets.go
index da29c7c87..ed3e2ddc8 100644
--- a/internal/console/fleets.go
+++ b/internal/console/fleets.go
@@ -630,8 +630,8 @@ func staleSealedRefusal(app string, vars []string) string {
const placeInstancesFailed = "could not update this app's instances — try again"
// placeAppTarget is placement's whole mechanism, and the ONLY place it
-// lives: repoints where an app's routes (and its already-provisioned
-// instances) should run. target "" clears placement back to
+// lives: repoints where an app's already-provisioned instances (and every
+// instance created after) should run. target "" clears placement back to
// platform-served/unconstrained; any other value must parse as
// "fleet/<name>" (registry.FleetPlacement) naming a fleet acct ITSELF owns —
// placing onto another account's fleet is refused with the same
@@ -655,39 +655,31 @@ const placeInstancesFailed = "could not update this app's instances — try agai
// error there would turn this door into an oracle for which fleet names exist
// in someone else's account.
//
-// THE TRIPWIRE this function exists to close: placement is stored in
-// Route.Region (SetPlacement) AND, separately, in every one of the app's
-// already-provisioned instance records' Region field
-// (provision.SetRecordRegion) — both are read by provision.Reconcile's
-// filter (rec.Region != cfg.Region) on a fleet box running
-// CARLOS_REGION=fleet/<name>. Stamping routes here does NOT, by itself,
-// repoint where a NEW instance provisions — instance-create validates its
-// Region from the REQUEST BODY (handleAPIInstanceCreate, apiinstances.go),
-// and provision.ValidRegion's shape (no "/") would refuse a "fleet/<name>"
-// value outright if it somehow arrived that way. A new instance inheriting
-// placement is a SEPARATE mechanism (appPlacement, above, consulted by
-// handleAPIInstanceCreate directly) — spec's "one flag on the app, all its
+// THE TRIPWIRE this function exists to close: placement is stored in every
+// one of the app's already-provisioned instance records' Region field
+// (provision.SetRecordRegion), which provision.Reconcile's filter
+// (rec.Region != cfg.Region) reads on every box, a fleet box running
+// CARLOS_REGION=fleet/<name> included. A NEW instance inheriting placement
+// is a SEPARATE mechanism (appPlacement, above, consulted by
+// handleAPIInstanceCreate directly): spec's "one flag on the app, all its
// instances follow". What THIS function's record write closes is the gap
// that inheritance cannot: every instance that ALREADY EXISTS at the moment
// placement changes. Inheritance only ever applies going forward, at
// create time, so without the write below an already-provisioned record
-// would stay filed under its old region forever — silently exempt from a
+// would stay filed under its old region forever, silently exempt from a
// placement change the caller was just told succeeded.
//
-// ORDER MATTERS: routes are stamped BEFORE records, never the reverse.
-// provision.Reconcile's adoption pass (reconcile.go:265) retires a route
-// whose Region no longer matches what it minted the route from; a
-// records-first ordering would open a window in which a reconcile pass —
-// running concurrently, on either the OLD or the NEW fleet's box — could
-// see a record already repointed to the new target while the route still
-// names the old one, and read that route as no longer wanted, deleting a
-// route that is still live. Stamping routes first means the route is
-// always ahead of (or equal to) any record a concurrent reconcile pass
-// would compare it against, never behind.
+// 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 console with no deployment bucket configured (cfg.Releases == nil)
-// refuses the whole request rather than silently doing the routes-only
-// half.
+// refuses the whole request: it has no records to stamp.
func (s *Server) placeAppTarget(ctx context.Context, acct *Account, app, target string) (status int, errMsg string) {
// apps place is cut once the hostname history is active or invalidated
// (nearest-region never-reuse spec §5): S3, before the temporary-app
@@ -754,9 +746,8 @@ func (s *Server) placeAppTarget(ctx context.Context, acct *Account, app, target
// from these reads through the last write: every console create of an
// instance record takes it (createRecordWithLifetime,
// createRecordMarked), so a first ship that lands during the place cannot
- // put a record under it. SetRecordRegion and registry.SetPlacement refuse
- // a runtime row again in the write itself, and SetRecordRegion an HA
- // record under its CAS (final review F3).
+ // put a record under it. SetRecordRegion refuses a runtime record again
+ // in the write itself, and an HA record under its CAS (final review F3).
//
// The account lock comes first (applocks.go: account, then app). The
// sealed-values check below reads the app's bundles for the target's key
@@ -803,12 +794,9 @@ func (s *Server) placeAppTarget(ctx context.Context, acct *Account, app, target
}
// The store-of-record write (2026-08-06 ruling): appPlacement consults
- // THIS before it ever walks a route. It has to land before routes/records
- // are stamped below, not after — the same "never observe an app in a
- // getting-placed state that some OTHER path already trusts" reasoning
- // the ORDER MATTERS paragraph above applies to routes-before-records, one
- // step earlier: a concurrent instance-create must never inherit a target
- // this request has not actually committed to.
+ // THIS before it ever walks a route. It has to land before the records
+ // are stamped below, not after: a concurrent instance-create must never
+ // inherit a target this request has not actually committed to.
if s.cfg.HostClaim {
if s.cfg.ClaimPlacement == nil {
return http.StatusServiceUnavailable, claimResponseUnavailable
@@ -842,24 +830,6 @@ func (s *Server) placeAppTarget(ctx context.Context, acct *Account, app, target
return http.StatusInternalServerError, "could not record placement — try again"
}
- routes, err := reg.List()
- if err != nil {
- log.Printf("console: place %s/%s: list routes: %v", acct.Sqid, app, err)
- return http.StatusBadGateway, "could not read the app's routes — try again"
- }
- for _, rt := range routes {
- if rt.Account != acct.Sqid || rt.App != app {
- continue
- }
- if err := reg.SetPlacement(rt.Host, target); err != nil {
- if errors.Is(err, registry.ErrRuntimePlacement) {
- return http.StatusConflict, rootfsPlaceWords
- }
- log.Printf("console: place %s/%s: set placement on %s: %v", acct.Sqid, app, rt.Host, err)
- return http.StatusBadGateway, "could not update every route — try again"
- }
- }
-
ctx, cancel := context.WithTimeout(ctx, instanceStoreTimeout)
defer cancel()
prefix := provision.RecordsPrefix(acct.Sqid, app)
diff --git a/internal/console/fleets_test.go b/internal/console/fleets_test.go
index afd7e0073..117279db8 100644
--- a/internal/console/fleets_test.go
+++ b/internal/console/fleets_test.go
@@ -397,13 +397,15 @@ func TestAppPlacementFallsBackToRouteWhenStoreEmpty(t *testing.T) {
}
}
-// TestPlaceStampsRoutesAndInstances is the tripwire test the brief calls out
-// by name: placing an app stamps BOTH its routes' Region (walked from the
-// registry, SetPlacement per host) AND its already-provisioned instance
-// records' Region (provision.SetRecordRegion) — the second half is what
-// makes placement real for instances that already exist, not only future
-// ones. Clearing (target "") repoints both back to "".
-func TestPlaceStampsRoutesAndInstances(t *testing.T) {
+// TestPlaceStampsInstancesNotRoutes is the tripwire test: placing an app
+// stamps its already-provisioned instance records' Region
+// (provision.SetRecordRegion), which is what makes placement real for
+// instances that already exist, not only future ones. It stamps no registry
+// row (fleet public routes spec §4.7, ruling Q5): the passes converge the
+// rows from the records. The app's routes keep their Region, another app's
+// route is untouched, and clearing (target "") repoints the record back to
+// "" and leaves the routes as they were.
+func TestPlaceStampsInstancesNotRoutes(t *testing.T) {
fx, token := fleetFixture(t, "code-place-tripwire")
now := time.Now()
if _, err := fx.st.CreateAppIn(OpsAccountID, "titogo", "paul@keymail.dev", now); err != nil {
@@ -448,8 +450,8 @@ func TestPlaceStampsRoutesAndInstances(t *testing.T) {
if err != nil || rt == nil {
t.Fatalf("route %s: %v", host, err)
}
- if rt.Region != "fleet/pi" {
- t.Errorf("route %s Region = %q, want fleet/pi", host, rt.Region)
+ if rt.Region != "" {
+ t.Errorf("route %s Region = %q, want \"\": apps place stamps no row", host, rt.Region)
}
}
other, err := reg.Get("other.go.tito.io")
@@ -465,14 +467,14 @@ func TestPlaceStampsRoutesAndInstances(t *testing.T) {
t.Fatal(err)
}
if got.Region != "fleet/pi" {
- t.Fatalf("instance record Region = %q, want fleet/pi — the tripwire: routes-only stamping is not enough", got.Region)
+ t.Fatalf("instance record Region = %q, want fleet/pi: the tripwire", got.Region)
}
// Nothing else about the record moved.
if got.Channel != "stable" || got.Slug != "acme" {
t.Fatalf("place touched more than Region: %+v", got)
}
- // Clearing repoints both back to "".
+ // Clearing repoints the record back to "", and the route stays as it was.
if status, body := postJSON(t, placeURL(fx, "titogo"), map[string]string{"target": ""}, token); status != http.StatusOK {
t.Fatalf("clear place = %d %v, want 200", status, body)
}
@@ -1199,7 +1201,7 @@ func placeFixture(t *testing.T, code string) (*consoleFixture, string) {
}
// Region "" throughout: the app starts genuinely unplaced, so "nothing
// moved" and "moved back to the shared fleet" are the same assertion —
- // assertPlacement can check one value across all three stores. (The API
+ // assertPlacement can check one value across both stores. (The API
// door's own tripwire test covers stamping OVER a pre-existing region.)
rec := provision.Record{Schema: 1, Host: "acme.go.tito.io", Slug: "acme", App: "titogo",
Account: fx.sqid, Channel: "stable", CreatedAt: now.UTC()}
@@ -1213,25 +1215,16 @@ func placeFixture(t *testing.T, code string) (*consoleFixture, string) {
return fx, token
}
-// assertPlacement is the whole tripwire in one call: the store of record, the
-// app's routes, and its already-provisioned instance record all agree on
-// where the app runs. Anything less is the routes-only half-move the API
-// door's own tests (TestPlaceStampsRoutesAndInstances) exist to refuse.
+// assertPlacement is the whole tripwire in one call: the store of record and
+// the app's already-provisioned instance record agree on where the app runs.
+// The routes are not placeAppTarget's to stamp (fleet public routes spec
+// §4.7): the passes converge them from the records, and
+// TestPlaceStampsInstancesNotRoutes pins that the place leaves them alone.
func assertPlacement(t *testing.T, fx *consoleFixture, want string) {
t.Helper()
if got, err := fx.st.AppPlacement(OpsAccountID, "titogo"); err != nil || got != want {
t.Fatalf("store placement = %q %v, want %q", got, err, want)
}
- reg := openTestReg(t, fx)
- for _, host := range []string{"acme.go.tito.io", "beta.go.tito.io"} {
- rt, err := reg.Get(host)
- if err != nil || rt == nil {
- t.Fatalf("route %s: %v", host, err)
- }
- if rt.Region != want {
- t.Fatalf("route %s Region = %q, want %q", host, rt.Region, want)
- }
- }
got, err := provision.GetRecord(context.Background(), fx.rel, fx.sqid, "titogo", "acme.go.tito.io")
if err != nil {
t.Fatal(err)
@@ -1242,7 +1235,7 @@ func assertPlacement(t *testing.T, fx *consoleFixture, want string) {
}
// TestAppPlacePageMovesAndClears: the owner's Placement form in the app's
-// Settings stamps routes AND records (placeAppTarget's whole job) and comes
+// Settings stamps the records (placeAppTarget's whole job) and comes
// back to the Placement section with a flash saying what happened — then
// clears the same way, which is a MOVE BACK to the shared fleet, not a no-op.
func TestAppPlacePageMovesAndClears(t *testing.T) {
@@ -1475,8 +1468,23 @@ func TestFleetPagePlaceFormPlacesApp(t *testing.T) {
if !strings.Contains(body, "placed on fleet/pi") {
t.Fatalf("no placed flash on the fleet page:\n%s", body)
}
- // The app is now among the placed apps, so it is no longer offered as
- // something to place HERE.
+ // The placed-apps list reads the rows, which the place no longer writes
+ // (fleet public routes spec §4.7): the hub's passes retire the app's
+ // instance row and mint its forward row (TestAccountFleetActiveFlipsWithPlacement
+ // runs them). Once that row is here, the app is among the placed apps
+ // and no longer offered as something to place HERE.
+ reg := openTestReg(t, fx)
+ defer reg.Close()
+ for _, host := range []string{"acme.go.tito.io", "beta.go.tito.io"} {
+ if err := reg.Delete(host); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := reg.PutForward(registry.Route{Host: "acme.go.tito.io", Kind: registry.KindForward, Slug: "acme",
+ App: "titogo", Account: fx.sqid, Region: "fleet/pi", Channel: "stable"}); err != nil {
+ t.Fatal(err)
+ }
+ _, _, body = get(t, c, fx.u("/fleets/pi"))
if strings.Contains(body, `<option value="titogo">titogo</option>`) {
t.Fatalf("an app already placed on this fleet is still offered as placeable:\n%s", body)
}
diff --git a/internal/console/rootfs_move_test.go b/internal/console/rootfs_move_test.go
index 7f9727bbe..fcd246a3d 100644
--- a/internal/console/rootfs_move_test.go
+++ b/internal/console/rootfs_move_test.go
@@ -274,8 +274,9 @@ func TestPlaceWaitsForACreateInFlight(t *testing.T) {
// Round 1 finding 1, the place first: a console create of a rootfs record
// that starts after the place's check waits for the app lock, so the place
-// lands whole (placement, route, binary record) and the new record is
-// created afterwards where it asked to be, not re-homed.
+// lands whole (placement, binary record; the route is the passes' to
+// converge, fleet public routes spec §4.7) and the new record is created
+// afterwards where it asked to be, not re-homed.
func TestACreateWaitsForAPlaceInFlight(t *testing.T) {
fx, token, reg := placeRootfsWorld(t, "code-place-rootfs-place-first")
created := make(chan error, 1)
@@ -305,8 +306,8 @@ func TestACreateWaitsForAPlaceInFlight(t *testing.T) {
t.Fatal(err)
}
after := readPlaceState(t, fx, reg)
- if after.placement != "fleet/pi" || after.routes["plain.example.com"] != "fleet/pi" {
- t.Fatalf("the place did not land: %+v", after)
+ if after.placement != "fleet/pi" || after.routes["plain.example.com"] != "" {
+ t.Fatalf("the place did not land, or stamped the route: %+v", after)
}
for host, want := range map[string]string{"plain.example.com": "fleet/pi", rootfsMoveHost: "ie"} {
got, err := provision.GetRecord(context.Background(), fx.rel, fx.sqid, "shop", host)
@@ -489,13 +490,18 @@ func TestPlaceRefusesARootfsKindApp(t *testing.T) {
}
unchanged("marker read fails", fx, reg, before)
- // A binary app places as before.
+ // A binary app places as before: the store and the record move, and the
+ // route is the passes' to converge (fleet public routes spec §4.7), so
+ // the place leaves it as it was.
fx, token, reg = placeRootfsWorld(t, "code-place-kind-binary")
putKindMarker(t, fx, "binary")
+ before = readPlaceState(t, fx, reg)
if code, msg := place(fx, token); code != http.StatusOK {
t.Fatalf("binary app: place = %d %s", code, msg)
}
- if after := readPlaceState(t, fx, reg); after.placement != "fleet/pi" || after.routes["plain.example.com"] != "fleet/pi" {
- t.Fatalf("binary app did not place: %+v", after)
+ after := readPlaceState(t, fx, reg)
+ if after.placement != "fleet/pi" || !maps.Equal(after.routes, before.routes) ||
+ !strings.Contains(after.records[provision.RecordKey(fx.sqid, "shop", "plain.example.com")], `"region":"fleet/pi"`) {
+ t.Fatalf("binary app did not place: before %+v\nafter %+v", before, after)
}
}
diff --git a/internal/console/view.go b/internal/console/view.go
index 233b9986d..ba0072064 100644
--- a/internal/console/view.go
+++ b/internal/console/view.go
@@ -528,7 +528,6 @@ 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 89cd5ebdb..6a5c6da66 100644
--- a/internal/provision/fleet_public_routes_census_test.go
+++ b/internal/provision/fleet_public_routes_census_test.go
@@ -60,6 +60,18 @@ package provision
// finished nor rolled back (no record CAS, no gate cleared, no
// rollback), and the host stays handled and journaled. The record key
// it compares is unchanged; it writes less, never more.
+//
+// Task 11, two re-pins, no new unit:
+// - internal/console/fleets.go Server.placeAppTarget (record-writer): the
+// loop that stamped the app's registry rows (reg.SetPlacement, and its
+// 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.
+// - 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
+// caller's own records. No new bucket read or write; the record listing
+// and its instances literal are unchanged.
func fleetPublicRoutesWriteCensusInventory() []censusEntry {
entries := append([]censusEntry(nil), rootfsFleetFollowupsWriteCensusInventory()...)
repins := []censusEntry{
@@ -73,6 +85,10 @@ 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: route_held from the registry listing; the same record listing.
+ {"internal/console/apiinstances.go", "Server.handleAPIInstanceList", "key-site", "lit:instances", "117d18b80409bccbb3e608b49effae4413dcf0ed561a4e18e7e9d28c6e3cef90"},
}
for _, r := range repins {
found := false