Skip to content

fix: deduplicate session validation logic and harden EmbeddingProvider#154

Merged
johnnichev merged 3 commits into
johnnichev:mainfrom
vaishnavidesai09:fix-140-session-validation-deduplication
Jun 24, 2026
Merged

fix: deduplicate session validation logic and harden EmbeddingProvider#154
johnnichev merged 3 commits into
johnnichev:mainfrom
vaishnavidesai09:fix-140-session-validation-deduplication

Conversation

@vaishnavidesai09

Copy link
Copy Markdown
Contributor

Summary

This PR centralizes session identifier validation logic into shared module-level helper functions and adds a default _dimension attribute to the embedding provider base class.

Changes

  • Extracted session ID validation into a reusable _validate_session_id() helper.
  • Added _validate_namespace() helper for consistent namespace validation.
  • Removed duplicated validation implementations from session store classes and reused shared helpers.
  • Added a default _dimension: int = 0 attribute to EmbeddingProvider to provide a safe base implementation for subclasses.

Validation

Verified session-related functionality by running:

pytest tests/test_sessions_edge_cases.py -q
pytest tests/test_sessions* -q

Results:

  • tests/test_sessions_edge_cases.py: 15 passed
  • Session test suite: 191 passed

@vaishnavidesai09

Copy link
Copy Markdown
Contributor Author

Hi @johnnichev! I've resolved the merge conflicts with the latest main branch, preserved the validation changes from both sides, and reran the session-related test suite locally.

@johnnichev

Copy link
Copy Markdown
Owner

lovely! thanks for pushing more code to selectools, I'll review right now :)

@johnnichev johnnichev self-requested a review June 23, 2026 17:20
@johnnichev

Copy link
Copy Markdown
Owner

Thanks for picking this up, the module-level extraction is the right call and Redis and Mongo look good. Two things before it can go in:

The dedup is only half done. Supabase and DynamoDB still define the old _validate_session_id/_validate_namespace static methods (around 1135/1147 and 1527/1538), but their _key already calls the new module-level helpers, so those are dead code now. Can you delete both pairs? That's what actually closes #140.

Also the four embeddings files each picked up a stray blank line before __stability__. Looks accidental, mind reverting those to keep the diff clean?

Drop those and it's good to merge.

@vaishnavidesai09 vaishnavidesai09 force-pushed the fix-140-session-validation-deduplication branch from dca6d18 to bb36ea7 Compare June 24, 2026 09:42
@vaishnavidesai09

Copy link
Copy Markdown
Contributor Author

Hi @johnnichev,

I've addressed the review feedback:

  • Removed the remaining dead _validate_session_id and _validate_namespace helpers from the Supabase and DynamoDB session stores.
  • Kept validation centralized through the module-level helper functions.
  • Removed the unrelated provider-refactor changes from the branch so the PR now contains only the session-validation cleanup.

Thanks for the review!

@vaishnavidesai09

Copy link
Copy Markdown
Contributor Author

I removed the dead Supabase and DynamoDB validation helpers and updated the Supabase validation tests to use the shared module-level validation helpers. I also reran the full session-related test suite locally (7459 passed, 215 skipped). CI is now passing on the updated branch.

@johnnichev johnnichev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The module-level extraction is the right call and the dead Supabase/DynamoDB helpers are gone now, so this closes #140 cleanly. Scoping the branch down to just the session-validation cleanup was the right move too. Merging. Thanks for the contribution! I'll do a small follow-up pass on the test polish myself.

@johnnichev johnnichev merged commit 08c7514 into johnnichev:main Jun 24, 2026
8 checks passed
johnnichev added a commit that referenced this pull request Jun 24, 2026
…ation tests (#155)

Adds a `lint` job to CI (ruff check + ruff format --check on src/ + tests/),
pinned to ruff 0.15.8 to match the ruff-pre-commit rev. Until now nothing
linted the whole tree: the pre-commit hook only sees changed files and CI
had no ruff step, so lint debt accumulated invisibly. `build` now needs lint.

Enabling that gate required clearing the pre-existing debt in tests/
(src/ was already clean):
- 411 F401 unused-imports: removed the dead ones; the 45 intentional
  availability probes (`from google.genai import types` / `import numpy`
  inside try/except ImportError or skipif guards) get an explicit
  `# noqa: F401` since deleting them would break skip logic.
- 92 F841 unused-variables: dropped the dead bindings while preserving the
  side-effecting calls (e.g. `result = agent.run(...)` -> `agent.run(...)`).

Also hardens the four Supabase namespace-validation tests carried in by
#154: they had been re-pointed at the module-level `_validate_namespace`
in isolation, leaving an orphaned `store` local (4x F841) and exercising
no store path. Routed them back through `store._key("sid", namespace=...)`
so the validator's wiring into _key is actually asserted, which also
removes the duplicate/unsorted import.

Full suite: 7469 passed, 205 skipped, coverage 91.01% (gate 90%).

Claude-Session: https://claude.ai/code/session_01HQhq1HKYipPa6rjQAzffcg
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.

2 participants