refactor(host): make HostState generic over the component backends#110
Merged
Conversation
HostState, every WIT Host impl, the supervisor, and the event loop are now generic over the component seam traits, with the concrete pools wired in bootstrap. Chain ids are typed as alloy_chains::Chain end to end including the engine config map keys, the CoW passthrough method is typed as http::Method, and HttpClient::fetch speaks http::Request/Response. Store and linker construction are deduplicated behind build_store and build_linker.
mfw78
force-pushed
the
refactor/host-generic-hoststate
branch
from
July 2, 2026 12:16
af044e3 to
dff5ae2
Compare
This was referenced Jul 2, 2026
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.
What
Makes
HostStategeneric over the component seam:HostState<C, W, S, H>(chain, cow, store handle, http), with all ten WITHostimpls rewritten as generic impls bounded on the seam traits, aComponentsbundle threading the shared backends through a genericSupervisorand event loop, and the concrete pools wired inbootstrap. Store and linker construction are deduplicated behindbuild_storeandbuild_linker, removing the near-identical blocks the module-restart path carried.Three typing improvements ride the rewrite, since these are exactly the signatures being rewritten:
alloy_chains::Chainend to end: the seam traits, both pools, the event loop, the supervisor, and theengine.tomlchains map keys (HashMap<Chain, ChainConfig>; numeric TOML keys stay canonical and named keys such as[chains.sepolia]now also parse; no existing config file changes). Every metric label, structured log field, and the persistedlast_dispatched_blockkey keeps the numeric id, pinned by a new test, so observable identifiers and stored data are unchanged.http::Method, with the four-method allowlist and its error text preserved and the guest string uppercased before parsing at the WIT glue.HttpClient::fetchspeakshttp::Request<Vec<u8>>/http::Response<Vec<u8>>with an explicit timeout, keeping the seam free of bindgen types; conversion lives in the glue and the stub's guest-visible message is byte-identical.Why
The concrete pools were baked into
HostState, so backends could not be swapped or faked and every host impl was welded to production types. This is the structural step that lets the following change collapse the runtime's shape into a single associated-type lattice parameter, and it was the one moment the chain-id, method, and HTTP typing could land without touching the same ten impl blocks twice.Closes #87. Closes #101. Closes #102. Closes #104.
Testing
Executed in five ordered slices, each passing the full workspace gate (fmt, clippy with
-D warnings, rustdoc with-D warnings, tests) before the next began. New tests: named-key and invalid-key config parsing, and the progress-marker key format pin for a named chain. Final audits confirm noBTreeMap<u64, _>remains, noChainreaches a metric label, log field, or persisted key through its Display form, and the WIT boundary still speaks plainu64.AI Assistance: Claude Code used for implementation, adversarial review, and PR preparation.