fix(runtime): epic mock-preset train follow-ups#204
Open
mfw78 wants to merge 1 commit into
Open
Conversation
…ess leg Extend the in-process mock chain with scriptable error and stream-end injection (push_block_err, push_chain_log_err, close_block_stream, close_chain_log_stream) so reconnect-and-backoff behaviour on the block and chain-log stream contracts can be unit-tested against the fake, and note on request that an unprogrammed method surfaces UnknownChain, so a caller does not read it as a chain-presence signal. Add a chain-log fixture test that drives a chain-log subscription through the harness, locking the log-stream path the way the block path is locked, and share the in-memory log-pipeline construction across the fake test bundles through one test_utils helper. Correct the operator-facing poison wording (quarantine fires at max_failures, not one past it), add the missing limits.logs example block to engine.example.toml, and note that MockTypes is a type-level marker.
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
Closes #80; part of the epic #80 train, merges in stack order.
This PR addresses ten follow-up items raised against the mock preset and test harness work, hardening the mock chain provider, tidying shared test scaffolding, and correcting an off-by-one in the poison policy documentation.
Changes
push_block_err,push_chain_log_err,close_block_stream, andclose_chain_log_streamonMockChainProvider, so tests can script stream errors and stream-end conditions rather than only successful items.UnknownChaincaveat on the mock request path: this variant conflates "chain absent" with "method not scripted" and must not be read as a chain-presence signal.pub(crate) test_utils::in_memory_logs()as the single construction site for the in-memoryLogPipeline, and switchedmock_components_fromand bothsupervisor/tests.rsbundles to use it, removing duplicated construction.PoisonLimitsSectionrustdoc and the[limits.poison]block inengine.example.tomlto state that the poison policy fires atmax_failures, not one past it.[limits.logs]example block toengine.example.toml, matching the resolved defaults of 262144 and 16.harness_dispatches_chain_logs, a test that drives akind = "chain-log"module through the harness end to end, locking in the chain-log injection leg.MockTypesas a type-level marker that is never constructed, in place of derivingClone/Defaultthat no call site needs.Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features(all suites pass, including the four new tests:block_stream_scripts_errors_and_end,chain_log_stream_scripts_errors_and_end,harness_dispatches_chain_logs, and the existingharness_launches...test, none skipped)cargo doc --workspace --no-depswithRUSTDOCFLAGS=-D warningscargo clippywithouttest-utilsenabled, confirming the mock cone stays out of a default buildNotes for reviewer
Three items from the original follow-up list are deferred rather than implemented here, each for a reason that needs more than a mechanical change:
MockRuntimepreset for.runtime::<MockRuntime>()sugar needs a preset-level instance-injection path that today's config-driven presets do not have; the existingmock_components*and harness helpers already cover the in-tree need.wasi:clocksand writes the observed value into the mock store; the reference example module reads no clock today.One related item surfaced during implementation but sits outside the poison-wording item's scope:
runtime/poison_policy.rs's module doc and a transition comment insupervisor.rsstill read "more thanmax_failures" and should be aligned to "reachesmax_failures" for full internal consistency with the change made here.AI Assistance: Claude Code (Opus 4.8 implementation and adversarial review, Sonnet 5 PR authoring) used for the full change.