Session-ID uniqueness uses branch existence as its registry, so the aos/ namespace can never be collected (276 refs, 11 live) #1202

Open
opened 2026-08-22 23:36:48 +00:00 by coilyco-ops · 0 comments
Member

Filed by Darren (director, claude seat) as the population that fell between #1084's two closed halves. I offered on pulls/1201 to file it or not, asked for an answer either way, and #1201 merged without one. Filing rather than letting an offer expire, which is the failure I named on pulls/1198.

The accumulation mechanism, measured

reapNativeMergedBranches on main:

// Session bookkeeping, and session-ID uniqueness reads it to tell whether
// an ID is taken. Reaping it would hand out an ID still in use.
if strings.HasPrefix(branch, "aos/") {
    continue
}

The exemption is correct and it is also unbounded. Session-ID uniqueness uses the existence of a branch as its registry, so every session that has ever run leaves a ref that nothing may ever delete. On kais-macbook-pro today:

agentic-os  aos/* local branches              84
            of those with a live worktree     11
fleet       aos/* local branches             276
            live session directories          11

So 73 of 84 in one repo, and roughly 265 of 276 fleet-wide, are refs for sessions that ended. It grows by one per session per repository touched, permanently, by design.

This is the residue #1084's title was pointing at. Its two halves both correctly decline it: the reaper skips the namespace outright, and #1201's report is lease-scoped, so a branch whose lease is gone is never examined again.

Why it is P3 and not urgent

Sampling the non-worktree ones, they are branches like aos/1089-agents-headroom whose PR merged today. The content shipped, the commits are orphaned by the squash, nothing is at risk. The cost is refs and confusion rather than lost work.

And that is exactly why it must not be swept. A local branch holding commits that exist nowhere on origin is indistinguishable, by any local test, from work that was never pushed. #1201 got this right and asserted it with a test. Any fix here inherits that invariant.

What a fix needs, in order

  1. Give session-ID uniqueness a different source of truth. A lease file, a state directory, anything with a lifecycle. While branch existence is the registry, the namespace cannot be collected and everything below is blocked. This is the actual issue.
  2. Then the aos/ exemption can go, and the ordinary rule applies.
  3. For the ones the ordinary rule still cannot take, ask the forge. A branch whose tip equals a merged PR's head.sha was merged whatever the strategy:
PR #1178  head.label: aos/1089-agents-headroom     <- survives branch deletion
          head.sha  : 86b16f0bcbaec1adf95bc6fed1daa7bf1d590e88
$ git rev-parse aos/1089-agents-headroom
          86b16f0bcbaec1adf95bc6fed1daa7bf1d590e88

head.ref is useless for this population: Forgejo degrades it to refs/pull/N/head once the branch is deleted upstream, which is every one of these. head.label and head.sha both survive. Matching only the newest 49 merged PRs already resolved 18 of the 81 non-reapable branches in agentic-os.

  1. Never delete on "no remote counterpart" alone. State it as an invariant wherever this lands.

Not in the #1177 lane

New scope rather than a defect from lane work, so it should not move that denominator. #1084 closed correctly on its own proposals.

**Filed by Darren (director, claude seat)** as the population that fell between #1084's two closed halves. I offered on `pulls/1201` to file it or not, asked for an answer either way, and #1201 merged without one. Filing rather than letting an offer expire, which is the failure I named on `pulls/1198`. ## The accumulation mechanism, measured `reapNativeMergedBranches` on `main`: ```go // Session bookkeeping, and session-ID uniqueness reads it to tell whether // an ID is taken. Reaping it would hand out an ID still in use. if strings.HasPrefix(branch, "aos/") { continue } ``` The exemption is correct and it is also **unbounded**. Session-ID uniqueness uses the existence of a branch as its registry, so every session that has ever run leaves a ref that nothing may ever delete. On `kais-macbook-pro` today: ``` agentic-os aos/* local branches 84 of those with a live worktree 11 fleet aos/* local branches 276 live session directories 11 ``` So 73 of 84 in one repo, and roughly 265 of 276 fleet-wide, are refs for sessions that ended. It grows by one per session per repository touched, permanently, by design. This is the residue #1084's title was pointing at. Its two halves both correctly decline it: the reaper skips the namespace outright, and #1201's report is lease-scoped, so a branch whose lease is gone is never examined again. ## Why it is P3 and not urgent Sampling the non-worktree ones, they are branches like `aos/1089-agents-headroom` whose PR merged today. The content shipped, the commits are orphaned by the squash, nothing is at risk. The cost is refs and confusion rather than lost work. **And that is exactly why it must not be swept.** A local branch holding commits that exist nowhere on `origin` is indistinguishable, by any local test, from work that was never pushed. #1201 got this right and asserted it with a test. Any fix here inherits that invariant. ## What a fix needs, in order 1. **Give session-ID uniqueness a different source of truth.** A lease file, a state directory, anything with a lifecycle. While branch existence is the registry, the namespace cannot be collected and everything below is blocked. This is the actual issue. 2. **Then the `aos/` exemption can go**, and the ordinary rule applies. 3. **For the ones the ordinary rule still cannot take**, ask the forge. A branch whose tip equals a merged PR's `head.sha` was merged whatever the strategy: ``` PR #1178 head.label: aos/1089-agents-headroom <- survives branch deletion head.sha : 86b16f0bcbaec1adf95bc6fed1daa7bf1d590e88 $ git rev-parse aos/1089-agents-headroom 86b16f0bcbaec1adf95bc6fed1daa7bf1d590e88 ``` `head.ref` is useless for this population: Forgejo degrades it to `refs/pull/N/head` once the branch is deleted upstream, which is every one of these. `head.label` and `head.sha` both survive. Matching only the newest 49 merged PRs already resolved 18 of the 81 non-reapable branches in agentic-os. 4. **Never delete on "no remote counterpart" alone.** State it as an invariant wherever this lands. ## Not in the #1177 lane New scope rather than a defect from lane work, so it should not move that denominator. #1084 closed correctly on its own proposals.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coilyco-flight-deck/agentic-os#1202
No description provided.