Skip to content

[Repo Assist] test(shared): add unit tests for AsyncEventHandlerGuard fault boundary#635

Draft
github-actions[bot] wants to merge 1 commit into
masterfrom
repo-assist/improve-async-event-handler-guard-tests-b66b52fe90629a0e
Draft

[Repo Assist] test(shared): add unit tests for AsyncEventHandlerGuard fault boundary#635
github-actions[bot] wants to merge 1 commit into
masterfrom
repo-assist/improve-async-event-handler-guard-tests-b66b52fe90629a0e

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 2, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

AsyncEventHandlerGuard is a critical fault boundary that prevents fire-and-forget async event handlers from crashing the process via async void escapes. Despite being used throughout the codebase (chat, transport, tray services), it had no dedicated unit tests.

This PR adds 8 unit tests covering all exit paths:

Test What it verifies
Run_NullWork_ThrowsArgumentNullException Null guard throws immediately
Run_SuccessfulWork_CompletesWithoutError Happy path
Run_CancelledException_DoesNotInvokeOnError OperationCanceledException is swallowed, not forwarded to onError
Run_CancelledException_LogsDebugMessage Cancellation is logged at Debug level
Run_UnexpectedException_InvokesOnError Exception is forwarded to onError callback
Run_UnexpectedException_LogsErrorWithException Exception is logged with the exception object attached
Run_OperationName_AppearsInLogMessages Custom operationName surfaces in log output
Run_NoCallbacks_ExceptionIsSwallowedCleanly No logger/no onError — fault is silently swallowed without crashing

Test Status

Passed! - Failed: 0, Passed: 8, Skipped: 0, Total: 8, Duration: 207 ms

Full OpenClaw.Shared.Tests suite (2045 pass, 8 pre-existing failures in MxcPolicyBuilderTests/ExecApprovalV2NormalizationTests unrelated to this change). OpenClaw.Connection.Tests: 267/267 passed.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

Cover all exit paths of the async event-handler guard:
- Null work argument throws ArgumentNullException immediately
- Successful work completes normally
- OperationCanceledException is swallowed (not forwarded to onError), and
  a debug message is logged
- Unexpected exceptions invoke onError callback and log an error with the
  exception attached
- operationName appears in logged messages
- No callbacks scenario: unhandled exceptions are silently swallowed
  without tearing down the process

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 2, 2026

Codex review: needs maintainer review before merge. Reviewed June 2, 2026, 10:07 AM ET / 14:07 UTC.

Summary
This PR adds a new shared test file with eight unit tests for AsyncEventHandlerGuard null-work, success, cancellation, exception logging/callback, operation-name logging, and no-callback paths.

Reproducibility: not applicable. this is a test coverage PR rather than a user-reported bug. Source inspection shows current master has AsyncEventHandlerGuard but no dedicated AsyncEventHandlerGuardTests file.

Review metrics: 3 noteworthy metrics.

  • Patch surface: 1 test file added, 215 lines. The change is narrowly scoped to shared test coverage, which keeps the merge surface small.
  • Coverage cases: 8 tests added. The test list covers the current guard’s null, success, cancellation, exception, logging, operation-name, and no-callback paths.
  • Validation reported: 8 new tests passed; shared suite reported 2045 pass and 8 pre-existing failures. Maintainers need this context because this read-only review did not run the repository-required validation commands.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Confirm AGENTS.md-required validation before merge: ./build.ps1, shared tests, and tray tests.

Risk before merge

  • [P1] I could not run the AGENTS.md-required validation in this read-only review; the PR body reports focused test output, but maintainers still need CI or a local validation pass for ./build.ps1, shared tests, and tray tests before merge.

Maintainer options:

  1. Decide the mitigation before merge
    Merge the focused test coverage after required build/test validation confirms the new shared tests compile and do not add regressions.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No ClawSweeper repair lane is needed because I found no concrete patch defect; the remaining action is maintainer/CI validation for a fresh draft PR.

Security
Cleared: The diff only adds a shared unit test file and does not touch dependencies, workflows, secrets, packaging, or runtime security boundaries.

Review details

Best possible solution:

Merge the focused test coverage after required build/test validation confirms the new shared tests compile and do not add regressions.

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

Not applicable; this is a test coverage PR rather than a user-reported bug. Source inspection shows current master has AsyncEventHandlerGuard but no dedicated AsyncEventHandlerGuardTests file.

Is this the best way to solve the issue?

Yes; adding focused unit tests under OpenClaw.Shared.Tests is the narrowest maintainable way to cover this shared fault boundary. The open item before merge is validation, not a code repair.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against e0ce52d2f16c.

Label changes

Label justifications:

  • P3: This is a low-risk automated test coverage PR with no user-facing 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 is a Repo Assist bot PR, so the external contributor proof gate is not applied; the PR body includes terminal-style test output, but validation still needs CI or maintainer confirmation.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read in full; its required build/shared/tray validation guidance is relevant, but this ClawSweeper review is read-only and did not run artifact-producing validation commands. (AGENTS.md:1, e0ce52d2f16c)
  • Current guard behavior: Current master validates the work delegate, starts RunCoreAsync, swallows OperationCanceledException with a debug log, and logs/invokes onError for unexpected exceptions. (src/OpenClaw.Shared/AsyncEventHandlerGuard.cs:9, e0ce52d2f16c)
  • PR patch surface: The PR commit adds only tests/OpenClaw.Shared.Tests/AsyncEventHandlerGuardTests.cs, a 215-line test file covering the guard’s main exit paths. (tests/OpenClaw.Shared.Tests/AsyncEventHandlerGuardTests.cs:1, e5ec19ba2e49)
  • Not already implemented on master: Search found no AsyncEventHandlerGuardTests or the new test method names on current master, so this test coverage is still unique to the PR. (e0ce52d2f16c)
  • Feature provenance: git blame and git log show AsyncEventHandlerGuard was introduced by commit 7d9152f, which is also tag v0.6.0. (src/OpenClaw.Shared/AsyncEventHandlerGuard.cs:1, 7d9152f427a3)
  • Validation evidence from PR body: The PR body reports the 8 new tests passed and notes broader shared-suite failures as pre-existing; it does not report the full AGENTS.md validation set of ./build.ps1 plus shared and tray tests. (e5ec19ba2e49)

Likely related people:

  • RBrid: Current blame and follow history show AsyncEventHandlerGuard was introduced in commit 7d9152f, so this is the strongest routing signal for the guarded behavior under test. (role: introduced behavior; confidence: high; commits: 7d9152f427a3; files: src/OpenClaw.Shared/AsyncEventHandlerGuard.cs)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@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-risk cleanup, docs, polish, ergonomics, or speculative feature. labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. repo-assist 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.

0 participants