Skip to content

donotmerge: insert and clear actor queue#5065

Draft
abcxff wants to merge 1 commit into
mainfrom
05-19-feat_inspector_insert_and_clear_actor_queue
Draft

donotmerge: insert and clear actor queue#5065
abcxff wants to merge 1 commit into
mainfrom
05-19-feat_inspector_insert_and_clear_actor_queue

Conversation

@abcxff
Copy link
Copy Markdown
Contributor

@abcxff abcxff commented May 19, 2026

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
Copy Markdown

railway-app Bot commented May 19, 2026

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

Service Status Web Updated (UTC)
frontend-inspector ❌ Build Failed (View Logs) Web Jun 3, 2026 at 1:14 am
frontend-cloud ❌ Build Failed (View Logs) Web Jun 3, 2026 at 1:14 am
kitchen-sink ❌ Build Failed (View Logs) Web Jun 3, 2026 at 1:13 am
website 😴 Sleeping (View Logs) Web May 30, 2026 at 9:03 pm
ladle ✅ Success (View Logs) Web May 19, 2026 at 8:30 pm
mcp-hub ✅ Success (View Logs) Web May 19, 2026 at 8:20 pm

Copy link
Copy Markdown
Contributor Author

abcxff commented May 19, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 19, 2026

Code Review: PR #5065 — Insert and Clear Actor Queue

Two new inspector HTTP endpoints: DELETE /inspector/queue (clear all messages) and POST /inspector/queue (enqueue a message). The cross-layer wiring (Rust core → NAPI → TypeScript native + wasm runtimes) is consistent with how existing inspector routes are structured.


Correctness: Race Condition in reset()

queue.rsActorContext::reset()

The reset sequence is not atomic with respect to concurrent send() calls:

  1. reset() calls list_message_entries() — snapshot of entries A, B
  2. A concurrent send() acquires queue_metadata lock and enqueues message C with some ID
  3. reset() calls batch_delete([A_key, B_key]) — message C survives in KV
  4. reset() writes {next_id: 0, size: 0} to KV and to the in-memory lock

After this sequence: message C is in KV, but both the in-memory metadata and KV metadata report size: 0 and next_id: 0. The next send() reuses ID 1, creating a duplicate-ID collision with message C.

The fix is to hold queue_metadata across the entire operation — acquiring the lock before list_message_entries() and releasing it only after the in-memory update on line 566. That matches how remove_messages() holds the lock around its KV delete + metadata write.


Performance: Unbounded Memory Load

list_message_entries() calls kv.list_prefix(limit: None), loading the entire queue into memory in a single call. Fine for the expected inspector use case (small, dev-time queues), but worth a comment noting the no-limit behavior so no one widens the call site to production hot paths.


Behavior: Completion Waiter Drops Are Undocumented

clear_async() on queue_completion_waiters silently drops all oneshot::Sender handles. Any concurrent enqueue_and_wait caller will receive QueueCompletionWaiterDropped. This is correct behavior for a "nuke the queue" operation, but a doc comment on reset() noting that in-flight waiters will error would help future maintainers.


Minor: Empty name Is Silently Accepted

InspectorEnqueueBody uses #[serde(default)] on the whole struct with name: String, so POST /inspector/queue with body {} enqueues a message named "". Worth deciding if an empty name should be rejected at the HTTP layer, since send() accepts it without error.


No Tests

The PR description checklist is unchecked and there are no new tests in the diff. A test covering reset() under concurrent send() would both validate correctness and catch the race described above.


Style Nit

inspector.rs line 132: Ok(_) => can be Ok(()) => since reset() returns Result<()>.


Summary: The overall structure and cross-runtime wiring is clean and consistent with existing patterns. The main issue is the race in reset() — holding queue_metadata across the full operation (list → delete → put metadata → update in-memory) is the straightforward fix.

@abcxff abcxff force-pushed the 05-19-feat_inspector_insert_and_clear_actor_queue branch from 3b46462 to a89784a Compare May 19, 2026 21:44
@abcxff abcxff force-pushed the 05-18-fix_rivetkit_wire_cancellationtoken_through_waitfornamesavailable_to_eliminate_kv_busy-polling branch from 73cbe67 to 9dc7e20 Compare May 21, 2026 00:35
@abcxff abcxff force-pushed the 05-19-feat_inspector_insert_and_clear_actor_queue branch from a89784a to 95dd3b3 Compare May 21, 2026 00:35
@abcxff abcxff mentioned this pull request May 21, 2026
11 tasks
@abcxff abcxff changed the base branch from 05-18-fix_rivetkit_wire_cancellationtoken_through_waitfornamesavailable_to_eliminate_kv_busy-polling to graphite-base/5065 May 21, 2026 19:45
@abcxff abcxff force-pushed the 05-19-feat_inspector_insert_and_clear_actor_queue branch from 95dd3b3 to 3f807cd Compare May 21, 2026 19:45
@abcxff abcxff changed the base branch from graphite-base/5065 to 05-21-feat_workflow-engine_add_retryontimeout_opt-in_for_step_timeout_retries May 21, 2026 19:45
@abcxff abcxff force-pushed the 05-21-feat_workflow-engine_add_retryontimeout_opt-in_for_step_timeout_retries branch from f7b5398 to a7e1162 Compare May 22, 2026 04:17
@abcxff abcxff force-pushed the 05-19-feat_inspector_insert_and_clear_actor_queue branch from 3f807cd to 0295ef9 Compare May 22, 2026 04:17
@abcxff abcxff force-pushed the 05-21-feat_workflow-engine_add_retryontimeout_opt-in_for_step_timeout_retries branch from a7e1162 to fccc091 Compare May 22, 2026 05:08
@abcxff abcxff force-pushed the 05-19-feat_inspector_insert_and_clear_actor_queue branch from 0295ef9 to 81264d4 Compare May 22, 2026 05:08
@abcxff abcxff changed the title feat(inspector): insert and clear actor queue donotmerge: insert and clear actor queue Jun 1, 2026
@abcxff abcxff force-pushed the 05-21-feat_workflow-engine_add_retryontimeout_opt-in_for_step_timeout_retries branch from fccc091 to ea20605 Compare June 2, 2026 20:09
@abcxff abcxff force-pushed the 05-19-feat_inspector_insert_and_clear_actor_queue branch from 81264d4 to 4ea4f78 Compare June 2, 2026 20:09
@abcxff abcxff changed the base branch from 05-21-feat_workflow-engine_add_retryontimeout_opt-in_for_step_timeout_retries to graphite-base/5065 June 3, 2026 01:07
@abcxff abcxff force-pushed the 05-19-feat_inspector_insert_and_clear_actor_queue branch from 4ea4f78 to 9bef952 Compare June 3, 2026 01:13
@abcxff abcxff force-pushed the graphite-base/5065 branch from ea20605 to 85cc607 Compare June 3, 2026 01:13
@graphite-app graphite-app Bot changed the base branch from graphite-base/5065 to main June 3, 2026 01:13
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