Skip to content

fix(database): reconcile chat session activity and state version - #68

Merged
moshloop merged 3 commits into
mainfrom
fix/issue-57-session-activity
Aug 12, 2026
Merged

fix(database): reconcile chat session activity and state version#68
moshloop merged 3 commits into
mainfrom
fix/issue-57-session-activity

Conversation

@adityathebe

Copy link
Copy Markdown
Member

last_activity_at is a high-water mark. The activity trigger and transcript ingest preserve that invariant, but touchChatSession assigned the current time directly and could move it backwards.

This changes the chat writer to use the same monotonic semantics as the other writers.

touchChatSession also attempted to increment state_version, but the session state trigger always discarded that increment because no state fields changed. The ineffective write is removed, preserving the existing optimistic-concurrency behavior.

Tests cover both contracts: chat activity cannot move backwards, and a chat touch does not advance state_version.

Closes #57

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@adityathebe, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f9eb927f-fd1c-4efc-8c07-e2565a894411

📥 Commits

Reviewing files that changed from the base of the PR and between ff7eed3 and 0527e18.

📒 Files selected for processing (2)
  • pkg/database/session_chat_store.go
  • pkg/database/session_last_activity_integration_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Gavel summary

Source Pass Fail Skip Duration

Totals: 0 passed · 0 failed · 0 skipped · -

View full results

@adityathebe
adityathebe force-pushed the fix/issue-57-session-activity branch from 868bf50 to 0527e18 Compare August 11, 2026 17:47
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Gavel summary

Source Pass Fail Skip Duration
ai 87 0 0 40ms
aichat 113 0 2 13.1s
anthropicmock 1 0 0 1ms
api 80 0 0 30ms
attachments 5 0 0 7ms
bash 4 0 0 180.677µs
callertools 10 0 0 101ms
captain 6 0 0 3ms
claude 22 0 0 14ms
claudeagent 13 0 0 231ms
cli 209 0 0 6.8s
cmux 4 0 0 345.274µs
collections 12 0 0 356.817µs
credentials 5 0 0 40ms
database 15 0 0 4.2s
genkit 25 0 0 104ms
gitagent 66 0 0 9.1s
github.com/flanksource/captain/migrations 11 0 0 4.4s
github.com/flanksource/captain/pkg/ai 232 0 0 260ms
github.com/flanksource/captain/pkg/ai/agent 23 0 0 -
github.com/flanksource/captain/pkg/ai/agent/commit 52 0 0 5.0s
github.com/flanksource/captain/pkg/ai/agent/setup 16 0 0 70ms
github.com/flanksource/captain/pkg/ai/agent/verify 21 0 0 370ms
github.com/flanksource/captain/pkg/ai/agent/worktree 6 0 0 -
github.com/flanksource/captain/pkg/ai/assistanttags 15 0 0 -
github.com/flanksource/captain/pkg/ai/fixture 42 0 0 210ms
github.com/flanksource/captain/pkg/ai/fixture/kubeproxy 2 0 0 40ms
github.com/flanksource/captain/pkg/ai/fixture/mcpproxy 6 0 0 -
github.com/flanksource/captain/pkg/ai/history 54 0 0 -
github.com/flanksource/captain/pkg/ai/internal/gen-model-registry 12 0 0 -
github.com/flanksource/captain/pkg/ai/middleware 25 0 0 -
github.com/flanksource/captain/pkg/ai/pricing 9 0 0 10ms
github.com/flanksource/captain/pkg/ai/prompt 16 0 0 10ms
github.com/flanksource/captain/pkg/ai/provider 144 0 0 10ms
github.com/flanksource/captain/pkg/ai/provider/claudeagent 44 0 0 1.4s
github.com/flanksource/captain/pkg/ai/provider/cmux 119 0 0 880ms
github.com/flanksource/captain/pkg/ai/provider/genkit 36 0 0 -
github.com/flanksource/captain/pkg/ai/provider/jsonrpc 6 0 0 50ms
github.com/flanksource/captain/pkg/aichat 5 0 0 100ms
github.com/flanksource/captain/pkg/aimock 50 0 7 490ms
github.com/flanksource/captain/pkg/aimock/anthropicmock 14 0 0 20ms
github.com/flanksource/captain/pkg/aimock/openaimock 18 0 0 40ms
github.com/flanksource/captain/pkg/api 136 0 0 390ms
github.com/flanksource/captain/pkg/api/registry 96 0 0 -
github.com/flanksource/captain/pkg/bash 348 0 0 30ms
github.com/flanksource/captain/pkg/captainconfig 25 0 0 -
github.com/flanksource/captain/pkg/claude 138 0 0 10ms
github.com/flanksource/captain/pkg/claude/tools 18 0 0 -
github.com/flanksource/captain/pkg/cli 532 0 0 47.9s
github.com/flanksource/captain/pkg/cmux 1 0 0 -
github.com/flanksource/captain/pkg/codexconfig 10 0 0 10ms
github.com/flanksource/captain/pkg/container 72 0 1 -
github.com/flanksource/captain/pkg/database 101 0 0 15.3s
github.com/flanksource/captain/pkg/dod 11 0 0 1m0s
github.com/flanksource/captain/pkg/gitagent 31 0 0 530ms
github.com/flanksource/captain/pkg/gitagent/proxy 12 0 0 10ms
github.com/flanksource/captain/pkg/monitor 54 0 0 2.6s
github.com/flanksource/captain/pkg/sandbox 1 0 0 -
github.com/flanksource/captain/pkg/sandbox/adapter 26 0 0 -
github.com/flanksource/captain/pkg/sandbox/presets 13 0 0 -
github.com/flanksource/captain/pkg/session 70 0 0 10ms
history 69 0 0 17ms
migrations 6 0 0 4.6s
openaimock 2 0 0 175.256µs
provider 10 0 0 12ms
registry 38 0 0 1ms
session 28 0 0 19ms
tools 38 0 0 1ms

Totals: 3541 passed · 0 failed · 10 skipped · 2m59s

View full results

@moshloop
moshloop merged commit d48c96d into main Aug 12, 2026
12 checks passed
@moshloop
moshloop deleted the fix/issue-57-session-activity branch August 12, 2026 04:50
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.

Reconcile the three writers of session activity and state version

2 participants