Repository navigation
perf(cli): rig send checks an issued sender without the hook bridge or, for a seat, the database - #4213
Conversation
…r, for a seat, the database Every `rig send` that isn't --raw asks whether its sender is a conversation OpenRig issued an address to, for its reply hint. That cost two things the send path didn't have before: - The check came through @openrig/daemon/conversation-key, so importing it evaluated the hook bridge script beside it (about 60 KB of CommonJS that Node reads for its exports at every load). The check now has its own surface, @openrig/daemon/issued-conversation-address, which brings only the check, and the conversation-key surface no longer re-exports it. - Each send opened the local database read-only (loading better-sqlite3) to run the one-row query. Every issued address has one shape, conversation-<hash>@kernel, so a sender without it (a seat, nearly always) is answered without opening the database. The shape is built from the same constants issuedReturnAddress uses, and a test ties the two together. What send does is unchanged: an issued sender still gets the hint, and anything else still doesn't.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…abase check A forwarded route keeps its host and its issued basis on the receiving host, and rig send's SSH relay names its sender there by that same origin (conversation-<hash>@kernel@<host>). The shape now takes that optional host part, so such a sender is still checked against the database and keeps its reply hint. A seat's name still fails the shape before any read. issuedReturnAddress moves beside the shape in domain/issued-conversation-address.ts and stays re-exported from return-route.ts, so the address format is written once. The sender tests now query real recorded rows: an issued address under either basis, alone and carried from another host, is recognized, and an unrecorded look-alike isn't.
openrig-review
left a comment
There was a problem hiding this comment.
Approving the reviewed head 2149251 to start the macOS package tests. rig send's check for whether its sender is a conversation OpenRig issued an address to now comes through its own small package export, @openrig/daemon/issued-conversation-address, instead of the surface that also loads the hook bridge script. A sender without an issued address's shape (conversation-@kernel, optionally carried from another host) is answered without opening the local database, so a seat's send opens neither. An issued sender, including one carried from another host, is still checked against the database and keeps its reply hint. What send delivers is unchanged.
The problem
Every
rig sendthat isn't--rawasks whether its sender is a conversation OpenRig issued an address to, for its reply hint (#4141). Since then,rig sendcosts more to start than it did in 0.7.26. Agents send all the time, so this matters. It comes from two things:isIssuedConversationAddress, came through@openrig/daemon/conversation-key. Evaluating that surface also evaluates the openrig plugin's hook bridge script beside it: about 60 KB of CommonJS that Node reads for its named exports at every load.daemon.json, loadingbetter-sqlite3, the open, the query and the close.What changes
@openrig/daemon/issued-conversation-addressexports onlyhasIssuedAddressShapeandisIssuedConversationAddress.rig sendimports it, and the conversation-key surface no longer re-exports the check, sincesendwas its only user. The check is still implemented once.conversation-<12 hex>@kernel, fromissuedReturnAddress. A route carried from another host keeps it with that host after it (…@kernel@<host>). SoisIssuedConversationSenderreturns false, without opening the database, for a sender with neither shape, which nearly always means a seat.rig send's SSH relay names its sender there by that same origin. So an issued conversation that sends across hosts keeps its reply hint.issuedReturnAddressnow lives beside the shape indomain/issued-conversation-address.tsand is still re-exported fromreturn-route.ts. The prefix, the rig and the hash length are each written once. Arig sendprocess already loadsnode:crypto, so this adds nothing to its start.senddoes is unchanged. An issued sender still gets the hint, and every other sender still doesn't, apart from the case under Limits.How it was checked
main:isIssuedConversationSenderisn't exported (TypeError);conversation-3f2a9c1b7e44@kernel@host-a (issued): expected false to be true"), and it opened the database twice for four senders with the shape; the shape test refused an address carried from another host.send*file, the MCP server and network-request files, the lazy program, the bin wrapper and the queue start-up), 332 passed.npm run lintpassed.mainas packed (M) andmainwith this change (F). Each sent 100 rounds of a non-rawrig sendfrom a sender session to a seat that doesn't exist, the order rotating each round. This was measured at the first head. The later change doesn't touch a seat's path: a seat's name still fails the shape before any database read.strace)daemon-lifecycle's bind-plan import (three files), which every read command has loaded since an earlier change. Its CPU spread overlaps A's.Limits
rig senddoesn't recognize a sender by that name as issued: only a database read could, and that read is the cost this removes from every seat's send. Such a sender gets the ordinary reply hint ("Reply: rig send …", or "has no session"), not the queue one. Delivery is unchanged.rig send) still opens the database, as it must to answer.daemon-lifecycleis left as it is here, as it was in perf(cli): load the conversation key only for the queue verbs that use it #4211.🤖 Generated with Claude Code
Summary by CodeRabbit