Skip to content

feat(server): dispatch pairs run as RuCode threads, and updates wait for running work - #36

Draft
mayberuk wants to merge 1 commit into
mainfrom
rucode-pair-bridge
Draft

mayberuk wants to merge 1 commit into
mainfrom
rucode-pair-bridge

Conversation

@mayberuk

@mayberuk mayberuk commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Problem

A driver and supervisor pair that dispatch (the plugin that runs initiatives) starts lives in tmux tabs. RuCode cannot show it, steer it or keep it alive across a restart, and it can restart the server in the middle of a run.

Change

  • The server now carries out dispatch's pair intents on RuCode threads: it starts the driver and supervisor as server-launched threads under the planning chat, delivers notes and wake-ups to them, and sends dp (dispatch's command) a receipt for each. Intents have deterministic ids, so a restart replays them without duplicates.
  • A new service reads dp's pair state and the bridge's own record, and serves the pair RPCs (state subscription plus the operator actions: authorize, decline, not now, start, supervision, check-in, stop, settle, raise ceiling, answer decision, and pack, unpack and release of an initiative). Every action needs orchestration:operate.
  • Threads started by the server can record a parent thread. Pair seats are left out of terminal import and generic restart continuation.
  • A planned update requested from a client (including the desktop updater) is refused while threads are working or dispatch parts are running, naming what is running. The web asks "Restart while work is running?" and re-sends with force after "Restart anyway"; stage-only updates are not guarded. The confirm dialog gained an optional confirmLabel for this.
  • @t3tools/client-runtime/state/dispatch-pair gives clients the pair snapshot, the commands, dispatchPairForThread, dispatchPairWaitingOnPerson and the move sequence for starting a pair on another machine. A move declines the source proposal only after the target confirms it unpacked the same archive.
  • Wire changes are optional fields, so older clients and servers keep working.

Scope

Requested by the maintainer of this fork. Depends on the dp release from the dp-native-pair work: the bridge reports "operator-unbound" instead of looping until dp binds the operator.

Verification

  • Server, client-runtime and web browser tests for each phase. The changed-file check (format, lint, typecheck of 45 packages, changed tests, React compiler) passed on this tree's head, and the wave gate passed; i18n:check passes in all eleven web locales.
  • Checked in the running app: the restart confirm in T3 Chat light and dark and in Grove light and dark (title, counts, destructive button labelled "Restart anyway", Cancel focused). Checked on an isolated server that the update service sees the restart guard.
  • A whole-branch review (one round) found one high, two medium and three low points, none fixed here; they are listed below. The phase 9 test review found gaps, which were closed with tests.
  • Waived checks: contract checks of waves 1 to 4 (the specs name shared types outside each phase's own line) and wave 4's ownership check (13 paths differ only from the checker's baseline snapshot; one older test file).
  • Not checked: the live probes (operator binding from the server process, restart in the middle of a wave, a steer reaching a long tool loop, supervisor context cost, a pair running with no client connected, the sender note envelope). They need the dp release and a real Claude seat. The dependency-failing scenario is also missing.
  • Screenshots are not attached: there is no command-line way to upload them to the pull request without publishing them somewhere else.

Open points (not blocking)

  • The restart guard on the desktop updater runs when the update is requested, not when the install is committed, so work started during the download is not guarded.
  • While dispatch is unreadable the guard counts the last known running parts.
  • A permanent launch error (for example a missing worktree path) is retried and gives no receipt, which holds that role's later intents. A rejected thread.archive receipt replays forever; a seat deleted before its receipt keeps its launch retrying.
  • DispatchPairState reads the thread projection from ProjectionStoreV2 where the spec says ProjectionThreads; the state, store and action layers also need the file system and path services.
  • Blocking a seat thread also stops restart resends of MCP or scheduled prompts to that seat.
  • dp's exit 28 (pair_busy) is reported as "failed" with the dp code kept; exit-5 retries make four attempts although the intent text says three.
  • Mobile has no "Restart anyway": an update refused for running work shows a plain error there.
  • A failure of start or authorize after decline in a move leaves the source declined and the target unstarted.
  • dp initiative pack|unpack|release take no operator or confirm flags, so those actions run outside the operator wrapper.

Built with Claude Code (Claude Sonnet and Opus models); review by Claude Haiku.

🤖 Generated with Claude Code

…for running work

## Problem

A driver and supervisor pair that dispatch (the plugin that runs initiatives) starts lives in tmux tabs. RuCode cannot show it, steer it or keep it alive across a restart, and it can restart the server in the middle of a run.

## Change

- The server now carries out dispatch's pair intents on RuCode threads: it starts the driver and supervisor as server-launched threads under the planning chat, delivers notes and wake-ups to them, and sends dp (dispatch's command) a receipt for each. Intents have deterministic ids, so a restart replays them without duplicates.
- A new service reads dp's pair state and the bridge's own record, and serves the pair RPCs (state subscription plus the operator actions: authorize, decline, not now, start, supervision, check-in, stop, settle, raise ceiling, answer decision, and pack, unpack and release of an initiative). Every action needs `orchestration:operate`.
- Threads started by the server can record a parent thread. Pair seats are left out of terminal import and generic restart continuation.
- A planned update requested from a client (including the desktop updater) is refused while threads are working or dispatch parts are running, naming what is running. The web asks "Restart while work is running?" and re-sends with `force` after "Restart anyway"; stage-only updates are not guarded. The confirm dialog gained an optional `confirmLabel` for this.
- `@t3tools/client-runtime/state/dispatch-pair` gives clients the pair snapshot, the commands, `dispatchPairForThread`, `dispatchPairWaitingOnPerson` and the move sequence for starting a pair on another machine. A move declines the source proposal only after the target confirms it unpacked the same archive.
- Wire changes are optional fields, so older clients and servers keep working.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

1 participant