[PR #6850] [MERGED] feat(multiplayer): add optional shared sessions #7355

Closed
opened 2026-10-23 04:18:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6850
Author: @SpicyMarinara
Created: 9/29/2026
Status: ✅ Merged
Merged: 9/29/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/6790-multiplayer


📝 Commits (9)

  • 3a38557 docs: record multiplayer trust boundaries and transport
  • bf561ef feat(multiplayer): add optional shared sessions in all three modes
  • 8246622 fix(multiplayer): harden recovery and preserve room companions
  • 0ec8664 Merge staging ruleset updates into multiplayer
  • d6c7169 test(multiplayer): build guest assets for clean security checks
  • 0c2f594 fix(multiplayer): enforce dormant gates and private room boundaries
  • 7958dcf fix(multiplayer): ignore unrelated availability invalidations
  • 3247b58 fix(multiplayer): retain successful sessions after status failures
  • 210015d Merge staging into optional multiplayer

📊 Changes

121 files changed (+15716 additions, -1435 deletions)

View changed files

📝 .env.example (+4 -0)
📝 CHANGELOG.md (+2 -0)
📝 CONTRIBUTING.md (+2 -0)
📝 README.md (+2 -0)
📝 android/README.md (+4 -0)
📝 docs/CONFIGURATION.md (+22 -0)
📝 docs/FAQ.md (+6 -0)
📝 docs/TROUBLESHOOTING.md (+12 -0)
➕ docs/development/multiplayer.md (+183 -0)
📝 e2e/game-experience-setup.e2e.ts (+79 -1)
➕ e2e/multiplayer-controls.e2e.ts (+1007 -0)
➕ e2e/multiplayer-guest-isolation.e2e.ts (+684 -0)
📝 packages/client/package.json (+1 -1)
➕ packages/client/scripts/build-multiplayer-guest.mjs (+38 -0)
📝 packages/client/scripts/build.mjs (+2 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+98 -62)
📝 packages/client/src/components/chat/ChatModeSelectorModal.tsx (+30 -5)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+21 -1)
📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+12 -6)
📝 packages/client/src/components/chat/ConversationAutonomousEffects.tsx (+5 -4)

...and 80 more files

📄 Description

Linked issue

Closes #6790

Why this change

People can create a fresh shared Conversation, Roleplay or Game, each controlling their own reviewed persona, with host-approved AI characters or an AI GM. Game collects every required human action or explicit pass before one shared resolution.

What changed

  • Reuses the existing mode chooser, setup wizards, chat drawer, sidebar, character/persona pickers, generation pipeline and autonomous scheduler. Adds invitations, approval, Players, connection state and bounded generation controls on desktop and mobile.
  • Requires MULTIPLAYER_ENABLED=true at startup, separate Settings consent, then an explicit Host or Join. Restart never restores a network session. Either gate being off stops session scans, TLS checks and host/guest polling; only activation discovery and explicit Settings refresh remain. The host chooses the human and AI roster without a fixed count cap; bounded request/snapshot sizes and rate protections remain.
  • Uses a dedicated HTTPS room listener, CA/hostname validation plus invite fingerprint binding, expiring credentials, exact bounded message schemas and saved action receipts. The regular Engine API is never exposed through the peer listener.
  • Guests use their own trusted Engine and an opaque-origin, CSP-restricted text renderer. No peer files, remote assets, executable cards, custom/package tools or native capability access. The current Android native wrapper cannot join because its bridge is injected into every frame.
  • Keeps Game rounds, persona/sheet/inventory ownership, private whisper recipients and historical attribution stable across retries, disconnects, renames and removals. Commands and scheduled/autonomous responses execute through one host authority; restrictions are documented in the compatibility matrix.

Validation

Implementation and substantive local review are complete. Human verification boxes remain unchecked. Merged into staging as 338e066ae97784db6ae9c5f956cba1caf54f8a30. All required GitHub checks and CodeRabbit passed on final integrated head 210015d738dbf2a5e361a12a1396e9832771f822 before merge. The complete hosted Node lane and platform/container jobs also passed. All review threads are resolved. Physical-device checks below remain explicitly unverified; browser emulation is not a claim of physical-device support.

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Automated evidence

  • pnpm check and pnpm version:check passed. Includes localization, formatting, lint, client/server/shared and e2e types, production builds and the isolated guest bundle.
  • All 12 multiplayer regression suites passed, including real TLS-connected Engines using registered Conversation, Roleplay and Game runtimes with a mock provider. Additional final proofs cover rapid disable/re-enable cleanup and distinct host/guest API-key canaries: only the host's provider receives its key; room projections and model prompts contain neither key.
  • Large-room proof: 10 humans and 14 AI, every required human action before one Game resolution, complete rosters/HUD/reactions, private whispers, separately bounded pending requests, retained guest state during oversized updates, host management and recovery. No fixed human or AI count cap.
  • Disabled-state proof: no session scans, certificate reads or autonomous work while either gate is off; an in-flight enable cannot defeat a newer disable. Client network assertions cover both disabled gates, remount/focus, unrelated global query invalidation, cross-tab disabling, 404 shutdown and saved-room recovery. Static status caching prevents unrelated workspace refreshes from waking the feature; explicit Settings, Host and Join still refresh correctly. The final affected browser matrix passed 42/42 across the three browser projects, including successful Host/Join followed by failed status and first-session reads, normal polling recovery, and delayed success after disabling.
  • Final controls matrix: 36/36 across desktop Chromium, mobile Chromium and mobile WebKit; the subsequent success-only consent reset reran its affected case 3/3. Final compiled guest isolation matrix: 36/36, including hostile text, denied network/storage/native/API access, source binding, replay, concurrent actions, large UTF-8 drafts and larger rosters. Earlier setup matrix: 48/48.
  • Final pnpm smoke:ui: 7/7; pnpm smoke:production: 3/3. Game parser/translation browser regressions: 5/5. Prompt, attachments, context-fit, generation-output, Game ruleset setup, parser attributes/inventory/dice and malformed-input runtime bounds passed. Parser differential checks matched 25,000 legacy cases.
  • Final Docker build/runtime proof passed: image sha256:a2839e1effd784cef1f430641e0817f477853de6041feff0290fd8951bed9428. Verified environment/Settings gates, packaged guest assets, production shell/CSP and no automatic peer listener. Temporary containers removed; image not published.
  • Clean-checkout security proof builds its own real guest assets; cold-assets and exact pnpm regression:security passed. The complete hosted Linux Node lane passed on final integrated head 210015d73. All required checks, Windows/macOS/Linux builds, container runtime jobs and Android build/signing guard passed on this head; nightly-only full-browser jobs were intentionally skipped. The initial local Mac sweep had one unchanged decision-sidecar-runtime platform expectation failure, independently reproduced on staging 0cad58d3; the full local Node lane is not claimed green.
  • Latest staging f953711ca is integrated in 210015d73; only the changelog conflicted and both entries were retained. After integration, pnpm check, all 12 multiplayer suites, focused weapon/inventory/combat-grid/invented-item regressions, UI smoke (7/7), production smoke (3/3), and Docker build/runtime passed again. Independent read-only review found no Game integration defect. No version or storage-format changes.

Review disposition

Hosted CodeRabbit findings were traced against current code. Fixes include central disabled polling, consent reset, setup-repair authority, sanitized/logged errors, TLS-free request gates, scheduler exception backoff, exact hidden-stat visibility keys, roster-only authorization, protected room metadata and awaited fixture cleanup. The old four-player constant and new roster-cap suggestions are obsolete after the maintainer requested no fixed caps; linked issue #6790 now reflects that updated requirement. A declined generation claim intentionally does not trigger failure backoff: it can be a harmless busy/Stop race, and failed provider generation already blocks autonomy until explicit recovery.

All eight hosted CodeQL findings are fixed; CodeQL passed on final integrated head 210015d73 and the PR code-scanning API reported no open alerts. Fixes include: a real dedicated guest-document rate bucket and bounded forward scans in the promoted Game parser/widget helpers, with malformed-input regression proof.

