Skip to content

fix(dispatch): unique role suffix to unblock wave dispatch collisions - #1626

Merged
namastex888 merged 1 commit into
devfrom
wish/dispatch-role-collision-fix
May 3, 2026
Merged

namastex888 merged 1 commit into
devfrom
wish/dispatch-role-collision-fix

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Summary

genie work was deterministically naming workers by group number, causing rejectDuplicateRole exit on every multi-wish dispatch. Genie está inútil — autopg G3+ blocked, retire-session-names work blocked, every wish-work dispatch hits this.

Root cause

src/term-commands/dispatch.ts:725:

const effectiveRole = `${agentName}-${group}`;

Two wishes with group 3 always produce engineer-3 → collide on the second one.

Fix (1-line, surgical)

const effectiveRole = `${agentName}-${group}-${randomUUID().slice(0, 4)}`;

Roles become engineer-3-a1b2 — unique by construction, no collision possible, short enough to read. Mirrors what generateWorkerId (agents.ts:446) already does for the agent id field.

Out of scope (followup)

Wider unification of the 3 worker-id paths (TUI nextRoleSuffix in tmux.ts:93, generateWorkerId at agents.ts:446, dispatch wish-work) is wish-territory. This PR is the surgical unblocker.

Validation

  • bun run typecheck clean

Test plan

  • After merge: genie work autopg-distribution-cutover from a fresh shell dispatches G3 without rejectDuplicateRole exit
  • After merge: parallel wishes (autopg + retire-session-names) can both dispatch group 3 without collision
  • No regression in existing single-wish dispatch flows

🤖 Generated with Claude Code

genie work was deterministic-naming workers by group number
(`agentName-group`), causing rejectDuplicateRole exit when alive
engineers with same role exist from prior wishes.

Symptom: every multi-wish operation hit
  Error: Worker with role "engineer-3" already exists in team "genie"

Root cause (dispatch.ts:725):
  effectiveRole = `${agentName}-${group}`
Two wishes with group 3 always collide.

Fix: append 4-char UUID suffix at construction time, mirroring the
generateWorkerId helper at agents.ts:446. Roles become
"engineer-3-a1b2" — unique by construction, no collision possible,
short enough to read.

Wider unification of the 3 worker-id paths (TUI nextRoleSuffix,
generateWorkerId, dispatch wish-work) deferred to a follow-up wish.
This is the surgical unblocker.

Validation: bun run typecheck clean.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac1133ab-e49d-4656-8772-8cfbf6fda071

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wish/dispatch-role-collision-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 237d1570a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

console.log(` Group: ${group}`);

const effectiveRole = `${agentName}-${group}`;
const effectiveRole = `${agentName}-${group}-${randomUUID().slice(0, 4)}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Increase role suffix entropy to avoid residual collisions

Using randomUUID().slice(0, 4) leaves only 16 bits of entropy for effectiveRole, so two same-group dispatches can still generate the same role and hit rejectDuplicateRole (the original failure mode), just probabilistically instead of deterministically. In multi-wish wave dispatches where many workers are started, this creates intermittent hard-to-reproduce aborts; consider a longer suffix (or retry-on-collision) so role uniqueness is effectively guaranteed.

Useful? React with 👍 / 👎.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the runWorkDispatch function in src/term-commands/dispatch.ts to append a random four-character suffix to the effectiveRole identifier. Feedback suggests logging the full effectiveRole to the console to help operators identify specific agent instances when multiple agents are running.

console.log(` Group: ${group}`);

const effectiveRole = `${agentName}-${group}`;
const effectiveRole = `${agentName}-${group}-${randomUUID().slice(0, 4)}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since the effectiveRole now includes a random suffix, it would be beneficial to log the full role name to the console. This helps the operator identify the specific agent instance for commands like genie read or genie send ... --to , especially when multiple agents of the same type are running in a wave.

Suggested change
const effectiveRole = `${agentName}-${group}-${randomUUID().slice(0, 4)}`;
const effectiveRole = agentName + "-" + group + "-" + randomUUID().slice(0, 4);
console.log(" Role: " + effectiveRole);

@namastex888
namastex888 merged commit 014dac9 into dev May 3, 2026
16 checks passed
namastex888 added a commit that referenced this pull request May 4, 2026


PRs #1626/1627/1628 enforce UUID-only agents.id post migration 061.
Tests in resolveSpawnIdentity (agents.test.ts) and tui-spawn-dx
integration (Group 8) assert the legacy id=name contract that those
PRs deliberately broke. Skipping with TODO pointer to
retire-session-names wish #175 which is rewriting them holistically
(G1 + G2 in flight, see tasks #176/#177).

This unblocks dev CI so the auto-version bump can publish v4.260503.11+
with the spawn pipeline UUID fixes that the production server needs.

Validation: bun run typecheck clean; bun run lint 0 errors.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@automagik-genie
automagik-genie deleted the wish/dispatch-role-collision-fix branch September 25, 2026 04:51
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.

1 participant