taskwire 0.4.1__tar.gz → 0.4.3__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 (65) hide show
  1. {taskwire-0.4.1 → taskwire-0.4.3}/PKG-INFO +19 -37
  2. {taskwire-0.4.1 → taskwire-0.4.3}/README.md +2 -2
  3. taskwire-0.4.3/pyproject.toml +153 -0
  4. taskwire-0.4.1/pyproject.toml → taskwire-0.4.3/pyproject.toml.orig +21 -21
  5. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/__init__.py +3 -1
  6. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/calls.py +10 -7
  7. taskwire-0.4.3/taskwire/publish.py +59 -0
  8. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/reporter.py +68 -6
  9. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/rest.py +7 -4
  10. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/settings.py +5 -1
  11. taskwire-0.4.1/.gitignore +0 -35
  12. {taskwire-0.4.1 → taskwire-0.4.3}/LICENSE +0 -0
  13. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/README.md +0 -0
  14. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/exception-names.json +0 -0
  15. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/sequences/.gitkeep +0 -0
  16. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/aggregate-counts.json +0 -0
  17. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/aggregate-waiting-input-dominates.json +0 -0
  18. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/dialog-request-open.json +0 -0
  19. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/envelope-cancel.json +0 -0
  20. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/envelope-progress.json +0 -0
  21. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/envelope-snapshot.json +0 -0
  22. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/error-dispatch-failed.json +0 -0
  23. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-percent-absent.json +0 -0
  24. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-percent-null.json +0 -0
  25. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-private.json +0 -0
  26. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-shared-origins.json +0 -0
  27. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-state-cancelled.json +0 -0
  28. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-state-done.json +0 -0
  29. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-state-failed.json +0 -0
  30. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-state-queued.json +0 -0
  31. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-state-running.json +0 -0
  32. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/progress-state-waiting-input.json +0 -0
  33. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/register-empty-null-aggregate.json +0 -0
  34. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/register-v2-with-aggregate.json +0 -0
  35. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/result-kind-and-params.json +0 -0
  36. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/result-label-and-value-no-ref.json +0 -0
  37. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/result-ref-with-expires-at.json +0 -0
  38. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/snapshot-v2-wall-clock-rev.json +0 -0
  39. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/snapshot-waiting-input-uncollected-result.json +0 -0
  40. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/text-key-and-text.json +0 -0
  41. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/text-key-only.json +0 -0
  42. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/text-key-params-and-text.json +0 -0
  43. {taskwire-0.4.1 → taskwire-0.4.3}/conformance/wire/text-text-only.json +0 -0
  44. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/ambient.py +0 -0
  45. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/conformance.py +0 -0
  46. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/__init__.py +0 -0
  47. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/asgi.py +0 -0
  48. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/celery.py +0 -0
  49. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/fastapi.py +0 -0
  50. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/muxws.py +0 -0
  51. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/redis_store.py +0 -0
  52. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/schema.py +0 -0
  53. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/threads.py +0 -0
  54. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/viewsets.py +0 -0
  55. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/viewsets_events.py +0 -0
  56. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/contrib/wsgi.py +0 -0
  57. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/decorators.py +0 -0
  58. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/delivery.py +0 -0
  59. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/headers.py +0 -0
  60. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/models.py +0 -0
  61. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/py.typed +0 -0
  62. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/reader.py +0 -0
  63. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/register.py +0 -0
  64. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/store.py +0 -0
  65. {taskwire-0.4.1 → taskwire-0.4.3}/taskwire/transport.py +0 -0
@@ -1,18 +1,14 @@
1
- Metadata-Version: 2.5
1
+ Metadata-Version: 2.4
2
2
  Name: taskwire
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Progress reporting and awaitable dialogs for long-running server-side operations.
5
- Project-URL: Homepage, https://github.com/velis74/taskwire
6
- Project-URL: Repository, https://github.com/velis74/taskwire
7
- Project-URL: Issues, https://github.com/velis74/taskwire/issues
8
- Project-URL: Documentation, https://docs.velis.si/taskwire/
9
- Author-email: Jure Erznožnik <jure.erznoznik@gmail.com>
10
- License: MIT
5
+ Keywords: progress,dialogs,celery,fastapi,websocket,dynamicforms
6
+ Author: Jure Erznožnik
7
+ Author-email: Jure Erznožnik <jure.erznoznik@velis.si>
8
+ License-Expression: MIT
11
9
  License-File: LICENSE
12
- Keywords: celery,dialogs,dynamicforms,fastapi,progress,websocket
13
10
  Classifier: Development Status :: 3 - Alpha
14
11
  Classifier: Intended Audience :: Developers
15
- Classifier: License :: OSI Approved :: MIT License
16
12
  Classifier: Operating System :: OS Independent
17
13
  Classifier: Programming Language :: Python :: 3
18
14
  Classifier: Programming Language :: Python :: 3.10
@@ -21,37 +17,23 @@ Classifier: Programming Language :: Python :: 3.12
21
17
  Classifier: Programming Language :: Python :: 3.13
22
18
  Classifier: Topic :: Internet :: WWW/HTTP
23
19
  Classifier: Typing :: Typed
20
+ Requires-Dist: celery>=5.3 ; extra == 'celery'
21
+ Requires-Dist: nest-asyncio>=1.6 ; extra == 'celery'
22
+ Requires-Dist: fastapi>=0.100 ; extra == 'fastapi'
23
+ Requires-Dist: muxws>=0.4.1 ; extra == 'muxws'
24
+ Requires-Dist: dynamicforms-fastapi-viewsets[muxws]>=0.13.0 ; extra == 'muxws'
25
+ Requires-Dist: redis>=5.0 ; extra == 'redis'
26
+ Requires-Dist: dynamicforms-fastapi-viewsets>=0.13.0 ; extra == 'viewsets'
24
27
  Requires-Python: >=3.10
28
+ Project-URL: Homepage, https://github.com/velis74/taskwire
29
+ Project-URL: Repository, https://github.com/velis74/taskwire
30
+ Project-URL: Issues, https://github.com/velis74/taskwire/issues
31
+ Project-URL: Documentation, https://docs.velis.si/taskwire/
25
32
  Provides-Extra: celery
26
- Requires-Dist: celery>=5.3; extra == 'celery'
27
- Requires-Dist: nest-asyncio>=1.6; extra == 'celery'
28
- Provides-Extra: demo
29
- Requires-Dist: uvicorn>=0.27; extra == 'demo'
30
- Provides-Extra: dev
31
- Requires-Dist: celery>=5.3; extra == 'dev'
32
- Requires-Dist: coverage; extra == 'dev'
33
- Requires-Dist: dynamicforms-fastapi-viewsets>=0.12.0; extra == 'dev'
34
- Requires-Dist: dynamicforms-fastapi-viewsets[muxws]>=0.12.0; extra == 'dev'
35
- Requires-Dist: fastapi>=0.100; extra == 'dev'
36
- Requires-Dist: httpx; extra == 'dev'
37
- Requires-Dist: hypothesis; extra == 'dev'
38
- Requires-Dist: muxws>=0.4.1; extra == 'dev'
39
- Requires-Dist: nest-asyncio>=1.6; extra == 'dev'
40
- Requires-Dist: pytest; extra == 'dev'
41
- Requires-Dist: pytest-asyncio; extra == 'dev'
42
- Requires-Dist: pytest-cov; extra == 'dev'
43
- Requires-Dist: redis>=5.0; extra == 'dev'
44
- Requires-Dist: ruff; extra == 'dev'
45
- Requires-Dist: uvicorn>=0.27; extra == 'dev'
46
33
  Provides-Extra: fastapi
47
- Requires-Dist: fastapi>=0.100; extra == 'fastapi'
48
34
  Provides-Extra: muxws
49
- Requires-Dist: dynamicforms-fastapi-viewsets[muxws]>=0.12.0; extra == 'muxws'
50
- Requires-Dist: muxws>=0.4.1; extra == 'muxws'
51
35
  Provides-Extra: redis
52
- Requires-Dist: redis>=5.0; extra == 'redis'
53
36
  Provides-Extra: viewsets
54
- Requires-Dist: dynamicforms-fastapi-viewsets>=0.12.0; extra == 'viewsets'
55
37
  Description-Content-Type: text/markdown
56
38
 
57
39
  # <img src="taskwire-icon.svg" alt="" width="40" height="40" style="vertical-align: middle"> taskwire
@@ -124,8 +106,8 @@ npm install taskwire
124
106
  ## The demo
125
107
 
126
108
  ```bash
127
- pip install -e ".[fastapi,viewsets,demo]" && npm install
128
- python demo.py # then open http://127.0.0.1:5174
109
+ uv sync && npm ci
110
+ uv run python demo.py # then open http://127.0.0.1:5174
129
111
  ```
130
112
 
131
113
  A night batch over one book: four back-office jobs that between them exercise progress, nested
@@ -68,8 +68,8 @@ npm install taskwire
68
68
  ## The demo
69
69
 
70
70
  ```bash
71
- pip install -e ".[fastapi,viewsets,demo]" && npm install
72
- python demo.py # then open http://127.0.0.1:5174
71
+ uv sync && npm ci
72
+ uv run python demo.py # then open http://127.0.0.1:5174
73
73
  ```
74
74
 
75
75
  A night batch over one book: four back-office jobs that between them exercise progress, nested
@@ -0,0 +1,153 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.13.6,<0.14"]
3
+ build-backend = "uv_build"
4
+
5
+ [project]
6
+ name = "taskwire"
7
+ version = "0.4.3"
8
+ description = "Progress reporting and awaitable dialogs for long-running server-side operations."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ keywords = [
14
+ "progress",
15
+ "dialogs",
16
+ "celery",
17
+ "fastapi",
18
+ "websocket",
19
+ "dynamicforms",
20
+ ]
21
+ classifiers = [
22
+ "Development Status :: 3 - Alpha",
23
+ "Intended Audience :: Developers",
24
+ "Operating System :: OS Independent",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Topic :: Internet :: WWW/HTTP",
31
+ "Typing :: Typed",
32
+ ]
33
+ dependencies = []
34
+
35
+ [[project.authors]]
36
+ name = "Jure Erznožnik"
37
+ email = "jure.erznoznik@velis.si"
38
+
39
+ [project.optional-dependencies]
40
+ redis = ["redis>=5.0"]
41
+ celery = [
42
+ "celery>=5.3",
43
+ "nest_asyncio>=1.6",
44
+ ]
45
+ fastapi = ["fastapi>=0.100"]
46
+ viewsets = ["dynamicforms-fastapi-viewsets>=0.13.0"]
47
+ muxws = [
48
+ "muxws>=0.4.1",
49
+ "dynamicforms-fastapi-viewsets[muxws]>=0.13.0",
50
+ ]
51
+
52
+ [project.urls]
53
+ Homepage = "https://github.com/velis74/taskwire"
54
+ Repository = "https://github.com/velis74/taskwire"
55
+ Issues = "https://github.com/velis74/taskwire/issues"
56
+ Documentation = "https://docs.velis.si/taskwire/"
57
+
58
+ [dependency-groups]
59
+ dev = [
60
+ "taskwire[redis,celery,fastapi,viewsets,muxws]",
61
+ "muxws[websockets]>=0.4.1",
62
+ "uvicorn>=0.27",
63
+ "coverage",
64
+ "pytest",
65
+ "pytest-asyncio",
66
+ "pytest-cov",
67
+ "hypothesis",
68
+ "httpx",
69
+ "ruff",
70
+ ]
71
+
72
+ [tool.publish]
73
+ additional_files = ["vue/index.ts"]
74
+
75
+ [tool.uv.build-backend]
76
+ module-name = "taskwire"
77
+ module-root = ""
78
+ source-include = [
79
+ "LICENSE",
80
+ "conformance/**",
81
+ ]
82
+ source-exclude = ["**/*_test.py"]
83
+
84
+ [tool.pytest.ini_options]
85
+ asyncio_mode = "auto"
86
+ asyncio_default_fixture_loop_scope = "function"
87
+
88
+ [tool.ruff]
89
+ exclude = [
90
+ "docs",
91
+ "design",
92
+ "ts",
93
+ "node_modules",
94
+ "dist",
95
+ "build",
96
+ ".git",
97
+ ".idea",
98
+ ".pytest_cache",
99
+ ".ruff_cache",
100
+ ".venv",
101
+ ]
102
+ line-length = 120
103
+
104
+ [tool.ruff.lint]
105
+ select = [
106
+ "E",
107
+ "W",
108
+ "F",
109
+ "I",
110
+ "Q",
111
+ "B",
112
+ "UP",
113
+ "N",
114
+ "PT",
115
+ "S",
116
+ "C4",
117
+ "ARG",
118
+ ]
119
+ ignore = [
120
+ "E731",
121
+ "E722",
122
+ "C408",
123
+ "S105",
124
+ "S106",
125
+ "S107",
126
+ ]
127
+ fixable = ["ALL"]
128
+ unfixable = []
129
+ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
130
+
131
+ [tool.ruff.lint.per-file-ignores]
132
+ "*_test.py" = ["S101"]
133
+ "taskwire/conformance.py" = ["S101"]
134
+
135
+ [tool.ruff.lint.isort]
136
+ case-sensitive = false
137
+ lines-between-types = 1
138
+ combine-as-imports = true
139
+ order-by-type = false
140
+
141
+ [tool.ruff.format]
142
+ quote-style = "double"
143
+ indent-style = "space"
144
+ skip-magic-trailing-comma = false
145
+ line-ending = "auto"
146
+
147
+ [tool.coverage.run]
148
+ omit = [
149
+ "demo/*",
150
+ "demo/**/*",
151
+ "test_*.py",
152
+ "*_test.py",
153
+ ]
@@ -1,20 +1,20 @@
1
1
  [build-system]
2
- requires = ["hatchling"]
3
- build-backend = "hatchling.build"
2
+ requires = ["uv_build>=0.13.6,<0.14"]
3
+ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "taskwire"
7
- dynamic = ["version"]
7
+ version = "0.4.3"
8
8
  description = "Progress reporting and awaitable dialogs for long-running server-side operations."
9
9
  readme = "README.md"
10
- license = { text = "MIT" }
11
- authors = [{ name = "Jure Erznožnik", email = "jure.erznoznik@gmail.com" }]
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Jure Erznožnik", email = "jure.erznoznik@velis.si" }]
12
13
  requires-python = ">=3.10"
13
14
  keywords = ["progress", "dialogs", "celery", "fastapi", "websocket", "dynamicforms"]
