← Back to Pull requests

perf(cli): rig send checks an issued sender without the hook bridge or, for a seat, the database #4213

Closed
unknown closed this pull request without merging on Nov 30, 2026 11:35 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 08:25 UTC
Author

The problem

Every rig send that isn't --raw asks whether its sender is a conversation OpenRig issued an address to, for its reply hint (#4141). Since then, rig send costs more to start than it did in 0.7.26. Agents send all the time, so this matters. It comes from two things:

  • The import. The check, 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.

  • - In a fresh process, importing the surface took a median 21.8 ms, against 2.7 ms for the check's own module (30 runs each).
  • The database. Each send opened the local database read-only to run the check's one-row query: a config read, daemon.json, loading better-sqlite3, the open, the query and the close.

  • - That took a median 15.0 ms in a fresh process, after the imports.

    What changes

  • A surface of its own: @openrig/daemon/issued-conversation-address exports only hasIssuedAddressShape and isIssuedConversationAddress. rig send imports it, and the conversation-key surface no longer re-exports the check, since send was its only user. The check is still implemented once.

  • No database for a seat: every issued address has one shape, conversation-<12 hex>@kernel, from issuedReturnAddress. A route carried from another host keeps it with that host after it (…@kernel@<host>). So isIssuedConversationSender returns false, without opening the database, for a sender with neither shape, which nearly always means a seat.

  • - A host-qualified issued address is checked against the database as before. A forwarded route keeps its host and its basis on the receiving host, and 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.
    - One definition of the format: issuedReturnAddress now lives beside the shape in domain/issued-conversation-address.ts and is still re-exported from return-route.ts. The prefix, the rig and the hash length are each written once. A rig send process already loads node:crypto, so this adds nothing to its start.
    - A test ties 500 generated addresses, alone and carried from another host, to the shape.
  • What send does 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

  • Red first, at main:

  • - the new start-up test fails with "rig send loaded the conversation key";
    - the sender tests fail because isIssuedConversationSender isn't exported (TypeError);
    - the shape test can't find the new surface.
  • Red, at this PR's first head, for the host-qualified case: the sender test's carried cases read false ("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.

  • Green: daemon: 20 files (issued addresses, return routes, conversation keys, the session transport, and every test that records a route's basis), 1,113 passed; CLI: 11 files (every send file, the MCP server and network-request files, the lazy program, the bin wrapper and the queue start-up), 332 passed. npm run lint passed.

  • Measurement. Three CLIs were installed side by side in one home against one daemon, on a shared 4-core Linux box (load 2.1-2.5), with Node 22.23.4: published 0.7.26 (A), main as packed (M) and main with this change (F). Each sent 100 rounds of a non-raw rig send from 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.
  • | | A | M | F |
    |---|---|---|---|
    | Child CPU, median | 387.5 ms | 430.4 ms (M/A 1.111) | 396.4 ms (F/A 1.023, F−M −34.0) |
    | Wall, median | 310.4 ms | 331.1 ms (M/A 1.066) | 317.3 ms (F/A 1.022, F−M −13.8) |
    | JS files opened (strace) | 134 | 155, the hook bridge and the database included | 139, neither |

    - What F still opens beyond A: the check's small surface and module, and 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

  • An issued route renamed by a queue transfer. An authorized queue transfer can map an issued route to another name and keep its basis. rig send doesn'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.

  • One shared Linux box, 100 rounds per CLI, as medians with wide spreads. This isn't a controlled benchmark.

  • An issued sender (a person's own conversation sending with rig send) still opens the database, as it must to answer.

  • The bind-plan import in daemon-lifecycle is left as it is here, as it was in #4211.
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Issued conversation addresses now follow a consistent format and can include a host component. The address format is recognized across supported workflows.
    Bug Fixes
    * The send command now checks whether a sender matches the issued-address format before checking local conversation records. Invalid or unmatched senders are treated as not issued, and database lookup failures are handled safely.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: openrig-review Review duration: 189m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4213"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%