region labels: Astra branch round 1 (READY AFTER FIXES, one P2) and its fix
Astra's findings committed unedited. P2: the --from and import create doors now answer region_label, and carlos instances create --from keeps the create answer's label through the follow (TestSeededAndImportedCreatesCarryLabels, TestSeededCreateKeepsTheCreatesLabel). Census re-proposed: two envelopes re-pinned, no unit changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+66
−4
docs/superpowers/specs/CODEX-FINDINGS-REGION-LABELS-BRANCH.md+13 −0instances_seed.go+3 −2instances_seed_test.go+18 −0internal/console/apiinstanceimport.go+3 −0internal/console/apiinstanceseed.go+3 −0internal/console/regionwire_test.go+24 −0internal/provision/testdata/plan14-root-reads-region-labels.tsv+2 −2
CI failed — run details
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-REGION-LABELS-BRANCH.md b/docs/superpowers/specs/CODEX-FINDINGS-REGION-LABELS-BRANCH.md| new file mode 100644 |
| index 000000000..520174f59 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-FINDINGS-REGION-LABELS-BRANCH.md |
| @@ -0,0 +1,13 @@ |
| +1. **P2 — Seeded and imported creates omit labels.** Spec §4 and §5 surface 17; plan 1 task 8, plan 2 task 2. |
| + |
| + `region_label` is added only to the ordinary create response at [apiinstances.go:1849](/home/paulca/amadan.net/carlos/platform-region-labels/internal/console/apiinstances.go:1849). Seeded and imported requests return earlier through separate responders that still set only `RegionName`: [apiinstanceseed.go:385](/home/paulca/amadan.net/carlos/platform-region-labels/internal/console/apiinstanceseed.go:385), [apiinstanceimport.go:244](/home/paulca/amadan.net/carlos/platform-region-labels/internal/console/apiinstanceimport.go:244). |
| + |
| + For `carlos instances create --from`, [instances_seed.go:208](/home/paulca/amadan.net/carlos/platform-region-labels/instances_seed.go:208) also overwrites the final GET’s label with the original full-place value. With London available, successful output therefore retains `UK · London` instead of `London (uk)`. |
| + |
| + **Fix:** Populate `region_label` from the cached map in both responders and preserve it through `followSeed`. Add targeted coverage for both response variants and seeded CLI output, retaining the older-console fallback. |
| + |
| + **Fault family:** Complete label propagation across every instance-create path. |
| + |
| +No P1 or P3 findings. Targeted tests could not start because the read-only sandbox blocked Go’s work-directory creation; test results remain unverified. |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
diff --git a/instances_seed.go b/instances_seed.go| index 8695ffbd7..3d3b0ff1b 100644 |
| --- a/instances_seed.go |
| +++ b/instances_seed.go |
| @@ -204,8 +204,9 @@ func (s *apiSession) runSeededCreate(ctx context.Context, w io.Writer, a apiAcct |
| if err != nil { |
| return err |
| } |
| - // The look at one record does not carry where the create placed it. |
| - final.RegionName, final.RegionFrom = rec.RegionName, rec.RegionFrom |
| + // The look at one record does not carry where the create placed it, |
| + // nor its label (region labels §4): the create answer's are kept. |
| + final.RegionName, final.RegionFrom, final.RegionLabel = rec.RegionName, rec.RegionFrom, rec.RegionLabel |
| rec = final |
| } |
| fmt.Fprintf(w, "%s %s\n", colorFor(w).ok("created instance"), instanceCreatedLine(rec, environmentSuffix(rec.Environment))) |
diff --git a/instances_seed_test.go b/instances_seed_test.go| index e2672fc9c..328ec087e 100644 |
| --- a/instances_seed_test.go |
| +++ b/instances_seed_test.go |
| @@ -215,3 +215,21 @@ func TestSeededCreateStopsWhenTheContextEnds(t *testing.T) { |
| t.Fatalf("err = %v", err) |
| } |
| } |
| + |
| +// TestSeededCreateKeepsTheCreatesLabel (Astra branch review, round 1, P2): |
| +// the final look's region_name is a get's label, so the create answer's |
| +// region_label and full place are kept for the success line; an older |
| +// console's answer prints as before. |
| +func TestSeededCreateKeepsTheCreatesLabel(t *testing.T) { |
| + labelled := `{"host":"canary.example.com","channel":"stable","region_name":"UK · London","region_label":"London (uk)","seed":{"id":"sd_x","kind":"replica","from":"www.example.com","state":"reserving"}}` |
| + out, err, _ := runSeeded(t, &seedConsole{createStatus: 202, createBody: labelled, |
| + gets: []func(http.ResponseWriter){seedRecord("ready", "")}}) |
| + if err != nil || !strings.Contains(out, "created instance canary.example.com (channel stable, London (uk)") || strings.Contains(out, "UK · London") { |
| + t.Fatalf("labelled console: %v\n%s", err, out) |
| + } |
| + out, err, _ = runSeeded(t, &seedConsole{createStatus: 202, createBody: reservingBody, |
| + gets: []func(http.ResponseWriter){seedRecord("ready", "")}}) |
| + if err != nil || !strings.Contains(out, "created instance canary.example.com (channel stable, Ireland") { |
| + t.Fatalf("older console: %v\n%s", err, out) |
| + } |
| +} |
diff --git a/internal/console/apiinstanceimport.go b/internal/console/apiinstanceimport.go| index 333be8355..caca774e4 100644 |
| --- a/internal/console/apiinstanceimport.go |
| +++ b/internal/console/apiinstanceimport.go |
| @@ -26,6 +26,7 @@ import ( |
| "github.com/carlosframework/platform/internal/lease" |
| "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/regionlabel" |
| "github.com/carlosframework/platform/internal/release" |
| "github.com/carlosframework/platform/internal/seeds" |
| ) |
| @@ -245,6 +246,8 @@ func (s *Server) beginImport(w http.ResponseWriter, r *http.Request, c seedCreat |
| out.PrivateStoreBucket = privateBucket |
| out.RegionFrom = c.regionFrom |
| out.RegionName = s.placeOf(rec.Region, s.candsOrHome(viewCtx)) // never fleet-placed: refused above |
| + // The region's label (region labels §4), as every create answer has. |
| + out.RegionLabel = regionlabel.ForRecord(rec, s.regionHome(), s.regionNames()).Text |
| writeJSON(w, http.StatusCreated, out) |
| } |
diff --git a/internal/console/apiinstanceseed.go b/internal/console/apiinstanceseed.go| index 1180d5087..eec696fbb 100644 |
| --- a/internal/console/apiinstanceseed.go |
| +++ b/internal/console/apiinstanceseed.go |
| @@ -30,6 +30,7 @@ import ( |
| "github.com/carlosframework/platform/internal/dbdoor" |
| "github.com/carlosframework/platform/internal/objstore" |
| "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/regionlabel" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| "github.com/carlosframework/platform/internal/seeds" |
| @@ -385,6 +386,8 @@ func (s *Server) beginFrom(w http.ResponseWriter, r *http.Request, c seedCreate, |
| out := recordView(rec) |
| out.RegionFrom = c.regionFrom |
| out.RegionName = s.placeOf(rec.Region, s.candsOrHome(writeCtx)) // never fleet-placed: refused above |
| + // The region's label (region labels §4), as every create answer has. |
| + out.RegionLabel = regionlabel.ForRecord(rec, s.regionHome(), s.regionNames()).Text |
| writeJSON(w, http.StatusAccepted, out) |
| handedOver = true |
| return &fromCopy{ctx: context.WithoutCancel(ctx), c: c, from: from, source: source, |
diff --git a/internal/console/regionwire_test.go b/internal/console/regionwire_test.go| index b22f32f3d..9abf68db2 100644 |
| --- a/internal/console/regionwire_test.go |
| +++ b/internal/console/regionwire_test.go |
| @@ -14,6 +14,7 @@ import ( |
| "github.com/carlosframework/platform/internal/dbdoor" |
| "github.com/carlosframework/platform/internal/dbreads" |
| "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/regionlabel" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| "github.com/carlosframework/platform/internal/status" |
| @@ -378,3 +379,26 @@ func TestStatusDoorsCarryLabels(t *testing.T) { |
| t.Fatalf("status layout = %v", lay) |
| } |
| } |
| + |
| +// TestSeededAndImportedCreatesCarryLabels (Astra branch review, round 1, |
| +// P2): the --from and import create doors answer region_label as the |
| +// ordinary create does. |
| +func TestSeededAndImportedCreatesCarryLabels(t *testing.T) { |
| + check := func(name string, f fromFixture, code int, out map[string]any, wantCode int) { |
| + t.Helper() |
| + want := regionlabel.ForCode("", f.fx.srv.regionHome(), f.fx.srv.regionNames()).Text |
| + if code != wantCode || want == "" || out["region_label"] != want { |
| + t.Fatalf("%s = %d, region_label %v, want %q: %v", name, code, out["region_label"], want, out) |
| + } |
| + } |
| + f := newFromFixture(t, 30) |
| + f.fx.srv.refreshRegionNames(context.Background(), nil, time.Now()) |
| + code, out := f.createAs(t, f.token, `{"host":"canary.shop.example.com","from":{"host":"main.shop.example.com"}}`) |
| + f.fx.srv.seedCopies.Wait() |
| + check("from", f, code, out, http.StatusAccepted) |
| + |
| + imp := newImportFixture(t) |
| + imp.fx.srv.refreshRegionNames(context.Background(), nil, time.Now()) |
| + code, out = beginImport(t, imp, importHost, importSHA, 4096) |
| + check("import", imp, code, out, http.StatusCreated) |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-region-labels.tsv b/internal/provision/testdata/plan14-root-reads-region-labels.tsv| index 801c4b324..9d8b4eb0c 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-region-labels.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-region-labels.tsv |
| @@ -46,9 +46,9 @@ internal/dbdoor/client.go doorError legacy accepted-legacy accepted-legacy;rev3= |
| status_instances.go printStatusLayout legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-labels;basis=a REGION column (statusRegionCell) from the console's answer; no read added data-literal@1617 fbb178fa8dad550c0d1373eb228d46f912cd0d68cf82fe321111853710c4d3d7 |
| internal/console/fleets.go Server.appPlacement legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-region-labels;basis=the legacy route fallback's loop moved whole into fleetFromRoutes (a decision row in region-labels-decisions); the same registry List, fewer sites here whole:Route@437 d35e13f1213674f0b55f79e7639ffbaa0acaed65d5a3bb1d03407041c1d76427 |
| internal/console/view.go Assemble legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-console-perf-1;basis=takes the request context instead of context.Background() and wraps the registry List in a perf db span (perf.SpanContext); the same registry and store reads, no read added;rev3=census-ruling-console-remote-instances;basis=Collects the set of local registry hosts (rt.Host) so a record host the registry has gets no remote row (its record's created_at bounds the local row's metrics history); adds rows from the account's records and remoteFacts when given a remote source.;rev3=census-ruling-region-labels;basis=labels each row through regionlabel.ForRoute/ForRecord from the row or record in hand and the cached name map, and folds the app's first fleet placement (fleetFromRoutes) from the listing it already made; no read added registry:App@2330,registry:App@2353,registry:App@2381,registry:App@2411,registry:Backing@2024,registry:Caps@1424,registry:Channel@999,registry:Environment@1949,registry:Hibernate@1866,registry:Host@1775,registry:Host@900,registry:Kind@1790,registry:Platform@1896,registry:Provisioned@2049,registry:Status@1807,registry:Unit@2006,registry:Version@1830,whole:Route@2099,whole:Route@2287,whole:Route@2431,whole:Route@3967,whole:Route@849,whole:Route@878,whole:Route@949 a5db383db1f845245da7fbe5730549766055b5ad7be65d623bc5780c0afd608c |
| -@coverage . d0ba452dba7cf9631bdd370237b8954ba9d4c41f1d6dbd656615d45fa1616ee7 |
| +@coverage . e4fe51075b3582a4af08c02a8ecd87c25434185c9d73374185a64d5ca4ef1884 |
| @coverage cmd/console ee11f13c516a8a04591bc29019e6398adf209f23860f4bd003701671bab7e19d |
| -@coverage internal/console db8e0f82386898d330f056f90bb788accf4345f586a3c29fea09a9f47f47671f |
| +@coverage internal/console e134585b8b4111c50b6eb5cc77025a2149e4b5daa3191bfa6c4e637ac4ecac92 |
| @coverage internal/console/templates cce8697997c79c6dab1cf9ccab47fc904ce97f3784ed654fd524aef5f233a38f |
| @coverage internal/dbdoor 5abbebc357a7a6dd8ce53c12f3da1a48c80e7ec3c5ef9ed436a88d08cda2670b |
| @coverage internal/geo 773e235a14fc13e58f570f9aae10598a3a26f571b01ca7553af4f4ac7494a159 |