Carry apply/rollback advisories as typed values: ApplyResult.error doubles as a warning string that three consumers decode by substring, and they disagree
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
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.
Written by the indexing model from the issue text.
Description
[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.
- Dominant language
- Rust
- Stars
- 9
- Forks
- 2
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 313
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SocketDev/socket-patch
-
agent:triaged arch-audit bug priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
SocketDev/socket-patch#2306 ·
Maintainers usually reply within 1 day
-
agent:triaged arch-audit bug priority:p3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
SocketDev/socket-patch#2296 ·
Maintainers usually reply within 1 day
-
agent:needs-human agent:triaged ci-janitor priority:p1
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SocketDev/socket-patch#2270 · 3 comments ·
Maintainers usually reply within 1 day
-
agent:triaged arch-audit bug priority:p1
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
SocketDev/socket-patch#2259 ·
Maintainers usually reply within 1 day
-
agent:triaged arch-audit priority:p3 refactor
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
SocketDev/socket-patch#1860 ·
Maintainers usually reply within 1 day
All issues in SocketDev/socket-patch
Similar issues
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`Possibly taken @iliqiliev claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ajeetdsouza/zoxide#1381 ·
Maintainers usually reply within 5 days
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
kornia/kornia-rs#1416 · 1 comment ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
paritytech/revive#749 ·
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
swc-project/swc-next-issues#1043 ·