# fix\(pi\): fork and revert past turns whose session entry was never captured · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/commit/b8d2fbadc67540ce398da54503e6ae467a22c9f3)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

Requested revision: b8d2fbadc67540ce398da54503e6ae467a22c9f3

Requested commit: b8d2fbadc67540ce398da54503e6ae467a22c9f3

Commit: b8d2fbadc67540ce398da54503e6ae467a22c9f3

Tree: c9a14161b6793adfc4b818cb961c06f70f17fd61

Author: Henry Chu

Committer: Henry Chu

## Message

```
fix(pi): fork and revert past turns whose session entry was never captured

A Pi turn gets its session-tree entry only when it finishes: finalizeTurn reads get_entries
and swaps the synthetic turn ref for the prompt's user entry. A turn that never finishes keeps
the synthetic ref for good: Pi or the server died mid-turn and recovery cancelled it, Stop's
2 s read timed out, or get_entries failed. Forking or reverting to any point before that turn
then fails every time with "Pi fork boundary has no captured session-tree entry", and the
retry button replays the identical fork.

Pi still has the prompt on disk. When the boundary turn's ref is weak, read the session tree
(the live session for a revert, the --fork process for a fork) and take the earliest user entry
on the active branch stamped after the target turn finished and before the boundary turn
ended, above the target turn's entry. Pi and the server share a clock, so the window is exact;
when nothing fits, the error stays.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

```

## Parents

- [a3e8cf69debae5942798cbe85845de49d6f84066](https://git.cafe/pingdotgg/t3code/commit/a3e8cf69debae5942798cbe85845de49d6f84066?format=markdown)

[Source at this commit](https://git.cafe/pingdotgg/t3code/tree/b8d2fbadc67540ce398da54503e6ae467a22c9f3?format=markdown)
