fix(lammps): validate dplr and spin options#5842
Conversation
Reject truncated or keyword-valued DPLR and model-deviation options before reading them. Replace the type_associate assertion with a normal LAMMPS input error and use strict numeric conversion for spin parser values. Coding-Agent: Codex Codex-Version: codex-cli 0.144.4 Model: gpt-5.6-sol Reasoning-Effort: xhigh
for more information, see https://pre-commit.ci
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughLAMMPS DeePMD, DeepSpin, and DPLR option parsing now validates required values, rejects keyword tokens in value positions, uses shared numeric parsing, and includes subprocess-based regression tests. ChangesLAMMPS parser hardening
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #5842 +/- ##
==========================================
+ Coverage 78.58% 78.64% +0.06%
==========================================
Files 1050 1054 +4
Lines 120637 121768 +1131
Branches 4356 4408 +52
==========================================
+ Hits 94801 95769 +968
- Misses 24278 24426 +148
- Partials 1558 1573 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Possible reviewers based on changed lines, exact file history, and exact-file review history:
No review request was made automatically. Coding agent: Codex |
wanghan-iapcm
left a comment
There was a problem hiding this comment.
LGTM. Correctly hardens the LAMMPS option parsers: the bounds guards fix the real iarg+N > narg off-by-one that allowed an arg[narg] overread, is_key uses fixed exact-string keyword lists (so no numeric value or v_ variable is misclassified), the atof->utils::numeric and assert->error->all migrations are correct, and pair_deepmd/pair_deepspin stay byte-for-byte parallel. The subprocess-isolated negative tests genuinely fail pre-fix. Minor sub-threshold note for a follow-up: the virtual_len/spin_norm validation is byte-identical in both pair files but only exercised for pair_style deepspin — a pair_style deepmd case (or a shared helper) would guard against future drift.
Move virtual_len and spin_norm bounds, keyword, and numeric validation into PairDeepBaseModel so pair_style deepmd and deepspin cannot drift. Existing deepspin subprocess tests now exercise the shared implementation. Coding-Agent: Codex Codex-Version: codex-cli 0.144.6 Model: gpt-5.6-sol Reasoning-Effort: xhigh
|
Followed up on the approved review’s drift note in 085f9e6. A direct Validation: rebuilt the Coding agent: Codex |
e5fdff0
Summary
fix dplrmodel and electric-field values before reading themtype_associatelists through a normal LAMMPS input error instead of an assertionrelative,relative_v,virtual_len, andspin_normvalues in both pair parsers and parse numeric values strictlyWhy existing tests missed the bugs
efieldcomponents, and pairedtype_associateentries, so they never reached the off-by-one reads or assertion path.relativeandrelative_v, so the parsers never read beyond the final argument.virtual_lenorspin_normwith missing values or a following keyword, leaving their unchecked loops uncovered.Validation
cmake --build source/build --target deepmd_lmp -j2pytest source/lmp/tests/test_lammps_option_parsers.py -q(18 passed)ruff format .ruff check .Fixes #5645
Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh
Summary by CodeRabbit
Bug Fixes
fix dplroptions and invalid values.Tests
fix dplroption lists, while confirming valid DeepSpin configurations still succeed.