Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions graph/src/components/store/entity_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ impl EntityCache {
for (key, op) in other.updates {
self.entity_op(key, op);
}
// Carry forward vid_seq to prevent VID collisions when the caller
// continues writing entities after merging.
self.vid_seq = self.vid_seq.max(other.vid_seq);
}

/// Generate an id.
Expand Down
12 changes: 10 additions & 2 deletions runtime/wasm/src/host_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ impl HostExports {

let host_metrics = wasm_ctx.host_metrics.clone();
let valid_module = wasm_ctx.valid_module.clone();
let ctx = wasm_ctx.ctx.derive_with_empty_block_state();
let mut ctx = wasm_ctx.ctx.derive_with_empty_block_state();
let callback = callback.to_owned();
// Create a base error message to avoid borrowing headaches
let errmsg = format!(
Expand All @@ -560,16 +560,24 @@ impl HostExports {
let mut v = Vec::new();
while let Some(sv) = stream.next().await {
let sv = sv?;
let mut derived = ctx.derive_with_empty_block_state();
// Continue the vid sequence from the previous callback so
// each iteration doesn't reset to RESERVED_VIDS and
// produce duplicate VIDs.
derived.state.entity_cache.vid_seq = ctx.state.entity_cache.vid_seq;
let module = WasmInstance::from_valid_module_with_ctx_boxed(
valid_module.clone(),
ctx.derive_with_empty_block_state(),
derived,
host_metrics.clone(),
wasm_ctx.experimental_features,
)
.await?;
let result = module
.handle_json_callback(&callback, &sv.value, &user_data)
.await?;
// Carry forward vid_seq so the next iteration continues
// the sequence.
ctx.state.entity_cache.vid_seq = result.entity_cache.vid_seq;
Comment on lines +563 to +580
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

This change will alter the VIDs assigned by ipfs.map() across multiple callback invocations (second callback should now get RESERVED_VIDS + 1, etc.). The existing runtime test runtime/test/src/test.rs::test_ipfs_map currently hard-codes vid: 100 for both inserted entities via make_thing(..., 100); with this fix it should expect the second insert to have vid: 101 (and potentially any additional callbacks to be sequential), otherwise CI will fail.

Copilot uses AI. Check for mistakes.
// Log progress every 15s
if last_log.elapsed() > Duration::from_secs(15) {
debug!(
Expand Down