Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

REFACTOR (docs): Archive the seeded admin replacement and add its spec

Rostislav Dugin418b64a67d6a
diff --git a/openspec/changes/archive/2026-09-20-replace-seeded-admin-with-first-signup/design.md b/openspec/changes/archive/2026-09-20-replace-seeded-admin-with-first-signup/design.md
index 1a36f20a..d03b22f2 100644
--- a/openspec/changes/archive/2026-09-20-replace-seeded-admin-with-first-signup/design.md
+++ b/openspec/changes/archive/2026-09-20-replace-seeded-admin-with-first-signup/design.md
@@ -243,7 +243,7 @@ Where a test is not the right instrument, and the task says so instead of preten
- **The migration meets an instance whose seeded account was never claimed, but which already holds members.** -> Deleting the row there would leave members with no administrator and no way to appoint one, so the row is kept and flagged instead, and its owner takes it over with the reset command. This is the shape the earlier plan got wrong, and it is reachable without anything unusual: `POST /users/signup` answers whether or not the claim screen offers registration.
- **The console command cannot reach the metadata database.** -> Every console command is affected today, not only this one, and `restore-console-command-database-access` fixes it. This change lands after it, and its verification runs the command through `docker exec` on a running container so the defect cannot hide behind a local database.
- **A test silently depends on how many accounts the instance holds.** -> Slot databases are shared across packages within a run and nothing empties the `users` table, so the precondition is stated explicitly: a test that needs an empty instance empties it, and a test that needs a populated one creates an account.
-- **A privilege check is missed and the owner silently loses a power.** -> This is the change's main failure mode, and it is why the inventory above is exhaustive rather than illustrative and why the tasks cover each of the three management privileges with its own test. After the change, `"admin"` should survive in production code only in the MongoDB feature, which means something else entirely by it.
+- **A privilege check is missed and the owner silently loses a power.** -> This is the change's main failure mode, and it is why the inventory above is exhaustive rather than illustrative and why the tasks cover each of the three management privileges with its own test. After the change, the literal `"admin"` should survive in backend production code only in the MongoDB feature, which means a database by it, and task 4.5 greps for exactly that. Two occurrences outside it are deliberate and stay: the sign-in form accepts `admin` as a login value (`SignInComponent.tsx:50`) because an upgraded instance still uses it, and the documentation names it as the address such an instance carries until its owner replaces it.
- **Two people register on an empty instance at the same moment.** -> The partial unique index admits one flagged account; the other registration proceeds as an ordinary one. The tasks cover it with a test that inserts the second flagged account directly and expects the database to refuse it.
- **An administrator sets an address that belongs to somebody else, and that somebody signs in through Google or GitHub.** `getOrCreateUserFromOAuth` (`user_services.go:891-900`) links an OAuth identity to an existing account by matching the email address. The behavior is unchanged by this change, but the bootstrap account was previously out of its reach, because no OAuth provider returns the address `admin`. A typo in the domain of an administrator address therefore hands the owner of that mailbox a route into the most privileged account on the instance. -> Not mitigated here: the same exposure already applies to every invited user, and narrowing it means changing how OAuth links accounts, which belongs in its own change. Recorded so that the change that narrows it knows this account is now in scope too.
- **Password reset by email starts working for the bootstrap account.** This is an intended consequence rather than a risk, but it is a behavior change: an account that could never be reset by email now can be, and the reset flow's own protections (active status only, three codes per hour, one-hour expiry, `user_services.go:557-571`) are what stands behind it.
diff --git a/openspec/changes/archive/2026-09-20-replace-seeded-admin-with-first-signup/tasks.md b/openspec/changes/archive/2026-09-20-replace-seeded-admin-with-first-signup/tasks.md
index 20be0780..e2c2397e 100644
--- a/openspec/changes/archive/2026-09-20-replace-seeded-admin-with-first-signup/tasks.md
+++ b/openspec/changes/archive/2026-09-20-replace-seeded-admin-with-first-signup/tasks.md
@@ -2,83 +2,89 @@ This change lands after `restore-console-command-database-access`. Console comma
## 1. Record the bootstrap administrator
-- [ ] 1.1 Create the migration with `make migration-create` under `backend/`: add `users.is_root_admin boolean not null default false`, add the partial unique index that allows at most one row to carry it, delete the seeded `admin` row when it has no password, no linked Google or GitHub identity **and is the only row in `users`**, and set the flag on the remaining `admin` row or, when none exists, on the oldest ADMIN-role account; write the down step that drops the index and the column. The "only row" condition is what keeps an instance that holds members while its seeded account was never claimed from losing its last administrator: registration answers on `POST /users/signup` whether or not the claim screen offers it, so that shape exists, and there the unclaimed row is kept and flagged instead of deleted. Verify with `make migration-up` then `make migration-down` on a scratch database, and check each shape by hand: a claimed `admin` row keeps its password and carries the flag, an unclaimed one alone on the instance is gone, an unclaimed one beside other accounts is kept and carries the flag, a renamed one leaves the flag on the oldest administrator, and an empty database backfills nothing. A test cannot stand in for this check - Goose has already run against the test databases before `go test` starts (`backend/Makefile:11-16`), so no test can observe an instance in the pre-migration shape.
-- [ ] 1.2 Add the field to the user model with `json:"-"`, the way `HashedPassword` and the OAuth ids carry it (`models/user.go:14-20`), so a handler that ever returns the model cannot leak it; add a repository lookup that finds the recorded bootstrap administrator by flag. No response shape changes: `GET /users/me` and the user list both build `UserProfileResponseDTO` rather than serializing the model (`user_controller.go:301`, `management_controller.go:91-101`), so there is nothing to assert about response bodies here. Verify with `make test` in `backend/` that the existing repository and controller suites still pass.
-- [ ] 1.3 Rebuild both bootstrap-account helpers in `backend/internal/features/users/testing/user_utils.go` on the flag. `RecreateInitialAdmin` (`:67-79`) retires the account currently holding the flag - found by flag, renamed and cleared in one statement - and creates a fresh flagged ADMIN account the way `CreateTestUser` (`:19-48`) does, panicking with a message that names what it could not find. `RecreateInitAdminAndGetAccess` (`:50-65`) returns the account that helper just created instead of reading it back with `GetUserByEmail(ctx, "admin")`, which would hand a nil user to `GenerateAccessToken` and panic. Selecting the outgoing account by address would no-op after any test that changes it (`user_repository.go:147-157`), leaving the next test without a bootstrap account. Verify with `make test` in `backend/` that all 11 call sites across `e2e_test.go`, `user_controller_test.go` and `management_controller_test.go` - 9 of them through `RecreateInitAdminAndGetAccess` - still get a usable bootstrap account and a working token.
-- [ ] 1.4 Add a test that pins the helpers against that failure: change the bootstrap address to a real one, call the helper, and confirm the fresh account carries the flag while the retired one holds neither the flag nor the old address; verify with `make test` in `backend/`.
-- [ ] 1.5 Add a test that the database refuses a second flagged account, by inserting one directly against an instance that already has a bootstrap administrator; verify with `make test` in `backend/`.
-- [ ] 1.6 Add an audit-log writer to `backend/internal/features/users/testing` that records the entries it receives, and use it in place of `AuditLogWriterStub` in all four test routers (`controllers/e2e_test.go:177`, `:196`, `:214`, `:232`), installing a fresh recorder per router so one test cannot read another's entries; delete the stub (`:255-258`). The services are package-level singletons and `SetAuditLogWriter` mutates them (`services/di.go:10-28`), and the four builders are called from about ninety sites, so keep their signatures and let a test reach the current recorder through `users/testing`. Verify with `make test` in `backend/` that the existing suites still pass with the recording writer installed.
-- [ ] 1.7 Add a helper to `backend/internal/features/users/testing` that empties the `users` table, so a test can put the instance in the state the new account-creation rule is keyed on. No test can assume that state: `cleanup_test_db` recreates the per-slot databases once per run (`backend/cmd/cleanup_test_db/main.go:64-97`), each binary claims a slot and releases it on exit (`internal/config/config.go:259-277`) so later packages inherit what earlier ones left, and around twenty packages outside `features/users` create accounts through `CreateTestUser`. Verify with `make test` in `backend/` that the suites still pass, and that a test calling the helper sees `GET /users/is-any-user-exist` answer false right afterwards (once task 2.6 lands).
+- [x] 1.1 Create the migration with `make migration-create` under `backend/`: add `users.is_root_admin boolean not null default false`, add the partial unique index that allows at most one row to carry it, delete the seeded `admin` row when it has no password, no linked Google or GitHub identity **and is the only row in `users`**, and set the flag on the remaining `admin` row or, when none exists, on the oldest ADMIN-role account; write the down step that drops the index and the column. The "only row" condition is what keeps an instance that holds members while its seeded account was never claimed from losing its last administrator: registration answers on `POST /users/signup` whether or not the claim screen offers it, so that shape exists, and there the unclaimed row is kept and flagged instead of deleted. Verify with `make migration-up` then `make migration-down` on a scratch database, and check each shape by hand: a claimed `admin` row keeps its password and carries the flag, an unclaimed one alone on the instance is gone, an unclaimed one beside other accounts is kept and carries the flag, a renamed one leaves the flag on the oldest administrator, and an empty database backfills nothing. A test cannot stand in for this check - Goose has already run against the test databases before `go test` starts (`backend/Makefile:11-16`), so no test can observe an instance in the pre-migration shape.
+- [x] 1.2 Add the field to the user model with `json:"-"`, the way `HashedPassword` and the OAuth ids carry it (`models/user.go:14-20`), so a handler that ever returns the model cannot leak it; add a repository lookup that finds the recorded bootstrap administrator by flag. No response shape changes: `GET /users/me` and the user list both build `UserProfileResponseDTO` rather than serializing the model (`user_controller.go:301`, `management_controller.go:91-101`), so there is nothing to assert about response bodies here. Verify with `make test` in `backend/` that the existing repository and controller suites still pass.
+- [x] 1.3 Rebuild both bootstrap-account helpers in `backend/internal/features/users/testing/user_utils.go` on the flag. `RecreateInitialAdmin` (`:67-79`) retires the account currently holding the flag - found by flag, renamed and cleared in one statement - and creates a fresh flagged ADMIN account the way `CreateTestUser` (`:19-48`) does, panicking with a message that names what it could not find. `RecreateInitAdminAndGetAccess` (`:50-65`) returns the account that helper just created instead of reading it back with `GetUserByEmail(ctx, "admin")`, which would hand a nil user to `GenerateAccessToken` and panic. Selecting the outgoing account by address would no-op after any test that changes it (`user_repository.go:147-157`), leaving the next test without a bootstrap account. Verify with `make test` in `backend/` that all 11 call sites across `e2e_test.go`, `user_controller_test.go` and `management_controller_test.go` - 9 of them through `RecreateInitAdminAndGetAccess` - still get a usable bootstrap account and a working token.
+- [x] 1.4 Add a test that pins the helpers against that failure: change the bootstrap address to a real one, call the helper, and confirm the fresh account carries the flag while the retired one holds neither the flag nor the old address; verify with `make test` in `backend/`.
+- [x] 1.5 Add a test that the database refuses a second flagged account, by inserting one directly against an instance that already has a bootstrap administrator; verify with `make test` in `backend/`.
+- [x] 1.6 Add an audit-log writer to `backend/internal/features/users/testing` that records the entries it receives, and use it in place of `AuditLogWriterStub` in all four test routers (`controllers/e2e_test.go:177`, `:196`, `:214`, `:232`), installing a fresh recorder per router so one test cannot read another's entries; delete the stub (`:255-258`). The services are package-level singletons and `SetAuditLogWriter` mutates them (`services/di.go:10-28`), and the four builders are called from about ninety sites, so keep their signatures and let a test reach the current recorder through `users/testing`. Verify with `make test` in `backend/` that the existing suites still pass with the recording writer installed.
+- [x] 1.7 Add a helper to `backend/internal/features/users/testing` that empties the `users` table, so a test can put the instance in the state the new account-creation rule is keyed on. No test can assume that state: `cleanup_test_db` recreates the per-slot databases once per run (`backend/cmd/cleanup_test_db/main.go:64-97`), each binary claims a slot and releases it on exit (`internal/config/config.go:259-277`) so later packages inherit what earlier ones left, and around twenty packages outside `features/users` create accounts through `CreateTestUser`. Verify with `make test` in `backend/` that the suites still pass, and that a test calling the helper sees `GET /users/is-any-user-exist` answer false right afterwards (once task 2.6 lands).
## 2. Create the administrator from the first account
-- [ ] 2.1 Delete the seeding: `CreateInitialAdmin` in the service (`user_services.go:291-293`) and the repository (`user_repository.go:65-86`), and its call in `backend/cmd/main.go:109`; verify with `make test` in `backend/` that nothing else referenced them.
-- [ ] 2.2 Grant the administrator role and the flag to an account created while the instance holds no user, on the path of each entry point that inserts a new row - `SignUp` (`user_services.go:114-127`) and `getOrCreateUserFromOAuth` (`:963-976`) - and not on the branches that complete an invitation or link an identity to an account that already exists (`:66-101`, `:896-944`). Ask the account count **before** the refusal `external registration is disabled` (`:110-111` for registration, `:951-952` for a first external sign-in), and let an empty instance skip that refusal: asking inside the insert branch is too late, because an empty instance whose setting is off would never reach it and could never gain an administrator. Write the audit entry recording that this account now administers the instance, beside the entry `SignUp` already writes (`:130`). Verify with controller tests, each starting from the empty-table helper, that the first registration on an empty instance comes back as an administrator, is the recorded bootstrap administrator and leaves that audit entry; that a first GitHub sign-in does the same; that a first Google sign-in does the same; that an empty instance grants it even with external registration disabled; and that a second account created afterwards is an ordinary member.
-- [ ] 2.3 Handle the lost race: when the insert is refused, unwrap the driver error with `errors.As` into `*pgconn.PgError` the way `internal/features/databases/service.go:335` does, and retry as an ordinary account under the open-registration policy only when `ConstraintName` names the bootstrap index - a violation of `users_email_idx` must keep returning the duplicate-address error it returns today. Verify with a test that creates the bootstrap administrator first and then registers again, expecting a member account and an unchanged bootstrap administrator, and with a test that registering on an address another account already holds is still refused as a duplicate.
-- [ ] 2.4 Add `email` to the `binding` tag of `SignUpRequestDTO.Email` (`backend/internal/features/users/dto/dto.go:12`); verify with a controller test that a registration whose email is not an address is refused and creates no account, and that a valid one still succeeds.
-- [ ] 2.5 Pin the check the previous tasks deliberately bypass, which has no test today: on an instance that already holds an account, a password registration is refused while external registration is disabled. Use `users_testing.DisableExternalRegistrations` (`testing/settings_utils.go:21`) and restore the setting with `ResetSettingsToDefaults`; the GitHub path already has its counterpart (`user_controller_test.go:1007`). Verify with `make test` in `backend/`.
-- [ ] 2.6 Replace `GET /users/admin/has-password` and `POST /users/admin/set-password` with `GET /users/is-any-user-exist`, answering `{ "isExist": boolean }` - the shape and the method the client already uses (`frontend/src/entity/users/api/userApi.ts:62-74`) - and delete `IsRootAdminHasPassword` (`user_services.go:299`), `SetRootAdminPassword` (`:312`), their controller handlers and the two DTOs that exist only for them (`dto.go:30-36`). Verify with controller tests that the new endpoint answers false on an empty instance - emptied through the helper from task 1.7 - and true once an account exists, and that both removed routes now answer 404, which is also what closes the unauthenticated password-setting path the spec refuses.
-- [ ] 2.7 Retire the tests that pin the removed claim path, once the tests above cover what replaces them. `Test_CheckAdminHasPassword_WhenAdminHasNoPassword_ReturnsFalse` and the three `Test_SetAdminPassword_*` tests (`user_controller_test.go:278-374`) are deleted outright. `Test_AdminLifecycleE2E_CompletesSuccessfully` (`controllers/e2e_test.go:21-119`) is rewritten rather than deleted: it opens by posting to the deleted `/users/admin/set-password`, and it is the walk this change makes canonical - an empty instance from the helper in task 1.7, a first registration that comes back as the bootstrap administrator, a sign-out and sign-in with that address, an address change, and a sign-in with the new address. Verify with `make test` in `backend/`.
-- [ ] 2.8 Give `Test_UserLifecycleE2E_CompletesSuccessfully` (`controllers/e2e_test.go:120`) its own precondition: it registers and asserts the member role (`:172`), which from now on only holds when the instance already has an account, and today it holds only because the test above it happens to seed one. Create that account in the test. Verify with `make test` in `backend/` and with `go test ./internal/features/users/... -run Test_UserLifecycleE2E_CompletesSuccessfully`, which must pass on its own.
-- [ ] 2.9 Run `make lint` in `backend/`.
+- [x] 2.1 Delete the seeding: `CreateInitialAdmin` in the service (`user_services.go:291-293`) and the repository (`user_repository.go:65-86`), and its call in `backend/cmd/main.go:109`; verify with `make test` in `backend/` that nothing else referenced them.
+- [x] 2.2 Grant the administrator role and the flag to an account created while the instance holds no user, on the path of each entry point that inserts a new row - `SignUp` (`user_services.go:114-127`) and `getOrCreateUserFromOAuth` (`:963-976`) - and not on the branches that complete an invitation or link an identity to an account that already exists (`:66-101`, `:896-944`). Ask the account count **before** the refusal `external registration is disabled` (`:110-111` for registration, `:951-952` for a first external sign-in), and let an empty instance skip that refusal: asking inside the insert branch is too late, because an empty instance whose setting is off would never reach it and could never gain an administrator. Write the audit entry recording that this account now administers the instance, beside the entry `SignUp` already writes (`:130`). Verify with controller tests, each starting from the empty-table helper, that the first registration on an empty instance comes back as an administrator, is the recorded bootstrap administrator and leaves that audit entry; that a first GitHub sign-in does the same; that a first Google sign-in does the same; that an empty instance grants it even with external registration disabled; and that a second account created afterwards is an ordinary member.
+- [x] 2.3 Handle the lost race: when the insert is refused, unwrap the driver error with `errors.As` into `*pgconn.PgError` the way `internal/features/databases/service.go:335` does, and retry as an ordinary account under the open-registration policy only when `ConstraintName` names the bootstrap index - a violation of `users_email_idx` must keep returning the duplicate-address error it returns today. Verify with a test that creates the bootstrap administrator first and then registers again, expecting a member account and an unchanged bootstrap administrator, and with a test that registering on an address another account already holds is still refused as a duplicate.
+- [x] 2.4 Add `email` to the `binding` tag of `SignUpRequestDTO.Email` (`backend/internal/features/users/dto/dto.go:12`); verify with a controller test that a registration whose email is not an address is refused and creates no account, and that a valid one still succeeds.
+- [x] 2.5 Pin the check the previous tasks deliberately bypass, which has no test today: on an instance that already holds an account, a password registration is refused while external registration is disabled. Use `users_testing.DisableExternalRegistrations` (`testing/settings_utils.go:21`) and restore the setting with `ResetSettingsToDefaults`; the GitHub path already has its counterpart (`user_controller_test.go:1007`). Verify with `make test` in `backend/`.
+- [x] 2.6 Replace `GET /users/admin/has-password` and `POST /users/admin/set-password` with `GET /users/is-any-user-exist`, answering `{ "isExist": boolean }` - the shape and the method the client already uses (`frontend/src/entity/users/api/userApi.ts:62-74`) - and delete `IsRootAdminHasPassword` (`user_services.go:299`), `SetRootAdminPassword` (`:312`), their controller handlers and the two DTOs that exist only for them (`dto.go:30-36`). Verify with controller tests that the new endpoint answers false on an empty instance - emptied through the helper from task 1.7 - and true once an account exists, and that both removed routes now answer 404, which is also what closes the unauthenticated password-setting path the spec refuses.
+- [x] 2.7 Retire the tests that pin the removed claim path, once the tests above cover what replaces them. `Test_CheckAdminHasPassword_WhenAdminHasNoPassword_ReturnsFalse` and the three `Test_SetAdminPassword_*` tests (`user_controller_test.go:278-374`) are deleted outright. `Test_AdminLifecycleE2E_CompletesSuccessfully` (`controllers/e2e_test.go:21-119`) is rewritten rather than deleted: it opens by posting to the deleted `/users/admin/set-password`, and it is the walk this change makes canonical - an empty instance from the helper in task 1.7, a first registration that comes back as the bootstrap administrator, a sign-out and sign-in with that address, an address change, and a sign-in with the new address. Verify with `make test` in `backend/`.
+- [x] 2.8 Give `Test_UserLifecycleE2E_CompletesSuccessfully` (`controllers/e2e_test.go:120`) its own precondition: it registers and asserts the member role (`:172`), which from now on only holds when the instance already has an account, and today it holds only because the test above it happens to seed one. Create that account in the test. Verify with `make test` in `backend/` and with `go test ./internal/features/users/... -run Test_UserLifecycleE2E_CompletesSuccessfully`, which must pass on its own.
+- [x] 2.9 Run `make lint` in `backend/`.
## 3. Free the administrator address
-- [ ] 3.1 Delete the refusal at `user_services.go:468`, and rewrite `Test_UpdateUserInfo_WhenAdminTriesToChangeEmail_ReturnsBadRequest` (`user_controller_test.go:761`), which pins the behavior being deleted, into a test that the change succeeds: the address becomes the new one, a sign-in with it works, and a sign-in with the previous value is rejected. Verify with `make test` in `backend/`.
-- [ ] 3.2 Assert with the recording audit writer that the recorded entries contain the one `user_services.go:486-506` builds for the address change, naming the old and the new address. Look for that entry among the recorded ones rather than expecting it to be the only one - the sign-in and account creation the test needs first write their own. Verify with `make test` in `backend/`.
-- [ ] 3.3 Verify that an invalid address is still rejected and that taking another user's address is still refused, by extending the same test with both cases; no new validation code is expected, since `UpdateUserInfoRequestDTO` already binds `omitempty,email` (`dto.go:42`) and `user_services.go:471-479` already checks uniqueness.
-- [ ] 3.4 Confirm with a test that the token issued before the address change still authenticates afterwards; `GenerateAccessToken` carries the user id and the password creation time and no email (`user_services.go:271-276`), so this is a check rather than a change.
-- [ ] 3.5 Add a test that the bootstrap administrator can request a password reset for their address and complete it with the emailed code.
-- [ ] 3.6 Delete the single-user sign-in hint branch at `user_services.go:157-161`; verify with a controller test that a sign-in attempt with an unknown address on a single-user instance returns a response whose text contains neither `admin` nor a user count. Confirm `GetUsersCount` stays, since telemetry calls it (`backend/internal/features/telemetry/service.go:102`) and the new account-creation rule asks it the same question.
-- [ ] 3.7 Guard the password comparison in `SignIn` (`user_services.go:181`) with `HasPassword()` (`models/user.go:56-58`) so an account with no password hash is refused the way a wrong password is, instead of dereferencing nil; verify with a controller test that submits the password form for an account created through Google or GitHub and expects the refusal rather than a 500.
-- [ ] 3.8 Pin the two refusals the new guard sits below, neither of which has a test today: signing in to an account still in the invited state and to a deactivated one (`user_services.go:168-179`). Both accounts are reachable through existing helpers - an invitation through `POST /users/invite`, a deactivation through the management endpoint. Verify with `make test` in `backend/`.
+- [x] 3.1 Delete the refusal at `user_services.go:468`, and rewrite `Test_UpdateUserInfo_WhenAdminTriesToChangeEmail_ReturnsBadRequest` (`user_controller_test.go:761`), which pins the behavior being deleted, into a test that the change succeeds: the address becomes the new one, a sign-in with it works, and a sign-in with the previous value is rejected. Verify with `make test` in `backend/`.
+- [x] 3.2 Assert with the recording audit writer that the recorded entries contain the one `user_services.go:486-506` builds for the address change, naming the old and the new address. Look for that entry among the recorded ones rather than expecting it to be the only one - the sign-in and account creation the test needs first write their own. Verify with `make test` in `backend/`.
+- [x] 3.3 Verify that an invalid address is still rejected and that taking another user's address is still refused, by extending the same test with both cases; no new validation code is expected, since `UpdateUserInfoRequestDTO` already binds `omitempty,email` (`dto.go:42`) and `user_services.go:471-479` already checks uniqueness.
+- [x] 3.4 Confirm with a test that the token issued before the address change still authenticates afterwards; `GenerateAccessToken` carries the user id and the password creation time and no email (`user_services.go:271-276`), so this is a check rather than a change.
+- [x] 3.5 Add a test that the bootstrap administrator can request a password reset for their address and complete it with the emailed code.
+- [x] 3.6 Delete the single-user sign-in hint branch at `user_services.go:157-161`; verify with a controller test that a sign-in attempt with an unknown address on a single-user instance returns a response whose text contains neither `admin` nor a user count. Confirm `GetUsersCount` stays, since telemetry calls it (`backend/internal/features/telemetry/service.go:102`) and the new account-creation rule asks it the same question.
+- [x] 3.7 Guard the password comparison in `SignIn` (`user_services.go:181`) with `HasPassword()` (`models/user.go:56-58`) so an account with no password hash is refused the way a wrong password is, instead of dereferencing nil; verify with a controller test that submits the password form for an account created through Google or GitHub and expects the refusal rather than a 500.
+- [x] 3.8 Pin the two refusals the new guard sits below, neither of which has a test today: signing in to an account still in the invited state and to a deactivated one (`user_services.go:168-179`). Both accounts are reachable through existing helpers - an invitation through `POST /users/invite`, a deactivation through the management endpoint. Verify with `make test` in `backend/`.
+- [x] 3.9 Pin the half of the upgrade scenario (`spec.md` - Upgrading an instance in use) that a test can reach: create a flagged ADMIN account whose address is the placeholder `admin`, and confirm a sign-in with that address and its password succeeds. The migration itself cannot be observed from a test, but this can, and it guards a specific regression: `SignInRequestDTO.Email` binds `required` alone (`dto.go:19`), so the day somebody adds `email` beside it for symmetry with the registration DTO task 2.4 changes, every upgraded instance that has not yet moved off the placeholder is locked out with a binding error. This test is what makes that edit fail instead of shipping. Verify with `make test` in `backend/`.
## 4. Keep the root administrator's powers
-- [ ] 4.1 Switch the three root-administrator checks in `backend/internal/features/users/services/management_service.go` from comparing the caller's email to reading the flag: deactivation (`:74`), reactivation (`:108`) and the ADMIN-role grant or revoke (`:154`). Update the three comments above them so they describe the rule rather than the address.
-- [ ] 4.2 Confirm the existing privilege matrix still passes and now proves more than it did. `management_controller_test.go` already covers the bootstrap administrator succeeding at all three actions (`:574`, `:596`, `:618`, `:636`) and an ordinary ADMIN account being refused all three (`:486`, `:512`, `:538`, `:556`), and after task 1.3 those tests run against a bootstrap account whose address is an ordinary one. Add the case they cannot reach: change the bootstrap administrator's address first, then exercise all three actions through the API and expect them to succeed. Verify with `make test` in `backend/`.
-- [ ] 4.3 Add the test the spec requirement rests on and no existing test names: an ordinary ADMIN account cannot revoke the role of the flagged account or deactivate it, and the flagged account cannot do either to itself. The self-action refusals exist (`:665`, `:686`) but target whichever account the helper returns; assert here that the account they protect is the one holding the flag, so the instance is never left without a recognized bootstrap administrator. Verify with `make test` in `backend/`.
-- [ ] 4.4 Assert with the recording audit writer that the recorded entries contain the ones a role grant and a deactivation performed by the bootstrap administrator write (`management_service.go:165` and `:83`), again matching an entry rather than expecting a single one; verify with `make test` in `backend/`.
-- [ ] 4.5 Grep production code under `backend/` for the literal `"admin"` and confirm the only remaining occurrences are in the MongoDB feature, which means a database by it; anything else is a site this change missed.
+- [x] 4.1 Switch the three root-administrator checks in `backend/internal/features/users/services/management_service.go` from comparing the caller's email to reading the flag: deactivation (`:74`), reactivation (`:108`) and the ADMIN-role grant or revoke (`:154`). Update the three comments above them so they describe the rule rather than the address.
+- [x] 4.2 Confirm the existing privilege matrix still passes and now proves more than it did. `management_controller_test.go` already covers the bootstrap administrator succeeding at all three actions (`:574`, `:596`, `:618`, `:636`) and an ordinary ADMIN account being refused all three (`:486`, `:512`, `:538`, `:556`), and after task 1.3 those tests run against a bootstrap account whose address is an ordinary one. Add the case they cannot reach: change the bootstrap administrator's address first, then exercise all three actions through the API and expect them to succeed. Verify with `make test` in `backend/`.
+- [x] 4.3 Add the test the spec requirement rests on and no existing test names: an ordinary ADMIN account cannot revoke the role of the flagged account or deactivate it, and the flagged account cannot do either to itself. The self-action refusals exist (`:665`, `:686`) but target whichever account the helper returns; assert here that the account they protect is the one holding the flag, so the instance is never left without a recognized bootstrap administrator. Verify with `make test` in `backend/`.
+- [x] 4.4 Assert with the recording audit writer that the recorded entries contain the ones a role grant and a deactivation performed by the bootstrap administrator write (`management_service.go:165` and `:83`), again matching an entry rather than expecting a single one; verify with `make test` in `backend/`.
+- [x] 4.5 Grep production code under `backend/` for the literal `"admin"` and confirm the only remaining occurrences are in the MongoDB feature, which means a database by it; anything else is a site this change missed.
## 5. Console recovery
-- [ ] 5.1 Add the administrator listing to the users feature under `backend/internal/features/users/`: select every ADMIN-role account, order it, mark the one holding the flag, and render the lines carrying the address, display name, creation date and active state and nothing else. The active state is part of the answer because a deactivated administrator otherwise reads as an address that should work. The listing writes no audit entry: `UserService` dereferences its audit writer without a nil check (`user_services.go:128`) and that writer only exists after `audit_logs.SetupDependencies()`, which the console path calls only for the password reset (`main.go:167-190`). It goes here rather than in `backend/cmd/` because `make test` and CI run `go test ./internal/...` only (`backend/Makefile:16`, `.github/workflows/ci-release.yml:221,345`), so logic living in `cmd/` ships untested. This is the one place the change tests a service directly instead of through HTTP, which `backend/AGENTS.md` allows for logic with no API surface.
-- [ ] 5.2 Add tests covering the listing on an instance with several administrators, where the flagged one is marked, a deactivated administrator is shown as inactive and members do not appear, and on one where no account exists yet - emptied through the helper from task 1.7 - where it reports that the instance has no administrator; assert the rendered output carries no password hash. Verify with `make test` in `backend/`.
-- [ ] 5.3 Add the `--list-admins` flag to `parseCommandLineOptions` (`backend/cmd/main.go:154`) and a handler invoked from the same startup point as `resetPasswordIfRequested` (`main.go:115`) that calls the listing, prints it to the process log and exits; verify with `docker exec -it databasus ./main --list-admins` against a running container, not against a local database, and confirm the output lists the administrators and contains no password material. Running it through `docker exec` is the point: that is how an owner reaches it, and it is the path `restore-console-command-database-access` repairs.
-- [ ] 5.4 Run `make test` and `make lint` in `backend/` and fix what they report.
+- [x] 5.1 Add the administrator listing to the users feature under `backend/internal/features/users/`: select every ADMIN-role account, order it, mark the one holding the flag, and render the lines carrying the address, display name, creation date and active state and nothing else. The active state is part of the answer because a deactivated administrator otherwise reads as an address that should work. The listing writes no audit entry: `UserService` dereferences its audit writer without a nil check (`user_services.go:128`) and that writer only exists after `audit_logs.SetupDependencies()`, which the console path calls only for the password reset (`main.go:167-190`). It goes here rather than in `backend/cmd/` because `make test` and CI run `go test ./internal/...` only (`backend/Makefile:16`, `.github/workflows/ci-release.yml:221,345`), so logic living in `cmd/` ships untested. This is the one place the change tests a service directly instead of through HTTP, which `backend/AGENTS.md` allows for logic with no API surface.
+- [x] 5.2 Add tests covering the listing on an instance with several administrators, where the flagged one is marked, a deactivated administrator is shown as inactive and members do not appear, and on one where no account exists yet - emptied through the helper from task 1.7 - where it reports that the instance has no administrator; assert the rendered output carries no password hash. Verify with `make test` in `backend/`.
+- [x] 5.3 Add the `--list-admins` flag to `parseCommandLineOptions` (`backend/cmd/main.go:154`) and a handler invoked from the same startup point as `resetPasswordIfRequested` (`main.go:115`) that calls the listing, prints it to the process log and exits; verify with `docker exec -it databasus ./main --list-admins` against a running container, not against a local database, and confirm the output lists the administrators and contains no password material. Running it through `docker exec` is the point: that is how an owner reaches it, and it is the path `restore-console-command-database-access` repairs.
+- [x] 5.4 Run `make test` and `make lint` in `backend/` and fix what they report.
## 6. Frontend
-- [ ] 6.1 Change `AuthPageComponent` (`frontend/src/pages/AuthPageComponent.tsx:21-41`) to ask whether any account exists instead of whether the administrator has a password, to open on registration when none does, and to drop the `AdminPasswordComponent` branch; delete that component, its barrel export (`frontend/src/features/users/index.ts:1`), and everything only it used: `userApi.isAdminHasPassword` and `userApi.setAdminPassword` (`entity/users/api/userApi.ts:76-95`) with the two types they are the only users of (`entity/users/model/IsAdminHasPasswordResponse.ts` and `entity/users/model/SetAdminPasswordRequest.ts`, exported at `entity/users/index.ts:10-11`). An instance that already holds accounts keeps the screen it opens on today - registration, with sign-in one click away - so the only branch that changes is the empty one. Verify in the running application against an empty instance and against one that already has accounts - the repository has no component or page tests, so this is a manual check rather than a missing one.
-- [ ] 6.2 Add the copy that tells the first visitor the account they are creating administers the instance, and delete the keys `users.adminPassword.*` and `app.auth.adminPasswordCheckFailed` from `frontend/src/shared/i18n/locales/{en,ru,es,pt,zh,fr}.ts`; verify the removed keys appear nowhere under `frontend/src`, and run `pnpm test` so the dictionary parity suite (`shared/i18n/dictionaries.test.ts`) confirms the six files still hold the same key set.
-- [ ] 6.3 Remove the four places in `frontend/src/features/users/ui/ProfileComponent.tsx` that treat the address `admin` as read-only: the skipped validation (`:138`), the omitted request field (`:157`), the `disabled` prop (`:234`) and the explanatory line (`:236-238`), and delete `users.profile.adminEmailReadOnly` from the six locale files; verify by changing the address on the profile screen of an upgraded instance.
-- [ ] 6.4 Confirm the sign-in form still accepts `admin` as a login value (`SignInComponent.tsx:50`), since an upgraded instance that has not changed the address still uses it; verify by signing in as `admin` against such an instance.
-- [ ] 6.5 Run `pnpm lint`, `pnpm format`, `pnpm test` and `pnpm build` in `frontend/` and fix what they report.
+- [x] 6.1 Change `AuthPageComponent` (`frontend/src/pages/AuthPageComponent.tsx:21-41`) to ask whether any account exists instead of whether the administrator has a password, to open on registration when none does, and to drop the `AdminPasswordComponent` branch; delete that component, its barrel export (`frontend/src/features/users/index.ts:1`), and everything only it used: `userApi.isAdminHasPassword` and `userApi.setAdminPassword` (`entity/users/api/userApi.ts:76-95`) with the two types they are the only users of (`entity/users/model/IsAdminHasPasswordResponse.ts` and `entity/users/model/SetAdminPasswordRequest.ts`, exported at `entity/users/index.ts:10-11`). An instance that already holds accounts keeps the screen it opens on today - registration, with sign-in one click away - so the only branch that changes is the empty one. Verify in the running application against an empty instance and against one that already has accounts - the repository has no component or page tests, so this is a manual check rather than a missing one.
+- [x] 6.2 Add the copy that tells the first visitor the account they are creating administers the instance, and delete the keys `users.adminPassword.*` and `app.auth.adminPasswordCheckFailed` from `frontend/src/shared/i18n/locales/{en,ru,es,pt,zh,fr}.ts`; verify the removed keys appear nowhere under `frontend/src`, and run `pnpm test` so the dictionary parity suite (`shared/i18n/dictionaries.test.ts`) confirms the six files still hold the same key set.
+- [x] 6.3 Remove the four places in `frontend/src/features/users/ui/ProfileComponent.tsx` that treat the address `admin` as read-only: the skipped validation (`:138`), the omitted request field (`:157`), the `disabled` prop (`:234`) and the explanatory line (`:236-238`), and delete `users.profile.adminEmailReadOnly` from the six locale files; verify by changing the address on the profile screen of an upgraded instance.
+- [x] 6.4 Confirm the sign-in form still accepts `admin` as a login value (`SignInComponent.tsx:50`), since an upgraded instance that has not changed the address still uses it; verify by signing in as `admin` against such an instance.
+- [x] 6.5 Run `pnpm lint`, `pnpm format`, `pnpm test` and `pnpm build` in `frontend/` and fix what they report.
## 7. English documentation
-- [ ] 7.1 Update the password section of the root `README.md` (lines 261-269): document `--list-admins` beside the existing reset command, and change the reset example so it no longer presents `--email="admin"` as the expected address, explaining that an instance created before this change still uses `admin` until its owner replaces it; verify by reading the rendered section as a reader who cannot sign in and can only reach the host.
-- [ ] 7.2 Add to the usage section of the root `README.md` (lines 251-259) the step that comes before everything else: open the instance and create the first account, which administers it; verify the section reads correctly for a reader who has just started the container.
-- [ ] 7.3 Add a section to `website/app/(en)/password/page.tsx` covering the administrator listing, with its own heading id so it can be linked, and correct the example command (`:41`) and the illustration of a valid address (`:141`) the same way; verify with `npm run build` in `website/` and by loading the page.
-- [ ] 7.4 Rewrite the sentence at `website/app/(en)/access-management/page.tsx:220-221` so it describes the first account created on the instance as its administrator rather than naming its address `admin`; verify with `npm run build` in `website/`.
-- [ ] 7.5 Add the FAQ entry "I forgot my admin email or password" to `website/app/(en)/page.tsx`, in both the visible FAQ list and the structured-data block that mirrors it, linking to the password page; verify with `npm run build` in `website/` and by confirming both copies carry the same answer text.
-- [ ] 7.6 Run `npm run lint` in `website/` and fix what it reports.
+- [x] 7.1 Update the password section of the root `README.md` (lines 261-269): document `--list-admins` beside the existing reset command, and change the reset example so it no longer presents `--email="admin"` as the expected address, explaining that an instance created before this change still uses `admin` until its owner replaces it; verify by reading the rendered section as a reader who cannot sign in and can only reach the host.
+- [x] 7.2 Add to the usage section of the root `README.md` (lines 251-259) the step that comes before everything else: open the instance and create the first account, which administers it; verify the section reads correctly for a reader who has just started the container.
+- [x] 7.3 Add a section to `website/app/(en)/password/page.tsx` covering the administrator listing, with its own heading id so it can be linked, and correct the example command (`:41`) and the illustration of a valid address (`:141`) the same way; verify with `npm run build` in `website/` and by loading the page.
+- [x] 7.4 Rewrite the sentence at `website/app/(en)/access-management/page.tsx:220-221` so it describes the first account created on the instance as its administrator rather than naming its address `admin`; verify with `npm run build` in `website/`.
+- [x] 7.5 Add the FAQ entry "I forgot my admin email or password" to `website/app/(en)/page.tsx`, in both the visible FAQ list and the structured-data block that mirrors it, linking to the password page; verify with `npm run build` in `website/` and by confirming both copies carry the same answer text.
+- [x] 7.6 Run `npm run lint` in `website/` and fix what it reports.
## 8. Translations
-- [ ] 8.1 Translate the new password-page section into Russian in `website/app/[lang]/password/content/ru.tsx`, mirror the access-management correction in `website/app/[lang]/access-management/content/ru.tsx`, and add the FAQ entry to the Russian home-page content; verify with `npm run build` in `website/` and by reading all three pages under `/ru/`.
-- [ ] 8.2 Repeat for Spanish (`es`).
-- [ ] 8.3 Repeat for Portuguese (`pt`).
-- [ ] 8.4 Repeat for Chinese (`zh`).
-- [ ] 8.5 Repeat for French (`fr`).
-- [ ] 8.6 Mirror the README changes into `assets/readme/README.{ru,es,pt,zh,fr}.md`, following the translation rules in `assets/readme/AGENTS.md`; verify each file keeps the command lines byte-identical to the English ones.
+- [x] 8.1 Translate the new password-page section into Russian in `website/app/[lang]/password/content/ru.tsx`, mirror the access-management correction in `website/app/[lang]/access-management/content/ru.tsx`, and add the FAQ entry to the Russian home-page content; verify with `npm run build` in `website/` and by reading all three pages under `/ru/`.
+- [x] 8.2 Repeat for Spanish (`es`).
+- [x] 8.3 Repeat for Portuguese (`pt`).
+- [x] 8.4 Repeat for Chinese (`zh`).
+- [x] 8.5 Repeat for French (`fr`).
+- [x] 8.6 Mirror the README changes into `assets/readme/README.{ru,es,pt,zh,fr}.md`, following the translation rules in `assets/readme/AGENTS.md`; verify each file keeps the command lines byte-identical to the English ones.
## 9. Verification and review
-- [ ] 9.1 Run `make test` and `make lint` in `backend/`, `pnpm lint`, `pnpm format`, `pnpm test` and `pnpm build` in `frontend/`, and `npm run lint` and `npm run build` in `website/`; fix every failure.
-- [ ] 9.2 Confirm every behavior in `specs/root-admin-account/spec.md` has a test or a documented manual check, and that no scenario is left unexercised. Three rest on manual checks: the migration shapes (task 1.1), the two screens (tasks 6.1 and 6.3) and the restart scenario (task 9.3, which restarts the instance rather than asserting it in Go). Everything else names a test.
+- [x] 9.1 Run `make test` and `make lint` in `backend/`, `pnpm lint`, `pnpm format`, `pnpm test` and `pnpm build` in `frontend/`, and `npm run lint` and `npm run build` in `website/`; fix every failure.
+- [x] 9.2 Confirm every behavior in `specs/root-admin-account/spec.md` has a test or a documented manual check, and that no scenario is left unexercised. Three rest on manual checks: the migration shapes (task 1.1), the two screens (tasks 6.1 and 6.3) and the restart scenario (task 9.3, which restarts the instance rather than asserting it in Go). Everything else names a test.
- [ ] 9.3 Walk a fresh install end to end: start an empty instance, register the first account, confirm it is an administrator, restart the container and confirm no account was created and the administrator is unchanged, invite a second user, confirm that user is a member and cannot manage administrators, and recover the address with `docker exec -it databasus ./main --list-admins`.
-- [ ] 9.4 Walk all three upgrade paths on databases seeded from the previous version: a claimed instance, where the owner signs in as `admin`, changes the address from the profile screen, signs out and signs in with the new address; an instance that was never claimed and holds nothing else, where the seeded account is gone and the first registration becomes the administrator; and an instance that was never claimed but holds a member registered through the API, where the seeded account is kept as the bootstrap administrator and a password set with `--new-password --email="admin"` gets the owner in.
-- [ ] 9.5 Record in the change's completion notes that the rollback window closes once an administrator address has been changed, and that the down step cannot restore the unclaimed account the up step deleted, as described in design.md - Migration Plan.
-- [ ] 9.6 Complete the mandatory compliance review for the finished diff and resolve every CHANGES REQUIRED finding.
+- [ ] 9.4 Walk all three upgrade paths on databases seeded from the previous version: a claimed instance, where the owner signs in as `admin`, changes the address from the profile screen, signs out, signs in with the new address and confirms `admin` is no longer accepted for that account; an instance that was never claimed and holds nothing else, where the seeded account is gone and the first registration becomes the administrator; and an instance that was never claimed but holds a member registered through the API, where the seeded account is kept as the bootstrap administrator and a password set with `--new-password --email="admin"` gets the owner in.
+- [x] 9.5 Record in the change's completion notes that the rollback window closes once an administrator address has been changed, and that the down step cannot restore the unclaimed account the up step deleted, as described in design.md - Migration Plan.
+- [x] 9.6 Complete the mandatory compliance review for the finished diff and resolve every CHANGES REQUIRED finding.
+
+## Completion notes
+
+- **The rollback window closes once an administrator address has been changed.** Rolling the binary back on an instance whose owner still signs in as `admin` leaves an unused column behind and works. Rolling it back after the owner has moved to a real address does not: the old code looks the bootstrap account up by the text `admin`, finds nothing, `IsRootAdminHasPassword` fails, and the authentication screen alerts without clearing its loading state, so nobody reaches the sign-in form. The restored `Email != "admin"` privilege checks would freeze administrator management even if sign-in worked. It is a lockout rather than a takeover, and it is recovered by rolling forward again or by setting the address back to `admin` in the database. See design.md - Migration Plan.
+- **The down step cannot restore the account the up step deleted.** The up step removes the seeded `admin` row when it was never claimed and is the only row in `users`. The down step drops the index and the column and does not try to bring that row back: on such an instance the old binary seeds the account again at startup, which is exactly where it was.
diff --git a/openspec/specs/root-admin-account/spec.md b/openspec/specs/root-admin-account/spec.md
new file mode 100644
index 00000000..20257414
--- /dev/null
+++ b/openspec/specs/root-admin-account/spec.md
@@ -0,0 +1,226 @@
+# Root Admin Account Specification
+
+## Purpose
+
+Describes how a Databasus instance gets the administrator account its owner works from: how that account is created on a new instance, what happens to the account older instances were shipped with, how the instance keeps recognizing it once its email address changes, which powers it holds over other administrators, and how an owner who has forgotten the address recovers it from the host.
+
+## Requirements
+
+### Requirement: A new instance creates no account until somebody registers
+
+A started instance SHALL NOT create any account on its own. An instance that holds no account SHALL offer account creation as the way in, and SHALL say that the account being created administers the instance.
+
+Creating that account SHALL require nothing the owner cannot supply locally: no delivered email, no outbound network access and no configured mail server.
+
+An instance that already holds an account SHALL offer the ordinary way in - signing in, and creating an account where the registration policy allows it - and SHALL NOT repeat that the account being created administers the instance.
+
+The instance SHALL NOT offer any way to set a password on an account that already exists without either authenticating as that account or proving control of its address with an emailed reset code. Claiming an instance is account creation; recovering an account whose password is lost is the emailed reset or a command run inside the instance.
+
+#### Scenario: Opening a freshly deployed instance
+
+- **WHEN** an owner opens a freshly started instance that has no mail server configured and no network access
+- **THEN** the instance offers to create an account, saying that it will administer the instance
+- **AND** no account exists on the instance until that form is submitted
+
+#### Scenario: Setting up without any mail server
+
+- **WHEN** the owner submits the form on that instance
+- **THEN** the account is created and the owner is signed in as an administrator, with no email sent
+
+#### Scenario: Opening an instance that already holds accounts
+
+- **WHEN** a visitor opens an instance on which at least one account exists
+- **THEN** the entry screen offers signing in, and says nothing about the first account administering the instance
+
+#### Scenario: An anonymous caller tries to set a password on an existing account
+
+- **WHEN** an unauthenticated caller attempts to set a password on an account that already exists, without an emailed reset code
+- **THEN** the instance refuses, whether or not that account currently has a password
+
+### Requirement: The first account on an empty instance administers it
+
+The first account created on an instance that holds no other account SHALL receive the administrator role and SHALL be recorded as the instance's bootstrap administrator. This SHALL hold however the account is created, including a first sign-in through an external identity provider, and SHALL NOT depend on whether open registration is enabled.
+
+An instance SHALL never record more than one bootstrap administrator, including when two accounts are created at the same moment.
+
+An account created by registration SHALL carry a syntactically valid email address, so that the administrator of an instance always has an address the product can deliver to. An account created through an external identity provider carries the address that provider reports for it.
+
+Recording an account as the bootstrap administrator SHALL be visible in the audit log, so the log explains where that account's privileges came from.
+
+**BREAKING**: registration previously accepted any non-empty value as the email address. A value that is not an email address is now refused.
+
+#### Scenario: The first registration takes the instance
+
+- **WHEN** the first person registers on an instance that holds no account
+- **THEN** that account holds the administrator role and is the recorded bootstrap administrator
+- **AND** the audit log holds an entry naming that account as the instance's administrator
+
+#### Scenario: The first sign-in through an external provider takes the instance
+
+- **WHEN** the first person to reach an empty instance signs in through Google or GitHub instead of registering
+- **THEN** the account created for them holds the administrator role and is the recorded bootstrap administrator
+
+#### Scenario: A later registration is an ordinary account
+
+- **WHEN** somebody registers on an instance that already holds an account
+- **THEN** the new account holds the member role and the recorded bootstrap administrator is unchanged
+
+#### Scenario: Two people register at the same moment
+
+- **WHEN** two accounts are created concurrently on an empty instance
+- **THEN** exactly one of them is recorded as the bootstrap administrator
+
+#### Scenario: Registering with a value that is not an address
+
+- **WHEN** somebody submits a registration whose email is not a valid email address
+- **THEN** the registration is refused and no account is created
+
+### Requirement: An upgraded instance keeps the account its owner already uses
+
+An instance upgraded from a version that created an account with the login `admin` at startup SHALL carry the bootstrap-administrator record onto the account its owner already signs in with, so the upgrade changes nothing that owner can observe.
+
+An upgraded instance whose account was never claimed - it has no password and no linked external identity, so nobody has ever signed in with it - and which holds no other account SHALL be left in the state of a new instance: that account is removed, and the first account created afterwards administers the instance.
+
+An instance whose account was never claimed while other accounts already exist SHALL keep that account and record it as the bootstrap administrator. No upgrade SHALL leave an instance that holds accounts without a recognized bootstrap administrator, and the owner of such an instance SHALL be able to take that account over from the host, the same way a lost password is recovered.
+
+#### Scenario: Upgrading an instance in use
+
+- **WHEN** an instance whose owner has been signing in as `admin` is upgraded
+- **THEN** that account is the recorded bootstrap administrator
+- **AND** the owner signs in exactly as before, with the address `admin` and the same password
+
+#### Scenario: Upgrading an instance nobody ever set up
+
+- **WHEN** an instance that was deployed but never claimed, and holds nothing else, is upgraded
+- **THEN** it holds no account, and the first account created on it administers it
+
+#### Scenario: Upgrading an instance that was never claimed but already holds accounts
+
+- **WHEN** an instance whose placeholder account was never signed in with, but which holds other accounts, is upgraded
+- **THEN** that placeholder account is kept and recorded as the bootstrap administrator
+- **AND** the owner can give it a password from the host and then move it to a real address
+
+### Requirement: The instance recognizes its bootstrap administrator independently of that account's email address
+
+The instance SHALL record which account is the bootstrap administrator when it creates that account, and SHALL keep recognizing it by that record. No decision about that account SHALL depend on the text of any account's email address. This covers, at minimum, every privilege the requirement below reserves for the bootstrap administrator.
+
+#### Scenario: The bootstrap administrator keeps its role after changing address
+
+- **WHEN** the bootstrap administrator changes their email address
+- **THEN** the instance still treats that account as the bootstrap administrator
+
+#### Scenario: Restarting the instance
+
+- **WHEN** an instance is restarted
+- **THEN** no account is created, and the recorded bootstrap administrator is unchanged
+
+### Requirement: The bootstrap administrator keeps its powers over other administrators after changing address
+
+Granting or revoking the administrator role, deactivating an account that holds it, and reactivating one SHALL remain reserved for the bootstrap administrator, and SHALL be permitted on the basis of the instance's record of which account that is. Changing the bootstrap administrator's email address SHALL NOT remove any of these powers, and SHALL NOT grant them to any other account.
+
+#### Scenario: Appointing an administrator after the address has changed
+
+- **WHEN** the bootstrap administrator, having changed its address, grants the administrator role to another user
+- **THEN** the role is granted
+
+#### Scenario: Another administrator still cannot manage administrators
+
+- **WHEN** an account that holds the administrator role but is not the bootstrap administrator tries to grant the role, revoke it, or deactivate or reactivate an account holding it
+- **THEN** every one of those attempts is refused, whatever address the bootstrap administrator currently holds
+
+#### Scenario: The bootstrap administrator cannot be stripped of its role
+
+- **WHEN** any account attempts to revoke the administrator role from the bootstrap administrator or to deactivate it
+- **THEN** the attempt is refused, so the instance is never left without a recognized bootstrap administrator
+
+### Requirement: The bootstrap administrator can change their email address
+
+The bootstrap administrator SHALL be able to change their email address through the same profile update every other user has, with no field locked and no explanation of why it is locked. The instance SHALL accept only a syntactically valid email address, and SHALL refuse an address another account already holds.
+
+After the change, the administrator SHALL sign in with the new address, and the previous value SHALL no longer be accepted for that account. The administrator's existing session SHALL survive the change.
+
+#### Scenario: An upgraded instance moves off the placeholder address
+
+- **WHEN** the bootstrap administrator of an upgraded instance submits a real email address in place of `admin`
+- **THEN** the change is accepted, and the audit log holds an entry naming the old and the new address
+- **AND** the next sign-in succeeds with the new address and fails with `admin`
+
+#### Scenario: Editing the address on the profile screen
+
+- **WHEN** the bootstrap administrator opens their profile
+- **THEN** the email field is editable and carries no notice that the address cannot be changed
+
+#### Scenario: Rejecting a value that is not an address
+
+- **WHEN** an administrator submits a new email value that is not a valid email address
+- **THEN** the change is rejected and the stored address is unchanged
+
+#### Scenario: Rejecting an address another account already holds
+
+- **WHEN** the bootstrap administrator submits an address that belongs to another user
+- **THEN** the change is rejected and the stored address is unchanged
+
+### Requirement: An administrator can reset their password by email
+
+The ordinary password reset SHALL work for the bootstrap administrator on the same terms as for any other user: a code is sent to the stored address, and it expires, is single-use and is rate-limited exactly as it is elsewhere. On a new instance this holds from the moment the account is created; on an upgraded one it holds as soon as the owner replaces the placeholder address.
+
+A reset requested while an upgraded account still holds the placeholder address `admin` SHALL NOT deliver a code, because no mail server can reach that address. What the caller is told in that case is the existing behavior of the reset flow and is not specified here.
+
+#### Scenario: Resetting the administrator's password by email
+
+- **WHEN** the bootstrap administrator requests a password reset for their stored address
+- **THEN** a reset code is sent to that address
+- **AND** submitting the code sets a new password
+
+### Requirement: Sign-in refuses cleanly and discloses nothing about the accounts an instance holds
+
+A failed sign-in SHALL NOT tell the caller that an account with the login `admin` exists on the instance, SHALL NOT suggest signing in under that login, and SHALL NOT reveal how many accounts the instance holds. This applies regardless of how many accounts there are.
+
+A sign-in attempt for an account that has no password - one created through an external identity provider, or an unclaimed account on an instance that has not yet been upgraded - SHALL be refused the way an incorrect password is refused, and SHALL leave the instance serving other requests.
+
+**BREAKING**: an instance holding a single user previously answered a sign-in attempt with an unknown address by naming the `admin` login. That response is removed; an owner recovers the address from the console instead.
+
+#### Scenario: Mistyped address on a single-user instance
+
+- **WHEN** an anonymous visitor attempts to sign in to an instance that holds only its administrator, using an address that does not exist
+- **THEN** the response does not mention the login `admin` and does not reveal how many accounts the instance holds
+
+#### Scenario: Password sign-in for an account that has no password
+
+- **WHEN** somebody submits the password form for an account that signs in through Google or GitHub
+- **THEN** the attempt is refused in the same way an incorrect password is refused
+- **AND** the instance keeps answering every other request
+
+### Requirement: An owner can recover the administrator addresses from the host
+
+An operator with shell access to the running instance SHALL be able to list every account holding the administrator role, seeing for each one its email address, its display name, when it was created, whether it is still active, and whether it is the bootstrap administrator. The active state is part of the answer because a deactivated administrator explains why an address does not let its owner in. The listing SHALL print no password, no password hash, no token and no other secret.
+
+The listing SHALL be available only to a caller who can already execute commands inside the running instance, which is the same trust level the existing password-reset command requires.
+
+#### Scenario: Recovering a forgotten address
+
+- **WHEN** an owner who cannot remember which address to sign in with runs the administrator listing command on the host
+- **THEN** the output names every administrator account with its address, display name, creation date and active state, and marks the bootstrap administrator
+- **AND** the output contains no password material
+
+#### Scenario: Listing on an instance nobody has set up
+
+- **WHEN** the listing command runs on an instance where no account has been created yet
+- **THEN** it reports that the instance has no administrator, and lists nothing
+
+### Requirement: Setting up and recovering an instance are documented
+
+The product documentation SHALL describe how an instance gets its administrator - the first account created on it - and SHALL describe both how to reset an administrator password and how to recover a forgotten administrator address, in the same place and in every language the documentation ships. The public documentation SHALL also answer the question of what to do when the administrator address or password is lost, and link to those steps.
+
+Documented command examples SHALL NOT present `admin` as the address an owner is expected to use, and the documentation SHALL NOT describe the instance as holding a user named `admin`. Where the placeholder address is mentioned at all, it SHALL be as the account an instance created before this change still carries until its owner replaces it.
+
+#### Scenario: An owner searches the documentation
+
+- **WHEN** an owner who cannot sign in reads the published password documentation
+- **THEN** it explains both resetting the password and listing the administrator addresses
+- **AND** the same guidance is reachable from the questions answered on the home page
+
+#### Scenario: Reading about roles
+
+- **WHEN** a reader consults the access-management documentation in any of the six published languages
+- **THEN** it describes the first account created on the instance as its administrator, without claiming that account's address is `admin`