Skip to content

nexum-world: replace the stringly capability and fault vocabulary with strum-derived enums #43

Description

@mfw78

Flagged on review of nullislabs/shepherd#440. Code is in nexum-world (L1 nullislabs/nexum-runtime). Confirmed unchanged to the end of the completed shepherd feature train (no later car converts it; a git log -S 'enum Capability' / IntoStaticStr across every subsequent car is empty).

Problem

nexum-world models the capability and fault vocabulary as bare &str consts with hand-written string matching:

  • nexum-world/src/lib.rs:24-36 - the seven host capabilities as &str consts (CHAIN = "chain", IDENTITY = "identity", LOCAL_STORE = "local-store", ...), plus ALL: [&str; 7].
  • nexum-world/src/lib.rs:43-55 - the seven fault kinds as &str consts (UNSUPPORTED, UNAVAILABLE, DENIED, RATE_LIMITED, ...).
  • struct Capability + const CORE: &[Capability] (lib.rs:69, 87) - a table keyed on those string names.
  • is_known / known_names / manifest_capabilities / synthesize match and compare on &str.

This is primitive-obsessed: an unknown capability is caught only at runtime by a string miss, adding one means editing several unlinked &str sites, and the validation error ("expected one of: chain, identity, ...") is hand-assembled from the array.

strum is already a workspace dependency (used for enums in engine_config.rs, manifest/error.rs, supervisor.rs, and the chain/log kinds), so the tooling is already in the tree.

Change

  • Introduce enum Capability { Chain, Identity, LocalStore, RemoteStore, Messaging, Logging, Http } and enum FaultKind { Unsupported, Unavailable, Denied, RateLimited, Timeout, InvalidInput, Internal }, each deriving strum::{IntoStaticStr, EnumString, Display, EnumIter} (with the kebab-case wire spelling where needed) plus serde where they cross a manifest boundary.
  • Replace the &str consts, ALL, and the string-keyed CORE table with variant-driven equivalents: is_known becomes a parse::<Capability>(), known_names becomes Capability::iter(), and the "expected one of" error is generated from the enum rather than hand-assembled.
  • Fold the remaining mechanical Display / From impls in this area into derive_more where they carry no logic.

Acceptance criteria

  • No bare &str capability or fault-kind name literals remain in nexum-world; matching is on enum variants.
  • Adding a capability or fault kind is a single exhaustively-checked enum edit.
  • The manifest round-trip (parse plus the "expected one of" error) is derived, not hand-written.

Related: #28 (types the two WASI names into a WasiCap enum) and #48 (the derive_more adoption); this is the core vocabulary those only nick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:witnexum-world, WIT packages/wiring, host verb surfacedebtRefactor/cleanup: typed replacements for stringly code, dedup, right-sizing

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions