Skip to content

[Bug Fix] Replace skill bundles atomically instead of merging over them - #767

Open
xsh310 wants to merge 1 commit into
skills-fetch-bundles-and-writefrom
skills-mirror-download
Open

xsh310 wants to merge 1 commit into
skills-fetch-bundles-and-writefrom
skills-mirror-download

Conversation

@xsh310

@xsh310 xsh310 commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

What did you change, and why?

Change: write_skill now clears a skill's bundle directory before rewriting it, so the on-disk copy is a fresh mirror of the current bundle rather than the new files merged on top of the old ones.

Why: The writer merged: it wrote every file from the new bundle but never removed files no longer in it, so a file deleted from a skill in Unity Catalog lingered on disk after a re-download. Clearing the directory first makes dropped files vanish. The clear-then-rewrite is also self-healing: a write interrupted partway leaves only that one directory incomplete (never a stray copy elsewhere), and the next write clears and rebuilds it, so a retry always converges on the current bundle. On the launch-refresh path the manifest's uc_update_time is advanced only after a successful write, so an interrupted write stays flagged as stale and is retried on the next launch.

This is the shared writer for every download path, so ug skills add re-downloads get the same mirror semantics; the launch-time auto-update stacked on top (#764) relies on it.

How do you know it works?

Testing: Added TestWriteSkill cases for the deleted-upstream-file case, an empty bundle leaving the existing copy untouched, replacing a symlinked bundle without following it to its target, converging from an interrupted previous write (a pre-seeded partial directory), and leaving only the bundle directory behind. uv run ruff check, ruff format --check, ty check src, and uv run pytest all pass locally.

This pull request and its description were written by Isaac.

@xsh310
xsh310 added this pull request to stack #768 September 20, 2026 19:23
Comment thread src/ucode/skills_download.py Outdated
Comment thread src/ucode/skills_download.py Outdated
@xsh310
xsh310 force-pushed the skills-mirror-download branch from 2314a51 to ec94820 Compare September 21, 2026 20:34
write_skill wrote each new file over the existing bundle dir, so a file removed
from a skill in Unity Catalog lingered on disk after a re-download. Clear the
bundle directory before rewriting it, so the on-disk copy mirrors UC. A write
interrupted partway leaves only that one directory incomplete, never a stray
copy elsewhere; the next write clears and rebuilds it, so a retry converges on
the current bundle.

This is the shared writer for every download path, so `ug skills add`
re-downloads gain the same mirror semantics.

Co-authored-by: Isaac <no-reply@databricks.com>
@xsh310
xsh310 marked this pull request as ready for review September 21, 2026 20:40
@xsh310
xsh310 force-pushed the skills-mirror-download branch from ec94820 to 678305b Compare September 21, 2026 20:45
@xsh310 xsh310 added bug Something isn't working and removed bug Something isn't working labels Sep 21, 2026
@xsh310 xsh310 changed the title Replace skill bundles atomically instead of merging over them [Bug Fix] Replace skill bundles atomically instead of merging over them Sep 21, 2026
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