Skip to content

wrap: sweep the artefacts a long session leaves behind — stale branches, cycle state, deferred notes, recordless claims #435

Description

@evanharmon1

Invariant

A session that ends with /retro then /wrap leaves no artefact behind that
the next session would have to find by hand — or is told about each one it
deliberately leaves.

Current violation (observed 2026-08-12)

/wrap covers uncommitted and unpushed work, claim release, and the session
rename. /retro covers PRs, issues, review threads, and promises. Neither
looks at anything on disk beyond git status, so a long session leaves a
predictable tail of debris that only a human notices.

Everything below was left over by one session and found by hand during its
retro — none of it was surfaced by either skill:

Artefact Left behind by this session
Local branches whose PR is merged or closed feat/checker-settle-and-carry (PR closed unmerged), fix/checker-empty-body-crash (merged) — both in harmon-devkit, still checked out-able weeks later
shepherd-codex cycle state 7 .json files across both repos, one per shepherded PR, all long merged. check-codex-cloud-review.sh reap exists precisely for this and nothing runs it
deferred-findings directories empty fix/ and feat/ parents remain after the notes are consumed
Fixture temp dirs from killed gate runs dozens of /tmp/codex-cloud-review-* and /tmp/harmon-init-worktree-* left by rounds killed on harness timeouts

None of it is harmful in isolation. Together it is the reason "is this branch
still needed?" is a question every session has to re-answer.

Verify

rg -n 'branch --merged|reap|deferred-findings|shepherd-codex' \
  ai/skills/universal/wrap/SKILL.md

No hits means /wrap still checks none of these.

Proposed additions to /wrap

Each is read-only first, and proposes rather than performs — the skill's
existing discipline for claims.

  1. Local branches whose PR is finished. For each local branch other than
    the default, resolve its PR and report merged / closed-unmerged / none.
    Offer git branch -d for merged ones and -D for closed-unmerged, one
    command per branch so the user can decline any. Never touch a branch with
    an open PR, unpushed commits, or no upstream — those are live work.
  2. Reap shepherd cycle state. Run check-codex-cloud-review.sh reap where
    the helper is vendored. It already refuses to remove state for open PRs, so
    this is safe unconditionally, and it is the exact lifecycle half the script
    documents as belonging to a sweep nobody runs.
  3. Deferred-findings sweep. Report any file left under the
    deferred-findings git-dir path — an unconsumed note is a lost P2 — and
    prune the empty branch-name directories once the files are gone.
  4. Claim markers with no claim record. /wrap's claim step keys off the
    Claiming — comment /claim writes. Markers set by hand — an easy path,
    since tick-criteria.sh requires an assignee — are invisible to it and to
    the release workflow, which then reports success (harmon-devkit#434). List
    any issue this session touched that still carries a claim:* label or
    assignee, whatever its record, so the mismatch surfaces at the moment
    somebody can act on it.
  5. Draft PRs left open by this session. For each, confirm the blocker
    report the shepherd contract requires actually exists on the PR. A draft
    with no stated blocker is a stall nobody can pick up.
  6. Merged PRs whose issue has unticked criteria. The closing-keywords
    guard catches this in CI, but only for the PR that closes the issue. A
    merged PR that used Refs can still leave criteria unticked on work that
    is genuinely done.
  7. Unreleased consumer changes. If the session merged anything under
    template/ and a release PR is still open, say so — consumers lag until it
    merges, and the session that made the change is the one that knows it
    matters.

Worth considering, not proposed: pruning /tmp fixture directories. They are
outside the repo, other processes may own them, and the pattern is
repo-specific — a report ("N fixture dirs older than a day") is probably the
right ceiling.

Acceptance criteria

  • /wrap reports local branches whose PR is merged or closed-unmerged, and offers a per-branch delete, never touching branches with open PRs or unpushed commits.
  • /wrap reaps shepherd cycle state where the helper is vendored.
  • /wrap reports unconsumed deferred-findings notes and prunes empty directories.
  • /wrap reports claim markers that have no claim record, independently of the record-based release path.
  • /wrap reports draft PRs from this session that carry no blocker report.
  • Every check reports before acting; nothing destructive runs without the user's go-ahead.

Found while running /retro on a session that had produced all four artefact
classes above. Related: harmon-devkit#434 (markers without a record strand
silently).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions