Repository navigation
fix(conn-server): preview tunnel, peer tool names, thread chips, orphaned subagents, resumed Claude MCP - #256
Merged
Merged
Conversation
…t3_* names The preview tunnel carries a remote desktop's browser to loopback ports, as apps/server does. gen-upstream now also lists HttpRouter.add routes. Peer calls retry once under the t3_* name when an older peer does not know the conn_* tool. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Claude keeps conn MCP - Expand composer context references (thread chips and the rest) before every provider turn, byte-equal to projectComposerContextForProvider; conn_thread_read and conn_thread_send accept thread_ ids. - End provider-native subagents whose process is gone: cancelled at engine start, interrupted at pump end (not on shutdown). - Bind the listener and give /mcp its address before recovered runs resume, and reconnect the conn MCP server once when Claude reports it unavailable. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… only when its process ended Closing a session on a shared Codex app-server (RuntimeShared) still ended its pump, and the pump-end cleanup then interrupted every open native subagent on the thread, a replacement session's included. As upstream writeReleasedSubagentEvents does, the cleanup now runs only for sessions whose background tasks end with the process: from close_session on RuntimeStopped, or at pump end when the session ended on its own and is still the thread's current one. It ends only subagents of that session's provider threads that started before the release. conn_thread_read and conn_thread_send reuse the projection the thread_ id resolver loaded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Codex session ended its child turns (subagent interrupted) before it learned that the app-server outlives the close. It now calls remove_session first, and on a shared close the mapper ends only root turns (Mapper::on_close). Run finalization no longer fails an open subagent item whose provider-native subagent is still running; that item ends with its subagent, from the provider or from the orphan cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a Stop ends them A session closed on Codex's shared app-server dropped its child turns and their routes, and the engine's pump stopped reading. A child that completed later reached no one. As T3 keeps the child's turn context past a release, the session now keeps the child's route, mapper turn and event sender until the child settles or the process exits. The engine pump reads on until the session drops its events; the run is detached before the close and ends failed. Run finalization skipped every open subagent item whose native row was active, so a confirmed Stop left the run's own subagent running. finish_run_as now takes the reason (RunEnd): a detached session keeps live native subagents, and a run that ends interrupted, failed or cancelled ends its open native subagents with it, record, node, item and child turn together (cascadeTerminalizeRunOwnedSubagents). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Codex subagents Round 3 of the #256 gate. - A shared close keeps the route of a child Codex announced but has not started: open_child_threads counts unsettled subagents, not only running child turns. - Root terminals follow emitOrDeferRootTerminal: a failed root with running descendants carries childTurnsContinue (the engine ends its run Detached), and an interrupted root's terminal waits until its descendants settle. - A confirmed Stop follows the run's child links even when the subagent record has already settled. The record keeps its result, and each open node and item settles once. - A refused thread/resume puts the previous route back. The app-server tracks closed sessions that wait on subagents by process generation, so the process exit always releases them. - close_session stores the terminals already received, with a bound, before it detaches the run. A confirmed Stop keeps its status. - A closed session's silent child is checked with Codex (thread/read with turns, as T3's readThreadSnapshot) every child_check_interval, at most 60 times. Then what is still open ends interrupted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…conciliation, readable search Round 4 of the #256 gate, and audit entry 6.5. - Stop: past the deadline, a root Codex already ended no longer waits for silent descendants; the rest of the lineage settles (T3 deferToActiveRoots). - A confirmed Stop follows the run's owned threads recursively, nested native subagents with no run included, and settles each open record, node, item and provider turn on its own (T3 ownedThreadIds; ports its nested regression test). - A resume of a thread another session owns takes nothing over until Codex accepts it, so a completion sent before a refusal reaches the owner. - A closed session's child checks go through the session inbox, so the driver applies and publishes each result in order. A failed read other than a missing thread is retried. At the bound, each open child turn gets turn/interrupt and is read once more before anything ends interrupted. - A process exit ends a child announced before its first turn. - The pump detaches a closing session's run only after it stored the events received before the close. A stopped session drains what is queued; no timeout decides the run's status. - At most one deferred root terminal per native root thread, published in order. - Thread search indexes each message as it reads (T3 readableSearchText): a citation as its text and comment, not its hidden link. Schema step 5 re-indexes existing messages and keeps their stored text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 23, 2026
…ownership and readable search - A Codex Stop that times out while its root still runs stays pending; the root's later end settles the rest of its lineage (T3 forks this wait). - A close marks the position of the events sent before it, so an interrupted turn the provider's own close produces is not taken for a confirmed Stop. The pump reads its receiver under a lock it never holds across a store write; a busy pump is counted by the close, an idle pump marks the position itself. - A Stop ends every open node and item in the run's subagent threads whose run is none or the root run, and clears `streaming` on each settled item (T3's ownership test). The traversal follows every owned thread, with no cap. - The silent-child watchdog ends a child only on T3's missing thread (-32600, `thread not found:`). A child still running after the last check keeps its route. - Deferred root terminals wait per native root turn, as T3's deferredRootTerminals. - Readable search moves to schema step 6 (#260 keeps step 5). The upgrade and the T3 import share one paged pass by message_keys.id, and every write goes through the same search-entry writer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rocesses, watchdog retry, release scope A session close no longer counts events against a mark. Instead the adapter marks a terminal its close produces (`TurnTerminal.cause: sessionClosed`). The engine records that terminal as failed and detached, never as a Stop. The pump owns its receiver again. After a close it stores what was already sent, then detaches a run still open. - Codex: a turn that ends during a Stop keeps its process ids, and the Stop terminates any not in its snapshot (`terminateTrackedTerminals`). - Codex: after the last watchdog check, a failed read is retried once per interval, without another interrupt. - Engine: release and recovery end only runless root turns and their attached work (`endRunlessRootTurns`). Cascade events carry the owning run id. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts running The 60th check of a closed session's subagent sent turn/interrupt even when every thread/read said inProgress, so an hour-long healthy child was cut off. The last check now interrupts only turns Codex did not last report running; those stay read-only until Stop or their own end. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # apps/conn-server/crates/conn-engine/src/commands.rs # apps/conn-server/crates/conn-engine/src/engine.rs # apps/conn-server/crates/conn-engine/src/fake.rs # apps/conn-server/crates/conn-engine/src/lib.rs # apps/conn-server/crates/conn-engine/src/runner.rs # apps/conn-server/crates/conn-engine/src/store.rs # apps/conn-server/crates/conn-provider-claude/src/interrupt_tests.rs # apps/conn-server/crates/conn-provider-claude/src/mapper/mod.rs # apps/conn-server/crates/conn-provider-codex/src/client.rs # apps/conn-server/crates/conn-provider-codex/src/launch.rs # apps/conn-server/crates/conn-provider-codex/src/mapper.rs # apps/conn-server/crates/conn-provider-codex/src/replay_tests.rs # apps/conn-server/crates/conn-provider-codex/src/session.rs # apps/conn-server/crates/conn-provider/src/lib.rs # apps/conn-server/crates/conn-server/src/serve.rs # apps/conn-server/tools/check.sh
…tached sessions - The receipt-owner step adds each column a store lacks, at any version up to 6, so a store the branch wrote at 6 before the merge gets them. - A shared Codex close settles a run held between goal turns: its completed turn and terminal show, as the process-ending close does. - A busy session a fresh run moved aside ends its native subagents when its stream ends on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # apps/conn-server/crates/conn-engine/src/engine_tests.rs # apps/conn-server/crates/conn-engine/src/reads.rs # apps/conn-server/crates/conn-engine/src/store.rs # apps/conn-server/crates/conn-engine/src/t3_import.rs
Owner
Author
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.
Five gaps between the Rust Conn Server and the TypeScript server, which is the reference.
1. Preview tunnel route
Conn's browser reaches a remote environment's loopback ports over SOCKS through
/api/preview/tunnel. Only the TS server had this route. Conn failed withERR_SOCKS_CONNECTION_FAILED, and both live servers answered 404.crates/conn-server/src/routes/preview_tunnel.rs. It uses the same protocol and auth asPreviewTunnel.ts:?port=1..65535, or it answers 400.terminal:operateopens it.x-t3-tunnel-port-refused: 1.tools/gen-upstream.mjsnow also lists the routesapps/servermounts withHttpRouter.add. Constants in paths are resolved, and a call it cannot read fails generation.http-routes.jsongained 17 routes, including/api/preview/tunnel.tools/bump-report.mjsunderstands/*wildcards and*methods.2. Thread messaging between server versions
A peer call that gets
Tool 'conn_x' not foundfrom an older peer retries once ast3_x(PeerLinks::call_once).3. Thread chips give agents context
crates/conn-engine/src/composer_context.rsandcitations.rs, ported fromprojectComposerContextForProviderandexpandAssistantCitationsForProvider. They cover all 11 record kinds, unknown and unavailable records, and envelope escaping.conn_thread_readandconn_thread_sendacceptthread_<id>.tools/gen-composer-context-cases.mjs, wired intocheck.sh), prove the output is byte-equal.4. Orphaned native subagents end
families.rs::end_orphaned_native_subagentsends provider-native subagent rows, their nodes and turn items, and the child thread's runless root turns. It works like upstreamendOrphanedNativeSubagentandendRunlessRootTurns.threads_with_live_native_subagents().writeReleasedSubagentEventsdoes, and only when the provider's background tasks end with its process (Claude yes, Codex no). It runs fromclose_sessionwhen the close returnsRuntimeStopped, or at pump end when the session ended on its own and is still the thread's current one. ARuntimeSharedclose or a replaced session never triggers it. It ends only subagents of the released session's provider threads that started before the release took effect. It does not run during shutdown.CodexAdapterV2.ts). OnRuntimeShared,Mapper::on_closeends only root turns and keeps child turns. The app-server keeps the child threads' routes (remove_session(id, keep)). The session keeps its mapper and event sender until no child turn is open, or until the process exits (then the child ends interrupted). The engine pump reads on until the session drops its events.close_sessiondetaches the active run before the close and ends it failed.RunEnd).Detached(the session was released or its events ended) leaves an open subagent item alone while its provider-native row still runs; the subagent's own end closes it.Settled(a confirmed Stop, a failure, a cancel) ends the run's open provider-native subagents with an interrupted, failed or cancelled run: record, node, item and the child's runless turns together, as T3'scascadeTerminalizeRunOwnedSubagents. App-owned subagents are not touched.subagent.updated,node.updated,turn-item.updatedandprovider-turn.updated. The web treats cancelled and interrupted as finished, so the agent moves to "Previous agents".5. Resumed Claude sessions keep the conn MCP
Root cause:
SqliteEngine::openstarted recovered runs beforeserve.rshad bound the listener and calledmcp.set_listen_address. Each resumed session got aconnentry pointing at the fallbackhttp://127.0.0.1/mcp(port 80), sosetMcpServersfailed (MCP servers unavailable: conn). Tokens were not the cause: every session gets a fresh token after a restart.Fix:
/mcpgets its address.EngineConfig::hold_recovery: recovered runs wait forresume_recovered(), whichserve.rscalls once/mcpis ready.connas failed, the session calls the SDK'sreconnectMcpServer("conn")once per registration. The SDK host allows that method, andPROTOCOL.mdlists it. This is a deliberate difference from T3, which only logs the failure.Gate round 3 (7f3ae5b)
Each fix has a test that failed on bdb9908. The tests port the reviewer's probes and, where one exists, the T3 test named here.
turn/starteda_shared_close_keeps_a_child_announced_before_its_first_turn(probe)childTurnsContinue, and the engine ends the runDetacheda_failed_root_with_a_running_child_says_the_child_continues(T3 "handles a late native child after the capacity retry failed"),a_failed_root_whose_children_continue_leaves_them_runningemitOrDeferRootTerminal,flushReadyRootTerminals)an_interrupted_root_ends_after_its_running_child(T3 "... capacity retry interrupted")families::end_run_native_subagents)a_confirmed_stop_after_the_record_settled_ends_the_childs_open_work(T3 "ends a subagent that outlived its root…",stoppedcase)AppServer)a_refused_resume_keeps_the_closed_sessions_route(probe)close_session)a_close_keeps_a_stop_the_provider_already_confirmed(probe)thread/readwith turns (T3's ownreadThreadSnapshotrequest) everychild_check_interval(60 s), at most 60 checks, then interrupteda_silent_child_is_reconciled_with_codexAll state is bounded: at most 16 deferred terminals, one detached entry per session, and 60 checks. Nothing new blocks the runtime thread. No generated contract changed:
TurnTerminal.child_turns_continuemaps the contract's existingchildTurnsContinue.Gate round 4 and audit 6.5 (8e103a9)
Each fix has a test that failed on 7f3ae5b (run there with only the new tests applied) and passes now.
deferToActiveRoots)a_stop_settles_a_silent_child_once_the_root_ended, throughinterrupt_turnfamilies.rs)runId: null); settle each open record, node, item and provider turn on its owna_confirmed_stop_ends_a_nested_native_subagent_and_its_thread(ports T3 "ends a nested native subagent and its thread…"),a_confirmed_stop_ends_an_open_item_under_a_settled_child_turnAppServer::claim_route)a_refused_resume_leaves_the_childs_completion_with_its_owner; the stub completes the child before refusing, and the process stays upSessionMsg::ChildRead); the driver applies and publishes them before it releases the sendera_checked_childs_end_survives_another_childs_live_completion(B's read held until its live completion is processed)turn/interrupt, then read again before ending interrupteda_failed_child_read_is_retried_and_the_last_check_interrupts_the_turnMapper::on_exit)a_process_exit_ends_a_child_announced_before_its_first_turnfailedfor a confirmed Stopclose_session, pump)a_close_behind_a_slow_write_keeps_a_confirmed_stop(store held past the close's wait)a_thread_keeps_one_deferred_root_terminal_in_orderstore.rs,reads.rs)readableSearchText: citation text and comment, unescaped link labels) inmessage_keys.search_text; schema step 5 re-indexes existing messagessearch_reads_a_citation_as_its_text_and_comment(ports T3 "matches the readable text of quotes and their comments" and "finds accented, CJK, and apostrophe words of a quote through the index"; includes an older index refreshed on upgrade)Ran locally on macOS:
cargo fmt --check.cargo clippy -D warnings(all targets and features) on conn-engine, conn-provider-codex, conn-provider and conn-provider-claude.cargo test --libfor conn-engine (228) and conn-provider-codex (88).The full
tools/check.shdid not run locally, because there was not enough disk for it; it runs on Linux in CI. Two store tests now expect schema version 5.Gate round 5 (1fd66b7)
Each test below failed on 8e103a9 (run there with only the new tests applied) and passes now.
a_late_root_end_settles_a_timed_out_stopclose_session, pump)received + queued; an idle pump marks the position itself. The provider's own close-timeinterruptedfalls after the marka_close_does_not_count_its_own_interrupt_as_a_stop(slow write, active root, no provider Stop:failed);a_close_behind_a_slow_write_keeps_a_confirmed_stopstill passest3_import.rs,store.rs)an_import_indexes_citations_as_they_readfamilies.rs)runIdis null or the root run settles;streamingclears on each settled item that has ita_confirmed_stop_ends_every_open_child_node_and_item_of_the_run-32600with athread not found:prefix ends a child. A child stillinProgressafter the last check keeps its route, and its own end settles itonly_codexs_missing_thread_error_ends_a_silent_child,a_child_still_running_at_the_last_check_settles_with_its_own_endstore.rs)refresh_readable_searchpages bymessage_keys.id, 500 at a time, and rewrites only rows whose readable text differs; the version advances after it finishesan_older_search_index_is_read_again_on_upgrade(from v4 and from v5 with the column really dropped, ending at v6). Correctness only: no memory testeach_deferred_root_terminal_waits_for_its_own_descendantsa_confirmed_stop_follows_a_long_chain_of_nested_subagents(300 levels)Migration: readable search is schema step 6, and step 5 belongs to #260. Two parts wait for the rebases. The folding from #285 (
fold(readable.unwrap_or(text)), in the v6 backfill and the import) goes in when #285 lands. The v5 test then reopens #260's real v5 schema instead of my stand-in.Ran locally on macOS:
cargo fmt --check.large_enum_varianton the pump's internalNextenum. I silenced it with a reasoned#[expect]and did not rerun clippy, because disk fell below the build floor; CI runs clippy.tools/check.shdid not run locally.Gate round 6 (e7841db)
Each test below failed on 1fd66b7 (run there with only the new tests applied) and passes now, unless the table says otherwise.
Close ordering, by attribution at the source. The close mark, the
received/takencounting for it, and the acknowledgement wait are gone.TurnTerminalgainscause(providerby default,sessionClosed). T3's ownreasonis free text that becomes the Stop message, so it did not fit.close()starts. Every root terminal they build from then on carriescause: sessionClosed.sessionClosedterminal asfailed("The provider session ended during the turn.") withRunEnd::Detached, never as a Stop. A Stop counts only when the user's Stop request and the provider's own end both exist.a_close_after_a_read_ahead_continuation_detaches_the_runa_close_does_not_count_its_own_interrupt_as_a_stop(now the fake's close names itself as the cause);a_stop_ended_only_by_the_close_is_not_a_confirmed_stop(new);a_close_behind_a_slow_write_keeps_a_confirmed_stopanda_close_keeps_a_stop_the_provider_already_confirmedstill endinterrupted;a_shared_close_leaves_a_running_subagent_openasserts the causesettle_lineageterminates those not in the snapshot (terminateTrackedTerminals)a_stop_terminates_a_process_reported_after_its_snapshota_failed_last_read_is_read_again_without_another_interruptfamilies.rs)endRunlessRootTurns: runlessroot_turnnodes and their runless items and provider turns. The broad owned-thread traversal stays only for the run-end cascadea_restart_ends_only_the_runless_root_turns_of_a_subagent_threadfamilies.rs)runIdis the row's run or else the owning run; subagent rows use the owning run. PayloadrunIdunchangeda_confirmed_stop_ends_a_nested_native_subagent_and_its_thread(extended)Not fail-first:
a_stop_ended_only_by_the_close_is_not_a_confirmed_stopanda_close_does_not_count_its_own_interrupt_as_a_stopalso pass on 1fd66b7, because the close mark covered them. They guard the new design. On 1fd66b7,a_failed_last_read_is_read_again_without_another_interrupthangs until its 60 s timeout. Its first run there passed once, most likely a stale binary in the shared target dir; it then failed in 4 of 4 runs.Ran locally on macOS:
cargo fmt --check.cargo clippy --all-targets -D warningson conn-provider, conn-engine, conn-provider-codex and conn-provider-claude: clean.tools/check.shdid not run, because disk stayed under 60 GB. ACP builds terminals as JSON, so the new optional field needs no change there; it was not rebuilt.Verified
cargo test --workspace: all pass. New tests:t3_*fallback.RuntimeShared, the child'sturn/completedstill yields its completed provider turn and subagent node, and the events then end; when the last session stops the process instead, the child ends interrupted. Fails on ba7f0e9.cargo clippy --workspace --all-targets -D warningsandcargo fmt --check: clean.tools/check.shon bdb9908: 57 passed.client-checktimed out only on build time in the shared target (it passes in 7 s run alone), andparityneedednpm ciinhelpers/sdk-host(then "no differences"). Earlier run: 61 passed, 0 failed. That includes parity, claude conformance, claude probe conformance, instances-flow and canary.cargo denywas skipped because it is not installed on this machine; CI runs it.vp run check:changed: pass.node tools/gen-upstream.mjs --checkandgen-composer-context-cases.mjs --check: current.Follow-ups
serve.rsitself. The engine's hold/resume gate and the reconnect are tested./mcpexists. A task that fires in that short gap gets noconntools./api/device-hub/*is built withformat!, sobump-reportlists it as not served even though it is served.endNativeSubagentTrees), and nowriteIfSubagentUnchangedconflict check.t3_import.rsstill copies running rows; the next start cleans them up.thread_id acceptance is new behaviour; T3 does not normalize these ids.🤖 Generated with Claude Code