Skip to content

chore(entity-resolver): remove dead resolve_entity/_create_entity/link_unit_to_entity#2367

Merged
nicoloboschi merged 1 commit into
mainfrom
chore/remove-dead-entity-resolver-methods
Jun 23, 2026
Merged

chore(entity-resolver): remove dead resolve_entity/_create_entity/link_unit_to_entity#2367
nicoloboschi merged 1 commit into
mainfrom
chore/remove-dead-entity-resolver-methods

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Summary

Removes four dead methods from EntityResolver that have no live callers:

  • resolve_entity (singular) — superseded by the batched resolve_entities_batch path used by retain/PATCH; zero callers anywhere (incl. tests).
  • _create_entity — only reachable from the dead resolve_entity.
  • link_unit_to_entity (singular) — superseded by link_units_to_entities_batch; zero callers.
  • _update_cooccurrence — only reachable from the dead link_unit_to_entity.

Why

While reviewing #2353 (sort unit_ids to avoid a concurrent-insert deadlock on graph_maintenance_queue), _create_entity's entities ... ON CONFLICT ... DO UPDATE looked like another live concurrent-deadlock site. It isn't — it's unreachable. The live entity paths are already deadlock-safe by consistent lock ordering:

  • entity create (bulk_insert_entities) — caller sorts by lower(name) + DO NOTHING
  • entity-stats UPDATE & co-occurrence DO UPDATE (flush_pending_stats) — both sorted() with explicit "prevents deadlocks" comments
  • bulk_insert_links, bulk_insert_unit_entities — sorted at the caller

Deleting the dead code so the misleading unsorted DO UPDATE stops tripping up future readers and reviewers.

Scope / safety

  • Pure deletion (230 lines), no behavior change.
  • ruff check/format and ty clean; lint.sh passes.
  • Entity-resolver suite green locally: test_entity_resolver.py, test_entity_labels.py, test_entity_resolver_pg_trgm.py, test_graph_entity_fanout_cap.py — 106 passed.
  • These methods were already flagged advisory-only by vulture (check-unused-code job).

…k_unit_to_entity

These per-entity methods have no live callers — the retain/PATCH paths all go
through the batched resolve_entities_batch + flush_pending_stats, which already
sort their writes for consistent lock ordering. The dead _create_entity carried
an unsorted 'entities ON CONFLICT ... DO UPDATE' that looked like a concurrent
deadlock site (it isn't, since it's unreachable). Removing the dead code so it
stops misleading readers/reviewers.

_update_cooccurrence is removed too — its only caller was the dead
link_unit_to_entity.
@nicoloboschi nicoloboschi merged commit d9a372a into main Jun 23, 2026
188 of 196 checks passed
@nicoloboschi nicoloboschi deleted the chore/remove-dead-entity-resolver-methods branch June 23, 2026 12:11
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