Skip to content

diff_dependency_resolver

Populates depends_on on typed diffs via match-dispatch over containment.

Containment rules (v1):

  • A child Added diff waits for its parent's Added diff (parent must exist before the child can be created).
  • A parent Removed diff waits for all its children's Removed diffs (children must be dropped before the parent).

Cross-cutting rules (reference dependencies for views, topological sort, cycle detection) intentionally have no implementation in v1 — the match-dispatch shape leaves room for them to slot in as additional cases.

DiffDependencyResolver

Wires depends_on between typed diffs based on containment.

Source code in src/cloe_delta_table_manager/diff/diff_dependency_resolver.py
class DiffDependencyResolver:
    """Wires `depends_on` between typed diffs based on containment."""

    def resolve(self, diffs: list[Diff]) -> list[Diff]:
        """Populate `depends_on` in place and return the same list."""
        for diff in diffs:
            for other in diffs:
                if diff is other:
                    continue
                if _depends_on(diff, other):
                    diff.depends_on.append(other.id)
        return diffs

resolve(diffs)

Populate depends_on in place and return the same list.

Source code in src/cloe_delta_table_manager/diff/diff_dependency_resolver.py
def resolve(self, diffs: list[Diff]) -> list[Diff]:
    """Populate `depends_on` in place and return the same list."""
    for diff in diffs:
        for other in diffs:
            if diff is other:
                continue
            if _depends_on(diff, other):
                diff.depends_on.append(other.id)
    return diffs