Prompt Ledger. A working library of AI prompts
← All prompts

Multiplayer Robustness & Networking Pass

Stress-test and harden an existing multiplayer game by finding and fixing authority, synchronization, disconnect, reconnect, latency, replication, concurrency, session, persistence, and entity-lifecycle bugs without redesigning the networking model.

Revised 04 Sep 2026 game development multiplayer networking netcode synchronization server authority replication latency reconnect concurrency multiplayer QA persistence sessions

You are responsible for a comprehensive multiplayer robustness, networking correctness, synchronization, concurrency, and recovery pass.

Your job is to harden the existing multiplayer game against the kinds of failures that appear only when:

  • multiple real players act simultaneously;
  • packets arrive late;
  • requests are duplicated;
  • clients disconnect unexpectedly;
  • players reconnect quickly;
  • entities disappear during actions;
  • asynchronous work finishes after its original context is gone;
  • persistence overlaps with live state changes;
  • clients join after the world has already changed.

The primary question throughout this task is:

What assumptions stop being true once real networks, asynchronous execution, and multiple players are involved?

Then fix those problems.

This is an implementation task, not merely a networking audit.

Do not stop after:

  • diagramming authority;
  • identifying race conditions;
  • listing synchronization risks;
  • documenting disconnect scenarios;
  • creating a multiplayer QA checklist;
  • recommending retries or validation;
  • producing a networking report.

Trace actual multiplayer flows.

Attack assumptions.

Reproduce failures where practical.

Identify violated invariants.

Implement robust fixes.

Validate normal behavior and hostile timing.

Then attack the corrected behavior again.

Use continuously:

trace → attack → reproduce → diagnose → implement → validate → attack again

The goal is:

Leave behind the same multiplayer game, but make its networking substantially safer, more synchronized, more recoverable, more concurrency-safe, and more resistant to stale or duplicated state.

Multiplayer Correctness Is the Priority

Prioritize approximately:

  1. authoritative-state corruption;
  2. item or currency duplication/loss;
  3. persistence races;
  4. transaction failures;
  5. duplicate consequential actions;
  6. broken sessions;
  7. reconnect corruption;
  8. duplicate player/entity instances;
  9. stale-session mutation;
  10. replication disagreement;
  11. entity lifecycle errors;
  12. combat concurrency;
  13. shared-resource races;
  14. late-join state correctness;
  15. disconnect cleanup;
  16. latency/jitter robustness;
  17. recovery behavior;
  18. minor synchronization polish.

This ordering is not rigid.

Prioritize the highest-risk multiplayer failures actually present.


Core Scope

Inspect only multiplayer systems that actually exist.

Relevant areas may include:

Connections and Sessions

  • connection;
  • authentication;
  • session creation;
  • session ownership;
  • disconnect;
  • reconnect;
  • duplicate login;
  • reconnect replacement;
  • timeout;
  • heartbeat;
  • session cleanup;
  • server restart behavior;
  • version compatibility.

Identity

  • player IDs;
  • account IDs;
  • connection IDs;
  • session IDs;
  • character IDs;
  • entity IDs;
  • ownership relationships;
  • reconnect identity restoration.

Authority

  • player movement;
  • health;
  • damage;
  • combat;
  • inventory;
  • equipment;
  • XP;
  • levels;
  • currency;
  • loot;
  • gathering;
  • crafting;
  • world objects;
  • trading;
  • quests where networked;
  • rewards;
  • cooldowns;
  • shared resources.

Replication

  • state snapshots;
  • deltas;
  • RPCs/messages;
  • spawn;
  • despawn;
  • transform synchronization;
  • health/state synchronization;
  • inventory state;
  • equipment state;
  • world state;
  • status effects;
  • event replication;
  • late join.

Concurrency

  • simultaneous attacks;
  • simultaneous loot attempts;
  • shared gathering resources;
  • purchases;
  • crafting completion;
  • rewards;
  • equipment changes;
  • trades;
  • inventory transfers;
  • player-session replacement;
  • persistence writes.

Persistence

  • logout saving;
  • periodic saving;
  • reconnect while save is pending;
  • database transactions;
  • stale snapshots;
  • retry behavior;
  • session replacement;
  • server shutdown persistence.

Asynchronous Work

  • database operations;
  • network callbacks;
  • timers;
  • delayed actions;
  • pathfinding;
  • external service calls;
  • persistence;
  • queued work;
  • background tasks.

Do not invent systems that do not exist.


Explicitly Out of Scope

This is not primarily:

  • a networking-stack rewrite;
  • a networking-library migration;
  • a protocol redesign;
  • a gameplay redesign;
  • a feature sprint;
  • a matchmaking feature expansion;
  • a persistence-architecture rewrite;
  • broad technical-debt cleanup;
  • repository cleanup;
  • generic performance optimization;
  • visual polish;
  • UI redesign.

Small architecture or protocol changes are allowed when required to fix a confirmed severe networking defect safely.

Do not use this pass as justification to replace working multiplayer infrastructure with a preferred technology.


Preserve the Existing Networking Model

First determine the existing networking architecture.

Identify whether the project uses:

  • authoritative server;
  • listen server;
  • dedicated server;
  • peer-hosted model;
  • client prediction;
  • interpolation;
  • reconciliation;
  • lockstep;
  • snapshot replication;
  • event-based replication;
  • RPCs;
  • custom messaging;
  • database-backed authoritative state.

Preserve the established model unless a confirmed severe defect cannot be corrected without a narrow structural change.

Do not casually change:

  • protocol semantics;
  • authority ownership;
  • message contracts;
  • persistence formats;
  • gameplay timing;
  • identity semantics;
  • session rules;
  • externally visible multiplayer behavior.

The goal is:

make the current architecture reliable

not:

replace it with a different networking philosophy.

Authority Is the Foundation

For every consequential multiplayer action, trace the actual path.

Use this conceptual flow where appropriate:

player intent → request → authoritative validation → authoritative mutation → persistence if required → replication → client presentation

Not every system uses every stage.

But every consequential action should have a clear authority path.

Identify who owns truth for:

  • position;
  • movement state;
  • health;
  • damage;
  • death;
  • inventory;
  • equipment;
  • currency;
  • XP;
  • levels;
  • loot ownership;
  • crafting results;
  • trade state;
  • gathering resources;
  • world objects;
  • session identity.

Ask repeatedly:

Who is allowed to decide this?
Where is the authoritative mutation performed?
What prevents the same mutation from occurring twice?

Single Authoritative Truth

Avoid situations where:

  • client believes one inventory state;
  • server believes another;
  • database contains another;
  • UI displays another;
  • an old session still has permission to mutate state.

For important state establish:

one authoritative owner

with other systems acting as:

  • requesters;
  • replicas;
  • caches;
  • presentation.

Do not create additional sources of truth merely to make synchronization easier.


Never Trust Client Presentation State as Authority

Where the server is authoritative, do not use client claims as final authority for consequential results such as:

  • item ownership;
  • currency;
  • damage;
  • XP;
  • rewards;
  • trade contents;
  • resource depletion;
  • cooldown completion;
  • quest reward completion.

Client-side validation may improve responsiveness.

It must not replace authoritative validation when the existing model requires server authority.


Consequential Requests Must Be Duplicate-Safe

Assume any consequential request may happen:

  • once;
  • twice;
  • many times;
  • after timeout;
  • after reconnect;
  • after the client retries;
  • after the original result was already committed.

Examples:

  • purchase;
  • reward claim;
  • loot pickup;
  • trade confirmation;
  • crafting completion;
  • currency transfer;
  • inventory transfer;
  • progression reward;
  • quest reward.

Ask:

What happens if this exact operation is processed twice?

Use appropriate project-compatible techniques such as:

  • idempotency;
  • unique operation IDs;
  • authoritative state checks;
  • atomic mutation;
  • transaction boundaries;
  • version checks;
  • conditional updates.

Do not add heavyweight infrastructure where existing authority already guarantees serialization.


Stale Work Must Not Become Current Truth

Assume asynchronous operations may finish after their original context has changed.

Examples:

  • old session save completes after reconnect;
  • old inventory query returns after newer mutation;
  • delayed combat callback runs after target died;
  • old character load completes after player switched characters;
  • reconnect creates a new entity before old cleanup completes.

Before applying asynchronous results, verify relevant:

  • owner still exists;
  • session is still current;
  • request is still current;
  • entity generation/version matches;
  • target still exists;
  • state transition is still valid;
  • newer authoritative state has not superseded the result.

Do not allow:

old work finishing late

to overwrite:

newer truth.

Preserve Existing Work

Before substantive modifications, inspect version-control state where available.

Do not:

  • overwrite unrelated work;
  • revert unfamiliar changes;
  • remove ambiguous files;
  • use destructive cleanup commands merely to simplify testing.

When existing changes overlap networking code:

  1. inspect their purpose;
  2. preserve that intent;
  3. integrate carefully;
  4. avoid broad rewrites where a narrow fix is sufficient.

Investigate Before Asking Questions

Use the project as evidence.

Inspect relevant:

  • network messages;
  • RPCs;
  • session management;
  • authority checks;
  • connection lifecycle;
  • persistence;
  • database access;
  • entity lifecycle;
  • spawn/despawn;
  • replication;
  • retry code;
  • timeout handling;
  • logs;
  • tests;
  • protocol definitions;
  • serialization;
  • client/server state machines.

Ask for clarification only when:

  • authority genuinely cannot be established;
  • intended reconnect semantics are ambiguous;
  • multiple incompatible session policies are equally plausible;
  • a protocol change requires external compatibility decisions;
  • production data behavior requires approval;
  • external infrastructure is unavailable.

Do not ask questions merely because tracing multiplayer flow is difficult.


Runtime Testing Over Static Assumptions

Where possible, run multiple clients and the real server configuration.

Do not judge networking solely from source code.

Use the strongest evidence available:

  • multiplayer runtime;
  • local multi-client testing;
  • automated integration tests;
  • server logs;
  • network logs;
  • packet simulation;
  • latency simulation;
  • database state;
  • state snapshots;
  • reproducible disconnect/reconnect sequences.

If realistic multiplayer execution is unavailable, state that limitation.

Do not claim a race, desync, or reconnect bug was reproduced when it was only inferred.


Implementation Over Reporting

The investigation exists to create an implementation queue.

Do not spend most of the task:

  • creating network diagrams;
  • listing hypothetical races;
  • writing architecture critiques;
  • generating exhaustive message inventories.

Once a meaningful defect is reproducible and understood:

fix it.

Then verify:

  1. original reproduction;
  2. normal path;
  3. repeated requests;
  4. stale timing;
  5. disconnect/reconnect where relevant;
  6. nearby analogous code.

Execution Strategy

Work autonomously where possible.

If the environment supports parallel agents, workers, subprocesses, or independent contexts, use them when they materially improve coverage.

Do not require delegation.

A single capable session must still be able to perform the pass sequentially.

Good independent investigation areas may include:

  • session lifecycle;
  • entity replication;
  • combat networking;
  • inventory/equipment;
  • loot/gathering;
  • persistence;
  • trade;
  • late join;
  • latency testing.

Serialize modifications to shared:

  • session infrastructure;
  • identity infrastructure;
  • protocol definitions;
  • persistence;
  • inventory authority;
  • currency authority;
  • transaction systems;
  • global replication.

Do not let independent workstreams invent contradictory authority models.

For high-risk areas such as:

  • persistent inventory;
  • currency;
  • trading;
  • session replacement;
  • transactions;
  • persistence races;
  • protocol changes;

use deeper review and fresh-context challenge where the environment supports it.


Multiplayer Priority Queue

P0 — Catastrophic Multiplayer Failure

Examples:

  • item duplication;
  • currency duplication;
  • item/currency loss;
  • persistent-state corruption;
  • trade duplication;
  • stale save overwriting current data;
  • authentication/session takeover bug;
  • duplicate authoritative player state;
  • catastrophic protocol failure.

Fix immediately.

P1 — Major Multiplayer Failure

Examples:

  • reconnect regularly fails;
  • ghost players remain;
  • duplicate entities appear;
  • combat desynchronizes;
  • shared resources can be claimed twice;
  • inventory state diverges;
  • late join receives wrong world state;
  • old session remains authoritative;
  • disconnect causes important state loss.

Prioritize heavily.

P2 — Significant Robustness Problem

Examples:

  • stale UI/client state;
  • temporary entity disagreement;
  • delayed cleanup;
  • minor duplicate presentation events;
  • latency exposes inconsistent behavior;
  • recovery requires unnecessary relog.

Fix where evidence supports it.

P3 — Finishing Robustness

Examples:

  • minor replicated-state delay;
  • small session cleanup issue;
  • low-impact ordering inconsistency;
  • harmless duplicate visual event.

Handle after consequential correctness problems.


Connection Lifecycle Attack

Test relevant:

  • initial connection;
  • authentication;
  • join;
  • normal disconnect;
  • unexpected disconnect;
  • timeout;
  • force close;
  • rapid reconnect;
  • repeated connect/disconnect;
  • server restart;
  • network interruption.

For each ask:

  • What state is created?
  • Who owns it?
  • What is cleaned up?
  • What persists?
  • What survives reconnect?
  • What can complete after disconnect?

Look for:

  • ghost sessions;
  • duplicate players;
  • leaked entities;
  • stale ownership;
  • repeated initialization;
  • incomplete cleanup.

Session Identity Pass

Trace relationships between:

  • account;
  • character;
  • connection;
  • session;
  • player entity.

Determine what uniquely identifies each.

Avoid relying on an unstable identifier for long-lived authoritative state.

Examples of dangerous assumptions:

  • connection ID equals account ID;
  • entity ID survives reconnect;
  • old connection remains the current owner;
  • character load from session A is valid for session B.

Make ownership explicit.


Duplicate Login Attack

If the same account can attempt multiple concurrent logins, establish intended behavior.

Possibilities include:

  • reject second login;
  • replace old session;
  • allow multiple characters/sessions;
  • platform-specific restriction.

Follow project intent.

Test timing such as:

  1. session A active;
  2. session B connects;
  3. A begins disconnect cleanup;
  4. B becomes current;
  5. delayed callback from A finishes.

Ensure old session A cannot:

  • remove B's entity;
  • overwrite B's save;
  • invalidate B's session;
  • mutate current inventory.

Reconnect Attack

Test:

  • immediate reconnect;
  • reconnect during disconnect cleanup;
  • reconnect while old save is pending;
  • reconnect after timeout;
  • reconnect after server restart where supported;
  • repeated reconnect loops.

Ensure reconnect does not create:

  • duplicate player entities;
  • duplicate inventories;
  • duplicate subscriptions;
  • stale world references;
  • lost state;
  • old-session authority.

Session Generation / Epoch Thinking

Where session replacement races exist, consider whether the project benefits from explicitly identifying the current session generation or equivalent.

The principle is:

work belonging to an old session must not mutate a newer session.

Do not add session-version infrastructure unless the existing lifecycle actually needs it.

Use the simplest mechanism compatible with current architecture.


Disconnect Cleanup Attack

When a player disconnects, inspect cleanup of:

  • player entity;
  • combat target;
  • active interactions;
  • gathering;
  • trade;
  • party/group state;
  • subscriptions;
  • timers;
  • locks;
  • ownership;
  • session references;
  • pending network operations.

Cleanup should be:

  • complete;
  • safe to repeat;
  • safe if the entity is already gone;
  • safe if reconnect has already occurred.

Avoid cleanup assuming it always runs exactly once.


Entity Lifecycle Pass

Trace:

spawn → replicate → update → despawn → cleanup

Test:

  • rapid spawn/despawn;
  • despawn before first replication;
  • update after despawn;
  • target destroyed during action;
  • client receives stale update;
  • server removes entity while callback remains pending;
  • same logical player receives a new entity after reconnect.

Look for:

  • phantom entities;
  • stale references;
  • duplicate spawn;
  • updates applied to replaced entities;
  • delayed despawn corrupting new state.

Entity Identity Safety

If IDs can be reused, ensure stale messages cannot incorrectly affect a newer entity using the same identifier.

Possible protections may include:

  • generation/version;
  • sufficiently unique IDs;
  • authoritative existence checks;
  • sequencing.

Do not build complex generation systems where IDs are already globally unique.


Spawn / Despawn Churn Test

Repeatedly create and remove relevant entities.

Examples:

  • players;
  • enemies;
  • NPCs;
  • loot;
  • projectiles;
  • world objects.

Watch for:

  • replicated duplicates;
  • memory/lifecycle leaks;
  • stale dictionaries;
  • stale targets;
  • callbacks after destruction;
  • ghost collision or interaction.

Late Join Pass

A new client must receive the current authoritative state, not merely future updates.

Test joining after:

  • enemies have died;
  • loot has been claimed;
  • doors have changed state;
  • resources have depleted;
  • players changed equipment;
  • combat is active;
  • status effects exist;
  • world state has changed.

Ask:

If the new client never witnessed the history, can it still construct the correct present?

Late join should not depend on having observed prior deltas.


Snapshot Versus Delta Review

Where replication uses deltas/events, determine how a late joiner obtains baseline state.

Ensure:

  • initial state is complete enough;
  • delta ordering is safe;
  • state arriving before entity creation is handled;
  • late events do not resurrect old state;
  • initialization does not overwrite newer updates.

Do not solve every replication problem by sending the entire world every frame.


Replication Authority Pass

For each replicated value ask:

  • Who writes it?
  • Who reads it?
  • Which side is authoritative?
  • Is it snapshot state or transient event?
  • What happens when packets are delayed?
  • What happens when updates arrive out of order?
  • Does stale data overwrite newer state?

Avoid treating replicated client copies as authoritative server state.


Sequence / Version Awareness

For state where old updates can arrive after newer ones, determine whether the protocol already guarantees ordering.

If it does:

  • use that guarantee.

If it does not:

  • consider sequence/version checks where materially required.

Do not add ordering metadata everywhere reflexively.

Use it only where stale application is realistically possible.


Movement Synchronization Pass

Where movement is networked, inspect:

  • authority;
  • input transmission;
  • position replication;
  • interpolation;
  • prediction;
  • reconciliation;
  • teleportation;
  • correction;
  • entity spawn position;
  • reconnect position.

Look for:

  • rubber-banding caused by incorrect authority;
  • stale correction;
  • remote jitter;
  • clients diverging permanently;
  • impossible movement accepted authoritatively;
  • interpolation continuing after despawn.

Do not redesign the movement networking model merely for cosmetic improvement.

Fix correctness and major robustness problems.


Combat Synchronization Pass

Trace:

intent → validation → attack commitment → hit resolution → authoritative damage → death → reward → replication

Test:

  • two attackers hitting simultaneously;
  • target dies during another pending attack;
  • attacker disconnects;
  • target disconnects;
  • target despawns;
  • repeated attack request;
  • simultaneous lethal damage;
  • latency around cooldown expiration.

Ensure:

  • damage is not applied twice accidentally;
  • dead entities do not resolve stale attacks unless explicitly intended;
  • death occurs once authoritatively;
  • rewards occur exactly once;
  • all clients converge on outcome.

Simultaneous Death Attack

Test scenarios where:

  • two players kill each other;
  • several players land lethal hits;
  • healing and lethal damage occur near-simultaneously;
  • death and disconnect overlap.

Look for:

  • duplicate death callbacks;
  • repeated loot;
  • repeated XP;
  • inconsistent kill credit;
  • clients disagreeing on alive/dead state.

Cooldown Authority

If cooldowns affect multiplayer actions, establish who owns them.

Avoid:

  • client deciding cooldown completion authoritatively;
  • reconnect resetting cooldown unintentionally;
  • duplicate requests bypassing cooldown;
  • server/client cooldown values diverging materially.

Client presentation may predict.

Authoritative acceptance should follow established server rules.


Inventory Authority Pass

Treat authoritative inventory as high risk.

Trace operations such as:

  • add;
  • remove;
  • move;
  • split;
  • merge;
  • equip;
  • unequip;
  • drop;
  • loot;
  • craft;
  • trade;
  • purchase;
  • reward.

For each ask:

Can two requests operate on the same item/state concurrently?

Protect invariants such as:

  • item ownership is unambiguous;
  • quantities do not become negative;
  • items are not created twice;
  • items are not lost between partial operations;
  • client disagreement does not become authority.

Equipment Concurrency Pass

Test:

  • equip while item is removed;
  • rapid equip/unequip;
  • swap while combat changes stats;
  • inventory full during unequip;
  • duplicate equip requests;
  • disconnect during equipment mutation.

Ensure:

  • bonuses apply once;
  • equipment and inventory ownership agree;
  • replicated appearance matches authoritative equipment.

Currency Authority Pass

Treat currency as high-risk authoritative state.

Test:

  • simultaneous purchases;
  • repeated purchase requests;
  • refunds;
  • rewards;
  • trades;
  • concurrent deductions;
  • reconnect during mutation.

Ensure two operations cannot both validate against the same old balance and overspend or duplicate funds.

Use appropriate atomic/transactional semantics where required.


Loot Concurrency Attack

For exclusive loot or pickup:

  1. two players attempt pickup;
  2. both requests arrive close together;
  3. only one outcome should succeed where ownership is exclusive.

Ensure:

  • item is not granted twice;
  • loser receives correct result;
  • world entity despawns once;
  • late replicas converge.

Do not rely solely on both clients observing the loot disappear.

The server must resolve exclusivity.


Shared Resource Concurrency

If several players can interact with shared resources, test:

  • final resource unit claimed simultaneously;
  • depletion during another pending action;
  • respawn while old interaction completes;
  • player disconnect during resource mutation.

Ensure resource state remains authoritative and rewards follow intended semantics.


Crafting Concurrency

If crafting mutates persistent inventory, test:

  • repeated craft request;
  • concurrent inventory mutation;
  • disconnect during craft;
  • reconnect while completion is pending;
  • resource availability changing before commit.

Ensure:

  • ingredients are consumed once;
  • output is created once;
  • partial failure does not duplicate or destroy state unexpectedly.

Reward Idempotency

For consequential rewards such as:

  • quest completion;
  • achievement reward;
  • level reward;
  • loot;
  • daily reward;
  • boss reward;

ask:

What uniquely identifies this reward occurrence?

A retried or duplicated message must not grant it repeatedly unless repeated granting is intentional.


Trade / Transaction Pass

Treat player-to-player trade or equivalent asset exchange as high risk.

Test:

  • simultaneous confirmation;
  • one side changes offer late;
  • disconnect during confirmation;
  • one inventory becomes full;
  • repeated network request;
  • retry after timeout;
  • one item disappears before commit;
  • session replacement during trade.

Protect:

nothing duplicated, nothing lost, nothing partially transferred

Where supported by architecture, use appropriate atomic transaction boundaries.

Do not simulate atomicity only through client UI locking.


Partial Transaction Failure

For multi-step authoritative mutations ask:

What if step 2 fails after step 1 succeeds?

Examples:

  • remove currency then grant item;
  • remove item then credit recipient;
  • consume ingredients then create output;
  • deduct fee then complete transfer.

Use:

  • atomic operations;
  • database transaction;
  • reversible staged state;
  • validated commit;

where actually required.

Avoid elaborate transaction frameworks for operations already atomic by design.


Persistence Race Hunt

Treat persistence as high risk.

Search for scenarios such as:

  • periodic save overlaps logout save;
  • logout save overlaps reconnect;
  • old session save finishes after new session save;
  • inventory update overlaps character snapshot;
  • server shutdown overlaps normal persistence;
  • retry repeats side effects;
  • DB write reads stale state then overwrites newer state.

Ask:

Can an older snapshot overwrite newer truth?

Fix confirmed stale-write paths.


Stale Snapshot Overwrite

A dangerous pattern is:

  1. session A loads state;
  2. session A mutates local copy;
  3. session B later becomes authoritative;
  4. session B writes newer data;
  5. delayed save from A overwrites it.

Prevent outdated session/state from replacing newer data.

Possible mechanisms may include:

  • session ownership checks;
  • version numbers;
  • optimistic concurrency;
  • conditional database updates;
  • centralized authoritative save serialization.

Use what best matches existing architecture.


Save Ordering

If multiple saves may be in flight, determine what guarantees ordering.

Do not assume asynchronous writes complete in request order.

If ordering matters, ensure older writes cannot become final after newer writes.


Persistence Idempotency

If persistence operations can retry, distinguish:

  • setting current state;
  • appending side effects;
  • granting rewards;
  • recording transactions.

A repeated state snapshot may be naturally idempotent.

A repeated reward insertion may not be.

Handle accordingly.


Database Transaction Review

For persistent multiplayer operations involving several related mutations, inspect transaction boundaries.

High-risk examples:

  • trade;
  • purchase;
  • currency transfer;
  • reward claim;
  • item conversion.

Avoid:

  • partial commits;
  • inconsistent ownership;
  • double processing under retry.

Do not wrap unrelated operations in giant transactions merely for theoretical safety.


Async Callback Attack

For each meaningful asynchronous operation, invalidate its assumptions while it is pending.

Examples:

  • disconnect;
  • reconnect;
  • change character;
  • target dies;
  • target despawns;
  • scene/zone changes;
  • request is superseded;
  • session is replaced.

When callback returns verify:

  • requester is still current;
  • session still matches;
  • target still exists;
  • expected state still applies;
  • result has not already been committed.

Timeout Behavior

Test operations that time out.

Ask:

  • Did the server actually process the request?
  • Will the client retry?
  • Can retry duplicate the result?
  • Is eventual response ignored safely?
  • Does timeout leave a locked state?

Timeout does not necessarily mean:

the operation did not happen.

Design retry behavior accordingly.


Retry Semantics

Classify network actions approximately as:

Naturally Safe to Retry

Examples may include:

  • fetch current state;
  • request snapshot.

Consequential Mutation

Examples:

  • purchase;
  • trade;
  • reward;
  • crafting completion;
  • currency transfer.

Consequential retries require special care.

Do not blindly retry side-effecting operations.


Latency Attack

Where practical test representative:

  • added latency;
  • asymmetric latency;
  • jitter;
  • delayed server response;
  • slow database response;
  • packet delay.

Look for assumptions such as:

  • action always completes before next input;
  • target still exists;
  • UI state remains valid;
  • client will not send another request;
  • session will not change.

Do not fix latency bugs using arbitrary sleep delays.

Correct the underlying state assumptions.


Packet Loss / Message Failure

Where the networking model and available tooling support it, test:

  • dropped non-critical updates;
  • delayed messages;
  • retransmission;
  • request failure;
  • duplicate delivery.

Do not assume transport behavior it does not provide.

First understand whether the transport guarantees:

  • reliability;
  • ordering;
  • deduplication.

Then test within those real constraints.


Rapid Input Under Latency

Combine rapid input with delayed responses.

Examples:

  • rapidly switch targets;
  • purchase several times;
  • loot repeatedly;
  • equip/unequip;
  • cast abilities;
  • move while action is pending.

Look for:

  • duplicate requests;
  • stale UI decisions;
  • reordered state;
  • client displaying impossible pending state;
  • server accepting mutations that should no longer be valid.

Concurrent Player Attack

For shared state, deliberately trigger simultaneous actions from multiple clients.

Examples:

  • loot same object;
  • gather same resource;
  • buy final stock item;
  • attack same target;
  • interact with same exclusive object;
  • trade;
  • claim shared objective.

The authority must resolve the outcome consistently.


Race Condition Standard

Do not call something a race merely because code is asynchronous.

Require an actual shared-state or ordering hazard.

For each confirmed race identify:

  • actors/tasks involved;
  • shared state;
  • possible ordering;
  • violated invariant;
  • current synchronization guarantee;
  • smallest robust fix.

Avoid adding locks indiscriminately.

Authority, single-threaded execution, transactions, unique constraints, or conditional state transitions may already provide safer and simpler guarantees.


Locking Policy

Do not add locks reflexively.

Before adding a lock ask:

  • Is this state already confined to one authoritative thread?
  • Can an atomic database operation solve the problem?
  • Can ownership eliminate the race?
  • Can a state transition make invalid double execution impossible?
  • Can idempotency solve retry duplication?

Use locks only where actual concurrency requires them.

Avoid:

  • deadlock risk;
  • unnecessary contention;
  • giant lock scopes;
  • cross-system lock ordering complexity.

Session Cleanup Versus Persistence

Be careful with disconnect flows such as:

disconnect → save → destroy session

Determine whether cleanup waits for persistence and whether reconnect may happen during that interval.

Ensure reconnect does not inherit ambiguous state.

Possible intended policies include:

  • old session remains authoritative until save finishes;
  • new session supersedes immediately and invalidates old save;
  • saves are serialized centrally.

Use the architecture's intended ownership.

Make it explicit.


Server Restart Pass

Where relevant test:

  • connected players during shutdown;
  • save flush;
  • session cleanup;
  • restart;
  • reconnect;
  • persisted world state;
  • stale client assumptions.

Do not redesign server orchestration.

Fix release-relevant robustness problems.


Version Mismatch

If client/server versions can differ, ensure behavior is intentional.

Avoid:

  • decoding incompatible messages;
  • silent state corruption;
  • undefined protocol behavior.

A clear rejection may be preferable to partial compatibility.

Preserve existing supported compatibility policy.


Serialization Pass

Inspect network serialization for consequential state.

Look for:

  • missing fields;
  • stale defaults;
  • optional/versioned fields;
  • integer overflow;
  • incorrect enum mapping;
  • identity loss;
  • inconsistent server/client representation.

Do not replace the protocol format without clear need.


Message Handler Validation

For important server-side handlers ensure they validate appropriate:

  • session ownership;
  • entity ownership;
  • target validity;
  • range;
  • cooldown;
  • required resources;
  • item ownership;
  • current state.

Do not duplicate every gameplay rule in every handler.

Prefer calling authoritative gameplay logic where existing architecture supports it.


Client-Supplied Entity IDs

Where clients submit:

  • target IDs;
  • item IDs;
  • entity IDs;
  • resource IDs;

validate that the current player is actually allowed to operate on that entity.

Do not assume knowledge of an ID grants permission.


Zone / Area Transition Pass

If multiplayer players transition between areas, test:

  • disconnect during transition;
  • reconnect during transition;
  • old-zone despawn arriving late;
  • new-zone spawn occurring early;
  • pending actions crossing zone boundary;
  • persistence during transition.

Ensure players cannot exist authoritatively in contradictory zones.


Party / Group State

If parties, guilds, teams, or groups exist, test relevant:

  • disconnect;
  • reconnect;
  • leader disconnect;
  • duplicate membership;
  • session replacement;
  • stale invitations;
  • entity despawn.

Only inspect systems that actually exist.


Chat / Social State

If networked social systems exist, inspect basic robustness such as:

  • duplicate messages caused by retry;
  • stale session routing;
  • messages sent after disconnect;
  • incorrect identity mapping.

Do not turn this into moderation or social-feature redesign.


Authority Matrix

Build a concise internal authority matrix where useful.

Possible columns:

  • system;
  • client intent;
  • server validation;
  • authoritative state;
  • persistence;
  • replication;
  • reconnect behavior.

Use it to expose ambiguity.

Do not spend the task polishing documentation.


Invariant-Driven Testing

For each major multiplayer system establish invariants.

Examples:

Inventory

  • every authoritative item has one valid owner/location;
  • item quantities remain valid;
  • operation occurs intended number of times.

Currency

  • balance cannot be spent twice;
  • authoritative mutations cannot unintentionally duplicate funds.

Sessions

  • only intended current session can mutate player state;
  • old session cannot overwrite new session.

Loot

  • exclusive reward can only be claimed the intended number of times.

Combat

  • death resolves once;
  • dead targets do not receive unintended stale attacks;
  • reward attribution follows authoritative outcome.

Replication

  • all clients eventually converge on authoritative current state.

Attack these invariants.


Pattern-Based Bug Hunting

When one multiplayer defect is found, search analogous paths.

Examples:

If one async handler applies stale results:

inspect other async handlers.

If one reward request is not duplicate-safe:

inspect other reward endpoints.

If one session cleanup uses an unsafe identity:

inspect all session cleanup.

If one inventory operation has a race:

inspect other multi-step inventory mutations.

Do not blindly apply the same fix everywhere.

Search for the repeated faulty assumption.


Regression Test Creation

For meaningful bugs, add focused tests where practical.

Potential forms include:

  • server unit tests;
  • integration tests;
  • multi-client tests;
  • database concurrency tests;
  • session lifecycle tests;
  • duplicate-request tests;
  • replication tests.

A useful regression test should:

  1. reproduce the original failure;
  2. fail before the fix;
  3. pass after the fix;
  4. remain deterministic enough to be useful;
  5. avoid relying solely on fragile timing sleeps.

Prefer explicit synchronization, test hooks, or controllable scheduling over random timing.


Bug-Fix Standard

For every meaningful multiplayer defect:

  1. reproduce where practical;
  2. identify violated invariant;
  3. identify exact authority/state ownership;
  4. determine root cause;
  5. implement the smallest robust fix;
  6. rerun original reproduction;
  7. validate normal path;
  8. test duplicate request where relevant;
  9. test late/stale completion where relevant;
  10. test disconnect/reconnect where relevant;
  11. test concurrent players where relevant;
  12. search analogous code;
  13. add regression coverage where practical.

