Skip to content

refactor(telegram): consolidate outbound contracts and targets - #119438

Merged
steipete merged 1 commit into
mainfrom
codex/loc-0804-telegram-luem8u
Aug 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-0804-telegram-luem8u

Conversation

@steipete

@steipete steipete commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Telegram outbound actions, edits, forum topics, and rich-message handling duplicated equivalent option contracts and target parsing. This is part of a maintainer-requested project-wide production LOC reduction campaign.

Why This Change Was Made

Move equivalent outbound options to their canonical Telegram owner and share behavior-identical target/record parsing without changing the plugin public surface.

User Impact

Telegram sending, editing, unsafe-topic rejection, reply threading, and rich-message formatting remain unchanged; removes 127 production lines.

Evidence

Exact-head Telegram mock-gateway delivery proof

An isolated in-memory mock gateway loaded nine actual committed production modules, verified their exact Git object IDs, and executed the real Telegram outbound adapter through the real send owner and text sender into a synthetic Bot API. No Telegram token, network, operator gateway, or live account was used. The following JSON was actually observed and asserted:

{
  "verdict": "PASS",
  "head": "38250ac3b0afe00f5fcee841df82a291a64fa8bd",
  "execution": "real Telegram outbound adapter -> real sendMessageTelegram -> real text sender -> synthetic Bot API; no token or network",
  "cases": [
    {
      "scenario": "target-qualified direct chat",
      "target": "telegram:123456789",
      "parsed": {"chatId":"123456789","chatType":"direct"},
      "botApiRequest": {"method":"sendMessage","chat_id":"123456789","text":"direct target-qualified delivery","parse_mode":"HTML"},
      "gatewayDelivery": {"channel":"telegram","messageId":"9001","chatId":"123456789","meta":{"telegramDeliveredText":"direct target-qualified delivery","telegramHasInlineKeyboard":false}},
      "result": {"channel":"telegram","messageId":"9001","chatId":"123456789"}
    },
    {
      "scenario": "target-qualified forum topic",
      "target": "telegram:group:-1001234567890:topic:77",
      "parsed": {"chatId":"-1001234567890","messageThreadId":77,"chatType":"group"},
      "botApiRequest": {"method":"sendMessage","chat_id":"-1001234567890","text":"forum target-qualified delivery","parse_mode":"HTML","message_thread_id":77},
      "gatewayDelivery": {"channel":"telegram","messageId":"9002","chatId":"-1001234567890","meta":{"telegramDeliveredText":"forum target-qualified delivery","telegramHasInlineKeyboard":false}},
      "result": {"channel":"telegram","messageId":"9002","chatId":"-1001234567890"}
    },
    {
      "scenario": "unsafe topic suffix rejected before Bot API",
      "target": "telegram:group:-1001234567890:topic:9007199254740992",
      "parsed": {"chatId":"-1001234567890:topic:9007199254740992","chatType":"unknown"},
      "rejection": "Telegram recipient target is not a valid numeric chat ID",
      "botApiCallsBefore": 2,
      "botApiCallsAfter": 2
    }
  ]
}

All production-path assertions passed at the exact reviewed commit. Direct chat, group forum-thread propagation, mock-gateway delivery metadata, and rejection before any unsafe Bot API call are demonstrated without external side effects.

Base-refresh disposition: Current main has not changed any of the seven touched Telegram production paths since this branch diverged. A rebase is therefore intentionally skipped: it would replace the already-reviewed exact commit and invalidate its 427 passing focused tests, full remote changed gate, exact-head hosted ci-gate, and production mock-gateway proof without addressing a conflict. The canonical maintainer merge workflow rechecks current-main drift immediately before landing and treats it as advisory.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: M maintainer Maintainer-authored PR labels Aug 5, 2026
@steipete
steipete marked this pull request as ready for review August 5, 2026 02:50
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 11:27 PM ET / August 5, 2026, 03:27 UTC.

ClawSweeper review

What this changes

The branch centralizes private Telegram outbound option contracts and target parsing while preserving sending, editing, forum-topic, and rich-message behavior.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness or security finding was found. This is a behavior-preserving Telegram refactor with sufficient exact-head mock-gateway proof; the protected maintainer label requires an authorized final merge decision.

Priority: P3
Reviewed head: 38250ac3b0afe00f5fcee841df82a291a64fa8bd
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused net-negative refactor with source-equivalence checks, passing hosted validation, and sufficient exact-head delivery proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies exact-head observed output from the real outbound adapter and sender through a synthetic Bot API for direct delivery, forum-thread propagation, and unsafe-target rejection; the repository policy accepts this mock-gateway proof for channel-visible behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies exact-head observed output from the real outbound adapter and sender through a synthetic Bot API for direct delivery, forum-thread propagation, and unsafe-target rejection; the repository policy accepts this mock-gateway proof for channel-visible behavior.
Evidence reviewed 6 items Equivalent outbound contracts: The branch derives common private option bags from the existing send options; its action, edit, and special-send consumers retain the same fields used by their prior local contracts.
Target semantics preserved: The branch keeps explicit topic parsing ahead of generic suffix parsing and returns the original normalized target when a suffix is invalid or unsafe; existing tests cover both forms, prefixes, and unsafe integers.
Canonical record guard: The replacement SDK guard is exactly the removed non-null, object, non-array predicate, so rich-message recognition does not change.
Findings None None.
Security None None.

How this fits together

Gateway and action requests enter the Telegram plugin, which parses a recipient and optional topic before invoking Telegram operations. Those operations return delivery metadata to the channel and gateway layers.

flowchart LR
A[Gateway or action request] --> B[Telegram plugin]
B --> C[Target and option normalization]
C --> D[Send edit or action]
D --> E[Telegram Bot API]
E --> F[Delivery metadata]
Loading

Decision needed

Question Recommendation
Does an authorized Telegram owner approve landing this behavior-preserving refactor after GitHub’s final clean merge-result check? Approve after merge-result check: Land the current exact head if GitHub continues to report a clean merge result and required checks remain green.

Why: The patch is clean, proof-positive, and has no actionable defect, but the protected maintainer label requires an explicit human merge decision.

Before merge

  • Resolve merge risk (P1) - GitHub should perform its standard exact-head merge-result check because the branch is behind current main, although current main has not changed any touched Telegram path since the branch base.
Agent review details

Security

None.

PR surface

Source -127. Total -127 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 7 66 193 -127
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 66 193 -127

Review metrics

Metric Value Why it matters
Production versus test LOC production +66/-193 (net -127); tests +0/-0 The refactor removes duplicated production contracts without expanding the test surface; existing focused tests cover the retained behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the single owner-local outbound contract and parser, then land after an authorized Telegram owner confirms the clean GitHub merge result.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the single owner-local outbound contract and parser, then land after an authorized Telegram owner confirms the clean GitHub merge result.

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

Not applicable: this PR refactors existing Telegram behavior rather than addressing a reported user-visible defect.

Is this the best way to solve the issue?

Yes. Consolidating behavior-identical private contracts at the Telegram owner keeps one canonical path without expanding the plugin or SDK surface.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a behavior-preserving internal Telegram cleanup with no reported user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies exact-head observed output from the real outbound adapter and sender through a synthetic Bot API for direct delivery, forum-thread propagation, and unsafe-target rejection; the repository policy accepts this mock-gateway proof for channel-visible behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head observed output from the real outbound adapter and sender through a synthetic Bot API for direct delivery, forum-thread propagation, and unsafe-target rejection; the repository policy accepts this mock-gateway proof for channel-visible behavior.

Evidence

What I checked:

Likely related people:

  • steipete: Recent history includes the Telegram outbound split and canonical topic-mutation work, and the current refactor continues that owner-boundary cleanup. (role: recent area contributor; confidence: high; commits: 07e625dac38f, 745b9a9ca9e1, 0881c7d27b3e; files: extensions/telegram/src/send-actions.ts, extensions/telegram/src/send-edit.ts, extensions/telegram/src/send-special.ts)
  • Dallin Romney: The available shallow-history boundary and current blame attribute the present target and contract source lineage to this contributor; older provenance is unavailable locally. (role: recent source-lineage contributor; confidence: low; commits: 8fc44585931d; files: extensions/telegram/src/targets.ts, extensions/telegram/src/send-message-types.ts)

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-08-05T03:03:30.178Z sha 38250ac :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T03:18:43.231Z sha 38250ac :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@steipete
steipete merged commit ad37e91 into main Aug 5, 2026
197 of 212 checks passed
@steipete
steipete deleted the codex/loc-0804-telegram-luem8u branch August 5, 2026 03:33
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 5, 2026
* origin/main:
  fix(channels): honor explicit preview streaming settings
  refactor(telegram): consolidate outbound contracts and targets (#119438)
  fix(qa): retry transport cleanup and always stop owned labs (#119442)
  fix(mcp): guard stdio stdout frame parsing against oversized-buffer crash (#119379)
  refactor(auto-reply): centralize delivery deduplication and routing (#119436)
  fix(qa): preserve scenario isolation in serial suites (#119439)
  perf(xai): lazy-load optional capability runtimes (#119374)
  refactor(browser): consolidate browser CLI and normalization helpers (#119432)
  fix(qa): require ready transport accounts (#119431)
  refactor(media): share image and video geometry normalization (#119416)
  fix(config): preserve plugin metadata for missing config (#119421)
  fix: retry delivery when outbound adapter is unavailable (#119371)
  fix(cli): retire invalid secret flags and prove doctor recovery (#118926)
  refactor(signal): share outbound and reaction transport (#119415)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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