Repository navigation
Harden the multiplayer API for 1.0: trial scopes, outcomes, shared utils - #107
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also moves the in-memory test backend to the new wire format and keeps non-plugin packages out of the README's plugin table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Local: onResumed replaces the fake reconnect; keyPrefix -> namespace; persistParticipant defaults to true; IDs from @jspsych-multiplayer/utils - JATOS: relays the seal to every member under $sealed with a trust check; sealGroup is omitted when unsupported; connectTimeoutMs and closeAfterReconnectingMs give way to the core's timeouts; push rejects instead of waiting forever for the channel - Firebase: pathPrefix -> namespace; tab-persisted participant IDs keep a reload in its group; rules tie slots, seats, rosters, and lobbies to auth.uid; connectTimeoutMs gives way to the core's connectTimeout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Use @jspsych-multiplayer/utils; delete the per-plugin multiplayer.ts shims - Trial scopes replace gate counters and data_key parameters - push_data -> write_data, which merges; nothing replaces the whole slot - Record multiplayer_outcome and left_participant in place of timed_out, partner_left, connection_lost, and wait_error - Group snapshots only with save_group; waits default to the remaining participants; a timeout of 0 still means no limit - Values shared across trials use the session scope; role and match accessors read jsPsych data instead of module-level stores Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Names and other values shared across trials use the session scope - Done screens read multiplayer_outcome; pages check restarted and handle a failed connect() - The JATOS ultimatum game waits with waitForGroup (maxActiveMembers: 2) - group-quiz waits on the host through the session scope Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vendors preview 4df7fbb6 (core 14b34bf2) and points the docs and example pages at it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
📦 New package — trusted-publishing bootstrap neededThis PR added one or more new packages. npm trusted publishing (OIDC) can't be configured for a package that doesn't exist yet, so a maintainer must do a one-time bootstrap per new package. After that, releases publish automatically via OIDC ( Before running the commands below: npm
|
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the whole ecosystem to the hardened multiplayer core, as agreed in the pre-1.0 API review. The core changes are on jspsych/jsPsych#3694 (commits
18e5fdb2..14b34bf2), and this branch vendors its preview build4df7fbb6.What changed in the core (for context)
subscribe, andwaituse that trial's own part of the shared data. It is named by the trial's position in the timeline, or by the newmultiplayer_scopetrial parameter.{ scope: "session" }is for data that lasts the whole session. Subscriptions and waits made during a trial end with it.update()is the write;push()becomesreplace(). Failed writes are retried with backoff.leftis final and agreed across the group. A participant who reloads seesrestarted(it replacespreviousInstance).MultiplayerErrorclass with acode.connectTimeoutandreconnectTimeout.multiplayer_participant_idandmultiplayer_session_id(recordIds, on by default).group(); peers' data can no longer seal the group. The bookkeeping format is versioned.This PR
@jspsych-multiplayer/utils: shared helpers (isMultiplayerError,outcomeOf,pluginTimeout,remainingParticipants,sealedGroupSize,waitForAll, and adapter ID/URL helpers). The root build now builds it first.keyPrefix/pathPrefixare renamednamespace, andpersistParticipantdefaults to true.onResumed()replaces the fake reconnect.sealGroupwhen JATOS can't seal.auth.uid, and a reload returns to its group.data_keyparameters are gone.push_databecomeswrite_data, which merges.multiplayer_outcomeandleft_participantin place oftimed_out/partner_left/connection_lost/wait_error.save_group.Breaking changes
Every changed package has a
minorchangeset describing its breaking changes. Existing Firebase deployments must redeploy the rules.Testing
npm run buildis clean.Open question
The default scope comes from a trial's position in the timeline, so role-specific conditional branches (e.g. proposer vs. responder) don't share a scope. Researchers have to set
multiplayer_scopefor them, as the ultimatum tutorial now shows. Should the default change, or is documenting this enough?After merge
The new
@jspsych-multiplayer/utilspackage needs its one-time bootstrap publish (npm publish+npm trust) before the Version Packages PR can publish it.🤖 Generated with Claude Code