Skip to content

test: replace assertion chains with typed fixture builders — wave 3 - #124986

Merged
steipete merged 5 commits into
mainfrom
steipete/test-fixtures-wave3
Aug 17, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/test-fixtures-wave3

Conversation

@steipete

@steipete steipete commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The next-highest test-fixture clusters still erased useful type information behind repeated chained assertions. That made mocks and scenario inputs easier to drift while hiding the intended runtime contracts from TypeScript.

Why This Change Was Made

This maintainer-requested wave extends the typed-fixture pattern from #124625 and #124865 across ten coherent clusters. Existing test-support owners now accept narrow typed overrides, existing fixture builders are reused where available, and intentionally malformed or heterogeneous boundary projections remain explicit instead of being hidden behind generic cast helpers.

The test-audit gate found no new or removed coverage, no behavior assertion changes, and no production seam. AI-assisted: yes. The final branch review reported no actionable findings.

User Impact

No user-visible runtime behavior changes. Maintainers get compiler-checked fixture setup and 327 fewer chained assertions while all existing test declarations and assertions remain in place.

Evidence

Cluster Chains before → after Test declarations before → after
extensions/policy/src/doctor/register.sandbox-and-tools.test-utils.ts 41 → 0 45 → 45
src/agents/tools/sessions-access.test.ts 39 → 2 intentional invalid visibility inputs 40 → 40
src/daemon/systemd.test.ts 36 → 0 133 → 133
ui/src/pages/chat/chat-pane-sharing.test.ts 35 → 0 17 → 17
extensions/discord/src/send.creates-thread.test.ts 33 → 0 25 → 25
src/cli/program.force.test.ts 33 → 0 31 → 31
src/commands/doctor-legacy-config.migrations.test.ts 32 → 2 intentional malformed/migration boundary projections 72 → 72
src/gateway/server-methods/chat.directive-tags.test.ts 30 → 0 157 → 157
ui/src/pages/chat/chat-pane.test.ts 30 → 7 heterogeneous context/DOM/hello projections 29 → 29
src/auto-reply/reply/agent-runner-memory.test.ts 29 → 0 63 → 63
Total 338 → 11 612 → 612

Focused Vitest proof passed 675 discovered tests across the nine directly runnable target files: sessions 43, systemd 151, chat-pane sharing 31, Discord 42, CLI force 31, doctor migrations 77, Gateway chat 199, chat pane 31, and agent-runner memory 70. The policy aggregate extension runner stalled twice at its 15-minute local no-output cutoff; the exact-head extension production/test type lanes and all changed-file lint passed remotely.

node scripts/check-changed.mjs passed the complete changed matrix on Blacksmith Testbox: https://github.com/openclaw/openclaw/actions/runs/31993643550

The final exact anti-slop scan reports only the 11 documented intentional boundary/projection cases. git diff --check is clean. Production LOC: +0/-0; test and test-support LOC: +962/-922 (net +40).

Final autoreview: clean, no accepted/actionable findings (--mode branch --base origin/main, 183,019-byte bundle).

Skipped after fresh classification:

  • ui/src/app/app-host.test.ts (49) and extensions/voice-call/src/webhook.test.ts (45): previously documented heterogeneous clusters.
  • src/agents/embedded-agent-runner/run/attempt.llm-boundary.test.ts (39): output projections plus malformed media boundary fixtures.
  • ui/src/pages/agents/agents-page.test.ts (35), ui/src/pages/chat/components/chat-message.test.ts (33), and src/cli/capability-cli.test.ts (31): multiple unrelated fixture/mock targets.
  • extensions/discord/src/internal/gateway.test.ts (31): private-state/member projections, not fixture construction.
  • extensions/anthropic/session-catalog.test.ts (30) and extensions/browser/src/browser/chrome.internal.test.ts (30): several distinct runtime/config/response types rather than one builder family.

@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: discord Channel integration: discord app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling extensions: policy size: XL maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 02:41
@steipete steipete self-assigned this Aug 17, 2026
@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 changes before merge. Reviewed August 17, 2026, 12:35 AM ET / 04:35 UTC.

ClawSweeper review

What this changes

The PR replaces repeated unsafe test fixture casts with typed fixture builders across test and test-support code.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: the Control UI fixture helpers newly centralize an unsafe whole-object assertion and no longer preserve the asynchronous contracts this refactor is meant to expose.

Priority: P3
Reviewed head: 0625cb2ca7ac30fe6f6116035f82a41a98656943

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has useful cleanup but needs one focused fixture-contract repair.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only refactor has no changed user-visible behavior to demonstrate.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-only refactor has no changed user-visible behavior to demonstrate.
Evidence reviewed 6 items New fixture contract is unsound: The new helpers accept a synchronous two-argument request returning unknown and a patch function returning unknown, then assert those partial overrides are complete runtime objects.
Browser client contract: The actual client request accepts an optional third options argument and returns Promise<T>.
Session patch contract: The session patch route is asynchronous and returns Promise<SessionsPatchResult | null>.
Findings 1 actionable finding [P2] Preserve the real async fixture contracts
Security None None.

How this fits together

Test fixtures provide mocked inputs to existing channel, gateway, CLI, agent, policy, daemon, and Control UI tests. This PR changes those fixture boundaries without changing production runtime behavior.

flowchart LR
A[Test scenarios] --> B[Fixture builders]
B --> C[Mocked client and session contracts]
C --> D[Existing subsystem tests]
D --> E[Type and regression feedback]
Loading

Before merge

  • Preserve the real async fixture contracts (P2) - These builders assert partial overrides to complete runtime objects, but request permits a synchronous two-argument function returning unknown and patch permits unknown. The production methods accept/return stronger async contracts, so callers can still typecheck incompatible mocks as full objects. Preserve the actual request and patch signatures, or keep intentional incomplete-boundary casts local and named.
  • Resolve merge risk (P1) - The supplied exact-head check rollup is incomplete and truncated; after the fixture repair, merge should wait for an exact-head green result.

Findings

  • [P2] Preserve the real async fixture contracts — ui/src/pages/chat/chat-pane.test-support.ts:152-170
Agent review details

Security

None.

PR surface

Source -8, Tests +48. Total +40 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 4 137 145 -8
Tests 9 825 777 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 962 922 +40

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests and test support +962/-922 (net +40) All changes are test-facing; no production behavior or public contract grows.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/policy/src/doctor/register.test-harness.ts, migration/backfill/repair: src/commands/doctor-legacy-config.migrations.test.ts, serialized state: src/agents/tools/sessions-access.test.ts, unknown-data-model-change: extensions/policy/src/doctor/register.sandbox-and-tools.test-utils.ts, unknown-data-model-change: src/agents/tools/sessions-access.test.ts, unknown-data-model-change: src/commands/doctor-legacy-config.migrations.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Type the shared Control UI overrides to the actual generic asynchronous request and session-patch contracts, leaving any deliberately incomplete fixture boundary explicit at its call site.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Type the shared Control UI overrides to the actual generic asynchronous request and session-patch contracts, leaving any deliberately incomplete fixture boundary explicit at its call site.

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

Yes: source inspection shows the fixture overrides accept synchronous unknown-returning methods where the production contracts require promises and an additional request option.

Is this the best way to solve the issue?

No: moving a broad assertion into a shared builder does not deliver compiler-checked fixtures; preserving the callable contracts is the narrower maintainable repair.

Full review comments:

  • [P2] Preserve the real async fixture contracts — ui/src/pages/chat/chat-pane.test-support.ts:152-170
    These builders assert partial overrides to complete runtime objects, but request permits a synchronous two-argument function returning unknown and patch permits unknown. The production methods accept/return stronger async contracts, so callers can still typecheck incompatible mocks as full objects. Preserve the actual request and patch signatures, or keep intentional incomplete-boundary casts local and named.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is test-only maintainability work with no user-visible runtime behavior change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored test-only refactor has no changed user-visible behavior to demonstrate.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs ui/src/pages/chat/chat-pane.test.ts ui/src/pages/chat/chat-pane-sharing.test.ts.
  • [P1] pnpm check:test-types.

What I checked:

Likely related people:

  • steipete: Introduced the shared agent-runner fixture visible on current history and authored the two merged preceding typed-fixture waves. (role: fixture-pattern owner and recent area contributor; confidence: high; commits: 18eb5610fd11, d258c6651a5e, 9b468ccaa2a8; files: src/auto-reply/reply/agent-runner.test-fixtures.ts, ui/src/pages/chat/chat-pane.test-support.ts)

Rank-up moves

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

  • Preserve the actual asynchronous request and patch signatures in the shared Control UI fixtures.
  • Run the affected Control UI tests and exact-head test-type checks after repair.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-17T03:17:43.235Z sha 9c4dc1f0b54e34be1f7755d0336575a1d7734352 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T03:32:35.072Z sha 0625cb2 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/test-fixtures-wave3 branch from 9c4dc1f to 0625cb2 Compare August 17, 2026 03:26
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for head 0625cb2ca7ac30fe6f6116035f82a41a98656943:

Focused proof inherited from the completed branch passed 675 discovered tests across the nine directly runnable targets. A fresh saturated-workstation rerun reproduced one timing-only anomaly: the existing memory-flush case exceeded its 120-second timeout after 69/70 assertions passed. The same exact head is green in CI and the earlier focused run passed 70/70, so no test timeout or behavior was changed in this fixture-only PR.

ClawSweeper reviewed this exact head with no actionable finding; its only rank-up move was to wait for exact-head CI, now complete. Production LOC is +0/-0; test and test-support LOC is +962/-922 (net +40). Current main changed none of the 13 touched paths, so the behind-main drift is advisory and does not justify discarding fresh exact-head proof with a rebase.

@steipete
steipete merged commit e6a14c0 into main Aug 17, 2026
183 checks passed
@steipete
steipete deleted the steipete/test-fixtures-wave3 branch August 17, 2026 04:49
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

* test: replace assertion chains with typed fixture builders — wave 3

* test: keep policy fixture type local

* test: type gateway context fixture

* test: type systemd stream fixture

* test: type chat pane fixture overrides
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: discord Channel integration: discord cli CLI command changes commands Command implementations extensions: policy gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant