Skip to content

What --prune should do inside a container, where recorded paths resolve #462

Description

@blooop

Question

What should --prune do when it runs inside a container, where every recorded worktree path resolves?

Raised by the keystone decision on #445, and it goes first among the fog it raised because it is a principle 1 question with a live hazard behind it.

The whole host-side design rests on an asymmetry: a registered agent worktree carries a container path like /workspaces/<id>/.claude/worktrees/agent-abc, which does not resolve on the host. That is what makes git worktree remove <recorded path> a pure metadata operation there: git skips the dirty check and the tree deletion because file_exists(wt->path) is false, and drops only the registration.

Inside a container that path does resolve. So the same call:

  • deletes a working tree, not just a registration, and
  • does apply git's dirty check, which is a different safety profile rather than simply a worse one.

The two radii the keystone separated collapse into one.

And the hazard as it stands: the keystone's note says the only thing currently stopping a container from collecting its own live agent worktrees is the Held arm of the classification, which is an accident of the classification rather than a decision. Something that prevents data loss by accident is not a safety property, it is a coincidence with a good outcome so far.

Note that running dl inside a container is a supported thing here, not a hypothetical: CLAUDE.md documents pixi run dl as the in-container build, and aid opens nested workspaces (see #327).

Candidates to weigh, at least:

  1. Refuse. --prune is a host maintenance command; detect the container and decline with a reason. Simplest, and principle 1's default. Establish how a container is detected without a guess.
  2. Run, with the container's own semantics acknowledged — every removal is a real tree deletion, so the whole safety predicate applies to every candidate rather than only to the ones with host directories.
  3. Scope it out — prune only what is not the container's own workspace. Weigh whether that distinction can be drawn soundly from inside.

Whatever wins must make the current accident into a stated property, and the answer feeds a row of the contract table on #455.

How the answer gets tested: a test that pins the in-container behaviour explicitly, so the property stops depending on which arm a classification happens to take.

Activity

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions