Skip to content

tests: attach the runtime adapter's host program to the control session - #671

Merged
Enrique Saurez (esaurez) merged 1 commit into
devfrom
esaurez/a1-host-h5-adapter-host-20261020
Oct 22, 2026
Merged

Enrique Saurez (esaurez) merged 1 commit into
devfrom
esaurez/a1-host-h5-adapter-host-20261020

Conversation

@esaurez

@esaurez Enrique Saurez (esaurez) commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

The runtime adapter's guest agent serves the control session between the host and the guest with the adapter's own framing (#640), but its host program had no end of that session. This PR adds the host program's client, runtime_adapter::host::Client, through public APIs only, with tests of the host's part of the session with independent framing. The hypervisor scenarios that launch, reattach and stop a VM with it come in a follow-up pull request.

Part of #620
Refs #535

What changed

  • runtime_adapter::host (feature host): Client attaches through nvx::host::nvxs::HostConnection::attach over any nvx::host::platform::Transport, with the launch capability, and exchanges the adapter's messages (Ping and Pong, Echo, Stop and Stopped) as the session's application data, mirroring the guest agent.
    • attach waits while the broker waits for the guest, and reports the identity of the session's epoch.
    • send sends a message in as many records as it takes. receive returns the guest agent's next message, whether it spans records or shares one with the next message.
    • ping, echo and stop send a request and check its answer: Pong, an Echo of the same bytes, and Stopped.
    • Besides the session's own buffers, the client holds at most the rest of one record and one partial message, whose header the framing's decoder checks before it takes any byte of the body.
    • A reset of the session ends the attachment, and its partial message with it: the next epoch starts with a new message, in a new attachment.
    • A failure of the session, a send that fails or times out, which the session cannot resume, a malformed message, or a message that only the host sends ends the client, and later calls fail with Ended. A receive that times out keeps what arrived. A request ends the client on any failure after the framing accepted it, a timeout included, because an answer that arrived later would answer the wrong request.
  • tests/host_session.rs, in the host-only configuration: a test broker plays the broker's host-facing end of the session, and the guest agent behind it, with the public record API of nvx::protocol::nvxs, over an in-memory Transport, so the tests run on Linux and Windows. They cover:
    • the attachment: its bootstrap record with the capability, waits for the guest, a deadline that passes meanwhile, and refusals with an ERROR or by the end of the stream;
    • messages that span records both ways, up to the longest, which spans five records; records that end a message and start the next; and records whose bytes arrive in pieces down to one byte;
    • a receive that times out inside a message and then returns it whole, and a send that times out after it wrote part of a record or whose transport fails, which ends the client with the message that it held;
    • resets and disconnects in the middle of a message, with the next epoch and with a new instance, and a stream that ends inside a record;
    • the records that the client refuses: sequence, epoch and instance errors, stale and identity-less resets, record lengths, bootstrap identity, ERROR payloads, and header faults;
    • bounded buffers: a record or a message whose header declares more than the limit fails at its header, before its payload or body arrives;
    • messages that only the host sends, a message beyond the framing's limit, which the client refuses to send, and the answers that requests check, including one that arrives too late.
  • Docs: the adapter's README, with a section on the host program, and its entries in doc/ci.md and doc/project-structure.md.

The adapter adds no dependency, and its binaries don't change.

Validation

At e1c767d, on dev at 916a61f. In tests/runtime-adapter, the commands of the three "Check the runtime adapter's ..." steps of check-nvx-rs:

  • Linux (WSL Ubuntu, x86-64, as an unprivileged user): protocol-only, host-only, and guest-only for x86_64-unknown-linux-musl, each with cargo fmt --all --check, Clippy with -D warnings, cargo build, cargo test, and cargo +1.89 check --all-targets. All pass; tests/host_session.rs runs 9 tests.
  • Windows 11: protocol-only and host-only, with the same commands. All pass; tests/host_session.rs runs 9 tests.

Also on Windows 11: cargo doc --no-deps --features host with RUSTDOCFLAGS=-D warnings in the adapter, python scripts/check_markdown_links.py, and python scripts/nvx.py verify.

The adapter declares no ignored test yet, so the microVM jobs, which a change to the adapter runs, only build its host-only configuration on each backend. I ran no hypervisor for this change.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 02:59

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.

🟡 Changes recommended

Terminal send timeouts can leave the client returning buffered messages after its underlying connection has ended.

1 open issue
What changed in this PR

Adds the runtime adapter’s host-side client for independent framing over NVXS, complementing its guest agent. Hypervisor lifecycle scenarios remain follow-up work.

Changes:

  • Adds attachment, message exchange, and request/reply APIs.
  • Adds cross-platform tests for framing, session failures, and timeouts.
  • Documents the host client and test coverage.
File Description
tests/​runtime-adapter/​tests/​host_session.rs Tests host sessions using an in-memory broker.
tests/​runtime-adapter/​src/​lib.rs Exposes the host module behind its feature.
tests/​runtime-adapter/​src/​host.rs Implements the host client and error handling.
tests/​runtime-adapter/​README.md Documents client behavior and tests.
doc/​project-structure.md Describes both adapter session endpoints.
doc/​ci.md Documents host-side session coverage.

Review effort: Balanced

Comment thread tests/runtime-adapter/src/host.rs Outdated
Copilot AI balanced review requested due to automatic review settings October 21, 2026 03:10
@esaurez
Enrique Saurez (esaurez) force-pushed the esaurez/a1-host-h5-adapter-host-20261020 branch from 497c36a to e1c767d Compare October 21, 2026 03:10

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 blocking issues remain, and the earlier send-timeout issue is fixed with targeted regression coverage.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

The runtime adapter's guest agent serves the control session between the
host and the guest with the adapter's own framing, but its host program had
no end of that session. Add `runtime_adapter::host::Client`, built on
`nvx::host::nvxs::HostConnection` over any platform transport:

- `Client::attach` attaches with the launch capability and reports the
  identity of the session's epoch;
- `send` and `receive` exchange the adapter's messages as application data,
  reassembling messages that span records or share one;
- `ping`, `echo` and `stop` send a request and check its answer.

The client holds at most the rest of one record and one partial message. A
reset of the session ends the attachment with its partial message, because the
next epoch starts with a new message, in a new attachment. A failure of the
session, a send that fails or times out, which the session cannot resume, a
malformed message, or a message that only the host sends ends the client. A
receive that times out keeps what arrived. A request ends the client on any
failure, since a late answer would answer the wrong request.

`tests/host_session.rs` checks it in the host-only configuration against a
test broker that plays the broker's host-facing end, and the guest agent
behind it, with the public record API over an in-memory transport, so it runs
on Linux and Windows: the attachment and its bootstrap record, waits and
refusals, messages that span records both ways, partial records, record
lengths, ERROR payloads, sequence and identity errors, resets and disconnects
in the middle of a message, timeouts, sends that fail, the answers that requests
check, and the bounded buffers of the framing and the records.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 76c7c1bb-20fe-4724-bbc0-dfb01bbec828
Copilot AI balanced review requested due to automatic review settings October 21, 2026 18:10
@esaurez
Enrique Saurez (esaurez) force-pushed the esaurez/a1-host-h5-adapter-host-20261020 branch from e1c767d to 02decf1 Compare October 21, 2026 18:10

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 blocking issues remain, and targeted regression coverage addresses the previously reported send-timeout failure.

No open issues 🎉

Review effort: Balanced

@esaurez
Enrique Saurez (esaurez) merged commit 35c57c7 into dev Oct 22, 2026
31 checks passed
@esaurez
Enrique Saurez (esaurez) deleted the esaurez/a1-host-h5-adapter-host-20261020 branch October 22, 2026 21:53
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