Avoid symptom patches such as:

  • arbitrary delays;
  • random retries;
  • blanket input disabling;
  • unexplained lock flags;
  • redundant full-state broadcasts.

Fix ownership, lifecycle, ordering, idempotency, or transaction semantics instead.


Work in Networking Waves

Do not change every multiplayer subsystem simultaneously.

Wave A — Authority and Sessions

Inspect:

  • identity;
  • current session;
  • connection lifecycle;
  • duplicate login;
  • disconnect;
  • reconnect.

Fix major ownership ambiguity.

Validate.

Wave B — Replication and Entity Lifecycle

Inspect:

  • spawn;
  • despawn;
  • late join;
  • stale updates;
  • entity replacement;
  • world-state synchronization.

Validate.

Wave C — Consequential Gameplay

Attack:

  • combat;
  • inventory;
  • equipment;
  • loot;
  • gathering;
  • crafting;
  • rewards.

Validate duplicate and concurrent execution.

Wave D — Transactions and Persistence

Attack:

  • currency;
  • trades;
  • purchases;
  • DB operations;
  • save ordering;
  • reconnect/save races;
  • stale writes.

Treat as high risk.

Validate deeply.

Wave E — Latency and Recovery

Test:

  • latency;
  • timeouts;
  • retries;
  • jitter;
  • disconnect timing;
  • rapid input while pending.

Validate recovery.

Wave F — Long Tail

Search for:

  • stale callbacks;
  • minor replication disagreement;
  • session churn;
  • unusual ordering;
  • repeated connect/disconnect;
  • server restart edge cases.

Reassess After Every Wave

Ask:

  • Who still has ambiguous authority?
  • Which consequential action can still happen twice?
  • Which callback can arrive after its owner is gone?
  • Can an old session mutate current state?
  • Can two players claim one exclusive result?
  • Can a stale snapshot overwrite newer data?
  • Does late join reconstruct current truth?
  • Can an entity receive updates after despawn?
  • Can reconnect produce duplicates?
  • Did a fix create unnecessary locking or latency?
  • Did normal multiplayer responsiveness regress?

Reprioritize.


Productive Networking Loop

Do not stop after the first severe networking fix.

Multiplayer defects often reveal deeper shared assumptions.

Examples:

  • reconnect fix reveals persistence race;
  • persistence fix reveals session ambiguity;
  • session fix reveals stale entity ownership;
  • loot fix reveals similar reward duplication;
  • late-join fix exposes incomplete replication baseline.

Continue:

trace → attack → reproduce → diagnose → implement → validate → attack again

while meaningful, safely actionable multiplayer issues remain.

Do not manufacture theoretical races merely to continue working.

Stop when remaining concerns are:

  • unsupported by evidence;
  • low impact;
  • dependent on unavailable production infrastructure;
  • intentional behavior;
  • outside scope.

Independent High-Risk Review

Near completion, use fresh context where practical to challenge significant changes involving:

  • inventory;
  • currency;
  • trades;
  • database transactions;
  • persistence;
  • session replacement;
  • authentication;
  • global replication;
  • protocol changes.

Do not ask:

Does this look correct?

Ask:

How could this still execute twice?
How could stale state still win?
How could partial failure lose or duplicate value?
What happens if reconnect occurs at the worst possible point?
What if two players trigger this simultaneously?
What if the callback arrives after ownership changed?

Repair justified findings.


Fresh Multiplayer Destruction Review

Near completion, perform a fresh multiplayer attack pass.

Focus independently on:

Session Lifecycle

  • duplicate login;
  • reconnect;
  • disconnect cleanup;
  • stale-session authority.

Entity Lifecycle

  • spawn/despawn;
  • target invalidation;
  • late updates;
  • late join.

Consequential Actions

  • loot;
  • inventory;
  • rewards;
  • crafting;
  • combat.

Transactions

  • purchases;
  • currency;
  • trades;
  • persistence.

Network Failure

  • latency;
  • timeout;
  • retry;
  • stale completion.

The purpose is to find failures the implementation process became accustomed to overlooking.


"What Happens Twice?" Review

For every consequential network action ask:

What happens if this request executes twice?

Explicitly review:

  • reward claims;
  • purchases;
  • crafting;
  • loot;
  • trade;
  • inventory transfers;
  • equipment;
  • combat actions;
  • persistence writes.

If duplicate execution creates material harm, make the operation robust.


"What Happens Late?" Review

For every delayed/asynchronous operation ask:

What happens if this completes much later than expected?

Especially after:

  • disconnect;
  • reconnect;
  • target death;
  • zone transition;
  • new request;
  • newer save.

Old results must not blindly become current truth.


"What Happens If It Disappears?" Review

For target-based operations ask:

What happens if the player, target, item, world object, entity, session, or zone disappears before completion?

Validate lifecycle before applying delayed results.


"What Does a New Client Believe?" Review

For major replicated systems ask:

What does a client joining right now believe the world looks like?

Compare that against current server truth.

Test changed:

  • world objects;
  • players;
  • equipment;
  • combat state;
  • resources;
  • doors;
  • loot;
  • relevant progression/world state.

"Can Old Truth Overwrite New Truth?" Review

Explicitly inspect:

  • session saves;
  • DB writes;
  • snapshots;
  • replication messages;
  • reconnect state;
  • caches.

Ask:

Can an older state version finish later and overwrite newer authoritative state?

Treat confirmed cases as high priority.


Anti-Overengineering Review

Before completion inspect whether robustness fixes added unnecessary complexity.

Ask:

  • Did we add locks where authority already serialized work?
  • Did we add sequence IDs where transport already guarantees ordering?
  • Did we build generalized infrastructure for one small bug?
  • Did we replace efficient deltas with full-state spam?
  • Did we add retries that can duplicate side effects?
  • Did we create unnecessary synchronization latency?
  • Did we add multiple sources of truth?
  • Did we complicate protocol without measurable need?

Simplify unjustified changes.

Robustness does not require maximal machinery.


Responsiveness Regression Review

Network correctness must not make multiplayer unnecessarily sluggish.

After fixes verify:

  • normal movement remains responsive;
  • combat remains responsive;
  • inventory actions remain usable;
  • UI does not wait on unnecessary round trips;
  • prediction remains safe where already used;
  • server validation does not create needless serialization bottlenecks.

Do not trade one correctness problem for widespread avoidable latency.


Performance Awareness

This is not primarily a network optimization pass.

However, avoid robustness changes that cause:

  • full-world replication every update;
  • duplicate database writes;
  • excessive locks;
  • request serialization across unrelated players;
  • repeated full inventory snapshots without need;
  • unbounded message queues;
  • unnecessary retries.

Prefer correctness with reasonable scalability.


Final Cross-System Multiplayer Review

Before completion inspect for:

  • ambiguous authority;
  • stale sessions;
  • duplicate authoritative entities;
  • stale callbacks;
  • repeated rewards;
  • inventory/currency duplication;
  • persistence overwrite races;
  • invalid late-join state;
  • updates after despawn;
  • incomplete disconnect cleanup;
  • transaction partial failure;
  • protocol disagreement;
  • regression in normal gameplay.

Fix justified issues.

Run final validation.


Completion Standard

The multiplayer robustness pass is complete when, to the degree available testing can establish:

  1. important authoritative state has clear ownership;
  2. major client requests are validated appropriately;
  3. consequential operations resist accidental duplicate execution;
  4. connect/disconnect lifecycle is stable;
  5. reconnect behavior is stable;
  6. old sessions cannot overwrite or mutate newer session state;
  7. duplicate-login behavior follows intended policy;
  8. entity spawn/despawn lifecycle is robust;
  9. stale entity updates do not corrupt current state;
  10. late joiners receive current authoritative state;
  11. important replicated state converges correctly;
  12. concurrent combat resolves correctly;
  13. shared resources resolve concurrent claims correctly;
  14. inventory authority remains consistent;
  15. currency authority remains consistent;
  16. important transaction paths avoid partial completion;
  17. loot/reward duplication paths discovered are fixed;
  18. persistence races discovered are fixed;
  19. stale-save overwrite paths discovered are fixed;
  20. delayed async callbacks validate current ownership/state where required;
  21. representative latency/failure behavior has been tested where practical;
  22. high-risk fixes received additional scrutiny;
  23. no known major multiplayer defect discovered during the pass remains unfixed without an explicit blocker;
  24. normal multiplayer behavior remains responsive;
  25. networking architecture remains recognizably the same rather than being unnecessarily redesigned;
  26. remaining risks require unavailable infrastructure, are speculative, low-impact, intentional, or better suited to another specialized pass.

The objective is not:

make networking infinitely defensive

The objective is:

make the existing multiplayer architecture robust against realistic latency, concurrency, disconnects, stale state, duplicate requests, lifecycle changes, and asynchronous execution.

Final Report

When complete, provide a concise multiplayer engineering report.

1. Overall Result

Summarize the largest improvements to multiplayer robustness.

2. Major Networking Problems Fixed

For each major issue include concise:

  • System
  • Failure
  • Root cause
  • Fix
  • Impact

3. Connection / Session / Reconnect

Summarize meaningful work involving:

  • login;
  • sessions;
  • disconnect;
  • reconnect;
  • duplicate sessions;
  • cleanup.

4. Replication / Entity Lifecycle

Summarize meaningful improvements to:

  • spawn/despawn;
  • stale updates;
  • replication;
  • late join;
  • target lifecycle.

5. Concurrency / Transactions

Summarize relevant:

  • inventory;
  • currency;
  • loot;
  • gathering;
  • crafting;
  • combat;
  • trading;
  • other shared state.

Include only systems that exist.

6. Persistence / Async Safety

Summarize:

  • stale writes;
  • save ordering;
  • reconnect/save races;
  • callback invalidation;
  • database transaction changes.

7. Latency and Failure Testing

State which relevant scenarios were actually tested:

  • latency;
  • jitter;
  • timeout;
  • retry;
  • duplicate request;
  • disconnect;
  • reconnect.

Do not imply tests occurred when they did not.

8. Validation

State exactly what was performed, including relevant:

  • automated tests;
  • multi-client tests;
  • server tests;
  • persistence tests;
  • duplicate-request tests;
  • concurrency tests;
  • late-join tests;
  • reconnect tests;
  • stress/repetition tests.

9. Deliberately Unchanged

Describe noteworthy behavior preserved because:

  • it is intentional;
  • protocol compatibility matters;
  • evidence was insufficient;
  • architecture already provides the required guarantee;
  • changing it would amount to redesign;
  • necessary production infrastructure was unavailable.

10. Remaining Risks

List only meaningful unresolved multiplayer risks.

For each include:

  • Risk
  • Severity
  • Why unresolved
  • Potential impact
  • Recommended next action

Do not pad this section with theoretical races unsupported by evidence.


Final Directive

Think like the multiplayer engineer who has to explain every duplicated item, ghost player, stale save, desync, or broken reconnect after launch.

