Acquire apply.lock through one lock_cli helper that takes &GlobalArgs; the sequence is open-coded 9 times and renders lock_held 3 ways
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue nà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
- 58/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
- cli, developer-experience
Hướng nghiên cứu
Start with crates/socket-patch-cli/src/commands/lock_cli.rs, then inspect the listed call sites in vendor.rs, scan/withdrawn.rs, scan/vendor_flow.rs, scan/hosted.rs, scan/gc.rs, agent_download.rs, and get.rs. Trace the existing lock acquisition and failure rendering, then run the existing lock tests and CLI lock end-to-end tests. Done means the listed sites use the shared helper, JSON mode keeps stderr empty, and lock error codes and exit codes remain 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-cli-tests). Register: register comment.
Kind: refactor. Register ID: T09.
Problem
lock_cli has a helper for taking .socket/apply.lock, acquire_or_emit, and its module doc says it exists so "call sites stay one line each". Only 5 sites use it: apply, repair, remove, rollback and vendor. Even those 5 pass the same fields by hand, args.common.json, args.common.dry_run and Duration::from_secs(lock_timeout.unwrap_or(0)).
9 more sites open-code the whole sequence instead: acquire_with_status, then lock_failure, then their own rendering. They are vendor ×2, scan/withdrawn, scan/vendor_flow, scan/hosted, scan/gc ×2, agent_download and get. In total Duration::from_secs(*.lock_timeout.unwrap_or(0)) is written 14 times in the CLI.
The copies have drifted:
lock_heldis rendered 3 ways for humans:- lock_cli
format_lock_errorprintsError: Another…plus a hint and(Lock file: <path>). - vendor eject
emit_eject_refusalprintsError (lock_held): another…, with no hint and no path. - scan/vendor_flow.rs L995-L1006 prints
Error (lock_held): ….plusHELD_RETRY_HINT, with no path.
- lock_cli
- scan/hosted writes the human error under
--jsontoo.acquire_hosted_lockalwayseprint!s theError:block, even when it also builds the JSON error envelope.agent_download::report_lock_failureandacquire_or_emitsuppress it under--json. I found this by reading the code; I did not run it. report_lock_failureis in the wrong module. It lives inagent_download.rs, notlock_cli.rs.
Proposed change
- Add
GlobalArgs::lock_timeout() -> Duration. - Replace
acquire_or_emit(dir, cmd, json, dry_run, timeout)withlock_cli::acquire(common: &GlobalArgs, cmd: Command) -> Result<LockGuard, LockFailure>. It renders through one function: human text to stderr unless--json, and the envelope error otherwise. - Move
report_lock_failureintolock_cli. - Route the 9 open-coded sites through
lock_cli::acquire. The vendor-eject and vendor_flow renderers go away. - Inline lock_cli's 4 single-caller helpers:
emit,waiting_message,held_hintandheld_message.
Size
About 12 files under crates/socket-patch-cli/src/commands/, roughly −120 lines.
Acceptance criteria
- Every lock-held and lock-io exit gives the same
errorCode(lock_held/lock_io) and the same exit code as today. The existing lock tests inlock_cli.rsand the CLI lock e2e tests still pass. - Human stderr is identical across commands, and nothing goes to stderr under
--json. Add one test that runsscan --jsonagainst a held lock and asserts that stderr is empty. - Drop the subset tests
acquire_or_emit_succeeds_on_fresh_dirandheld_message_reports_whole_seconds, and fix the doc oferror_envelope_propagates_dry_run_and_command, which claims more than it asserts.
- Ngôn ngữ chính
- Rust
- Star
- 9
- Fork
- 2
- Merge trung bình
- 20 giờ 47 phút
- Pull request đã merge (30 ngày)
- 681
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 54/100
SocketDev/socket-patch#1993 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
arch-audit refactor
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
SocketDev/socket-patch#1992 ·
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#1987 · 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ó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
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 66/100
riverqueue/river#1576 ·
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 74/100
stadelmanma/fitparse-rs#64 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày