Skip to content

refactor(channels): share terminal approval interpretation - #140677

Merged
steipete merged 2 commits into
mainfrom
steipete/dedup-channels-approvals-0906-terminal
Sep 7, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/dedup-channels-approvals-0906-terminal

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Related: #140645 and #140695.

What Problem This Solves

Approval results were interpreted independently in Discord, Slack, Matrix, Google Chat, Teams, Telegram, and the SDK text helper. Denied system changes also publish not-applied, so consolidating those copies without preserving their precedence would change existing receipts.

Why This Change Was Made

One private SDK interpreter now supplies terminal labels and system-agent prose through the existing openclaw/plugin-sdk/approval-runtime entrypoint. Rich labels retain application-status precedence; prose retains denial precedence; both prioritize cancellation. Discord's decision spelling/colors, Telegram's UTF-16 limits, and the SDK wrapper's resolved-event decision override remain intact.

The three new helpers replace three unused bindings on that same public entrypoint: matchesApprovalRequestSessionFilter, resolveApprovalRequestAccountId, and resolveApprovalRequestChannelAccountId. Account lookup remains available through approval-native-runtime; the session predicate is private behind the retained full request-filter API. Its unsafe-regex test now exercises that public filtering path.

Global and OpenClaw-org consumer searches were fully paged and import blobs inspected. No independent consumer of the retired broad bindings was found; matches were self-contained hosts or generated/historical artifacts. The verified Inline consumer uses the retained narrow binding. No compatibility alias or budget increase is introduced.

User Impact

No user-visible behavior or appearance change. Approval authorization, settlement, persistence, decision/application precedence, and message limits remain unchanged. Plugin authors use the existing approval runtime entrypoint for the shared presentation helpers and the native runtime entrypoint for account lookup.

Evidence

Fresh validation is for 6e96706af6e941aa8226b29174b8971ce5af38be, rebased onto main including #140645. Production patches are unchanged; the docs conflict was resolved by retaining both consolidations' guidance.

  • node scripts/run-vitest.mjs with 46 concrete approval, Telegram handler, and public request-filter test files: 535 tests passed. Tests preserve cancellation, denial/application precedence, channel-specific receipt text, UTF-16 bounds, and the resolved-event decision override.
  • node scripts/check-changed.mjs passed ratchets, formatting, SDK checks, core/plugin production and test typechecks, declaration/deprecation guards, all three dead-export scans (zero entries), and core lint. Local plugin lint reaches the documented nested-worktree declaration-boundary exception; exact-head hosted lint, typechecks, and extension package-boundary checks passed.
  • pnpm build passed in 6m29s. pnpm plugin-sdk:surface:check passed with 4,446 public exports and 2,629 callables, within unchanged budgets. The public replacement remains three additions/three removals on the existing approval-runtime entrypoint.
  • All nine isolated startup profiles passed, with zero failures/timeouts. The command was OPENCLAW_LOCAL_CHECK=0 node --import tsx scripts/profile-extension-memory.mts --extension <id> --skip-combined --concurrency 1, for Discord, Google Chat, iMessage, Matrix, Teams, Signal, Slack, Telegram, and WhatsApp.
  • Fresh isolated Codex branch review: zero actionable P0–P2 findings. Production +140/−145 = −5; tests +416/−52 = +364.
  • Exact-head CI passed, including required openclaw/ci-gate: https://github.com/openclaw/openclaw/actions/runs/34121243751. No CI rerun was needed.

Live channel proof remains unavailable. Mock-Gateway handler suites verify the changed presentation boundary; they are not live transport proof.

Maintainer-directed SDK replacement

The maintainer explicitly required this consolidation to use the existing approval runtime entrypoint and replace at least as many public exports as it adds, without increasing SDK budgets. The lane's public-contract rule authorizes removal and internal migration after a GitHub-wide plus OpenClaw-org audit finds no external consumer. All search variants were paged to completion; the retiring broad bindings have no independent upstream consumer. Existing narrow account helpers remain available and the observed independent Inline consumer retains its import path. This is an intentional import-level removal under that direction, with migration documented; flat counts alone are not the compatibility argument. The bot's request to retain all broad bindings would conflict with the explicit replacement decision.

@clawsweeper

clawsweeper Bot commented Sep 7, 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: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: telegram Channel integration: telegram size: L maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 02:48
@steipete
steipete marked this pull request as draft September 7, 2026 02:50
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 7, 2026, 8:25 AM ET / 12:25 UTC.

ClawSweeper review

What this changes

Centralizes approval-result labels and text across six channel plugins while preserving their wording and precedence, and replaces three public SDK exports with presentation helpers.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-directed consolidation remains distinct from current main and the related PRs. No actionable correctness finding remains; the earlier compatibility-alias request was superseded by the documented export-replacement decision.

Priority: P3
Reviewed head: 6e96706af6e941aa8226b29174b8971ce5af38be

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused consolidation preserves existing presentation contracts, with useful boundary coverage and an explicitly accepted SDK compatibility tradeoff.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this presentation-only refactor from the external-contributor proof gate; no authority change triggers additional proof. Reported handler suites exercise rendering, but live channel behavior was not demonstrated.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this presentation-only refactor from the external-contributor proof gate; no authority change triggers additional proof. Reported handler suites exercise rendering, but live channel behavior was not demonstrated.
Evidence reviewed 8 items Introduced presentation logic: The pinned merge-base-to-head diff centralizes cancellation, application-status, and denial precedence. The SDK wrapper still uses the resolved event's decision, and Telegram still truncates its operation summary before rendering.
Current-main necessity: Fetched main still implements system-agent receipt precedence inline. The requested shared presentation implementation is therefore still useful; the supplied merged reaction-settlement PR addresses a different boundary.
Released import contract: The latest supplied release exports all three retired bindings from approval-runtime, establishing a real import-level compatibility change rather than an inferred risk.
Findings None None.
Security None None.

How this fits together

Channel approval handlers receive recorded decisions and application results from the Gateway. Shared presentation helpers turn those facts into labels and receipts, while each plugin retains its transport formatting and message limits.

flowchart TD
  A[Gateway approval result] --> B[Typed approval view]
  B --> C[Shared outcome interpretation]
  C --> D[Application-first card label]
  C --> E[Denial-first receipt text]
  D --> F[Channel formatting and limits]
  E --> F
  F --> G[Updated approval message]
Loading

Before merge

  • Resolve merge risk (P1) - Installed or private plugins importing the three retired approval-runtime bindings will fail until migrated; the reported public-consumer audit cannot rule out private consumers. This import-level removal is explicitly accepted in the supplied maintainer direction.
Agent review details

Security

None.

PR surface

Source -5, Tests +364, Docs +14. Total +373 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 10 140 145 -5
Tests 8 416 52 +364
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 570 197 +373

Review metrics

Metric Value Why it matters
Public SDK replacement 3 callable exports added, 3 removed The public count stays flat, but named imports change and require the documented compatibility decision.
Production versus test delta Production −5 lines; tests +364 lines The consolidation reduces production code while adding coverage for precedence, channel presentation, and UTF-16 limits.

Merge-risk options

Maintainer options:

  1. Honor the documented export replacement (recommended)
    Proceed under the recorded maintainer decision, accepting that consumers of retired bindings must migrate to the retained APIs.

Technical review

Best possible solution:

Retain one shared presentation interpreter, transport-owned limits, and the documented migration paths under the accepted SDK replacement decision.

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

Not applicable: this refactor preserves existing behavior rather than claiming a reproduced defect; source comparison and added cases cover the relevant presentation invariants.

Is this the best way to solve the issue?

Yes: a private shared interpreter removes repeated precedence logic while preserving channel-specific formatting, and the public export replacement follows the recorded maintainer decision.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a behavior-preserving consolidation without a demonstrated urgent runtime defect.
  • merge-risk: 🚨 compatibility: Three bindings present in v2026.9.2 are intentionally removed, so external consumers may need import migration.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this presentation-only refactor from the external-contributor proof gate; no authority change triggers additional proof. Reported handler suites exercise rendering, but live channel behavior was not demonstrated.

Evidence

What I checked:

  • Introduced presentation logic: The pinned merge-base-to-head diff centralizes cancellation, application-status, and denial precedence. The SDK wrapper still uses the resolved event's decision, and Telegram still truncates its operation summary before rendering. (src/plugin-sdk/approval-terminal.ts:24, 6e96706af6e9)
  • Current-main necessity: Fetched main still implements system-agent receipt precedence inline. The requested shared presentation implementation is therefore still useful; the supplied merged reaction-settlement PR addresses a different boundary. (src/plugin-sdk/approval-handler-runtime.ts:62, 44269cf16d1f)
  • Released import contract: The latest supplied release exports all three retired bindings from approval-runtime, establishing a real import-level compatibility change rather than an inferred risk. (src/plugin-sdk/approval-runtime.ts:34, 3928bad9badf)
  • Retained migration paths: Account lookup remains exported by approval-native-runtime, and the full request-filter API still calls the now-private session predicate. Repository searches found no remaining imports of the retired broad bindings. (src/plugin-sdk/approval-native-runtime.ts:27, 6e96706af6e9)
  • Compatibility disposition and proof context: The complete supplied PR body explicitly records maintainer-directed replacement without aliases, a fully paged public-consumer audit, and migration documentation. The latest completed review has no findings. Its earlier alias request is expressly rejected with rationale. Reported handler tests are supplemental boundary evidence; the body does not claim live channel proof. (6e96706af6e9)
  • Documented presentation boundary: The SDK guide distinguishes recorded approval from completed application, documents the two precedence orders, and identifies the retained account-lookup entrypoint. Public docs: docs/plugins/sdk-channel-plugins.md. (docs/plugins/sdk-channel-plugins.md:649, 6e96706af6e9)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (4 earlier review cycles)
  • reviewed 2026-09-07T02:56:37.723Z sha 7d3d4cd :: blocked before merge. :: none
  • reviewed 2026-09-07T06:05:59.460Z sha 50f77ae :: blocked before merge. :: [P1] [P1] Preserve released approval imports through a migration window
  • reviewed 2026-09-07T06:23:07.921Z sha 50f77ae :: blocked before merge. :: [P1] [P1] Preserve released approval imports through a migration window
  • reviewed 2026-09-07T07:22:29.184Z sha 50f77ae :: blocked before merge. :: none

@steipete
steipete force-pushed the steipete/dedup-channels-approvals-0906-terminal branch from 7d3d4cd to 50f77ae Compare September 7, 2026 05:58
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 7, 2026
Preserve application precedence in rich labels and denial precedence in
system change prose, including the real deny/not-applied producer result.
Keep transport label spelling and text bounds at their existing owners.

Proof: node scripts/run-vitest.mjs across 48 approval/ingress files
(547 tests); isolated autoreview clean through P2.
Expose terminal presentation only through approval-runtime and preserve both
precedence orders. Retire three unused broad bindings, make the session
predicate private, and retain the narrow account helpers used by plugins.

Proof: canonical SDK export/surface checks (4446 exports, 2630 callables),
48 files/547 focused tests, 3 filter tests, and targeted typechecks passed.
@steipete
steipete force-pushed the steipete/dedup-channels-approvals-0906-terminal branch from 50f77ae to 6e96706 Compare September 7, 2026 12:19
@steipete
steipete marked this pull request as ready for review September 7, 2026 12:19
@steipete
steipete merged commit 6b54af7 into main Sep 7, 2026
251 of 253 checks passed
@steipete
steipete deleted the steipete/dedup-channels-approvals-0906-terminal branch September 7, 2026 12:37
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…140677)

* refactor(channels): share terminal approval interpretation

Preserve application precedence in rich labels and denial precedence in
system change prose, including the real deny/not-applied producer result.
Keep transport label spelling and text bounds at their existing owners.

Proof: node scripts/run-vitest.mjs across 48 approval/ingress files
(547 tests); isolated autoreview clean through P2.

* refactor(plugin-sdk): replace duplicate approval exports

Expose terminal presentation only through approval-runtime and preserve both
precedence orders. Retire three unused broad bindings, make the session
predicate private, and retain the narrow account helpers used by plugins.

Proof: canonical SDK export/surface checks (4446 exports, 2630 callables),
48 files/547 focused tests, 3 filter tests, and targeted typechecks passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: telegram Channel integration: telegram docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant