Files
Ananta-ps/docs/GO_MIGRATION_AUDIT.md

86 lines
6.4 KiB
Markdown

# Go migration audit — 2026-10-29
Compared Gemini's Go branch (`e43a310`) with the last pre-migration C# revision
`ca2e80f`, the shipped `MethodIds.json`, and the original wire contracts.
Compilation does not establish feature parity. This port is **incomplete**.
## Fixed in this review
- Corrected 65 active method IDs against the C# reference, including world entry,
character switching, teleport, vehicle, dialog and wardrobe methods. Removed
23 fabricated constants/routes rather than assigning unrelated retail messages
to invented handlers. `GateLogin` is an alias for the verified `Login` method.
- Restored 4,544 verified method names and 2,356 return contracts from C# metadata.
Unknown invokes now use the exact neutral payload required by their return
reader. A truly unknown invoke returns an error. Neutral replies do not implement
gameplay or persistence.
- Unknown notification names resolve to zero and are rejected before writing.
Guessed fallback IDs can no longer invoke an unrelated client handler.
- Corrected `EnterSceneInfo` loading/link type markers, integer widths and list
counts, ground-data byte fields, and nullable teleport tail fields.
- Player login data now patches account and Unicode display name as well as
aid/pid, parsing offsets and rebuilding variable-length strings. Remaining
template bytes are preserved. This is still a template, not a replacement for
the original dynamic `RuntimePayloadFactory`.
- Restored configured `SyncRoleList` behavior and the default empty-list format;
the legacy bare-pid shape is available only when explicitly configured.
- Returns are emitted only for invokes, including valid invoke ID zero.
Return/unknown packets and non-RPC frame modes are not dispatched as requests.
- Movement now handles the actual list contracts for `AskReportLogicAgentSyncData`
and `AskUnitMoveActionSimple`, validating the entire body before changing state.
- Hangup/resume gates background traffic; traffic waits for scene readiness.
Character switching sets current-spirit identity before creating the new entity.
- Heartbeats share the encrypted write lock with RPC output. Failed writes close
the stream because its cipher state has advanced. Writes have deadlines; short
writes are completed. Oversized/unterminated varints return errors.
- Login/game shutdown closes tracked sockets, including clients stalled in
handshake, and waits for connection handlers. Traffic starts only after binding
succeeds and stops with its worker joined.
- Gateway startup reports TLS/bind failures synchronously and rolls back partially
opened listeners. Admin/debug binding errors are returned to the caller. Admin
binding respects `admin.host` instead of using the public network bind host.
- Admin coordinate parsing rejects invalid/non-finite input and propagates
teleport failures. Time/weather commands use the verified client IDs and wire
fields instead of nonexistent `SyncTimeWeather`/`SyncTimeOfDay` messages.
- The item catalog reads `ItemCatalog.json` or the shipped `ConsumableConfig.json`,
projects typed entries, implements lookup, and caches by source path rather than
sharing the first directory's table with every caller.
## Remaining migration gaps
The reproducible static inventory is [GO_MIGRATION_INVENTORY.json](GO_MIGRATION_INVENTORY.json).
Run `python tools/migration/audit_go.py` to refresh it, or add `--check` to fail
while incomplete artifacts remain. Its counts detect explicit generator markers;
unmarked omissions and incorrect gameplay behavior require further review.
| Finding | Evidence / impact |
| --- | --- |
| 2,127 placeholder functions across 223 files | `Router implementation for` and `Catalog helper` bodies return nil, zero, true or false without the original logic. |
| Generated router package disconnected | `go list -deps ./cmd/ananta-server` does not contain `internal/gameserver/routers`. Its 155-file port claim does not describe the running server. |
| Catalog package disconnected | The running binary does not import `internal/catalogs`; repairing item loading alone does not restore inventory grants. |
| 74 generated catalog input references missing from shipped Configs | Includes `.json.json` paths and fabricated catalog filenames. Some require data export or joining several real config tables, not simply removing an extension. |
| 16 unresolved notification call sites in the active server | Calls remain in simplified vehicle/NPC/combat/police handlers. They now fail instead of sending guessed IDs; the missing contracts still need porting. |
| Most original configuration ignored | The active `Config` only binds a subset. Generated settings structs are not equivalent to integrating content/gameplay/UI/path settings into runtime behavior. |
| State/persistence and gameplay simplifications | Original progress, wallet, inventory, gacha, ownership, NPC behavior, police, minigames, scene transitions and many other handlers need their real logic ported and connected. A generic OK cannot restore them. |
| Fixed player template and hardcoded content | Login payloads, clothing, spawn presets, traffic lanes and several responses still contain simplified/static data. Rebuilding the original dynamic factories remains necessary. |
| Proxy parity incomplete | Existing HTTP response tests do not establish equivalence to all legacy proxy endpoints, MPay flows, patch assets or mobile clients. |
Do not connect the generated routers wholesale: many helper signatures use `any`,
drop C# `out`/`ref` behavior, or have placeholder success values. Restore one
subsystem's contracts, catalog transformations, state and handlers together, then
register it and validate it with a real client.
## Validation
- `go test ./...` and `go vet ./...` pass after the fixes.
- Regression tests check independently referenced IDs and payload bytes, variable
player strings, fallback shapes, role-list behavior, invoke/notify distinction,
movement validation, socket shutdown, bind rollback, admin host and item loading.
- `go test -race ./...` could not run: this host has CGO disabled and no C compiler
available on PATH. Passing ordinary tests is not evidence of race-detector coverage.
- No real game-client or mobile playthrough was performed. The fixes are not a
claim that world entry or all advertised gameplay now works end to end.
Regenerate recovered protocol metadata with
`python tools/migration/generate_protocol.py`; its input is pinned to `ca2e80f`.