Repository navigation
feat(approvals): typed approval scope summaries on channel cards - #130116
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 1:52 PM ET / 17:52 UTC. ClawSweeper reviewWhat this changesThe PR adds typed, display-only approval-scope summaries to exec and plugin requests, carrying them into channel approval cards. Merge readinessKeep this maintainer-authored PR open. The earlier generator and preview-count findings are addressed; the remaining blocker is an explicit compatibility decision for persisted approval records during a Gateway downgrade. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherApproval owners create pending exec or plugin requests, which the Gateway persists and distributes to channel adapters and operator clients. This change carries a bounded scope summary from the producer through the shared presentation into rendered approval cards. flowchart LR
A[Approval owner] --> B[Gateway request validation]
B --> C[Scope sanitization]
C --> D[Durable approval presentation]
D --> E[Shared channel view]
E --> F[Approval card]
D --> G[Operator clients]
Decision needed
Why: This is a persisted closed protocol shape with an acknowledged compatibility tradeoff; code review cannot decide whether that operator impact is acceptable. Before merge
Agent review detailsSecurityNone. PR surfaceSource +172, Tests +354, Docs +76, Other +120. Total +722 across 44 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Mantis proof suggestionA redacted Telegram Desktop capture would directly show the new Scope line in one changed channel surface. A maintainer can ask Mantis to capture proof by posting this exact PR comment: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep scope opt-in and display-only, while either preserving older-reader tolerance for pending records or recording explicit protocol-owner acceptance of the short-lived incompatibility. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds a new approval-card capability rather than repairing a reported failure. Is this the best way to solve the issue? Unclear: the producer-to-shared-view design is coherent, but its persisted-protocol downgrade behavior needs explicit owner acceptance or compatibility proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f7bd83d1b2f9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
Mantis could not complete this proof. Open the failed run. |
Live channel proof (iMessage, real gateway)Rig: isolated dev gateway from this branch's dist ( Before — card without scope (current behavior, unchanged): After — After — Also observed live: the fail-closed lifecycle messages ( Decision buttons/reactions are untouched by this PR (card content only); decision handling is covered by the existing suites plus the new handler tests. |
ccd46b7 to
40ea7ea
Compare
Approval owners can attach a closed ApprovalScope union (message-send, payment, external-post) describing an action's blast radius. The gateway sanitizes it once at the producer boundary, the core view model renders a Scope metadata row so Slack/Discord/Google Chat cards show it unchanged, shared text builders cover Telegram/WhatsApp/Signal/iMessage/Matrix, and the durable presentation carries it additively for operator surfaces. Scope is display-only, never authorization; missing scope keeps today's cards.
…reviews Name the three scope variants as registered protocol schemas so the Swift generator emits the ApprovalScope discriminated union the presentation structs reference, and commit the regenerated GatewayModels.swift. Clamp recipient previews to the declared recipientCount at the sanitize boundary so a count of 1 with 2 previews can no longer render inconsistently. Addresses both ClawSweeper findings on #130116.
40ea7ea to
575ca5d
Compare
|
Both ClawSweeper findings are addressed in 575ca5d:
Third rank-up move (contract confirmation): the public scope contract is intentional and documented in |
…ls import cycle check:architecture flagged approval-scope joining the exec-approvals SCC through exec-approval-command-display. Move the self-contained display sanitizer into a leaf module (exec-approval-text-sanitize) with no exec-approvals imports and migrate all sanitize importers; command-display keeps only the payload-typed command/preview resolver.
…r extraction The approval display sanitizers left the publicly reachable SDK graph when they moved to the exec-approval-text-sanitize leaf: exports 4343 -> 4338, callable exports 2582 -> 2578. Shrink-only budget pin.
|
Merged via squash.
|
…nclaw#130116) * feat(approvals): typed approval scope summaries on channel cards Approval owners can attach a closed ApprovalScope union (message-send, payment, external-post) describing an action's blast radius. The gateway sanitizes it once at the producer boundary, the core view model renders a Scope metadata row so Slack/Discord/Google Chat cards show it unchanged, shared text builders cover Telegram/WhatsApp/Signal/iMessage/Matrix, and the durable presentation carries it additively for operator surfaces. Scope is display-only, never authorization; missing scope keeps today's cards. * fix(approvals): emit native ApprovalScope union and clamp recipient previews Name the three scope variants as registered protocol schemas so the Swift generator emits the ApprovalScope discriminated union the presentation structs reference, and commit the regenerated GatewayModels.swift. Clamp recipient previews to the declared recipientCount at the sanitize boundary so a count of 1 with 2 previews can no longer render inconsistently. Addresses both ClawSweeper findings on openclaw#130116. * refactor(approvals): extract text sanitizer to break the exec-approvals import cycle check:architecture flagged approval-scope joining the exec-approvals SCC through exec-approval-command-display. Move the self-contained display sanitizer into a leaf module (exec-approval-text-sanitize) with no exec-approvals imports and migrate all sanitize importers; command-display keeps only the payload-typed command/preview resolver. * chore(plugin-sdk): ratchet public surface budgets down after sanitizer extraction The approval display sanitizers left the publicly reachable SDK graph when they moved to the exec-approval-text-sanitize leaf: exports 4343 -> 4338, callable exports 2582 -> 2578. Shrink-only budget pin.



What Problem This Solves
Channel approval cards today show only the command or title text. For consequence-bearing tool calls — message/email sends, payments, external posts — the reviewer cannot see the blast radius: how many recipients, what amount, which target system, internal vs external audience. Approving "Send customer update" without knowing it goes to 3 external addresses is a bad approval experience.
Why This Change Was Made
Adds a small typed "approval scope" contract the approval owner attaches when it knows the consequences, rendered on every channel with native approvals:
ApprovalScopeSchemain the gateway protocol:message-send(target, recipientCount, bounded recipient previews, internal/external audience),payment(decimal amount string, currency, payee),external-post(target, public/restricted visibility). No freeform arm — extending later is an additive union member.src/infra/approval-scope.ts: one bounded summary line (Send to 3 recipients via email (external): alice@…, bob@…, +1 more) and sanitize-once at the producer boundary (same bidi/invisible-char escaping as approval titles; post-escape overflow drops the scope, never the approval).plugin.approval.request/exec.approval.requestwire params,requireApproval.scopein the plugin SDK hook result, node-invoke policy, embedded broker path.Scopemetadata row (Slack/Discord/Google Chat cards pick it up with zero adapter changes) and the shared text builders add aScope:line (Telegram/WhatsApp/Signal/iMessage/Matrix). Channel adapters only pass the typed fact through — no scope inference from strings anywhere.scopeon the protocol approval presentations, so the operator approval store and Control UI clients carry it. Note: a downgraded reader (older closed presentation schema) rejects persisted presentations carryingscope; accepted — approvals are short-lived and beta contracts aren't shipped.Scope is display-only, never authorization; missing scope renders exactly today's cards.
User Impact
Approval cards on all native-approval channels now state what an action will actually touch before the operator taps Allow. Plugin authors get a documented, typed
requireApproval.scopefield (docs/plugins/plugin-permission-requests.md, docs/tools/exec-approvals.md).Evidence
pnpm check:changedgreen;pnpm plugin-sdk:surface:checkgreen (export budget 4340→4341 for the one new public type);pnpm buildclean.Before — approval card without scope (current behavior, unchanged):
After —
message-sendscope (recipient count, bounded previews, external audience):After —
paymentscope (amount, currency, payee) withcriticalseverity:Production LOC ≈ +156/−3; the rest is tests and docs. Follow-ups: render scope natively in the Control UI approval inbox; wire the first bundled producer (message/email tools) to declare scope.