# Mirror Tool — working journal ## Objective Rewrite the legacy Python TCP mirror manager in Rust, in this repository. Preserve the operator workflow, repair networking/failover bugs, integrate ForcAD accurately, and verify performance rather than promise physically impossible zero overhead. ## Binding user decisions - 2026-10-23: automatic routing means upstream selection inside the TCP proxy; no nftables/iptables or host route changes. - 2026-10-23 correction: preserve the original UI essentially literally: original CSS, layout, service columns, primary dots, replica row selection, robot switch, open-service icon, login and custom proxy name/port/optional direct-IP workflow. Only small improvements are authorized. The initial redesign was rejected; `web/*` now restores the original CSS/layout and interactions. - Preserve manual promotion semantics: the previous primary becomes a replica. Direct-IP entry must not require the operator to create a team first. - Keep the legacy directories unchanged. Never copy credentials from their config into this repository. ## Current state Rust modules implemented: config, store, engine, scoreboard, control, auth, web and CLI. Initial commit `4b01fb4`, branch `rewrite/rust`; no remote or deployment. The original UI is restored and assets are embedded locally. `docs/ui-report.md` describes preserved controls and small improvements; source-CSS parity and real browser checks confirm the restoration. Initial review R1-R5 are addressed: bounded shutdown with early quiesce, probe completion timestamps, Linux/mapped-address loop prevention, removal of rejected journal and restored previous-primary-as-replica. Transient accept recovery and absolute Engine.IO heartbeat are implemented. Final independent review found R6: request cancellation can abandon control transactions. Owned transactions now complete despite caller cancellation; five regressions and the original HTTP reproduction pass, and independent final review is approved. Fresh root verification after R6: 40 tests on macOS arm64, 41 on Orb Linux amd64; native fmt/Clippy and release binary/examples on both pass. Real Socket.IO-library ForcAD interoperability passes. Browser covers start, route/replica promotion, robot, custom IP, settings, logout, actual390px viewport, watchdog stale/recovery and byte-exact1MiB half-close. Loopback benchmark results are checked in under `docs/benchmarks/`; isolate saturated its bounded replica queue and explicitly disconnected replicas as designed (3 on macOS,4 on Linux across5 sessions). `docs/verification.md` is the acceptance record. ## Verification policy No completion/performance claims without fresh output. Use loopback and Orb Linux fixtures; never contact configured legacy game hosts. Test exact byte delivery, half-close, idle connections, live target changes, failure selection, replica overload, ForcAD reconnects, auth and persistence. Record limits explicitly. ## Milestone 1 - Async bounded engine, strict/isolate policies, replica response draining, hot target changes, RAII active accounting, acknowledged listener shutdown, bounded whole-engine drain. - Verified canonical ForcAD init/delta format; persistent Engine.IO 4 implementation with heartbeat and reconnect. - Typed config validation, same-filesystem fsync+rename state replacement, rollback on persistence failure, fresh-health deterministic selection with cooldown. - Cookie sessions (HttpOnly/SameSite), CSRF header, same-origin checks, login rate limiting, no secret persistence. HTTP binds locally by default; user supplies environment password. - Fresh engine evidence: 11 loopback tests passed (see docs/engine-report.md). Full integrated checks still pending. ## Final handoff - `docs/final-review.md`: independent approval; R1-R6 addressed, no remaining Critical/Important findings. - `docs/verification.md`: final gates, browser/ForcAD evidence and measured performance; raw benchmark JSON in `docs/benchmarks/`. - Generated, git-ignored `dist/` contains macOS arm64 and Linux amd64 binaries plus SHA256SUMS. Linux binary is glibc-linked from Orb Ubuntu; not an all-distribution static build. - Legacy tracked files remain unchanged and all12 match Downloads. Local-only rewrite; configure real teams/ports/scoreboard manually before deployment. No service installed.