Skip to content

afx spawn: issue-less protocol short ids can look like a numbered spawn (maintain-12-a), so the name fallback gives the wrong role id #1998

Backlog

Description

@waleedkadous

Problem

An issue-less protocol spawn (afx spawn --protocol maintain, experiment, …) names its worktree <protocol>-<shortId>, where the short id is four base64url characters. Some short ids make that name indistinguishable from a numbered spawn's worktree name:

  • <digits>-<rest>, for example 12-a: maintain-12-a has the same shape as issue 12 with slug a, so worktreeNameToRoleId() returns builder-maintain-12 instead of builder-maintain-12-a.
  • <key>-, for example A-0-: the same clash with the tracker-key form.

A count over the whole short-id space, made during the fix for #1844 (PR #1994), found 48,880 such ids out of about 16.7 million (48,360 of the first shape, 520 of the second), roughly 0.29% of draws.

Why it matters

worktreeNameToRoleId() is the fallback used when a builder has no row in global.db (the stored id is preferred and is correct). When the fallback is used for one of these worktrees, the role id is wrong, so the builder is missing or mislabelled in the overview and the VS Code Agents view, the same symptom as #1844. The name alone cannot be parsed correctly: both readings are valid.

Suggested fix

generateShortId() already redraws ids that look like a tracker key (#1740, isIssueKey). Extend that redraw so an issue-less spawn never draws an id that starts with <digits>- or has the <key>- shape. That removes the ambiguity for new spawns without changing how any existing name is parsed.

Existing worktrees with such ids are not changed by this; they still resolve through their global.db row.

Acceptance

  • generateShortId() never returns an id for which worktreeNameToRoleId('<protocol>-<id>') differs from buildAgentName()'s role id for that spawn. A test enumerates the id space (or the two shapes) and asserts it.
  • Short ids for task and worktree spawns keep working (task-<id>, worktree-<id> are parsed whole and are not affected, but they share the generator).

Found by the builder on PR #1994 and left out of that PR because it changes the id space.

Activity

  1. added
    area/tower
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions