Skip to content

Canvas Extensions: staged install + atomic swap + two-step refresh (check/apply) #4351

Closed

Description

@VascoSch92

Write-to-temp + validate-before-swap; atomic swap with rollback on validation failure.

Refresh must be a two-step operation, not a single call:

  • Check — resolve the tracked source's ref, fetch into a staging location (never the active install path), run manifest + entrypoint validation against the staged content, return {requested_ref, resolved_ref, validated}. The active bundle is untouched and keeps serving.
  • Apply — a separate, explicit, reconfirmed call, atomically swaps staged → active, with the new bundle's own enabled state set to whatever was just confirmed.

Do not implement this by calling InstallationManager.update() or install(force=True) — confirmed against current source:

  • update() (manager.py:292-317) resolves ref=None ("latest available") and calls self.install(..., force=True) — by its own docstring, this "re-fetches... and force-reinstalls."
  • install(force=True) (manager.py:106-112) does shutil.rmtree(install_path) immediately followed by shutil.copytree(fetched_path, install_path) directly on the live install path — no temp/staging directory at all, and there's a real window mid-swap where the path is empty/partial if anything fails between the two calls.
  • This exact pattern is already the live implementation backing Plugins' refresh (update_plugin() → openhands/sdk/plugin/installed.py:136-141, a direct passthrough to .update()).

Suggested shape: stage into a sibling directory (e.g. <install_dir>/.staging/<name>-<resolved_ref>/), validate there, then swap with a single atomic rename (os.replace, atomic on the same filesystem) rather than rmtree-then-copytree.

Blocked by: #4350, #4349

Metadata

Metadata

Assignees

No one assigned

    Labels

    canvas-extensionspriority:highsecurity-related

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions