Skip to content

feat(line): approve exec, plugin, and OpenClaw-change requests from a card in LINE - #147255

Open
edenfunf wants to merge 27 commits into
openclaw:mainfrom
edenfunf:feat/line-native-approvals
Open

edenfunf wants to merge 27 commits into
openclaw:mainfrom
edenfunf:feat/line-native-approvals

Conversation

@edenfunf

@edenfunf edenfunf commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #104521

What Problem This Solves

When an operator is asked in LINE to approve a command, they have to copy the approval ID out of a text prompt and type /approve <id> <decision> back. Discord, Slack, Telegram, Matrix, and other channels give them a button instead.

User Impact

Cards are added on top of what LINE does today; they never replace it.

  • Until cards are on for an approval type, LINE approves as it does on main, except that typed /approve is now scoped to the LINE account (see "Typed /approve now reaches the Gateway" below). Cards are on when forwarding is session or both in approvals.exec / approvals.plugin and approvers are listed in channels.line.allowFrom. Until then, a request raised from a LINE chat stays pending, /approve <id> <decision> from that chat decides it, and command authorization decides who may. Listing users in allowFrom for DM access does not restrict /approve.
  • Who approves: the U user IDs written in channels.line.allowFrom. Users admitted through pairing or accessGroup: entries are not approvers. Every listed approver gets every card and outcome notice, and each is a push that counts against the monthly message quota.
  • With cards on, each approver gets a Flex card in their LINE chat for a request raised from a LINE conversation and decides with one tap. The outcome is posted as a new message naming who decided.
    • A request raised in an approver's own chat keeps the card there. A group, or another user's chat, is told the request went to LINE DMs.
    • LINE group postbacks carry no user ID, so cards never go to groups.
    • While the account's card handler is running, a chat that gets the card or that notice does not also get the forwarded text prompt. Other forwarding targets, such as an operations group, still get it. If the handler is not running, every forwarded prompt is delivered.
  • Behavior change once cards are on: only listed approvers decide that approval type from LINE, typed /approve included. Some setups already forward approvals in session mode and list DM users in allowFrom; upgrading turns cards on for them. Group members outside allowFrom then lose typed /approve for that type until they are listed.
  • Typed /approve now reaches the Gateway with the sender's LINE identity, whether or not cards are on. As on the other channels with approver authorization, it decides only exec and plugin requests that belong to that LINE account, meaning requests raised from it or forwarded to it. A request raised in the Control UI or on another channel is approved where it was raised; on main, /approve from LINE could decide it. Typed /approve never handled OpenClaw-change approvals; those are decided with their card (fix(channels): make system-agent approval cards actionable #147152) or from the Control UI.
  • Forwarding changes need a Gateway restart for cards. Card delivery reads forwarding when the channel starts. If no approval type had cards on at start, forwarded text prompts keep arriving. Otherwise, until the restart, a request raised from a LINE chat that only the new settings would send as a card gets core's notice naming the /approve command instead (for an OpenClaw-change approval, decide from the Control UI). A channels.line change, such as removing an approver, takes effect once active runs and replies finish.

Why This Change Was Made

LINE already carries typed callback data through postbacks for ask_user (#133421), so approval decisions can use the same transport instead of the text-only fallback. This change wires LINE into the existing approver-restricted native approval capability.

Forwarded prompts. LINE uses the SDK's forwarding suppressor, which reports the origin chat and approver DMs as reached by a card or routed notice and every other target as not reached. Since #148228, core applies that answer only while a native approval runtime for the account is active, so a handler that failed to start or was never registered no longer takes the prompt away. After a forwarding change without a restart, the handler keeps its start configuration and can decline a request whose prompt core still suppresses. For a request raised from a LINE chat, core then reports the owner as unavailable and posts its /approve notice in that chat (live run below), so I did not add a per-request check in core: it would send the full prompt and an outcome notice next to that notice.

Availability. Approval availability stays enabled on every LINE chat. A disabled state makes the Gateway expire any request that no other client holds, which would take away the same-chat /approve that LINE chats have on main. Approver authorization uses the same predicate as card delivery, so allowFrom narrows who decides only where cards are on. Elsewhere, LINE returns implicit same-chat authorization and command authorization keeps deciding, as before.

Typed /approve where cards are on. It is restricted to listed approvers too, rather than staying on command authorization while only card taps are restricted. Right before writing a decision, Gateway custody checks LINE's authorizeActorAction against the live config, for taps and typed /approve alike, and the hook cannot tell the two apart. If typed /approve stayed on command authorization, the hook would return same-chat authorization for every LINE sender. Custody would then stop checking the approver list at write time, and a tap from someone just removed or replaced as an approver could still be written. Keeping existing typed rights without that trade-off needs either maintainer acceptance of the upgrade restriction (the step c2cbdea28cf took for other shipped channels) or an explicit opt-in setting, which is a new config key.

Button tags. Each decision button on a card carries a tag derived from the sending account's channel secret. The key is derived under a fixed label, the way Mattermost derives its interaction secret from the bot token. A tap decides only when its tag verifies against the secret that verified the webhook carrying it. Postback data from any other button that merely reuses the approval parameters decides nothing: it is logged as a warning and answered with a fixed notice that repeats none of the data. Without a channel secret, no card is drawn and the approver gets the approval command text.

After a channel secret change, a tap on an earlier card decides nothing. It replies that the button could not be verified, and points to the Control UI, or to /approve with the ID shown on the card for exec and plugin approvals. Approvals still waiting are not sent again as new cards: each approval's route is chosen once, so a handler restarted with the new secret does not take over approvals raised before it started. A card or fallback text that fails to send is logged at error level, since it stands in for a prompt that native delivery suppressed.

Card size. A Flex bubble LINE rejects takes the whole card away and leaves the approver with the command text, and an approval body carries a command, a working directory, and a host line that no single field owns. The builder therefore shrinks the body as one region until the bubble fits, keeping the approval ID in what it retains, instead of capping one field and hoping the rest fits (#135229 is the same platform limit hit from the reply path).

Tap authorization. A card tap decides only for a listed approver. It checks authority against the configuration current just before the decision is sent (after the lazy Gateway import, not when the tap arrived). It treats implicit same-chat authorization as "use /approve", following the SDK rule for native callbacks in docs/plugins/sdk-channel-plugins/approvals.md. For an OpenClaw-change approval, which typed /approve cannot decide, that fallback, the Gateway-error fallback, and the text sent when a card cannot be drawn or sent point to the Control UI instead of a command that would fail.

Remaining custody window. One window remains outside this PR. The Gateway's custody check re-reads live config but does not distinguish implicit same-chat authorization, so a tap already on its way to the Gateway when the last approver is removed could still be written. Custody cannot simply refuse same-chat authorization, because typed /approve without approvers depends on it. The reviewer identity sent to the Gateway (channel, account, sender) also has no field that tells a typed command from a native button. Closing the window therefore needs a core change for every channel. In practice, removing an approver is a channels.line change, and the Gateway does not publish it while runs and Gateway requests are active (live log below), up to its restart deferral timeout.

LINE cannot edit sent messages, so the terminal state is published as a new message. A later tap on an old card replies that the approval is no longer waiting.

lineQuestionOutcomeNotice moved from bot-handlers.ts to question-postback.ts to keep bot-handlers.ts under the max-lines limit after the approval branch was added.

Evidence

Live on a LINE test channel, with the Gateway built from this branch and a local model stand-in issuing an exec tool call (the test rig has no model credentials). The first two blocks run on the merge of this branch with current main, with nothing patched: the ingress failure that earlier runs had to work around locally is fixed on main by #148548. The blocks below them are from earlier heads and say so.

Current head on plain main: one card instead of a prompt to retype, and today's behavior next to it

Each run is its own Gateway (own state dir and port), with injected signed webhook events from the operator's DM and real pushes. Two bounded observables: the channel's monthly push consumption, and a local diagnostic printed after each successful LINE send that names the message type.

With approvers listed (approvals.exec session, allowFrom = operator), request raised in the approver's DM:

step pushes what went out
request raised +1 [line-wire] push ok n=1 types=flex text="Exec Approval Required: date"
decided (deny) +2 ✅ Exec approval deny. Resolved by cli. ID: e372af9b-…, then exec finished. Output: Exec denied (…)

line inbound: → embedded run tool start tool=exec → [line] received request e372af9b-…: the turn completes on plain main, and nothing else is pushed while the request waits. No forwarded text prompt.

Same settings without a listed approver (allowFrom: ["*"], so the approver set is empty and cards stay off), fresh state dir — this is what an install does today:

step pushes what went out
request raised +1 [line-wire] push ok n=1 types=text text="🔒 Exec approval required\nID: 451100df-…\nCommand: date\nCWD: …"
decided (deny) +2 ✅ Exec approval denied. Resolved by cli., then exec finished. Output: …

No [line] received request: the card handler does not take that request. The message count is the same; the difference is that one is a button and the other is an ID to retype.

Current head: signed card taps, and a decision attempted through the wrong account

Approvers are the operator only (dmPolicy: "open", allowFrom: ["*", <operator>], so anyone may talk to the bot but only the operator may decide). The three postbacks use the card's encoding and a tag computed from the channel's real secret, which was never printed.

[line] received request 4346aa24-…   -> [line-wire] push ok n=1 types=flex text="Exec Approval Required: date"

T1 valid tag, sender not a listed approver
  received postback line.approval=4346aa24-…&…&line.sig=…
  (no gateway-client connect, no approval.resolve)    approvals pending -> 4346aa24-… still pending
T2 operator, tag made with another account's secret
  [line] [default] ignored approval postback data that no approval card for this account built
  (no approval.resolve)  -> "Nothing was decided: this approval button could not be verified…"
                                                      approvals pending -> 4346aa24-… still pending
T3 operator, valid tag
  connect clientDisplayName=LINE approval (U47f0…9b63) -> res ✓ approval.resolve 10ms -> exec.approval.resolved
  [line] resolved 4346aa24-… with allow-once -> tool end exec
  "✅ Exec approval allow-once. Resolved by LINE approval (U47f0…9b63)." then "exec finished. Output: Sun Sep 20 18:50:29 CST 2026"
                                                      approvals pending -> []

Wrong account, on one Gateway carrying two LINE accounts (default and work, each listing the operator as its approver). The request belongs to default; the tap arrives on work with a valid work tag, so LINE's own check passes:

[line] received request b190ceaf-…        (its card push failed 429, monthly limit; logged at error level)
postback for b190ceaf-… via /line/work
  connect clientDisplayName=LINE approval (U47f0…9b63)
  res ✗ approval.resolve 9ms errorCode=INVALID_REQUEST errorMessage=approval not found
  line: approval decision could not be recorded: GatewayClientRequestError: approval not found
  -> "That approval is no longer waiting for a decision."
approvals pending -> b190ceaf-… still pending

Gateway custody refused a reviewer from an account the request does not belong to. Not covered live: an approver removed while a tap is already on its way to the Gateway (see the remaining window above); with custody reading only authorized, the outcome of that race today is acceptance, not rejection.

What the two look like in the chat (captures from dist 2862c1d)

One Gateway with two LINE accounts, both listing the operator as approver, with approvals.exec in session mode. Only the build changes between the two captures: first a build without LINE approvals, then dist 2862c1d29c1. Each capture is cropped to the message, with the working directory redacted.

Before: forwarded text prompt After: approval card
dist 4f865fd: same-chat approval with cards off, and taps after an approver is removed

Injected webhook events from the operator's DM and real pushes, with quota consumption as the bounded observable. Postbacks below use that build's card encoding, which had no tag yet. On the current head a tap also needs the tag the card carries; the signed-tap run above checks that tag live.

Cards off (no approvals block, allowFrom: [<operator>]), same-chat typed /approve:

tool start exec
approvals pending --json  -> f64bc0d5-… kind exec summary date   (pending, quota unchanged)
inbound "/approve f64bc0d5-… allow-once"
connect clientDisplayName=Chat approval (line:U47f0…) -> res ✓ exec.approval.resolve 28ms
tool end exec -> stand-in function_call_output "Mon Sep 14 03:43:21 CST 2026"
approvals pending --json  -> []

Cards on (approvals.exec session, allowFrom: ["*", <operator>]), card delivered ([line] received request 2dc8424c-…, quota +1), then allowFrom edited to ["*"]:

[reload] config change requires channel reload (line) — deferring until ... 1 embedded run(s) ... complete
postback line.approval=2dc8424c-…&line.decision=allow-once   (removal not yet published)
res ✓ approval.resolve -> [line] resolved 2dc8424c-… with allow-once
[reload] config hot reload applied (channels.line.allowFrom)          (after the run finished)

After the removal was published, a request raised afterwards gets no card. The former approver's decision postback is therefore built with the card encoding and that request's ID, which is what a card from before the removal would send:

approvals pending --json  -> 89bbaf31-… (no card: no approvers)
postback line.approval=89bbaf31-…&line.decision=allow-once   from the former approver
(no approval.resolve)       quota +1 for the /approve notice
approvals pending --json  -> 89bbaf31-… still pending
Main flow on an earlier head: a real tap on a card resolves the approval and the command runs

Webhook bodies came from the real LINE client, captured through the tunnel inspector.

webhook message  "approval-proof: please run date"   (LineBotWebhook/2.0, source.userId present)
[line] embedded run tool start tool=exec
[line] received request 076edb96-…                      -> Flex card in approver DM, no /approve text prompt
webhook postback line.approval=076edb96-…&line.approvalKind=exec&line.decision=allow-once
[line] resolved 076edb96-… with allow-once
tool end exec -> "exec finished. Output: Sun Sep 13 21:04:41 CST 2026"
terminal: "✅ Exec approval allow-once. Resolved by LINE approval (U47f0…). ID: 076edb96-…"
Routing paths on earlier heads (injected webhook events, real pushes)
  • Group origin with an approver: the card goes to the approver's DM, and the group session receives "Approval required. I sent the approval request to LINE DMs, not this chat." (quota +2).
  • Approver's own DM origin: card only, no routed-elsewhere notice (quota +1).
  • Forwarding on, allowFrom: ["*"], DM origin: no card, text prompt only (quota +1); typed /approve … allow-once resolves and the command runs.
  • Tap on a card whose approval is gone: "That approval is no longer waiting for a decision." (reply token stale, push fallback, quota +1).

Tests: pnpm exec vitest run --config test/vitest/vitest.extension-line.config.ts passes 75 files / 1118 tests. Both tsgo lanes, lint:extensions, oxfmt --check, check:assertion-safety, check:max-lines-ratchet, and docs:check-mdx pass.

I removed or rewrote each guard one at a time and confirmed that a named test fails for each:

  • button data is accepted only with the tag made from this account's channel secret; an account without a secret draws no card and accepts no button data;
  • a tap without a sender, with cards off, or with no approvers listed does not decide and points to /approve (the Control UI for OpenClaw-change); a sender who is not a listed approver is refused;
  • a tap is authorized against the config current at decision time; a tap on a decided or missing approval is told the outcome that stands;
  • the tap notice reaches the tapper by reply or push, and is not sent if the sender's access was revoked during the Gateway call, without a new pairing challenge;
  • typed /approve narrows to listed approvers only for a type whose cards are on, and same-chat /approve stays available;
  • cards go only to approver DMs; forwarded prompts are dropped only for chats a card or routed notice reaches, and kept when forwarding has no approvers; the runtime context registers only when cards are enabled;
  • approval button data never becomes agent turn text;
  • a card that cannot be drawn or sent falls back to command text (the Control UI for OpenClaw-change); a card LINE rejects counts as failed, one whose receipt was unreadable counts as delivered; a card with an undrawable decision is not sent partially;
  • long bodies are shortened and marked with the approval ID kept, long approval IDs use a digest reference, approver IDs keep their case, group IDs are not approvers, and the outcome is published as a new message.

Not live-verified:

  • A group member outside allowFrom using typed /approve while cards are off. Unit tests cover it against the real capability.
  • Plugin and OpenClaw-change cards: every live run raised an exec approval. Unit tests cover the other two kinds, including taps on OpenClaw-change cards that fall back and the fallback text when such a card cannot be drawn or sent. A tap carrying a tag that does not verify against the account's secret — the state an old card is in after the secret changes — is covered live above (T2).
  • More than one approver: each listed approver gets its own card and its own outcome notice, and the live runs all had a single approver. Unit tests cover the fan-out.
  • A card body shortened to fit LINE's bubble limit. Unit tests cover the marker and the retained approval ID.
  • The lazy runtime boundary that loads the card handler: unit tests import the runtime module directly, so only the live runs above cross the loader itself.
  • An explicit LINE group listed in approvals.exec.targets with mode: "both". Unit tests cover it.
  • /bash chat commands create approvals without a turn source and hold the conversation's ingress lane until they finish, so a card tap during /bash waits for the stall watchdog. Model-driven exec does not have this limitation.

Follow-ups outside this PR, in core for every channel:

  • The custody window above.
  • Exec cards carry the metadata core builds in buildExecMetadata, which never includes the question asked or the node the command would run on, although the forwarded text prompt this card replaces shows both. Every channel drawing an approval card is missing them the same way.
  • OpenClaw-change approvals: core's approval view publishes /approve commands for them, and core's "could not deliver the native approval request" notice names /approve, but typed /approve decides only exec and plugin approvals. When a LINE card cannot be drawn or sent for a request raised in the approver's own chat, that chat gets LINE's fallback (Control UI) and then core's notice (/approve).

@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: line Channel integration: line size: XL labels Sep 13, 2026
@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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 20, 2026, 8:55 AM ET / 12:55 UTC (Revision 7).

ClawSweeper review

What this changes

Adds signed LINE approval cards, approver direct-message delivery, button handling, and outcome notices for exec, plugin, and OpenClaw-change requests.

Merge readiness

⛔ Blocked before merge - 9 items remain

Keep open: this remains a useful, distinct LINE integration. Fresh real LINE evidence strengthens the contribution, but the prior upgrade finding and an unresolved authorization defect still block merge.

Priority: P2
Reviewed head: ba409e6d2eebcb6a1c07b53ec4b9a6e6bd4d5e12
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful implementation with credible real exec evidence, limited by unresolved upgrade semantics and final-write authorization.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: snapshot-matching real LINE/Gateway traces establish signed exec approval, command continuation, and wrong-user, wrong-secret, and wrong-account rejection. They explicitly leave native authority withdrawal during Gateway resolution untested; rejection before the final decision write remains required. The positive runtime evidence is retained. 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) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: snapshot-matching real LINE/Gateway traces establish signed exec approval, command continuation, and wrong-user, wrong-secret, and wrong-account rejection. They explicitly leave native authority withdrawal during Gateway resolution untested; rejection before the final decision write remains required. The positive runtime evidence is retained. 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 10 items Introduced authorization behavior: The introduced capability automatically uses forwarding configuration and DM allowlist identities to enable cards, then applies that approver restriction to typed commands as well. The tests explicitly demonstrate denial of an unlisted group member when exec cards are enabled.
Gateway discards the implicit-authorization distinction: Custody consumes only authorizeActorAction(...).authorized. The same implementation remains on fetched main; it cannot distinguish a native callback from a typed command when LINE returns implicit same-chat authorization.
Final decision path: approval.resolve obtains current configuration, prepares channel custody, checks account ownership, and then applies the decision. The LINE callback passes channel, account, and sender identity without preserving its requirement for explicit native authorization.
Findings 2 actionable findings [P1] Preserve existing group approval rights during upgrade
[P1] Preserve native authorization through the Gateway decision write
Security Needs attention In-flight native decisions can survive withdrawal of native authority: The callback's explicit authorization requirement is lost at the Gateway boundary; custody accepts an implicit fallback result without requiring the command checks that justify it.

How this fits together

OpenClaw pauses sensitive operations for approval through the Gateway. The LINE plugin presents those requests as cards and sends the tapping user's account identity and decision back to the Gateway.

flowchart TD
  A[Paused operation] --> B[Gateway approval request]
  B --> C[LINE routing and approver policy]
  C --> D[Signed card in approver DM]
  D --> E[Webhook and actor checks]
  E --> F[Gateway custody check]
  F --> G[Recorded decision and operation outcome]
Loading

Decision needed

Question Recommendation
Should LINE cards require explicit opt-in, or may existing forwarding and DM allowlist settings automatically narrow typed approval rights on upgrade? Require explicit card activation: Adopt the shared execApprovals configuration pattern with cards disabled by default, and separately define compatibility for typed-command account scoping.

Why: The contributor has documented both paths and explicitly requested direction; introducing configuration or accepting changed permissions requires maintainer intent.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: snapshot-matching real LINE/Gateway traces establish signed exec approval, command continuation, and wrong-user, wrong-secret, and wrong-account rejection. They explicitly leave native authority withdrawal during Gateway resolution untested; rejection before the final decision write remains required. The positive runtime evidence is retained. 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.
  • Preserve existing group approval rights during upgrade (P1) - This prior finding remains. An existing account with session forwarding and a DM allowFrom list now rejects typed /approve from command-authorized group members outside that list, without any new activation setting. Adding those members to allowFrom also grants DM access, so the documented workaround changes another permission. Preserve existing rights behind explicit activation, or obtain maintainer acceptance of the permission transition and prove its upgrade behavior.
  • Preserve native authorization through the Gateway decision write (P1) - If native eligibility ends after the local check but before this Gateway call resolves, authorizeLineApprovalActor returns implicit { authorized: true }. Gateway custody reads only .authorized, and a request belonging to this LINE account still passes binding checks, so the card decision can be recorded without the command authorization that implicit fallback requires. Carry the native-callback requirement to the final write and reject ineffective authority there. This was previously reported as a proof gap; the unchanged path should have been identified as a concrete defect earlier.
  • Resolve security concern: In-flight native decisions can survive withdrawal of native authority - The callback's explicit authorization requirement is lost at the Gateway boundary; custody accepts an implicit fallback result without requiring the command checks that justify it.
  • Resolve merge risk (P1) - Existing forwarding and DM allowlist settings automatically activate cards and remove typed approval rights from unlisted group members; registering the hook also narrows cross-account/channel approval commands even with cards off. Maintainer acceptance or a compatibility-preserving activation policy is unresolved.
  • Resolve merge risk (P1) - Final-write rejection after native authority becomes ineffective remains unproved; current custody accepts the implicit authorization result identified in the security finding.
  • Resolve merge risk (P1) - Live evidence exercises exec approvals; plugin decisions and OpenClaw-change application outcomes remain covered only by supplemental tests.
  • Complete next step (P2) - Obtain the LINE activation and upgrade decision, repair callback authorization at the Gateway write, and provide the remaining final-effect proof before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve existing group approval rights during upgrade — extensions/line/src/approval-native.ts:97-99
  • [P1] Preserve native authorization through the Gateway decision write — extensions/line/src/approval-postback.ts:204-211
  • [high] In-flight native decisions can survive withdrawal of native authority — extensions/line/src/approval-postback.ts:204
Agent review details

Security

Needs attention: Signed callbacks and account binding are sound controls, but native authorization can degrade to command-only fallback before the final write.

PR surface

Source +898, Tests +1506, Docs +97. Total +2501 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 12 914 16 +898
Tests 9 1509 3 +1506
Docs 2 98 1 +97
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 2521 20 +2501

Review metrics

Metric Value Why it matters
Production versus test growth Production +914/-16; tests +1509/-3 The growth supports a new signed channel adapter and its routing, authorization, and delivery coverage rather than a new core approval owner.
Approval-kind runtime coverage 3 kinds added; 1 exercised live The retained real LINE traces cover exec, while plugin and OpenClaw-change paths still rely on tests.

Merge-risk options

Maintainer options:

  1. Resolve activation and custody before landing (recommended)
    Choose the upgrade policy and carry native callback authorization through the final Gateway write, with allowed and revoked controls.
  2. Hold for the shared custody prerequisite
    Keep this contribution open until the shared approval owner supplies a callback-aware resolution contract.

Technical review

Best possible solution:

Keep the existing native approval SDK owner, make activation preserve existing approval rights unless maintainers approve an explicit migration, and enforce callback-specific live authority at the Gateway decision write.

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

Yes, from source for the findings: existing forwarding plus a DM allowlist changes group authorization, and disabling native eligibility between the local tap check and Gateway resolution reaches the implicit fallback. These paths were traced, not executed.

Is this the best way to solve the issue?

Not yet: using the existing native approval SDK is appropriate, but automatic permission changes need an accepted upgrade policy and native authorization must survive the complete resolution path.

Full review comments:

  • [P1] Preserve existing group approval rights during upgrade — extensions/line/src/approval-native.ts:97-99
    This prior finding remains. An existing account with session forwarding and a DM allowFrom list now rejects typed /approve from command-authorized group members outside that list, without any new activation setting. Adding those members to allowFrom also grants DM access, so the documented workaround changes another permission. Preserve existing rights behind explicit activation, or obtain maintainer acceptance of the permission transition and prove its upgrade behavior.
    Confidence: 0.99
  • [P1] Preserve native authorization through the Gateway decision write — extensions/line/src/approval-postback.ts:204-211
    If native eligibility ends after the local check but before this Gateway call resolves, authorizeLineApprovalActor returns implicit { authorized: true }. Gateway custody reads only .authorized, and a request belonging to this LINE account still passes binding checks, so the card decision can be recorded without the command authorization that implicit fallback requires. Carry the native-callback requirement to the final write and reject ineffective authority there. This was previously reported as a proof gap; the unchanged path should have been identified as a concrete defect earlier.
    Confidence: 0.96
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a useful LINE approval enhancement with limited channel scope, rather than an active production emergency.
  • merge-risk: 🚨 compatibility: Existing settings can automatically remove group members' typed approval rights and narrow approval account scope.
  • merge-risk: 🚨 security-boundary: A native callback can retain effective approval authority after the policy switches to implicit command-only authorization.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: snapshot-matching real LINE/Gateway traces establish signed exec approval, command continuation, and wrong-user, wrong-secret, and wrong-account rejection. They explicitly leave native authority withdrawal during Gateway resolution untested; rejection before the final decision write remains required. The positive runtime evidence is retained. 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

Security concerns:

  • [high] In-flight native decisions can survive withdrawal of native authority — extensions/line/src/approval-postback.ts:204
    The callback's explicit authorization requirement is lost at the Gateway boundary; custody accepts an implicit fallback result without requiring the command checks that justify it.
    Confidence: 0.96

What I checked:

  • Introduced authorization behavior: The introduced capability automatically uses forwarding configuration and DM allowlist identities to enable cards, then applies that approver restriction to typed commands as well. The tests explicitly demonstrate denial of an unlisted group member when exec cards are enabled. (extensions/line/src/approval-native.ts:97, ba409e6d2eeb)
  • Gateway discards the implicit-authorization distinction: Custody consumes only authorizeActorAction(...).authorized. The same implementation remains on fetched main; it cannot distinguish a native callback from a typed command when LINE returns implicit same-chat authorization. (src/gateway/approval-channel-custody.ts:35, fcc927f58d02)
  • Final decision path: approval.resolve obtains current configuration, prepares channel custody, checks account ownership, and then applies the decision. The LINE callback passes channel, account, and sender identity without preserving its requirement for explicit native authorization. (src/gateway/server-methods/approval.ts:409, ba409e6d2eeb)
  • Native eligibility can change during the request: approvals.exec and approvals.plugin are hot-reload settings. Turning forwarding off can make LINE return implicit authorization while an already-authorized callback is awaiting Gateway resolution; a LINE-origin request still passes its account binding. (src/gateway/config-reload-plan.ts:270, ba409e6d2eeb)
  • Complete snapshot-matching contributor evidence: Read the complete live body and verified SHA-256 64f9e53ce23908951d7c19e3b7e92ae677e24076427a69d5eba29e3c951e3fec against the supplied snapshot. It records real LINE pushes, signed injected webhooks, successful exec continuation, and wrong-user, wrong-secret, and wrong-account rejection. It explicitly excludes in-flight withdrawal of native authority and live plugin/system-agent coverage. Older before/after screenshots are linked; their remote retrieval failed, so visual inspection is not claimed. (ba409e6d2eeb)
  • Re-review continuity: The approval policy and callback modules are unchanged from the previous reviewed head. The group-approval restriction remains unfixed; the previously disclosed custody concern is now tied to the concrete final-write path. The earlier inactive-handler suppression concern is addressed by the merged shared forwarder fix and is not raised again. (extensions/line/src/approval-postback.ts:204, ba409e6d2eeb)

Likely related people:

  • Ayaan Zaidi: Raw commit 9935ca3 adds src/gateway/approval-channel-custody.ts:36 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9935ca3b30dc; files: src/gateway/approval-channel-custody.ts)
  • Eden: Raw commit 008a95d adds extensions/line/src/question-postback.ts:64 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 008a95d8059d; files: extensions/line/src/question-postback.ts)

Rank-up moves

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

  • Resolve the activation-policy decision and demonstrate fresh-install and upgrade approval rights.
  • Add redacted Gateway final-effect evidence for an allowed callback and withdrawal of native authority during resolution, showing no unauthorized decision or operation.
  • Demonstrate plugin decisions and OpenClaw-change final outcomes through the real LINE/Gateway path; redact private details and update the PR body to trigger re-review, or ask a maintainer to comment @clawsweeper re-review.

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-13T18:17:55.352Z sha f5f26f0 :: needs real behavior proof before merge. :: [P1] [P1] Preserve same-chat approvals when forwarding is disabled
  • reviewed 2026-09-13T23:18:41.822Z sha 2862c1d :: needs real behavior proof before merge. :: [P1] [P1] Preserve existing group approval rights during upgrade | [P2] [P2] Retain forwarded prompts until native startup succeeds
  • reviewed 2026-09-13T23:39:57.736Z sha 2862c1d :: needs real behavior proof before merge. :: [P1] [P1] Preserve existing group approval rights during upgrade | [P2] [P2] Retain forwarded prompts until native startup succeeds
  • reviewed 2026-09-14T07:48:18.317Z sha 2862c1d :: needs real behavior proof before merge. :: [P1] [P1] Preserve existing group approval rights during upgrade | [P2] [P2] Retain forwarded prompts until native startup succeeds
  • reviewed 2026-09-14T09:33:32.832Z sha 600d57f :: needs real behavior proof before merge. :: [P1] [P1] Preserve existing group approval rights during upgrade
  • reviewed 2026-09-14T22:45:01.972Z sha f300ebb :: needs real behavior proof before merge. :: [P1] [P1] Preserve existing group approval rights during upgrade

LINE chats approved with typed /approve before native cards existed, and
allowFrom is the DM allowlist before it names approvers. Report approvals
as available on every LINE chat, restrict deciding to listed approvers only
for approval kinds whose cards are on, and check a tap's authority against
the config current when the decision is sent.
The card handler decides with the config its LINE account started with,
while forwarding settings hot-reload. Turning forwarding on, or widening it,
without a restart let the forwarder drop the text prompt for a chat no card
would reach. Drop a forwarded prompt only when both the start config and the
current config would draw the card.
… built

Replies can carry postback buttons built from agent-authored content, and
LINE returns postback data unchanged. Tag each card decision with an HMAC
derived from the account's channel secret and ignore approval data without
a valid tag. Also look up started accounts with the same id normalizer that
records them, and log card and fallback delivery failures at error level.
… card tag across accounts

Verify a tap's tag with the secret the webhook carrying it was verified
with, draw no card without a channel secret, normalize the default account
id on the forwarding lookup, and warn when a tap carries approval data no
card built. Document that buttons stop working after a secret change until
the restart re-sends pending approvals.
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Sep 13, 2026
@edenfunf

Copy link
Copy Markdown
Contributor Author

On the recommendation to keep typed /approve on command authorization and restrict only card taps: I looked at this and it doesn't work on its own.

Addendum: Gateway custody checks LINE's authorizeActorAction against the live config right before it writes a decision, for taps and typed /approve alike. The hook can't tell the two apart, so "typed stays on command authorization" means the hook returns same-chat authorization for every LINE sender. Custody would then stop checking the approver list at write time. A tap from someone who was just removed or replaced as an approver could still be written. The upgrade issue would go away, but the authority boundary gets weaker. Keeping existing typed rights without that trade-off needs either maintainer acceptance of the upgrade restriction (the step c2cbdea28cf took for other shipped channels) or an explicit opt-in setting, which is a new config key.

On P2 (forwarded prompts dropped while the native handler isn't running): this isn't LINE-specific. The forwarder asks every channel's suppressor using config alone, while the local prompt path already checks whether a native runtime is active. It's tracked separately in #148031.

…t observable

Forwarding cannot tell whether an account's card handler actually started,
and the start-config record treated registration as readiness. Keep the
forwarded text prompt for every target instead, so a failed or disabled
handler never leaves a chat with neither a card nor the prompt. The local
prompt still yields to the card through core's running-runtime hint.
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Sep 14, 2026
@edenfunf edenfunf changed the title feat(line): approve exec and plugin requests from a card in LINE feat(line): approve exec, plugin, and OpenClaw-change requests from a card in LINE Sep 14, 2026
@edenfunf

Copy link
Copy Markdown
Contributor Author

The latest review (Revision 6, f300ebbaeaf) leaves two items that I can't settle from the contributor side, so I'm asking before changing anything.

1. Upgrade semantics for typed /approve (P1)

LINE has no approver list of its own. Cards take approvers from channels.line.allowFrom, which was LINE's DM allowlist long before approvals existed. An account that already forwards approvals in session or both mode and lists DM users gets cards on upgrade, and typed /approve for that approval type narrows to that list. Registering the approval auth hook also scopes typed /approve to requests that belong to the LINE account, even with cards off. Both effects are in the PR body and docs/channels/line.md now.

I see two ways forward:

  • Accept it as an upgrade change. c2cbdea28cf did the same when it added approval auth to shipped channels such as Signal, Slack, WhatsApp and Matrix: typed /approve moved to the approver list with no opt-in. The code stays as it is; the upgrade note is already in the docs.
  • Opt in through the shared execApprovals block. Discord, Slack and Telegram already accept channels.<channel>.execApprovals from buildChannelExecApprovalsSchema. LINE would take the same block, except enabled defaults to off rather than auto, because LINE would otherwise infer approvers from a DM allowlist. With it off, no cards are drawn and the approver list never narrows typed /approve; with it on, the approver list decides for taps and typed commands alike, and execApprovals.approvers lets operators name approvers without editing allowFrom. This adds config surface to LINE, which is why I haven't pushed it.

If you prefer the second, I'll add the schema, docs and tests in this PR.

2. Custody when native authority ends while a tap is in flight

This part isn't LINE-specific. Gateway custody reads only authorizeActorAction(...).authorized, and once no approver is listed LINE returns implicit same-chat authorization (typed /approve without approvers depends on that). A tap that already passed LINE's local check can therefore still be written if the last approver is removed during the Gateway call. LINE can't close this alone, because the reviewer identity sent to the Gateway doesn't say whether a decision came from a native callback or a typed command. In practice the Gateway defers publishing a channels.line change while runs are active (live log in the body), so the window is narrow, but it is real.

The fix I have in mind is a separate core change: carry the authorization source on the channel reviewer and have custody reject implicit authorization when the source is a native callback. That touches the gateway protocol schema and the generated Swift models, so I'd open an issue for the design first. Should that land before this PR, or is a tracked follow-up enough?

Separately, the live suppression runs in the body used a local workaround for the ingress failure that #148548 fixes; current main fails every LINE turn before any approval can be raised.

@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 Oct 12, 2026

This branch has not been deployed

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

Labels

channel: line Channel integration: line docs Improvements or additions to documentation 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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

1 participant