Skip to content

fix(apollo-forest-run): apply structural diffs to divergent chunks#695

Merged
vladar merged 5 commits into
mainfrom
vladar/fix-forestrun-null-diffing
Jul 17, 2026
Merged

fix(apollo-forest-run): apply structural diffs to divergent chunks#695
vladar merged 5 commits into
mainfrom
vladar/fix-forestrun-null-diffing

Conversation

@vladar

@vladar vladar commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Why

A node of the graph can contain divergent representations of the same value: an object or list in one chunk and null or missing data in another. Applying the shared structural difference to every representation then fails update invariants. PR #686 demonstrated these failures, but relaxing the invariants leaves stale chunks behind.

The earlier reconciliation approach fixed correctness but imposed common-path diffing and allocation costs. This version keeps the exceptional handling localized to the existing update invariant branches.

Approach

  • Carry the model newValue on ObjectDifference and CompositeListDifference only when diffing exits with an actual or incomplete difference. Clean comparisons remain allocation-free.
  • At the existing object/list incompatibility guards, use that carried value only when the concrete chunk is CompositeNull or CompositeUndefined.
  • Let diff-produced structural values pass the existing missing-field guard so CompositeUndefined can be filled.
  • Preserve genuine object-vs-list invariant failures and leave list layout, mutation tracking, and history logic unchanged.

The regression scenarios from #686 now require complete, consistently updated results across every affected query view.

Validation

  • 1,117 ForestRun tests (1,098 passed, 12 skipped, 7 todo)
  • yarn workspace @graphitation/apollo-forest-run types
  • yarn lint

Performance validation is left to the ForestRun benchmark workflow in CI.

Promote nested object and list differences to replacements for null chunks and fillers for missing chunks, while preserving genuine structural mismatch invariants.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 27f20a2a-77b3-4142-89c2-bc2dc2b5f2c5
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

📊 Benchmark Analysis Report

No significant performance changes detected


Threshold: 5% change


Updated: 2026-07-17T11:25:20.962Z

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 27f20a2a-77b3-4142-89c2-bc2dc2b5f2c5
@vladar vladar changed the title fix(apollo-forest-run): reconcile divergent chunks during diffing fix(apollo-forest-run): apply structural diffs to divergent chunks Jul 16, 2026
vrazuvaev added 3 commits July 16, 2026 17:54
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 27f20a2a-77b3-4142-89c2-bc2dc2b5f2c5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 27f20a2a-77b3-4142-89c2-bc2dc2b5f2c5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 27f20a2a-77b3-4142-89c2-bc2dc2b5f2c5
@vladar
vladar marked this pull request as ready for review July 17, 2026 11:19
@vladar
vladar merged commit 2898c46 into main Jul 17, 2026
7 checks passed
@vladar
vladar deleted the vladar/fix-forestrun-null-diffing branch July 17, 2026 11:52
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.

3 participants