Plan: a post that gets no reply wakes its sender once
Closes: #837. Relates to: #833 (a post that wakes nobody is said at post time), #839 (an agent’s aliases). Branch: feat/msg-awaiting-reply. Status: Done (2026-11-18) — with the errata below: the wait is 60 minutes
Erratum (2026-11-17): REPLY_WAIT_MS is 60 minutes, not 30, by the operator’s decision on the measurement this plan asked for. On luchs’s store (seven days, pi-feedback/pi, 644 addressed posts of one agent) a 30-minute wait would have told 40, of which 25 were answered within the next half hour; at 60 minutes 15. The Context’s "43 of 1,469 (3%)" counted every sender’s posts; per sender it is 6.2%. Every "30 minutes" below reads 60.
Erratum (2026-11-18): the Windows rows. The pi-remote suite passed there (528 passed, 7 skipped), and a member session’s own posts were seen open on a copy of panther’s store. Over that store, told at 60 minutes: 12 of one agent’s 449 addressed posts on pi, 47 of 126 of canopy’s on rules (the days nobody was subscribed, the case this was written for). Ten of the twelve on pi were reports that expected no reply. Not watching a post that is itself a reply was suggested and counted (13 of 15 tellings on luchs’s pi, but 85% of all addressed posts there) and is not in this change. Not run: a real post watched and told end to end.
Context
An agent that asks another agent for something has no way to wait for the answer but a monitor or poll of its own, which expires or is never set. In the canopy and config sessions read for #833, the sender polled the other repository’s branch for an hour, saw nothing, and looked again 25 minutes later. #833 tells a sender at post time when its addressee has no subscriber or no running session on the same box. Left open: an addressee on another box, and one that was woken and did not answer.
Measured on luchs’s store before this plan: 43 of 1,469 addressed posts on pi-feedback/pi (3%) had no post from their addressee thirty minutes later.
The operator’s decision (2026-11-17): automatic. Every to:<name> post is open until that agent posts anything on the channel; after thirty minutes of silence the sender is woken once; reply: false opts out.
What exists (read in packages/pi-remote/): the box’s store keeps every delivered and own message per channel (msg-store.ts, lines of kind message, missed, read; an unknown line is skipped by parseLine). A member session reads the store from disk as the hub does (unreadNotice, waitingMessages in messaging.ts). namesOf(agentDir, agent) gives an agent’s name and aliases; loadAliases the box’s whole alias record. startMessaging in index.ts runs at every session start, and tellRelabelled there sends the agent a MSG_NOTICE_TYPE message with no turn.
Design
D1. What is open
New packages/pi-remote/awaiting.ts, pure functions over the store:
-
A post is tracked when it was posted from this box (
from === selfBox) by this agent (itsagentis one ofnamesOf), carries at least oneto:<name>tag other thanto:all, and carries neither the tagreply:none(D4) nor the receipt tag (RECEIPT_TAG, a box’s automatic answer). -
It is answered by any later message in the same channel’s file that is not a receipt and either cites it (
reequals its id) and is not this agent’s own from this box, or comes from an addressee: the message’sagentorhandleequals an addressed name, or an addressed name is one of that agent’s aliases on this box (loadAliases). With several addressees, any one answers it. -
It is nudged when the channel’s file holds a line
{ kind: "nudged", id, agent, at }for its id. -
openPosts(agentDir, agent, selfBox, now, store)returns, for each channel the agent subscribes to, its tracked posts that are neither answered nor nudged and were stored withinONSET_WINDOW_MS(24 h, the existing constant), each withdueAt = received + REPLY_WAIT_MS.REPLY_WAIT_MSis 30 minutes, a constant.
Only subscribed channels: a reply can reach this agent only where it listens.
D2. The store’s new line
msg-store.ts: NudgedLine { kind: "nudged"; id; agent; at } joins StoreLine, with its guard in parseLine; MsgStore.nudged(spaceId, channel) returns the ids; MsgStore.markNudged(spaceId, channel, id, agent) appends one. bound drops a nudged line whose message is no longer kept, as it does a read line. messages() ignores the new kind.
D3. The one wake
In index.ts, per session (not in a helper’s session, as the other hooks):
-
armAwaiting(state): clears the session’s timer, readsopenPosts, and sets oneunref’d timer for the earliest `dueAt(at once when one is already due).RemoteStategainsawaitingTimer. -
When it fires:
openPostsis read again (an answer or another session’s nudge may have come); each post now due is marked nudged in the store first, then told in one message, then the timer is re-armed. The message isMSG_NOTICE_TYPE,display: true, sent with{ triggerTurn: true, deliverAs: "steer" }: "No reply has reached this box in 30 min to your message <id> to:<names> on <space>/<channel> («subject»). The addressee has not posted there since. Follow up, or carry on; this is said once." It says nothing of whether the addressee is running or read it: this box cannot know. -
Armed at session start (every reason, from
startMessaging) and after eachmsg_postthat tracked something. Cleared atsession_shutdown, before that handler’s early return for a session with no link. -
At session start, posts already overdue are marked and told in one message with
triggerTurn: false: a start is not the moment to begin a turn, and a one-shot host’s own prompt must not be refused (#656’s lesson).
D4. The tools
msg-tools.ts:
-
msg_postgainsreply: Type.Optional(Type.Boolean());reply: falseadds the tagreply:none. Its description gains one sentence: ato:<name>post is watched, and the sender is woken once if that agent has not posted on the channel in 30 minutes, so no poll is needed;reply: falsefor a message that expects none. -
The result of a tracked post on a channel this agent subscribes to gains one line: "watched: you are woken once if <names> has not posted here in 30 min". On a channel it does not subscribe to, the line is instead: "not watched: you are not subscribed to <channel>, so a reply there would not reach you; msg_subscribe to it". The existing subscription-change path (
subscriptionsChanged) re-arms the timer, so a post made just before subscribing is watched from then. -
msg_channelslists, under a channel, each open post: "awaiting <names>: <id> «subject», posted <n> min ago" (nis the whole minutes since it was stored).
Scope
In: packages/pi-remote/ awaiting.ts (new), msg-store.ts, msg-tools.ts, index.ts, state.ts, their tests; docs/modules/ROOT/pages/remote.adoc; CHANGELOG.adoc.
Out: any change to the wire or to what a receiving box does; a configurable wait; a second nudge; the addressee’s side ("requests open for you"); the phone.
Risks
| Risk | Mode | Mitigation |
|---|---|---|
A nudge for a message that needed no reply (a closing "thanks") |
silent |
One wake, said once, cheap to dismiss; |
Two sessions of one agent both nudge the same post |
silent |
The store is marked before the message is sent and read again when the timer fires; two timers firing within the same few milliseconds can still both tell it. Accepted; the concurrency test pins the marked-first order. |
The reply came but this box did not receive it (link down, a replay gap) |
silent |
The wording says "has reached this box"; the store’s existing |
An older pi-remote on the same box reads a file with |
fail-closed |
|
The timer keeps a quitting pi alive |
fail-closed |
|
A wake at session start begins a turn in a one-shot host |
fail-closed |
Start-time overdue posts are told with |
Tests
Unit (packages/pi-remote/test/awaiting.test.ts): tracked or not (no to:, to:all only, reply:none, a receipt, another agent’s, another box’s, an alias’s own post); answered by re, by the addressee’s agent name, by its handle, by a local alias, by any one of several; not answered by a receipt, by the sender’s own later post, by a message on another channel, by an earlier message; nudged excluded; older than the window excluded; unsubscribed channel excluded; dueAt.
Property (fast-check, same file): for arbitrary message sequences, openPosts never returns an answered or nudged post, and appending a message from the addressee after a post always closes it.
Contract (packages/pi-remote/test/msg-store.test.ts): a nudged line round-trips; messages() and unread are unchanged by it; a line of an unknown kind is skipped; bound drops a nudged line with its message.
Wiring (packages/pi-remote/test/extension.test.ts, fake timers): a tracked post arms the timer and the wake comes at 30 minutes, once, with the store marked; an answer before then means no wake; reply: false arms nothing; a post overdue at session start is told with no turn and marked; one not yet due is armed for the remainder; the timer is unref’d and cleared at shutdown. Concurrency: two sessions of one agent on one store, both timers fire: the second, reading the store, sends nothing.
Tools (packages/pi-remote/test/extension.test.ts): the watched line; the not-watched line on an unsubscribed channel, and that subscribing afterwards arms the timer; the reply:none tag; the msg_channels rows with minutes since posting.
Measured before merge, prediction first, read-only: openPosts and the 30-minute silent rate over luchs’s real store and, by the Windows seat, a copy of panther’s (the canopy and config channels included): how many posts each rule tracks, how many would have been nudged, and ten of those read by eye for whether a nudge was wanted.
Delivery
-
Plan committed in
docs/modules/ROOT/pages/plans/msg-awaiting-reply.adocwith itsnav.adocline. -
One branch: code and tests, the messaging section of
remote.adoc, CHANGELOG under Unreleased, Added. -
node tools/task.mjs validate, fullconsumer-sim, the Windows suite and the measured rows; MR closing #837, squash off, the merge SHA on the issue.