Skip to content

refactor(channels): share native approval control ownership - #140695

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

steipete merged 3 commits into
mainfrom
steipete/dedup-channels-approvals-0906-controls

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Related: #140645 and #140677.

What Problem This Solves

Google Chat and Microsoft Teams duplicated native approval token registries and the claim/settle/release lifecycle. Concurrent clicks and failed terminal-card updates require that lifecycle to remain consistent while retaining each plugin's expiry policy.

Why This Change Was Made

createNativeApprovalControlRegistry, exposed only through the existing openclaw/plugin-sdk/approval-runtime entrypoint, owns each plugin's independent in-memory bindings and claims. The 18-byte base64url tokens and 1,024-binding FIFO limit are unchanged. A claim covers Gateway resolution and terminal-card update; retryable failures release the claim while retaining the binding, and terminal/not-found results retire controls.

Google Chat keeps its lookup-expiry behavior and manual-followup suppression through its registration wrapper and completion callback. Teams keeps its distinct lookup-expiry claim release. Explicit sweeps clear claims, while eviction retains in-flight claims. Native event scope checks, actor authorization, card rendering, error propagation and Gateway first-answer authority remain with their existing owners.

The unused public createChannelApprovalForwardingEvaluator binding and implementation are retired to fund the single new registry export. Its shared routing predicates and public parameter types remain; equivalent direct private callback types replace the obsolete params record. Global and OpenClaw-org searches were fully paged and all matching import blobs inspected. The nine consuming matches belong to self-contained historical hosts with their own matching SDK implementation; no independent upstream consumer was found. No compatibility alias or SDK budget increase is introduced.

User Impact

No user-visible behavior or appearance change. Approval decisions, authorization, retry behavior, expiry, persistence and configuration are unchanged.

Evidence

Fresh validation is for 3d19045240de38ef22c327bfba72af58788536fb, rebased onto main including #140645 and #140677. The original changes are preserved; docs, formatter imports, and SDK exports retain both earlier consolidations alongside this registry.

  • node scripts/run-vitest.mjs with 48 concrete approval, registry, route-gate, Telegram handler, request-filter, and Google Chat configuration test files: 551 tests passed. Coverage includes concurrent clicks, terminal-card-update failures, retry, expiry, authorization, suppression, and canonical-winner reporting.
  • node scripts/check-changed.mjs passed ratchets, formatting, SDK checks, all core/plugin production and test types, declaration/deprecation guards, three zero-entry dead-export scans, and core lint. Local plugin lint reaches the documented nested-worktree declaration-boundary exception; exact-head hosted lint, types, and extension package-boundary checks passed.
  • pnpm build passed in 6m16s. pnpm plugin-sdk:surface:check passed with 4,445 public exports and 2,627 callables, within unchanged budgets. The approved public replacement remains one addition on approval-runtime and one removal on approval-native-runtime.
  • All nine isolated startup profiles passed with zero failures/timeouts. Command: OPENCLAW_LOCAL_CHECK=0 node --import tsx scripts/profile-extension-memory.mts --extension <id> --skip-combined --concurrency 1. IDs: discord, googlechat, imessage, matrix, msteams, signal, slack, telegram, whatsapp.
  • Fresh final isolated Codex branch review: zero actionable P0–P2 findings. Production +181/−314 = −133; tests +149/−33 = +116.
  • Exact-head CI and required openclaw/ci-gate passed: https://github.com/openclaw/openclaw/actions/runs/34123752872. No failed-job rerun was needed.

Live channel proof remains unavailable. The isolated mock-Gateway card handlers and registry tests cover the changed lifecycle boundary; they are not live transport proof.

Maintainer-directed SDK replacement

The maintainer explicitly required a fixed SDK budget and retirement of at least as many public exports as this consolidation adds. The lane's public-contract rule authorizes removal with internal migration when the GitHub-wide and OpenClaw-org consumer check finds no external consumer, and requires a named compatibility re-export if one exists. The completed, fully paged audit found no independent consumer of this binding. This is an intentional import-level removal under that direction, not a claim that flat aggregate counts guarantee compatibility. Internal users are migrated and the retirement is documented. The bot's request for a new allocation conflicts with the explicit no-budget-increase decision; the requested build and startup evidence is now complete.

@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 in progress

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

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: googlechat Channel integration: googlechat channel: msteams Channel integration: msteams size: L maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 03:12
@steipete
steipete force-pushed the steipete/dedup-channels-approvals-0906-controls branch from d03e22e to 93dcc97 Compare September 7, 2026 03:17
@steipete
steipete marked this pull request as draft September 7, 2026 03:21
@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, 3:21 AM ET / 07:21 UTC.

ClawSweeper review

What this changes

Shares Google Chat and Microsoft Teams approval-card token handling through one SDK registry and retires an unused forwarding helper export.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-directed consolidation remains distinct from current main and the related PRs. No blocking correctness finding remains; the updated discussion addresses the prior retirement-approval concern and reports completion of the requested build and startup checks.

Priority: P3
Reviewed head: 5c0b781cf9b3613c1ae0a19ce0254ea6207caeb5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused consolidation with useful boundary coverage and addressed prior feedback; the intentional SDK retirement remains visible as an accepted compatibility tradeoff.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored refactor does not materially change authority, so the external-contributor proof gate does not apply. Inspected handler tests exercise settlement with mocked Gateway and transport calls; reported build and startup passes support import compatibility, not live card behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored refactor does not materially change authority, so the external-contributor proof gate does not apply. Inspected handler tests exercise settlement with mocked Gateway and transport calls; reported build and startup passes support import compatibility, not live card behavior.
Evidence reviewed 7 items Shared lifecycle preserves existing behavior: The registry retains 18-byte random tokens, the 1,024-binding FIFO limit, distinct lookup-expiry policies, and claims covering resolution plus card updates. Retryable exceptions retain bindings; completion and approval-not-found retire them.
Authorization remains with the existing owners: Both handlers retain account, destination, message, decision, and actor checks before settlement. The callback passes the same reviewer identity to the existing Gateway resolver; extraction does not materially change authority or introduce persistent state.
Focused boundary coverage: Inspected tests cover unauthorized actors, mismatched card scope, concurrent settlement, Gateway failure, terminal-card retry, canonical winning decisions, expiry policies, and independent registries. These use mocked Gateway and transport calls and were not executed during this read-only review.
Findings None None.
Security None None.

How this fits together

Native approval cards let operators approve or deny requests from chat. Plugins validate the click and actor, use the registry to prevent concurrent settlement, then resolve through the Gateway and update the card.

flowchart TD
  A[Approval card click] --> B[Plugin scope and actor checks]
  B --> C[Plugin-local token registry]
  C --> D[Gateway approval resolution]
  D --> E[Terminal card update]
  E --> F[Retire token and cleanup]
  D --> G[Release claim on retryable failure]
  E --> G
Loading

Before merge

  • Resolve merge risk (P1) - An undiscovered plugin importing createChannelApprovalForwardingEvaluator would fail to load after upgrading. The recorded consumer audit reduces this risk but cannot exclude private consumers; the PR documents intentional acceptance of the retirement.
Agent review details

Security

None.

PR surface

Source -133, Tests +116, Docs +10. Total -7 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 11 181 314 -133
Tests 6 149 33 +116
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 340 347 -7

Review metrics

Metric Value Why it matters
Public SDK replacement 1 callable added, 1 removed The unchanged total masks an intentional import-level compatibility change.

Merge-risk options

Maintainer options:

  1. Honor the documented export retirement (recommended)
    Proceed under the recorded fixed-budget replacement decision, accepting the residual risk to undiscovered consumers of the removed named import.

Technical review

Best possible solution:

Retain the shared lifecycle and plugin-owned authorization, with the documented SDK retirement governed by the recorded maintainer replacement decision.

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

Not applicable: this is a behavior-preserving consolidation, and review found no introduced runtime defect to reproduce.

Is this the best way to solve the issue?

Yes: a single generic registry removes duplicated lifecycle code while preserving plugin policy; the export tradeoff now has explicit maintainer-visible justification.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded internal consolidation with no demonstrated urgent user-facing regression.
  • merge-risk: 🚨 compatibility: The PR intentionally removes a named SDK export present in v2026.9.2.
  • 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 maintainer-authored refactor does not materially change authority, so the external-contributor proof gate does not apply. Inspected handler tests exercise settlement with mocked Gateway and transport calls; reported build and startup passes support import compatibility, not live card behavior.

Evidence

What I checked:

  • Shared lifecycle preserves existing behavior: The registry retains 18-byte random tokens, the 1,024-binding FIFO limit, distinct lookup-expiry policies, and claims covering resolution plus card updates. Retryable exceptions retain bindings; completion and approval-not-found retire them. (src/plugin-sdk/approval-native-controls.ts:64, 5c0b781cf9b3)
  • Authorization remains with the existing owners: Both handlers retain account, destination, message, decision, and actor checks before settlement. The callback passes the same reviewer identity to the existing Gateway resolver; extraction does not materially change authority or introduce persistent state. (extensions/msteams/src/approval-card-submit.ts:66, 5c0b781cf9b3)
  • Focused boundary coverage: Inspected tests cover unauthorized actors, mismatched card scope, concurrent settlement, Gateway failure, terminal-card retry, canonical winning decisions, expiry policies, and independent registries. These use mocked Gateway and transport calls and were not executed during this read-only review. (extensions/msteams/src/approval-card-submit.test.ts:298, 5c0b781cf9b3)
  • Current-main necessity: Fetched main still implements the Teams registry locally; the shared registry file is absent. The related open PRs concern reaction settlement and terminal presentation, rather than this token lifecycle consolidation. (extensions/msteams/src/approval-card-actions.ts:29, 2d58961f33fd)
  • Shipped export compatibility: The latest supplied release exports createChannelApprovalForwardingEvaluator. Its removal is an actual named-import compatibility change, regardless of unchanged aggregate SDK counts. (src/plugin-sdk/approval-native-runtime.ts:5, 3928bad9badf)
  • Prior feedback addressed by updated maintainer context: The supplied PR body records explicit fixed-budget replacement direction, a fully paged consumer audit finding no independent consumer, documented retirement, and completed build plus nine startup profiles. This addresses both prior rank-up moves without requiring an unrequested budget increase. The body still reports a failed required Telegram loopback check and draft status; neither establishes a defect in this diff. (5c0b781cf9b3)

Likely related people:

  • Peter Steinberger: Raw commit ea78c24 adds extensions/msteams/src/approval-card-submit.ts:74 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ea78c2488b05; files: extensions/msteams/src/approval-card-submit.ts)
  • Kevin Lin: 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 (2 earlier review cycles)
  • reviewed 2026-09-07T03:27:14.145Z sha 93dcc97 :: blocked before merge. :: none
  • reviewed 2026-09-07T07:03:34.248Z sha 5c0b781 :: blocked before merge. :: [P1] Preserve the shipped forwarding export until its retirement is approved

@steipete
steipete force-pushed the steipete/dedup-channels-approvals-0906-controls branch from 93dcc97 to 5c0b781 Compare September 7, 2026 06:55
@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
Hold each token claim through Gateway resolution and terminal card updates.
Keep plugin expiry policy, identity checks, and Google Chat suppression local.

Proof: node scripts/run-vitest.mjs across 12 native-control suites (96 tests);
extension production/test typechecks and isolated autoreview through P2 passed.
Expose native controls through approval-runtime and retire the uncalled
forwarding evaluator. Preserve the shared routing predicates, callback types,
and each plugin's claim, expiry, retry, and completion policy.

Proof: canonical SDK export/surface checks (4446 exports, 2630 callables),
50 files/583 focused tests, targeted typechecks, and isolated review passed.
Keep the same void latch without a redundant type argument in the native
approval registry test. Production and public API code are unchanged.

Proof: native approval registry suite (4 passed) and fresh isolated review.
@steipete
steipete force-pushed the steipete/dedup-channels-approvals-0906-controls branch from 5c0b781 to 3d19045 Compare September 7, 2026 12:46
@steipete
steipete marked this pull request as ready for review September 7, 2026 12:46
@steipete
steipete merged commit 3545380 into main Sep 7, 2026
250 of 252 checks passed
@steipete
steipete deleted the steipete/dedup-channels-approvals-0906-controls branch September 7, 2026 13:07
@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
…#140695)

* refactor(channels): share native approval control ownership

Hold each token claim through Gateway resolution and terminal card updates.
Keep plugin expiry policy, identity checks, and Google Chat suppression local.

Proof: node scripts/run-vitest.mjs across 12 native-control suites (96 tests);
extension production/test typechecks and isolated autoreview through P2 passed.

* refactor(plugin-sdk): replace unused approval forwarding export

Expose native controls through approval-runtime and retire the uncalled
forwarding evaluator. Preserve the shared routing predicates, callback types,
and each plugin's claim, expiry, retry, and completion policy.

Proof: canonical SDK export/surface checks (4446 exports, 2630 callables),
50 files/583 focused tests, targeted typechecks, and isolated review passed.

* test(plugin-sdk): omit the default deferred result type

Keep the same void latch without a redundant type argument in the native
approval registry test. Production and public API code are unchanged.

Proof: native approval registry suite (4 passed) and fresh isolated review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: googlechat Channel integration: googlechat channel: msteams Channel integration: msteams 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