Skip to content

feat(filters): channel probe — pre-add quality card from a LIVE sample - #1622

Merged
axisrow merged 2 commits into
mainfrom
feat-channel-probe
Oct 19, 2026
Merged

axisrow merged 2 commits into
mainfrom
feat-channel-probe

Conversation

@axisrow

@axisrow axisrow commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Что и зачем

Ответ на вопрос владельца «сколько постов нужно, чтобы определить качество канала?» — из
калибровок самого кода: 300 (quick-сэмпл анализатора, 99.65% совпадения с полным сканом),
окно engagement/forward — 100, минимум статистики — 30. Фича: channel probe — карточка
качества канала по живым последним постам до добавления в базу (сценарии 3+4: discovery
шорт-лист → probe → одобрение владельца).

  • tg_agent/filters/probe.py — чистая функция над снапшотами постов: low_engagement
    (views vs подписчики, окно-100), forwarder (label-only), auto_feed (короткие+ссылка,
    masked-ссылки из entities), low_uniqueness, non_cyrillic (label-only), chat_noise,
    suspicious_username, low_subscribers (min_subscribers_filter). Пороги импортируются из
    criteria.py — probe-флаг и пост-коллект-флаг означают одно и то же. <30 постов =
    insufficient. Метрики, требующие собранной истории (cross_channel_spam,
    low_subscriber_ratio), — в not_checked.
  • channel probe <id|@username> [--limit 300] [--json] — live-чтение через session pool
    (floodgate), подписчики через GetFullChannelRequest; резолв мимо fetch_channel_meta, чтобы
    не писать phone-map/dialog-cache. Никаких записей в channels/messages.
  • discovery.md шаг 3.5: probe каждого кандидата шорт-листа до одобрения; флаги
    forwarder/auto_feed/low_engangement топят кандидата.
  • manifest: channel probe = safe_ro.

Тесты

  • Новые юниты tests/test_filters_probe.py: каждая метрика pos/neg, guard <30, пороги
    из criteria (12 passed); policy + test_levels зелёные.
  • Боевой прогон (по согласию владельца): probe на кандидате из discovery-шорт-листа +
    на известном мусорном канале.

🤖 Generated with Claude Code

axisrow and others added 2 commits October 19, 2026 22:32
Scenario 3+4 followup: before adding a discovered channel, sample its recent
posts straight from Telegram and judge the quality — no DB write, no channel
row.

- tg_agent/filters/probe.py: pure function over ProbeMessage snapshots
  (text/views/forward/urls) + participants_count; thresholds are IMPORTED
  from criteria.py so a probe flag and a post-collect `filter analyze` flag
  mean the same thing. Sample guard: <30 posts = insufficient (the analyzer's
  own 30-post statistics guard). DB-history metrics (cross_channel_spam,
  low_subscriber_ratio) are reported as not_checked.
- `channel probe <id|@username> [--limit 300] [--json]`: live read via the
  session pool (floodgate-wrapped), subscribers via GetFullChannelRequest;
  resolves without fetch_channel_meta so no phone-map/dialog-cache writes.
  Default N=300 — the analyzer's calibrated quick-sample size (99.65%
  agreement with the full scan); 100 is the engagement/forward window.
- discovery.md step 3.5: probe every short-list candidate before user
  approval; forwarder/auto_feed/low_engagement flags sink the candidate.
- command_manifest: channel probe = safe_ro (live read, no DB write).

Co-Authored-By: Claude Code <noreply@anthropic.com>
CI on #1622 caught probe_impl in three regression guards:

- test_real_telegram_policy: a parser leaf needs live coverage or an
  excluded-manifest entry — safe_ro/test_channel_probe.py covers it
  (real_tg_safe, gated, mirrors `messages read --live`)
- test_cli_pool_classification: probe_impl classified RUNS_ANYWAY
  (read-only live card, no worker-queue equivalent)
- test_client_pool_lease_stress: probe_impl joins the lease-ownership
  allowlist (one-shot CLI; disconnect_all() in finally clears the lease)

Co-Authored-By: Claude Code <noreply@anthropic.com>
@axisrow
axisrow merged commit 191a98f into main Oct 19, 2026
8 checks passed
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