Preserve history across a no-op resume
Use when
A harness reuses a worktree, then decides whether its directory and branch can be retired. The dangerous case is committed, unpushed work with a clean checkout.
Action
During authorized maintenance, require 2.1.334 or a reviewed equivalent. In an owned lifecycle adapter, preserve repository/worktree identity, the original creation-base commit, and the pre-resume tip in the existing task record. Never replace that base with current HEAD merely because a session resumed. Missing provenance blocks automatic retirement.
Before
separately
authorized
retirement,
require
git
merge-base
--is-ancestor
"$SAVED_TIP"
"$RETAINED_REF"
to
return
zero
in
the
attested
repository.
The
approved
retained
ref
must
be
protected
outside
the
removal
scope.
Non-ancestor
results
and
errors
block.
Hold
lifecycle
ownership
and
recheck
tip/ref
identities
immediately
before
disposition.
Acceptance check
In a separately authorized disposable repository, create a worktree containing a committed sentinel reachable only through its branch. Leave no dirty files. Exercise the actual resume-and-exit path, making no new commits and approving no removal. The branch, worktree, and committed sentinel must survive.
Missing or unrelated retained refs, missing baseline, wrong repository, and Git errors must block the owned gate. A protected ref containing the saved tip passes only the history-retention check. Retain version, frozen commit IDs, lifecycle events, and before/after branch and file evidence.
Evidence
The dated release explicitly repairs an unchanged resumed worktree losing its branch-only unpushed commit. An inspectable historical report combines extracted-code analysis with a standalone Git simulation: replacing the creation baseline with resumed HEAD makes the new-commit comparison empty. Official Git documentation separates working-tree status from ancestry.
Caveat
The historical script simulates cleanup; it does not exercise today’s binary. No vendor implementation/regression suite or independent post-fix result was inspected. A recorded SHA is not a backup. Ancestry excludes squash-equivalent history; ignored files, submodules, live dependencies, and cleanup approval remain separate obligations. No upgrade, deletion, or fixture ran here.