|
| 1 | +# BUILD_PR_LEVEL_12_3_REPLICATION_CLIENT_APPLICATION |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Implement the Level 12.3 client replication and authoritative application layer on top of the Level 12.1/12.2 network foundation with no engine API breakage. |
| 5 | + |
| 6 | +## Scope |
| 7 | +Primary target files: |
| 8 | +- `src/engine/network/ReplicationMessageContract.js` |
| 9 | +- `src/engine/network/ClientReplicationApplicationLayer.js` |
| 10 | +- `src/engine/network/ClientReconciliationStrategy.js` |
| 11 | +- `src/engine/network/index.js` |
| 12 | +- `tests/final/MultiplayerNetworkingStack.test.mjs` |
| 13 | +- `docs/pr/LEVEL_12_3_REPLICATION_CLIENT_APPLICATION_CONTRACTS.md` |
| 14 | + |
| 15 | +Allowed nearby reads: |
| 16 | +- `src/engine/network/StateReplication.js` |
| 17 | +- `src/engine/network/AuthoritativeServerRuntime.js` |
| 18 | +- `src/engine/network/AuthoritativeInputIngestionContract.js` |
| 19 | +- `src/engine/network/HandshakeSimulator.js` |
| 20 | +- `docs/pr/LEVEL_12_1_REAL_NETWORK_FOUNDATION_CONTRACTS.md` |
| 21 | + |
| 22 | +## Required implementation |
| 23 | +- Define a replication message contract for server-to-client authoritative snapshots. |
| 24 | +- Implement a client-side application layer that: |
| 25 | + - accepts validated replication envelopes |
| 26 | + - applies authoritative snapshots into client-owned replicated state |
| 27 | + - rejects stale/out-of-order updates deterministically |
| 28 | +- Implement a reconciliation/update strategy for Level 12.3 without prediction/rollback: |
| 29 | + - authoritative-first apply |
| 30 | + - stale snapshot ignore rules |
| 31 | + - deterministic metadata updates (`lastAppliedTick`, `appliedSequence`) |
| 32 | +- Export new symbols additively from `src/engine/network/index.js` only. |
| 33 | +- Extend `tests/final/MultiplayerNetworkingStack.test.mjs` to validate: |
| 34 | + - replication envelope validation |
| 35 | + - client authoritative apply behavior |
| 36 | + - stale update rejection |
| 37 | + - existing handshake and server-runtime coverage still passing |
| 38 | + |
| 39 | +## Acceptance criteria |
| 40 | +- Replication contract documented and implemented. |
| 41 | +- Client application model defined and implemented. |
| 42 | +- Reconciliation rules established and enforced by tests. |
| 43 | +- No existing engine network exports are removed or renamed. |
| 44 | +- Existing Level 12.1 and 12.2 networking tests remain green. |
| 45 | + |
| 46 | +## Validation |
| 47 | +Run only: |
| 48 | +- `node --check src/engine/network/ReplicationMessageContract.js` |
| 49 | +- `node --check src/engine/network/ClientReplicationApplicationLayer.js` |
| 50 | +- `node --check src/engine/network/ClientReconciliationStrategy.js` |
| 51 | +- `node --input-type=module -e "import('./tests/final/MultiplayerNetworkingStack.test.mjs').then(async ({ run }) => { await run(); console.log('PASS MultiplayerNetworkingStack'); })"` |
| 52 | +- `node --input-type=module -e "import('./tests/production/EnginePublicBarrelImports.test.mjs').then(async ({ run }) => { await run(); console.log('PASS EnginePublicBarrelImports'); })"` |
| 53 | + |
| 54 | +## Non-goals |
| 55 | +- no client prediction implementation |
| 56 | +- no rollback implementation |
| 57 | +- no gameplay-specific coupling |
| 58 | +- no UI/debug expansion |
| 59 | +- no engine core API redesign |
| 60 | +- no repo-wide cleanup or unrelated refactor |
| 61 | + |
| 62 | +## Working tree rule |
| 63 | +If the tree is already dirty, ignore unrelated files and modify only the scoped files for this PR purpose. |
0 commit comments