Skip to content

Managed worktrees: adopt OpenClaw lifecycle (snapshot, provision, GC) #118

Description

@sambitcreate

Summary

Aiden already has a strong owned-worktree core (userData/worktrees, ownership markers, fail-closed admission, quarantine delete, startup crash reconcile, desktop + remote APIs). We should not rewrite that stack — add OpenClaw’s product lifecycle layer on top.

Reference plan (Notion draft): https://app.notion.com/p/3da80314a1c481ea9631e23994e8689d
OpenClaw docs: https://docs.openclaw.ai/concepts/managed-worktrees
OpenClaw PRs: openclaw/openclaw#100535 · openclaw/openclaw#100788
steipete (2026-09-13): worktrees ~80% faster via APFS/Btrfs/XFS/ReFS folder clones — treat CoW as P2 after correctness.

What Aiden has today

  • Layout: userData/worktrees/<repo>-<12hex>/<branchSlug>-<uuid8> (git.ts:4645-4654)
  • Create: git worktree add -b <branch> … HEAD only — no base-ref picker (git.ts:4625-4658)
  • Ownership: aiden-owner + device/inode; admission gates terminals/LLM/schedules
  • Delete: clean-only (incl. ignored); quarantine + native remover; no snapshot/restore (git.ts:4835-4851)
  • UI: /worktree, create → new chat (chat-pane.tsx:2459-2504); remote create/delete

P0

  1. Snapshot-before-delete + restore (refs/aiden/snapshots/…) — dirty work is stuck today
  2. Disk admission before create
  3. Disable Git hooks on managed worktree add
  4. .worktreeinclude provisioning
  5. Fail-closed .aiden/worktree-setup.sh with sanitized env only (AIDEN_SOURCE_TREE_PATH / AIDEN_WORKTREE_PATH)

P1

  • aiden/<name> branch namespace + base-ref picker
  • Idle GC (~7d) + snapshot retain (~30d); manual never auto-swept
  • Settings → Worktrees (list / restore / force)

P2

  • APFS/Btrfs/ReFS CoW acceleration
  • Configurable worktreeRoot

Do not

  • Run setup scripts with full process env
  • Auto-sweep manual worktrees
  • Chase CoW before snapshot/restore is correct

Acceptance (MVP)

  • Hooks disabled on managed create
  • Disk admission gates create
  • .worktreeinclude copies recorded ignored files
  • Dirty delete snapshots then removes; restore recreates unstaged dirty state
  • Existing ownership/admission/quarantine delete still pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions