Skip to content

fix(gateway): stop inferring forwarded senders from text - #138579

Merged
obviyus merged 3 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-138493-provenance-sender
Sep 16, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-138493-provenance-sender

Conversation

@LiuwqGit

@LiuwqGit LiuwqGit commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: #138493

What Problem This Solves

Forwarded history could turn a sender asserted in text into another agent's chip and session link.

Why This Change Was Made

This state has one writer: the shared history projection. Only structured provenance identifies the sender. This removes the legacy text fallback from #132054.

User Impact

Unknown sources show “Forwarded message.” Recorded sources keep their chip, color, and navigation.

Evidence

A released Gateway’s public agent requests created historical rows; current doctor --fix imported them. HTTP history and WebSocket chat.history invented a source on main; the fix returns generic attribution without senderSession. Five-page history, access denial, current sessions_send, source navigation, and byte preservation passed.

Before After
Text-only source incorrectly shows a helper chip Text-only source is generic; recorded source keeps its helper chip

Compatibility

No stored-data, schema, protocol, config, or import change. Wider provenance design remains in #138493.

Consumers

HTTP, WebSocket, and Control UI share the projection.

Invalidation

Existing history refresh and grouping rules remain.

Tests

The registered HTTP/WebSocket regression covers recorded, asserted, and malformed sources over three pages. It fails on main and passes with the fix. Five selected correction checks pass.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This restores the correct authority boundary: displayed sender identity must come from producer-owned structured provenance, never from relayed message text that can assert an arbitrary sourceSession. Removing the prompt-header fallback prevents false native attribution while preserving the existing generic forwarded-message presentation when provenance is absent. The dual-transport regression is the important one here.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 16, 2026, 4:16 AM ET / 08:16 UTC (Revision 7).

ClawSweeper review

What this changes

Forwarded chat history derives sender labels and session links only from structured provenance, with regression coverage across HTTP, WebSocket, and pagination.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: the attribution defect remains on current main and the latest release, and this focused patch addresses it without a correctness finding. Recorded Gateway results support the repair, but required before/after UI screenshots are no longer attached.

Priority: P2
Reviewed head: b5b487ce1df5a1a42bba43999e4d96085c43c862

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and boundary regression are sound, but required visual evidence delivery remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Recorded real-Gateway HTTP and WebSocket results show generic attribution for source-less rows and retained structured senders, with historical-import and current-send observations in the body. That runtime evidence is preserved; the remaining gap is the required published before/after Control UI screenshots, whose attachments the contributor reports expired. 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 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Recorded real-Gateway HTTP and WebSocket results show generic attribution for source-less rows and retained structured senders, with historical-import and current-send observations in the body. That runtime evidence is preserved; the remaining gap is the required published before/after Control UI screenshots, whose attachments the contributor reports expired. 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 11 items Introduced repair: The pinned merge-base-to-head delta removes text-header sender inference. The projection retains its existing generic label and only constructs senderSession from normalized structured provenance.
Current main still needs the fix: The fetched main implementation still falls back to extractPromptPrefixField(text, "sourceSession") when structured provenance lacks a source key.
Latest-release check: The v2026.9.4 source retrieved through GitHub's contents API also retains the text-header fallback; this is not an already-shipped fix.
Findings None None.
Security None None.

How this fits together

The Gateway converts stored conversation messages into display history consumed by HTTP, WebSocket, and the Control UI. Forwarded-message attribution determines which agent label and source-session link users see.

flowchart LR
  A[Stored forwarded message] --> B[Shared history projection]
  B --> C{Structured source present?}
  C -->|Yes| D[Recorded sender and session link]
  C -->|No| E[Generic forwarded label]
  D --> F[HTTP and WebSocket history]
  E --> F
  F --> G[Control UI conversation]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Recorded real-Gateway HTTP and WebSocket results show generic attribution for source-less rows and retained structured senders, with historical-import and current-send observations in the body. That runtime evidence is preserved; the remaining gap is the required published before/after Control UI screenshots, whose attachments the contributor reports expired. 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) - The recorded transport proof remains useful, but the required before/after UI screenshot delivery cannot be verified after the attachments expired.
  • Complete next step (P2) - Restore inspected, sanitized before/after screenshots in the originating chat and PR body or a body-linked comment, verifying both render; redact private data. Keep the draft pause until its owner marks it ready. Updating the proof in the body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

PR surface

Source -14, Tests +83. Total +69 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 16 -14
Tests 2 86 3 +83
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 88 19 +69

Review metrics

None.

Mantis proof suggestion

Targeted web UI chat evidence could replace the expired screenshots and verify the affected sender chips. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis verify before/after web UI chat attribution for a source-less forwarded message asserting another session and a message with structured provenance; return redacted screenshots and navigation observations.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep attribution in the shared projection, preserve stored messages, and render unknown sources generically while leaving broader claimed-origin and adopter semantics to the linked issue.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep attribution in the shared projection, preserve stored messages, and render unknown sources generically while leaving broader claimed-origin and adopter semantics to the linked issue.

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

