Files
WoW-Hybrid-gateway/docs/NATIVE_SESSION_LIFECYCLE.md
praxisandClaude Fable 5.2 60b6d4b7a5 Design records
59 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

429 lines
26 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Native session ownership and engine transport
This document records historical native-session investigations and later
verified outcomes. The current status is: genuine Turtle SRP, native roster
display, character selection and world entry have been demonstrated in the
actual private Forever client with the external gateway stopped. Server-
authoritative movement and broader gameplay synchronization remain unfinished.
## Corrected backend lifetime
Previously `native/bootstrap.cpp::run` closed both backend handles after the
single roster-delivery experiment. It now owns the authenticated `gw_native_login`
and `gw_native_session` with RAII, retaining them on the original Linux worker for
a bounded handoff window. The account handle preserves genuine realm discovery
and SRP session material; the world handle owns its socket and cipher state.
Neither handle, socket nor session key is cast into a Windows engine object.
`native/engine_bridge.cpp::retain_session` observes only our imported PE host's
status and services the same authenticated socket. It stops on restoration or
failure of that host, a transport/integrity error, an undelivered non-control
packet, or expiry. Default retention is120 seconds; the private opt-in setting
`session_retention_seconds` accepts1–600. This is a diagnostic handoff window,
not a completed engine connection implementation or permanent keepalive service.
The real-client expiry path was verified. Follow-up WowB67193 also verified early
host-restoration cancellation during an active authenticated retention window:
the account/world handles were released at108ms, with a valid pong and error0.
`native/session.cpp::gw_native_ping` sends genuine CMSG_PING0x1dc, with sequence
and latency32-bit fields, including before character login. Only one ping may be
outstanding. `gw_native_service` validates matching SMSG_PONG0x1dd and keeps
other packets in the session's existing pending slot. Repeated service calls
cannot consume/overwrite that deferred packet. Unsupported integrity challenges
still fail closed. Actual pings are30 seconds apart: Tortoise's
`src/game/Protocol/WorldSocket.cpp::HandlePing` checks authentication, reads those
fields, returns the same sequence and counts intervals shorter than27 seconds.
Its `ProcessIncoming` handles ping at the socket layer; no selected character is
required. The server was not modified to accommodate these tests.
`LegacySession::receive_for` in `src/legacy_client.cpp` preserves fragmented
encrypted headers and partial bodies across bounded readiness waits. Each header
is decrypted exactly once. `receive` uses that same reader with its existing
10-second deadline. `gw_native_lifecycle_at` exposes backend facts and counters,
never keys or engine-authentication claims. No additional external listener,
proxy, database provider or codec subprocess was introduced.
## Engine lifecycle contracts established from saved code
All addresses require the unchanged70334 executable SHA256
`c49ce22c3e0aaeb7a7007a5c5cb792e4c3e6cdecc55a1145a5933fc113e3e57f`.
These are disassembly observations, **not authorization to call a function with
an inferred ABI**. `ops/native_lifecycle_audit.py` reproduces fixed instruction
and on-disk vtable checks from existing code captures. Private code remains in
`runtime/native-handler-code`; no executable bytes are committed.
| Queue event | Consumer action in0x141e53d80 | ClientConnection method |
|---|---|---|
|0x12|virtual+0x30, copied packet|0x141e47960|
|0x13|virtual+0x38, connected|0x1422bcb40|
|0x14|virtual+0x40, disconnected|0x1422bc740|
|0x15|virtual+0x48, connect failed|0x1422bd130|
|0x16|sets NetClient destruction byte+0xac|no method call|
The actual derived vtable is0x144efa998. Connected handler0x1422bcb40 invokes
base0x141e47b20, whose genuine transition expects connecting4 and writes connected5.
The derived handler also clears character caches and invokes registered listeners
at+0xc78/+0xc80. Disconnect and connect-failure base handlers0x141e47d10 and
0x141e47f20 restore initialized2. Enqueuing a made-up connected event would skip
the missing transport/account/realm ownership; this implementation does not do it.
The constructor trace at0x141e45211–0x141e4522b establishes a distinct16-byte
listener object: vtable0x144e5a748, owner pointer at+8, stored in NetClient+0x220.
The factory passes that listener into the TCP wrapper at wrapper+0x28. The
socket-facing embedded callback interface is **0x145039510 at wrapper+0x10**;
the earlier candidate0x145039518 was eight bytes into that table, not its start.
Treating the later purecall slots as the complete interface was misleading.
The listener vtable includes:
| Offset | Function | Established path |
|---|---|---|
|+8|0x141e43370|matches the real connection against four slots; slot0 enqueues0x13 at0x141e43834|
|+0x10|0x141e43ba0|failure/result path reaches0x141e476b0|
|+0x18|0x141e43870|disconnect path enqueues0x14 at0x141e43afc and handles pipe ownership|
|+0x20|0x141e43280|matches connection, takes NetClient lock and feeds its packet pipe|
TCP callback thunks at0x1434dc050 and following acquire the wrapper lock, retain
its reference, forward to that listener, unlock and release. The factory creates
a0x60-byte wrapper and0x440-byte bsSocket, with different destructor/reference
contracts. Consequently a POSIX descriptor or LegacySession pointer cannot be
substituted for either object. The full transport interface and lifetime must be
validated before implementing an adapter; only the paths above are established.
There is also a separate **world-authentication data provider** at global callback
slot0x147c64de0. Actual inspection identified function0x14216e1b0; saved code shows
it returns an owned string object at0x14574b1f0. Consumer0x14224deb0 copies its
pointer/length into a CDataStore using0x1445b8330. Saved writer code references that
string at0x14217551f. **The string contents were never read or changed.** This is
a concrete account/session dependency, not evidence that a Turtle session key
can be placed in a modern authentication string.
`ops/engine_session_inspect.py` now checks only the known derived subtype before
reading listener identity/owner equality, the+0x7e8 accepted-world-auth-response
boolean, the+0xc49 connected-callback marker and public event-handler addresses.
For the known TCP wrapper it can compare listener ownership and read only the
underlying socket's state enum, with a second ownership check. Unknown transports
are reported as unverified, and changing pointers or invalid enum values are
rejected. No socket handle, auth string, account name or session key is exported.
## Actual-client verification
WowB61164 performed genuine SRP/M2, realm discovery and world authentication,
received4 real characters and delivered the roster through the existing engine
queue host. The same in-process backend/account remained alive for120088ms and
received4/4 genuine encrypted heartbeat replies at30-second intervals. The frame
host continued15974 calls with error0. The engine had its legitimate listener,
whose owner matched NetClient, but all four transport slots were empty. Its
accepted-world-auth-response and connected-callback booleans remained false;
NetClient stayed2 and the real UI stayed at login. No character login was sent.
This run exposed a reporting bug: after the last acknowledged ping, the retention
deadline was mislabelled heartbeat timeout. The corrected predicate requires an
actually outstanding ping. Actual WowB62969 then verified a private four-second
window:1/1 valid pong,4032ms, `bounded-retention-expired`, error0. Its actual UI
also stayed login. This is successful backend lifetime/cleanup verification,
**not successful engine adoption**.
Both runs restored the original per-object vtable at the verified queue safepoint
and restored hardware debug registers. Clients closed through WM_DELETE_WINDOW.
The original installation, private WowB hash, loader, StartupFiles schema, original
Wine prefix and trust-key service were preserved. The private DXVK dependency was
restored byte-for-byte; its unused observer DLL remains inactive. No new fatal
report was observed. No character progression, position, equipment or permissions
were modified.
The temporary duration override was backed up to
`recovery/native-lifecycle-retention-config.json` and restored byte-for-byte.
`ops/native_pe_bridge.py restore` remains the private-prefix rollback command,
after normal client closure. Existing gateway fallback services were not started.
Tortoise authentication/world services were left running.
Evidence: `evidence/gameplay/native-session-lifecycle.json`; private screenshot
`runtime/native-session-lifetime.png`. The screenshot and independent UI-state
classification confirm login, not character selection.
## Tests and next integration boundary
Normal CTest22/22 passed in23.17s; ASan/UBSan22/22 passed in24.12s. Focused tests
also passed before activation. The new independent SRP fixture covers fragmented
header/body timeouts, two successive encrypted pongs, wrong/short pongs, integrity
failure, EOF, partial-header EOF and preservation of a deferred initialization
packet across character login and a required-size retry. Existing SRP negative
proof, roster, Windows ABI, vtable rollback, object/movement and talent tests pass.
The offline lifecycle audit verifies the saved instruction/vtable contracts.
The specific remaining boundary is **creating/adopting a Windows-owned realm
transport backed by the retained authenticated Turtle account/session**, including
the selected realm/address-vector lifetime and the modern account-data-provider
replacement. Genuine listener/queue callbacks then provide the transition to the
typed auth and roster handlers. The existing OpenRealmConnection0x141e46020
constructs a real transport and changes2→4, but its address-vector element
constructors, account/realm initialization and complete cancellation/reference
contract remain unvalidated. No guessed vector, foreign socket or fabricated
state5 is passed to it. Another roster packet alone cannot resolve this boundary.
## Follow-up: real roster consumption and readiness comparison
A labelled **gateway reference** run, WowB65840, authenticated normally and
displayed real Turtle characters in the actual Forever character-selection UI.
It did not send a character-login request. The new metadata matched the genuine
positive path: NetClient5; slot0 TCP socket state6; transport listener identity and
owner matched; accepted-world-auth-response and connected markers true. The
character-list-consumer marker was true and its pending slot was empty.
Saved code now establishes that `ClientConnection` character handler0x1422bee30
deep-copies the typed decoded packet into owned storage at+0xc90. Its normal poll
0x1422bd580 checks readiness callback+0xca8 and a separate processing gate before
passing that owned packet to0x142414e80. It clears the pending pointer, calls the
packet destructor and sets+0xca0. The consumer identifies its actual source as
`Mainline/Source/Glue/CharacterSelection.cpp`, logging “Character selection
updating character list”. This is an additional ownership stage beyond the raw
copied queue. No raw/typed packet pointers were substituted for one another.
The reference readiness callback was0x140225b00. Its code was captured through
the diagnostic parent's executable-only RPC after the genuine path ran, along
with the previously missing0x142415000 consumer continuation. A subsequent
request for another temporarily nonexecutable page was rejected by the existing
guard; no execution permission was changed or forced. Raw code remains private.
The predicate checks fixed boolean flags, two pointer-null conditions and a
phase-dependent helper0x1422bb300. The inspector reports only those conditions,
not the two pointed-to objects, and never calls the predicate or its side effects.
The accepted phase values0–2 and boolean ranges are bounded in diagnostics.
The global names below are deliberately not invented; their semantic owners
still need to be established from writers.
| Readiness condition | Reference character selection | Native ready login |
|---|---|---|
|0x145700079 clear|true|false|
|0x145ffa559 set|true|false|
|0x146004ea8 null|true|true|
|0x1457139c0 null|true|true|
|0x145e6e976 set|true|false|
|phase0x145ead210|1|0|
|0x145e720f8 set for phase1/2|true|false|
|poll gate0x1456ad44d clear|true|false|
Native WowB67193 then ran with every reference/gateway listener stopped. It
performed genuine SRP, world authentication and a valid heartbeat. Its native
character-list pending/consumer markers remained false. The readiness conditions
were false both during the authenticated handoff and after the actual UI was
independently verified to be a ready login screen. Thus these differences cannot
be attributed solely to sampling before the login UI initialized. The flags were
not changed to manufacture a transition. The original frame binding was restored
while the backend was active, verifying prompt retention cancellation. Actual UI
remained login. Evidence: `evidence/gameplay/native-character-consumption-boundary.json`.
Further static tracing locates a higher-level realm adoption candidate
**0x1422bbe90** (unwind range through0x1422bc235). It accepts the connection inRCX
and a parameter object inRDX, copies its first0x68 bytes into the connection,
copies realm properties from parameter+0x68, copies an address vector from+0x1b0,
and calls OpenRealmConnection at0x1422bc15f. A saved caller at0x142175f50 is in
the same modern realm-join path that populates the separate owned auth string.
The first0x68 bytes may contain account/session material: **no live parameter
buffer was read or dumped**. This identifies a more complete adoption boundary
than merely opening a socket. Parameter semantics/constructors and a correct
Turtle-compatible transport implementation remain unvalidated; the method was
not invoked with a guessed parameter structure.
The temporary reference gateway/bnet/world services and all disposable clients
were stopped normally; Tortoise remained running. Native flags/provider strings,
character progression and original client files were not modified. The focused
metadata tests and extended saved-code audit pass. The preceding22/22 normal and
22/22 ASan/UBSan results still cover the unchanged C++ implementation.
## Race/class eligibility vector follow-up
On the later gateway-stopped native roster run, the real Enter World click again
reached validator `0x140208810` (wrapper return `0x1423fb39c`) and displayed the
client's disabled-login modal. Captured executable code links the separate
eligibility vector to the roster consumer: at `0x142415208`, inside the
`0x142414e80` character-selection handler, the code invokes helper
`0x142403ee0`, reads a pointer/count pair from the handler object at `+0x70` and
`+0x78`, then replaces the global vector rooted at `0x147c67110`. The count is
also used to retire the prior vector. These are static instructions from an
actual in-process code capture, not guessed packet fields.
The natural-entry observer at `0x142415208` was armed after the roster had
already been consumed and timed out on the idle selection screen. Thus it has
not yet shown whether a fresh native roster reaches that copy block or what
valid server response populates the source pair. The code observer is bounded,
does not inspect registers or packet objects, and restores debug registers.
Next test: arm it before one fresh native SRP and character-list cycle, then
trace the authenticated, source-defined field only if that block is reached.
No global table contents were written or eligibility checks bypassed.
## Native roster and world-entry follow-up (2026-10-15)
The historical statements above describe earlier checkpoints. A later actual
Forever run reached character selection and world entry with the external gateway
stopped. The failed Enter World check was traced to an omitted `RaceUnlockData`
section in the native roster response. Forever's local server implementation
serializes this section after the character records; the client copies it into a
separate race/class eligibility vector used by its native login validator.
`src/roster_translation.cpp` now includes that section from the versioned Turtle
presentation profile. The actual native response passed the eligibility gate;
Forever sent its character login and rendered Gatewaytest in-world. Engine
counters recorded successful world auth, login send, server packet delivery and
self-create. Visual evidence is at
`evidence/gameplay/native-direct-world-entry-race-unlock.png`.
This proves native authentication, roster display, character selection and world
entry for the tested Human Warrior. It does not prove authoritative movement:
a W-key attempt produced client-side motion/facing while two outgoing packets
were counted as unsupported. The diagnostic now retains only the latest ignored
client opcode and body length in the existing public metadata word. The exited
client's runtime files are stale and must not be treated as a live process; a
fresh controlled run is required to collect that opcode and compare Tortoise
position before and after.
A controlled 0.3-second W-key attempt was subsequently checked against the
local `tw_char.characters` row for disposable GUID4509 before and after. Its
position/orientation remained `(-8914.03, -209.305, 82.9931) / 3.62709`, so
server-authoritative movement is still unsupported. The latest diagnostic
launch found a transient WowB PID after its owner had exited; later process
inspection showed no stable inspectable client, so no memory access or process
termination was attempted. The adapter fixture and full 42-test CTest suite
pass after the public opcode/length counter change.
## Fresh gateway-stopped direct run and movement dispatch result (2026-10-15)
After the power interruption, local Tortoise auth/world containers and the
local Forever authentication/world services were already listening. A fresh
disposable private-copy WowB process completed real Turtle SRP and server-proof
verification, established the Forever-owned world pipe, received the actual
four-character Turtle roster, and entered the world. The external gateway
port19085 remained stopped. The client displayed Gatewaytest in the Hall of
Arms. Public diagnostics recorded `world_auth=1`, `characters=4`,
`login_sent=1`, `self_create=1`, `received=1046`, `queued=17`,
`ignored=1036`, and adapter `error=0`.
The ignored inbound count is a remaining object-update gap: the adapter has not
yet translated most of the server's compressed movement/object stream. More
urgently, focused forward/backward keyboard trials caused no increment in the
bound engine packet-pipe write counter. Only periodic empty-body `0x4400CA`
time-offset requests appeared. The authoritative disposable character row
remained at `(-8914.03,-209.305,82.9931)`, orientation `3.62709`. The actual
client screenshot showed the rendered character but this does not establish
server-side movement.
The adapter's `0x5E0003` server active-mover opcode and `0x42005B` client
active-mover opcode are grounded in the local Forever protocol source
`servers/trinity-forever/src/server/game/Server/Protocol/Opcodes.h` and
`ClassicClientOpcodes.inc`; Turtle `src/game/Protocol/Opcodes_1_12_1.h` defines
the translated `CMSG_SET_ACTIVE_MOVER=0x26A`. The implementation validates the
selected translated GUID and rejects unsupported movement shapes. Despite
that correct source mapping and passing serializer tests, the actual client
did not dispatch movement to the installed packet pipe. The next investigation
must identify the engine input/control-to-network boundary or prove that the
queued active-mover packet is not being consumed. Do not report movement as
functional until Tortoise confirms a position change.
Private visual evidence is retained in
`evidence/gameplay/native-direct-world-entry-resume.png`; non-secret counters
and the before/after server position are in the matching JSON. Talent-interface
work stays in the deferred backlog until this native world synchronization
blocker is resolved.
### Active-mover A/B result (2026-10-15)
A gateway-stopped real-client session repeated verified Turtle SRP and entered
the local world. The direct path was tested once with the gateway-era active
mover opcode `0x600003`; it was submitted to the engine queue, but the client
still emitted no active-mover acknowledgement or movement request after bounded
W/S input. Pipe `write_calls` remained64 and the ignored outbound remained an
empty `0x44000A`; Tortoise position remained
`(-8914.03,-209.305,82.9931) / 3.62709`. The queue telemetry flag records
submission only, not engine consumption. The implementation therefore retains
the source-declared Forever `SMSG_MOVE_SET_ACTIVE_MOVER` opcode `0x5E0003`.
Evidence: `evidence/gameplay/native-active-mover-ab.json/png`. This narrows the
blocker to client object/control activation or a later engine dispatch boundary;
it does not prove that either active-mover packet was consumed.
### Verified receive-consumer observation (2026-10-15)
The actual WowB private copy was relaunched with the existing per-NetClient
receiver wrapper installed alongside the native frame callback. At the genuine
main-thread receive boundary, it observed and forwarded both the translated
`0x5E0000` self-create and `0x5E0003` active-mover packets. The wrapper retains
only two seen bits, the last opcode and counters; packet payloads are not copied.
The original receive method remains `0x141E47960` and executable. A focused W
input still produced no active-mover acknowledgment or movement request, and
Tortoise's saved coordinates were unchanged. This rules out simple failure to
dequeue those two packets, but not rejection by their original handlers or a
missing player-control activation elsewhere. Gateway stayed stopped; genuine SRP
proof was verified; the actual client rendered the in-world character. See
`evidence/gameplay/native-packet-consumer-observed.json/png`.
### Local movement simulation is active; network dispatch is not (2026-10-15)
A read-only ticker sampled `IsPlayerMoving()` while the real W key was held. It
reported true during the hold and false after release. `UnitGUID("player")` was
`Player-70-0000119D`, matching authenticated Tortoise GUID4509, and
`UnitIsPlayer("player")` was true. During six samples while W was held, native
pipe write calls stayed64, unsupported outbound count stayed55, and neither the
active-mover nor movement-request marker changed. The authoritative Tortoise
position stayed `(-8914.03,-209.305,82.9931) / 3.62709`. Thus the client creates
a controllable local player and simulates motion, but does not generate/dispatch
movement to its network send boundary. The next investigation should follow the
client's local movement update into its movement-packet send gate, looking for a
missing session/authority condition or client-side send policy. Do not alter
server position to mask this. Evidence: `evidence/gameplay/native-client-local-movement-no-network.json/png`.
### Initial active-mover packet removed; movement still blocked (2026-10-15)
Source comparison showed that the login-time `0x5E0003` sent by the native
translation was not part of the reference server's initial self-create flow.
`servers/trinity-forever/src/server/game/Maps/Map.cpp::SendInitSelf` documents
that the ThisIsYou update should prompt
`CMSG_MOVE_INIT_ACTIVE_MOVER_COMPLETE`; `Unit.cpp::SetMovedUnit` sends
`SMSG_MOVE_SET_ACTIVE_MOVER` for a subsequent control handoff. Accordingly,
`native/world_translation.cpp` now emits only the self-create at login.
A fresh gateway-stopped WowB test repeated real proof-verified local SRP,
displayed all four Tortoise characters, and entered the world with the self
character visible. The native pipe queued 16 packets rather than the prior 17,
with `self_create=1`, `active_mover_queued=false`, and no adapter error. Focused
W/S input produced no observed `0x420064`, active-mover request, or movement
request at the actual engine pipe writer. That writer remained at65 calls during
the held input. The database row for disposable GUID4509 was unchanged at
`(-8914.03, -209.305, 82.9931, 3.62709)` before and after; this is persisted
database evidence, not a live world-memory read. The earlier Lua sample still
shows local input simulation, so the blocker remains the local-movement-to-send
gate or authority state. No movement success is claimed. Evidence:
`evidence/gameplay/native-self-create-without-login-mover.json/png`.
The default sandbox run of all CTest tests had policy failures for socket and
ptrace fixtures, and one Windows ABI fixture failed under that restricted run.
Rerunning the same complete suite in the authorized local context passed42/42
in 28.80s. Diagnosis and subsystem coverage are maintained in
`NATIVE_PROTOCOL_MATRIX.md`.
### Turtle movement ownership gate corrected (2026-10-15)
Tortoise `src/game/Handlers/MovementHandler.cpp::HandleMovementOpcodes` gets
the confirmed mover from the authenticated player's session; its separate
`HandleSetActiveMoverOpcode` handles control handoffs. The native adapter had
incorrectly required that handoff before forwarding any movement. It now
requires a processed self-create and checks that the parsed movement GUID is
the selected authenticated Turtle character. `native-movement-ownership-gate`
tests reject movement before self-create and reject a foreign GUID.
The rebuilt code was loaded in actual WowB.exe: genuine local authentication,
four-character display, and world entry passed again with no adapter error.
During a new 1.5-second focused W hold, native pipe `write_calls` stayed62 and
`unsupported_out` stayed53; `movement_request`, `movement_accepted`, and
`CMSG_MOVE_INIT_ACTIVE_MOVER_COMPLETE` remained false. So the adapter-side gate
is corrected, but the engine still fails to generate a movement packet. Evidence
and the in-world screenshot are in
`evidence/gameplay/native-self-create-without-login-mover.json/png`.
After adding the focused movement ownership test, the full local CTest suite
passed 43/43 in 28.45s. The real-client run confirms no regression to
authentication, roster, or world entry; authoritative movement is still not
verified.