Artifact 333c24f9c549863696a79b3c0f86736e9ee71461a3aace25828275e2b3385e97:
- File
docs/manual/tools.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: 2424) [annotate] [blame] [check-ins using]
# Tools A reply can call the tools a request offers (`--tools`, setting `defaultTools`; see [the command line reference](../reference/cli.md)). How each call is journaled is in [durability](../dev/durability.md). ## Parallel tool calls The tool calls of one reply run at the same time, as in Pi (its `toolExecution` "parallel", the default). Each call's PreToolUse hooks run first, one call after another in call order; then the calls run together, each in a process forked from pic, and each is journaled as a lone call is: intent, started, result, every step its own short transaction. Results commit as calls finish, but reach the transcript (and the model) in call order. `tool_execution_start` comes for every call before any runs; `tool_execution_update` and `tool_execution_end` come as each call goes. A crash mid-batch is recovered per call: a started command becomes unknown and is never run again, a started read, write or edit runs again, and a finished call keeps its one result. Esc, Ctrl-C and the RPC `abort` abort every running call. Calls on the same file wait for each other in call order when either changes it (Pi queues only edits and writes to one file; pic also keeps a read of that file in its place). `pic settings toolExecution sequential` (or Tool execution in `/settings`) runs the calls one by one instead. ## A file another conversation changed When [several pics work in one project](sessions.md#several-pics-in-one-project), two conversations can change the same file. pic does not merge. It knows from the journal which conversation edited or wrote which file, and tells the agent when it meets another's change: one made after this conversation last read, edited or wrote the file (or, if it never has, after this conversation began). - **`edit`** that cannot find its text, or finds it more than once, in such a file: Pi's error, then `PATH was changed by another pic conversation (ID) after this one last read it`, and the file as `read` would return it, so the agent can redo the edit. An edit whose text still matches is applied as usual. - **`write`** to such a file is not performed the first time: the result is an error that says the same and shows the file. Having been shown it, the agent's next write to that file goes through. Changes made by commands (`bash`) are not tracked. With one conversation at a time none of this happens, and the tools behave as Pi's.