Skip to content

fix(daemon): no reply command for an @external sender the queue would refuse - #3275

Merged
mvschwarz merged 3 commits into
mvschwarz:mainfrom
cavalcanticampos:fix/3268-fix-daemon-no-reply-command-for-an-exter
Nov 17, 2026
Merged

mvschwarz merged 3 commits into
mvschwarz:mainfrom
cavalcanticampos:fix/3268-fix-daemon-no-reply-command-for-an-exter

Conversation

@cavalcanticampos

@cavalcanticampos cavalcanticampos commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What a user gets

Fixes #3268.

Before: a queue row whose source is an @external address that isn't registered (for example rig queue create --source some-team@external --destination advisor@kernel ...) reached the seat ending with ↩ Reply if needed: rig queue create --destination some-team@external .... Running that command fails with unknown_destination_rig.

After: that delivery ends with
↩ No reply route: some-team@external isn't a registered person (rig gateway human list lists who's registered).
This works like the #2895 note for a sender with no session. Registered people and registered shared channels keep the existing --reply-to hint.

Cause: wrapPaneEnvelope (and its CLI twin wrapSendBody) gives every sender ending in @external the queue create hint. Nothing checked whether the queue would accept that address as a destination.

Fix:

  • EnvelopeMeta gains senderRegistered?: boolean, in both twins with byte-identical output. When it is false, an @external sender gets the note above instead of the command. When it is absent or true, the output is unchanged.
  • QueueRepository.senderReach sets senderRegistered: false for an @external sender when canRecordDestination(sender) returns false. That is the same admission check that refuses the reply, so registered people and shared channels pass and unregistered sources don't.
  • senderReachable keeps its current meaning. Its test that "senderReachable false leaves the external reply line alone" is unchanged.

How you verified it

Tested on main at 4d2284c with this change.

  • New test in packages/daemon/test/queue-nudge-summary.test.ts wires the production makeTopologyDestinationCheck and a registry that holds only alex@external. A row from some-team@external must end with the new note, and the reply it used to suggest must be refused with unknown_destination_rig. A row from alex@external must keep the --reply-to hint. The test fails without the fix (it gets the old rig queue create line) and passes with it.
  • Mirrored renderer tests in packages/daemon/test/pane-envelope.test.ts and packages/cli/test/send-header.test.ts cover the parity contract.
  • These passed: pane-envelope, queue-nudge-summary, queue-repository, queue-cross-host-create, draft-aware-delivery (daemon) and send-header (cli). npm run lint passed.
  • I did not complete a full npm test run or the UI suite; I'm relying on CI for those. Not exercised against a live daemon or Slack.

Anything you were unsure about

  • I added a new meta field rather than reusing senderReachable, because an existing test pins that senderReachable: false leaves the @external line alone.

  • The rig send envelope path (session-transport.ts) doesn't set the new field. The issue is about queue deliveries, and rig send from an @external sender isn't a normal path.

  • The note's wording is a suggestion; happy to change it.

  • One concern per PR; no version bump; no CHANGELOG.md edit

  • Tests added or updated where the change is testable

  • I listed the checks I ran, their results, and any checks I could not run

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Messages from unregistered external senders now indicate when no reply route is available, instead of showing a reply command that cannot be used.
    • Registered external senders and other senders retain their existing reply guidance.
    • When registration or participant information is unavailable, inconsistent, or cannot be checked, existing reply guidance is preserved.
    • Messages continue to use existing reply guidance when sender checks fail, so delivery and handoff behavior remain unaffected.

… refuse

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The queue repository now identifies certain unregistered external senders using person and participant data plus destination admission. The CLI and daemon envelope renderers use that metadata to show a no-reply-route note instead of a reply command.

Changes: External Sender Reply Routes

Layer / File(s) Summary
Classify sender registration
packages/daemon/src/domain/gateway/participants.ts, packages/daemon/src/domain/queue-repository.ts, packages/daemon/test/queue-nudge-summary.test.ts
The repository distinguishes unreadable participant data from an empty list. It marks an external sender as unregistered only when registry and participant reads succeed and destination admission rejects the address. Tests cover unreadable data, registered people and shared channels, and lookup exceptions.
Update daemon envelope output
packages/daemon/src/lib/pane-envelope.ts, packages/daemon/test/pane-envelope.test.ts
The daemon envelope shows a no-reply-route note for an external sender marked unregistered. Tests check that registered and non-external senders retain their existing hints.
Update CLI envelope output
packages/cli/src/commands/send.ts, packages/cli/test/send-header.test.ts
The CLI envelope shows a no-reply-route note for an external sender marked unregistered. Tests check that registered and non-external senders retain their existing hints.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant QueueRepository
  participant Registries
  participant DestinationAdmission
  participant EnvelopeRenderer
  QueueRepository->>Registries: Read person and participant data
  QueueRepository->>DestinationAdmission: Check sender destination
  QueueRepository->>EnvelopeRenderer: Pass sender registration metadata
  EnvelopeRenderer->>EnvelopeRenderer: Select reply text
Loading

Possibly related PRs

  • mvschwarz/openrig#2055: Changes the @external reply hint in the same CLI and daemon envelope renderers.
  • mvschwarz/openrig#2898: Adds senderReachable metadata to the same envelope renderers and changes reply-footer selection.

Suggested reviewers: mvschwarz, openrig-review

Merge Risk: Minimal · up to fb121

This changes the reply footer for unregistered external senders so it no longer suggests a queue command that would be refused. Failures fall back to the existing hint, and queue admission is unchanged, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main behavior change: the daemon no longer suggests a reply command for an @external sender that the queue would refuse. The raw summary and objectives confirm the change adds a no…
Linked Issues check Passed Issue #3268 requires that an @external sender that is not a registered person get a no-reply-route note instead of a rig queue create reply command that fails with unknown_destination_rig. At head f…
Out of Scope Changes check Passed The reviewed changes stay within the #3268 reply-footer path. In pane-envelope.ts, the new field and branch affect only the @external reply line. In queue-repository.ts, the changes add `senderRegiste…
Full details: Title check

Explanation

The title names the main behavior change: the daemon no longer suggests a reply command for an @external sender that the queue would refuse. The raw summary and objectives confirm the change adds a no-reply-route note for unregistered @external senders in the daemon envelope path, which matches the title. The 'fix(daemon)' prefix fits the scope, though the CLI envelope also gets a matching change, so the title is slightly narrower than the full changeset.

Full details: Linked Issues check

Explanation

Issue #3268 requires that an @external sender that is not a registered person get a no-reply-route note instead of a rig queue create reply command that fails with unknown_destination_rig. At head fb1210b, wrapPaneEnvelope (packages/daemon/src/lib/pane-envelope.ts) renders ↩ No reply route: &lt;sender&gt; isn't a registered person (...) when meta.senderRegistered === false for an @external sender. Otherwise it keeps the existing --reply-to hint. QueueRepository.senderReach sets senderRegistered: false only when knownUnregistered succeeds. That helper reads the person registry and the shared-channel list once each, returns false on any failed or null read, requires resolveExternal to report unregistered, and requires canRecordDestination(sender) to be false. Registered people and registered shared channels keep the hint. The change since the previous review moves the lookup to one snapshot of the registry and participant data, as the reviewer requested. The diff for queue-repository.ts and pane-envelope.ts supports this. Limits: I did not verify end to end that the nudge path spreads senderReach into the envelope meta, and I did not run the author-reported tests. The rig send envelope path (session-transport.ts) does not set the field, which the issue does not require.

Full details: Out of Scope Changes check

Explanation

The reviewed changes stay within the #3268 reply-footer path. In pane-envelope.ts, the new field and branch affect only the @external reply line. In queue-repository.ts, the changes add senderRegistered to senderReach, the knownUnregistered helper, and an injectable readSharedChannels dependency. In participants.ts, readSharedChannelAddresses returns null on read failure so the helper can fail safe. These support the snapshot and read-failure safeguards the reviewer requested. senderReachable behavior is unchanged, and admission behavior is not altered. No unrelated behavior change appears in the inspected hunks.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 28d9ac94-9306-4c46-9f2b-2dc8250bc8e7
Commits

