Skip to content

Reject duplicate node IDs in graph clones - #396

Merged
jserv merged 1 commit into
sysprog21:mainfrom
bangyou0912:codex/reject-duplicate-graph-nodes
Oct 22, 2026
Merged

jserv merged 1 commit into
sysprog21:mainfrom
bangyou0912:codex/reject-duplicate-graph-nodes

Conversation

@bangyou0912

@bangyou0912 bangyou0912 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Graph serializers discarded a second object carrying an already visited node ID, so an invalid clone could receive full marks. JavaScript, Python, C, C++, and Java now reject distinct objects sharing an ID while continuing to accept cycles and shared nodes in valid graphs. C neighbor ordering remains tracked separately by #360.

The regression suite executes the browser runners and compiled harnesses against a valid cyclic triangle, a duplicated root, and a duplicated non-root node in each language. Before the fix, all ten invalid-graph checks failed and all five valid-graph checks passed. Afterward, all 15 checks passed without skips on both Windows and Linux.

Validation: Prettier, ESLint, Clippy, and the Git hooks passed. The completed ./scripts/test.sh run reported 1,294 browser checks passing with no failures and six Java checks skipped; Java was then installed and the focused five-language suite passed without skips. The full gate failed at the existing CLI file-permission assertion (0777 instead of 0600 on the WSL Windows filesystem) and six mutation-planning checks caused by missing jq. After installing jq, all six mutation-planning checks passed. The full gate is not green locally; the CLI failure also prevented later Rust test targets from running. Additional broad reruns were stopped after severe local resource contention and do not establish a passing result.

The completed gate also skipped commentflow, ruff, shfmt, shellcheck, cargo-audit, and actionlint because their tools were unavailable. Credentialed live-interview checks, mutation testing, and cross-platform release builds were not run locally and remain for their appropriate CI or credentialed lanes.

The before and after screenshots show the same intentionally invalid JavaScript solution on the actual interview page, served from a local static test server: 5/5 before the fix and 2/5 afterward, with the three corrupted graph cases rejected. This was not a credentialed live interview.

graph-before graph-after

Closes #381


Summary by cubic

Fixes graph clone validation so returned graphs with distinct nodes sharing an ID are rejected instead of silently passing. Previously, serializers collapsed nodes by ID, letting an invalid clone earn full marks.

  • JavaScript, Python, C, C++, and Java runners now reject distinct objects sharing an ID while still accepting legitimate cycles and shared nodes.
  • C also rejects node IDs outside 1–1023 so out-of-range nodes can't disappear from serialized output.
  • A regression suite covers the valid cyclic triangle, duplicated root and non-root nodes, C out-of-range IDs, NULL neighbors, and nodes shared from the input.

Closes #381.

Written for commit fb8b164. Summary will update on new commits.

View guided diff

Comment thread tests/browser/graph-clone-identity.test.js Outdated
Comment thread tests/browser/graph-clone-identity.test.js Outdated
@bangyou0912
bangyou0912 force-pushed the codex/reject-duplicate-graph-nodes branch from 3e698ef to 6f239f8 Compare October 21, 2026 02:29
@bangyou0912

Copy link
Copy Markdown
Contributor Author

The browser, Rust, and mutation checks pass at 6f239f8. The portable lane fails only at cargo-audit, which reports RUSTSEC-2026-0381 and RUSTSEC-2026-0382 in the existing dependencies. Cargo.toml and Cargo.lock are unchanged from upstream main at f3ae86c.

The failed run is https://github.com/sysprog21/codetrial/actions/runs/39533317148. Should the dependency updates be handled separately, with this PR rebased afterward?

@jserv

jserv commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

The failed run is https://github.com/sysprog21/codetrial/actions/runs/39533317148. Should the dependency updates be handled separately, with this PR rebased afterward?

Rebase latest main branch.

@bangyou0912
bangyou0912 force-pushed the codex/reject-duplicate-graph-nodes branch from 6f239f8 to 45a8896 Compare October 21, 2026 02:46
@bangyou0912
bangyou0912 marked this pull request as ready for review October 21, 2026 03:00
cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv
jserv requested review from ColtenOuO and alanhc October 21, 2026 03:03
Comment thread web/compiler-explorer.js Outdated
@bangyou0912
bangyou0912 force-pushed the codex/reject-duplicate-graph-nodes branch from 45a8896 to 7031df8 Compare October 21, 2026 05:07
cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase latest main branch and resolve conflicts.

@bangyou0912
bangyou0912 force-pushed the codex/reject-duplicate-graph-nodes branch from 7031df8 to 3cf4dfd Compare October 22, 2026 05:45
Comment thread web/compiler-explorer.js Outdated
Graph output was collapsed by node ID, allowing distinct objects with
the same ID to pass as a valid clone. Reject these outputs in every
runner while retaining legitimate shared nodes and cycles, so reported
test results reflect the graph the candidate actually returned. C also
rejects IDs outside its supported range so extra nodes cannot disappear
from the serialized output and bypass validation. Existing input nodes
are reported as deep-copy errors before duplicate-ID errors.

Closes sysprog21#381
@bangyou0912
bangyou0912 force-pushed the codex/reject-duplicate-graph-nodes branch from 3cf4dfd to fb8b164 Compare October 22, 2026 06:09
@jserv
jserv merged commit 01e280d into sysprog21:main Oct 22, 2026
10 checks passed
@jserv

jserv commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Thank @bangyou0912 for contributing!

@bangyou0912
bangyou0912 deleted the codex/reject-duplicate-graph-nodes branch October 22, 2026 07:14
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.

Graph clone tests accept extra nodes with duplicate IDs

2 participants