Background
sourced_from lets a field on an indexed type be populated from a different source type's events. #1252 extended this to fields on nested elements of a document.
sourced_from forbids a source from changing which target it feeds. validateSource (index_data.painless) enforces this for the top-level case: it rejects an event whose relationship has "apparently changed," since allowing it would break out-of-order processing guarantees.
Problem
The guard doesn't catch the nested analog — a source re-targeting from one nested element to another.
It works per sourceKey, which for a nested event encodes the relationship plus the target element's identifiers. A source moving from element A to element B writes to two different sourceKey buckets, and the guard only compares source ids within a single bucket — so it never sees the move, and the re-target is silently accepted.
Question to resolve
Top-level relationship mutations are rejected; nested-element re-targeting currently isn't. Should it be — and if so, how, given that detecting it means looking across __versions buckets for the same source id rather than within one?
Background
sourced_fromlets a field on an indexed type be populated from a different source type's events. #1252 extended this to fields on nested elements of a document.sourced_fromforbids a source from changing which target it feeds.validateSource(index_data.painless) enforces this for the top-level case: it rejects an event whose relationship has "apparently changed," since allowing it would break out-of-order processing guarantees.Problem
The guard doesn't catch the nested analog — a source re-targeting from one nested element to another.
It works per
sourceKey, which for a nested event encodes the relationship plus the target element's identifiers. A source moving from element A to element B writes to two differentsourceKeybuckets, and the guard only compares source ids within a single bucket — so it never sees the move, and the re-target is silently accepted.Question to resolve
Top-level relationship mutations are rejected; nested-element re-targeting currently isn't. Should it be — and if so, how, given that detecting it means looking across
__versionsbuckets for the same source id rather than within one?