Skip to content

refactor(discord): deduplicate presence listener tests - #118155

Merged
steipete merged 1 commit into
mainfrom
codex/wave19-discord-presence-cleanup
Aug 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/wave19-discord-presence-cleanup

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Discord presence-listener regression suite repeated the same full listener, clock, cooldown-store, guild, and client setup across 29 cases. That duplication made the suite substantially longer and made scenario-specific differences harder to review.

Why This Change Was Made

Use one constructor-derived listener fixture with explicit per-case overrides, plus a deterministic clock and human client reset before every test. Production code, Discord configuration, event ordering, privacy checks, and assertions are unchanged.

User Impact

No user-visible behavior changes. This reduces the presence-listener test file by 203 net lines while preserving its complete regression contract.

Evidence

  • Diff: one test file, +74/-277; production LOC delta: 0; test LOC delta: -203.
  • Exact static parity: 29/29 test titles and 93/93 assertion sites; async operation counts also unchanged.
  • Focused local: node scripts/run-vitest.mjs extensions/discord/src/monitor/listeners.presence.test.ts (29/29 passed).
  • Blacksmith Testbox tbx_01kz1zdrj67q00t7ssfwz4p2hv: focused presence suite 29/29; full Discord suite 2,489/2,489; changed gate passed formatting, extension test typecheck, lint, dependency, duplicate, boundary, and dead-code checks.
  • Remote run: https://github.com/openclaw/openclaw/actions/runs/30763606786
  • Two independent xhigh reviews inspected the listener lifecycle, cooldown/burst gates, channel-visibility privacy boundary, history, and direct discord-api-types 0.38.52 contracts.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: M maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 3:54 PM ET / 19:54 UTC.

ClawSweeper review

What this changes

The branch replaces repeated Discord presence-listener test construction with a shared fixture, per-case overrides, and resettable test clock/client state while preserving the existing scenarios.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for normal maintainer landing. It is a focused test-only cleanup with no production, configuration, dependency, or security surface change; source inspection found no blocking correctness regression in the shared fixture.

Priority: P3
Reviewed head: 4ee6c139f9a009553e5c93eb3b498cee16f05a4e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable test refactor with preserved scenario coverage and supplied focused/full-suite validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a non-user-visible test-only refactor; the relevant proof is preservation of the regression contract plus the focused and Discord-suite runs reported in the PR body.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a non-user-visible test-only refactor; the relevant proof is preservation of the regression contract plus the focused and Discord-suite runs reported in the PR body.
Evidence reviewed 5 items Focused test-only diff: The branch changes only the presence-listener test file; the new fixture supplies the same constructor defaults and exposes explicit overrides for cases that need alternate guild entries, stores, clocks, baselines, or gates.
Regression-contract parity: The base and branch have identical 29 test titles, and each version contains 93 assertion sites; the shared fixture does not remove a named scenario or assertion family.
Runtime owner boundary: Current main keeps the behavior in DiscordPresenceListener: constructor-owned cooldown, baseline, and emission-gate state feed the presence handler's visibility check and durable cooldown reservation. The PR does not alter this runtime path.
Findings None None.
Security None None.

How this fits together

Discord gateway presence events are processed by the Discord presence listener, which applies snapshot, cooldown, visibility, and burst rules before queueing a system event and requesting a heartbeat. This PR changes only the regression harness that supplies those event inputs and verifies those outputs.

flowchart TD
  A[Presence event fixtures] --> B[Shared test fixture]
  B --> C[Discord presence listener]
  C --> D[Snapshot, cooldown, visibility, and burst decisions]
  D --> E[Queued system event]
  D --> F[Heartbeat assertion]
Loading

Before merge

  • Add real behavior proof - Not applicable: This is a non-user-visible test-only refactor; the relevant proof is preservation of the regression contract plus the focused and Discord-suite runs reported in the PR body.
  • Complete next step (P2) - This is a coherent open implementation PR with no discrete repair for an automated worker; it only needs the normal maintainer landing path.
Agent review details

Security

None.

PR surface

Tests -203. Total -203 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 74 277 -203
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 74 277 -203

Review metrics

None.

Technical review

Best possible solution:

Retain one canonical fixture for the 29 existing regression scenarios and land it after the ordinary current-head checks complete, without changing Discord presence runtime behavior.

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

Not applicable: this PR refactors regression-test setup rather than reporting or changing a user-visible runtime failure. The preserved test-title and assertion counts provide a high-confidence check that the existing behavioral contract remains covered.

Is this the best way to solve the issue?

Yes. A constructor-derived fixture is the narrowest maintainable solution because it centralizes only the repeated listener defaults while each scenario retains explicit overrides for the behavior it exercises.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 254ab826f1e3.

Labels

Label changes:

  • add P3: This is a low-risk internal test-maintenance refactor with no user-visible behavior or public contract change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a non-user-visible test-only refactor; the relevant proof is preservation of the regression contract plus the focused and Discord-suite runs reported in the PR body.

Label justifications:

  • P3: This is a low-risk internal test-maintenance refactor with no user-visible behavior or public contract change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a non-user-visible test-only refactor; the relevant proof is preservation of the regression contract plus the focused and Discord-suite runs reported in the PR body.

Evidence

What I checked:

  • Focused test-only diff: The branch changes only the presence-listener test file; the new fixture supplies the same constructor defaults and exposes explicit overrides for cases that need alternate guild entries, stores, clocks, baselines, or gates. (extensions/discord/src/monitor/listeners.presence.test.ts:84, 4ee6c139f9a0)
  • Regression-contract parity: The base and branch have identical 29 test titles, and each version contains 93 assertion sites; the shared fixture does not remove a named scenario or assertion family. (extensions/discord/src/monitor/listeners.presence.test.ts:119, 4ee6c139f9a0)
  • Runtime owner boundary: Current main keeps the behavior in DiscordPresenceListener: constructor-owned cooldown, baseline, and emission-gate state feed the presence handler's visibility check and durable cooldown reservation. The PR does not alter this runtime path. (extensions/discord/src/monitor/listeners.ts:117, 254ab826f1e3)
  • Feature provenance: Blame attributes the current presence-listener constructor and associated test area to commit 040e0f5, whose author is Shakker; file history shows Peter Steinberger as the most frequent contributor across the runtime and regression-test pair. (extensions/discord/src/monitor/listeners.ts:117, 040e0f5a6eff)
  • Validation supplied with the PR: The PR body reports a focused 29/29 presence suite, a 2,489/2,489 Discord suite in Testbox, and changed-gate checks; the supplied check snapshot also shows the relevant fast, lint, type, dependency, boundary, and security checks succeeding or still running. (4ee6c139f9a0)

Likely related people:

  • Shakker: Current-main blame attributes the Discord presence listener constructor and the adjacent presence-test setup to the commit that established this behavior. (role: feature owner; confidence: high; commits: 040e0f5a6eff; files: extensions/discord/src/monitor/listeners.ts, extensions/discord/src/monitor/listeners.presence.test.ts)
  • steipete: History shortlog shows sustained contributions across the listener and its regression suite, in addition to the focused refactor under review. (role: recent area contributor; confidence: high; commits: 4ee6c139f9a0; files: extensions/discord/src/monitor/listeners.ts, extensions/discord/src/monitor/listeners.presence.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

@steipete
steipete merged commit bc826d6 into main Aug 2, 2026
95 of 103 checks passed
@steipete
steipete deleted the codex/wave19-discord-presence-cleanup branch August 2, 2026 20:07
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant