Skip to content

fix(telegram): enforce direct-message tool policies - #120992

Merged
obviyus merged 7 commits into
mainfrom
fix/telegram-direct-tool-policy
Aug 9, 2026
Merged

obviyus merged 7 commits into
mainfrom
fix/telegram-direct-tool-policy

Conversation

@obviyus

@obviyus obviyus commented Aug 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #44886

Problem

Telegram DM direct.<peer>.tools and toolsBySender were accepted, but native agent harnesses did not consume the selected requester policy. A denied tool could still be advertised and invoked.

Fix

Telegram resolves the direct policy from trusted ingress and carries it through queues, retries, compaction, and descendants into the canonical tool-policy pipeline. Core prepares one explicit-policy restriction fact for harnesses. Codex replaces its native surface with policy-filtered OpenClaw equivalents; Copilot filters its full catalog, including native ask_user. Harnesses that cannot certify exact enforcement now return a visible, actionable refusal.

No explicit policy keeps existing access and native behavior unchanged. Default profiles stay unchanged. Telegram groups stay unchanged. Exact peers replace wildcard entries; global, agent, sender, and direct layers still apply together.

Evidence

  • Red → green: removing only the ingress handoff reproduces the missing-policy assertion; the identical test passes on this head.
  • Current-main baseline: wildcard exec denial still advertised exec; the mock model attempted it, Telegram showed Exec progress, and the final reply arrived.
  • Live Telegram with Codex 0.147: the control used native shell; the restricted turn exposed only the allowed dynamic read path, produced no denied exec/write side effects, and returned a visible final; removing the policy restored the original native thread and behavior.
  • ClawSweeper P1 resolved: restricted pending supervision now disables and attests inherited MCP on both the probe and canonical thread before either is used; failed attestation cleans tracked threads without committing the binding.
  • Codex 0.147 contract verified from exact source: disabled MCP servers remain inactive status rows, so attestation matches the exact disabled set and requires every expected disabled row exactly once and rejects missing, duplicate, active, tool-bearing, or unexpected rows.
  • Focused suites: 903 tests passed; supervision/attestation follow-up: 242 tests passed; Copilot hygiene rerun: 80 tests passed.
  • Blacksmith Testbox changed gate: passed.
  • Plugin SDK API/surface, docs, formatting, and diff checks passed.
  • Exact-head autoreview after rebase: clean, confidence 0.97.

AI-assisted maintainer change; implementation and evidence reviewed.

@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@obviyus
obviyus marked this pull request as ready for review August 9, 2026 08:06
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: telegram Channel integration: telegram agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 9, 2026
@obviyus
obviyus force-pushed the fix/telegram-direct-tool-policy branch from 6776d1b to e3b3bfb Compare August 9, 2026 08:25
@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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 9:39 AM ET / 13:39 UTC.

ClawSweeper review

What this changes

The PR carries Telegram direct-message tool policy through the agent runtime and makes Codex and Copilot either enforce that restricted tool surface or visibly refuse it.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this protected maintainer PR open. The Telegram/core and Copilot paths look coherent and the prior MCP-attestation finding is addressed, but the required Codex dependency-source check cannot be completed because sibling ../codex is absent; do not treat the exact-enforcement certification as merge-ready yet.

Priority: P1
Reviewed head: 74d141a493baccb7da1a8ae25d2f9ac15de16945

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation is well-covered in source and tests, but confidence is capped until the required Codex dependency contract is directly inspected.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the claimed Codex live result still cannot substitute for direct dependency-contract inspection.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the claimed Codex live result still cannot substitute for direct dependency-contract inspection.
Evidence reviewed 5 items Telegram ingress and canonical policy path: At the PR head, direct policy is resolved for normal Telegram messages and native commands, recorded in inbound context, and passed into the existing requester-policy pipeline rather than introducing Telegram-specific policy logic in core.
Prior MCP-attestation blocker addressed: The new attestation requires one inactive, tool-free status row for every expected disabled MCP server and rejects missing, duplicate, active, malformed, tool-bearing, or unexpected rows; supervision applies it to both probe and canonical threads before binding.
Codex contract remains unverified: The PR pins Codex 0.147.0 and certifies exact enforcement based on its MCP-status behavior, but the required sibling Codex checkout is not present and a read-only review cannot provision it.
Findings None None.
Security Needs attention Verify the Codex MCP-status contract: Exact policy enforcement attests disabled MCP servers using Codex status rows, but the required Codex 0.147.0 source checkout is unavailable for independent verification of those row semantics.

How this fits together

Telegram resolves a trusted per-DM policy at ingress and attaches it to the queued agent run. Core applies that policy when selecting a harness and building its tool catalog, so a provider-native tool surface cannot bypass a configured denial.

flowchart LR
A[Telegram direct message] --> B[Trusted direct policy]
B --> C[Queued agent run]
C --> D[Shared tool-policy pipeline]
D --> E[Harness selection]
E --> F[Codex or Copilot tools]
F --> G[Reply or visible refusal]
Loading

Before merge

  • Resolve security concern: Verify the Codex MCP-status contract - Exact policy enforcement attests disabled MCP servers using Codex status rows, but the required Codex 0.147.0 source checkout is unavailable for independent verification of those row semantics.
  • Resolve merge risk (P1) - The exact Codex MCP-status contract behind conversationToolPolicySupport: "exact" is not independently verified because ../codex is unavailable.
  • Resolve merge risk (P1) - Existing restricted sessions using an uncertified third-party harness will now visibly refuse rather than run with a potentially bypassable native tool surface; this intentional compatibility transition needs upgrade-path confirmation before merge.

Findings

  • [medium] Verify the Codex MCP-status contract — extensions/codex/src/app-server/thread-requests.ts:559
Agent review details

Security

Needs attention: No supply-chain or workflow change was found, but the security-sensitive Codex exact-enforcement claim depends on an unavailable upstream source contract.

PR surface

Source +314, Tests +1064, Docs +32, Generated 0. Total +1410 across 62 files.

View PR surface stats
Area Files Added Removed Net
Source 42 455 141 +314
Tests 17 1088 24 +1064
Docs 2 33 1 +32
Config 0 0 0 0
Generated 1 74 74 0
Other 0 0 0 0
Total 62 1650 240 +1410

Review metrics

Metric Value Why it matters
Plugin harness contract 1 additive capability declaration The optional exact-enforcement certification affects how every plugin harness is admitted for restricted conversations.

Stored data model

Persistent data-model change detected: migration/backfill/repair: docs/plugins/sdk-agent-harness.md. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #44886
Summary: This PR is the active candidate fix for the Telegram direct-message policy enforcement defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Mantis proof suggestion

A Telegram Desktop recording would directly demonstrate that a denied tool is unavailable while the restricted conversation still receives its expected visible outcome. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify that a restricted direct-message turn does not expose or execute a denied tool and returns its final reply.

Merge-risk options

Maintainer options:

  1. Verify the Codex status contract (recommended)
    Provision and inspect the exact Codex 0.147.0 source behavior for disabled MCP status rows, then refresh this review on the same head.
  2. Accept the fail-closed transition
    Merge with the documented behavior that uncertified harnesses visibly reject explicitly restricted conversations rather than bypass policy.

Technical review

Best possible solution:

Verify Codex 0.147.0 source semantics, then retain this single ingress-to-canonical-policy design and merge only if exact-head checks remain green.

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

Yes, from source: current main accepts the direct configuration but does not carry it from Telegram ingress into the requester-policy pipeline; the PR adds focused regression coverage for that handoff.

Is this the best way to solve the issue?

Unclear: the selected owner boundary is the best apparent fix, but the Codex native-MCP status contract must be checked from its exact upstream source before the certification can be accepted.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0dbce297fd40.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: A configured Telegram direct-message tool denial could previously be bypassed by native harnesses.
  • merge-risk: 🚨 compatibility: Restricted sessions on plugin harnesses without the new certification now receive a visible refusal instead of their previous runtime behavior.
  • merge-risk: 🚨 security-boundary: The PR changes authorization of executable and advertised tools across Telegram and provider-native harnesses.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the claimed Codex live result still cannot substitute for direct dependency-contract inspection.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes the visible behavior of restricted Telegram direct-message turns and their refusal or final reply.

Evidence

Security concerns:

  • [medium] Verify the Codex MCP-status contract — extensions/codex/src/app-server/thread-requests.ts:559
    Exact policy enforcement attests disabled MCP servers using Codex status rows, but the required Codex 0.147.0 source checkout is unavailable for independent verification of those row semantics.
    Confidence: 0.96

What I checked:

  • Telegram ingress and canonical policy path: At the PR head, direct policy is resolved for normal Telegram messages and native commands, recorded in inbound context, and passed into the existing requester-policy pipeline rather than introducing Telegram-specific policy logic in core. (extensions/telegram/src/bot-message-context.session.ts:642, 74d141a493ba)
  • Prior MCP-attestation blocker addressed: The new attestation requires one inactive, tool-free status row for every expected disabled MCP server and rejects missing, duplicate, active, malformed, tool-bearing, or unexpected rows; supervision applies it to both probe and canonical threads before binding. (extensions/codex/src/app-server/thread-requests.ts:559, 74d141a493ba)
  • Codex contract remains unverified: The PR pins Codex 0.147.0 and certifies exact enforcement based on its MCP-status behavior, but the required sibling Codex checkout is not present and a read-only review cannot provision it. (extensions/codex/package.json:11, 74d141a493ba)
  • Additive harness contract: Core fails closed for restrictive policies when a plugin harness has not opted into exact enforcement; Copilot opts in and derives its catalog from the canonical filtered OpenClaw tools. (src/agents/harness/selection.ts:681, 74d141a493ba)
  • Current-area provenance: Available current-main blame attributes the affected ingress/requester/harness boundary to Peter Steinberger; deeper history was unavailable in this shallow promisor checkout. (src/agents/harness/selection.ts:681, 4e9e7359f6a6)

Likely related people:

  • Peter Steinberger: Available current-main blame connects the Telegram ingress, requester-policy, and harness-selection boundary to this recent main commit; deeper history was unavailable. (role: recent area contributor; confidence: low; commits: 4e9e7359f6a6; files: extensions/telegram/src/bot-message-context.session.ts, src/agents/requester-tool-policy.ts, src/agents/harness/selection.ts)

Rank-up moves

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

  • Provision sibling ../codex at the pinned version and verify the disabled MCP status-row semantics before a fresh exact-head 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 (3 earlier review cycles)
  • reviewed 2026-08-09T08:54:38.086Z sha e3b3bfb :: found issues before merge. :: [P1] Enforce direct policies for native harnesses
  • reviewed 2026-08-09T11:47:10.085Z sha 82c2cd0e719a712ce9bf788fc41d9c43ee6bc804 :: found issues before merge. :: [P1] Propagate restricted MCP enforcement through supervision
  • reviewed 2026-08-09T12:40:44.665Z sha 76db88e5c6c19938fe915fb2c425755ea6b6ea9f :: needs changes before merge. :: [P1] Reject missing disabled MCP status rows

@obviyus

obviyus commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus
obviyus force-pushed the fix/telegram-direct-tool-policy branch from 34f0a58 to 82c2cd0 Compare August 9, 2026 11:24
@obviyus

obviyus commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 9, 2026
@obviyus
obviyus force-pushed the fix/telegram-direct-tool-policy branch from 76db88e to 13b3b90 Compare August 9, 2026 12:47
@obviyus

obviyus commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus

obviyus commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer decision: I accept the additive conversationToolPolicySupport: "exact" contract. Harnesses that cannot enforce an explicit conversation policy must return a visible refusal instead of silently bypassing it; turns with no explicit policy keep their existing behavior and tool access.

@obviyus
obviyus force-pushed the fix/telegram-direct-tool-policy branch from ee0c90e to 74d141a Compare August 9, 2026 13:34
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 9, 2026
@obviyus
obviyus force-pushed the fix/telegram-direct-tool-policy branch from 74d141a to 457ee66 Compare August 9, 2026 13:46
@obviyus
obviyus force-pushed the fix/telegram-direct-tool-policy branch from 457ee66 to 29f144d Compare August 9, 2026 14:02
@obviyus
obviyus merged commit 409fb7a into main Aug 9, 2026
47 checks passed
@obviyus
obviyus deleted the fix/telegram-direct-tool-policy branch August 9, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: telegram Channel integration: telegram docs Improvements or additions to documentation extensions: codex extensions: copilot maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram DM direct.tools appears accepted by config but is not reliably enforced as per-user tool policy

1 participant