Drive pdm.lock and poetry.lock rewrites through one lock_fragments driver instead of two mirrored triads

Đang mở
#1,844 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@mikolalysenko đang làm issue này rồi.

Từ ngày 1/11/2026.

  • #1898 của @mikolalysenko — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

Start by reading crates/socket-patch-core/src/utils/lock_fragments.rs, pdm_lock.rs, and poetry_lock.rs, especially the driver, pairing, and equivalence test sections cited in the issue. Then trace the listed call sites in redirect/pdm.rs, redirect/poetry.rs, vendor/pypi_pdm.rs, and vendor/pypi_poetry.rs. Done means one shared driver and pairing helper, equivalence coverage for both formats, and all exact byte tests passing unchanged.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

agent:claimed agent:triaged arch-audit priority:p1 refactor

[agent] Filed by the scheduled architecture audit (audit-core). Register: register.

Kind: refactor. Register ID: A05.

Problem

utils/pdm_lock.rs and utils/poetry_lock.rs each carry the same driver around utils::lock_fragments:

  • Poetry has rewrite_poetry_lock / _with_edits / _in / _all / _all_with_version / _batch / _steps: poetry_lock.rs L426-L731.
  • PDM has the mirror: pdm_lock.rs L136-L353.
  • The test modules are mirrored too. parse_reuse_equivalence_tests and batch_equivalence_tests exist in both files, and the "fragments changed shape" test exists three times (lock_fragments L595, pdm_lock L921, poetry_lock).

The _steps loops have already drifted:

Inside lock_fragments itself, fragment pairing is written three times, and the copies disagree on how uniqueness is counted:

  • pair_fragments L191-L210 counts non-overlapping matches on both sides.
  • the finish loop L316-L336 checks old in the text and new in the spliced result.
  • rewrite_batch L473-L495 counts overlapping sole_occurrences.
  • The shape-change length check is repeated at L198, L322 and L477.
Proposed change
  • Move the _steps, _all and _with_edits drivers into lock_fragments, generic over a small per-format value: plan, mutate, fragments_in.
  • Delete the per-format wrappers and the PoetryLockRewrite/PoetryLockParse aliases.
  • Have finish and rewrite_batch call one pairing helper.
  • Keep one copy of each equivalence test, parameterized over both formats.
Size

Three files (lock_fragments.rs, pdm_lock.rs, poetry_lock.rs), plus call-site renames in redirect/pdm.rs, redirect/poetry.rs, vendor/pypi_pdm.rs and vendor/pypi_poetry.rs. About −250 net lines.

Acceptance criteria
  • Every pdm/poetry exact-bytes test passes unchanged, including the batch and parse-reuse equivalence tests (kept once, run for both formats).
  • The duplicated shape-change test is kept once, in lock_fragments.
  • No user-visible change.
Ngôn ngữ chính
Rust
Star
9
Fork
2
Merge trung bình
18 giờ 47 phút
Pull request đã merge (30 ngày)
637

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của SocketDev/socket-patch

Tất cả issue của SocketDev/socket-patch

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.