Skip to content

Let several conversations share one corpus - #46

Merged
daniel-rossier merged 1 commit into
mainfrom
named-sessions
Nov 28, 2026
Merged

daniel-rossier merged 1 commit into
mainfrom
named-sessions

Conversation

@daniel-rossier

Copy link
Copy Markdown
Contributor

A corpus held a single conversation: two spear-chat processes on the same tree read and rewrote the same history file, and the last to save won.

What changes

  • spear-chat --session <name> opens a named conversation; in the chat, /session [list|new <name>|switch <name>|rm <name>] manages them (switch default returns to the unnamed one).
  • Each conversation keeps its history beside the default one (history-adhoc-<tag>-<name>.json); the default keeps the file it always had, so nothing changes for whoever never names one.
  • One process per conversation: an flock on <history>.lock, held for the life of the process (the kernel drops it with a crashed one). A second spear-chat, in another terminal or another container on the same state directory, is refused the conversation and pointed at another name; /session lists conversations open elsewhere.
  • A switch drops what the previous answer engaged, through the same helper as /clear. /cd keeps the conversation and takes its lock in the new corpus, staying put if that one is held elsewhere.
  • Training episodes record the conversation's name in provenance.conversation (None for the default one).
  • Docs: using/usage.rst, using/context.rst.

Verification

  • New tests/test_conversation_sessions.py (names, paths, listing, lock refusal across processes, switch and reset, the flag and the command); the 59 test modules touching the CLI, its settings and training capture: 1293 tests OK.
  • Driven through the CLI: two spear-chat processes on one tree, alpha and beta; the second launch on alpha was refused, /session showed beta as open elsewhere and switch beta was refused, new/switch/rm behaved, and the episode recorded in alpha carries conversation: alpha.

A corpus held a single conversation: two spear-chat processes on the same
tree read and rewrote the same history file, and the last to save won.

Conversations now have names. `spear-chat --session <name>` opens one and
`/session [list|new|switch|rm]` manages them in the chat; each keeps its
history beside the default one, which keeps the file it always had. A
conversation is held by one process through an flock on a lock file beside
its history, so a second spear-chat (another terminal, or another container
on the same state directory) is refused it and pointed at another name,
and the kernel drops the lock with a crashed process.

A switch drops what the previous answer engaged, through the same helper
as /clear. /cd keeps the conversation and takes its lock in the new corpus,
staying put if that one is held elsewhere. Training episodes record the
conversation's name in their provenance (None for the default one).
@daniel-rossier
daniel-rossier merged commit de9a99d into main Nov 28, 2026
2 checks passed
@daniel-rossier
daniel-rossier deleted the named-sessions branch November 28, 2026 11:23
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.

1 participant