Carry apply/rollback advisories as typed values: ApplyResult.error doubles as a warning string that three consumers decode by substring, and they disagree
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start in crates/socket-patch-core/src/patch/apply.rs, where ApplyResult.error gets advisories joined with "; " (join_notes) and advisory_warning_codes matches marker consts. Then read the CLI consumers in crates/socket-patch-cli/src/commands/apply.rs and rollback.rs, plus store_copies.rs fold. Done means a typed Advisory enum on the results, one mapping helper to RunWarning, and the listed tests asserting variants; the maintainer's open decision on rollback's fallback needs settling first.
由索引模型根據 Issue 內容生成。
描述
[agent] Filed by the scheduled architecture audit (audit-core). Register: discussion #1830 register.
Kind: refactor. Register ID: A76.
Problem
ApplyResult.error (and the rollback result) means "why it failed" when success == false, but on a successful result it carries advisories instead: a --force skip note, an ownership restore the process could not make, or a failed stale-bytecode cleanup. These are joined with "; " into one string (apply.rs L121-L125, join_notes L1192). Consumers then get the warning codes back by substring-matching marker text (advisory_warning_codes L977-L989, which uses OWNERSHIP_NOT_RESTORED_MARKER and STALE_BYTECODE_NOT_REMOVED_MARKER).
The three consumers handle a note differently:
- CLI
apply(apply.rs L1411-L1419): a note that matches no marker, such as the--forceskip note, produces no run warning. - CLI
rollback(rollback.rs L2316-L2323):`` a note that matches no marker is labelledownership_not_restoredanyway. - Core
store_copies::fold(store_copies.rs L65-L72): a successful store copy keeps its advisory only if it contains the ownership marker. A store copy's stale-bytecode advisory is dropped before the CLI sees it. This is read from the code; I did not execute it.
Refusals are matched by marker the same way, for example SHARED_STORE_REFUSAL_MARKER, so tests can only check them with .contains on a sentence (rollback.rs L3086).
Proposed change
- Add a typed
advisories: Vec<Advisory>to the apply and rollback results, withenum Advisory { ForceSkipped(..), OwnershipNotRestored(..), StaleBytecodeNotRemoved(..) }. Each variant has its warning code and display text. - Keep
errorfor failures only. - Make
store_copies::foldconcatenate every copy's advisories. - Have both CLI commands map variants to
RunWarningthrough one helper. - Delete
advisory_warning_codesand the two marker consts, or make them private if a test still needs the text.
Size
About 6 files: core patch/{apply,rollback,store_copies}.rs and CLI commands/{apply,rollback}.rs, plus their tests. Estimated diff is ±250 lines.
Acceptance criteria
- The human text and the
--jsonwarning codes stay the same for ownership and bytecode advisories. - Decide whether
rollback's fallback toownership_not_restoredfor unrecognized notes is intended. If not, delete it and add a test. - A store-copy stale-bytecode advisory now reaches the run warnings, with a test.
test_restore_file_permissions_ownership_failure_is_a_warningand the shared-store refusal tests assert variants instead of sentence substrings.
- 主要語言
- Rust
- 星號
- 9
- 分支
- 2
- 平均合併
- 18 小時 47 分鐘
- 30 天內合併 PR
- 637
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged arch-audit priority:p3 refactor
難度 2/5 1-3 小時 新手友好度 83/100
SocketDev/socket-patch#1860 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit priority:p3 refactor
難度 2/5 1-3 小時 新手友好度 78/100
SocketDev/socket-patch#1838 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit priority:p3 refactor
難度 4/5 3-5 天 新手友好度 35/100
SocketDev/socket-patch#1983 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit bug priority:p3
難度 3/5 半天 新手友好度 55/100
SocketDev/socket-patch#1982 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit bug priority:p3
難度 3/5 1-2 天 新手友好度 55/100
SocketDev/socket-patch#1981 · 1 則留言 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
question
難度 1/5 1 小時以內 新手友好度 72/100
維護者通常 1 天內回覆
-
field-report
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
area:core
難度 2/5 1-3 小時 新手友好度 85/100
julian-hemmer/ypass#4 ·
-
難度 1/5 1 小時以內 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 62/100
davidkodar/klipp#3426 ·
維護者通常 1 天內回覆