You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support embedding user-provided data in persisted snapshots #1839
Hyperlight-wasm and Hyperlight-js could use this to prevent accidental misuse for loading hyperlight snapshots. For example (proposed api) LoadedJsSnapshot::load(...) API should reject arbitrary hyperlight snapshots. It should validate that a snapshot represents a loaded JS sandbox saved through (proposed api) LoadedJSSandbox::snapshot(&mut self).save() API. But there's currently no way to do this.
Maybe extend Snapshot::save(path, tag) and Snapshot::load(path, reference) APIs, and add variants that accept and return user-provided data (changed is data parameter for save_with_data and returned Vec<u8> for load_with_data):
I think I would hold the metadata in the snapshot, and then have the assignment and retrieval of the metadata as independent methods in the snapshot instead of doing it at load/save time:
#[derive(Serialize,Deserialize)]structMetadata{ .. }// load the snapshot as normallet snapshot = snapshot.load(path)?;// get the metadata in "namespace"let metadata:Metadata = snapshot.metadata("namespace")?;// mutate metadatalet metadata = mutate_metadata(metadata);// create a new snapshot, replacing the metadata in "namespace" with the new metadatalet snapshot = snapshot.with_metadata("namespace", metadata)?;// save the snapshot as usual
snapshot.save(path)?;
This looks good! We'd need to be careful to make sure with_metadata can take in an Arc<Self> to make sure the api is ergonomic since snapshot() returns an Arc<snapshot>,. However this prevents the method from gettinga mut self, so we'd probably need to refactor the snapshots field slighly to make the inner state cheaply clonable via arc, and then create a new identical snapshot except for the metadata
Activity
ludfjig commentedon Sep 17, 2026
Maybe extend
Snapshot::save(path, tag)andSnapshot::load(path, reference)APIs, and add variants that accept and return user-provided data (changed isdataparameter forsave_with_dataand returnedVec<u8>forload_with_data):ludfjig commentedon Sep 18, 2026
Curious if you have any thoughts about this @jprendes
jprendes commentedon Sep 21, 2026
I think I would hold the metadata in the snapshot, and then have the assignment and retrieval of the metadata as independent methods in the snapshot instead of doing it at load/save time:
what do you think?
ludfjig commentedon Sep 22, 2026
This looks good! We'd need to be careful to make sure
with_metadatacan take in anArc<Self>to make sure the api is ergonomic sincesnapshot()returns anArc<snapshot>,. However this prevents the method from gettinga mut self, so we'd probably need to refactor the snapshots field slighly to make the inner state cheaply clonable via arc, and then create a new identical snapshot except for the metadata