Net

From Kevin-Liu-01/CoTFly · View interactive version

Net is an AI agent skill from the GitHub repository Kevin-Liu-01/CoTFly. Implement the transport-independent multiplayer protocol, lobby, authority, snapshots, and network adapters.

How to use this skill

Skill file

claude-of-tanks / src/net

Purpose

Provide one authoritative match path for campaign, LAN, private, and ranked

play without importing Three.js rendering or DOM state.

Mental model & key files

and untrusted input validation.

permissions, host migration, round state, and start policy.

broadcast, and the lossless lobby-to-match channel handoff.

identity, share-link parsing, and deployment-aware signaling URL policy.

reconnect backoff, room-seat resume, and RTC-session epoch rotation.

refresh while preserving immediate control edges.

behind explicit multiplayer intent; solo boot must not import it.

explicit snapshot acknowledgements, per-peer deltas, and periodic keyframes.

the same bounded transport contract.

correction. Its reconciliation stages authority seeding, input

acknowledgement/replay, error accounting, bounded presentation correction,

and terminal cleanup; it never owns combat or match results.

application, input cadence, snapshot barriers, and network diagnostics.

the identity-bound idempotent READY retry lease.

presentation, selection commands, readiness, and rematch admission.

optional chunks, and warms new roster builders. It reasserts canonical map

intent on waiting-room packets; the world coordinator owns in-flight/cache

deduplication and retry admission, not a permanent map-ID latch. Garage

browsing must preserve joined-room preparation, including while Not Ready.

ranked launch policy, including cold-loader presentation and terminal cleanup.

opaque loader through parallel module/world/transport acquisition, hidden

roster preparation, initial authority, warmup, atomic visual activation,

black-frame validation, reveal, and then all-peer readiness.

out of Garage/solo boot and retries failed intent transfers.

into live player or spectator presentation: world/HUD/FX/result reset, phase

publication, camera ownership, and Garage shutdown.

edge; transport replacement remains below it.

dedicatedClient.ts owns authenticated WebSocket handoff and reconnect.

rtcIceLease.ts owns expiring TURN generations;

privateMatchHandoff.ts is the strict lobby-to-match boundary: it

deterministically fills open team slots with bots

and releases those same channels to match authority.

Patterns and invariants

live input use the unordered zero-retransmit state lane. Fire/consumable

edges repeat until acknowledged and authority deduplicates them. WebSocket

snapshots and input coalesce under backpressure so stale state cannot

consume control headroom.

generation. Duplicate descriptions must be idempotent; never overlap offers

merely because a fresh browser is slow.

is presentation-only: horizontal hull motion, terrain support/tilt, and live

turret aim use separate bounded decay channels. Contacts may extend smoothing

but must never change authority, collision, or ballistic state. Keep the

collision adapter stable for the predictor lifetime; do not allocate a new

closure for every replayed fixed step.

and warmup; do not publish battle phase or camera state piecemeal from

main.ts. Send READY only after the verified battlefield frame and awaited

loader fade. Authority still holds gameplay until every peer is ready and

its countdown expires; visible loading peers show WAITING FOR COMMANDERS.

paint. Settle in-flight world activation before restoring Garage, without

waiting on an unrelated stalled transport.

collision before preparing authority. Guest module, world and connection work

stays concurrent; a retained transport does not remove the host dependency.

draining; the watchdog itself owns compatibility fallback. Preserve the

cancellation checkpoint before reporting graphics failure. A null lobby

callback is also used for successful match handoff, so it must not blindly

cancel the room's in-flight map build.

snapshot are ready. Keep that order in networkBattlePresentationRuntime.ts;

failed unpublished bridges are disposed before the launcher handles cleanup.

Verification

Run node src/net/browserInputRuntime.selftest.mjs, node src/net/net.selftest.mjs,

node src/net/privateMatchHandoff.selftest.mjs, then npm test and

npm run build. Network adapters additionally require browser-pair proof.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.