Artifact fc57f874ce866e0e66635b1d574c6a8b8857cd095471a0da2598bb9c9120ea41:
- File
docs/manual/sessions.md
— part of check-in
[eae917e9e9]
at
2026-11-21 12:03:36
on branch shared-store
— Shared journal store: several pic processes on one workspace, one conversation each
Each conversation has a lease (an exclusive flock beside the journal) that its process holds while it advances it and that the kernel drops when the process and its forked children are gone. Taking a lease claims the conversation's request and settles what a dead owner left; open recovers only conversations whose lease is free. The journal lock is held shared and taken exclusive only to create or migrate the schema. SQLite runs in normal locking mode with the fair busy handler; dev builds stop on a write begun under an open read.
pic run takes only requests nobody is running. A second pic asking into a conversation in use is refused with its owner's pid. An edit that misses in a file another conversation changed says so and shows the file; a write to such a file is refused once.
New test/pic/shared.sh: two-process crash matrix, kill -9 beside a live pic, claim and admission races, stale-file results. No schema change. (user: dmestas, size: 3269) [annotate] [blame] [check-ins using] [more...]
Sessions
A session is a conversation in the workspace's journal, WORKSPACE/.pic/journal.sqlite. pic
sessions lists them, pic log [ID] shows one's entries, pic name ID NAME names one, and -c or
--session ID continues one in ask, chat, tui and RPC mode.
Several pics in one project
More than one pic can work in a project at the same time, each in its own conversation. While one
runs a long task, start another in a second terminal: pic ask a side question (a new
conversation), continue a different conversation with --session ID, or look at the running one
with pic sessions, pic log ID and pic dump. pic sessions marks a conversation another pic is
working (in use by pid N).
A conversation is worked by one pic at a time. Asking into one that another pic is working is refused:
pic: conversation ab12cd34 is in use by another pic process (pid 4711)
pic cancel KEY is refused the same way while the request's own pic runs it; press Ctrl-C there
(or send that pid SIGINT). pic run finishes the requests nobody is running and says which it left
to their owners. -c continues the conversation changed most recently, which may be the one the
other pic is working; name yours with --session ID.
If a pic is killed, its conversation is free again as soon as its running command has been stopped. The next pic to open the journal settles what it left (durability); nothing another pic is doing is touched.
Two conversations can change the same file. pic does not merge their work; tools says what an edit or write that meets the other's change is told. Upgrading pic to a version with a new journal format needs the other pics in that project closed first; pic says so and changes nothing until they are.
Forking
/fork with no argument opens Pi's "Fork from Message" picker of your earlier messages: Enter
forks the path before the chosen message into a new conversation and puts that message in the
editor. /fork ENTRY forks after an entry (see pic log). On the command line, pic fork ID --at
ENTRY does the same.
Compaction and branch summaries
Compaction and branch summaries take Pi's settings, in Pi's settings.json shape (pic settings
compaction '{"reserveTokens":16384,"keepRecentTokens":20000}'): compaction.enabled (default true;
off stops automatic compaction, overflow recovery included, as in Pi, but not pic compact;
/settings Auto-compact and the RPC command set_auto_compaction set it),
compaction.reserveTokens, compaction.keepRecentTokens,
compaction.modelOverrides["provider/model"], branchSummary.reserveTokens and
branchSummary.skipPrompt. Leaving a branch in /tree asks Pi's "Summarize branch?"; a summary
(pic fork ID --at ENTRY --summarize) is a journaled, priced request, and the new conversation
starts with Pi's branch_summary entry.
The defaults are in settings. pic compact [ID [INSTRUCTIONS]] and
/compact [FOCUS] compact before the next request.
Exporting
pic export --html ID writes a conversation as one self-contained HTML page, pic export --pi
writes conversations as Pi session lines, and pic import PATH reads a Pi session back as a new
conversation.