Repository navigation
Allow for this chat: a granted bot's offers go with no Send; offers expire and report back - #2497
Merged
Merged
Conversation
…Send; offers expire and their computer hears what became of them A PC window showing another computer's bot chat can allow it for up to 8 bots here. While the grant is open, offers to those bots from turns that window's messages started are kept with no Send, through the same commit as Send. The grant lives on the PC alone, bound to the window and to a run token its router issues per message; it ends on End access, leaving or closing, idle and hard expiry, the stream ending or replaying, Make private, a block or removal. Offers expire after a day or when their grant ends; the offering computer hears delivered, busy or expired; Make private of another computer's bot closes its offers there.
… offers in its own shape; grants end at their time when read; End access wins over a pending Allow; expired is final and Send reports it
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Stage 1 (#2496) lets a bot on another computer offer a message for a bot on the computer you write from, and you press Send on each one. Three gaps were left: offers never expired, the offering bot's chat never learned what happened, and Make private on another computer's bot left that bot taking offers there. Pressing Send on every message is also slow when you trust the conversation you're in.
Change
This is the backend for Allow for this chat. The window UI comes in the next PR.
The grant. While a PC window shows a Mac bot's chat, a person there can allow up to 8 of the PC's bots (
bots.remote.grantOpen). While the grant is open, what the Mac bot offers one of them is kept on the PC with no Send, if it came from a turn that window's message started. It goes through the same commit as Send: same checks, caps and one-receipt dedupe; a quiet notice; no turn started; no reply. An offer to a bot outside the grant still waits for Send. Messages only.Where it lives. The grant lives only in the PC's memory (
ChatGrants). It is bound to the window's connection and to that window showing the chat. Other windows can read its state (bots.remote.grantState), but they can't end it or take it over (grant_elsewhere).Run tokens. Each message from the granting window gets a fresh token from the PC's router (
run,bots.chat.sendversion 4). A window can never supply one. The Mac stamps the token on that turn's offers, and only the device each offer is for sees it. The PC sends an offer on its own only when:tonames exactly one of the grant's bots.A forged token, a replayed one, or one from an ended grant is held by no grant, so that offer expires. If a message without a token (another window, another device) joins the turn, it takes the token off. A resend of the same message carries the token it was first sent with, so the Mac takes it as the same message.
When it ends:
Every one of these wins over a send in progress, because the last check and the commit run with nothing awaited between them. Offers left unsent under the grant expire. Reconnecting or another window needs a new Allow.
What the Mac hears. The Mac's offer card now has a state.
queuedfor a PC that reports (offers: 2) andunsupportedfor an older PC (offers: 1). An older PC keeps stage 1's Send, with nothing wider.delivered(with the bot's name),busy(the hourly cap, under a grant) orexpired, throughbots.offers.outcome. The Mac takes a report only from the device the offer is for, anddeliveredis final.queuedafter a day showsunknown.Expiry. An offer expires a day after it was made, or when the grant it was made under ends. Send then answers
offer_expired.Make private of a Mac bot from the PC now also closes that bot's offers on the Mac (
bots.devices.setwithoffers: false, version 2). An older Mac is sent the access change alone.Hourly cap. It now counts receipts instead of chat rows, so clearing a chat no longer makes room for more.
Person-only methods trust a connection's self-declared gui label, which any local client with the owner token can claim #2052 (Send trusts the declared window type) is unchanged. A grant adds nothing a window couldn't already do with Send, and it is bound to that window's connection and its open chat. Binding "a window" to a real window is still Person-only methods trust a connection's self-declared gui label, which any local client with the owner token can claim #2052's job.
Docs.
docs/bots.md→ "Offered messages" now has "Allow for this chat", the end rules, expiry, outcomes and remote Make private.How to review
src/shared/bots/personal/offers.ts: tokens, states, times, grant refusals.src/mms/bridge/routed/chatGrants.ts: the grant itself, its tokens and timers.BotRouter.ts, the "Offered messages" part:commitOffer,observed(auto-delivery),tellOutcome, the end rules andgrantOpen. This is where the risk is.BotEngine.offerBotMessageandrecordOfferOutcome,BotChatService(the token on the turn,narrowOwnerRunon join), andRemoteBots.ts(bots.offers.outcome, remote Make private).Verification
tests/netEngine/checks/offeredMessagesOneWay.test.ts, which runs two real daemons paired one way. It shows:grant_unsupported.tests/bots/offeredMessagesGrant.test.tscovers:tests/net/bridge/routed/chatGrants.test.tscovers tokens, idle and hard expiry, and ending once.node scripts/verify.mjs <38 affected test files> --max-failures 40ran on b7ca302: 787 of 788 tests pass. The one failure,tests/gitAccessTable.test.ts, timed out under load and passes alone (6 of 6).tests/gitDaemonMethods.test.ts(Git hooks and pushes, slow on this PC) passes alone on this branch, 39 of 39, as on master.--typecheck all).Notes
The UI (picker, active state, End access and per-message states) comes next, then the bot guidance wording. Until then, the
bot_offerresult still tells the bot that its offer waits for Send, which is wrong for one sent under a grant; the guidance PR changes it.The plan was read against master before coding. Its points that touched this code are fixed here: a silent reconnect ends the grant, a second window's message can't ride a granted turn, a resend keeps its first token, lost reports are retried on a timer, and the hourly cap survives a cleared chat.
The review pass found six points, all fixed in b7ca302:
busycan't overwrite it.A third device on stage 1 that reads a stage-2 offer card (one for another device) drops the card, because its parser refuses the new fields. It had no Send on it anyway, and the row's words still show.
Refs #2490