Skip to content

Fix/cache children prevent nondeterministic adapter bugs#10

Merged
linde9821 merged 3 commits into
mainfrom
fix/cache-children-prevent-nondeterministic-adapter-bugs
May 20, 2026
Merged

Fix/cache children prevent nondeterministic adapter bugs#10
linde9821 merged 3 commits into
mainfrom
fix/cache-children-prevent-nondeterministic-adapter-bugs

Conversation

@linde9821
Copy link
Copy Markdown
Owner

The Walker layout algorithm called adapter.children() multiple times per node during traversal.
If an adapter returned a new list instance on each call (e.g. toList()), the precomputed
indexAmongSiblings would reference stale objects, causing silent layout corruption or
index-out-of-bounds crashes in leftSibling.

  • Cache the children list per node during initNodes and use it exclusively throughout the
    algorithm, making it structurally immune to non-deterministic adapters.
  • Document the identity contract on TreeAdapter so users understand the expectations.
  • Add a regression test with an adapter that returns a fresh list on every call.

also add new compile targets

linde9821 added 3 commits May 20, 2026 16:12
…ic adapter bugs

  - Add childrenOf cache populated once during initNodes; algorithm no
    longer calls adapter.children() after initialization
  - Document identity contract on TreeAdapter (deterministic children,
    consistent parent-child, unique membership)
  - Add test proving layout works with adapters returning new list instances
@linde9821 linde9821 marked this pull request as ready for review May 20, 2026 15:15
@linde9821 linde9821 merged commit 194fe71 into main May 20, 2026
1 check passed
@linde9821 linde9821 deleted the fix/cache-children-prevent-nondeterministic-adapter-bugs branch May 20, 2026 15:16
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