Skip to content

feat(sdk): SessionStore::has_session, and selection matches the identity listing - #262

Merged
willwashburn merged 2 commits into
mainfrom
fix/identity-selection-parity
Sep 25, 2026
Merged

willwashburn merged 2 commits into
mainfrom
fix/identity-selection-parity

Conversation

@willwashburn

@willwashburn willwashburn commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

SessionStore::has_session(&SessionIdentity) tells an embedder on the public API whether a session exists, using the same rule as session_identities. Every session the listing counts can be selected and drained. This also covers the two Devin findings on #261 that arrived after it merged (r4101158605, r4101158685).

  • SessionStore::has_session(&SessionIdentity) -> Result<bool, Error> is true exactly when session_identities would list the identity. It covers the same tables, plus the trajectory id, and returns false for an empty source or session id. It's one indexed existence probe per table, all on one snapshot, and reads no payload. It takes the SessionIdentity that session_identities returns, so the desktop probe in relay-desktop can validate a selection without unstable-internal.
  • storage::session_identity_exists calls the same identity_exists, and plugins/relayhistory's validate_identities now uses it. A session whose only evidence is a tool call or a connector observation can now be selected as well as counted; before, sessions include answered "Unknown session".
  • An empty source is no session. The identity listing skips an empty source the same way it skips an empty session id, so every identity it lists is one ChangeQuery::session and has_session accept.
  • The existence check reads one snapshot, by the same rule as a listing page: the caller's transaction, or its own on an autocommit connection. A session whose only row moves between tables mid-check is still found.

New public API:

+pub fn ai_hist::SessionStore::has_session(&self, &ai_hist::SessionIdentity) -> core::result::Result<bool, ai_hist::Error>

Tests

  • tests/session_identities.rs::has_session_is_true_exactly_for_listed_identities (outside the crate, default features): every listed identity exists. An empty source (('', 'blank-source')), empty session ids, missing identities, and a child named only by an edge don't exist.
  • session_identities::tests::an_identity_exists_exactly_when_it_is_listed: every existence probe is an index SEARCH.
  • session_identities::tests::an_existence_check_reads_one_snapshot: another connection moves a session from session_events to sessions exactly between the two probes. It's still found; without the snapshot it isn't.
  • bridge::tests::a_session_with_only_evidence_rows_can_be_selected (probe): a tool-only and an observation-only session are counted and then selected. With the previous three-table check it fails with "Unknown session."

🤖 Generated with Claude Code


Note

Medium Risk
Behavior changes which (source, session_id) pairs count as sessions (empty source excluded) and which identities the probe accepts for sharing; embedders relying on the old listing or the narrower validation could see different results.

Overview
Session counting and selection now share one rule. SessionStore::has_session and storage::session_identity_exists probe the same evidence tables as session_identities (indexed EXISTS checks on one read snapshot). The relayhistory probe’s validate_identities uses that helper instead of a three-table SQL check, so sessions that only have tool calls or connector observations can be selected after they appear in the list.

Empty source is no longer an identity. Identity paging SQL adds source <> '', matching the empty-session-id rule, so rows like ('', 'blank-source') are neither listed nor accepted by ChangeQuery::session.

Docs, changelog, and public-api.txt document has_session as the twelfth default SessionStore operation; integration tests assert listing ↔ existence parity and probe selection for evidence-only sessions.

Reviewed by Cursor Bugbot for commit a8a87a4. Bugbot is set up for automated code reviews on this repo. Configure here.

…e no session

storage::session_identity_exists answers by the identity listing's own
tables and rule, and the probe's selection validation uses it, so a
session whose only evidence is a tool call or an observation can be
selected as well as counted. The listing skips an empty source as it
skips an empty session id, so every identity it names is one
ChangeQuery::session accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e795002e-29bc-44db-afc3-a6beea36afe8

📥 Commits

Reviewing files that changed from the base of the PR and between 5e2389d and a8a87a4.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • crates/ai-hist/README.md
  • crates/ai-hist/public-api.txt
  • crates/ai-hist/src/session_identities.rs
  • crates/ai-hist/src/storage.rs
  • crates/ai-hist/tests/session_identities.rs
  • docs/sourcing-sdk.md
  • plugins/relayhistory/rust/src/probe/bridge.rs

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T05:00:20.291415Z f6f8832 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 2 potential issues.

Devin Review

Comment thread plugins/relayhistory/rust/src/probe/bridge.rs
Comment thread crates/ai-hist/src/session_identities.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6f88320a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ai-hist/src/session_identities.rs
…s rule

has_session(&SessionIdentity) is true exactly when session_identities
would list the identity: the same tables, the same empty-source and
empty-id rule, one indexed existence probe per table on one snapshot.
storage::session_identity_exists is the same check, so an embedder on
the public API selects every session it counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willwashburn willwashburn changed the title fix(sdk): the probe selects every session it counts; empty sources are no session feat(sdk): SessionStore::has_session, and selection matches the identity listing Sep 25, 2026
@willwashburn
willwashburn merged commit 8e73626 into main Sep 25, 2026
14 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.

1 participant