Skip to content

Refine history persistence architecture#16

Merged
merefield merged 5 commits into
mainfrom
history_architecture
Mar 6, 2026
Merged

Refine history persistence architecture#16
merefield merged 5 commits into
mainfrom
history_architecture

Conversation

@merefield

@merefield merefield commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • make history writes atomic with temp-file-then-rename persistence
  • move normal history saving onto explicit exit paths, keeping cleanup as a fallback
  • warn when persisted history cannot be parsed or written, and repair normalized/invalid history on immediate exit
  • stop persisting regenerated system messages and trim saved history by conversation turn
  • rename the turn-retention setting to max_history_turns while keeping legacy max_history as a deprecated compatibility fallback
  • extend Bats coverage for invalid history files, immediate repair-on-exit behavior, turn-based trimming, and the renamed config key

Verification

  • make check

Fixes #12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors CLAI’s cross-session history persistence to be more robust and intentional: atomic writes, explicit save points, warning on failures, and persisting a turn-trimmed conversation view rather than raw transcripts.

Changes:

  • Add atomic history persistence (temp file + rename) with warnings on parse/write failures.
  • Introduce max_history_turns (with deprecated max_history fallback) and trim persisted history by user-turn boundaries.
  • Extend Bats coverage for invalid history repair, turn-based trimming, deprecation behavior, and ensuring system messages aren’t persisted.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
clai.sh Implements atomic history writes, new max_history_turns config handling, history normalization/trimming, and explicit exit persistence.
test/smoke.bats Updates configs to max_history_turns and adds tests for trimming behavior, legacy key warning, and invalid history handling.
README.md Documents max_history_turns and deprecates max_history.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread clai.sh Outdated
Comment thread clai.sh Outdated
@merefield
merefield merged commit 4f6e979 into main Mar 6, 2026
2 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.

Improve session history persistence architecture

2 participants