daemon: persist a retained-worktree store in state_dir #78

Closed
opened 2026-08-24 09:38:40 +01:00 by naps62-yolo · 0 comments
Collaborator

Once a kill can be refused and a force-kill retains, worktrees outlive their sessions on purpose. Something has to remember them, or a refusal just produces invisible garbage on disk — the failure mode the Spawn v2 reviews kept finding.

A state_dir-backed store of worktrees the daemon created that no longer have a session, holding for each one:

  • the worktree path and its base repository
  • the branch it holds
  • why it was retained (force-killed, exited-with-unsaved-work, and room for more)
  • when it entered the store

It must survive a daemon restart — this is the recovery path for everything else in the milestone, so a store that is lost on restart is worse than none. Write it the way sidecar.rs writes session records: atomic replace, tolerant of a missing or malformed file.

Entries leave the store when the worktree is reclaimed, and when the daemon notices the directory is gone (someone removed it by hand) — a stale entry must not accumulate.

Non-goals: this is not an ownership record and must not be used to decide whether a path may be adopted; #E1 settles that nothing is ever adopted.

Once a kill can be refused and a force-kill retains, worktrees outlive their sessions on purpose. Something has to remember them, or a refusal just produces invisible garbage on disk — the failure mode the Spawn v2 reviews kept finding. A `state_dir`-backed store of worktrees the daemon created that no longer have a session, holding for each one: - the worktree path and its base repository - the branch it holds - why it was retained (`force-killed`, `exited-with-unsaved-work`, and room for more) - when it entered the store It must survive a daemon restart — this is the recovery path for everything else in the milestone, so a store that is lost on restart is worse than none. Write it the way `sidecar.rs` writes session records: atomic replace, tolerant of a missing or malformed file. Entries leave the store when the worktree is reclaimed, and when the daemon notices the directory is gone (someone removed it by hand) — a stale entry must not accumulate. Non-goals: this is not an ownership record and must not be used to decide whether a path may be adopted; #E1 settles that nothing is ever adopted.
naps62-yolo added this to the Worktree lifecycle milestone 2026-08-24 09:38:40 +01:00
naps62-yolo added the area/daemondifficulty/mediumtype/feat labels 2026-08-24 09:38:40 +01:00
naps62-yolo added a new dependency 2026-08-24 09:39:00 +01:00
naps62-yolo added a new dependency 2026-08-24 09:39:00 +01:00
naps62-yolo added a new dependency 2026-08-24 09:39:01 +01:00
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Reference: naps62/maestro#78