aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


docs/pet-dismissal.md (5847B)


Owned pet dismissal

Original /pet terminate now retires the authenticated owner's pet. The command releases the summon limit without charging nano and preserves another owner's entity. Its retirement shares the same committed path as timed expiry.

Original request and scope

Real keyboard input captures PetCommand 6b333303, owner envelope50000:id, with body words 10, 0, 1009, 0, 0. The empty encoded selector addresses the owner's set; no explicit pet identity is supplied. The capture is retained in local/pet-owner-protocol/20261103-224256/,15.69 seconds. The shipped cd_image/text/help/Pet Commands.txt describes /pet terminate as the pet killing itself. In the raw fixture the request does not delete the actor locally.

Only the current ready, living owner can issue this admitted command. Foreign actors, stale clients, loading owners, arguments and named/explicit selectors are refused. The server selects its ownership map. An owned entity can be retired even if it is dead, expired or in another playfield; its owner still receives the limit correction. Original combat death and termination animation/corpse presentation remain part of the open pet-death work.

Durable retirement

A SQLite transaction deletes the character and cascades its NPC/ownership rows. Required deletion uses RETURNING and completes its commit before in-memory ownership, the world entry, saved NPC cache and active expiry list are removed. Failed or ignored writes preserve the complete entity and permit retry.

Committed retirement also uses the shared encounter-cancellation path before removing the world entry. It clears the pet's outgoing target, swing deadline and scheduler entry, removes encounter threat against it, and stops opponents still targeting it. StopFight reaches interested clients before typed Destroy. Deletion failures leave these transient encounters untouched for retry; no stop is published before the ownership transaction commits.

After commit, original RemovePet updates native membership, stat251 publishes the remaining packed limit, and a typed Destroy removes the interested actor. Ready observers whose snapshots are still loading receive the queued removal. The owner receives membership/limit updates after leaving the pet's playfield. Duplicate requests with an empty owned set publish no further retirement. The allocator remains monotonic and the retired entity cannot keep following.

Timed expiry uses this same path. Its indexed active-list traversal retains failed retirements and advances to other entries without database writes before their deadlines. This does not establish the original TimeExist units or disconnect lifecycle; those TODOs remain open.

Focused verification

The Go baseline leaves the pet owned and moving after the original command. Public-handler regressions cover one durable retirement, duplicate requests, foreign actor/ownership and unsupported selectors, ignored deletion, cascade failure, deferred commit failure, cold retention/retry, loading observers, another-playfield ownership, simultaneous expiry/dismissal and old deadlines after replacement. Routine movement after retirement cannot rewrite the entity.

TestBrowserPetDismiss uses two controlled owners, each with one completed ordinary summon. It is not earned progression. Real chat starts follow, real movement covers three metres, then /pet terminate removes only the first pet. Both native clients receive one RemovePet and one typed Destroy. The peer's pose and cost remain unchanged. A real Programs cast creates replacement1000003 with owner15nano/peer25nano and allocator1000004. Both page reloads and a fresh server preserve the replacement and peer, with the retired identity absent.

The passing capture is local/pet-dismiss/20261103-225205/: live24.10 seconds, cold15.05 seconds. No client C/WASM change was required.

The related Go run passes66 roots/204 results. The focused race run passes18 results, including concurrent expiry/dismissal and the replacement deadline. All six native traces have no client errors or dropped events. Vet, driver syntax and the packet/ownership checks retained in local/pet-dismiss/validation.json pass.

Combat during retirement

A controlled held-swing fixture reproduces a second defect: native terminate removes the actor and ownership row while its target/deadline and scheduler entry remain live. The baseline two-client check fails in 17.21 seconds with scheduled=true, target 1 and the original deadline after dismissal. This does not establish a PT50 weapon binding or historical attack/expiry timing.

TestPetRetirementCancelsCombatOnlyAfterCommit covers dismissal and timed expiry, mutual queued combat, ignored deletion, cascade failure and deferred COMMIT failure. Failed attempts preserve database contents, both encounters, deadlines and output. Successful retry cancels immediately; advancing beyond both old deadlines produces no weapon result or resource change. Cold loading retains no retired ownership.

The extended TestBrowserPetDismiss starts a held production-scheduler swing before real /pet terminate. Both native streams must receive StopFight before Destroy. A real Programs cast creates a new pet; advancing the old deadline leaves it, the peer, owner resources and ownership unchanged. Both page reloads and separate fresh-server clients retain the replacement. The setup uses controlled owners and a held attack, not earned progression or an inferred original pet combat profile. Evidence and independent checks are retained in local/pet-retirement-combat/. The live/cold browser phases pass in 24.94/15.47 seconds. The broader pet/threat suite passes 24 roots/83 results both normally and under race detection; vet and driver syntax pass. Eight complete native captures have no errors or drops.