Do not assume:

  • requests happen once;
  • responses arrive quickly;
  • callbacks finish in order;
  • clients remain connected;
  • targets remain alive;
  • entities remain spawned;
  • old sessions disappear immediately;
  • database writes finish in order;
  • retries are harmless;
  • two players will not act simultaneously.

Repeatedly ask:

Who owns this truth?
What happens if this occurs twice?
What happens if it arrives late?
What happens if the player, target, session, or entity disappears?
Can an old session overwrite a new one?
Can two players both claim one exclusive result?
What does a client joining right now believe?
Can every client eventually converge on authoritative current state?

Continue:

trace → attack → reproduce → diagnose → implement → validate → attack again

while meaningful multiplayer robustness problems remain.

Leave behind the same multiplayer game, but make its networking substantially safer, synchronized, recoverable, concurrency-safe, and resilient to real-world network behavior.

View raw markdown
You are responsible for a comprehensive **multiplayer robustness, networking correctness, synchronization, concurrency, and recovery pass**.

Your job is to harden the existing multiplayer game against the kinds of failures that appear only when:

- multiple real players act simultaneously;
- packets arrive late;
- requests are duplicated;
- clients disconnect unexpectedly;
- players reconnect quickly;
- entities disappear during actions;
- asynchronous work finishes after its original context is gone;
- persistence overlaps with live state changes;
- clients join after the world has already changed.

The primary question throughout this task is:

> **What assumptions stop being true once real networks, asynchronous execution, and multiple players are involved?**

Then fix those problems.

This is an **implementation task**, not merely a networking audit.

Do not stop after:

- diagramming authority;
- identifying race conditions;
- listing synchronization risks;
- documenting disconnect scenarios;
- creating a multiplayer QA checklist;
- recommending retries or validation;
- producing a networking report.

Trace actual multiplayer flows.

Attack assumptions.

Reproduce failures where practical.

Identify violated invariants.

Implement robust fixes.

Validate normal behavior and hostile timing.

Then attack the corrected behavior again.

Use continuously:

> **trace → attack → reproduce → diagnose → implement → validate → attack again**

The goal is:

> **Leave behind the same multiplayer game, but make its networking substantially safer, more synchronized, more recoverable, more concurrency-safe, and more resistant to stale or duplicated state.**

---

# Multiplayer Correctness Is the Priority

Prioritize approximately:

1. authoritative-state corruption;
2. item or currency duplication/loss;
3. persistence races;
4. transaction failures;
5. duplicate consequential actions;
6. broken sessions;
7. reconnect corruption;
8. duplicate player/entity instances;
9. stale-session mutation;
10. replication disagreement;
11. entity lifecycle errors;
12. combat concurrency;
13. shared-resource races;
14. late-join state correctness;
15. disconnect cleanup;
16. latency/jitter robustness;
17. recovery behavior;
18. minor synchronization polish.

This ordering is not rigid.

Prioritize the highest-risk multiplayer failures actually present.

---

# Core Scope

Inspect only multiplayer systems that actually exist.

Relevant areas may include:

## Connections and Sessions

- connection;
- authentication;
- session creation;
- session ownership;
- disconnect;
- reconnect;
- duplicate login;
- reconnect replacement;
- timeout;
- heartbeat;
- session cleanup;
- server restart behavior;
- version compatibility.

## Identity

- player IDs;
- account IDs;
- connection IDs;
- session IDs;
- character IDs;
- entity IDs;
- ownership relationships;
- reconnect identity restoration.

## Authority

- player movement;
- health;
- damage;
- combat;
- inventory;
- equipment;
- XP;
- levels;
- currency;
- loot;
- gathering;
- crafting;
- world objects;
- trading;
- quests where networked;
- rewards;
- cooldowns;
- shared resources.

## Replication

- state snapshots;
- deltas;
- RPCs/messages;
- spawn;
- despawn;
- transform synchronization;
- health/state synchronization;
- inventory state;
- equipment state;
- world state;
- status effects;
- event replication;
- late join.

## Concurrency

- simultaneous attacks;
- simultaneous loot attempts;
- shared gathering resources;
- purchases;
- crafting completion;
- rewards;
- equipment changes;
- trades;
- inventory transfers;
- player-session replacement;
- persistence writes.

## Persistence

- logout saving;
- periodic saving;
- reconnect while save is pending;
- database transactions;
- stale snapshots;
- retry behavior;
- session replacement;
- server shutdown persistence.

## Asynchronous Work

- database operations;
- network callbacks;
- timers;
- delayed actions;
- pathfinding;
- external service calls;
- persistence;
- queued work;
- background tasks.

Do not invent systems that do not exist.

---

# Explicitly Out of Scope

This is **not primarily**:

- a networking-stack rewrite;
- a networking-library migration;
- a protocol redesign;
- a gameplay redesign;
- a feature sprint;
- a matchmaking feature expansion;
- a persistence-architecture rewrite;
- broad technical-debt cleanup;
- repository cleanup;
- generic performance optimization;
- visual polish;
- UI redesign.

Small architecture or protocol changes are allowed when required to fix a confirmed severe networking defect safely.

Do not use this pass as justification to replace working multiplayer infrastructure with a preferred technology.

---

# Preserve the Existing Networking Model

First determine the existing networking architecture.

Identify whether the project uses:

- authoritative server;
- listen server;
- dedicated server;
- peer-hosted model;
- client prediction;
- interpolation;
- reconciliation;
- lockstep;
- snapshot replication;
- event-based replication;
- RPCs;
- custom messaging;
- database-backed authoritative state.

Preserve the established model unless a confirmed severe defect cannot be corrected without a narrow structural change.

Do not casually change:

- protocol semantics;
- authority ownership;
- message contracts;
- persistence formats;
- gameplay timing;
- identity semantics;
- session rules;
- externally visible multiplayer behavior.

The goal is:

> **make the current architecture reliable**

not:

> **replace it with a different networking philosophy.**

---

# Authority Is the Foundation

For every consequential multiplayer action, trace the actual path.

Use this conceptual flow where appropriate:

> **player intent → request → authoritative validation → authoritative mutation → persistence if required → replication → client presentation**

Not every system uses every stage.

But every consequential action should have a clear authority path.

Identify who owns truth for:

- position;
- movement state;
- health;
- damage;
- death;
- inventory;
- equipment;
- currency;
- XP;
- levels;
- loot ownership;
- crafting results;
- trade state;
- gathering resources;
- world objects;
- session identity.

Ask repeatedly:

> **Who is allowed to decide this?**

> **Where is the authoritative mutation performed?**

> **What prevents the same mutation from occurring twice?**

---

# Single Authoritative Truth

Avoid situations where:

- client believes one inventory state;
- server believes another;
- database contains another;
- UI displays another;
- an old session still has permission to mutate state.

For important state establish:

> **one authoritative owner**

with other systems acting as:

- requesters;
- replicas;
- caches;
- presentation.

Do not create additional sources of truth merely to make synchronization easier.

---

# Never Trust Client Presentation State as Authority

Where the server is authoritative, do not use client claims as final authority for consequential results such as:

- item ownership;
- currency;
- damage;
- XP;
- rewards;
- trade contents;
- resource depletion;
- cooldown completion;
- quest reward completion.

Client-side validation may improve responsiveness.

It must not replace authoritative validation when the existing model requires server authority.

---

# Consequential Requests Must Be Duplicate-Safe

Assume any consequential request may happen:

- once;
- twice;
- many times;
- after timeout;
- after reconnect;
- after the client retries;
- after the original result was already committed.

Examples:

- purchase;
- reward claim;
- loot pickup;
- trade confirmation;
- crafting completion;
- currency transfer;
- inventory transfer;
- progression reward;
- quest reward.

Ask:

> **What happens if this exact operation is processed twice?**

Use appropriate project-compatible techniques such as:

- idempotency;
- unique operation IDs;
- authoritative state checks;
- atomic mutation;
- transaction boundaries;
- version checks;
- conditional updates.

Do not add heavyweight infrastructure where existing authority already guarantees serialization.

---

# Stale Work Must Not Become Current Truth

Assume asynchronous operations may finish after their original context has changed.

Examples:

- old session save completes after reconnect;
- old inventory query returns after newer mutation;
- delayed combat callback runs after target died;
- old character load completes after player switched characters;
- reconnect creates a new entity before old cleanup completes.

Before applying asynchronous results, verify relevant:

- owner still exists;
- session is still current;
- request is still current;
- entity generation/version matches;
- target still exists;
- state transition is still valid;
- newer authoritative state has not superseded the result.

Do not allow:

> **old work finishing late**

to overwrite:

> **newer truth.**

---

# Preserve Existing Work

Before substantive modifications, inspect version-control state where available.

Do not:

- overwrite unrelated work;
- revert unfamiliar changes;
- remove ambiguous files;
- use destructive cleanup commands merely to simplify testing.

When existing changes overlap networking code:

1. inspect their purpose;
2. preserve that intent;
3. integrate carefully;
4. avoid broad rewrites where a narrow fix is sufficient.

---

# Investigate Before Asking Questions

Use the project as evidence.

Inspect relevant:

- network messages;
- RPCs;
- session management;
- authority checks;
- connection lifecycle;
- persistence;
- database access;
- entity lifecycle;
- spawn/despawn;
- replication;
- retry code;
- timeout handling;
- logs;
- tests;
- protocol definitions;
- serialization;
- client/server state machines.

Ask for clarification only when:

- authority genuinely cannot be established;
- intended reconnect semantics are ambiguous;
- multiple incompatible session policies are equally plausible;
- a protocol change requires external compatibility decisions;
- production data behavior requires approval;
- external infrastructure is unavailable.

Do not ask questions merely because tracing multiplayer flow is difficult.

---

# Runtime Testing Over Static Assumptions

Where possible, run multiple clients and the real server configuration.

Do not judge networking solely from source code.

Use the strongest evidence available:

- multiplayer runtime;
- local multi-client testing;
- automated integration tests;
- server logs;
- network logs;
- packet simulation;
- latency simulation;
- database state;
- state snapshots;
- reproducible disconnect/reconnect sequences.

If realistic multiplayer execution is unavailable, state that limitation.

Do not claim a race, desync, or reconnect bug was reproduced when it was only inferred.

---

# Implementation Over Reporting

The investigation exists to create an **implementation queue**.

Do not spend most of the task:

- creating network diagrams;
- listing hypothetical races;
- writing architecture critiques;
- generating exhaustive message inventories.

Once a meaningful defect is reproducible and understood:

> **fix it.**

Then verify:

1. original reproduction;
2. normal path;
3. repeated requests;
4. stale timing;
5. disconnect/reconnect where relevant;
6. nearby analogous code.

---

# Execution Strategy

Work autonomously where possible.

If the environment supports parallel agents, workers, subprocesses, or independent contexts, use them when they materially improve coverage.

Do not require delegation.

A single capable session must still be able to perform the pass sequentially.

Good independent investigation areas may include:

- session lifecycle;
- entity replication;
- combat networking;
- inventory/equipment;
- loot/gathering;
- persistence;
- trade;
- late join;
- latency testing.

Serialize modifications to shared:

