Skip to content

Add WebSocket broadcasts for challenge lifecycle events#5

Merged
echobt merged 1 commit intomainfrom
dev
Dec 27, 2025
Merged

Add WebSocket broadcasts for challenge lifecycle events#5
echobt merged 1 commit intomainfrom
dev

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Dec 27, 2025

  • Add ChallengeRegistered, ChallengeStarted, ChallengeStopped events
  • Broadcast events when challenges are registered/started/stopped
  • csudo: Add interactive mode, fix short flag conflicts
  • Validators receive real-time notifications when challenges change

Summary by CodeRabbit

  • New Features

    • Interactive mode is now the default when no explicit command is provided.
    • Real-time event notifications for challenge lifecycle events (registration, start, stop).
    • Health check endpoints available for system status monitoring.
    • Cryptographic signing support for secure operations.
  • Refactor

    • CLI redesigned to use API-based interactions instead of previous architecture.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add ChallengeRegistered, ChallengeStarted, ChallengeStopped events
- Broadcast events when challenges are registered/started/stopped
- csudo: Add interactive mode, fix short flag conflicts
- Validators receive real-time notifications when challenges change
@coderabbitai
Copy link

coderabbitai bot commented Dec 27, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The pull request refactors the csudo CLI to use a REST-based PlatformClient for challenge management, updates dependencies, and adds event broadcasting to the platform-server. Challenge registration, start, and stop operations now emit WebSocket events to connected validators.

Changes

Cohort / File(s) Summary
CLI Dependency Updates
bins/csudo/Cargo.toml
Removed platform-related crates (platform-network, platform-consensus, platform-storage); replaced reqwest 0.11 with 0.12 and narrowed features; added dialoguer and console for interactive UI; added sp-core workspace dependency.
CLI Implementation Refactor
bins/csudo/src/main.rs
Introduced PlatformClient struct with methods for API communication (health, list_challenges, register_challenge, start_challenge, stop_challenge, remove_challenge); added data types RegisterChallengeRequest, Challenge, ApiResponse, HealthResponse; refactored CLI commands (StartCommands, StopCommands, RemoveCommands, AddCommands); replaced in-process state logic with HTTP-based API calls; added load_keypair helper for keypair initialization.
Server Event Broadcasting
crates/platform-server/src/main.rs
Added broadcast_event calls after challenge registration, start, and stop operations to notify all connected validators via WebSocket.
Server Event Models
crates/platform-server/src/models/mod.rs
Introduced three new public event payload structs (ChallengeRegisteredEvent, ChallengeStartedEvent, ChallengeStoppedEvent); extended WsEvent enum with corresponding variants for challenge lifecycle events.

Sequence Diagram(s)

sequenceDiagram
    participant Client as csudo CLI
    participant Server as Platform Server
    participant Validators as Connected Validators

    rect rgb(220, 240, 255)
    Note over Client,Validators: Challenge Registration Flow
    Client->>Server: POST /api/v1/challenges (RegisterChallengeRequest)
    Server->>Server: Store challenge
    Server->>Validators: Broadcast ChallengeRegistered event
    Validators->>Validators: Receive event via WebSocket
    Server-->>Client: ApiResponse (success)
    end

    rect rgb(240, 255, 240)
    Note over Client,Validators: Challenge Start Flow
    Client->>Server: POST /api/v1/challenges/{id}/start
    Server->>Server: Update challenge status
    Server->>Validators: Broadcast ChallengeStarted event (with endpoint)
    Validators->>Validators: Receive event via WebSocket
    Server-->>Client: ApiResponse (endpoint)
    end

    rect rgb(255, 240, 240)
    Note over Client,Validators: Challenge Stop Flow
    Client->>Server: POST /api/v1/challenges/{id}/stop
    Server->>Server: Update challenge status
    Server->>Validators: Broadcast ChallengeStopped event
    Validators->>Validators: Receive event via WebSocket
    Server-->>Client: ApiResponse (success)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • v1.0.0 Platform #2: Introduces the platform-server endpoints and WebSocket event infrastructure that the csudo PlatformClient now consumes; directly aligned on challenge registration, start, stop, and event broadcasting payloads.

Poem

🐰 A REST-ful hop, the client now flies,
With PlatformClient's modern disguise,
Events broadcast through WebSocket skies,
Challenges spring to life, oh what a prize!
No more RPC—just REST and wise sighs!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eda164e and 40d7349.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • bins/csudo/Cargo.toml
  • bins/csudo/src/main.rs
  • crates/platform-server/src/main.rs
  • crates/platform-server/src/models/mod.rs

Comment @coderabbitai help to get the list of available commands and usage tips.

@echobt echobt merged commit 46542ab into main Dec 27, 2025
3 of 4 checks passed
echobt added a commit that referenced this pull request Feb 21, 2026
…ration (#5)

- Remove all hardcoded chain.platform.network references
- Require explicit CORS and URL configuration (no defaults)
- Update Docker configs for P2P-first architecture
- Update CLI tools to use explicit arguments
- Update documentation to reflect P2P mode as primary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant