NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

[E2E] Add Discord coverage and provider-isolation checks to token-rotation E2E

Open hunglp6d opened this issue 7 months ago • 0 comments

Problem Statement

Current state

The token-rotation E2E test (test/e2e/test-token-rotation.sh, added under #1903) is exercising Telegram:

  • Phase 0 install seeds only TELEGRAM_BOT_TOKEN.
  • Phase 1 verifies only the telegram-bridge provider and the Telegram credential hash.
  • Phase 2 rotates TELEGRAM_BOT_TOKEN_A → TELEGRAM_BOT_TOKEN_B and asserts the sandbox is rebuilt.
  • Phase 3 re-onboards with the same token and asserts reusing it.

NemoClaw supports Discord through the same rotation pipeline:

  • messagingTokenDefs (src/lib/onboard.ts:3241) declares discord-bridge alongside telegram-bridge.
  • upsertMessagingProviders registers a Discord provider when DISCORD_BOT_TOKEN is set.
  • detectMessagingCredentialRotation (src/lib/onboard.ts:899) compares Discord's stored hash on every re-onboard.
  • The rotation log message at src/lib/onboard.ts:3343 lists discord-bridge the same way it lists telegram-bridge.

But none of that Discord behavior is exercised by any E2E test today. The Telegram and Discord paths are symmetric in code, but coverage is asymmetric.

Why also add provider-isolation checks

What the rotation log line looks like

When we rotate only the Telegram token (A → B) and re-run nemoclaw onboard, the system prints a log line like this:

Messaging credential(s) rotated: e2e-token-rotation-telegram-bridge

It mentions telegram-bridge only. There is no discord-bridge in there — which is correct, because the Discord token didn't change.

Phase 2 today only checks half of that

Check Test does it? What slips through if missing
Positive — log contains telegram-bridge ✅ yes Bug that breaks Telegram rotation entirely
Negative — log does NOT contain discord-bridge ❌ no Bug that flags Discord as also rotated when it didn't change

That missing Negative check is what we call the provider-isolation check.

Why we need the Negative check

Suppose someone introduces a bug into detectMessagingCredentialRotation later — say, an accidental line that makes the function think both Telegram AND Discord rotated when only Telegram changed. The log would then print:

Messaging credential(s) rotated: e2e-token-rotation-telegram-bridge, e2e-token-rotation-discord-bridge

The current test would still pass, because telegram-bridge is still in the log. The bug slips by silently.

Real user impact: the sandbox would rebuild every time the user rotates any token (each rebuild takes ~10 min) — even when the other token never changed. Users would sit through pointless rebuilds with no idea why.

Proposed Design

Approach

Extend the existing test/e2e/test-token-rotation.sh to onboard both Telegram and Discord into the same sandbox, then rotate each provider in isolation. The new phases mirror the Telegram pattern that's already there — same shape, just doubled.

Phase layout

The test goes from 4 phases to 6. Phases 0–3 keep their meaning with small additions for Discord. Phases 4–5 are new and mirror Phases 2–3 for Discord:

Phase Status Action Key new assertions
0 modified Install with both TELEGRAM_BOT_TOKEN_A and DISCORD_BOT_TOKEN_A install.sh now seeds both providers
1 extended Verify install state Add: ${SANDBOX_NAME}-discord-bridge provider exists; DISCORD_BOT_TOKEN key present in providerCredentialHashes
2 extended Rotate Telegram only (T=B, keep D=A) Add the Negative check: log does NOT contain discord-bridge
3 unchanged Re-onboard with same tokens (existing: reusing it printed)
4 new Rotate Discord only (T=B, D=B) Log contains discord-bridge AND does NOT contain telegram-bridge
5 new Re-onboard with same tokens reusing it printed

Other changes

  • Add Discord prereq guards (DISCORD_BOT_TOKEN_A/_B set, A ≠ B) mirroring the existing Telegram ones; SKIP cleanly if either is missing.
  • Wire DISCORD_BOT_TOKEN_A / DISCORD_BOT_TOKEN_B into the token-rotation-e2e job in .github/workflows/nightly-e2e.yaml so the new prereq does not silently skip the test under nightly cron.

Alternatives Considered

No response

Category

enhancement: feature

Checklist

  • [x] I searched existing issues and this is not a duplicate
  • [x] This is a design proposal, not a "please build this" request

hunglp6d avatar Apr 22 '26 10:04 hunglp6d