Skip to content

fix(test): report chat RPC failures without stray rejections - #201985

Merged
vincentkoc merged 2 commits into
mainfrom
refactor/test-cleanup-20261120
Nov 20, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
refactor/test-cleanup-20261120

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Fixes #201963

What Problem This Solves

When a chat RPC fails in the main-session subscription test, the assertion hides its error details and leaves the event waiter unobserved. Fixture cleanup can then add an unrelated unhandled WebSocket rejection to the failure.

User Impact

No user-visible change. Developers get the failed RPC's details without a second unhandled rejection from this test.

Why This Change Was Made

Observe the event waiter and RPC assertion together, while registering the listener before sending. All existing authorization and visibility assertions remain intact.

This repairs test failure handling. The separate production admission fix, #201790, has merged and is included in the refreshed baseline.

Evidence

  • Forced an invalid chat.send message through the real Gateway fixture on Linux with the repository's pinned Bun runtime. The original code failed its assertion and produced one unhandled WebSocket-close rejection. The patched code failed only its assertion, with the INVALID_REQUEST details visible.
  • Targeted formatting parity, type-checking and lint passed with zero warnings or errors.
  • Original-head integration failure, before baseline refresh: the original baseline passed 2/2 tests; the patched ordinary run passed 1/2 and failed with UNAVAILABLE: Session actor turn was refused by its current owner. One diagnostic replay preserving the original wait order passed 2/2. Those passes do not establish that the intermittent refusal is fixed or that timing is irrelevant. The refusal originates in production session-actor admission; the exact rejected guard remains unproven.
  • Local autoreview covered the complete range cd2ae19272a3ee7be456385fa7efc56d6e2109a6..2f23b19caddf73e5f76384ad871bbefdb25dbdfb, priorities P0–P3: complete, scoped-clean, no findings. Local ClawSweeper was unavailable; the maintainer fallback route is used.
  • Conflict resolution at 8a1c43e37a99bf7b5308c918a747cbe80b5c256b preserves the merged production fix and changes only the same test waiter block. The candidate file is byte-identical to the previously reviewed and tested patch; independent exact-candidate source review passed. The full target test passed 2/2 in the Gateway CI job, and CI run 44675264741 succeeded for this head. The tested merge checkout was c9aef378aff4fc052e03787f59ce145c60d93eee. These results qualify this patch; they do not establish that every intermittent production refusal is fixed.

@vincentkoc vincentkoc self-assigned this Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@vincentkoc
vincentkoc marked this pull request as ready for review November 19, 2026 18:19
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR observes the event waiter alongside the chat RPC assertion and includes RPC error details in assertion failures.

Example: chat.send returns INVALID_REQUEST during ownerTurn.

  • Before: The assertion reports only false versus true, and socket cleanup can produce an additional unhandled waiter rejection.
  • After: The assertion includes INVALID_REQUEST details, and Promise.all observes the waiter's subsequent rejection.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-correct, with reported fault-injection evidence, but exact-head integration validation remains unresolved.
Proof confidence 🦐 gold shrimp (3/6) This test-only change requires no shipped-entry-point proof; the reported Gateway-fixture fault injection directly targets its diagnostic behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers investigating a failed chat RPC receive incomplete diagnostics and a distracting secondary unhandled rejection.
Reason: The maintainer-authored change fixes an observed test failure-handling defect without expanding production scope or weakening coverage.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: the focused waiter repair preserves the existing assertions and improves failure diagnostics; the remaining CI admission refusal is not established as patch-caused.

Priority: P3
Reviewed head: 2f23b19caddf73e5f76384ad871bbefdb25dbdfb

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway integration test sends WebSocket RPCs and observes session events to verify subscription visibility across sharing and role changes.

flowchart LR
  A[Visibility integration test] --> B[ownerTurn]
  B --> C[chat.send RPC]
  B --> D[Session event waiter]
  C --> E[Promise.all]
  D --> E
  E --> F[Visibility assertions]
Loading

Technical review

Best possible solution:

Retain this local Promise.all repair and keep production session-admission changes with their existing owner.

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

Current-main control flow and historical CI annotations establish the abandoned waiter failure; the PR reports an invalid-message before/after experiment, but no target code was executed during this review.

Is this the best way to solve the issue?

The change is the smallest complete caller repair: register the event listener first, observe both promises immediately, preserve RPC failure details, and leave shared helpers and authorization checks unchanged.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2420b7db04c7.

Provenance checked

  • Main-session visibility integration test keeps the original intent (ad4e676: Verify that admitting an absent-main subscription grants no later access to foreign drafts or sessions hidden by role and scope changes.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Free Wortley: Raw commit ad4e676 adds src/gateway/server.chat-main-session-narrow.test.ts:151 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ad4e67659f1c; files: src/gateway/server.chat-main-session-narrow.test.ts)

PR surface

Tests +4. Total +4 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 6 2 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 6 2 +4

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.

Root-cause cluster

Relationship: same_root_cause
Canonical: #201963
Summary: The linked issue owns the diagnostic and waiter defect; production admission is related but separately scoped.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P3: This bounded test diagnostic repair changes no production 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 bounded test diagnostic repair changes no production 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.

Rank-up moves

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

  • Classify the exact-head session-actor refusal against the historical failure or the production admission repair before landing.

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 19, 2026, 1:33 PM ET / 18:33 UTC.

Baseline-Refresh: 0fe6bc2d7e36dfffdebd213714572986d0bd4d81
@vincentkoc
vincentkoc enabled auto-merge (squash) November 20, 2026 04:37
@vincentkoc
vincentkoc merged commit 085479c into main Nov 20, 2026
108 checks passed
@vincentkoc
vincentkoc deleted the refactor/test-cleanup-20261120 branch November 20, 2026 04:41
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

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

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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.

fix(test): preserve main-session RPC failures and observe event waiters

1 participant