fix: reconcile the manifest and migrate the sibling option keys - #339
Merged
Conversation
Found by verifying the v1.13.0 upgrade on h44lacrosse.com rather than trusting it: the mode migrated to the new key, the sources did not, and no manifest was written at all — the one thing the release existed to do. source_policy_record_owned_sources compared through the legacy-aware reader, which on a pre-rename install returns exactly the paths about to be written. So it returned early, never wrote the new key, and never reached the manifest call sitting after it. This is the same defect the mode recorder already carries a comment about; I fixed it there and did not apply it to the siblings, which is precisely the failure that comment warns about. The writable and log recorders had it too. The manifest now reconciles BEFORE any no-change return. It is a projection of the declaration, not a record of a change to it: an install whose sources never change would otherwise never get one, and a manifest deleted by hand would never come back. Also fixes reads under --dry-run. wp_cmd routes through run_cmd, which ECHOES its arguments instead of executing them when DRY_RUN is set, so every recorded_* reader returned the echoed command text and the resolver fell through to defaults. The mode reader papered over this with its own DRY_RUN short-circuit that returned the not-yet-resolved variable, so `./upgrade.sh --dry-run` on h44 reported `--source-mode workspace` and a full deny set for a site recorded as owned — advertising exactly the destructive outcome an operator runs a dry run to rule out. I nearly aborted a correct upgrade because of it. Reads are side-effect free and should happen during a dry run rather than be simulated; only writes belong behind run_cmd.
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.
Found by verifying the v1.13.0 upgrade on h44lacrosse.com rather than trusting it.
What the live check showed
The manifest was the entire point of the release, and it did not appear.
Cause
source_policy_record_owned_sourcescompared through the legacy-aware reader, which on a pre-rename install returns exactly the paths about to be written. So it returned early, never wrote the new key, and never reached the manifest call sitting after it.This is the same defect
source_policy_record_modealready carries a comment about:I wrote that, fixed it in one place, and didn't apply it to the siblings.
record_writable_pathsandrecord_log_pathshad it too.The manifest now reconciles before any no-change return. It's a projection of the declaration, not a record of a change to it — an install whose sources never change would otherwise never get one, and a manifest deleted by hand would never come back.
Second bug: dry runs lie
wp_cmdroutes throughrun_cmd, which echoes its arguments instead of executing them underDRY_RUN. So everyrecorded_*reader returned echoed command text and the resolver fell through to defaults.The mode reader papered over this with its own
DRY_RUNshort-circuit returning the not-yet-resolved variable. Net effect on h44:For a site recorded as owned. The dry run advertised exactly the destructive outcome an operator runs a dry run to rule out — I nearly aborted a correct upgrade over it.
Reads are side-effect free and should happen during a dry run, not be simulated. Only writes belong behind
run_cmd.Coverage
Four new assertions in
tests/source-mode.sh: a legacy install migrates onto the new sources key; the manifest is written for one; a manifest deleted by hand is restored even when the option needs no write; and a dry run reports the mode the install actually has.