fix(runtime): route parse error slots through a silent context probe#2670
Merged
Conversation
The parse_error_slot routing decision (actor map vs. thread-local fallback) called hew_actor_current_id(), whose missing-context path writes "execution context not installed" into the generic last-error slot. Every non-actor set/get/clear — the module's own documented fallback path — therefore clobbered an unrelated real error, for every error kind (json/yaml/toml/datetime/cron/...). Add hew_actor_current_id_silent(), which probes current_context() without the diagnostic write, factor the shared actor-id derivation into actor_id_from_context(), and route all three parse_error_slot call sites through the silent probe. The extern "C" hew_actor_current_id() keeps its diagnostic contract bit-for-bit: callers that treat an absent context as a failure still get the last-error write, pinned by a new regression test. Fixes #2658
Extend the dispatch-identity regression: under WASM-scheduler dispatch hew_actor_current_id_silent() must report the same actor ID as the diagnostic accessor, and outside dispatch it must return -1 while leaving the generic last-error slot untouched.
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.
Why
Parse error-slot routing (
set_error/clear_error/get_errorinhew-runtime/src/parse_error_slot.rs) identified the current actor via the diagnostic externhew_actor_current_id(). When no execution context is installed, that extern writes theEXECUTION_CONTEXT_NOT_INSTALLEDsentinel intoLAST_ERRORas a side effect — so merely routing an error slot could corrupt the very error state the slot exists to protect. A prior parse error (or a clean null slot) got clobbered with an unrelated context diagnostic on non-actor threads.Fixes #2658
What
hew_actor_current_id_silent(), apub(crate)probe built on the non-clobberingexecution_context::current_context()and the sharedactor_id_from_contexthelper — same actor-id semantics, noLAST_ERRORwrite. All three parse error-slot routing sites now use it. The diagnostic externhew_actor_current_id()is untouched: same#[no_mangle] extern "C"signature, same sentinel-write contract (callers such as the execution-context tests explicitly consume that write).hew_last_error()null; diagnostic extern returns -1 and writes exactly theEXECUTION_CONTEXT_NOT_INSTALLEDconstant. Four non-actor regressions cover the error slot preserving a prior error and staying null from clean. A WASM scheduler parity test drives a real mailbox → enqueue →hew_sched_rundispatch and asserts both probes agree inside dispatch and stay silent outside it.Test
silent_probe_diverges_from_diagnostic_on_missing_context(actor.rs) — mutation-verified: reverting the silent probe torequire_current_context()fails this test plus all four non-actor slot testsnonactor_*regression tests inparse_error_slot.rs(prior-error preserved; slot stays null from clean)self_api_sees_current_actor_during_dispatchextended inscheduler_wasm.rsfor silent/diagnostic probe parity on the WASM scheduler pathQuality Checklist
.ok()?orunwrap_or_default()in codegen without// JUSTIFIEDcomment// WASM-TODO(#NNN):marker, and newhew_*exports are classified inscripts/jit-symbol-classification.toml(silent probe ispub(crate), not an export; WASM path covered by the parity test)current_context()and the sharedactor_id_from_contexthelper