fix(ocap-kernel): restore IO channels for persisted subclusters#963
Merged
Conversation
Subclusters that declared `config.io` (Unix sockets, etc.) had their channels created inside `launchSubcluster` only. On a kernel restart the persisted vats were re-incarnated via `initializeAllVats` but their IO channels were never re-created, so any IOService references the vats held went dead at first use. Add `SubclusterManager.restorePersistedIOChannels()` and call it from `Kernel.#init` before `initializeAllVats`. Walks the persisted subcluster table and re-creates declared IO channels via the IOManager. Per-subcluster failures are logged and skipped rather than aborting the broader init.
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SubclusterManager.restorePersistedIOChannels()and calls it fromKernel.#initbeforeinitializeAllVats.io, and re-creates the channels via theIOManager.Why
Subclusters that declare
config.io(Unix sockets, named pipes, etc.) had their channels created insidelaunchSubclusteronly. On a kernel restart the persisted vats are re-incarnated viainitializeAllVats, but their IO channels were never re-created — anyIOServicereferences the vats held went dead at first use after the restart.Concretely: the
@ocap/service-matchermatcher vat persists across restarts (its OCAP URL is deterministic and its registry is in baggage), and it holds anIOServicereference for thellmsocket used to talk to its LLM bridge. After adaemon stop/daemon startcycle, the matcher vat came back up but the first registration attempt failed insideingestServicebecause thellmchannel no longer existed in the kernel'sIOManager. With this fix, the channel is re-established before any vat code runs.Test plan
SubclusterManager.test.tscovering: multi-subcluster restoration, skipping subclusters with no IO config, no-op when IOManager is absent, and continuing past a per-subcluster failure.yarn workspace @metamask/ocap-kernel test:dev:quiet --run— all package tests pass.yarn workspace @metamask/ocap-kernel lint— clean.daemon stop/startcycle now leaves the matcher'sllmIOService live; first service registration after restart succeeds.🤖 Generated with Claude Code
Note
Medium Risk
Touches kernel init ordering and external IO resources (sockets); failures are isolated per subcluster but affected vats still break at first IO use until the channel is restored.
Overview
Fixes dead
IOServicereferences after a kernel restart when subclusters were only created once vialaunchSubcluster.Adds
SubclusterManager.restorePersistedIOChannels(), which scans persisted subclusters withconfig.ioand callsIOManager.createChannelsagain (same as at launch).Kernel.#initnow awaits this afterinitSystemSubclustersand beforeinitializeAllVats, so IO kernel services exist before re-incarnated vats run.Per-subcluster
createChannelsfailures are logged only; init continues for other subclusters. No-op if noIOManagerwas wired. CHANGELOG and four unit tests cover the new behavior.Reviewed by Cursor Bugbot for commit 96ed00e. Bugbot is set up for automated code reviews on this repo. Configure here.