feat(sdk): SessionStore::has_session, and selection matches the identity listing - #262
Conversation
…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>
|
Warning Review limit reachedNext included review available in 7 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
…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>
SessionStore::has_session(&SessionIdentity)tells an embedder on the public API whether a session exists, using the same rule assession_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 whensession_identitieswould 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 theSessionIdentitythatsession_identitiesreturns, so the desktop probe in relay-desktop can validate a selection withoutunstable-internal.storage::session_identity_existscalls the sameidentity_exists, andplugins/relayhistory'svalidate_identitiesnow 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 includeanswered "Unknown session".ChangeQuery::sessionandhas_sessionaccept.New public API:
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 indexSEARCH.session_identities::tests::an_existence_check_reads_one_snapshot: another connection moves a session fromsession_eventstosessionsexactly 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_sessionandstorage::session_identity_existsprobe the same evidence tables assession_identities(indexedEXISTSchecks on one read snapshot). The relayhistory probe’svalidate_identitiesuses 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
sourceis no longer an identity. Identity paging SQL addssource <> '', matching the empty-session-id rule, so rows like('', 'blank-source')are neither listed nor accepted byChangeQuery::session.Docs, changelog, and
public-api.txtdocumenthas_sessionas the twelfth defaultSessionStoreoperation; 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.