Skip to content

improve(test): reduce Tlon monitor test runtime - #124036

Merged
steipete merged 1 commit into
mainfrom
steipete/test-suite-performance-pass-13-aug15
Aug 15, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/test-suite-performance-pass-13-aug15

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Tlon monitor tests paid to load a broad core graph even though the monitor already receives an injected Tlon runtime. Partial importOriginal mocks for Plugin SDK runtime/media modules and the real core channel-context helper dominated import time, CPU, and memory for nine focused tests.

Why This Change Was Made

The test now mocks the exact Plugin SDK seams it consumes: human-delay resolution, channel-inbound envelope/formatter construction, abortable sleep, and media constants/functions. The real Tlon monitor, Urbit client and loopback SSE lifecycle, Tlon media composition, ingress, and dispatch wiring remain intact; this adds no production or test-only seam.

The first lead review found two composition gaps. The revision now tracks a distinct inner envelope builder and asserts its exact factory configuration plus the Tlon invocation (channel, owner sender label, timestamp, and byte-exact media prompt). It also makes buildContext return a distinct sentinel and requires dispatch to receive that object by identity, while separately asserting the raw context input, attachment facts, unavailable notice, and reply media.

Generic channel-envelope and media-helper semantics remain owned by the core envelope/media tests. This file continues to prove Tlon's composition of those seams.

User Impact

There is no production behavior change. Maintainers get the same nine Tlon monitor tests with substantially lower import cost, CPU demand, and peak RSS.

Evidence

  • Controlled same-Testbox A/B on the exact candidate:
    • wall: 7.355s -> 5.130s (-30.3%)
    • harness: 7.075s -> 4.855s (-31.4%)
    • Vitest: 4.380s -> 2.185s (-50.1%)
    • import: 3.700s -> 1.655s (-55.3%)
    • test body: 0.3800s -> 0.2615s (-31.2%)
    • CPU user: 7.670s -> 5.220s
    • CPU sys: 0.880s -> 0.525s
    • max RSS: 1,114,342 -> 757,214 KiB (-32.0%)
  • Mutation proof:
    • changing the unavailable notice failed both target cases;
    • changing the production envelope channel to a wrong value failed both cases at the tracked inner-envelope assertion;
    • both mutations were reverted.
  • Owner/sibling proof: node scripts/run-vitest.mjs extensions/tlon/src/monitor/index.test.ts extensions/tlon/src/monitor/media.test.ts extensions/tlon/src/monitor/ingress.test.ts extensions/tlon/src/monitor/tracking.test.ts --maxWorkers=1 — 4 files / 26 tests passed.
  • Exact path-scoped changed gate passed on Blacksmith Testbox tbx_01m01y1xf3244wtd0y1k0e5zgr: https://github.com/openclaw/openclaw/actions/runs/31866871032. The one-shot lease was stopped after success.
  • Revised worker proof also passed on Testbox tbx_01m01xaatfmqg32qhyexxqw56d: https://github.com/openclaw/openclaw/actions/runs/31866338265. That lease was stopped.
  • git diff --check origin/main...HEAD passed.
  • Targeted oxfmt --check passed.
  • Fresh committed-branch autoreview against origin/main reported no accepted or actionable findings.
  • LOC: tests +92/-29 (net +63); production +0/-0; still 9 tests; no new seam.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 15, 2026 05:31
@openclaw-barnacle openclaw-barnacle Bot added channel: tlon Channel integration: tlon size: S maintainer Maintainer-authored PR labels Aug 15, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for exact head acd0d441b09cbfbe354152b116e48b09a190a9f5:

Exact proof

Mutation and owner-boundary proof

  • Changing the unavailable-media notice failed both target cases.
  • Changing the production envelope channel to the wrong value failed both cases at the tracked inner-envelope assertion.
  • Both mutations were reverted.
  • The real Tlon monitor, Urbit client and loopback SSE lifecycle, Tlon media composition, ingress, and dispatch remain exercised.
  • Exact mocks cover only the SDK seams consumed behind the injected runtime. The tracked inner builder asserts exact factory config and Tlon invocation; a distinct context sentinel proves dispatch receives the produced context by identity. Raw context input, attachment facts, unavailable notice, and reply media are asserted separately.
  • Generic envelope and media-helper semantics remain covered in the core owner tests; Tlon composition remains here.

Same-Testbox A/B

Metric Before After Gain
wall 7.355s 5.130s -30.3%
harness 7.075s 4.855s -31.4%
Vitest 4.380s 2.185s -50.1%
import 3.700s 1.655s -55.3%
test body 0.3800s 0.2615s -31.2%
CPU user 7.670s 5.220s lower
CPU sys 0.880s 0.525s lower
max RSS 1,114,342 KiB 757,214 KiB -32.0%

The controlled A/B was run on Testbox tbx_01m01xaatfmqg32qhyexxqw56d: https://github.com/openclaw/openclaw/actions/runs/31866338265. That lease was stopped.

LOC split: tests +92/-29 (net +63); production +0/-0; same 9 tests; no new seam. Gap: no live Tlon-channel proof was run because this is a test-import/performance-only change with no production diff; the real production composition is exercised by the focused owner tests above.

@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 15, 2026
@steipete
steipete merged commit 49e783d into main Aug 15, 2026
165 of 168 checks passed
@steipete
steipete deleted the steipete/test-suite-performance-pass-13-aug15 branch August 15, 2026 05:37
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 1:36 AM ET / 05:36 UTC.

ClawSweeper review

What this changes

The PR replaces broad SDK imports in the Tlon monitor test with focused mocks to reduce test startup time while retaining Tlon-specific composition assertions.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. This maintainer-owned, test-only optimization is still needed on current main; the narrowed mocks preserve the Tlon composition boundary and no actionable patch defect was found.

Priority: P3
Reviewed head: acd0d441b09cbfbe354152b116e48b09a190a9f5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-only patch with retained composition assertions and strong submitted targeted validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only PR is outside the external-contributor proof gate; its recorded Testbox A/B and targeted-suite evidence is still useful supplemental validation.
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 is outside the external-contributor proof gate; its recorded Testbox A/B and targeted-suite evidence is still useful supplemental validation.
Evidence reviewed 7 items Changed test boundary: The branch mocks only the Plugin SDK bindings imported by the monitor/media path and gives the context builder a distinct sentinel, allowing the test to verify construction and dispatch identity without importing the broad implementations.
Retained Tlon composition proof: The revised media cases assert the exact envelope-builder configuration and invocation, unavailable-media inputs, raw context facts, dispatch identity, and reply media.
Production owner boundary: The current monitor builds the media prompt, creates the shared inbound envelope, formats the unavailable-media notice, builds context, and dispatches that context; the PR changes none of this runtime code.
Findings None None.
Security None None.

How this fits together

The Tlon monitor receives Urbit SSE chat events, prepares media and an inbound envelope, then builds an OpenClaw agent context and dispatches it. This test exercises that pipeline while replacing expensive shared SDK implementation loading with tracked seams.

flowchart LR
  A[Tlon chat event] --> B[Tlon monitor]
  B --> C[Media preparation]
  C --> D[Inbound envelope]
  D --> E[Agent context and dispatch]
  F[Focused SDK mocks] --> B
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: this protected maintainer PR has no concrete defect to fix and should follow normal exact-head CI and owner review.
Agent review details

Security

None.

PR surface

Tests +63. Total +63 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 92 29 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 92 29 +63

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0 (net 0); tests +92/-29 (net +63) All growth is focused test instrumentation and assertions; the runtime and public/plugin contracts are unchanged.

Technical review

Best possible solution:

Retain the focused Tlon composition assertions and land the test-only import optimization after the remaining exact-head checks are green.

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

Not applicable: this is test-maintenance work rather than a report of broken user behavior; the PR supplies a focused before/after Testbox measurement.

Is this the best way to solve the issue?

Yes. Mocking only the monitor's imported SDK seams preserves Tlon’s real composition checks while core envelope and media suites retain ownership of shared-helper semantics.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded test-runtime 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 is outside the external-contributor proof gate; its recorded Testbox A/B and targeted-suite evidence is still useful supplemental validation.

Label justifications:

  • P3: This is a bounded test-runtime 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 is outside the external-contributor proof gate; its recorded Testbox A/B and targeted-suite evidence is still useful supplemental validation.

Evidence

What I checked:

Likely related people:

  • steipete: Current Tlon monitor envelope/media composition is attributed to this recent commit, and the proposed test optimization targets that same owner boundary. (role: recent Tlon monitor contributor; confidence: high; commits: 8e7962277705, acd0d441b09c; files: extensions/tlon/src/monitor/index.ts, extensions/tlon/src/monitor/media.ts, extensions/tlon/src/monitor/index.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.

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

Labels

channel: tlon Channel integration: tlon 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