commit e43454ce11a784276a53275e9057e02fd9303af5
parent 1f8a1cc95c51bd82403390b8746e64d345f58ed5
Author: anon <anon@example.com>
Date: Tue, 3 Nov 2026 13:44:56 +0000
Record native combat-turn publication contract
Diffstat:
4 files changed, 224 insertions(+), 0 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -3458,6 +3458,12 @@ with payloads and known client/server provenance.
encounter; its canonical publication policy remains open. Evidence:
`local/game-tests/starter-20261031-011445/outdoor/` and
`local/todo-progression-play/starter-full-facing.json`.
+ A short controlled two-client check now reproduces a 180-degree native turn
+ and stop without any movement request; ordinary A-key input publishes the
+ retained facing and reconciles both views with the server. Original state 7
+ turns gradually at a nominal 7.2 rad/s and completes below 0.005 rad. The native
+ publication regression leaves authoritative combat-turn policy open; see
+ [combat facing](docs/combat-facing.md).
- [x] Keep browser rebuilds independent of reviewed server-world data. `make wasm`
previously recopied ignored extraction output through its `assets` prerequisite,
removing reviewed destination/arrival/requirement rows from `zone_links.yaml`.
diff --git a/docs/combat-facing.md b/docs/combat-facing.md
@@ -0,0 +1,65 @@
+# Combat auto-turning and movement publication
+
+The facing mismatch recorded in the earned outdoor fight now has a small
+controlled reproduction. Native combat turns both visible copies of the owner;
+the authoritative heading remains unchanged until ordinary movement input.
+The original turn is visual simulation without an emitted movement request in
+this scenario. A client-side forced movement send would change that contract.
+Authoritative combat-turn simulation and the original server's publication
+policy remain unresolved; this milestone does not fix the server heading.
+
+## Original turning path
+
+The original 14.9.1 `kkr.dll` SHA256 is
+`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`.
+Fresh REA queries recover the following bounded chain:
+
+- Fight update 10086390 checks every 0.67 seconds. When its numeric state/vehicle
+ gates permit it, a target-direction difference above 0.26 radians requests
+ state 7 through 10086bd0. This is the existing documented fight predicate,
+ not a newly established universal melee/ranged/casting rule.
+- Factory 10086bd0 constructs state 7 through 10086e60, setting speed 9.0,
+ Y-axis turn and an initial angle computed by 100870d0. Direction 10086ef0
+ resolves the current fight target, with separate idle/casting target paths.
+- The state vtable at 10171c24 points to update 10087340. Its next float is 0.8.
+ Each frame takes `min(remaining_angle, 9.0 * 0.8 * frame_delta)`, constructs
+ the axis quaternion, left-multiplies the current relative rotation and calls
+ `n3Dynel_t::SetRelRot`. It decrements the remaining angle and completes below
+ 0.005 radians, returning to fight/cast/idle according to the live actor state.
+- That update body contains no explicit network send. The runtime check below
+ tests publication through this path and its indirect calls, rather than
+ inferring network silence from that body alone.
+
+Complete original pseudocode and vtable bytes are in
+`local/combat-facing-research/native-evidence.json`, with the closed analysis
+snapshot beside it. The accepted turning update is retained under batch evidence
+`ev_d53be616a7268fc4abde5182fad6d63e85dd86cbdc66367140843a98878b4530`.
+The selected generated body is
+`client/game/kkr.dll/lifted-0039.c:sub_36087340`; the original artifact is the
+authority for the recovered contract. Two other selected generated entries
+had no Ghidra procedure; neither is used to establish this chain.
+
+## Focused native regression
+
+`TestBrowserCombatTurnPublication` uses two isolated WASM clients, a stationary
+owner facing north and an original level-one Leet three metres south. The
+fixture holds the server attack scheduler: no hits, rewards, skills or supplies
+are earned or needed. Real Tab and Q input starts combat. Both native owner
+copies turn approximately 180 degrees, while the live server retains
+`[0,0,0,1]`. Real Q stops combat; both copies keep their turned heading.
+The only owner world requests between start and subsequent manual input are
+Attack and StopFight. There is no movement request, delayed pose publication,
+or unnoticed manual turn in that interval.
+
+A real A-key turn then sends the original 46-byte movement requests, carrying
+the retained facing into the existing movement decoder. Both native views and
+the server agree again; target HP stays 100 throughout. The fixture's native
+ground settling moves Y from 16.5 to 16.41; manual input also publishes that
+settled position. This is recorded separately from the orientation mismatch.
+
+The maintained regression protects original native turning/publication and
+ordinary-input reconciliation. It records server heading diagnostically, and
+does not require future server combat simulation to retain the stale heading.
+Original eligibility gates, moving-target retiming, interruption, casting and
+the original server's authoritative turn/replication policy still need evidence
+before implementing a general server turn or changing the client.
diff --git a/server/browser_combat_facing_test.go b/server/browser_combat_facing_test.go
@@ -0,0 +1,76 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "testing"
+ "time"
+)
+
+func TestBrowserCombatTurnPublication(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for combat turning publication")
+ }
+
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/combat-facing-research", time.Now().Format("20060102-150405"))
+ world := newTestServer(t)
+ var npc *character
+ for _, actor := range world.characters {
+ if actor.npc && actor.playfield == 950 && actor.monsterData == 17655 && actor.level == 1 && actor.combatProfile != nil && (npc == nil || actor.id < npc.id) {
+ npc = actor
+ }
+ }
+ if npc == nil {
+ t.Fatal("no admitted level-one Leet")
+ }
+ npc.playfield, npc.position, npc.rotation, npc.motion = 705, [3]float32{960, 16.5, 508}, [4]float32{0, 0, 0, 1}, nil
+ world.characters = map[uint32]*character{npc.id: npc}
+ for index := range 2 {
+ player := world.newCharacter()
+ player.playfield, player.position = 705, [3]float32{960 + float32(index*2), 16.5, 511}
+ player.rotation = [4]float32{0, 0, 0, 1}
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte(fmt.Sprint("combat-facing-", index))))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := world.flushWorld(); err != nil {
+ t.Fatal(err)
+ }
+ 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()
+ owner := world.characters[1]
+ json.NewEncoder(w).Encode(map[string]any{"npc": npc.id, "rotation": owner.rotation,
+ "position": owner.position, "fighting": owner.fighting, "health": owner.health, "targetHealth": npc.health})
+ })
+ host := httptest.NewServer(mux)
+ t.Cleanup(host.Close)
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
+ defer cancel()
+
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_combat_facing.mjs"), host.URL, output)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ t.Logf("Browser artifacts: %s", output)
+
+ if err != nil {
+ t.Fatal(err)
+ }
+ if world.characters[1].fighting != 0 || npc.health != 100 {
+ t.Fatal("facing fixture left combat active or executed a held attack")
+ }
+}
diff --git a/tools/client/test_combat_facing.mjs b/tools/client/test_combat_facing.mjs
@@ -0,0 +1,77 @@
+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 = [], evidence = {};
+const actor = game => game.state.actors.find(actor => actor.type === 50000 && actor.id === 1);
+const angle = (first, second) => 2 * Math.acos(Math.min(1, Math.abs(first.reduce((sum, value, index) => sum + value * second[index], 0))));
+try {
+ for (const index of [0, 1]) {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'combat-facing-' + index, url}]);
+ const page = await context.newPage(), game = await GameTest.attach(page);
+ games.push(game);
+ await page.goto(url);
+ await game.ready();
+ }
+ const [owner, observer] = games;
+ const server = async () => (await owner.page.request.get(url + '/test-state')).json();
+ const capture = async () => {
+ await Promise.all(games.map(game => game.snapshot()));
+ return {server: await server(), clients: games.map(game => ({rotation: actor(game).rotation,
+ position: actor(game).position, fighting: actor(game).fighting, target: actor(game).combatTarget}))};
+ };
+ await Promise.all(games.map(game => game.wait('owner ready', () => actor(game))));
+ evidence.initial = await capture();
+ const target = evidence.initial.server.npc;
+ const deadline = Date.now() + 10000;
+ while (owner.state.selected[0] !== 50000 || owner.state.selected[1] !== target) {
+ assert(Date.now() < deadline, 'native Tab must select the controlled Leet');
+ await owner.key('Tab');
+ }
+
+ // Hold server attacks while the original visual state performs its own turn.
+ const attack = owner.sequence;
+ await owner.key('KeyQ');
+ await owner.wait('real attack request', () => owner.events.some(event => event.sequence > attack &&
+ event.direction === 'framesent' && event.opcode === '28494070'));
+ await Promise.all(games.map(game => game.wait('original combat auto-turn', () =>
+ actor(game).combatTarget === target && angle(actor(game).rotation, evidence.initial.server.rotation) > 3)));
+ evidence.turned = await capture();
+ assert.deepEqual(evidence.turned.server.position, evidence.initial.server.position);
+ assert.equal(evidence.turned.server.targetHealth, 100);
+ evidence.turnMovement = owner.events.filter(event => event.sequence > attack &&
+ event.direction === 'framesent' && event.opcode === '54111123');
+ assert.equal(evidence.turnMovement.length, 0);
+ await Promise.all(games.map((game, index) => game.save(output + '/turned-' + index)));
+
+ await owner.key('KeyQ');
+ await Promise.all(games.map(game => game.wait('ordinary stop retains facing', () => actor(game).combatTarget === 0)));
+ evidence.stopped = await capture();
+ assert(evidence.stopped.clients.every(client => angle(client.rotation, evidence.initial.server.rotation) > 3));
+ assert(!owner.events.some(event => event.sequence > attack &&
+ event.direction === 'framesent' && event.opcode === '54111123'));
+ const manual = owner.sequence;
+ await owner.key('KeyA');
+ await owner.wait('ordinary input publishes movement', () => owner.events.some(event => event.sequence > manual &&
+ event.direction === 'framesent' && event.opcode === '54111123'));
+ await owner.wait('manual turn carries the auto-turned quaternion', () =>
+ angle(actor(owner).rotation, evidence.initial.server.rotation) > 2.5);
+ evidence.manual = await capture();
+ assert(angle(evidence.manual.server.rotation, evidence.initial.server.rotation) > 2.5);
+ assert(angle(evidence.manual.server.rotation, evidence.manual.clients[0].rotation) < 0.03);
+ assert(games.every(game => game.errors.length === 0));
+ console.log('PASS: native auto-turn changes both visible owners without movement publication; ordinary input publishes the retained facing');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ for (const [index, game] of games.entries()) await game.save(output + '/final-' + index);
+ } finally { await browser.close(); }
+}