Module entity_context

Module entity_context 

Source
Expand description

Thread-local context for canonical entity deduplication during deserialization.

When deserializing a solution from JSON, planning list variables contain copies of entities rather than references to canonical entities from value range providers. This causes WASM pointer mismatches that break Timefold’s entity tracking.

This module provides a thread-local registry that:

  1. Registers canonical entities (from value range providers) during Phase 1
  2. Allows lookup of canonical entities by (type, planning_id) during Phase 2

The EntityContextGuard ensures proper cleanup via RAII.

Structs§

EntityContextGuard
RAII guard that initializes and cleans up the entity context.

Functions§

lookup_canonical
Looks up a canonical entity by type and planning ID.
register_canonical
Registers a canonical entity in the thread-local registry.