Commit 03b6a62
authored
fix(ocap-kernel): restore IO channels for persisted subclusters (#963)
## Summary
- Adds `SubclusterManager.restorePersistedIOChannels()` and calls it
from `Kernel.#init` before `initializeAllVats`.
- Walks every persisted subcluster, finds those whose config declares
`io`, and re-creates the channels via the `IOManager`.
- Per-subcluster failures are logged but do not abort the broader init.
## Why
Subclusters that declare `config.io` (Unix sockets, named pipes, etc.)
had their channels created inside `launchSubcluster` only. On a kernel
restart the persisted vats are re-incarnated via `initializeAllVats`,
but their IO channels were never re-created — any `IOService` references
the vats held went dead at first use after the restart.
Concretely: the `@ocap/service-matcher` matcher vat persists across
restarts (its OCAP URL is deterministic and its registry is in baggage),
and it holds an `IOService` reference for the `llm` socket used to talk
to its LLM bridge. After a `daemon stop` / `daemon start` cycle, the
matcher vat came back up but the first registration attempt failed
inside `ingestService` because the `llm` channel no longer existed in
the kernel's `IOManager`. With this fix, the channel is re-established
before any vat code runs.
## Test plan
- [x] 4 new unit tests in `SubclusterManager.test.ts` covering:
multi-subcluster restoration, skipping subclusters with no IO config,
no-op when IOManager is absent, and continuing past a per-subcluster
failure.
- [x] `yarn workspace @MetaMask/ocap-kernel test:dev:quiet --run` — all
package tests pass.
- [x] `yarn workspace @MetaMask/ocap-kernel lint` — clean.
- [ ] CI green.
- [ ] End-to-end verification (in a downstream branch): `daemon
stop`/`start` cycle now leaves the matcher's `llm` IOService live; first
service registration after restart succeeds.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!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 `IOService` references** after a kernel restart when
subclusters were only created once via `launchSubcluster`.
>
> Adds **`SubclusterManager.restorePersistedIOChannels()`**, which scans
persisted subclusters with `config.io` and calls
**`IOManager.createChannels`** again (same as at launch).
**`Kernel.#init`** now awaits this **after** `initSystemSubclusters` and
**before** `initializeAllVats`, so IO kernel services exist before
re-incarnated vats run.
>
> Per-subcluster **`createChannels`** failures are **logged only**; init
continues for other subclusters. **No-op** if no `IOManager` was wired.
**CHANGELOG** and **four unit tests** cover the new behavior.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
96ed00e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 7c3845b commit 03b6a62
4 files changed
Lines changed: 174 additions & 0 deletions
File tree
- packages/ocap-kernel
- src
- vats
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
285 | 291 | | |
286 | 292 | | |
287 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
824 | 939 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
371 | 421 | | |
372 | 422 | | |
373 | 423 | | |
| |||
0 commit comments