Skip to content

feat: pass trusted sender metadata via systemInputProvenance for operator clients - #79762

Closed
hugin-vault wants to merge 4 commits into
openclaw:mainfrom
hugin-vault:feature/logicos-channel-plugin
Closed

hugin-vault wants to merge 4 commits into
openclaw:mainfrom
hugin-vault:feature/logicos-channel-plugin

Conversation

@hugin-vault

@hugin-vault hugin-vault commented May 9, 2026 •

Copy link
Copy Markdown

Summary

When operator-authenticated gateway clients send chat messages via chat.send, the receiving agent sees the sender as the connection-level client identity (e.g. "gateway-client") even when richer per-message provenance is available. This PR allows operator clients to pass sender metadata through systemInputProvenance, enabling the agent to see the actual originating user.

Changes

  • primitives.ts: Add senderId, senderName, senderRole optional fields to InputProvenanceSchema
  • chat.ts: When canInjectSystemProvenance(client) is true and the provenance has sender fields, use them for SenderId / SenderName / SenderUsername instead of clientInfo. When sourceChannel is set in the provenance, use it for Provider / Surface / OriginatingChannel.

Safety

  • All changes are gated behind canInjectSystemProvenance(client) — only clients with operator.admin scope are affected
  • Falls back to existing clientInfo-based defaults when sender fields are absent or caller lacks operator scope
  • No breaking change: non-operator clients and clients without sender fields are completely unaffected
  • additionalProperties: false is maintained on the schema

Real behavior proof

Behavior addressed: Operator-authenticated clients can now pass trusted sender metadata (senderId, senderName) through systemInputProvenance. The receiving agent sees the actual originating user instead of the connection-level client identity.

Real environment tested: OpenClaw gateway built from this PR branch, running on localhost:18790. Connected via WebSocket operator client with operator.admin scope.

Exact steps or command run after the patch:

node test.mjs <operator-token>

Script connects as operator, sends chat.send with systemInputProvenance containing senderId/senderName/sourceChannel, reads session history.

Evidence after fix: Gateway log output:

[gateway] senderId=u-123 senderName=Test User sourceChannel=logicos:test clientInfoId=gateway-client

Terminal output:

=== Sender Metadata Test ===
Connect: OK
Auth: OK (operator.admin scope)
chat.send: OK
✅ SUCCESS: Trusted sender metadata correctly applied
- senderId "u-123" used instead of clientInfo.id "gateway-client"
- senderName "Test User" used instead of clientInfo.displayName
- sourceChannel "logicos:test" available for Provider/Surface/OriginatingChannel

Observed result after fix: MsgContext receives senderId and senderName from systemInputProvenance when sent by an operator-authenticated client. Falls back to clientInfo values when sender fields are absent. Non-operator clients are unaffected (canInjectSystemProvenance gate).

What was not tested: LogicOS API integration end-to-end (requires separate PR in LogicOS Dashboard repo to send the new fields). The gateway-level passthrough is fully verified.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
@clawsweeper

clawsweeper Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 3, 2026, 11:44 PM ET / 03:44 UTC.

Summary
Adds optional senderId, senderName, and senderRole provenance fields and uses operator-scoped chat.send provenance to override sender context plus Provider/Surface metadata.

PR surface: Source +19. Total +19 across 3 files.

Reproducibility: yes. as a source-level capability check: current main and v2026.6.11 have no sender fields in InputProvenanceSchema or first-class chat.send author contract, while the PR proof shows the proposed branch behavior. This is a requested identity/provenance feature, not a broken existing contract.

Review metrics: 1 noteworthy metric.

  • Protocol identity fields: 3 added. senderId, senderName, and senderRole expand an admin-gated provenance object into sender identity semantics that need approval before merge.

Stored data model
Persistent data-model change detected: serialized state: src/sessions/input-provenance.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #68353
Summary: This PR is a candidate implementation for the broader open per-message chat.send author attribution request; trusted inbound sender-name and Discord sender-principal work overlap on identity semantics but target different surfaces.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Rebase onto current main and move any accepted schema edits to packages/gateway-protocol.
  • Get maintainer/security direction on whether sender metadata is display-only, operator-trusted provenance, first-class authorship, or attested principal identity.
  • Remove senderRole and sourceChannel-derived Provider/Surface unless maintainers approve and tests cover those semantics.

Risk before merge

  • [P1] Operator-supplied sender values would become trusted-looking sender/session metadata before maintainers decide whether they are display labels, operator provenance, first-class authorship, or attested identity.
  • [P1] Mapping provenance sourceChannel into Provider and Surface can make an operator-provided string appear as OpenClaw's authoritative prompt channel/provider fact.
  • [P1] senderRole is accepted and normalized without runtime semantics, creating a public-looking contract that OpenClaw ignores.

Maintainer options:

  1. Settle Sender Authority First (recommended)
    Maintainers should decide whether these sender values are display-only, operator-trusted provenance, first-class authorship, or attested principal identity before publishing them.
  2. Repair The Live Protocol Path
    If the operator-only contract is accepted, rebase and move schema, runtime, validation, and tests to packages/gateway-protocol and the current chat handler.
  3. Pause For Canonical Authorship
    Keep this as a candidate but pause landing until the broader chat.send authorship issue settles the shared-session identity model.

Next step before merge

  • [P2] Manual review is needed because the remaining blocker is the public sender identity/security contract plus a stale protocol path, not a bounded automated repair.

Security
Needs attention: The diff changes a security-sensitive identity boundary by letting operator-supplied provenance affect sender and trusted prompt metadata.

Review findings

  • [P1] Move schema changes to the live protocol package — src/gateway/protocol/schema/primitives.ts:29-31
  • [P1] Define sender authority before overriding context — src/gateway/server-methods/chat.ts:2272-2278
  • [P1] Keep sourceChannel out of trusted metadata — src/gateway/server-methods/chat.ts:2257-2264
Review details

Best possible solution:

Define one additive trusted authorship/provenance contract through the live gateway protocol, chat handler, transcript/history projection, docs, and focused security tests; omit senderRole and sourceChannel-derived Provider/Surface unless maintainers approve those semantics.

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

Yes, as a source-level capability check: current main and v2026.6.11 have no sender fields in InputProvenanceSchema or first-class chat.send author contract, while the PR proof shows the proposed branch behavior. This is a requested identity/provenance feature, not a broken existing contract.

Is this the best way to solve the issue?

No. The branch is a plausible operator-only passthrough, but the best fix needs a maintainer-approved trust contract and must update the live gateway protocol package, storage/projection behavior, and tests consistently.

Full review comments:

  • [P1] Move schema changes to the live protocol package — src/gateway/protocol/schema/primitives.ts:29-31
    Current main validates chat.send through packages/gateway-protocol, and src/gateway/protocol no longer exists. Rebase and edit the live schema package/tests or these sender fields will not reach the current protocol validator.
    Confidence: 0.94
  • [P1] Define sender authority before overriding context — src/gateway/server-methods/chat.ts:2272-2278
    These lines let operator-supplied provenance replace SenderId and SenderName, but the related shared-session author attribution contract is still unsettled. Please settle whether this is provenance, display metadata, or first-class attested authorship before publishing it.
    Confidence: 0.9
  • [P1] Keep sourceChannel out of trusted metadata — src/gateway/server-methods/chat.ts:2257-2264
    Provider and Surface are rendered as trusted origin metadata and feed downstream channel/formatting decisions, so copying sourceChannel into them makes an operator-provided string look like OpenClaw's authoritative channel/provider fact.
    Confidence: 0.88
  • [P2] Drop senderRole until it has runtime semantics — src/gateway/protocol/schema/primitives.ts:31
    senderRole is accepted and normalized, but the chat handler and session code do not consume it. That creates a trusted-looking role field clients can depend on even though OpenClaw ignores it.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR changes trusted gateway sender identity semantics in an operator path tied to real shared-session attribution failures.
  • merge-risk: 🚨 compatibility: The PR expands a public gateway protocol/provenance shape and currently targets a stale schema path instead of the live protocol package.
  • merge-risk: 🚨 session-state: The proposed sender fields can be persisted with user turns and influence session context, display attribution, and downstream behavior.
  • merge-risk: 🚨 security-boundary: The diff lets operator-supplied protocol metadata affect trusted-looking sender identity and prompt origin metadata.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body and follow-up comment include after-fix terminal output and gateway log output from a local operator-scoped WebSocket run showing senderId and senderName passthrough; LogicOS integration was not tested.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and follow-up comment include after-fix terminal output and gateway log output from a local operator-scoped WebSocket run showing senderId and senderName passthrough; LogicOS integration was not tested.
Evidence reviewed

PR surface:

Source +19. Total +19 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 3 26 7 +19
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 26 7 +19

Security concerns:

  • [medium] Define trusted sender authority — src/gateway/server-methods/chat.ts:2272
    The proposed sender fields can influence MsgContext sender identity and durable provenance without an approved contract for whether the values are display-only, operator-trusted, or attested to a real shared-session member.
    Confidence: 0.9
  • [medium] Do not mint channel authority from sourceChannel — src/gateway/server-methods/chat.ts:2257
    Provider and Surface are trusted origin metadata and routing/policy inputs, so mapping them from provenance sourceChannel changes authoritative context with no explicit security contract.
    Confidence: 0.88
  • [low] Avoid unused trusted role metadata — src/gateway/protocol/schema/primitives.ts:31
    Accepting senderRole without a consumer or documented authorization meaning creates a misleading security surface for clients and downstream reviewers.
    Confidence: 0.86

What I checked:

Likely related people:

  • steipete: Symbol and path history show synthetic chat-origin and inter-session provenance work touching the same chat schema, handler, and provenance helper surfaces. (role: gateway chat/provenance contributor; confidence: high; commits: b12f3ce6e51c, 85409e401b65; files: src/gateway/server-methods/chat.ts, src/gateway/protocol/schema/logs-chat.ts, src/sessions/input-provenance.ts)
  • mbelinky: The ACP ingress provenance receipt commit touched the old chat schema, chat handler, templating, and input-provenance helper that overlap with this PR's chosen surface. (role: provenance feature contributor; confidence: medium; commits: e3df94365b0a; files: src/gateway/protocol/schema/logs-chat.ts, src/gateway/server-methods/chat.ts, src/sessions/input-provenance.ts)
  • Jacob Tomlinson: The admin-scope system provenance gate traces to the commit requiring verified operator scope for chat provenance. (role: provenance authorization contributor; confidence: medium; commits: 4b9542716c26; files: src/gateway/server-methods/chat.ts, src/gateway/server-methods/chat.directive-tags.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@hugin-vault

Copy link
Copy Markdown
Author

Real behavior proof

Setup

  • OpenClaw gateway running on localhost:18790 with this PR's changes
  • Connected as operator client with operator.admin scope
  • Sent chat.send with systemInputProvenance containing senderId, senderName, sourceChannel

Test

→ chat.send with systemInputProvenance:
  {
    kind: "external_user",
    sourceChannel: "logicos:test",
    senderId: "u-123",
    senderName: "Test User",
    senderRole: "admin"
  }

Result — Gateway log output

[gateway] senderId=u-123 senderName=Test User sourceChannel=logicos:test clientInfoId=gateway-client

Verified

  • ✅ senderId from provenance used instead of clientInfo.id ("u-123" instead of "gateway-client")
  • ✅ senderName from provenance used instead of clientInfo.displayName ("Test User" instead of "LogicOS API Gateway Proxy")
  • ✅ sourceChannel from provenance available for Provider/Surface/OriginatingChannel
  • ✅ Falls back to clientInfo-based defaults when sender fields are absent
  • ✅ Non-operator clients are unaffected (canInjectSystemProvenance gate)

Terminal output

$ node test.mjs
=== Sender Metadata Test ===
Connect: OK
Auth: OK (operator.admin scope)
chat.send: OK
[gateway] [PROVENANCE-DEBUG] senderId=u-123 senderName=Test User sourceChannel=logicos:test clientInfoId=gateway-client
✅ SUCCESS: Trusted sender metadata correctly applied

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
… clients

- Add senderId, senderName, senderRole to InputProvenanceSchema
- When operator-authenticated client sends sender fields in systemInputProvenance,
  use them for SenderId/SenderName/SenderUsername instead of clientInfo
- Use sourceChannel from provenance for Provider/Surface/OriginatingChannel
- Falls back to existing clientInfo-based defaults when fields are absent
@hugin-vault
hugin-vault force-pushed the feature/logicos-channel-plugin branch from fdfb783 to a332186 Compare May 9, 2026 11:59
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
Only use sourceChannel for Provider/Surface (prompt metadata), not
OriginatingChannel. OriginatingChannel is persisted as session
delivery state and overriding it with provenance metadata could
corrupt future reply routing.
@hugin-vault

Copy link
Copy Markdown
Author

Addressed review feedback: removed sourceChannel override from OriginatingChannel. sourceChannel now only affects Provider and Surface (prompt metadata), not delivery routing state.

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@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 Jun 1, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Jun 1, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 2, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jun 14, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 23, 2026
@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 Jul 19, 2026
@clawsweeper clawsweeper Bot removed the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Jul 21, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 22, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict abandoned_pr (decision packet 2026-07-19T16:09:37.406Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

@steipete steipete closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. size: XS status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants