mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6790] [Feature]: Optional secure multiplayer for Conversation, Roleplay, and Game #3800
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3800
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SpicyMarinara on GitHub (Sep 27, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6790
Originally assigned to: @SpicyMarinara on GitHub.
What problem does this solve?
Let people create Roleplay, Conversation, and Game sessions and play together, each controlling their own persona/player character, with optional AI-controlled characters and/or an AI GM in every mode.
Game mode should use shared rounds: each participating player character states what they do, and the engine waits for all required player actions before resolving the round. With two player characters, submitting the first action must not trigger the GM; submitting the second completes the collection step.
Security is a release requirement in both directions. A guest must not gain access to the host's private Marinara installation. A malicious host must not be able to use multiplayer to deliver executable files, run scripts, install packages, or invoke capabilities on the guest's machine. A password and an encrypted peer connection alone do not establish these boundaries.
Multiplayer must remain completely optional, inaccessible until the user explicitly enables it in both
.envand Settings. Prefer the simplest maintainable solution, reuse existing code where its trust assumptions fit, and avoid over-engineering.Proposed solution
Product scope and session behavior
UI plan: extend the existing Marinara interface
Multiplayer is a sharing capability of Conversation, Roleplay, and Game, not a fourth mode. Keep the existing home launcher, mode chooser, sidebar, chat surfaces, setup wizards, settings drawer, character/persona pickers, and composer. Use the user's local theme/accent and existing components. The guest's trusted client renders the familiar interface from validated room data; the host never supplies the guest UI code, theme CSS, or executable components.
Activation and creating a room
When
.envdisables the feature, Settings may show a read-only explanation of the required change/restart, but there are no usable host/join controls or Play together choices. With the environment gate enabled, the user must separately enable Multiplayer in Settings. This permits room actions; it does not start networking by itself. Keep Start hosting and Join explicit, and never restore an active session automatically after restart.The host chooses a mode through the normal New Chat flow and chooses Play together in the existing setup. Reuse the current persona, character, AI GM, command, and autonomy controls. Start hosting reviews the room name, room password, and exactly which setup fields will be shared, then opens the room's Players section. No separate social-network lobby, friends directory, or new global navigation system.
For Game, creating the room and starting the adventure are separate actions: invite and approve players before the existing Start game action generates the initial party/world context. Reuse the Game setup Party/GM and Review stages to show the approved human roster plus AI companions; require every participating human to select a player character before Start game. Invitations and readiness can live in the same reusable Players section during setup and play.
Do not make an existing private chat public merely by pressing Invite. The initial UI creates a fresh shared session from explicitly reviewed setup. Any later Share existing chat path must define history/private-state disclosure separately; do not automatically copy old transcripts, hidden notes, or private memories.
Inviting and admitting a person
Use the existing drawer/inline section as the persistent room management surface. Reserve an existing
Modal/confirmation pattern for an actual consent or destructive step; avoid nesting a new lobby modal, invitation modal, and persona modal on top of one another.Players and AI characters must be visibly distinct
Players rows show connection state, display name, the persona they control, and text labels such as You, Host, Connected, Waiting, or Reconnecting. For example:
Mari (Host, You) · playing LunaandAlex · playing Rowan. Use safe local/bundled avatar placeholders while peer media transfer is unavailable. Real-player connection state must not be confused with an AI character's fictional availability/status.Keep Invite player separate from the existing Add character control. The latter selects an AI character using the current library picker, with an AI label and an optional GM role; it does not add a person. Guests can propose an AI character through the same picker pattern, sharing only reviewed text fields for host approval. In Game, show both human-controlled characters and AI companions in the existing Party presentation, with clear ownership.
Reuse the persona picker's presentation, but bind its multiplayer action to the current participant rather than updating the chat's single global
personaId. A guest cannot switch someone else's identity, reassign their message history, or take control of an AI/GM. Game persona/roster changes are pending until a safe round boundary. Host-only setup controls remain host-only; guests see a concise explanation such as AI managed by host, never connection secrets or editable host settings.Game turns and ordinary chat input
Keep the existing Game writing/action area. Add a compact status row above it, for example:
Round 4 · 1/2 ready · Waiting for Alex. The submission button is Submit action; after acceptance, show Action submitted and allow Edit action only while the round is still collecting. An explicit Pass counts as that character's submission. Status updates must use labels/icons, not color alone.When all required actors are ready, show GM resolving round and prevent duplicate submissions/edits. A disconnected participant shows Reconnecting/Waiting, and the host sees Pause/Record pass/Remove actions with confirmation where appropriate. New arrivals join the next defined round boundary. Preserve unsent drafts across temporary disconnects and make retry/closed-room states explicit.
Conversation and Roleplay keep their current composer and slash-command affordances. Commands, autonomous replies, schedules, and AI results appear in the same transcript/status locations as today after room validation. Annotate who acted and explain a restricted command inline. Do not add a parallel multiplayer command console or silently send a room command to the guest's own Engine.
Mobile, accessibility, and states
Use the existing responsive settings drawer rather than introducing an always-open player sidebar. Keep the Players shortcut, readiness strip, Close/Back, and Leave/Stop reachable on narrow screens and with the software keyboard open. Approval, invitation, and removal actions cannot depend on hover. Preserve keyboard focus/return behavior, announce readiness/connection changes appropriately, and respect reduced motion, light/dark modes, and local theme settings.
Specify empty, loading, joining, awaiting approval, declined, expired invite, wrong password, full room, incompatible version, reconnecting, identity-changed, and host-ended states. Each needs a clear recovery or Leave action without requiring an app restart. Warning acknowledgment does not bypass the feature gates or protocol restrictions.
Concrete reuse points:
HomeNewChatLauncher,ChatModeSelectorModal,ChatSetupWizard,GameSetupWizard/GameSetupSummary,ChatSidebar,ChatSettingsDrawer,ChatSettingsSection,PickerDropdown,QuickPersonaSwitcher,ChatToolbarControls,ChatInput/ConversationInput, and existing Game action controls. Extract a small reusable Players section if setup and in-chat management need the same content. Reuse audited presentation components while keeping the guest entrypoint free of administrative hooks and native capability registration. Preserve state-based navigation and existing localization conventions.Compatibility with commands, autonomous messages, and existing features
Commands and autonomous messages are required compatibility work, not optional follow-ups. Preserve the existing features where they apply to each mode; do not turn multiplayer into a separate basic chat implementation.
Mandatory double opt-in and shutdown
Proposed name:
MULTIPLAYER_ENABLED=falsein.env.example; absent, invalid, or false means disabled. This variable does not exist yet.Security contract: protect the guest from the host
Assume the host can modify their server, forge every packet and filename, lie about MIME types, and deliberately send malicious AI output or character data. Host-side checks cannot protect a guest from that host.
eval, or dynamic module loading from room content. Links may remain plain text initially; any later external-link action needs explicit user interaction and scheme validation.The enforceable claim is that the supported multiplayer client provides no peer-controlled executable/file-transfer/native-action path. Do not promise absolute immunity to every browser/OS vulnerability or to files a user independently downloads outside Marinara. Keep the security goal strict, document residual risks honestly, and do not use a warning checkbox to bypass the above restrictions.
Security contract: protect the host and other participants
Connection model and minimal architecture
Implementation phases and deliverables
1. Threat model and narrow proof of feasibility
Document host, guest, signaling/relay, AI provider, guest browser/native shell, and local Engine trust boundaries. Inventory dangerous renderers, imports, native bridges, privileged routes, and tool dispatch. Prove an independently trusted guest receiving inert text from a deliberately malicious host with no local capability access. Select one transport and concrete guest isolation arrangement. Record protocol limits and supported initial platforms. Do not start with a full multiplayer UI.
2. Opt-in, admission, and restricted room protocol
Implement the environment gate and Settings activation with fail-closed defaults, password/approval/session handling, participant ownership, narrow message schemas, output projection, Stop/Kick/Disconnect, and local logs that omit credentials/private content. Integrate existing auth protections rather than globally bypassing them. Add isolated regressions proving disabled and unauthorized paths before enabling admission.
3. Shared Conversation and Roleplay
Add create/join room, participant list, persona selection, attributed messages, approved AI characters/GM, host-coordinated response generation, validated streaming, and reconnect snapshots. Integrate the compatibility matrix, existing command dispatch, and a single room autonomous scheduler in this phase. Reuse safe chat layout/state logic with the restricted renderer. Make participant identities explicit in prompts and history; define multi-user macro behavior instead of overwriting the existing chat persona. Preserve existing single-player macro/identity behavior. No peer file imports or rich remote presentation.
4. Game round coordination
Add the smallest persisted round record: round ID/revision, required actor roster, submitted actions/pass state, and collecting/resolving/completed status. Reuse the existing generation lock and game-state write ordering. Atomically close collection only after all required actors are ready, resolve using attributed actions plus participant context, and commit one logical result. Reject stale/duplicate submissions and edits after resolution starts. Handle disconnect, host-approved roster changes, failure, cancellation, and restart recovery explicitly; never silently retry an ambiguous paid generation or double-apply world state.
5. Warnings, security verification, docs, and staged delivery
Add localized enable/join warnings, persistent hosting/guest indicators, clear participant/ready state, accessible controls, mobile layouts, and easy Stop/Leave actions. Complete the negative security matrix below and obtain focused security review before shipping. Deliver small issue-linked PRs against
staging; keep each incomplete increment disabled. All three modes and the mandatory boundaries are required before calling this feature complete.Update
.env.example, Settings help,README.md,android/README.md,CONTRIBUTING.md,CHANGELOG.md, and configuration/troubleshooting/FAQ docs as applicable. Update translated docs or file the required[docs-i18n]follow-up. Review the current local-single-user threat-model documentation explicitly; do not silently change prompt escaping to compensate for a new multiplayer boundary. Package-owned agent changes, if needed, belong in Marinara-Agents with linked work; Engine owns this feature's host integration.Required warnings and consent
Before activation and before joining a new host, clearly say:
Explain that protection is limited to the supported client's controls and is not a guarantee that an unknown host or external download is safe. Show the host identity/fingerprint and room name in trusted UI separately from peer-controlled text, disclose whether the connection is direct or relayed, and require fresh consent after a host identity change. Host warnings should explain guest-content risks and generation usage. All new UI copy uses semantic English localization keys; community locales may fall back to English.
Acceptance and regression plan
These are required future checks, not claims that implementation or testing has happened:
pnpm check,pnpm localization:check, relevant Node/security regressions,pnpm regression:prompt,pnpm smoke:ui, and focused multi-client Playwright cases on desktop Chromium, mobile Chromium, and mobile WebKit. Use existing regression conventions; do not retain temporary.test.tsfiles.Alternatives considered
Additional context
Requested by maintainer @SpicyMarinara. This issue is an implementation plan/feature request, not a claim that the feature exists or that its security has been verified. Implementation is not started or assigned by this ticket.
Related earlier suggestion: #5781, closed with an invitation to reopen/recreate when the maintainer approves the direction. This request provides the current three-mode scope, Game round behavior, explicit double opt-in, and security boundaries in both directions. No matching open multiplayer PR or local multiplayer branch was found during preparation.
Code inspection at
0eac28284c80190c19dfd568d4f6933aa027a0e6suggests these reuse/audit points; they are starting points, not blanket approval to expose existing code to peers:packages/shared/src/types/chat.tsandtypes/game.ts: current chat persona and message identity snapshots; game setup/party model.packages/server/src/services/chat-user-identity.ts,services/generation/identity-context-runtime.ts,services/prompt/assembler.ts,services/prompt/macro-context.ts: explicit multi-participant identity and prompt semantics.packages/server/src/routes/generate.routes.ts: existing per-chat generation guard and SSE output; filter room-safe events rather than exposing raw internal events.packages/server/src/services/conversation/{autonomous.service,autonomous-candidates,server-autonomous-scheduler.service,schedule.service}.ts,services/generation/{conversation-command-runtime,roleplay-commands}.ts, andservices/capability-packages/capability-command-registry.service.ts: reuse command/scheduling behavior with room scope and single-coordinator guarantees.packages/client/src/lib/slash-commands.tsandhooks/{use-autonomous-messaging,use-background-autonomous,use-roleplay-commands}.ts: route authorized room actions through the host instead of duplicating local execution/polling on guests.packages/server/src/services/storage/chats.storage.ts,game-state.storage.ts,game-engine-state.storage.ts, anddb/schema/chats.ts: persisted chat/game state and write ordering.packages/server/src/config/runtime-config.tsandmiddleware/{basic-auth,privileged-gate,csrf-protection,host-validation,android-local-auth}.ts: environment enforcement and authorization boundaries.privileged-gate.tscurrently includes a localhost trust path that must not apply to forwarded peer actions.packages/client/src/lib/chat-html.ts,components/chat/ChatMessage.tsx, chat surfaces, game stores, andhooks/use-generate.ts: reuse candidates requiring a multiplayer-specific audit. Existing HTML sanitization still permits rich markup and image sources; it is not the proposed text-only guest renderer.CONTRIBUTING.mdexplicitly describes the existing local/single-user prompt-content threat model. Multiplayer changes that deployment assumption; preserve existing prompt-leaf semantics and enforce import, rendering, and tool boundaries deliberately.Security references: WebRTC trust model, OWASP safe DOM output. These inform the plan; they do not certify an implementation.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Sep 29, 2026):
Implementation is being taken on by @SpicyMarinara with Codex. I am starting with the issue’s trusted-guest isolation and transport feasibility proof, then the double opt-in and room protocol, before integrating the existing three-mode UI and generation paths. The implementation will stay disabled while its security boundaries and mode compatibility are incomplete. An issue-linked draft PR will track the work; no multiplayer implementation branch or PR was present when starting.