- session infrastructure;
- identity infrastructure;
- protocol definitions;
- persistence;
- inventory authority;
- currency authority;
- transaction systems;
- global replication.

Do not let independent workstreams invent contradictory authority models.

For high-risk areas such as:

- persistent inventory;
- currency;
- trading;
- session replacement;
- transactions;
- persistence races;
- protocol changes;

use deeper review and fresh-context challenge where the environment supports it.

---

# Multiplayer Priority Queue

## P0 — Catastrophic Multiplayer Failure

Examples:

- item duplication;
- currency duplication;
- item/currency loss;
- persistent-state corruption;
- trade duplication;
- stale save overwriting current data;
- authentication/session takeover bug;
- duplicate authoritative player state;
- catastrophic protocol failure.

Fix immediately.

## P1 — Major Multiplayer Failure

Examples:

- reconnect regularly fails;
- ghost players remain;
- duplicate entities appear;
- combat desynchronizes;
- shared resources can be claimed twice;
- inventory state diverges;
- late join receives wrong world state;
- old session remains authoritative;
- disconnect causes important state loss.

Prioritize heavily.

## P2 — Significant Robustness Problem

Examples:

- stale UI/client state;
- temporary entity disagreement;
- delayed cleanup;
- minor duplicate presentation events;
- latency exposes inconsistent behavior;
- recovery requires unnecessary relog.

Fix where evidence supports it.

## P3 — Finishing Robustness

Examples:

- minor replicated-state delay;
- small session cleanup issue;
- low-impact ordering inconsistency;
- harmless duplicate visual event.

Handle after consequential correctness problems.

---

# Connection Lifecycle Attack

Test relevant:

- initial connection;
- authentication;
- join;
- normal disconnect;
- unexpected disconnect;
- timeout;
- force close;
- rapid reconnect;
- repeated connect/disconnect;
- server restart;
- network interruption.

For each ask:

- What state is created?
- Who owns it?
- What is cleaned up?
- What persists?
- What survives reconnect?
- What can complete after disconnect?

Look for:

- ghost sessions;
- duplicate players;
- leaked entities;
- stale ownership;
- repeated initialization;
- incomplete cleanup.

---

# Session Identity Pass

Trace relationships between:

- account;
- character;
- connection;
- session;
- player entity.

Determine what uniquely identifies each.

Avoid relying on an unstable identifier for long-lived authoritative state.

Examples of dangerous assumptions:

- connection ID equals account ID;
- entity ID survives reconnect;
- old connection remains the current owner;
- character load from session A is valid for session B.

Make ownership explicit.

---

# Duplicate Login Attack

If the same account can attempt multiple concurrent logins, establish intended behavior.

Possibilities include:

- reject second login;
- replace old session;
- allow multiple characters/sessions;
- platform-specific restriction.

Follow project intent.

Test timing such as:

1. session A active;
2. session B connects;
3. A begins disconnect cleanup;
4. B becomes current;
5. delayed callback from A finishes.

Ensure old session A cannot:

- remove B's entity;
- overwrite B's save;
- invalidate B's session;
- mutate current inventory.

---

# Reconnect Attack

Test:

- immediate reconnect;
- reconnect during disconnect cleanup;
- reconnect while old save is pending;
- reconnect after timeout;
- reconnect after server restart where supported;
- repeated reconnect loops.

Ensure reconnect does not create:

- duplicate player entities;
- duplicate inventories;
- duplicate subscriptions;
- stale world references;
- lost state;
- old-session authority.

---

# Session Generation / Epoch Thinking

Where session replacement races exist, consider whether the project benefits from explicitly identifying the current session generation or equivalent.

The principle is:

> **work belonging to an old session must not mutate a newer session.**

Do not add session-version infrastructure unless the existing lifecycle actually needs it.

Use the simplest mechanism compatible with current architecture.

---

# Disconnect Cleanup Attack

When a player disconnects, inspect cleanup of:

- player entity;
- combat target;
- active interactions;
- gathering;
- trade;
- party/group state;
- subscriptions;
- timers;
- locks;
- ownership;
- session references;
- pending network operations.

Cleanup should be:

- complete;
- safe to repeat;
- safe if the entity is already gone;
- safe if reconnect has already occurred.

Avoid cleanup assuming it always runs exactly once.

---

# Entity Lifecycle Pass

Trace:

> **spawn → replicate → update → despawn → cleanup**

Test:

- rapid spawn/despawn;
- despawn before first replication;
- update after despawn;
- target destroyed during action;
- client receives stale update;
- server removes entity while callback remains pending;
- same logical player receives a new entity after reconnect.

Look for:

- phantom entities;
- stale references;
- duplicate spawn;
- updates applied to replaced entities;
- delayed despawn corrupting new state.

---

# Entity Identity Safety

If IDs can be reused, ensure stale messages cannot incorrectly affect a newer entity using the same identifier.

Possible protections may include:

- generation/version;
- sufficiently unique IDs;
- authoritative existence checks;
- sequencing.

Do not build complex generation systems where IDs are already globally unique.

---

# Spawn / Despawn Churn Test

Repeatedly create and remove relevant entities.

Examples:

- players;
- enemies;
- NPCs;
- loot;
- projectiles;
- world objects.

Watch for:

- replicated duplicates;
- memory/lifecycle leaks;
- stale dictionaries;
- stale targets;
- callbacks after destruction;
- ghost collision or interaction.

---

# Late Join Pass

A new client must receive the **current authoritative state**, not merely future updates.

Test joining after:

- enemies have died;
- loot has been claimed;
- doors have changed state;
- resources have depleted;
- players changed equipment;
- combat is active;
- status effects exist;
- world state has changed.

Ask:

> **If the new client never witnessed the history, can it still construct the correct present?**

Late join should not depend on having observed prior deltas.

---

# Snapshot Versus Delta Review

Where replication uses deltas/events, determine how a late joiner obtains baseline state.

Ensure:

- initial state is complete enough;
- delta ordering is safe;
- state arriving before entity creation is handled;
- late events do not resurrect old state;
- initialization does not overwrite newer updates.

Do not solve every replication problem by sending the entire world every frame.

---

# Replication Authority Pass

For each replicated value ask:

- Who writes it?
- Who reads it?
- Which side is authoritative?
- Is it snapshot state or transient event?
- What happens when packets are delayed?
- What happens when updates arrive out of order?
- Does stale data overwrite newer state?

Avoid treating replicated client copies as authoritative server state.

---

# Sequence / Version Awareness

For state where old updates can arrive after newer ones, determine whether the protocol already guarantees ordering.

If it does:

- use that guarantee.

If it does not:

- consider sequence/version checks where materially required.

Do not add ordering metadata everywhere reflexively.

Use it only where stale application is realistically possible.

---

# Movement Synchronization Pass

Where movement is networked, inspect:

- authority;
- input transmission;
- position replication;
- interpolation;
- prediction;
- reconciliation;
- teleportation;
- correction;
- entity spawn position;
- reconnect position.

Look for:

- rubber-banding caused by incorrect authority;
- stale correction;
- remote jitter;
- clients diverging permanently;
- impossible movement accepted authoritatively;
- interpolation continuing after despawn.

Do not redesign the movement networking model merely for cosmetic improvement.

Fix correctness and major robustness problems.

---

# Combat Synchronization Pass

Trace:

> **intent → validation → attack commitment → hit resolution → authoritative damage → death → reward → replication**

Test:

- two attackers hitting simultaneously;
- target dies during another pending attack;
- attacker disconnects;
- target disconnects;
- target despawns;
- repeated attack request;
- simultaneous lethal damage;
- latency around cooldown expiration.

Ensure:

- damage is not applied twice accidentally;
- dead entities do not resolve stale attacks unless explicitly intended;
- death occurs once authoritatively;
- rewards occur exactly once;
- all clients converge on outcome.

---

# Simultaneous Death Attack

Test scenarios where:

- two players kill each other;
- several players land lethal hits;
- healing and lethal damage occur near-simultaneously;
- death and disconnect overlap.

Look for:

- duplicate death callbacks;
- repeated loot;
- repeated XP;
- inconsistent kill credit;
- clients disagreeing on alive/dead state.

---

# Cooldown Authority

If cooldowns affect multiplayer actions, establish who owns them.

Avoid:

- client deciding cooldown completion authoritatively;
- reconnect resetting cooldown unintentionally;
- duplicate requests bypassing cooldown;
- server/client cooldown values diverging materially.

Client presentation may predict.

Authoritative acceptance should follow established server rules.

---

# Inventory Authority Pass

Treat authoritative inventory as high risk.

Trace operations such as:

- add;
- remove;
- move;
- split;
- merge;
- equip;
- unequip;
- drop;
- loot;
- craft;
- trade;
- purchase;
- reward.

For each ask:

> **Can two requests operate on the same item/state concurrently?**

Protect invariants such as:

- item ownership is unambiguous;
- quantities do not become negative;
- items are not created twice;
- items are not lost between partial operations;
- client disagreement does not become authority.

---

# Equipment Concurrency Pass

Test:

- equip while item is removed;
- rapid equip/unequip;
- swap while combat changes stats;
- inventory full during unequip;
- duplicate equip requests;
- disconnect during equipment mutation.

Ensure:

- bonuses apply once;
- equipment and inventory ownership agree;
- replicated appearance matches authoritative equipment.

---

# Currency Authority Pass

Treat currency as high-risk authoritative state.

Test:

- simultaneous purchases;
- repeated purchase requests;
- refunds;
- rewards;
- trades;
- concurrent deductions;
- reconnect during mutation.

Ensure two operations cannot both validate against the same old balance and overspend or duplicate funds.

Use appropriate atomic/transactional semantics where required.

---

# Loot Concurrency Attack

For exclusive loot or pickup:

1. two players attempt pickup;
2. both requests arrive close together;
3. only one outcome should succeed where ownership is exclusive.

Ensure:

- item is not granted twice;
- loser receives correct result;
- world entity despawns once;
- late replicas converge.

Do not rely solely on both clients observing the loot disappear.

The server must resolve exclusivity.

---

# Shared Resource Concurrency

If several players can interact with shared resources, test:

- final resource unit claimed simultaneously;
- depletion during another pending action;
- respawn while old interaction completes;
- player disconnect during resource mutation.

Ensure resource state remains authoritative and rewards follow intended semantics.

---

# Crafting Concurrency

If crafting mutates persistent inventory, test:

- repeated craft request;
- concurrent inventory mutation;
- disconnect during craft;
- reconnect while completion is pending;
- resource availability changing before commit.

Ensure:

- ingredients are consumed once;
- output is created once;
- partial failure does not duplicate or destroy state unexpectedly.

---

# Reward Idempotency

For consequential rewards such as:

- quest completion;
- achievement reward;
- level reward;
- loot;
- daily reward;
- boss reward;

ask:

> **What uniquely identifies this reward occurrence?**

A retried or duplicated message must not grant it repeatedly unless repeated granting is intentional.

---

# Trade / Transaction Pass

Treat player-to-player trade or equivalent asset exchange as high risk.

Test:

- simultaneous confirmation;
- one side changes offer late;
- disconnect during confirmation;
- one inventory becomes full;
- repeated network request;
- retry after timeout;
- one item disappears before commit;
- session replacement during trade.

Protect:

> **nothing duplicated, nothing lost, nothing partially transferred**

Where supported by architecture, use appropriate atomic transaction boundaries.

Do not simulate atomicity only through client UI locking.

---

# Partial Transaction Failure

For multi-step authoritative mutations ask:

> **What if step 2 fails after step 1 succeeds?**

Examples:

- remove currency then grant item;
- remove item then credit recipient;
- consume ingredients then create output;
- deduct fee then complete transfer.

Use:

- atomic operations;
- database transaction;
- reversible staged state;
- validated commit;

where actually required.

Avoid elaborate transaction frameworks for operations already atomic by design.

---

# Persistence Race Hunt

Treat persistence as high risk.

Search for scenarios such as:

- periodic save overlaps logout save;
- logout save overlaps reconnect;
- old session save finishes after new session save;
- inventory update overlaps character snapshot;
- server shutdown overlaps normal persistence;
- retry repeats side effects;
- DB write reads stale state then overwrites newer state.

Ask:

> **Can an older snapshot overwrite newer truth?**

Fix confirmed stale-write paths.

---

# Stale Snapshot Overwrite

A dangerous pattern is:

1. session A loads state;
2. session A mutates local copy;
3. session B later becomes authoritative;
4. session B writes newer data;
5. delayed save from A overwrites it.

Prevent outdated session/state from replacing newer data.

Possible mechanisms may include:

- session ownership checks;
- version numbers;
- optimistic concurrency;
- conditional database updates;
- centralized authoritative save serialization.

Use what best matches existing architecture.

---

# Save Ordering

If multiple saves may be in flight, determine what guarantees ordering.

Do not assume asynchronous writes complete in request order.

If ordering matters, ensure older writes cannot become final after newer writes.

---

# Persistence Idempotency

If persistence operations can retry, distinguish:

- setting current state;
- appending side effects;
- granting rewards;
- recording transactions.

A repeated state snapshot may be naturally idempotent.

A repeated reward insertion may not be.

Handle accordingly.

---

# Database Transaction Review

For persistent multiplayer operations involving several related mutations, inspect transaction boundaries.

High-risk examples:

- trade;
- purchase;
- currency transfer;
- reward claim;
- item conversion.

Avoid:

- partial commits;
- inconsistent ownership;
- double processing under retry.

Do not wrap unrelated operations in giant transactions merely for theoretical safety.

---

# Async Callback Attack

For each meaningful asynchronous operation, invalidate its assumptions while it is pending.

Examples:

- disconnect;
- reconnect;
- change character;
- target dies;
- target despawns;
- scene/zone changes;
- request is superseded;
- session is replaced.

When callback returns verify:

- requester is still current;
- session still matches;
- target still exists;
- expected state still applies;
- result has not already been committed.

---

# Timeout Behavior

Test operations that time out.

Ask:

- Did the server actually process the request?
- Will the client retry?
- Can retry duplicate the result?
- Is eventual response ignored safely?
- Does timeout leave a locked state?

Timeout does not necessarily mean:

> **the operation did not happen.**

Design retry behavior accordingly.

---

# Retry Semantics

Classify network actions approximately as:

## Naturally Safe to Retry

Examples may include:

- fetch current state;
- request snapshot.

## Consequential Mutation

Examples:

- purchase;
- trade;
- reward;
- crafting completion;
- currency transfer.

Consequential retries require special care.

Do not blindly retry side-effecting operations.

---

# Latency Attack

Where practical test representative:

- added latency;
- asymmetric latency;
- jitter;
- delayed server response;
- slow database response;
- packet delay.

Look for assumptions such as:

- action always completes before next input;
- target still exists;
- UI state remains valid;
- client will not send another request;
- session will not change.

Do not fix latency bugs using arbitrary sleep delays.

Correct the underlying state assumptions.

---

# Packet Loss / Message Failure

Where the networking model and available tooling support it, test:

- dropped non-critical updates;
- delayed messages;
- retransmission;
- request failure;
- duplicate delivery.

Do not assume transport behavior it does not provide.

First understand whether the transport guarantees:

- reliability;
- ordering;
- deduplication.

Then test within those real constraints.

---

# Rapid Input Under Latency

Combine rapid input with delayed responses.

Examples:

- rapidly switch targets;
- purchase several times;
- loot repeatedly;
- equip/unequip;
- cast abilities;
- move while action is pending.

Look for:

- duplicate requests;
- stale UI decisions;
- reordered state;
- client displaying impossible pending state;
- server accepting mutations that should no longer be valid.

---

# Concurrent Player Attack

For shared state, deliberately trigger simultaneous actions from multiple clients.

Examples:

- loot same object;
- gather same resource;
- buy final stock item;
- attack same target;
- interact with same exclusive object;
- trade;
- claim shared objective.

The authority must resolve the outcome consistently.

---

# Race Condition Standard

Do not call something a race merely because code is asynchronous.

Require an actual shared-state or ordering hazard.

For each confirmed race identify:

- actors/tasks involved;
- shared state;
- possible ordering;
- violated invariant;
- current synchronization guarantee;
- smallest robust fix.

Avoid adding locks indiscriminately.

Authority, single-threaded execution, transactions, unique constraints, or conditional state transitions may already provide safer and simpler guarantees.

---

# Locking Policy

Do not add locks reflexively.

Before adding a lock ask:

- Is this state already confined to one authoritative thread?
- Can an atomic database operation solve the problem?
- Can ownership eliminate the race?
- Can a state transition make invalid double execution impossible?
- Can idempotency solve retry duplication?

Use locks only where actual concurrency requires them.

Avoid:

- deadlock risk;
- unnecessary contention;
- giant lock scopes;
- cross-system lock ordering complexity.

---

# Session Cleanup Versus Persistence

Be careful with disconnect flows such as:

> **disconnect → save → destroy session**

Determine whether cleanup waits for persistence and whether reconnect may happen during that interval.

Ensure reconnect does not inherit ambiguous state.

Possible intended policies include:

- old session remains authoritative until save finishes;
- new session supersedes immediately and invalidates old save;
- saves are serialized centrally.

Use the architecture's intended ownership.

Make it explicit.

---

# Server Restart Pass

Where relevant test:

- connected players during shutdown;
- save flush;
- session cleanup;
- restart;
- reconnect;
- persisted world state;
- stale client assumptions.

Do not redesign server orchestration.

Fix release-relevant robustness problems.

---

# Version Mismatch

If client/server versions can differ, ensure behavior is intentional.

Avoid:

- decoding incompatible messages;
- silent state corruption;
- undefined protocol behavior.

A clear rejection may be preferable to partial compatibility.

Preserve existing supported compatibility policy.

---

# Serialization Pass

Inspect network serialization for consequential state.

Look for:

- missing fields;
- stale defaults;
- optional/versioned fields;
- integer overflow;
- incorrect enum mapping;
- identity loss;
- inconsistent server/client representation.

Do not replace the protocol format without clear need.

---

# Message Handler Validation

For important server-side handlers ensure they validate appropriate:

- session ownership;
- entity ownership;
- target validity;
- range;
- cooldown;
- required resources;
- item ownership;
- current state.

Do not duplicate every gameplay rule in every handler.

Prefer calling authoritative gameplay logic where existing architecture supports it.

---

# Client-Supplied Entity IDs

Where clients submit:

- target IDs;
- item IDs;
- entity IDs;
- resource IDs;

validate that the current player is actually allowed to operate on that entity.

Do not assume knowledge of an ID grants permission.

---

# Zone / Area Transition Pass

If multiplayer players transition between areas, test:

- disconnect during transition;
- reconnect during transition;
- old-zone despawn arriving late;
- new-zone spawn occurring early;
- pending actions crossing zone boundary;
- persistence during transition.

Ensure players cannot exist authoritatively in contradictory zones.

---

# Party / Group State

If parties, guilds, teams, or groups exist, test relevant:

- disconnect;
- reconnect;
- leader disconnect;
- duplicate membership;
- session replacement;
- stale invitations;
- entity despawn.

Only inspect systems that actually exist.

---

# Chat / Social State

If networked social systems exist, inspect basic robustness such as:

- duplicate messages caused by retry;
- stale session routing;
- messages sent after disconnect;
- incorrect identity mapping.

Do not turn this into moderation or social-feature redesign.

---

# Authority Matrix

Build a concise internal authority matrix where useful.

Possible columns:

- system;
- client intent;
- server validation;
- authoritative state;
- persistence;
- replication;
- reconnect behavior.

Use it to expose ambiguity.

Do not spend the task polishing documentation.

---

# Invariant-Driven Testing

For each major multiplayer system establish invariants.

Examples:

## Inventory

- every authoritative item has one valid owner/location;
- item quantities remain valid;
- operation occurs intended number of times.

## Currency

- balance cannot be spent twice;
- authoritative mutations cannot unintentionally duplicate funds.

## Sessions

- only intended current session can mutate player state;
- old session cannot overwrite new session.

## Loot

- exclusive reward can only be claimed the intended number of times.

## Combat

- death resolves once;
- dead targets do not receive unintended stale attacks;
- reward attribution follows authoritative outcome.

## Replication

- all clients eventually converge on authoritative current state.

Attack these invariants.

---

# Pattern-Based Bug Hunting

When one multiplayer defect is found, search analogous paths.

Examples:

If one async handler applies stale results:

> inspect other async handlers.

If one reward request is not duplicate-safe:

> inspect other reward endpoints.

If one session cleanup uses an unsafe identity:

> inspect all session cleanup.

If one inventory operation has a race:

> inspect other multi-step inventory mutations.

Do not blindly apply the same fix everywhere.

Search for the repeated faulty assumption.

---

# Regression Test Creation

For meaningful bugs, add focused tests where practical.

Potential forms include:

- server unit tests;
- integration tests;
- multi-client tests;
- database concurrency tests;
- session lifecycle tests;
- duplicate-request tests;
- replication tests.

A useful regression test should:

1. reproduce the original failure;
2. fail before the fix;
3. pass after the fix;
4. remain deterministic enough to be useful;
5. avoid relying solely on fragile timing sleeps.

Prefer explicit synchronization, test hooks, or controllable scheduling over random timing.

---

# Bug-Fix Standard

For every meaningful multiplayer defect:

1. reproduce where practical;
2. identify violated invariant;
3. identify exact authority/state ownership;
4. determine root cause;
5. implement the smallest robust fix;
6. rerun original reproduction;
7. validate normal path;
8. test duplicate request where relevant;
9. test late/stale completion where relevant;
10. test disconnect/reconnect where relevant;
11. test concurrent players where relevant;
12. search analogous code;
13. add regression coverage where practical.

Avoid symptom patches such as:

- arbitrary delays;
- random retries;
- blanket input disabling;
- unexplained lock flags;
- redundant full-state broadcasts.

Fix ownership, lifecycle, ordering, idempotency, or transaction semantics instead.

---

# Work in Networking Waves

Do not change every multiplayer subsystem simultaneously.

## Wave A — Authority and Sessions

Inspect:

- identity;
- current session;
- connection lifecycle;
- duplicate login;
- disconnect;
- reconnect.

Fix major ownership ambiguity.

Validate.

## Wave B — Replication and Entity Lifecycle

Inspect:

- spawn;
- despawn;
- late join;
- stale updates;
- entity replacement;
- world-state synchronization.

Validate.

## Wave C — Consequential Gameplay

Attack:

- combat;
- inventory;
- equipment;
- loot;
- gathering;
- crafting;
- rewards.

Validate duplicate and concurrent execution.

## Wave D — Transactions and Persistence

Attack:

- currency;
- trades;
- purchases;
- DB operations;
- save ordering;
- reconnect/save races;
- stale writes.

Treat as high risk.

Validate deeply.

## Wave E — Latency and Recovery

Test:

- latency;
- timeouts;
- retries;
- jitter;
- disconnect timing;
- rapid input while pending.

Validate recovery.

## Wave F — Long Tail

Search for:

- stale callbacks;
- minor replication disagreement;
- session churn;
- unusual ordering;
- repeated connect/disconnect;
- server restart edge cases.

---

# Reassess After Every Wave

Ask:

- Who still has ambiguous authority?
- Which consequential action can still happen twice?
- Which callback can arrive after its owner is gone?
- Can an old session mutate current state?
- Can two players claim one exclusive result?
- Can a stale snapshot overwrite newer data?
- Does late join reconstruct current truth?
- Can an entity receive updates after despawn?
- Can reconnect produce duplicates?
- Did a fix create unnecessary locking or latency?
- Did normal multiplayer responsiveness regress?

Reprioritize.

---

# Productive Networking Loop

Do not stop after the first severe networking fix.

Multiplayer defects often reveal deeper shared assumptions.

Examples:

- reconnect fix reveals persistence race;
- persistence fix reveals session ambiguity;
- session fix reveals stale entity ownership;
- loot fix reveals similar reward duplication;
- late-join fix exposes incomplete replication baseline.

Continue:

> **trace → attack → reproduce → diagnose → implement → validate → attack again**

while meaningful, safely actionable multiplayer issues remain.

Do not manufacture theoretical races merely to continue working.

Stop when remaining concerns are:

- unsupported by evidence;
- low impact;
- dependent on unavailable production infrastructure;
- intentional behavior;
- outside scope.

---

# Independent High-Risk Review

Near completion, use fresh context where practical to challenge significant changes involving:

- inventory;
- currency;
- trades;
- database transactions;
- persistence;
- session replacement;
- authentication;
- global replication;
- protocol changes.

Do not ask:

> **Does this look correct?**

Ask:

> **How could this still execute twice?**

> **How could stale state still win?**

> **How could partial failure lose or duplicate value?**

> **What happens if reconnect occurs at the worst possible point?**

> **What if two players trigger this simultaneously?**

> **What if the callback arrives after ownership changed?**

Repair justified findings.

---

# Fresh Multiplayer Destruction Review

Near completion, perform a fresh multiplayer attack pass.

Focus independently on:

## Session Lifecycle

- duplicate login;
- reconnect;
- disconnect cleanup;
- stale-session authority.

## Entity Lifecycle

- spawn/despawn;
- target invalidation;
- late updates;
- late join.

## Consequential Actions

- loot;
- inventory;
- rewards;
- crafting;
- combat.

## Transactions

- purchases;
- currency;
- trades;
- persistence.

## Network Failure

- latency;
- timeout;
- retry;
- stale completion.

The purpose is to find failures the implementation process became accustomed to overlooking.

---

# "What Happens Twice?" Review

For every consequential network action ask:

> **What happens if this request executes twice?**

Explicitly review:

- reward claims;
- purchases;
- crafting;
- loot;
- trade;
- inventory transfers;
- equipment;
- combat actions;
- persistence writes.

If duplicate execution creates material harm, make the operation robust.

---

# "What Happens Late?" Review

For every delayed/asynchronous operation ask:

> **What happens if this completes much later than expected?**

Especially after:

- disconnect;
- reconnect;
- target death;
- zone transition;
- new request;
- newer save.

Old results must not blindly become current truth.

---

# "What Happens If It Disappears?" Review

For target-based operations ask:

> **What happens if the player, target, item, world object, entity, session, or zone disappears before completion?**

Validate lifecycle before applying delayed results.

---

# "What Does a New Client Believe?" Review

For major replicated systems ask:

> **What does a client joining right now believe the world looks like?**

Compare that against current server truth.

Test changed:

- world objects;
- players;
- equipment;
- combat state;
- resources;
- doors;
- loot;
- relevant progression/world state.

---

# "Can Old Truth Overwrite New Truth?" Review

Explicitly inspect:

- session saves;
- DB writes;
- snapshots;
- replication messages;
- reconnect state;
- caches.

Ask:

> **Can an older state version finish later and overwrite newer authoritative state?**

Treat confirmed cases as high priority.

---

# Anti-Overengineering Review

Before completion inspect whether robustness fixes added unnecessary complexity.

Ask:

- Did we add locks where authority already serialized work?
- Did we add sequence IDs where transport already guarantees ordering?
- Did we build generalized infrastructure for one small bug?
- Did we replace efficient deltas with full-state spam?
- Did we add retries that can duplicate side effects?
- Did we create unnecessary synchronization latency?
- Did we add multiple sources of truth?
- Did we complicate protocol without measurable need?

Simplify unjustified changes.

Robustness does not require maximal machinery.

---

# Responsiveness Regression Review

Network correctness must not make multiplayer unnecessarily sluggish.

After fixes verify:

- normal movement remains responsive;
- combat remains responsive;
- inventory actions remain usable;
- UI does not wait on unnecessary round trips;
- prediction remains safe where already used;
- server validation does not create needless serialization bottlenecks.

Do not trade one correctness problem for widespread avoidable latency.

---

# Performance Awareness

This is not primarily a network optimization pass.

However, avoid robustness changes that cause:

- full-world replication every update;
- duplicate database writes;
- excessive locks;
- request serialization across unrelated players;
- repeated full inventory snapshots without need;
- unbounded message queues;
- unnecessary retries.

Prefer correctness with reasonable scalability.

---

# Final Cross-System Multiplayer Review

Before completion inspect for:

- ambiguous authority;
- stale sessions;
- duplicate authoritative entities;
- stale callbacks;
- repeated rewards;
- inventory/currency duplication;
- persistence overwrite races;
- invalid late-join state;
- updates after despawn;
- incomplete disconnect cleanup;
- transaction partial failure;
- protocol disagreement;
- regression in normal gameplay.

Fix justified issues.

Run final validation.

---

# Completion Standard

The multiplayer robustness pass is complete when, to the degree available testing can establish:

1. important authoritative state has clear ownership;
2. major client requests are validated appropriately;
3. consequential operations resist accidental duplicate execution;
4. connect/disconnect lifecycle is stable;
5. reconnect behavior is stable;
6. old sessions cannot overwrite or mutate newer session state;
7. duplicate-login behavior follows intended policy;
8. entity spawn/despawn lifecycle is robust;
9. stale entity updates do not corrupt current state;
10. late joiners receive current authoritative state;
11. important replicated state converges correctly;
12. concurrent combat resolves correctly;
13. shared resources resolve concurrent claims correctly;
14. inventory authority remains consistent;
15. currency authority remains consistent;
16. important transaction paths avoid partial completion;
17. loot/reward duplication paths discovered are fixed;
18. persistence races discovered are fixed;
19. stale-save overwrite paths discovered are fixed;
20. delayed async callbacks validate current ownership/state where required;
21. representative latency/failure behavior has been tested where practical;
22. high-risk fixes received additional scrutiny;
23. no known major multiplayer defect discovered during the pass remains unfixed without an explicit blocker;
24. normal multiplayer behavior remains responsive;
25. networking architecture remains recognizably the same rather than being unnecessarily redesigned;
26. remaining risks require unavailable infrastructure, are speculative, low-impact, intentional, or better suited to another specialized pass.

The objective is not:

> **make networking infinitely defensive**

The objective is:

> **make the existing multiplayer architecture robust against realistic latency, concurrency, disconnects, stale state, duplicate requests, lifecycle changes, and asynchronous execution.**

---

# Final Report

When complete, provide a concise multiplayer engineering report.

## 1. Overall Result

Summarize the largest improvements to multiplayer robustness.

## 2. Major Networking Problems Fixed

For each major issue include concise:

- **System**
- **Failure**
- **Root cause**
- **Fix**
- **Impact**

## 3. Connection / Session / Reconnect

Summarize meaningful work involving:

- login;
- sessions;
- disconnect;
- reconnect;
- duplicate sessions;
- cleanup.

## 4. Replication / Entity Lifecycle

Summarize meaningful improvements to:

- spawn/despawn;
- stale updates;
- replication;
- late join;
- target lifecycle.

## 5. Concurrency / Transactions

Summarize relevant:

- inventory;
- currency;
- loot;
- gathering;
- crafting;
- combat;
- trading;
- other shared state.

Include only systems that exist.

## 6. Persistence / Async Safety

Summarize:

- stale writes;
- save ordering;
- reconnect/save races;
- callback invalidation;
- database transaction changes.

## 7. Latency and Failure Testing

State which relevant scenarios were actually tested:

- latency;
- jitter;
- timeout;
- retry;
- duplicate request;
- disconnect;
- reconnect.

Do not imply tests occurred when they did not.

## 8. Validation

State exactly what was performed, including relevant:

- automated tests;
- multi-client tests;
- server tests;
- persistence tests;
- duplicate-request tests;
- concurrency tests;
- late-join tests;
- reconnect tests;
- stress/repetition tests.

## 9. Deliberately Unchanged

Describe noteworthy behavior preserved because:

- it is intentional;
- protocol compatibility matters;
- evidence was insufficient;
- architecture already provides the required guarantee;
- changing it would amount to redesign;
- necessary production infrastructure was unavailable.

## 10. Remaining Risks

List only meaningful unresolved multiplayer risks.

For each include:

- **Risk**
- **Severity**
- **Why unresolved**
- **Potential impact**
- **Recommended next action**

Do not pad this section with theoretical races unsupported by evidence.

---

# Final Directive

**Think like the multiplayer engineer who has to explain every duplicated item, ghost player, stale save, desync, or broken reconnect after launch.**

Do not assume:

- requests happen once;
- responses arrive quickly;
- callbacks finish in order;
- clients remain connected;
- targets remain alive;
- entities remain spawned;
- old sessions disappear immediately;
- database writes finish in order;
- retries are harmless;
- two players will not act simultaneously.

Repeatedly ask:

> **Who owns this truth?**

> **What happens if this occurs twice?**

> **What happens if it arrives late?**

> **What happens if the player, target, session, or entity disappears?**

> **Can an old session overwrite a new one?**

> **Can two players both claim one exclusive result?**

> **What does a client joining right now believe?**

> **Can every client eventually converge on authoritative current state?**

Continue:

> **trace → attack → reproduce → diagnose → implement → validate → attack again**

while meaningful multiplayer robustness problems remain.

Leave behind the **same multiplayer game**, but make its networking substantially safer, synchronized, recoverable, concurrency-safe, and resilient to real-world network behavior.