Reviewing files that changed from the base of the PR and between f902f42 and fb1210b.

Files selected for processing: 3

  • packages/daemon/src/domain/gateway/participants.ts
  • packages/daemon/src/domain/queue-repository.ts
  • packages/daemon/test/queue-nudge-summary.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@mvschwarz

Copy link
Copy Markdown
Owner

Thanks, @cavalcanticampos. We want to check with @ziadeh about their plans for #3268 before choosing a fix. We'll review this proposal on its merits; this isn't a merge or release promise.

@cavalcanticampos

Copy link
Copy Markdown
Contributor Author

Thanks, @mvschwarz. That makes sense. I'll leave the PR as it is until you've heard from @ziadeh. If their plan for #3268 goes a different way (for example, refusing an unregistered @external source at queue create, or different wording for the note), I'm happy to change this PR or close it.

The latest CodeRabbit pass had no actionable comments, so I haven't changed any code since the last push.

🤖 Generated with Claude Code

@mvschwarz

Copy link
Copy Markdown
Owner

Thanks, @cavalcanticampos, and thanks for waiting. The reply line now asks the queue's own admission check, so the hint and the queue can't disagree, and the two envelope copies give the same output, each with a test. @ziadeh has confirmed on #3268 that this is the fix they hoped for, and that queue create should keep accepting an unregistered @external source. So please keep this PR's approach rather than the alternative you offered.

Two small changes, each with one test

1. A registry that can't be read isn't proof of absence. When the person registry or the shared-channel list can't be read, the admission check finds no one, so every @external sender reads as unregistered and the note says "isn't a registered person", which may not be true. Please show the no-route note only when the registry was read and the sender isn't in it. When it couldn't be read, keep today's reply line. Tests: an unreadable registry keeps today's line, and a shared channel keeps its hint.

2. If the new check throws, the notification should still go out. The new lookup runs while the notification to the recipient is being staged (senderReach, called from the staging path in queue-repository.ts). If reading the registry throws there, a new queue item is kept but its notification is rolled back and nothing is delivered, and a handoff fails outright. Please treat the reply-line lookup as optional: catch a failure there, and keep today's reply line and the notification. Test, for a new item and a handoff: let the earlier reads succeed, make the new check throw, and check that the notification is still staged and delivered with today's reply line.

One wording point: where the description and commit say the two copies match, say that of the changed reply branch. The daemon copy already has one branch the CLI copy lacks, for OpenRig's own sender, which this PR doesn't touch.

Neither change adds a refusal, and queue admission stays as it is.

After your push we'll take a short read of the change and let CI run.

…d or throws

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cavalcanticampos

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Both changes are in, each with tests.

1. A registry that can't be read isn't proof of absence. The no-route note now shows only when the person registry and the participant file were both read and the queue still refuses the sender. If the registry is broken (registeredPeople(...) === null) or the participant file doesn't read, the delivery keeps today's --reply-to line. A registry with nobody registered yet counts as read and empty, so it still gets the note. The participant-file read is a new optional participantsReadable dep, which by default reads the file from the OpenRig home. Tests in queue-nudge-summary.test.ts:

  • an unreadable registry keeps today's line
  • an unreadable participant file keeps today's line
  • a registered shared channel (ops@external) keeps its hint

The first two fail without this change.

2. If the new check throws, the notification still goes out. The lookup is now an optional step (knownUnregistered) that catches any failure and falls back to today's reply line. Two tests let the destination checks succeed and make only the sender lookup throw: one for a new item, one for a handoff. Both check that the notification is staged and delivered with today's reply line. Without the change, the new item delivers nothing and the handoff rejects with the thrown error.

Wording: agreed. The claim that the two envelope copies give the same output holds for the changed @external reply branch only. The daemon copy also has a branch for OpenRig's own sender, which the CLI copy lacks and this PR doesn't touch. I'll fix the description to say so.

Tested: the new tests above, plus pane-envelope, queue-repository, queue-cross-host-create, draft-aware-delivery and queue-transactional-closure (daemon), the daemon typecheck and npm run lint. Not run this round: CLI send-header (no CLI change), the full npm test, the UI suite, a live daemon or Slack.

🤖 Generated with Claude Code

@mvschwarz

Copy link
Copy Markdown
Owner

Thanks again, @cavalcanticampos. A lookup that throws now keeps the notification and the handoff, and an unreadable registry keeps today's reply line, as asked, each with tests.

One remainder of last round's first item

knownUnregistered checks readability with its own reads (queue-repository.ts:1492), and then the address check reads both files again (queue-destination-check.ts:27-32, and sharedChannelAddresses at gateway/participants.ts:450-453). If the first reads succeed and the second can't read, the second collapses to an empty list, and the "no reply route" note comes back for a sender who may be registered. Please derive the note from the same snapshot that address resolution reads: show it only when that snapshot was read and the sender isn't in it, keep today's reply line whenever it's unknown, and leave admission as it is. Test: first read succeeds, second can't read. If sharing the snapshot isn't cheap, say why in the PR and name that window as a limit instead.

The description

It still says both copies give byte-identical output. As your last comment offered, please narrow it to the changed @external reply branch.

After your push we'll take a short read of the change.

…ticipant snapshot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cavalcanticampos

Copy link
Copy Markdown
Contributor Author

Thanks, @mvschwarz.

Note from the same snapshot. knownUnregistered now does one read of the person registry and one read of the participant file (new readSharedChannelAddresses, which returns null when the file can't be read, unlike sharedChannelAddresses which returns []). It decides absence from that snapshot with resolveExternal, the rule admission uses. The note shows only when both reads succeeded, the sender isn't in them, and canRecordDestination refuses the address. If admission's own later read can't read and collapses to an empty list, the snapshot still lists the sender, so today's reply line stays. Any failed or throwing read also keeps today's line. Admission is unchanged. The test-only participantsReadable option is replaced by readSharedChannels (list, or null when unreadable).

Test: queue-nudge-summary.test.ts, "the note comes from one snapshot…". The first read lists ops@external and admission's read returns an empty list. The test expects the --reply-to hint. It fails on the previous commit (it gets the "No reply route" note) and passes now. The tests for an unreadable registry, an unreadable participant file, a registered channel and a throwing lookup now inject through readSharedChannels.

Ran: queue-nudge-summary, pane-envelope, queue-repository, queue-cross-host-create, draft-aware-delivery, gateway-participants, slack-shared-channel-inbound, slack-shared-channel-way-back, workflow-human-destination (all pass), daemon tsc --noEmit and npm run lint. Not run: the CLI suite and the full npm test.

Description. Narrowed: both copies render the changed @external reply branch identically, not all of their output byte for byte.

🤖 Generated with Claude Code

@openrig-review openrig-review left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at fb1210b. A notification from an @external sender the queue would refuse no longer suggests a reply command that fails; the note now comes from one readable snapshot of the people registry and the participant file, checked by the same resolver the queue uses, and anything unknown or unreadable keeps today's reply line. Both review halves are clear, and required CI passes at this head. Thank you, @cavalcanticampos, and thanks @ziadeh for the report and for reading the fix.

@mvschwarz
mvschwarz merged commit 047c690 into mvschwarz:main Nov 17, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRig roadmap Nov 17, 2026
@mvschwarz

Copy link
Copy Markdown
Owner

Thanks again, @cavalcanticampos. This was merged into main as 047c6903, and it closed #3268.

What it gives people: a notification from an @external sender that the queue would refuse no longer suggests a reply command that would fail. The note appears only when readable snapshots of the people registry and the participant file both show the sender as unregistered and admission also refuses it. Anything unknown keeps today's reply line, and the notification and handoff always go out. Thanks for working through our review rounds so patiently and precisely.

@ziadeh, thanks for the report with source pointers, and for reading the fix.

@mvschwarz mvschwarz added this to the v0.7.19 milestone Nov 19, 2026
@mvschwarz

Copy link
Copy Markdown
Owner

@cavalcanticampos, thanks again: this is now released in OpenRig 0.7.19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

The reply line on a message from an unregistered @external source suggests a queue create that fails with unknown_destination_rig

3 participants