Skip to content

feat(session): branch or fork a session to try approach B without losing approach A - #497

Merged
ajianaz merged 2 commits into
developfrom
feat/session-branching
Nov 3, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/session-branching

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

Session forking (#210, first slice):

  • JsonlStorage::fork(src, dir, new_id, at) copies the source's lineage up to a settled entry into a NEW session file; the source is untouched. The new file's header records forkedFrom: {session, entry} (additive field — older files replay unchanged).
  • tole branch <id> [--at <entry>] creates the fork, prints branched: <new-id> and the tole resume <new-id> "<prompt>" continuation command, and records the fork in the session index.
  • tole sessions --tree nests forks under the session they were cut from.
  • Replay and todo hydration work per branch with no reader changes. Docs synced (README, architecture, epics). CHANGELOG under [Unreleased].

Why (the problem you're solving)

Closes #210 — try approach B without losing approach A. Implemented as the first slice: fork-as-new-file, NOT the in-file branching design sketch (deferred; rationale in the commit and below). Every reader folds entries() linearly and most messages are written as root entries, so in-file leaves would touch many modules and break write-once storage simplicity.

Testing (how you verified this works)

  • RED: session_fork failed to compile (no fork/forked_from); the CLI e2e failed with unrecognized subcommand 'branch'.
  • GREEN: crates/tole-core/tests/session_fork.rs 4/4 (fork copies the settled prefix, source untouched, forkedFrom recorded, todo hydration on a fork vs its source) and crates/tole-cli/tests/session_branch_e2e.rs 1/1 (real binary: tole branch output, resume of the fork works).
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace --no-fail-fast (968 passed / 0 failed, 57 binaries), cargo test -p tole-core --no-default-features (387 passed / 0 failed), cargo build -p tole-cli --no-default-features: all pass. cora pre-commit: "No issues found".
  • Design decisions recorded: "settled" = a final assistant message (the only Final-with-no-open-sandwich point; mid-tool-batch cuts are refused); default cut = the last settled entry; the fork starts at Final with a CLEAN ledger (usage rows and fact/* registers are not copied into forks); no branch --name.
  • Scope note: in-file branching (the sketch's full shape) is deferred to a follow-up if needed.

Comment thread crates/tole-core/src/storage.rs Outdated
) -> Result<Self, StorageError> {
let new_id = new_id.into();
let from = Self::open_read_only(src)?;
let settled =
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

A fork cut at an assistant message that has tool calls hanging off it copied an unfinished tool lineage and then forced pc to Final. Settled now also requires the assistant message to have no children.
@ajianaz
ajianaz merged commit ea03c55 into develop Nov 3, 2026
16 checks passed
@ajianaz
ajianaz deleted the feat/session-branching branch November 3, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session branching/forking — try approach B without losing approach A

2 participants