Skip to content

host: give each domain of the new APIs its own error type - #1267

Closed
Enrique Saurez (esaurez) wants to merge 1 commit into
devfrom
esaurez/slim-2.1.1-sl2.1-20261103
Closed

Enrique Saurez (esaurez) wants to merge 1 commit into
devfrom
esaurez/slim-2.1.1-sl2.1-20261103

Conversation

@esaurez

Copy link
Copy Markdown
Contributor

Part of #1097. Stacked on #1261.

What and why

SL2.1 of #1097: each domain of the host's new APIs gets an error type of its
own, instead of the crate-wide Error and its registry of 30 codes.

  • nvx::host::error holds six types, one file each in
    nvx-rs/src/host/error/: ConfigError, LaunchError, TransportError,
    SnapshotError, RestoreError and ReportError.
  • Each has a kind from a small, #[non_exhaustive] enum of its own domain,
    which kind() returns; a message, which it displays; and an optional
    source, which with_source sets and source() returns, as the crate-wide
    Error behaves, without its codes. The kinds are independent of
    ErrorCode: ConfigErrorKind has Invalid and Unsupported, and the
    others name what fails in a launch, a transport, a snapshot, a restore or
    a report.
  • No API returns them yet. The host's new APIs take them up as they come;
    the existing ones keep the crate-wide Error, ErrorKind and ErrorCode,
    whose taxonomy, registry and tests don't change.
  • nvx-rs/README.md gets the module's row and section.

Public API

Both snapshots gain the same 57 items: the module, the six types with
new, kind and with_source, and their kinds' variants. None is removed.

Size

298 core lines in 7 counted files, as measured; #1097 estimated 300, in one
folder with one file per type. Each type's file counts 45 to 50 lines, and
host/mod.rs, which declares the module, 14.

Tests

No existing test changes, and none is retired: the crate-wide error's
taxonomy and table tests in nvx-rs/src/error/tests.rs stay as they are.
Each new type's tests.rs adds an_error_has_the_kind_that_it_was_created_with
and an_error_displays_its_message_and_exposes_its_source.
scripts/check_test_changes.py reports 0 changes and 30 added items.

Validation

The gates below ran at the heads that they name, which hold this patch on
an earlier head of SL0.4 or before it: git range-diff shows the patch
unchanged, and SL0.4 changes no Rust input. On this head, the public API
check, the script tests that SL0.4 touches, the README, link and layout
checks, check_test_changes and the size ran again, and pass.

  • Windows, at 108c0900: the Rust steps of check-nvx-rs for the crate and
    the runtime adapter, 24 of 24, with the cli and testing Clippy builds.
  • Windows, the Python steps of validate-nvx, at 108c0900: all pass but
    scripts/test_adversarial.py, whose 4 test_contained_*_kills_descendants
    cases fail under the shared virtual environment's Microsoft Store Python
    3.13. Under a standard CPython 3.14.9, all 84 of its tests pass, at
    83f50d2a, 11 of them skipped as Linux-only. The first run, at 99333456,
    before SL0.4, also timed out one loopback test of
    scripts/test_microvm_tests.py at 69 to 96% host CPU, which passed 3 of 3
    alone, and the environment's timestamp guard saw 157 files change: pip's
    own bytecode, which no step of these gates writes. The run at 108c0900,
    with that bytecode moved aside and the host's processes watched, changed
    none.
  • Linux (Azure Linux 3), at 108c0900, in a checkout with its own target
    directory: a replay of check-nvx-rs; the OpenVMM vector and CPU profile
    tests; the shell, Markdown, test layout, kernel configuration and specula
    checks; and the 13 steps of validate-nvx that need no VM: all pass.

Add ConfigError, LaunchError, TransportError, SnapshotError, RestoreError
and ReportError in host::error, one file each in host/error/. Each has a
kind from a small, non-exhaustive enum of its own domain, which kind()
returns, a message, which it displays, and an optional source, as the
crate-wide Error has, without its codes.

No API returns them yet: the host's new APIs take them up as they come,
while the existing ones keep the crate-wide Error, ErrorKind and
ErrorCode.

The public API snapshots list the new types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1504d30d-8f6a-4254-9b3d-b350b73fe01e

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the domain-specific host error additions.

No open issues 🎉

What changed in this PR

This PR implements SL2.1 of #1097 by introducing six domain-specific error types for future host APIs. Existing APIs retain the legacy crate-wide error types and behavior.

Changes:

  • Add independent error kinds, display messages, and optional sources for configuration, launch, transport, snapshot, restore, and report errors.
  • Add unit tests covering every initial kind, message display, and source handling.
  • Document the new module and record its 57 public API additions in both platform snapshots.
File Description
nvx-rs/​src/​host/​mod.rs Declares and documents host::error, re-exporting its types.
nvx-rs/​src/​host/​error/​transport/​tests.rs Tests transport kinds, messages, and sources.
nvx-rs/​src/​host/​error/​transport.rs Defines transport errors and their classifications.
nvx-rs/​src/​host/​error/​snapshot/​tests.rs Tests snapshot kinds, messages, and sources.
nvx-rs/​src/​host/​error/​snapshot.rs Defines snapshot errors and their classifications.
nvx-rs/​src/​host/​error/​restore/​tests.rs Tests restore kinds, messages, and sources.
nvx-rs/​src/​host/​error/​restore.rs Defines restore errors and their classifications.
nvx-rs/​src/​host/​error/​report/​tests.rs Tests report kinds, messages, and sources.
nvx-rs/​src/​host/​error/​report.rs Defines report errors and their classifications.
nvx-rs/​src/​host/​error/​launch/​tests.rs Tests launch kinds, messages, and sources.
nvx-rs/​src/​host/​error/​launch.rs Defines launch errors and their classifications.
nvx-rs/​src/​host/​error/​config/​tests.rs Tests configuration kinds, messages, and sources.
nvx-rs/​src/​host/​error/​config.rs Defines configuration errors and their classifications.
nvx-rs/​README.md Documents the module and its separation from legacy errors.
nvx-rs/​public-api/​windows.txt Records the new public error API on Windows.
nvx-rs/​public-api/​linux.txt Records the same public error API on Linux.

Review effort: Balanced

Base automatically changed from esaurez/slim-1.1.1-sl0.4-20261103 to dev November 4, 2026 06:12
@esaurez
Enrique Saurez (esaurez) marked this pull request as ready for review November 4, 2026 15:41
@esaurez
Enrique Saurez (esaurez) marked this pull request as draft November 4, 2026 15:51
@esaurez

Copy link
Copy Markdown
Contributor Author

Closing as not planned: the plan in #1076 changed. nvx keeps one public error: Error, with its ErrorKind, and Result, which the new host APIs return, as most existing ones do. Callers act on an error's kind; the two kinds that the new lifecycle needs, RuntimeMismatch and StillRunning, join ErrorKind with their first users, and #1126 makes the error codes and constructors private. The six error types that this PR adds aren't needed, so #1097 starts with the runtime values. The branch stays until the PRs stacked on it are rebased onto dev.

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.

2 participants