Repository navigation
Conversation
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.
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
src/main/runtime/rpc/errors.tssrc/main/runtime/rpc/methods/orchestration.test.tssrc/main/runtime/rpc/methods/orchestration.ts
| 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) | ||
| }) |
There was a problem hiding this comment.
🗄️ 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
doneRepository: 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 || trueRepository: 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 200Repository: 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.
| const result = (await call('orchestration.send', { | ||
| from: 'term_coord', | ||
| to: 'term_worker', | ||
| subject: 'how is it going?', | ||
| type: 'status' | ||
| })) as { message: { to_handle: string } } |
There was a problem hiding this comment.
🎯 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.
Summary
orchestration send --toalready refuses unknownrun:/dispatch:addresses but accepted bare terminal handles that do not exist, returningok: trueand storing unreachable mail ([Bug]: orchestration send accepts an unknown terminal handle silently, creating a message nobody can read #13363).terminal_not_foundwhen there is no live pane key and no active Dispatch assignee (so in-flight workers without a momentarily resolvable pane still receive status mail).Test plan
vitest run src/main/runtime/rpc/methods/orchestration.test.ts -t orchestration.send(39 passed)orca orchestration send --to term_00000000-0000-0000-0000-000000000000 --subject x --body y --json→terminal_not_foundFixes #13363