Skip to content

Establish session persistence and mediation (mediate-session)#31

Merged
drzo merged 2 commits intomainfrom
copilot/establish-session-persistence
Mar 29, 2026
Merged

Establish session persistence and mediation (mediate-session)#31
drzo merged 2 commits intomainfrom
copilot/establish-session-persistence

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

Sessions had no file-based persistence — mediate_session only wrote to AtomSpace (when available), and resume_session had no fallback for cross-process recovery. The Scheme module also shadowed the C++ SessionManager bindings with weaker pure-Scheme wrappers and omitted key exports.

C++ (SessionManager)

  • File persistence: persist_session_to_file() serialises metadata + full message history to ~/.caichat/sessions/<name>.json; load_session_from_file() deserialises and populates restored_messages for replay into the restored ChatCompletion
  • resume_session(): now checks memory → AtomSpace → file before creating a new session; replays messages back into the live completion instance
  • mediate_session(): always persists (previously skipped active sessions, leaving their state unwritten)
  • persist_session(): uses a new session_id_to_name_ reverse map for O(1) name lookup instead of linear scan
  • get_session_file_path(): creates ~/.caichat/sessions/ tree with errno-aware error reporting
  • Bidirectional session_name_to_id_ / session_id_to_name_ maps maintained across all session lifecycle calls

Scheme

  • caichat.scm: exports caichat-create-persistent-session, caichat-resume-session, caichat-mediate-session, caichat-audit-core-modules, caichat-neural-symbolic-bridge; removes Scheme wrappers that shadowed the C++ bindings
  • init.scm: re-exports caichat-create-persistent-session and caichat-resume-session
  • repl.scm: adds /persist <name>, /resume <name>, /mediate interactive commands and updates help text
;; Create a named persistent session — saved immediately to ~/.caichat/sessions/my-session.json
(define sid (caichat-create-persistent-session "my-session" "openai" "gpt-4"))

;; Sync state to disk at any point during the session
(caichat-mediate-session sid)

;; Resume across processes — loads from file when not in memory/AtomSpace
(define sid2 (caichat-resume-session "my-session" "openai" "gpt-4"))
Original prompt

This section details on the original issue you should resolve

<issue_title>Establish session persistence and mediation (mediate-session)</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

- SessionManager: file-based persistence to ~/.caichat/sessions/<name>.json
  - persist_session_to_file(): serialise metadata + messages as JSON
  - load_session_from_file(): deserialise and replay messages on resume
  - get_session_file_path(): creates directories with proper error reporting
  - Bidirectional name<->id maps for O(1) lookup
  - resume_session() tries memory, AtomSpace, then file before creating new
  - mediate_session() always persists (active or inactive)
  - persist_session() uses reverse map for O(1) name lookup

- caichat.scm: export caichat-create-persistent-session, caichat-resume-session,
  caichat-mediate-session, caichat-audit-core-modules, caichat-neural-symbolic-bridge;
  remove Scheme wrappers that shadowed C++ bindings

- init.scm: re-export caichat-create-persistent-session and caichat-resume-session

- repl.scm: update help text; add /persist, /resume, /mediate REPL commands

Co-authored-by: drzo <15202748+drzo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/HyperCogWizard/caichat/sessions/4fb16d77-6bd3-4244-b583-4f0c74ef53ea
Copilot AI changed the title [WIP] Establish session persistence and mediation Establish session persistence and mediation (mediate-session) Mar 25, 2026
Copilot AI requested a review from drzo March 25, 2026 16:11
Copilot finished work on behalf of drzo March 25, 2026 16:11
Copy link
Copy Markdown

@drzo drzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coool

@drzo drzo marked this pull request as ready for review March 29, 2026 13:38
@drzo drzo merged commit b8baf66 into main Mar 29, 2026
0 of 3 checks passed
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.

Establish session persistence and mediation (mediate-session)

2 participants