Skip to content

fix(workspace): survive a mid-scaffold abort without wiping .vig-os - #1513

Merged
c-vigo merged 2 commits into
devfrom
bugfix/1480-atomic-force-upgrade
Aug 14, 2026
Merged

c-vigo merged 2 commits into
devfrom
bugfix/1480-atomic-force-upgrade

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the destructive non-atomicity from the field failure in #1480 (filesender 1.6.0→1.8.0):

  • Torn-window guard: init-workspace.sh snapshots .vig-os and the root .gitignore immediately before the template rsync (the point where both are replaced by template content whose values are only refilled by the write-backs hundreds of lines later). An EXIT trap restores both byte-for-byte on any failing exit inside that window and prints a loud message naming what was restored and warning that other scaffold files may be half-applied (with git checkout -- <path> guidance). The guard disarms after the late write-back completes, so later non-window failures never roll back this run's resolved values. Covers both the normal and smoke copy paths.
  • Scoped u+w sweep (suggestion 3): the blanket chmod -R u+w $WORKSPACE_DIR walked the consumer's entire workspace — .git object packs (deliberately 0444), multi-GB target/, node_modules — the exact surface of the transient fts_read failure that aborted the field run. The sweep is now keyed on the template tree (same shape as the init-workspace.sh chmod +x sweeps pre-existing consumer .sh files it does not own #1195 +x sweep), skips symlinks, and additionally covers smoke overlays.

Suggestion 4 from the issue (dirty-tree preflight) already exists (install.sh run_preflight_guard, #1283); suggestions 1–3 are what this PR delivers. The related nix-detection gap is tracked on #1400.

Test plan

New tests/bats/upgrade-atomicity.bats (5 tests, executing the real script with a deterministic in-window abort via the VIG_OS_VERSION validation exit — no stubs or signals):

  • in-window abort restores .vig-os + .gitignore byte-for-byte, with the restore named in output
  • a restored workspace upgrades cleanly on retry, opt-outs intact
  • a fresh-scaffold abort exits loudly without a pre-image (trap is set-e-safe)
  • consumer .git/target/ files stay 0444 through an upgrade
  • template-derived scaffold files still end up user-writable

The #664 structural pin updated to assert the scoped sweep and the absence of the blanket -R. Full local run: bats 530/530 green, scaffold-driven pytest suites (173 tests) green, prek run --all-files green.

Refs: #1480

c-vigo added 2 commits August 14, 2026 14:45
The template rsync replaces .vig-os and the root .gitignore with template
content that the write-backs only refill hundreds of lines later; an abort
inside that window persisted a blanked manifest — the input of the next
--force run. Snapshot both files before the copy, restore them on any
failing exit with a loud message, and disarm after the late write-back.
The u+w sweep is scoped to template-derived paths so consumer .git and
build trees are never walked.

Refs: #1480
@c-vigo
c-vigo merged commit 9df08f5 into dev Aug 14, 2026
12 checks passed
@c-vigo
c-vigo deleted the bugfix/1480-atomic-force-upgrade branch August 14, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant