zae-limiter 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. zae_limiter-0.1.0/.github/dependabot.yml +18 -0
  2. zae_limiter-0.1.0/.github/workflows/ci.yml +55 -0
  3. zae_limiter-0.1.0/.github/workflows/claude-code-review.yml +44 -0
  4. zae_limiter-0.1.0/.github/workflows/claude-infra-review.yml +40 -0
  5. zae_limiter-0.1.0/.github/workflows/claude-test-review.yml +36 -0
  6. zae_limiter-0.1.0/.github/workflows/claude.yml +50 -0
  7. zae_limiter-0.1.0/.github/workflows/release.yml +65 -0
  8. zae_limiter-0.1.0/.gitignore +94 -0
  9. zae_limiter-0.1.0/.python-version +1 -0
  10. zae_limiter-0.1.0/CLAUDE.md +365 -0
  11. zae_limiter-0.1.0/LICENSE +21 -0
  12. zae_limiter-0.1.0/PKG-INFO +470 -0
  13. zae_limiter-0.1.0/README.md +413 -0
  14. zae_limiter-0.1.0/cliff.toml +71 -0
  15. zae_limiter-0.1.0/environment.yml +9 -0
  16. zae_limiter-0.1.0/examples/basic_rate_limiting.py +120 -0
  17. zae_limiter-0.1.0/examples/hierarchical_limits.py +196 -0
  18. zae_limiter-0.1.0/examples/llm_token_reconciliation.py +169 -0
  19. zae_limiter-0.1.0/pyproject.toml +82 -0
  20. zae_limiter-0.1.0/src/zae_limiter/__init__.py +130 -0
  21. zae_limiter-0.1.0/src/zae_limiter/aggregator/__init__.py +11 -0
  22. zae_limiter-0.1.0/src/zae_limiter/aggregator/handler.py +54 -0
  23. zae_limiter-0.1.0/src/zae_limiter/aggregator/processor.py +270 -0
  24. zae_limiter-0.1.0/src/zae_limiter/bucket.py +291 -0
  25. zae_limiter-0.1.0/src/zae_limiter/cli.py +608 -0
  26. zae_limiter-0.1.0/src/zae_limiter/exceptions.py +214 -0
  27. zae_limiter-0.1.0/src/zae_limiter/infra/__init__.py +10 -0
  28. zae_limiter-0.1.0/src/zae_limiter/infra/cfn_template.yaml +255 -0
  29. zae_limiter-0.1.0/src/zae_limiter/infra/lambda_builder.py +85 -0
  30. zae_limiter-0.1.0/src/zae_limiter/infra/stack_manager.py +536 -0
  31. zae_limiter-0.1.0/src/zae_limiter/lease.py +196 -0
  32. zae_limiter-0.1.0/src/zae_limiter/limiter.py +925 -0
  33. zae_limiter-0.1.0/src/zae_limiter/migrations/__init__.py +114 -0
  34. zae_limiter-0.1.0/src/zae_limiter/migrations/v1_0_0.py +55 -0
  35. zae_limiter-0.1.0/src/zae_limiter/models.py +302 -0
  36. zae_limiter-0.1.0/src/zae_limiter/repository.py +656 -0
  37. zae_limiter-0.1.0/src/zae_limiter/schema.py +163 -0
  38. zae_limiter-0.1.0/src/zae_limiter/version.py +214 -0
  39. zae_limiter-0.1.0/tests/__init__.py +1 -0
  40. zae_limiter-0.1.0/tests/conftest.py +83 -0
  41. zae_limiter-0.1.0/tests/test_bucket.py +226 -0
  42. zae_limiter-0.1.0/tests/test_cli.py +461 -0
  43. zae_limiter-0.1.0/tests/test_lambda_builder.py +340 -0
  44. zae_limiter-0.1.0/tests/test_limiter.py +435 -0
  45. zae_limiter-0.1.0/tests/test_models.py +113 -0
  46. zae_limiter-0.1.0/tests/test_stack_manager.py +163 -0
  47. zae_limiter-0.1.0/tests/test_sync_limiter.py +75 -0
  48. zae_limiter-0.1.0/tests/test_version.py +224 -0
  49. zae_limiter-0.1.0/uv.lock +2142 -0
@@ -0,0 +1,18 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "pip"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ groups:
8
+ dev-dependencies:
9
+ patterns:
10
+ - "pytest*"
11
+ - "ruff"
12
+ - "mypy"
13
+ - "moto*"
14
+
15
+ - package-ecosystem: "github-actions"
16
+ directory: "/"
17
+ schedule:
18
+ interval: "weekly"
@@ -0,0 +1,55 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v6
14
+ - uses: astral-sh/setup-uv@v7
15
+ - name: Set up Python
16
+ run: uv python install 3.12
17
+ - name: Install dependencies
18
+ run: uv sync --extra dev
19
+ - name: Lint with ruff
20
+ run: uv run ruff check .
21
+ - name: Check formatting
22
+ run: uv run ruff format --check .
23
+
24
+ typecheck:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v6
28
+ - uses: astral-sh/setup-uv@v7
29
+ - name: Set up Python
30
+ run: uv python install 3.12
31
+ - name: Install dependencies
32
+ run: uv sync --extra dev
33
+ - name: Type check with mypy
34
+ run: uv run mypy src/zae_limiter
35
+
36
+ test:
37
+ runs-on: ubuntu-latest
38
+ strategy:
39
+ matrix:
40
+ python-version: ["3.11", "3.12"]
41
+ steps:
42
+ - uses: actions/checkout@v6
43
+ - uses: astral-sh/setup-uv@v7
44
+ - name: Set up Python ${{ matrix.python-version }}
45
+ run: uv python install ${{ matrix.python-version }}
46
+ - name: Install dependencies
47
+ run: uv sync --extra dev
48
+ - name: Run tests
49
+ run: uv run pytest --cov=zae_limiter --cov-report=xml
50
+ - name: Upload coverage
51
+ uses: codecov/codecov-action@v5
52
+ if: matrix.python-version == '3.12'
53
+ with:
54
+ files: coverage.xml
55
+ fail_ci_if_error: false
@@ -0,0 +1,44 @@
1
+ name: Claude Code Review
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, ready_for_review, reopened]
6
+ # Optional: Only run on specific file changes
7
+ # paths:
8
+ # - "src/**/*.ts"
9
+ # - "src/**/*.tsx"
10
+ # - "src/**/*.js"
11
+ # - "src/**/*.jsx"
12
+
13
+ jobs:
14
+ claude-review:
15
+ # Optional: Filter by PR author
16
+ # if: |
17
+ # github.event.pull_request.user.login == 'external-contributor' ||
18
+ # github.event.pull_request.user.login == 'new-developer' ||
19
+ # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20
+
21
+ runs-on: ubuntu-latest
22
+ permissions:
23
+ contents: read
24
+ pull-requests: read
25
+ issues: read
26
+ id-token: write
27
+
28
+ steps:
29
+ - name: Checkout repository
30
+ uses: actions/checkout@v6
31
+ with:
32
+ fetch-depth: 1
33
+
34
+ - name: Run Claude Code Review
35
+ id: claude-review
36
+ uses: anthropics/claude-code-action@v1
37
+ with:
38
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
39
+ plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
40
+ plugins: 'code-review@claude-code-plugins'
41
+ prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
42
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
43
+ # or https://code.claude.com/docs/en/cli-reference for available options
44
+
@@ -0,0 +1,40 @@
1
+ name: Claude Infrastructure Review
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, ready_for_review]
6
+ paths:
7
+ - 'src/zae_limiter/infra/**'
8
+ - 'src/zae_limiter/aggregator/**'
9
+ - 'src/zae_limiter/migrations/**'
10
+ - 'src/zae_limiter/version.py'
11
+ - 'src/zae_limiter/schema.py'
12
+
13
+ jobs:
14
+ claude-infra-review:
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ contents: read
18
+ pull-requests: read
19
+ issues: read
20
+ id-token: write
21
+
22
+ steps:
23
+ - name: Checkout repository
24
+ uses: actions/checkout@v6
25
+ with:
26
+ fetch-depth: 1
27
+
28
+ - name: Run Claude Infrastructure Review
29
+ uses: anthropics/claude-code-action@v1
30
+ with:
31
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
32
+ prompt: |
33
+ Review this PR focusing on infrastructure changes:
34
+ 1. CloudFormation template validity and security
35
+ 2. Lambda code correctness
36
+ 3. Schema migration safety
37
+ 4. Version compatibility
38
+ 5. DynamoDB access pattern correctness
39
+
40
+ Be specific about issues found. Reference file:line numbers.
@@ -0,0 +1,36 @@
1
+ name: Claude Test Coverage Review
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, ready_for_review]
6
+ paths:
7
+ - 'src/zae_limiter/**'
8
+ - '!src/zae_limiter/infra/**'
9
+
10
+ jobs:
11
+ claude-test-review:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ pull-requests: read
16
+ issues: read
17
+ id-token: write
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v6
22
+ with:
23
+ fetch-depth: 1
24
+
25
+ - name: Run Claude Test Review
26
+ uses: anthropics/claude-code-action@v1
27
+ with:
28
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
29
+ prompt: |
30
+ Review this PR focusing on test coverage:
31
+ 1. Check if changed src/ files have corresponding tests
32
+ 2. Identify missing edge case tests
33
+ 3. Verify async/sync test parity
34
+ 4. Suggest specific test cases to add
35
+
36
+ For each missing test, provide a concrete example.
@@ -0,0 +1,50 @@
1
+ name: Claude Code
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+ pull_request_review_comment:
7
+ types: [created]
8
+ issues:
9
+ types: [opened, assigned]
10
+ pull_request_review:
11
+ types: [submitted]
12
+
13
+ jobs:
14
+ claude:
15
+ if: |
16
+ (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17
+ (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18
+ (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19
+ (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20
+ runs-on: ubuntu-latest
21
+ permissions:
22
+ contents: read
23
+ pull-requests: read
24
+ issues: read
25
+ id-token: write
26
+ actions: read # Required for Claude to read CI results on PRs
27
+ steps:
28
+ - name: Checkout repository
29
+ uses: actions/checkout@v6
30
+ with:
31
+ fetch-depth: 1
32
+
33
+ - name: Run Claude Code
34
+ id: claude
35
+ uses: anthropics/claude-code-action@v1
36
+ with:
37
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38
+
39
+ # This is an optional setting that allows Claude to read CI results on PRs
40
+ additional_permissions: |
41
+ actions: read
42
+
43
+ # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
44
+ # prompt: 'Update the pull request description to include a summary of changes.'
45
+
46
+ # Optional: Add claude_args to customize behavior and configuration
47
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
48
+ # or https://code.claude.com/docs/en/cli-reference for available options
49
+ # claude_args: '--allowed-tools Bash(gh pr:*)'
50
+
@@ -0,0 +1,65 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v6
13
+ - uses: astral-sh/setup-uv@v7
14
+ - name: Set up Python
15
+ run: uv python install 3.12
16
+ - name: Build package
17
+ run: uv build
18
+ - name: Upload artifacts
19
+ uses: actions/upload-artifact@v6
20
+ with:
21
+ name: dist
22
+ path: dist/
23
+
24
+ publish:
25
+ needs: build
26
+ runs-on: ubuntu-latest
27
+ environment: pypi
28
+ permissions:
29
+ id-token: write
30
+ steps:
31
+ - uses: actions/download-artifact@v7
32
+ with:
33
+ name: dist
34
+ path: dist/
35
+ - name: Publish to PyPI
36
+ uses: pypa/gh-action-pypi-publish@release/v1
37
+
38
+ release:
39
+ needs: build
40
+ runs-on: ubuntu-latest
41
+ permissions:
42
+ contents: write
43
+ steps:
44
+ - uses: actions/checkout@v6
45
+ with:
46
+ fetch-depth: 0
47
+ - uses: actions/download-artifact@v7
48
+ with:
49
+ name: dist
50
+ path: dist/
51
+ - name: Generate changelog
52
+ uses: orhun/git-cliff-action@v4
53
+ with:
54
+ config: cliff.toml
55
+ args: --latest --strip header
56
+ env:
57
+ OUTPUT: CHANGELOG.md
58
+ - name: Create GitHub Release
59
+ env:
60
+ GH_TOKEN: ${{ github.token }}
61
+ run: |
62
+ gh release create ${{ github.ref_name }} \
63
+ --title "Release ${{ github.ref_name }}" \
64
+ --notes-file CHANGELOG.md \
65
+ dist/*
@@ -0,0 +1,94 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # PyInstaller
28
+ *.manifest
29
+ *.spec
30
+
31
+ # Installer logs
32
+ pip-log.txt
33
+ pip-delete-this-directory.txt
34
+
35
+ # Unit test / coverage reports
36
+ htmlcov/
37
+ .tox/
38
+ .nox/
39
+ .coverage
40
+ .coverage.*
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+ *.cover
45
+ *.py,cover
46
+ .hypothesis/
47
+ .pytest_cache/
48
+
49
+ # Translations
50
+ *.mo
51
+ *.pot
52
+
53
+ # Environments
54
+ .env
55
+ .venv
56
+ env/
57
+ venv/
58
+ ENV/
59
+ env.bak/
60
+ venv.bak/
61
+ .conda/
62
+
63
+ # IDEs
64
+ .idea/
65
+ .vscode/
66
+ *.swp
67
+ *.swo
68
+ *~
69
+
70
+ # mypy
71
+ .mypy_cache/
72
+ .dmypy.json
73
+ dmypy.json
74
+
75
+ # ruff
76
+ .ruff_cache/
77
+
78
+ # Jupyter
79
+ .ipynb_checkpoints/
80
+
81
+ # Local development
82
+ *.local
83
+ .env.local
84
+
85
+ # Lambda packaging
86
+ lambda_package/
87
+ *.zip
88
+
89
+ # OS files
90
+ .DS_Store
91
+ Thumbs.db
92
+
93
+ # Claude Code
94
+ .claude/settings.local.json
@@ -0,0 +1 @@
1
+ 3.12