Repository navigation
fix(conn-server): launch saves a new thread and its first message in one transaction - #262
Merged
Merged
Conversation
…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]>
…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]>
… 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]>
nckrtl
force-pushed
the
fix/conn-server-atomic-launch
branch
from
November 23, 2026 18:54
e583247 to
a419171
Compare
nckrtl
changed the base branch from
main
to
conn-server/unsettle-restore-anchor
November 23, 2026 18:54
… 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]>
thread.settle with an expectedLatestRunId that is not the thread's latest run (every run by ordinal, queued ones too; or no run at all) is refused with T3's "The thread received another run before settlement." instead of returning quietly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nckrtl
force-pushed
the
fix/conn-server-atomic-launch
branch
from
November 23, 2026 19:30
a419171 to
78fec3f
Compare
nckrtl
force-pushed
the
fix/conn-server-atomic-launch
branch
from
November 23, 2026 20:06
78fec3f to
4611c3e
Compare
…d queue admission as T3 - Migration 5 names an older receipt's owner only from its own execution: the event at the receipt's sequence must carry its command id, so an older run of a reused id (main pruned receipts, not events) never decides it. A delegation's parent is the thread whose task row names the created child. The upgrade pages receipts and commits columns, owners and the version in one transaction. - The queue start holds the queue when the run's provider is off for its project (T3's startNextQueuedRun), so a replayed queue.resume starts nothing then. - A project write reads its receipt in its own transaction and records its project and command type: a thread command's id, or another project's or command's, is refused with T3's text and the receipt kept. - thread.visit reads the stored read mark as a command time, so main's stored forms compare correctly. - thread-cli-diff excuses the expired question only when it pairs with exactly one T3 question for the same native request, thread, run and request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nckrtl
force-pushed
the
fix/conn-server-atomic-launch
branch
from
November 23, 2026 20:28
4611c3e to
2b0b43a
Compare
… queue start as T3 - Migration 5 only adds the receipt columns (one transaction). A receipt from before keeps no owner, so a retry across the upgrade is refused, never run twice. The evidence-based backfill and its tests are gone. - A project command takes its id inside its write (insert-if-absent) and validates a receipt another write holds there; a receipt is never replaced. A refusal from planning is recorded under the project and T3's command type (project.update is project.meta.update) and replayed; folder and store failures stay retryable. A replay with no project row is T3's typed read error. - The queue start resolves the run's effective selection (a message that follows the conversation takes the thread's) and checks it with T3's queue rule: only an explicit project override or a machine entry disables. The server reads it from the settings under the lock, without a copy. - thread-cli-diff binds its one exception to the thread and run of the scenario's asked step, with the pending row before its terminal row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Moved from fix/conn-server-rejected-receipts (4bbd2ac, audit 1.6 and 1.7): after the store reopens, a refused id is refused again though its precondition now holds, an accepted archive replays with its original sequence after an undo and 4,400 later writes, and the same command under a new id runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nckrtl
added a commit
that referenced
this pull request
Nov 23, 2026
…ls, overflow and message-less launches - A thread a link below full access starts, and a delegate of one, runs no setup script (T3's linkOriginIsFenced, checked before the terminal opens). - A cancel during the terminal's open waits for it, then closes that terminal. - A delegate the engine would refuse is refused before its checkout and script. - A sentinel the subscriber's overflowing queue dropped is read from the resync snapshot; an exited shell there ends the wait. - A worktree launch with no first message ends its agent stage when it commits. - Tests for shutdown and concurrent-retry cleanup of delegates, ignored until #262. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…one transaction A launch wrote the new thread and its first message as two commands, so a dropped socket between them left an empty thread. The gates then found replays and claims that could land on the wrong thread, project or checkout, or leave state behind. Each check now runs in the write that commits, as T3's orchestrator does. - thread.create carries its first message; thread, message and run commit together. A reused thread takes its message in a command of its own. Every separate first message checks the checkout its claim recorded, read from the claim's own event. - A launch's own checks (reusable thread, project, checkout, mode limit) run at admission in the command's write. As in T3's ThreadLaunchService they record no receipt, so a refused launch id stays usable. - Receipts (#260's owner columns) decide replays. A replayed launch must be the id's own thread.create; only an accepted message.dispatch of the thread with its run counts as a first message. - A launch runs on a server-owned task. Shutdown refuses new launches, cancels worktree setup through the host, and gives admitted launches a 10 s grace to commit or clean up in process, as T3 closes its preparation scope. A worktree a crash leaves stays on disk, as in T3. - conn-vcs reports a worktree's claim before `git worktree add` and runs git in its own process group, so a cancel during `post-checkout` reaps the hook's process tree and removes the checkout and its branch. A discard removes the branch only once the worktree is gone, and says what stayed. - Provider admission passes a launch already accepted and reads settings off the runtime thread; a thread.create with its first message checks the provider in its commit. - The returned projection must be in the launch's project. - thread.delete honours onlyIfUnused under the thread lock. - A refused or replayed message releases only its own claim's copies. - The .gitmodules check runs off the runtime thread. - Test binaries stop git's repository search at the temp folder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nckrtl
force-pushed
the
fix/conn-server-atomic-launch
branch
from
November 23, 2026 22:11
2b0b43a to
019fc24
Compare
…y, monograms count graphemes - An unpinned scheduled dispatch sets followsThreadSelection, and the queue start recognises Conn's delegated-completion wakes by their id, so both run on the thread's current selection, as T3's followsCurrentConversation. - project.create checks the folder before it plans, as T3's ProjectService.create: an offline folder another project holds is a retryable ProjectOperationError, not a recorded conflict. - A monogram counts extended grapheme clusters, as T3's Intl.Segmenter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the thread, wakes reach their conversation - thread.settle refuses a thread with a queued user message, as T3's settle; queued server, agent or scheduled messages do not block it. - Starting a queued run on another selection moves the thread to it in the same transaction, as T3's startNextQueuedRun, so an unpinned scheduled run queued behind it starts on the same model. - The runner recognises delegated-completion wakes with the queue's is_delegated_completion, so a fresh scheduled run's result reaches the conversation that delegated it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A settle refused a queued user message but left a queued scheduled, agent or server run in place, so a later queue resume still started it. The settle now cancels those runs before it writes thread.settled, as T3's settle cancels its automatic cohort. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…data matches ICU Linux tzdata merges backzone local mean times (Amsterdam reads Brussels), so pre-1970 cases differ from the TypeScript server's ICU values on the CI runner, not in this code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…heckout cleans up A failing post-checkout hook made the launch force-remove the checkout and its branch, losing the hook's files. Git and the TypeScript server keep it. The early claim now serves only cancel cleanup; setup cleanup marks the checkout after `git worktree add` succeeds. A cancel while Git still populated the checkout left Git's `initializing` lock, which `git worktree remove --force` refuses, so a partial checkout and its branch stayed and blocked a retry. As in the TypeScript server, `worktree add` now locks with a unique reason, and cancel cleanup unlocks the matching registration before it removes it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t -z Git 2.34 (Ubuntu 22.04) takes `worktree add --lock --reason` but refuses `worktree list -z`. The unlock read that list, so a checkout kept after a failed hook stayed locked, and a cancel mid-checkout left the partial checkout and its branch. The unlock now reads each registration's `locked` and `gitdir` files, as the TypeScript server does, and unlocks only on an exact reason match. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The direct vcs.createWorktree RPC locks the checkout during git worktree add. When the client disconnects during a slow post-checkout hook, the server aborts the handler and the unlock never ran, so the branch stayed in use and force-remove refused the checkout. create_worktree now holds a drop guard. If its future is dropped while the checkout is claimed, a background task unlocks, removes the checkout and deletes its new branch, as the TypeScript server does on interrupt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # apps/conn-server/crates/conn-engine/src/lib.rs
…hor' into HEAD # Conflicts: # apps/conn-server/crates/conn-engine/src/engine.rs
# Conflicts: # apps/conn-server/crates/conn-engine/src/runner.rs # apps/conn-server/crates/conn-engine/src/store.rs
…hor' into HEAD # Conflicts: # apps/conn-server/crates/conn-engine/src/commands.rs
nckrtl
changed the base branch from
conn-server/unsettle-restore-anchor
to
main
November 24, 2026 04:15
# Conflicts: # apps/conn-server/crates/conn-engine/src/commands.rs # apps/conn-server/crates/conn-engine/src/store.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.
Stacked on #260 (
conn-server/unsettle-restore-anchor). The launch receipts use #260's receipt schema: migration 5 withowner_kind,owner_id,errorand thesequenceindex, and no pruning. A receipt from before the upgrade has no owner and is refused on replay, so it never counts as a launch's first message. This PR adds no table, column or migration. Merge #260 first; this PR's base then moves tomain.A Conn Server launch wrote the new thread and its first message as two commands, so a dropped socket between them left an empty thread. Three gates then found replays and claims that could land on the wrong thread, project or checkout, or leave state behind. As in T3's
ThreadLaunchServiceand orchestrator, each check now runs in the write that commits.thread.createcarries its first message, so thread, message and run commit together. A reused thread takes its message in a command of its own.ThreadLaunchService.ts:829). Every separate first message, including an older build's split launch, reads the checkout from its claim's own event and checks it in its own write. A rebind meanwhile makes it refuse.thread.create. Only an acceptedmessage.dispatchof the thread, with itsrun.created, counts as a first message (T3: "Initial message was accepted without a durable run"). The:initial-messagereceipt is read only when the claim needs a separate first message or for a verified legacy send.create_worktreereports its claim beforegit worktree add, and git runs in its own process group. A cancel duringpost-checkoutreaps the hook's process tree and removes the checkout and its branch. A discard removes the branch only once the worktree is gone, and a failed setup says what stayed.thread.createwith its first message checks the provider in its commit.thread.deletehonoursonlyIfUnusedunder the thread lock..gitmodulescheck runs off the runtime thread.Depends on #261. A first turn committed just before the RPC is cancelled, but before
effect.start(), staysstarting. The effect outbox in #261 closes that.Tests. Each test failed on the head the gate reviewed and passes here. They are in
engine_tests.rsunless noted.Round 5 (failed on
4611c3e630):a_split_launch_replay_keeps_its_claimed_checkouta_continuation_under_the_launch_id_is_no_launchconn-vcs/tests/repos.rsa_cancel_during_post_checkout_removes_the_checkout_and_branchconn-vcs/tests/repos.rsa_worktree_cleanup_cannot_remove_keeps_its_branch_and_says_soRound 4 (failed on
78fec3f52e):a_rebound_checkout_refuses_the_first_messagea_continuation_run_is_no_first_messageshutdown_cancels_a_stalled_worktree_setupa_stray_message_id_does_not_change_admissionRound 3 (failed on
a419171af3):a_reused_thread_runs_in_the_launch_checkouta_metadata_command_under_the_message_id_is_no_first_messageshutdown_waits_for_a_launch_that_owns_a_worktreea_replayed_launch_releases_the_copies_its_claim_madean_invalid_reuse_does_not_burn_its_launch_ida_replay_returns_no_projection_from_another_projectEarlier rounds (failed on
e583247679):a_launch_message_checks_its_project_in_its_own_writea_launch_id_another_thread_used_is_a_conflicta_launch_dropped_during_its_claim_still_cleans_upan_older_reuse_replays_after_its_provider_is_offidentical_reuse_retries_convergea_reuse_refuses_a_thread_archived_before_its_claima_provider_turned_off_mid_launch_refuses_itthe_receipt_owner_is_a_key_lookupa_receipt_without_an_owner_replays_for_no_threadan_old_launch_id_replays_after_many_writesa_refused_launch_keeps_attachments_it_did_not_claima_send_wins_against_a_conditional_deletean_old_retry_after_an_undo_and_many_writes_changes_nothingconn-files/tests/files.rsuploads_claims_and_deletes_attachmentsChecks.
cargo fmt --checkpasses.cargo clippy -D warningspasses for conn-engine, conn-files and conn-vcs.cargo testpasses for the same crates (conn-engine 265).Checkout cleanup (5da0078). A failed
post-checkouthook now keeps the checkout and its files, as Git and the TypeScript server do; only a cancel removes it. A cancel while Git still populates the checkout unlocks the launch's own lock (a unique--reason) before it removes the checkout and branch. Tests:a_failed_post_checkout_hook_keeps_the_checkout_and_its_files,a_cancel_while_git_populates_the_checkout_removes_it.Old Git unlock. The launch's unlock reads Git's registration files (
locked,gitdir) instead ofworktree list -z, which Git 2.34 refuses. Test:conn-vcs/tests/old_git.rswith a shimgit.Dropped createWorktree (b45a40a). The direct
vcs.createWorktreeRPC locks its checkout too. A client that disconnects during a slowpost-checkouthook aborted the handler before the unlock, so the checkout stayed locked.create_worktreenow holds a drop guard: a dropped call unlocks, removes the checkout and deletes its new branch on a background task, as the TypeScript server does on interrupt. Test:a_dropped_create_worktree_leaves_no_locked_checkout(fails on 27d1e9f withlocked t3-create-…, passes now).Follow-ups (not fixed here).
worktreeSetup.cancelreturns false while the first hook runs; the TypeScript server reserves one preparation per command ID (engine.rs:1349,setup.rs:129).worktree.rs:463).🤖 Generated with Claude Code