Skip to content

✨ feat(repository): add Repository.connect() factory classmethod (#381)#402

Merged
sodre merged 9 commits into
mainfrom
feat/381-repository-connect
Feb 19, 2026
Merged

✨ feat(repository): add Repository.connect() factory classmethod (#381)#402
sodre merged 9 commits into
mainfrom
feat/381-repository-connect

Conversation

@sodre

@sodre sodre commented Feb 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Add Repository.connect() async classmethod as the recommended one-call entry point for connecting to existing zae-limiter infrastructure (the 80% use case)
  • Generate SyncRepository.connect() sync counterpart via the async-to-sync transformer with a new @classmethod handler in generate_sync.py
  • Emit DeprecationWarning from Repository.__init__() and SyncRepository.__init__() directing users to connect() or builder()
  • Migrate all documentation (CLAUDE.md, README, docs/, API reference) to use connect() as the primary pattern, with builder() for infrastructure provisioning
  • Migrate E2E, benchmark, and doctest fixtures from direct __init__ to connect() or builder
  • Update unit tests to cover connect() parameters (namespace, config_cache_ttl, auto_update) and deprecation warnings

Test plan

  • uv run pytest tests/unit/ -v passes (connect() unit tests, deprecation warning tests)
  • uv run pytest tests/unit/test_repository_builder.py -v passes (expanded builder + connect tests)
  • uv run mypy src/zae_limiter/ passes with no new errors
  • hatch run generate-sync produces no diff (sync code is up-to-date)
  • uv run pytest tests/e2e/test_localstack.py -v passes with LocalStack (connect-based fixtures)

Closes #381

🤖 Generated with Claude Code

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>
@sodre sodre added this to the v0.10.0 milestone Feb 16, 2026
@sodre sodre added documentation Improvements or additions to documentation testing Test coverage api-design API surface changes area/limiter Core rate limiting logic labels Feb 16, 2026
@codecov

codecov Bot commented Feb 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.76%. Comparing base (f8582a0) to head (c897641).
⚠️ Report is 10 commits behind head on main.
✅ All tests successful. No failed tests found.

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     
Flag Coverage Δ
doctest 29.55% <28.57%> (+0.13%) ⬆️
e2e 43.33% <41.26%> (+1.02%) ⬆️
integration 51.27% <69.84%> (+0.55%) ⬆️
unit 91.50% <100.00%> (-0.16%) ⬇️

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.

sodre and others added 4 commits February 16, 2026 20:37
…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>
Comment thread src/zae_limiter/cli.py Dismissed
sodre and others added 3 commits February 16, 2026 22:58
…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>
@sodre sodre marked this pull request as ready for review February 17, 2026 07:01
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>

@sodre sodre left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks good to me

@sodre sodre merged commit 6b450ad into main Feb 19, 2026
17 checks passed
@sodre sodre deleted the feat/381-repository-connect branch February 19, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-design API surface changes area/limiter Core rate limiting logic documentation Improvements or additions to documentation testing Test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Add Repository.connect() factory classmethod as recommended entry point

1 participant