Drive pdm.lock and poetry.lock rewrites through one lock_fragments driver instead of two mirrored triads
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
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] 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_testsandbatch_equivalence_testsexist in both files, and the "fragments changed shape" test exists three times (lock_fragmentsL595,pdm_lockL921,poetry_lock).
The _steps loops have already drifted:
- PDM calls
rewrite.edits()?before its Unchanged check: pdm_lock.rs L333-L340. - Poetry compares the text first: poetry_lock.rs L710-L719.
- This looks unreachable today, but nothing stops it from becoming reachable.
Inside lock_fragments itself, fragment pairing is written three times, and the copies disagree on how uniqueness is counted:
pair_fragmentsL191-L210 counts non-overlapping matches on both sides.- the
finishloop L316-L336 checksoldin the text andnewin the spliced result. rewrite_batchL473-L495 counts overlappingsole_occurrences.- The shape-change length check is repeated at L198, L322 and L477.
Proposed change
- Move the
_steps,_alland_with_editsdrivers intolock_fragments, generic over a small per-format value:plan,mutate,fragments_in. - Delete the per-format wrappers and the
PoetryLockRewrite/PoetryLockParsealiases. - Have
finishandrewrite_batchcall 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SocketDev/socket-patch
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SocketDev/socket-patch#1860 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SocketDev/socket-patch#1838 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
arch-audit refactor
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
SocketDev/socket-patch#1987 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
SocketDev/socket-patch#1983 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit bug priority:p3
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
SocketDev/socket-patch#1982 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SocketDev/socket-patch
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
limitlessprojects/Go-Hybrid#3342 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
librespeed/speedtest-rust#52 · 1 bình luận ·
-
enhancement needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
bherbruck/solvecraft#11246 · 1 bình luận · 1 reaction ·
-
example
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rust-lang-nursery/rust-cookbook#954 ·
Maintainer thường phản hồi trong vòng 1 ngày