sonnet-server 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 (183) hide show
  1. sonnet_server-0.1.0/.github/workflows/ci.yml +116 -0
  2. sonnet_server-0.1.0/.github/workflows/publish.yml +82 -0
  3. sonnet_server-0.1.0/.gitignore +49 -0
  4. sonnet_server-0.1.0/.pre-commit-config.yaml +17 -0
  5. sonnet_server-0.1.0/LICENSE.md +190 -0
  6. sonnet_server-0.1.0/PKG-INFO +154 -0
  7. sonnet_server-0.1.0/README.md +101 -0
  8. sonnet_server-0.1.0/Taskfile.yml +89 -0
  9. sonnet_server-0.1.0/docs/design/api-guards.md +214 -0
  10. sonnet_server-0.1.0/docs/design/crud-repository.md +292 -0
  11. sonnet_server-0.1.0/docs/design/database-session-management.md +260 -0
  12. sonnet_server-0.1.0/docs/design/filtering-framework.md +714 -0
  13. sonnet_server-0.1.0/docs/design/list-api.md +351 -0
  14. sonnet_server-0.1.0/docs/design/managed-cache.md +1145 -0
  15. sonnet_server-0.1.0/docs/design/message-router.md +568 -0
  16. sonnet_server-0.1.0/docs/design/readiness-pipeline.md +195 -0
  17. sonnet_server-0.1.0/pyproject.toml +130 -0
  18. sonnet_server-0.1.0/setup.cfg +4 -0
  19. sonnet_server-0.1.0/src/sonnet_server/__init__.py +5 -0
  20. sonnet_server-0.1.0/src/sonnet_server/api/__init__.py +1 -0
  21. sonnet_server-0.1.0/src/sonnet_server/api/dependencies.py +88 -0
  22. sonnet_server-0.1.0/src/sonnet_server/api/error_utils.py +16 -0
  23. sonnet_server-0.1.0/src/sonnet_server/api/extensions.py +64 -0
  24. sonnet_server-0.1.0/src/sonnet_server/api/health_check.py +107 -0
  25. sonnet_server-0.1.0/src/sonnet_server/api/list_params.py +341 -0
  26. sonnet_server-0.1.0/src/sonnet_server/api/ping.py +26 -0
  27. sonnet_server-0.1.0/src/sonnet_server/api/version.py +18 -0
  28. sonnet_server-0.1.0/src/sonnet_server/cache/__init__.py +22 -0
  29. sonnet_server-0.1.0/src/sonnet_server/cache/api.py +195 -0
  30. sonnet_server-0.1.0/src/sonnet_server/cache/backends/__init__.py +130 -0
  31. sonnet_server-0.1.0/src/sonnet_server/cache/backends/distributed.py +173 -0
  32. sonnet_server-0.1.0/src/sonnet_server/cache/backends/local.py +87 -0
  33. sonnet_server-0.1.0/src/sonnet_server/cache/backends/near_cache.py +127 -0
  34. sonnet_server-0.1.0/src/sonnet_server/cache/cache.py +352 -0
  35. sonnet_server-0.1.0/src/sonnet_server/cache/config.py +101 -0
  36. sonnet_server-0.1.0/src/sonnet_server/cache/events.py +38 -0
  37. sonnet_server-0.1.0/src/sonnet_server/cache/extension.py +43 -0
  38. sonnet_server-0.1.0/src/sonnet_server/cache/listeners.py +37 -0
  39. sonnet_server-0.1.0/src/sonnet_server/cache/registry.py +209 -0
  40. sonnet_server-0.1.0/src/sonnet_server/cache/serialization.py +60 -0
  41. sonnet_server-0.1.0/src/sonnet_server/checks/__init__.py +52 -0
  42. sonnet_server-0.1.0/src/sonnet_server/checks/cache_store_check.py +100 -0
  43. sonnet_server-0.1.0/src/sonnet_server/checks/database_health_check.py +82 -0
  44. sonnet_server-0.1.0/src/sonnet_server/checks/database_initialization.py +54 -0
  45. sonnet_server-0.1.0/src/sonnet_server/checks/database_schema_check.py +54 -0
  46. sonnet_server-0.1.0/src/sonnet_server/checks/messaging_check.py +76 -0
  47. sonnet_server-0.1.0/src/sonnet_server/checks/pipeline_builders.py +69 -0
  48. sonnet_server-0.1.0/src/sonnet_server/checks/stages.py +22 -0
  49. sonnet_server-0.1.0/src/sonnet_server/cli/__init__.py +8 -0
  50. sonnet_server-0.1.0/src/sonnet_server/cli/__main__.py +38 -0
  51. sonnet_server-0.1.0/src/sonnet_server/cli/app.py +25 -0
  52. sonnet_server-0.1.0/src/sonnet_server/cli/checks/__init__.py +1 -0
  53. sonnet_server-0.1.0/src/sonnet_server/cli/checks/pipeline_builders.py +78 -0
  54. sonnet_server-0.1.0/src/sonnet_server/cli/checks/runner.py +43 -0
  55. sonnet_server-0.1.0/src/sonnet_server/cli/commands/__init__.py +5 -0
  56. sonnet_server-0.1.0/src/sonnet_server/cli/commands/db.py +108 -0
  57. sonnet_server-0.1.0/src/sonnet_server/cli/utils.py +51 -0
  58. sonnet_server-0.1.0/src/sonnet_server/constants.py +14 -0
  59. sonnet_server-0.1.0/src/sonnet_server/database/__init__.py +38 -0
  60. sonnet_server-0.1.0/src/sonnet_server/database/advisory_lock.py +116 -0
  61. sonnet_server-0.1.0/src/sonnet_server/database/alembic_utils.py +245 -0
  62. sonnet_server-0.1.0/src/sonnet_server/database/connection.py +260 -0
  63. sonnet_server-0.1.0/src/sonnet_server/database/crud/__init__.py +11 -0
  64. sonnet_server-0.1.0/src/sonnet_server/database/crud/config.py +124 -0
  65. sonnet_server-0.1.0/src/sonnet_server/database/crud/repository.py +567 -0
  66. sonnet_server-0.1.0/src/sonnet_server/database/extension.py +43 -0
  67. sonnet_server-0.1.0/src/sonnet_server/database/filtering/__init__.py +21 -0
  68. sonnet_server-0.1.0/src/sonnet_server/database/filtering/compiler.py +373 -0
  69. sonnet_server-0.1.0/src/sonnet_server/exception_handlers.py +153 -0
  70. sonnet_server-0.1.0/src/sonnet_server/exceptions.py +113 -0
  71. sonnet_server-0.1.0/src/sonnet_server/extensions.py +211 -0
  72. sonnet_server-0.1.0/src/sonnet_server/graphql/__init__.py +23 -0
  73. sonnet_server-0.1.0/src/sonnet_server/graphql/context.py +47 -0
  74. sonnet_server-0.1.0/src/sonnet_server/guards.py +317 -0
  75. sonnet_server-0.1.0/src/sonnet_server/home/index.html +155 -0
  76. sonnet_server-0.1.0/src/sonnet_server/logging.py +135 -0
  77. sonnet_server-0.1.0/src/sonnet_server/messaging/__init__.py +90 -0
  78. sonnet_server-0.1.0/src/sonnet_server/messaging/api.py +171 -0
  79. sonnet_server-0.1.0/src/sonnet_server/messaging/channels/__init__.py +14 -0
  80. sonnet_server-0.1.0/src/sonnet_server/messaging/channels/broker.py +210 -0
  81. sonnet_server-0.1.0/src/sonnet_server/messaging/channels/in_process.py +164 -0
  82. sonnet_server-0.1.0/src/sonnet_server/messaging/channels/nats.py +295 -0
  83. sonnet_server-0.1.0/src/sonnet_server/messaging/channels/postgres.py +266 -0
  84. sonnet_server-0.1.0/src/sonnet_server/messaging/events.py +18 -0
  85. sonnet_server-0.1.0/src/sonnet_server/messaging/extension.py +54 -0
  86. sonnet_server-0.1.0/src/sonnet_server/messaging/listeners.py +18 -0
  87. sonnet_server-0.1.0/src/sonnet_server/messaging/router.py +453 -0
  88. sonnet_server-0.1.0/src/sonnet_server/messaging/types.py +736 -0
  89. sonnet_server-0.1.0/src/sonnet_server/messaging/wiring.py +96 -0
  90. sonnet_server-0.1.0/src/sonnet_server/models/page_result.py +69 -0
  91. sonnet_server-0.1.0/src/sonnet_server/profile.py +117 -0
  92. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/__init__.py +51 -0
  93. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/base.py +138 -0
  94. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/builder.py +163 -0
  95. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/calculator.py +146 -0
  96. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/check_executor.py +119 -0
  97. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/enums.py +29 -0
  98. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/executor.py +147 -0
  99. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/models.py +68 -0
  100. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/pipeline.py +231 -0
  101. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/processor.py +164 -0
  102. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/registry.py +275 -0
  103. sonnet_server-0.1.0/src/sonnet_server/readiness_pipeline/stage.py +283 -0
  104. sonnet_server-0.1.0/src/sonnet_server/services/__init__.py +1 -0
  105. sonnet_server-0.1.0/src/sonnet_server/services/di.py +31 -0
  106. sonnet_server-0.1.0/src/sonnet_server/services/health_check_service.py +162 -0
  107. sonnet_server-0.1.0/src/sonnet_server/services/registry.py +71 -0
  108. sonnet_server-0.1.0/src/sonnet_server/settings.py +200 -0
  109. sonnet_server-0.1.0/src/sonnet_server/state.py +107 -0
  110. sonnet_server-0.1.0/src/sonnet_server/utils/__init__.py +6 -0
  111. sonnet_server-0.1.0/src/sonnet_server/utils/file_utils.py +62 -0
  112. sonnet_server-0.1.0/src/sonnet_server/utils/filtering/__init__.py +49 -0
  113. sonnet_server-0.1.0/src/sonnet_server/utils/filtering/db_model_walker.py +324 -0
  114. sonnet_server-0.1.0/src/sonnet_server/utils/filtering/filter_defs.py +143 -0
  115. sonnet_server-0.1.0/src/sonnet_server/utils/filtering/parser.py +153 -0
  116. sonnet_server-0.1.0/src/sonnet_server/utils/filtering/schema_walker.py +390 -0
  117. sonnet_server-0.1.0/src/sonnet_server/utils/filtering/types.py +98 -0
  118. sonnet_server-0.1.0/src/sonnet_server/utils/filtering/value_parsers.py +92 -0
  119. sonnet_server-0.1.0/src/sonnet_server/utils/graphql.py +101 -0
  120. sonnet_server-0.1.0/src/sonnet_server/utils/id_generator.py +53 -0
  121. sonnet_server-0.1.0/src/sonnet_server/utils/json_schema.py +191 -0
  122. sonnet_server-0.1.0/src/sonnet_server/utils/model_builder.py +353 -0
  123. sonnet_server-0.1.0/src/sonnet_server/utils/model_converter.py +190 -0
  124. sonnet_server-0.1.0/src/sonnet_server/utils/schema_utils.py +82 -0
  125. sonnet_server-0.1.0/src/sonnet_server/utils/version.py +76 -0
  126. sonnet_server-0.1.0/src/sonnet_server/utils/version_sort.py +138 -0
  127. sonnet_server-0.1.0/src/sonnet_server.egg-info/PKG-INFO +154 -0
  128. sonnet_server-0.1.0/src/sonnet_server.egg-info/SOURCES.txt +181 -0
  129. sonnet_server-0.1.0/src/sonnet_server.egg-info/dependency_links.txt +1 -0
  130. sonnet_server-0.1.0/src/sonnet_server.egg-info/requires.txt +45 -0
  131. sonnet_server-0.1.0/src/sonnet_server.egg-info/top_level.txt +1 -0
  132. sonnet_server-0.1.0/tests/__init__.py +1 -0
  133. sonnet_server-0.1.0/tests/conftest.py +36 -0
  134. sonnet_server-0.1.0/tests/integration/__init__.py +0 -0
  135. sonnet_server-0.1.0/tests/integration/cache/__init__.py +0 -0
  136. sonnet_server-0.1.0/tests/integration/cache/conftest.py +58 -0
  137. sonnet_server-0.1.0/tests/integration/cache/test_distributed_backend.py +152 -0
  138. sonnet_server-0.1.0/tests/integration/conftest.py +1 -0
  139. sonnet_server-0.1.0/tests/integration/database/__init__.py +0 -0
  140. sonnet_server-0.1.0/tests/integration/database/conftest.py +60 -0
  141. sonnet_server-0.1.0/tests/integration/database/test_crud_repository.py +535 -0
  142. sonnet_server-0.1.0/tests/unit/__init__.py +0 -0
  143. sonnet_server-0.1.0/tests/unit/cache/__init__.py +0 -0
  144. sonnet_server-0.1.0/tests/unit/cache/test_distributed_backend.py +320 -0
  145. sonnet_server-0.1.0/tests/unit/cache/test_local_backend.py +115 -0
  146. sonnet_server-0.1.0/tests/unit/cache/test_managed_cache.py +238 -0
  147. sonnet_server-0.1.0/tests/unit/cache/test_registry.py +209 -0
  148. sonnet_server-0.1.0/tests/unit/filtering/__init__.py +0 -0
  149. sonnet_server-0.1.0/tests/unit/filtering/test_compiler.py +441 -0
  150. sonnet_server-0.1.0/tests/unit/filtering/test_db_model_walker.py +474 -0
  151. sonnet_server-0.1.0/tests/unit/filtering/test_list_params.py +90 -0
  152. sonnet_server-0.1.0/tests/unit/filtering/test_parser.py +166 -0
  153. sonnet_server-0.1.0/tests/unit/filtering/test_schema_walker.py +443 -0
  154. sonnet_server-0.1.0/tests/unit/filtering/test_typed_compiler.py +393 -0
  155. sonnet_server-0.1.0/tests/unit/filtering/test_types.py +215 -0
  156. sonnet_server-0.1.0/tests/unit/filtering/test_value_parsers.py +90 -0
  157. sonnet_server-0.1.0/tests/unit/graphql/__init__.py +0 -0
  158. sonnet_server-0.1.0/tests/unit/graphql/test_context.py +83 -0
  159. sonnet_server-0.1.0/tests/unit/messaging/__init__.py +0 -0
  160. sonnet_server-0.1.0/tests/unit/messaging/test_in_process_channel.py +280 -0
  161. sonnet_server-0.1.0/tests/unit/messaging/test_nats_channel.py +449 -0
  162. sonnet_server-0.1.0/tests/unit/messaging/test_pg_channel.py +328 -0
  163. sonnet_server-0.1.0/tests/unit/messaging/test_router.py +568 -0
  164. sonnet_server-0.1.0/tests/unit/messaging/test_type_registry.py +586 -0
  165. sonnet_server-0.1.0/tests/unit/readiness_pipeline/__init__.py +1 -0
  166. sonnet_server-0.1.0/tests/unit/readiness_pipeline/test_base.py +190 -0
  167. sonnet_server-0.1.0/tests/unit/readiness_pipeline/test_check_executor.py +161 -0
  168. sonnet_server-0.1.0/tests/unit/readiness_pipeline/test_pipeline.py +219 -0
  169. sonnet_server-0.1.0/tests/unit/readiness_pipeline/test_registry.py +322 -0
  170. sonnet_server-0.1.0/tests/unit/readiness_pipeline/test_stage.py +246 -0
  171. sonnet_server-0.1.0/tests/unit/services/__init__.py +0 -0
  172. sonnet_server-0.1.0/tests/unit/services/test_registry.py +100 -0
  173. sonnet_server-0.1.0/tests/unit/test_exceptions.py +34 -0
  174. sonnet_server-0.1.0/tests/unit/test_settings.py +119 -0
  175. sonnet_server-0.1.0/tests/unit/test_unique_violation_extractor.py +56 -0
  176. sonnet_server-0.1.0/tests/unit/utils/__init__.py +1 -0
  177. sonnet_server-0.1.0/tests/unit/utils/test_id_generator.py +101 -0
  178. sonnet_server-0.1.0/tests/unit/utils/test_json_schema.py +366 -0
  179. sonnet_server-0.1.0/tests/unit/utils/test_model_builder.py +571 -0
  180. sonnet_server-0.1.0/tests/unit/utils/test_model_converter.py +335 -0
  181. sonnet_server-0.1.0/tests/unit/utils/test_version.py +70 -0
  182. sonnet_server-0.1.0/tests/unit/utils/test_version_sort.py +280 -0
  183. sonnet_server-0.1.0/uv.lock +1323 -0
@@ -0,0 +1,116 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - 'src/**'
9
+ - 'tests/**'
10
+ - 'pyproject.toml'
11
+ - '.github/workflows/ci.yml'
12
+ - '!**/*.md'
13
+ pull_request:
14
+ branches:
15
+ - main
16
+ paths:
17
+ - 'src/**'
18
+ - 'tests/**'
19
+ - 'pyproject.toml'
20
+ - '.github/workflows/ci.yml'
21
+ - '!**/*.md'
22
+ workflow_dispatch:
23
+
24
+ permissions:
25
+ contents: read
26
+ pull-requests: read
27
+ checks: write
28
+
29
+ jobs:
30
+ test:
31
+ name: Lint and Test
32
+ runs-on: ubuntu-latest
33
+ timeout-minutes: 30
34
+ strategy:
35
+ matrix:
36
+ python-version: ['3.14']
37
+
38
+ steps:
39
+ - name: Checkout repository
40
+ uses: actions/checkout@v4
41
+ with:
42
+ fetch-depth: 0
43
+
44
+ - name: Set up Python ${{ matrix.python-version }}
45
+ uses: actions/setup-python@v5
46
+ with:
47
+ python-version: ${{ matrix.python-version }}
48
+
49
+ - name: Install uv
50
+ uses: astral-sh/setup-uv@v3
51
+ with:
52
+ version: "latest"
53
+ enable-cache: true
54
+
55
+ - name: Ensure uv cache directory exists
56
+ run: mkdir -p ~/.cache/uv
57
+
58
+ - name: Cache uv packages
59
+ uses: actions/cache@v4
60
+ with:
61
+ path: ~/.cache/uv
62
+ key: ${{ runner.os }}-uv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
63
+ restore-keys: |
64
+ ${{ runner.os }}-uv-${{ matrix.python-version }}-
65
+
66
+ - name: Install system dependencies
67
+ run: |
68
+ sudo apt-get update
69
+ sudo apt-get install -y --no-install-recommends \
70
+ build-essential \
71
+ libpq-dev
72
+
73
+ - name: Install dependencies
74
+ run: |
75
+ uv lock
76
+ uv sync --python ${{ matrix.python-version }} --extra dev
77
+
78
+ - name: Lint code
79
+ run: .venv/bin/ruff check src tests
80
+
81
+ - name: Check formatting
82
+ run: .venv/bin/ruff format --check src tests
83
+
84
+ - name: Run unit tests
85
+ run: .venv/bin/pytest -x -m unit
86
+
87
+ build:
88
+ name: Build Package
89
+ runs-on: ubuntu-latest
90
+ timeout-minutes: 20
91
+ needs: test
92
+
93
+ steps:
94
+ - name: Checkout repository
95
+ uses: actions/checkout@v4
96
+
97
+ - name: Set up Python 3.14
98
+ uses: actions/setup-python@v5
99
+ with:
100
+ python-version: '3.14'
101
+
102
+ - name: Install uv
103
+ uses: astral-sh/setup-uv@v3
104
+ with:
105
+ version: "latest"
106
+ enable-cache: true
107
+
108
+ - name: Build package
109
+ run: uv build
110
+
111
+ - name: Upload build artifacts
112
+ uses: actions/upload-artifact@v4
113
+ with:
114
+ name: dist-${{ github.sha }}
115
+ path: dist/
116
+ retention-days: 7
@@ -0,0 +1,82 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write # Required for trusted publishing (OIDC)
11
+
12
+ jobs:
13
+ test:
14
+ name: Lint and Test
15
+ runs-on: ubuntu-latest
16
+ timeout-minutes: 30
17
+
18
+ steps:
19
+ - name: Checkout repository
20
+ uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ - name: Set up Python 3.14
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: '3.14'
28
+
29
+ - name: Install uv
30
+ uses: astral-sh/setup-uv@v3
31
+ with:
32
+ version: "latest"
33
+ enable-cache: true
34
+
35
+ - name: Install system dependencies
36
+ run: |
37
+ sudo apt-get update
38
+ sudo apt-get install -y --no-install-recommends build-essential libpq-dev
39
+
40
+ - name: Install dependencies
41
+ run: |
42
+ uv lock
43
+ uv sync --python 3.14 --extra dev
44
+
45
+ - name: Lint code
46
+ run: .venv/bin/ruff check src tests
47
+
48
+ - name: Check formatting
49
+ run: .venv/bin/ruff format --check src tests
50
+
51
+ - name: Run unit tests
52
+ run: .venv/bin/pytest -x -m unit
53
+
54
+ publish:
55
+ name: Build and Publish
56
+ runs-on: ubuntu-latest
57
+ timeout-minutes: 20
58
+ needs: test
59
+ environment: pypi
60
+
61
+ steps:
62
+ - name: Checkout repository
63
+ uses: actions/checkout@v4
64
+ with:
65
+ fetch-depth: 0 # Required for setuptools-scm
66
+
67
+ - name: Set up Python 3.14
68
+ uses: actions/setup-python@v5
69
+ with:
70
+ python-version: '3.14'
71
+
72
+ - name: Install uv
73
+ uses: astral-sh/setup-uv@v3
74
+ with:
75
+ version: "latest"
76
+ enable-cache: true
77
+
78
+ - name: Build package
79
+ run: uv build
80
+
81
+ - name: Publish to PyPI
82
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,49 @@
1
+ # SCM tool version information, which is generated
2
+
3
+ # Python
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ *.so
8
+ .Python
9
+ build/
10
+ develop-eggs/
11
+ dist/
12
+ downloads/
13
+ eggs/
14
+ .eggs/
15
+ lib/
16
+ lib64/
17
+ parts/
18
+ sdist/
19
+ var/
20
+ wheels/
21
+ *.egg-info/
22
+ .installed.cfg
23
+ *.egg
24
+
25
+ # Environment
26
+ .env
27
+ .venv
28
+ env/
29
+ venv/
30
+ ENV/
31
+
32
+ # Testing
33
+ .coverage
34
+ htmlcov/
35
+ .pytest_cache/
36
+ .tox/
37
+
38
+ # Ruff
39
+ .ruff_cache/
40
+
41
+ # IDE
42
+ .idea/
43
+ .vscode/
44
+ *.swp
45
+ *.swo
46
+
47
+ .env*
48
+ !.env.example
49
+ .DS_Store
@@ -0,0 +1,17 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: fct
5
+ name: "sonnet-server: ruff+pytest (quick)"
6
+ entry: bash -c 'task fct'
7
+ language: system
8
+ pass_filenames: false
9
+ files: \.py$
10
+ always_run: false
11
+
12
+ - id: fct-pre-push
13
+ name: "sonnet-server (pre-push): ruff+pytest full"
14
+ entry: bash -c 'task fct'
15
+ language: system
16
+ pass_filenames: false
17
+ stages: [pre-push]
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 Petrarca Labs (Wolfgang Miller)
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: sonnet-server
3
+ Version: 0.1.0
4
+ Summary: Domain-service foundation for Petrarca Labs backend services
5
+ Author-email: Wolfgang Miller <wolfgang.miller@petrarca-labs.com>
6
+ License-Expression: Apache-2.0
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.14
11
+ Requires-Python: <4.0,>=3.14
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE.md
14
+ Requires-Dist: fastapi>=0.135.1
15
+ Requires-Dist: uvicorn>=0.41.0
16
+ Requires-Dist: typer>=0.24.1
17
+ Requires-Dist: python-dotenv>=1.2.2
18
+ Requires-Dist: loguru>=0.7.3
19
+ Requires-Dist: jinja2>=3.1.6
20
+ Requires-Dist: sqlmodel>=0.0.37
21
+ Requires-Dist: sqlalchemy>=2.0.48
22
+ Requires-Dist: alembic>=1.18.4
23
+ Requires-Dist: tenacity>=9.1.4
24
+ Requires-Dist: pydantic-settings>=2.13.1
25
+ Requires-Dist: arrow>=1.4.0
26
+ Requires-Dist: jsonschema>=4.23.0
27
+ Requires-Dist: cachetools>=7.0.5
28
+ Provides-Extra: filtering
29
+ Requires-Dist: lark>=1.3.1; extra == "filtering"
30
+ Provides-Extra: graphql
31
+ Requires-Dist: strawberry-graphql[fastapi]>=0.308.3; extra == "graphql"
32
+ Provides-Extra: postgres
33
+ Requires-Dist: psycopg>=3.3.3; extra == "postgres"
34
+ Requires-Dist: psycopg-binary>=3.3.3; extra == "postgres"
35
+ Provides-Extra: nats
36
+ Requires-Dist: nats-py>=2.14.0; extra == "nats"
37
+ Provides-Extra: redis
38
+ Requires-Dist: redis[hiredis]>=7.0; extra == "redis"
39
+ Provides-Extra: all
40
+ Requires-Dist: sonnet-server[filtering,graphql,nats,postgres,redis]; extra == "all"
41
+ Provides-Extra: dev
42
+ Requires-Dist: sonnet-server[all]; extra == "dev"
43
+ Requires-Dist: setuptools-scm; extra == "dev"
44
+ Requires-Dist: ruff>=0.3.0; extra == "dev"
45
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
46
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
47
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
48
+ Requires-Dist: pre-commit>=4.3.0; extra == "dev"
49
+ Requires-Dist: fakeredis>=2.0; extra == "dev"
50
+ Requires-Dist: testcontainers[postgres,redis]>=4.0; extra == "dev"
51
+ Requires-Dist: watchfiles>=0.19.0; extra == "dev"
52
+ Dynamic: license-file
53
+
54
+ # Sonnet Server
55
+
56
+ Domain-service foundation for Petrarca backend services. Provides the
57
+ infrastructure layer that every backend service inherits: FastAPI app
58
+ factory, extension-based lifecycle, database connectivity, messaging,
59
+ caching, DI, readiness pipeline, guards, CLI framework, and system
60
+ endpoints.
61
+
62
+ ## What it provides
63
+
64
+ - **Extension protocol** -- opt-in subsystem lifecycle (database, messaging,
65
+ cache, profiles). Infrastructure and profile extensions with conditional
66
+ startup and router mounting.
67
+ - **Database** -- engine management, ambient sessions, CRUD repository,
68
+ Alembic utilities, advisory locks.
69
+ - **Messaging** -- content-based router with pluggable channels (Postgres
70
+ LISTEN/NOTIFY, NATS, in-process), CloudEvents envelope, `@handles`
71
+ decorator.
72
+ - **Cache** -- managed cache with pluggable backends (local, distributed,
73
+ near-cache), cross-process invalidation via messaging.
74
+ - **Readiness pipeline** -- composable health check stages with decorator-based
75
+ auto-discovery.
76
+ - **Guards** -- protocol-based authentication and tenant context validation.
77
+ - **DI** -- type-keyed service registry with factory and singleton patterns.
78
+ - **CLI** -- Typer-based framework with reusable `db check` / `db upgrade`
79
+ commands.
80
+ - **System endpoints** -- `/ping`, `/version`, `/health-check`, plus
81
+ extension-contributed routes (`/messaging`, `/cache`).
82
+
83
+ ## Prerequisites
84
+
85
+ - Python 3.14+
86
+ - [Task](https://taskfile.dev/) (task runner)
87
+ - [uv](https://docs.astral.sh/uv/) (Python package manager)
88
+
89
+ ## Setup
90
+
91
+ ```bash
92
+ task install
93
+ ```
94
+
95
+ ## Development
96
+
97
+ ```bash
98
+ # Format, check, test
99
+ task fct
100
+
101
+ # Individual steps
102
+ task format
103
+ task check
104
+ task test
105
+ ```
106
+
107
+ ## Consumer usage
108
+
109
+ ### Dependency
110
+
111
+ Add to your project's `pyproject.toml`:
112
+
113
+ ```toml
114
+ [project]
115
+ dependencies = [
116
+ "sonnet-server[all]>=0.1.0",
117
+ ]
118
+ ```
119
+
120
+ For local co-development, add an editable source override:
121
+
122
+ ```toml
123
+ [tool.uv.sources]
124
+ sonnet-server = { path = "../../sonnet-server", editable = true }
125
+ ```
126
+
127
+ ### Settings
128
+
129
+ Subclass `Settings` with your own env prefix. Call `init_settings()` at the
130
+ bottom of your settings module to register with sonnet-server:
131
+
132
+ ```python
133
+ # my_app/settings.py
134
+ from functools import lru_cache
135
+ from pydantic_settings import SettingsConfigDict
136
+ from sonnet_server.settings import Settings as SonnetSettings, init_settings
137
+
138
+ class Settings(SonnetSettings):
139
+ model_config = SettingsConfigDict(env_prefix="MY_APP_", ...)
140
+ # project-specific fields here
141
+
142
+ @lru_cache
143
+ def get_settings() -> Settings:
144
+ return Settings()
145
+
146
+ init_settings(get_settings())
147
+ ```
148
+
149
+ All sonnet-server infrastructure (database, messaging, cache, checks) will
150
+ then read from `MY_APP_*` env vars.
151
+
152
+ ## License
153
+
154
+ Apache License 2.0. See [LICENSE.md](LICENSE.md).