Skip to content

Replay integration#123

Merged
wallstop merged 9 commits intomainfrom
dev/wallstop/session-hotjoin
Mar 29, 2026
Merged

Replay integration#123
wallstop merged 9 commits intomainfrom
dev/wallstop/session-hotjoin

Conversation

@wallstop
Copy link
Copy Markdown
Owner

Description

This PR delivers a full replay + telemetry feature set and hardens docs/wiki synchronization.

It solves two core gaps:

  1. No first-class way to record, serialize, and replay real P2P matches for deterministic debugging and validation.
  2. Wiki mirror generation and SYNC-header validation were easier to drift or fail with less-actionable diagnostics.

What changed

  • Added replay domain types and serialization:
    • Replay<I> and ReplayMetadata
    • Replay::to_bytes(), Replay::from_bytes(), Replay::validate(), Replay::total_frames()
  • Added replay playback session:
    • ReplaySession<T> implementing Session<T>
    • ReplaySession::new() and ReplaySession::new_with_validation()
    • Validation mode emits SaveGameState before AdvanceFrame and compares checksums frame-by-frame
  • Added replay recording support to P2P sessions:
    • SessionBuilder::with_recording(bool)
    • P2PSession::is_recording(), P2PSession::into_replay(), P2PSession::take_replay()
    • Recording now captures confirmed inputs and recorded checksums
  • Added session telemetry API and built-in collector:
    • SessionTelemetry trait
    • TelemetryEvent enum (Rollback, PredictionMiss, NetworkStatsUpdate, FrameAdvance)
    • CollectingTelemetry
    • SessionBuilder::with_telemetry(...)
    • P2P telemetry emission integrated in rollback, prediction miss, network stats polling, and frame advance paths
  • Added sync-layer helper used for telemetry:
    • players_with_incorrect_predictions(...)
  • Expanded public exports and docs:
    • Re-exports for replay/telemetry in lib.rs and prelude
    • New docs: replay and telemetry guides
    • Added MkDocs nav entries and wiki mirror pages/sidebar links
  • Hardened docs/wiki synchronization pipeline:
    • Added pre-commit sync-wiki hook before wiki consistency checks
    • sync-wiki.py now:
      • injects/normalizes reciprocal wiki SYNC headers
      • validates sidebar coverage before writing files
      • normalizes generated markdown EOF/newline format deterministically
    • check-sync-headers.py now reports case-mismatch hints and remediation guidance
    • Added/expanded script tests for sync behavior and diagnostics
  • Added .gitignore entries for local pre-commit/pre-push log artifacts

Breaking change

  • Added FortressEvent::ReplayDesync { frame, expected_checksum, actual_checksum }.
  • Because FortressEvent is not #[non_exhaustive], downstream exhaustive match statements must add a branch for ReplayDesync.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation (changes to documentation only)
  • ♻️ Refactor (code change that neither fixes a bug nor adds a feature)
  • 🧪 Test (adding or updating tests)
  • 🔧 CI/Build (changes to CI configuration or build process)

Checklist

Required

  • I have read the CONTRIBUTING guide
  • I have followed the zero-panic policy:
    • No unwrap() in production code
    • No expect() in production code
    • No panic!() or todo!()
    • All fallible operations return Result
  • I have added tests that prove my fix is effective or my feature works
  • I have run cargo fmt && cargo clippy --all-targets --features tokio,json with no warnings
  • I have run cargo nextest run and all tests pass

If Applicable

  • I have updated the documentation accordingly
  • I have added an entry to CHANGELOG.md for user-facing changes
  • I have updated relevant examples in the examples/ directory
  • My changes generate no new compiler warnings

Testing

Tests added/modified:

  • Added replay model tests in src/replay.rs (serialization roundtrip, validation invariants, metadata/display, recorder behavior)
  • Added replay session tests in src/sessions/replay_session.rs (playback flow, completion behavior, validation mode, checksum mismatch event emission)
  • Added event display coverage for ReplayDesync in src/lib.rs
  • Added builder/session tests in src/sessions/builder.rs and src/sessions/p2p_session.rs for replay-session creation and recording API behavior
  • Added new script tests in scripts/tests/test_check_sync_headers.py
  • Expanded scripts/tests/test_sync_wiki.py coverage for SYNC header generation, sidebar coverage validation, idempotent output normalization, and fail-before-write behavior

Manual testing performed:

  • Reviewed API docs and migration impact for new replay + telemetry APIs
  • Verified docs navigation additions and wiki mirror wiring in this branch
  • Full local command status (cargo fmt, cargo clippy, cargo nextest) intentionally left unchecked in checklist for final author confirmation

Related Issues

  • N/A (no issue links provided in branch metadata)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class replay recording/playback and session telemetry to the Fortress Rollback runtime, and strengthens docs↔wiki synchronization + validation to reduce drift and improve diagnostics.

Changes:

  • Introduces replay domain model (Replay, ReplayMetadata), P2P recording hooks, and a deterministic ReplaySession (optionally validating checksums and emitting ReplayDesync).
  • Adds a session telemetry API (SessionTelemetry, TelemetryEvent, CollectingTelemetry) and integrates emission into P2P rollback/prediction/network-stats/frame-advance paths.
  • Hardens docs/wiki sync: sidebar coverage validation, deterministic output normalization, reciprocal SYNC header generation, improved hook diagnostics, and expanded tests.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wiki/_Sidebar.md Adds wiki navigation entries for replay + telemetry pages.
wiki/Telemetry.md Generated wiki mirror for telemetry guide.
wiki/Replay.md Generated wiki mirror for replay guide.
wiki/Overview.md Adjusts wiki spec overview table formatting.
src/telemetry.rs Adds telemetry trait/events + collecting implementation and tests.
src/sync_layer/mod.rs Adds helper for identifying players with incorrect predictions (telemetry support).
src/sessions/session_trait.rs Updates session trait docs to include ReplaySession.
src/sessions/replay_session.rs New replay playback session with optional checksum validation + tests.
src/sessions/p2p_session.rs Integrates telemetry emission and replay recording into P2P session.
src/sessions/builder.rs Adds builder options for recording + telemetry, and replay-session constructors + tests.
src/replay.rs New replay model, deterministic serialization helpers, and internal recorder + tests.
src/prelude.rs Re-exports replay/session telemetry types in the prelude.
src/lib.rs Exposes replay module/types and adds FortressEvent::ReplayDesync + display tests.
scripts/tests/test_sync_wiki.py Expands tests for sync-wiki SYNC headers, sidebar coverage, normalization, and fail-before-write behavior.
scripts/tests/test_check_sync_headers.py Adds unit/integration tests for improved SYNC header diagnostics.
scripts/hooks/check-sync-headers.py Improves diagnostics (case mismatch hints + remediation guidance).
scripts/docs/sync-wiki.py Adds reciprocal SYNC header injection, deterministic EOF normalization, and sidebar coverage validation.
mkdocs.yml Adds MkDocs nav entries for replay + telemetry docs.
docs/telemetry.md New telemetry guide (docs source).
docs/replay.md New replay guide (docs source).
CHANGELOG.md Documents new replay/telemetry APIs and breaking ReplayDesync event.
.pre-commit-config.yaml Adds sync-wiki hook before wiki consistency checks.
.llm/skills/ci-cd-tooling/wiki-sync.md Updates internal wiki sync guidance to reflect new enforcement/behavior.
.gitignore Ignores local pre-commit/pre-push log artifacts.

Comment thread src/sessions/p2p_session.rs
Comment thread scripts/docs/sync-wiki.py
Comment thread src/sync_layer/mod.rs Outdated
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Fortress Rollback Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 3af8486 Previous: f520cca Ratio
Message serialization/input_deserialize 1244 ns/iter (± 1) 681 ns/iter (± 2) 1.83
Message serialization/input_encode_into_buffer 1557 ns/iter (± 99) 871 ns/iter (± 14) 1.79

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Mar 29, 2026
@wallstop wallstop requested a review from Copilot March 29, 2026 15:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated 3 comments.

Comment thread docs/telemetry.md
Comment thread docs/telemetry.md Outdated
Comment thread src/replay.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 28 changed files in this pull request and generated 2 comments.

Comment thread src/sessions/replay_session.rs Outdated
Comment thread CHANGELOG.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 32 changed files in this pull request and generated 1 comment.

Comment thread src/sessions/p2p_session.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 34 changed files in this pull request and generated 2 comments.

Comment thread CHANGELOG.md Outdated
Comment thread src/replay.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 60 out of 62 changed files in this pull request and generated 2 comments.

Comment thread scripts/ci/check-doc-claims.sh Outdated
Comment thread scripts/ci/check-derive-bounds.sh Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 67 out of 69 changed files in this pull request and generated 1 comment.

Comment thread src/sessions/replay_session.rs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 67 out of 69 changed files in this pull request and generated no new comments.

@wallstop wallstop merged commit e499999 into main Mar 29, 2026
78 checks passed
@wallstop wallstop deleted the dev/wallstop/session-hotjoin branch March 29, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants