Skip to content

fix(irc): prevent ghost nick collisions on rejoin after network delay - #96108

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
wendy-chsy:fix/irc-ghost-nick
Jun 28, 2026
Merged

vincentkoc merged 2 commits into
openclaw:mainfrom
wendy-chsy:fix/irc-ghost-nick

Conversation

@wendy-chsy

@wendy-chsy wendy-chsy commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • When an IRC connection experiences a network delay and rejoins, the nick collision fallback always appends the same suffix _, causing a ghost nick collision with the still-connected session.
  • This fix adds a monotonically increasing sequence counter to the fallback nick suffix, so each reconnection attempt generates a unique nick (e.g., bot_, bot_2, bot_3).
  • Added 5 regression tests covering: sequential uniqueness, special char sanitization, empty/fallback nick, and long nick truncation.

Linked issue

Closes #96064

Real behavior proof

  • Behavior or issue addressed: Repeated IRC reconnections after network delay fail because every fallback nick is identical (bot_). The module-level counter produces bot_, bot_2, bot_3, ... across reconnect calls.
  • Real environment tested: ngircd 26 running locally on port 6667. Two clients connected — the first holds nick testbot, the second attempts testbot and receives ERR_NICKNAMEINUSE (433). buildFallbackNick("testbot") then produces unique sequential fallback nicks.
  • Exact steps or command run after this patch:
    1. Started ngircd 26 locally: ngircd -n -f /tmp/ngircd.conf
    2. Real IRC proof: node /tmp/irc-proof.mjs — full end-to-end verification
    3. Unit tests: pnpm test extensions/irc/src/client.test.ts — 9 passed
    4. Full IRC suite: pnpm test extensions/irc/ — 15/16 files passed (4 pre-existing locale failures in setup.test.ts unrelated to this change)
    5. Build: pnpm build — clean
  • Evidence after fix (real ngircd server):
    Phase 1 — Establish ghost session holding nick 'testbot'
      ✅ Ghost connected with nick "testbot"
    
    Phase 2 — Second client tries nick 'testbot' (simulates rejoin after network delay)
      ✅ Got ERR_NICKNAMEINUSE (433): ":irc.test.local 433 * testbot :Nickname already in use"
      ✅ Ghost nick collision reproduced on real IRC server
    
    Phase 3 — Fallback nick counter prevents duplicate nicks
      call 1: buildFallbackNick("testbot") → "testbot_"
      call 2: buildFallbackNick("testbot") → "testbot_2"
      call 3: buildFallbackNick("testbot") → "testbot_3"
      call 4: buildFallbackNick("testbot") → "testbot_4"
      call 5: buildFallbackNick("testbot") → "testbot_5"
      ✅ All 5 nicks unique: testbot_, testbot_2, testbot_3, testbot_4, testbot_5
    
    Phase 4 — Connect to IRC server with each fallback nick
      ✅ "testbot_" → connected successfully
      ✅ "testbot_2" → connected successfully
      ✅ "testbot_3" → connected successfully
    
    Phase 5 — Edge case coverage
      ✅ sanitize whitespace + special chars: "my bot!" → "mybot_"
      ✅ all-special chars → openclaw fallback: "!!!" → "openclaw_2"
      ✅ empty string → openclaw fallback: "" → "openclaw_3"
      ✅ truncate 50-char nick to max 30 → "aaaa..._4" (≤30 chars)
    
  • Observed result after fix: buildFallbackNick("bot") returns bot_, bot_2, bot_3, ... on successive calls. All nicks are unique and within the 30-char IRC limit. Each nick successfully connects to a real ngircd server. The counter prevents the ghost nick collision loop that previously caused reconnection failures.
  • What was not tested: Production IRC network with actual NickServ GHOST commands (requires registered nicks and NickServ password).

Tests and validation

pnpm build                                            → clean
pnpm test extensions/irc/src/client.test.ts            → 9 passed (4 existing + 5 new)
pnpm test extensions/irc/                              → 15/16 passed, 65/69 tests
  (4 pre-existing failures in setup.test.ts due to locale, unrelated to this PR)
node /tmp/irc-proof.mjs (real ngircd server)           → ALL CHECKS PASSED

Risk checklist

  • User-visible behavior change: No (fixes a connection reliability bug)
  • Config/default surface change: No
  • Security/audit impact: No
  • New dependency: No
  • Migration needed: No

🤖 Generated with Claude Code

@clawsweeper

clawsweeper Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 28, 2026, 5:06 AM ET / 09:06 UTC.

Summary
The PR changes IRC fallback nick generation to use a module-scoped monotonically increasing suffix and adds five regression tests for fallback nick behavior.

PR surface: Source +3, Tests +35. Total +38 across 2 files.

Reproducibility: yes. for source-level reproduction: current main and v2026.6.10 still use a fixed underscore fallback, and fresh connectIrcClient calls recreate fallback state. The contributor also supplied copied ngircd live output for the after-fix path, but I did not rerun ngircd in this read-only review.

Review metrics: 1 noteworthy metric.

  • Fallback helper coverage: 5 added. The new tests cover sequencing and edge cases, so maintainer attention can focus on choosing the correct IRC fix path.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #96064
Summary: This PR is a candidate fix for the canonical IRC fallback ghost-nick issue; another open PR targets the same issue but remains weaker because its attempted counter is connection-local and proof is insufficient.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Resolve or close the sibling PR once maintainers choose this landing path.

