fix(dispatch): unique role suffix to unblock wave dispatch collisions - #1626
Conversation
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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 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)}`; |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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)}`; |
There was a problem hiding this comment.
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.
| const effectiveRole = `${agentName}-${group}-${randomUUID().slice(0, 4)}`; | |
| const effectiveRole = agentName + "-" + group + "-" + randomUUID().slice(0, 4); | |
| console.log(" Role: " + effectiveRole); |
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>
Summary
genie workwas deterministically naming workers by group number, causingrejectDuplicateRoleexit 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:Two wishes with group 3 always produce
engineer-3→ collide on the second one.Fix (1-line, surgical)
Roles become
engineer-3-a1b2— unique by construction, no collision possible, short enough to read. Mirrors whatgenerateWorkerId(agents.ts:446) already does for the agentidfield.Out of scope (followup)
Wider unification of the 3 worker-id paths (TUI
nextRoleSuffixintmux.ts:93,generateWorkerIdatagents.ts:446, dispatch wish-work) is wish-territory. This PR is the surgical unblocker.Validation
bun run typecheckcleanTest plan
genie work autopg-distribution-cutoverfrom a fresh shell dispatches G3 withoutrejectDuplicateRoleexit🤖 Generated with Claude Code