You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ocap-kernel): enqueue async vat syscalls immediately when outside a crank (#848)
## Summary
- When a vat's async operation (e.g. `fetch`) completes **between
cranks**, the resulting `syscall.resolve` was buffered with
`immediate=false`. Since no crank was active to flush the buffer,
notifications were never delivered and the crank loop never restarted —
causing the kernel to hang indefinitely.
- Add `isInCrank()` to the kernel store's crank methods. In
`VatSyscall`, check `isInCrank()` to determine the `immediate` flag:
during a crank, buffer as before; outside a crank, enqueue immediately
to wake the run queue.
- This unblocks any vat method that chains multiple `E()` calls with
real async I/O between vats (e.g. `coordinator → provider(fetch) →
coordinator → keyring → provider(fetch)`).
## Test plan
- [x] All 1983 ocap-kernel unit tests pass
- [x] All 62 kernel-test integration tests pass (persistence, liveslots,
remotes, IO)
- [x] New unit tests for `isInCrank()` (true during crank, false
outside)
- [x] New unit tests for out-of-crank syscall behavior
(`immediate=true`)
- [x] Verified with eth-wallet's `redeemDelegation` pipeline (5-hop E()
chain with real fetch I/O) — previously hung, now completes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes core syscall-to-queue behavior for `send`/`resolve`/`notify`,
which can affect scheduling and ordering across the kernel run loop,
though the change is small and covered by new tests.
>
> **Overview**
> Fixes a kernel hang by making vat syscalls that occur *outside* an
active crank enqueue work immediately instead of buffering it for crank
completion.
>
> Adds `isInCrank()` to crank methods / kernel store, and updates
`VatSyscall` (`send`, `resolve`, and resolved-`subscribe` notify) to set
the queue `immediate` flag based on `!kernelStore.isInCrank()`, with new
unit tests covering both the new API and out-of-crank behavior.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9a8f97c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments