Skip to content

feat(p2p): add protocol handlers and session validation to test peer#35

Merged
mads-jm merged 1 commit intomvpfrom
claude/test-peer-client-playlist-rLa0a
Mar 15, 2026
Merged

feat(p2p): add protocol handlers and session validation to test peer#35
mads-jm merged 1 commit intomvpfrom
claude/test-peer-client-playlist-rLa0a

Conversation

@mads-jm
Copy link
Owner

@mads-jm mads-jm commented Mar 15, 2026

Summary

Upgrades the test peer from a bare connection probe to a full protocol participant capable of validating playlist interactions end-to-end.

  • Protocol handlers (protocols.js): JS ports of handshake.ts and replication.ts, registering both /whatnext/handshake/1.0.0 and /whatnext/rxdb-replication/1.0.0 with pull-response support
  • Session store (session-store.js): In-memory document store with LWW conflict resolution, checkpoint tracking, document factories (track, vote), and chalk-formatted display helpers
  • CLI commands: 7 new interactive commands (pull, track-add, playlist, tracks, peers-info, vote, session) with short aliases for rapid testing

Changes

File Description
test-peer/src/index.js Wire protocol modules, hoist readline to module scope, auto-initiate handshake on peer connect, add CLI commands
test-peer/src/protocols.js Handshake and replication protocol handlers (JS ports of TS originals)
test-peer/src/session-store.js In-memory store with LWW conflict resolution, document factories, display helpers

Test plan

  • Start app + test peer with node scripts/start-dev.mjs
  • Verify auto-handshake completes on peer discovery
  • Test pull command to trigger replication pull from app
  • Test track-add to push a track document and verify it appears in the app
  • Test vote command and confirm vote propagation
  • Verify playlist, tracks, peers-info, session display commands render correctly
  • Confirm peer disconnect cleans up handshake state

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
@github-actions
Copy link

github-actions bot commented Mar 15, 2026

⚠️ P2P Protocol Files Modified

This PR touches files in the P2P scope gate:

The P2P protocol is off-limits for fully autonomous agentic work without explicit human approval.

Before merging, a human reviewer must explicitly confirm:

  • Changes are intentional and understood
  • Backward compatibility with existing peers considered
  • No unintended side effects on session stability or replication

See [[workflow-story-to-pr]] §3 Agentic Scope Gates.

@mads-jm mads-jm changed the base branch from main to mvp March 15, 2026 07:10
@mads-jm mads-jm changed the title Replace Node.js Scripts with ESM Variants for Cross-Platform Development test peer iteration Mar 15, 2026
@mads-jm mads-jm changed the title test peer iteration feat(p2p): add protocol handlers and session validation to test peer Mar 15, 2026
@mads-jm mads-jm merged commit d2d006e into mvp Mar 15, 2026
1 of 4 checks passed
@mads-jm mads-jm deleted the claude/test-peer-client-playlist-rLa0a branch March 15, 2026 21:04
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