Skip to content

operators: document and assert the ReduceTactic / JoinTactic contracts#789

Merged
frankmcsherry merged 1 commit into
TimelyDataflow:master-nextfrom
frankmcsherry:tactic-contracts
Jul 6, 2026
Merged

operators: document and assert the ReduceTactic / JoinTactic contracts#789
frankmcsherry merged 1 commit into
TimelyDataflow:master-nextfrom
frankmcsherry:tactic-contracts

Conversation

@frankmcsherry

Copy link
Copy Markdown
Member

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:

  • 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, 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 setting fuel from whether its queues are empty.

Contracts + debug_assert!s only; no behavior change. reduce, reduce_reference, join, bfs, scc pass 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

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 frankmcsherry merged commit 553d9bc into TimelyDataflow:master-next Jul 6, 2026
6 checks passed
@frankmcsherry frankmcsherry deleted the tactic-contracts branch July 6, 2026 01:59
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant