-
Notifications
You must be signed in to change notification settings - Fork 135
fix(pb): simplify runner wf #3483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(pb): simplify runner wf #3483
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
More templates
@rivetkit/cloudflare-workers
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
Pull Request ReviewOverviewThis PR simplifies the runner workflow by removing the command/event handling logic from the runner workflow and moving event forwarding directly to actor workflows. This is a significant refactoring that reduces ~500 lines of code by eliminating intermediate state management. Key Changes
Code Quality & Best Practices✅ Good:
Potential Bugs❌ CRITICAL: Compilation Error
Performance Considerations✅ Improvements:
Security Concerns✅ No new security issues introduced
Test Coverage
Additional Questions
SummaryThis is a valuable simplification that removes significant complexity from the runner workflow. However, there's a critical compilation error that needs to be fixed before this can be merged. Additionally, the missing event acknowledgment logic needs to be clarified or implemented. Recommendation: Request changes to fix the compilation error and clarify the event acknowledgment and command flow architecture. Review generated following CLAUDE.md conventions for error handling, logging patterns, and code style. |
fa56065 to
fefb6f0
Compare
1a4f15a to
4294775
Compare
Code ReviewOverviewThis PR significantly simplifies the runner workflow by removing event and command tracking logic. The changes reduce the workflow state and delegate more responsibility to actor workflows. Key Changes Analysis1. Removed Event/Command State Management ✅The PR removes:
Positive: This is a good simplification that reduces state size and complexity. 2. Event Forwarding Moved to WebSocket Handler ✅In protocol::ToServer::ToServerEvents(events) => {
let res = ctx.signal(pegboard::workflows::runner2::Forward {
inner: protocol::ToServer::try_from(msg)
.context("failed to convert message for workflow forwarding")?,
})
.tag("actor_id", actor_id)
.graceful_not_found()
// ...
}Issue Found: This code references Looking at the protocol, Recommendation: You need to iterate over the events and extract actor_id properly: protocol::ToServer::ToServerEvents(events) => {
for event in &events.events {
let actor_id = crate::utils::event_actor_id(&event.inner);
let res = ctx.signal(pegboard::workflows::actor::Event {
inner: event.inner.clone(),
})
.to_workflow::<pegboard::workflows::actor::Workflow>()
.tag("actor_id", &actor_id.to_string())
.graceful_not_found()
.send()
.await
.with_context(|| {
format!("failed to forward signal to actor workflow: {}", actor_id)
})?;
if res.is_none() {
tracing::warn!(?actor_id, "failed to send signal to actor workflow, likely already stopped");
}
}
}3. Removed Init Message Handling 🔍The runner workflow no longer processes
Concerns:
Recommendation: Verify that runner initialization is complete elsewhere, or this may break runner connectivity and actor allocation. 4. Simplified Runner Workflow State ✅
struct LifecycleState {
draining: bool,
}Positive: Much cleaner state management. 5. Variable Naming Improvement ✅In 6. Removed Signal Type ✅Removed Potential Issues
Testing Recommendations
Security ConsiderationsNo security issues identified. The changes maintain proper actor ownership validation in KV operations. Performance ConsiderationsPositive: Removing state buffering reduces memory usage and workflow replay time. The simplified state should improve workflow performance. Code Quality
SummaryThis is a good architectural simplification, but has critical compilation errors that must be fixed before merging. The undefined Recommendation: Fix the compilation error, verify the init flow is complete, and add tests before merging. |
|
Critical Bug Found: The variable |
|
PR Review Summary - Part 1: This PR significantly simplifies the runner workflow by removing ~500 lines of code. Major changes include: MUST FIX:
CODE QUALITY ISSUES:
ARCHITECTURAL CONCERNS:
Questions to address:
|
|
PR Review Summary - Part 2: PERFORMANCE CONSIDERATIONS: Positive:
Concerns:
TEST COVERAGE:
POSITIVE CHANGES:
Overall: This is a valuable simplification but needs the compilation fix and testing before merge. The architectural changes need documentation to help understand the new event flow and migration path for existing runners. |
fefb6f0 to
c088d42
Compare
4294775 to
5458e50
Compare
Code ReviewI've reviewed this PR which simplifies the runner workflow. Here's my detailed feedback: 🎯 Overall AssessmentThis is a substantial refactoring that introduces a new protocol version (v4/mk2) and simplifies the runner workflow architecture. The changes are generally well-structured, but there are several areas that need attention. ✅ Strengths
🔴 Critical Issues1. Compilation Errors in tunnel_to_ws_task.rsThe refactored code has critical issues that will prevent compilation: Lines ~45-65: The
The functions appear to have been extracted but weren't properly parameterized. Example: async fn recv_msg() -> Result<std::result::Result<Option<()>, LifecycleResult>> {
let tunnel_msg = tokio::select! {
res = tunnel_sub.next() => { // ❌ tunnel_sub not in scopeFix: Add proper parameters to these functions or inline them back into the main task loop. 2. Missing Signal Type in conn.rs:149ctx.signal(Init); // ❌ What is Init?This signal type doesn't appear to be defined anywhere in the visible code. This will fail to compile. 3. Undefined Helper Function in lib.rsLine 6 references let workflow_id = if protocol::is_new(protocol_version) { // ❌ Undefined functionShould probably be 4. Incorrect Return Type in tunnel_to_ws_task.rsasync fn recv_msg() -> Result<std::result::Result<Option<()>, LifecycleResult>> {
// ...
Ok(Some(data)) // ❌ Returns data but signature says Option<()>
}The function signature says it returns
|
PR Review: fix(pb): simplify runner wfI've reviewed this PR which introduces a new protocol version (v4/mk2) for the pegboard runner workflow and adds an event demuxer for actor events. Critical Issues1. Compilation Errors in tunnel_to_ws_task.rs
These helper functions need to either accept the necessary parameters in their signatures OR be moved inside the main function as closures. 2. Compilation Errors in ws_to_tunnel_task.rs 3. Missing Signal Handling in conn.rs High Priority Issues4. Potential Memory Leak in ActorEventDemuxer 5. Error Handling Silently Drops Send Failures 6. Protocol Version Checking Inconsistencies Medium Priority Issues7. Missing Protocol Version Field 8. Incorrect Message Type Usage Code QualityGood:
Suggestions:
SummaryCannot merge as-is due to compilation errors. Priority fixes:
Once addressed, this is a solid simplification! |
c088d42 to
657b813
Compare
5458e50 to
8431b53
Compare
Code Review: PR #3483 - fix(pb): simplify runner wfI've reviewed this PR which simplifies the runner workflow and introduces protocol version 4. Here are my findings: Critical Issues 🔴1. Compilation Errors in Both refactored task files have multiple critical compilation errors:
These errors suggest the refactoring was incomplete. The functions need proper parameter passing. 2. ActorEventDemuxer: Potential Memory Leak In if let Some(channel) = self.channels.get(&actor_id) {
let _ = channel.tx.send(event);The
Fix: Update if let Some(channel) = self.channels.get_mut(&actor_id) {
channel.last_seen = Instant::now();
let _ = channel.tx.send(event);3. Silently Dropped Events In Recommendation: Log failed sends at minimum: if channel.tx.send(event).is_err() {
tracing::warn!(?actor_id, "failed to send event to actor channel");
}4. Protocol Version Helper Function Inconsistency In pub fn is_mk2(protocol_version: u16) -> bool {
protocol_version > PROTOCOL_MK1_VERSION
}But in High Priority Issues 🟠5. Missing Signal Type in conn.rs
6. Unsafe Task Abort with TODO
// TODO: Verify aborting is safe here
channel.handle.abort();Aborting tasks can leave actors in inconsistent states. This needs verification before merge, or implement graceful shutdown instead. 7. Incorrect Logging Convention
Medium Priority Issues 🟡8. Missing Error Context in Protocol Detection In 9. Unbounded Channel Risk
10. Inconsistent Import Patterns
use anyhow::Context;Following CLAUDE.md: "Always add imports at the top of the file inside of inline within the function." Though the current import is at the top, ensure new code doesn't add inline imports. 11. Potential Integer Overflow
Positive Aspects ✅
Security Considerations 🔒No major security issues identified. The actor validation in KV requests (checking Testing Recommendations 🧪
SummaryThis PR cannot be merged in its current state due to critical compilation errors. The refactoring needs to be completed to properly pass parameters to the extracted functions. The ActorEventDemuxer also needs the Blocking issues before merge:
Would be happy to review again once these are addressed! |
Pull Request ReviewI've reviewed this PR and found several critical issues that prevent compilation: Critical Compilation Errorstunnel_to_ws_task.rs:
ws_to_tunnel_task.rs:
actor_event_demuxer.rs:
Other Issues
Recommendations
This needs significant work before merging. The errors suggest it wasn't tested after refactoring. |
9da2f02 to
5d9024f
Compare
a5ec483 to
9893845
Compare
9893845 to
7dad582
Compare
5d9024f to
246cd19
Compare
PR Review: fix(pb): simplify runner wfOverviewThis PR simplifies the runner workflow by introducing a new protocol version (mk2) and refactoring the WebSocket message handling architecture. The changes are significant and introduce several architectural improvements. Code Quality & Best Practices✅ Strengths
|
7dad582 to
b422891
Compare
246cd19 to
1c47db0
Compare
Merge activity
|

No description provided.