PgQueuer 2.1.0__tar.gz → 2.2.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 (325) hide show
  1. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/AGENTS.md +3 -3
  2. {pgqueuer-2.1.0/pgqueuer.egg-info → pgqueuer-2.2.0}/PKG-INFO +2 -4
  3. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/RELEASE.md +143 -19
  4. pgqueuer-2.2.0/docs/adr/ADR-0000-record-each-decision-in-one-short-adr.md +72 -0
  5. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/ADR-0024-sql-is-assembled-by-the-composer.md +9 -6
  6. pgqueuer-2.2.0/docs/adr/ADR-0026-connection-creator-controls-its-lifecycle.md +53 -0
  7. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/README.md +6 -4
  8. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/agent-guide.md +4 -2
  9. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/design/README.md +4 -4
  10. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/design/connection-failures.md +4 -2
  11. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/design/dequeue-composition.md +29 -16
  12. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/design/schema-manifest.md +6 -5
  13. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/design/sql-naming.md +9 -6
  14. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/development/development.md +5 -0
  15. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/getting-started/installation.md +1 -2
  16. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/getting-started/upgrading.md +0 -2
  17. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/deployment.md +10 -5
  18. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/performance-tuning.md +6 -10
  19. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/reliability.md +2 -2
  20. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/index.md +3 -4
  21. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/integrations/tracing.md +40 -13
  22. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/llms.txt +0 -1
  23. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/reference/cli.md +177 -7
  24. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/reference/drivers.md +3 -5
  25. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/reference/ports-and-adapters.md +18 -1
  26. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/reference/skip-locked.md +6 -5
  27. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/mkdocs.yml +0 -1
  28. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/_version.py +3 -3
  29. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/cli/cli.py +246 -69
  30. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/cli/supervisor.py +34 -29
  31. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/drivers/asyncpg.py +79 -31
  32. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/drivers/psycopg.py +13 -11
  33. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/inmemory/jobs.py +33 -6
  34. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/inmemory/queries.py +18 -8
  35. pgqueuer-2.2.0/pgqueuer/adapters/persistence/composer.py +136 -0
  36. pgqueuer-2.2.0/pgqueuer/adapters/persistence/dequeue.py +538 -0
  37. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/persistence/qb.py +78 -429
  38. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/persistence/queries.py +33 -3
  39. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/persistence/schema_inspect.py +19 -0
  40. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/persistence/schema_plan.py +64 -1
  41. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/routes.py +14 -5
  42. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/applications.py +24 -2
  43. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/completion.py +12 -7
  44. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/insights.py +1 -1
  45. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/listeners.py +49 -4
  46. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/qm.py +69 -16
  47. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/sm.py +5 -4
  48. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/schema/declaration.py +17 -1
  49. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/schema/model.py +23 -0
  50. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/settings.py +9 -12
  51. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/metrics/prometheus.py +1 -1
  52. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/ports/repository.py +29 -3
  53. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/ports/tracing.py +19 -2
  54. {pgqueuer-2.1.0 → pgqueuer-2.2.0/pgqueuer.egg-info}/PKG-INFO +2 -4
  55. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer.egg-info/SOURCES.txt +5 -6
  56. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer.egg-info/requires.txt +1 -4
  57. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer.egg-info/scm_file_list.json +5 -6
  58. pgqueuer-2.2.0/pgqueuer.egg-info/scm_version.json +8 -0
  59. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pyproject.toml +82 -6
  60. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/query_shapes/dequeue_both_gates.sql +28 -23
  61. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/query_shapes/dequeue_entrypoint_gate.sql +24 -19
  62. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/query_shapes/dequeue_global_gate.sql +13 -13
  63. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/query_shapes/dequeue_no_gates.sql +9 -9
  64. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_adapter_parity.py +19 -0
  65. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_audit_regressions.py +0 -20
  66. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_cli_reports.py +121 -2
  67. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_cli_run_and_install.py +22 -0
  68. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_cli_run_options.py +8 -0
  69. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_composer.py +65 -42
  70. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_concurrency_limit.py +23 -0
  71. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_dequeue_shapes.py +62 -11
  72. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_driver_remove_listener.py +47 -1
  73. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_drivers.py +5 -5
  74. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_inmemory.py +70 -0
  75. pgqueuer-2.2.0/test/test_listener_healthy_contract.py +170 -0
  76. pgqueuer-2.2.0/test/test_notification_listener.py +98 -0
  77. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_psycopg_notify_resilience.py +25 -0
  78. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_qm.py +20 -3
  79. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_qm_no_stall.py +67 -1
  80. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_query_plan_regression.py +87 -2
  81. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_run.py +17 -11
  82. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_scheduler.py +3 -3
  83. pgqueuer-2.2.0/test/test_schema_inspect.py +180 -0
  84. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_model.py +8 -0
  85. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_settings.py +8 -10
  86. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_superviser.py +23 -16
  87. pgqueuer-2.2.0/test/test_tracing.py +41 -0
  88. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_web_routes.py +30 -0
  89. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/tools/benchmark.py +52 -38
  90. pgqueuer-2.2.0/tools/dequeue_plan.py +205 -0
  91. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/uv.lock +10 -425
  92. pgqueuer-2.1.0/docs/integrations/mcp-server.md +0 -204
  93. pgqueuer-2.1.0/pgqueuer/adapters/mcp/__main__.py +0 -14
  94. pgqueuer-2.1.0/pgqueuer/adapters/mcp/server.py +0 -499
  95. pgqueuer-2.1.0/pgqueuer/adapters/persistence/composer.py +0 -72
  96. pgqueuer-2.1.0/pgqueuer/metrics/__init__.py +0 -1
  97. pgqueuer-2.1.0/pgqueuer.egg-info/scm_version.json +0 -8
  98. pgqueuer-2.1.0/test/test_listener_healthy_contract.py +0 -61
  99. pgqueuer-2.1.0/test/test_mcp_server.py +0 -122
  100. pgqueuer-2.1.0/test/test_mcp_tool_output.py +0 -149
  101. pgqueuer-2.1.0/test/test_schema_inspect.py +0 -87
  102. pgqueuer-2.1.0/test/test_tracing.py +0 -9
  103. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/.github/FUNDING.yml +0 -0
  104. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  105. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  106. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/.github/pull_request_template.md +0 -0
  107. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/.github/workflows/ci.yml +0 -0
  108. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/.github/workflows/docs.yml +0 -0
  109. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/.github/workflows/release.yml +0 -0
  110. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/.gitignore +0 -0
  111. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/CLAUDE.md +0 -0
  112. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/CODE_OF_CONDUCT.md +0 -0
  113. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/CONTRIBUTING.md +0 -0
  114. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/Dockerfile +0 -0
  115. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/LICENSE +0 -0
  116. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/README.md +0 -0
  117. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docker-compose.yml +0 -0
  118. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/ADR-0001-job-state-lives-in-postgresql.md +0 -0
  119. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/ADR-0002-workers-claim-by-lock-contention.md +0 -0
  120. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/ADR-0003-notifications-signal-not-carry.md +0 -0
  121. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/ADR-0004-delivery-is-at-least-once.md +0 -0
  122. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/ADR-0005-worker-liveness-is-application-signal.md +0 -0
  123. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/ADR-0016-schema-upgrades-are-computed-from-the-live-database.md +0 -0
  124. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/adr/ADR-0025-the-schema-contract-is-a-declared-manifest.md +0 -0
  125. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/comparisons/benchmarks.md +0 -0
  126. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/comparisons/celery-comparison.md +0 -0
  127. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/design/schema-upgrade.md +0 -0
  128. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/development/troubleshooting.md +0 -0
  129. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/favicon.svg +0 -0
  130. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/getting-started/core-concepts.md +0 -0
  131. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/getting-started/quickstart.md +0 -0
  132. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/getting-started/when-to-use.md +0 -0
  133. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/completion-tracking.md +0 -0
  134. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/concurrency-control.md +0 -0
  135. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/custom-executors.md +0 -0
  136. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/deferred-execution.md +0 -0
  137. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/docker-images.md +0 -0
  138. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/heartbeat.md +0 -0
  139. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/hold-failed-jobs.md +0 -0
  140. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/job-cancellation.md +0 -0
  141. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/retry.md +0 -0
  142. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/scheduling.md +0 -0
  143. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/guides/shared-resources.md +0 -0
  144. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/integrations/postgrest.md +0 -0
  145. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/integrations/prometheus.md +0 -0
  146. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/integrations/web-dashboard.md +0 -0
  147. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/integrations/web-dashboard.png +0 -0
  148. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/logo.svg +0 -0
  149. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/reference/architecture.md +0 -0
  150. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/reference/database-permissions.md +0 -0
  151. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/reference/database-setup.md +0 -0
  152. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/reference/in-memory.md +0 -0
  153. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/docs/stylesheets/extra.css +0 -0
  154. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/examples/consumer.py +0 -0
  155. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/examples/fastapi_usage.py +0 -0
  156. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/examples/flask_sync_usage.py +0 -0
  157. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/examples/producer.py +0 -0
  158. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/examples/scheduler.py +0 -0
  159. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/__init__.py +0 -0
  160. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/__main__.py +0 -0
  161. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/__init__.py +0 -0
  162. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/cli/__init__.py +0 -0
  163. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/cli/factories.py +0 -0
  164. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/cli/sql_cmd.py +0 -0
  165. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/connections.py +0 -0
  166. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/drivers/__init__.py +0 -0
  167. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/inmemory/__init__.py +0 -0
  168. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/inmemory/driver.py +0 -0
  169. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/inmemory/logs.py +0 -0
  170. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/inmemory/schedules.py +0 -0
  171. {pgqueuer-2.1.0/pgqueuer/adapters/mcp → pgqueuer-2.2.0/pgqueuer/adapters/persistence}/__init__.py +0 -0
  172. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/persistence/query_helpers.py +0 -0
  173. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/persistence/schema_ddl.py +0 -0
  174. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/persistence/sqlstate.py +0 -0
  175. {pgqueuer-2.1.0/pgqueuer/adapters/persistence → pgqueuer-2.2.0/pgqueuer/adapters/tracing}/__init__.py +0 -0
  176. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/tracing/logfire.py +0 -0
  177. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/tracing/opentelemetry.py +0 -0
  178. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/tracing/sentry.py +0 -0
  179. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/__init__.py +0 -0
  180. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/__main__.py +0 -0
  181. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/app.py +0 -0
  182. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/auth.py +0 -0
  183. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/deps.py +0 -0
  184. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/payload.py +0 -0
  185. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/sse.py +0 -0
  186. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/static/htmx.min.js +0 -0
  187. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/static/idiomorph-ext.min.js +0 -0
  188. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/static/sse.js +0 -0
  189. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/static/style.css +0 -0
  190. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/base.html +0 -0
  191. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/entrypoints.html +0 -0
  192. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/failures.html +0 -0
  193. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/job_detail.html +0 -0
  194. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/jobs.html +0 -0
  195. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/overview.html +0 -0
  196. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/partials/entrypoints.html +0 -0
  197. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/partials/failures.html +0 -0
  198. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/partials/jobs_table.html +0 -0
  199. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/partials/overview.html +0 -0
  200. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/partials/workers.html +0 -0
  201. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/schedules.html +0 -0
  202. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/system.html +0 -0
  203. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/adapters/web/templates/workers.html +0 -0
  204. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/applications.py +0 -0
  205. {pgqueuer-2.1.0/pgqueuer/adapters/tracing → pgqueuer-2.2.0/pgqueuer/core}/__init__.py +0 -0
  206. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/buffers.py +0 -0
  207. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/executors.py +0 -0
  208. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/heartbeat.py +0 -0
  209. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/logconfig.py +0 -0
  210. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/core/tm.py +0 -0
  211. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/db.py +0 -0
  212. {pgqueuer-2.1.0/pgqueuer/core → pgqueuer-2.2.0/pgqueuer/domain}/__init__.py +0 -0
  213. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/errors.py +0 -0
  214. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/models.py +0 -0
  215. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/schema/__init__.py +0 -0
  216. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/schema/notify.py +0 -0
  217. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/schema/queue.py +0 -0
  218. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/schema/queue_log.py +0 -0
  219. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/schema/schedules.py +0 -0
  220. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/schema/statistics.py +0 -0
  221. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/domain/types.py +0 -0
  222. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/errors.py +0 -0
  223. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/executors.py +0 -0
  224. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/factories.py +0 -0
  225. {pgqueuer-2.1.0/pgqueuer/domain → pgqueuer-2.2.0/pgqueuer/metrics}/__init__.py +0 -0
  226. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/metrics/fastapi.py +0 -0
  227. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/models.py +0 -0
  228. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/ports/__init__.py +0 -0
  229. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/ports/driver.py +0 -0
  230. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/py.typed +0 -0
  231. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/qm.py +0 -0
  232. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/queries.py +0 -0
  233. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/sm.py +0 -0
  234. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/types.py +0 -0
  235. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer/web.py +0 -0
  236. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer.egg-info/dependency_links.txt +0 -0
  237. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer.egg-info/entry_points.txt +0 -0
  238. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/pgqueuer.egg-info/top_level.txt +0 -0
  239. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/setup.cfg +0 -0
  240. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/__init__.py +0 -0
  241. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/conftest.py +0 -0
  242. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/helpers.py +0 -0
  243. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/integration/test_fastapi.py +0 -0
  244. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/integration/test_flask_sync.py +0 -0
  245. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/integration/test_persistence_queries_sql.py +0 -0
  246. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v0.18.10.sql +0 -0
  247. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v0.19.7.sql +0 -0
  248. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v0.20.1.sql +0 -0
  249. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v0.22.0.sql +0 -0
  250. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v0.24.3.sql +0 -0
  251. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v1.0.2.sql +0 -0
  252. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v1.1.1.sql +0 -0
  253. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v1.3.2.sql +0 -0
  254. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/schema_releases/v1.4.0.sql +0 -0
  255. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_benchmark_grace_period.py +0 -0
  256. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_buffers.py +0 -0
  257. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_cancellation.py +0 -0
  258. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_cli_queue.py +0 -0
  259. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_cli_sql.py +0 -0
  260. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_cli_web.py +0 -0
  261. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_completion.py +0 -0
  262. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_connections.py +0 -0
  263. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_docs_agent_guide.py +0 -0
  264. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_durability.py +0 -0
  265. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_execute_after.py +0 -0
  266. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_executors.py +0 -0
  267. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_factories.py +0 -0
  268. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_factory_supervisor_chain.py +0 -0
  269. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_future_guards.py +0 -0
  270. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_health_check_cancellation.py +0 -0
  271. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_heartbeat.py +0 -0
  272. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_helpers.py +0 -0
  273. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_hold_failed.py +0 -0
  274. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_inmemory_integration.py +0 -0
  275. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_insights_service.py +0 -0
  276. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_issue_536_minimal.py +0 -0
  277. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_listeners.py +0 -0
  278. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_log_statistics_shapes.py +0 -0
  279. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_metrics_prometheus.py +0 -0
  280. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_models.py +0 -0
  281. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_pgqueuer.py +0 -0
  282. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_pgqueuer_run_fail_fast.py +0 -0
  283. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_port_conformance.py +0 -0
  284. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_qb_upgrade_migration.py +0 -0
  285. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_qm_capacity_poll.py +0 -0
  286. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_qm_default_budget.py +0 -0
  287. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_queries.py +0 -0
  288. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_query_helpers.py +0 -0
  289. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_register_entrypoint_validation.py +0 -0
  290. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_retry.py +0 -0
  291. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_retry_requeue.py +0 -0
  292. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_scheduler_heartbeat.py +0 -0
  293. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_converge_script.py +0 -0
  294. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_convergence.py +0 -0
  295. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_id_widen.py +0 -0
  296. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_index_rebuild.py +0 -0
  297. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_plan.py +0 -0
  298. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_render.py +0 -0
  299. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_support.py +0 -0
  300. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_schema_upgrade.py +0 -0
  301. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_sigterm_cancellation.py +0 -0
  302. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_slot_contention.py +0 -0
  303. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_sql_safety.py +0 -0
  304. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_sqlstate.py +0 -0
  305. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_stale_worker_fencing.py +0 -0
  306. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_strict_serialized.py +0 -0
  307. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_sync_queries.py +0 -0
  308. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_tm.py +0 -0
  309. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_traceback_record.py +0 -0
  310. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_tracing_graceful_degradation.py +0 -0
  311. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_tracing_logfire.py +0 -0
  312. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_tracing_opentelemetry.py +0 -0
  313. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_tracing_sentry.py +0 -0
  314. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_tracing_sentry_status.py +0 -0
  315. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_types.py +0 -0
  316. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_uvloop.py +0 -0
  317. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/test_web_integration.py +0 -0
  318. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/windows/test_cli_event_loop_policy.py +0 -0
  319. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/windows/test_psycopg_async_loop.py +0 -0
  320. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/test/windows/test_shutdown.py +0 -0
  321. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/tools/mkdocs_agent_guide.py +0 -0
  322. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/tools/prometheus/Dockerfile +0 -0
  323. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/tools/prometheus/prometheus.py +0 -0
  324. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/tools/web/Dockerfile +0 -0
  325. {pgqueuer-2.1.0 → pgqueuer-2.2.0}/tools/web/docker-compose.yml +0 -0
@@ -152,7 +152,7 @@ When deprecating dataclass fields, use a module-level `_SENTINEL = object()` def
152
152
 
153
153
  ### Dependency Injection
154
154
 
155
- `QueueManager` and `SchedulerManager` accept an optional `queries` argument (default=None). When omitted, they auto-create `Queries(self.connection)`. Prefer injecting a mock for tests.
155
+ `QueueManager` and `SchedulerManager` take a required `queries` argument (a `RepositoryPort`) as the first positional parameter. In tests, inject `InMemoryQueries` or a fake.
156
156
 
157
157
  ## Code Style
158
158
 
@@ -181,7 +181,7 @@ When deprecating dataclass fields, use a module-level `_SENTINEL = object()` def
181
181
  - **Exhaustive dispatch.** When branching on a `Literal` or `Enum` value, handle every member in an explicit `if`/`elif` chain and terminate with `else: assert_never(value)` (`typing.assert_never`) so mypy proves totality. No bare fallthroughs, no catch-all `else` doing real work — adding a new member must produce a type error at every dispatch site.
182
182
  - Use `Protocol` for structural subtyping (port interfaces)
183
183
  - Use `TypeAlias` for complex callable types
184
- - **`Any` is banned in `pgqueuer/`, `tools/` and `examples/`** (`disallow_any_explicit`). Use `object` and narrow with `isinstance`. Driver `*args` are `object`; rows come back as `dict[str, object]` and scalars are read through `query_helpers.cell(row, key, kind)`, multi-column rows through a pydantic model. User-owned bags (`Context.resources`) are `MutableMapping[str, object]`. `Callable[..., X]` counts as `Any`; declare a `Protocol` with `__call__(self, *args: object)` instead. Untyped third-party values are assigned to an `object`-annotated name before an `isinstance` check. Test code under `test/` may use `Any`.
184
+ - **`Any` is banned in `pgqueuer/`, `tools/` and `examples/`** (`disallow_any_explicit`). Use `object` and narrow with `isinstance`. Driver `*args` are `object`; rows come back as `dict[str, object]` and scalars are read through `query_helpers.cell(row, key, kind)`, multi-column rows through a pydantic model. User-owned bags (`Context.resources`) are `MutableMapping[str, object]`. `Callable[..., X]` counts as `Any`; declare a `Protocol` with `__call__(self, *args: object)` instead. Untyped third-party values are assigned to an `object`-annotated name before an `isinstance` check. Never widen an already-typed value to `object` to get a check past mypy: trust the annotation, and if mypy calls a check unreachable, delete the check. Test code under `test/` may use `Any`.
185
185
  - **Import domain types from `pgqueuer.domain.types`**, never via `models.JobId`; `no_implicit_reexport` is on and only the top-level shims re-export.
186
186
  - **Generic constructors over type-annotated assignments** for typed stdlib objects: `fut = asyncio.Future[MyType]()` not `fut: asyncio.Future[MyType] = asyncio.Future()`.
187
187
  - **No bare tuples as records.** A tuple whose elements mean different things needs a `NamedTuple` at minimum, a frozen dataclass when it grows behaviour. `tuple[X, ...]` as a homogeneous collection is fine; `tuple[str, str]` standing in for a record is not — the caller unpacks by position, a swap type-checks, and the meaning lives only in the variable name at the call site.
@@ -297,6 +297,7 @@ The grandfathered `tracing.TRACER` is the sole legacy exception; add no more, an
297
297
  - Hierarchy: `PgqException > RetryException > RetryRequested`; also `DuplicateJobError`, `FailingListenerError`, `SchemaDriftError`
298
298
  - Use `logconfig.logger.exception(...)` for logging errors in job dispatch
299
299
  - Use `contextlib.suppress(...)` for non-critical errors
300
+ - **Every resource is cleaned up by a context manager.** A `finally` block is the last resort, used only where no context manager can express the cleanup.
300
301
  - Use `pytest.raises` in tests for expected exceptions
301
302
 
302
303
  ### Docstrings
@@ -309,7 +310,6 @@ Follow [PEP 257](https://peps.python.org/pep-0257/) for format. Keep them tight.
309
310
  - **Skip docstrings on trivial or private helpers.** A descriptive name beats a docstring that repeats it.
310
311
  - **Test docstrings**: one line describing the behavior under test. Skip when the test name is self-evident.
311
312
  - **Module docstrings**: optional. When present, one sentence. No "This module defines..." preambles.
312
- - **External-schema docstrings exempt.** Where a docstring is the canonical, externally-published description of a function -- specifically `@mcp.tool()` and `@mcp.prompt()` handlers in `pgqueuer/adapters/mcp/`, whose docstrings are surfaced verbatim to MCP clients as the tool's schema -- the verbosity rules above do not apply. Document return columns, parameter semantics, and usage patterns at whatever length the consumer needs.
313
313
  - **Usage examples recommended on public APIs.** Public classes and functions exported from `pgqueuer/__init__.py` (or otherwise documented for end users) should include a short `Usage example::` block in the docstring -- one realistic call, placed after the summary/body. Skip the example when the API is trivial and the call site is self-evident from the signature (e.g. simple getters, one-arg helpers, obvious one-liners). Judgement call: if a new user would not need to look at the example, don't write one.
314
314
 
315
315
  ### Comments
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pgqueuer
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: PostgreSQL-backed background job and task queue for Python.
5
5
  Author: JeyBee
6
6
  License: MIT License
@@ -51,12 +51,10 @@ Requires-Dist: opentelemetry-sdk>=1.20.0; extra == "opentelemetry"
51
51
  Requires-Dist: opentelemetry-semantic-conventions>=0.41b0; extra == "opentelemetry"
52
52
  Provides-Extra: fastapi
53
53
  Requires-Dist: fastapi>=0.100.0; extra == "fastapi"
54
- Provides-Extra: mcp
55
- Requires-Dist: mcp>=1.0; extra == "mcp"
56
- Requires-Dist: asyncpg>=0.30.0; extra == "mcp"
57
54
  Provides-Extra: web
58
55
  Requires-Dist: fastapi>=0.115.0; extra == "web"
59
56
  Requires-Dist: jinja2>=3.1; extra == "web"
57
+ Requires-Dist: python-multipart>=0.0.18; extra == "web"
60
58
  Requires-Dist: uvicorn>=0.30; extra == "web"
61
59
  Dynamic: license-file
62
60
 
@@ -12,6 +12,147 @@
12
12
 
13
13
  ---
14
14
 
15
+ ## v2.2.0
16
+
17
+ ### Added
18
+
19
+ - Read-only CLI commands for queue inspection, each with `--json` for scripts
20
+ and agents: `pgq size` (job counts per entrypoint, status and priority),
21
+ `pgq throughput` (totals per status, optional `--period`), `pgq log`
22
+ (recent status changes; `--exceptions` for failures with their error),
23
+ `pgq jobs` (browse the queue table with `--limit`/`--offset`) and
24
+ `pgq tables` (persistence, row estimate and size per table).
25
+ - `pgq schedules --json` and `pgq dashboard --json`. The dashboard prints
26
+ once with `--json`; it rejects `--interval`.
27
+ - `PgQueuer(tracer=...)` and a `tracer` argument on its factory methods.
28
+ The queue manager and the default queries use this tracer, so you do not
29
+ need the global `set_tracing_class()`. With your own `queries`, give the
30
+ same tracer to the queries and to `PgQueuer`: `PgQueuer` raises if they differ.
31
+ - `add_listener` and `remove_listener` on `Queries` and `InMemoryQueries`
32
+ (see `pgqueuer.ports.repository.NotificationListener`). `QueueManager` and
33
+ `CompletionWatcher` now listen through the repository, not its driver.
34
+ `CompletionWatcher` uses the driver of its `queries`, not its `driver`
35
+ argument, when the queries have these methods.
36
+
37
+ ### Deprecated
38
+
39
+ - `set_tracing_class()`. It now emits a `DeprecationWarning` and still sets
40
+ the global tracer. Pass `PgQueuer(tracer=...)` instead, or `tracer=` to
41
+ `Queries` when you build your own queries. It will be removed in the next
42
+ major release.
43
+ - A custom repository without `add_listener` and `remove_listener`. The
44
+ queue manager and `CompletionWatcher` then listen through
45
+ `repository.driver` and emit a `DeprecationWarning`. Add the two methods.
46
+ The next major release removes this fallback.
47
+
48
+ ### Removed
49
+
50
+ - **Breaking:** the MCP server, `pgqueuer.adapters.mcp` and the `pgqueuer[mcp]`
51
+ extra. Every tool has a `pgq` command with `--json`; see
52
+ [Migrating from the MCP server](docs/reference/cli.md#migrating-from-the-mcp-server).
53
+
54
+ ### Changed
55
+
56
+ - `QueueManager.run`, `SchedulerManager.run` and `PgQueuer.run` no longer
57
+ enter or exit the driver you give them (ADR-0026). Before, a stopped worker
58
+ could drop the listeners of your application on a shared psycopg or pool
59
+ driver. If your own driver needs `async with`, enter it yourself.
60
+ - `max_concurrent_tasks` must now be at least `batch_size`, not twice
61
+ `batch_size`. `batch_size=1, max_concurrent_tasks=1` runs one job at a time
62
+ per worker (#1150).
63
+ - A failed listener health check is now logged as an error. With
64
+ `shutdown_on_listener_failure` off, the default, the worker used to keep
65
+ running with no log line: no NOTIFY wake-ups, no job cancellations, only
66
+ polling every `dequeue_timeout` (#1025). It still keeps running; restart it,
67
+ or pass `shutdown_on_listener_failure=True` to make it exit.
68
+ - The listener health check reports a dead listener after three probes in a
69
+ row go unanswered, instead of after the first. One late or dropped NOTIFY
70
+ used to end the check: with `shutdown_on_listener_failure` off the worker
71
+ never probed again, and with it on the worker stopped (#1120). A dead
72
+ listener is now found after about 30 s instead of 10 s.
73
+ - `pgq` reads `PGQUEUER_DSN` before `PGDSN`. `PGDSN` used to win when both
74
+ were set (#1126); if the two differ in your environment, `pgq` now connects
75
+ with `PGQUEUER_DSN`.
76
+ - A second SIGINT or SIGTERM stops `pgq run` and `pgqueuer.run()` at once.
77
+ The first signal still starts a graceful shutdown and waits for the running
78
+ jobs; a second one used to do nothing, so a blocked job kept the process
79
+ alive until SIGKILL (#1133). Jobs cut off this way stay `picked` and run
80
+ again after `heartbeat_timeout`.
81
+
82
+ ### Fixed
83
+
84
+ - `DBSettings` rejects a schema-qualified name such as `myschema.pgqueuer` and
85
+ points to `db_schema`. Such names never worked: install failed and workers
86
+ refused to start (#1134).
87
+ - The `web` extra installs `python-multipart`. The dashboard's requeue and
88
+ cancel forms need it, and `pip install pgqueuer[web]` alone did not install
89
+ it, so those actions failed.
90
+ - Drain mode stops as soon as its last job ends. Since #1092 it could miss the
91
+ NOTIFY from that job's end and sit out the whole `dequeue_timeout`, 30 s by
92
+ default, before exiting.
93
+ - With a per-entrypoint `concurrency_limit`, the dequeue's estimated cost no
94
+ longer grows with the number of queued rows. A large backlog pushed it past
95
+ `jit_above_cost`, and PostgreSQL then JIT-compiled the statement on every
96
+ poll. The batch size is now written into the statement as an integer
97
+ literal, so the plan PostgreSQL caches for the prepared dequeue sees it
98
+ too (#1071).
99
+ - `QueueManager.run()` refuses to start when the notify function or the
100
+ notify trigger is missing. A worker used to start without them, and
101
+ enqueues then sent no NOTIFY. `pgq upgrade` recreates both.
102
+ - `QueueManager`, `SchedulerManager` and `pgq verify --expect present` check
103
+ every table, column, index and enum label the schema declares, plus the
104
+ notify function and trigger. They used to check a fixed list: the queue
105
+ manager missed most indexes, the scheduler checked two tables, and `pgq
106
+ verify` checked no columns. The error lists every missing object. A missing
107
+ non-unique index only slows queries, so it is now logged as a warning and
108
+ does not stop the start or fail `pgq verify`; before, the log table's
109
+ `job_id_status` index did. Custom repositories keep the old check unless
110
+ they add `verify_schema()` (see `pgqueuer.ports.repository.SchemaVerifier`).
111
+ - With `shutdown_on_listener_failure=True`, a healthy worker no longer stops
112
+ about 10 seconds after it starts. Its first health probe could go out before
113
+ LISTEN was in place, so nothing heard the NOTIFY and the check failed
114
+ (#1118).
115
+ - `QueueManager.run()` removes its NOTIFY listener when it stops. Each run
116
+ used to leave its callback behind, so a connection used for several runs
117
+ collected one dead callback per run (#1122).
118
+ - A query on a listening `PsycopgDriver` connection no longer waits up to 1 s.
119
+ The NOTIFY watcher held the connection lock for a second at a time; it now
120
+ waits in 50 ms slices, so a query waits at most one slice (#1121).
121
+ - `AsyncpgPoolDriver.remove_listener` returns the listener connection to the
122
+ pool with the last listener. The driver used to keep it until its last exit,
123
+ so a caller that removed its listeners without exiting the driver held one
124
+ pool connection, and `pool.close()` then waited for it forever.
125
+ - `pgqueuer.run()` removes its SIGINT and SIGTERM handlers when it returns.
126
+ They used to stay in place, so a later SIGTERM only set an event that nobody
127
+ read, and the process ran on until SIGKILL (#1133).
128
+ - The web dashboard's `/healthz` answers without credentials when Basic auth
129
+ is on. It used to return 401, so an orchestrator's liveness probe failed
130
+ (#1127).
131
+ - The web dashboard rejects a cross-site POST that arrives without a
132
+ `Sec-Fetch-Site` header. It used to check only that header, so it accepted
133
+ such a request. It now compares `Origin`, or else `Referer`, with the
134
+ request's `Host`; a request with none of the three headers still passes, so
135
+ curl and scripts keep working (#1128). Behind a reverse proxy, pass the
136
+ original `Host` header through, or such a POST gets 403.
137
+ - An object name longer than 63 bytes raises `ValueError` with the name.
138
+ PostgreSQL truncates such a name, so a long prefix made `pgq install` and
139
+ `pgq upgrade` fail (#1134).
140
+ - `pgq install` and `pgq upgrade` stop when the queue table resolves to a
141
+ schema other than `current_schema()`. With `db_schema` unset and a new
142
+ schema first in `search_path`, `pgq install` found no tables, created a
143
+ second queue there, and left the jobs in the old one unread (#1135). A
144
+ worker and `pgq verify` stop with the same error, where they used to report
145
+ missing tables. Set `db_schema`, or change `search_path`.
146
+ - In-memory `mark_job_as_cancelled` on a failed job keeps the dedupe key of a
147
+ newer job, matching PostgreSQL. It released the key, so a later enqueue
148
+ with that key was accepted as a duplicate (#1130).
149
+ - The in-memory adapter frees cancelled jobs, and jobs re-added at a higher
150
+ priority, while a higher priority stays busy. Their entries, payload
151
+ included, used to stay referenced until the dequeue reached them, which
152
+ never happened while higher-priority work kept arriving (#1131).
153
+
154
+ ---
155
+
15
156
  ## v2.1.0
16
157
 
17
158
  ### Changed
@@ -30,10 +171,6 @@
30
171
  - An idle worker wakes about every `heartbeat_timeout / 2` while other workers
31
172
  run jobs of its entrypoints, instead of once per `dequeue_timeout`, so a dead
32
173
  worker's job is re-picked once its heartbeat goes stale (#1092).
33
- - MCP `failed_jobs` no longer returns the log row `id` (`job_id` is still
34
- there), and `traceback` is a JSON object rather than a JSON string (#1094).
35
- `queue_stats` and `throughput_summary` fold pending log rows into statistics,
36
- so they need write access; the docs no longer call every tool read-only.
37
174
 
38
175
  ### Fixed
39
176
 
@@ -77,8 +214,8 @@
77
214
 
78
215
  ### Changed
79
216
 
80
- - `Queries`, `SyncQueries`, `InMemoryQueries`, `PgQueuer`, `create_web_app` and
81
- `create_mcp_server` read their default `DBSettings` from the `PGQUEUER_*` env
217
+ - `Queries`, `SyncQueries`, `InMemoryQueries`, `PgQueuer` and `create_web_app`
218
+ read their default `DBSettings` from the `PGQUEUER_*` env
82
219
  vars when they are built. v1.6 read them once per process and kept that
83
220
  value. Building `DBSettings()` takes a few hundred microseconds, so if you
84
221
  create queries per request, build the settings once and pass them in.
@@ -344,8 +481,6 @@
344
481
  - `enqueue()` rejects one value next to a list of entrypoints, which v1.4.0
345
482
  accepted: `enqueue(["a", "b"], None, [0, 0])` now raises `ValueError` for
346
483
  `payload`. Pass one value per job, e.g. `[None, None]`.
347
- - MCP `stale_jobs` and `queue_age` return numeric fields as JSON numbers, not
348
- strings, on PostgreSQL 14+.
349
484
  - `InsightsService.stale_jobs(threshold=timedelta(0))` returns every picked
350
485
  job. Previously a zero threshold fell back to the 5-minute default.
351
486
  - Workers flush queued heartbeats every eighth of `heartbeat_timeout`, not
@@ -384,9 +519,6 @@
384
519
  - `QueryBuilderEnvironment.build_upgrade_queries()`. Use
385
520
  `Queries.plan_upgrade()` / `apply_upgrade()`, or `pgq sql upgrade` for the
386
521
  script.
387
- - MCP server: the `Tail`, `TimePeriod`, `StaleThreshold`, `Limit` and `Offset`
388
- type aliases, and `PgQueuerDatabase.settings` / `.qbs`. Tool schemas are
389
- unchanged.
390
522
 
391
523
  ## v1.4.0
392
524
 
@@ -722,14 +854,6 @@
722
854
  gets `ctx.resources`, like `Context.resources` for job handlers. Previously
723
855
  the only way was a closure over `pgq.resources`. Handlers without
724
856
  `accepts_context` still take just the schedule.
725
- - **Read-only MCP server.** `pip install pgqueuer[mcp]`, then
726
- `python -m pgqueuer.adapters.mcp`. Eleven tools: `queue_size`,
727
- `queue_table_info`, `queue_stats`, `throughput_summary`, `failed_jobs`,
728
- `queue_log`, `schedules`, `stale_jobs`, `active_workers`, `queue_age`,
729
- `schema_info`. Connects with the libpq variables or
730
- `create_mcp_server(dsn="postgresql://...")`. Works with Claude Desktop,
731
- Claude Code, Cursor and other MCP clients; see the
732
- [MCP Server docs](docs/integrations/mcp-server.md).
733
857
 
734
858
  ### Bug fixes
735
859
 
@@ -0,0 +1,72 @@
1
+ # ADR-0000: Record each design decision in one short ADR
2
+
3
+ ## Status
4
+
5
+ Proposed
6
+
7
+ ## Summary
8
+
9
+ For design decisions in PgQueuer, we keep one short record in the repository
10
+ for each decision. Decisions in PRs, chats and trackers become lost. We do not
11
+ use trackers or long design documents for decisions. Each decision then has
12
+ one place. The cost is one documentation PR for each decision.
13
+
14
+ ## Context
15
+
16
+ We make decisions in PR threads, reviews, agent chats and trackers. These are
17
+ not records. Because of this, the same questions occur again.
18
+
19
+ ## Decision
20
+
21
+ Write a record when a real alternative exists and a change of the decision has
22
+ a cost. Use the sections of this record, in the same order.
23
+
24
+ Put one decision in each record, and keep the record to one page. Write the
25
+ title as a sentence that states the decision. The summary gives the context,
26
+ the problem, the decision, the rejected option, the benefit and the cost. Cite
27
+ code, mechanisms and values by path, and do not explain them. Give at least
28
+ one real alternative and at least one cost. The sections "Not covered" and
29
+ "Revisit when" show the limits of the decision. Write each record in
30
+ ASD-STE100.
31
+
32
+ A record starts as `Proposed`. It then becomes `Accepted` or `Rejected`.
33
+ Use `Accepted (retroactive)` for behaviour that exists before its record. Do
34
+ not change an accepted record. Write a new record, and set the status of the
35
+ old record to `Superseded by ADR-NNNN`.
36
+
37
+ Name the file `docs/adr/ADR-NNNN-<slug>.md`, with the next free number. Do not
38
+ use a number again. Add each record to the index in README.md. Put one record
39
+ in each PR, with no code in it. Keep rejected proposals. A record refers only
40
+ to merged records.
41
+
42
+ Trackers, code comments and AGENTS.md refer to records by number. They do not
43
+ hold decisions.
44
+
45
+ ## Consequences
46
+
47
+ Each decision has one place, and short records are easy to read and to
48
+ replace. But each decision requires an extra PR. Also, a small correction to
49
+ an accepted decision requires a new record.
50
+
51
+ ## Alternatives considered
52
+
53
+ We can keep decisions in trackers and PR descriptions. This adds no step. We
54
+ did not choose it, because we delete trackers and we do not search PR threads.
55
+
56
+ The full MADR template is more complete. We did not choose it, because each
57
+ extra section makes a long design document more probable.
58
+
59
+ ## Not covered by this ADR
60
+
61
+ This record does not control the approval of records, publication or tools.
62
+ Today, the maintainer approves records.
63
+
64
+ ## Revisit when
65
+
66
+ Examine this record again when more maintainers join, or when new records are
67
+ often longer than one page.
68
+
69
+ ## References
70
+
71
+ This record uses ideas from Michael Nygard (2011), Uwe Zdun et al. (2013),
72
+ MADR 4.0, Olaf Zimmermann (2023) and Martin Fowler.
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Status
4
4
 
5
- Accepted (adoption is incremental; dequeue migrates first)
5
+ Accepted (adoption is incremental; dequeue has migrated)
6
6
 
7
7
  ## Context
8
8
 
@@ -25,11 +25,14 @@ is bound, and the text and argument list emerge as one pair. A
25
25
  statement renders only the fragments its configuration needs, and one
26
26
  configuration always renders identical text. "Not configured" is
27
27
  expressed as absence, never as a sentinel value, and the composer
28
- never rewrites fragment text.
29
-
30
- Adoption is incremental and has not started yet: dequeue migrates
31
- first, the remaining builders follow when next touched, and a
32
- statement that gains a conditional fragment migrates at that moment.
28
+ never rewrites fragment text. The dequeue's `batch_size` is the one
29
+ exception to binding: a validated positive integer written as a
30
+ literal, so the plan PostgreSQL caches for the prepared statement can
31
+ see its `LIMIT`.
32
+
33
+ Adoption is incremental: dequeue migrated first, the remaining
34
+ builders follow when next touched, and a statement that gains a
35
+ conditional fragment migrates at that moment.
33
36
  Static, argument-free DDL migrates last, if ever.
34
37
 
35
38
  ## Consequences
@@ -0,0 +1,53 @@
1
+ # ADR-0026: The code that makes a connection controls its lifecycle
2
+
3
+ ## Status
4
+
5
+ Proposed
6
+
7
+ ## Summary
8
+
9
+ The code that makes a database connection controls its setup and teardown.
10
+ PgQueuer does not enter, exit or close a connection, pool or driver that it
11
+ receives.
12
+
13
+ ## Context
14
+
15
+ Users give PgQueuer a connection, a pool or a driver, and often share it with
16
+ their application. The drivers tell the caller to close it. But
17
+ `QueueManager.run` and `SchedulerManager.run` enter the driver, so two parties
18
+ control one lifecycle.
19
+
20
+ ## Decision
21
+
22
+ PgQueuer releases a resource that it borrows, such as a LISTEN connection from
23
+ a pool, when its last user stops. When PgQueuer makes a connection itself, for
24
+ example in the CLI, it closes it.
25
+
26
+ ## Consequences
27
+
28
+ The application controls the shutdown order and can share a pool with
29
+ PgQueuer. Today `QueueManager.run` and `SchedulerManager.run` do not obey this
30
+ record. The creator of a custom driver must enter it if the driver requires
31
+ this.
32
+
33
+ ## Alternatives considered
34
+
35
+ PgQueuer can enter and close each driver that it receives. We did not choose
36
+ it, because PgQueuer then closes a pool that the application still uses.
37
+
38
+ PgQueuer can enter the driver once and not close it. We did not choose it,
39
+ because an enter changes the state of some drivers, such as psycopg.
40
+
41
+ ## Not covered by this ADR
42
+
43
+ This record does not control reconnection, pool size or the list of drivers.
44
+
45
+ ## Revisit when
46
+
47
+ Examine this record again if PgQueuer starts to make connections from a DSN.
48
+
49
+ ## References
50
+
51
+ [ADR-0000](ADR-0000-record-each-decision-in-one-short-adr.md) gives the rules.
52
+ `PoolListener` in `pgqueuer/adapters/drivers/asyncpg.py` releases the LISTEN
53
+ connection.
@@ -19,6 +19,7 @@ Conventions:
19
19
 
20
20
  ## Index
21
21
 
22
+ - [ADR-0000: Record each design decision in one short ADR](ADR-0000-record-each-decision-in-one-short-adr.md)
22
23
  - [ADR-0001: Job state lives in PostgreSQL](ADR-0001-job-state-lives-in-postgresql.md)
23
24
  - [ADR-0002: Workers claim jobs by row-level lock contention, not assignment](ADR-0002-workers-claim-by-lock-contention.md)
24
25
  - [ADR-0003: Notifications signal that something changed, never carry job data](ADR-0003-notifications-signal-not-carry.md)
@@ -27,6 +28,7 @@ Conventions:
27
28
  - [ADR-0016: Schema upgrades are computed from the live database](ADR-0016-schema-upgrades-are-computed-from-the-live-database.md)
28
29
  - [ADR-0024: SQL statements are assembled by the composer](ADR-0024-sql-is-assembled-by-the-composer.md)
29
30
  - [ADR-0025: The schema contract is a declared manifest](ADR-0025-the-schema-contract-is-a-declared-manifest.md)
31
+ - [ADR-0026: The code that makes a connection controls its lifecycle](ADR-0026-connection-creator-controls-its-lifecycle.md)
30
32
 
31
33
  ## Backlog
32
34
 
@@ -55,7 +57,7 @@ leaves open.
55
57
  assigns work to named workers.
56
58
  - Consequences: workers are homogeneous and stateless; adding a worker
57
59
  needs no registration; no fairness guarantee between workers.
58
- - Pointers: claim query built in `pgqueuer/adapters/persistence/qb.py`.
60
+ - Pointers: claim query built in `pgqueuer/adapters/persistence/dequeue.py`.
59
61
  - Not covered: the claim query's shape (single-statement CTE is detail).
60
62
 
61
63
  - [x] **ADR-0003: Notifications signal that something changed, never carry job data**
@@ -90,7 +92,7 @@ leaves open.
90
92
  bounded by that threshold rather than being instant.
91
93
  - Pointers: heartbeat timeout plumbed through
92
94
  `pgqueuer/adapters/cli/supervisor.py` (`runit(..., heartbeat_timeout)`);
93
- stale re-pick lives in the claim query (`qb.py`).
95
+ stale re-pick lives in the claim query (`dequeue.py`).
94
96
  - Not covered: intervals, thresholds, batching of heartbeat updates.
95
97
 
96
98
  - [ ] **ADR-0006: Concurrency limits are enforced globally at claim time, not per process**
@@ -251,8 +253,8 @@ leaves open.
251
253
  - [x] **ADR-0024: SQL statements are assembled by the composer**
252
254
  - Decision: statements are built from conditional fragments, binds
253
255
  auto-numbered, text and arguments emerging as one pair; unconfigured
254
- is absence, never a sentinel. Adoption is incremental; dequeue is
255
- first.
256
+ is absence, never a sentinel. Adoption is incremental; dequeue has
257
+ migrated.
256
258
  - Fork: composer vs. hand-numbered text per statement vs. an external
257
259
  query builder.
258
260
  - Consequences: numbering cannot drift; unused gates render nothing;
@@ -43,8 +43,10 @@ commands, examples, and configuration live at
43
43
  - Deployment and performance:
44
44
  <https://janbjorge.github.io/pgqueuer/guides/deployment/> and
45
45
  <https://janbjorge.github.io/pgqueuer/guides/performance-tuning/>
46
- - Monitoring a live queue from an agent:
47
- <https://janbjorge.github.io/pgqueuer/integrations/mcp-server/>
46
+ - Monitoring a live queue from an agent: the `pgq` inspection commands
47
+ (`size`, `throughput`, `log`, `jobs`, `stale`, `workers`, `backlog`,
48
+ `tables`, `schedules`), each with `--json`:
49
+ <https://janbjorge.github.io/pgqueuer/reference/cli/>
48
50
 
49
51
  ## Troubleshooting route
50
52
 
@@ -34,7 +34,7 @@ participants:
34
34
  record. The scaling unit is the process; run more of them for more
35
35
  throughput.
36
36
  - The **operator** is a human. They install and upgrade the schema, start
37
- workers, and observe via CLI, dashboard, or MCP server.
37
+ workers, and observe via CLI or dashboard.
38
38
 
39
39
  ## Architecture
40
40
 
@@ -43,7 +43,7 @@ participants:
43
43
  │ Producer │ │ Operator │
44
44
  │ (app code) │ │ (human) │
45
45
  └─────┬──────┘ └─────┬──────┘
46
- │ SQL: enqueue, │ CLI / dashboard / MCP:
46
+ │ SQL: enqueue, │ CLI / dashboard:
47
47
  │ schedule, cancel │ install, upgrade, observe
48
48
  ▼ ▼
49
49
  ┌─────────────────────────────────────────────────────────┐
@@ -89,7 +89,7 @@ Steps:
89
89
  1. Install schema (`pgq install`), choosing durability and namespace.
90
90
  2. Start one or more worker processes (`pgq run <factory>`).
91
91
  3. Observe queue depth, throughput, failures, and worker liveness via
92
- dashboard, MCP, Prometheus, or CLI.
92
+ dashboard, Prometheus, or CLI.
93
93
  4. Upgrade schema on library upgrades (`pgq upgrade`).
94
94
 
95
95
  ### UC2: Process jobs (subfunction level)
@@ -270,4 +270,4 @@ summary here:
270
270
  [SQL naming model](sql-naming.md), upgrades in the
271
271
  [schema upgrade model](schema-upgrade.md)).
272
272
  - Observability model: the log/statistics pipeline, dashboard, metrics,
273
- and the MCP read surface.
273
+ and the CLI read commands.
@@ -20,7 +20,7 @@ supervisor reruns the fa
20
20
  │ ├─ job task (per job) waited for
21
21
  │ │ ├─ heartbeats, buffered ─► update_heartbeat logged, kept
22
22
  │ │ └─ results, buffered ─► log_jobs at exit: 5 tries, then kept
23
- │ ├─ health check, 10 s ─► notify ends run (opt-in)
23
+ │ ├─ health check, 10 s ─► notify logged, ends run (opt-in)
24
24
  │ └─ log aggregation ─► aggregate_logs swallowed
25
25
  └─ SchedulerManager.run
26
26
  ├─ loop, cron + 1 s ─► fetch_schedule raises, run ends
@@ -89,7 +89,9 @@ that `notifies()` holds.
89
89
 
90
90
  The asyncpg pool hides the failure. `AsyncpgPoolDriver` keeps its LISTEN
91
91
  connection out of the pool, and that connection dies without an error. Queries
92
- move to fresh pool connections, so nothing raises and nothing restarts. The
92
+ move to fresh pool connections, so the run does not raise and nothing restarts.
93
+ The health check times out and logs an error. Without
94
+ `shutdown_on_listener_failure` that log line is the only sign. The
93
95
  [performance guide](../guides/performance-tuning.md#notify-channel-and-polling-fallback)
94
96
  already advises a direct connection for the queue manager, and #951 deprecates
95
97
  the pool drivers.
@@ -14,13 +14,13 @@ a sub-model of the [system design](README.md).
14
14
  └───────┬───────┘
15
15
  │
16
16
  ▼
17
- ┌───────────────┐ derives the gate shape from what is configured
18
- │ Query builder │ and picks the fragments that shape needs
17
+ ┌───────────────┐
18
+ │ Dequeue SQL │ picks the shape, lists its CTEs
19
19
  └───────┬───────┘
20
- │ fragments and values, in a fixed order
20
+ │
21
21
  ▼
22
- ┌───────────────┐ couples each value to its placeholder as it is
23
- │ Composer │ bound; chains the fragments into one statement
22
+ ┌───────────────┐
23
+ │ Query template│ cached per shape and batch size
24
24
  └───────┬───────┘
25
25
  │
26
26
  ▼
@@ -36,8 +36,10 @@ a sub-model of the [system design](README.md).
36
36
 
37
37
  The two gate predicates (is any entrypoint limit configured, is a
38
38
  worker budget configured) select one of four shapes. The rendered text
39
- depends only on the shape and the installation's table names; every
40
- runtime value travels as a bound argument.
39
+ depends only on the shape, the batch size and the installation's table
40
+ names. The batch size is a literal, so the plan PostgreSQL caches for
41
+ the prepared statement can see its `LIMIT`; every other runtime value
42
+ travels as a bound argument.
41
43
 
42
44
  ## Shapes
43
45
 
@@ -48,23 +50,34 @@ runtime value travels as a bound argument.
48
50
  | Global gate | off | on |
49
51
  | Both gates | on | on |
50
52
 
53
+ `dequeue_shape` picks the shape. Each shape is one method on `DequeueSql`
54
+ listing its CTEs in `WITH` order; each CTE is one method. Snapshots live
55
+ under `test/query_shapes/`.
56
+
51
57
  ## Components
52
58
 
53
- | Component | Type | Description |
54
- |---------------|--------------|----------------------------------------------------|
55
- | Composer | Service | Assembles a statement from fragments; couples each value to its placeholder as it is bound |
56
- | Composed query| Value Object | Immutable pairing of rendered text and arguments |
57
- | Query builder | Service | Derives the gate predicates and composes the shape |
58
- | Gate shape | Value Object | The pair of gate predicates; selects the statement |
59
+ | Component | Type | Description |
60
+ |-------------------|--------------|-----------------------------------------------|
61
+ | Template composer | Service | Numbers placeholders, records each one's reader |
62
+ | Query template | Value Object | Rendered text and its readers |
63
+ | CTE | Value Object | Name, body and one-line log comment |
64
+ | Composed query | Value Object | Rendered text paired with its arguments |
65
+ | Dequeue args | Value Object | One call's values, validated on construction |
66
+ | Dequeue shape | Value Object | Which gates the statement renders |
67
+ | Dequeue SQL | Service | One method per shape and per CTE |
59
68
 
60
- The composer and builder live in `pgqueuer/adapters/persistence/`.
69
+ Code: `pgqueuer/adapters/persistence/composer.py` and `dequeue.py`. The
70
+ builder caches one template per shape and batch size.
61
71
 
62
72
  ## Invariants
63
73
 
64
74
  - "Unlimited" is expressed as absence at every boundary, never as a
65
75
  sentinel value.
66
- - One gate configuration always renders identical text; arguments are
67
- bound fresh on every claim and never shared between claims.
76
+ - One gate configuration and batch size always render identical text;
77
+ arguments are bound fresh on every claim and never shared between claims.
78
+ - Each placeholder carries its own reader, so a cached template never
79
+ depends on bind order.
80
+ - Rendering rejects a CTE name defined twice.
68
81
  - The stale-job re-pick skips the entrypoint gate on purpose:
69
82
  re-picking transfers ownership of an already-counted job, and gating
70
83
  it would deadlock recovery.
@@ -6,11 +6,12 @@ turns that into a startup decision. The *why* lives in
6
6
  Sub-model of the [system design](README.md).
7
7
 
8
8
  This document describes the target design. Revisions, severity and the
9
- verdict are not built yet. Today `QueueManager.verify_structure` checks
10
- hand-listed tables, columns, enum labels and indexes by name and refuses
11
- to start when one is missing, `SchedulerManager.run` checks only that the
12
- schedules and log tables exist, and `pgq verify` checks the tables, the
13
- function and the trigger.
9
+ verdict are not built yet. Today `QueueManager.verify_structure`,
10
+ `SchedulerManager.run` and `pgq verify --expect present` check every
11
+ declared table, column, index and enum label, the notify function and the
12
+ notify trigger by name, not by shape. A missing non-unique index only slows
13
+ queries, so it is a warning; anything else missing refuses the start. A
14
+ custom repository without `verify_schema` still gets the old fixed list.
14
15
 
15
16
  ## Flow
16
17