Skip to content

feat(server): a parent moving to its child's computer takes the child back - #998

Merged
badcuban merged 3 commits into
mainfrom
feat/adopt-stranded-children
Nov 18, 2026
Merged

badcuban merged 3 commits into
mainfrom
feat/adopt-stranded-children

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

A thread can start a child on another computer. If that thread later moved to the child's computer, the two stayed apart. The child stayed fenced for good, it still answered to a read-only copy on the old computer, its reports retried forever, and nothing could direct it.

Now the computer the parent arrives on adopts the child as its own attached child again (docs/design/fleet.md, Part 3f (g)).

  • Who. Only threads that both the old computer's move manifest (startedThere) and this computer's own records name: same link and origin thread, pinned computer, same project, not archived or moving, and within the new parent's mode ceiling. One shared check (adoptionRefusal) decides this before anything is released and again in the decider. A child that fails stays separate, and the Moved here line says why.
  • Fence. The adopted child keeps a fence marker (adoptedFromLink) until a person's own message in it lifts it. While fenced, it can only move back to the computer that started it.
  • The old link lets go. Before the import, the child's open link requests are released: cancelled, their own turn stopped by turn id, reports marked delivered. A second release after landing catches a late send. Link stops, wraps and handed-back records now carry byLink, and the decider refuses them once the thread isn't that link's, which closes the races between the two computers.
  • Old computer. It drops the adopted remoteChildren entries when the move completes, and stops retrying reports for a parent that moved away. A pending Wrap up or Reopen rides along and applies only if newer.
  • Compatibility. All contract fields are optional, behind a moveAdoptsChildren capability. Migration 120 adds one nullable column.

The design was planned by the lead model, and the plan and the diff were each reviewed twice by an independent reviewer. All findings were fixed except one narrow window, which is documented in fleet.md. Not verified on two real computers; the integration tests run the real engine through release, import and late link commands.

… back

A thread's agent on computer A could start a child on computer B over a
link. If that parent later moved to B, the child stayed stranded: fenced
for good, pointing at A's read-only copy, its reports to A retried forever,
and nobody could direct it.

Now the moving parent takes such threads back as its own children on B.
A sends the list it holds (PeerMoveManifest.startedThere, only to a
computer that says moveAdoptsChildren). B adopts only threads its own
records also name as started over that link by that thread, and only when
the decider's checks pass (same link, origin thread, pinned computer,
project, not archived or moving, no children, within the parent's access).
Before the import, B's link releases each one: open requests end, queued
messages are taken back, the request's own running turn stops, and the
ledger owes the link nothing more. The adopted child clears remoteOrigin,
carries adoptedFromLink, and stays fenced until the user writes in it.
The committed answer names the adopted threads, and A's read-only copy
drops their records. LinkRequests now checks the thread is still the
link's before any cancel clean-up, ack, send, read, stop or wrap, so a late
cancel can't stop the user's new turn.
…eps what stays apart

Review fixes for taking a link's threads back on arrival:

- The decider now guards what a link asks for: a stop, Wrap up or answer's
  record names the link (byLink) and is refused unless the thread is still
  that link's, and a link's queued request is taken back instead of run
  once it isn't. The LinkRequests read before it can be stale.
- One shared check (adoptionRefusal) decides which threads qualify. LinkMoves
  asks it before releasing anything, with the modes the import will write,
  so a thread that stays apart keeps its requests. Archived ones the
  manifest names now say why they stay apart.
- Release stops the turn the link's request started, found from the
  thread's turn starts (the ledger has no turn id while it runs), and never
  a turn the user started since.
- After the import lands, the adopted threads are released again, so a send
  that arrived in between ends and its message is taken back.
…nk stop is kept

- A stop can name the turn it means (`thread.session.stop.expectedTurnId`);
  the decider refuses it when another turn began before it landed. Release
  uses it, so it never ends the user's next turn.
- Release decides and dispatches its stop before it marks the request
  ended, so a retry after a failed read decides it again. A failed release
  after the import leaves the move unsettled for the sweep to redo.
- A link's stop answers "not yours" only for the ownership refusal; any
  other refusal fails as before, so the asking computer keeps the stop.
- fleet.md names the window where a thread queues its own move between the
  check and the import.
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Nov 18, 2026 10:55pm UTC

Request Review

@badcuban
badcuban added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit a37bee4 Nov 18, 2026
24 checks passed
@badcuban
badcuban deleted the feat/adopt-stranded-children branch November 18, 2026 23:07

This branch was previously deployed

1 inactive deployment
Preview — d66cfc29 Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant