Skip to content

ADR-014 - Remove depth-first link expansion / dependency resolution#4

Open
richardTowers wants to merge 2 commits into
adr-014-3-default-bfsfrom
adr-014-4-remove-depth-first
Open

ADR-014 - Remove depth-first link expansion / dependency resolution#4
richardTowers wants to merge 2 commits into
adr-014-3-default-bfsfrom
adr-014-4-remove-depth-first

Conversation

@richardTowers

Copy link
Copy Markdown
Owner

This is the fourth in the series of ADR-014 PRs, starting with alphagov#4097

This removes the old implementation, and cleans up any code that's no longer required.

richardTowers and others added 2 commits June 10, 2026 12:50
Delete the LinkGraph traversal now that the breadth-first batch-SQL
implementation is the default, and drop the LINK_EXPANSION_IMPLEMENTATION
flag so LinkExpansion and DependencyResolution are thin entry points to
the new expander/resolver.

Removed: app/models/link_graph{,/node,/node_collection_factory}.rb,
lib/link_expansion/{link_reference,content_cache}.rb,
lib/dependency_resolution/link_reference.rb, and their specs.

Retained: app/queries/links.rb and app/queries/edition_links.rb, which
the new dependency resolver uses at the root; and
lib/link_expansion/edition_hash.rb.

Docs updated to describe the breadth-first / two-batch-SQL model and the
new console-debugging entry points.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Now that the breadth-first resolver is the only caller of Queries::Links,
strip the has_own_links / is_linked_to EXISTS optimisation and its
next_allowed_link_types_from/to and parent_content_ids parameters.

These existed solely to let the old depth-first traversal prune which
nodes were worth visiting and so minimise its one-query-per-node count.
The breadth-first resolver batches a whole level per query, never passes
those parameters, and only reads each link's content_id, so the whole
machinery was computed-or-skipped but never consumed. This takes the
class from ~240 lines to ~70 and drops the EXISTS subqueries the ADR
flagged as significant SQL complexity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <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