feat(wit-abi): add the fault vocabulary and SDK HostFault surface#213
Open
mfw78 wants to merge 1 commit into
Open
feat(wit-abi): add the fault vocabulary and SDK HostFault surface#213mfw78 wants to merge 1 commit into
mfw78 wants to merge 1 commit into
Conversation
Add a fault variant and rate-limit record to nexum:host/types alongside the existing host-error record, with no consumers moving yet. The richer per-interface errors that follow embed fault as a shared, payload-bearing failure case. Mirror Fault and RateLimit in nexum-sdk with thiserror, snake_case IntoStaticStr labels and non_exhaustive, plus a HostFault trait that recovers the embedded fault and a stable label from a richer error.
6 tasks
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 #207, part of the typed-fault train stacked on the epic-80 stack, merges in stack order.
Adds the shared fault vocabulary that later host interfaces will embed as a case, plus the SDK-side mirror that module authors program against.
Changes
wit/nexum-host/types.wit: addedvariant faultwith the seven specified cases (unsupported,unavailable,denied,rate-limited,timeout,invalid-input,internal) andrecord rate-limit { retry-after-ms: option<u64> }, both alongside the existing untouchedhost-errorrecord.crates/nexum-sdk/src/host.rs: mirroredFault(thiserror#[error]per case,IntoStaticStrwith snake_case labels,#[non_exhaustive]), theRateLimitstruct, and theHostFaulttrait (fault(&self) -> Option<&Fault>,label(&self) -> &'static str) with a reflexive impl onFaultitself.example,twap-monitor,ethflow-watcher,price-alert,balance-tracker,stop-loss,http-probe,flaky-bomb,fuel-bomb,memory-bomb,panic-bomb) so the supervisor e2e tests resolve them, since the wit path was touched.No host interface or consumer moves onto
Faultyet andhost-erroris not removed. That migration is deliberately out of scope here and lands in the next PRs in the stack.Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features --no-fail-fast(new testshost::tests::fault_labels_are_stable_snake_caseandhost::tests::host_fault_is_object_safeboth pass)wasm-tools component wit wit/nexum-hostround-trips the package with the new variant and record presentNotes for reviewer
RateLimitderivesCopy,Default, andHashsince it is a singleOption<u64>;Faultitself staysCloneonly because it carriesStringpayloads.label()delegates toIntoStaticStrviaself.into()so the snake_case set has one source of truth, and the test pins all seven labels plus therate_limitedunderscore form.Object safety is proven rather than asserted:
host_fault_is_object_safeboxes adyn HostFaultso both trait methods are checked as dispatchable.Follow-ups intentionally not implemented here: migrating host interfaces onto typed per-interface errors that embed
Fault, retiringhost-erroronce every consumer has moved, and addingFrom/TryFrombetween the wit-bindgen-generatedFaultand the SDKFaultonce the first consumer interface lands.There is one pre-existing
duplicated_attributesclippy lint innexum-sdk'sproptests.rs/lib.rsthat only surfaces under the host's rustc 1.92 rather than the project-pinned 1.94; it is untouched by this diff and present on the base commit.AI Assistance: Claude Code (Opus 4.8 implementation and adversarial review, Sonnet 5 PR authoring) used for the full change.