14
15
  classifiers = [
15
16
  "Development Status :: 3 - Alpha",
16
17
  "Intended Audience :: Developers",
17
- "License :: OSI Approved :: MIT License",
18
18
  "Operating System :: OS Independent",
19
19
  "Programming Language :: Python :: 3",
20
20
  "Programming Language :: Python :: 3.10",
@@ -30,7 +30,8 @@ dependencies = [] # DELIBERATE: core has no runtime dependency of any kind (TW
30
30
  redis = ["redis>=5.0"]
31
31
  celery = ["celery>=5.3", "nest_asyncio>=1.6"]
32
32
  fastapi = ["fastapi>=0.100"]
33
- # >=0.12.0: namespaced error codes (`fastapi-viewsets.<code>`), which `TaskwireMiddleware` forwards
33
+ # >=0.13.0, the release the npm peer range names; from 0.12.0: namespaced error codes
34
+ # (`fastapi-viewsets.<code>`), which `TaskwireMiddleware` forwards
34
35
  # verbatim, and one error body for every viewset route. From earlier releases: the execution hook
35
36
  # and the Idempotency-Key helpers; a muxws command that runs to the end of its action when its
36
37
  # stream ends early (TW-CALL-*); delivery filters that run on poll as on push,
@@ -39,16 +40,19 @@ fastapi = ["fastapi>=0.100"]
39
40
  # `Middleware.executor_started()` and `Middleware.on_transition()` - so that `contrib/viewsets.py`
40
41
  # imports no Celery (TW-CALL-101, TW-CALL-105), and that reports a process exit to `on_transition()`
41
42
  # in every pool.
42
- viewsets = ["dynamicforms-fastapi-viewsets>=0.12.0"]
43
+ viewsets = ["dynamicforms-fastapi-viewsets>=0.13.0"]
43
44
  # The socket carries the six request/response calls as viewset commands (TW-REST-004), so the muxws
44
45
  # extra needs the viewset layer's muxws half as well as muxws itself. >=0.4.1: `Peer.close()` sends
45
46
  # every queued frame before closing the socket, so the `goaway` of `goaway_if_stale` (TW-WS-007)
46
47
  # reaches the client.
47
- muxws = ["muxws>=0.4.1", "dynamicforms-fastapi-viewsets[muxws]>=0.12.0"]
48
- demo = ["uvicorn>=0.27"]
48
+ muxws = ["muxws>=0.4.1", "dynamicforms-fastapi-viewsets[muxws]>=0.13.0"]
49
+
50
+ [dependency-groups]
49
51
  # Everything the test suite, the linters and the demo need.
50
52
  dev = [
51
- "taskwire[redis,celery,fastapi,viewsets,muxws,demo]",
53
+ "taskwire[redis,celery,fastapi,viewsets,muxws]",
54
+ "muxws[websockets]>=0.4.1",
55
+ "uvicorn>=0.27",
52
56
  "coverage",
53
57
  "pytest",
54
58
  "pytest-asyncio",
@@ -64,9 +68,6 @@ Repository = "https://github.com/velis74/taskwire"
64
68
  Issues = "https://github.com/velis74/taskwire/issues"
65
69
  Documentation = "https://docs.velis.si/taskwire/"
66
70
 
67
- [tool.hatch.version]
68
- path = "taskwire/__init__.py"
69
-
70
71
  # The release tool stamps the two manifests by itself. `vue/index.ts` is the third place the version
71
72
  # is written down - the npm half exports it as `VERSION` - and nothing about a Python manifest points
72
73
  # at it, so it is named here. `packaging_test.py::test_python_and_npm_versions_match` and
@@ -75,12 +76,11 @@ path = "taskwire/__init__.py"
75
76
  [tool.publish]
76
77
  additional_files = ["vue/index.ts"]
77
78
 
78
- [tool.hatch.build.targets.wheel]
79
- packages = ["taskwire"]
80
-
81
- [tool.hatch.build.targets.sdist]
82
- include = ["/taskwire", "/conformance", "/README.md", "/LICENSE"]
83
- exclude = ["**/*_test.py"]
79
+ [tool.uv.build-backend]
80
+ module-name = "taskwire"
81
+ module-root = ""
82
+ source-include = ["LICENSE", "conformance/**"]
83
+ source-exclude = ["**/*_test.py"]
84
84
 
85
85
  [tool.pytest.ini_options]
86
86
  asyncio_mode = "auto"
@@ -90,7 +90,7 @@ asyncio_default_fixture_loop_scope = "function"
90
90
  # `design` holds the normative specification and the design brief. They are prose that happens to
91
91
  # quote Python, and ruff would otherwise reformat the code inside their fenced blocks.
92
92
  exclude = ['docs', 'design', 'ts', 'node_modules', 'dist', 'build', '.git', '.idea',
93
- '.pytest_cache', '.ruff_cache']
93
+ '.pytest_cache', '.ruff_cache', '.venv']
94
94
  line-length = 120
95
95
 
96
96
  [tool.ruff.lint]
@@ -12,7 +12,9 @@ outside. Nothing in the core imports a framework, a driver or a UI library (TW-C
12
12
 
13
13
  from __future__ import annotations
14
14
 
15
- __version__ = "0.4.1"
15
+ from importlib.metadata import version
16
+
17
+ __version__ = version("taskwire")
16
18
 
17
19
  from .ambient import ask, current_reporter, progress
18
20
  from .calls import Call, call_token, end_call, execute_call, hand_off, receive_call
@@ -49,7 +49,7 @@ from .models import (
49
49
  ProgressState,
50
50
  Text,
51
51
  )
52
- from .reporter import mark_failed, mark_queued, operation, OperationScope, Reporter
52
+ from .reporter import _mark_failed, mark_queued, operation, OperationScope, Reporter
53
53
  from .rest import _is_uuid
54
54
  from .settings import configured
55
55
  from .store import key as make_key
@@ -59,7 +59,7 @@ logger = logging.getLogger("taskwire.calls")
59
59
  IDEMPOTENCY_KEY_HEADER = "Idempotency-Key"
60
60
  """The header whose key names a call that carries no `X-Taskwire-Token` (TW-CALL-001)."""
61
61
 
62
- SAFE_METHODS = frozenset({"GET", "HEAD", "OPTIONS"})
62
+ UNTRACKED_METHODS = frozenset({"HEAD", "OPTIONS"})
63
63
  """Methods whose `Idempotency-Key` does not make a call tracked (TW-CALL-002)."""
64
64
 
65
65
 
@@ -131,7 +131,7 @@ def call_token(headers: Mapping[str, str] | Iterable[tuple[str, str]], method: s
131
131
  `headers` is a mapping or a sequence of `(name, value)` pairs; names compare case-insensitively.
132
132
  `X-Taskwire-Token` is the token when present. Otherwise the token is the key of a single
133
133
  `Idempotency-Key` header holding a Structured Field string whose content is a UUID, for any
134
- `method` outside `SAFE_METHODS`. A missing, repeated or malformed `Idempotency-Key` leaves the call
134
+ `method` outside `UNTRACKED_METHODS`. A missing, repeated or malformed `Idempotency-Key` leaves the call
135
135
  untracked and is never an error.
136
136
  """
137
137
  token_name, key_name = TOKEN_HEADER.lower(), IDEMPOTENCY_KEY_HEADER.lower()
@@ -142,7 +142,7 @@ def call_token(headers: Mapping[str, str] | Iterable[tuple[str, str]], method: s
142
142
  return value
143
143
  if lowered == key_name:
144
144
  keys.append(value)
145
- if (method is not None and method.upper() in SAFE_METHODS) or len(keys) != 1:
145
+ if (method is not None and method.upper() in UNTRACKED_METHODS) or len(keys) != 1:
146
146
  return None
147
147
  key = _sf_string(keys[0])
148
148
  return key if key is not None and _is_uuid(key) else None
@@ -243,7 +243,7 @@ class CallReceipt:
243
243
  error = Error(code=DISPATCH_FAILED, message=Text(key=DISPATCH_FAILED), retryable=True)
244
244
  else:
245
245
  error = Error(code=NOT_EXECUTED, message=Text(key=NOT_EXECUTED), retryable=False)
246
- await mark_failed(call.token, session=call.session, error=error)
246
+ await _mark_failed(call.token, session=call.session, error=error, call=True)
247
247
  except Exception: # noqa: BLE001 - reporting never replaces the call's own outcome
248
248
  logger.warning("taskwire: could not end the unexecuted operation %s", call.token, exc_info=True)
249
249
 
@@ -321,7 +321,9 @@ class CallExecution:
321
321
  receipt = _receipt.get()
322
322
  if receipt is not None and receipt.call is not None and receipt.call.token == call.token:
323
323
  receipt.started = True
324
- return operation(call.token, session=call.session, connection=call.connection, result_kind=call.result_kind)
324
+ scope = operation(call.token, session=call.session, connection=call.connection, result_kind=call.result_kind)
325
+ scope._call = True
326
+ return scope
325
327
 
326
328
  def _entered(self, scope: OperationScope, reporter: Reporter) -> Reporter:
327
329
  self._scope, self._reporter = scope, reporter
@@ -442,10 +444,11 @@ async def end_call(
442
444
  if queued_only and ProgressState(snapshot.progress.state) is not ProgressState.QUEUED:
443
445
  return False
444
446
  asking = any(DialogState(dialog.state) is DialogState.OPEN for dialog in snapshot.dialogs)
445
- await mark_failed(
447
+ await _mark_failed(
446
448
  call.token,
447
449
  session=call.session,
448
450
  error=asking_error if asking and asking_error is not None else error,
451
+ call=True,
449
452
  )
450
453
  except Exception: # noqa: BLE001 - reporting is an accelerator
451
454
  logger.warning("taskwire: could not end the operation %s", call.token, exc_info=True)
@@ -0,0 +1,59 @@
1
+ """The push delay (TW-THR-008): what a writer publishes while an operation is younger than
2
+ `settings.push_delay`.
3
+
4
+ An operation that ends inside the delay is answered by its own call, and a client shows nothing for
5
+ it (`progressUi.delay`), so its envelopes would be traffic nobody reads. The store is written as
6
+ always (TW-CORE-001); only the publish waits.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from datetime import datetime, timezone
12
+ from typing import Any
13
+
14
+ from .models import Envelope, EnvelopeKind, Progress, Snapshot
15
+ from .settings import settings
16
+
17
+ _FORCED = (EnvelopeKind.DIALOG_OPEN, EnvelopeKind.CANCEL)
18
+ """Published inside the delay too, as a `snapshot`: a question nobody sees is a worker nobody frees."""
19
+
20
+
21
+ def push_delay_left(progress: Progress) -> float:
22
+ """Seconds until the operation of `progress` leaves its push delay; 0 once it has."""
23
+ if settings.push_delay <= 0:
24
+ return 0.0
25
+ try:
26
+ created = datetime.fromisoformat(progress.created_at.replace("Z", "+00:00"))
27
+ except (AttributeError, ValueError):
28
+ return 0.0
29
+ age = (datetime.now(timezone.utc) - created).total_seconds()
30
+ return max(0.0, settings.push_delay - age)
31
+
32
+
33
+ def snapshot_envelope(snapshot: Snapshot) -> Envelope:
34
+ """`snapshot` as the envelope that carries it."""
35
+ return Envelope(token=snapshot.token, rev=snapshot.rev, kind=EnvelopeKind.SNAPSHOT, body=snapshot.to_dict())
36
+
37
+
38
+ async def publish(store: Any, ns: str, key: str, envelope: Envelope, progress: Progress, *, call: bool = False) -> None:
39
+ """Publish `envelope` of the operation at `key`, whose current progress is `progress`.
40
+
41
+ Inside the push delay a dialog open or a cancel publishes the operation's `snapshot`, and a
42
+ terminal state is published unless the operation is a tracked call (`call`), whose caller learns
43
+ the outcome from the call's own answer. Nothing else is published.
44
+ """
45
+ if push_delay_left(progress) <= 0:
46
+ await store.publish(ns, envelope)
47
+ elif envelope.kind in _FORCED:
48
+ snapshot = await store.snapshot(key)
49
+ if snapshot is not None:
50
+ await store.publish(ns, snapshot_envelope(snapshot))
51
+ elif progress.is_terminal and not call:
52
+ await store.publish(ns, envelope)
53
+
54
+
55
+ async def announce(store: Any, ns: str, key: str) -> None:
56
+ """Publish the `snapshot` of the operation at `key` unless it has ended: the push delay is over."""
57
+ snapshot = await store.snapshot(key)
58
+ if snapshot is not None and not snapshot.progress.is_terminal:
59
+ await store.publish(ns, snapshot_envelope(snapshot))
@@ -50,6 +50,7 @@ from .models import (
50
50
  Text,
51
51
  unhandled_exception_error,
52
52
  )
53
+ from .publish import announce, publish, push_delay_left
53
54
  from .settings import configured, settings
54
55
  from .store import CANCELLED_BUTTON, key as make_key
55
56
 
@@ -169,6 +170,8 @@ class Reporter:
169
170
  # TW-RES-004: a clean exit with a result already written lands in `waiting_input`
170
171
  # rather than `done`, and `operation()`'s exit reads this to know which.
171
172
  self._result_parked = False
173
+ # A tracked call's terminal state inside the push delay is not published (TW-THR-008).
174
+ self._call = False
172
175
 
173
176
  # ---------------------------------------------------------------- properties
174
177
 
@@ -394,6 +397,12 @@ class Reporter:
394
397
  unbind(self._ambient_token)
395
398
  self._ambient_token = None
396
399
 
400
+ def _root(self) -> Reporter:
401
+ root = self
402
+ while root._parent is not None:
403
+ root = root._parent
404
+ return root
405
+
397
406
  async def _tick(self) -> None:
398
407
  """The inline throttle (TW-THR-002) and the once-per-interval yield (TW-THR-003)."""
399
408
  now = self._clock()
@@ -428,14 +437,18 @@ class Reporter:
428
437
  self._cancelled = written.cancelled
429
438
  self._raise_if_cancelled(state)
430
439
 
431
- await self._store.publish(
440
+ await publish(
441
+ self._store,
432
442
  self._ns,
443
+ self._key,
433
444
  Envelope(
434
445
  token=self._token,
435
446
  rev=self._rev,
436
447
  kind=EnvelopeKind.PROGRESS,
437
448
  body=self._progress.to_dict(),
438
449
  ),
450
+ self._progress,
451
+ call=self._root()._call,
439
452
  )
440
453
  return self._rev
441
454
 
@@ -567,9 +580,12 @@ class Reporter:
567
580
  # see is a worker nobody can free.
568
581
  await self.flush()
569
582
  rev = await self._store.put_dialog(self._key, request, settings.active_ttl)
570
- await self._store.publish(
583
+ await publish(
584
+ self._store,
571
585
  self._ns,
586
+ self._key,
572
587
  Envelope(token=self._token, rev=rev, kind=EnvelopeKind.DIALOG_OPEN, body=request.to_dict()),
588
+ self._progress,
573
589
  )
574
590
 
575
591
  root = self
@@ -591,8 +607,10 @@ class Reporter:
591
607
 
592
608
  snapshot = await self._store.snapshot(self._key)
593
609
  closed = next((d for d in (snapshot.dialogs if snapshot else []) if d.id == did), None)
594
- await self._store.publish(
610
+ await publish(
611
+ self._store,
595
612
  self._ns,
613
+ self._key,
596
614
  Envelope(
597
615
  token=self._token,
598
616
  rev=snapshot.rev if snapshot else rev,
@@ -603,6 +621,7 @@ class Reporter:
603
621
  "reply": reply.to_dict(),
604
622
  },
605
623
  ),
624
+ self._progress,
606
625
  )
607
626
  # The state returns to `running` on resolution (TW-DLG-009) with nothing written: it was
608
627
  # never written on the way in either. `waiting_input` is derived from the open dialogs
@@ -805,6 +824,7 @@ class OperationScope:
805
824
  self._clock = clock
806
825
  self._reporter: Reporter | None = None
807
826
  self._keepalive: asyncio.Task | None = None
827
+ self._announce: asyncio.Task | None = None
808
828
  self._loop: asyncio.AbstractEventLoop | None = None
809
829
  self._loop_thread: threading.Thread | None = None
810
830
  self._ambient_token: Any = None
@@ -819,6 +839,8 @@ class OperationScope:
819
839
  self._caller_binds_ambient = False
820
840
  # True once the operation was handed to another process, which then owns its terminal write.
821
841
  self._handed_off = False
842
+ # True for the operation of a tracked call (TW-CALL-004), set by `execute_call()`.
843
+ self._call = False
822
844
 
823
845
  @property
824
846
  def _inert(self) -> bool:
@@ -872,15 +894,30 @@ class OperationScope:
872
894
  raise_on_cancel=self._raise_on_cancel,
873
895
  )
874
896
  self._reporter._loop = asyncio.get_running_loop()
897
+ self._reporter._call = self._call
875
898
  # TW-API-001: bind the ambient reporter, so code six frames down can `await progress.set()`
876
899
  # without every function between here and there growing a `reporter` parameter. The
877
900
  # caller-bound form binds around the body instead - see `bind_ambient_in_caller`.
878
901
  if not self._caller_binds_ambient:
879
902
  self._ambient_token = ambient_bind(self._reporter)
880
903
  await self._reporter._commit()
881
- self._keepalive = asyncio.get_running_loop().create_task(self._keepalive_loop(store, k))
904
+ loop = asyncio.get_running_loop()
905
+ self._keepalive = loop.create_task(self._keepalive_loop(store, k))
906
+ delay = push_delay_left(progress)
907
+ if delay > 0:
908
+ self._announce = loop.create_task(self._announce_after(delay, store, ns, k))
882
909
  return self._reporter
883
910
 
911
+ async def _announce_after(self, delay: float, store: Any, ns: str, k: str) -> None:
912
+ """TW-THR-008: the operation's snapshot once its push delay is over, unless it has ended."""
913
+ try:
914
+ await asyncio.sleep(delay)
915
+ await announce(store, ns, k)
916
+ except asyncio.CancelledError: # pragma: no cover - normal shutdown path
917
+ raise
918
+ except Exception: # noqa: BLE001 - a failed push costs latency only (TW-CORE-002)
919
+ logger.debug("taskwire: no snapshot after the push delay for %s", k, exc_info=True)
920
+
884
921
  async def _keepalive_loop(self, store: Any, k: str) -> None:
885
922
  """TW-RET-002: touch every `active_ttl / 4`, without the operation's cooperation.
886
923
 
@@ -907,6 +944,12 @@ class OperationScope:
907
944
  ambient_unbind(self._ambient_token)
908
945
  self._ambient_token = None
909
946
 
947
+ if self._announce is not None:
948
+ self._announce.cancel()
949
+ with contextlib.suppress(asyncio.CancelledError, Exception):
950
+ await self._announce
951
+ self._announce = None
952
+
910
953
  if self._keepalive is not None:
911
954
  self._keepalive.cancel()
912
955
  # The keepalive is being torn down deliberately; whatever it was doing is no longer
@@ -1122,9 +1165,12 @@ async def mark_queued(
1122
1165
  connection=connection,
1123
1166
  )
1124
1167
  written = await store.commit(k, progress, settings.active_ttl)
1125
- await store.publish(
1168
+ await publish(
1169
+ store,
1126
1170
  session,
1171
+ k,
1127
1172
  Envelope(token=token, rev=written.rev, kind=EnvelopeKind.PROGRESS, body=progress.to_dict()),
1173
+ progress,
1128
1174
  )
1129
1175
  return None
1130
1176
 
@@ -1144,6 +1190,18 @@ async def mark_failed(
1144
1190
  TW-REG-007, TW-RET-004): the caller is already watching a token, and a `404` would tell it nothing
1145
1191
  about why the work ended.
1146
1192
  """
1193
+ await _mark_failed(token, session=session, error=error, store=store)
1194
+
1195
+
1196
+ async def _mark_failed(
1197
+ token: str,
1198
+ *,
1199
+ session: str | None,
1200
+ error: BaseException | Error,
1201
+ store: Any = None,
1202
+ call: bool = False,
1203
+ ) -> None:
1204
+ """`mark_failed()`; `call` marks the operation of a tracked call (TW-THR-008)."""
1147
1205
  if session is None:
1148
1206
  return None
1149
1207
  store = store if store is not None else configured.store
@@ -1162,9 +1220,13 @@ async def mark_failed(
1162
1220
  progress.updated_at = now_iso()
1163
1221
  progress.state = ProgressState.FAILED
1164
1222
  written = await store.commit(k, progress, settings.tombstone_ttl)
1165
- await store.publish(
1223
+ await publish(
1224
+ store,
1166
1225
  session,
1226
+ k,
1167
1227
  Envelope(token=token, rev=written.rev, kind=EnvelopeKind.PROGRESS, body=progress.to_dict()),
1228
+ progress,
1229
+ call=call,
1168
1230
  )
1169
1231
  return None
1170
1232
 
@@ -30,6 +30,7 @@ from .models import (
30
30
  ProgressState,
31
31
  WIRE_VERSION,
32
32
  )
33
+ from .publish import publish as _publish
33
34
  from .register import build_register, CEILING_POLL_MS, poll_after_ms
34
35
  from .settings import configured, settings
35
36
  from .store import DialogResolution, key as make_key
@@ -270,9 +271,8 @@ async def request_cancel(client: Client, token: str) -> Response:
270
271
  return 409, {"detail": HOLDS_AN_UNCOLLECTED_RESULT}
271
272
 
272
273
  rev = await store.request_cancel(key)
273
- await store.publish(
274
- client.session,
275
- Envelope(token=token, rev=rev, kind=EnvelopeKind.CANCEL, body={}),
274
+ await _publish(
275
+ store, client.session, key, Envelope(token=token, rev=rev, kind=EnvelopeKind.CANCEL, body={}), progress
276
276
  )
277
277
  return 202, {"detail": REQUESTED}
278
278
 
@@ -320,9 +320,12 @@ async def _release(client: Client, token: str, *, idempotent: bool) -> Response:
320
320
  if after is not None:
321
321
  ended = replace(after.progress, state=ProgressState.DONE, updated_at=now_iso())
322
322
  written = await store.commit(key, ended, settings.tombstone_ttl)
323
- await store.publish(
323
+ await _publish(
324
+ store,
324
325
  client.session,
326
+ key,
325
327
  Envelope(token=token, rev=written.rev, kind=EnvelopeKind.PROGRESS, body=ended.to_dict()),
328
+ ended,
326
329
  )
327
330
  # TW-RES-010: the event must CARRY THE RELEASED RESULT. `release_result` clears `result` off the
328
331
  # document as part of the same atomic step, so a snapshot read afterwards has none - and an
@@ -39,10 +39,14 @@ class Settings:
39
39
  """Backstop on an uncollected result. Seconds; 7 days. Must be aligned with the application's
40
40
  own artefact retention (TW-RET-003) - taskwire stores a pointer and deletes nothing."""
41
41
 
42
- progress_interval: float = 0.25
42
+ progress_interval: float = 0.1
43
43
  """Latest-wins coalescing window for commits (TW-THR-001). Seconds, float, no unit suffix in
44
44
  the name - matching `push_timeout` and `max_overrides`."""
45
45
 
46
+ push_delay: float = 0.25
47
+ """How long after its creation an operation publishes nothing but a dialog open or a cancel
48
+ (TW-THR-008). Seconds; 0 publishes every write at once."""
49
+
46
50
  push_timeout: float = 2.0
47
51
  """Bound on any single `notify()` call (TW-TR-003). Seconds."""
48
52
 
taskwire-0.4.1/.gitignore DELETED
@@ -1,35 +0,0 @@
1
- # Claude Code session artefacts
2
- .claude/
3
-
4
- # Python
5
- __pycache__/
6
- *.py[cod]
7
- *.egg-info/
8
- build/
9
- dist/
10
- .venv/
11
- .pytest_cache/
12
- .ruff_cache/
13
- .mypy_cache/
14
- .coverage
15
- coverage.xml
16
- htmlcov/
17
-
18
- # Node
19
- node_modules/
20
- *.tsbuildinfo
21
- coverage/
22
- # Not committed, matching the muxws repository's convention.
23
- /package-lock.json
24
-
25
- # VitePress
26
- docs/.vitepress/cache/
27
- docs/.vitepress/dist/
28
-
29
- # Editors / OS
30
- .idea/
31
- .vscode/
32
- .DS_Store
33
-
34
- # Scratch drivers written while chasing something down
35
- .scratch/
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes