commit 6b63eeb999c19deeeabb723681bdacc9a0d70e09
parent cc824872af0457c8f5832fd8ab49536c7fb4cdc6
Author: anon <anon@example.com>
Date: Tue, 3 Nov 2026 15:47:03 +0000
Verify faction insurance reachability and recovery
Diffstat:
4 files changed, 417 insertions(+), 4 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -1254,7 +1254,7 @@ Historical outdoor give-up timing and wider route-selection fidelity remain open
location and a later death returns the character there.
- [x] Reclaim items after death. Check: the applicable items move to reclaim and
can be recovered once, including after reconnect.
-- [ ] [P0] Provide reachable insurance and reclaim coverage for all factions as
+- [x] [P0] Provide reachable insurance and reclaim coverage for all factions as
progression reaches level 10. Admit original Clan/ICC scanners and reclaim
placements through shared data and rules; verify ordinary travel, saved-return
precedence, affiliation restrictions and recovery of the same item instances.
@@ -1270,8 +1270,17 @@ Historical outdoor give-up timing and wider route-selection fidelity remain open
and exact-book return pays its promised item/cash once. Selected original
Clan/ICC pairs now pass controlled level-ten native saving, fatal combat, saved return and
exact reclaim collection, including page/cold recovery. Connected earned
- level-ten Omni travel, saved return and collection now pass; broader connected
- faction travel/recovery remains open. A focused controlled native stair check
+ level-ten Omni travel, saved return and collection now pass. Controlled Tir and
+ Newland backyard-complex exits now reach the original scanners through twelve
+ verified native street waypoints. A maintained scanner-checkpoint regression
+ verifies both saved returns, ordinary booth walking and exact recovery of six
+ carried instances while two worn weapons remain equipped. Both page reloads
+ and fresh server/WASM startup retain all eight physical instances and charges.
+ These separate route/recovery proofs and the earned Omni run establish reachable
+ faction coverage; no earned Clan/Neutral progression or continuous Neutral
+ playthrough is claimed. See [focused verification](docs/insurance.md#focused-level-ten-reachability-and-recovery).
+ Original fee/return/timing policies remain in the open recovery audits below.
+ A focused controlled native stair check
now resolves the original Omni courtyard approach gap: both Solitus and the
report's Atrox body climb the authored entrance, cross its landing and save at
the first scanner with matching server poses. Earlier approaches crossed
@@ -4039,6 +4048,9 @@ and server restarts. Turn every reproduced bug into a focused regression test.
- [ ] [P1] Audit death, resurrection, insurance and reclaim. Cover each supported
item policy, saved/unsaved locations, repeated return/retrieval, full inventory,
failed persistence and restart at each transition.
+ Recover original saved-scanner return transforms and reclaim availability
+ timing; the current offsets and timer remain provisional. Reachable faction
+ coverage does not establish those historical policies.
Pending-death reconnects now resume the native scanner return instead of
restoring full health at the death location. Regression cases cover saved
and default arrivals, database reopen, premature/repeated return requests,
diff --git a/docs/insurance.md b/docs/insurance.md
@@ -75,7 +75,7 @@ All 30 owned items, 803 credits and earned skills remained unchanged. The preced
raised-courtyard approach attempts stopped at authored collision faces in both
native and server observations; they do not establish that every original
approach is blocked. The focused stair check below now resolves courtyard access.
-Broader connected faction progression remains open.
+Focused Clan/Neutral reachability and recovery are recorded below.
The actual adjacent reclaim accepts native Use, opens an empty private window
and closes it again. Both page reconnects retain the same scanner, insured XP,
@@ -215,6 +215,62 @@ empty-inventory logging error are retained with their limits; the driver error
occurs after the successful Clan return, and its saved database is used for
the continuation. All test-owned browsers and servers are closed between runs.
+### Focused level-ten reachability and recovery
+
+Controlled level-ten characters now walk from the original Tir Backyard 1
+complex exit (3100 to 640) and Newland Backyard 1 exit (3060 to 566) to their
+selected city scanners. Native walking, twelve street waypoints and actual
+typed scanner Use pass, with native/server positions agreeing within 0.5 metres.
+Tir's route goes around the buildings and crosses the bridge at Z446; earlier
+approaches hit a building or the bridge railing. Another candidate entered an
+apartment: each accepted street waypoint checks its destination and city,
+because `GameTest.walk` deliberately returns on field changes. No collision,
+door, placement or production routing change was needed. The route capture
+and independent verifier are under `local/faction-route/20261103-071814/`
+and `local/faction-route/`.
+
+The route capture also completes Clan fatal retaliation and saved return. It
+stops before Neutral combat because the small encounter is below the viewport;
+this is not a complete combined recovery run. The maintained
+`TestBrowserFactionInsuranceCheckpoint` instead starts at controlled scanner
+checkpoints, using real turning and camera input to expose the encounter.
+It holds regeneration at 1HP/1nano and uses stationary level-one Leets with
+100HP and landed rolls to isolate fatal retaliation. These are test encounters,
+not city spawn or combat-balance evidence.
+
+Both characters save, initiate combat, die and return through exactly one
+native action99/action152/Resurrect sequence. Their worn Kinetic Axe remains
+equipped; each original Monster Part, 50-charge Treatment Laboratory and
+100-round Energy Ammunition stack moves to private reclaim. Native walking
+reaches both original booths and collection restores those same six carried
+instances once, using ordinary availability deadlines. Both page reloads and
+a fresh server/two fresh WASM clients retain all eight physical instances,
+qualities, charges, raw skills, XP0/IP1500, 37-credit wallets and saved scanner
+IDs with cumulative insured XP38650. Independent SQL checks find exactly
+eight item rows and eight unique locations in both phase snapshots.
+
+The focused WASM check passes in 242.26 seconds (189.46 warm, 52.80 cold), with
+ten error-free captures. The bounded transport ring rolls over in some traces;
+its separate lifecycle history retains all three critical packets per owner
+without drops. Evidence and SQLite snapshots are under
+`local/faction-checkpoint/20261103-073313/`, with the independent report at
+`local/faction-checkpoint/verification.json`. A cold-only input follow-up uses
+that actual warm database, opens both retained inventories and captures the
+rendered cities with their 50/100-charge icons. It passes in 36.83 seconds;
+evidence is under `local/faction-cold-inventory/20261103-074437/`. This resolves
+an initial cold capture taken while the loading overlay was still visible,
+without replaying travel or combat. The matching Go selection passes 17 roots
+and 74 results normally and under the race detector; vet also passes.
+Together with the existing Omni
+run and authored affiliation checks, these separate controlled route/recovery
+proofs establish reachable coverage for all three factions. They do not earn
+levels or supplies, establish a continuous Neutral playthrough, or resolve
+original fees, return transforms, resurrection resources or reclaim timing.
+
+```sh
+AO_GAME_TEST=1 go test ./server -run '^TestBrowserFactionInsuranceCheckpoint$' -count=1 -v
+```
+
## Native contract and server handling
The target is original `anarchy-vanilla-14.9.1/kkr.dll`, SHA-256
diff --git a/server/browser_faction_insurance_test.go b/server/browser_faction_insurance_test.go
@@ -0,0 +1,169 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserFactionInsuranceCheckpoint(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for focused faction insurance recovery")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/faction-checkpoint", time.Now().Format("20060102-150405"))
+ configs := []struct {
+ city, scanner, reclaim uint32
+ appearance uint16
+ }{
+ {640, 3221357184, 3221357184, 0x315},
+ {566, 3221357110, 3221291574, 0x115},
+ }
+
+ t.Chdir(t.TempDir())
+ for _, phase := range []string{"warm", "cold"} {
+ t.Run(phase, func(t *testing.T) {
+ world := newServerForTest(t)
+ world.combatRoll = landedCombatRoll
+ // Controlled scanner checkpoints isolate recovery without earning levels.
+ // Hold regeneration so one ordinary retaliatory hit is fatal.
+ if phase == "warm" {
+ world.characters = make(map[uint32]*character)
+ world.mobileNPCs = make(map[uint32][]*character)
+ world.nextNPC = 9000003
+ for index, config := range configs {
+ player := world.newCharacter()
+ player.name, player.level, player.appearance = fmt.Sprint("InsuranceRoute", index), 10, config.appearance
+ player.rotation = [4]float32{0, 0, 0, 1}
+ player.playfield = config.city
+ player.position = gamedata.InsuranceTerminals.Scanners[config.scanner].Arrival.Position
+ player.health, player.nano = 1, 1
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte(fmt.Sprint("faction-route-", index))))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ for _, template := range []uint32{209283, 42640, 25812, 21609} {
+ if ok, err := world.grantItem_locked(player, template); err != nil || !ok {
+ t.Fatal(ok, err)
+ }
+ }
+ inventory := player.inventory
+ inventory.Items[0].Slot, inventory.Credits = 6, 37
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ scanner := gamedata.InsuranceTerminals.Scanners[config.scanner]
+ position := scanner.Arrival.Position
+ position[0] += 1
+ enemy := &character{id: 9000001 + uint32(index), name: "Insurance encounter", npc: true,
+ playfield: config.city, position: position, rotation: [4]float32{0, 0, 0, 1}, appearance: 229,
+ monsterData: 17655, level: 1, health: 100, combatProfile: gamedata.NPCCombatProfiles[17655][1], geometry: world.geometry}
+ world.characters[enemy.id] = enemy
+ }
+ }
+ 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()
+ var rows []map[string]any
+ for index, config := range configs {
+ player := world.characters[uint32(index+1)]
+ rows = append(rows, map[string]any{"id": player.id, "field": player.playfield,
+ "position": predictedPosition_locked(player, time.Now()), "health": player.health, "fighting": player.fighting,
+ "inventory": player.inventory, "scanner": player.resurrectionTerminal, "insured": player.insuredExperience,
+ "experience": player.experience, "stats": player.stats, "returnDoor": player.returnDoor,
+ "city": config.city, "scannerID": config.scanner, "reclaimID": config.reclaim,
+ "arrival": gamedata.InsuranceTerminals.Scanners[config.scanner].Arrival.Position,
+ "scannerPosition": gamedata.InsuranceTerminals.Scanners[config.scanner].Position,
+ "reclaimPosition": gamedata.InsuranceTerminals.Reclaim[config.reclaim].Position, "enemy": 9000001 + uint32(index)})
+ }
+ json.NewEncoder(w).Encode(map[string]any{"phase": phase, "players": rows})
+ })
+ host := httptest.NewServer(mux)
+ t.Cleanup(host.Close)
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 8*time.Minute)
+ defer cancel()
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ ticker := time.NewTicker(time.Second / 60)
+ checkpoint := time.NewTicker(time.Second)
+ defer ticker.Stop()
+ defer checkpoint.Stop()
+ for {
+ select {
+ case now := <-ticker.C:
+ world.advancePlayerMovement(now)
+ world.advanceZoneCrossings(now)
+ world.advanceEquipment(now)
+ world.advanceCombat(now)
+ case now := <-checkpoint.C:
+ if err := world.flushPositions(now); err != nil {
+ t.Error(err)
+ }
+ if err := world.checkpointWorld(now); err != nil {
+ t.Error(err)
+ }
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+
+ if err := os.MkdirAll(filepath.Join(output, phase), 0755); err != nil {
+ t.Fatal(err)
+ }
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_faction_insurance.mjs"), host.URL, filepath.Join(output, phase))
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ cancel()
+ <-stopped
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ // Preserve committed checkpoints even if a native assertion fails.
+ if _, err := world.db.Exec("VACUUM INTO ?", filepath.Join(output, phase, "world.sqlite")); err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("Browser artifacts: %s", output)
+
+ if err != nil {
+ t.Fatal(err)
+ }
+ for index, config := range configs {
+ player := world.characters[uint32(index+1)]
+ first := uint32(index*4 + 1)
+ expected := []ownedItem{
+ {ID: first, Type: 51018, Template: 209283, Quality: 1, Slot: 6, Count: 1},
+ {ID: first + 1, Type: 51005, Template: 42640, Quality: 1, Slot: 64, Count: 1},
+ {ID: first + 2, Type: 51005, Template: 25812, Quality: 1, Slot: 65, Count: 50},
+ {ID: first + 3, Type: 51005, Template: 21609, Quality: 1, Slot: 66, Count: 100},
+ }
+ if !slices.Equal(player.inventory.Items, expected) || len(player.inventory.Reclaim) != 0 ||
+ player.inventory.Credits != 37 || player.playfield != config.city || player.health != 1 || player.nano != 1 ||
+ player.resurrectionTerminal != config.scanner || player.insuredExperience != 38650 ||
+ player.level != 10 || player.experience != 0 || player.stats != defaultCharacterStats(player.appearance>>4&7) {
+ t.Fatal("faction recovery lost its save or exact ownership", player.userData(), player.inventory)
+ }
+ }
+ })
+ if t.Failed() {
+ return
+ }
+ }
+}
diff --git a/tools/client/test_faction_insurance.mjs b/tools/client/test_faction_insurance.mjs
@@ -0,0 +1,176 @@
+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', headless: false,
+ args: ['--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+const games = [], evidence = {};
+const state = async () => (await games[0].page.request.get(url + '/test-state')).json();
+
+async function face(game, position) {
+ const deadline = Date.now() + 8000;
+ for (;;) {
+ await game.snapshot();
+ const actor = game.local();
+ const yaw = Math.atan2(position[0] - actor.position[0], position[2] - actor.position[2]);
+ const delta = yaw - 2 * Math.atan2(actor.rotation[1], actor.rotation[3]);
+ const angle = Math.atan2(Math.sin(delta), Math.cos(delta));
+ if (Math.abs(angle) < 0.06) return;
+ assert(Date.now() < deadline, 'Native turn did not reach the interaction target');
+ const sequence = game.sequence;
+ await game.page.keyboard.press(angle > 0 ? 'KeyD' : 'KeyA',
+ {delay: Math.min(150, Math.max(20, Math.abs(angle) / 3.5 * 1000))});
+ await game.waitInput(sequence, 769);
+ }
+}
+
+async function frameEnemy(game, identity) {
+ const enemy = () => game.state.actors.find(actor => actor.type === 50000 && actor.id === identity);
+ if (enemy().screenPosition[1] >= 200 && enemy().screenPosition[1] <= 700) return;
+ const point = await game.point(512, 300);
+ let mouseY = point.y;
+ let sequence = game.sequence;
+ const deadline = Date.now() + 10000;
+ await game.page.mouse.move(point.x, mouseY);
+ await game.page.mouse.down({button: 'right'});
+ try {
+ await game.waitInput(sequence, 1025);
+ for (;;) {
+ await game.snapshot();
+ const y = enemy().screenPosition[1];
+ if (y >= 200 && y <= 700) break;
+ assert(Date.now() < deadline, 'Encounter did not frame above the native toolbar');
+ mouseY += y > 700 ? 20 : -20;
+ await game.page.mouse.move(point.x, mouseY, {steps: 2});
+ }
+ } finally {
+ sequence = game.sequence;
+ await game.page.mouse.up({button: 'right'});
+ await game.waitInput(sequence, 1026);
+ }
+}
+
+try {
+ for (const index of [0, 1]) {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'faction-route-' + index, url}]);
+ const page = await context.newPage(), game = await GameTest.attach(page);
+ games.push(game);
+ await page.goto(url);
+ await game.ready();
+ }
+ evidence.initial = await state();
+ if (evidence.initial.phase === 'warm') {
+ for (const [index, game] of games.entries()) {
+ const config = evidence.initial.players[index];
+ const [x, , z] = config.arrival;
+ await face(game, config.scannerPosition);
+ await game.click(...await game.pick(51005, config.scannerID), 'right');
+ await game.wait('native insured message', () => game.events.some(event => event.direction === 'framereceived' &&
+ event.opcode === '5e477770' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 79));
+ evidence['saved' + index] = (await state()).players[index];
+ assert.equal(evidence['saved' + index].scanner, config.scannerID);
+ await game.save(output + '/saved-' + index);
+
+ // Real attack input starts retaliation; one server hit ends this controlled encounter.
+ const enemy = game.state.actors.find(actor => actor.type === 50000 && actor.id === config.enemy);
+ assert(enemy);
+ await face(game, enemy.position);
+ await frameEnemy(game, config.enemy);
+ await game.click(...await game.pick(50000, config.enemy));
+ const sequence = game.sequence;
+ await game.key('KeyQ');
+ await game.wait('native attack request', () => game.events.some(event => event.sequence > sequence &&
+ event.direction === 'framesent' && event.opcode === '28494070'));
+ await game.wait('saved city resurrection', snapshot => game.local(snapshot)?.playfield === config.city &&
+ game.local(snapshot)?.stats[27] === 1 && game.lifecycle.some(event => event.sequence > sequence &&
+ event.direction === 'framereceived' && event.opcode === '445f2a0b'), 30000);
+ await game.ready();
+ evidence['returned' + index] = (await state()).players[index];
+ const returned = evidence['returned' + index];
+ assert.equal(returned.health, 1);
+ assert.equal(returned.returnDoor, null);
+ assert.equal(returned.inventory.Items.length, 1);
+ assert.equal(returned.inventory.Items[0].Slot, 6);
+ assert.deepEqual(returned.inventory.Reclaim.map(entry => entry.Item), config.inventory.Items.slice(1));
+ assert(Math.hypot(returned.position[0] - x, returned.position[2] - z) < 0.5);
+ assert.deepEqual(game.lifecycle.filter(event => event.sequence > sequence && event.actor?.[1] === config.id)
+ .map(event => [event.direction, event.opcode, Buffer.from(event.hex, 'hex').readUInt32BE(29)]), [
+ ['framereceived', '5e477770', 99], ['framesent', '5e477770', 152], ['framereceived', '445f2a0b', 1],
+ ]);
+ await game.save(output + '/returned-' + index);
+ }
+
+ // Walk to each actual booth, letting the ordinary reclaim deadline expire.
+ for (const index of [1, 0]) {
+ const game = games[index];
+ const config = evidence.initial.players[index];
+ const streets = [[[487, 401]], [[299, 320], [320, 320], [318, 303]]][index];
+ for (const [x, z] of streets) {
+ await game.walk(x, z);
+ assert.equal(game.local().playfield, config.city);
+ assert(Math.hypot(x - game.local().position[0], z - game.local().position[2]) < 0.35);
+ }
+ const returned = evidence['returned' + index];
+ await game.wait('ordinary reclaim availability', () => returned.inventory.Reclaim.every(entry =>
+ Date.now() >= Date.parse(entry.AvailableAt)), 90000);
+ await face(game, config.reclaimPosition);
+ await game.click(...await game.pick(51059, config.reclaimID), 'right');
+ await game.wait('three reclaim sources', snapshot => snapshot.grids.flatMap(grid => grid.cells)
+ .filter(cell => cell.identity[0] === 106 && !cell.dummy).length === 3);
+ for (const [slot, item] of config.inventory.Items.slice(1).entries()) {
+ const cell = game.state.grids.flatMap(grid => grid.cells).find(cell =>
+ cell.identity[0] === 106 && cell.identity[1] === slot && !cell.dummy);
+ assert(cell);
+ await game.click((cell.bounds[0] + cell.bounds[2]) / 2, (cell.bounds[1] + cell.bounds[3]) / 2);
+ await game.wait('exact instance reclaimed', snapshot => game.local(snapshot).inventory.some(proxy =>
+ proxy.id === item.ID && proxy.count === item.Count && proxy.slot === 48 + slot));
+ }
+ await game.click(170, 8);
+ await game.save(output + '/collected-' + index);
+ await game.page.reload();
+ await game.ready();
+ }
+ }
+
+ // Page replay and a fresh server must retain the same four instances per owner.
+ evidence.final = await state();
+ for (const [index, game] of games.entries()) {
+ const player = evidence.final.players[index];
+ assert.equal(player.field, player.city);
+ assert.equal(player.scanner, player.scannerID);
+ assert.equal(player.insured, 38650);
+ assert.equal(player.experience, 0);
+ assert.equal(player.stats.ImprovementPoints, 1500);
+ assert.equal(player.inventory.Credits, 37);
+ assert.equal(player.inventory.Reclaim, null);
+ assert.deepEqual(player.inventory.Items.map(item => [item.ID, item.Template, item.Quality, item.Slot, item.Count]), [
+ [index * 4 + 1, 209283, 1, 6, 1], [index * 4 + 2, 42640, 1, 64, 1],
+ [index * 4 + 3, 25812, 1, 65, 50], [index * 4 + 4, 21609, 1, 66, 100],
+ ]);
+ assert.deepEqual(game.local().inventory.map(item => [item.id, item.slot, item.quality, item.count]).sort((a, b) => a[0] - b[0]), [
+ [index * 4 + 1, 6, 1, 1], [index * 4 + 2, 48, 1, 1],
+ [index * 4 + 3, 49, 1, 50], [index * 4 + 4, 50, 1, 100],
+ ]);
+ assert.equal(game.lifecycleDropped, 0);
+ if (evidence.initial.phase === 'cold') {
+ await game.key('KeyI');
+ await game.wait('retained inventory opens after cold loading', snapshot => snapshot.grids.some(grid =>
+ grid.cells.some(cell => cell.identity[0] === 104 && !cell.dummy)));
+ await game.save(output + '/inventory-' + index);
+ }
+ }
+ assert(games.every(game => game.errors.length === 0));
+ console.log('PASS:', evidence.initial.phase, 'controlled faction save, death and exact reclaim ownership');
+} finally {
+ try {
+ evidence.final = await state();
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ await Promise.all(games.map((game, index) => game.save(output + '/final-' + index)));
+ } finally { await browser.close(); }
+}