You're offline — showing cached data

MC-4940

ccgram: Telegram RetryAfter/rate-limit delivery hardening for luci-persistent/foreign tmux sessions
2026-06-13 07:35:02 SAST
Home Board MC-4940

ccgram: Telegram RetryAfter/rate-limit delivery hardening for luci-persistent/foreign tmux sessions

## Bug: ccgram does not deliver INBOUND messages from foreign tmux sessions (e.g. luci-persistent) **Reported:** Elmar, 2026-06-10. "Messages TO luci-persistent work, but I get...
State Done Next Action Closed Owner Luci Runtime Closed Age 2d ago
MC-4940
Ticket is done; runtime is closed. · profile claude_opus_1m_medium

Description

MC-4940
## Bug: ccgram does not deliver INBOUND messages from foreign tmux sessions (e.g. luci-persistent) **Reported:** Elmar, 2026-06-10. "Messages TO luci-persistent work, but I get nothing back FROM it." ### Symptom - Outbound (Telegram topic → luci-persistent): works (send_keys to the bound window). - Inbound (luci-persistent output → Telegram): silently dropped. Same for any non-`ccgram:` tmux session (e.g. `mc-root:`). ### Evidence chain (all verified live on Luci) 1. Topic 1227 (user 246672479) is bound to foreign window `luci-persistent:@2` in `~/.ccgram/state.json` thread_bindings. ✓ (outbound proves the binding.) 2. luci-persistent's Claude hooks fire — `~/.ccgram/events.jsonl` has its Stop/Notification/SessionStart events, tagged `session_id=2952377d-9acb…`, `window_id=None` (events carry sid only, not window). ✓ 3. `state.json` WindowState `luci-persistent:@2` is correct: `session_id=2952377d…`, `external=true`. ✓ 4. `session_resolver.find_users_for_session(sid)` iterates thread_bindings, matches WindowState.session_id → would resolve topic 1227. ✓ 5. **ROOT CAUSE — `session_monitor.py:255-256`:** ```python prefix = f"{config.tmux_session_name}:" # = "ccgram:" return parse_session_map(raw, prefix) ``` `_load_current_session_map()` prefix-filters session_map to ONLY `ccgram:` keys. `_cleanup_all_stale_sessions` (264) and `_detect_and_cleanup_changes` (280) build `active_session_ids` from this filtered map, so foreign keys (`luci-persistent:@2`, `mc-root:@1`) are excluded → their session_ids are never in the tracked/active set → their transcripts are never tailed for content → inbound content is never routed. Native `ccgram:@N` windows (e.g. this session @30) match the prefix and deliver fine — which is why only foreign sessions are affected. ### Fix direction Broaden the monitored set to include **explicitly thread-bound foreign/external sessions**, not just `{tmux_session_name}:`-prefixed ones. Options: - (a) In `_load_current_session_map`, union the prefix-matched entries with any session_map entry whose window_id is present in `thread_router.iter_thread_bindings()` (i.e. a user is bound to it). emdash foreign windows already work this way — luci-persistent is the manually-bound foreign case the prefix filter misses. - (b) Or have `parse_session_map` keep entries for windows with a live binding regardless of prefix. Keep `make check` green (4500+ unit/integration tests); add a regression that a bound non-`ccgram:` session's new assistant message routes to its topic. Be careful NOT to start monitoring truly-dead sessions (see hygiene item). ### Secondary (hygiene, not the root cause) `~/.ccgram/session_map.json` has **1590 entries**, most dead (`mc-MC-26xx:@N`, April-era, transcripts missing on disk). Prune entries whose transcript_path is gone AND window no longer exists. Reduces monitor scan cost + reverse-lookup noise. ### Constraints - ccgram is the SOLE Telegram poller (MC-2617). Any change requires a careful `ccgram.service` restart — two pollers on one token = 409 + outage. Restart ccgram only after `make check` passes. - File: `~/workspace/ccgram/src/ccgram/session_monitor.py` (+ `session_map.py` parse_session_map). Tier 2, dev-loop.

Activity

done
Luci is working...
Live
No activity yet
Help