ITADN

Resumable Reactions 01 - QueryResult sequence & ResultDiff row_signature

#395Closedamansinghoriginal 创建于 2026-04-24
## Background Part of the [Reaction Recovery](https://github.com/drasi-project/drasi-core/issues/393) initiative. See the [Reaction Checkpoints design docs](https://github.com/drasi-project/design-documents/tree/main/drasi-lib/Reaction-Checkpoints), specifically doc 01 section 6. The rest of the reaction-recovery work depends on each emitted query result being individually addressable. Today, results flow through the query-to-reaction channel without a stable identity: there is no sequence number reactions can checkpoint or dedup against, and no key for the live-results map other than full-row JSON equality (an O(N) scan). The in-memory outbox, the `fetch_snapshot` and `fetch_outbox` bootstrap APIs, framework-level dedup, and the persistent `live_results` namespace all build on the pieces of identity established here. ## Work - Add a sequence number to `QueryResult`. This becomes the value reactions persist in their checkpoint, the position the outbox is keyed by, and the `as_of_sequence` returned by the bootstrap APIs. - Add a row signature to every `ResultDiff` variant (`Add`, `Delete`, `Update`, `Aggregation`). The core engine already stamps a signature on every `QueryPartEvaluationContext` (the path-solver binding for non-aggregating rows, the grouping-key hash for aggregations); the lib layer currently ignores it and falls back to JSON-equality matching when reconciling live results. Propagating the signature through the core-to-lib conversion lets the live-results map be keyed directly, replacing the O(N) scan with O(1) updates. - Handle aggregation identity values. When an aggregation's `after` value equals the group's identity (`count: 0`, `sum: 0`, `avg: null`, `min`/`max: null`, `collect: []`), the group has emptied and the diff must be emitted as a removal rather than an overwrite. Without this, emptied groups would persist as zero-valued ghost rows in `live_results` indefinitely. ## Dependencies The aggregation identity-value handling depends on drasi-project/drasi-core#384, which adds the signal needed to distinguish a real value from the group's identity.
关闭于 2026-05-06 0 条评论