Skip to content

perf(test): reuse SMS test modules - #125151

Merged
steipete merged 1 commit into
mainfrom
perf/sms-test-module-reuse
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/sms-test-module-reuse

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The 33 SMS test cases rebuilt the broad SMS SDK module graph for every case, making this focused suite slower and substantially more memory-hungry than the behavior under test required.

Why This Change Was Made

Hoist partial-real mocks and static owner-module imports so the suite reuses the expensive module graph. The partial-real boundaries preserve the real Twilio constants and status formatting, while each test still owns and resets its mocks, environment, and timers.

User Impact

There is no production or user-visible behavior change. Maintainers get faster, lower-memory SMS test feedback with the same assertions and isolation. This is test-only, so no changelog entry is needed.

Evidence

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: sms Channel integration: sms size: S maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete steipete self-assigned this Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 07:40
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 3:47 AM ET / 07:47 UTC.

ClawSweeper review

What this changes

The PR replaces per-test SMS module resets and dynamic imports with shared partial-real Vitest mocks and static owner-module imports, reducing test-suite setup cost.

Merge readiness

✅ Ready for maintainer review

No blocking findings. This remains a useful test-only optimization: current main still rebuilds the SMS module graph per case, while the PR preserves the mocked transport and delivery boundaries with the repository’s established partial-real mock pattern.

Priority: P3
Reviewed head: cfe4af194a81f50bc68c6fd864a1f1bc5e26222c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, behavior-preserving test refactor with strong reported suite evidence and no identified correctness defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only PR includes benchmark, fault-injection, focused-suite, repeat-run, and full-SMS-suite evidence in its body.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-only PR includes benchmark, fault-injection, focused-suite, repeat-run, and full-SMS-suite evidence in its body.
Evidence reviewed 6 items PR-head test setup: The PR head hoists partial-real mocks for Twilio, media, delivery observations, and status before statically importing the SMS channel; each test still resets the mutable mock state in beforeEach.
Owner-boundary coverage: The channel owner reads delivery records then probes account status, while the send owner calls Twilio and records initial delivery state; the revised tests continue to replace exactly those boundaries.
Invariant-sharing sibling: The SMS inbound suite already uses a hoisted partial-real Twilio mock with importOriginal and a static import, matching the mock shape adopted here.
Findings None None.
Security None None.

How this fits together

The bundled SMS plugin routes outgoing text and MMS through Twilio, records initial delivery observations, and exposes account status. The changed tests isolate those transport, media, status, and runtime boundaries while exercising the channel and send owners.

flowchart LR
  A[SMS test cases] --> B[Shared Vitest mocks]
  B --> C[SMS channel and send owners]
  C --> D[Twilio transport]
  C --> E[Delivery and status boundaries]
  D --> F[Behavior assertions]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests -12. Total -12 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 51 63 -12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 51 63 -12

Review metrics

Metric Value Why it matters
Production vs test LOC production +0/-0; tests +51/-63 (net -12) The refactor reduces repeated test setup without expanding the shipped SMS plugin.

Technical review

Best possible solution:

Retain the shared mock setup and merge once the in-progress exact-head checks complete, preserving the existing per-case mock, environment, and timer resets.

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

Not applicable: the PR optimizes test execution rather than fixing a reported user-facing defect; its body supplies focused, repeat-run, and suite-level validation results.

Is this the best way to solve the issue?

Yes. Reusing the loaded owner modules while resetting mutable mocks, timers, and environment per test removes repeated setup without changing the tested production boundaries.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3b8f9fb5a2bb.

Labels

Label changes:

  • add P3: This is a bounded test-performance and memory optimization with no production behavior 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 maintainer-authored test-only PR includes benchmark, fault-injection, focused-suite, repeat-run, and full-SMS-suite evidence in its body.

Label justifications:

  • P3: This is a bounded test-performance and memory optimization with no production behavior 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 maintainer-authored test-only PR includes benchmark, fault-injection, focused-suite, repeat-run, and full-SMS-suite evidence in its body.

Evidence

What I checked:

  • PR-head test setup: The PR head hoists partial-real mocks for Twilio, media, delivery observations, and status before statically importing the SMS channel; each test still resets the mutable mock state in beforeEach. (extensions/sms/src/channel.test.ts:40, cfe4af194a81)
  • Owner-boundary coverage: The channel owner reads delivery records then probes account status, while the send owner calls Twilio and records initial delivery state; the revised tests continue to replace exactly those boundaries. (extensions/sms/src/channel.ts:487, 3b8f9fb5a2bb)
  • Invariant-sharing sibling: The SMS inbound suite already uses a hoisted partial-real Twilio mock with importOriginal and a static import, matching the mock shape adopted here. (extensions/sms/src/inbound.test.ts:16, 3b8f9fb5a2bb)
  • Current-main comparison: Current main still contains per-case resetModules, doMock, and dynamic imports in both changed tests, so the optimization is not already implemented or superseded. (extensions/sms/src/channel.test.ts:48, 3b8f9fb5a2bb)
  • Test-history provenance: The prior per-test reset/mock lifecycle dates to the commit that introduced these SMS tests; the proposed change is a focused replacement of that setup rather than a production behavior change. (extensions/sms/src/channel.test.ts:48, d6be4f355203)
  • Reported execution evidence: The PR body reports focused 33/33, repeated 99/99, and full SMS 341/341 passes plus fault injection and reduced RSS; no assertions were removed. (cfe4af194a81)

Likely related people:

  • steipete: Git history and blame attribute the current SMS test lifecycle to the commit that introduced these files; the same contributor authored this focused refactor. (role: introduced the current test setup and recent area contributor; confidence: high; commits: d6be4f355203, cfe4af194a81; files: extensions/sms/src/channel.test.ts, extensions/sms/src/send.test.ts)
  • Vincent Koc: Recent SMS delivery-status and MMS feature commits own behavior exercised by the changed mocks. (role: adjacent SMS delivery feature contributor; confidence: medium; commits: 0758316883f5, 554a6f3bbf6d; files: extensions/sms/src/channel.ts, extensions/sms/src/send.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the in-progress exact-head checks complete before merge.

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 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head cfe4af194a81f50bc68c6fd864a1f1bc5e26222c:

No proof gaps. No changelog: test-only change.

@steipete
steipete merged commit e446679 into main Aug 17, 2026
168 checks passed
@steipete
steipete deleted the perf/sms-test-module-reuse branch August 17, 2026 07:56
@steipete

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: sms Channel integration: sms 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: S 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