Skip to content

runtime-adapter: refresh, list, inspect, and remove template generations - #962

Open
Enrique Saurez (esaurez) wants to merge 1 commit into
esaurez/846-pr2-network-templates-20261025from
esaurez/847-pr1-template-operations-20261024
Open

Enrique Saurez (esaurez) wants to merge 1 commit into
esaurez/846-pr2-network-templates-20261025from
esaurez/847-pr1-template-operations-20261024

Conversation

@esaurez

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

Copy link
Copy Markdown
Contributor

Part of #847 (PR 1 of 2: template operations).

Stacked on #958.

Chain: #951 → #954 → #957 → #959 → #960 → #955 → #958 → this PR → #963, on dev; #879, #881, #885, #886, #877, #932, #884, #887, #933, #880, #936, #937, #939, #940, #941, #888, #949, and #950 have merged.

What and why

The runtime adapter's host program creates templates with create, but nothing refreshes, examines, or empties the template store that create fills. This PR adds refresh, list, inspect, and remove, as the operations table of #847 asks, through the public API of nvx::host::template alone.

  • refresh captures a new generation of the class even when the store already serves one. As create does, it prints the key and the generation only once the store committed them, and no restore triggers either command.
  • list and inspect report each generation from the store's index, its tombstones, and the records of its leases alone: its store generation, the identities of its compatibility key and of its capture class, its state, available or tombstoned, whether a clone may restore it at the host's time and why, and its leases. inspect adds each lease's sandbox and launch, and the metadata of the capture. They read no payload, neither the snapshot nor the key, whose decoding checks a digest, so they load no VM state and hash nothing.
  • remove retires the generation that it names with NVX's Store::retire, which tombstones it first, so that no new lease takes it, and deletes it once no lease remains. While leases keep it, the command exits with status 7, busy, and lists them. It never moves or deletes a leased generation.

Where the store lives, and what it evicts

The store is the directory that each template command names, private to the current user and apart from every sandbox's store. create and refresh create it if needed, while list, inspect, and remove only open it.

Of each capture class, the adapter keeps the generation that it served last. Once create or refresh served a generation, generations::evict retires every other generation of the class that the store published before it, and any that a tombstone quarantines. A generation that leases keep stays tombstoned, with its payload, until a later retirement finds its leases gone. An eviction that fails only warns, since the store already committed what the command served, and the next create or refresh of the class retries it.

Tests

  • template_operations, without a hypervisor: the command lines that the host program refuses, the operations on a directory that holds no template store, and a store without generations.
  • vm_template, in VMs: a refresh that captures and retires the generations that it supersedes while a clone leases one of them, and a removal that reports busy while leases keep its generation, then deletes it once they end.

Not in this PR

  • Starting and running clones of a template, and the stage's consolidated suite: PR 2.

Validation

Pending at 32942c3.

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

Retirement cleanup skips unindexed tombstones left by interrupted retirement, allowing them to persist indefinitely instead of being retried during later evictions.

1 open issue
What changed in this PR

Adds template-generation management to the runtime adapter through NVX’s public template-store API, implementing the template operations portion of #847.

Changes:

  • Adds refresh, list, inspect, and lease-aware remove commands.
  • Adds eviction of superseded generations and metadata-only listings without reading payloads or hashing.
  • Documents the operations and adds command-line and VM-backed lifecycle tests.
File Description
tests/​runtime-adapter/​tests/​vm_template.rs Tests refresh, eviction, listings, and removal with retained leases.
tests/​runtime-adapter/​tests/​template_operations.rs Tests argument validation, missing stores, and empty stores without a hypervisor.
tests/​runtime-adapter/​tests/​common/​mod.rs Adds a shared refresh-command helper.
tests/​runtime-adapter/​src/​lib.rs Exposes and documents the host-only generations module.
tests/​runtime-adapter/​src/​generations.rs Implements generation descriptions and eviction policy.
tests/​runtime-adapter/​src/​bin/​runtime-adapter-host.rs Adds command parsing, dispatch, output, and busy status handling.
tests/​runtime-adapter/​README.md Documents store behavior, commands, output, and test scenarios.

Review effort: Balanced

Comment thread tests/runtime-adapter/src/generations.rs Outdated

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 are reported for the template-generation management changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

The runtime adapter's host program gets refresh, list, inspect and remove
commands beside create, so that the template store that create fills can
be refreshed, examined and emptied through the same program.

Refresh captures a new generation of the class even when the store
already serves one. Create and refresh print the key and generation only
after the store commits them. Neither runs for a restore.

The store is the directory that each command names: create and refresh
create it, while the other commands only open it. A store keeps the latest
generation of each capture class. After create or refresh serves a
generation, the adapter retires every other generation of its class that
the store published before it, and any tombstoned one. Retirement deletes
an unleased generation at once and leaves a leased one in place until its
leases end. A failed eviction only warns, because the served generation is
already committed, and the next create or refresh of the class retries it.

List and inspect read only the store's index, tombstones and leases. They
never decode a key, load VM state or hash anything, since decoding a key
hashes its kernel command line. Remove retires a generation and exits
with the busy status, with the leases that keep it, while any remain.

New tests check the commands' refusals without a hypervisor. VM tests
refresh a template, check what each eviction retires, and remove a
generation while leases keep it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7d3db585-441c-495b-901f-ab7203c0f36b
@esaurez
Enrique Saurez (esaurez) force-pushed the esaurez/847-pr1-template-operations-20261024 branch from 747d4ad to 32942c3 Compare October 29, 2026 08:01
@esaurez
Enrique Saurez (esaurez) changed the base branch from esaurez/847-pr1-base-snapshot-20261028 to esaurez/846-pr2-network-templates-20261025 October 29, 2026 08:01
@esaurez
Enrique Saurez (esaurez) requested a balanced review from Copilot October 29, 2026 08:02

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

Listing generations repeatedly scans and reads all leases, causing G × L record reads instead of reading each lease once through a bulk API.

1 open issue

Review effort: Balanced

Comment thread tests/runtime-adapter/src/generations.rs

This branch has not been deployed

No deployments
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