Skip to content

Fix #1992: afx cleanup finds all-digit task builders (task id via buildAgentName) - #1994

Merged
waleedkadous merged 23 commits into
mainfrom
builder/bugfix-1992
Nov 27, 2026
Merged

waleedkadous merged 23 commits into
mainfrom
builder/bugfix-1992

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reduced after PR #1993 merged. The Agents-view part of #1992 is now fully fixed on main. v3.3.6 (PR #1848) fixed the reported task-S0-L / task-_-LM ids. PR #1993 (bugfix-1844) then routed the remaining task and issue-less protocol role ids through buildAgentName, closing the leading-zero drift. This PR originally did that same overview.ts work. I merged main in, took its overview.ts and overview.test.ts unchanged, and dropped my duplicates.

What remains is the same drift in afx cleanup, which main doesn't have yet.

Fixes #1992

Root Cause

Spawn names a task builder with buildAgentName('task', shortId), which strips leading zeros from an all-digit id: task-0123 becomes builder-task-123. afx cleanup rebuilt the id by hand (`builder-task-${shortId.toLowerCase()}`) and kept the zeros:

  • afx cleanup -p task-0123 looked up builder-task-0123 and missed the stored builder-task-123. Its last fallback matches the builder's display name (Task: …), so it failed with "Builder not found for project: task-0123".
  • afx cleanup --task 0123 failed the same way. Its worktree-path fallback looks for /0123 and can't match /task-0123. (--task task-0123 was saved by that fallback.)

Fix

  • utils/agent-names.ts: new taskBuilderId(name). It takes task-bEPd or bEPd and returns buildAgentName('task', …), next to the function spawn names builders with.
  • commands/cleanup.ts: the --task and --project lookups are extracted into exported findTaskBuilder / findProjectBuilder, which cleanup() calls. Both normalize through taskBuilderId. Lookup order and fallbacks are unchanged.

Test Plan

  • cleanup-task-builders.test.ts now drives cleanup.ts's real lookups; before, it re-implemented them in the test file. New cases --task 0123 and --project task-0123 find builder-task-123. Both fail with the old hand-built normalization and pass with the fix.
  • agent-names.test.ts: direct taskBuilderId test (task-bEPd, bEPd, task-S0-L, task-_-LM, task-0123, 0123).
  • overview.ts / overview.test.ts are identical to main (no diff).
  • Build passes
  • All tests pass on the branch merged with current main

The short-id redraw for ambiguous issue-less protocol names is tracked separately in #1998.

The parser kept the leading zeros of an all-digit task short id (task-0123 ->
builder-task-0123) while spawn names the terminal builder-task-123, so the
Agents view filtered that builder out when its global.db row was missing.
The task branch now calls buildAgentName, the function spawn names the
terminal with, so the two cannot drift.
…ay in the overview

Pins the issue's ids (task-S0-L, task-_-LM) through getOverview's
live-terminal filter, and the all-digit leading-zero case that still drifted.
…with buildAgentName

CMAP review (claude) found the same leading-zero drift in two more places:
- worktreeNameToRoleId's generic-protocol branch kept the zeros of an all-digit
  issue-less short id (maintain-0123 -> builder-maintain-0123; terminal is
  builder-maintain-123). It now calls buildAgentName too.
- afx cleanup -p task-0123 built builder-task-0123, missed the stored
  builder-task-123, and failed with 'Builder not found'. Both task lookups in
  cleanup now share taskBuilderId(), built on buildAgentName.
…h buildAgentName

The cleanup mirror tests now normalize with cleanup.ts's own taskBuilderId
rather than a hand-rolled copy, so they exercise the real derivation.
@waleedkadous waleedkadous changed the title Fix #1992: name a task builder's overview role id with buildAgentName Fix #1992: name builder role ids with buildAgentName (task, protocol, cleanup) Nov 26, 2026
…e- asymmetry

CMAP round 2 (codex, claude):
- cleanup's --task / --project lookups are now exported findTaskBuilder /
  findProjectBuilder, which cleanup() calls, so tests drive the real lookups
  rather than a re-implementation (behavior unchanged).
- taskBuilderId moves to utils/agent-names.ts, beside buildAgentName.
- Comment the worktree- branch: spawnWorktree keeps leading zeros, so it must
  not go through buildAgentName.
…sk-0123); pin worktree-0123

The cleanup tests import findTaskBuilder / findProjectBuilder instead of
mirroring them. worktree-0123 must stay worktree-0123.
…ctly

CMAP round 3 (claude): the parser test compared against buildAgentName on
both sides; add literal builder-task-123 / builder-maintain-123, and a direct
taskBuilderId test including the issue's ids.
@waleedkadous
waleedkadous marked this pull request as draft November 26, 2026 00:27
# Conflicts:
#	packages/codev/src/agent-farm/__tests__/overview.test.ts
#	packages/codev/src/agent-farm/servers/overview.ts
PR #1993 (bugfix-1844) already routes worktreeNameToRoleId's task and
issue-less protocol branches through buildAgentName, with tests for the
issue's ids, leading zeros, getOverview and the worktree- carve-out. The
merge took main's overview.ts and overview.test.ts; this drops my duplicate
getOverview test that merged in beside main's. What remains is the afx
cleanup fix (findTaskBuilder / findProjectBuilder via taskBuilderId) and its
tests.
@waleedkadous waleedkadous changed the title Fix #1992: name builder role ids with buildAgentName (task, protocol, cleanup) Fix #1992: afx cleanup finds all-digit task builders (task id via buildAgentName) Nov 26, 2026
@waleedkadous
waleedkadous marked this pull request as ready for review November 27, 2026 04:43
@waleedkadous
waleedkadous merged commit 33e07f1 into main Nov 27, 2026
8 checks passed
waleedkadous added a commit that referenced this pull request Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VSCode Agents view hides task builders whose id contains - or _

1 participant