commit 270738d2d6f1c45223e766e46fda52701aa9b3e6
parent 6a1d888bbff279c6712c0c931cccca336ea08e01
Author: anon <anon@example.com>
Date: Fri, 6 Nov 2026 03:24:13 +0000
Verify Clan and Neutral level training and repeat missions
Diffstat:
4 files changed, 365 insertions(+), 4 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -225,8 +225,10 @@ research separately. More screenshots and test cases do not count as new gamepla
using starting IP and issued equipment; MPs use their issued pet and shield.
The level-5/10 non-Enforcer checkpoints now pass with available shop loadouts,
including the level-ten Nanomage MA with a complete QL5 Metaplast set.
- A7 remains open for a current Clan/Neutral repeat/level-training sample and
- bounded release/affordability/pace checks.
+ Current native Clan/Neutral checkpoints now earn/train level two, settle the
+ saved level-one contract, request/complete a level-two repeat and preserve
+ exact ownership and training through reconnects and cold starts. A7 remains
+ open for bounded release/affordability/pace checks.
- [x] **A8: Isolate administration before public hosting.** The current HTTP
and HTTPS listeners share a handler. Administration now requires separate
diff --git a/docs/alpha-progression-matrix.md b/docs/alpha-progression-matrix.md
@@ -27,9 +27,9 @@ and encounter balance remains explicitly provisional.
| --- | --- | --- |
| Create offered characters and use issued tools | All 255 original heads with profession/faction choices survive restart; the twelve-profession check uploads all nineteen issued crystals with starting IP; the 48 profession/breed starter checks below connect fight, recovery and cold ownership | Starter readiness covered; controlled higher-level paths are recorded below |
| Fight and loot on every faction's training route | Original creature and human placement checks use native picking and exact corpse ownership through cold recovery | These controlled body checks do not establish normal-play pace |
-| Earn/train a level | Retained fresh Omni Enforcer loop earns level 2 and spends earned IP; the same ordinary progression continues through level 10 | Inspect retained evidence for the bounded release sample; do not repeat leveling |
+| Earn/train a level | Retained fresh Omni Enforcer loop earns level 2 and spends earned IP; the same ordinary progression continues through level 10; current native Clan/Neutral checkpoints below earn level 2 and spend its IP | Inspect retained evidence for the bounded release sample; do not repeat leveling |
| Obtain/use an upgrade and replenish supplies | Ordinary Omni armor/weapon/recovery purchases; ordinary Clan bat and Neutral glove mission rewards; current three-faction purchase/use/reconnect checks; 23 controlled level-5/10 profession checkpoints below | Available loadouts pass; ordinary affordability and pace remain separate below |
-| Finish and repeat missions | Ordinary Omni repeated contracts through level 10; ordinary Clan and Neutral entry, book return, reward wear and cold native login | One bounded current Clan/Neutral repeat/level-training integration sample remains |
+| Finish and repeat missions | Ordinary Omni repeated contracts through level 10; ordinary Clan and Neutral entry, book return, reward wear and cold native login; current native Clan/Neutral saved settlement and repeat contracts below | Controlled integration covered; ordinary pace remains separate below |
| Recover from death | Ordinary Omni level-10 combat death, cold pending reclaim, exact collection and return to the interrupted mission; controlled native Clan/Neutral scanner/death/reclaim checkpoints | Shared recovery ownership is covered by A6; retain the faction checkpoints in release acceptance |
| Reconnect/restart without losing progress | Exact-state and failed-write/retry matrix; two-client native cold login; ordinary earned checkpoints | One bounded release acceptance pass after remaining known gaps are resolved |
| Affordability and progression pace | Current 500-credits-per-mission-level policy has all-faction level-1/5/10 settlement/resupply checks; retained ordinary level-two mission funds recovery and armor | Older earned runs used 20-credit hand-ins. Use one bounded current ordinary sample for pace; funded fixtures alone do not close it |
@@ -142,3 +142,39 @@ The final run passes in 30.77 seconds after package initialization; its log is
local document-link checks pass. Initial probes corrected missing Fling
qualification, absent combat reload input and use of an inventory-only cold
loader that does not load pets; they did not require server behavior changes.
+
+## November 5 Clan/Neutral level and repeat contracts
+
+`TestBrowserFactionLevelAndMissionRepeat` uses the original Tir Backyard 1
+booth `3221228572` and Newland Backyard 1 booth `3221228532`. Each checkpoint
+starts with a normally created/trained Atrox Enforcer and its issued kit,
+with faction and placement changed by the fixture. The fixture grants 1350 XP
+and one credit for the initial level-one request. Mission entry and objective
+pickup use normal handlers with controlled placement; travel and objective
+collection are not native-play claims in this check. The retained ordinary
+faction creation, entry and book-return runs cover those separate paths.
+
+Native enemy selection and Q defeat a full-health level-one Leet for 100 XP,
+reaching level two and awarding 4000 IP. The native skills window raises Body
+Development from 9 to 15 for 69 IP. Native book-on-booth Use settles the saved
+level-one contract for 500 credits and its exact QL1 item, despite the level
+change. A native repeat request costs two credits and promises 1000 credits
+and a QL2 item. After acceptance and a cold start, the second prepared book
+is returned through native input for that saved reward. Both factions finish
+at level two with zero carried XP, 5085 IP and 1498 credits; neither hand-in
+grants completion XP.
+
+Each settlement/repeat stage checks the exact retained items and selected
+reward, reconnects the browser and cold-loads the production server. Inventory,
+trained stats, XP, health and active mission state survive. Screenshots show
+the native level award and mission completion; reconnect assertions use
+client/server state because the final images can still show the fading arrival
+overlay. All test browsers and servers are closed after each stage.
+
+Clan passes in 73.07 seconds and Neutral in 77.33 seconds after package
+initialization. Logs are `local/alpha-faction-progression/clan.log` and
+`local/alpha-faction-progression/neutral.log`; artifacts are under
+`local/alpha-faction-progression/20261105-192033/Clan/` and
+`local/alpha-faction-progression/20261105-192202/Neutral/`.
+This completes the named faction repeat/level-training integration check,
+without changing gameplay or establishing ordinary affordability or pace.
diff --git a/server/browser_faction_progression_test.go b/server/browser_faction_progression_test.go
@@ -0,0 +1,184 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "context"
+ "crypto/sha256"
+ "encoding/binary"
+ "encoding/json"
+ "fmt"
+ "math"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "testing"
+ "time"
+)
+
+func TestBrowserFactionLevelAndMissionRepeat(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for the Clan/Neutral progression checkpoints")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/alpha-faction-progression", time.Now().Format("20060102-150405"))
+ for _, fixture := range []struct {
+ name string
+ booth uint32
+ side uint16
+ }{{"Clan", 3221228572, 1}, {"Neutral", 3221228532, 0}} {
+ t.Run(fixture.name, func(t *testing.T) {
+ groups := gamedata.NPCGroups
+ world, _ := newCreatedStarterCombatWorld(t, 9, 40132)
+ for _, encounter := range gamedata.MissionTemplates[fixture.booth].Encounters {
+ gamedata.NPCGroups[encounter.Definition] = groups[encounter.Definition]
+ }
+ player, target, client := world.characters[2], world.characters[1000000], world.clients[2]
+ booth := gamedata.MissionBooths[fixture.booth]
+ player.appearance = player.appearance&^(3<<9) | fixture.side<<9
+ player.playfield, player.position = booth.Playfield, booth.Position
+ // Grant only a near-level XP checkpoint and the first request fee.
+ player.experience = gamedata.ExperienceLevels[0] - 100
+ player.inventory.Credits = 1
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("faction-progression")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ request := missionOffersRequest()
+ binary.BigEndian.PutUint32(request[8:12], player.id)
+ originator, admitted := world.missionBoothEligibility_locked(client, booth)
+ if !admitted {
+ t.Fatal("faction checkpoint cannot use its original booth")
+ }
+ request[28] = byte(originator)
+ binary.BigEndian.PutUint32(request[33:37], fixture.booth)
+ if err := world.handleMissionOffers(client, request); err != nil || client.missionOffer == nil {
+ t.Fatal("initial offer", err)
+ }
+ request = missionAcceptanceRequest(*client.missionOffer)
+ binary.BigEndian.PutUint32(request[8:12], player.id)
+ if err := world.handleMissionAcceptance(client, request); err != nil {
+ t.Fatal(err)
+ }
+ initialIP := player.stats.ImprovementPoints
+
+ for phase := 0; phase < 2; phase++ {
+ // Objective collection and return placement are controlled checkpoints.
+ // Native input performs the level, training, settlement and repeat request.
+ client = &worldClient{id: player.id, conn: &combatTestConn{}, ready: true, target: true, npcs: map[uint32]bool{target.id: true}}
+ world.clients[player.id] = client
+ if len(player.missions) != 1 {
+ t.Fatal("expected one accepted contract", len(player.missions))
+ }
+ mission := player.missions[0]
+ itemCount := len(player.inventory.Items)
+ player.position = mission.offer.definition.Position
+ player.movement = playerMovement{}
+ if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil {
+ t.Fatal(err)
+ }
+ world.clients[player.id], client.ready, client.loading = client, true, false
+ mission = player.missions[0]
+ player.position = world.worldItems[mission.objective].position
+ player.movement = playerMovement{}
+ if err := world.handleInventory(client, worldPickupRequest(player.id, mission.objective)); err != nil {
+ t.Fatal(err)
+ }
+ if mission.objective == 0 || len(player.inventory.Items) != itemCount+1 {
+ t.Fatal("checkpoint did not collect its mission book", player.inventory)
+ }
+ player.playfield, player.position = booth.Playfield, booth.Position
+ player.position[1] += .5
+ player.position[2] += 3
+ yaw := math.Atan2(float64(booth.Position[0]-player.position[0]), float64(booth.Position[2]-player.position[2]))
+ player.rotation = [4]float32{0, float32(math.Sin(yaw / 2)), 0, float32(math.Cos(yaw / 2))}
+ if phase == 0 {
+ target.playfield, target.position = player.playfield, player.position
+ target.position[0] += 1
+ target.position[2] -= 2
+ target.motion.home = target.position
+ }
+ if err := world.savePosition_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ delete(world.clients, player.id)
+
+ 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()
+ missions := []map[string]any{}
+ for _, accepted := range player.missions {
+ missions = append(missions, map[string]any{"id": accepted.id, "objective": accepted.objective, "definition": accepted.offer.definition})
+ }
+ var offer any
+ if client := world.clients[player.id]; client != nil && client.missionOffer != nil {
+ offer = client.missionOffer.definition
+ }
+ json.NewEncoder(w).Encode(map[string]any{"phase": phase, "booth": fixture.booth, "id": player.id,
+ "health": player.health, "level": player.level, "experience": player.experience, "stats": player.stats,
+ "inventory": player.inventory, "target": target.id, "targetHealth": target.health,
+ "completed": world.missionWorld_locked(mission.world).completed, "definition": mission.offer.definition, "missions": missions, "offer": offer})
+ })
+ host := httptest.NewServer(mux)
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ ticker := time.NewTicker(50 * time.Millisecond)
+ defer ticker.Stop()
+ for {
+ select {
+ case now := <-ticker.C:
+ world.advancePlayerMovement(now)
+ world.advanceNPCs(now)
+ world.advanceCombat(now)
+ world.advanceRegeneration(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ artifacts := filepath.Join(output, fixture.name, fmt.Sprint(phase))
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_faction_progression.mjs"), host.URL, artifacts)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ cancel()
+ <-stopped
+ host.Close()
+ closeTestSessions(t, world)
+ t.Logf("Browser artifacts: %s", artifacts)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ cold := newServerForTest(t)
+ restored := cold.characters[player.id]
+ expected := player.inventory
+ expected.LastID = world.nextItem
+ if restored.level != 2 || restored.experience != 0 || restored.stats != player.stats || restored.health != player.health ||
+ !reflect.DeepEqual(restored.inventory, expected) || len(restored.missions) != 1-phase || !cold.missionWorld_locked(mission.world).completed {
+ t.Fatal("faction progression changed on cold load", restored.profile(), restored.inventory)
+ }
+ world, player = cold, restored
+ target = world.characters[1000000]
+ }
+ if player.stats.Body.BodyDevelopment != 15 || player.stats.ImprovementPoints != initialIP+4000-69 || player.inventory.Credits != 1498 {
+ t.Fatal("repeat contract or earned training accounting changed", player.stats, player.inventory)
+ }
+ })
+ }
+}
diff --git a/tools/client/test_faction_progression.mjs b/tools/client/test_faction_progression.mjs
@@ -0,0 +1,139 @@
+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']});
+let game;
+const evidence = {};
+try {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'faction-progression', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ const frame = async (type, id) => {
+ const point = await game.point(512, 300);
+ let mouseY = point.y, sequence = game.sequence;
+ await page.mouse.move(point.x, mouseY);
+ await page.mouse.down({button: 'right'});
+ try {
+ await game.waitInput(sequence, 1025);
+ const deadline = Date.now() + 10000;
+ for (;;) {
+ await game.snapshot();
+ const y = game.state.actors.find(actor => actor.type === type && actor.id === id).screenPosition[1];
+ if (y >= 350 && y <= 550) break;
+ assert(Date.now() < deadline, 'Could not frame faction checkpoint target');
+ mouseY += y > 550 ? 10 : -10;
+ await page.mouse.move(point.x, mouseY, {steps: 2});
+ }
+ } finally {
+ sequence = game.sequence;
+ await page.mouse.up({button: 'right'});
+ }
+ await game.waitInput(sequence, 1026);
+ };
+ await page.goto(url);
+ await game.ready();
+ await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ const initial = evidence.initial = await server();
+ if (initial.phase === 0) {
+ assert.equal(initial.targetHealth, 100);
+ assert.equal(initial.level, 1);
+ await frame(50000, initial.target);
+ await game.click(...await game.pick(50000, initial.target));
+ await game.wait('enemy selected', state => state.selected[1] === initial.target);
+ await game.key('q');
+ await game.wait('native level-two award', state => {
+ assert(game.local(state).stats[27] > 0, 'Faction checkpoint died');
+ return game.local(state).stats[54] === 2;
+ }, 120000);
+ evidence.levelled = await server();
+ assert.equal(evidence.levelled.targetHealth, 0);
+ assert.equal(evidence.levelled.experience, 0);
+ assert.equal(evidence.levelled.stats.ImprovementPoints, initial.stats.ImprovementPoints + 4000);
+ await game.save(output + '/level-two');
+
+ // Spend the newly awarded IP beyond the level-one Body Development cap.
+ await game.key('KeyU');
+ await game.click(334, 196);
+ for (let point = 0; point < 6; ++point) await game.click(835, 346);
+ await game.click(445, 622);
+ await game.wait('level-two Body Development purchase', state =>
+ game.local(state).stats[152] === 15 && game.local(state).stats[53] === initial.stats.ImprovementPoints + 4000 - 69);
+ evidence.trained = await server();
+ assert.equal(evidence.trained.stats.Body.BodyDevelopment, 15);
+ await game.save(output + '/trained');
+ }
+
+ // Return the exact prepared book through native item-on-booth Use.
+ await frame(56001, initial.booth);
+ await game.key('KeyI');
+ const book = initial.inventory.Items.find(item => item.ID === initial.missions[0].objective);
+ assert(book && book.Template === 40822);
+ await game.wait('prepared book visible in inventory', state => state.grids.some(grid =>
+ grid.cells.some(cell => cell.identity[0] === 104 && cell.identity[1] === book.Slot - 16 && !cell.dummy)));
+ const cell = game.state.grids.flatMap(grid => grid.cells).find(cell =>
+ cell.identity[0] === 104 && cell.identity[1] === book.Slot - 16 && !cell.dummy);
+ await game.click((cell.bounds[0] + cell.bounds[2]) / 2, (cell.bounds[1] + cell.bounds[3]) / 2);
+ await game.wait('prepared book picked', state => state.dragged[0] === 104);
+ await game.click(...await game.pick(56001, initial.booth), 'right');
+ const paid = initial.inventory.Credits + initial.definition.Credits;
+ await game.wait('native saved reward paid', state => game.local(state).stats[61] === paid);
+ evidence.completed = await server();
+ assert(evidence.completed.completed);
+ assert.equal(evidence.completed.experience, 0);
+ assert.equal(evidence.completed.level, 2);
+ const retained = initial.inventory.Items.filter(item => item.ID !== initial.missions[0].id && item.ID !== book.ID);
+ const reward = evidence.completed.inventory.Items.find(item => !retained.some(old => old.ID === item.ID));
+ assert(reward);
+ assert.equal(reward.Template, initial.definition.RewardItem);
+ assert.equal(reward.Quality, initial.definition.RewardQuality);
+ assert.deepEqual(evidence.completed.inventory.Items.filter(item => item.ID !== reward.ID), retained);
+ await game.save(output + '/completed');
+ await game.key('KeyI');
+
+ if (initial.phase === 0) {
+ await game.click(...await game.pick(56001, initial.booth), 'right');
+ await game.wait('repeat mission request form', state => state.regions.some(region =>
+ region[0] === 150 && region[1] === 180 && region[2] === 220 && region[3] === 200));
+ await game.click(100, 163);
+ await game.wait('level-two repeat request fee', state => game.local(state).stats[61] === paid - 2);
+ evidence.offer = (await server()).offer;
+ assert.equal(evidence.offer.Credits, 1000);
+ assert.equal(evidence.offer.RewardQuality, 2);
+ assert.equal(evidence.offer.Entrance, initial.booth);
+ await game.click(30, 45);
+ await game.click(74, 190);
+ await game.wait('repeat mission key delivered', state => game.local(state).inventory.some(item => item.templates[0] === 28577));
+ evidence.accepted = await server();
+ assert.equal(evidence.accepted.missions.length, 1);
+ assert.notEqual(evidence.accepted.missions[0].id, initial.missions[0].id);
+ assert.deepEqual(evidence.accepted.missions[0].definition,
+ {...evidence.offer, RewardItems: null, Encounters: null, PassageDoor: 0});
+ await game.save(output + '/repeat-accepted');
+ }
+ const beforeReload = await server();
+ await page.reload();
+ await game.ready();
+ await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
+ evidence.reconnected = await server();
+ assert.deepEqual(evidence.reconnected.inventory, beforeReload.inventory);
+ assert.deepEqual(evidence.reconnected.stats, beforeReload.stats);
+ assert.deepEqual(evidence.reconnected.missions, beforeReload.missions);
+ assert.equal(game.local().stats[54], 2);
+ assert.deepEqual(game.errors, []);
+ console.log('PASS:', initial.booth, 'phase', initial.phase, 'level/training, saved settlement and repeat contract retained');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ if (game) await game.save(output + '/final');
+ } finally { await browser.close(); }
+}