Repository navigation
feat(gateway): accept WebSocket request trace context - #113189
Conversation
|
Codex review: found issues before merge. Reviewed July 28, 2026, 12:37 PM ET / 16:37 UTC. ClawSweeper reviewWhat this changesThis PR lets authenticated Gateway WebSocket clients attach an optional W3C Merge readinessThe Gateway trace-context implementation is a coherent additive protocol feature with strong authenticated-session proof, but this PR also changes the iOS screenshot workflow in a way that does not match its stated “native Apple changes” scope. Keep it open for a small CI-condition correction and a refreshed merge-result check before landing. Priority: P2 Review scores
Verification
How this fits togetherGateway clients authenticate over a long-lived WebSocket and submit individual request frames to the authenticated dispatcher. The dispatcher creates request-local diagnostics context before invoking Gateway methods, allowing agent, harness, model, and provider telemetry to remain correlated without sharing context across unrelated RPCs. flowchart LR
Client[Authenticated WebSocket client] --> Frame[Request frame with optional trace context]
Frame --> Schema[Gateway protocol validation]
Schema --> Dispatcher[Authenticated request dispatcher]
Dispatcher --> RequestTrace[Request-local diagnostic trace]
RequestTrace --> GatewayMethods[Gateway method handling]
GatewayMethods --> Telemetry[Agent and provider telemetry]
Frame --> NativeClients[Swift and Android protocol clients]
Decision needed
Why: The current Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +18, Tests +437, Docs +43, Config 0, Other +5. Total +503 across 14 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the request-scoped protocol feature, but define an explicit preflight condition for iOS screenshot-worthy changes (or document why a narrower condition is correct), then rebase and let the required checks validate that exact head. Do we have a high-confidence way to reproduce the issue? Not applicable for the feature request itself: the PR includes a real authenticated Gateway session proof showing the new trace propagation, fallback, and concurrent-isolation behavior after the change. Is this the best way to solve the issue? No for the PR as a whole: request-scoped trace propagation is the narrow compatible design, but using Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a88c4283ad48. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
Merged via squash.
|
* feat(gateway): accept WebSocket request trace context * test(gateway): prove WebSocket trace isolation * test(gateway): simplify traced response match * ci: allow iOS screenshot validation to finish * fix(gateway): keep traced request failures scoped * test(ci): align iOS screenshot timeout contract * test(ui): reset config route location * ci: scope iOS screenshots to native changes --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #113196
AI-assisted: Codex deep-reviewed the contributor implementation, compared it with the installed OpenTelemetry contracts and W3C specification, added real authenticated-session proof, and ran the maintainer landing gates.
What Problem This Solves
Gateway WebSocket requests could not carry upstream W3C trace context. Every frame therefore started a new diagnostic trace, preventing an experiment runner or observability backend from correlating one dataset item with the OpenClaw agent, harness, model-call, and provider work it triggered.
Why This Change Was Made
The request frame now accepts one optional
traceparentstring capped at 128 characters. After the existing authentication handshake, a valid value becomes the parent of a new request-scoped diagnostic context. Missing or syntactically malformed values inside that bound keep the existing fresh per-message root. Values longer than 128 characters remain invalid request frames.Request scope is the important ownership boundary. A connection-level trace would incorrectly combine unrelated or concurrent RPCs on a long-lived socket, while adding trace metadata to each method payload would duplicate one cross-cutting contract across the protocol. The initial
connectframe is deliberately ignored, andtracestateandbaggageremain out of scope.Generated Swift and Kotlin request models expose the optional field, and the Gateway protocol and OpenTelemetry docs describe the authentication, fallback, concurrency, and length contracts.
User Impact
Authenticated Gateway clients can correlate each logical RPC with an upstream OpenTelemetry/Langfuse trace without changing existing clients or authentication behavior. The field affects observability only; it does not change authorization, routing, request identity, or persistence.
Dependency and Standards Review
@opentelemetry/core2.9.0W3CTraceContextPropagatoruses the same version/ID/flag contract and marks extracted parents remote.@opentelemetry/api1.9.1 models trace flags as a bitmap; diagnostics-otel masks the sampled bit before creating the remote parent context.Maintainer Decision
The Gateway owner accepts this additive request-scoped protocol capability for landing. Request scope is deliberate: connection scope would merge concurrent RPCs, while method-payload fields would duplicate one cross-cutting contract across every method.
Evidence
Final head:
8f4de600f49767dc75b80b31a7edf1ca76c5e8cc. Broad product-code proof ran on ancestor2abf9dcb94c47f13c5976c3b0ba2eb2d6fb79bfb; later commits scope release screenshots to native Apple changes, align the workflow contract test, keep rejected-handler diagnostics inside the propagated request trace, and isolate an unrelated baseline UI route test from leaked location hashes.Blacksmith Testbox
tbx_01kym9m7rpe7k4qfghqmwyk11a(run 30357185740) passed:PROTOCOL_SINCE_BASE_SHA=89b6d85cdd862d3315927abcc604c9e128e67314, followed by byte-for-byte comparison against the fetched immutable PR refGatewayProtocolGeneratedTestThe real server regression starts a loopback Gateway with token and signed-device authentication, sends a
traceparenton theconnectframe, and proves the next untraced RPC receives a different fresh trace. It then proves malformed fallback and holds two valid traced requests across an async barrier on the same socket. The two requests retain distinct trace IDs (1111…and2222…), parent span IDs, and sampled flags before and after interleaving.The final code diff was rerun on Blacksmith Testbox
tbx_01kymhmxdpsmsjb18yymjpwq6p(run 30367985039); this redacted terminal excerpt is the inspectable runtime proof:These were delegated Testbox commands. The wrapper's final timing JSON and exit code are authoritative; the backing Actions job can show cancelled after the successful one-shot lease is stopped during cleanup.
Focused local proof passed the original 102-test set before the current-main merge. Autoreview accepted two findings across the landing cycle: optional chaining could have hidden a missing fallback context, and rejected handlers registered their failure callback outside
AsyncLocalStorage.run(). The latter reproduced red on Testbox with the outer random message trace and no parent span, then passed green after failure logging and the error response moved inside request execution. Final whole-branch autoreview completed clean at 0.94.Earlier Testbox attempts were proof-setup failures rather than code failures: targeted sync left generated native files at
main, then an exact-head checkout needed an explicit protocol-since base. The final run fetched the immutable PR ref, regenerated the outputs, and compared them directly to that commit before continuing through every proof gate; it supersedes the setup failures.Hosted CI proved the full App Store screenshot matrix cannot fit even a 100-minute PR job: the finalized log completed every iPhone capture but was still serially resolving packages and restarting simulators for iPad captures at timeout. The final branch keeps iOS build and lifecycle tests for generated protocol-client changes, but runs release screenshots only for manual/full-release workflows and PRs whose preflight scope includes native Apple changes; those real screenshot lanes have a 150-minute bounded budget. The matching Fastlane workflow contract passes 20/20 assertions,
actionlintis clean, and an explicit classifier probe returnsrunIosBuild=truewithrunMacos=falsefor generated protocol models. A separate current-main UI shard exposed three config-route tests inheriting#agent-tool-readfrom another test; resetting browser history in that test fixture passes both implicated files (21/21).git diff --check, focused red/green proof, and Codex autoreviews are clean. Exact-head hosted CI run 30378627970 passed every selected lane, includingios-buildandopenclaw/ci-gate.No credentials, external collectors, release artifacts, or production Gateway state were changed during proof.