Skip to content

fix(orchestration): refuse unknown bare terminal send targets - #13458

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/13363-orchestration-send-unknown-terminal
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/13363-orchestration-send-unknown-terminal

Conversation

@bbingz

@bbingz bbingz commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • vitest run src/main/runtime/rpc/methods/orchestration.test.ts -t orchestration.send (39 passed)
  • Manual: orca orchestration send --to term_00000000-0000-0000-0000-000000000000 --subject x --body y --json → terminal_not_found

Fixes #13363

Bare `orchestration send --to term_…` accepted non-existent handles with
ok:true and stored mail that no check path can surface. Validate live pane
keys (or active Dispatch assignee) and return terminal_not_found, matching
run:/dispatch: refusal.

Fixes stablyai#13363.
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

orchestration.send now validates bare terminal recipients before delivery. It accepts recipients that resolve to a live pane or active Dispatch assignee. It rejects unresolved handles with terminal_not_found and avoids storing undeliverable mail. The RPC error passthrough allowlist preserves this structured error code and its associated data. Tests cover both rejection and delivery without pane identity.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the bug and tests, but omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add all required template sections, state whether there is visual change, record the required checks, and summarize AI review, security audit, and platform risks.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: rejecting unknown bare terminal send targets.
Linked Issues check ✅ Passed The implementation rejects unknown bare terminal handles, preserves active Dispatch assignee delivery, and adds regression tests for issue #13363.
Out of Scope Changes check ✅ Passed The allowlist update, orchestration validation, and focused tests directly support issue #13363 and the stated pull request objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 518bb223-a68f-4912-95fe-273ef4b16b56

📥 Commits

Reviewing files that changed from the base of the PR and between 9ccec55 and 60b326c.

📒 Files selected for processing (3)
  • src/main/runtime/rpc/errors.ts
  • src/main/runtime/rpc/methods/orchestration.test.ts
  • src/main/runtime/rpc/methods/orchestration.ts

Comment on lines +378 to +388
it('rejects unknown bare terminal handles instead of storing unread mail', async () => {
setup()
await expect(
call('orchestration.send', {
from: 'term_coord',
to: 'term_00000000-0000-0000-0000-000000000000',
subject: 'gone'
})
).rejects.toMatchObject({ code: 'terminal_not_found' })
expect(db.getUnreadMessages('term_00000000-0000-0000-0000-000000000000')).toHaveLength(0)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and inspect the relevant test file and relevant methods/types.
if [ -f "src/main/runtime/rpc/methods/orchestration.test.ts" ]; then
  echo "== file exists =="
  wc -l src/main/runtime/rpc/methods/orchestration.test.ts
  echo "== target section =="
  sed -n '350,415p' src/main/runtime/rpc/methods/orchestration.test.ts | cat -n
else
  echo "target file not found"
  fd -i 'orchestration.test.ts|orchestration' src/main | sed -n '1,80p'
fi

echo "== search getUnreadMessages/usages =="
rg -n "getUnreadMessages|sendUnread|unread|message" src/main/runtime/rpc/methods src/main || true

echo "== outline rpc method orchestration =="
fd -i 'orchestration.ts' src/main | while read -r f; do
  echo "--- $f"
  wc -l "$f"
  ast-grep outline "$f" --view compact || true
  sed -n '1,220p' "$f" | cat -n
done

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate target files directly =="
fd -a 'orchestration\.(ts|test\.ts)$' . | sed 's#^\./##' | sort

echo "== target file around relevant lines =="
sed -n '350,415p' src/main/runtime/rpc/methods/orchestration.test.ts | cat -n

echo "== targeted usages under src/main/runtime/rpc/methods =="
rg -n "getUnreadMessages|setRead|sendUnread|markRead|unread|message|messages" src/main/runtime/rpc/methods || true

echo "== orchestration implementation focused =="
for f in $(fd -a 'orchestration\.ts$' src/main/runtime/rpc/methods); do
  echo "--- $f"
  wc -l "$f"
  rg -n "getUnreadMessages|setRead|sendUnread|markRead|unread|message|messages" "$f" || true
  sed -n '1,240p' "$f" | cat -n
done

echo "== local declaration definitions =="
rg -n "function getUnreadMessages|const getUnreadMessages|export .*getUnreadMessages|getUnreadMessages\s*=" src/main/runtime src/main || true

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== orchestration import/mock/failure section =="
sed -n '600,715p' src/main/runtime/rpc/methods/orchestration.ts | cat -n

echo "== orchestration storage schema/read modes =="
rg -n "CREATE TABLE message|insertMessage|getMessageById|getUnreadMessages|markAsRead|read" src/main/runtime src/main --glob '!**/*.test.ts' | head -n 200

echo "== focused tests around mark-read/all modes =="
rg -n "getUnreadMessages|markAsRead|insertMessage|unread === false|all === true|peek" src/main/runtime/rpc/methods/orchestration*.test.ts src/main/runtime/rpc/methods/orchestration-migration-behavior.test.ts | head -n 200

Repository: stablyai/orca

Length of output: 35781


Check all persisted rows after rejecting an unknown terminal.

getUnreadMessages only reads read = 0, but the message table also stores read mail. A regression that inserts the message as read would still make this test pass. Assert zero total rows or probe the read mode that returns all messages instead.

Comment on lines +396 to +401
const result = (await call('orchestration.send', {
from: 'term_coord',
to: 'term_worker',
subject: 'how is it going?',
type: 'status'
})) as { message: { to_handle: string } }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Remove the duplicated type assertion.

The supplied final file repeats })) as { message: { to_handle: string } } at Line [401]. The second occurrence is outside the call expression and causes a TypeScript parse error. Keep one cast statement.

@bbingz

bbingz commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #13639 — artile kept the #13458 shape/carve-out and correctly extended reachability (group forms, receipt warnings, adopted-Run settlement). Thanks for building on it; happy to have the fuller fix land.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: orchestration send accepts an unknown terminal handle silently, creating a message nobody can read

3 participants