Repository navigation
fix(engine): make --write-devices imply --inplace on every path - #7260
Merged
Merged
Conversation
Upstream resolves the inplace write strategy in two adjacent blocks of
`parse_arguments()`:
if (append_mode) { ...; inplace = 1; } /* options.c:2400-2411 */
if (write_devices) { ...; inplace = 1; } /* options.c:2413-2419 */
Every peer runs that same function, so client and server always agree.
oc reached the strategy from two independent places and each learned only
half the rule. The client config (`cli`) applied the `--write-devices`
implication inline; the `ServerConfig` promotion (`transfer`) applied only
`--append`. A server invoked with `--write-devices` therefore kept
`inplace = false` and wrote regular files through temp+rename where
upstream writes in place. Nothing in `transfer` or `core` promoted
`inplace` from `write_devices` at all - the only other references are doc
comments and the separate `write_devices && IS_DEVICE(st.st_mode)`
device-target branch, which is a different rule (`receiver.c`).
Give the rule one owner. This crate already owns the strategy the rule
selects - "Temp-file write + atomic rename (`--inplace` bypasses the
rename)" - so `engine::write_strategy::implies_inplace` holds it, and both
front ends call it. `cli` and `transfer` already depend on `engine`, so no
new dependency edge is introduced.
The client expression is routed through the shared rule rather than
deleted: a purely local copy never reaches
`run_server_with_handshake_adopting`, so deleting it would have dropped
the promotion for local `--write-devices` entirely.
Verified on Linux with --all-features:
- Red check: dropping `write_devices` from the rule fails exactly
`every_input_combination_matches_upstream` and
`write_devices_alone_promotes`.
- `cargo nextest run --workspace --all-features`: 32389 passed, 0 failed.
- fmt clean; `clippy --locked --workspace --all-targets --all-features
--no-deps -- -D warnings` clean.
Not addressed here, and deliberately left out of scope: upstream's blocks
also raise `create_refuse_error(refused_inplace)` when the daemon refuses
`--inplace`. oc models no `refused_inplace` state at all - the daemon
`refuse options` directive is unimplemented - which is materially larger
than this fix and belongs in its own change.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Upstream resolves the inplace write strategy in two adjacent blocks of
`parse_arguments()`:
if (append_mode) { ...; inplace = 1; } /* options.c:2400-2411 */
if (write_devices) { ...; inplace = 1; } /* options.c:2413-2419 */
Every peer runs that same function, so client and server always agree.
oc reached the strategy from two independent places and each learned only
half the rule. The client config (`cli`) applied the `--write-devices`
implication inline; the `ServerConfig` promotion (`transfer`) applied only
`--append`. A server invoked with `--write-devices` therefore kept
`inplace = false` and wrote regular files through temp+rename where
upstream writes in place. Nothing in `transfer` or `core` promoted
`inplace` from `write_devices` at all - the only other references are doc
comments and the separate `write_devices && IS_DEVICE(st.st_mode)`
device-target branch, which is a different rule (`receiver.c`).
Give the rule one owner. This crate already owns the strategy the rule
selects - "Temp-file write + atomic rename (`--inplace` bypasses the
rename)" - so `engine::write_strategy::implies_inplace` holds it, and both
front ends call it. `cli` and `transfer` already depend on `engine`, so no
new dependency edge is introduced.
The client expression is routed through the shared rule rather than
deleted: a purely local copy never reaches
`run_server_with_handshake_adopting`, so deleting it would have dropped
the promotion for local `--write-devices` entirely.
Verified on Linux with --all-features:
- Red check: dropping `write_devices` from the rule fails exactly
`every_input_combination_matches_upstream` and
`write_devices_alone_promotes`.
- `cargo nextest run --workspace --all-features`: 32389 passed, 0 failed.
- fmt clean; `clippy --locked --workspace --all-targets --all-features
--no-deps -- -D warnings` clean.
Not addressed here, and deliberately left out of scope: upstream's blocks
also raise `create_refuse_error(refused_inplace)` when the daemon refuses
`--inplace`. oc models no `refused_inplace` state at all - the daemon
`refuse options` directive is unimplemented - which is materially larger
than this fix and belongs in its own change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream
parse_arguments()resolves the inplace write strategy in two adjacent blocks:Every peer runs that same function, so client and server always agree on the result.
The defect
oc reaches the strategy from two independent places, and each learned only half the rule:
--append--write-devicescli/.../workflow/run.rs)ServerConfigServerConfig::apply_append_implies_inplace(transfer)So a server invoked with
--write-deviceskeptinplace = falseand wrote regular files through temp+rename, where upstream writes in place. Confirmed by grep: nothing intransferorcorepromotesinplacefromwrite_devices— the only other references are doc comments and the separatewrite_devices && IS_DEVICE(st.st_mode)device-target branch, which is a different upstream rule (receiver.c).This is the recurrence class, not a one-off: the
--appendhalf was fixed previously, and the sibling option was left behind precisely because the rule had two homes.Fix
Give the rule one owner.
enginealready documents itself as owning the strategy the rule selects — "Temp-file write + atomic rename (--inplacebypasses the rename)" (engine/src/lib.rs:33) — soengine::write_strategy::implies_inplace(inplace, append, write_devices)holds it and both front ends call it.cliandtransferalready depend onengine, so no new dependency edge is introduced.The client expression is routed through the shared rule rather than deleted. That distinction matters: a purely local copy never reaches
run_server_with_handshake_adopting, so deleting the client site would have silently dropped the promotion for local--write-devices. Verified before changing it.Verification
write_devicesfrom the rule fails exactly the two tests that pin it:every_input_combination_matches_upstreamandwrite_devices_alone_promotes. Restored and re-run green.cargo nextest run --workspace --all-features— 32389 passed, 0 failed.cargo fmt --all -- --checkclean;cargo clippy --locked --workspace --all-targets --all-features --no-deps -- -D warningsclean.⚠ Out of scope, flagged not absorbed
Upstream's blocks also raise
create_refuse_error(refused_inplace)when a daemon refuses--inplace. oc models norefused_inplacestate at all — the daemonrefuse optionsdirective is unimplemented. That is materially larger than this fix and belongs in its own change; it is not silently folded in here.Note on the originating task
The task that prompted this recorded
--write-devicesas missing the implication outright. That premise was half wrong — the client already had it. Measuring first is what located the real defect (server-side only) and the real cause (one rule, two homes).