Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
matt2e
added a commit
that referenced
this pull request
Dec 1, 2026
… refactors Staged CI failed on this branch (PR #1112) with one Rust test, and its Frontend job never ran: Hermit's bootstrap download failed, so the frontend checks had not been run on the branch at all. The request was to make CI pass with one commit, without weakening the failing test. Both failures are tests of this branch that describe code as it was before the branch was rebased onto main. The code they test is right, so only tests change. The Rust pin - `the_tool_checks_the_mode_before_it_creates_anything` reads the source of `start_repo_session` and failed looking for `build_repo_session_stub(` in it. - #1109 moved the tool's store writes onto the blocking pool, into a new helper, `create_repo_session_rows`. The rebase onto it kept the branch's change to the tool intact, but the stub is now built and stored in the helper, and the pin still searched the tool's own body. - It was not specific to CI. The test fails the same way on any run of the rebased tree. CI was the first thing to run the suite after the rebase. - The property holds: the tool calls `requested_commit_mode` before it awaits anything, looks up the repository or touches the store, and resolves the mode before the one call that creates rows. - The pin now reads both functions. In the tool: the refusal comes before the first await, the first blocking call and the repository lookup, the mode is resolved before the single call to the helper, and the tool itself builds and stores nothing. In the helper: the stub is built and stored before any artifact row, with the provider and mode it was handed. Whitespace is removed from both sides of each search, so a call chain that rustfmt breaks across lines is still found. - With the check temporarily moved after the row creation, the test fails. The other source pins - Every other function body this branch's pins read in the files the rebase changed (`session_commands.rs`, `session_runner.rs`, `lib.rs`, `web_server.rs`, `branches.rs`) is identical before and after the rebase, and the branch's own changes to those files are line for line what they were. None needed a change. The frontend test - `SessionChatPane.integration.component.test.ts`, "still starts a turn when a serial session's queued follow-up is sent", failed on every run. - Since #1108 the pane reads the session back at once after a send where the fallback poll feeds it, instead of starting an interval poll. The test's fake backend left the row `cancelled` after the send, which the real backend never does: it has written `running` before the command returns. The pane read the stale row and offered Send again. - The fake now moves the row to `running` on the send, and the test also checks that the pane read the session back. With a serial session treated as one waiting to land, the test still fails. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
matt2e
force-pushed
the
independant-commit-sessions
branch
from
December 1, 2026 04:31
75e85a2 to
05d480e
Compare
matt2e
added a commit
that referenced
this pull request
Dec 1, 2026
…independent` CI's `Rust test` job failed on PR #1112 at `rendered_help_matches_the_pinned_fixture` (crates/stagedctl/tests/help_pins.rs), the first test binary after the `Staged` lib tests. Earlier attempts stopped at a failing lib test, so this binary had never run in CI for the branch. The request was to make the rest of the job pass with one commit: refresh the fixture, check that every changed line is help the branch meant to change, and run everything else the job runs after the lib tests. The fixture - Refreshed with `STAGEDCTL_UPDATE_HELP_PINS=1 cargo test -p stagedctl --test help_pins`. Only `tests/fixtures/help.txt` changes. - The diff is one sentence, in the long help of `session start`. The paragraph on `--independent` ended "the session runs serially instead and the output says so." It now goes on to say that the output's `mode:` line (`commitMode` in JSON) is the mode the app reported: `independent`, `serial`, or `unknown` when the app did not say. - That sentence is in `cli.rs` word for word, wrapped at the same places. ad0b50f added it on purpose, with the change that made `stagedctl` print the mode the app reports instead of inferring it, and did not refresh the fixture. - Nothing else differs. The branch's other help changes (the `--independent` option, the phase text in `session status`, the second queued state in `session wait`) were pinned by the commits that made them. No help text is changed here. - The help is rendered the same way on CI's Linux as on this Mac: `clap` is built without `wrap_help`, so no terminal width is read, and its features are the same in a `-p stagedctl` build as in a `--workspace` one. What was run `just ci-rust-test` is `cargo test --workspace --lib --bins --tests` in `src-tauri`, after the sidecar is staged. The workspace has five test targets. Four were run here, without the update variable and with `--no-fail-fast`, and all pass: - `cargo test -p stagedctl --lib --bins --tests --no-fail-fast`: the `stagedctl` lib (256 passed), its bin (no tests) and `help_pins` (1 passed). - `cargo test -p Staged --bins --no-fail-fast`: the `Staged` bin (no tests; it builds and runs). Not run here: the `Staged` lib tests, which passed in CI on this head (3818 passed), and so the build of that test binary. The crates under `crates/` are not members of this workspace, so the job does not run their tests. `just ci-rust-lint` (`cargo fmt --check`, the sidecar build, and `cargo clippy --workspace -- -D warnings`) passes after the change. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Step 1 of the independent commit sessions design: the stored state for a commit session that implements its change in a private side worktree, in parallel with the branch's other work, and then lands through the branch's serial queue. Nothing reads or writes the new state yet, so no session's behaviour changes. This adds a migration, 0055-add-session-independent-phase, with the two nullable `sessions` columns the design names and nothing else: - `independent_phase`: NULL for a serial session, otherwise one of `implementing`, `awaiting_integration`, `integrating`, `integrated`. - `independent_base_sha`: the commit the side worktree was created at. Every existing row reads NULL for both, which is what marks a serial session. Model: `IndependentPhase`, the two `Session` fields (left out of the serialized form when unset), and `Session::as_independent`, which starts a session in the implementing phase. Store: the phase transitions, each a single compare-and-set UPDATE that reports whether it matched, in a new `store/independent_sessions.rs`: - record the base while implementing - park for integration: `running`/implementing to `queued`/awaiting_integration, keeping `created_at` and the agent's session id so the row lands in start order and the queue resumes its conversation - claim for integration: `queued`/awaiting_integration to `running`/integrating in one write - mark integrated, for a `running` integration only - return to awaiting_integration, for an integration a pause or a crash interrupted - requeue a stopped, failed or paused integration to try again - restart a landed session's implementation with a new base The existing status writers are unchanged, so a session that is stopped or fails keeps the phase it was in. Tests cover each transition, the rows each one refuses and what each leaves alone. The migration tests assert version 55 and the new columns on a fresh store, and that rows from before the migration stay serial. Three older migration tests built a schema with no `sessions` table, so they gain one. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
Step 2 of the independent commit sessions design: the git operations an independent session needs around its side worktree and around the turn that lands its commits in the branch's worktree. Nothing calls them yet, so no session's behaviour changes. Side worktrees, in git/worktree.rs: - `independent_worktree_path_for(project_id, session_id)` and `independent_worktree_root_for`: `<project>/independent/<session-id>/`, beside the project's branch worktrees. The directory is the session id as it is, so an id that is not a plain name is refused, not sanitized. - `create_detached_worktree`: `git worktree add --detach`. - `remove_worktree_keeping_branch` moves here from project_transfer/undo.rs, which now re-exports it. - `list_independent_worktrees` reads the folder, so it also finds directories git has forgotten. Around an integration turn, in a new git/independent module: - `operation_in_progress` and `abort_operation`: rebase, am, cherry-pick, revert and merge, read the way `git status` reads them, including a cherry-pick sequence between two picks. - `is_ancestor`, in git/refs.rs. - `list_range_commits` and `list_range_changed_paths` for `base..head`, with both paths of a rename. - `list_uncommitted_paths`, whose `overlapping` finds uncommitted changes to files a range touches, untracked files included. - `snapshot_uncommitted_changes` pins the worktree's state under `refs/staged/integration/<session-id>/` without touching the worktree or the stash list; `pinned_integration_snapshot` and `discard_integration_snapshot` read and drop it. - `restore_worktree_to_snapshot` aborts what is in progress, resets the branch to the snapshot's tip, removes untracked files that appeared, re-applies the snapshot and deletes it. Where this differs from the design: - The snapshot is two refs, `tip` and `changes`, and `tip` is written even for a clean worktree. A restore with no snapshot pinned does nothing, which is what makes a second restore harmless: with a ref only for dirty worktrees, a repeated restore would reset away the changes the first had just put back. The restore reads its tip from the ref and takes no tip argument. - The restore takes the branch name and leaves `HEAD` alone when the worktree is detached or on another branch, as well as when `HEAD` no longer descends from the tip. A reset there would move the wrong thing. - When git refuses `cherry-pick --abort`, which it does over a conflict that was staged and then edited again, the restore resets and then runs `--quit`. - Files that were untracked before the turn are taken back out of the index before the reset, so an agent's `git add -A` does not get them deleted. - `create_detached_worktree` is a plain add that fires `post-checkout` itself. The detached-add-then-fire-hook pair the design names exists for a worktree that is put on a branch later, and needs `git hook run` and a config check this has no use for. - `UncommittedPaths` lists staged paths separately: `git cherry-pick` refuses to start while anything is staged, whatever the file, which the design's "snapshot and proceed" does not account for. Tests run on temporary clones with a branch worktree and a side worktree: the fast-forward, a clean cherry-pick of the range, overlap detection, each operation's probe and abort, and the restore against every combination of commits made, a pick stopped mid-way, extra uncommitted changes and new untracked files, for worktrees that started clean, with staged changes, with unstaged changes, with untracked files and with all of them. Also: a branch reset underneath, a worktree off its branch, a rebase left in progress, a held index lock, a restore without the untracked list, and a restore run twice. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
Step 3 of the independent commit sessions plan: teach the branch queue about a commit session that implements in its own worktree, so it runs beside the branch's serial work and is held only to a cap. No row can have a phase until the entry point lands, so nothing changes for the sessions that exist today. - A new schedule kind, `IndependentImplement`, for a commit session in the `implementing` phase. It is outside the serial rule in both directions: it starts beside anything, and it is left out of the active set, so it holds nothing back. In every other phase the session is an ordinary exclusive `Commit`, which is what makes integration serial. - The resolver reads the phase, and so does the continue gate: a stopped implementation resumes while the branch is busy. - The drain makes two passes over the queue. The first starts implementations wherever they are in the queue while a parallel slot is free; the second is the first-in-first-out walk it always was. A row that cannot start ends its own pass only, so neither kind is a barrier to the other. - At most three sessions implement on a branch at once (`INDEPENDENT_IMPLEMENT_CAP`). The cap is checked wherever a start is scheduled: a new start, the drain, "Start now", continue, and the rate-limit auto-resume. - Claiming a queued row that is waiting to integrate moves it to `integrating` in the same write. - The branch-busy audit: push, pull, rebase and auto-resume no longer count implementing sessions (`branch_work_in_flight`); "Push after current work" and branch teardown still do; a project transfer and a branch move are refused while an independent session has not landed. - The reads by phase are in `store/sessions.rs`. The scheduling rules moved out of `session_commands.rs` into `session_commands/schedule.rs`, with their tests beside them. The tests cover parallel starts beside a running commit, the cap, integration in start order, and no barrier in either direction; and they compare the serial rule and the drain scan, case by case, with what they were before, to show existing sessions are scheduled as they were. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…sions Step 4 of the independent commit sessions plan: a commit session can be started in the independent mode, implement in a side worktree of its own, and end its turn back on the branch's queue, waiting to integrate. The mode is threaded through the backend start and insert functions only. No Tauri command, MCP tool, `stagedctl` verb or UI passes it yet, so nothing outside the tests can create such a session, and a parked session waits on the queue until the integration phase lands. - `CommitMode` (`serial`, the default, or `independent`) goes through `start_or_queue_branch_session_for_store`, `queue_branch_session_for_store` and the two inserts. Independent is refused for a note, a review and a remote branch. The row is inserted in the `implementing` phase, and the start-or-queue decision asks for a parallel slot instead of the branch's worktree. - The side worktree is made by the task that finishes a start, after the row is `running` under its liveness hold: detached at the tip of the branch's own worktree, under the clone's worktree lock, with a leftover from an interrupted start replaced. The base is recorded on the row, the branch's prerun actions run in the new checkout, and the prompt gains a paragraph saying where the agent is and what to leave. - A queued implementation is claimed by the drain and handed to that same second phase, in place of the refusal that was there. Nothing awaits between the claim and the spawn, and the hold taken before the claim moves into the task, so the row stays live for the sweep while the worktree is made. - At the end of an implementation turn the runner reads the phase off the row. Commit detection is off, so the `commits` row records nothing. A completed turn whose `HEAD` has moved off the base parks the row (`queued`, `awaiting_integration`), announces it and kicks the branch with a new `KickSource::IndependentParked`; one that left no commit completes as a serial session without a commit does. A Stop wins over parking. - A row waiting to integrate is stepped over by every queued start path, so it is neither resumed with the launch-resume prompt nor claimed before the integration phase exists. The worktree helpers are in `branches/independent_worktree.rs`, the start in `session_commands/independent.rs` and the turn's end in `session_runner/independent.rs`, each with its tests: the inserts with the mode, worktree creation and its base, parking with commits and completing without, the kick on park, stop and end refilling a freed slot, the sweep leaving a held start alone, and source pins on the no-await-after-claim and hold-before-claim invariants. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…t commit sessions
Step 5 of the independent commit sessions plan: the turn that lands an
independent commit session runs in the session's side worktree and
writes, by absolute path, in the branch's own worktree and in the
clone's git directory. This adds what the runner needs to give a harness
that access, and the list of harnesses it was seen to work on. Nothing
sets the directories on a real turn yet; the integration phase does.
- `AcpDriver::with_additional_directories` sends ACP
`additionalDirectories` on `session/new` and `session/load`, on the
connect and attach paths alike. They go only to an agent that
advertised the session capability, relative paths are left out, and an
empty list leaves the field off the request.
- `SessionConfig::additional_directories` carries the list for one run.
`session_runner/second_directory.rs` turns it into the driver option
and the harness's session mode, for a local session only. Every
existing run passes an empty list.
- `integration_session_mode(agent_id)` is the per-harness table of the
session mode that turn needs. It has no entries: no harness that was
run needed one.
- `supports_independent_sessions(provider_id)` lists Claude, Codex and
Goose.
- A fake agent that writes only under its working directory and its
granted directories shows a loaded session writing in a second
directory while it is granted, and refused once a later load leaves
the grant out.
The supported list was decided by an ignored test that runs the two
turns against a real harness, in throwaway worktrees
(`driver/tests/real_bridge/two_directories.rs`, which records the runs):
ACP_REAL_BRIDGE=<provider id> cargo test -p acp-client \
two_directories -- --ignored --nocapture --test-threads=1
- Claude passed in `auto` and `default`, with and without the grant.
- Codex passed in `agent` and `agent-full-access`, with and without the
grant. Its sandbox refuses every git write in a worktree, granted or
not, and its own review then allows the command outside the sandbox.
The load has to wait for the previous `codex app-server` to exit, four
to seven seconds after its bridge, or it is refused as
`thread_active_writer`.
- Goose passed in `auto` and `approve`. It does not advertise the
capability, so it is sent nothing, and does not confine a session.
- Amp was not run: its CLI gave no reply to a prompt on this machine.
Pi was not run: it is not installed. Neither is on the list.
The throwaway repositories are made under `~/.cache`, not the system
temp directory, because Codex's sandbox allows writes under `$TMPDIR`
and `/tmp`, so a run there would show nothing.
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Step 6 of the independent commit sessions plan: an independent commit session that finished its work in its side worktree waits on its branch's queue, and its turn there lands its commits on the branch. This adds that turn: what is checked before it, the prompt, what is checked after it, how the commit is recorded, and how the branch's worktree is put back when the turn does not land. Starting it - `start_queued_session_for_branch` hands a row waiting to integrate to `start_queued_integration` in place of stepping over it. The claim is the last thing before the runner handoff, with no await after it, and the oldest follow-up queued for the session is taken to go in the prompt. - `session_runner/integration` runs the checks on the runner thread. A missing side worktree, a missing base, no commits, an operation in progress, staged changes, a branch worktree on another branch, or uncommitted changes that overlap the session's paths end the row with an error and no agent turn, and leave the branch's worktree alone. - A session whose base is still the branch tip, with nothing left uncommitted and no follow-up, is fast-forwarded without a turn. - Otherwise the branch worktree's uncommitted state is snapshotted and the session is loaded with the branch worktree and the clone's git directory as additional directories, on this run only. A Codex session waits out the time its app-server may still refuse the load. Ending it - `settle_turn` runs while the row is still `running`. A completed turn is validated (`git::validate_integrated_worktree`): on the branch, descending from the tip, no operation in progress, nothing staged, and the uncommitted state as it was. A worktree that passes moves the session to `integrated`, and the commit is read from the branch's own worktree (`SessionConfig::commit_dir`). One that does not is restored and the row says why. - A Stop, an error and a pause each restore the worktree. A paused integration goes back to waiting, and the rate-limit scheduler puts it back on the queue with its retry count instead of resuming it. Resume, Retry and Continue - A session that has not landed is never resumed where it stopped: `prepare_resume` and the continue gate refuse it. `resume_session` puts it back on the queue (`queuedForIntegration`), with the message queued to go with it, and `continue_repo_session` does the same (`queued_for_integration`). A landed session is refused until the continue step. - The app recognises the integration prompt by its first sentence, so it stays out of a session's subtitle. Tests cover commit detection from the branch worktree, the fast path, each refusal, validation failures, the restore after a stop, an error and a pause, the additional directories, the retry from a new tip, the queue and resume routing, and source pins for the claim ordering. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…sions Step 7 of the independent commit sessions plan asked for the side worktrees and snapshot refs to be removed when they are no longer needed, for a sweep of the leftovers at launch, for the branch worktree to be put back after an integration that a crash or a quit cut off, and for launch resume to know both phases. Side worktrees follow one rule, in `branches/independent_cleanup.rs`: a worktree lasts while its session row exists and the session has not landed. It is applied at the end of every run (the run that lands, and any run whose row was deleted under it), when a session or its pending commit is deleted, when a branch is torn down, and by a sweep at launch that lists each project's `independent/` folder and then prunes the project's clones. A delete or a teardown also drops the session's snapshot refs. A session deleted while it runs is left to the end of its run, which still needs the snapshot to put the branch worktree back. An integration with no run left to settle it is restored from its pinned snapshot (`session_runner/integration/recover.rs`), leaving untracked files alone, and the session goes back to the phase that waits for the branch. Dead-owner recovery does this before it ends the row, so the row still holds the branch while its worktree is reset. A pass at launch, after that recovery and before launch resume or any queue kick, does it for rows a quit ended before their run settled. It skips the reset when another session is at work in the branch worktree, and leaves rows that a Stop or a failure ended to their Retry. Launch resume plans by phase: an implementing session resumes in its worktree or starts over from the queue, one that has yet to land goes back on the queue in the waiting phase (never `queued` while integrating), and one that has landed is listed with the reason. Continuing an implementing session whose side worktree is missing now says whether the worktree was never created or was lost, instead of failing on a missing directory or a missing conversation. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
Step 8 of the independent commit sessions plan: make the mode reachable from every entry point that starts a branch session, so the only work left for the UI is the frontend itself. Deciding the mode - The start path now also checks the harness. An independent session needs an agent that can work in a second directory (`acp_client::supports_independent_sessions`), and nothing enforced that before. A session started without a provider runs on the first installed agent, so that agent is looked up, checked, and pinned on the row: the harness that was checked is the one that runs. - A caller chooses what happens where the mode is unavailable (a remote branch, an unsupported or missing agent). The app's own clients are refused with the reason. `start_repo_session` and control callers (`stagedctl`) run the session serially and report why. A note or a review asking for the mode is an error for every caller. Entry points - MCP: `start_repo_session` takes `commit_mode` (`"serial"` or `"independent"`), valid only with `expected_outcome: "commit"`. Its result names the mode the session runs in and, on a fallback, why it is serial. `wait_for_repo_session` reports `phase` for an independent session. The three tool descriptions explain the second queued state, what each completed phase means, and that a message for a session waiting to land is kept for the landing. - Coordinator prompt: a paragraph on when an independent session suits a change and when a session should wait or stay serial. Local prompt only, since every session on a remote workspace is serial. - Tauri commands `start_branch_session`, `start_or_queue_branch_session` and `queue_branch_session` accept `commitMode`, as do their web dispatcher arms. A control caller's response carries `serialFallbackReason` when its session fell back. - The queue-only entry kicks the branch for an independent row, which waits for a parallel slot rather than for the work ahead of it, so nothing else would start it. - `stagedctl session start --independent` (only with `--type commit`) reports the mode it got; `session status` shows the phase, and the help for `start`, `status` and `wait` describes the two queued states. Tests cover parameter validation (rejected for notes and reviews), the stub row's phase and the drain claiming it beside a running serial session, the serial fallback and its message for a remote branch and an unsupported harness, the `phase` field through the lifecycle in the wait result, and CLI flag parsing, dispatch arguments and output. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
Step 9 of the independent commit sessions plan asked for the app's side of the mode: a way to ask for it in the composer, rows that say which phase a session is in, and client copies of the queue rules that know an implementing session is not in the branch's worktree. Composer - A "Run in parallel" switch under the prompt of a branch commit session (the branch card's composer and the diff viewer's). With it on the three start commands are sent `commitMode: "independent"`. - The switch is disabled, and says why in place of its hint, wherever the backend would refuse the mode: a remote branch, an agent that cannot work in a second directory, no installed agent. Which agents can is read from a new `supportsIndependentSessions` flag on each discovered provider, so the list stays in `acp-client`. - The Start/Queue button asks the queue rule about the mode it would send, so it reads Start with the switch on while the branch is busy, and Queue once the parallel slots are taken. Timeline - Commit rows carry the session's `independentPhase`, and the labels follow the plan's table: "Queued — waiting for a parallel slot", "Preparing worktree", "Implementing in parallel", "Waiting to integrate", "Integrating". "Preparing worktree" has no event of its own, so the live hint poller reports it while a running implementation has no base recorded. - A failed row names the part that did not finish. One that ended while landing says "Integration failed — commit not on the branch" in place of "no commit created", since its commits exist. - Such a row offers "Retry integration", which puts the session back on the branch's queue. It is offered for any ending, because a landing that fails its checks ends with its turn complete, and whatever the branch is doing. A stopped implementation keeps Resume, offered while a parallel slot is free. The session pane's button is relabelled to match. Client mirrors - `branchSessionQueue.ts`: an independent start ignores the serial rule and is held to the cap and to queued implementations ahead of it; a serial start no longer counts implementing rows. Starts this client has sent but the timeline does not show yet are counted the same way. - `queuedSessionStart.ts`: "Start now" is offered on a queued implementation beside a writer, a push or a reset, and withheld only while the slots are taken or the branch is provisioning. A session waiting to land follows the existing writer rule. - The cap is sent with the timeline (`independentImplementCap`), so the client keeps no number of its own. - The branch timeline's "a session is at work here" checks leave implementing sessions out. The persisted response cache is bumped, since the provider list and the timeline changed shape. Tests cover the label per phase, the failure copy per phase, the queue and "Start now" rules, the resume offer, the "Preparing worktree" hint, each reason the switch is unavailable, and, in the mounted composer, the button label and the submitted mode with the switch on and off. Rust tests cover the phase and the cap on the timeline and the provider flag. The composer and timeline were also run as the real frontend against a fixture backend; no session was run against the real backend. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
Step 10 of the independent commit sessions plan asked that a session whose commits have landed can be continued: its worktree is recreated at the same path at the branch's current tip, and the session goes round the lifecycle again. Until now such a session was refused, because its worktree is removed when it lands. The restart - Continuing an `integrated` session no longer resumes it where it stopped. Every resume path (the Resume button and a typed follow-up, a queued message's drain, `continue_repo_session`) hands it to the new `session_commands/restart.rs`, which starts its implementation over in the same conversation. - The steps are ordered so the worktree's lifetime rule never sees a worktree whose row still says `integrated`. Under the branch's launch lock one compare-and-set takes the row to `running` + `implementing` and clears its base (`claim_independent_session_restart`). Only then is the worktree made, off the async runtime, followed by the branch's prerun actions in it. The base is written last, immediately before the turn is launched (`finish_independent_session_restart`), with nothing awaited in between. The cleared base is also what shows "Preparing worktree" on the row while this runs. - A restart counts as an implementation for the queue: it is outside the serial rule and is held to the parallel cap. A continue with the slots taken is refused with a reason to retry once one finishes. - The prompt tells the agent its commits landed, that it is in a new worktree at the branch's tip, the base it starts from, and repeats the implementation rules, including not to rewrite what has landed. The message it was continued with follows. - A restart is refused, with a reason that says to start a new session, when the branch is gone, is remote or has no worktree, when the landed commit is not recorded on the branch, or when the branch has moved to another project since. When a restart does not reach the agent - A Stop, a failure or a deleted session while the worktree is prepared puts the row back to `integrated` and applies the lifetime rule to whatever was made (`give_up`); the message it was sent with is kept on the session's queue. A restart cut off by a quit or a crash is taken back the same way at launch, before the orphan sweep runs. - An implementing session whose worktree exists but has no base is not resumed in place: it is one of these, still being prepared. - A continued round that completes with nothing new (HEAD on its base, clean worktree) returns the session to `integrated` before its terminal write, so the end-of-run removal takes the worktree and the row does not read as an implementation that stopped. The commit record No schema change. The session keeps its one `commits` row, and the second landing re-points it at the branch's new head through the path `detect_session_commit` already has for a session whose HEAD moved past its recorded commit. The first landing stays on the timeline as a plain git commit with no session row; the session's row, with its status and phase, follows its latest landing. Texts and UI - `continue_repo_session`, `wait_for_repo_session`, the coordinator guidance, the `stagedctl` phase help and the launch-resume skip reason now say a landed session can be continued and what that does. - `branchRowResumeOffer` offers Resume on a landed row while a parallel slot is free, and Retry integration on a row whose later landing stopped. The restart prompt is recognised as one of Staged's own, so a row's live hint does not show it as the user's reply. Tests cover the claim, finish, abandon and return transitions, the gate claiming and refusing a landed session, the cap, the phase write against the sweep and the end-of-run removal in both orders, a restart taken back after a stop, a failure, a delete and a relaunch, the prompt, the second landing's commit record by fast-forward and through a turn, the nothing-to-land return, and the frontend offer. The async path that needs an app handle is pinned by source text, as the other start paths are. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
… branch worktree The review of the independent commit sessions asked for five fixes to how an integration puts the branch's own worktree back. The rule they add up to: a restore resets the worktree only when it can prove the branch has not moved since the attempt its snapshot belongs to, a snapshot never outlives a landing, nothing else starts in the worktree until a live integration has settled, and a restore never deletes a file that was untracked before the turn. Git stays the record for all of it: two more refs beside the snapshot's, no column and no model. A restore that did not hold the worktree proves the branch has not moved - A restore now says what it knows of the worktree since the snapshot (`SinceSnapshot`). The run's own restore and the dead-owner recovery held the branch through a `running` row the whole time, and keep the rule they had: commits past the snapshot's tip are the turn's. - A Retry's preflight and the launch pass restore for a row that ended some time ago. "HEAD descends from the tip" is also true when other sessions landed since, and the reset took their commits off the branch. These restores now reset only a branch that is exactly where the attempt left it: at the snapshot's tip, or at the commit a restore that gave up recorded in a new `left-at` ref. Anything else is reported as moved and nothing is touched. - On a moved branch the Retry lets the old snapshot go and integrates from the branch as it is. If that snapshot held uncommitted changes, the Retry is refused once with the commit they are in and the `git stash apply` that brings them back. - A quit no longer ends a `running` row in the integrating phase. The run that outlasted the quit's budget may have left a cherry-pick in the worktree, and the row is what keeps the branch's next session out of it. The next launch finds the owner gone and restores before it ends the row, as it does after a crash. A snapshot does not outlive a landing - Recording a landing deletes the snapshot first and writes `integrated` second, on both the turn's path and the fast-forward's. A snapshot that cannot be deleted stops the landing from being recorded, and the commits come back off the branch. - Continuing a landed session drops any snapshot it still has before its worktree is made again, and the launch sweep drops the snapshots of sessions that have landed or whose row is gone. A late Stop keeps the "needs attention" text - Settling a turn now returns the text that says the worktree was left needing attention beside the decision. A Stop that lands during the post-completion hooks still replaces the whole decision, and the stopped row carries that text instead of reading as a plain stop. A delete waits for a live integration - Deleting a session, or its pending commit with the session, while its run is landing stops the run and waits for it to put the worktree back before the row goes and the branch is kicked. The row stays the holder of the branch until then. The check and the delete run under the branch's launch lock, and a run that has not settled in 30 s refuses the delete with nothing deleted. Every restore knows which files were untracked - The snapshot pins the list of untracked files as a blob in a third ref, and every restore reads it from there. The crash recovery, the launch pass and the Retry used to restore with no list, so the reset deleted a previously untracked file the agent had staged or committed, and left the turn's own untracked files behind. Each fix has a test that fails without it: the Retry and the launch pass over a branch others landed on, a snapshot left on an integrated row followed by a continue and a second landing, a delete during a live integration, a crash recovery and a Retry over a previously untracked file the agent staged, the late Stop, and the quit sweep. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…rectory grant The review of the independent commit sessions left two suggestions open: the parallel cap was not enforced when a stopped implementing session was resumed directly, and the rule that only an integration turn is given directories outside its working directory was pinned by a scan of source text. Both are addressed here, with no schema or model change. The cap on a direct Resume - `resume_session_for_store` wrote `running` with a bare status compare-and-set. The Resume button, a follow-up sent to a stopped session and the drain of a queued follow-up all go through it, and none asked for a parallel slot. The app withholds the button while the slots are taken, but that is a copy of the rule: a second client, or a resume racing the drain's claim of a queued implementation, put a fourth implementation on the branch. - The write is now `schedule::claim_direct_resume`. For a session in the implementing phase it takes the branch's launch lock, asks `independent_implement_slot_free` and writes under the same hold, as every other start of an implementation does. Without a slot the resume is refused with `independent_implement_cap_message` and the row is left as it was. A row that is already running is still told so, not that the slots are taken. - Every other session is claimed exactly as before: the same compare-and-set, without the lock, whatever the branch is doing. - The other ways into `running` + `implementing` already asked under the lock (a new start, the drain, "Start now", `continue_resume_gate` for continue, MCP, the CLI, launch resume and a restart, and the rate-limit auto-resume). The continue gate keeps its own wording for a refusal. The directory grant - `SessionConfig::additional_directories` is gone. The directories a harness is told about now come from the `IntegrationTurn` a run carries (`IntegrationTurn::additional_directories`: the branch's worktree and the clone's git directory, which the turn gains as a field). `second_directory::access_for` reads them from there. - The turn's fields are private to `session_runner::integration` and the type is no longer `Clone`, so no other module can build one or copy one. A run that was not built by the integration module cannot be given a second directory, whichever file builds its config and whatever it is built from. The eight other construction sites lose a line. - The source scan `no_other_run_is_built_with_additional_directories` is deleted. The settle ordering - `finish_session_run` needs the app's handle, so no test could run it, and the order it settles an integration turn in was pinned by source text. The part between the run's decision and the write that takes the row out of `running` (settle, hooks, late Stop, write) needs no handle. It moves, unchanged, to `session_runner/run_end.rs` as `record_run_end`, and `finish_session_run` calls it. - The tests run it on a real clone. A stopped turn whose restore waits for a locked index keeps its row `running`, and the branch held, until the worktree is back. A completed turn that fails its check is put back before the hooks read the branch's `HEAD`, so no commit is recorded. A turn that landed is recorded before its row completes. A paused turn ends paused in the waiting phase. A Stop during the settling ends a row whose worktree is already back. - `finish_session_run_settles_the_turn_before_it_records_anything` is replaced by those. One order in it has no test, because both orders end in the same row: a paused integration's phase is moved back before its row is paused. That keeps a pin of its own. Three other pins that read `finish_session_run`'s body (late Stop, parking, the return to `integrated`) now read the two functions. Tests for the cap: a stopped implementation refused at the cap and claimed once a slot is free, the serial rule ignored, a resume and the drain not both taking the last slot in either order, nine resumes at once claiming three, a running row not read as a cap refusal, and serial sessions claimed while the test holds the launch lock. The cap tests and the two ordering tests were each seen to fail with their change taken out. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…ommit sessions The review of independent commit sessions raised three warnings and two cheap suggestions against the backend. Each was confirmed against the code, and each is fixed here with a test that fails without the fix. Nothing is added to the schema or the models: what the fixes need to know is read from git refs and from columns the rows already have. Serial sessions behave as before, their review cleanup included. A Retry's restore no longer discards work it does not own (git/independent/restore.rs). A restore that did not hold the worktree since its snapshot (`SinceSnapshot::Released`) used to `reset --hard` and delete every untracked file the snapshot did not list, so another session's uncommitted work, or the user's, went with a failed attempt's leftovers. It now commits the tracked work that is present with `git stash create` and keeps it under `refs/staged/kept/<session>/<sha>` before the reset, never deletes an untracked file, and refuses when an untracked file is in the way of the reset or the re-apply, or when files are unmerged. The Retry is refused once with the paths, the kept commit and how to get it back. The launch pass has no row to say that on, so it leaves such a worktree to the next attempt (`SinceSnapshot::ReleasedUnattended`). A landing that was never recorded is recorded by the next attempt (session_runner/integration/preflight.rs). A failure between dropping the snapshot and writing `integrated` left a row whose commits were on the branch already, so every Retry cherry-picked nothing and failed. The preflight now asks git whether the session's range is on the branch (`git::range_landed_at`: an ancestor for a fast-forward, patch equivalence by `git cherry` for a cherry-pick) and, where it is, records the landing without a turn and points the commit row at the session's own commit. Deleting an independent session's commit keeps the reviews of other commits (timeline/commit_delete.rs). `cleanup_reviews_after_commit` deletes the reviews made since the commit row was created, which for an independent session is when it started, not when it landed. For those commits only, a review now goes if it was made at or after the row's SHA was last written, or names the commit itself, which also covers a rebase that rewrote the SHA and carried the reviews over. `delete_commit` is refused while a session is landing on the branch. It takes the branch's launch lock, which a landing's claim takes too, and refuses while a `running` row is in the integrating phase, so the branch is not reset under the agent and the run does not lose its row. A dropped snapshot's changes stay reachable. Where a Retry over a moved branch, or a deleted session, drops a snapshot it will not restore, the `changes` commit is kept under the same `refs/staged/kept/` namespace first, so the commit the row and the log name survives a `git gc`. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…pendent commit sessions The review of independent commit sessions raised one issue against the chat pane and two suggestions, against the timeline row's Resume offer and against what `stagedctl session start --independent` prints. Each was confirmed against the code and is fixed here with a test that fails without the fix. The chat pane offers Retry integration for every ending - A landing that fails its post-turn check ends as an error with its turn complete and the reason in its message. The pane shows that as its raw-error alert, which had no action, so the session had Retry on its timeline row and none in its pane. The "Retry integration" label further down was never reached for it: that branch is only rendered for a row without an error message. - The error alert now carries the action for a session that ended before its commits landed (`canRetryIntegration`: an `error`, `cancelled` or `paused` row in a landing phase, the statuses the backend puts back on the queue). A stopped landing whose worktree was left needing attention gets it the same way. The notice below it offers it for an ending that is not resumable and left no message, with copy of its own in place of "This session can be resumed." - The three Resume buttons of the pane's notices are one snippet. A queued follow-up sent from the pane leaves the session queued - Confirmed: `send_queued_session_message` keeps the message of a session that has yet to land and puts the session back on its branch's queue, and the pane then set itself to `running` and started polling until a poll corrected it. It now reads the phase before the send and sets `queued`, as the composer's send does for `queuedForIntegration`. Resume on a landed row: the backend's rule was the wrong one - The row offers Resume on a landed session while a parallel slot is free. The backend claimed the restart through `continue_resume_gate`, which also refuses while an implementation is still queued, with a reason about slots that were not taken. The pane's Resume and a typed follow-up took the same path, so withholding the row's button would have left that refusal in place. - A continue the user asks for on the session itself now claims through `direct_restart_gate`, which waits for provisioning and a parallel slot and nothing else (`schedule::direct_restart_waits`). That is the rule a stopped implementation resumed directly already has (`claim_direct_resume`). The check and the claim stay under the branch's launch lock, so the cap holds against the drain. - A project session's `continue_repo_session` and the resume at launch keep the queue's order, as before. `stagedctl` no longer infers the mode - `session start --independent` printed `mode: independent` whenever the response had no `serialFallbackReason`. An app updated on disk but not restarted passes the handshake, ignores `commitMode`, starts a serial session and sends no reason. - The start response now always carries `commitMode` (`serial` or `independent`), the mode the row was inserted in. This is the one new wire field; nothing is added to the schema or the stored models, and the protocol version is unchanged, since the field is additive. - The CLI prints the mode the app reported. A response without the field, or with a spelling it does not know, is `mode: unknown` in words and `"commitMode": "unknown"` in JSON, with the `session status` command that shows the phase. A reason without a mode is still read as serial. Tests: the mounted pane with a failed landing, a stopped one, an ending with no message, a serial failure, a landed session, and a queued follow-up sent for a landing session and for a serial one; `canRetryIntegration` per status and phase; the direct restart claimed beside a queued implementation while the in-order gate refuses it, and held to the cap; the response's wire shape and the mode of the inserted row; and the CLI's output for an app that reports no mode. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…er a ref Requested: fix the four findings of the review of independent commit sessions, so that no restore of the branch worktree resets, aborts away or deletes anything a ref does not hold first, kept refs get a lifetime, a landing whose record was interrupted is recognised even when its pick was resolved by hand, and a session found already landed does not lose what is uncommitted in its side worktree. Restores (Held, Released, unattended): - Every restore now captures the worktree before the first step that changes the index or the files: the index, the tracked files as they are on disk and the untracked files that are not in the snapshot's list, as one stash-shaped commit written through a copy of the index (git/independent/capture.rs). Unmerged files are captured as they are on disk, which `git stash create` cannot do. - Where that state is not the snapshot's own, the commit is kept under refs/staged/kept/<session>/ before `untrack_again`, the abort, the removal of untracked files and the reset. Only captured untracked files are removed. Commits the reset takes off the branch are kept too. - A restore that cannot capture, or that would have to write over a nested repository, stops with nothing changed. An unattended restore with work to set aside changes nothing at all, so its own `rm --cached` is no longer reported as someone's work. - The kept commit and how to get the work back are in the row's text on every path: restored, left alone, and an error after the capture (`RestoreFailed` carries what was kept). Stopped and paused rows say it too, and a late Stop keeps it. Landing marks: - `record_landing` writes refs/staged/landed/<session>/<side-head> at the branch commit before it lets the snapshot go, and deletes it once the phase is written. The next attempt trusts a mark whose commit is still on the branch, so a hand-resolved landing that git cannot match by its changes is recorded without a turn. Already landed with leftovers: - When git, not a turn's mark, finds the commits on the branch and the side worktree has uncommitted files, they are kept in a commit and the attempt is refused once with the commit named. The retry finds the same state held and records the landing. Kept-ref lifetime: - Kept refs are named <seconds>-<commit> and swept at launch by age (30 days), never while the session's row exists and has not landed, nor while a landed row's text still names the commit. They are not removed with the session: a delete is itself something that keeps one. Landing marks go with the session and in the launch sweep. No schema or model changes; serial sessions are unchanged. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
… a requeue Fixes the three warnings and three suggestions of the review of 65f8c223 (independent commit sessions), each with a test that fails without it. - capture: untracked files are added with `git update-index --add --remove`, so a file that is gone between the listing and the add is left out instead of failing the capture and the restore with it. A file that is there and cannot be read still fails it, before anything is changed. - recovery text: a row no longer prints `git stash apply <commit>`, which stops on the first file the restored snapshot also changed. It prints `git --literal-pathspecs restore --source=<commit>[^3] --worktree -- <paths>` with the real, shell-quoted paths the commit holds, and names the files the commit has no copy of. The moved-branch and kept-leftovers texts print the same commands, read from the kept commit. - pointer: where kept work is goes in the session's transcript as a message Staged authors (event kind `independent_kept_work`, left out of replay boundaries), written once, by every path that reports a kept commit. It is still there after the rate-limit and launch requeues clear the row's text and after the session lands. No schema or model change. - landing mark: a landing is marked under the side worktree's HEAD read when it is recorded, since the prompt has the agent commit leftovers there and land them too. - refusal: a cherry-pick or unmerged files this session did not start names the sessions of the branch that still have a snapshot pinned, whose Retry puts the worktree back. - kept refs: a ref's 30 days run from when its session lands or is deleted. The refs are re-stamped then, so texts name the commit and `refs/staged/kept/<session>/` and not the ref. Serial sessions are unchanged. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…ds and notes exact Applies three of the suggestions of the review of 84f7f3a9 (independent commit sessions), each with a test that fails with the fix switched off. No schema, model or wire change; the row's plain text keeps its form. Kept refs are re-stamped before a landing is written - `record_landing` gave the session's kept refs their new time after it wrote `integrated`. The sweep at launch runs beside the queue and lets go of an old ref the moment its row reads as landed, so a sweep that read the row between the two deleted the ref the re-stamp was about to renew, and left the commit with none. - The re-stamp now runs before the phase write, while the row still keeps the refs. A sweep that reads the row as landed finds the refs already renewed; one that listed the old ref earlier finds it gone. A landing that then fails to record has only had the time moved on refs its row goes on keeping. The printed commands run in sh and in zsh, with extendedglob or not - A file name is quoted unless it is made of plain characters, and `=` is no longer one of them: zsh reads a word starting with `=` as the path of a command (`=eq.txt` gave `eq.txt not found`). - The `<commit>^3` and `<commit>^1` words are in single quotes: zsh with `extendedglob` set reads the `^` as a pattern (`no matches found`). - The two commands that list more than ten files run with `-c core.quotePath=false`, so a name that is not ASCII is printed as it is and not as octal escapes. The transcript's note is written for Markdown - The chat pane renders the note as Markdown, and it was the row's plain text: `src/__init__.py` showed a bold "init", and a backtick or a line break in a name ended the code span around the command. - The note now has each command to copy in a fenced block of its own, fenced past any run of backticks in it, and each file name in a code span, delimited the same way. A name with a control character is written as git writes one (`"new\nline.txt"`), since a code span cannot hold a line break. The quoting and the two Markdown forms are in a new `integration/literal.rs`. - The texts are still built once: the builders take the form to write, and each caller writes the row's text and the note from the same values. The note is still keyed on its content, which names the commit, so another kept commit is another note. Tests - A sweep run from inside the landing, at the moment the row reads as landed, both as one that listed the refs earlier and as one that starts then: the commit keeps a ref. - The existing test that runs the printed commands now runs each in `sh`, `zsh -f` and `zsh -f -o extendedglob` (zsh where installed), and has a file named `=eq.txt`. The over-ten test covers tracked files as well as untracked ones, runs both listings, and checks a name that is not ASCII. - A turn over files named for Markdown and for a shell (`__init__`, backticks, a fence on a line of its own, line breaks, `*`, `#`, `=`): nothing of a name is left where Markdown reads markup, and the commands read out of the note's blocks bring every file back. - The note for one restore is held to a file that a frontend test renders with the pane's `renderMarkdown`, checking the names, the commands and the words around them as shown. The row's text for the same restore is held to what it was. Not done: a listing still prints a name with a line break in git's quoted form. `-z` is the only flag that would not, and it runs the names together on a terminal. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
…ext menu
A commit session that was queued behind the branch's other work could
only wait its turn or be started ahead of the queue ("Start now"). The
request was for a context-menu action that turns such a session into an
independent commit session and starts it straight away, so the user can
decide after the fact that it should not have waited.
The menu item
- "Start in parallel", directly after "Start now" on a queued commit
row. The label is the one that was suggested: it reads as the sibling
of "Start now" and matches the composer's "Run in parallel".
- It is only on a commit session that is queued as a serial session and
has never started. Not on notes or reviews, not on a session that is
independent already (waiting to implement, waiting to integrate), and
not on a queued rebase or squash, which is a commit row too.
- The queued states were checked for ones that are not a fresh start.
There is one: a session a quit cut short, which launch resume puts
back on the queue with its conversation (`QueuedStartKind::Resume`).
Its work so far is in the branch's worktree, so it is not offered a
worktree of its own.
- Disabled, with the reason under the label, where the mode itself is
not available: a remote branch, an agent that cannot work in a second
directory, no installed agent, agents not yet discovered. The reasons
are the composer switch's own (`parallelUnavailableReason`), asked
about the agent the session names, or the first one installed when it
names none.
- Omitted where the session could not start straight away for a reason
that passes on its own: the branch still provisioning, every parallel
slot taken, the project being transferred, the row being deleted.
That is the convention "Start now" already follows for the same
conditions, a queued implementation's cap included, and it needs no
new copy.
- The rule is `startInParallelOffer` in `queuedSessionStart.ts`, built
from the existing mirrors (`parallelSlotFree`, the provisioning flag,
`parallelUnavailableReason`). It is a copy; a refusal by the backend
is shown as a toast with the backend's reason, and the row reloads.
The backend
- New `session_commands/convert.rs`, exposed as the Tauri command
`start_queued_session_in_parallel` with a web dispatcher arm. No MCP
tool and no `stagedctl` verb.
- The conversion and the claim of the start are one statement
(`Store::claim_queued_session_as_independent`): a compare-and-set from
`queued` with no phase to `running` + `implementing` that also pins
the provider. It takes the row only with the `agent_id` it was read
with, and never a pipeline row.
- It is made under the branch's launch lock, as a "converting"
`QueuedSessionClaim`, after the row, the branch and the cap have been
read again there. That is the lock the drain's claim, "Start now" and
every new start take, so the row cannot also be claimed as a serial
session and the cap cannot be overshot.
- From the claim on the session is started by the path a queued
implementation already takes (`start_queued_implementation`), which
is unchanged: the same side worktree, the same implementation prompt
paragraph, the prompt and launch context the row was queued with, its
images, and any follow-up queued for it.
- The harness is decided as for a new independent start
(`independent_mode_availability`): the row's provider, else the
caller's, else the first one installed, and the answer is pinned on
the row.
- Refused, with the reason and with nothing written: a row that is no
longer queued or was already claimed, a session that is independent
already or has a conversation to resume, a note, review or pipeline,
a remote branch, an unsupported harness or no installed agent, a
branch still being set up or being transferred, and the cap reached.
- After a conversion the branch's queue is kicked (new
`KickSource::ConvertedToIndependent`): the session has left the line
for the branch's worktree, so a row held behind it may start.
Serial sessions that are not converted take the paths they took before.
Data shape
No schema or stored-model change. The timeline's pending commit rows
gain two wire fields, both left off when unset, so the client can mirror
the two things it could not see: `sessionProvider` (the agent the
session names) and `resumesConversation` (the queued row will resume a
conversation). These are new fields on a backend type and want the
review AGENTS.md asks for. The persisted-cache version is not bumped
again: this branch already moved it from main's 3 to 4.
Tests
- Store: the write converts and claims in one step and keeps the row's
place in the order; it refuses every other kind of row, and a row
whose `agent_id` is not the one read, and leaves each untouched.
- Conversion: each ineligible row and each branch or harness refusal
with its reason and no write, by the first look and again by the
claim; provider pinning; the cap, including conversions racing each
other; the drain and a conversion in either order for one row and for
the last slot, and racing on threads; a converted session no longer
holding the queue behind it; the prompt, launch context and a queued
follow-up surviving. The command's shape is pinned on its source, as
the other start paths are.
- Timeline: the two wire fields, and their absence when unset.
- Frontend: the offer rule; the menu item enabled, disabled with its
reason, and alone on a row; the real `BranchTimeline` showing it only
on eligible rows and in each unavailable case; the card invoking the
command and reporting a refusal.
Each new test was checked to fail with its rule taken out.
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… refactors Staged CI failed on this branch (PR #1112) with one Rust test, and its Frontend job never ran: Hermit's bootstrap download failed, so the frontend checks had not been run on the branch at all. The request was to make CI pass with one commit, without weakening the failing test. Both failures are tests of this branch that describe code as it was before the branch was rebased onto main. The code they test is right, so only tests change. The Rust pin - `the_tool_checks_the_mode_before_it_creates_anything` reads the source of `start_repo_session` and failed looking for `build_repo_session_stub(` in it. - #1109 moved the tool's store writes onto the blocking pool, into a new helper, `create_repo_session_rows`. The rebase onto it kept the branch's change to the tool intact, but the stub is now built and stored in the helper, and the pin still searched the tool's own body. - It was not specific to CI. The test fails the same way on any run of the rebased tree. CI was the first thing to run the suite after the rebase. - The property holds: the tool calls `requested_commit_mode` before it awaits anything, looks up the repository or touches the store, and resolves the mode before the one call that creates rows. - The pin now reads both functions. In the tool: the refusal comes before the first await, the first blocking call and the repository lookup, the mode is resolved before the single call to the helper, and the tool itself builds and stores nothing. In the helper: the stub is built and stored before any artifact row, with the provider and mode it was handed. Whitespace is removed from both sides of each search, so a call chain that rustfmt breaks across lines is still found. - With the check temporarily moved after the row creation, the test fails. The other source pins - Every other function body this branch's pins read in the files the rebase changed (`session_commands.rs`, `session_runner.rs`, `lib.rs`, `web_server.rs`, `branches.rs`) is identical before and after the rebase, and the branch's own changes to those files are line for line what they were. None needed a change. The frontend test - `SessionChatPane.integration.component.test.ts`, "still starts a turn when a serial session's queued follow-up is sent", failed on every run. - Since #1108 the pane reads the session back at once after a send where the fallback poll feeds it, instead of starting an interval poll. The test's fake backend left the row `cancelled` after the send, which the real backend never does: it has written `running` before the command returns. The pane read the stale row and offered Send again. - The fake now moves the row to `running` on the send, and the test also checks that the pane read the session back. With a serial session treated as one waiting to land, the test still fails. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The branch was rebased onto main at 5b09555, which brought in #1113 ("open a session row's best content when its body is clicked"). The request was to keep both sides' behaviour and to put anything the rebase needed beyond conflict resolution in one commit, saying what #1113 changed that required it. This is that commit. It touches the chat pane and its tests only. What #1113 changed - A click on a queued row now opens the session, so #1113 made the pane refuse everything that would start a queued session ahead of the branch's queue: the composer is blocked for any `queued` row (`composerSessionBlock`'s new `queued` reason), a follow-up the row holds has no Send, and an empty transcript reads "Queued". - That rule is right for a session that has not started. It is wrong for one kind of queued row this branch adds: an independent commit session waiting on the queue to land its commits. The backend takes a reply to that row, keeps it for the landing and leaves the row where it is on the queue (`queue_for_integration`), so nothing starts early. With the block the pane had no way to send that message. What this changes - The composer is not blocked for a session queued to land (`isQueuedToLand`: `queued` in a landing phase). Its reply goes through `resumeSession` as before the rebase, comes back `queuedForIntegration`, and is listed on the queue. Every other queued row stays blocked, a queued implementation included: a reply to that one would start it. - #1113's rule for a held follow-up is kept for every queued row. A session queued to land has no Send on it either: the message goes with the landing, and there is nothing to send it to before then. - The empty transcript of a queued session says what its timeline row says. #1113 gave both the same label so they agree; a queued implementation's row reads "Queued — waiting for a parallel slot", and the pane now uses the row's own copy (`queuedCommitMeta`). A serial session reads "Queued", or the transfer label, as in #1113. Tests - One test of this branch failed on the rebased tree, and nothing else in the frontend suite did: "reads as queued, not running, after a queued follow-up is sent" expected the follow-up to keep its Send once the session was back on the queue. #1113 removes that button for a queued session, which is the better answer, so the test now expects no Send and a Remove. - New, in the same file: a session queued to land takes a reply, the reply is sent to the backend and listed with no Send; a follow-up it already holds has no Send; a queued implementation is blocked and reads as its row does. The first and the last fail with their change taken out. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…independent` CI's `Rust test` job failed on PR #1112 at `rendered_help_matches_the_pinned_fixture` (crates/stagedctl/tests/help_pins.rs), the first test binary after the `Staged` lib tests. Earlier attempts stopped at a failing lib test, so this binary had never run in CI for the branch. The request was to make the rest of the job pass with one commit: refresh the fixture, check that every changed line is help the branch meant to change, and run everything else the job runs after the lib tests. The fixture - Refreshed with `STAGEDCTL_UPDATE_HELP_PINS=1 cargo test -p stagedctl --test help_pins`. Only `tests/fixtures/help.txt` changes. - The diff is one sentence, in the long help of `session start`. The paragraph on `--independent` ended "the session runs serially instead and the output says so." It now goes on to say that the output's `mode:` line (`commitMode` in JSON) is the mode the app reported: `independent`, `serial`, or `unknown` when the app did not say. - That sentence is in `cli.rs` word for word, wrapped at the same places. ad0b50f added it on purpose, with the change that made `stagedctl` print the mode the app reports instead of inferring it, and did not refresh the fixture. - Nothing else differs. The branch's other help changes (the `--independent` option, the phase text in `session status`, the second queued state in `session wait`) were pinned by the commits that made them. No help text is changed here. - The help is rendered the same way on CI's Linux as on this Mac: `clap` is built without `wrap_help`, so no terminal width is read, and its features are the same in a `-p stagedctl` build as in a `--workspace` one. What was run `just ci-rust-test` is `cargo test --workspace --lib --bins --tests` in `src-tauri`, after the sidecar is staged. The workspace has five test targets. Four were run here, without the update variable and with `--no-fail-fast`, and all pass: - `cargo test -p stagedctl --lib --bins --tests --no-fail-fast`: the `stagedctl` lib (256 passed), its bin (no tests) and `help_pins` (1 passed). - `cargo test -p Staged --bins --no-fail-fast`: the `Staged` bin (no tests; it builds and runs). Not run here: the `Staged` lib tests, which passed in CI on this head (3818 passed), and so the build of that test binary. The crates under `crates/` are not members of this workspace, so the job does not run their tests. `just ci-rust-lint` (`cargo fmt --check`, the sidecar build, and `cargo clippy --workspace -- -D warnings`) passes after the change. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…work pauses and session feed The branch was rebased from #1113 onto main at d57ff39, which adds #1116 and #1114. The rebase itself only resolves conflicts. This commit is what main's changes ask of the branch's own code beyond that, with the main change that requires each part. #1116 (store reads off the window's thread) gave the store reader connections and a background read lane, and the rule that a method that only reads takes a reader. The rate-limit tick and the other timer work run in that lane, which governs readers only. The branch's reads still took the write connection, in the tick (the parallel cap) and everywhere else they are made: - `has_running_session_in_branch_worktree`, `count_implementing_sessions_for_branch`, `get_unlanded_independent_sessions_for_branch` and `get_independent_sessions_interrupted_integrating` take a reader. - The last is keyed on the status, so its SQL moves to `session_status_sql.rs` and its plan is pinned on the `idx_sessions_status` index #1116 added (migration 0052). #1114 (auto-resume network-paused sessions) classifies the Claude CLI's request timeout as a network pause, where it used to end the session as an error. An integration turn that times out is therefore paused for the network and put back on its branch's queue by the scheduler, behind the network gate, which is a path the branch had not exercised: - The tick registers a requeued integration as the gate's probe, as it does a claimed row. Before, the gate never heard of the retry: a landing that failed on the network again was neither charged to the session nor paced, and the row, due at once, was requeued every tick. - An integration that ends with no agent turn (a fast-forward, commits already on the branch, a refusal) gives the probe up before it writes its row. A `completed` probe is otherwise read as a turn that got through, and the gate would open on a network nobody tried. - A requeued row the queue has not reached stays an abandoned probe, so another session probes. That was already the gate's rule; it is now said where the verdict is made. #1108 (the session feed) is not new in this rebase: it was in the branch's previous base, and the earlier rebase onto it missed this. Each `sessions` writer marks its row on the feed, and the session stream sends a row only when it is marked. The branch's phase writers and the once-only authored message left no mark, so a pane on the stream could keep a stale phase, and with it the wrong offer: - Every write in `independent_sessions.rs` marks its session, the multi-row launch pass included. - `add_authored_session_message_once` marks the row it inserts. Tests: the gate with independent sessions in both phases (probe beside branch work, deferral at the parallel cap, requeue as the probe, a failed landing paced and uncharged, a no-turn landing, a landing that reaches the provider); source pins on the tick's arm and on the no-turn ending; the feed mark of each writer, and none when a write is refused; the query plan; and the Resume labels for an independent session paused in each phase, with and without a resume on its way. No schema, model or wire change. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
matt2e
force-pushed
the
independant-commit-sessions
branch
from
December 1, 2026 06:09
f9d8533 to
6c34d66
Compare
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.
Summary
Adds independent commit sessions to Staged: a commit session can run in parallel with other work on a branch by doing its implementation in its own worktree, then landing the result on the branch in a separate integration phase.
0052-add-session-independent-phaseand the store support for a session's independent phase.git/independent/*,git/worktree.rs): capture, snapshot, range, validate, landed-detection and restore. A restore keeps whatever it takes out of the branch worktree under a ref, so kept work is recoverable with the commands the note prints.session_runner/independent.rs,session_runner/integration/*): preflight, prompt, settle and recovery for landing the work on the branch.crates/acp-client): the harness can grant an agent a typed additional directory, so an independent session can reach the branch worktree.stagedctl.Testing
Unit and component tests accompany each layer (store, git helpers, scheduling, runner phases, CLI help fixture, frontend). The local pre-push checks were skipped for this push, so CI is the first full run.
🤖 Generated with Claude Code