fix(runtime): whole-train hardening for the typed-fault stack#219
Open
mfw78 wants to merge 2 commits into
Open
fix(runtime): whole-train hardening for the typed-fault stack#219mfw78 wants to merge 2 commits into
mfw78 wants to merge 2 commits into
Conversation
The orderbook rejection envelope has an optional structured data field (e.g. a minimum-fee quote) that the retired host-error envelope round-tripped in full but the typed order-rejection dropped. Add data: option<string> to the record, populate it host-side from the parsed envelope, and thread it through the SDK mirror and the wit-bindgen conversion so no rejection information is lost end to end.
Nothing guest-side decodes the orderbook ApiError JSON any more: the host parses the envelope once into the typed order-rejection and the classifier dispatches on that. The re-export and its comment described the retired flow, so remove them from the prelude surface.
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 out the typed-fault train (epic #206) with a red-team pass over the whole stack, from the unified
host-errorenvelope's replacement by the per-interfacefaultvocabulary through to the WASI-idiom end state on this tip.The verdict: the envelope is fully dead (zero
host-error/HostError/domain/kind/codedispatch remaining anywhere incrates/,modules/, orwit/), each interface's error type honestly matches what it can fail with, and the chain revert and cow-rejection traces are lossless end to end, except one hole this PR closes.Changes
datapayload. The retiredhost-errorenvelope round-tripped the wholeApiError(includingdata, e.g. a minimum-fee quote) but the typedorder-rejectionrecord dropped it, soorderbook_error_to_witsilently discarded information the old flow preserved. Addsdata: option<string>to the WIT record, populates it host-side from the parsed envelope, and threads it through the SDK mirror and thewit-bindgenconversion. This is a pre-1.0 wire break, sanctioned, and the affected wasms are rebuilt.ApiErrorprelude re-export inshepherd-sdk/src/prelude.rs. Nothing guest-side decodesApiErrorany more since the host parses the envelope once and the classifier dispatches on the typed rejection; the re-export's comment described a flow that no longer exists.Test plan
just ci(fmt, clippy-D warnings, rustdoc-D warnings, all 11 module wasms, full workspace tests) exits clean on the fixed tree.cow_bootend-to-end tests exercised the real artefacts, not stubs:e2e_twap_monitor,e2e_stop_loss,e2e_ethflow,e2e_http_probe, and the rest all pass, zero SKIP lines, zero failures.dataround-trip throughorderbook_error_to_wit.Notes
Broader red-team findings that came back clean, for the record: exhaustive macro conversions in both directions (the only wildcard arm sits on the
#[non_exhaustive]SDK side and folds toInternalwithDisplaydetail preserved, not a re-creation of the envelope), supervisor telemetry now emits stablefault_label/fault_messagesnake_case metric labels, and the epic-80 harness (MockChain/MockLocalStore/MockCowApi) is reshaped to the typed errors and still exercises the module tests correctly.Deferred documentation
docs/adr/0011-per-interface-typed-errors.mdline 11 describes the cow rejection shape as{errorType, description}; it should read{errorType, description, data}after this fix. Left for the prose pass.docs/07-rpc-namespace-design.mdand the migration guide could call out thedatapayload explicitly; the WIT-snippet lines themselves are already corrected in this PR.Follow-ups (not implemented here)
impl From<&CowApiError> for RetryActionat the SDK level:twap-monitorandstop-losscurrently duplicate the identical "Rejectedclassifies, everything else retries on next block" match.rate-limit.retry-after-ms: the 429 mapping intransport_faultalways sendsNone; capturing the upstreamRetry-Afterheader needs alloy transport-layer support.transport_fault(msg.contains("timed out")) with a host-side request deadline or a typed alloy timeout signal.fault_messagerenders the fixed phrase "rate limited" forRateLimitedwithout theretry_after_msdetail when present.request-batch's outerchain-erroris structurally dead on the reference host; either flatten the WIT tolist<rpc-result>or record in ADR-0011 why the escape hatch stays for other hosts.AI Assistance: Claude Code (Fable 5 red-team and fixes, Sonnet 5 PR authoring) used for the full change.