✨ feat(repository): add Repository.connect() factory classmethod (#381)#402
Merged
Conversation
Add `Repository.connect()` and `SyncRepository.connect()` as the recommended entry point for connecting to existing infrastructure. This provides a one-call alternative to `builder().build()` for the common case (80% of usage). - Add `connect()` classmethod with namespace, config_cache_ttl, auto_update params - Add `parallel_mode` param to `SyncRepository.connect()` via sync generator - Deprecate direct `__init__` with DeprecationWarning directing to connect()/builder() - Migrate docs (CLAUDE.md, README, getting-started, basic-usage, deployment, api/) to connect() - Migrate e2e tests to connect() or builder() (zero deprecated constructor calls) - Migrate benchmark AWS fixtures to builder(), moto fixtures to _skip_deprecation_warning - Add unit tests for connect() parameter forwarding and deprecation warning Closes #381 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #402 +/- ##
==========================================
- Coverage 91.93% 91.76% -0.17%
==========================================
Files 33 33
Lines 7473 7333 -140
==========================================
- Hits 6870 6729 -141
- Misses 603 604 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ration - CLI test fixtures: use builder() instead of connect() since CLI deploy doesn't register namespaces - Doctest conftest: patch _resolve_namespace and version check methods so connect() works in moto-backed mock environment - Audit archival test: use dynamic namespace_id instead of hardcoded "default" in DynamoDB PK query Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CLI `audit list` command internally uses Repository(name, region, endpoint_url) which defaults to the literal "default" namespace_id. The test fixture must use the same constructor (not builder) so both operate on the same namespace and audit events are found. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace _resolve_namespace helper with _connect helper that wraps Repository.connect() for proper namespace resolution via opaque IDs. - 17 data-access commands (audit, usage, entity, resource, system) now use Repository.connect() instead of the deprecated constructor - 12 infrastructure/namespace commands use _skip_deprecation_warning=True - Deploy command registers "default" namespace after stack creation - E2E audit test uses SyncRepository.connect() to match CLI behavior This fixes the namespace mismatch where CLI used literal "default" as namespace_id while builder/connect use opaque IDs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ect() Status, version, check, upgrade, and all namespace commands now use Repository.connect() via the _connect helper instead of the deprecated constructor. Deploy is the only command still using the constructor (it creates the namespace that connect() requires). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eprecation version to v1.0.0 - Migrate test fixtures in test_namespace_registry, test_namespace_scoping, and test_repository_builder to use Repository.connect() instead of constructor - Migrate doctest conftest globals to use Repository.connect() after bootstrap - Change deprecation warning removal version from v2.0.0 to v1.0.0 across all source files (limiter, repository, models, and generated sync files) - Update test assertions to match v1.0.0 version string - Adjust namespace list tests to account for "default" namespace from bootstrap Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The paginated_query mock in test_list_orphan_namespaces_handles_pagination was passing the fake ExclusiveStartKey to moto's actual query, which returned 0 items since the key was in a different partition. Now strips the key before forwarding to moto, since pagination is simulated by the mock itself. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test_usage_list_plot_cli_workflow test inserted DynamoDB items with hardcoded "default/" namespace prefix, but the CLI now uses Repository.connect() which resolves "default" to an opaque 11-char namespace ID. Look up the actual namespace ID from the registry before inserting test items. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Repository.connect()async classmethod as the recommended one-call entry point for connecting to existing zae-limiter infrastructure (the 80% use case)SyncRepository.connect()sync counterpart via the async-to-sync transformer with a new@classmethodhandler ingenerate_sync.pyDeprecationWarningfromRepository.__init__()andSyncRepository.__init__()directing users toconnect()orbuilder()connect()as the primary pattern, withbuilder()for infrastructure provisioning__init__toconnect()or builderconnect()parameters (namespace, config_cache_ttl, auto_update) and deprecation warningsTest plan
uv run pytest tests/unit/ -vpasses (connect() unit tests, deprecation warning tests)uv run pytest tests/unit/test_repository_builder.py -vpasses (expanded builder + connect tests)uv run mypy src/zae_limiter/passes with no new errorshatch run generate-syncproduces no diff (sync code is up-to-date)uv run pytest tests/e2e/test_localstack.py -vpasses with LocalStack (connect-based fixtures)Closes #381
🤖 Generated with Claude Code