Repository navigation
Graph clone tests accept extra nodes with duplicate IDs #381
Description
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
- Serve the checkout's
web/directory locally and open a page on that origin. - 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);- Observe
5 5, with every case marked as passing. - Remove the block that creates
duplicateand 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
bangyou0912 commentedon Oct 20, 2026
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.
Reject duplicate node IDs in graph clones
Reject duplicate node IDs in graph clones
Reject duplicate node IDs in graph clones
Reject duplicate node IDs in graph clones
Reject duplicate node IDs in graph clones