Skip to content

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

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

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

Conversation

@gold-silver-copper

Copy link
Copy Markdown
Contributor

create/add/list/remove/prune use the records instead of the store: remove requires a record naming the set; add copies the set's record; list reads TTL/ephemeral/custom from records; prune finds sets under the worktree root and through records in the workspace's repos, judges each by its live record, and reports records it can't read as kept. Tests in tests/safety.rs adapted and added.

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: 19781564-5c03-449c-b0de-4de2a34067fa
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A nested .meta that fails to parse stops the walk over the workspace's
repositories; prune now lists that as kept (so --strict fails) instead
of only warning.

Refs [[tasks/harmony-2765]]
…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]]
…leaves partly moved sets

- only a missing commondir means a --separate-git-dir checkout; any other
  read error is reported as kept, so --strict fails
- a bare source repository is its own git dir, so its sets are found
- a set whose directory is gone is forgotten only when every one of its
  worktrees is gone
- remove says what to do with a refused directory that holds no worktrees

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 c24c7a5 into main Oct 26, 2026
12 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.

1 participant