carlos / platform Public

Fleet public routes Task 10: the forward phase of the hub's instance pass (dormant)

provision.Reconcile gains a forward phase (internal/provision/forward.go),
run before the instance phase lists and mints. On the hub (the new
ReconcileConfig.FleetOwners, which nothing sets until Task 12) the scan
keeps the fleet-placed records it skips at the fleet boundary, a
trash-only prefetch reads their apps' markers (never manifest, seed or
policy), and each record is decided by decideForward: mint for the
fleet owner's record, refuse (logged once per host per pass) a replica,
a pool, an unknown fleet or an account that does not own the fleet,
keep on an unreadable marker, a trashed production app or a disputed
host, retire a removable trashed app. PutForward never overwrites
another row: a held host is logged once per pass (a plain line; no
throttled report exists, preflight 4.4). Retirement only on a whole
pass, re-confirmed against the bucket over a record view snapshot. Off
the hub every forward row is retired on a whole pass; claims on, the
phase does nothing and logs once per pass.

The instance pass's retirable and retireAbortedSeedRow exclude forward
rows, and its mint loop leaves a host a forward row holds.

Spec: §4.3 records the plain held-host line, the wide collision rule and
the refusal retirements; §4.6 gains the platform-to-fleet two-pass row
(preflight 4.7); §7 records Task 10's card. Reconcile re-pinned in
fleetPublicRoutesWriteCensusInventory (same kinds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev e50ffe0d7a1baeed1a3a04ea1a774a24d5c1b3b9 parent 9f877cf
7 files changed, +1,287 −11
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +48 −5
  • internal/provision/fleet_public_routes_census_test.go +15 −0
  • internal/provision/forward.go +293 −0
  • internal/provision/forward_parity_test.go +117 −0
  • internal/provision/forward_test.go +704 −0
  • internal/provision/reconcile.go +104 −3
  • internal/provision/seedreconcile.go +6 −3

Intent

Human

<task-notification> <task-id>a37f12949b7b1e734</task-id> <tool-use-id>toolu_018hjAKaCcEbbfd5r2JhK4wL</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a37f12949b7b1e734.output</output-file> <status>completed</status> <summary>Agent "Implement Task 9: fleet-create barrier" 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 one commit, not pushed. **Commit:** 9f877cfc "Fleet public routes Task 9 fix round 2: the barrier judges two-segment channels and skips release identities by release's own rules" (on top of 42337eb6). **What changed:** - The barrier no longer skips channel names with a slash. It now uses release's own channel check (`release.ValidChannel`), so two-segment channels like `canary/paul` are judged like any other. - Release identity files (`control/system/router/releases/&lt;tag&gt;.json`) sit under the same listing. They are recognised by release's own key rule (`release.IdentityKey`) and skipped without being read, so a fleet create still costs one read per channel, not one per release. - Objects under that prefix whose names aren't valid channels are skipped too, since no box can follow them. - Each channel pointer is judged as before: below the floor or unparseable without the override gives 409 FPR-C06, unreadable gives 503 FPR-C07, and a pointer published with the override passes. **Tests:** - New cases: `canary/paul` below the floor and unparseable are both refused with C06 naming the channel; with the override the create goes through; with unreadable bytes it gets C07. - A separate case puts a real signed release identity, the `stable` pointer and an invalid three-segment object under the prefix, checks the listing returns them, and the create succeeds. - Failing first: against 42337eb6 the three refusal cases created the fleet. The override and identity cases already passed there, because the old filter skipped those keys anyway; they are covered by mutation instead. - Three mutations, all caught: putting the slash filter back, dropping the identity skip, and dropping the channel-name check. - Re-runs all pass: the console fleet, floor, door and service tests, the interleavings under `-race`, the copy gate, `TestPlan9B8RecordWriteCensus`, build, vet, gofmt and the darwin, windows and linux-arm64 cross-builds. - `make census-card` shows no unit and the seal (`78b7e7e3...`) is unchanged. **Spec:** §9 now states the channel rule and why identities are skipped; §7 records the fix round. **Open question for the reviewer:** a pointer published on purpose for a channel named `releases/&lt;tag&gt;` would overwrite that release's identity file, and the barrier would skip it. No door publishes such a channel today, since the update and rollback doors only accept canary and stable. Closing that gap would mean reading every identity on each fleet create, one read per release, so I left it. The fix 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-9-report.md`.</result> <usage><subagent_tokens>268109</subagent_tokens><tool_uses>12</tool_uses><duration_ms>411922</duration_ms></usage> </task-notification>

Human

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

Attributed to this commit: 23.6 g CO₂e (3,011,381 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 3bc8676e8..fc7edd2d4 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
@@ -368,14 +368,28 @@ The cost is the audit of every reader (§4.15).
row is kept as it is, nothing is minted;
- **retire**: `removable` is true.
+ As built (Task 10): every refusal (replica, pool, unknown fleet, an
+ account that does not own the fleet) is logged once per host per pass,
+ and an existing forward row of a refused record is retired on a whole
+ pass, as if the record were gone. The collision is read widely: a host
+ that any other usable record in the listing also names (in scope, on
+ another fleet, or in another platform region), or whose record exists
+ but could not be used (`protect`), is disputed. A disputed host is
+ "keep": no forward row is minted and an existing one is left as it is
+ (uncertainty keeps). "Given neither" applies to the forward row only;
+ the in-scope record's own instance handling is the instance pass's,
+ unchanged, and while a forward row holds its host the instance pass
+ leaves the host alone and logs it.
+
Instance moves refuse fleet records (`internal/console/apiinstancemove.go:91`),
so no move is in flight.
4. **Write.** `PutForward` for each mint. `ErrHostHeld` (any non-forward
row at the host, a hand row, a legacy placed row, another account's
- row) leaves that row exactly as it is and is reported: one log line per
- host per pass through the provision pass's existing throttled report,
- plus a REASON on `instances list` (copy review) **(R1-7, ruling: no
- conversion)**.
+ row) leaves that row exactly as it is and is reported: one plain log
+ line per host per pass (the provision pass has no throttled report;
+ preflight 4.4: none is added), plus a REASON on `instances list` (copy
+ review) **(R1-7, ruling: no conversion)**. A forward row already
+ current (inert, the declared columns equal) is not written again.
5. **Retire.** Only on a pass where nothing failed to read and the scan
was whole, under the instance pass's rules (`reconcile.go:1968-2044`):
over a record view snapshot, every removal is decided again against the
@@ -546,6 +560,7 @@ by up to one bindings pass (about 5.5 minutes). 1b owns this.
| app trashed, marker read, not production | retired (`removable`), confirmed with a fresh-store read |
| app trashed but flagged production, or marker unreadable | kept; nothing minted (`declineMint` without `removable`) |
| app placed back on the platform | retired; the instance pass mints the real row afterwards in the same pass |
+| app placed from the platform onto a fleet while the hub held its instance row | two passes (preflight 4.7): pass 1 finds the instance row, leaves it and logs the host; the instance pass then retires that row as record gone; pass 2 mints the forward row. Seconds apart on the change index, the host unreachable in between |
| app placed on another fleet of the same account | rewritten by `PutForward`, `FleetBox` cleared |
| fleet's owner changes, or the fleet row goes | the edge stops serving on its next reload; the pass retires |
| every box of the fleet detached | kept; 503 `fleet unreachable` with `Retry-After` |
@@ -985,6 +1000,31 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
prefetch, `retirable` guard); the forward phase's own helpers (N), named
by the plan; `ReconcileConfig` (the `FleetOwners` field; envelope unless
a site).
+
+ Task 10's card, reconciled with this list. `Reconcile`: `body`, read
+ sites unchanged (174): the scan's collection, the trash-only prefetch,
+ the phase call, the instance loop's skip of a host a forward row holds
+ and the `retirable` guard read only records, local maps and
+ `Route.IsForward()` (a method call, not a field read). `ReconcileConfig`
+ (the `FleetOwners` field) has no read site and moves only the
+ `internal/provision` envelope. The phase's helpers are in a new file,
+ `internal/provision/forward.go`, not in `reconcile.go`; the four with
+ read sites are N on the card: `forwardCurrent` (`+registry:Account`,
+ `App`, `Channel`, `Provisioned`, `RateLimit`, `Region`, `Slug`,
+ `Status`, each x2: the existing row against the wanted one),
+ `forwardPhase.mint` (`+registry:Account`, `+registry:App`,
+ `+registry:Kind`, `+whole:Route` x4: the held-host line names the
+ holding row), `forwardPhase.run` (`+registry:Host`, `+whole:Route` x7:
+ the pass's own `reg.List`) and `forwardView.retirements`
+ (`+registry:Host` x5, `+whole:Route`). `forwardRowFor`,
+ `decideForward`, `forwardView.decide`, `forwardPhase.held` and the
+ `forwardDecision` constants have no read site. A difference from the
+ list above, recorded here: `internal/provision/seedreconcile.go`
+ `retireAbortedSeedRow` (`body`, read sites unchanged, 15) gains
+ `rt.IsForward()` in its guard (Task 7's carry: a forward row is never
+ handed to its retirement, whose ClaimRetire hook would not refuse one as
+ `reg.Delete` does). All of these are the agent's own pass, reading its
+ own registry rows; none is a root read and none adds a bucket write.
- `internal/domains/reconcile.go`: `Reconcile` (trash-loop skip).
- `internal/domains/aliases.go`: `ReconcileAliasesReport` (no wildcard
parent for a refused primary; Task 6 fix round 2, card under
@@ -1250,7 +1290,10 @@ 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),
and its fix round 1 re-pins `runRoute` again and `runRouteHibernate`
-(key-site, `key:SidecarManifestKey`, unchanged: the write-race mapping); Task 10 `reconcile.go` `Reconcile`;
+(key-site, `key:SidecarManifestKey`, unchanged: the write-race mapping); Task 10 `reconcile.go` `Reconcile`
+(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`.
diff --git a/internal/provision/fleet_public_routes_census_test.go b/internal/provision/fleet_public_routes_census_test.go
index 80c655f18..a52c0f438 100644
--- a/internal/provision/fleet_public_routes_census_test.go
+++ b/internal/provision/fleet_public_routes_census_test.go
@@ -33,6 +33,19 @@ package provision
// error goes through refuseForwardWrite (FPR-C01 when a forward row took
// the host after the read). The sidecar manifest key it names is
// unchanged.
+//
+// Task 10, one re-pin, no new unit:
+// - internal/provision/reconcile.go Reconcile (key-site): the forward
+// phase (forward.go). On the hub (FleetOwners set) the scan keeps the
+// fleet-placed records it skips at the fleet boundary and counts the
+// records naming each host; a trash-only prefetch reads those apps'
+// markers into the same tombs map; the phase runs before the instance
+// phase lists and mints, and over a record view snapshot re-walks the
+// bucket through the same scan (freshStore) before it retires. The
+// instance loop leaves a host a forward row holds; retirable excludes
+// forward rows. No new bucket write and no new record key: the same
+// ParseRecordKey, RecordKey and instances literal, read as before; the
+// phase writes only the registry (PutForward, DeleteForward).
func fleetPublicRoutesWriteCensusInventory() []censusEntry {
entries := append([]censusEntry(nil), rootfsFleetFollowupsWriteCensusInventory()...)
repins := []censusEntry{
@@ -42,6 +55,8 @@ func fleetPublicRoutesWriteCensusInventory() []censusEntry {
{"cli.go", "runRoute", "key-site", "lit:instances", "1dbcc1f1b43bb4b38d5095de12b72f65e07e1d1ac2cc5035291bced93807c910"},
// Task 3, C01 fix round 1: the write-race mapping; the same manifest key.
{"cli.go", "runRouteHibernate", "key-site", "key:SidecarManifestKey", "51c9d6fada4fccba3ea62e8df01444cc2945442f298dccb3e805557567b6c820"},
+ // Task 10: the forward phase; the same record keys, no bucket write.
+ {"internal/provision/reconcile.go", "Reconcile", "key-site", "key:ParseRecordKey,key:RecordKey,lit:instances", "0f3d6bcf7f4edd1811c050581981aaa4d746a89c04e2349f999a49f016514004"},
}
for _, r := range repins {
found := false
diff --git a/internal/provision/forward.go b/internal/provision/forward.go
new file mode 100644
index 000000000..e3e17c176
--- /dev/null
+++ b/internal/provision/forward.go
@@ -0,0 +1,293 @@
+package provision
+
+// The forward phase of the hub's instance pass (fleet public routes spec
+// §4.3, docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md).
+// On the hub it mints a forward row for each fleet-placed record whose
+// account owns its fleet, keeps one it cannot judge, and retires one the
+// bucket or the owner rule no longer vouches for. On any other box it
+// retires every forward row it holds. It writes and deletes forward rows
+// only, through registry.PutForward and registry.DeleteForward; every other
+// row at a host is left exactly as it is and the host is reported.
+
+import (
+ "errors"
+ "fmt"
+ "log"
+ "slices"
+
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+// forwardRowFor is the forward row a fleet-placed record describes: the
+// declared columns of spec §4.2 and nothing else. CreatedAt is PutForward's
+// (kept from the existing row, else now), FleetBox the bindings pass's, and
+// every forbidden column is zero, so the row is InertForward by construction.
+func forwardRowFor(rec Record) registry.Route {
+ return registry.Route{
+ Host: rec.Host,
+ Kind: registry.KindForward,
+ Slug: rec.Slug,
+ App: rec.App,
+ Account: rec.Account,
+ Region: rec.Region,
+ Channel: rec.Channel,
+ RateLimit: rec.RateLimitColumn(),
+ Status: "ready",
+ Provisioned: true,
+ }
+}
+
+// forwardCurrent reports whether existing already is want: an inert forward
+// row with want's declared columns. Such a row is not written again, so a
+// pass with nothing changing writes nothing (and wakes no registry watcher).
+func forwardCurrent(existing, want registry.Route) bool {
+ return existing.InertForward() &&
+ existing.Status == want.Status &&
+ existing.Provisioned == want.Provisioned &&
+ existing.Slug == want.Slug &&
+ existing.App == want.App &&
+ existing.Account == want.Account &&
+ existing.Region == want.Region &&
+ existing.Channel == want.Channel &&
+ existing.RateLimit == want.RateLimit
+}
+
+// forwardDecision is step 3's answer for one fleet-placed record.
+type forwardDecision int
+
+const (
+ // forwardMint: PutForward the record's row (step 4).
+ forwardMint forwardDecision = iota + 1
+ // forwardKeep: mint nothing, and leave an existing forward row at the
+ // host as it is. The pass cannot judge the host: the app's trash marker
+ // would not read, the app is trashed but flagged production, or another
+ // record names the host too.
+ forwardKeep
+ // forwardRetire: the app is in the trash and removable (marker read,
+ // production clear); an existing row goes on a whole pass (step 5).
+ forwardRetire
+ // forwardRefuse: the record gives no forward row (a replica, a pool, an
+ // unknown fleet, an account that does not own the fleet). An existing
+ // row goes on a whole pass, as if the record were gone.
+ forwardRefuse
+)
+
+// decideForward is spec §4.3 step 3 for one record the scan kept (fleet
+// placed, skipped only at the fleet boundary). owners maps each fleet in
+// the hub's fleets table to its owning account. disputed holds the hosts
+// the pass cannot give a forward row to: one another record also names (an
+// in-scope record, the collision of step 3, or any other record in the
+// listing), or one whose record exists but could not be used (protect).
+// trash is the instance pass's own answer for the record's app (trashFor).
+// The string is the reason, for the log line.
+//
+// The refusals come first and mirror edge.FleetServeEligible's forward arm
+// on the hub: a fleet in owners, a non-empty raw Account equal to the
+// owner. A row this decision mints is one the hub's edge serves
+// (TestForwardPhaseMintsOnlyRowsTheHubEdgeServes).
+func decideForward(rec Record, owners map[string]string, disputed map[string]bool, trash trashState) (forwardDecision, string) {
+ fleet, placed := registry.FleetPlacement(rec.Region)
+ switch {
+ case !placed:
+ return forwardRefuse, fmt.Sprintf("region %q is not a fleet placement", rec.Region)
+ case rec.Role == "replica":
+ return forwardRefuse, "a replica record is never forwarded"
+ case rec.Pool != "":
+ return forwardRefuse, fmt.Sprintf("the record names pool %q, which has no meaning on a fleet", rec.Pool)
+ }
+ owner, known := owners[fleet]
+ switch {
+ case !known:
+ return forwardRefuse, fmt.Sprintf("fleet %q is not in this hub's fleets table", fleet)
+ case rec.Account == "" || rec.Account != owner:
+ return forwardRefuse, fmt.Sprintf("account %q does not own fleet %q", rec.Account, fleet)
+ case disputed[rec.Host]:
+ return forwardKeep, "another record names this host"
+ case trash.removable:
+ return forwardRetire, "app in the trash"
+ case trash.declineMint:
+ return forwardKeep, "the app's trash marker would not read, or the app is in the trash and flagged production"
+ }
+ return forwardMint, ""
+}
+
+// forwardView is what one record scan says to the forward phase: the kept
+// records by host, the disputed hosts, and the trash lookup over the same
+// store.
+type forwardView struct {
+ fleet map[string]Record
+ disputed map[string]bool
+ trashFor func(acct, app string) trashState
+}
+
+func (v forwardView) decide(rec Record, owners map[string]string) (forwardDecision, string) {
+ return decideForward(rec, owners, v.disputed, v.trashFor(rec.Account, rec.App))
+}
+
+// retirements is step 5's list over rows: each forward row that goes, with
+// its reason. On a box that is not the hub, every one. On the hub, a row
+// whose host no kept record names (the record is gone, or no longer fleet
+// placed), and a row whose record's decision is retire or refuse; never a
+// disputed host's row, nor one whose decision is keep or mint.
+func (v forwardView) retirements(rows []registry.Route, hub bool, owners map[string]string) map[string]string {
+ out := map[string]string{}
+ for _, rt := range rows {
+ if !rt.IsForward() {
+ continue
+ }
+ if !hub {
+ out[rt.Host] = "this box is not the hub"
+ continue
+ }
+ if v.disputed[rt.Host] {
+ continue
+ }
+ rec, ok := v.fleet[rt.Host]
+ if !ok {
+ out[rt.Host] = "record gone, or no longer placed on a fleet"
+ continue
+ }
+ switch d, why := v.decide(rec, owners); d {
+ case forwardRetire, forwardRefuse:
+ out[rt.Host] = why
+ }
+ }
+ return out
+}
+
+// forwardPhase is one pass's forward phase (spec §4.3 steps 2 to 5).
+type forwardPhase struct {
+ cfg ReconcileConfig
+ reg *registry.Registry
+ view forwardView
+ // whole: the scan was whole and nothing failed to read, so step 5 may
+ // retire.
+ whole bool
+ // confirm, when the pass reads a record view snapshot, walks the bucket
+ // itself and returns its view, trash lookup over the bucket included;
+ // false when that walk could not be read cleanly. Nil over the bucket.
+ confirm func() (forwardView, bool)
+}
+
+// run does steps 2 to 5. The hub is a box whose FleetOwners is set.
+func (p *forwardPhase) run() {
+ hub := p.cfg.FleetOwners != nil
+ if p.cfg.ClaimEnabled {
+ if hub {
+ log.Printf("provision: forward phase off: host claims are on; no forward row is minted or retired")
+ }
+ return
+ }
+ var owners map[string]string
+ if hub {
+ o, err := p.cfg.FleetOwners()
+ if err != nil {
+ log.Printf("provision: forward phase skipped this pass: the hub's fleets could not be read: %v", err)
+ return
+ }
+ owners = o
+ }
+ rows, err := p.reg.List()
+ if err != nil {
+ log.Printf("provision: forward phase skipped this pass: list routes: %v", err)
+ return
+ }
+ byHost := make(map[string]registry.Route, len(rows))
+ for _, rt := range rows {
+ byHost[rt.Host] = rt
+ }
+
+ if hub {
+ hosts := make([]string, 0, len(p.view.fleet))
+ for h := range p.view.fleet {
+ hosts = append(hosts, h)
+ }
+ slices.Sort(hosts)
+ for _, h := range hosts {
+ rec := p.view.fleet[h]
+ switch d, why := p.view.decide(rec, owners); d {
+ case forwardMint:
+ p.mint(rec, byHost)
+ case forwardKeep:
+ log.Printf("provision: forward %s: kept as it is, nothing minted: %s", h, why)
+ case forwardRefuse:
+ log.Printf("provision: forward %s: refused: %s", h, why)
+ }
+ // forwardRetire is step 5's, logged there.
+ }
+ }
+
+ if !p.whole {
+ return
+ }
+ gone := p.view.retirements(rows, hub, owners)
+ if len(gone) == 0 {
+ return
+ }
+ // Over a record view snapshot, a removal the snapshot decides is decided
+ // again from the bucket's own walk and a fresh-store trash read (S3
+ // change-index design §4.4): a snapshot's absence is not the bucket's.
+ // Off the hub nothing here depends on a record, so nothing is re-read.
+ if hub && p.confirm != nil {
+ live, ok := p.confirm()
+ if !ok {
+ log.Printf("provision: not retiring any forward row this pass: the record view would retire one, and the bucket's own walk could not be read cleanly")
+ return
+ }
+ gone = live.retirements(rows, hub, owners)
+ }
+ hosts := make([]string, 0, len(gone))
+ for h := range gone {
+ hosts = append(hosts, h)
+ }
+ slices.Sort(hosts)
+ for _, h := range hosts {
+ if p.cfg.DryRun {
+ log.Printf("provision: dry-run: would retire forward row %s (%s)", h, gone[h])
+ continue
+ }
+ deleted, err := p.reg.DeleteForward(h)
+ switch {
+ case err != nil:
+ log.Printf("provision: retire forward row %s: %v", h, err)
+ case deleted:
+ log.Printf("provision: retired forward row %s (%s)", h, gone[h])
+ }
+ }
+}
+
+// mint is step 4 for one record: PutForward, unless the row is already
+// current. A row of another kind at the host (a hand row, a legacy placed
+// row, another app's row) is never converted, overwritten or deleted: it
+// stays exactly as it is and the host is logged, once per host per pass
+// (spec §4.3 step 4, §4.7; preflight 4.4: a plain line, no throttle).
+func (p *forwardPhase) mint(rec Record, byHost map[string]registry.Route) {
+ want := forwardRowFor(rec)
+ existing, ok := byHost[rec.Host]
+ switch {
+ case ok && !existing.IsForward():
+ p.held(rec.Host, fmt.Sprintf("kind %q, app %q, account %q", existing.Kind, existing.App, existing.Account))
+ return
+ case ok && forwardCurrent(existing, want):
+ return
+ }
+ if p.cfg.DryRun {
+ log.Printf("provision: dry-run: would write forward row %s (app %q acct %q region %q)", rec.Host, rec.App, rec.Account, rec.Region)
+ return
+ }
+ err := p.reg.PutForward(want)
+ switch {
+ case errors.Is(err, registry.ErrHostHeld):
+ p.held(rec.Host, "taken since this pass listed the routes")
+ case err != nil:
+ log.Printf("provision: forward %s: write: %v", rec.Host, err)
+ case ok:
+ log.Printf("provision: forward %s: rewritten (app %q acct %q region %q)", rec.Host, rec.App, rec.Account, rec.Region)
+ default:
+ log.Printf("provision: forward %s: minted (app %q acct %q region %q)", rec.Host, rec.App, rec.Account, rec.Region)
+ }
+}
+
+func (p *forwardPhase) held(host, what string) {
+ log.Printf("provision: forward %s: not minted: another row holds the host (%s); leaving it as it is", host, what)
+}
diff --git a/internal/provision/forward_parity_test.go b/internal/provision/forward_parity_test.go
new file mode 100644
index 000000000..eac3794c1
--- /dev/null
+++ b/internal/provision/forward_parity_test.go
@@ -0,0 +1,117 @@
+package provision_test
+
+import (
+ "context"
+ "fmt"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/domains"
+ "github.com/carlosframework/platform/internal/edge"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// The forward phase never mints a row the hub's edge would refuse (spec
+// §4.3 and §4.4: the writer and the edge agree). Run through the exported
+// pass, then asked of the edge's one refusal decision, edge.FleetArmVerdict,
+// on the hub (hub and tunnels both armed). For each owner and fleet case
+// the two agree both ways: a row is minted exactly when the edge would serve
+// it; the phase's own extra refusals (a replica, a pool) only ever mint less.
+func TestForwardPhaseMintsOnlyRowsTheHubEdgeServes(t *testing.T) {
+ ctx := context.Background()
+ s := release.NewDirStore(t.TempDir())
+ var accts []string
+ for _, id := range []int64{7, 8} {
+ sqid := domains.Sqid(id)
+ body := fmt.Sprintf(`{"id":%d,"sqid":%q,"name":"Account %d","created_at":"2026-08-02T09:00:00Z"}`, id, sqid, id)
+ if _, err := s.Put(ctx, "accounts/"+sqid+"/account.json", []byte(body), ""); err != nil {
+ t.Fatal(err)
+ }
+ accts = append(accts, sqid)
+ }
+ bah, baj := accts[0], accts[1]
+ if bah != "bah" || baj != "baj" {
+ t.Fatalf("fixture: sqids %q %q, want bah and baj", bah, baj)
+ }
+ owners := map[string]string{"home": bah, "away": baj, "orphan": ""}
+
+ type tc struct {
+ acct, region, role, pool string
+ ownerCase bool // the edge's rule alone decides: agreement both ways
+ }
+ var cases []tc
+ for _, acct := range []string{bah, baj} {
+ for _, f := range []string{"home", "away", "orphan", "nowhere"} {
+ cases = append(cases, tc{acct: acct, region: "fleet/" + f, ownerCase: true})
+ }
+ }
+ cases = append(cases,
+ tc{acct: bah, region: "fleet/home", role: "replica"},
+ tc{acct: bah, region: "fleet/home", pool: "p1"})
+ recs := map[string]tc{}
+ for i, c := range cases {
+ host := fmt.Sprintf("h%d.example.com", i)
+ rec := provision.Record{Schema: 1, Host: host, Slug: fmt.Sprintf("h%d", i), App: "shop",
+ Account: c.acct, Region: c.region, Role: c.role, Pool: c.pool, Channel: "stable", CreatedAt: time.Now()}
+ if err := provision.CreateRecord(ctx, s, rec); err != nil {
+ t.Fatalf("create %s: %v", host, err)
+ }
+ recs[host] = c
+ }
+
+ reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ cfg := provision.ReconcileConfig{Region: "uk", DataDir: "/data",
+ FleetOwners: func() (map[string]string, error) { return owners, nil }}
+ if err := provision.Reconcile(ctx, s, reg, cfg); err != nil {
+ t.Fatal(err)
+ }
+ rows, err := reg.List()
+ if err != nil {
+ t.Fatal(err)
+ }
+ minted := map[string]registry.Route{}
+ for _, rt := range rows {
+ if rt.IsForward() {
+ minted[rt.Host] = rt
+ }
+ }
+ verdict := edge.FleetArmVerdict(rows, owners, true, true)
+ for host, why := range verdict.Refused {
+ if _, ok := minted[host]; ok {
+ t.Errorf("the phase minted %s and the hub's edge refuses it: %s", host, why)
+ }
+ }
+ served := 0
+ for host, c := range recs {
+ rt, isMinted := minted[host]
+ if isMinted {
+ served++
+ if !rt.InertForward() {
+ t.Errorf("%s: minted a row that is not inert: %+v", host, rt)
+ }
+ }
+ if !c.ownerCase {
+ if isMinted {
+ t.Errorf("%s (role %q pool %q): minted", host, c.role, c.pool)
+ }
+ continue
+ }
+ // What the edge says of the row this record would give.
+ would := registry.Route{Host: host, Kind: registry.KindForward, App: "shop", Account: c.acct,
+ Region: c.region, Channel: "stable", Status: "ready", Provisioned: true}
+ ok, why := edge.FleetServeEligible(would, true, owners)
+ if ok != isMinted {
+ t.Errorf("%s (account %s, %s): minted %v, the edge eligible %v (%s)", host, c.acct, c.region, isMinted, ok, why)
+ }
+ }
+ if served != 2 || !strings.HasPrefix(minted["h0.example.com"].Region, "fleet/home") {
+ t.Errorf("minted %d rows (%v), want 2: bah on home and baj on away", served, minted)
+ }
+}
diff --git a/internal/provision/forward_test.go b/internal/provision/forward_test.go
new file mode 100644
index 000000000..4dd9b168b
--- /dev/null
+++ b/internal/provision/forward_test.go
@@ -0,0 +1,704 @@
+package provision
+
+import (
+ "bytes"
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "log"
+ "os"
+ "reflect"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/domains"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/seeds"
+)
+
+// The forward phase of the hub's instance pass (fleet public routes spec
+// §4.3, Task 10). Fixtures: accounts bah (id 7, owner of fleet home) and baj
+// (id 8, owner of fleet away), real sqids from domains.Sqid, so every record
+// below is one ParseRecordKey accepts and the scan really reads; the hub's
+// own region is uk.
+
+const (
+ fwdOwnerID int64 = 7
+ fwdSecondID int64 = 8
+)
+
+// fwdSetup writes both accounts and an app manifest for each app the tests
+// use, and asserts the sqids are the ones the controller bound (bah, baj).
+func fwdSetup(t *testing.T, s release.Store) (bah, baj string) {
+ t.Helper()
+ bah = writeAccountManifest(t, s, fwdOwnerID, "Shop owner")
+ baj = writeAccountManifest(t, s, fwdSecondID, "Second account")
+ if bah != "bah" || baj != "baj" || bah != domains.Sqid(fwdOwnerID) {
+ t.Fatalf("fixture: sqids are %q and %q, want bah and baj", bah, baj)
+ }
+ for _, acct := range []string{bah, baj} {
+ for _, app := range []string{"shop", "shop2", "x", "blog", "prod", "new"} {
+ if err := PutManifest(ctx, s, acct, app, Manifest{Schema: 1, App: app, Domain: "example.com", Seed: []string{"seed"}}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+ return bah, baj
+}
+
+func fwdRecord(acct, app, host, region string) Record {
+ return Record{Schema: 1, Host: host, Slug: strings.SplitN(host, ".", 2)[0], App: app,
+ Account: acct, Region: region, Channel: "stable", CreatedAt: time.Now()}
+}
+
+func mustCreate(t *testing.T, s release.Store, recs ...Record) {
+ t.Helper()
+ for _, rec := range recs {
+ if err := CreateRecord(ctx, s, rec); err != nil {
+ t.Fatalf("create %s: %v", rec.Host, err)
+ }
+ }
+}
+
+// hubCfg is a hub's pass: region uk, the shared pool, owners as given.
+func hubCfg(owners map[string]string) ReconcileConfig {
+ return ReconcileConfig{Region: "uk", DataDir: "/data",
+ FleetOwners: func() (map[string]string, error) { return owners, nil }}
+}
+
+func mustPass(t *testing.T, s release.Store, reg *registry.Registry, cfg ReconcileConfig) {
+ t.Helper()
+ if err := Reconcile(ctx, s, reg, cfg); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func getRow(t *testing.T, reg *registry.Registry, host string) *registry.Route {
+ t.Helper()
+ rt, err := reg.Get(host)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return rt
+}
+
+func wantNoRow(t *testing.T, reg *registry.Registry, host, why string) {
+ t.Helper()
+ if rt := getRow(t, reg, host); rt != nil {
+ t.Errorf("%s: a row at %s: %+v", why, host, *rt)
+ }
+}
+
+func wantForward(t *testing.T, reg *registry.Registry, rec Record) registry.Route {
+ t.Helper()
+ rt := getRow(t, reg, rec.Host)
+ if rt == nil {
+ t.Fatalf("no forward row at %s", rec.Host)
+ }
+ got := *rt
+ got.CreatedAt = 0
+ got.FleetBox = ""
+ if want := forwardRowFor(rec); !reflect.DeepEqual(got, want) {
+ t.Fatalf("forward row at %s:\n got %+v\nwant %+v", rec.Host, got, want)
+ }
+ return *rt
+}
+
+// fwdLog sends the standard logger to a buffer for the test.
+func fwdLog(t *testing.T) *lockedBuf {
+ t.Helper()
+ b := &lockedBuf{}
+ log.SetOutput(b)
+ t.Cleanup(func() { log.SetOutput(os.Stderr) })
+ return b
+}
+
+type lockedBuf struct {
+ mu sync.Mutex
+ b bytes.Buffer
+}
+
+func (l *lockedBuf) Write(p []byte) (int, error) {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ return l.b.Write(p)
+}
+
+// take returns what was logged since the last take and empties the buffer.
+func (l *lockedBuf) take() string {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ s := l.b.String()
+ l.b.Reset()
+ return s
+}
+
+// failGetStore fails every read of one key, the way a half-broken bucket
+// would; everything else reads normally.
+type failGetStore struct {
+ release.Store
+ key string
+}
+
+func (f failGetStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ if key == f.key {
+ return nil, "", errors.New("injected read failure")
+ }
+ return f.Store.Get(ctx, key)
+}
+
+// Step 3's owner rule: a row only for a record of the fleet's owner, on a
+// fleet the hub knows, that is not a replica and names no pool, whose host no
+// other record names. Every refusal is logged once per host per pass (R3
+// P2-3: Task 13's witness observes the owner-mismatch line).
+func TestForwardPhaseMintsForTheFleetOwnerOnly(t *testing.T) {
+ s := dirStore(t)
+ bah, baj := fwdSetup(t, s)
+ shop := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ away := fwdRecord(bah, "shop2", "shop2.example.com", "fleet/away")
+ nowhere := fwdRecord(bah, "x", "x.example.com", "fleet/nowhere")
+ replica := fwdRecord(bah, "shop", "replica.example.com", "fleet/home")
+ replica.Role = "replica"
+ pooled := fwdRecord(bah, "shop", "pool.example.com", "fleet/home")
+ pooled.Pool = "p1"
+ // A collision: the same host as an in-scope record of another app.
+ clashFleet := fwdRecord(bah, "shop", "clash.example.com", "fleet/home")
+ clashHere := fwdRecord(baj, "blog", "clash.example.com", "uk")
+ mustCreate(t, s, shop, away, nowhere, replica, pooled, clashFleet, clashHere)
+
+ reg := regWith(t)
+ logs := fwdLog(t)
+ cfg := hubCfg(map[string]string{"home": bah, "away": baj})
+ for pass := 1; pass <= 2; pass++ {
+ mustPass(t, s, reg, cfg)
+ out := logs.take()
+ wantForward(t, reg, shop)
+ // Minted on the first pass; a current row is not written again.
+ wrote := strings.Count(out, "provision: forward shop.example.com: minted") +
+ strings.Count(out, "provision: forward shop.example.com: rewritten")
+ if want := map[int]int{1: 1, 2: 0}[pass]; wrote != want {
+ t.Errorf("pass %d: the row was written %d times, want %d; log:\n%s", pass, wrote, want, out)
+ }
+ for _, c := range []struct{ host, line string }{
+ {away.Host, `provision: forward shop2.example.com: refused: account "bah" does not own fleet "away"`},
+ {nowhere.Host, `provision: forward x.example.com: refused: fleet "nowhere" is not in this hub's fleets table`},
+ {replica.Host, `provision: forward replica.example.com: refused: a replica record is never forwarded`},
+ {pooled.Host, `provision: forward pool.example.com: refused: the record names pool "p1"`},
+ {clashFleet.Host, `provision: forward clash.example.com: kept as it is, nothing minted: another record names this host`},
+ } {
+ if c.host != clashFleet.Host {
+ wantNoRow(t, reg, c.host, "pass "+fmt.Sprint(pass))
+ }
+ if n := strings.Count(out, c.line); n != 1 {
+ t.Errorf("pass %d: %q logged %d times, want once; log:\n%s", pass, c.line, n, out)
+ }
+ }
+ // The collision gives the fleet record nothing; the in-scope record
+ // keeps the instance pass's own handling, unchanged.
+ if rt := getRow(t, reg, clashHere.Host); rt == nil || rt.IsForward() || rt.Account != baj {
+ t.Errorf("pass %d: the in-scope record's row at the colliding host = %+v, want its instance row", pass, rt)
+ }
+ }
+}
+
+// FleetOwners nil (not a hub): nothing minted, an existing forward row
+// retired on a whole pass. A read error from FleetOwners stops the phase
+// for the pass. Claims on: the phase does nothing and logs once.
+func TestForwardPhaseIsInertWithoutOwners(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ shop := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ mustCreate(t, s, shop)
+ old := forwardRowFor(fwdRecord(bah, "shop", "gone.example.com", "fleet/home"))
+
+ t.Run("not a hub", func(t *testing.T) {
+ reg := regWith(t)
+ if err := reg.PutForward(old); err != nil {
+ t.Fatal(err)
+ }
+ // A partial pass first: nothing retired.
+ mustPass(t, failGetStore{s, RecordKey(bah, "shop", shop.Host)}, reg, ReconcileConfig{Region: "uk", DataDir: "/data"})
+ if getRow(t, reg, old.Host) == nil {
+ t.Fatal("a partial pass retired a forward row")
+ }
+ mustPass(t, s, reg, ReconcileConfig{Region: "uk", DataDir: "/data"})
+ wantNoRow(t, reg, shop.Host, "not a hub")
+ wantNoRow(t, reg, old.Host, "a whole pass on a box that is not the hub")
+ })
+ t.Run("owners unreadable", func(t *testing.T) {
+ reg := regWith(t)
+ if err := reg.PutForward(old); err != nil {
+ t.Fatal(err)
+ }
+ logs := fwdLog(t)
+ cfg := ReconcileConfig{Region: "uk", DataDir: "/data",
+ FleetOwners: func() (map[string]string, error) { return nil, errors.New("fleets table locked") }}
+ mustPass(t, s, reg, cfg)
+ wantNoRow(t, reg, shop.Host, "owners unreadable")
+ if getRow(t, reg, old.Host) == nil {
+ t.Error("owners unreadable: a forward row was retired")
+ }
+ if !strings.Contains(logs.take(), "provision: forward phase skipped this pass: the hub's fleets could not be read: fleets table locked") {
+ t.Error("owners unreadable: not logged")
+ }
+ })
+ t.Run("claims on", func(t *testing.T) {
+ reg := regWith(t)
+ if err := reg.PutForward(old); err != nil {
+ t.Fatal(err)
+ }
+ logs := fwdLog(t)
+ cfg := hubCfg(map[string]string{"home": bah})
+ cfg.ClaimEnabled = true
+ cfg.ClaimRetire = func(context.Context, registry.Route) error { return nil }
+ for pass := 1; pass <= 2; pass++ {
+ mustPass(t, s, reg, cfg)
+ wantNoRow(t, reg, shop.Host, "claims on")
+ if getRow(t, reg, old.Host) == nil {
+ t.Fatal("claims on: a forward row was retired")
+ }
+ if n := strings.Count(logs.take(), "provision: forward phase off: host claims are on"); n != 1 {
+ t.Errorf("claims on, pass %d: logged %d times, want once", pass, n)
+ }
+ }
+ })
+}
+
+// Step 3's trash answers: removable retires, declineMint alone keeps an
+// existing row and mints nothing.
+func TestForwardPhaseTrashDecisions(t *testing.T) {
+ priv, pub := releaseKeys(t)
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ trashed := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ prod := fwdRecord(bah, "prod", "prod.example.com", "fleet/home")
+ blind := fwdRecord(bah, "blog", "blog.example.com", "fleet/home")
+ mustCreate(t, s, trashed, prod, blind)
+ reg := regWith(t)
+ cfg := hubCfg(map[string]string{"home": bah})
+ cfg.ReleasePub = pub
+ mustPass(t, s, reg, cfg)
+ for _, rec := range []Record{trashed, prod, blind} {
+ wantForward(t, reg, rec)
+ }
+
+ // The flag goes on first: SetProduction refuses a trashed app.
+ if err := release.SetProduction(ctx, s, priv, bah, "prod", true, "owner@example.com"); err != nil {
+ t.Fatal(err)
+ }
+ for _, app := range []string{"shop", "prod"} {
+ if err := release.TrashApp(ctx, s, bah, app, "owner@example.com", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ }
+ // blog's marker will not read; a new record for an app whose marker
+ // will not read either is never minted.
+ fresh := fwdRecord(bah, "new", "new.example.com", "fleet/home")
+ mustCreate(t, s, fresh)
+ broken := failGetStore{failGetStore{s, release.AppTombstoneKey(bah, "blog")}, release.AppTombstoneKey(bah, "new")}
+
+ for pass := 1; pass <= 2; pass++ {
+ mustPass(t, broken, reg, cfg)
+ wantNoRow(t, reg, trashed.Host, "trashed, production clear")
+ wantForward(t, reg, prod) // trashed but flagged production: kept
+ wantForward(t, reg, blind) // marker unreadable: kept
+ wantNoRow(t, reg, fresh.Host, "marker unreadable, new record")
+ }
+}
+
+// Step 5: no retirement unless the scan was whole and nothing failed to
+// read, and over a record view snapshot, only what the bucket confirms.
+func TestForwardPhaseRetiresOnlyOnAWholePass(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ v := staleView(t, s) // before any record: its snapshots lack every record below
+ shop := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ other := fwdRecord(bah, "blog", "blog.example.com", "fleet/home")
+ mustCreate(t, s, shop, other)
+ reg := regWith(t)
+ cfg := hubCfg(map[string]string{"home": bah})
+ mustPass(t, s, reg, cfg)
+ wantForward(t, reg, shop)
+ wantForward(t, reg, other)
+
+ // Over a snapshot missing both records while the bucket holds them: kept.
+ sn := completeSnapshot(t, v)
+ if recs, err := ListAllRecords(ctx, sn.Store(s)); err != nil || len(recs) != 0 {
+ t.Fatalf("fixture: the snapshot has records %v, %v; it should lack both", recs, err)
+ }
+ mustPass(t, sn.Store(s), reg, cfg)
+ wantForward(t, reg, shop)
+ wantForward(t, reg, other)
+
+ // The record goes while another will not read: kept.
+ if err := DeleteRecord(ctx, s, bah, "shop", shop.Host); err != nil {
+ t.Fatal(err)
+ }
+ mustPass(t, failGetStore{s, RecordKey(bah, "blog", other.Host)}, reg, cfg)
+ wantForward(t, reg, shop)
+
+ // The next whole pass, over the snapshot (the bucket confirms): retired.
+ mustPass(t, completeSnapshot(t, v).Store(s), reg, cfg)
+ wantNoRow(t, reg, shop.Host, "a whole pass after the record went")
+ wantForward(t, reg, other)
+}
+
+// Step 4: a non-forward row at the host stays exactly as it is, and the
+// host is reported once per pass.
+func TestForwardPhaseLeavesAHeldHostAndReportsIt(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ hand := registry.Route{Host: "shop.example.com", Kind: "instance", App: "shop", Account: bah,
+ Socket: "/run/carlos/hand.sock", Status: "ready"}
+ placed := registry.Route{Host: "shop2.example.com", Slug: "shop2", Kind: "instance", App: "shop2",
+ Account: bah, Region: "fleet/home", Channel: "stable", Socket: "/run/carlos/shop2.example.com.sock",
+ DBPath: "/data/shop2.example.com.db", Provisioned: true, Hibernate: true, Status: "ready"}
+ reg := regWith(t, hand, placed)
+ mustCreate(t, s,
+ fwdRecord(bah, "shop", hand.Host, "fleet/home"),
+ fwdRecord(bah, "shop2", placed.Host, "fleet/home"))
+ before, err := reg.List()
+ if err != nil {
+ t.Fatal(err)
+ }
+ logs := fwdLog(t)
+ cfg := hubCfg(map[string]string{"home": bah})
+ for pass := 1; pass <= 2; pass++ {
+ mustPass(t, s, reg, cfg)
+ out := logs.take()
+ for _, host := range []string{hand.Host, placed.Host} {
+ line := "provision: forward " + host + ": not minted: another row holds the host"
+ if n := strings.Count(out, line); n != 1 {
+ t.Errorf("pass %d: %q logged %d times, want once; log:\n%s", pass, line, n, out)
+ }
+ }
+ }
+ after, err := reg.List()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(before, after) {
+ t.Errorf("held rows changed:\nbefore %+v\nafter %+v", before, after)
+ }
+}
+
+// Spec §4.6 (preflight 1.13, 4.7): an app placed from the platform onto a
+// fleet while the hub held its instance row takes two passes. Pass 1: the
+// forward phase finds the instance row and reports the host; the instance
+// pass then retires that row as record gone. Pass 2 mints.
+func TestForwardPhasePlatformToFleetTakesTwoPasses(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ rec := fwdRecord(bah, "shop", "shop.example.com", "uk")
+ mustCreate(t, s, rec)
+ reg := regWith(t)
+ cfg := hubCfg(map[string]string{"home": bah})
+ mustPass(t, s, reg, cfg)
+ if rt := getRow(t, reg, rec.Host); rt == nil || rt.Kind != "instance" {
+ t.Fatalf("fixture: no instance row: %+v", rt)
+ }
+ if err := SetRecordRegion(ctx, s, bah, "shop", rec.Host, "fleet/home"); err != nil {
+ t.Fatal(err)
+ }
+ rec.Region = "fleet/home"
+
+ logs := fwdLog(t)
+ mustPass(t, s, reg, cfg)
+ wantNoRow(t, reg, rec.Host, "pass 1: the instance row retired, no forward row yet")
+ if n := strings.Count(logs.take(), "provision: forward shop.example.com: not minted: another row holds the host"); n != 1 {
+ t.Errorf("pass 1: held host logged %d times, want once", n)
+ }
+ mustPass(t, s, reg, cfg)
+ wantForward(t, reg, rec)
+}
+
+// §4.6's moves: fleet to fleet of the same account rewrites the row and
+// clears its binding; fleet to this box's region retires it and the instance
+// pass mints the real row in the same pass.
+func TestForwardPhaseMovesBetweenFleetsAndBack(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ rec := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ mustCreate(t, s, rec)
+ reg := regWith(t)
+ for _, f := range []string{"home", "away"} {
+ if _, err := reg.CreateFleet(registry.Fleet{Name: f, Account: bah}); err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.AddFleetBox(registry.FleetBox{Fleet: f, Label: "box-1", TokenHash: strings.Repeat("a", 64), Status: "active"}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ cfg := hubCfg(map[string]string{"home": bah, "away": bah})
+ mustPass(t, s, reg, cfg)
+ wantForward(t, reg, rec)
+ if ok, err := reg.SetFleetBoxIf(rec.Host, "home", "box-1"); err != nil || !ok {
+ t.Fatalf("fixture: binding not stamped: %v %v", ok, err)
+ }
+ if rt := getRow(t, reg, rec.Host); rt.FleetBox != "box-1" {
+ t.Fatalf("fixture: FleetBox = %q", rt.FleetBox)
+ }
+
+ if err := SetRecordRegion(ctx, s, bah, "shop", rec.Host, "fleet/away"); err != nil {
+ t.Fatal(err)
+ }
+ rec.Region = "fleet/away"
+ mustPass(t, s, reg, cfg)
+ if got := wantForward(t, reg, rec); got.FleetBox != "" {
+ t.Errorf("moved to fleet away: FleetBox = %q, want cleared", got.FleetBox)
+ }
+
+ if err := SetRecordRegion(ctx, s, bah, "shop", rec.Host, "uk"); err != nil {
+ t.Fatal(err)
+ }
+ mustPass(t, s, reg, cfg)
+ rt := getRow(t, reg, rec.Host)
+ if rt == nil || rt.IsForward() || rt.Kind != "instance" || rt.Region != "uk" {
+ t.Fatalf("back on the platform: row = %+v, want the instance row minted in the same pass", rt)
+ }
+}
+
+// §4.6: the fleet's owner changes, or the fleet row goes: the pass retires
+// the row (the edge has already stopped serving it).
+func TestForwardPhaseOwnerChangeRetires(t *testing.T) {
+ s := dirStore(t)
+ bah, baj := fwdSetup(t, s)
+ rec := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ mustCreate(t, s, rec)
+ for _, after := range []map[string]string{{"home": baj}, {"away": bah}} {
+ reg := regWith(t)
+ mustPass(t, s, reg, hubCfg(map[string]string{"home": bah}))
+ wantForward(t, reg, rec)
+ mustPass(t, s, reg, hubCfg(after))
+ wantNoRow(t, reg, rec.Host, fmt.Sprintf("owners now %v", after))
+ }
+}
+
+// The instance pass's retirable excludes forward rows (spec §4.3, the
+// sidecar rule). Witnessed where the instance pass would otherwise reach
+// one: a box whose region is the row's fleet, claims on (the forward phase
+// is off, so the row stands), with a ClaimRetire hook that records every
+// row the instance pass hands it; and a dry run, whose would-remove lines
+// name every row the instance pass judges retired.
+func TestInstancePassNeverRetiresForwardRows(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ row := forwardRowFor(fwdRecord(bah, "shop", "shop.example.com", "fleet/home"))
+
+ t.Run("claims on", func(t *testing.T) {
+ reg := regWith(t)
+ if err := reg.PutForward(row); err != nil {
+ t.Fatal(err)
+ }
+ var handed []string
+ cfg := ReconcileConfig{Region: "fleet/home", DataDir: "/data", ClaimEnabled: true,
+ ClaimRetire: func(_ context.Context, rt registry.Route) error {
+ handed = append(handed, rt.Host)
+ return nil
+ }}
+ mustPass(t, s, reg, cfg)
+ if len(handed) != 0 {
+ t.Errorf("the instance pass handed forward rows to its retirement: %v", handed)
+ }
+ if getRow(t, reg, row.Host) == nil {
+ t.Error("the forward row is gone")
+ }
+ })
+ t.Run("dry run", func(t *testing.T) {
+ reg := regWith(t)
+ if err := reg.PutForward(row); err != nil {
+ t.Fatal(err)
+ }
+ logs := fwdLog(t)
+ mustPass(t, s, reg, ReconcileConfig{Region: "fleet/home", DataDir: "/data", DryRun: true})
+ out := logs.take()
+ if strings.Contains(out, "would remove retired forward route") {
+ t.Errorf("the instance pass judged a forward row retired:\n%s", out)
+ }
+ if !strings.Contains(out, "provision: dry-run: would retire forward row shop.example.com") {
+ t.Errorf("the forward phase did not judge it (positive control):\n%s", out)
+ }
+ })
+}
+
+// The instance pass never writes over a forward row at an in-scope record's
+// host: a record moved from a fleet back to this box's region, on a pass
+// that is not whole, leaves the forward row as it is and mints nothing.
+func TestInstancePassLeavesAForwardRowAtItsHost(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ rec := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ other := fwdRecord(bah, "blog", "blog.example.com", "fleet/home")
+ mustCreate(t, s, rec, other)
+ reg := regWith(t)
+ cfg := hubCfg(map[string]string{"home": bah})
+ mustPass(t, s, reg, cfg)
+ before := wantForward(t, reg, rec)
+ if err := SetRecordRegion(ctx, s, bah, "shop", rec.Host, "uk"); err != nil {
+ t.Fatal(err)
+ }
+ logs := fwdLog(t)
+ mustPass(t, failGetStore{s, RecordKey(bah, "blog", other.Host)}, reg, cfg)
+ if got := getRow(t, reg, rec.Host); got == nil || *got != before {
+ t.Fatalf("a pass that was not whole changed the forward row: %+v", got)
+ }
+ if !strings.Contains(logs.take(), "provision: shop.example.com: a forward row holds the host; the forward phase retires it on a whole pass") {
+ t.Error("the instance pass did not say why it left the host")
+ }
+ mustPass(t, s, reg, cfg)
+ if rt := getRow(t, reg, rec.Host); rt == nil || rt.Kind != "instance" {
+ t.Fatalf("whole pass: row = %+v, want the instance row", rt)
+ }
+}
+
+// Task 7's carry: retireAbortedSeedRow never removes a forward row. Claims
+// on, so a removal would go to the ClaimRetire hook rather than to
+// reg.Delete (whose own refusal is the second guard).
+func TestRetireAbortedSeedRowLeavesAForwardRow(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ rec := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ rec.Seed = &SeedSource{ID: "seed-1", Kind: seeds.KindReplica}
+ row := forwardRowFor(rec)
+ reg := regWith(t)
+ if err := reg.PutForward(row); err != nil {
+ t.Fatal(err)
+ }
+ stored := *getRow(t, reg, row.Host)
+ var handed []string
+ cfg := ReconcileConfig{Region: "fleet/home", DataDir: "/data", ClaimEnabled: true,
+ ClaimRetire: func(_ context.Context, rt registry.Route) error {
+ handed = append(handed, rt.Host)
+ return nil
+ }}
+ retireAbortedSeedRow(ctx, reg, cfg, rec, stored)
+ if len(handed) != 0 {
+ t.Errorf("retireAbortedSeedRow handed a forward row to its retirement: %v", handed)
+ }
+ if getRow(t, reg, row.Host) == nil {
+ t.Error("the forward row is gone")
+ }
+}
+
+// The phase writes and deletes only forward rows: an instance row, a
+// sidecar row, a Platform row and a hand row are untouched while it mints
+// one forward row and retires another, on a hub and on a box that is not.
+func TestForwardPhaseNeverTouchesOtherRows(t *testing.T) {
+ s := dirStore(t)
+ bah, _ := fwdSetup(t, s)
+ inst := fwdRecord(bah, "blog", "blog.example.com", "uk")
+ mustCreate(t, s, inst, fwdRecord(bah, "shop", "shop.example.com", "fleet/home"))
+ others := []registry.Route{
+ {Host: "side.example.com", Kind: SidecarKind, App: "x", Account: bah, Region: "uk", Provisioned: true, Status: "ready"},
+ {Host: "www.example.com", Kind: "static", App: "x", Account: bah, Platform: true, Status: "ready"},
+ {Host: "hand.example.com", Kind: "instance", App: "x", Account: bah, Socket: "/run/carlos/hand.sock", Status: "ready"},
+ {Host: "fleethand.example.com", Kind: "instance", App: "x", Account: bah, Region: "fleet/home", Socket: "/run/carlos/fh.sock", Status: "ready"},
+ }
+ for _, cfg := range []ReconcileConfig{hubCfg(map[string]string{"home": bah}), {Region: "uk", DataDir: "/data"}} {
+ reg := regWith(t, others...)
+ if err := reg.PutForward(forwardRowFor(fwdRecord(bah, "shop2", "gone.example.com", "fleet/home"))); err != nil {
+ t.Fatal(err)
+ }
+ mustPass(t, s, reg, cfg) // mints the instance row
+ before := nonForward(t, reg)
+ if len(before) != len(others)+1 {
+ t.Fatalf("fixture: %d non-forward rows, want %d", len(before), len(others)+1)
+ }
+ mustPass(t, s, reg, cfg)
+ mustPass(t, s, reg, cfg)
+ if after := nonForward(t, reg); !reflect.DeepEqual(before, after) {
+ t.Errorf("hub %v: other rows changed:\nbefore %+v\nafter %+v", cfg.FleetOwners != nil, before, after)
+ }
+ wantNoRow(t, reg, "gone.example.com", "the forward row whose record is gone")
+ if cfg.FleetOwners != nil {
+ wantForward(t, reg, fwdRecord(bah, "shop", "shop.example.com", "fleet/home"))
+ }
+ }
+}
+
+func nonForward(t *testing.T, reg *registry.Registry) []registry.Route {
+ t.Helper()
+ rows, err := reg.List()
+ if err != nil {
+ t.Fatal(err)
+ }
+ var out []registry.Route
+ for _, rt := range rows {
+ if !rt.IsForward() {
+ out = append(out, rt)
+ }
+ }
+ return out
+}
+
+// getCounter counts every read of every key.
+type getCounter struct {
+ *release.DirStore
+ mu sync.Mutex
+ gets map[string]int
+}
+
+func (c *getCounter) count(key string) {
+ c.mu.Lock()
+ c.gets[key]++
+ c.mu.Unlock()
+}
+
+func (c *getCounter) Get(ctx context.Context, key string) ([]byte, string, error) {
+ c.count(key)
+ return c.DirStore.Get(ctx, key)
+}
+
+func (c *getCounter) GetIfChanged(ctx context.Context, key, etag string) ([]byte, string, bool, error) {
+ c.count(key)
+ return c.DirStore.GetIfChanged(ctx, key, etag)
+}
+
+func (c *getCounter) Open(ctx context.Context, key string) (io.ReadCloser, string, error) {
+ c.count(key)
+ return c.DirStore.Open(ctx, key)
+}
+
+func (c *getCounter) take() map[string]int {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ g := c.gets
+ c.gets = map[string]int{}
+ return g
+}
+
+// Step 1 (R2-4) and the §6 budget: a forward app costs one trash marker GET
+// per pass, and its manifest, seed, kind marker and policy are never read.
+// An in-scope app beside it reads its manifest (the positive control).
+func TestForwardAppsReadOnlyTheMarker(t *testing.T) {
+ c := &getCounter{DirStore: dirStore(t), gets: map[string]int{}}
+ bah, _ := fwdSetup(t, c)
+ shop := fwdRecord(bah, "shop", "shop.example.com", "fleet/home")
+ mustCreate(t, c, shop, fwdRecord(bah, "blog", "blog.example.com", "uk"))
+ reg := regWith(t)
+ cfg := hubCfg(map[string]string{"home": bah})
+ for pass := 1; pass <= 2; pass++ {
+ c.take()
+ mustPass(t, c, reg, cfg)
+ gets := c.take()
+ wantForward(t, reg, shop)
+ if n := gets[release.AppTombstoneKey(bah, "shop")]; n != 1 {
+ t.Errorf("pass %d: %d trash marker reads for the forward app, want 1", pass, n)
+ }
+ prefix := release.AppPrefix(bah, "shop")
+ for key, n := range gets {
+ switch {
+ case key == release.AppTombstoneKey(bah, "shop"), strings.HasPrefix(key, RecordsPrefix(bah, "shop")):
+ case strings.HasPrefix(key, prefix), key == release.AppPolicyKey(bah, "shop"):
+ t.Errorf("pass %d: the forward app's %s was read %d times", pass, key, n)
+ }
+ }
+ if gets[ManifestKey(bah, "blog")] == 0 {
+ t.Errorf("pass %d: the in-scope app's manifest was not read (the count is blind)", pass)
+ }
+ }
+}
diff --git a/internal/provision/reconcile.go b/internal/provision/reconcile.go
index dec39b96e..6116e4e73 100644
--- a/internal/provision/reconcile.go
+++ b/internal/provision/reconcile.go
@@ -195,6 +195,17 @@ type ReconcileConfig struct {
// listing proves nothing about a host it did not see). A dry run
// leaves it alone. Nil: no index is kept.
Lifetimes *LifetimeIndex
+ // FleetOwners makes this pass the hub's (fleet public routes spec §4.3):
+ // it answers, once per pass, each fleet in the hub's fleets table with
+ // its owning account, read from the box's own registry. The pass then
+ // keeps the fleet-placed records its scan skips at the fleet boundary,
+ // reads their apps' trash markers (the marker alone), and runs the
+ // forward phase (forward.go) before it mints: a forward row for each
+ // record of a fleet's owner, never over a row of another kind. An error
+ // stops the forward phase for the pass: nothing minted, nothing
+ // retired. Nil: not a hub, and the forward phase only retires, on a
+ // whole pass, every forward row this box holds.
+ FleetOwners func() (map[string]string, error)
// beforeHoldWrite is the tests' pause under the host's hold lock, just
// before holdExisting's conditional write (TestReconcileHoldWrite...).
@@ -1040,6 +1051,13 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
// removal phase reads both for the scan it judges.
known map[string]bool
stale map[string]bool
+ // fleet and hosts are the forward phase's, kept only on the hub
+ // (FleetOwners set): fleet the fleet-placed records the scan skips
+ // only at the fleet boundary, by host, and hosts the number of
+ // usable records naming each host, in scope or not (a host two
+ // records name is disputed, forwardView).
+ fleet map[string]Record
+ hosts map[string]int
}
scan := func(st release.Store) (recordScan, error) {
known, failedAccts, err := knownAccountsNaming(ctx, st)
@@ -1081,6 +1099,11 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
// protected: to this pass it is gone. The removal phase observes a
// row's own key afresh before it acts on that.
stale := map[string]bool{}
+ var fleet map[string]Record
+ var hosts map[string]int
+ if cfg.FleetOwners != nil {
+ fleet, hosts = map[string]Record{}, map[string]int{}
+ }
for _, part := range chunks(recordKeys) {
bodies := getEach(ctx, st, part)
// One sequence per key: the prefetched read, then the judge's
@@ -1214,7 +1237,22 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
// other box skips it exactly like any other out-of-scope record;
// the replica's own box sees Region == cfg.Region through the
// ordinary test above.
+ if hosts != nil {
+ hosts[rec.Host]++
+ }
if !cfg.inScope(rec.Region, rec.Pool, everywhereClass(rec)) {
+ // On the hub, a fleet-placed record skipped only at the
+ // fleet boundary is the forward phase's (spec §4.3 step
+ // 1): judged and validated above exactly as an in-scope
+ // record, kept here for its decision. Pool records are
+ // kept too, so the phase refuses them out loud.
+ if fleet != nil {
+ if _, onFleet := registry.FleetPlacement(rec.Region); onFleet && rec.Region != cfg.Region {
+ if _, dup := fleet[rec.Host]; !dup {
+ fleet[rec.Host] = rec
+ }
+ }
+ }
continue // another agent's jurisdiction, not this pass's business
}
// Two accounts writing the same host is a collision this pass
@@ -1233,7 +1271,7 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
}
}
return recordScan{recs: recs, protect: protect, readFailed: readFailed, known: known, stale: stale,
- unread: unread, failedAccts: failedAccts, partial: partial}, nil
+ unread: unread, failedAccts: failedAccts, partial: partial, fleet: fleet, hosts: hosts}, nil
}
sc, err := scan(s)
if err != nil {
@@ -1312,6 +1350,26 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
manifests[k] = r
prefetchMu.Unlock()
})
+ // The forward phase's apps (fleet public routes spec §4.3 step 1, R2-4):
+ // a second, trash-only prefetch over the kept records' apps not already
+ // read above, into the same tombs map trashFor answers from. The marker
+ // alone: a forward app's manifest, seed and policy are never read.
+ var fleetApps []string
+ for _, rec := range sc.fleet {
+ id := rec.Account + "/" + rec.App
+ if _, seen := appOf[id]; !seen {
+ appOf[id] = acctApp{rec.Account, rec.App}
+ fleetApps = append(fleetApps, id)
+ }
+ }
+ slices.Sort(fleetApps)
+ forEach(fleetApps, func(id string) {
+ k := appOf[id]
+ tomb, terr := release.ReadAppTombstone(ctx, s, k.acct, k.app)
+ prefetchMu.Lock()
+ tombs[k] = tombRead{tomb, terr}
+ prefetchMu.Unlock()
+ })
// The apps' signed operator policies (#328, #329), for the apps this
// pass mints or keeps rows for: those with an in-scope record and a
// trash marker read and absent. Read through the cache, so a pass reads
@@ -1505,6 +1563,37 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
trashFor := trashOver(s, tombs)
trashedFor := func(acct, app string) bool { return trashFor(acct, app).declineMint }
+ // --- the forward phase (fleet public routes spec §4.3) --------------------
+ // Before the instance phase lists and mints, so a record that moved from
+ // a fleet into this box's region finds its forward row gone (on a whole
+ // pass) before the instance phase looks for a row at its host. It
+ // retires only when the scan was whole and nothing failed to read, and
+ // over a record view snapshot only what the bucket's own walk confirms.
+ fwdView := func(sc recordScan, trashFor func(acct, app string) trashState) forwardView {
+ disputed := map[string]bool{}
+ for h := range sc.protect {
+ disputed[h] = true
+ }
+ for h, n := range sc.hosts {
+ if n > 1 {
+ disputed[h] = true
+ }
+ }
+ return forwardView{fleet: sc.fleet, disputed: disputed, trashFor: trashFor}
+ }
+ fp := &forwardPhase{cfg: cfg, reg: reg, view: fwdView(sc, trashFor), whole: !sc.readFailed && !sc.partial}
+ if onSnapshot(s) {
+ fp.confirm = func() (forwardView, bool) {
+ live := freshStore(s)
+ lsc, err := scan(live)
+ if err != nil || lsc.readFailed || lsc.partial {
+ return forwardView{}, false
+ }
+ return fwdView(lsc, trashOver(live, nil)), true
+ }
+ }
+ fp.run()
+
// --- mint / converge / conflict -------------------------------------------
routes, err := reg.List()
if err != nil {
@@ -1536,12 +1625,21 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
if cfg.RunSeen != nil && rec.ActiveRun != nil {
cfg.RunSeen(rec)
}
+ existing, ok := byHost[rec.Host]
+ // A forward row at the host is the forward phase's (fleet public
+ // routes spec §4.3): the record moved here from a fleet, and the
+ // phase retires the row on a whole pass, after which this loop
+ // mints. Until then nothing here writes over it, and the record is
+ // not applied.
+ if ok && existing.IsForward() {
+ log.Printf("provision: %s: a forward row holds the host; the forward phase retires it on a whole pass", rec.Host)
+ continue
+ }
// A mint-only fallback ("", the record-already-written-is-truth
// case) is fine here even when the manifest is unreadable this
// pass — there is no existing seed value a brand new route could
// clobber, and a later pass converges it once the manifest reads.
seed, seedIsKnown := seedFor(rec.Account, rec.App)
- existing, ok := byHost[rec.Host]
if !ok && strippedRootfs(rec) {
continue
}
@@ -2041,7 +2139,10 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
// in the logs that reads as a failure. ReconcileSidecars carries
// the mirror of this guard; both directions are asserted
// (TestInstanceReconcileNeverRemovesSidecarRows).
- return rt.Kind != SidecarKind && rt.Provisioned && cfg.inScope(rt.Region, rt.Pool, everywhereRoute(rt))
+ // A forward row is the forward phase's alone, the same rule
+ // (fleet public routes spec §4.3): it is Provisioned, and on a box
+ // whose region is its fleet it is in scope.
+ return rt.Kind != SidecarKind && !rt.IsForward() && rt.Provisioned && cfg.inScope(rt.Region, rt.Pool, everywhereRoute(rt))
}
retiredWhy := func(recs map[string]Record, trashFor func(acct, app string) trashState, rt registry.Route) (string, bool) {
if !retirable(rt) {
diff --git a/internal/provision/seedreconcile.go b/internal/provision/seedreconcile.go
index d9af28c3e..d58c0bbcc 100644
--- a/internal/provision/seedreconcile.go
+++ b/internal/provision/seedreconcile.go
@@ -165,13 +165,16 @@ func seedAction(rec Record, row *registry.Route, cfg ReconcileConfig, nested fun
// is gone, with the same authority: a Provisioned row of this pass's own
// kind and scope, not a running operation's participant, through
// claimRetire (reg.Delete, which the activator follows by stopping it). It
-// also requires the row to be this record's (account and app). A row it
-// may not remove is left alone, logged, and the seed stays aborted.
+// also requires the row to be this record's (account and app), and never
+// removes a forward row, which is the forward phase's alone (fleet public
+// routes spec §4.3; reg.Delete refuses one too, but a ClaimRetire hook
+// would not). A row it may not remove is left alone, logged, and the seed
+// stays aborted.
//
// Only --from seeds: an import's row is the instance the import replaces,
// which its rollback restores (Plan 7) and never removes.
func retireAbortedSeedRow(ctx context.Context, reg *registry.Registry, cfg ReconcileConfig, rec Record, rt registry.Route) {
- if rt.Kind == SidecarKind || !rt.Provisioned || !cfg.inScope(rt.Region, rt.Pool, everywhereRoute(rt)) ||
+ if rt.Kind == SidecarKind || rt.IsForward() || !rt.Provisioned || !cfg.inScope(rt.Region, rt.Pool, everywhereRoute(rt)) ||
rt.Account != rec.Account || rt.App != rec.App {
log.Printf("provision: %s: aborted seed %s has a row this pass may not remove; leaving the seed aborted", rec.Host, rec.Seed.ID)
return