Skip to content

fix: apply.sh has no rollback on partial write failure - #57

Merged
AnayDhawan merged 1 commit into
CreativesLibrary:mainfrom
ResourceMint:rm/apply-atomic-rollback
Aug 17, 2026
Merged

AnayDhawan merged 1 commit into
CreativesLibrary:mainfrom
ResourceMint:rm/apply-atomic-rollback

Conversation

@ResourceMint

Copy link
Copy Markdown
Contributor

What and why

apply.sh generated files directly into the target repo. set -euo pipefail means a crash mid-generation (a missing template, a fill() failure) left the target with only whichever files had written before the failure. Because apply.sh never overwrites an existing file, a re-run after a partial failure then skipped the files it did manage to write on the first pass — a confusing state to land in.

Generation now writes into a mktemp staging dir; the target repo is only touched in a final commit loop, once every write has already succeeded once. Either everything lands, or nothing does.

Closes #43

Type

  • Script fix or improvement (scripts/)

Checklist

  • shellcheck scripts/*.sh passes (if scripts changed) — not available locally, CI's shellcheck job will verify
  • Templates still use generic {{PLACEHOLDERS}}, no hardcoded names or paths
  • No secrets or personal paths committed
  • SKILL.md / references updated if behaviour changed — no behavior visible to callers changed, apply.sh's external contract (usage, output, never-overwrite semantics) is unchanged

Verified locally: bash demo/scaffold.sh init + bash scripts/apply.sh against the fresh fixture, and full bash tests/run.sh suite, both pass.

…r generation succeeds

A crash mid-generation (a missing template, a fill() failure on some
stack's command table) previously left the target repo with whichever
files had written before the failure. Because apply.sh never overwrites
an existing file, a re-run then skipped the files it did manage to
write on the first, partial pass -- a confusing state to land in.

Generation now writes into a mktemp staging dir; the target repo is
only touched in a final commit loop once every write has already
succeeded once. Fixes CreativesLibrary#43.

@AnayDhawan AnayDhawan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally: fixture apply.sh run + full test suite pass. CI green.

@AnayDhawan
AnayDhawan merged commit 6fa8ab3 into CreativesLibrary:main Aug 17, 2026
2 checks passed
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.

apply.sh has no rollback on partial write failure

2 participants