Skip to content
This repository was archived by the owner on Nov 3, 2026. It is now read-only.

feat(worktree)!: keep worktree records beside git, drop the global store - #19

Merged
gold-silver-copper merged 6 commits into
mainfrom
feat/stateless-worktrees
Oct 26, 2026
Merged

gold-silver-copper merged 6 commits into
mainfrom
feat/stateless-worktrees

Conversation

@gold-silver-copper

Copy link
Copy Markdown
Contributor

Replaces worktree::store with worktree::record: one record per linked worktree in git's admin dir. The safety check reads each member's record: one naming another set, one it can't read, one outside <repo git dir>/worktrees, differing records in a set, and a locked worktree all block. Loose files are deleted before worktrees are unregistered.

Part of gitkb/meta#126, which has the full description, the investigation and how it was verified. Merge together with it (same branch name, so CI builds them together).

Implements [[tasks/harmony-2765]]

meta recorded every worktree set in ~/.meta/worktree.json behind
worktree.lock. Each linked worktree meta creates now gets a record in
git's own admin directory for it (<repo>/.git/worktrees/<id>/meta-worktree.json),
which git deletes with the worktree. remove and prune prove ownership
from those records; list reads TTL, ephemeral and custom metadata from
them; prune finds sets under the worktree root and through the records
in the workspace's repositories. The store, its lock and the lock module
are deleted.

Sets created by an older meta have no record: remove and prune refuse
them, as they refused unrecorded sets before.

Implements [[tasks/harmony-2765]]
… live record

- add, list and prune read records through one check (member_record),
  so a record outside <repo git dir>/worktrees is never copied or used
- a worktree git has locked blocks removal up front
- prune decides with the record the set's own worktrees hold and needs
  the removal check to see that same record; an orphaned-repos verdict is
  re-checked with every repo the full scan finds; records it cannot read
  are reported as kept (so --strict fails); forgetting a missing set
  deletes only the records prune read

Refs [[tasks/harmony-2765]]
…orts unlistable records

- when the full scan shows a set is not orphaned after all, prune still
  checks its TTL
- a .git/worktrees directory or worktree root prune cannot list is
  reported as kept, so --strict fails instead of finding nothing

Refs [[tasks/harmony-2765]]
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e9499860-20a2-49e0-9e4e-aa52adedd8d1
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

…ved sets and every repo layout

- records are written with a plain atomic write into the existing admin
  dir, without the data dir's privacy check: a git dir inherits its
  checkout's ACL (on Windows under C:\ any signed-in user may change
  files), and that check made create fail there
- prune finds the git dir of --separate-git-dir repos and reports repos
  it cannot inspect; aliases are /-separated on every platform
- records whose worktree is still checked out elsewhere (a moved set)
  are not forgotten; stale records under a reused path are left to git;
  a recorded path that became a link is still checked and reported
- remove says when a record names a set path that is gone
- tests for these, for record-write failures in create and add, and the
  dangling-link test keeps its record again

Refs [[tasks/harmony-2765]]
A record that cannot be read blocks remove and prune, as proof of
ownership, but no longer stops a failed create from deleting the set it
claimed itself. The record-failure test now checks the rollback.

Refs [[tasks/harmony-2765]]
@gold-silver-copper
gold-silver-copper merged commit fd5355c into main Oct 26, 2026
7 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant