collision_detection: enforce pair-bond precondition in GlueToSurface (bug-sweep #40)#5367
Draft
RudolfWeeber wants to merge 1 commit into
Draft
Conversation
…(bug-sweep #40) GlueToSurface::initialize never validated the arity of bond_centers or bond_vs, unlike the sibling protocols BindCenters and BindAtPointOfCollision. A non-pair (e.g. angle) bond was accepted at set time; at the first collision handle_collisions() stores it with a single-partner list, so it gets misclassified as a pair bond and calc_bond_pair_force throws BondUnknownTypeError inside a Kokkos parallel region, leading to std::terminate far from the misconfiguration. handle_collisions() inserts a single-partner list for both bond_centers and bond_vs, so both must be strict pair bonds (exactly one partner). Add the arity guards in initialize() at the same point the sibling protocols do, raising a clear RuntimeError. Existence is already guaranteed upstream by Protocol::find_bond_id, so at() is safe. Extend test_glue_to_surface in collision_detection_interface.py with the two assertRaisesRegex blocks mirroring the existing bind_centers and bind_at_point_of_collision checks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Which way do we fix this? Keep the script interface or the doc-string. I do not think, we want to merge the testcase, though. Parsing docstrings in a test is probably over the top. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GlueToSurface::initialize never validated the arity of bond_centers or
bond_vs, unlike the sibling protocols BindCenters and
BindAtPointOfCollision. A non-pair (e.g. angle) bond was accepted at set
time; at the first collision handle_collisions() stores it with a
single-partner list, so it gets misclassified as a pair bond and
calc_bond_pair_force throws BondUnknownTypeError inside a Kokkos parallel
region, leading to std::terminate far from the misconfiguration.
handle_collisions() inserts a single-partner list for both bond_centers
and bond_vs, so both must be strict pair bonds (exactly one partner).
Add the arity guards in initialize() at the same point the sibling
protocols do, raising a clear RuntimeError. Existence is already
guaranteed upstream by Protocol::find_bond_id, so at() is safe.
Extend test_glue_to_surface in collision_detection_interface.py with the
two assertRaisesRegex blocks mirroring the existing bind_centers and
bind_at_point_of_collision checks.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
🤖 Generated with Claude Code