# DISPATCH — worker_remediation_server_and_tests

## Identity
- Role: Server Gateway & E2E Test Grounding Remediation Worker
- Subagent Type: teamwork_preview_worker
- Working Directory: c:\Projects\FreeExile\.agents\teamwork\worker_remediation_server_and_tests
- Parent: orchestrator_20

## Mission
Remediate the server gateway opcode and deadzone defects, and ground Tier 4 E2E test assertions as reported by `reviewer_proto_qa` in Iteration 1.

## Feedback Reports to Remediate
- Read `c:\Projects\FreeExile\.agents\teamwork\reviewer_proto_qa\handoff.md`

## Specific Defect Fixes Required
1. `server/gateway/ws_gateway_bridge.py`:
   - Harmonize the binary opcode table with `client/cocos/assets/scripts/network/OpcodeRegistry.ts` and `TEST_INFRA.md`:
     * `0x0010`: `PlayerMoveInput`
     * `0x0011`: `EntityState`
     * `0x0012`: `ZoneData` / `ZoneInfoPayload`
     * `0x0020`: `CastMartialSkillRequest`
     * `0x0021`: `PhantomEvasionRequest`
     * `0x0022`: `CombatDamageEvent`
     * `0x0030`: `EnterZoneRequest`
     * `0x0031`: `ZonePortalData`
     * `0x0040`: `ChatMessage`
     * `0x0050`: `QuickRegisterRequest` / `LoginRequest`
   - Deadzone mathematics: In `verify_zero_residual_momentum`, use `math.hypot(input_x, input_y) <= 0.05` instead of `abs(input_x) < 0.001` to match the client's 0.05 analog joystick deadzone threshold.
   - Clean up heuristic routing in lines 159-183 so all binary opcodes route deterministically without ad-hoc patches.
2. `tests/unit/test_ws_protobuf_gateway.py`:
   - Update any opcode numbers to match the harmonized table. Run and ensure all tests pass.
3. `tests/e2e_cocos/test_tier4_human_player_journey.py`:
   - Remove dummy/facade local variable declarations (e.g. `dummy_hp -= 150; assert dummy_hp == 79120`).
   - Import and test against authentic server/client components (e.g. `ZoneEngine`, `MovementAuthorityEngine`, `WsGatewayBridge`, `BossGateController` logic, character creation catalogs in `npc_dialogue_catalog.py`).

## Verification Tasks
- Run unit tests: `pytest tests/unit/test_ws_protobuf_gateway.py -v` (must pass 100%).
- Run E2E tests: `pytest tests/e2e_cocos/ -v` (all 178 tests must pass 100% without facades).
- Run hygiene check: `python tools/lint/check_code_and_doc_hygiene.py` (ensure <= 350 lines per file).

## Deliverable
Deliver `handoff.md` detailing all fixes, verification command outputs, and notify parent.


## 2026-10-03T08:42:00Z
You are worker_remediation_server_and_tests. Working directory is c:\Projects\FreeExile\.agents\teamwork\worker_remediation_server_and_tests. Read your DISPATCH.md at c:\Projects\FreeExile\.agents\teamwork\worker_remediation_server_and_tests\DISPATCH.md and reviewer_proto_qa handoff. Harmonize binary opcodes in ws_gateway_bridge.py, update deadzone math to hypot(x,y) <= 0.05, ground Tier 4 E2E test assertions to eliminate facades, verify all tests pass via pytest, write handoff.md, and notify parent.
