Skip to content

[argus] patch #40: extract Telegram send path to _telegram_sender.py#6

Merged
Nichol4s merged 1 commit into
argusfrom
argus-patch-40-telegram-sender
Jul 2, 2026
Merged

[argus] patch #40: extract Telegram send path to _telegram_sender.py#6
Nichol4s merged 1 commit into
argusfrom
argus-patch-40-telegram-sender

Conversation

@Nichol4s

@Nichol4s Nichol4s commented Jul 2, 2026

Copy link
Copy Markdown

What

FORK-REVIEW lever 1 / stability-plan item 8. Moves the argus Telegram send path (stage-emoji indicator, HTML chunked sends with retry + plain-text fallback) out of telegram.py into argus-owned backend/app/channels/_telegram_sender.py (zero merge tax, like _telegram_format.py / _coalesce.py / _artifact_presenter.py). telegram.py keeps three thin bound-method shims (send, _send_running_reply, _send_running_reply_safe) plus its other carried patches (bytedance#17 welcome/lock, bytedance#28 webhook).

Upstream v2.0.0's superseded edit-in-place stream helpers (_send_stream_update .. _split_message, constants, _stream_messages init) are restored byte-identical as fenced, unreachable code so upstream churn in those regions merges clean instead of modify/delete-conflicting on every sync. The restored regions show zero diff vs v2.0.0.

Design constraints (why the shape is what it is)

  • ALL mutable state stays on the channel instance (init_state(channel, config) from __init__) — test_telegram_send.py reads/writes ch._working_msg & friends directly.
  • _send_running_reply_safe dispatches through the bound self._send_running_reply, never the module function — test_channels.py::TestTelegramProcessingOrder and test_telegram_channel_connections.py override it per instance.
  • send_file is byte-identical upstream and is untouched; manager.py is untouched (its [argus] patch #46: tool_search.exclude — deferral opt-out for hot MCP tools #10 hand-off seam is already minimal and tested).

Zero behavior change — proof

  • Existing suites run byte-unmodified. Full backend suite: baseline at d8ef0d1 = 5007 passed / 2 failed / 17 skipped; after this PR = 5016 passed / 2 failed / 17 skipped (+9 = the new seam tests). The 2 failures are the same pre-existing env-dependent test_artifacts_router.py xhtml cases in both runs.
  • New test_telegram_sender_seam.py (9 tests) locks the shim delegation and the upstream contracts the sender consumes (OutboundMessage.progress_stage/is_final/chat_id, _application resolved at call time, Channel._on_outbound → send), so a future bad merge that resurrects upstream's send body fails loudly.
  • make test-blocking-io green (21 passed); diff-scoped scan_changed_blocking_io.py reports no new candidates.

Carry impact (measured vs v2.0.0, insertions+deletions on files existing at v2.0.0)

Scope before after
telegram.py 574 251
app/channels/ app code 1099 776
app code excl. tests/docs 2246 1923

PATCHES.md updated in the same commit (hard rule): new bytedance#40 section, #9-chain files/delete-when reword, carry-ledger row + methodology note, and a fix to the stale bytedance#39 status note (it still said "NOT yet on argus tip" although f37b829 merged it — the d8ef0d1 ledger rebuild was authored against 2df36c9).

CI notes

  • patches-ledger, backend-unit-tests, backend-blocking-io-tests should be green.
  • lint-backend and frontend-unit-tests are red on pre-existing debt, unrelated to this PR. ruff check is clean on all three changed/new files; ruff format --check is clean on the two new files, and its single finding in telegram.py is a pre-existing patch-refactor: refactor the prompt management mechanism bytedance/deer-flow#17 hunk also present at the current tip (left alone to keep this PR behavior/format-pure).
  • Cosmetic: log lines emitted by the moved code now carry logger name app.channels._telegram_sender instead of app.channels.telegram. No test or tooling depends on it.

After merge

Pin bump in VERSIONS.md + make deerflow-canary (live Telegram round-trip: stage emoji animates, HTML reply, indicator cleared on final) then make deerflow-promote.

🤖 Generated with Claude Code

…ender.py (carry-reduction refactor)

telegram.py was the fork's dominant merge tax (574 changed lines vs v2.0.0,
~80% of the v2.0.0 rebase effort). Move the argus send path (stage-emoji
indicator, HTML chunked sends with retry + plain-text fallback) verbatim into
argus-owned _telegram_sender.py as channel-first free functions; state stays
on the channel instance and telegram.py keeps three bound-method shims.
Restore upstream's superseded stream-edit helpers byte-identical as fenced,
unreachable code so upstream churn there merges clean instead of
modify/delete-conflicting on every sync.

Zero behavior change: the pre-existing suite runs unmodified (5016 passed,
same 2 pre-existing env-dependent artifacts-router failures as the baseline).
New test_telegram_sender_seam.py locks the shim delegation and upstream
contracts. telegram.py carry: 574 -> 251; app/channels app-code carry:
1099 -> 776.

Also refresh PATCHES.md: bytedance#40 section, #9-chain files/delete-when reword,
stale bytedance#39 status note (merged as f37b829), carry-ledger row + methodology
note.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Nichol4s
Nichol4s merged commit a8516b0 into argus Jul 2, 2026
4 of 6 checks passed
@Nichol4s
Nichol4s deleted the argus-patch-40-telegram-sender branch July 2, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant