carlos / platform Public

Fleet public routes Task 3: FPR-C01 on a forward host (copy approved)

Paul approved FPR-C01 to C08 unchanged. The deck marks all eight rows
approved, text unchanged, and moves FPR-C06 and FPR-C07's file cells to
internal/console/fleetfloor.go (preflight #11).

cli.go: carlos add, route and remove refuse a forward row with FPR-C01,
first: runAdd right after it reads the row, runRemove before Delete,
runRoute on both --host branches before suffixRail and the record-owned
channel rail, and an --app batch holding a forward row refused whole
before any rail or write. A write the registry refuses with ErrForwardRow
(a forward row minted after the read) answers FPR-C01 too.

FPR-C01 joins fleetRoutesCopyBuilt. TestForwardHostRefusedByTheCLI reads
the approved text from the deck and expects it on six invocations, with
controls. Record-write census: runRoute re-pinned in
fleetPublicRoutesWriteCensusInventory. Spec §7 lists the root units.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 40337fd2a05ea37cbe8570de49bd7743bfee886a parent 253f533
6 files changed, +166 −34
  • approved_fleet_routes_copy_test.go +1 −1
  • cli.go +73 −3
  • docs/superpowers/plans/2026-10-30-fleet-public-routes-copy.md +14 −10
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +20 −10
  • forward_cli_test.go +49 −10
  • internal/provision/fleet_public_routes_census_test.go +9 −0
diff --git a/approved_fleet_routes_copy_test.go b/approved_fleet_routes_copy_test.go
index e278fd83e..ca5f36206 100644
--- a/approved_fleet_routes_copy_test.go
+++ b/approved_fleet_routes_copy_test.go
@@ -42,7 +42,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{}
+var fleetRoutesCopyBuilt = []string{"FPR-C01"}
func mustParseFleetRoutesRecord(t *testing.T) []copyRow {
t.Helper()
diff --git a/cli.go b/cli.go
index decf516c0..213d1c230 100644
--- a/cli.go
+++ b/cli.go
@@ -100,6 +100,46 @@ func addWrite(r *registry.Registry, host string, route registry.Route) error {
return err
}
+// forwardRouteRefusal is FPR-C01 for a forward row (fleet public routes spec
+// §4.2): the hub's forward phase owns it, so `carlos add`, `route` and
+// `remove` name the app and its fleet and send the operator to the record.
+func forwardRouteRefusal(rt registry.Route) string {
+ fleet, _ := registry.FleetPlacement(rt.Region)
+ return fmt.Sprintf("%s is app %s on fleet %s. its route follows the app's instance record, so change the app instead: carlos apps place or carlos instances delete", rt.Host, rt.App, fleet)
+}
+
+// refuseForwardRoute prints FPR-C01 and exits 1 when rt is a forward row.
+func refuseForwardRoute(rt *registry.Route) {
+ if rt != nil && rt.IsForward() {
+ fmt.Fprintln(os.Stderr, forwardRouteRefusal(*rt))
+ os.Exit(1)
+ }
+}
+
+// refuseForwardWrite is the answer to a write the registry refused with
+// ErrForwardRow: a forward row took the host after this verb read it. The row
+// is read again for FPR-C01's app and fleet; any other error is returned.
+func refuseForwardWrite(r *registry.Registry, host string, err error) error {
+ if !errors.Is(err, registry.ErrForwardRow) {
+ return err
+ }
+ if rt, gerr := r.Get(host); gerr == nil {
+ refuseForwardRoute(rt)
+ }
+ return err
+}
+
+// refuseForwardBatch is refuseForwardWrite for a batch write: the registry
+// refused it whole, so FPR-C01 names whichever host is now a forward row.
+func refuseForwardBatch(r *registry.Registry, hosts []string, err error) {
+ if !errors.Is(err, registry.ErrForwardRow) {
+ return
+ }
+ for _, h := range hosts {
+ _ = refuseForwardWrite(r, h, err)
+ }
+}
+
// addBeforeWrite is a test seam: when set, runAdd calls it between its read
// of the row and its write. Nil outside tests.
var addBeforeWrite func(host string)
@@ -273,6 +313,9 @@ func runAdd(args []string) {
if err != nil {
log.Fatal(err)
}
+ // A forward row is refused before any check that reads the row
+ // (fleet public routes spec §4.2): FPR-C01.
+ refuseForwardRoute(existing)
effectiveUnit := *unit
if effectiveUnit == "" && existing != nil {
effectiveUnit = existing.Unit
@@ -459,7 +502,7 @@ func runAdd(args []string) {
addBeforeWrite(host)
}
if err := addWrite(r, host, route); err != nil {
- log.Fatal(err)
+ log.Fatal(refuseForwardWrite(r, host, err))
}
if existing != nil {
fmt.Printf("%s %s (existing route)\n", colorFor(os.Stdout).ok("updated"), host)
@@ -480,9 +523,16 @@ func runRemove(args []string) {
if err != nil {
log.Fatal(err)
}
+ // A forward row is the hub's forward phase's (fleet public routes spec
+ // §4.2): FPR-C01, before the delete.
+ existing, err := r.Get(fs.Arg(0))
+ if err != nil {
+ log.Fatal(err)
+ }
+ refuseForwardRoute(existing)
// Data-safe by contract: stops routing the host, never touches its DB.
if err := r.Delete(fs.Arg(0)); err != nil {
- log.Fatal(err)
+ log.Fatal(refuseForwardWrite(r, fs.Arg(0), err))
}
fmt.Printf("%s %s\n", colorFor(os.Stdout).ok("removed"), fs.Arg(0))
}
@@ -964,6 +1014,8 @@ func runRoute(args []string) {
if rt == nil {
log.Fatalf("route: no route for host %q", *host)
}
+ // First of every rail (fleet public routes spec §4.2): FPR-C01.
+ refuseForwardRoute(rt)
if err := suffixRail(*rt); err != nil {
log.Fatalf("route: %v", err)
}
@@ -991,6 +1043,8 @@ func runRoute(args []string) {
if rt == nil {
log.Fatalf("route: no route for host %q", *host)
}
+ // First of every rail (fleet public routes spec §4.2): FPR-C01.
+ refuseForwardRoute(rt)
if err := suffixRail(*rt); err != nil {
log.Fatalf("route: %v", err)
}
@@ -1010,6 +1064,7 @@ func runRoute(args []string) {
} else if !strings.EqualFold(*acctFilter, "all") {
wantAcct = resolveAccount(*regPath, *acctFilter, "")
}
+ var forward []registry.Route
for _, rt := range routes {
if rt.App != *app {
continue
@@ -1017,6 +1072,10 @@ func runRoute(args []string) {
if wantAcct != "" && release.RouteAccount(rt) != wantAcct {
continue
}
+ if rt.IsForward() {
+ forward = append(forward, rt)
+ continue
+ }
if rt.Platform {
// A bulk sweep changing every tenant's platform-minted route
// in one command is a different, riskier operation than
@@ -1040,6 +1099,14 @@ func runRoute(args []string) {
}
candidates = append(candidates, rt)
}
+ // A batch naming a forward row is refused whole, before any rail
+ // and any write (fleet public routes spec §4.2): FPR-C01 for each.
+ if len(forward) > 0 {
+ for _, rt := range forward {
+ fmt.Fprintln(os.Stderr, forwardRouteRefusal(rt))
+ }
+ os.Exit(1)
+ }
if len(candidates) == 0 {
log.Fatalf("route: no non-platform routes for app %q (with the given --account filter, if any)", *app)
}
@@ -1323,18 +1390,21 @@ func runRoute(args []string) {
hosts[i] = rt.Host
}
if err := r.SetChannelsAndEnvironments(hosts, *channel, resolvedEnv); err != nil {
+ refuseForwardBatch(r, hosts, err)
log.Fatalf("route: write: %v — nothing written; the batch is one transaction", err)
}
}
case *channel != "":
if len(toWrite) > 0 && !*dryRun {
if err := r.SetChannels(toWrite, *channel); err != nil {
+ refuseForwardBatch(r, toWrite, err)
log.Fatalf("route: write: %v — nothing written; the batch is one transaction", err)
}
}
case *environment != "":
if len(envToWrite) > 0 && !*dryRun {
if err := r.SetEnvironments(envToWrite, resolvedEnv); err != nil {
+ refuseForwardBatch(r, envToWrite, err)
log.Fatalf("route: write: %v — nothing written; the batch is one transaction", err)
}
}
@@ -1345,7 +1415,7 @@ func runRoute(args []string) {
// is nothing for it to be atomic WITH.
if tunnelWillWrite && !*dryRun {
if err := r.SetTunnel(candidates[0].Host, resolvedTunnel); err != nil {
- log.Fatalf("route: write: %v", err)
+ log.Fatalf("route: write: %v", refuseForwardWrite(r, candidates[0].Host, err))
}
}
diff --git a/docs/superpowers/plans/2026-10-30-fleet-public-routes-copy.md b/docs/superpowers/plans/2026-10-30-fleet-public-routes-copy.md
index f15dfc9b2..33a692ba9 100644
--- a/docs/superpowers/plans/2026-10-30-fleet-public-routes-copy.md
+++ b/docs/superpowers/plans/2026-10-30-fleet-public-routes-copy.md
@@ -7,8 +7,12 @@ Every user-facing string of the fleet public routes feature (spec
the format of `2026-10-29-fleet-secrets-key-copy.md`: columns id, file, text,
status. Ids are `FPR-C01` upward, never renumbered.
-Every row is `pending`: these are drafts, and copy review settles the words.
-A row comes back `approved` with its final text. No later task writes a row
+Every row was a `pending` draft until copy review settled the words. Paul
+approved all eight unchanged on 2026-10-30
+(`.superpowers/sdd/2026-10-30-fleet-public-routes/copy-approved.json`), and
+FPR-C06 and FPR-C07's file cells moved to `internal/console/fleetfloor.go`,
+where `fleetCreateFloorRefusal` lives (preflight #11). A row comes back
+`approved` with its final text. No later task writes a row
that is not `approved`, and each adds its ids to `fleetRoutesCopyBuilt` in the
commit that writes them.
@@ -46,11 +50,11 @@ Placeholders by row:
| id | file | text | status |
|---|---|---|---|
-| FPR-C01 | cli.go (`carlos add`, `route`, `remove` on a forward host; Task 3) | %s is app %s on fleet %s. its route follows the app's instance record, so change the app instead: carlos apps place or carlos instances delete | pending |
-| FPR-C02 | internal/console/fleetfloor.go (409, a channel move across the floor; Task 8) | %s runs %s. this deployment has a customer fleet, so it must run %s or later. %s is not one. to move the channel there anyway, pass --allow-below-fleet-forward-floor | pending |
-| FPR-C03 | internal/console/fleetfloor.go (409, a first publication below the floor; Task 8) | %s has no release yet. this deployment has a customer fleet, so its first release must be %s or later. %s is not one. to publish it anyway, pass --allow-below-fleet-forward-floor | pending |
-| FPR-C04 | internal/console/fleetfloor.go (console log on the override; Task 8) | moving to %s below %s on %s with --allow-below-fleet-forward-floor: the hub keeps serving fleet apps it can no longer retire. remove their routes first | pending |
-| FPR-C05 | internal/release/layoutintent.go (`FleetForwardFloorOverrideUsage`, flag help; Task 8) | allow a release below %s while customer fleets exist. a hub on that release keeps serving fleet apps it can no longer retire | pending |
-| FPR-C06 | internal/console/fleets.go (409, fleet create while a channel is below the floor; Task 9) | this deployment's %s channel is on %s, below %s. new fleets wait until every channel is on %s or later. try again after the deployment's next update | pending |
-| FPR-C07 | internal/console/fleets.go (503, fleet create when a channel pointer cannot be read; Task 9) | could not check this deployment's release channels. try again in a minute | pending |
-| FPR-C08 | internal/console/apiinstances.go (REASON, a fleet-placed instance whose host another route holds; Task 11) | another route on the router holds this name, so requests do not reach fleet %s. the deployment's operator can remove that route | pending |
+| FPR-C01 | cli.go (`carlos add`, `route`, `remove` on a forward host; Task 3) | %s is app %s on fleet %s. its route follows the app's instance record, so change the app instead: carlos apps place or carlos instances delete | approved |
+| FPR-C02 | internal/console/fleetfloor.go (409, a channel move across the floor; Task 8) | %s runs %s. this deployment has a customer fleet, so it must run %s or later. %s is not one. to move the channel there anyway, pass --allow-below-fleet-forward-floor | approved |
+| FPR-C03 | internal/console/fleetfloor.go (409, a first publication below the floor; Task 8) | %s has no release yet. this deployment has a customer fleet, so its first release must be %s or later. %s is not one. to publish it anyway, pass --allow-below-fleet-forward-floor | approved |
+| FPR-C04 | internal/console/fleetfloor.go (console log on the override; Task 8) | moving to %s below %s on %s with --allow-below-fleet-forward-floor: the hub keeps serving fleet apps it can no longer retire. remove their routes first | approved |
+| FPR-C05 | internal/release/layoutintent.go (`FleetForwardFloorOverrideUsage`, flag help; Task 8) | allow a release below %s while customer fleets exist. a hub on that release keeps serving fleet apps it can no longer retire | approved |
+| FPR-C06 | internal/console/fleetfloor.go (409, fleet create while a channel is below the floor; Task 9) | this deployment's %s channel is on %s, below %s. new fleets wait until every channel is on %s or later. try again after the deployment's next update | approved |
+| FPR-C07 | internal/console/fleetfloor.go (503, fleet create when a channel pointer cannot be read; Task 9) | could not check this deployment's release channels. try again in a minute | approved |
+| FPR-C08 | internal/console/apiinstances.go (REASON, a fleet-placed instance whose host another route holds; Task 11) | another route on the router holds this name, so requests do not reach fleet %s. the deployment's operator can remove that route | approved |
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 3ae4e1aef..9f647c873 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
@@ -894,12 +894,20 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
`forwardAt` (`forward.go`, N, `+file:QueryRow`) is a new unit the list
did not name: the one `SELECT kind` every guarded writer uses.
`noRoute` (`forward.go`) has no read site and moves only the envelope.
- The root package's `runAdd`, `runRemove` and `runRoute` are NOT on
- Task 3's card: they change no code yet. `carlos add` and `carlos remove`
- (and `carlos route` on an axis that reaches the registry) already exit 1
- with `ErrForwardRow` from the registry; the refusal wording (FPR-C01)
- lands in the same three functions once that copy row is approved, and
- they appear on that commit's card.
+ The root package (Task 3's FPR-C01 step, after copy approval): `runAdd`
+ (`sites`, `+whole:Route`: the forward check on the row it read, first
+ of every check on that row), `runRemove` (`reads`, `+whole:Route`: a
+ `Get` and the forward check before `Delete`), `runRoute` (`sites`,
+ `+registry:Host`, `+whole:Route` x9: the check first on both `--host`
+ branches, before `suffixRail` and the record-owned channel rail, and an
+ `--app` batch holding a forward row refused whole before any rail or
+ write); three new units in `cli.go`: `forwardRouteRefusal` (N,
+ `+registry:App`, `+registry:Host`, `+registry:Region`: FPR-C01's
+ three values), `refuseForwardRoute` (N, `+whole:Route` x2) and
+ `refuseForwardWrite` (N, `+whole:Route`: a write the registry refused
+ with `ErrForwardRow` reads the row again for FPR-C01).
+ `refuseForwardBatch` has no read site. The root envelope `.` re-pins.
+ All of these only read an agent-written row to refuse; none writes.
- `internal/registry/forward.go` (a new file; the plan puts the forward
row's writers here rather than in `registry.go`): `Registry.SetFleetBoxIf`
(N, Task 1). Task 1's card shows it with `+file:Exec`,
@@ -982,8 +990,9 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
`internal/release` envelope re-pins.
- Root package: `runSystemUpdate` (`system.go:289`) and
`runSystemRollback` (`system.go:578`) (the flag); `runAdd`,
- `runRemove`, `runRoute` (`cli.go:197`, `:471`, `:709`) (the refusal
- wording on `ErrForwardRow`).
+ `runRemove`, `runRoute` (`cli.go:197`, `:471`, `:709`) (FPR-C01 on a
+ forward row, first; Task 3's card, above, adds the three `cli.go`
+ helpers).
Root's own row readers (adopt, capability, named units, restart, stage,
rootfs, `layoutReversalIncomplete`) change no code and select by
@@ -1003,8 +1012,9 @@ They are not outside the record-write census, which pins by digest
`rootfsFleetFollowupsWriteCensusInventory`. Task 3 re-pins
`internal/registry/importjournal.go` `Registry.SwapForImport` (key-site,
`key:RecordKey`, class and kinds unchanged: the forward refusals; the
-journal row and its record key are written as before). The C01 step
-re-pins `cli.go` `runRoute` there; Task 10 `reconcile.go` `Reconcile`;
+journal row and its record key are written as before). Task 3's C01
+step re-pins `cli.go` `runRoute` there (key-site, `lit:instances`,
+unchanged: FPR-C01 first; `runAdd` and `runRemove` are not 9B8 units); Task 10 `reconcile.go` `Reconcile`;
Task 11 `fleets.go` `Server.placeAppTarget` and `apiinstances.go`
`Server.handleAPIInstanceList`.
diff --git a/forward_cli_test.go b/forward_cli_test.go
index d936e8354..e1105b264 100644
--- a/forward_cli_test.go
+++ b/forward_cli_test.go
@@ -2,6 +2,7 @@ package main
import (
"errors"
+ "fmt"
"os/exec"
"path/filepath"
"strings"
@@ -11,13 +12,14 @@ import (
)
// A forward row is the hub's forward phase's (fleet public routes spec §4.2):
-// `carlos add`, `carlos route` and `carlos remove` over a forward host exit 1
-// and leave the row exactly as it was. add, route -tunnel and remove reach
-// the registry and fail there with ErrForwardRow; route -channel is refused
-// before any write by its record-owned rail (a forward row is Provisioned).
-// The registry-reaching verbs succeed on an ordinary host, so the refusal is
-// the forward row's, not the fixture's. (route -channel on an ordinary host
-// needs a release key to compare channels, so it has no positive arm here.)
+// `carlos add`, `carlos route` (-host with any axis, and an --app batch that
+// holds one) and `carlos remove` over a forward host print FPR-C01, exit 1
+// and change nothing, the batch's ordinary rows included. The forward check
+// comes first, before route's record-owned channel rail. add, route -tunnel
+// and remove succeed on an ordinary host, so the refusal is the forward
+// row's, not the fixture's. (route -channel on an ordinary host needs a
+// release key to compare channels, so its control is a batch that stops at
+// that check instead.)
func TestForwardHostRefusedByTheCLI(t *testing.T) {
bin := buildCarlos(t)
regPath := filepath.Join(t.TempDir(), "registry.db")
@@ -78,18 +80,55 @@ func TestForwardHostRefusedByTheCLI(t *testing.T) {
}
}
+ // FPR-C01, as the deck approved it, for the forward host.
+ var c01 string
+ for _, row := range mustParseFleetRoutesRecord(t) {
+ if row.ID == "FPR-C01" {
+ c01 = fleetRoutesAppliedText(row.Text)
+ }
+ }
+ if c01 == "" {
+ t.Fatal("the deck has no FPR-C01")
+ }
+ want := fmt.Sprintf(c01, host, "shop", "home")
+
+ // The --app batch: an ordinary row of app shop rides with the forward
+ // one, and an app with no forward row (blog) shows the batch path runs
+ // and does not answer C01 (it stops at the channel check, which needs a
+ // release key here).
+ const sibling, blog = "shop-b.example.com", "blog-b.example.com"
+ for _, h := range [][]string{{sibling, "shop"}, {blog, "blog"}} {
+ if out, code := run("add", "-registry", regPath, "-app", h[1], h[0]); code != 0 {
+ t.Fatalf("add %s: exit %d\n%s", h[0], code, out)
+ }
+ }
+ siblingBefore, err := reg.Get(sibling)
+ if err != nil || siblingBefore == nil {
+ t.Fatalf("sibling: %+v, %v", siblingBefore, err)
+ }
+ if out, code := run("route", "-registry", regPath, "-app", "blog", "-account", "all", "-channel", "x"); code != 1 || strings.Contains(out, "is app") {
+ t.Fatalf("batch of app blog: exit %d, want 1 at the channel check, not C01\n%s", code, out)
+ }
+
channel := []string{"route", "-registry", regPath, "-host", host, "-channel", "x"}
- for _, args := range append(verbs(host), channel) {
+ batch := []string{"route", "-registry", regPath, "-app", "shop", "-account", "all", "-channel", "x"}
+ // add's unit rail would refuse this flag pair with its own words; the
+ // forward check comes before it.
+ unitAdd := []string{"add", "-registry", regPath, "-app", "shop", "-unit", "shop.service", "-socket", "/run/shop.sock", host}
+ for _, args := range append(verbs(host), channel, batch, unitAdd) {
out, code := run(args...)
if code != 1 {
t.Errorf("carlos %v over a forward row: exit %d, want 1\n%s", args, code, out)
}
- if args[len(args)-2] != "-channel" && !strings.Contains(out, registry.ErrForwardRow.Error()) {
- t.Errorf("carlos %v over a forward row did not fail in the registry:\n%s", args, out)
+ if !strings.Contains(out, want) {
+ t.Errorf("carlos %v over a forward row: output does not carry FPR-C01 %q:\n%s", args, want, out)
}
after, err := reg.Get(host)
if err != nil || after == nil || *after != *before {
t.Fatalf("carlos %v changed the forward row:\n before %+v\n after %+v (%v)", args, before, after, err)
}
+ if got, err := reg.Get(sibling); err != nil || got == nil || *got != *siblingBefore {
+ t.Fatalf("carlos %v changed the batch's ordinary row: %+v, %v", args, got, err)
+ }
}
}
diff --git a/internal/provision/fleet_public_routes_census_test.go b/internal/provision/fleet_public_routes_census_test.go
index 355dab9d8..971d0a0bc 100644
--- a/internal/provision/fleet_public_routes_census_test.go
+++ b/internal/provision/fleet_public_routes_census_test.go
@@ -15,11 +15,20 @@ package provision
// the host is ErrForwardRow before the journal row is written; the
// route DELETE carries kind <> 'forward'. The journal row and its record
// key are written exactly as before.
+//
+// Task 3's FPR-C01 step, one re-pin, no new unit:
+// - cli.go runRoute (key-site): a forward row is refused with FPR-C01 first,
+// before every rail, on the --host axes and for an --app batch that
+// holds one (the whole batch, before any write); a write the registry
+// refuses with ErrForwardRow is answered with FPR-C01 too. The instance
+// record path it names (lit:instances) is unchanged.
func fleetPublicRoutesWriteCensusInventory() []censusEntry {
entries := append([]censusEntry(nil), rootfsFleetFollowupsWriteCensusInventory()...)
repins := []censusEntry{
// Task 3: the forward-row refusals; the same journal row and record key.
{"internal/registry/importjournal.go", "Registry.SwapForImport", "key-site", "key:RecordKey", "ce455c5e25b3534423b4a7113c8429ce8f57057b04a298abe8f8ca839ccd0162"},
+ // Task 3, FPR-C01: the forward refusal first; the same record path literal.
+ {"cli.go", "runRoute", "key-site", "lit:instances", "2c95f72274284129671cf93653341c33aed1f9b826b6995b0ba7dacbf9b24ac8"},
}
for _, r := range repins {
found := false