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 25, 2026 at 5:34 am
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

PR Review: fix: runner alloc idx logic, api auth for actor get

Summary

This PR fixes two related issues: (1) runner allocation index logic during drain/eviction, and (2) API auth being required for actor lookups by specific IDs/keys. Overall the approach is correct, but I have some concerns worth discussing.


Concerns

1. Auth bypass logic may need clarification (security)

File: engine/packages/api-public/src/actors/list.rs

The comment says “Reading is allowed, list requires auth” — but this allows unauthenticated access to any actor when the caller knows its ID or key. Since ctx.auth() validates an admin token, this means admin auth is only needed to list all actors, but any caller who knows an actor ID can fetch it without credentials.

This may be intentional (e.g., actors have public-readable state by design), but the comment should clarify why unauthenticated reads are safe here — specifically, whether actor IDs/keys are considered non-secret or whether there is another access control layer downstream.

2. Incomplete eviction handling in tunnel_to_ws_task.rs

The PR changes the eviction_sub.next() path to return Ok(Err(LifecycleResult::Evicted)), which correctly skips clearing the alloc idx. However, other eviction paths in the same file still return Err(errors::WsError::Eviction.build()):

  • protocol::mk2::ToRunner::ToRunnerClose
  • protocol::ToRunner::ToClientClose

If ToRunnerClose / ToClientClose are sent as part of a drain/eviction flow, those paths would still incorrectly clear the alloc idx. It may be that these have distinct semantics (protocol-level close vs. eviction subscription signal), but if they can fire during an eviction it would undermine this fix.


Positives

  • Draining vs expired distinction — removing the redundant ExpiredTsKey write when setting Draining state (in both runner.rs and runner2.rs) and instead checking DrainTsKey explicitly in update_alloc_idx is a clean fix. Draining and expired are distinct states and conflating them was the root cause.

  • LifecycleResult::Evicted variant — threading the eviction signal back through the result type rather than using an error is a good use of the type system. It allows the eviction path to skip the alloc idx clear while still surfacing an error to the caller.

  • Path display fixdb_path=%db_path.display() over ?db_path is correct; % (Display) is more appropriate for user-visible paths than ? (Debug).

  • Removed “critical:” prefix from the error log — consistent with log style guidelines.

  • Warning log for non-empty notifications — useful diagnostic for catching unexpected update_alloc_idx responses during drain.

  • OpenAPI description for input — small but helpful documentation improvement.


Minor

The else block in lib.rs has else on its own line after }. Idiomatic Rust (and rustfmt) places it on the same line as }. Not blocking, but cargo fmt would change this.

@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 force-pushed the 03-17-fix_runner_alloc_idx_logic_api_auth_for_actor_get branch from 84dbf32 to 90c2e97 Compare March 24, 2026 00:30
@MasterPtato MasterPtato mentioned this pull request Mar 24, 2026
11 tasks
@MasterPtato MasterPtato force-pushed the 03-17-fix_runner_alloc_idx_logic_api_auth_for_actor_get branch from 90c2e97 to ebdaa13 Compare March 24, 2026 00:36
@MasterPtato MasterPtato force-pushed the 03-17-fix_runner_alloc_idx_logic_api_auth_for_actor_get branch from ebdaa13 to 63b3a1f Compare March 25, 2026 00:05
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