operators: document and assert the ReduceTactic / JoinTactic contracts#789
Merged
frankmcsherry merged 1 commit intoJul 6, 2026
Merged
Conversation
The reduce and join tactic drivers rely on contracts their tactics were only implicitly honoring. Write them down where implementors will see them, and cheaply enforce the driver-checkable ones so a misbehaving tactic fails loudly instead of silently corrupting the output trace or dropping work. ReduceTactic::retire — document the contract and, since the output is produced in order, check the two cheap invariants in `reduce_with_tactic` with a linear scan: - output batches are ordered and tile `[lower, upper)` (first lower is `lower`, each upper meets the next lower, last upper is `upper`); - each batch ships at a time the operator holds a capability for. The "no work => empty frontier" rule (whose violation deadlocks recursive scopes) stays a documented, tactic-self-enforced invariant: the withheld set is tactic-internal, so it is not driver-checkable, but deriving the frontier from the actual pending set gives it for free. JoinTactic::work — document the fuel protocol (non-negative on return iff all work is exhausted; the driver reschedules iff negative). Not driver-checkable either; the in-tree tactic already makes it structural by setting `fuel` from whether its queues are empty. Contracts + debug asserts only; no behavior change. reduce, reduce_reference, join, bfs, scc green with the asserts active — the cursor and reference tactics already conform. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
frankmcsherry
added a commit
to frankmcsherry/differential-dataflow
that referenced
this pull request
Jul 6, 2026
`key_hash` is a content hash, so it is an independence marker, not identity — colliding keys share a cell. The framework stays collision-oblivious (sound, just coarse), but exactness is recoverable *backend-side*, because the backend always holds the real keys and values. Add that recipe to `mod.rs`'s collision-risk docs: - Join: verify real keys at `cross` and drop collision-fabricated pairs (their times/diffs are never emitted, so the output is exactly the real-key equijoin). - Reduce: partition the bracket by real key and mint key-qualified value ids (`hash(key, value)` or per-`(key, value)` ordinals) so `(key_hash, vid)` tracks `(key, value)` exactly. The unrecoverable residue is granularity only (colliding keys share `pending` and the changed-key restriction) — extra work, never wrong answers. Also document, on `vec_backend` itself, that the reference deliberately does NOT implement this — it hashes keys/values and accepts the birthday bound for simplicity. Also folds in pending DESIGN.md updates: G2 recorded as done/merged (TimelyDataflow#789) with TimelyDataflow#781 rebased and conforming; the S1-recipe task marked done. Docs only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
frankmcsherry
added a commit
to frankmcsherry/differential-dataflow
that referenced
this pull request
Jul 6, 2026
Restore the `[x]` checkbox on the G2 gate entry (lost when it was rewritten to "done as TimelyDataflow#789"), and fix "a AbelianReduceBackend" -> "an" in F1 (an article the ProxyReduce* -> AbelianReduce* rename left ungrammatical). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reduce and join tactic drivers (
reduce_with_tactic/join_with_tactic) rely on contracts their tactics were only implicitly honoring. This writes them down where implementors will see them, and cheaply enforces the driver-checkable ones so a misbehaving tactic fails loudly instead of silently corrupting the output trace or dropping work.ReduceTactic::retire— documents the contract, and (since output is produced in order) checks two cheap invariants in the driver with a single linear scan:[lower, upper)(first lower islower, each upper meets the next lower, last upper isupper);The "no work ⇒ empty frontier" rule (whose violation deadlocks recursive scopes) stays a documented, self-enforced invariant: the withheld set is tactic-internal, so it isn't driver-checkable, but deriving the frontier from the actual pending set gives it for free.
JoinTactic::work— documents the fuel protocol (non-negative on return iff all work is exhausted; the driver reschedules iff negative). Also not driver-checkable; the in-tree tactic already makes it structural by settingfuelfrom whether its queues are empty.Contracts +
debug_assert!s only; no behavior change.reduce,reduce_reference,join,bfs,sccpass with the asserts active — the cursor and reference tactics already conform.Companion to the integer-proxy work (#781): the proxy reduce/join tactics conform to these same contracts, but the contracts belong to the shared tactic tier, so they land here independently of that PR.
🤖 Generated with Claude Code