Skip to content

feat: the Boat adapter's start script and the coordinator's first turn - #56

Merged
OmarAlex24 merged 1 commit into
dispatch/corefrom
dispatch/boat-adapter
Nov 17, 2026
Merged

OmarAlex24 merged 1 commit into
dispatch/corefrom
dispatch/boat-adapter

Conversation

@OmarAlex24

@OmarAlex24 OmarAlex24 commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Second of the kontext dispatch stack: the Boat adapter's start script and the coordinator's first turn.

What changed and why

  • The start script (src/dispatch/script.rs, passed with boat new --setup-file). It holds no secret and never echoes a command.
    1. Installs kontext with install.sh at the pinned release ([dispatch] kontext_version, default this binary's version), unless that version is already there.
    2. Sets the project up from the server: KONTEXT_TOKEN="$(cat <token file>)" kontext clone --server …, retried for up to 10 minutes (the server may not be reachable yet), then removes the token file; a trap removes it on every other way out too.
    3. Waits for Boat's clone of the code repo, runs kontext --role coordinator install --local there, and adds what it wrote to info/exclude so it never reaches a commit.
  • Dispatch waits for setupStatus (boat info --json) before prompting, up to 20 minutes; a failed or timed-out script stops the sandbox and revokes the token.
  • The coordinator's turn (src/dispatch/turn.rs): boat prompt --json --provider claude --model opus-5-5 --new "<prompt>" (both configurable). The prompt is short: run epic <name> following .claude/agents/kontext-coordinator.md, starting from kontext brief <name>, until kontext has it closed; deliver it as one PR stack; ask the pm, never the user.
  • Turn-end detection goes behind one function, turn_state. It is implemented by holding boat prompt open: a hidden kontext dispatch turn <epic> <n> process, detached in its own process group, holds a lock while boat prompt runs, saves the conversation id as soon as Boat prints it, and writes ended or lost: <why> when it returns.

Departures from the brief

  • kontext install --local in the clone, plus info/exclude, so the coordinator's hooks and agent files stay out of the epic's PRs.
  • [dispatch] repo_dir is where Boat clones the repo, default /home/user/<first [[repos]] remote>; dispatch refuses when it cannot tell.
  • The turn holders are detached processes, not the watcher's children, so a watcher restart does not lose a running turn.
  • A turn whose process died or whose boat prompt failed is lost, not ended. The watcher (next PR) decides nothing from it.
  • The setup limit is 20 minutes.

Test plan

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings and the full cargo test passed at this commit
  • The coordinator is prompted in a process of its own: the fake's prompt call has the provider, model and prompt; the conversation id is saved; the turn's exit file says ended
  • A boat prompt that exits nonzero leaves the turn lost, not ended
  • A failed start script (setupStatus: failed): the sandbox is stopped, the token revoked
  • The start script, run with sh in a home of its own with a fake curl whose install.sh copies the test's binary: kontext installed, the project cloned from the local server with the token from the file, the token file removed, install --local run in a git clone that git status still shows clean, kontext brief works there, and a second run is idempotent
  • The script's quoting (unit test): a server URL with '; rm -rf / # stays one quoted word

🤖 Generated with Claude Code

@OmarAlex24
OmarAlex24 added this pull request to stack #59 November 16, 2026 22:42
The sandbox gets a start script (`--setup-file`) that installs the pinned
kontext release with install.sh, sets the project up from the server with
the token file (`kontext clone --server`, retried while the server is not
reachable), removes the token file on every way out, waits for the repo's
clone and runs `kontext install --local` there, with what it writes kept
out of git through info/exclude. Dispatch waits for `setupStatus` (20
minutes at most), then prompts the coordinator (claude, opus-5-5 by
default) in a detached process that holds `boat prompt` open, saves the
conversation id and leaves how the turn ended in a file. `turn_state` is
the one function that says whether a turn ended; a turn that cannot be
followed to its end is lost, never ended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@OmarAlex24
OmarAlex24 force-pushed the dispatch/boat-adapter branch from 8deaf0c to 509bcdd Compare November 16, 2026 22:53
@OmarAlex24
OmarAlex24 marked this pull request as ready for review November 17, 2026 14:30
@OmarAlex24
OmarAlex24 merged commit 27b7d92 into main Nov 17, 2026
1 of 2 checks passed
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