Skip to content

Commit 97a53a9

Browse files
authored
feat: audit admitted channel participant identity (#122863)
* feat: audit admitted channel participant identity * fix: preserve Telegram identity through thread recovery * fix: signal held gateway process groups * fix: keep audit evidence passive in collect routing * fix: validate copied channel participant evidence * fix: bind channel participant evidence to host ingress * fix: honor Telegram proof credential roles * fix: restart held Telegram proof through gateway * fix: repair channel identity CI regressions * test(matrix): bind thread routing owner * fix: preserve direct DM SDK compatibility * fix: bind channel provenance at host runtime * test(feishu): provide channel context builder * fix: defer record-bound channel runtime resolution * fix: keep channel admission evidence core-private * fix(audit): bind channel admission to plugin lifecycle * fix(audit): bind ingress provenance to final context * refactor(audit): split admission scope keys * test(queue): cover combined metadata carriers * refactor(audit): keep lifecycle helpers private * fix(queue): preserve combined turn authority * test(channels): provide ingress context builders * test(channels): align integrated CI fixtures * test(clickclack): resolve model-loop ingress * docs: preserve channel participant evidence invariant
1 parent 8c7e86a commit 97a53a9

174 files changed

Lines changed: 6880 additions & 639 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Skills own workflows; root owns hard policy and routing. Product direction and m
177177
- Decision receipts adapt owner-native durable decisions directly; `execution_decision_facts` is only for boundaries without an owner-native record and must never duplicate approvals. The generic fact store stays dormant until an explicit product-boundary producer exists, and any producer requires an explicit operator retention opt-in; the 30-day retention bound does not authorize default collection. Receipt coverage `enforced` is diagnostic, not authority: emit it only when the owner changed the outcome and the exact context/execution/run tuple validates; otherwise keep it `unknown`.
178178
- Admission may only validate, bound, freeze, and enqueue through the shared audit writer. Admission validates only a recursively owned, enumerable, accessor-free data snapshot constructed from descriptors before schema checks or ordinary property reads; inherited properties are absent and accessors never run. No synchronous SQLite, schema, filesystem, HMAC-key, or readiness work. Audit failure never delays or aborts execution.
179179
- Raw identity references are transient worker-message data. Never persist, export, inspect, or log them. Public Plugin SDK ingress must strip private recovery/admission authority, including JavaScript extra and inherited properties.
180+
- Channel participant evidence is host-minted only from an exact active registered native-plugin resolver result and redeemed once against the finalized context plus plugin record/lifecycle epoch. Missing, copied, substituted, replayed, stale, scope-changed, or mixed evidence becomes `unknown`. Mixed participants may remove sender-derived authority only; never widen or erase independent tools, grants, routing, or approval authority.
180181
- Default or disabled collection creates and propagates no identity token and does not create optional storage. Existing-storage maintenance may continue. Reads enforce expiry before projection; missing or expired evidence never proves no run occurred.
181182
- `audit.run.inspect` intentionally uses `operator.read` within one trusted Gateway domain. Reader isolation requires separate domains. Ask before changing this scope, default-off behavior, retained fields, 30-day cutoff, maintenance/row bounds, or schema/protocol contract.
182183

‎docs/channels/qa-channel.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ Full repo-backed scenario suite:
7878
pnpm openclaw qa suite
7979
```
8080

81+
The isolated `channel-participant-identity-inspection` scenario enables
82+
execution identity before startup, exercises DM, group, senderless, same- and
83+
mixed-participant collect paths, proves an ingress rejection creates no audit
84+
rows, and compares JSON plus human CLI inspection across Gateway restart:
85+
86+
```bash
87+
pnpm openclaw qa suite --scenario channel-participant-identity-inspection
88+
```
89+
8190
Runs scenarios in parallel against the QA gateway lane. See [QA overview](/concepts/qa-e2e-automation) for scenarios, profiles, and provider modes.
8291

8392
Docker-backed QA site (gateway + QA Lab debugger UI in one stack):

‎docs/cli/audit.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ immutable connection-time audit fact. Ordinary session provenance stores no
135135
display label. An optional bounded, secret-redacted label can be retained only
136136
in execution identity after that audit storage is explicitly enabled.
137137

138+
An admitted channel run can also show a pseudonymized person invoker. The
139+
trusted active registered native plugin produces the remote participant fact;
140+
core verifies its exact record, registry epoch, scope, and one-shot handoff.
141+
The resulting `boundary-verified` assurance describes that in-process boundary,
142+
not an independent core query to the remote service. Identity never comes from
143+
the conversation, room, route, account, thread, message, transport, session
144+
key, or display name. A collected run shows the person only when all queued
145+
inputs carry valid evidence for the same participant; mixed or missing evidence
146+
shows an unknown invoker. Its `channel/admission` receipt is enforced only when
147+
the participant affected every contributing access decision; otherwise it is
148+
attribution-only.
149+
150+
For channel ingress, `unknown` means a supported integration could not supply
151+
valid host-bound evidence; it never means allowed. `unsupported` is reserved
152+
for a named path with no authoritative Phase 0 integration. A plugin-provided
153+
sender or structurally copied resolver result cannot upgrade either state.
154+
138155
A terminal approval receipt shows `allowed` or `denied`, its stable reason
139156
code, enforcement state, authoritative source boundary, policy and grant
140157
references, context fields used, and remediation. Expired and cancelled

‎docs/concepts/qa-e2e-automation.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,13 @@ Seed assets live in `qa/`:
11211121
- `qa/scenarios/index.yaml`
11221122
- `qa/scenarios/<theme>/*.yaml`
11231123

1124+
Identity-sensitive channel changes use the isolated
1125+
`channel-participant-identity-inspection` QA Channel flow. It drives a real
1126+
ephemeral Gateway and mock provider, then inspects admitted runs with the same
1127+
`openclaw audit --run ... --explain` JSON and human surfaces operators use.
1128+
The flow includes lifecycle-owned restart and a row-count check for rejected
1129+
pre-run ingress.
1130+
11241131
These are intentionally in git so the QA plan is visible to both humans and
11251132
the agent.
11261133

‎docs/gateway/audit.md‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,22 @@ state for these fields:
8686
- applicable grants and assurance evidence;
8787
- parent or child lineage when available.
8888

89-
The foundation records direct local CLI ingress and Gateway boot-system ingress
90-
at their authoritative producers. Generic public ingress remains explicitly
91-
unknown when its boundary cannot prove a more specific source; OpenClaw never
92-
infers ingress or invoker identity from a session key. A direct local execution
89+
The foundation records direct local CLI ingress, Gateway boot-system ingress,
90+
and admitted channel participants at their authoritative producers. For a
91+
channel run, the trusted active registered native plugin produces the remote
92+
participant fact. Core accepts it only across an exact record, registry epoch,
93+
scope, and one-shot handoff; the room, route, account, thread, message, and
94+
transport remain non-principal facts. `boundary-verified` describes that
95+
in-process boundary verification, not an independent core query to Telegram,
96+
Discord, or another remote service. Collected messages retain a person only
97+
when every contribution proves the same participant. Mixed, missing, invalid,
98+
stale, replayed, or unminted evidence is unknown, and an adapter that explicitly
99+
lacks support is unsupported. OpenClaw never reconstructs a participant from
100+
`SenderId`, `From`, session keys, or routing metadata. Plugins cannot publicly
101+
mint or upgrade participant evidence; fake, copied, changed, stale, reused, or
102+
lost host carriers remain unknown.
103+
Other public ingress remains explicitly unknown when its
104+
boundary cannot prove a more specific source. A direct local execution
93105
is `unattributed`: the Gateway cell, local CLI ingress, configured agent, and
94106
runtime binding are present, but no durable invoker principal is supplied at
95107
this boundary. A run becomes
@@ -115,6 +127,13 @@ is `not-applicable`, its policy and grant references are empty, and its reason
115127
states that no identity-aware policy or grant evaluation was proven. This is
116128
an explanation of admission evidence, not an enforcement claim.
117129

130+
Admitted channel runs also project a `channel/admission` decision receipt after
131+
their exact context/execution/run tuple is queued. Coverage is `enforced` only
132+
when every contributing ingress decision was participant-aware and
133+
outcome-affecting. Wildcard/open policy and explicit attribution-only adapters
134+
remain `attribution-only`; mixed or missing evidence is `unknown`. Identity and
135+
the corresponding decision share the existing audit-writer FIFO.
136+
118137
When the same `runId` has a retained terminal row in `operator_approvals`, the
119138
inspector also reads its owner-local `operator_approval_execution_identities`
120139
binding. Only an exact context, execution, and run tuple projects the approval

‎docs/plugins/sdk-channel-inbound.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ import {
3232
into the prompt/session context. Pass channel-owned sender/chat metadata
3333
through `channelContext`, which plugin hooks see as `ctx.channelContext`.
3434
Augment `PluginHookChannelSenderContext` or `PluginHookChannelChatContext`
35-
from this subpath for channel-specific fields.
35+
from this subpath for channel-specific fields. This public standalone builder
36+
is non-authoritative and cannot mint participant evidence. Bundled production
37+
receive paths use the host-injected registered
38+
`runtime.channel.inbound.buildContext` and pass the exact resolver result as
39+
`channelIngress`. Resolve that result with `contextBinding` after final route
40+
selection. Core accepts it once only when the same active plugin record,
41+
lifecycle epoch, agent, session, message, event, and admission scope still
42+
match; receive paths must not rebuild participant provenance from context fields. Only a named,
43+
source-proven unsupported path passes `channelIngress: "unsupported"`.
3644
- `runChannelInboundEvent(...)`: runs ingest, classify, preflight, resolve,
3745
record, dispatch, and finalize for one inbound platform event.
3846
- `dispatchChannelInboundReply(...)`: records and dispatches an already

‎docs/plugins/sdk-channel-ingress.md‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const result = await resolveChannelMessageIngress({
3636
identity,
3737
subject: { stableId: platformUserId },
3838
conversation: { kind: isGroup ? "group" : "direct", id: conversationId },
39+
contextBinding: {
40+
agentId: agentRoute.agentId,
41+
sessionKey: agentRoute.sessionKey,
42+
messageId,
43+
inboundEventKind: "user_request",
44+
},
3945
event: { kind: "message", authMode: "inbound", mayPair: !isGroup },
4046
policy: {
4147
dmPolicy: config.dmPolicy,
@@ -49,12 +55,27 @@ const result = await resolveChannelMessageIngress({
4955
readStoreAllowFrom,
5056
command: hasControlCommand ? { allowTextCommands: true, hasControlCommand } : undefined,
5157
});
58+
59+
const ctx = runtime.channel.inbound.buildContext({
60+
// Pass the exact host result; do not rebuild participant evidence from
61+
// SenderId, From, session keys, routes, rooms, or message metadata.
62+
channelIngress: result,
63+
// ...normalized channel facts
64+
});
5265
```
5366

5467
Do not precompute effective allowlists, command owners, or command groups.
5568
The resolver derives them from raw allowlists, store callbacks, route
5669
descriptors, access groups, policy, and conversation kind.
5770

71+
For a result that will enter a host context, resolve after the channel's route
72+
owner has selected the final agent and session. `contextBinding` freezes those
73+
facts with the stable transport message id (when present) and final inbound
74+
event kind. Decision-only checks may omit it, but such a result is not valid
75+
execution provenance and must not be passed as `channelIngress`. When a channel
76+
batches several admitted messages, pass their exact results in source order;
77+
the finalized context message id identifies the last source result.
78+
5879
## Result
5980

6081
Bundled plugins should consume modern projections directly:
@@ -74,6 +95,37 @@ Deprecated third-party SDK helpers may rebuild older shapes internally. New
7495
bundled receive paths should not translate modern results back into local
7596
DTOs.
7697

98+
When execution-identity audit collection is enabled, a trusted active native
99+
plugin is the authoritative in-process producer of its remote participant
100+
fact. The host-injected registered runtime binds the resolver result to the
101+
exact plugin record and registry lifecycle epoch, then validates its complete
102+
available conversation, route, agent, session, message, event, and participant scope during a
103+
one-shot context handoff. The public standalone builder remains
104+
non-authoritative and cannot mint participant evidence.
105+
Queue collection retains attribution only when every contribution has valid
106+
evidence for the same participant; mixed, missing, stale, or unminted evidence
107+
is `unknown`. The carrier is opaque, bounded, one-shot, and diagnostic only.
108+
Plugins cannot mint participant evidence from caller-chosen sender, account,
109+
room, route, session, message, or transport fields. The SDK intentionally
110+
exposes no record, epoch, owner capability, participant-evidence constructor,
111+
or evidence copier. A structurally similar result, stale record, reused result,
112+
or scope-changed context does not gain host authority.
113+
114+
`boundary-verified` means core verified that the participant fact crossed this
115+
trusted active registered native-plugin boundary with the exact record, epoch,
116+
scope, and one-shot handoff. It does not mean core independently queried the
117+
remote service; only the channel plugin can observe that transport fact.
118+
119+
The audit states are distinct:
120+
121+
- **supported**: the authoritative ingress resolver ran. Its exact result can
122+
yield a present invoker and enforced or attribution-only coverage.
123+
- **unknown**: a supported handoff was missing, stale, fake, reused, mixed, or
124+
otherwise failed host validation. Unknown never means allowed.
125+
- **unsupported**: a named path has no Phase 0 authoritative integration and
126+
explicitly passes `channelIngress: "unsupported"`. Unsupported never means
127+
allowed and is not a shortcut for incomplete wiring.
128+
77129
## Access groups
78130

79131
`accessGroup:<name>` entries stay redacted. Core resolves static

‎docs/plugins/sdk-channel-plugins.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ the resolved state or decision. See
118118
[Channel ingress API](/plugins/sdk-channel-ingress) for the API design,
119119
ownership boundary, and test expectations.
120120

121+
Pass the exact resolver result to the host-injected registered context builder
122+
as `channelIngress`. Results used for execution must include the final
123+
agent/session/message/event `contextBinding`; decision-only resolver calls may
124+
omit it. This preserves the native plugin's record-, epoch-, and scope-bound participant evidence through one-shot queued run admission without
125+
exposing it in message context fields. The standalone public builder is not an
126+
authoritative substitute. Never reconstruct evidence from sender, route, room,
127+
account, thread, message, transport, or session values. Legacy adapters can explicitly pass
128+
`channelIngress: "unsupported"` only when the path is source-proven to lack an
129+
authoritative Phase 0 integration. Supported paths must pass the exact result;
130+
omission is invalid production wiring. Missing, fake, stale, reused, or mixed
131+
supported evidence projects as unknown, never as an allow signal.
132+
121133
### Durable ingress and replay dedupe
122134

123135
Channels adopting durable ingress should use `createChannelIngressMonitor`

‎extensions/buzz/src/gateway.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { PluginRuntime } from "openclaw/plugin-sdk/channel-core";
12
import { waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
23
import { attachChannelToResult } from "openclaw/plugin-sdk/channel-send-result";
34
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
@@ -59,6 +60,8 @@ function resolveBuzzProfileName(params: {
5960
}
6061

6162
export async function startBuzzGatewayAccount(ctx: ChannelGatewayContext<ResolvedBuzzAccount>) {
63+
const channelRuntime = ctx.channelRuntime as PluginRuntime["channel"] | undefined;
64+
const buildContext = channelRuntime?.inbound.buildContext;
6265
const account = resolveBuzzAccount({
6366
cfg: ctx.cfg,
6467
accountId: ctx.account.accountId,
@@ -103,7 +106,14 @@ export async function startBuzzGatewayAccount(ctx: ChannelGatewayContext<Resolve
103106
if (!isConfiguredBuzzChannel(configuredChannelIds, message.channelId)) {
104107
return;
105108
}
106-
await handleBuzzInbound({ account, cfg: ctx.cfg, bus: sessionBus, message, signal });
109+
await handleBuzzInbound({
110+
account,
111+
cfg: ctx.cfg,
112+
bus: sessionBus,
113+
message,
114+
signal,
115+
buildContext,
116+
});
107117
},
108118
onMessageError: (error) => {
109119
ctx.log?.error?.(`[${account.accountId}] Buzz message failed: ${error.message}`);

‎extensions/buzz/src/inbound.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { buildChannelInboundEventContext } from "openclaw/plugin-sdk/channel-inbound";
2+
import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
13
// Buzz tests cover inbound room admission, mention gating, and reply delivery.
24
import { createPluginRuntimeMock } from "openclaw/plugin-sdk/channel-test-helpers";
35
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
@@ -13,6 +15,22 @@ import {
1315
import { setBuzzRuntime } from "./runtime.js";
1416
import type { ResolvedBuzzAccount } from "./types.js";
1517

18+
vi.mock("openclaw/plugin-sdk/channel-inbound", async (importOriginal) => {
19+
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/channel-inbound")>();
20+
return {
21+
...actual,
22+
buildChannelInboundEventContext: vi.fn(actual.buildChannelInboundEventContext),
23+
};
24+
});
25+
vi.mock("openclaw/plugin-sdk/channel-ingress-runtime", async (importOriginal) => {
26+
const actual =
27+
await importOriginal<typeof import("openclaw/plugin-sdk/channel-ingress-runtime")>();
28+
return {
29+
...actual,
30+
resolveStableChannelMessageIngress: vi.fn(actual.resolveStableChannelMessageIngress),
31+
};
32+
});
33+
1634
const ROOM_ID = "b25b8e40-eb1a-43a4-b56b-30a4e16df586";
1735
const BOT_PUBLIC_KEY = "a".repeat(64);
1836
const SENDER_PUBLIC_KEY = "b".repeat(64);
@@ -112,6 +130,11 @@ describe("handleBuzzInbound", () => {
112130
GroupSubject: ROOM_ID,
113131
});
114132
expect(firstDispatch(runtime).ctxPayload.GroupChannel).toBeUndefined();
133+
const resolverResult = await vi.mocked(resolveStableChannelMessageIngress).mock.results[0]
134+
?.value;
135+
expect(vi.mocked(buildChannelInboundEventContext).mock.calls[0]?.[0].channelIngress).toBe(
136+
resolverResult,
137+
);
115138
});
116139

117140
it("uses current Buzz labels without changing the stable sender identity", async () => {

0 commit comments

Comments
 (0)