carlos / platform Public

apps region: Luna copy applied verbatim; census proposal app-region-set

The GET reads placement through appPlacement, the same answer the change
door refuses on, instead of a registry listing of its own. Census: five
body changes, no new read (card docs/superpowers/notes/census-proposal-app-region-set.md).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 1e9b8b326ea69e7223cdda9f33a99cf863da3edd parent 1f11e66
9 files changed, +172 −39
  • apps.go +2 −2
  • apps_region_cmd.go +17 −9
  • docs/site/cli.md +6 −5
  • docs/superpowers/notes/census-proposal-app-region-set.md +27 −0
  • docs/superpowers/specs/LUNA-COPY-RESULT-APP-REGION-SET.md +60 −0
  • internal/console/appregionset.go +38 −18
  • internal/console/appregionset_test.go +5 −5
  • internal/provision/testdata/plan14-root-reads-app-region-set.tsv +16 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0

CI cancelled — superseded by a newer push — run details

diff --git a/apps.go b/apps.go
index bfd5701e6..9e4831726 100644
--- a/apps.go
+++ b/apps.go
@@ -73,8 +73,8 @@ const appsUsage = `usage: carlos apps <create|place|build-probe|set|show|delete|
silent clear (a fleet box retires an app's routes on its
next reconcile the moment placement reads empty).
- region --app <name> [--set <region>] show the region the app's new
- instances start in, or change it with --set. existing
+ region --app <name> [--set <region>] show the region where the app's new
+ instances start, or change it with --set. existing
instances stay where they are. changing it is for account
owners and deployment operators.
diff --git a/apps_region_cmd.go b/apps_region_cmd.go
index 35d2ee13b..dd392f1db 100644
--- a/apps_region_cmd.go
+++ b/apps_region_cmd.go
@@ -19,16 +19,24 @@ import (
"github.com/carlosframework/platform/internal/updatewords"
)
-// The verb's strings (deck docs/superpowers/notes/copy-app-region-set.md).
+// The verb's strings (deck docs/superpowers/notes/copy-app-region-set.md;
+// approved by delegation, Luna pass 2026-10-26).
const (
- appsRegionUsage = "usage: carlos apps region --app <name> [--set <region>] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]"
- appsRegionFlagSet = "the region this app's new instances start in. existing instances stay where they are. account owners and deployment operators only"
- appsRegionShow = "%s's region is %s. new instances start there." // AR-32: app, label
- appsRegionShowFleet = "%s runs on your fleet %s, which decides where its instances run." // AR-33: app, fleet
- appsRegionChanged = "%s's region changed from %s to %s. new instances start in %s. existing instances stay where they are." // AR-34: app, old, new, new
- appsRegionSame = "%s's region is already %s. nothing changed." // AR-35: app, label
- appsRegionDirectMode = "apps region works through a console, and this shell is in direct bucket mode (CARLOS_DEPLOYMENT_BUCKET or CARLOS_DEPLOYMENT_DIR is set). log in instead: carlos auth login --console <url>" // AR-36
- appsRegionOldConsole = "not found: either %s is not an app in this account, or this console predates carlos apps region (deploy a console built from current main)" // AR-37: app
+ // AR-30, AR-31
+ appsRegionUsage = "usage: carlos apps region --app <name> [--set <region>] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]"
+ appsRegionFlagSet = "the region where this app's new instances start. existing instances stay where they are. only account owners and deployment operators can change it"
+ // AR-32: app, label
+ appsRegionShow = "%s's region is %s. new instances start there."
+ // AR-33: app, fleet name
+ appsRegionShowFleet = "%s runs on your fleet %s, which decides where its instances run."
+ // AR-34: app, old label, new label, new label
+ appsRegionChanged = "%s's region changed from %s to %s. new instances start in %s. existing instances stay where they are."
+ // AR-35: app, label
+ appsRegionSame = "%s's region is already %s. nothing changed."
+ // AR-36
+ appsRegionDirectMode = "apps region works through a console, and this shell is in direct bucket mode (CARLOS_DEPLOYMENT_BUCKET or CARLOS_DEPLOYMENT_DIR is set). log in instead: carlos auth login --console <url>"
+ // AR-37: app
+ appsRegionOldConsole = "not found: either %s is not an app in this account, or this console is too old for carlos apps region (deploy a console built from current main)"
)
// apiAppRegion is the door's answer (the console's appRegionView).
diff --git a/docs/site/cli.md b/docs/site/cli.md
index 8dd45cb8c..71aab8d9d 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -184,16 +184,16 @@ carlos apps ttl --app tmp-docs 5d
carlos apps keep --app tmp-docs
```
-carlos apps list shows each app's own region, the one it was given when it was created or changed to since, or the fleet it runs on. Where new instances start can differ. For a pooled app, the app's Running page in the console shows where they start.
+`carlos apps list` shows each app's own region, the region where its new instances start. For an app with a region, it shows the region set when the app was created or changed later. For an app on a fleet, it shows the fleet instead. Where new instances start can differ from where existing instances run. For a pooled app, the app's Running page in the console shows where its instances start.
-`carlos apps region` shows an app's region, and `--set` changes it:
+`carlos apps region` shows where an app's new instances start, and `--set` changes that default:
```sh
carlos apps region --app hello
carlos apps region --app hello --set uk
```
-An app's region is only where its new instances start. Changing it moves nothing: instances that already exist stay where they are, and only instances created afterwards start in the new region. Use carlos move to move one that exists. The new region must be one the platform offers and can start instances in now, and one the app's instances may use. An app on a fleet is refused, because the fleet decides where its instances run; use `carlos apps place` instead. So is an app whose instances start in a pool, and an app in the Trash. Account owners and deployment operators can change the region, here or in the Region section of the app's settings in the console. The console records who changed it, from what and to what, in the app's activity. After a change, `carlos deploy --region` has to name the new region.
+An app's region is only where its new instances start. Changing it moves nothing: instances that already exist stay where they are, and only instances created afterwards start in the new region. Use `carlos move` to move one that exists. The new region must be one the platform offers, able to start instances now, and allowed for this app's instances. An app on a fleet is refused because the fleet decides where its instances run. Use `carlos apps place` instead. The command also refuses an app whose instances start in a pool or an app in the Trash. Account owners and deployment operators can change the region with this command or in the Region section of the app's settings in the console. The console records who changed it, from what and to what, in the app's activity. After a change, `carlos deploy --region` must name the app's current region.
`carlos apps set` changes how the app's running instances take a new build:
@@ -352,8 +352,9 @@ When `carlos deploy` creates your first app, it sends your timezone so the
console can pick the region nearest you, and prints the choice. `--region
<code>` chooses instead. On an app that already exists, `--region` must
match the app's region, or deploy stops before shipping anything. That is
-the region the app has now, after any `carlos apps region --set`, and deploy
-never moves an instance to match it.
+the app's current region after any `carlos apps region --set`. If `carlos
+deploy --region` names another region, deploy stops before shipping
+anything. Deploy never moves an instance to match the app's region.
`carlos deploy` takes the same repeatable `--assets` flag and passes it to the ship. Save the list as `"assets": ["/assets/"]` in `.carlos/config` and a bare `carlos deploy` declares it on every release. A flag on the command line replaces the saved list for that run, and `--no-assets` ships with none. A release that declares no folders gets no copies, so deploying a build without them turns copying off for that build. `--assets` and `--no-assets` cannot be given together.
diff --git a/docs/superpowers/notes/census-proposal-app-region-set.md b/docs/superpowers/notes/census-proposal-app-region-set.md
new file mode 100644
index 000000000..9202dee9b
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-app-region-set.md
@@ -0,0 +1,27 @@
+# Census approval: app-region-set
+
+Ruling `census-ruling-app-region-set`. Every change below keeps the disposition it already has, so it needs an approval, not a decision.
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/console/server.go` `NewServer` | body | unchanged (1) | registers POST /a/{sqid}/apps/{app}/region (handleAppRegionSet, appregionset.go) beside the rename route; route registration only; no read added, read site unchanged |
+| `internal/console/store.go` `Store.NonHomeAppRegions` | body | unchanged (1) | selects max(created_at, region_set_at) instead of created_at, so a record from before an app region change is not a discrepancy candidate; the same one console-owned SQLite query; no read added |
+| `internal/console/store.go` `Store.migrate` | body | unchanged (2) | adds the additive apps.region_set_at column (INTEGER NOT NULL DEFAULT 0) to the ALTER list; the same two Exec sites; no read added |
+| `internal/console/store.go` `Store.migrateAppsKey` | body | unchanged (2) | carries region_set_at across the apps rebuild (column list and INSERT ... SELECT); console-owned table only; no read added |
+| `internal/console/templates/app_settings.html` `external` | body | unchanged (1) | the General Region section gains, for an owner or a deployment operator, a select of region codes and a Change region button posting to /a/{sqid}/apps/{app}/region with the CSRF token, and a note; markup only; no read added |
+
+Envelopes re-pinned: `.`, `internal/console`, `internal/console/templates`, `internal/regionlabel`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Escalate if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. An escalation goes to the census owner as a decision.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/console/server.go` `NewServer`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console construction adds the lifetime judge, the cutover admission gate and its first marker read; claims-off app materialisation moves to the cutover watch; the existing logs/data route literal moves and is not a filesystem read;rev3=census-ruling-plans-4d-lapse;basis=registers GET and POST /a/{sqid}/plan/keep (the owner-only keep page, plans 4d) beside the account settings routes; no goroutine; read sites unchanged, offsets moved;rev3=census-ruling-plans-6-checkout;basis=refuses Config.Billing without a plan catalog, sets the billing runtime from Config.Billing, and registers POST /billing/webhook beside /api/ses/events; no goroutine and no store call; the one data-literal is still the logs/data route pattern, moved; no read added;rev3=census-ruling-console-perf-1;basis=takes cfg.Perf (or makes its own perf.Recorder), builds the instance fetcher after it so app-host calls are counted, and wraps the mux in perf.Middleware with /healthz skipped; no read added, read site unchanged;rev3=census-ruling-console-ux-nav;basis=GET /deployments now registers handleAppDeploymentsRedirect and GET /pipeline handleAppPipelineRedirect (named handlers in appredirect.go that call appRedirect for /releases and /settings/pipeline, after accountApp's gates) instead of their handlers; route registration only; no root read added, read site unchanged
+- `internal/console/store.go` `Store.NonHomeAppRegions`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
+- `internal/console/store.go` `Store.migrate`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console.service user carlos-console, J4 root-input: adds the three account/app-scoped lifetime intent tables and apps.lifetime at unarmed store boot, then backfills missing lifetimes;rev3=census-ruling-plans-4d-lapse;basis=adds the additive account_plans.lapse_since and account_plans.disabled columns and calls migratePlanLapse last, which creates the console's own plan_lapse_items table (plans 4d). No read added; the new store units are the plans-4d-units decision.;rev3=census-ruling-plans-6-checkout;basis=calls migrateBilling last, after main's migratePlanLapse, which creates the console's own billing tables (plans 6a, its own decision row); no read added here;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 9: calls migrateAppPolicy (a new unit: CREATE TABLE IF NOT EXISTS app_policy_revisions, the console's own table) before migratePlanLapse. The same two Exec sites; no read added here.
+- `internal/console/store.go` `Store.migrateAppsKey`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console.service user carlos-console, J4 root-input: copies apps into the composite-key schema while preserving existing lifetimes and minting only missing ids
+- `internal/console/templates/app_settings.html` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-design-edge-rate-limit-358;basis=the Settings page gains a Rate limit section: per instance host, a form of four numbers (busy at, per address while busy, backstop rate, backstop burst) and a reset form, both posting to /a/{sqid}/apps/{app}/ratelimit with the CSRF token, and the record's path rules listed read-only; embedded and rendered by the console (carlos-console), as before; no read added;rev3=census-ruling-console-ux-nav;basis=adds the Placement section (the existing POST /place form, moved from app_instances) and the Errors and analytics section; Advanced folds into General; link texts reworded; markup only; no read added;rev3=census-ruling-region-labels;basis=General gains a Region section (RC-18a, RC-18d, RC-19, RL-S1, or the unread sentence); the placement form's button reads Change fleet (RC-14); markup only; no read added
+
+Seal: `d1e00cfb29d88b7a8e4998b641164e539067a6e1e9e4f52524255343c0c5f9f7` → `798a1ee3d8c8b775f963b9ae1dbc45e18628fa0c1e63404f46606601766ad66c`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-app-region-set.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/specs/LUNA-COPY-RESULT-APP-REGION-SET.md b/docs/superpowers/specs/LUNA-COPY-RESULT-APP-REGION-SET.md
new file mode 100644
index 000000000..29023b4f7
--- /dev/null
+++ b/docs/superpowers/specs/LUNA-COPY-RESULT-APP-REGION-SET.md
@@ -0,0 +1,60 @@
+# Luna copy result: carlos apps region (app-region-set)
+
+Approved by delegation (Luna). Model gpt-5.6-luna via codex, reasoning high, read-only, run 2026-10-26 against docs/superpowers/specs/LUNA-COPY-BRIEF-APP-REGION-SET.md and the deck docs/superpowers/notes/copy-app-region-set.md (commit 1f11e665). Applied verbatim. Luna flagged nothing.
+
+The brief asked for full stops on form labels and buttons by mistake, so Luna's AR-15 and AR-16 ended in one. A follow-up pass with that rule corrected (label and button take no final full stop, like the neighbouring Change fleet button) answered the second table below, and that is what is applied.
+
+## Pass 1
+
+| key | new | why |
+|---|---|---|
+| AR-1 | only an account owner or a deployment operator can change an app's region | unchanged |
+| AR-2 | %s is in the Trash. restore it before you change its region | lower-case continuation; no final stop |
+| AR-3 | %s runs on your fleet %s, which decides where its instances run. use carlos apps place to change that | lower-case continuation; no final stop |
+| AR-4 | %s starts its instances in a pool, so an app region would not be used. nothing was changed | lower-case continuation; no final stop |
+| AR-5 | name the region to set, for example --set uk | unchanged |
+| AR-6 | region %s is not offered by this platform. choose from: %s | plainer wording; required casing |
+| AR-6b | region %s is not offered by this platform right now | plainer wording |
+| AR-7 | region %s cannot be used by this app's instances. allowed: %s | plainer wording; required casing |
+| AR-7b | region %s cannot be used by this app's instances, and none of the regions this app can use is offered right now | plainer wording |
+| AR-8 | this app's region changed while this ran. run it again | lower-case continuation; no final stop |
+| AR-9 | could not read this app's instance policy, so its region was not changed. try again | lower-case continuation; no final stop |
+| AR-9b | could not read the regions this platform offers, so the app's region was not changed. try again | lower-case continuation; no final stop |
+| AR-10 | could not change this app's region. nothing was changed. try again | lower-case continuation; no final stop |
+| AR-11 | changed %s's region from %s to %s | unchanged |
+| AR-12 | Changed after the app was created. | unchanged |
+| AR-13 | New instances now start in %s. Existing instances stay where they are. | unchanged |
+| AR-14 | This app's region is already %s. | unchanged |
+| AR-15 | Region for new instances. | added required full stop |
+| AR-16 | Change region. | added required full stop |
+| AR-17 | Changing the region moves nothing. Only instances created after the change start in the new region. | unchanged |
+| AR-19 | region %s can't start new instances right now (%s), so the app's region was not changed | aligned wording with the stated fact; no final stop |
+| AR-20 | could not confirm that region %s can start new instances, so the app's region was not changed. try again | lower-case continuation; no final stop |
+| AR-21 | changing an app's region is not supported on a console with host claims on | unchanged |
+| AR-30 | usage: carlos apps region --app <name> [--set <region>] [--account <sqid\|name>] [--account-id <sqid>] [--console <origin>] | unchanged |
+| AR-31 | the region where this app's new instances start. existing instances stay where they are. only account owners and deployment operators can change it | clearer flag help |
+| AR-32 | %s's region is %s. new instances start there. | unchanged |
+| AR-33 | %s runs on your fleet %s, which decides where its instances run. | unchanged |
+| AR-34 | %s's region changed from %s to %s. new instances start in %s. existing instances stay where they are. | unchanged |
+| AR-35 | %s's region is already %s. nothing changed. | unchanged |
+| AR-36 | apps region works through a console, and this shell is in direct bucket mode (CARLOS_DEPLOYMENT_BUCKET or CARLOS_DEPLOYMENT_DIR is set). log in instead: carlos auth login --console <url> | unchanged |
+| AR-37 | not found: either %s is not an app in this account, or this console is too old for carlos apps region (deploy a console built from current main) | plainer wording |
+| AR-38 | region --app <name> [--set <region>] show the region where the app's new<br> instances start, or change it with --set. existing<br> instances stay where they are. changing it is for account<br> owners and deployment operators. | clearer wording; preserved indentation and line breaks |
+| AR-40 | `carlos apps list` shows each app's own region, the region where its new instances start. For an app with a region, it shows the region set when the app was created or changed later. For an app on a fleet, it shows the fleet instead. Where new instances start can differ from where existing instances run. For a pooled app, the app's Running page in the console shows where its instances start. | clarified region, fleet, pooled, and existing-instance behavior |
+| AR-41 | `carlos apps region` shows where an app's new instances start, and `--set` changes that default: | clarified that the region is the default for new instances |
+| AR-42 | An app's region is only where its new instances start. Changing it moves nothing: instances that already exist stay where they are, and only instances created afterwards start in the new region. Use `carlos move` to move one that exists. The new region must be one the platform offers, able to start instances now, and allowed for this app's instances. An app on a fleet is refused because the fleet decides where its instances run. Use `carlos apps place` instead. The command also refuses an app whose instances start in a pool or an app in the Trash. Account owners and deployment operators can change the region with this command or in the Region section of the app's settings in the console. The console records who changed it, from what and to what, in the app's activity. After a change, `carlos deploy --region` must name the app's current region. | clarified restrictions and deploy behavior |
+| AR-43 | That is the app's current region after any `carlos apps region --set`. If `carlos deploy --region` names another region, deploy stops before shipping anything. Deploy never moves an instance to match the app's region. | made the deploy constraint explicit |
+
+**Flags**
+
+- None.
+## Pass 2 (AR-15, AR-16)
+
+| key | new | why |
+|---|---|---|
+| AR-15 | Region for new instances | Form label; no final full stop. |
+| AR-16 | Change region | Button label; no final full stop, matching “Change fleet”. |
+
+**Flags**
+
+- None.
\ No newline at end of file
diff --git a/internal/console/appregionset.go b/internal/console/appregionset.go
index ab1b5847f..65e3b1caf 100644
--- a/internal/console/appregionset.go
+++ b/internal/console/appregionset.go
@@ -35,10 +35,12 @@ import (
"github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/regionlabel"
+ "github.com/carlosframework/platform/internal/registry"
)
// appRegionSetCopy is every string this file adds (deck
-// docs/superpowers/notes/copy-app-region-set.md).
+// docs/superpowers/notes/copy-app-region-set.md; approved by delegation,
+// Luna pass 2026-10-26, docs/superpowers/specs/LUNA-COPY-RESULT-APP-REGION-SET.md).
type appRegionSetCopyStrings struct {
NotOwner string // AR-1
InTrash string // AR-2: app
@@ -67,21 +69,21 @@ type appRegionSetCopyStrings struct {
var appRegionSetCopy = appRegionSetCopyStrings{
NotOwner: "only an account owner or a deployment operator can change an app's region",
- InTrash: "%s is in the Trash. Restore it before you change its region.",
- OnFleet: "%s runs on your fleet %s, which decides where its instances run. Use carlos apps place to change that.",
- Pooled: "%s starts its instances in a pool, so an app region would not be used. Nothing was changed.",
+ InTrash: "%s is in the Trash. restore it before you change its region",
+ OnFleet: "%s runs on your fleet %s, which decides where its instances run. use carlos apps place to change that",
+ Pooled: "%s starts its instances in a pool, so an app region would not be used. nothing was changed",
NoRegion: "name the region to set, for example --set uk",
- NotOffered: "region %s is not one this platform offers. Choose from: %s.",
- NotOfferedNone: "region %s is not one this platform offers right now.",
- NotAllowed: "region %s is not one this app's instances may use. Allowed: %s.",
- NotAllowedNone: "region %s is not one this app's instances may use, and none of the regions they may use is offered right now.",
+ NotOffered: "region %s is not offered by this platform. choose from: %s",
+ NotOfferedNone: "region %s is not offered by this platform right now",
+ NotAllowed: "region %s cannot be used by this app's instances. allowed: %s",
+ NotAllowedNone: "region %s cannot be used by this app's instances, and none of the regions this app can use is offered right now",
ClaimOff: "changing an app's region is not supported on a console with host claims on",
- Unavailable: "region %s can't take new instances right now (%s), so the app's region was not changed.",
- Unconfirmed: "could not confirm that region %s can take new instances, so the app's region was not changed. Try again.",
- Changed: "this app's region changed while this ran. Run it again.",
- PolicyUnread: "could not read this app's instance policy, so its region was not changed. Try again.",
- OptionsUnread: "could not read the regions this platform offers, so the app's region was not changed. Try again.",
- WriteFailed: "could not change this app's region. Nothing was changed. Try again.",
+ Unavailable: "region %s can't start new instances right now (%s), so the app's region was not changed",
+ Unconfirmed: "could not confirm that region %s can start new instances, so the app's region was not changed. try again",
+ Changed: "this app's region changed while this ran. run it again",
+ PolicyUnread: "could not read this app's instance policy, so its region was not changed. try again",
+ OptionsUnread: "could not read the regions this platform offers, so the app's region was not changed. try again",
+ WriteFailed: "could not change this app's region. nothing was changed. try again",
AuditChanged: "changed %s's region from %s to %s",
SourceChanged: "Changed after the app was created.",
FlashChanged: "New instances now start in %s. Existing instances stay where they are.",
@@ -178,13 +180,31 @@ func (s *Server) handleAPIAppRegionGet(w http.ResponseWriter, r *http.Request) {
if !ok {
return
}
- routes, routesOK := s.registryRoutes()
- f := s.regionFactsFor(acct, app, fleetFromRoutes(routes, acct.Sqid, app), routesOK)
- if !f.Known {
+ // The same placement the change door refuses on (appPolicy's
+ // appPlacement: the stored column, else the registry's legacy rows).
+ placed := ""
+ reg, err := openRegistry(s.cfg.Registry)
+ if err == nil {
+ placed, err = s.appPlacement(reg, acct, app)
+ }
+ if err != nil {
+ log.Printf("console: app region %s/%s: placement: %v", acct.Sqid, app, err)
+ jsonError(w, http.StatusBadGateway, msgAppRegionUnreadable)
+ return
+ }
+ if name, ok := registry.FleetPlacement(placed); ok {
+ l := regionlabel.ForCode(placed, s.regionHome(), s.regionNames())
+ writeJSON(w, http.StatusOK, appRegionView{App: app, Region: l.Code, Label: l.Text, Fleet: name})
+ return
+ }
+ region, source, err := s.appRegion(acct.ID, app)
+ if err != nil {
+ log.Printf("console: app region %s/%s: read: %v", acct.Sqid, app, err)
jsonError(w, http.StatusBadGateway, msgAppRegionUnreadable)
return
}
- writeJSON(w, http.StatusOK, appRegionView{App: app, Region: f.Code(), Label: f.Text(), Source: f.Source, Fleet: f.Fleet})
+ l := regionlabel.ForCode(region, s.regionHome(), s.regionNames())
+ writeJSON(w, http.StatusOK, appRegionView{App: app, Region: l.Code, Label: l.Text, Source: source})
}
// handleAPIAppRegionSet is PUT /api/cli/apps/{account}/{app}/region with
diff --git a/internal/console/appregionset_test.go b/internal/console/appregionset_test.go
index 314054ddd..105b1dd33 100644
--- a/internal/console/appregionset_test.go
+++ b/internal/console/appregionset_test.go
@@ -288,14 +288,14 @@ func TestAppRegionSetRefusals(t *testing.T) {
status int
want string
}{
- {"unknown region", "shop", "zz", http.StatusBadRequest, "region zz is not one this platform offers. Choose from: fr, ie, uk."},
- {"not armed", "shop", "us", http.StatusBadRequest, "region us is not one this platform offers. Choose from: fr, ie, uk."},
- {"not a region", "shop", "UK!", http.StatusBadRequest, "region UK! is not one this platform offers. Choose from: fr, ie, uk."},
- {"cannot start instances", "shop", "fr", http.StatusConflict, "region fr can't take new instances right now (boxes there don't take ordinary instances), so the app's region was not changed."},
+ {"unknown region", "shop", "zz", http.StatusBadRequest, "region zz is not offered by this platform. choose from: fr, ie, uk"},
+ {"not armed", "shop", "us", http.StatusBadRequest, "region us is not offered by this platform. choose from: fr, ie, uk"},
+ {"not a region", "shop", "UK!", http.StatusBadRequest, "region UK! is not offered by this platform. choose from: fr, ie, uk"},
+ {"cannot start instances", "shop", "fr", http.StatusConflict, "region fr can't start new instances right now (boxes there don't take ordinary instances), so the app's region was not changed"},
{"no region", "shop", " ", http.StatusBadRequest, appRegionSetCopy.NoRegion},
{"fleet", "fleeted", "uk", http.StatusConflict, fmt.Sprintf(appRegionSetCopy.OnFleet, "fleeted", "racks")},
{"pooled", "pooled", "uk", http.StatusConflict, fmt.Sprintf(appRegionSetCopy.Pooled, "pooled")},
- {"allow-list", "narrow", "ie", http.StatusConflict, "region ie is not one this app's instances may use. Allowed: uk."},
+ {"allow-list", "narrow", "ie", http.StatusConflict, "region ie cannot be used by this app's instances. allowed: uk"},
{"trash", "binned", "uk", http.StatusConflict, fmt.Sprintf(appRegionSetCopy.InTrash, "binned")},
} {
st, out := fx.put(t, owner, c.app, c.region)
diff --git a/internal/provision/testdata/plan14-root-reads-app-region-set.tsv b/internal/provision/testdata/plan14-root-reads-app-region-set.tsv
new file mode 100644
index 000000000..36cf3f0fc
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-app-region-set.tsv
@@ -0,0 +1,16 @@
+# Census overlay app-region-set, written by census-propose (#369). census-ruling-app-region-set, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-app-region-set.md.
+# 5 body, 0 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy c7b572706c114574ad45b597b62ee98ac688149f026c24baa72f59fae4f4ddf6 internal/console/server.go NewServer legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console construction adds the lifetime judge, the cutover admission gate and its first marker read; claims-off app materialisation moves to the cutover watch; the existing logs/data route literal moves and is not a filesystem read;rev3=census-ruling-plans-4d-lapse;basis=registers GET and POST /a/{sqid}/plan/keep (the owner-only keep page, plans 4d) beside the account settings routes; no goroutine; read sites unchanged, offsets moved;rev3=census-ruling-plans-6-checkout;basis=refuses Config.Billing without a plan catalog, sets the billing runtime from Config.Billing, and registers POST /billing/webhook beside /api/ses/events; no goroutine and no store call; the one data-literal is still the logs/data route pattern, moved; no read added;rev3=census-ruling-console-perf-1;basis=takes cfg.Perf (or makes its own perf.Recorder), builds the instance fetcher after it so app-host calls are counted, and wraps the mux in perf.Middleware with /healthz skipped; no read added, read site unchanged;rev3=census-ruling-console-ux-nav;basis=GET /deployments now registers handleAppDeploymentsRedirect and GET /pipeline handleAppPipelineRedirect (named handlers in appredirect.go that call appRedirect for /releases and /settings/pipeline, after accountApp's gates) instead of their handlers; route registration only; no root read added, read site unchanged;rev3=census-ruling-app-region-set;basis=registers POST /a/{sqid}/apps/{app}/region (handleAppRegionSet, appregionset.go) beside the rename route; route registration only; no read added, read site unchanged data-literal@10574 b9b22ee5933f80618afa83e46c228632af67a7d2e5a15d3dae4a11dddff4bf77
+@legacy 6287d4aa7901529278b845fc7bd8d108231a91baeb23e37ee749aa1b0b2b4078 internal/console/store.go Store.NonHomeAppRegions legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-app-region-set;basis=selects max(created_at, region_set_at) instead of created_at, so a record from before an app region change is not a discrepancy candidate; the same one console-owned SQLite query; no read added file:Query@80 6ca73e6f90e7b0a8f373bc8b9c6bb8011f3471ecb54519a0d604ef6854ca9388
+@legacy 6be36fa21f2645e0a9b13c846b9dd63907300a3f6329647dfd2ed01b49731f72 internal/console/store.go Store.migrate legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console.service user carlos-console, J4 root-input: adds the three account/app-scoped lifetime intent tables and apps.lifetime at unarmed store boot, then backfills missing lifetimes;rev3=census-ruling-plans-4d-lapse;basis=adds the additive account_plans.lapse_since and account_plans.disabled columns and calls migratePlanLapse last, which creates the console's own plan_lapse_items table (plans 4d). No read added; the new store units are the plans-4d-units decision.;rev3=census-ruling-plans-6-checkout;basis=calls migrateBilling last, after main's migratePlanLapse, which creates the console's own billing tables (plans 6a, its own decision row); no read added here;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 9: calls migrateAppPolicy (a new unit: CREATE TABLE IF NOT EXISTS app_policy_revisions, the console's own table) before migratePlanLapse. The same two Exec sites; no read added here.;rev3=census-ruling-app-region-set;basis=adds the additive apps.region_set_at column (INTEGER NOT NULL DEFAULT 0) to the ALTER list; the same two Exec sites; no read added file:Exec@13226,file:Exec@20688 9cce47c664c920211c5f9ef290164c1b34962a2106f6a9bc7b797fcc4d71092a
+@legacy d94d8d07152e015dc1f629f8c9293701d556428ea2be291694957d1469cc31ed internal/console/store.go Store.migrateAppsKey legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console.service user carlos-console, J4 root-input: copies apps into the composite-key schema while preserving existing lifetimes and minting only missing ids;rev3=census-ruling-app-region-set;basis=carries region_set_at across the apps rebuild (column list and INSERT ... SELECT); console-owned table only; no read added file:Exec@2425,file:QueryRow@65 a6d4f9c819c32c9d311e793e3de0cbd9aa4f387fbaf3ca85b0e03d732a93182f
+@legacy bdd627c48bd58792268d2891089790829fad8ce6ef50ab0ac29352ecc9539524 internal/console/templates/app_settings.html external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-design-edge-rate-limit-358;basis=the Settings page gains a Rate limit section: per instance host, a form of four numbers (busy at, per address while busy, backstop rate, backstop burst) and a reset form, both posting to /a/{sqid}/apps/{app}/ratelimit with the CSRF token, and the record's path rules listed read-only; embedded and rendered by the console (carlos-console), as before; no read added;rev3=census-ruling-console-ux-nav;basis=adds the Placement section (the existing POST /place form, moved from app_instances) and the Errors and analytics section; Advanced folds into General; link texts reworded; markup only; no read added;rev3=census-ruling-region-labels;basis=General gains a Region section (RC-18a, RC-18d, RC-19, RL-S1, or the unread sentence); the placement form's button reads Change fleet (RC-14); markup only; no read added;rev3=census-ruling-app-region-set;basis=the General Region section gains, for an owner or a deployment operator, a select of region codes and a Change region button posting to /a/{sqid}/apps/{app}/region with the CSRF token, and a note; markup only; no read added file:external@0 9a9cd510dbd50d7362db8355ecca9226eaf2c05dc89fe46ac33aa22abb33fca9
+internal/console/server.go NewServer legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console construction adds the lifetime judge, the cutover admission gate and its first marker read; claims-off app materialisation moves to the cutover watch; the existing logs/data route literal moves and is not a filesystem read;rev3=census-ruling-plans-4d-lapse;basis=registers GET and POST /a/{sqid}/plan/keep (the owner-only keep page, plans 4d) beside the account settings routes; no goroutine; read sites unchanged, offsets moved;rev3=census-ruling-plans-6-checkout;basis=refuses Config.Billing without a plan catalog, sets the billing runtime from Config.Billing, and registers POST /billing/webhook beside /api/ses/events; no goroutine and no store call; the one data-literal is still the logs/data route pattern, moved; no read added;rev3=census-ruling-console-perf-1;basis=takes cfg.Perf (or makes its own perf.Recorder), builds the instance fetcher after it so app-host calls are counted, and wraps the mux in perf.Middleware with /healthz skipped; no read added, read site unchanged;rev3=census-ruling-console-ux-nav;basis=GET /deployments now registers handleAppDeploymentsRedirect and GET /pipeline handleAppPipelineRedirect (named handlers in appredirect.go that call appRedirect for /releases and /settings/pipeline, after accountApp's gates) instead of their handlers; route registration only; no root read added, read site unchanged;rev3=census-ruling-app-region-set;basis=registers POST /a/{sqid}/apps/{app}/region (handleAppRegionSet, appregionset.go) beside the rename route; route registration only; no read added, read site unchanged data-literal@10574 b9b22ee5933f80618afa83e46c228632af67a7d2e5a15d3dae4a11dddff4bf77
+internal/console/store.go Store.NonHomeAppRegions legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-app-region-set;basis=selects max(created_at, region_set_at) instead of created_at, so a record from before an app region change is not a discrepancy candidate; the same one console-owned SQLite query; no read added file:Query@80 6ca73e6f90e7b0a8f373bc8b9c6bb8011f3471ecb54519a0d604ef6854ca9388
+internal/console/store.go Store.migrate legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console.service user carlos-console, J4 root-input: adds the three account/app-scoped lifetime intent tables and apps.lifetime at unarmed store boot, then backfills missing lifetimes;rev3=census-ruling-plans-4d-lapse;basis=adds the additive account_plans.lapse_since and account_plans.disabled columns and calls migratePlanLapse last, which creates the console's own plan_lapse_items table (plans 4d). No read added; the new store units are the plans-4d-units decision.;rev3=census-ruling-plans-6-checkout;basis=calls migrateBilling last, after main's migratePlanLapse, which creates the console's own billing tables (plans 6a, its own decision row); no read added here;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 9: calls migrateAppPolicy (a new unit: CREATE TABLE IF NOT EXISTS app_policy_revisions, the console's own table) before migratePlanLapse. The same two Exec sites; no read added here.;rev3=census-ruling-app-region-set;basis=adds the additive apps.region_set_at column (INTEGER NOT NULL DEFAULT 0) to the ALTER list; the same two Exec sites; no read added file:Exec@13226,file:Exec@20688 9cce47c664c920211c5f9ef290164c1b34962a2106f6a9bc7b797fcc4d71092a
+internal/console/store.go Store.migrateAppsKey legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=console.service user carlos-console, J4 root-input: copies apps into the composite-key schema while preserving existing lifetimes and minting only missing ids;rev3=census-ruling-app-region-set;basis=carries region_set_at across the apps rebuild (column list and INSERT ... SELECT); console-owned table only; no read added file:Exec@2425,file:QueryRow@65 a6d4f9c819c32c9d311e793e3de0cbd9aa4f387fbaf3ca85b0e03d732a93182f
+internal/console/templates/app_settings.html external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-design-edge-rate-limit-358;basis=the Settings page gains a Rate limit section: per instance host, a form of four numbers (busy at, per address while busy, backstop rate, backstop burst) and a reset form, both posting to /a/{sqid}/apps/{app}/ratelimit with the CSRF token, and the record's path rules listed read-only; embedded and rendered by the console (carlos-console), as before; no read added;rev3=census-ruling-console-ux-nav;basis=adds the Placement section (the existing POST /place form, moved from app_instances) and the Errors and analytics section; Advanced folds into General; link texts reworded; markup only; no read added;rev3=census-ruling-region-labels;basis=General gains a Region section (RC-18a, RC-18d, RC-19, RL-S1, or the unread sentence); the placement form's button reads Change fleet (RC-14); markup only; no read added;rev3=census-ruling-app-region-set;basis=the General Region section gains, for an owner or a deployment operator, a select of region codes and a Change region button posting to /a/{sqid}/apps/{app}/region with the CSRF token, and a note; markup only; no read added file:external@0 9a9cd510dbd50d7362db8355ecca9226eaf2c05dc89fe46ac33aa22abb33fca9
+@coverage . 35092e4af1e6da9b70857f55eb1aaa26751c06e31020f5b100ffdf27eeed8fda
+@coverage internal/console f81dbf9f4361baa298d7da0f87777d82b42e946bfbbe09680ed21af69ffb19ad
+@coverage internal/console/templates 31b5a71a123d232e2f36cd8032b5ff8d9f43c1474f203c81b2dd1852aeedc6e7
+@coverage internal/regionlabel a4cc5a2ff624a1aa3215c711302c7dc68d2bdca9853eadc372f31a8c99113872
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index f814feea2..a70137945 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -57,3 +57,4 @@ plan14-root-reads-instance-egress-sizes-328-329-new.tsv aa6c6832fe50f05ab771ebe2
plan14-root-reads-instance-egress-sizes-328-329.tsv c1ab16d1d7eaccb3928a4fd5f74f8fc931221cbd67d5d751a63354984c7b249f
plan14-root-reads-region-labels-decisions.tsv b265c2ae74edbaca766d33e085d31a8e7c6f86883d12d0ed4472bd99a7c3278d
plan14-root-reads-region-labels.tsv d1e00cfb29d88b7a8e4998b641164e539067a6e1e9e4f52524255343c0c5f9f7
+plan14-root-reads-app-region-set.tsv 798a1ee3d8c8b775f963b9ae1dbc45e18628fa0c1e63404f46606601766ad66c