feat(p2p): add protocol handlers and session validation to test peer#35
Merged
feat(p2p): add protocol handlers and session validation to test peer#35
Conversation
Upgrades the test peer from a bare connection probe to a full protocol participant capable of validating playlist interactions end-to-end. New files: - test-peer/src/protocols.js: JS ports of handshake.ts and replication.ts. Registers both /whatnext/handshake/1.0.0 and /whatnext/rxdb-replication/1.0.0 handlers; adds pull-response callback path missing from the TS original. - test-peer/src/session-store.js: In-memory document store with LWW conflict resolution, checkpoint tracking, document factories (track, vote), and chalk-formatted display helpers for playlist/tracks/session/peers views. Changes to index.js: - Imports and wires both protocol modules. - Hoists readline interface to module scope so async protocol callbacks can re-prompt the CLI. - Auto-initiates handshake 200ms after peer:connect (mirrors app behaviour, avoids race where both sides dial before the handler is registered). - Cleans up handshake info on peer:disconnect. - Adds 7 new CLI commands: pull, track-add, playlist, tracks, peers-info, vote, session — each with short aliases (pl, ta, tr, pi, v, ss). https://claude.ai/code/session_01MyHJWWEcdTVCQ7nJbYC636
|
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.
Summary
Upgrades the test peer from a bare connection probe to a full protocol participant capable of validating playlist interactions end-to-end.
protocols.js): JS ports ofhandshake.tsandreplication.ts, registering both/whatnext/handshake/1.0.0and/whatnext/rxdb-replication/1.0.0with pull-response supportsession-store.js): In-memory document store with LWW conflict resolution, checkpoint tracking, document factories (track, vote), and chalk-formatted display helperspull,track-add,playlist,tracks,peers-info,vote,session) with short aliases for rapid testingChanges
test-peer/src/index.jstest-peer/src/protocols.jstest-peer/src/session-store.jsTest plan
node scripts/start-dev.mjspullcommand to trigger replication pull from apptrack-addto push a track document and verify it appears in the appvotecommand and confirm vote propagationplaylist,tracks,peers-info,sessiondisplay commands render correctly