Yes, from source: a sessions_send history row with no structured source key but an asserted sourceSession header receives that asserted sender on current main. This review did not execute the runtime; the contributor records matching before/after Gateway observations.

Is this the best way to solve the issue?

Yes. Removing the fallback at the shared projection uses the existing generic presentation and preserves normal structured attribution without rewriting persisted history.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: False forwarded-message attribution is a bounded history-presentation defect without a demonstrated delivery or authorization failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Recorded real-Gateway HTTP and WebSocket results show generic attribution for source-less rows and retained structured senders, with historical-import and current-send observations in the body. That runtime evidence is preserved; the remaining gap is the required published before/after Control UI screenshots, whose attachments the contributor reports expired. 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:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Restore sanitized before/after screenshots showing generic unknown-source attribution and preserved structured-source navigation, and verify they render in the originating chat and PR.

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 (6 earlier review cycles)
  • reviewed 2026-09-04T21:14:17.638Z sha 4a610d4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T02:08:36.004Z sha 33f3ccd :: blocked before merge. :: none
  • reviewed 2026-09-10T18:19:03.118Z sha c726585 :: blocked before merge. :: none
  • reviewed 2026-09-10T18:28:20.129Z sha c726585 :: blocked before merge. :: none
  • reviewed 2026-09-13T00:01:33.925Z sha 01c5b5a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T00:11:20.245Z sha 01c5b5a :: needs maintainer review before merge. :: none

@cubefarm-trogdor

Copy link
Copy Markdown

@openclaw-mantis verify web UI chat history renders a source-less forwarded relay generically while retaining the structured-provenance sender label when present.

@LiuwqGit

LiuwqGit commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Added the requested real behavior proof (33f3ccd):

  • New e2e proof test/pr138493-forwarded-attribution-real-gateway.e2e.test.ts boots a real Gateway server (loopback, token auth), seeds persisted transcripts through the repo's session persistence layer, and issues real chat.history requests over both transports — the WebSocket RPC and the HTTP /sessions/<key>/history endpoint.
  • Fixture rows: one forwarded message with structured provenance (sourceSessionKey: agent:helper:ops), one source-less row whose prompt text asserts sourceSession=agent:grimwald:secret-ops. All data is synthetic; nothing to redact.
  • After fix: real responses show senderLabel: "Forwarded from helper" + senderSession for the structured row, and senderLabel: "Forwarded agent message" with no senderSession (asserted origin appears nowhere) for the source-less row — on both transports.
  • Before (RED): with only src/gateway/chat-display-projection.history.ts restored to origin/main, the same real Gateway run renders the asserted origin: expected 'Forwarded from grimwald' to be 'Forwarded agent message'.
  • pnpm check:test-types and pnpm tsgo:core pass with the new test file.

PR body Evidence section updated accordingly (proof tier L3).

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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. labels Sep 5, 2026
@obviyus obviyus self-assigned this Sep 10, 2026
@obviyus
obviyus requested review from a team and steipete as code owners September 10, 2026 18:11
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Sep 10, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line labels Sep 10, 2026
Use structured source provenance for forwarded history attribution. Keep
legacy entries with unknown sources generic, without changing their stored
messages. Preserve both public history transports and paging under the
existing shared Gateway test harness.

Related: openclaw#138493
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (8fd40f48bb02) and force-pushed as a single clean commit (01c5b5a9abf), replacing the stale test-merge head.

Two housekeeping items addressed:

  1. CI red cleared: the checks-node-compact-small-8 failure was the sessions.delete keeps the Gateway responsive timing flake (expected 509.98ms < 500), unrelated to this PR's projection change; upstream has since moved client setup before the sampling window, so the rebase picks up that repair.
  2. Screenshot 404 (the open P2 merge-risk item): both linked user-attachments are no longer hosted. The PR body Evidence section now quotes the recorded real-Gateway transport output (before: Forwarded from grimwald + asserted senderSession on both HTTP and WebSocket; after: Forwarded agent message, no senderSession) instead of the dead images.

Re-validation on the rebased tree: validate.sh on all three changed files is fully green — 98 focused gateway tests pass (including attributes forwarded history only from structured provenance across transports and pages through the maintained real HTTP + WebSocket harness) and tsgo:core passes.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@LiuwqGit

Copy link
Copy Markdown
Contributor Author

Body restored to the maintainer-edited version verbatim; my earlier edit had rewritten parts of it. The only changes now are the 404 screenshot table replaced with the equivalent recorded transport output, and one line noting the rebase onto current main.

@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-admin-merge
pr: 138579
head: d191933
scope: owner-review

@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks @LiuwqGit!

Proof: Imported historical messages show generic attribution for text-only sources and preserve recorded sender links in history and the chat interface.

  • Bug: A text header could invent another agent's sender chip and session link.
  • Fix: The shared history projection uses recorded source metadata for attribution.
Before After
A text-only source created a named sender and link. Unknown sources stay generic; recorded sources stay linked.

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

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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.

4 participants