Skip to content

test(build-edges): add regression test for confidence-sorted dedup in WASM engine #1519

@carlos-alm

Description

@carlos-alm

Context

In PR #1487 (fix(bench): add warmup runs to incremental tiers in benchmark.ts), a confidence sort was added to src/domain/graph/builder/stages/build-edges.ts:1115-1121 to align the WASM engine's edge dedup behavior with the native engine's sort_targets_by_confidence call.

Problem

There is no regression test covering this ordering guarantee. A future refactor could silently revert the sort and the WASM engine would again emit the wrong (lower-confidence) edge when duplicate (source_id, target_id) pairs appear in the targets array.

Task

Add a unit or integration test to tests/ that:

  1. Sets up a call site with multiple resolution candidates for the same (source, target) pair where the candidates have different confidence scores.
  2. Asserts that the emitted edge corresponds to the highest-confidence target — not the first one encountered.

This test should cover the WASM engine path (build-edges.ts) and run in CI to prevent the sort from being silently removed.

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions