Repository navigation
feat(server): watch pull requests and settle threads on merge in own mode - #312
Merged
Merged
Conversation
Port the rules of upstream's pull request sync and watches to tern-server-vcs: snapshot fields and cadences, watch evaluation and wake text, comment snippets and the shell commands that open, push to or close a pull request. The bridge answers upstream's PullRequestService reads (pullRequests.read). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port thread.pull-request.watch, -watch.sync, -watch.checks-reopen and -link.sync from Orchestrator.ts. A watch sync queues its wake as the agent's message from the server, and the queue cancels a wake whose watch ended or moved and rewrites one whose pull requests changed, as startNextQueuedRun does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port PullRequestSyncReactor and PullRequestWatchReactor: the sweeps, the reads on a new link or watch and after an agent's merge, close, create or push command, held wakes per thread, and the read failure limit. Settlement runs at once when a pull request or a run changes, so a merge settles its thread without waiting out the sweep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Register upstream's watch tools with PullRequestWatchService on Rust's thread shell and dispatch, and list them in own mode's tools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fake GitHub whose pull request the harness changes between steps: watch, checks failing, checks passing, a comment and the merge, each read by a restarted upstream and own mode from the same database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In own mode, agents can now watch a pull request, and a linked pull request's merge settles its thread.
What changed
PullRequestSyncReactor): every minute, and at once for a new link or an agent's shell command that merged, closed, opened or pushed to a pull request, Rust reads each linked pull request's summary on upstream's cadences and commits a changed snapshot (thread.pull-request-link.sync). It links native stack layers and pull requests an agent opened withgh pr create, and a push clears a watch's pending-checks answer.PullRequestWatchReactor,pullRequestWatch.ts): a watch is read at once when it starts, at startup, every two minutes and when the agent's own merge or close ends. Rust evaluates failed, passed and finished checks, checks awaiting approval, new comments and reviews, no checks after 15 minutes, conflicts, a needed rebase and merge queue removals, and queues one wake per thread as the agent's message from the server. The comment wake limit, the eight-failure give-up,until: "checks" | "merged"and the end on merge, close, settle or subagent are upstream's. A queued wake whose watch ended is cancelled, and one whose pull requests changed is rewritten.thread.pull-request.watch,-watch.sync,-watch.checks-reopenand-link.sync, ported fromOrchestrator.ts.watch_pull_requestandunwatch_pull_requestare served on/mcpwith upstream's handlers and listed in own mode's tools.Reads stay in the bridge
docs/bridge-to-rust.md puts source control in
tern-server-vcs(18g/18h). The sync and watch rules, evaluation, wake text and deciders are there and intern-server-threads, but the GitHub reads (summary,detail,activity,threadComments,stack,watchFingerprint) go through upstream'sPullRequestServicein the bridge with one new ask (pullRequests.read). Porting the GitHub provider's GraphQL reads with their decoders and batching (about 4,000 lines) is much larger than this step, so it stays 18g's work, which will replace the ask.Left out: the host change feeds (only a GitHub app sign-in on github.com streams them), so a watch hears of a change at its next sweep; upstream's own write notifications, which the sweeps stand in for; and the read cache's invalidation, which the bridge keeps off. Wake text says tern where upstream's says T3 Code, as the packed bridge does.
Checks
cargo fmt --all,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo test --workspace --locked(scratchHOME,TERN_KEYCHAIN=off),scripts/check-bridge.sh.own_pull_request_watchagainst upstream9677111with a fake GitHub whose pull request it changes between steps. Each step stops upstream, copies its database to a new own-mode server and starts both, so both read the change from the same state as they start, and the harness waits on conditions (the wake or the recorded watch, the turn ended, the thread settled). The tool answer, the baseline, and the wakes, link and settlement after each step matched: checks failing woke the thread, checks passing was recorded without a wake, a comment woke it with the comment, and the merge woke it with the merge commit, ended the watch and settled the thread. 37 s locally.own_agent_tools,own_mcp_sessions(tool lists updated to 17),own_agent_threads,own_commands,own_scheduled_tasks,own_steering,own_workspace.own_source_controlandown_git_actionsfail on this Mac with main's bridge too, so CI decides them.🤖 Generated with Claude Code