Repository navigation
Conversation
…iled A fork of a Session with a child branch opens with a `branch/create-failed` for the copied child, which clients show as "branch creation failed". The new flow forks such a Session, runs one turn in the fork to settle everything its opening wrote, and asserts the fork's `main` records no creation failure, its directory is its root and `session.branches` lists only `main`. Refs #1978
A fork copied each child branch's directory with head 0, and the store writes a child's row in the same transaction as the parent's `branch/create`, so a directory with no events means a creation still in flight. TimelineTree's restore reads it that way and records `branch/create-failed` on the fork's `main`, which clients show as "branch creation failed" for every sub-branch of the source (#1978). Nothing failed, and the copied directory carried no content. The fork copy now writes `main`'s directory row and no child's. The copied `branch/create` facts stay in `main` as stored, no child event is copied, and restore's crash-recovery contract is untouched. A source whose root row is gone reports `Closed` as before, or a storage error when its Session row is still there. Refs #1978
State that a fork copies `main` and no child branch: a child directory without events is what the store writes for a creation in flight, so copying one made the fork's own restore report a failed creation for a branch nothing created (#1978). Keep the rejected alternatives with the reasons the copy may not carry a child's events either. Refs #1978
A fork still has to list the lines that ended before its cut with the end the source recorded (timeline branches §10, acceptance 19). Only those lines: an ended line carries no pending work, so its directory row with head 0 is honest, and the copied `branch/ended` on `main` is what tells the fork's restore the line is over. A line still open at the cut gets no directory row, which is where the false `branch/create-failed` came from (#1978): the fork reads the source's `main` conclusions through `timeline_events_by_kind` and writes a child's row only when its `branch/ended` or `branch/create-failed` is within the copied prefix. Refs #1978
zerob13
left a comment
There was a problem hiding this comment.
The fork no longer records a false creation failure for a child that was open at the cut. One user-visible gap remains: the native TUI still treats the preserved branch/create fact as proof the child exists in the fork. When reopening the fork, replay projects that child into /lines as Waiting and schedules a session.turn.get for it, even though the fork's branch directory excludes it. An isolated client fixture reproduced both behaviors.
Please verify that reopening a fork keeps the historical creation fact in main but does not show the omitted child in /lines or query its turn. A child whose end was recorded before the cut should still appear with its recorded end. Seven isolated App Server cases passed for the cut, copied history, ended-line metadata, and storage recovery; the tested merge's CI passed the selected Linux and macOS checks, including Linux coverage for a genuine interrupted creation. Those results do not cover native TUI replay of an omitted child.
Summary
Fixes #1978.
A fork of a Session with sub-branches opened with one
branch/create-failedon the fork'smainper sub-branch, which clients render as "Branch<id>: branch creation failed". Nothing failed. The fork transaction copied each child's directory with head 0, and the store writes a child'stimeline_branchesrow in the same transaction as the parent'sbranch/create, so a directory with no events means a creation still in flight. TimelineTree's restore reads it that way and records the creation as failed on the fork'smain. The failure was that fact being read back, not a restore bug.The fix is at the producer, and it keeps the requirement that a fork's directory lists the lines that ended before its cut with the end the source recorded (timeline branches §10 §acceptance 19, #1165):
branch/endedorbranch/create-failed) is inside the copiedmainprefix gets its directory row with head 0. The copied conclusion is what tells the fork's restore the line is over, so F lists it as ended (or as a failed creation) exactly as S does, with no events of its own — and no creation is re-reported.Nothing else moves: the copied
branch/createfacts stay inmainbyte for byte, no child event is copied, no child can start work in F's sharedcwd, TimelineTree's crash-recovery contract is unchanged (a directory with no events still means an interrupted creation), and no format changes. The fork reads the source's conclusions through the existingtimeline_events_by_kindindex, and a source whose root row is gone still reportsClosed.Copying child content instead (the other reading of the report) stays rejected: a child's events are not ordered against
main's cut, and its pending inputs and wakes would run again in the sharedcwd(§6.2, §6.3, rejected alternatives).The design is updated with the change: session-deletion-and-fork.md §1, §6.2, §6.3 (including a new rejected alternative), §6.4, §6.5, §6.6/§8, §7, §15; native-storage-format.md S5c; request-delta-storage.md §9; and the
docs/zh/mirrors. The change to §6.3 amends a decision this page made in the S5c review, so it needs maintainer confirmation on this PR.Design rule checklist
beforecallbacks: n/a, unchanged.main's own copied prefix.Documentation
Verification
Red test at the first commit, on the reported symptom:
After the fix, at
f0d5b4e3e:The new flow
a_fork_of_a_session_with_a_child_branch_reports_no_creation_failurecreates a Session with one sub-branch still open and one ended before the cut, forks atmain's head, then asserts — after a turn the fork accepts, which orders the read after everything its opening wrote — that the fork'smainholds nobranch/create-failed, its directory ismainplus the ended line,session.brancheslists the ended line asendedand omits the open one, and neither line is loaded in the fork.Checks:
Not run:
cargo test --workspace --lockedand the tmux TUI suite. No TUI code changes; the lines panel keeps renderingbranch/create-failed, and the fact is no longer produced for a fork.