Skip to content

feat(match): multi-level hierarchy exclusion that still groups siblings (#800) - #883

Merged
athvin merged 2 commits into
mainfrom
issue/800-hierarchy-exclusion
Nov 8, 2026
Merged

athvin merged 2 commits into
mainfrom
issue/800-hierarchy-exclusion

Conversation

@athvin

@athvin athvin commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Closes #800

🚧 Claimed by an agent session — 2026-11-08T17:01:35Z, session 93a44611-348c-4819-b503-ac48b5acd076 on Mac.
The claim is this open draft PR: closing it releases the ticket.

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

constraints.exclude_hierarchy: { parent: <metadata key>, include_parent_child: false }:
a declared hierarchy compiles a NOT-EXISTS conjunct into every blocking rule
against a new __dedupe__hierarchy_ancestors closure (recursive, depth-capped),
materialized inside the blocking funnel. Ancestor chains (parent↔child,
grandparent↔grandchild) are never candidates; siblings still group.

Why

Spec unit 1.25, the last open sub-issue of epic #513. exclude_when_equal on a
parent column sees one level and cannot both exclude the chain and keep
siblings; a closure can, and the two directions are asserted against the same
corpus (a tree-wide exclusion would flip the sibling assertion red).

Proof

make check green locally (exit 0). The three real-engine goldens
(er-compile --test main hierarchy, under DEDUPE_E2E_EXTENSIONS=1): dedupe
(exactly the sibling + uncle-nephew pairs survive a four-record clique),
toggle (all six pairs return), incremental cross (a new child of an EXISTING
parent is excluded; an unrelated existing record still pairs). Mutation
observed failing: capping the closure at one hop re-admits the
grandparent-grandchild pair and the golden names it. The incremental goldens
(golden_incremental*) prove a hierarchy-free model blocks byte-identically.

Risk & rollback

Additive: an undeclared hierarchy compiles byte-identically (asserted), and old
model documents parse unchanged (hierarchy absent → None). git revert <merge-sha> rolls back cleanly; a tenant model compiled WITH the block keeps
working, since its conjunct and closure ride in its own frozen document.

Post-merge ledger

Closed by: agent · session 93a44611-348c-4819-b503-ac48b5acd076 on Mac · 2026-11-08T18:00:00Z

  • main is green with this change on it — merge SHA 2771aacf;
    rust, frontend, infra, devcontainer, images and deploy all
    completed success on that SHA itself.
  • images built — completed success on 2771aacf (this diff touches
    rust/, so an image rebuild is correct).
  • deploy converged — run 42506638480: the new colour's pod answered
    er-api-preview /readyz -> 200 before the flip, then Cut over and
    Retire the old colour both succeeded.
  • the push-only surface no pull request can pre-test — deploy
    success (above); drift and kind latest runs success.
  • the board card reached Done through the automation (read back
    from the board) and feat(match): multi-level hierarchy exclusion that still groups siblings #800 closed COMPLETED by the merge — which also
    completes the last open sub-issue of epic E5 — Classic matcher #513.
  • follow-ups are open for everything deferred here — n/a: nothing was
    deferred; all three of the ticket's DoD boxes shipped in this PR.
  • what was learned is written down — the hierarchy section in
    er-matching/references/config-to-model.md (in this PR), and the
    CtePipeline constraint (a recursive CTE only renders standalone, never as
    a second CTE) is recorded at materialize_hierarchy_ancestors_cross.

Specific to this change

Context — plan, discoveries, measurements, files

Plan

  1. er-config: HierarchyExclusion { parent, include_parent_child } on
    MatchConstraints (exclude_hierarchy:), serde defaults; declaring it IS
    turning it on (the DataGroomr default-on maps to the SF config generator
    always emitting it for Account — E1 — Salesforce commercial connector: finish onboarding and extraction reliability #511's job); include_parent_child: true
    is the opt-out toggle.
  2. dedupe-core: SettingsJson.hierarchy: Option<HierarchyJson>
    (+ accessor, absent → None — the comparator_algorithm_version precedent);
    stages/hierarchy.rs with the recursive ancestor-closure SQL over
    __dedupe__concat (edges: json_extract_string(metadata, '$.<parent>') = source_record_id within one source_system; depth cap 10 = cycle guard);
    materialize it in materialize_blocked_pairs_chunk AND the incremental
    cross-blocking path, registering the handle on the pipeline so the frozen
    conjunct's templated table name rewrites to the physical one.
  3. er-compile: validate the parent key (identifier charset — it is
    spliced into a JSON path); emit the conjunct + the settings hierarchy
    block together (one without the other is a broken model); a note; no
    COMPARATOR_ALGORITHM_VERSION bump (comparator SQL untouched; old models
    compile byte-identically when the block is absent).
  4. Tests: er-compile unit (conjunct present / absent / toggled off / bad
    key refused; absent block compiles byte-identically); real-engine golden
    hierarchy_exclusion.rs (the cross_field_groups.rs harness): parent↔child
    and grandparent↔grandchild never pair, siblings pair, include_parent_child: true re-admits them — the two opposing directions the ticket demands.
  5. Docs: er-matching/references/config-to-model.md constraints section
    states the default; make check green; /land-pr.

Discoveries

Measurements

Files

constraints.exclude_hierarchy declares which metadata key carries the parent
reference; the compiler freezes a NOT EXISTS conjunct against a depth-capped
recursive ancestor closure (__dedupe__hierarchy_ancestors) into every blocking
rule, and the settings block that makes the engine materialize it travels with
the conjunct. Ancestor chains never pair — grandparent included, which single
-column exclude_when_equal cannot see — while siblings and uncle-nephew pairs
still group; include_parent_child is the recorded opt-out, and declaring the
hierarchy is what turns exclusion on. Covered on the dedupe, toggle and
incremental-cross paths by real-engine goldens; the depth mutation was
observed re-admitting the grandparent pair.
@athvin
athvin marked this pull request as ready for review November 8, 2026 17:31
@athvin
athvin merged commit 2771aac into main Nov 8, 2026
45 checks passed
@athvin athvin mentioned this pull request Nov 8, 2026
@athvin
athvin deleted the issue/800-hierarchy-exclusion branch November 8, 2026 17:57
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.

feat(match): multi-level hierarchy exclusion that still groups siblings

2 participants