Hosted CodeRabbit completed on final integrated head 210015d73 with no actionable comments in its latest review; all historical threads are resolved with fixes or documented dispositions. Local CodeRabbit reviews completed and substantive findings were addressed. The static-cache follow-up review reported no new findings. The later Host/Join recovery review reported one fixture-only finding: a synthetic test button can submit before status loads. Production Host and Join controls both require loaded, available, enabled status; successful status data is retained with infinite garbage-collection time during ordinary use. The only global cache clear is the explicit admin expunge/clear-all runtime reset, where a late session must not be resurrected. Unknown or disabled status therefore remains fail-closed; the suggestion to seed a session without known enablement was not adopted. Hosted finding 4136044408 is fixed by immediately retaining successful session results while enabled, with the 42-case recovery/disable proof above. The docstring-coverage advisory is not a repository merge gate; existing boundary documentation is retained without adding comments that merely repeat self-explanatory helpers. Suggestions not adopted: restoring a fixed roster cap (explicit maintainer requirement; byte/rate limits and recovery remain), process-lifetime guest asset caching (development rebuild/reload), reparsing normalized client character IDs, a redundant SSE adapter branch, narrowing chat invalidation despite roster/setup changes, deduplicating disjoint library/NPC IDs already maintained uniquely, and moving inert retry counters before terminal-state assignment (terminal sessions already stop all polling; no retry timer is created). This is not a claim of zero findings. Independent review also traced both directions of the peer boundary, key handling, admission/revocation, tool dispatch, plain-text host rendering and isolated guest rendering. No absolute security guarantee is asserted.

Manual verification notes

  • Manually verify a physical iPhone/iPad Home Screen guest and Android browser guest against a separately trusted Engine: warning/persona review, invitation/approval, connection loss and recovery, software-keyboard layout, host-tab suspension, Stop and Leave.
  • Manually complete a two-person session in each mode with the intended provider and certificate setup, including Game readiness, changing persona at a round boundary and removing a player during generation.
  • Browser-device emulation does not establish physical-device support. The native Android wrapper remains explicitly blocked as a guest. Physical-device results are still pending under #6790 and must not be represented as completed mobile-platform validation.

Docs and release impact

Updated setup, FAQ, troubleshooting, architecture/security boundary, compatibility matrix, Android restriction and Unreleased changelog. Translation follow-up: #6854. No app version or storage-format change.

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

UI evidence

Desktop/mobile screenshot bundle and evidence index. Download the self-contained HTML to view the nine embedded PNGs. Covers light/dark Settings warnings, IP/provider disclosure, joining, Players and larger host/guest rosters; all data are disposable fixtures. No screenshot assets are committed to the repository.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6850 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/29/2026 **Status:** ✅ Merged **Merged:** 9/29/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/6790-multiplayer` --- ### 📝 Commits (9) - [`3a38557`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3a3855716418deb923c01a5e28e38ee4c7034596) docs: record multiplayer trust boundaries and transport - [`bf561ef`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bf561ef8f5da63bce3e33bf32d09fa56441d4614) feat(multiplayer): add optional shared sessions in all three modes - [`8246622`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8246622236bc9f4c87fcdb40ceea1c77e6d222dd) fix(multiplayer): harden recovery and preserve room companions - [`0ec8664`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0ec8664a98e55c2665b2ced410bb3d5b341a236b) Merge staging ruleset updates into multiplayer - [`d6c7169`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d6c7169ab446b7dcdc60755d3519d7431f71bdb8) test(multiplayer): build guest assets for clean security checks - [`0c2f594`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0c2f59413d1954634ce2d492de118aec987bbb9d) fix(multiplayer): enforce dormant gates and private room boundaries - [`7958dcf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7958dcf7d7cc2fa06d85b85c77b14aab64421da8) fix(multiplayer): ignore unrelated availability invalidations - [`3247b58`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3247b58799967476073a0d5102fd1111e7215051) fix(multiplayer): retain successful sessions after status failures - [`210015d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/210015d738dbf2a5e361a12a1396e9832771f822) Merge staging into optional multiplayer ### 📊 Changes **121 files changed** (+15716 additions, -1435 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+4 -0) 📝 `CHANGELOG.md` (+2 -0) 📝 `CONTRIBUTING.md` (+2 -0) 📝 `README.md` (+2 -0) 📝 `android/README.md` (+4 -0) 📝 `docs/CONFIGURATION.md` (+22 -0) 📝 `docs/FAQ.md` (+6 -0) 📝 `docs/TROUBLESHOOTING.md` (+12 -0) ➕ `docs/development/multiplayer.md` (+183 -0) 📝 `e2e/game-experience-setup.e2e.ts` (+79 -1) ➕ `e2e/multiplayer-controls.e2e.ts` (+1007 -0) ➕ `e2e/multiplayer-guest-isolation.e2e.ts` (+684 -0) 📝 `packages/client/package.json` (+1 -1) ➕ `packages/client/scripts/build-multiplayer-guest.mjs` (+38 -0) 📝 `packages/client/scripts/build.mjs` (+2 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+98 -62) 📝 `packages/client/src/components/chat/ChatModeSelectorModal.tsx` (+30 -5) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+21 -1) 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+12 -6) 📝 `packages/client/src/components/chat/ConversationAutonomousEffects.tsx` (+5 -4) _...and 80 more files_ </details> ### 📄 Description ## Linked issue Closes #6790 ## Why this change People can create a fresh shared Conversation, Roleplay or Game, each controlling their own reviewed persona, with host-approved AI characters or an AI GM. Game collects every required human action or explicit pass before one shared resolution. ## What changed - Reuses the existing mode chooser, setup wizards, chat drawer, sidebar, character/persona pickers, generation pipeline and autonomous scheduler. Adds invitations, approval, Players, connection state and bounded generation controls on desktop and mobile. - Requires `MULTIPLAYER_ENABLED=true` at startup, separate Settings consent, then an explicit Host or Join. Restart never restores a network session. Either gate being off stops session scans, TLS checks and host/guest polling; only activation discovery and explicit Settings refresh remain. The host chooses the human and AI roster without a fixed count cap; bounded request/snapshot sizes and rate protections remain. - Uses a dedicated HTTPS room listener, CA/hostname validation plus invite fingerprint binding, expiring credentials, exact bounded message schemas and saved action receipts. The regular Engine API is never exposed through the peer listener. - Guests use their own trusted Engine and an opaque-origin, CSP-restricted text renderer. No peer files, remote assets, executable cards, custom/package tools or native capability access. The current Android native wrapper cannot join because its bridge is injected into every frame. - Keeps Game rounds, persona/sheet/inventory ownership, private whisper recipients and historical attribution stable across retries, disconnects, renames and removals. Commands and scheduled/autonomous responses execute through one host authority; restrictions are documented in the compatibility matrix. ## Validation Implementation and substantive local review are complete. Human verification boxes remain unchecked. Merged into `staging` as `338e066ae97784db6ae9c5f956cba1caf54f8a30`. All required GitHub checks and CodeRabbit passed on final integrated head `210015d738dbf2a5e361a12a1396e9832771f822` before merge. The complete hosted Node lane and platform/container jobs also passed. All review threads are resolved. Physical-device checks below remain explicitly unverified; browser emulation is not a claim of physical-device support. - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Automated evidence - `pnpm check` and `pnpm version:check` passed. Includes localization, formatting, lint, client/server/shared and e2e types, production builds and the isolated guest bundle. - All 12 multiplayer regression suites passed, including real TLS-connected Engines using registered Conversation, Roleplay and Game runtimes with a mock provider. Additional final proofs cover rapid disable/re-enable cleanup and distinct host/guest API-key canaries: only the host's provider receives its key; room projections and model prompts contain neither key. - Large-room proof: 10 humans and 14 AI, every required human action before one Game resolution, complete rosters/HUD/reactions, private whispers, separately bounded pending requests, retained guest state during oversized updates, host management and recovery. No fixed human or AI count cap. - Disabled-state proof: no session scans, certificate reads or autonomous work while either gate is off; an in-flight enable cannot defeat a newer disable. Client network assertions cover both disabled gates, remount/focus, unrelated global query invalidation, cross-tab disabling, 404 shutdown and saved-room recovery. Static status caching prevents unrelated workspace refreshes from waking the feature; explicit Settings, Host and Join still refresh correctly. The final affected browser matrix passed 42/42 across the three browser projects, including successful Host/Join followed by failed status and first-session reads, normal polling recovery, and delayed success after disabling. - Final controls matrix: 36/36 across desktop Chromium, mobile Chromium and mobile WebKit; the subsequent success-only consent reset reran its affected case 3/3. Final compiled guest isolation matrix: 36/36, including hostile text, denied network/storage/native/API access, source binding, replay, concurrent actions, large UTF-8 drafts and larger rosters. Earlier setup matrix: 48/48. - Final `pnpm smoke:ui`: 7/7; `pnpm smoke:production`: 3/3. Game parser/translation browser regressions: 5/5. Prompt, attachments, context-fit, generation-output, Game ruleset setup, parser attributes/inventory/dice and malformed-input runtime bounds passed. Parser differential checks matched 25,000 legacy cases. - Final Docker build/runtime proof passed: image `sha256:a2839e1effd784cef1f430641e0817f477853de6041feff0290fd8951bed9428`. Verified environment/Settings gates, packaged guest assets, production shell/CSP and no automatic peer listener. Temporary containers removed; image not published. - Clean-checkout security proof builds its own real guest assets; cold-assets and exact `pnpm regression:security` passed. The complete hosted Linux Node lane passed on final integrated head `210015d73`. All required checks, Windows/macOS/Linux builds, container runtime jobs and Android build/signing guard passed on this head; nightly-only full-browser jobs were intentionally skipped. The initial local Mac sweep had one unchanged `decision-sidecar-runtime` platform expectation failure, independently reproduced on staging `0cad58d3`; the full local Node lane is not claimed green. - Latest staging `f953711ca` is integrated in `210015d73`; only the changelog conflicted and both entries were retained. After integration, `pnpm check`, all 12 multiplayer suites, focused weapon/inventory/combat-grid/invented-item regressions, UI smoke (7/7), production smoke (3/3), and Docker build/runtime passed again. Independent read-only review found no Game integration defect. No version or storage-format changes. ### Review disposition Hosted CodeRabbit findings were traced against current code. Fixes include central disabled polling, consent reset, setup-repair authority, sanitized/logged errors, TLS-free request gates, scheduler exception backoff, exact hidden-stat visibility keys, roster-only authorization, protected room metadata and awaited fixture cleanup. The old four-player constant and new roster-cap suggestions are obsolete after the maintainer requested no fixed caps; linked issue #6790 now reflects that updated requirement. A declined generation claim intentionally does not trigger failure backoff: it can be a harmless busy/Stop race, and failed provider generation already blocks autonomy until explicit recovery. All eight hosted CodeQL findings are fixed; CodeQL passed on final integrated head `210015d73` and the PR code-scanning API reported no open alerts. Fixes include: a real dedicated guest-document rate bucket and bounded forward scans in the promoted Game parser/widget helpers, with malformed-input regression proof. Hosted CodeRabbit completed on final integrated head `210015d73` with no actionable comments in its latest review; all historical threads are resolved with fixes or documented dispositions. Local CodeRabbit reviews completed and substantive findings were addressed. The static-cache follow-up review reported no new findings. The later Host/Join recovery review reported one fixture-only finding: a synthetic test button can submit before status loads. Production Host and Join controls both require loaded, available, enabled status; successful status data is retained with infinite garbage-collection time during ordinary use. The only global cache clear is the explicit admin expunge/clear-all runtime reset, where a late session must not be resurrected. Unknown or disabled status therefore remains fail-closed; the suggestion to seed a session without known enablement was not adopted. Hosted finding 4136044408 is fixed by immediately retaining successful session results while enabled, with the 42-case recovery/disable proof above. The docstring-coverage advisory is not a repository merge gate; existing boundary documentation is retained without adding comments that merely repeat self-explanatory helpers. Suggestions not adopted: restoring a fixed roster cap (explicit maintainer requirement; byte/rate limits and recovery remain), process-lifetime guest asset caching (development rebuild/reload), reparsing normalized client character IDs, a redundant SSE adapter branch, narrowing chat invalidation despite roster/setup changes, deduplicating disjoint library/NPC IDs already maintained uniquely, and moving inert retry counters before terminal-state assignment (terminal sessions already stop all polling; no retry timer is created). This is not a claim of zero findings. Independent review also traced both directions of the peer boundary, key handling, admission/revocation, tool dispatch, plain-text host rendering and isolated guest rendering. No absolute security guarantee is asserted. ### Manual verification notes - Manually verify a physical iPhone/iPad Home Screen guest and Android browser guest against a separately trusted Engine: warning/persona review, invitation/approval, connection loss and recovery, software-keyboard layout, host-tab suspension, Stop and Leave. - Manually complete a two-person session in each mode with the intended provider and certificate setup, including Game readiness, changing persona at a round boundary and removing a player during generation. - Browser-device emulation does not establish physical-device support. The native Android wrapper remains explicitly blocked as a guest. Physical-device results are still pending under #6790 and must not be represented as completed mobile-platform validation. ## Docs and release impact Updated setup, FAQ, troubleshooting, architecture/security boundary, compatibility matrix, Android restriction and Unreleased changelog. Translation follow-up: #6854. No app version or storage-format change. - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence [Desktop/mobile screenshot bundle and evidence index](https://gist.github.com/SpicyMarinara/62df87f4649f340b2bafc56689075b6b). Download the self-contained HTML to view the nine embedded PNGs. Covers light/dark Settings warnings, IP/provider disclosure, joining, Players and larger host/guest rosters; all data are disposable fixtures. No screenshot assets are committed to the repository. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:18:56 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7355
No description provided.