Skip to content

A channel's wakeFrom: only the people and places on it wake the bot, and the log keeps no text of the others - #137

Merged
Crokily merged 2 commits into
mainfrom
wake-list
Dec 4, 2026
Merged

Crokily merged 2 commits into
mainfrom
wake-list

Conversation

@Crokily

@Crokily Crokily commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Closes #130: a Telegram bot is public, anyone who finds it can DM it, and a DM wakes a bot that has full access to its computer.

Thanks to @krau for the issue and for #135, whose Telegram allowlist this generalises. His /setjoingroups step, his point that a @username must not be used, and his test cases are in here; the commit has him as co-author.

What it does

Any channel entry in bot.json can have wakeFrom: the addresses, as the log gives them, of the people, places and threads whose events may wake the bot there.

{ "id": "telegram", "type": "telegram", "secrets": "~/.pots/secrets/telegram-ada.env", "wakeFrom": ["telegram:@7712345678", "telegram:#-1001234567890"] }
  • No wakeFrom: nothing changes. []: nobody on that channel wakes the bot.
  • A listed place: everyone in it wakes the bot. A listed person: wakes it anywhere. The terminal has no entry in bot.json, so it is never limited.
  • The gate is in the gateway, for every channel: the log decides as it writes the event, as it already does for the bot's own events and for deletes. An event whose person, place and thread are all not on the list gets wake unlisted and never reaches the waker: no wake, no judge, no steer, no typing, no outage line, no file download.
  • An unlisted event keeps only who, where, when and its kind. No text, mentions, files or raw data, no gw_messages row, no thread name or place description, and its gw_inbox row loses its raw data in the same transaction that decides it. Bots read their log, and that text comes from people they do not know. The text of a join or a leave stays: the adapter writes it from names and addresses, such as "added by eve (telegram:@333)", so the bot can see who added it to a group and leave.
  • A change to a message the log keeps (an edit, a delete, an update) follows the message. The same message again from a backfill is logged once.
  • bot.json refuses an entry that is not an address of its channel ("@eve", 123). A change to wakeFrom applies to the next event without connecting the channel again.
  • No limit on where the bot sends: that stays its judgment.

The bot learns of strangers by reading its log (wake = 'unlisted'), as the system prompt says in one sentence. The Telegram skill connects with "wakeFrom": [], asks the person to DM the bot once, and has the bot take their address from the log.

What is not taken from #135

The adapter-level gate, the outbound guard, leaveUnauthorizedGroups, groupAllowUsers, the policy modes and the in-memory supergroup allowance. The gateway's list covers the same cases for every channel; the bot can leave a group itself with call; and a group that becomes a supergroup already gives its new address in the log.

Checks

  • npm run check, npm test (818 passed, 4 skipped), npm run tla with spec/Inbox.tla in step: events the log decides as it writes them are never woken, and an unlisted one leaves no text on disk once decided (Inbox.unlisted.cfg).
  • New tests: the inbox and log rules on the memory channel, bot.json end to end with the test channel (a stranger's DM logs no text and makes no model request; a longer list applies without a reconnect; the two errors), and Telegram updates from feat: telegram allowlist #135 (DM, mention, channel post, a stranger adding the bot to a group, a button press, a reaction) through the log.

Known limits

  • SQLite may keep the old bytes of a scrubbed gw_inbox.raw in free pages or the WAL until they are written over; SQL does not read them.
  • An event the adapter cannot translate keeps its raw data in gw_inbox with state error, as today: nothing was decided.
  • A listed person who adds the bot to a group that is not listed does not wake it by the join (its person is the bot); their first message there does.
  • A listed person's own event is kept whole, with the platform's data as it is: a Telegram reply's raw data holds the message it answers, also an unlisted one. That person chose to bring it in.
  • What adapters keep in their own state files is unchanged (names, chat descriptions on Feishu, the emoji of a WhatsApp reaction): names and emoji, not messages.

Review

One Codex (gpt-6.2-astra, xhigh) round. Fixed in the second commit: a new channel's list is in force before its adapter starts; no raw data kept of an event that brought nothing on a channel with a list (menu search text); a message logged unlisted stays so when a backfill brings it after its person is listed; backfill start and thread lists count unlisted messages; a reaction takes the thread of the unlisted message it is on; an authorless link preview on the bot's own message is its own; a failure after an event was applied does not reopen it with its raw data gone. Not taken: redacting a listed person's quote of an unlisted message, an actor field for membership events, and adapter state (see Known limits).

…and the log keeps no text of the others

A Telegram bot is public: anyone who finds it can DM it, and a DM wakes a bot
that has full access to its computer. Any channel entry in bot.json can now
have wakeFrom, the addresses (as the log gives them) of the people, places and
threads whose events may wake the bot there.

* Without wakeFrom nothing changes; with [] nobody on that channel wakes the
  bot. A listed place lets everyone in it wake the bot; a listed person wakes
  it anywhere. The terminal has no entry, so it is never limited.
* The log decides as it writes an event, as for the bot's own events and
  deletes: an event whose person, place and thread are all not on the list is
  logged with wake 'unlisted' and never reaches the waker (no wake, judge,
  steer, typing, outage line or download).
* Such an event keeps only who, where, when and its kind: no text, mentions,
  files or raw data, no gw_messages row, no thread name or place description,
  and its gw_inbox row loses its raw data in the same transaction. The text of
  a join or a leave stays, as it only names who added or removed whom (such as
  who added the bot to a group). A change to a message the log keeps follows
  the message. The same message again from a backfill is logged once.
* bot.json refuses an entry that is not an address of its channel. A change to
  wakeFrom applies to the next event without connecting the channel again.
* No limit on where the bot sends: that stays its judgment.
* The prompt names wakeFrom in the bot.json line and 'unlisted' in the log's
  wake values. The Telegram skill connects with "wakeFrom": [], has the person
  DM the bot once so it takes their address from the log, warns that a
  @username never matches, and has krau's /setjoingroups step.
* spec/Inbox.tla: events the log decides as it writes them are decided and
  never woken, and an unlisted one leaves no text on disk once decided
  (Inbox.unlisted.cfg).

Co-authored-by: krau <71133316+krau@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T04:47:47.131222Z f47fae1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Crokily Crokily mentioned this pull request Dec 4, 2026
* A changed channel gets its new list before its adapter starts, so the
  events it brings at once (Telegram's waiting updates, a backfill) are
  decided by it.
* On a channel with a list, an inbox event that brought no happening (what a
  person types into a menu's search) keeps no raw data either.
* A message logged as unlisted that a backfill brings again after its person
  was put on the list stays as it was decided.
* A backfill's newest message and the threads it reads count unlisted
  messages, so it does not read them again; a reaction that names no thread
  takes the thread of the unlisted message it is on.
* A change that names no one to the bot's own kept message, such as a link
  preview, is the bot's own, also on a channel with an empty list.
* A failure after an inbox event was applied does not reopen it: its raw data
  may be gone, and its events come back through the undecided ones.
@Crokily
Crokily merged commit 422dfcd into main Dec 4, 2026
11 of 12 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.

Feature Request: Add allowlist access control for the Telegram channel

1 participant