Skip to content

fix(open_nodes): direction 'any' returns in-edges, each edge once - #256

Open
Levalicious wants to merge 1 commit into
developfrom
fix/open-nodes-any-direction
Open

Levalicious wants to merge 1 commit into
developfrom
fix/open-nodes-any-direction

Conversation

@Levalicious

Copy link
Copy Markdown
Owner

Problem

openNodes kept an in-edge under direction: 'any' only when its source was also in the opened set — the inverse of the intended filter. So:

  • any returned out-edges only; in-edges from outside the opened set vanished (e.g. a node with 50 out / 96 in reported 50 under any).
  • An edge between two opened nodes was listed twice (as the source's out-edge and the target's in-edge).

Fix

One condition: under any, skip an in-edge exactly when its source is opened (already emitted as that source's out-edge). Every other in-edge is kept; shared edges and self-loops appear once.

Tests

tests/open-nodes-direction.test.ts (3): single node any = forward ∪ backward with self-loop once; in-edges from outside the set; shared edge listed once. 3/3 fail on develop, pass here. Full suite 199/199.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B7UQfn7Vue83jAPFaWfmAZ

The 'any' branch kept an in-edge only when its source was also in the
opened set: the inverse of the intended filter. 'any' therefore returned
out-edges only (in-edges from outside the opened set were dropped), and
an edge between two opened nodes was listed twice, once as the source's
out-edge and once as the target's in-edge.

Skip an in-edge under 'any' exactly when its source is opened (it was
already emitted as that source's out-edge). That keeps every other
in-edge and lists shared edges and self-loops once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B7UQfn7Vue83jAPFaWfmAZ
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Per-op benchmark — p50 cycles (base vs head)

base runs: 5, head runs: 5 (median of mins) · freq-correction ×0.9987 · threshold head−base > max(40 cyc, 5%)

op base head* Δ Δ%
lookup 118.4 120 +1.6 +1.4%
read_entity 40 40 +0.0 +0.0%
neighbors_d1 814.9 804 -10.9 -1.3%
neighbors_d2 2627.6 2592 -35.6 -1.4%
find_path_d6 182794 181561 -1233.0 -0.7%
search 1179136 1179312 +176.0 +0.0%
entities_by_type 14038 14020 -18.0 -0.1%
random_walk_d5 1328.4 1343 +14.6 +1.1%
inc_walker_visit 17.5 17 -0.5 -2.9%
structural_sample 2587910 2561227 -26683.0 -1.0%
compute_merw_psi 919607 912109 -7498.0 -0.8%
create_entity 809 832 +23.0 +2.8%
create_relation 784 783 -1.0 -0.1%

* head frequency-corrected to base via the reference op.

No regressions beyond threshold.

This branch has not been deployed

No deployments
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