Skip to main content

Module thread

Module thread 

Source
Expand description

Client-owned thread store.

A thread is the interactive client’s durable record of a conversation: a stable id, a subject, the policy currently acting as the “model”, and the ordered messages. The client owns this transcript (standard Chat Completions semantics), so restoring a conversation does not depend on the orchestrator’s history retention. See docs/explanation/policy-as-model-and-threads.md.

This is deliberately separate from crate::agents::session_store, which maps Claude-CLI transcript UUIDs and holds no conversation content.

Layout: one JSON file per thread under ~/.nsed/threads/{id}.json ($NSED_THREAD_DIR overrides the directory). one-file-per-thread keeps listing cheap and avoids whole-store rewrite races between concurrent clients.

Structs§

Message
One message in a conversation. policy_id records which policy (the “model”) produced an assistant message, so a thread that swapped policy mid-thread stays self-describing; job_id links the turn back to its deliberation.
Thread
A stored conversation. server_thread is the x-nsed-session-id used for cheap same-policy continuation; it is an optimisation, not the source of truth — the source of truth is messages.
ThreadStore
Filesystem-backed store of threads.