fix(update): publish configuration backups transactionally - #3066
Draft
tang-vu wants to merge 1 commit into
Draft
Conversation
Contributor
Author
|
Batch compatibility receipt (2026-08-23) This head was merged locally with the independent candidate heads for #2114 (446099d), #2375 (2750621), #3040 (75deb4f), #3065 (bad25e7), and #3066 (ef87fce). The synthetic integration head was 548dda8414b8f3519c0be8f80787b2d26ccd9d8b.
This is compatibility evidence for the exact candidate heads, not a substitute for the live operator backup/rollback gate or independent review requested in the PR body. Keeping this PR in draft until that review/gate is resolved. |
tang-vu
marked this pull request as draft
August 23, 2026 14:58
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.
Why this matters
ods-update.sh backupproduces the configuration snapshot that operators can later select throughods-update.sh rollback. Today it creates the finalbackup-*directory before copying any files. A failed copy or metadata write therefore leaves a partial directory that looks like a valid rollback candidate. Two calls with the same name in the same second also share that directory and silently overwrite/mix contents. Direct CLI labels are interpolated into the path without the host-agent's label validation, so path-like names can escape the intended leaf directory.All three paths are reachable through the shipped Bash command; same-ID calls are also reachable through concurrent dashboard backup requests. A successful-looking or selectable partial backup weakens the update safety net exactly when rollback is needed.
Root cause and invariant
Root cause: backup construction and publication were the same directory operation (
mkdir -pon the final path), with no transaction boundary, duplicate writer guard, or validation at the Bash entry point.Invariant: only a fully copied snapshot with valid metadata may appear under the public
backup-*namespace; one ID has one writer and can never overwrite a completed snapshot; labels remain plain identifiers at every entry point.What changed
mktemp -dstaging directory.Overlap check
Searched open and closed PRs for backup traversal/name validation, partial/transactional backups, concurrent backup collisions, and scanned every open PR changing
ods/ods-update.sh.ods-update.sh; it does not changecmd_backup.cmd_backup.Focused validation
Concrete red evidence on the pre-fix production script after adding the first three regressions:
bash tests/test-update-script-backup.sh? 6 passed, 3 failed: path-like label accepted, failed copy left a selectable directory, repeated ID overwrote the completed snapshot.After the fix:
bash tests/test-update-script-backup.sh? 10 passed, 0 failedbash tests/test-ods-update-runtime-compose.sh? 5 passedbash tests/test-update-rollback-contract.sh? 5 passedbash -n ods-update.sh tests/test-update-script-backup.sh? passedshellcheck --rcfile /dev/null --severity=error ods-update.sh tests/test-update-script-backup.sh? passedgit diff --check? passedThe ordinary local ShellCheck invocation could not parse the checkout's CRLF
.shellcheckrcand also reported pre-existing warnings in unrelated lines; the explicit error-severity run bypassed that local config artifact. No live operator backup or rollback was performed. The real script ran against isolated temporary HOME/install fixtures and the rollback contract verified restored hashes.Design, platform, and rollback
The final
backup-<name>-<timestamp>format and lexicographic rotation behavior remain unchanged. Hidden staging/lock names do not match rollback or rotation globs. Directory creation,mktemp -d,mv, and traps are available on the supported Bash paths: Linux, macOS, and Windows through WSL2/Git Bash; the focused suite ran under Git Bash on Windows.A process killed without a catchable exit may leave hidden staging/lock directories, but they are deliberately invisible to rollback selection. A later timestamp remains usable, and operators can inspect/remove stale hidden paths manually. This PR does not add automatic stale-lock deletion because guessing whether another writer is alive would weaken the one-writer invariant.
Rollback is a normal revert, but restores partial-publication and same-ID overwrite behavior. Human review is requested because this code protects rollback artifacts.