commit d6d7ee1b43808a853a6746cd87cb3437defbbf57
parent d092e0212ed675494880cd4445ffdf113dfc8cec
Author: anon <anon@example.com>
Date: Thu, 5 Nov 2026 00:00:49 +0000
Verify starter recovery in fresh clients after cold loading
Diffstat:
6 files changed, 241 insertions(+), 0 deletions(-)
diff --git a/DEVELOPERS.md b/DEVELOPERS.md
@@ -527,6 +527,18 @@ available (`node` on PATH, `playwright` installed locally or on NODE_PATH,
AO_GAME_TEST=1 go test ./server -run '^TestBrowser(GameHarness|StarterEquipment|StarterMissionTargets)$' -count=1 -timeout=95m -v
```
+For a short native cold-recovery check without replaying progression, run:
+
+```sh
+AO_GAME_TEST=1 go test ./server -run '^TestBrowserStarterColdRecovery$' -count=1 -timeout=4m -v
+```
+
+This uses current-schema accounts and controlled level, wallet, equipment and
+charge conditions. Two fresh browser contexts log in normally after database
+closure/restoration and compare exact native ownership and private progress.
+The full `StarterEquipment` scenario uses the same cold check after earning its
+state; the short fixture does not establish earned progression.
+
This starts an HTTP server on a random loopback port and uses a disposable
database and browser context. It exercises actor readiness, movement, targeting,
posture, native world picking, UI input, resizing and reload reconstruction.
diff --git a/TODO.md b/TODO.md
@@ -5024,6 +5024,15 @@ and server restarts. Turn every reproduced bug into a focused regression test.
an observer, no admin-generated items/stats/cash/rewards, and account for every
item and credit on success and rejection. Turn each reproduced blocker into a
focused regression; record unsupported professions/content separately.
+ Current maintained gap: `TestBrowserStarterEquipment` reaches level 2 with
+ mission-reward wear, sales/purchases and recovery, but does not yet repeat
+ useful creature-equipment acquisition or actual reclaim. Existing earned
+ continuations document those paths separately. Its new cold stage closes the
+ original server/database and connects two fresh WASM clients to the restored
+ server through normal password login. `TestBrowserStarterColdRecovery` verifies
+ that stage with controlled current-schema profiles; it is not fresh earned
+ progression. Finish the remaining checkpoint phases without re-earning levels
+ merely to reach their conditions. Keep this gate open until they are maintained.
Initial baseline: two Neutral Enforcers created through Options with their
issued loadouts; ordinary right-click equips the same starter Baseballbat
instance in slot6, with no page errors or admin edits. Combat, earned loot,
diff --git a/docs/starter-progression.md b/docs/starter-progression.md
@@ -1737,3 +1737,34 @@ checkpoint paths. The browser-control JavaScript regression passes126 cases.
Logs are `starter-full-go-focused.json` and `starter-full-js-unit-cases.log`
under `local/todo-progression-play/`. This milestone does not claim a full
Go-suite rerun or a change to original game rules.
+
+## Fresh native clients after starter cold loading
+
+`TestBrowserStarterEquipment` now closes its original HTTP server, retires its
+world sessions and closes SQLite before constructing the restored server. After
+its existing Go ownership/progress comparisons, `testBrowserStarterCold` starts
+a new HTTP server and `tools/client/test_starter_cold.mjs` opens two fresh browser
+contexts. Both characters use the normal Options/password login flow. Native
+physical IDs, types, slots, qualities, quantities and endpoints must match the
+restored server, alongside cumulative XP, level, IP, wallet and health maxima.
+The named profiles' owned items and private progress must remain unchanged.
+
+`TestBrowserStarterColdRecovery` exercises that same stage in a short current-
+schema fixture. It creates accounts through the account API, then controls the
+owner's level/IP/wallet, worn bat and partial laboratory count before closing
+and restoring the server. These are controlled verification conditions, not
+new earned progression. Its maintained native run passes in 29.85 seconds.
+The same two-client check passes under the race detector in 51.87 seconds;
+related account/shutdown checks pass five roots / eight results. Vet, syntax and
+an independent audit of fourteen physical IDs and eight native traces pass.
+The old earned SQLite checkpoint predates `resurrection_shock` and was not
+migrated; the server's current-schema policy remains intact.
+
+This adds repeatable native cold coverage without another leveling run. The
+full fresh earned scenario was not replayed for this addition. Its maintained
+creature-equipment acquisition and actual reclaim phases are still missing;
+the existing earned continuations remain separate evidence for those paths.
+The complete supported-loop P0 gate stays open. Local checks and the bounded
+mission-capture/quantity investigations are recorded under
+`local/starter-native-cold/`, `local/period-mission-capture/` and
+`local/overdrawn-backpack-split/`.
diff --git a/server/browser_game_test.go b/server/browser_game_test.go
@@ -199,6 +199,11 @@ func TestBrowserStarterEquipment(t *testing.T) {
t.Fatal(err)
}
+ host.Close()
+ closeTestSessions(t, world)
+ if err := world.db.Close(); err != nil {
+ t.Fatal(err)
+ }
restored := newServerForTest(t)
world.mutex.Lock()
defer world.mutex.Unlock()
@@ -255,6 +260,7 @@ func TestBrowserStarterEquipment(t *testing.T) {
if players != 2 {
t.Fatalf("created %d ordinary characters, want 2", players)
}
+ testBrowserStarterCold(t, restored, root, filepath.Join(output, "cold"))
}
func TestBrowserStarterMissionTargets(t *testing.T) {
diff --git a/server/browser_starter_cold_test.go b/server/browser_starter_cold_test.go
@@ -0,0 +1,126 @@
+package main
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserStarterColdRecovery(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for the focused starter cold check")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/starter-native-cold", time.Now().Format("20060102-150405"))
+ world := newTestServer(t)
+ cookie := accountVisitor(t, world)
+ for _, name := range []string{"Starterowner", "Starterwatch"} {
+ fields := creationForm()
+ fields.Set("name", name)
+ fields.Set("password", "starter regression password")
+ fields.Set("profession", "9")
+ response := creationRequest(world, cookie, fields)
+ if response.Code != 204 {
+ t.Fatal(response.Code, response.Body.String())
+ }
+ cookie = response.Result().Cookies()[0]
+ player := world.characters[world.nextCharacter]
+ if name == "Starterowner" {
+ // Seed the cold recovery condition; this fixture does not earn progress.
+ player.level, player.experience, player.stats.ImprovementPoints = 2, 150, 5006
+ player.health = player.maximumHealth()
+ inventory := player.inventory
+ inventory.Items = slices.Clone(inventory.Items)
+ inventory.Credits = 50
+ for index := range inventory.Items {
+ if inventory.Items[index].Template == 121564 {
+ inventory.Items[index].Slot = 6
+ }
+ if inventory.Items[index].Template == 116628 {
+ inventory.Items[index].Count = 17
+ }
+ }
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+ host := httptest.NewServer(world.httpHandler())
+ host.Close()
+ closeTestSessions(t, world)
+ if err := world.db.Close(); err != nil {
+ t.Fatal(err)
+ }
+ restored := newServerForTest(t)
+
+ testBrowserStarterCold(t, restored, root, output)
+}
+
+func testBrowserStarterCold(t *testing.T, world *server, root, output string) {
+ t.Helper()
+ items := make(map[string][]ownedItem)
+ progress := make(map[string][4]uint32)
+ for _, player := range world.characters {
+ if player.name == "Starterowner" || player.name == "Starterwatch" {
+ items[player.name] = slices.Clone(player.inventory.Items)
+ progress[player.name] = [4]uint32{uint32(player.level), player.experience, player.stats.ImprovementPoints, player.inventory.Credits}
+ }
+ }
+ if len(items) != 2 {
+ t.Fatal("cold starter check requires both normally created profiles")
+ }
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ player := world.browserCharacter_locked(r)
+ owned := make([][7]uint32, 0, len(player.inventory.Items))
+ for _, item := range player.inventory.Items {
+ low, high := item.templateIDs()
+ owned = append(owned, [7]uint32{item.ID, item.Type, item.Slot, item.Quality, uint32(item.Count), low, high})
+ }
+ lower, _ := player.experienceBounds()
+ json.NewEncoder(w).Encode(map[string]any{"name": player.name, "items": owned, "level": player.level,
+ "ip": player.stats.ImprovementPoints, "credits": player.inventory.Credits,
+ "experience": lower + player.experience,
+ "health": player.health, "maximumHealth": player.maximumHealth(), "playfield": player.playfield})
+ })
+ host := httptest.NewServer(mux)
+ t.Cleanup(host.Close)
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
+ defer cancel()
+
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_starter_cold.mjs"), host.URL, output)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+
+ t.Logf("Cold browser artifacts: %s", output)
+ if err != nil {
+ t.Fatal(err)
+ }
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ for _, player := range world.characters {
+ if before, exists := items[player.name]; exists {
+ if !reflect.DeepEqual(player.inventory.Items, before) || progress[player.name] !=
+ ([4]uint32{uint32(player.level), player.experience, player.stats.ImprovementPoints, player.inventory.Credits}) {
+ t.Fatal("cold native login changed starter items or private progress", player.name)
+ }
+ }
+ }
+}
diff --git a/tools/client/test_starter_cold.mjs b/tools/client/test_starter_cold.mjs
@@ -0,0 +1,57 @@
+import assert from 'node:assert/strict';
+import fs from 'node:fs/promises';
+import {createRequire} from 'node:module';
+import {GameTest} from './game_test.mjs';
+
+const {chromium} = createRequire(import.meta.url)('playwright');
+const [url, output] = process.argv.slice(2);
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: [
+ '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+const games = [];
+const evidence = {};
+try {
+ for (const name of ['Starterowner', 'Starterwatch']) {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ const page = await context.newPage();
+ const game = await GameTest.attach(page);
+ games.push(game);
+ await page.goto(url);
+ await game.ready();
+ await page.keyboard.press('Control+Alt+M');
+ await page.locator('#login-button').click();
+ await page.locator('#account-name').fill(name);
+ await page.locator('#account-password').fill('starter regression password');
+ await Promise.all([page.waitForEvent('load'), page.locator('#account-submit').click()]);
+ await game.ready();
+ const state = await (await page.request.get(url + '/test-state')).json();
+ assert.equal(state.name, name);
+ assert.equal(game.local().playfield, state.playfield);
+ assert.equal(game.local().stats[54], state.level);
+ assert.equal(game.local().stats[52], state.experience);
+ assert.equal(game.local().stats[53], state.ip);
+ assert.equal(game.local().stats[61], state.credits);
+ assert.equal(game.local().stats[27], state.health);
+ assert.equal(game.local().stats[1], state.maximumHealth);
+ const expected = state.items.map(([id, type, slot, quality, count, low, high]) =>
+ [id, type, slot >= 64 ? slot - 16 : slot, quality, count, low, high]).sort((a, b) => a[0] - b[0]);
+ const actual = game.local().inventory.map(item =>
+ [item.id, item.type, item.slot, item.quality, item.count, ...item.templates]).sort((a, b) => a[0] - b[0]);
+ assert.deepEqual(actual, expected);
+ assert.deepEqual(game.errors, []);
+ evidence[name] = state;
+ await game.key('KeyI');
+ await game.save(output + '/' + name);
+ }
+ assert.equal(evidence.Starterowner.level, 2);
+ assert.equal(evidence.Starterwatch.level, 1);
+ assert.equal(evidence.Starterwatch.credits, 0);
+ assert.equal(evidence.Starterwatch.ip, 1500);
+ console.log('PASS: two fresh native clients log into cold starter profiles with exact items, charges, levels, IP, wallets and resource maxima');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ for (let index = 0; index < games.length; ++index) await games[index].save(output + '/final-' + index);
+ } finally { await browser.close(); }
+}