|
Download tasks/data/reverse/abdelstark__guts.8876fcf/environment/docs/MILESTONE-6.md from Lego-X/ProgramGen: direct link, hf CLI and curl.
- Browser
- Download file 5.65 kB
-
https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/reverse/abdelstark__guts.8876fcf/environment/docs/MILESTONE-6.md
- Command line
-
hf download hf://datasets/Lego-X/ProgramGen/tasks/data/reverse/abdelstark__guts.8876fcf/environment/docs/MILESTONE-6.md
-
curl -L -o MILESTONE-6.md https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/reverse/abdelstark__guts.8876fcf/environment/docs/MILESTONE-6.md
5.65 kB
Milestone 6: Real-time Updates & Notifications
Status: In Progress Started: 2025-12-21
Overview
Milestone 6 implements real-time updates using WebSockets, enabling live notifications and instant updates across the platform. This enhances the user experience by eliminating the need to refresh pages to see new activity.
Goals
- WebSocket Server: Persistent connections for real-time communication
- Event Broadcasting: Broadcast repository events to connected clients
- Notification System: In-app notifications for subscribed events
- Live Updates: Real-time UI updates for PRs, Issues, Comments, and Repository changes
New Crate: guts-realtime
Technology Choices
| Component | Technology | Rationale |
|---|---|---|
| WebSocket | tokio-tungstenite | Production-ready, async WebSocket |
| Channels | tokio::sync::broadcast | Efficient multi-consumer broadcasting |
| Serialization | serde_json | JSON messages for browser compatibility |
WebSocket Protocol
Connection URL
Message Types
Client -> Server:
Server -> Client:
Channel Types
| Channel Pattern | Description | Example |
|---|---|---|
repo:{owner}/{name} |
All events for a repository | repo:alice/myrepo |
repo:{owner}/{name}/prs |
Pull request events only | repo:alice/myrepo/prs |
repo:{owner}/{name}/issues |
Issue events only | repo:alice/myrepo/issues |
user:{username} |
Notifications for a user | user:alice |
org:{orgname} |
Organization events | org:acme |
Event Types
| Event | Description | Payload |
|---|---|---|
push |
Code pushed to repository | ref, before, after, commits |
pr.opened |
Pull request created | pr_number, title, author |
pr.closed |
Pull request closed | pr_number, merged |
pr.merged |
Pull request merged | pr_number, merge_commit |
pr.review |
Review submitted | pr_number, reviewer, state |
pr.comment |
Comment on PR | pr_number, comment_id, author |
issue.opened |
Issue created | issue_number, title, author |
issue.closed |
Issue closed | issue_number |
issue.comment |
Comment on issue | issue_number, comment_id |
branch.created |
Branch created | ref, sha |
branch.deleted |
Branch deleted | ref |
Data Flow
Phase 1: Foundation
- Create
guts-realtimecrate structure - Implement event types and serialization
- Create connection hub for managing clients
- Add WebSocket upgrade handler in guts-node
- Implement ping/pong keepalive
Phase 2: Subscriptions
- Implement subscription management
- Add channel parsing and validation
- Create subscription storage per client
- Implement unsubscribe logic
- Add subscription limits and rate limiting
Phase 3: Event Broadcasting
- Integrate with existing webhook events
- Add event emission in API handlers
- Implement broadcast to subscribed clients
- Add event filtering by channel
- Implement event buffering for reconnection
Phase 4: Web UI Integration
- Add WebSocket client JavaScript
- Update templates with real-time containers
- Implement live update animations
- Add connection status indicator
- Handle reconnection gracefully
Phase 5: Notifications
- Create notification storage
- Implement notification preferences
- Add notification badge to UI
- Create notification dropdown/panel
- Implement mark-as-read functionality
API Integration
Event Emission
WebSocket Handler
Success Criteria
- WebSocket connections work reliably
- Events broadcast within 100ms of mutation
- UI updates without page refresh
- Reconnection handles gracefully (with backoff)
- 1000+ concurrent connections supported
- No memory leaks with connection churn
- Notifications persist across sessions
- Mobile-friendly notification display
Dependencies
futures-util: Stream utilitiestokio::sync::broadcast: Event broadcastingguts-auth: Webhook event types (reused)guts-collaboration: PR/Issue typesserde_json: Message serialization
Security Considerations
- Rate Limiting: Limit subscription count and message rate per client
- Channel Authorization: Verify user has access to subscribed channels
- Message Validation: Sanitize all incoming messages
- Connection Limits: Cap concurrent connections per IP/user
- TLS: Require WSS in production
Performance Considerations
- Connection Pooling: Efficient memory use per connection
- Broadcast Channels: Use tokio broadcast for O(1) distribution
- Message Batching: Combine rapid events into batches
- Lazy Serialization: Serialize events once, send to many
- Backpressure: Handle slow clients without blocking
Future Enhancements
These features are out of scope for Milestone 6 but planned:
- Push Notifications: Mobile/desktop push via service workers
- Email Digests: Periodic email summaries of notifications
- Mention Detection: Parse @mentions in comments
- Watch Lists: Follow specific PRs/Issues
- Notification Rules: Custom filtering rules