Deterministic key derivation for intervention caching.
Two tiers of keys:
Intervention Key — identifies a specific intervention datum (type + target IO key + data digest). Read-only during DAG execution.
Merge Result Key — identifies the outcome of merging step output with intervention data. Derived from the intervention key and optionally the inner result key, controlled by
data_enable/0. Read + write during DAG execution.
Key Formulas
InterventionKey = MD5(term_to_binary({type_string, io_key_string, digest_binary}))
MergeResultKey = MD5(term_to_binary(
[intervention_key | if use_inner? -> [inner_result_key]]
))MD5 is chosen deliberately: these are cache-eviction keys, not security primitives. The 128-bit space is sufficient and faster than SHA-256.
Summary
Functions
Derives a cache key for the intervention data itself.
Derives a cache key for the merge result.
Types
@type key_type() :: binary()
Functions
@spec intervention_key( OrchidIntervention.intervention_type(), Orchid.Step.io_key(), term() ) :: key_type()
Derives a cache key for the intervention data itself.
data_digest is domain-specific:
- For files: file metadata (size + mtime)
- For network resources: URI + last-modified / etag
- For in-memory data: a content hash or user-supplied fingerprint
@spec merge_result_key(module(), Orchid.Step.io_key(), key_type(), key_type() | nil) :: key_type()
Derives a cache key for the merge result.
Uses data_enable/0 from the Operate module to decide which components
participate in the key:
{false, true}(:override): inner result changes don't invalidate{true, true}(:offsetetc.): both sources invalidate{true, false}: intervention data changes don't invalidate (unusual)