Skip to content

fix(runtime): epic mock-preset train follow-ups#204

Open
mfw78 wants to merge 1 commit into
feat/m0-test-harnessfrom
fix/m0-mock-followups
Open

fix(runtime): epic mock-preset train follow-ups#204
mfw78 wants to merge 1 commit into
feat/m0-test-harnessfrom
fix/m0-mock-followups

Conversation

@mfw78

@mfw78 mfw78 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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

  • Added push_block_err, push_chain_log_err, close_block_stream, and close_chain_log_stream on MockChainProvider, so tests can script stream errors and stream-end conditions rather than only successful items.
  • Documented the UnknownChain caveat on the mock request path: this variant conflates "chain absent" with "method not scripted" and must not be read as a chain-presence signal.
  • Added pub(crate) test_utils::in_memory_logs() as the single construction site for the in-memory LogPipeline, and switched mock_components_from and both supervisor/tests.rs bundles to use it, removing duplicated construction.
  • Reworded the PoisonLimitsSection rustdoc and the [limits.poison] block in engine.example.toml to state that the poison policy fires at max_failures, not one past it.
  • Added a commented [limits.logs] example block to engine.example.toml, matching the resolved defaults of 262144 and 16.
  • Added harness_dispatches_chain_logs, a test that drives a kind = "chain-log" module through the harness end to end, locking in the chain-log injection leg.
  • Documented MockTypes as a type-level marker that is never constructed, in place of deriving Clone/Default that no call site needs.

Test plan

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo 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 existing harness_launches... test, none skipped)
  • cargo doc --workspace --no-deps with RUSTDOCFLAGS=-D warnings
  • cargo clippy without test-utils enabled, confirming the mock cone stays out of a default build

Notes 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:

  • An optional MockRuntime preset for .runtime::<MockRuntime>() sugar needs a preset-level instance-injection path that today's config-driven presets do not have; the existing mock_components* and harness helpers already cover the in-tree need.
  • Asserting guest-observed time in the clock end-to-end test needs a new guest fixture that reads wasi:clocks and writes the observed value into the mock store; the reference example module reads no clock today.
  • Replacing the harness's wall-clock poll barrier with a deterministic signal needs a paused-clock drive or an event-loop readiness signal; the current 2ms/5s poll is correct but out of scope for this change.

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 in supervisor.rs still read "more than max_failures" and should be aligned to "reaches max_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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant