Skip to content

fix(irc): prevent ghost nick loops on collision recovery - #96067

Closed
mar-zh wants to merge 1 commit into
openclaw:mainfrom
mar-zh:fix/irc-ghost-nick-collision
Closed

mar-zh wants to merge 1 commit into
openclaw:mainfrom
mar-zh:fix/irc-ghost-nick-collision

Conversation

@mar-zh

@mar-zh mar-zh commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Fixes #96064

When multiple IRC accounts are configured, the nick collision recovery logic creates "ghost" nicks with underscore suffixes that connect and immediately disconnect in a loop.

Root Cause

The buildFallbackNick function always returns nick + "_" with no uniqueness. Combined with a per-connection fallbackNickAttempted flag that resets on each reconnect, this causes the same ghost nick to be used repeatedly.

Changes

  1. buildFallbackNick now accepts an attempt parameter — allows generating unique fallback nicks (Nick1, Nick2, etc.) instead of always Nick_

  2. Track fallback attempt count instead of boolean flag — allows attempting multiple unique fallbacks instead of just one

  3. Limit attempts to 10 per connection — prevents infinite loops if all fallbacks are taken

Before

function buildFallbackNick(nick: string): string {
  const suffix = "_";  // Always the same
  return `${base}${suffix}`;
}

// Only one attempt per connection
if (!fallbackNickAttempted) {
  fallbackNickAttempted = true;
  const fallbackNick = buildFallbackNick(desiredNick);  // Always "Nick_"
  ...
}

After

function buildFallbackNick(nick: string, attempt: number = 0): string {
  const suffix = attempt > 0 ? `${attempt}` : "_";  // Unique suffix
  ...
}

// Up to 10 unique attempts
if (fallbackNickAttemptCount < 10) {
  fallbackNickAttemptCount++;
  const fallbackNick = buildFallbackNick(desiredNick, fallbackNickAttemptCount);  // "Nick1", "Nick2", etc.
  ...
}

Testing

  • NoPII leaked (generic bug report, no mesh-specific details)
  • Tested locally with a simple node script verifying buildFallbackNick("Test", 0) → "Test_" and buildFallbackNick("Test", 1) → "Test1"

Notes

This is a minimal fix. A more comprehensive solution might involve:

  • Caching successful fallback nicks across reconnects
  • Better GHOST command handling (wait for response before proceeding)
  • Server-side detection of "my own ghost" vs "someone else's nick"

- Change buildFallbackNick to accept attempt number for unique suffixes
- Use numeric suffix (1, 2, 3...) instead of always '_'
- Limit fallback attempts to 10 per connection to prevent infinite loops
- Fixes issue where Nick_ ghosts would repeatedly connect/disconnect

Fixes openclaw#96064
@openclaw-barnacle openclaw-barnacle Bot added channel: irc size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 23, 2026
@clawsweeper

clawsweeper Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Close: current main already fixes the IRC ghost-nick fallback loop through #96108, with a module-scoped fallback sequence and regression tests. This PR is now a weaker, conflicting branch because its counter remains scoped to one connectIrcClient call and the branch lacks real IRC proof/tests.

Root-cause cluster
Relationship: superseded
Canonical: #96108
Summary: This PR and the merged canonical PR targeted the same IRC ghost-nick issue, but the merged PR is now the current-main implementation with tests and proof.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the merged current-main IRC fallback implementation from #96108 and close this superseded branch.

Do we have a high-confidence way to reproduce the issue?

Yes for the original pre-fix path: the PR base and latest release use a fixed underscore fallback with connection-local recovery state, and the merged canonical PR supplied ngircd live output. Current main no longer has that failure path because fallback suffix sequencing is module-scoped.

Is this the best way to solve the issue?

No for this branch. The merged implementation in #96108 is the better fix because its sequence crosses fresh connection attempts and includes regression coverage plus real IRC proof.

Security review:

Security review cleared: The PR diff only changes in-memory IRC nick fallback logic and adds no dependency, script, credential, permission, or package-supply-chain surface.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • wendy-chsy: Authored the merged IRC fallback fix branch whose merge commit introduced the current main module-scoped fallback sequence and tests. (role: recent fix author; confidence: high; commits: 4535a353c820, 33a03d9a3f1e, 6ce88ca51d05; files: extensions/irc/src/client.ts, extensions/irc/src/client.test.ts)
  • vincentkoc: Live PR metadata shows this account merged the canonical fix PR that closed the linked IRC ghost-nick issue. (role: merger of fixed implementation; confidence: medium; commits: 6ce88ca51d05; files: extensions/irc/src/client.ts, extensions/irc/src/client.test.ts)
  • vignesh07: Authored the merged first-class IRC channel support that introduced the IRC client, monitor, and send paths containing the fallback behavior. (role: feature introducer; confidence: high; commits: fa906b26add7; files: extensions/irc/src/client.ts, extensions/irc/src/monitor.ts, extensions/irc/src/send.ts)
  • Takhoffman: Merged the first-class IRC channel support PR that added the current IRC client area. (role: feature merger; confidence: medium; commits: fa906b26add7; files: extensions/irc/src/client.ts, extensions/irc/src/monitor.ts, extensions/irc/src/send.ts)

Codex review notes: model internal, reasoning high; reviewed against 3811001d2783; fix evidence: commit 6ce88ca51d05, main fix timestamp 2026-06-28T10:47:39-07:00.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 23, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: irc P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IRC plugin creates ghost nicks with underscore suffix on nick collision recovery

1 participant