Skip to content

Graph clone tests accept extra nodes with duplicate IDs #381

Closed

Description

@bangyou0912

Observed behavior

The JavaScript tests for Sandbox Topology Replica (clone-graph) accept a returned graph containing an extra reachable node with the same ID as another node. A correct clone and the invalid clone below both pass 5/5 cases at revision 0fecc3371614adb87c0fa840a9e4b52b1e29154d.

For the two-node input 1 <-> 2, this defect can produce three distinct objects: 1a -> 2 -> 1b -> 2, where 1a and 1b both have val === 1. This is not a copy of the original two-node graph, but the judge serializes it as [[2],[1]].

Expected behavior

Different reachable objects sharing one node ID should fail. A correct deep copy should continue to pass, including one whose neighbors appear in a different order.

Reproduction

  1. Serve the checkout's web/ directory locally and open a page on that origin.
  2. Run the following in the browser console. This isolates the existing JavaScript runner without requiring LiveKit or Gemini credentials.
const { runBrowserTests } = await import("/runners.js");

function replicateTopology(node) {
  const copies = new Map();
  function clone(current) {
    if (!current) return null;
    if (copies.has(current)) return copies.get(current);
    const copy = new Node(current.val);
    copies.set(current, copy);
    copy.neighbors = current.neighbors.map(clone);
    return copy;
  }
  const root = clone(node);
  if (root && root.neighbors.length) {
    const first = root.neighbors[0];
    const duplicate = new Node(root.val, root.neighbors.slice());
    first.neighbors = first.neighbors.map(
      neighbor => neighbor === root ? duplicate : neighbor
    );
  }
  return root;
}

const result = await runBrowserTests(
  "sandbox-topology-replica",
  replicateTopology.toString(),
  "javascript"
);
console.log(result.passed, result.total, result.cases);
  1. Observe 5 5, with every case marked as passing.
  2. Remove the block that creates duplicate and repeat. The correct clone also passes 5/5.

CodeTrial version

Source checkout: 0fecc3371614adb87c0fa840a9e4b52b1e29154d. The reproduction used the checkout's browser modules served by a local static server, not a prebuilt CodeTrial binary or a live interview. The Rust source build has not completed.

Environment

Environment: Windows, Chrome 155.0.8059.85, JavaScript, Sandbox Topology Replica.

Sanitized evidence

Initial analysis

graphToAdjacency in web/runners.js records visited nodes in byValue, keyed by current.val. A different object with an already visited value is silently skipped. The adjacency list therefore loses the distinction between those objects before answer comparison.

The problem contract requires a corresponding deep copy with distinct IDs and the same links. Python, C++, and Java contain similar value-keyed traversal, but I have only executed the JavaScript reproduction.

Proposed scope and verification

Detect distinct returned objects that share an ID before adjacency serialization. Preserve rejection of original nodes and order-independent neighbor comparison. Add executable regression coverage that rejects the invalid clone, accepts the correct clone, and accepts reordered neighbors. Confirm the affected languages before expanding the implementation.

Related: #360 and PR #376 address neighbor ordering in C; #332 and PR #333 address a C struct field name. Neither addresses duplicate node identities.

Public data confirmation

  • This report contains only synthetic examples and excludes credentials, session tokens, candidate recordings, and personal interview content.

Public data confirmation

  • I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.

Activity

  1. added theissue type on Oct 20, 2026
  2. bangyou0912 commented on Oct 20, 2026

    @bangyou0912
    ContributorAuthor

    I am working on the duplicate-node identity check and its regression coverage. I have read CONTRIBUTING.md, docs/development.md, docs/adding-a-problem.md, and the contribution, verification, and browser skills; installed the Git hooks with make hooks; and reproduced the JavaScript false positive on main at 0fecc33. I will keep the change focused on validating graph node identity before serialization, confirm the affected languages, and report the test gate's failures and skipped checks. Please assign this issue to me.

  3. added 5 commits that reference this issue on Oct 21, 2026
    6f239f8
    45a8896
    7031df8
    3cf4dfd
    fb8b164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions