commit a1d08ce15f8e7da95a4f01cf246f754af3bb5336
parent 7f89fbcfbced5c4c6f28a096473d8d7b6d1d293f
Author: anon <anon@example.com>
Date: Wed, 4 Nov 2026 16:10:27 +0000
Verify strict native armor requirement boundaries
Diffstat:
5 files changed, 220 insertions(+), 10 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -3958,14 +3958,15 @@ with payloads and known client/server provenance.
fresh-server startup. WASM contracts cover nonzero raw values, signed and
missing modifiers and unchanged guest state; raw zero AC is not evidence of
lost armor. See [effective armor snapshots](docs/browser-effective-armor.md).
-- [ ] [P1] Reconcile native and server selected-quality armor requirement
- boundaries. The QL2 vest85481/85690 fixture sends no native wear request at
- raw Sense10/Agility10, then wears at11/11, while the public-handler catalog
- test admits10/9. Isolate each ability and recover the original interpolation,
- integer conversion and strict comparison before changing admission. Check
- both reviewed anchors at exact boundaries and adjacent values, with native
- requests and matching server acceptance. See the snapshot fixture's retained
- first run; this is separate from AC capture.
+- [x] [P1] Reconcile native and server selected-quality armor requirement
+ boundaries. The reported QL2 vest discrepancy misread the Go table's strict
+ thresholds10/9 as minimum abilities; its successful case already adds one.
+ Original records and interpolation give minimum Sense11/Agility10. Eight
+ native cases at both stored anchors reject each threshold equality and admit
+ the exact minimum and adjacent higher values, matching the public-handler
+ matrix. All eight instances retain selected QL and ownership after cold load.
+ No gameplay formula change was needed. See
+ [strict armor boundaries](docs/leather-armor.md#strict-requirement-boundaries).
- [x] [P1] Audit native inventory-proxy identities immediately after rewards.
Mission 81's new boots have the correct slot, QL, templates and count while
their raw proxy still reports type/id 0; page replay populates exact ID 87.
diff --git a/docs/browser-effective-armor.md b/docs/browser-effective-armor.md
@@ -36,8 +36,9 @@ exact vest and defenses; no earned acquisition or progression is claimed.
Accepted captures: `local/effective-armor/20261104-075711/`, warm23.56s and
cold9.98s. The first controlled run at raw10/10 was refused locally without a
-wear request. Its comparison with the server's10/9 admission remains a separate
-TODO for recovering requirement interpolation, not a claimed fix here.
+wear request. The [focused boundary check](leather-armor.md#strict-requirement-boundaries)
+confirms the server also requires Sense11/Agility10: the table's10/9 entries
+are strict thresholds, and the successful test adds one to each.
Original getter/resource evidence, source and bundle hashes, complete traces,
validation logs and a packet/state audit are retained in `local/effective-armor/`.
The focused armor checks pass2 roots/76 results in19.120s; maintained-package
diff --git a/docs/leather-armor.md b/docs/leather-armor.md
@@ -116,3 +116,39 @@ roots skipped in that run. The server package takes 2657.123s; game data takes
7.779s. `go vet ./server/...` passes. Full and focused race JSON logs remain in
`local/todo-progression-play/leather-go-full-verified.json` and
`local/todo-progression-play/leather-go-race-verified.json`.
+
+## Strict requirement boundaries
+
+For QL2 vest85481/85690, the interpolated action6 operands are Sense10 and
+Agility9 with operator2 (strictly larger). Minimum abilities are therefore
+Sense11/Agility10. The `sense`/`agility` fields in
+`TestLeatherArmorQualitiesWearRemoveAndRecover` store these operands; its
+successful fixture adds one. Reading those fields as minimum abilities caused
+the reported disagreement with a native10/10 refusal. No gameplay formula
+change is required.
+
+Independent original-resource reads recover7/7 at QL1 and510/460 at QL200.
+Original KKR `FUN_100effe0` interpolates criteria values through
+`FUN_100eff20`, which adds0.5 before truncating the interpolated difference.
+The resulting QL2 operands are10/9. Original evaluator `FUN_100056e0`
+requires the local effective stat to be strictly greater. The maintained
+server follows those same operations.
+
+`TestBrowserArmorRequirementBoundaries` checks four controlled ability pairs
+for each stored anchor, keeping selected QL2. Actual right-clicks reject
+10/10 on Sense and11/9 on Agility without sending a wear packet;11/10 and
+12/11 send requests and equip the exact vest. Native feedback explicitly
+requires Sense11 and Agility10. All eight instances retain their stored
+anchor, selected quality and expected carried/worn slot after cold loading.
+These are controlled contract checks, not earned progression.
+
+The eight native cases pass in62.22s under
+`local/armor-requirement-boundaries/20261104-080632/`, with no client errors
+or dropped events. The combined native/public-handler run passes2 roots/66
+results in79.777s, including the existing QL1..200 armor matrix. Original
+payloads/hashes, static evidence, screenshot review and independent packet/
+state checks are retained in that folder's parent.
+
+```sh
+AO_GAME_TEST=1 go test ./server -run '^(TestBrowserArmorRequirementBoundaries|TestLeatherArmorQualitiesWearRemoveAndRecover)$' -count=1 -timeout=5m -v
+```
diff --git a/server/browser_armor_requirements_test.go b/server/browser_armor_requirements_test.go
@@ -0,0 +1,107 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserArmorRequirementBoundaries(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for native armor requirement boundaries")
+ }
+
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/armor-requirement-boundaries", time.Now().Format("20060102-150405"))
+ world := newTestServer(t)
+ var cases []map[string]any
+ var worn []bool
+ for _, anchor := range []uint32{85481, 85690} {
+ for _, abilities := range [][2]uint16{{10, 10}, {11, 9}, {11, 10}, {12, 11}} {
+ player := world.newCharacter()
+ player.level = 2
+ player.stats.Abilities.Sense, player.stats.Abilities.Agility = abilities[0], abilities[1]
+ token := fmt.Sprint("armor-requirements-", player.id)
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte(token)))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if granted, err := world.grantItem_locked(player, anchor); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ inventory := player.inventory
+ inventory.Items = slices.Clone(inventory.Items)
+ inventory.Items[0].Quality = 2
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ eligible := abilities[0] > 10 && abilities[1] > 9
+ cases = append(cases, map[string]any{"id": player.id, "token": token, "anchor": anchor,
+ "sense": abilities[0], "agility": abilities[1], "eligible": eligible})
+ worn = append(worn, eligible)
+ }
+ }
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-cases", func(w http.ResponseWriter, r *http.Request) {
+ json.NewEncoder(w).Encode(cases)
+ })
+ mux.HandleFunc("GET /test-state/{id}", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ var id uint32
+ fmt.Sscan(r.PathValue("id"), &id)
+ json.NewEncoder(w).Encode(world.characters[id].inventory)
+ })
+ mux.HandleFunc("POST /test-complete/{id}", func(w http.ResponseWriter, r *http.Request) {
+ var id uint32
+ fmt.Sscan(r.PathValue("id"), &id)
+ world.mutex.Lock()
+ finish := world.clients[id].equipment.readyAt
+ world.mutex.Unlock()
+ world.advanceEquipment(finish)
+ })
+ 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_armor_requirements.mjs"), host.URL, output)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ t.Logf("Armor requirement artifacts: %s", output)
+
+ if err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t)
+ for index, eligible := range worn {
+ id, slot := uint32(index+1), uint32(64)
+ if eligible {
+ slot = 21
+ }
+ anchor := uint32(85481)
+ if index >= 4 {
+ anchor = 85690
+ }
+ expected := []ownedItem{{ID: id, Type: 51022, Template: anchor, Quality: 2, Slot: slot, Count: 1}}
+ if !slices.Equal(world.characters[id].inventory.Items, expected) || !slices.Equal(cold.characters[id].inventory.Items, expected) {
+ t.Fatal("native boundary check changed ownership or selected quality", id)
+ }
+ }
+ if world.nextItem != 8 || cold.nextItem != 8 {
+ t.Fatal("native boundary check changed item allocation")
+ }
+}
diff --git a/tools/client/test_armor_requirements.mjs b/tools/client/test_armor_requirements.mjs
@@ -0,0 +1,65 @@
+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 evidence = [];
+try {
+ const cases = await (await fetch(url + '/test-cases')).json();
+ for (const fixture of cases) {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ let game;
+ try {
+ await context.addCookies([{name: 'ao_client', value: fixture.token, url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ await page.goto(url);
+ await game.ready();
+ assert.equal(game.local().id, fixture.id);
+ assert.equal(game.local().stats[20], fixture.sense);
+ assert.equal(game.local().stats[17], fixture.agility);
+ const state = async () => (await page.request.get(url + '/test-state/' + fixture.id)).json();
+ const before = await state();
+ await game.key('i');
+ await page.keyboard.press('Control+1');
+ await game.click(953, 53);
+ await game.wait('exact carried vest available', snapshot => game.local(snapshot).inventory.some(item =>
+ item.id === fixture.id && item.slot === 48 && item.quality === 2));
+ const sequence = game.sequence;
+ const source = game.state.grids.flatMap(grid => grid.cells).find(cell =>
+ cell.identity[0] === 104 && cell.identity[1] === 48 && !cell.dummy);
+ assert(source);
+ await game.click((source.bounds[0] + source.bounds[2]) / 2, (source.bounds[1] + source.bounds[3]) / 2, 'right');
+ if (fixture.eligible) {
+ await game.wait('qualified native wear request', () => game.events.some(event => event.sequence > sequence &&
+ event.direction === 'framesent' && event.opcode === '47537a24'));
+ assert((await page.request.post(url + '/test-complete/' + fixture.id)).ok());
+ await game.wait('qualified exact vest worn', snapshot => game.local(snapshot).inventory.some(item =>
+ item.id === fixture.id && item.slot === 21));
+ assert.deepEqual(game.local().effectiveArmor, [9, 10, 2, 2, 9, 9, 2, 6]);
+ } else {
+ // Consumed mouse release and a later native frame establish local refusal.
+ assert(!game.events.some(event => event.sequence > sequence && event.direction === 'framesent' && event.opcode === '47537a24'));
+ assert.deepEqual(await state(), before);
+ assert.deepEqual(game.local().effectiveArmor, [0, 0, 0, 0, 0, 0, 0, 0]);
+ }
+ evidence.push({fixture, inventory: await state()});
+ assert.deepEqual(game.errors, []);
+ assert.equal(game.dropped, 0);
+ console.log('PASS: anchor' + fixture.anchor + ' Sense' + fixture.sense + '/Agility' + fixture.agility + ' eligible=' + fixture.eligible);
+ } finally {
+ try { if (game) await game.save(output + '/' + fixture.id); }
+ finally { await context.close(); }
+ }
+ }
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ } finally { await browser.close(); }
+}