Skip to content

test(macos): stabilize gateway session negotiation tests - #120141

Merged
vincentkoc merged 1 commit into
mainfrom
fix-120130-gateway-session-tests
Aug 7, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix-120130-gateway-session-tests

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Fixes #120130

What Problem This Solves

Fixes an issue where unrelated pull requests could intermittently fail the
macos-swift gate because GatewayNodeSessionTests asserted negotiation and
receipt timing that the test transport had not made deterministic.

Why This Change Was Made

Post-negotiation tests now enqueue the protocol response or error before the
invoke frame, matching websocket frame ordering without waiting on scheduler
timing. Receipt coverage separately proves an unbounded stale retry dispatches
exactly once and that a deadline-bound retry may expire before or after its
single permitted dispatch.

Intentional pre-negotiation and response-plus-invoke ordering tests are
unchanged. This is test-only: no production behavior, timeout, polling, or sleep
changed.

User Impact

No runtime behavior changes. Contributors get a deterministic macos-swift
signal instead of intermittent failures inherited from main.

Evidence

  • Seven affected/changed tests: 20 consecutive runs, 140/140 executions passed.
  • Full GatewayNodeSessionTests: 11 consecutive runs, 83/83 tests passed each run.
  • Full OpenClawKit package: 1,331 tests in 102 suites passed.
  • SwiftFormat: clean.
  • SwiftLint: the patch and origin/main report the same three pre-existing
    whole-file violations; no changed-line violation.
  • Blacksmith changed gate: passed on tbx_01kzd5x2wcm3m3gyx5mz8bme0z
    (run).
  • Max-P1 autoreview: clean, no accepted/actionable findings, confidence 0.98.

Punchcard-Session: golden-meadow-timber-8g

Fixes #120130

Punchcard-Session: golden-meadow-timber-8g
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 7, 2026
@vincentkoc vincentkoc self-assigned this Aug 7, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@vincentkoc
vincentkoc marked this pull request as ready for review August 7, 2026 04:06
@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. P2 Normal backlog priority with limited blast radius. 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, 12:21 AM ET / 04:21 UTC.

ClawSweeper review

What this changes

The PR makes macOS gateway-session negotiation and receipt tests deterministic by explicitly ordering fake protocol frames and replacing sleep-based retry assertions.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer review: the PR removes a real test-harness ordering race without changing runtime behavior, and no blocking correctness or security finding was found.

Priority: P2
Reviewed head: f83443a2afff3b4cf39eecaf8cbac2892611243e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-only repair with strong source-level alignment and reported repeated validation, pending normal exact-head review completion.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This MEMBER-authored, test-only PR is outside the external-contributor proof gate; its body supplies repeated focused-suite and package test evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored, test-only PR is outside the external-contributor proof gate; its body supplies repeated focused-suite and package test evidence.
Evidence reviewed 5 items Fake transport ordering contract: The fake transport queues inbound frames in insertion order when no receive callback is installed, so explicitly enqueueing a negotiation result before an invoke exercises WebSocket frame order rather than scheduler timing.
Runtime negotiation boundary: The gateway session resolves an authoritative mode except for the exact compatibility fallback, making response-before-invoke the correct invariant for these tests.
Patch covers the reported race: The PR manually queues success and error responses before invokes, and separates unbounded exactly-once receipt coverage from the bounded-deadline 0-or-1 dispatch outcome.
Findings None None.
Security None None.

How this fits together

OpenClawKit’s macOS node session negotiates protocol capabilities over a gateway connection before handling invokes and receipt retries. The changed fake-transport tests verify that negotiation state is resolved before subsequent frames are processed.

flowchart LR
  Node[Mac node session test] --> Fake[Fake gateway transport]
  Fake --> Negotiation[Protocol negotiation response]
  Negotiation --> Mode[Resolved session mode]
  Mode --> Invoke[Gateway invoke]
  Invoke --> Receipt[Receipt retry assertion]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main and one CI job remains in progress; before merge, refresh review against the exact mergeable head and confirm the latest ClawSweeper rank-up moves.
Agent review details

Security

None.

PR surface

Other +56. Total +56 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 82 26 +56
Total 1 82 26 +56

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +82/-26 (net +56) All changed lines are focused Swift test coverage, so the repair adds no runtime or compatibility surface.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #120130
Summary: This PR is a focused candidate fix for the canonical flaky GatewayNodeSessionTests report.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused test-owner repair once exact-head checks and the current review moves are satisfied; no production session behavior change is warranted.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the focused test-owner repair once exact-head checks and the current review moves are satisfied; no production session behavior change is warranted.

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

Yes: the linked report gives a repeated focused Swift-test path, and current source establishes the race between the detached fake response and the emitted invoke; this review did not rerun it.

Is this the best way to solve the issue?

Yes: controlling the fake transport’s frame order and separating deadline semantics fixes the test owner boundary instead of weakening production behavior or adding timing tolerance.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: An intermittent macOS test-suite failure can mislead contributor merge-gate results, but the PR changes no shipped runtime behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored, test-only PR is outside the external-contributor proof gate; its body supplies repeated focused-suite and package test evidence.

Label justifications:

  • P2: An intermittent macOS test-suite failure can mislead contributor merge-gate results, but the PR changes no shipped runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored, test-only PR is outside the external-contributor proof gate; its body supplies repeated focused-suite and package test evidence.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Authored the session-attribution test feature and the subsequent queued-frame test work, and is connected to the current repair beyond this PR alone. (role: feature and recent test-path contributor; confidence: high; commits: 735f176b0121, bc5b29a032ca; files: apps/shared/OpenClawKit/Tests/OpenClawKitTests/GatewayNodeSessionTests.swift)
  • Peter Steinberger: Recent history includes the GatewayNodeSessionTests refactor that touches this central test surface. (role: recent area contributor; confidence: medium; commits: 65d2222a6e84; files: apps/shared/OpenClawKit/Tests/OpenClawKitTests/GatewayNodeSessionTests.swift)

Rank-up moves

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

  • Confirm the latest ClawSweeper rank-up moves and the final exact-head required checks before merge.

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.

@vincentkoc
vincentkoc merged commit aea8b4f into main Aug 7, 2026
112 checks passed
@vincentkoc
vincentkoc deleted the fix-120130-gateway-session-tests branch August 7, 2026 05:31
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 7, 2026
…cope

* origin/main:
  fix(qa): bound Matrix scenario preparation separately (#119996)
  test(msteams): cover occupied webhook port (#120158)
  fix(agents): clear btw attribution reservations
  fix(agents): reserve execution attribution atomically
  fix(agents): reject attribution collisions before capture
  fix(agents): reject CLI attribution collisions
  fix(agents): reject private attribution recovery by run id
  fix(agents): restore runtime check cleanliness
  fix(agents): refresh rebound run admission time
  refactor(agents): propagate exact attribution across runtimes
  fix(release): provide prerelease plugin companions to package QA (#120107)
  test(macos): stabilize gateway session negotiation tests (#120141)
  refactor(test): replace logic-bearing vi.mock factories with boundary fakes, batch 2 (#120117)

# Conflicts:
#	src/agents/command/attempt-execution.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

[Bug]: GatewayNodeSessionTests is flaky on main, making macos-swift unreliable as a merge gate

1 participant