Skip to content

test(a2ui): queued SVG decode test fails on a slow runner because it checks total elapsed time - #2170

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-a2ui-svg-queue-flake
Nov 13, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-a2ui-svg-queue-flake

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: A2UISvgTests.Load_QueuedBehindBusyDecodeSlots_CompletesOnceASlotFrees failed on main 30e8a49f (run 43423590868, job 131879466615) with: "queue wait 00:00:00.5 plus a trivial decode took 00:00:02.844 (>00:00:02.5)".

User Impact

User impact: none. The product change only replaces the literal 3 with a named constant, so behavior is unchanged. This removes a false CI failure.

Why This Change Was Made

The test held every decode slot, released them from a timer after 500 ms, and asserted that the whole operation finished within 2.5 s of wall-clock time. On a loaded runner, the UI-thread dispatch alone can exceed that, so the test measured runner speed rather than queueing.

MediaResolver.LoadImageAsync runs synchronously for a data: SVG until it reaches s_svgDecodeSemaphore.WaitAsync. The test now proves the queue behavior causally:

  1. It holds every decode slot. It requires all MediaResolver.SvgDecodeConcurrency slots to be idle first, so no earlier work can take part.
  2. It starts the load and asserts that it is still pending.
  3. It frees exactly one slot and asserts CurrentCount == 0. SemaphoreSlim.Release hands a freed slot directly to a queued async waiter, so the count stays at 0 only if the load was waiting in the queue.
  4. It awaits the load within the existing named SingleDecodeBound (SvgRenderTimeout plus OPENCLAW_UI_SVG_DECODE_SLACK_SECONDS). A timeout reports diagnostics.
  5. It asserts the result is a decoded SvgImageSource with no warnings, and CurrentCount == 1 (the load returned its slot).

MediaResolver now names its concurrency (internal const int SvgDecodeConcurrency = 3). The timing ratchet baseline for this file drops from 2 to 1 because the Task.Delay was removed.

Evidence

  • RED: I added a 2.5 s UI-thread stall after the release, a stand-in for CI's loaded runner. The old test fails with CI's signature: "queue wait 00:00:00.5000000 plus a trivial decode took 00:00:03.0831039 (>00:00:02.5000000)".
  • GREEN: the new test passes with the same stall.
  • Mutation: I bypassed WaitAsync and Release in the product, so loads no longer queue. The new test fails at the hand-off check: "Expected: 0, Actual: 1".
  • Not weakened: pending-before-release plus a verified hand-off replaces the old "completed after release" timestamp check. Successful decode is still required, and the no-warnings and slot-returned checks are new. Only the intentionally removed wall-clock limit is gone.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • none: test change plus a product constant with no behavior change. CI's UI job runs this test. No custom pool applies.

Validation

Tested on base 49a9747a with the final tree (commit 2962d433; the tested tree is identical). main is now 5e882426, with no changes to these files.

  • dotnet test tests/OpenClaw.Tray.UITests --no-build --filter "FullyQualifiedName~A2UISvgTests.Load_QueuedBehindBusyDecodeSlots_CompletesOnceASlotFrees": 5 consecutive passes.
  • dotnet test tests/OpenClaw.Tray.UITests --no-build --filter "FullyQualifiedName~A2UISvgTests": 23 passed, 0 failed.
  • .\scripts\validate-test-timing-patterns.ps1: passed. The only remaining warning is about an unrelated Shared test file.
  • ./build.ps1: all builds succeeded.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj: 6,441 passed, 0 failed.
  • Shared tests were not run; no Shared code changed.
  • Isolation: native runs used isolated OPENCLAW_TRAY_* roots under the shared desktop lock. The real OpenClawTray profile manifests were unchanged.
  • Review: Hanselman dual-model review (Claude Opus 5.5, and GPT-6 Astra with long context; high reasoning). No CRITICAL, HIGH or MEDIUM findings.
    • Both reviewers confirmed that SemaphoreSlim.Release hands the slot to the queued waiter synchronously in .NET 10. This is long-stable implementation behavior, not a documented guarantee.
    • Fixed the LOW findings: the test now requires every slot to be idle at start (via the named constant), and the bounded wait reports diagnostics on timeout.

Real Behavior Proof

  • Environment tested: Windows 11 dev box, in-process native WinUI UI tests, Debug win-x64.
  • PR head or commit tested: 2962d433.
  • Exact steps or command run: see Validation, plus the temporary RED stall and product mutation (not committed).
  • Evidence after fix: RED, GREEN and mutation results as above.
  • Observed result: as above.
  • Screenshot or artifact links verified? (Yes/No/N/A) N/A
  • Not verified or blocked: the CI first-attempt result is pending.

Security Impact

  • New permissions or capabilities? (Yes/No) No
  • Secrets or tokens handling changed? (Yes/No) No
  • New or changed network calls? (Yes/No) No
  • Command or tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any answer is Yes, explain the risk and mitigation:

Compatibility and Migration

  • Backward compatible? (Yes/No) Yes
  • Config or environment changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, list the exact upgrade steps:

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

…checks total elapsed time

Load_QueuedBehindBusyDecodeSlots_CompletesOnceASlotFrees asserted that a 500 ms queue hold plus one decode finished within 2.5 s of wall-clock time, which a loaded runner exceeded. Prove the queueing causally instead: with every decode slot held the load is pending, the single freed slot is handed directly to it (SemaphoreSlim CurrentCount stays 0), and it then decodes within the existing named SingleDecodeBound and returns its slot. Name the decode concurrency (MediaResolver.SvgDecodeConcurrency) so the test can require every slot idle at start, and lower the file's fixed-delay baseline.

Co-authored-by: Copilot App <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR replaces a queued SVG decode test’s elapsed-time assertion with queue hand-off checks and names the existing three-slot concurrency limit.

Example: A busy runner completes a queued trivial SVG load in 2.844 seconds.

  • Before: The test fails its 2.5-second total elapsed-time limit despite successful decoding.
  • After: The test checks that the load queues, receives one released slot, decodes within the existing named bound, and returns its slot.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with reported native harness and mutation validation; exact-head CI remains in progress.
Proof confidence 🦐 gold shrimp (3/6) This test-reliability change has no user-visible product behavior; reported native WinUI regression and mutation runs support it without requiring shipped-entry-point media.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Contributors encounter false native-test failures on busy CI runners.
Reason: The maintainer-authored direction is established, and the patch removes an incidental timing constraint without changing SVG policy or adding another implementation path.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a concrete timing-sensitive test still present on main. The introduced diff preserves product behavior, and no actionable correctness or security defect was found.

Priority: P3
Reviewed head: 2962d4339bc5e64856661b17b7ca8fb23c541647

Before merge

None.

Findings

None.

Agent review details

How this fits together

MediaResolver converts permitted A2UI image URLs into native WinUI image sources; SVG decoding uses a shared three-slot semaphore, and the changed native test exercises that queue directly.

flowchart LR
A[A2UI image URL] --> B[MediaResolver]
B --> C[SVG input validation]
C --> D[Three slot decode queue]
D --> E[Native SVG decoder]
E --> F[WinUI image source]
Loading

Technical review

Best possible solution:

Retain the causal queue assertions and unchanged product limit, with the existing native test lane validating the candidate.

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

Current-main source confirms the 500 ms timer and 2.5-second total bound; the author reports matching CI and injected-stall failures, but this review did not independently execute them.

Is this the best way to solve the issue?

The smallest complete fix replaces runner-speed measurement in the existing test with observable queue transitions while preserving successful native decoding and the separate single-decode bounds.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5e8824267216.

Provenance checked

  • Queued SVG decode assertions changes intended behavior with a stated reason (b6c849e: Separate queue wait from single-admitted-decode timing coverage.)
  • Three-slot SVG concurrency limit keeps the original intent (9fa43f3: Native SVG decoding used bounded concurrency as part of the renderer’s decode budgeting.)
  • Timing-pattern baseline keeps the original intent (ee8edbc: Ratchet existing timing-sensitive patterns and prevent new occurrences.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced change and current main: The pinned introduction diff changes only the concurrency constant, the existing queued-load test, and its timing baseline; current main retains the timer and total elapsed-time assertion. (tests/OpenClaw.Tray.UITests/A2UISvgTests.cs:525, 2962d4339bc5)
  • Production queue contract: Data-URL decoding reaches the semaphore without an earlier asynchronous suspension; successful decoding releases its slot in finally, supporting the pending, hand-off, and returned-slot assertions. (src/OpenClaw.Tray.WinUI/A2UI/Rendering/MediaResolver.cs:350, 2962d4339bc5)
  • Original test intent: test: stabilize flaky UI-job and SetupEngine CI failures #1981 introduced separate queue coverage while preserving the single-decode bound; this PR explains replacing the queue test’s incidental timing limit while retaining that separation. (tests/OpenClaw.Tray.UITests/A2UISvgTests.cs:525, b6c849e8ed44)
  • Validation evidence and limits: The full PR body reports an old-test failure under an injected stall, a new-test pass under the same stall, a failing queue-bypass mutation, five focused passes, 23 SVG-suite passes, a successful build, and 6,441 Tray passes; Shared tests were explicitly not run locally. Exact-head CI has successful fast validation and ongoing native test jobs. No builds or tests were run during this read-only review; the linked historical job log redirected to a blocked storage host. (2962d4339bc5)
  • Review policy and history: Root and applicable WinUI instructions were read; no maintainer-notes directory or additional changed-path ancestor instructions exist. Test-audit and pr-simplify steps 1–3 support retaining the focused queue test without new machinery. The user’s single-reviewer restriction supersedes the helper route. File-follow history reaches a missing predecessor blob at creation; scoped history and current-main blame establish the relevant later ownership. (AGENTS.md:11, 2962d4339bc5)
  • Semaphore hand-off implementation: The PR explicitly relies on .NET 10 SemaphoreSlim behavior. Its Release implementation decrements the available count for an asynchronous waiter before publishing CurrentCount, supporting the immediate zero-count assertion in this serialized UI scenario. (src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs:897, 60629d14374c)

Likely related people:

  • Pedro Larroy: Raw commit b6c849e adds tests/OpenClaw.Tray.UITests/A2UISvgTests.cs:320 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b6c849e8ed44; files: tests/OpenClaw.Tray.UITests/A2UISvgTests.cs)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Focused change size Production +3/-1 lines; tests and baseline +31/-23 lines The small increase replaces timer bookkeeping with distinct queue-admission, successful-decode, and slot-return checks.

Labels

Label changes:

  • add P3: This is a focused test-reliability repair with unchanged user-facing product behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a focused test-reliability repair with unchanged user-facing product behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 13, 2026, 9:44 AM ET / 14:44 UTC.

@bkudiess
bkudiess merged commit ec49620 into openclaw:main Nov 13, 2026
56 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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