Repository navigation
Closed
Labels
plan:donePlanboard status
Description
From the T3 Code Orchestrator V2 comparison (report: reports/T3 Code orchestrator for Solenta.md on branch coder/i-want-you-to-research-t3-codes-orchestr-fae77a). This is item 1 of 4. T3 V2 mints a session-scoped token for each provider session, so the server knows who is calling. Solenta's coder-threads server instead trusts a thread id the agent passes in.
Bug
assertCrossThreadApproved(electron/orchServer.js:536) starts withif (!fromId || fromId === targetId) return;, andfromThreadIdis an optional argument the agent supplies.thread_stop(:1058) andthread_archive(:1012) check onlyrequireOwnThread, i.e. that the target is in the same project.- So any agent that leaves out
fromThreadIdcan stop or archive any thread in its project without approval. That breaks the Cross-thread message delivery contract: hold until idle, attributed card, per-thread inbound policy #551/Non-bypassable destructive-action gate outside the trust dials #322 rule that these are "the user's decision in every permission mode, including Auto and Bypass". - The merge gate's machine-turn check (
runner.isAutoTurn,electron/runner.js:9033) has the same weakness: it runs on whichever thread id the caller claims. - Found by reading the code, not reproduced live.
Fix
- Do for the thread id what Isolate Kimi runs: no cross-project threads, memory, or workspaces #671 did for
projectId. WritethreadId=<caller>into the per-thread coder-threads MCP URL (electron/memory-sup.js, near the bound config around :1713). Read it next toboundProjectId(electron/orchServer.js:1964) and pass it tocreateToolHandlersas the bound caller. - If no
fromThreadIdis given, use the bound id. If a differentfromThreadIdis claimed, reject the call. - Stopping or archiving yourself (bound id === target) stays ungated.
- External pairing clients (
electron/pairing.js) keep their capability tokens. Check they still work and can't bypass the gate. - In the same change, enforce privilege narrowing in
forkThread(electron/services.js): a child's snapped permission mode must not rank above its parent's. If it does, refuse with a typed error (T3 calls thisruntime_mode_escalation_denied). Headless grok needsauto, so any override must be a user-set flag on the pool alias, never an argument the agent passes.
Tests
- A worker calling
thread_stopon its lead withoutfromThreadIdis refused. - A thread can still stop itself.
- A
fromThreadIdthat conflicts with the bound id is rejected. - A fork whose permission mode would be higher than its parent's is refused.
Size: S. A work_suggest chip with a full prompt for this fix is already on thread fae77a0b.
Metadata
Metadata
Assignees
Labels
plan:donePlanboard status
Activity
currentbits commentedon Oct 4, 2026
A code-level pass found more holes than this issue lists. Full design:
reports/T3 Code orchestrator deep dive.mdon branchcoder/i-want-you-to-research-t3-codes-orchestr-fae77a. Revised size: small M, about 250–350 lines including tests (~2 days).Ship first: one-line fix (I3, verified)
thread_sendstarts the receiver's turn withfromInbound: true(electron/orchServer.js:766). ButstartRunresets the machine-turn counter for every turn that isn't a notice:if (!input.fromNotice && !isReplayTurn(input)) autoTurns.set(threadId, 0);(electron/runner.js:8253).thread_sendits idle lead "the user approved, merge me". The lead's turn then counts as human,isAutoTurnis false, and the lead can passapproved:truetothread_merge. That defeats the gate the code calls "the real lock".runner.js:8490already treatsfromInboundas a machine turn, so the two lines contradict each other.!input.fromInboundto the reset and countfromInboundturns asn+1. This also makes agent ping-pong count toward the 25-turn crew cap.All identity holes
fromThreadIdskips the stop/archive approval gate. A test asserts this as correct:electron/test/orch-server.test.js:1066-1071orchServer.js:536-539threadIdonthread_merge/thread_prlets any running thread act as the leadorchServer.js:459-526thread_sendresetsautoTurns(above)runner.js:8251-8253fromThreadIdonthread_sendskips the unattended-sender refusalcrossThread.js:83-88reviewsPassedcounter, which drives its permission capsorchServer.js:905-916,services.js:3559bypassPermissionson grok/kimi/cursor/opencode/muse, and failover re-snaps the modeproviders.js:194-215,subagentPool.js:381Corrections to the issue body
boundSolentaMcpUrl(memory-sup.js:635) adds onlyprojectId. Each provider writes it somewhere different (Claudemcp-bound/file, Codex argv, grok/kimi/cursor/muse home overlays), and OpenCode gets no coder-threads tools at all.projectId. The bound id silently wins.?threadId=alone can be forged. The shared bearer token sits in every per-thread config, so an agent with a shell cancurlthe loopback port with any thread id.Design
threadIdin every per-run config. UpdateboundSolentaMcpUrl,kimiMcpServersForRun,getCodexMcpArgs,getClaudeMcpArgs,writeBoundMcpConfig(addthreadIdto its sha1 key) andmcpServersDoc. Runner call sites: 4177, 4209, 5081, 5876, 6723 and 7213, plusworkflow.js480/653/846/1025.ensureGrok/Cursor/KimiMcpConfig. Those write user-global files where the last writer wins.mcp-bound/files after 7 days (M1).HMAC-SHA256(token, threadId)instead of the shared token.authorized()(orchServer.js:147-155) accepts the shared token, which leaves the call unbound, or the HMAC, which setsboundThreadId.caller(claimed)helper increateToolHandlers. The bound id wins.assertCrossThreadApprovedrefuses when the caller is empty.args.threadIdgoes through it: fork, merge, pr, ask_user, hypothesis_record, work_suggest, spec_submit, teach_review, task_*, peer_send, refresh_worker_snapshot, preview.PERMISSION_RANK = {plan:0, default:1, acceptEdits:2, bypassPermissions:3}inservices.js, and run the snap beforecreateThread(services.js:1331). Throwcode:"PERMISSION_ESCALATION", applied tothread_forkonly.allowEscalation("Full access") flag on pool entries (subagentPool.js:66-71+ SettingsModal). Without it, headless grok workers stop working.Tests
thread_stopwithoutfromThreadIdare both refused. This rewrites the test at 1066-1071.fromThreadIdis ignored.thread_mergewiththreadId=<lead>is refused.?threadId=doesn't.PERMISSION_ESCALATIONand no thread is created.fromInboundturn leavesisAutoTurntrue.None of this was reproduced live. All of it comes from reading the code at fbba4e10.
currentbits commentedon Oct 13, 2026
Landed from Solenta thread "P1: Bind the caller's thread id at the MCP transport (closes" (PR #1612). Closed on merge.