fix(runtime): whole-train hardening for the mock preset and testing DX#205
Open
mfw78 wants to merge 2 commits into
Open
fix(runtime): whole-train hardening for the mock preset and testing DX#205mfw78 wants to merge 2 commits into
mfw78 wants to merge 2 commits into
Conversation
…cribe Closing a mock stream previously parked every later subscribe call on a pending stream and silently dropped subsequent pushes, so a harness test that scripted a connection drop diverged from the real provider, whose subscription reopens after backoff and resumes delivery. Each stream slot now re-arms on close: the open stream drains and terminates, and the next subscribe call receives a fresh stream fed by the pushes made since.
… and reconnect legs The [limits] knobs (fuel, memory, outbound HTTP, log retention, poison thresholds) were unreachable through TestRuntimeBuilder, which pinned the default EngineConfig. A limits setter now threads them into the launch, locked by a log-retention test observable through the pipeline. Two end-to-end gaps close alongside: price-alert drives the chain-request leg (programmed eth_call response to alert log line), and a scripted block-stream drop proves dispatch resumes once the event loop reconnects onto the re-armed mock. The wasm fixture helper takes the artifact name so harness tests can load any built module.
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
End of the epic #80 (mock preset and testing DX) train. This PR is a red-team pass over the whole train, hardening the
TestRuntimeharness and the mock chain provider so the harness cannot silently diverge from the real event loop it is meant to stand in for.Why
A prior audit walked the composed builder path (
RuntimeBuilder::new -> with_types::<MockTypes<E>> -> with_extensions -> with_module_source -> with_wasi_clocks -> with_components(Prebuilt(...)) -> launch) against the real spawned event loop and found two defects that would make the harness lie to module authors, plus a coverage gap on the chain-request leg. Fixing these closes out #80.Changes
close_block_streamclosed a fixed channel forever, so a re-subscribe after a scripted drop gotfutures::stream::pending()and every laterpush_blockwas silently dropped.StreamSlot<T>now drains-and-terminates the open stream onclose, then re-arms a fresh pair per kind.ModuleLimits, including the train's[limits.poison]knob) onTestRuntimeBuildervia a newlimits()method, threaded into the launch config. PreviouslyTestRuntimeBuilderpinnedEngineConfig::default(), so the harness could not exercise the config knob the train itself shipped.harness_serves_chain_requests_to_the_module, locking theChainProvider::requestleg from a guest (price-alert module, programmed oracle answer, asserts the triggered log and the recordedeth_call). Previously only block and chain-log dispatch were locked.harness_resumes_dispatch_after_a_dropped_block_stream, a composed anti-lie lock across the reconnect task and the re-armed mock stream (close, real backoff, block 42 dispatches).module_wasm_or_skip(file).Test plan
SKIP:lines in the run.cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test -p nexum-runtime(196 passed, 0 failed)RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-depscargo check -p nexum-runtimebuilds withtest-utilsoff by default; the feature is enabled only by the crate's own dev-dependency,nexum-cliandshepherd-cow-hostdepend featureless, and the Cargo.lock delta is limited to the self dev-dependency entry.Deferred documentation
limitsknob in its narrative paragraph, though the method doc covers it; a follow-up docs pass should add it.Notes
Also, as a DX read on the harness (writing the price-alert test as a module author would): about 30 lines including the manifest, genuinely low ceremony. One wrinkle worth a follow-up: mock programming happens via
builder.chain()on a bound variable becauseon_methodreturns&MockChainProvider, so the builder chain cannot stay a single expression.Follow-ups filed against #80 rather than blocking this PR:
SystemTime::now()) to proveManualClockguest-visibility end to end; today the override is locked at plumbing level only.Instantand cost the reconnect e2e a real 1s wait.configure_chain(|c| ...)-style builder hook to restore single-expression harness setup.AI Assistance: Claude Code (Fable 5 red-team and fixes, Sonnet 5 PR authoring) used for the full change.