Skip to content

[codex] route Telegram poll_answer updates - #95309

Closed
liaoyl830 wants to merge 2 commits into
openclaw:mainfrom
liaoyl830:codex/telegram-poll-answer-routing
Closed

liaoyl830 wants to merge 2 commits into
openclaw:mainfrom
liaoyl830:codex/telegram-poll-answer-routing

Conversation

@liaoyl830

@liaoyl830 liaoyl830 commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • route Telegram poll_answer updates through agent turns by adding a poll_id context cache
  • record poll routing context when sendPollTelegram sends a poll
  • persist poll routing context in Telegram plugin state instead of a session-store JSON sidecar
  • add Telegram coverage for poll context persistence, legacy sidecar migration, and poll_answer event handling

Root cause

Telegram poll_answer updates do not include chat_id or thread routing metadata, so the runtime had no way to resolve the target conversation after a user voted in a poll.

Impact

Non-anonymous Telegram poll votes can now reach the correct agent session, including forum-topic sessions when the poll was sent in a topic.

Validation

  • node scripts/run-vitest.mjs extensions/telegram/src/send.test.ts --testNamePattern 'poll'
  • node scripts/run-vitest.mjs extensions/telegram/src/bot.test.ts --testNamePattern 'poll_answer|poll answer|poll context'
  • plugin-state migration coverage verifies restart persistence without writing .telegram-poll-context.json, and imports existing legacy sidecars into plugin state on first read

Notes

  • This addresses issue Telegram poll_answer updates are not routed to agent turns #89573.
  • Live Telegram proof has been requested separately in the PR thread so the storage-shape fix and behavior proof can land independently.
  • A second local rerun on the fresh branch previously hit a missing local rastermill dependency in this environment, but the targeted Telegram tests above passed on the current branch.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 20, 2026
@clawsweeper

clawsweeper Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 27, 2026, 2:25 PM ET / 18:25 UTC.

Summary
This draft adds a Telegram poll context store, records poll IDs from sendPollTelegram, routes poll_answer updates into system events, and adds focused Telegram tests.

PR surface: Source +440, Tests +221. Total +661 across 7 files.

Reproducibility: yes. Source inspection shows current main can send Telegram polls and request poll-capable updates, but no current-main handler routes a later poll_answer update into an agent-visible event.

Review metrics: 1 noteworthy metric.

  • Persistent State Surface: 1 namespace added; 1 runtime sidecar import/delete path added. The PR changes stored Telegram plugin state and adds runtime compatibility behavior that maintainers should settle before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #89573
Summary: This PR is a candidate fix for the canonical Telegram poll_answer routing issue; a newer open PR overlaps but still lacks positive live proof, so it is not yet a safe superseding close target.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add the requireTopic/no-topic guard for poll_answer DM events and cover it with a focused test.
  • Remove the unshipped .telegram-poll-context.json runtime migration and compatibility test.
  • [P1] Add redacted live Telegram proof showing a non-anonymous poll vote reaching the intended direct and topic-agent session.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body supplies focused Vitest commands and a Mantis request, but no redacted live Telegram recording, terminal output, logs, or linked artifact showing a real poll vote reaching the session; after adding proof, update the PR body for re-review or ask a maintainer to comment @clawsweeper re-review.

Mantis proof suggestion
Native Telegram Desktop proof would directly show a real user voting in a non-anonymous poll and the resulting OpenClaw session event. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify a non-anonymous Telegram poll vote reaches the correct OpenClaw direct and topic-agent sessions.

Risk before merge

  • [P1] No redacted live Telegram recording, terminal output, logs, or linked artifact shows a real non-anonymous poll vote reaching the intended direct or topic session on this head.
  • [P1] The poll_answer handler can enqueue a DM poll vote into the base session when requireTopic=true and no topic is known, bypassing the topic-only routing policy used by reactions and callbacks.
  • [P1] The runtime sidecar import/delete path adds compatibility behavior for state written only by earlier unmerged versions of this draft.
  • [P1] Another open candidate targets the same canonical issue, so maintainers should choose one implementation path before the two poll-answer registries drift.

Maintainer options:

  1. Fix Routing And Drop Branch-Only Migration (recommended)
    Add the poll_answer requireTopic guard, remove the legacy .telegram-poll-context.json runtime migration and test, then rerun the focused Telegram tests before live proof.
  2. Require Live Telegram Proof
    Keep the draft blocked until a redacted Telegram Desktop recording, terminal output, logs, or linked artifact proves a real poll vote reaches the intended direct and topic session.
  3. Defer To The Cleaner Candidate
    If maintainers prefer the newer keyed-state implementation in fix(telegram): route poll answers into sessions #95830, keep this draft open only until that candidate has positive live proof or close it after a proof-positive replacement exists.

Next step before merge

  • [P1] Human follow-up is needed because the PR has concrete code blockers and the external real-behavior proof gate cannot be satisfied by repair automation.

Security
Needs attention: The diff adds a concrete Telegram authorization-boundary concern because poll_answer can bypass requireTopic DM routing and wake the base session.

Review findings

  • [P1] Block requireTopic DMs before enqueueing poll answers — extensions/telegram/src/bot-handlers.runtime.ts:1967-1973
  • [P2] Remove the branch-only poll sidecar migration — extensions/telegram/src/poll-context-store.ts:188-228
Review details

Best possible solution:

Land one Telegram plugin fix that stores poll origin in keyed plugin state, honors requireTopic and conversation routing, removes branch-only sidecar migration, and includes redacted live Telegram proof for direct and topic poll votes.

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

Yes. Source inspection shows current main can send Telegram polls and request poll-capable updates, but no current-main handler routes a later poll_answer update into an agent-visible event.

Is this the best way to solve the issue?

No, not merge-ready. The send-boundary plugin-state approach is plausible, but this draft should add the missing requireTopic guard, remove branch-only sidecar migration, and provide live Telegram proof before merge.

Full review comments:

  • [P1] Block requireTopic DMs before enqueueing poll answers — extensions/telegram/src/bot-handlers.runtime.ts:1967-1973
    For DMs with requireTopic=true, reactions and callbacks return when no topic is known, but this new poll_answer path proceeds from authorization into resolveTelegramSessionState and can wake the base DM session. Add the same requireTopic/no-topic guard before resolving or enqueueing the event.
    Confidence: 0.88
  • [P2] Remove the branch-only poll sidecar migration — extensions/telegram/src/poll-context-store.ts:188-228
    The plugin-state store still imports and deletes ${store}.telegram-poll-context.json, but that file was only written by an earlier unmerged version of this draft. Keeping runtime migration code for branch-only cache state adds unnecessary steady-state file probing/deletion and conflicts with the existing doctor/plugin-state migration pattern.
    Confidence: 0.87

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded Telegram channel bugfix with real poll-vote delivery impact but limited blast radius outside Telegram poll flows.
  • merge-risk: 🚨 compatibility: The diff adds a persistent plugin-state namespace plus runtime import/delete behavior for an unshipped poll sidecar path.
  • merge-risk: 🚨 message-delivery: The new handler controls whether Telegram poll votes are delivered, skipped, or routed to the wrong agent session.
  • merge-risk: 🚨 security-boundary: The handler can bypass the Telegram DM requireTopic policy and wake a base session when no topic is known.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body supplies focused Vitest commands and a Mantis request, but no redacted live Telegram recording, terminal output, logs, or linked artifact showing a real poll vote reaching the session; after adding proof, update the PR body for re-review or ask a maintainer to comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram poll-vote behavior that can be demonstrated in a short Telegram Desktop proof recording.
Evidence reviewed

PR surface:

Source +440, Tests +221. Total +661 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 440 0 +440
Tests 2 222 1 +221
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 662 1 +661

Security concerns:

  • [medium] Poll answers bypass requireTopic DM isolation — extensions/telegram/src/bot-handlers.runtime.ts:1967
    The new handler lacks the explicit requireTopic/no-topic block used by adjacent Telegram event paths, so a poll vote without cached topic metadata can enqueue work in the base DM session despite topic-only policy.
    Confidence: 0.86

What I checked:

Likely related people:

  • joshavant: Current-main blame for resolveTelegramSessionState and resolveTelegramConversationRoute points to recent work on the routing helpers this PR must follow. (role: recent routing contributor; confidence: medium; commits: ff35f3bb2cd6; files: extensions/telegram/src/bot-handlers.runtime.ts, extensions/telegram/src/conversation-route.ts)
  • akyourowngames: Authored the merged Telegram poll action wiring PR that established the shipped poll send surface this PR extends. (role: poll feature contributor; confidence: high; commits: 433bfe3278ff, b641a749c79f, d68dbbf87443; files: src/telegram/bot-handlers.ts, src/telegram/poll-vote-cache.ts, src/telegram/send.ts)
  • steipete: Merged the prior Telegram poll action wiring PR, making them a useful routing candidate for the historical product boundary. (role: poll PR merger; confidence: medium; commits: 0a02b916380f; files: src/telegram/bot-handlers.ts, src/telegram/send.ts)
  • miorbnli: Current history shows recent Telegram send-path work, which is adjacent to the sendPollTelegram boundary this PR changes. (role: recent adjacent send contributor; confidence: low; commits: ce15f348bbc4; files: extensions/telegram/src/send.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

@openclaw-mantis telegram desktop proof: verify a non-anonymous Telegram poll vote reaches the correct OpenClaw agent session, including topic routing when applicable.

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 20, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 16, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram 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: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant