Skip to content

Add provenance-validated snapshot overlay loading - #2117

Open
jprendes wants to merge 4 commits into
hyperlight-dev:mainfrom
jprendes:feat/snapshot-overlay-loading
Open

jprendes wants to merge 4 commits into
hyperlight-dev:mainfrom
jprendes:feat/snapshot-overlay-loading

Conversation

@jprendes

@jprendes jprendes commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add explicit, provenance-validated loading of snapshot descendants while reusing immutable memory layers from a caller-authorized base.

let snapshot = base.load_overlay(path, reference)?;
let checked = base.checked_load_overlay(path, reference)?;

Atomic commits

  1. Reuse declared memory digests on ordinary snapshot saves
    • Retain ordinary-load digest declarations separately from computed or verified hashes.
    • Avoid hashing trusted loaded memory again on ordinary save.
    • Preserve checked-save verification and repair; document that incorrect declarations are deliberately preserved by ordinary load/save.
  2. Add provenance-validated snapshot overlay loading
    • Require a declaration identifying the whole supplied base, rather than accepting any snapshot with a matching layer.
    • Persist snapshot IDs and inherited base IDs in the OCI config.
    • Propagate ancestry directly through the existing whole-snapshot memory backing during capture, including without compaction.
    • Record explicitly supplied compaction bases without retaining unused layers.
    • Share matching layers by digest and geometry; their files may be omitted from the descendant layout.

Semantics and trust

  • The saved descendant supplies the complete target state. Overlay loading reuses backing memory; it does not merge registers/metadata or append unused base layers.
  • Ordinary loading trusts declared memory hashes. Checked overlay loading reuses only computed or verified base-layer hashes and verifies newly loaded content.
  • Snapshot IDs and base declarations are trusted provenance, not cryptographic proof of ancestry or authorization, even in checked mode.
  • Callers must authorize the base and keep all backing files immutable; this is not a cross-actor content cache.
  • Writers emit config v7 with provenance; legacy v6 configs still load standalone without it. Save the resulting base to persist its assigned ID before relying on independently loaded copies for overlay.
  • There are no changes to the memory manager, no extra retained base layers, and no newly introduced memory hashing for ancestry.

Validation

  • First commit independently: 174 host loader tests passed.
  • Final tree: 255 snapshot/memory-manager tests passed, with one existing hardware-specific test ignored.
  • Copied-memory/GDB path: 6 targeted provenance and compaction tests passed.
  • Existing hash-reuse and omitted-layer/backing-lifetime assertions passed.

Review follow-ups

  • Versioned the config as v7, preserving strict legacy v6 loading and updating schema/ABI tripwires. The format-fix commit independently passed 16 focused tests.
  • compact(None) clears provenance. compact(Some(base)) replaces the target's history with the selected base's inherited list plus its ID. This provides an explicit reset while retaining a caller-selected base, rather than silently imposing an ancestry cap.
  • Inheritance now copies one validated, ordered list and appends its unique parent ID in linear time, eliminating quadratic membership scans.
  • Regression coverage seeds 30,000 ancestor IDs, verifies both save APIs hit the actual 1 MiB config limit, and verifies compaction recovers save capacity.
  • Uncompacted ancestry can still grow; callers should periodically compact without a base or against a fixed base with a short ancestry list.
  • Command snapshot/checkpoint tests (10), copied-memory/GDB tests (6), and static worker KVM lifecycle tests (2) passed. Performance benchmarks were not rerun.

jprendes and others added 2 commits November 26, 2026 12:28
Keep asserted layer digests separate from computed or verified hashes. Ordinary load/save avoids rehashing trusted memory, while checked_save continues to verify and repair content.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
Add load_overlay and checked_load_overlay methods that require a declared whole-snapshot base and reuse matching immutable layers. Persist snapshot IDs and inherit provenance through capture and compaction without retaining unused layers or adding memory-manager bookkeeping.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>

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

Newly saved configs break compatibility with existing v6 readers, which reject the added provenance fields despite the unchanged media type and ABI.

3 open issues
What changed in this PR

This PR adds provenance-validated snapshot overlay loading to Hyperlight’s host snapshot APIs. Descendants can reuse immutable memory layers from a caller-authorized base while supplying their complete saved state.

Changes:

  • Add ordinary and checked overlay loaders with provenance, digest, and geometry checks.
  • Persist snapshot identities and ancestry through capture and compaction.
  • Reuse declared digests on ordinary saves, with tests and documentation for verification and trust requirements.
File Description
src/​hyperlight_host/​src/​sandbox/​snapshot/​mod.rs Inherit base provenance during capture.
src/​hyperlight_host/​src/​sandbox/​snapshot/​memory/​mod.rs Store snapshot IDs, ancestors, and declared digests.
src/​hyperlight_host/​src/​sandbox/​snapshot/​memory/​backing.rs Expose backing snapshot memory for provenance inheritance.
src/​hyperlight_host/​src/​sandbox/​snapshot/​file/​mod.rs Implement overlay loading and declared-digest reuse.
src/​hyperlight_host/​src/​sandbox/​snapshot/​file/​config.rs Serialize and validate provenance fields.
src/​hyperlight_host/​src/​sandbox/​snapshot/​file_tests.rs Cover provenance, layer sharing, verification, and legacy loading.
src/​hyperlight_host/​src/​sandbox/​snapshot/​compact.rs Preserve ancestry and record explicit compaction bases.
docs/​snapshot-oci-format.md Describe overlay semantics and trust requirements.
CHANGELOG.md Document the public APIs and save behavior.

Review effort: Balanced

Comment on lines +216 to +219
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(super) snapshot_id: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub(super) bases: Vec<String>,
Comment on lines +719 to +721
.iter()
.map(ToString::to_string)
.collect(),
Comment on lines +184 to +188
for id in base.bases.iter().copied().chain(std::iter::once(base.id)) {
if id != self.id && !self.bases.contains(&id) {
self.bases.push(id);
}
}
@jprendes jprendes added the C-enhancement For PRs adding features, improving functionality, docs, tests, etc. label Nov 26, 2026
jprendes and others added 2 commits November 26, 2026 13:00
Emit config v7 with explicit loader dispatch and require its snapshot ID. Keep strict v6 loading without provenance, update schema and ABI tripwires, and cover legacy and mislabeled layouts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
Clear base provenance when compacting without a base. With a base, replace target ancestry with that base inherited list and ID. Copy the validated ordered list directly instead of quadratic membership scans, and cover config-limit recovery and repeated checkpoint cycles.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>

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

C-enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants