Skip to content

feat(adk): ADK 2.0 Migration#457

Open
cofin wants to merge 29 commits into
mainfrom
feat/adk-2-0-migrate
Open

feat(adk): ADK 2.0 Migration#457
cofin wants to merge 29 commits into
mainfrom
feat/adk-2-0-migrate

Conversation

@cofin
Copy link
Copy Markdown
Member

@cofin cofin commented May 23, 2026

Summary

This PR implements the ADK 2.0 clean-break foundation and the retained-adapter schema-parity work for upstream ADK scoped state.

Expected ADK Changes Covered Here

  • Align ADK event persistence on the upstream event_data payload column across adapter stores.
  • Use singular default table names: adk_session, adk_event, adk_app_state, adk_user_state, and adk_internal_metadata.
  • Add app-scoped, user-scoped, and metadata table configuration to ADKConfig while keeping driver-specific config types out of the sqlspec.extensions.adk public export surface.
  • Add app/user/metadata DDL and CRUD hooks to BaseAsyncADKStore and implement them across retained shipped ADK stores.
  • Extend ADK migration 0001 to create app/user/metadata tables and seed schema_version = 1.
  • Route app:* and user:* state through dedicated store hooks in SQLSpecSessionService, strip temp:* at the service boundary, and merge app/user/session state on get_session().
  • Keep shared helper code scoped to ADK or existing project-level utilities; no new cross-extension DDL builder surface is introduced.
  • Add shared scoped-state integration coverage for the fixture-backed adapter paths and update Oracle in-memory tests for the singular table names.
  • Document scoped state, table defaults, migrations, and backend configuration in docs/extensions/adk/ and ADK examples.
  • Temporarily disable Ruff PLW0717 in pyproject.toml for the new lint rule.

Remaining ADK Work Tracked Outside This Commit

  • BigQuery ADK store and schema-parity DDL/CRUD remains open under sqlspec-3x32 / sqlspec-9k0 because sqlspec/adapters/bigquery/adk/ is not present yet.
  • Full adapter-local transaction proof for event insert + session update + app/user scoped-state upserts remains open under sqlspec-v8io; current routing is service-level after the store event/session transaction.
  • The central every-retained-adapter scoped-state contract matrix remains open under sqlspec-epy6 / sqlspec-9yex; this PR adds fixture-backed coverage but does not close the full matrix.

@cofin cofin changed the title feat(adk): prepare clean-break ADK 2.0 contracts feat(adk): ADK 2.0 Migration May 23, 2026
@cofin cofin force-pushed the feat/adk-2-0-migrate branch 3 times, most recently from d6da42e to 41c556b Compare May 24, 2026 14:17
@cofin cofin marked this pull request as ready for review May 24, 2026 14:17
@cofin cofin force-pushed the feat/adk-2-0-migrate branch 3 times, most recently from f04986d to 1fc1e54 Compare May 25, 2026 20:07
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 25, 2026

Codecov Report

❌ Patch coverage is 59.59258% with 1329 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.91%. Comparing base (6f91042) to head (3017d21).

Files with missing lines Patch % Lines
sqlspec/adapters/mysqlconnector/adk/store.py 33.61% 233 Missing and 4 partials ⚠️
sqlspec/adapters/cockroach_psycopg/adk/store.py 45.27% 167 Missing and 1 partial ⚠️
sqlspec/adapters/psycopg/adk/store.py 50.32% 153 Missing ⚠️
sqlspec/adapters/bigquery/adk/store.py 52.88% 100 Missing and 6 partials ⚠️
sqlspec/adapters/adbc/adk/store.py 60.97% 85 Missing and 11 partials ⚠️
sqlspec/adapters/asyncmy/adk/store.py 47.50% 81 Missing and 3 partials ⚠️
sqlspec/adapters/aiomysql/adk/store.py 47.79% 80 Missing and 3 partials ⚠️
sqlspec/adapters/psqlpy/adk/store.py 57.96% 65 Missing and 1 partial ⚠️
sqlspec/adapters/pymysql/adk/store.py 68.88% 56 Missing ⚠️
sqlspec/adapters/asyncpg/adk/store.py 58.62% 44 Missing and 4 partials ⚠️
... and 12 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #457      +/-   ##
==========================================
+ Coverage   70.78%   70.91%   +0.13%     
==========================================
  Files         438      443       +5     
  Lines       52541    54891    +2350     
  Branches     7370     7484     +114     
==========================================
+ Hits        37189    38925    +1736     
- Misses      12682    13217     +535     
- Partials     2670     2749      +79     
Flag Coverage Δ
integration 57.30% <53.20%> (+0.71%) ⬆️
py3.10 55.95% <31.01%> (-11.90%) ⬇️
py3.11 55.96% <31.01%> (-11.91%) ⬇️
py3.12 67.49% <49.65%> (-0.38%) ⬇️
py3.13 55.96% <31.01%> (-11.92%) ⬇️
py3.14 70.15% <59.28%> (+0.19%) ⬆️
unit 56.20% <31.13%> (-1.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cofin added 21 commits May 25, 2026 15:52
Extends BaseAsyncADKStore.append_event_and_update_state with app_name,
user_id, app_state, user_state keyword arguments so events INSERT, sessions
UPDATE, app_state UPSERT, and user_state UPSERT execute inside one
adapter-local transaction. SQLSpecSessionService stops issuing separate
upsert_app_state / upsert_user_state calls and routes everything through
the unified atomic method, closing the silent correctness drift where a
crash between calls left session state advanced but scoped state stale
(Chapter 14 v8io acceptance).

Shared contract helper assert_session_atomic_scoped_write_contract is
exercised by every retained adapter test file that already used the
scoped-state contract.
…over

- New tests/unit/extensions/test_adk/test_clean_break_guards.py fails CI if
  event_json reappears in any ADK source or per-adapter adk/ module, and if
  any backwards_compat / legacy_ / # DEPRECATED markers leak into the
  extension surface (PRD Global Constraint #1).
- docs/extensions/adk/migrations.rst now documents the programmatic
  recreate_tables() / drop_tables() cutover path (Revision 6 Q8).
Revives the BigQuery ADK store per Chapter 9 (sqlspec-9k0). The store wraps
BigQuery's sync client with async_(), uses native JSON columns, DATE
partitioning + clustering for sessions and events, and MERGE for
scoped-state upserts. ADKConfig.bigquery.session_lookup_window_days bounds
list-sessions partition scans, and ADKRetentionConfig.event_ttl_seconds is
converted to partition_expiration_days on the events table.

The store is positioned as the analytics-replica path: BigQuery DML is
seconds-latency and not transactional across statements, so production
deployments should pair it with an OLTP-grade ADK adapter for live state.

Unit tests in tests/unit/adapters/test_bigquery_adk.py cover instantiation,
DDL shape, partitioning, clustering, and idempotent metadata seeding. The
support matrix in docs/extensions/adk/backends.rst documents the new
analytics-replica status and the BigQuery-specific configuration knobs.
- sqlspec/extensions/adk/memory/presets.py registers eight embedding presets
  (Google Vertex AI gemini-embedding-002/001, embeddinggemma-300m,
  text-embedding-005/004, OpenAI 3-large/3-small/ada-002). Explicit
  embedding_dimension wins over embedding_preset; an unresolvable config
  raises ImproperConfigurationError that lists every available preset.
  Exposed via sqlspec.extensions.adk.memory public API and documented.
- docs/extensions/adk/optimizations.rst documents the Chapter 16 variation
  catalog (V1 NULL-encoded empty state through V8 AlloyDB columnar
  autopromote) and the memory embedding preset table. Linked from
  docs/extensions/adk/index.rst.
- tools/scripts/bench_adk.py provides the harness contract (chat_loop,
  list_replay, struct_scan scenarios) so Chapter 16 implementers have a
  stable invocation surface. Scenarios remain stubs pending sqlspec-badb.
- tests/unit/extensions/test_adk/test_embedding_presets.py covers preset
  registry, explicit-dimension overrides, runtime registration, and the
  ImproperConfigurationError paths.
cofin added 4 commits May 25, 2026 15:52
Add four contract helpers (assert_session_temp_state_not_persisted,
assert_session_empty_state_roundtrip, assert_session_sibling_app_isolation,
assert_session_sibling_user_isolation) and wire them across the retained
ADK adapters.

New per-adapter contract test files for oracledb, psycopg, psqlpy,
cockroach_asyncpg, cockroach_psycopg, pymysql, and BigQuery (analytics
replica path) consume the shared helpers. Spanner and BigQuery follow
the existing emulator skip gates.

Bugs surfaced by the matrix and tracked as xfail with bd refs:
- sqlspec-xqnf: psycopg/cockroach_psycopg ADK read paths return tuples
- sqlspec-8cyp: psqlpy ADK store doesn't catch UndefinedTable on reads
- sqlspec-7rbl: cockroach_asyncpg hits CockroachDB multiple_active_portals

Closes sqlspec-epy6, sqlspec-9yex, sqlspec-vf94.
Scope each new *_adk_store fixture session-wide so create_tables runs
once per test session, dropping tables on session teardown. BigQuery
routes through native_bigquery_service so the goccy/bigquery-emulator
skips the suite (production DDL with PARTITION BY + multi-key CLUSTER
BY + OPTIONS hangs CREATE TABLE on the emulator) and uses an autouse
DELETE FROM cleanup between tests instead of DROP TABLE (per bd memory
session-scope-fixtures).

Closes sqlspec-0s50.
Leaves session-scoped *_adk_store fixtures in a usable state after
the helper exercises drop_tables. Without this, every test that runs
after assert_session_table_lifecycle_contract in the same worker
fails with "table does not exist" -- pymysql, oracledb, and
cockroach_asyncpg surfaced 14 such failures in CI.

Closes sqlspec-nfde.
@cofin cofin force-pushed the feat/adk-2-0-migrate branch from 9edaaee to 276317e Compare May 25, 2026 20:52
cofin added 4 commits May 26, 2026 00:15
- Removed unnecessary xfail markers in CockroachDB and Psycopg tests.
- Updated table names in SQLite and Spanner tests to reflect new schema.
- Changed metadata table name in BigQuery tests for consistency.
- Enhanced test assertions for session store configurations and migrations.
- Consolidated nested configuration tests into flat structure for ADK.
- Removed deprecated lifecycle and capability tests.
- Added new migration tests for ADK cutover scenarios.
- Improved session service tests to validate state persistence and event handling.
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