Skip to content

fix: runner alloc idx logic, api auth for actor get#4443

Open
MasterPtato wants to merge 1 commit intomainfrom
03-17-fix_runner_alloc_idx_logic_api_auth_for_actor_get
Open

fix: runner alloc idx logic, api auth for actor get#4443
MasterPtato wants to merge 1 commit intomainfrom
03-17-fix_runner_alloc_idx_logic_api_auth_for_actor_get

Conversation

@MasterPtato
Copy link
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@railway-app
Copy link

railway-app bot commented Mar 17, 2026

🚅 Deployed to the rivet-pr-4443 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-cloud 😴 Sleeping (View Logs) Web Mar 23, 2026 at 2:19 pm
frontend-inspector 😴 Sleeping (View Logs) Web Mar 19, 2026 at 3:17 pm
website ❌ Build Failed (View Logs) Web Mar 17, 2026 at 7:41 pm
mcp-hub ✅ Success (View Logs) Web Mar 17, 2026 at 7:39 pm
ladle ❌ Build Failed (View Logs) Web Mar 17, 2026 at 7:38 pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 17, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4443

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4443

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4443

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4443

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4443

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4443

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4443

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4443

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4443

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4443

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4443

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4443

commit: 84dbf32

@claude
Copy link

claude bot commented Mar 17, 2026

Code Review

engine/packages/pegboard-runner/src/lib.rs - Eviction refactor

The eviction refactoring is a meaningful improvement. Separating LifecycleResult::Evicted from WsError::Eviction and skipping ClearIdx on the eviction path is correct - a freshly evicted runner should not have its alloc index cleared here, since the eviction itself already implies the runner is leaving the pool.

Potential edge case in the result matching:
If ws_to_tunnel_res returns Ok(Evicted) while tunnel_to_ws_res returns something other than Ok(Aborted) (e.g. Ok(Closed)), the third match arm (res, _, _) returns Ok(Closed) and the Evicted result is silently dropped - ClearIdx would then be called when it should not be. This scenario is likely prevented in practice if eviction in one task sends an abort signal to the other (so the other always returns Aborted), but it is fragile. Consider adding a match arm that prefers Evicted over Aborted/Closed.

The if/else pattern here places a comment between } and else. Standard Rust style puts the comment before or inside the else block.

The removal of the "critical:" string prefix from the log message is fine; that was a string prefix rather than a structured field anyway.


engine/packages/pegboard/src/ops/runner/update_alloc_idx.rs - Semantic change

The change from tx.exists(&old_alloc_key, Serializable).await? to !draining is a meaningful semantic shift. The old condition checked whether the alloc key actually existed in the index; the new condition checks whether the runner is draining.

These are not equivalent: a non-draining runner could have no alloc key (e.g. never indexed, or already cleared), and a draining runner could still have a stale alloc key. If the goal is "skip alloc index updates while draining," this is intentional and correct - but if a draining runner retains a stale key, it will not be cleaned up by this path. Worth verifying there is no scenario where a draining runner has a stale key that never gets cleared.

The batch read of drain_ts_key and expired_ts_key as booleans via tx.exists in the initial tokio::try_join! is cleaner than the previous in-transaction await call.


engine/packages/pegboard/src/workflows/runner.rs and runner2.rs - ExpiredTsKey removal on Drain

Removing the ExpiredTsKey write from the Draining branch is a correct bug fix. Draining and Expired are distinct states; conflating them was causing the eviction path to incorrectly short-circuit allocation index updates.

The added warning log in runner2.rs for non-empty update_alloc_idx notifications is a useful diagnostic.


engine/packages/api-public/src/actors/list.rs - Auth bypass

This makes specific-actor reads unauthenticated (capability-style: knowing the actor ID grants read access). A few things worth confirming:

  1. Actor IDs as capabilities: Are actor IDs intended to be unguessable (e.g. random UUIDs)? If they are predictable, this pattern exposes actor metadata to anyone who can enumerate them.
  2. What does ctx.skip_auth() do? If it marks auth as satisfied without any credential check, there is zero access control for these reads. Is that intentional, or should there be a softer check (e.g. rate-limiting, project scoping)?
  3. The comment "Reading is allowed, list requires auth" describes the intent, but inline documentation on the endpoint's access model would help future maintainers.

engine/artifacts/errors/serverless_runner_pool.failed_to_fetch_metadata.json - Nit

Missing newline at end of file.


Other changes

  • api-types/src/actors/create.rs: Doc comment addition is clear and accurate.
  • openapi.json: Description matches the doc comment.
  • universaldb/src/driver/rocksdb/database.rs: Correct fix - %db_path.display() is the right way to log a PathBuf using Display rather than Debug.
  • tunnel_to_ws_task.rs / ws_to_tunnel_task.rs: The change from Err(WsError::Eviction) to Ok(Err(LifecycleResult::Evicted)) correctly moves error-conversion responsibility to lib.rs, keeping task return types consistent.

@MasterPtato MasterPtato force-pushed the 03-17-fix_runner_alloc_idx_logic_api_auth_for_actor_get branch from 5b2bead to cfc4fad Compare March 17, 2026 20:38
@MasterPtato MasterPtato force-pushed the 03-17-fix_runner_alloc_idx_logic_api_auth_for_actor_get branch from cfc4fad to 65280b5 Compare March 18, 2026 22:12
@MasterPtato MasterPtato force-pushed the 03-17-fix_runner_alloc_idx_logic_api_auth_for_actor_get branch from 65280b5 to 84dbf32 Compare March 21, 2026 01:55
@MasterPtato MasterPtato mentioned this pull request Mar 21, 2026
11 tasks
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