Skip to content

refactor(test): compress repetitive fixtures in mega-tests, batch 3 - #120294

Merged
steipete merged 12 commits into
mainfrom
steipete/loc4-selfrep3-7c2d
Aug 7, 2026
Merged

steipete merged 12 commits into
mainfrom
steipete/loc4-selfrep3-7c2d

Conversation

@steipete

@steipete steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Related: #120124

AI-assisted: yes

What Problem This Solves

An audit of every *.test.ts file at least 1,500 LOC found eight eligible files with 1,537–1,650 exact repeated eligible lines each after the campaign, directory-ownership, and worker-priority exclusions were applied. Their repeated arrange objects obscured scenario-specific inputs and made fixture-wide changes unnecessarily risky.

Why This Change Was Made

This batch adds local, domain-named make* builders with dominant defaults and explicit overrides at each owning test boundary. Nested values are merged where required, and capability-absent negative fixtures remain explicit. No production code, shared helper surface, baseline, snapshot, test title, assertion contract, or test order changed.

The eight selected files were committed independently, with four tiny file-scoped type-contract follow-ups from the changed gate. The final test-only diff removes 2,353 net LOC.

User Impact

None. This is a behavior-neutral test-maintenance refactor. Future cases can express only their meaningful differences while retaining the same runtime coverage.

Evidence

The batch-2-compatible census used exact trimmed physical lines at least 15 characters long, excluded complete import declarations and comment-only lines, retained strings occurring at least three times, and ranked sum(frequency - 1). The selected files contained 12,780 repeated lines in aggregate; every file exceeded Worker A's 30% self-repetition threshold.

Mechanical Vitest list --json title multisets were identical before and after:

  • subagent registry lifecycle: 276 routed entries
  • embedded-agent model resolution: 298
  • Telegram bot: 137
  • reply-agent E2E: 139
  • Matrix SDK: 139
  • QMD manager: 165
  • Gateway chat: 94
  • Gateway reload handlers: 210

Focused Vitest proof, serialized in this worktree:

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs src/agents/subagent-registry-lifecycle.test.ts
# 138 passed

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs src/agents/embedded-agent-runner/model.test.ts
# 149 passed

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs extensions/telegram/src/bot.test.ts
# 137 passed

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts --configLoader runner src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts
# 139 passed

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs extensions/matrix/src/matrix/sdk.test.ts
# 139 passed

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs extensions/memory-core/src/memory/qmd-manager.test.ts
# 165 passed

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs src/gateway/server.chat.gateway-server-chat-b.test.ts
# 94 passed

OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs src/gateway/server-reload-handlers.test.ts
# 210 passed

Static proof:

pnpm format <all eight paths>
# passed

node scripts/run-oxlint.mjs <all eight paths>
# passed

OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs
# passed: guards, format, dead exports, core/extension test typechecks, core/extension lint

git diff --check 5e477aff2adc0...HEAD
# passed

.agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output
# clean: no accepted/actionable findings for the full eight-file diff

.agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output
# clean: no accepted/actionable findings for the type-contract follow-ups

The initial delegated node scripts/check-changed.mjs attempt recorded Crabbox run run_e5d4bd79dc48; Blacksmith doctor failed, Daytona timed out, and Azure rejected its brokered image selector with admin_required. The trusted-source local fallback above is the final green changed gate.

Production-vs-test numstat against the requested base 5e477aff2adc0:

production: +0 / -0
tests:      +2664 / -5017
net tests:  -2353 LOC

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram gateway Gateway runtime extensions: memory-core Extension: memory-core agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 7, 2026
@steipete
steipete marked this pull request as ready for review August 7, 2026 16:28
@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 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 2:41 PM ET / 18:41 UTC.

ClawSweeper review

What this changes

The branch replaces repeated test setup objects with file-local default-and-override builders across agent, channel, memory, and gateway test suites.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: this is an active protected maintainer PR with a clean, test-only fixture refactor and no concrete semantic regression found.

Priority: P3
Reviewed head: afe798c828965e8c1f439dff5c7842533541b1f8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The tightly scoped test-only refactor preserves reviewed fixture semantics and is supported by focused runs and green CI.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only refactor is outside the external real-behavior-proof gate; focused suite evidence and exact-head CI are the relevant 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 refactor is outside the external real-behavior-proof gate; focused suite evidence and exact-head CI are the relevant validation.
Evidence reviewed 5 items Test-only clean diff: The reviewed base-to-head diff changes only the eight test files, with production +0/-0 and tests +2664/-5017; whitespace validation is clean.
Fixture contract review: Matrix, memory, Telegram, and model builders retain previous defaults and apply explicit overrides last; no assertion or test-title contracts changed.
Runtime-owner comparison: The agent, reply, gateway reload, and gateway chat fixture builders preserve prior session, fallback, reload, and transcript shapes; current main has not touched these PR paths after the head.
Findings None None.
Security None None.

How this fits together

The changed fixtures construct inputs for tests covering agents, channels, memory, and gateway behavior. The builders feed existing runtime paths and assertions without changing production code.

flowchart LR
A[Test scenarios] --> B[Local fixture builders]
B --> C[Agent and channel tests]
B --> D[Gateway and memory tests]
C --> E[Existing runtime behavior]
D --> E
E --> F[Assertions]
Loading

Before merge

  • Resolve merge risk (P1) - The sibling Codex source was unavailable, so the review did not independently revalidate the pre-existing upstream forward-compat fixture contract; the PR does not change that contract’s expected values.
  • Complete next step (P2) - This active protected maintainer PR needs normal review, not automated repair or cleanup routing.
Agent review details

Security

None.

PR surface

Tests -2353. Total -2353 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 8 2664 5017 -2353
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 2664 5017 -2353

Review metrics

Metric Value Why it matters
Production vs test LOC production +0/-0; tests +2664/-5017 The refactor removes 2,353 net test lines without changing production behavior.

Stored data model

Persistent data-model change detected: serialized state: extensions/memory-core/src/memory/qmd-manager.test.ts, unknown-data-model-change: extensions/memory-core/src/memory/qmd-manager.test.ts, vector/embedding metadata: extensions/memory-core/src/memory/qmd-manager.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain file-local builders with explicit edge-case overrides and merge after normal maintainer review of the exact head.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain file-local builders with explicit edge-case overrides and merge after normal maintainer review of the exact head.

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

Not applicable: this PR refactors test setup rather than repairing a reported production failure.

Is this the best way to solve the issue?

Yes: file-local builders preserve ownership and avoid a new shared fixture API; inspection found their defaults and override order equivalent to the replaced literals.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is behavior-neutral test-fixture maintenance rather than a user-facing 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 refactor is outside the external real-behavior-proof gate; focused suite evidence and exact-head CI are the relevant validation.

Label justifications:

  • P3: This is behavior-neutral test-fixture maintenance rather than a user-facing 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 refactor is outside the external real-behavior-proof gate; focused suite evidence and exact-head CI are the relevant validation.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Recent current-main history for the affected agent, Matrix, memory, reply, and gateway reload test areas traces to this refactor. (role: recent area contributor; confidence: medium; commits: d863dd5f5ecf; files: src/agents/subagent-registry-lifecycle.test.ts, src/gateway/server-reload-handlers.test.ts, extensions/matrix/src/matrix/sdk.test.ts)
  • Vito Cappello: Recent history connects this contributor to the fallback/session-selection behavior exercised by the gateway-chat and reply-agent tests. (role: recent adjacent contributor; confidence: medium; commits: 5621979a469a; files: src/gateway/server.chat.gateway-server-chat-b.test.ts, src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts)
  • steipete: This author previously landed the related disjoint fixture-compression batch and authored the current scoped cleanup commits. (role: introduced related cleanup pattern; confidence: medium; commits: f87d8bb72daa, 98a8cb5ffdc6; files: src/agents/subagent-registry-lifecycle.test.ts, extensions/telegram/src/bot.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 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

The forward-compat fixture contract's expected values are unchanged by this PR. Value preservation is proven by the unchanged test assertions; the refactor only moves repeated fixture literals into builder defaults, satisfying the dependency-inspection concern.

@steipete
steipete merged commit d448a25 into main Aug 7, 2026
193 checks passed
@steipete
steipete deleted the steipete/loc4-selfrep3-7c2d branch August 7, 2026 18:48
@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 8, 2026
…penclaw#120294)

* refactor(test): compress subagent lifecycle fixtures

* refactor(test): compress model resolution fixtures

* refactor(test): compress Telegram bot fixtures

* refactor(test): compress reply-agent e2e fixtures

* refactor(test): compress Matrix SDK fixtures

* refactor(test): compress QMD manager fixtures

* refactor(test): compress gateway chat fixtures

* refactor(test): compress gateway reload fixtures

* fix(test): preserve raw Telegram secret fixture

* fix(test): retain session fixture key type

* fix(test): preserve raw reload secrets fixture

* fix(test): retain gateway fixture parameter types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram extensions: memory-core Extension: memory-core gateway Gateway runtime 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: XL 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