Skip to content

feat(gateway): continue trusted HTTP trace context - #112991

Closed
moria97 wants to merge 6 commits into
openclaw:mainfrom
moria97:codex/http-upstream-trace-context
Closed

moria97 wants to merge 6 commits into
openclaw:mainfrom
moria97:codex/http-upstream-trace-context

Conversation

@moria97

@moria97 moria97 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #112979

AI-assisted implementation prepared with Codex.

What Problem This Solves

OpenClaw Gateway HTTP requests always started a new diagnostic trace, so an offline evaluation runner or external orchestrator could not correlate an agent invocation with its existing Langfuse or OpenTelemetry trace through standard W3C propagation.

Why This Change Was Made

HTTP requests now continue a valid W3C traceparent only when the direct TCP peer matches gateway.trustedProxies. OpenClaw creates a new request span beneath the upstream parent, preserving the trace ID and flags; untrusted, missing, duplicate, or malformed headers retain the existing fresh-trace behavior.

The first change is intentionally HTTP-only. It does not add configuration, change Gateway payloads, or propagate tracestate/baggage, and it leaves WebSocket trace behavior unchanged.

User Impact

Operators can attach OpenClaw HTTP agent runs to upstream experiment and workflow traces without vendor-specific protocol fields. Concurrent offline experiments can therefore remain separated by their upstream trace identity.

The OpenTelemetry documentation also explains the trusted-proxy setup and requires proxies to remove client-supplied traceparent values before injecting trusted context.

Evidence

  • server-http.request-trace.test.ts: 4 tests passed, covering:
    • existing fresh request trace correlation;
    • trusted upstream trace continuation with a new child span;
    • untrusted peer fallback;
    • malformed header fallback.
  • Focused test command: node node_modules/vitest/vitest.mjs run src/gateway/server-http.request-trace.test.ts --config test/vitest/vitest.gateway-server.config.ts --maxWorkers=1
  • oxfmt completed for both changed TypeScript files.
  • git diff --check passed.
  • Targeted security review passed with no blocking findings. The residual trusted-proxy sanitation requirement is documented.

The local repository wrapper could not complete its broader changed-surface delegation because dependency hydration repeatedly stalled on optional native packages; hosted CI remains the full-suite authority.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Jul 23, 2026
@moria97
moria97 marked this pull request as ready for review July 24, 2026 01:11
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 31, 2026, 8:59 AM ET / 12:59 UTC.

ClawSweeper review

What this changes

The PR allows Gateway HTTP handlers to create a child diagnostic span from a valid W3C traceparent only when the direct peer is listed in gateway.trustedProxies, with documentation and focused tests for trusted and fallback paths.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 6 items remain

Keep this PR open: it remains the active implementation candidate for the linked feature request, but it adds a security-sensitive inbound trust boundary and still lacks redacted after-fix real Gateway/proxy evidence. The patch appears bounded and CI-backed; a maintainer should confirm the product direction and require live behavior proof before merge.

Priority: P3
Reviewed head: 3ed68b4ff3e5bbe9599ecdded3e7fc012ab783ed
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and CI-backed, but the required real behavior proof is absent and final product-direction approval remains unresolved.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR reports focused tests and CI but supplies no redacted after-fix real Gateway/proxy run, terminal output, runtime logs, recording, or artifact showing a trusted upstream trace becoming an OpenClaw child span; add that evidence and redact private addresses and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR reports focused tests and CI but supplies no redacted after-fix real Gateway/proxy run, terminal output, runtime logs, recording, or artifact showing a trusted upstream trace becoming an OpenClaw child span; add that evidence and redact private addresses and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Active linked implementation: The PR body explicitly links the open feature request and the related issue remains open, so this branch is an implementation candidate rather than an already-resolved duplicate.
Changed security boundary: The branch gates inbound trace continuation on a parsed traceparent plus the direct peer matching gateway.trustedProxies, preserving a fresh trace on invalid or untrusted input.
Focused coverage reported: The PR adds focused request-trace coverage for fresh traces, trusted continuation, untrusted-peer fallback, and malformed-header fallback; the supplied check digest also reports successful repository checks.
Findings None None.
Security None None.

How this fits together

Gateway HTTP requests establish the diagnostic trace context that downstream hooks, agent runs, logs, and model-call spans inherit. This change accepts an upstream trace only at the trusted-proxy boundary, then passes a child request context into the existing HTTP handler.

flowchart LR
  A[Reverse proxy or orchestrator] --> B[Gateway HTTP request]
  B --> C{Direct peer trusted?}
  C -- No or invalid header --> D[Fresh diagnostic trace]
  C -- Trusted valid traceparent --> E[Child request trace]
  D --> F[Gateway request handler]
  E --> F
  F --> G[Hooks, agent runs, logs, model spans]
Loading

Decision needed

Question Recommendation
Should OpenClaw accept trusted upstream W3C trace context for Gateway HTTP requests as an endorsed built-in observability capability, limited to the existing trusted-proxy boundary? Sponsor the HTTP-only capability: Confirm the narrow trusted-proxy design, require redacted real behavior proof, and continue normal merge review.

