Skip to content

chore(conn-server): merge train for the audit PRs - #327

Merged
nckrtl merged 175 commits into
mainfrom
train/conn-server-audit
Nov 24, 2026
Merged

nckrtl merged 175 commits into
mainfrom
train/conn-server-audit

Conversation

@nckrtl

@nckrtl nckrtl commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Seventeen approved Conn Server PRs touch the same conn-engine files and kept breaking each other when they merged one by one. This train merges 16 of them onto main in one branch, one merge commit per PR, and leaves #309 out (reason below). It also fixes #310's review blocker and makes main's own conn-engine tests compile again.

Included, in merge order

  1. fix(conn-server): launch saves a new thread and its first message in one transaction #262 launch saves a new thread and its first message in one transaction: fix(conn-server): launch saves a new thread and its first message in one transaction #262
  2. fix(conn-server): a worktree launch runs the project's setup script, as T3 #314 a worktree launch runs the project's setup script: fix(conn-server): a worktree launch runs the project's setup script, as T3 #314
  3. feat(conn-server): reconcile the effect outbox after a process loss, as T3 #268 reconcile the effect outbox after a process loss: feat(conn-server): reconcile the effect outbox after a process loss, as T3 #268
  4. refactor(conn-server): keep the rollback phase in its outbox row #269 keep the rollback phase in its outbox row: refactor(conn-server): keep the rollback phase in its outbox row #269
  5. fix(conn-server): preview tunnel, peer tool names, thread chips, orphaned subagents, resumed Claude MCP #256 preview tunnel, peer tool names, thread chips, orphaned subagents, resumed Claude MCP: fix(conn-server): preview tunnel, peer tool names, thread chips, orphaned subagents, resumed Claude MCP #256
  6. fix(conn-server): side chats follow their parent through archive and delete, as T3 #290 side chats follow their parent through archive and delete: fix(conn-server): side chats follow their parent through archive and delete, as T3 #290
  7. fix(conn-server): Find searches a fork's inherited messages and the text Markdown shows, as T3 #295 Find searches a fork's inherited messages and the text Markdown shows: fix(conn-server): Find searches a fork's inherited messages and the text Markdown shows, as T3 #295
  8. fix(conn-server): new worktrees honour sparse patterns and worktreeSubmodules, as T3 #313 new worktrees honour sparse patterns and worktreeSubmodules: fix(conn-server): new worktrees honour sparse patterns and worktreeSubmodules, as T3 #313
  9. fix(conn-server): status refresh follows the fetch interval and defaultAutoPull, as T3 #315 status refresh follows the fetch interval and defaultAutoPull: fix(conn-server): status refresh follows the fetch interval and defaultAutoPull, as T3 #315
  10. fix(conn-server): terminals take their provider instance, restore a missing worktree, and keep T3 scrollback, as T3 #300 terminals take their provider instance, restore a missing worktree, keep T3 scrollback: fix(conn-server): terminals take their provider instance, restore a missing worktree, and keep T3 scrollback, as T3 #300
  11. fix(conn-server): saved schedules survive a deleted base and a folder without Git, as T3 #286 saved schedules survive a deleted base and a folder without Git: fix(conn-server): saved schedules survive a deleted base and a folder without Git, as T3 #286
  12. fix(conn-server): bounded thread snapshots and older history pages, as T3 #316 bounded thread snapshots and older history pages: fix(conn-server): bounded thread snapshots and older history pages, as T3 #316
  13. fix(conn-server): delegated tasks settle with their children, follow-ups get their own task, as T3 #275 delegated tasks settle with their children, follow-ups get their own task: fix(conn-server): delegated tasks settle with their children, follow-ups get their own task, as T3 #275
  14. fix(conn-server): worktree cleanup rules remove managed worktrees, as T3 #310 worktree cleanup rules remove managed worktrees: fix(conn-server): worktree cleanup rules remove managed worktrees, as T3 #310
  15. fix(conn-server): a provider switch or portable fork carries the conversation, as T3 #318 a provider switch or portable fork carries the conversation: fix(conn-server): a provider switch or portable fork carries the conversation, as T3 #318
  16. fix(conn-server): Pass 4 steer app notes and PR watch merge wakes, as T3 #280 Pass 4 steer app notes and PR watch merge wakes: fix(conn-server): Pass 4 steer app notes and PR watch merge wakes, as T3 #280

Left out

Worth a review

Resolution log

Resolution log

#310 blocker fix

#310 review blocker, fixed in the train (f245bea).

  • Problem: a fresh scheduled run moves a busy Claude session into detached. When the replacement session exits, open_session_cwds() (conn-engine/src/engine.rs) dropped the thread, because it read only live, so a cleanup sweep could remove the worktree before Claude woke. The TypeScript server checks liveness per provider session (apps/server/src/storageCleanup.ts:1374).
  • Fix: open_session_cwds() reads the threads in live and detached. The pump now wakes cleanup (session_released) when a session leaves either collection; release() already woke it for the reaper and thread-close paths.
  • Test: engine_tests::a_detached_session_keeps_its_folder_in_use_until_it_exits. Before the fix it failed on both checks: the folder list was empty after the replacement closed (left: [], right: ["/tmp/conn-engine-project"]), and with only the first half fixed, cleanup never heard the detached session end (timeout). It passes with the fix.

#276/#280 test port

main's conn-engine tests did not compile: #276 (squash ccd733ed95) added tests that use reserve_effect/ReservedEffect, which #261's outbox removed. These are the tests the brief placed in #280; #280's own diff has none. The train's first commit, before any merge, ports them to the outbox's test hooks:

  • gate() enqueues a CloseSession row in t1's thread lane and registers it, before the commit, in a new #[cfg(test)] TestHooks::gates map.
  • The worker holds a gated row until its release drops, then settles it without running it. The old ReservedEffect also ran nothing when dropped.
  • Two gates keep their order, as two rows in one lane.
  • All 11 callers keep their checks and pass. A throwaway probe showed the gate holds: a held thread stays starting and completes once released; with the hold disabled it completes at once.

Review fixes (head 6fda097)

The review of 35d95c6 found three defects. Each fix is its own commit, with a test that failed first.

  1. Cleanup could remove a worktree a detached session still used (d318f5480e). Archiving deletes the thread's session rows and closes only the current session, but open_session_cwds() read a detached session's folder from those rows. The live session now keeps its folder in memory (LiveThread::cwd), and detached sessions report it from there.

    • Test: engine_tests::an_archived_threads_detached_session_keeps_its_folder_in_use. Before: failed, left: [], right: ["/tmp/conn-engine-project"]. After: passes.
  2. A restart could leave a finished delegated task marked running (f656ae1640). Recovery cancelled the child's orphaned native subagent but ran finalize_tasks only for threads with unfinished runs. It now also runs it for every thread whose orphaned subagents it cancelled, in the same write.

    • Test: engine_tests::a_restart_publishes_a_task_its_orphaned_native_subagent_held. Before: failed after the restart, the task still running. After: passes; the task is completed with the child's result.
  3. A blocking delegate call dropped during setup lost the parent's wake (f2db3c9157). The worktree dispatch runs on its own task through setup, and the wake upgrade was armed only after it returned. The dispatch task now holds the armed upgrade and hands it back; if the caller is gone, the task drops it after the child commits, and the upgrade lands. This restores fix(conn-server): delegated tasks settle with their children, follow-ups get their own task, as T3 #275's test, which the train had dropped.

    • Test: tests::delegate_worktree::a_blocking_worktree_delegate_dropped_during_setup_upgrades_the_wake (setup held by the test's setup stub, the call dropped, then setup released). Before: failed, the task stayed completionWake: settled_only. After: passes.
  4. CI flake in fix(conn-server): preview tunnel, peer tool names, thread chips, orphaned subagents, resumed Claude MCP #256's a_close_keeps_a_stop_the_provider_already_confirmed (6fda097089). Test timing, not an engine defect. The test raced interrupt and close_session with tokio::join!(biased; …) and read the run status right after, before the event pump had stored anything; under load it saw running. The interrupt here runs inline, not through the outbox. The engine keeps fix(conn-server): preview tunnel, peer tool names, thread chips, orphaned subagents, resumed Claude MCP #256's behaviour: the pump stores what the session sent before the close, in order.

    • Fix: the test interrupts to completion (the provider confirmed the Stop), holds the pump at a new #[cfg(test)] pause point (pump.event) with those events received but not stored, closes the session, resumes the pump, and waits for the run's end. It still asserts interrupted, plus running before the close.
    • Proof: before, 49/50 under load (10 at a time), with the CI failure reproduced. After, 50/50 under the same load and 50/50 with --test-threads=1. A mutation that detaches every interrupted terminal makes it fail (failed vs interrupted).

Checks after the fixes: cargo fmt --check and cargo clippy --workspace --all-targets -D warnings clean. conn-engine 451 passed, 1 ignored (again after fix 4); conn-mcp 155 passed, 2 ignored; conn-server 466 passed. In the first combined run, methods::terminal::tests::a_provider_instance_terminal_gets_its_environment failed once under load (it waits up to 15 s on a real shell); it passed 5/5 alone, and the conn-server suite then passed in full.

Tests

  • cargo fmt --all (--check clean) and cargo clippy --workspace --all-targets -- -D warnings: clean.
  • node tools/gen-upstream.mjs --check: upstream tables are current.
  • cargo test --workspace --features conn-support/test-util (apps/conn-server): 1,924 passed, 16 ignored, 2 failed. The 2 failures are the known conn-terminal parallel-load flake (finds_terminals_by_id_and_respects_resume, clears_and_reports_the_foreground_command); conn-terminal alone passes 32/32, in parallel and with --test-threads=1. commit_all_commits_thousands_of_conflicts_resolved_to_ours passed.
  • During the merges, fix(conn-server): preview tunnel, peer tool names, thread chips, orphaned subagents, resumed Claude MCP #256's a_close_keeps_a_stop_the_provider_already_confirmed failed once under parallel load; review fix 4 makes it deterministic.
  • After each merge: cargo check --workspace --all-targets, and the tests of the crates that merge touched.

The original PRs stay open; close them after this merges.

Opus 5.5, Claude Code

🤖 Generated with Claude Code

nckrtl and others added 30 commits November 23, 2026 10:45
…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]>
…e settle cleared

The engine ignored restoreUnsettledAt, so undoing a settle moved the
thread to the top of Active. It now sets unsettledAt to the given time,
to null for null, and refuses a time that does not parse, as T3's
Orchestrator does.

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]>
Effects now commit in the same transaction as their command, as T3's
EventSink and EffectOutbox do, and one worker claims and runs them
(T3's EffectWorker). A closed socket that aborts a handler after the
commit can no longer lose a committed provider start. The in-memory
effect lanes are gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The restart tests open a second engine on the store while the first
engine's tasks still run. The first engine's worker could still claim the
new engine's rows, such as the continuation's turn start, and write events
with its own stale sequence counter: "UNIQUE constraint failed:
events.seq" (1 in 30 runs on Linux, 9 in 120 under load).

Dropping the engine now stops its worker and prune loop. The claim checks
the flag while it holds the write lock, and the worker checks it again
before it runs what it claimed, so a claim in flight at the drop takes
nothing the next engine wrote.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tries and wire times

- An archived thread refuses thread.unsettle before its anchor is read.
- The anchor parses as T3's DateTime.make: a time without a zone is UTC.
- A fresh command on a thread already active records thread.unsettled and
  keeps the anchor and updatedAt; a retry of the same command id records
  nothing. The shell row keeps its updatedAt, as T3's projection does.
- The event envelope carries providerInstanceId, from the updated thread.
- Wire times outside years 0000-9999 get toISOString's signed six-digit
  year, so T3's client decoder reads them.

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]>
…h on commit

Three gate findings on the effect outbox:

- A dropped or replaced engine still wrote: an effect already running
  committed into the next engine's store with a stale sequence. The
  engine now takes an engine_epoch lease at open, and every write checks
  the lease and the drop flag inside its own transaction (Tx::commit,
  claim, settle, prune). The drop flag at claim and before execution
  stays.
- One failed settlement write held the thread's lane until a restart.
  As T3's worker does, a settlement retries while the store is locked
  (100 ms), and any other failure settles the row failed instead, so the
  lane frees without running the effect again.
- A commit published its sequence only when its caller lived, so an
  aborted caller hid the change from connected clients. Tx::commit now
  sends it, for every command path, as T3's EventSink publishes after
  its transaction.

Also: pruning lets the store go between 500-row batches, and the lane
order test waits on the host's event instead of a 50 ms sleep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…al, as T3

Ending any run cancelled every pending runtime request on the thread. So
removing queued run B while run A waited on an approval cancelled A's card,
and the server refused the answer while the provider still waited.

A run's end now cancels only the requests whose node belongs to that run.
T3's queued-run cancel writes only the run, its attempt and its root node.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…starts one run, as T3

A question whose provider can no longer take it live (responseCapability
`message`, as one imported from T3 after its provider exited) was answered
like a live approval. With no live session the delivery failed, the card
expired and the answer was lost: no message and no run.

The respond command now matches the capability. For `message` it checks
the answers against the question as T3 does, resolves the card and its
item, and dispatches one user message `async-answer:<requestId>` in the
same transaction: a steer of the active run, or a queued or started turn.
Like T3, it refuses the answer when the thread's provider is disabled for
its project. Live requests keep their adapter delivery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… wake, as T3

A failed turn held every queued run. A buffered provider notification
replays output the CLI already produced, so T3 starts it while it holds
the user's messages. Here it stayed held with them.

The failure hold now leaves a queued run free when its message is a
buffered provider notification (agent, provider source, a notification,
no delegated completion), and the normal queue starts it. Stop and other
holds are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ups get their own task, as T3

Four task-lifecycle gaps against T3, all through delegatedTaskProgress:

- A child whose own turn ended while its delegate still ran reported its
  result to the parent at once. The engine now publishes a task only once its
  work settled (finalizeAppOwnedSubagent, Orchestrator.ts:14777), and
  task_status answers waiting_for_children until then (readTask,
  OrchestratorMcpService.ts:1703).
- A send to a finished child started a run with no task, and its answer
  replaced the original task's result. It is now a follow-up task bound to the
  run (recordSubagentFollowup, Orchestrator.ts:9794); conn_thread_send returns
  its taskId, and each task reads only its own runs.
- A blocking delegate_task returned the result but left its delivery pending,
  so the parent was woken with it again. readTask acknowledges a terminal
  result it returns (OrchestratorMcpService.ts:1902).
- untilDelegatedWorkSettled held on any background task. Unawaited commands
  and monitors no longer hold it (backgroundWorkHoldsCompletion,
  orchestrationV2PendingBackgroundWork.ts:90).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s T3

The engine passed MCP app notes in the turn input, but the Claude session
never used them, so the model never saw what an app reported.

As T3's withClaudeAppContext, a turn now puts each note the native thread
has not seen with its current text before the prompt, as quoted app data
(`<external_KEY>text</external_KEY>`). A slash command gets none. What a
turn offers enters the history only when the turn completes, so an
interrupted turn's notes go again. Compaction, a conversation reset and a
rollback clear what the history holds. Steers follow with SteerInput.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…delete, as T3

thread.delete ignored onlyIfUnused, so closing a side chat that held a
conversation deleted it. Archiving or deleting a parent left its side chats
active and readable.

Port T3's Orchestrator.ts (thread.delete, thread.archive/unarchive and
liveSideChatIds): onlyIfUnused keeps a thread with a message or a run;
archive takes active side chats except one with running delegated tasks;
unarchive restores only those archived with or after the parent; delete
takes them all. The command's one transaction stands in for T3's
side-chat locks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… switch

A Conn thread can now move between Claude, Codex, Grok and Antigravity
mid-thread, and the new provider gets the conversation, as T3 does.

- A run on another instance than the conversation's carries a consumed
  provider_handoff transfer and a context handoff (prepareProviderHandoff):
  the whole history for a provider with no native thread yet, else the
  delta since its thread last took part. A queued run decides when it
  starts. The turn start delivers it as merge-back does: injected for
  Codex, inline for the others.
- The switch checks the target's context capabilities
  (ensureContextHandoff) with T3's refusal text.
- All four providers now advertise supportsProviderSwitchingViaHandoff,
  so clients open the model picker to other providers.
- Fix: the condensed delivery coverage names the provider thread's app
  thread, as T3 does.

Proof: three engine tests, 9 more T3 handoff cases (90), and a client
check of the switch through the client's reducers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lippy in the switch test

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pt, as T3

Settling a thread closed its stopOnSettle terminals but never ran the
project's runOnSettle script. T3's cleanUpSettledThread
(ThreadSettlementService.ts:700) runs it after closeOnSettle, in the thread's
own existing worktree, once per settlement, and skips a delegate that shares
its parent's checkout. The host now calls McpService::run_settle_script from
the committed settle effect; it reuses the project-script runner, generalised
to T3's runForThread trigger (a fresh settle-<id>-<8 hex> terminal).

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]>
…nd settling closes idle shells, as T3

T3 follows a settle script to its end: the command is wrapped to print a
sentinel with a per-run token and the exit code (wrapCommandForCompletion,
ProjectSetupScriptRunner.ts:229), and after exit 0 the terminal closes once
its shell is idle (closeIdle). T3's closeOnSettle also closes every idle shell
of the settled thread (Manager.ts:3922).

- conn-terminal: TerminalManager::shell (getShell) and close_idle (closeIdle):
  only a shell at its prompt closes; a foreground job, an unreadable foreground
  group, a shell replaced by exec (rootIsCommand) and a terminal that changed
  while it was checked stay.
- conn-mcp: script_completion ports the POSIX, fish, Nushell and PowerShell
  wrappers, the sentinel and the completion observer; cmd.exe is refused as
  T3 refuses it. Settle scripts use them.
- conn-server: the settle effect closes stopOnSettle terminals, then idle ones,
  then runs the settle script.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… and envelopes

- Command times (restoreUnsettledAt, snoozedUntil, visitedAt) parse as T3's
  DateTime.make: a port of V8's Date.parse, legacy forms included, with
  Effect's zone rule and the server's zone for local times. Checked against
  T3's own answers for 1683 strings in five zones (gen-date-cases.mjs).
- An archived thread refuses settle, auto-settle, unsettle, snooze,
  unsnooze, auto-settle set, pin, unpin and both reorders first, as T3.
- The thread's updatedAt follows T3's ProjectionStore: a thread event writes
  its payload's, every other event its own time, in the row and the stored
  thread (list generated from T3). Pin and settle keep updatedAt as T3 does.
- The event envelope names providerInstanceId wherever T3's does, mapped
  flow by flow; thread-cli-diff compares it with the T3 server.
- Command receipts are kept for good and record refusals: a retry gets the
  recorded refusal, a receipt answers only for its own thread, and an old
  retry after an undo changes nothing (T3's receipt tests, ported).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An outbox row outlives a server update. Fields a later build adds to
CleanupHtmlAttachments take #[serde(default)], so a row stored before
them still decodes (audit 6.7 adds one).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rules

Gate findings on 4.2 and 4.4:
- A held queue is released only by a client send (`sentByUserFromClient`:
  a user's web or mobile message, not a steer follow-up or scheduled task).
  The async answer, created by the server, no longer resumes work the user
  stopped.
- The async answer steers only into a provider turn that runs. A run still
  starting gets the answer as its own later run, instead of the deferred
  steer that delivered it into the start.
- A provider result queued while a held queue waits does not take the
  hold unless Stop reached the active run (`wakeSkipsHold`), so a second
  buffered result drains while the user's message stays held.
- A usage-limit failure holds everything queued, provider wakes too, as
  T3 checks `usageLimitHoldsQueue` before a failure starts a wake.

T3's worktree-setup condition has no counterpart: this engine records no
workspace preparation on runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…runtime

Four gate findings on the outbox:

- A replaced engine could send a rollback twice: its phase update checked
  only the command id and took zero changed rows as success. The move
  from admitted to provider is now one write that checks the engine's
  lease and the expected phase, and the provider is contacted only when
  exactly one row moved. Otherwise the rollback stops and writes nothing.
- Overlapping opens: engine A's late startup cancel could cancel engine
  B's committed start. The ownership check and the cancel are one
  immediate transaction; a stale open gets NOT_OWNER and aborts.
- Two failed settlement writes left a row running. The settlement is
  kept and tried again with backoff (100 ms, doubling, 30 s at most) for
  as long as the engine owns the store; the effect ran once.
- The server opened the store, ran its migrations and recovery on the
  runtime thread. SqliteEngine::start opens on the blocking pool; the
  worker starts once recovery committed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… without Git, as T3

- A scheduled run launches its saved strategy, which can outlive its base
  branch. Its provisioning now falls back as T3's worktreeFallbackBase does:
  the remote's default branch (fetched), then the checked-out branch, then
  HEAD. A stale tracking ref is skipped when the fetch finds no branch. An
  interactive launch that names a missing base still fails.
- A worktree strategy for a project whose folder is positively not a Git
  repository, Scratch included, is saved as root, as T3's upsert does. Runs
  apply the same rule to tasks saved earlier. A folder Git cannot read keeps
  its own error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on, proven through the host

Gate review on #277:
- P3: deduplication used a 512-entry cache, so after enough other threads a
  repeated settle could run a script again. The engine now tells the host
  whether a settle is a transition: a settle of an already settled thread
  emits ThreadClose::SettledAgain, which closes terminals (closeOnSettle) but
  does not run the settle script. The cache is gone.
- P2: the acceptance test now drives the production path. In conn-server, a
  real engine whose host is the real Host settles a thread in a Git worktree:
  the script starts from the settle effect, its terminal closes after exit 0,
  a repeat settle runs nothing, and a failing script keeps its terminal. With
  the host hook removed the test fails ("the settle effect starts the
  project's settle script").

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]>
… and replay follow T3

- Receipts name their owner (owner_kind thread or project, owner_id), chosen
  by command type as T3's commandThreadId: a fork's and a merge-back's is
  the target thread. Migration 5 names older receipts' owners from their own
  events; one nothing proves is kept and refused, never run twice. A project
  receipt never answers for a thread.
- A replayed queue.resume or queued-run.start checks the queue again and
  answers the recorded sequence. A command that writes nothing answers its
  own thread's latest sequence. Thread setters record their event even when
  nothing changes (a re-pin keeps updatedAt).
- thread.auto-settle refuses a thread set active or changed after its
  snapshot, then settles with the archive guard first.
- thread.visit keeps the later visit, compared as times, and records
  thread.visit-recorded.
- The first message after a merge-back names its instance on the handoff and
  transfer events.
- The receipts' high-water mark reads an index. Opening the engine off the
  runtime thread is #261's.
- thread-cli-diff excuses only the expired question after its session's
  release, row by row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cel queued follow-ups, as T3

Gate review on #275, each with a consumer test that fails on e2af431:

- A running follow-up woke its parent when the parent's turn ended. Delivery
  now requires a terminal task status (Orchestrator.ts:2113).
- A task held by an awaited command never settled when the command ended
  after the turn. The runner now finalizes a child's tasks in the write of a
  roster update that drops a holding task, or of a subagent that stops
  (Orchestrator.ts:16085). The fake provider can end its bg-1 command.
- Claude roster entries carry no run, so a follow-up never counted its own
  awaited command. The store attributes each task to the run it first
  appeared under and keeps it across roster updates (ProjectionStore.ts:915).
- task_status preferred a later untagged run's text over the task's
  published result. It returns the published result first
  (OrchestratorMcpService.ts:1819); the test also reads both tasks after the
  engine reopens.
- task_cancel left a follow-up's queued run for Resume. It now disposes the
  delivery, stops the child's active run and cancels the task's queued runs
  (OrchestratorMcpService.ts:2947); a follow-up whose only run was cancelled
  before it started ends cancelled (delegatedTaskResultRun).
- A blocking delegate_task watched only the parent's row after the child's
  first turn. It follows both threads from before its first read, so a
  question or approval in the child returns it (OrchestratorMcpService.ts:2090).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
nckrtl and others added 3 commits November 24, 2026 08:49
…ies the conversation, as T3

# Conflicts:
#	apps/conn-server/crates/conn-engine/src/checkpoint_tests.rs
#	apps/conn-server/crates/conn-engine/src/commands.rs
…ge wakes, as T3

Merged with merge base 0148c3f: the branch is built on #276, which is in
main as squash ccd733e.
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XXL labels Nov 24, 2026
nckrtl and others added 4 commits November 24, 2026 09:06
…der in use

Archiving deletes the thread's session rows and closes only its current
session. A session a fresh scheduled run moved aside still runs, but
open_session_cwds read its folder from those rows, so cleanup could remove
the worktree under it. The live session now keeps its folder in memory,
and detached sessions report it from there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gent held

A delegated child whose run completed while a provider-native subagent
still worked keeps its task open. A restart cancels that subagent, but ran
finalize_tasks only for threads with unfinished runs, so the parent never
got the result. Recovery now also finalizes the tasks of every thread whose
orphaned subagents it cancelled, in the same write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ades the wake

A worktree delegate's dispatch runs on its own task, through the setup
script. A caller that disconnected meanwhile was gone before the wake
upgrade was armed, so the child committed with settled_only and could
finish without waking a parent still at work. The dispatch task now holds
the armed upgrade and hands it back; a call that went away leaves it to
that task, which drops it after the child committed. Restores #275's test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
a_close_keeps_a_stop_the_provider_already_confirmed raced interrupt and
close_session with join!(biased), then read the run before the pump had
stored anything. Under load it saw `running` (CI on #327). The engine is
right: the pump stores what the session sent before the close in order.

The test now interrupts to completion, holds the pump at a new cfg(test)
pause point (pump.event) with the confirmed events received but not
stored, closes the session, resumes the pump, and waits for the run's
end. A close that detached the run would leave it `failed`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nckrtl
nckrtl merged commit ee7b1f9 into main Nov 24, 2026
48 of 49 checks passed
This was referenced Nov 24, 2026
nckrtl added a commit that referenced this pull request Nov 24, 2026
Conflicts kept both sides:
- message.dispatch keeps `idleCompaction` beside main's `target_capabilities`, worktree-missing
  check and provider-switch handoff item.
- The close hook keeps main's SettledUnnamed and its awaited archive/delete cleanup; the idle
  compaction timer cancel moves into that Archived/Deleted arm.
- clean_up_settled takes main's optional settlement; its body runs in an inner block so the
  settlement sweep still wakes on main's early returns.
- serve.rs: main's start_agent_tools call, then the settlement and compaction start; shutdown
  stops them before main's worktree cleanup.
- Host keeps settlement_wake, idle_compaction and main's worktree_cleanup in every initializer.
- Store, fake provider, families, Cargo.lock, status.md and engine_tests take main's code plus
  #311's additions. Migrations stay at main's user_version 5.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant