Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Store Context & First-Run Setup
Status: In Progress (Phases 1–3 implemented; Phase 3 country-aware setup shipped 2026-08-15; 6.1 cleanup pending)
Target: Spree 6.0
Depends on: 6.0-platform-auth.md (auth stack), 5.5-admin-api-key-scopes.md (shipped), 6.0-admin-rbac.md (role/membership model), 6.0-drop-country-state-models.md (countries-gem value objects that setup derives currency/locale from)
Author: Damian Legawiec + Claude
Last updated: 2026-08-15
Summary
Two related gaps in the headless stack. First, store context is resolved wrong everywhere: the v3 API resolves every request to Spree::Store.default — the configured finder (Spree::Stores::FindDefault) accepts the request hostname and discards it, the admin SDK sends X-Spree-Store-Id on every request but no server code reads it, and API keys are validated against the already-resolved store instead of selecting it. The dashboard is fully multi-store in its URL structure (/$storeId/..., store switcher) and the backend silently ignores all of it. Second, installation mints a dummy admin ([email protected] / spree123) with hardcoded credentials duplicated across three codebases, and there is no way to create an admin account or a store outside seeds and invitations. This plan makes store context explicit and credential-derived (no hostname resolution anywhere), and replaces the dummy-admin seed with a first-run setup flow: a one-time, token-guarded screen in the dashboard that creates the first admin account and names the store — the Medusa-style onboarding.
Key Decisions (do not deviate without discussion)
- No hostname-based store resolution in the APIs — ever. (2026-08-13) Store context is explicit and credential-derived: the publishable key selects the store on the Store API,
X-Spree-Store-Id(validated against role membership) selects it on the Admin API, and a secret key is bound to its store. Hostname resolution was a requirement of the server-rendered era (admin + storefront per subdomain) and is retired with it.Spree.current_store_finderremains as an override point, andFindDefaultremains the single-store fallback. - The key selects the store; the store never validates the key. (2026-08-13) Today's flow is inverted:
current_storeresolves first (to the default store) and the key is nulled on mismatch. New flow: authenticate the credential, then setSpree::Current.storefrom it. This implements what the auth docs already claim ("publishable key identifies the store"). - Admin API honors
X-Spree-Store-Id. (2026-08-13) JWT staff sessions resolve the requested store by prefixed ID and are checked for membership against that store (the check exists today but runs against the default store, so the store switcher silently lies). Secret keys ignore the header for selection — the key's ownstore_idwins; a conflicting header is a 403. - First-run setup replaces the dummy admin. (2026-08-13) When no admin user exists, the dashboard shows a setup screen (create admin account + name the store) instead of login, backed by one-time endpoints under
auth/. TheSeeds::AdminUserdummy defaults are removed: the seed only creates an admin whenADMIN_EMAIL/ADMIN_PASSWORDare explicitly set (CI, worktrees, and scripted installs keep working by passing them). - The setup endpoint is guarded by a one-time setup token in every environment. (2026-08-13) The zero-admins gate alone leaves a freshly deployed instance claimable by whoever finds the URL first. The token lives on
Spree::Storeviahas_secure_token :setup_token(amended 2026-08-13: no separate digest table — plaintext at rest matches the invitation-token posture, and only means anything while the database holds nothing but seed data). Generated at store creation, printed by the installer and reprintable bybin/rails spree:setup:token(ROTATE=1issues a fresh one), required by the setup endpoint, cleared on completion, and dead permanently once the first admin exists. Same rule in development — dev tooling seeds explicit credentials instead, so the setup flow never engages there unless you want to exercise it. - No general store CRUD in the OSS Admin API. (2026-08-13) First-run setup configures the one store; creating additional stores is out of scope for open core (multi-store provisioning is an enterprise concern). The singular
resource :store(show/updateoncurrent_store) stays as-is. - First-run setup adopts and renames the seeded store; it never creates one. (2026-08-13)
Seeds::Storeskeeps creating the default store duringdb:seed(dozens of downstream seeds depend on it existing), and the setup flow renames/configures it. One code path for store creation — the seed — and setup stays a pure "claim this installation" step. - Admin API requests without the header keep resolving to the default store through 6.0, removed in 6.1. (2026-08-13) The SDK always sends the header, so this only affects hand-written curl/scripts against a single-store install — where the default store is the right answer anyway. A deprecation warning logs when a JWT request omits the header; 6.1 makes it required.
- First-run setup asks for the store's country and locale; currency is derived from the country and shown, never typed. (2026-08-15) The seed can only guess a country (US), and the guess is baked into every country-shaped default it creates. Setup is where the merchant is actually asked, so it collects
country_code(required) andlocale(a choice), derivescurrencyfrom the country through the countries gem — the same derivationStores::Markets#ensure_default_marketalready performs at store creation — and displays it read-only so the merchant sees what they are getting (Switzerland → CHF, not EUR). Amended 2026-08-15 (same day, after review): read-only was too strict — shipping from Warsaw while pricing in euros is ordinary, and the screen made it impossible. Currency is a picker with the country's own currency leading the list and preselected, re-derived whenever the country changes;currencyreturns to the request contract as optional, defaulting to the country's. It is validated rather than silently ignored (the original silent-ignore path is still retired): an unresolvable code is a pre-token-spend 422, likecountry_code. The same reasoning applies to locale, which was already a picker. Locale options are the chosen country's official languages plus English, English preselected — short and relevant, with the Markets page as the place to add more later; every-locale-the-browser-can-name was rejected as too much choice for a one-shot screen where backend strings fall back to English anyway. - Setup writes the bootstrap market, never the store's legacy columns. (2026-08-15) Once a store has a market, the market is authoritative for country/currency/locale (
Spree::Stores::Marketsreaders delegate to it), butStore#default_country_code=only seeds the market throughafter_createand theafter_updatesync copies locale and currency only — sostore.update!(default_country_code: 'DE')on a seeded store writes a dead column whilestore.default_country_codekeeps answeringUS(verified 2026-08-15). The store settings endpoint permits none of these columns, so the only writer is setup; rather than fix a bridge nobody else uses, setup updates the market itself (country_codes,name,currency,default_locale) — the shapedb/sample_data/markets.rbalready uses. The@default_country_for_marketbootstrap hint stays for store creation. Post-creation country changes go through the market, full stop. - One provisioning service owns every country-derived per-store default, and both install paths call it. (2026-08-15) Four seeds bake the seeded country/currency in:
StockLocations(warehousecountry_code),DeliveryZones(Domestic = seeded country, International = everyone else, both flat rates in the seeded currency),PickupDelivery(pickup calculator currency), and the bootstrap market itself. Rewriting them after the fact — the first sketch — leaves stale "Domestic = United States" data behind whenever a rewrite step is missed. Instead these defaults are born from the merchant's answer:Spree::Stores::ProvisionDefaults.call(store:, country:, locale:)updates the bootstrap market and creates the stock location, delivery zones + methods and pickup method in the right country and currency, andSeeds::Allstops running those seeds directly. The setup endpoint calls it inside its existing store lock; the env-credential path (Seeds::AdminUserwithADMIN_EMAIL/ADMIN_PASSWORD) calls it withSTORE_COUNTRY/STORE_LOCALE(defaultsUS/en) so CI, worktrees and e2e stay byte-for-byte unchanged while a scripted non-US install gets the right zones without the dashboard. Digital delivery, tax categories, product types, roles, API keys keep seeding as today — they carry no country opinion. - Sample data adds markets around the default market and never overwrites it. (2026-08-15)
db/sample_data/markets.rbforce-reset the default market toUS/USD/en/US+CA, which would silently flip a store set up as German back to a US store the first time someone loads sample data. Sample data now reads the existing default market and builds its regional markets around it (skipping countries the default already claims); it also creates the Domestic/International zones it depends on when they are absent, instead of aborting. - The setup screen gets its country data from a dedicated unauthenticated endpoint. (2026-08-15)
GET /api/v3/admin/auth/setup/countriesreturns each country's code, name, derived currency and official-language locales, computed server-side from the countries gem — one source of truth, shared with the market bootstrap. Guarded exactly like the setup endpoint (rate-limited, 404 once an admin exists). Folding the list intoGET /auth/setupwas rejected because the login page polls that endpoint for its setup notice and would fetch ~250 rows per page load; a static map in the SDK was rejected as a second source of truth that drifts from the one the server builds the market with.
Design Details
1. Store API: publishable key selects the store
Spree::Api::V3::ApiKeyAuthentication#authenticate_api_key! changes from
@current_api_key = current_store.api_keys.active.publishable.find_by(token: extract_api_key)
to a global lookup followed by context assignment:
@current_api_key = Spree::ApiKey.active.publishable.find_by(token: extract_api_key)
# then: Spree::Current.store = @current_api_key.store
current_store in the Store API base becomes an alias for the key's store. Channel binding (5.6-store-channel-context-and-key-binding.md) is unaffected — the bound channel already belongs to the key's store. Guest cart tokens keep their existing store-scoped lookups, which now scope against the key-derived store.
2. Admin API: X-Spree-Store-Id header
A StoreContext concern in the v3 Admin base controller resolves current_store in this order:
- Secret key →
@current_api_key.store. If the header is also present and names a different store → 403. - JWT + header →
Spree::Store.find_by_prefix_id(header); unknown ID → 404.require_store_membership!then runs against this store (today it runs against the default store — the actual bug behind the inert store switcher). - JWT, no header →
Spree::Store.default+ deprecation log line (removed in 6.1).
Spree::Current.store is set from the result before any authorization runs, so every current_store.<association> lookup, Ransack scope, and cache key downstream is against the requested store. No dashboard changes are needed — the SDK already sends the header and the routes already carry $storeId. Two small SPA cleanups ride along: _authenticated/index.tsx drops its literal 'default' fallback ID, and store-provider.tsx's query becomes honest (the storeId key now actually varies the response).
3. First-run setup flow
Endpoints (unauthenticated, rate-limited like login, mounted under auth/ so the refresh-cookie path matches — same shape as invitation acceptance):
GET /api/v3/admin/auth/setup→{ "setup_required": true | false }. True only while zero admin users exist. Safe to expose: it leaks one boolean that is also self-evident from a fresh install.POST /api/v3/admin/auth/setup→ params:setup_token,email,password,first_name,last_name,store_name,country_code,locale. Guards, in order: admin count is zero; the submitted token matches the store'ssetup_token(secure_compare), re-checked under a lock on the store so concurrent submissions cannot both spend it;country_coderesolves to a real country (422 before the token is spent — setup is one-shot, so a wrong country would be unrecoverable in-band). Effects, in one transaction: create the admin user,add_userwith theadminrole on the default store, rename the store, runStores::ProvisionDefaults(below) for the chosen country/locale, clear thesetup_tokencolumn. Then issue the refresh cookie + JWT exactly likeInvitationAcceptancesControllerand return the admin-user payload. Any later call 404s (setup no longer required). Amended 2026-08-15:currencyis no longer a request parameter — it is derived fromcountry_codeserver-side, the same way the market bootstrap derives it;country_codemoved from optional to required, andlocalewas added. Clients built against the earlier optional-currencycontract get a 422 naming the missing country rather than a silently US-shaped store.GET /api/v3/admin/auth/setup/countries→{ "countries": [{ "code", "name", "currency", "locales" }] }, every country the countries gem knows, withcurrencyits ISO 4217 code andlocalesits official languages (may be empty). Same guards as the setup endpoint: rate-limited on the login budget, 404 once an admin exists. Exists because the setup screen runs before any credential does, so it cannot use the authenticated countries endpoint, and because deriving currency client-side would be a second source of truth (see Key Decisions).
Setup token mechanics. The token is a has_secure_token :setup_token on Spree::Store — generated when the seed creates the default store, so a repeated db:seed reprints the same URL. Store#setup_url builds it on top of Spree::Stores::DashboardUrl, the single resolver for "where is the dashboard" now shared by the setup link, invitation emails and the SSO callback: Spree::Config[:dashboard_url] (env-backed, see below) → the deprecated admin_url → this app's own /dashboard mount when spree_dashboard is installed with a build to serve → the Vite dev server in development → the store's own URL.
The chicken-and-egg problem the mount solves (2026-08-13). The setup link is printed by db:seed, which runs before anything is serving the dashboard — and under create-spree-app it runs inside a container, where the host's Vite port is unknowable. Two answers, one per install path. A plain Rails app (spree:install, template.rb) links at its own /dashboard, which the app serves itself the moment it boots — no second process, which is why the mount outranks the Vite guess: it is a fact about the deployment rather than an assumption about the developer's setup. The CLI keeps only the token from the seed output and rebuilds the URL against the dashboard it is about to launch (dev server if runnable, else the API's bundled mount), since it alone knows the host-side ports.
App configuration reads the environment (2026-08-13). RuntimeConfiguration.preference takes an env: option, so an app-level setting can be configured from the deployment environment instead of Ruby, with precedence explicit value → env var → coded default. dashboard_url is the first adopter (SPREE_DASHBOARD_URL) because the setup link is printed by db:seed, before anyone can reach a console to set a preference, and every worktree and container has a different dashboard origin (worktree provisioning writes it into server/.env). admin_url is deprecated in its favour — both named the same origin, and the split was a legacy-admin artifact. The option is deliberately limited to Spree::Config; per-store behavior belongs in Store preferences, which one global env var cannot express. bin/rails spree:setup:token prints the current link (generating one for stores predating the column; ROTATE=1 rotates). The setup endpoint compares with secure_compare behind the zero-admins gate and clears the token when setup completes, so the flow is dead on every install that seeds credentials explicitly. Plaintext at rest, deliberately — the same posture as invitation tokens, and the token only works while the database contains nothing but seed data.
Dashboard. A fifth unauthenticated route, /setup: reads ?token=, calls the lookup endpoint, renders the account + store form (same form/error conventions as invitation acceptance), and on success lands in /$storeId. The login page checks setup_required and links to /setup when true (covering the "opened /login first" path — they'll still need the token from the install output).
Country-aware setup form (2026-08-15, as shipped). The store section of the form grows a country combobox (required, fed by auth/setup/countries), a locale picker whose options are the chosen country's official languages — filtered to those Spree translates — plus English, and a currency picker with the country's own currency leading the list. Choosing a country re-derives both: the country's first official language and its currency are selected, and both stay editable (a Warsaw merchant pricing in euros, or running a Polish store in English). The form submits country_code, locale and currency; the last two are optional to the endpoint, which falls back to the country's own.
Spree::Stores::ProvisionDefaults (2026-08-15). One Tier-1 service (app/services/, plain call(store:, country:, locale:)) that owns every per-store default whose shape depends on the store's country or currency, in one transaction:
- the bootstrap market:
country_codes = [country],name = country.name,currencyderived from the country,default_locale = locale(updated in place, never a second market — the shapedb/sample_data/markets.rbuses); - the default stock location,
country_codeset to the country; - the Domestic zone (the country) and International zone (every other country) with their
Standard/International Shippingflat-rate methods priced in the derived currency; - the pickup method, its zero-amount calculator in the derived currency (still riding the store's default delivery profile and opening the default location for collection);
and nothing else — digital delivery, tax categories, product types and API keys carry no country opinion and keep their rows in Seeds::All. One exception to "creates only": it normalizes the currency of already-seeded zero-amount rates, because digital delivery is seeded before anyone names a country and its calculator would otherwise quote a Swiss store in dollars. That is a currency restatement, not row creation, and it never touches a method the merchant has priced. Idempotent by identity (find-or-create by name/default flag, same posture as the seeds it absorbs), so re-running is safe. Two callers only: the setup endpoint inside its store lock, and Seeds::AdminUser's env-credential branch with STORE_COUNTRY/STORE_LOCALE/STORE_CURRENCY (defaults US/en, currency from the country). No third caller — a merchant changing country later edits markets/zones/locations directly, and the service must not become a "reset my store" button.
4. Seed and tooling changes
Seeds::AdminUser: dummy defaults removed. Creates an admin only whenADMIN_EMAILandADMIN_PASSWORDare both set; otherwise defers to the setup-token flow. The existing table-widecount.zero?guard stays (it is the same gate the setup flow uses).@spree/cliinit: prompts for admin email/password (Medusa-style) with a--no-adminescape that prints the setup URL instead; deletes the hardcodedDEFAULT_ADMIN_EMAIL/DEFAULT_ADMIN_PASSWORDconstants — the success card echoes whatever was actually used.spree/template.rb,scripts/worktree/setup.sh, e2e global setup, Docker scripts: passADMIN_EMAIL/ADMIN_PASSWORDexplicitly (worktrees and e2e keep[email protected]/spree123as their explicit choice — dev docs stay true).spree:cli:create_adminrake task: made idempotent (find-or-create by email), fails loudly when theadminrole is missing instead of silently minting a role-less user.- Country-derived seeds move behind
ProvisionDefaults(2026-08-15).Seeds::Allstops callingStockLocations,DeliveryZonesandPickupDeliverydirectly; the three classes are deleted with their behavior absorbed by the service (they were only everSpree::Store.find_eachloops around the same find-or-create).Seeds::Storeskeeps creating the store (with the market bootstrap it triggers) and the setup token.Seeds::AdminUser's env-credential branch calls the service after creating the admin, readingSTORE_COUNTRY(ISO 3166-1 alpha-2, defaultUS) andSTORE_LOCALE(defaulten); its setup-token branch calls nothing — the merchant answers on the setup screen. Net effect on a baredb:seedwithout credentials: a store with a market, tax categories, product types, digital delivery, roles and keys, but no warehouse, zones or pickup until setup runs — which is correct, since nobody has said where the shop is yet. - Sample data (
db/sample_data) reads the existing default market instead of resetting it, builds its regional markets around it, and creates the Domestic/International zones itself when they are missing (fulfillment.rbaborted on their absence). Under the CLI sample data only loads when an admin was seeded, so the setup path is unaffected either way; the change protects the manualspree:load_sample_dataafter setup.
5. Store model fixes (ride-along)
Spree::Store#set_default_codecurrently defaultscodeto the literal'default', which collides with the unique index the moment a second store is created (the enterprise provisioning path hits this immediately). Fix: derive fromparameterize(name)with a numeric suffix on conflict; keep'default'only for the very first store for back-compat with tooling that references it.ensure_default_exists_and_is_uniquekeeps its demote-others behavior (correct for a single-default invariant) but gains a spec pinning it, since provisioning code will lean on it.
Migration Path
- Phase 1 — store context. Key-selects-store inversion in
ApiKeyAuthentication;StoreContextconcern in the Admin API base honoringX-Spree-Store-Id; membership check against the requested store; deprecation log on header-less JWT requests; SPA fallback cleanups. No client changes required — the SDK already sends everything. Shipped 2026-08-13 (KeyStoreContext+Admin::StoreContextconcerns; dashboardsetStoremoved to the$storeIdroute'sbeforeLoadso the header is set before any query fires). Two token-in-URL public endpoints resolved their store context explicitly: digital downloads derive the store from the globally unique link token (the token IS the credential), and data feeds serve the default store (slugs are only unique per store; matches the old finder's effective behavior — a store-carrying feed URL shape is future work). - Phase 2 — first-run setup.
setup_tokencolumn onspree_stores, seed changes, the twoauth/setupendpoints, the/setupdashboard route, CLI/template/scripts updates,spree:setup:tokenrake task. Shipped 2026-08-13 (has_secure_token :setup_tokenon Store;Seeds::AdminUserenv-only;spree:cli:create_adminmade idempotent;spree initprompts for credentials,spree devreads the remembered email; create-spree-app no longer prints dummy credentials; worktree template passes explicit credentials). - Phase 3 — country-aware setup. Shipped 2026-08-15.
Spree::Stores::ProvisionDefaultsabsorbing the three country-derived seeds (StockLocations/DeliveryZones/PickupDeliverydeleted);Seeds::AdminUserenv branch calling it withSTORE_COUNTRY/STORE_LOCALE; setup endpoint requiringcountry_code, addinglocaleand an optional validatedcurrency, running the service in its lock;GET auth/setup/countries;Spree::Country#official_locales; sample data reading rather than resetting the default market (and the Europe market skipping the home country) plus provisioning its own zones instead of aborting; dashboard form (country, locale and currency pickers, each defaulted from the country; button triggers so browser address autofill cannot cover the lists) +auth.setupCountries()+ types + translations in all six locales; OpenAPI regenerated. Verified end to end against a live install: a bare seed leaves no warehouse/zones/pickup, and completing setup asCH/fryields a Swiss market, Swiss warehouse, Domestic = Switzerland and every rate in CHF, which survives a fullspree:load_sample_data. One addition beyond the plan:restate_seeded_calculatorsrewrites the seeded zero-amount digital-delivery rate into the store currency — it is seeded before the country is known and would otherwise quote in dollars on a Swiss store; a merchant's own priced methods are never touched. - 6.1 cleanup. Header becomes required for JWT Admin API requests;
FindDefault's ignoredurl:parameter is dropped from the finder contract.
6. Isolation tripwires (added 2026-08-13)
Open-core isolation rests on the controller discipline — every lookup through a current_store association — because row-level enforcement is deliberately not a core feature. Two nets now sit under that discipline:
Spree::StoreScopeGuard— development/test only, wrapped around every v3 API request. ASELECTagainst a store-owned table (anyspree_*table with astore_idcolumn, derived from the schema — no registry) that carries nostore_idpredicate is reported with the SQL and call site. Modes viaSPREE_STORE_SCOPE_GUARD/Spree::Config[:store_scope_guard]:log(default),raise(this repo's API suite),off. Deliberately global lookups (credential searches — the key selects the store) opt out withSpree::StoreScopeGuard.skip { }, which doubles as documentation.watchable_environment?is overridable so a multi-tenant enforcement layer can run the guard as a production log-mode canary; the schema-derived watched set means tables stamped withstore_idlater are watched with zero registration.- Cache-key audit — a static spec (
spec/lib/spree/store_scoped_cache_keys_spec.rb) walks everyRails.cachecall site in core and api: each must visibly carry the store (or a recordcache_key_with_version) in its key, or hold a reviewed allowlist entry justifying why the data is global. A new unscoped call site fails the suite with instructions. The audit also fixed a real one: idempotency replay caching was keyed per credential but not per store, so a staff JWT reusing anIdempotency-Keyacross stores replayed the first store's response — the key now partitions by the resolved store. - List-position audit — a store-owned model with an unscoped
acts_as_listnumbers positions across the whole table, shifting every store's rows on create/reorder; a spec (spec/lib/spree/store_scoped_list_positions_spec.rb) fails on any such model. PaymentMethod shipped that bug — fixed withscope: :store_idplus a per-store renumber inspree:upgrade:populate_single_store_associationsfor upgraded data.
Honest coverage, and the next increment. The guard exempts id/FK filters (loads from rows already reached through a scoped association) and SELECT 1 AS one existence checks (dominated by uniqueness validations on deliberately global columns, like document numbers) — so its net is secondary-key lookups and unscoped scans, with attacker-controlled raw ids covered structurally by for_store(current_store) in resource controllers. Coverage follows the store context, not the entry point (2026-08-14). Spree::Current#store= arms the guard for the rest of that unit of work, so anything declaring a store — jobs, the webhook controllers (which inherit ActionController::API directly and never saw the v3 around_action), console scripts, entry points not yet written — is watched with no registration. The latch lives on Spree::Current because CurrentAttributes is what Rails resets per request and per job; a RequestStore flag would leak across jobs on a reused worker thread. Deliberately asymmetric: work that never declares a store stays unguarded, since reading the default store through Spree::Current.store's fallback is not a scoping claim worth checking — guarding all 35 jobs unconditionally would produce noise rather than signal. The v3 around_action stays for the window before store resolution. First harvest of the tripwires beyond the guard's own findings: the pickup-location fallback listing every store's counters, the stock-location default flag demoting across stores, variant stock items propagating into every store's warehouses, and data-feed name uniqueness blocking reuse across stores.
Constraints on Current Work
- Never assume
current_store == Spree::Store.defaultin Admin API controllers, serializers, or jobs — after Phase 1 the requested store can be any store the caller has a role on. The existing rule (every lookup throughcurrent_store.<association>) is what makes this safe; violations are now cross-store leaks, not just IDOR risks. - No new hostname-based store logic anywhere — don't read
request.host/SERVER_NAMEto pick a store, don't add URL-matching to finders. - Store-touching cache keys must include the store id by construction (
cache_key_with_versionon the store, or an explicit store-id component), never a bare global key — enforced by the cache-key audit spec; genuinely global data gets a reviewed allowlist entry there, not an exemption in review. - A deliberately store-less query in request handling wraps itself in
Spree::StoreScopeGuard.skip— an unscoped lookup on a store-owned table inside an API request otherwise fails the API suite. - New scripts and tooling must pass
ADMIN_EMAIL/ADMIN_PASSWORDexplicitly instead of relying on the dummy defaults, which are removed at 6.0. - A store's country is changed through its market, never through
Store#default_country_code=— on a store that already has a market that writer updates a dead column (the readers delegate to the market). Setup, sample data and any future provisioning code update the default market'scountry_codes/name/currency/default_localedirectly. - A new seed that depends on the store's country or currency goes into
Stores::ProvisionDefaults, notSeeds::All— the seed runs before anyone has said where the shop is; only the provisioning service knows. Country-neutral seeds (reference data, tax categories, product types, keys) stay inSeeds::All. ProvisionDefaultshas exactly two callers (setup endpoint, env-credential seed branch). Don't wire it to a settings page or an admin action — post-setup changes edit markets/zones/locations directly, and re-running it against a configured store would be a data reset.- Sample data never overwrites the default market — it reads whatever the merchant (or the env seed) chose and builds around it.
Open Questions
None — the 2026-08-15 country-aware setup questions (where the setup screen gets its country data, which locales it offers, whether the env seed path can pick a country) were all resolved the same day; see Key Decisions.
References
docs/plans/6.0-platform-auth.md— auth stack this builds ondocs/plans/6.0-admin-rbac.md— role membership model used by the store checkdocs/plans/5.6-store-channel-context-and-key-binding.md— channel binding on publishable keys (unaffected, composes)spree/core/app/finders/spree/stores/find_default.rb— the finder that discards its hostnamespree/api/app/controllers/concerns/spree/api/v3/api_key_authentication.rb,admin_authentication.rb— inverted key validation + membership checkspree/core/app/services/spree/seeds/admin_user.rb— the dummy-admin seedpackages/admin-sdk/src/client.ts—X-Spree-Store-Idheader (already sent)spree/api/app/controllers/spree/api/v3/admin/invitation_acceptances_controller.rb— the pattern the setup endpoints followspree/core/app/models/concerns/spree/stores/markets.rb— the market-authoritative readers and the create-only country bootstrap that setup must not rely onspree/core/db/sample_data/markets.rb— the update-the-bootstrap-market shapeProvisionDefaultsfollows; must stop resetting the default market to USspree/core/app/services/spree/stores/provision_defaults.rb— the provisioning service that absorbed the deletedSeeds::StockLocations/DeliveryZones/PickupDelivery