Why: The code introduces a new inbound observability behavior at a security-sensitive proxy boundary; implementation correctness does not decide whether this capability belongs in the default Gateway product surface.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR reports focused tests and CI but supplies no redacted after-fix real Gateway/proxy run, terminal output, runtime logs, recording, or artifact showing a trusted upstream trace becoming an OpenClaw child span; add that evidence and redact private addresses and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Merging changes a trust boundary: a trusted proxy that forwards a client-supplied traceparent without stripping it would let that client select the diagnostic trace context for the request.
  • Resolve merge risk (P2) - The PR provides focused tests and successful CI, but not a redacted real proxy-to-Gateway trace showing the upstream parent, OpenClaw child span, and untrusted-peer fallback after the fix.
  • Resolve merge risk (P1) - The feature adds inbound propagation behavior without evidence of maintainer product sponsorship; the linked issue is explicitly marked as needing a product decision.
  • Complete next step (P2) - A maintainer must choose whether Gateway should endorse this new trusted inbound observability behavior; the contributor must also supply real after-fix boundary proof before merge.
Agent review details

Security

None.

PR surface

Source +25, Tests +80, Docs +31. Total +136 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 30 5 +25
Tests 1 80 0 +80
Docs 2 31 0 +31
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 141 5 +136

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Prove and retain the scoped trust gate (recommended)
    Add redacted live proxy-to-Gateway evidence and have a Gateway owner confirm that trusting only direct configured peers is the intended product boundary.
  2. Accept the operational proxy requirement
    Merge with the documented requirement that every trusted proxy removes client-supplied traceparent values before injecting its own.
  3. Pause the feature direction
    Close or defer the PR if maintainers do not want Gateway to accept upstream diagnostic identity at this boundary.

Technical review

Best possible solution:

Keep the direct-peer trust gate and fresh-trace fallback, then land only after a maintainer sponsors the HTTP-only scope and a redacted real proxy-or-orchestrator run proves trusted child-span continuation plus untrusted fallback.

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

Not applicable as a defect reproduction: this PR adds a new HTTP trace-continuation capability, and the supplied focused tests describe the intended trusted and fallback behavior.

Is this the best way to solve the issue?

Unclear: reusing gateway.trustedProxies and standard W3C trace context is a narrow design, but maintainers must first confirm that inbound context continuation is an intended Gateway capability and require real boundary proof.

AGENTS.md: unclear because the file could not be read completely.

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

Labels

Label justifications:

  • P3: This is an optional observability enhancement rather than a regression in the default Gateway request path.
  • merge-risk: 🚨 security-boundary: The patch changes when Gateway trusts a caller-provided diagnostic context, making correct direct-peer validation and proxy sanitization merge-critical.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports focused tests and CI but supplies no redacted after-fix real Gateway/proxy run, terminal output, runtime logs, recording, or artifact showing a trusted upstream trace becoming an OpenClaw child span; add that evidence and redact private addresses and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Active linked implementation: The PR body explicitly links the open feature request and the related issue remains open, so this branch is an implementation candidate rather than an already-resolved duplicate. (3ed68b4ff3e5)
  • Changed security boundary: The branch gates inbound trace continuation on a parsed traceparent plus the direct peer matching gateway.trustedProxies, preserving a fresh trace on invalid or untrusted input. (src/gateway/server-http.ts:530, 3ed68b4ff3e5)
  • Focused coverage reported: The PR adds focused request-trace coverage for fresh traces, trusted continuation, untrusted-peer fallback, and malformed-header fallback; the supplied check digest also reports successful repository checks. (src/gateway/server-http.request-trace.test.ts:37, 3ed68b4ff3e5)
  • Proof gate remains unmet: The previous completed ClawSweeper review requested a redacted after-fix Gateway/proxy run, and the supplied PR body contains tests and CI claims but no live run, runtime log, terminal capture, recording, or linked artifact demonstrating the upstream parent and OpenClaw child span. (3ed68b4ff3e5)
  • Branch provenance: The head commit refreshes the generated docs map after the feature and test commits; current GitHub metadata reports the PR as cleanly mergeable but behind main, not merged or released. Public docs: docs/docs_map.md. (docs/docs_map.md:3777, 3ed68b4ff3e5)

Likely related people:

  • moria97: Authored the linked design request and all six commits in this focused trace-context branch; current-main ownership history could not be established from the available read-only inspection path. (role: trace-context proposal and branch author; confidence: low; commits: 325909b3734d, 7af1c7ba548b, 3ed68b4ff3e5; files: src/gateway/server-http.ts, src/gateway/server-http.request-trace.test.ts, docs/gateway/opentelemetry.md)

Rank-up moves

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

  • Post a redacted real proxy-or-orchestrator to Gateway trace capture showing the upstream trace ID and a distinct OpenClaw child span, plus an untrusted-peer fresh-trace result.
  • Ask a Gateway owner to confirm the HTTP-only trusted-proxy propagation scope 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-25T14:59:19.402Z sha 3ed68b4 :: needs real behavior proof before merge. :: none

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Aug 28, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@openclaw-barnacle openclaw-barnacle Bot closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Continue trusted HTTP trace context

1 participant