commit 491782f827dc7c0ed4cf946b8614f3353deff992
parent 31f04acc6b4f094d531c431cf1518572daede855
Author: anon <anon@example.com>
Date: Wed, 4 Nov 2026 14:47:44 +0000
Use portable surgery clinics from carried backpacks
Diffstat:
7 files changed, 411 insertions(+), 9 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -718,6 +718,12 @@ unverified mass/deletion/reclaim policies are in [backpacks](docs/backpacks.md).
and utility effects. Native Dust Collector tiers, live skill recovery,
rejected re-equipping and QL100 Metaplast boundaries are verified in
[armor overequipping](docs/armor-overequipping.md).
+- [x] [P1] Use the portable surgery clinic from a carried backpack. A real
+ page107 right-click previously returned failure2 despite an eligible selected
+ owner. Its ordinary self-use contract now preserves the packed source and
+ grants surgery access/Treatment lock atomically. Native implant wear,
+ source/companion conservation, replay/lock refusal, transaction rollback/retry
+ and page/cold recovery pass; see [portable clinics](docs/implants.md).
- [ ] [P3] Recover original maximum-HP clamp timing when armor effectiveness falls.
Check: original server/capture evidence distinguishes transient native modifier
replacement from final resource loss and fixes the ordering of HP publication.
diff --git a/docs/implants.md b/docs/implants.md
@@ -235,8 +235,8 @@ applies trickle once.
## Surgery permission and cooldown
Portable Surgery Clinic 43552, exact QL 1, type 51005, is supported for self-use
-from ordinary inventory. Select yourself before using it. Other selected
-targets are rejected; friendly portable-clinic use remains future work.
+from ordinary inventory or a carried backpack. Select yourself before using it.
+Other selected targets are rejected; friendly portable-clinic use remains future work.
The 155 original stationary clinics now supply their separate paid, five-minute
Treatment/access effect; see [stationary clinics](stationary-clinics.md).
The portable item comes from `server/gamedata/items/items_002.yaml` and
@@ -270,6 +270,25 @@ remains 30 seconds. Historical handling of portable permission
across zoning, death and server downtime remains unverified; retaining these
absolute deadlines is the current persistence policy.
+`TestBackpackClinicPreservesSourcesAndSharesPermission` covers first/last child
+slots, open/closed known bags, exact effect sources, replay/lock refusal and
+cold recovery without any item-store change. Companion checks reject unavailable
+sources/targets and verify failed/ignored writes and failed commit roll back both
+deadlines, with a complete retry. The native fixture uses a controlled level2
+character with cap-checked Treatment10/Strength8, a carried clinic, one implant
+and an unrelated bag item. It right-clicks the clinic after real F1 selection,
+installs the chest implant, advances that admitted move to its existing deadline,
+then reloads. The clinic, bag, companion, implant and both absolute deadlines
+survive page/cold recovery; the installed implant retains its +8 melee AC on the
+server. This is controlled permission/ownership evidence, not earned progression.
+Baseline and fixed captures are under `local/backpack-clinic/`.
+The accepted run `20261104-064356` completes in17.96s. Independent checks retain
+the exact page107 request, successful effect/lock, native implant move and all
+four owned identities. Focused Go checks pass11 roots/43 results; related race
+checks pass15 roots/52 results in104.218s. Maintained-package vet and JavaScript
+syntax checks pass. That folder's `verification.json` records source hashes and
+the three clean, complete native traces.
+
## Native messages
The ordinary item remains a template proxy. GenericCmd `52526858` success only
@@ -277,11 +296,16 @@ updates a proxy's inventory state; it does not execute the resource's Use effect
The server therefore follows the acknowledgement with TemplateAction `35505644`:
```text
-43552,43552,1,1,3,104,nativeSlot,50000,ownerID
+43552,43552,1,1,3,sourcePage,sourceSlot,50000,ownerID
```
The auxiliary identity selects the effect recipient. It is required for the
-clinic's target-3 effects. Ordinary placement slots are translated between saved
+clinic's target-3 effects. A contained source keeps page107 and the packed
+session handle/inner slot in both the acknowledgement and TemplateAction;
+the physical bag ID is not that handle. Known contents remain usable after
+their carried bag closes. Banked, foreign and unknown bags remain ineligible.
+The reusable clinic and all companion items stay owned in their original slots.
+Ordinary placement slots are translated between saved
64..93 and native 48..77, including this message. CharacterAction `5e477770`
with body `{170,0,0,124,rawSeconds}` starts the native Treatment lock;
`{164,0,0,0,124}` clears it. LockSkill's authored function reaches an original
diff --git a/server/backpack_clinic_test.go b/server/backpack_clinic_test.go
@@ -0,0 +1,196 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "reflect"
+ "slices"
+ "testing"
+ "time"
+)
+
+func newBackpackClinicWorld(t *testing.T) (*server, *combatTestConn) {
+ t.Helper()
+ world, output := newImplantWorld(t)
+ if granted, err := world.grantItem_locked(world.characters[1], 99228); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ client := world.clients[1]
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 69, 1)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleInventory(client, backpackMoveRequest(104, 67, 51017, 6, 111)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ output.packets = nil
+ return world, output
+}
+
+func TestBackpackClinicPreservesSourcesAndSharesPermission(t *testing.T) {
+ for _, slot := range []uint32{0, 20} {
+ for _, closed := range []bool{false, true} {
+ t.Run(fmt.Sprintf("slot%d/closed%v", slot, closed), func(t *testing.T) {
+ world, output := newBackpackClinicWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.inventory.Containers[6][0].Slot = slot
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ if closed {
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 69, 2)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ source := 65536 | slot
+ request := backpackUseRequest(1, source, 10)[20:]
+ binary.BigEndian.PutUint32(request[40:44], 107)
+ output.packets = nil
+
+ err = world.handleOwnedItemUse(client, request)
+ window, lock := player.implantChangesUntil, player.skillLocks[124]
+ if err == nil {
+ err = world.handleOwnedItemUse(client, request)
+ }
+ binary.BigEndian.PutUint32(request[20:24], 11)
+ if err == nil {
+ err = world.handleOwnedItemUse(client, request)
+ }
+ after, readErr := readTestItemStore(world)
+ cold := newTestInventoryServer(t).characters[1]
+
+ if err != nil || readErr != nil || !bytes.Equal(before, after) || window.IsZero() || lock.Sub(window) != 570*time.Second ||
+ !player.implantChangesUntil.Equal(window) || !player.skillLocks[124].Equal(lock) ||
+ !cold.implantChangesUntil.Equal(window) || !cold.skillLocks[124].Equal(lock) ||
+ !reflect.DeepEqual(player.inventory, cold.inventory) || world.nextItem != 6 ||
+ client.backpacks[1] != (backpackHandle{6, !closed}) || len(output.packets) != 4 {
+ t.Fatal("contained clinic changed ownership, lost permission, extended a lock or changed its handle", err, readErr)
+ }
+ if binary.BigEndian.Uint32(output.packets[0][29:33]) != 1 ||
+ !bytes.Equal(output.packets[2], targetPacket(skillLockPacket(1, 124, 600))) ||
+ binary.BigEndian.Uint32(output.packets[3][29:33]) != 2 {
+ t.Fatal("contained clinic omitted success/lock or admitted its locked retry")
+ }
+ var action []byte
+ for _, value := range []uint32{43552, 43552, 1, 1, 3, 107, source, 50000, 1} {
+ action = binary.BigEndian.AppendUint32(action, value)
+ }
+ if !bytes.Equal(output.packets[1], targetPacket(n3Packet(0x35505644, 50000, 1, action))) {
+ t.Fatal("contained clinic effect lost its actual source or selected owner")
+ }
+ })
+ }
+ }
+}
+
+func TestBackpackClinicRejectsUnavailableSourcesAndTargets(t *testing.T) {
+ for _, scenario := range []string{"unknown handle", "banked bag", "foreign owner", "no target", "other target", "treatment equality", "wrong type", "wrong quality", "pending equipment"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, output := newBackpackClinicWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ request := backpackUseRequest(1, 65536, 10)[20:]
+ binary.BigEndian.PutUint32(request[40:44], 107)
+ switch scenario {
+ case "unknown handle":
+ binary.BigEndian.PutUint32(request[44:48], 131072)
+ case "banked bag":
+ inventory := player.inventory
+ bag := inventory.Items[len(inventory.Items)-1]
+ bag.Slot = 0
+ inventory.Items, inventory.Bank = slices.Clone(inventory.Items[:len(inventory.Items)-1]), []ownedItem{bag}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ case "foreign owner":
+ binary.BigEndian.PutUint32(request[8:12], 2)
+ case "no target":
+ client.selectedTarget = [2]uint32{}
+ case "other target":
+ client.selectedTarget = [2]uint32{50000, 2}
+ case "treatment equality":
+ player.stats.NanoAiding.Treatment = 3
+ case "wrong type":
+ player.inventory.Containers[6][0].Type = 51022
+ case "wrong quality":
+ player.inventory.Containers[6][0].Quality = 200
+ case "pending equipment":
+ if err := world.handleInventory(client, inventoryMovePacket(1, 64, 6)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("fixture equipment did not start", err)
+ }
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ output.packets = nil
+
+ err = world.handleOwnedItemUse(client, request)
+ after, readErr := readTestItemStore(world)
+
+ if err != nil || readErr != nil || !bytes.Equal(before, after) || !player.implantChangesUntil.IsZero() || len(player.skillLocks) != 0 {
+ t.Fatal("refused contained clinic use changed permission, lock or items", err, readErr)
+ }
+ for _, packet := range output.packets {
+ if binary.BigEndian.Uint32(packet[16:20]) != 0x52526858 || binary.BigEndian.Uint32(packet[29:33]) != 2 {
+ t.Fatal("refused contained clinic use emitted success or an effect")
+ }
+ }
+ })
+ }
+}
+
+func TestBackpackClinicFailedTransactionRetriesAtomically(t *testing.T) {
+ for _, phase := range []string{"window", "ignored window", "lock", "ignored lock", "commit"} {
+ t.Run(phase, func(t *testing.T) {
+ world, output := newBackpackClinicWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ statement := "CREATE TRIGGER reject_clinic BEFORE UPDATE OF implant_changes_until ON characters BEGIN SELECT RAISE(FAIL, 'window'); END"
+ switch phase {
+ case "ignored window":
+ statement = "CREATE TRIGGER reject_clinic BEFORE UPDATE OF implant_changes_until ON characters BEGIN SELECT RAISE(IGNORE); END"
+ case "lock":
+ statement = "CREATE TRIGGER reject_clinic BEFORE INSERT ON skill_locks BEGIN SELECT RAISE(FAIL, 'lock'); END"
+ case "ignored lock":
+ statement = "CREATE TRIGGER reject_clinic BEFORE INSERT ON skill_locks BEGIN SELECT RAISE(IGNORE); END"
+ case "commit":
+ statement = "CREATE TABLE pending_clinic (player_id INTEGER REFERENCES players(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER reject_clinic AFTER INSERT ON skill_locks BEGIN INSERT INTO pending_clinic VALUES (999999); END"
+ }
+ if _, err := world.db.Exec(statement); err != nil {
+ t.Fatal(err)
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ request := backpackUseRequest(1, 65536, 10)[20:]
+ binary.BigEndian.PutUint32(request[40:44], 107)
+
+ failed := world.handleOwnedItemUse(client, request)
+ after, readErr := readTestItemStore(world)
+ rolledBack := newTestInventoryServer(t).characters[1]
+
+ if failed == nil || readErr != nil || !bytes.Equal(before, after) || len(output.packets) != 0 ||
+ !player.implantChangesUntil.IsZero() || len(player.skillLocks) != 0 ||
+ !rolledBack.implantChangesUntil.IsZero() || len(rolledBack.skillLocks) != 0 || world.nextItem != 6 {
+ t.Fatal("failed contained clinic published only part of its transaction", failed, readErr)
+ }
+ if _, err := world.db.Exec("DROP TRIGGER reject_clinic"); err != nil {
+ t.Fatal(err)
+ }
+ binary.BigEndian.PutUint32(request[20:24], 11)
+ if err := world.handleOwnedItemUse(client, request); err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t).characters[1]
+ if player.implantChangesUntil.IsZero() || player.skillLocks[124].IsZero() ||
+ !cold.implantChangesUntil.Equal(player.implantChangesUntil) || !cold.skillLocks[124].Equal(player.skillLocks[124]) ||
+ !reflect.DeepEqual(player.inventory, cold.inventory) || len(output.packets) != 3 || world.nextItem != 6 {
+ t.Fatal("contained clinic retry lost an item, permission or lock")
+ }
+ })
+ }
+}
diff --git a/server/backpacks.go b/server/backpacks.go
@@ -89,6 +89,9 @@ func (server *server) handleOwnedItemUse(client *worldClient, body []byte) error
}
for index, item := range player.inventory.Containers[bag] {
if item.Slot == slot&65535 {
+ if item.Template == 43552 {
+ return server.useClinic_locked(client, index, body)
+ }
if stat, supported := item.tokenUpload(); supported {
return server.uploadToken_locked(client, index, body, stat)
}
diff --git a/server/browser_backpack_clinic_test.go b/server/browser_backpack_clinic_test.go
@@ -0,0 +1,88 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserBackpackClinic(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for carried-backpack surgery clinic use")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/backpack-clinic", time.Now().Format("20060102-150405"))
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.level = 2
+ player.stats.NanoAiding.Treatment, player.stats.Abilities.Strength = 10, 8
+ if player.trainingMaximum(124) < 10 || player.trainingMaximum(16) < 8 {
+ t.Fatal("clinic fixture exceeds native training caps")
+ }
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("backpack-clinic")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ inventory := playerInventory{LastID: 4, Items: []ownedItem{
+ {ID: 1, Type: 51017, Template: 99228, Quality: 1, Slot: 64, Count: 1},
+ {ID: 3, Type: 51022, Template: 101173, Quality: 1, Slot: 65, Count: 1}},
+ Containers: map[uint32][]ownedItem{1: {
+ {ID: 2, Type: 51005, Template: 43552, Quality: 1, Slot: 0, Count: 1},
+ {ID: 4, Type: 51005, Template: 42640, Quality: 1, Slot: 1, Count: 1}}}}
+ if err := world.saveInventory_locked(player, inventory); 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()
+ json.NewEncoder(w).Encode(map[string]any{"inventory": player.inventory,
+ "window": player.implantChangesUntil, "lock": player.skillLocks[124]})
+ })
+ // Complete the admitted native wear at its existing deadline.
+ mux.HandleFunc("POST /test-complete-implant", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ pending := world.clients[1].equipment
+ world.mutex.Unlock()
+ if pending == nil {
+ http.Error(w, "implant wear was not admitted", http.StatusConflict)
+ return
+ }
+ world.advanceEquipment(pending.readyAt)
+ })
+ 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_backpack_clinic.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)
+ }
+ cold := newTestInventoryServer(t).characters[1]
+ expected := []ownedItem{inventory.Items[0], {ID: 3, Type: 51022, Template: 101173, Quality: 1, Slot: 37, Count: 1}}
+ if !slices.Equal(player.inventory.Items, expected) || !slices.Equal(cold.inventory.Items, expected) ||
+ !reflect.DeepEqual(player.inventory.Containers, inventory.Containers) || !reflect.DeepEqual(cold.inventory.Containers, inventory.Containers) ||
+ !cold.implantChangesUntil.Equal(player.implantChangesUntil) || !cold.skillLocks[124].Equal(player.skillLocks[124]) ||
+ player.inventory.equipmentBonus(91) != 8 || cold.inventory.equipmentBonus(91) != 8 || world.nextItem != 4 {
+ t.Fatal("contained clinic use lost a source, implant, permission or Treatment lock")
+ }
+}
diff --git a/server/implants.go b/server/implants.go
@@ -25,11 +25,16 @@ func (server *server) useClinic_locked(client *worldClient, index int, body []by
player := server.characters[client.id]
// Portable clinic self-use requires selecting the owner.
- slot := binary.BigEndian.Uint32(body[44:48])
+ page, slot := binary.BigEndian.Uint32(body[40:44]), binary.BigEndian.Uint32(body[44:48])
+ items := player.inventory.Items
+ if page == 107 {
+ items = player.inventory.Containers[client.backpacks[slot>>16].id]
+ }
+ item := items[index]
stats := player.baseStats()
now := time.Now()
- accepted := client.selectedTarget == [2]uint32{50000, client.id} && slot >= 64 && slot < 94 &&
- player.inventory.Items[index].Type == 51005 && player.inventory.Items[index].Template == 43552 && player.inventory.Items[index].Quality == 1 &&
+ accepted := client.selectedTarget == [2]uint32{50000, client.id} && (page == 107 || page == 104 && slot >= 64 && slot < 94) &&
+ item.Type == 51005 && item.Template == 43552 && item.Quality == 1 &&
player.effectiveSkill(124, stats.NanoAiding.Treatment, [6]uint32{0, 30, 0, 50, 20, 0}) > 5 && !now.Before(player.skillLocks[124])
if accepted {
// Save the cooldown and access window before acknowledging any authored effects.
@@ -69,9 +74,8 @@ func (server *server) useClinic_locked(client *worldClient, index int, body []by
}
// Template proxies need an explicit Use action; their acknowledgement only updates counts.
- item := player.inventory.Items[index]
var action []byte
- for _, value := range []uint32{item.Template, item.Template, item.Quality, 1, 3, 104, slot, 50000, client.id} {
+ for _, value := range []uint32{item.Template, item.Template, item.Quality, 1, 3, page, slot, 50000, client.id} {
action = binary.BigEndian.AppendUint32(action, value)
}
if err := client.send(n3Packet(0x35505644, 50000, client.id, action)); err != nil {
diff --git a/tools/client/test_backpack_clinic.mjs b/tools/client/test_backpack_clinic.mjs
@@ -0,0 +1,81 @@
+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: 'backpack-clinic', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ const cell = (page, slot) => game.state.grids.flatMap(grid => grid.cells).find(cell =>
+ cell.identity[0] === page && cell.identity[1] === slot && !cell.dummy);
+ const click = async source => {
+ assert(source, 'the exact owned source must be usable');
+ await game.click((source.bounds[0] + source.bounds[2]) / 2, (source.bounds[1] + source.bounds[3]) / 2, 'right');
+ };
+ await page.goto(url);
+ await game.ready();
+ await game.key('KeyI');
+ await click(cell(104, 48));
+ await game.wait('clinic and companion visible inside bag', () => cell(107, 65536) && cell(107, 65537));
+ await game.key('F1');
+ await game.wait('self selected', state => state.selected[0] === 50000 && state.selected[1] === state.localId);
+ evidence.before = await server();
+
+ // The real contained Use must execute its effects against the selected owner.
+ const sequence = game.sequence;
+ await click(cell(107, 65536));
+ await game.wait('actual contained clinic Use and completion', () => game.events.some(event => event.sequence > sequence &&
+ event.direction === 'framesent' && event.opcode === '52526858' && Buffer.from(event.hex, 'hex').readUInt32BE(53) === 107) &&
+ game.events.some(event => event.sequence > sequence && event.direction === 'framereceived' && event.opcode === '52526858'));
+ evidence.used = await server();
+ await game.save(output + '/use-result');
+ const completion = game.events.find(event => event.sequence > sequence && event.direction === 'framereceived' && event.opcode === '52526858');
+ assert.equal(Buffer.from(completion.hex, 'hex').readUInt32BE(29), 1);
+ await game.wait('native surgery access and lock installed', () => (game.local().stats[224] & 16) !== 0 &&
+ game.events.some(event => event.sequence > sequence && event.direction === 'framereceived' && event.opcode === '35505644'));
+ assert.deepEqual(evidence.used.inventory, evidence.before.inventory);
+ assert(Date.parse(evidence.used.window) > Date.parse(evidence.before.window));
+ assert.equal(Date.parse(evidence.used.lock) - Date.parse(evidence.used.window), 570000);
+ assert(cell(107, 65536) && cell(107, 65537));
+
+ // Original implant gates must now admit the carried chest through real input.
+ await page.keyboard.press('Control+1');
+ await game.wait('Wear panel open', state => state.regions.some(bounds =>
+ bounds[0] === 832 && bounds[1] === 0 && bounds[2] === 1024 && bounds[3] === 360));
+ await game.click(993, 53);
+ const wear = game.sequence;
+ await click(cell(104, 49));
+ await game.wait('actual implant wear request', () => game.events.some(event => event.sequence > wear &&
+ event.direction === 'framesent' && event.opcode === '47537a24'));
+ assert((await page.request.post(url + '/test-complete-implant')).ok());
+ await game.wait('clinic-qualified implant worn', state => game.local(state).inventory.some(item => item.id === 3 && item.slot === 37));
+ evidence.worn = await server();
+ assert.deepEqual(evidence.worn.inventory.Containers, evidence.before.inventory.Containers);
+ assert.equal(evidence.worn.inventory.Items.find(item => item.ID === 3).Slot, 37);
+ await game.save(output + '/worn');
+
+ await page.reload();
+ await game.ready();
+ evidence.replayed = await server();
+ assert.deepEqual(evidence.replayed, evidence.worn);
+ assert((game.local().stats[224] & 16) !== 0);
+ assert.deepEqual(game.local().inventory.map(item => [item.id, item.slot]).sort((a, b) => a[0] - b[0]), [[1, 48], [3, 37]]);
+ assert.deepEqual(game.errors, []);
+ console.log('PASS: contained portable clinic grants surgery access without consuming any owned item; native wear and page/cold recovery retain all four identities');
+} 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(); }
+}