Risk before merge

  • [P1] A sibling open PR also closes the canonical IRC ghost-nick issue, so maintainers should select one landing path and close or supersede the other before both changes drift.

Maintainer options:

  1. Decide the mitigation before merge
    Land one reviewed IRC client fix that makes fallback nicks unique across fresh connection attempts; this PR is currently the stronger candidate because its sequence crosses that boundary and includes live ngircd proof plus regression tests.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed; maintainers need to choose and land one of the two open IRC fix candidates.

Security
Cleared: The diff only changes in-memory IRC fallback suffix generation and adjacent tests; it adds no dependencies, scripts, permissions, secrets, or package metadata.

Review details

Best possible solution:

Land one reviewed IRC client fix that makes fallback nicks unique across fresh connection attempts; this PR is currently the stronger candidate because its sequence crosses that boundary and includes live ngircd proof plus regression tests.

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

Yes for source-level reproduction: current main and v2026.6.10 still use a fixed underscore fallback, and fresh connectIrcClient calls recreate fallback state. The contributor also supplied copied ngircd live output for the after-fix path, but I did not rerun ngircd in this read-only review.

Is this the best way to solve the issue?

Yes. The module-scoped sequence is the narrow maintainable repair for this reported fallback bug because it crosses fresh connectIrcClient calls, while the sibling connection-local counter would not.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7ba9212665a7.

Label changes

Label justifications:

  • P2: This is a focused IRC channel reliability bugfix with limited blast radius and a linked canonical issue.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes sufficient after-fix live output from ngircd showing the collision, generated unique fallback nicks, and successful connections with those nicks.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes sufficient after-fix live output from ngircd showing the collision, generated unique fallback nicks, and successful connections with those nicks.
Evidence reviewed

PR surface:

Source +3, Tests +35. Total +38 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 2 +3
Tests 1 36 1 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 41 3 +38

What I checked:

  • Root policy read: Root AGENTS.md was read fully; its deep review, plugin-boundary, fallback-behavior, and real behavior proof guidance applied to this PR review. (AGENTS.md:1, 7ba9212665a7)
  • Scoped extension policy read: extensions/AGENTS.md was read fully; the patch stays inside the IRC plugin boundary and does not add core imports, dependency changes, or public SDK surface. (extensions/AGENTS.md:1, 7ba9212665a7)
  • Current main fallback behavior: Current main still sanitizes the desired IRC nick and appends a constant underscore suffix, so repeated fallback calls can reuse the same nick. (extensions/irc/src/client.ts:69, 7ba9212665a7)
  • Fresh connection boundary: monitor, transient send, and probe paths all call connectIrcClient, while the gateway wraps the monitor with runStoppablePassiveMonitor; a fallback sequence that lives only inside connectIrcClient would not cross fresh calls, but this PR's module-level sequence does. (extensions/irc/src/gateway.ts:43, 7ba9212665a7)
  • Lifecycle helper contract: runStoppablePassiveMonitor delegates to runPassiveAccountLifecycle, which keeps passive monitor tasks pending until abort and then stops the handle; the broader monitor-lifecycle fix proposed in older closed PRs is not needed for this fallback-suffix change. (src/plugin-sdk/channel-lifecycle.core.ts:123, 7ba9212665a7)
  • Latest release still has the bug: The latest release tag v2026.6.10 points at aa69b12 and still contains the fixed underscore fallback in extensions/irc/src/client.ts, so this PR is not obsolete on shipped code. (extensions/irc/src/client.ts:69, aa69b12d0086)

Likely related people:

  • vignesh07: Authored the merged first-class IRC channel work that introduced the IRC client and original fallback nick behavior. (role: feature introducer; confidence: high; commits: fa906b26add7, c323e3fb50e5; files: extensions/irc/src/client.ts, extensions/irc/src/monitor.ts, extensions/irc/src/send.ts)
  • Takhoffman: Merged the first-class IRC channel PR and later touched adjacent IRC runtime behavior in the same plugin area. (role: feature merger and adjacent contributor; confidence: medium; commits: fa906b26add7; files: extensions/irc/src/client.ts, extensions/irc/src/monitor.ts, extensions/irc/src/send.ts)
  • Peter Steinberger: Recent history shows connector/runtime refactors and a small IRC client maintenance fix in the central files around the current runtime path. (role: recent area contributor; confidence: medium; commits: 544ffbcf7b25, b50640c6001f; files: extensions/irc/src/client.ts, extensions/irc/src/monitor.ts, extensions/irc/src/send.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@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
@wendy-chsy

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@wendy-chsy

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Jun 28, 2026
@vincentkoc
vincentkoc merged commit 6ce88ca into openclaw:main Jun 28, 2026
120 of 130 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 29, 2026
…openclaw#96108)

* fix(irc): prevent ghost nick collisions on rejoin after network delay

* test(irc): add regression tests for fallback nick uniqueness

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: wendy-chsy <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
…openclaw#96108)

* fix(irc): prevent ghost nick collisions on rejoin after network delay

* test(irc): add regression tests for fallback nick uniqueness

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: wendy-chsy <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
@wendy-chsy
wendy-chsy deleted the fix/irc-ghost-nick branch July 2, 2026 01:49
Rorqualx pushed a commit to Rorqualx/cortex that referenced this pull request Jul 2, 2026
…openclaw#96108)

* fix(irc): prevent ghost nick collisions on rejoin after network delay

* test(irc): add regression tests for fallback nick uniqueness

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: wendy-chsy <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
(cherry picked from commit 6ce88ca)
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

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

2 participants