duroxide 0.1.28__tar.gz → 0.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 (53) hide show
  1. {duroxide-0.1.28 → duroxide-0.2.0}/.agents/skills/pyo3-interop/SKILL.md +4 -4
  2. duroxide-0.2.0/.agents/skills/release-preparation/SKILL.md +61 -0
  3. {duroxide-0.1.28 → duroxide-0.2.0}/.github/copilot-instructions.md +2 -0
  4. duroxide-0.1.28/.github/workflows/publish.yml → duroxide-0.2.0/.github/workflows/build.yml +41 -117
  5. {duroxide-0.1.28 → duroxide-0.2.0}/CHANGELOG.md +57 -0
  6. {duroxide-0.1.28 → duroxide-0.2.0}/Cargo.lock +111 -112
  7. {duroxide-0.1.28 → duroxide-0.2.0}/Cargo.toml +2 -2
  8. {duroxide-0.1.28 → duroxide-0.2.0}/PKG-INFO +7 -1
  9. {duroxide-0.1.28 → duroxide-0.2.0}/README.md +6 -0
  10. duroxide-0.2.0/RELEASE_POLICY.md +28 -0
  11. {duroxide-0.1.28 → duroxide-0.2.0}/docs/architecture.md +7 -7
  12. {duroxide-0.1.28 → duroxide-0.2.0}/docs/user-guide.md +37 -0
  13. {duroxide-0.1.28 → duroxide-0.2.0}/pyproject.toml +1 -1
  14. {duroxide-0.1.28 → duroxide-0.2.0}/python/duroxide/context.py +28 -17
  15. {duroxide-0.1.28 → duroxide-0.2.0}/src/handlers.rs +85 -113
  16. {duroxide-0.1.28 → duroxide-0.2.0}/src/lib.rs +24 -26
  17. {duroxide-0.1.28 → duroxide-0.2.0}/src/runtime.rs +60 -0
  18. duroxide-0.2.0/tests/test_lock_options.py +116 -0
  19. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_races.py +164 -0
  20. duroxide-0.2.0/tests/test_replay_isolation.py +198 -0
  21. duroxide-0.1.28/.agents/skills/pypi-publish/SKILL.md +0 -208
  22. {duroxide-0.1.28 → duroxide-0.2.0}/.agents/skills/duroxide-python-orchestrations/SKILL.md +0 -0
  23. {duroxide-0.1.28 → duroxide-0.2.0}/.env.example +0 -0
  24. {duroxide-0.1.28 → duroxide-0.2.0}/.github/dependabot.yml +0 -0
  25. {duroxide-0.1.28 → duroxide-0.2.0}/.gitignore +0 -0
  26. {duroxide-0.1.28 → duroxide-0.2.0}/CODE_OF_CONDUCT.md +0 -0
  27. {duroxide-0.1.28 → duroxide-0.2.0}/CONTRIBUTING.md +0 -0
  28. {duroxide-0.1.28 → duroxide-0.2.0}/LICENSE +0 -0
  29. {duroxide-0.1.28 → duroxide-0.2.0}/SECURITY.md +0 -0
  30. {duroxide-0.1.28 → duroxide-0.2.0}/ci/smoke/README.md +0 -0
  31. {duroxide-0.1.28 → duroxide-0.2.0}/ci/smoke/run-local.ps1 +0 -0
  32. {duroxide-0.1.28 → duroxide-0.2.0}/ci/smoke/run-local.sh +0 -0
  33. {duroxide-0.1.28 → duroxide-0.2.0}/ci/smoke/run-registry.ps1 +0 -0
  34. {duroxide-0.1.28 → duroxide-0.2.0}/ci/smoke/run-registry.sh +0 -0
  35. {duroxide-0.1.28 → duroxide-0.2.0}/ci/smoke/smoke.py +0 -0
  36. {duroxide-0.1.28 → duroxide-0.2.0}/python/duroxide/__init__.py +0 -0
  37. {duroxide-0.1.28 → duroxide-0.2.0}/python/duroxide/driver.py +0 -0
  38. {duroxide-0.1.28 → duroxide-0.2.0}/src/client.rs +0 -0
  39. {duroxide-0.1.28 → duroxide-0.2.0}/src/pg_provider.rs +0 -0
  40. {duroxide-0.1.28 → duroxide-0.2.0}/src/provider.rs +0 -0
  41. {duroxide-0.1.28 → duroxide-0.2.0}/src/types.rs +0 -0
  42. {duroxide-0.1.28 → duroxide-0.2.0}/tests/scenarios/__init__.py +0 -0
  43. {duroxide-0.1.28 → duroxide-0.2.0}/tests/scenarios/test_toygres.py +0 -0
  44. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_admin_api.py +0 -0
  45. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_advanced_features.py +0 -0
  46. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_async_blocks.py +0 -0
  47. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_copilot_chat.py +0 -0
  48. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_e2e.py +0 -0
  49. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_init_tracing.py +0 -0
  50. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_kv_store.py +0 -0
  51. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_sessions.py +0 -0
  52. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_tags.py +0 -0
  53. {duroxide-0.1.28 → duroxide-0.2.0}/tests/test_typed_apis.py +0 -0
@@ -97,7 +97,7 @@ fn call_create_blocking(&self, payload: String) -> Result<GeneratorStepResult, S
97
97
  Rust (tokio thread) Python (GIL)
98
98
  ─────────────────── ────────────────────
99
99
  1. invoke(ctx, input)
100
- ├─ Store ctx in ORCHESTRATION_CTXS[instance_id]
100
+ ├─ Store ctx in ORCHESTRATION_CTXS[token] // token = "orch-{n}", new for every invocation
101
101
  ├─ call_create_blocking(payload) ──────► create_generator(payload)
102
102
  │ (block_in_place + with_gil) ├─ Create OrchestrationContext
103
103
  │ ├─ Create generator: fn(ctx, input)
@@ -111,7 +111,7 @@ Rust (tokio thread) Python (GIL)
111
111
  │ │ └─ Return next task or completion
112
112
  │ │◄────────────────────────────────────┘
113
113
  │ └─ If completed/error: break
114
- └─ Remove ctx from ORCHESTRATION_CTXS
114
+ └─ Remove ctx from ORCHESTRATION_CTXS[token]
115
115
  ```
116
116
 
117
117
  ## Activity Interop (Synchronous GIL Call)
@@ -148,7 +148,7 @@ static ORCHESTRATION_CTXS: LazyLock<Mutex<HashMap<String, OrchestrationContext>>
148
148
  ```python
149
149
  # In OrchestrationContext (fire-and-forget, no yield)
150
150
  def trace_info(self, message):
151
- orchestration_trace_log(self.instance_id, "info", str(message))
151
+ orchestration_trace_log(self._ctx_token, "info", str(message))
152
152
 
153
153
  # In ActivityContext (fire-and-forget)
154
154
  def trace_info(self, message):
@@ -160,7 +160,7 @@ def trace_info(self, message):
160
160
  1. **Never expose `is_replaying` to Python** — Rust `OrchestrationContext.trace()` handles suppression
161
161
  2. **Always use global maps, not thread-locals** — Python runs on a different thread
162
162
  3. **Clean up map entries on ALL exit paths** — leaked entries cause stale traces
163
- 4. **Use atomic tokens for activities** (not instance_id) — multiple activities for the same instance can run concurrently
163
+ 4. **Use atomic tokens for activities and for orchestrations** (never instance_id) — multiple activities for the same instance can run concurrently, and two replays of one instance can be alive in the same process (a replay that lost its lock keeps running until its commit is rejected). Rust passes the orchestration token in `ctxInfo["_ctxToken"]`; `OrchestrationContext` sends it back on every synchronous native call
164
164
 
165
165
  ## ScheduledTask Protocol
166
166
 
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: release-preparation
3
+ description: Preparing duroxide-python release pull requests. Use when bumping the package version, updating release notes, or preparing a new PyPI release.
4
+ ---
5
+
6
+ # Release Preparation
7
+
8
+ This skill prepares the repository changes for a release. Publishing is handled
9
+ by Microsoft's internal release infrastructure as described in
10
+ `RELEASE_POLICY.md`.
11
+
12
+ Do not publish to PyPI, create a GitHub Release, start the internal release
13
+ pipeline, or request publishing credentials.
14
+
15
+ ## Prepare the Release
16
+
17
+ 1. Confirm the target semantic version with the user if it was not provided.
18
+ 2. Set the same version in:
19
+ - `pyproject.toml` under `[project]`
20
+ - `Cargo.toml` under `[package]`
21
+ 3. Move the relevant entries from `CHANGELOG.md`'s `[Unreleased]` section into
22
+ a section named for the target version and current date.
23
+ 4. Keep an empty `[Unreleased]` section above the new release entry.
24
+ 5. Update directly related documentation when the release changes documented
25
+ behavior.
26
+ 6. Confirm `Cargo.toml` uses registry versions for `duroxide` and
27
+ `duroxide-pg`, with no local path overrides or `[patch.crates-io]` section.
28
+
29
+ Do not invent changelog entries or include unrelated changes in the release
30
+ preparation.
31
+
32
+ ## Validate the Preparation
33
+
34
+ Before presenting the changes:
35
+
36
+ - Confirm the versions in `pyproject.toml` and `Cargo.toml` match.
37
+ - Confirm the changelog version and date are correct.
38
+ - Confirm the diff contains only the intended release preparation.
39
+
40
+ ## Create the Release Pull Request
41
+
42
+ Commit the release preparation, push the branch, and create a pull request.
43
+ Check that its `Build & Smoke` workflow passes. Do not merge the pull request
44
+ on the user's behalf.
45
+
46
+ ## Tag the Merged Release
47
+
48
+ After the pull request is merged:
49
+
50
+ 1. Resolve the pull request's exact merge commit SHA from GitHub and confirm
51
+ the pull request state is `MERGED`.
52
+ 2. Fetch `origin/main`, confirm the merge SHA is contained in it, and verify the
53
+ package and changelog versions at that exact commit.
54
+ 3. Ask the user for explicit approval to create and push the release tag. Prior
55
+ approval to prepare the release or create the pull request is not sufficient.
56
+ 4. Confirm the `v`-prefixed tag does not already exist locally or on `origin`.
57
+ 5. Create the tag on the recorded merge SHA and push it to `origin`.
58
+
59
+ For example, package version `0.1.29` uses tag `v0.1.29`. Treat release tags as
60
+ immutable; never move or reuse an existing tag. Never substitute the current
61
+ `origin/main` or `HEAD` tip for the release pull request's merge SHA.
@@ -124,6 +124,8 @@ static ACTIVITY_CTXS: LazyLock<Mutex<HashMap<String, ActivityContext>>>
124
124
 
125
125
  Python `ctx.trace_info()` → PyO3 function → looks up Rust context by key → delegates to `ctx.trace()`.
126
126
 
127
+ Both maps are keyed by an atomic token that is new for every invocation (`act-{n}`, `orch-{n}`), never by `instance_id`: two replays of one instance can be alive in the same process, and each must only reach its own context. Rust passes the orchestration token in `ctxInfo["_ctxToken"]`.
128
+
127
129
  ## ScheduledTask Protocol
128
130
 
129
131
  Python `OrchestrationContext` methods return dicts with a `"type"` key. Rust deserializes to `ScheduledTask` enum:
@@ -1,18 +1,46 @@
1
- name: Build, Smoke & Publish
1
+ name: Build & Smoke
2
2
 
3
3
  on:
4
4
  pull_request:
5
5
  push:
6
6
  branches: [main]
7
- release:
8
- types: [published]
9
7
  workflow_dispatch:
10
8
 
11
9
  permissions:
12
10
  contents: read
13
- issues: write # smoke-registry opens an issue on failure
14
11
 
15
12
  jobs:
13
+ tests:
14
+ name: Tests
15
+ runs-on: ubuntu-latest
16
+ services:
17
+ postgres:
18
+ image: postgres:16
19
+ env:
20
+ POSTGRES_DB: duroxide
21
+ POSTGRES_PASSWORD: postgres
22
+ ports:
23
+ - 5432:5432
24
+ options: >-
25
+ --health-cmd "pg_isready -U postgres -d duroxide"
26
+ --health-interval 10s
27
+ --health-timeout 5s
28
+ --health-retries 5
29
+ env:
30
+ DATABASE_URL: postgresql://postgres:postgres@localhost:5432/duroxide
31
+ steps:
32
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
33
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
34
+ with:
35
+ python-version: "3.12"
36
+ - name: Install package and test dependencies
37
+ run: |
38
+ python -m venv .venv
39
+ .venv/bin/python -m pip install --upgrade pip
40
+ .venv/bin/python -m pip install --editable ".[dev]"
41
+ - name: Run tests
42
+ run: .venv/bin/python -m pytest -v
43
+
16
44
  # ── macOS (ARM64 + x86_64) ─────────────────────────────────
17
45
  macos:
18
46
  runs-on: macos-latest
@@ -110,7 +138,7 @@ jobs:
110
138
  name: wheels-sdist
111
139
  path: dist/*.tar.gz
112
140
 
113
- # ── Pre-publish smoke: install wheel into fresh venv on real OSes ──
141
+ # ── Packaging smoke: install wheel into fresh venv on real OSes ──
114
142
  smoke-local:
115
143
  name: Smoke (local) ${{ matrix.os }} py${{ matrix.python }}
116
144
  needs: [macos, linux, windows]
@@ -119,17 +147,12 @@ jobs:
119
147
  strategy:
120
148
  fail-fast: false
121
149
  matrix:
122
- include:
123
- - os: ubuntu-latest
124
- shell: bash
125
- - os: ubuntu-24.04-arm
126
- shell: bash
127
- - os: macos-14 # arm64
128
- shell: bash
129
- - os: macos-13 # x64
130
- shell: bash
131
- - os: windows-latest
132
- shell: pwsh
150
+ os:
151
+ - ubuntu-latest
152
+ - ubuntu-24.04-arm
153
+ - macos-14 # arm64
154
+ - macos-15-intel # x64
155
+ - windows-latest
133
156
  python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
134
157
  runs-on: ${{ matrix.os }}
135
158
  steps:
@@ -160,114 +183,15 @@ jobs:
160
183
  }
161
184
  done
162
185
  - name: Run smoke (local wheel)
163
- if: matrix.shell == 'bash'
186
+ if: runner.os != 'Windows'
164
187
  env:
165
188
  WHEEL_DIR: ${{ github.workspace }}/wheels
166
189
  SMOKE_SCRIPT: ${{ github.workspace }}/ci/smoke/smoke.py
167
190
  run: bash ci/smoke/run-local.sh
168
191
  - name: Run smoke (local wheel, Windows)
169
- if: matrix.shell == 'pwsh'
192
+ if: runner.os == 'Windows'
170
193
  shell: pwsh
171
194
  env:
172
195
  WHEEL_DIR: ${{ github.workspace }}/wheels
173
196
  SMOKE_SCRIPT: ${{ github.workspace }}/ci/smoke/smoke.py
174
197
  run: pwsh ci/smoke/run-local.ps1
175
-
176
- # ── Publish to PyPI ─────────────────────────────────────────
177
- publish:
178
- name: Publish to PyPI
179
- runs-on: ubuntu-latest
180
- if: github.event_name == 'release'
181
- needs: [macos, linux, windows, sdist, smoke-local]
182
- environment:
183
- name: pypi
184
- url: https://pypi.org/p/duroxide
185
- permissions:
186
- id-token: write # trusted publishing
187
- steps:
188
- - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
189
- with:
190
- pattern: wheels-*
191
- merge-multiple: true
192
- path: dist
193
- - name: List wheels
194
- run: ls -lh dist/
195
- - name: Publish to PyPI
196
- uses: pypa/gh-action-pypi-publish@release/v1
197
- with:
198
- skip-existing: true
199
-
200
- # ── Post-publish smoke: install from real PyPI on real OSes ──
201
- smoke-registry:
202
- name: Smoke (registry) ${{ matrix.os }} py${{ matrix.python }}
203
- if: github.event_name == 'release'
204
- needs: [publish]
205
- env:
206
- PIP_ONLY_BINARY: duroxide
207
- strategy:
208
- fail-fast: false
209
- matrix:
210
- include:
211
- - os: ubuntu-latest
212
- shell: bash
213
- - os: ubuntu-24.04-arm
214
- shell: bash
215
- - os: macos-14
216
- shell: bash
217
- - os: macos-13
218
- shell: bash
219
- - os: windows-latest
220
- shell: pwsh
221
- python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
222
- runs-on: ${{ matrix.os }}
223
- steps:
224
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
225
- - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
226
- with:
227
- python-version: ${{ matrix.python }}
228
- - name: Normalize version (strip leading v)
229
- id: ver
230
- shell: bash
231
- run: |
232
- V="${{ github.event.release.tag_name }}"
233
- V="${V#v}"
234
- echo "version=$V" >> "$GITHUB_OUTPUT"
235
- - name: Run smoke (registry install)
236
- if: matrix.shell == 'bash'
237
- env:
238
- DUROXIDE_VERSION: ${{ steps.ver.outputs.version }}
239
- SMOKE_SCRIPT: ${{ github.workspace }}/ci/smoke/smoke.py
240
- run: bash ci/smoke/run-registry.sh
241
- - name: Run smoke (registry install, Windows)
242
- if: matrix.shell == 'pwsh'
243
- shell: pwsh
244
- env:
245
- DUROXIDE_VERSION: ${{ steps.ver.outputs.version }}
246
- SMOKE_SCRIPT: ${{ github.workspace }}/ci/smoke/smoke.py
247
- run: pwsh ci/smoke/run-registry.ps1
248
-
249
- smoke-registry-report:
250
- name: Report registry smoke failure
251
- if: github.event_name == 'release' && failure() && needs.smoke-registry.result == 'failure'
252
- needs: [smoke-registry]
253
- runs-on: ubuntu-latest
254
- steps:
255
- - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
256
- with:
257
- script: |
258
- const tag = context.payload.release.tag_name;
259
- const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
260
- await github.rest.issues.create({
261
- owner: context.repo.owner,
262
- repo: context.repo.repo,
263
- title: `Post-publish smoke FAILED for ${tag}`,
264
- body: [
265
- `Post-publish (PyPI registry) smoke failed for release \`${tag}\`.`,
266
- ``,
267
- `Run: ${runUrl}`,
268
- ``,
269
- `Consumers installing \`duroxide==${tag.replace(/^v/,'')}\` from PyPI may be broken on one or more platforms.`,
270
- `The release has NOT been auto-yanked. Action: investigate, patch, release a new version, and yank the bad one via PyPI UI if needed.`,
271
- ].join('\n'),
272
- labels: ['bug', 'release-smoke'],
273
- });
@@ -7,6 +7,63 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.0] - 2026-10-04
11
+
12
+ ### Changed
13
+
14
+ - **Breaking: `ctx.race()` and `ctx.race_typed()` raise when the winner failed.** Before, a
15
+ winning activity or sub-orchestration that failed came back like a success:
16
+ `{"index": ..., "value": ...}`, with the error text in `value`. Nothing marked it as an
17
+ error. Now the `yield` raises the same exception as yielding that task on its own: same
18
+ type, same message. If the orchestration does not catch it, the orchestration fails.
19
+ - Winners that succeeded, timers, events and dequeued messages return
20
+ `{"index": ..., "value": ...}` as before.
21
+ - Code that read the error text from `value` must catch the exception instead.
22
+ - A race over a task type that `race()` does not support now raises
23
+ `unsupported task in select`. Before, it returned that text as the value.
24
+ - Instances in flight: if a history already holds a race won by a failed task, the replay
25
+ now raises at that race. If the code then takes a different path than the first run did,
26
+ the instance fails. Upgrade when no such instance is running.
27
+
28
+ ### Added
29
+
30
+ - **`worker_lock_renewal_buffer_ms`, `session_lock_timeout_ms`,
31
+ `session_lock_renewal_buffer_ms` runtime options** — map to `worker_lock_renewal_buffer`,
32
+ `session_lock_timeout` and `session_lock_renewal_buffer` of the Rust runtime. Keyword
33
+ arguments of `RuntimeOptions`, added after the existing ones. With these, every lock
34
+ timeout and renewal buffer of the runtime can be set from Python.
35
+ - `tests/test_lock_options.py` — checks that every lock option reaches the runtime, from the
36
+ renewal intervals the runtime logs.
37
+
38
+ ## [0.1.29] - 2026-10-03
39
+
40
+ ### Fixed
41
+
42
+ - **Replays of the same instance no longer share a native context.** The synchronous
43
+ context calls (`ctx.set_kv_value` / `ctx.get_kv_value` and the other KV calls,
44
+ `ctx.set_custom_status` / `ctx.get_custom_status`, and `ctx.trace_*`) found the Rust
45
+ `OrchestrationContext` by instance ID. Two replays of one instance can be alive in the
46
+ same process: a replay that lost its orchestration lock (for example after the process
47
+ stalled for longer than the lock timeout) keeps running until its commit is rejected,
48
+ and another dispatcher slot can fetch the instance again. Calls from one replay then
49
+ reached the other. The replay that held the lock could commit events it never
50
+ produced, and the next replay failed with `nondeterministic: kv set mismatch` or
51
+ `nondeterministic: schedule mismatch`. The context is now looked up by a token that is
52
+ new for every invocation, the same way activity contexts already work.
53
+
54
+ ### Changed
55
+
56
+ - **Bumped `duroxide-pg` dependency** — `0.1.34` → `0.1.35`.
57
+
58
+ ### Added
59
+
60
+ - **`orchestrator_lock_timeout_ms`, `orchestrator_lock_renewal_buffer_ms`, `max_attempts`
61
+ runtime options** — map to `orchestrator_lock_timeout`, `orchestrator_lock_renewal_buffer`
62
+ and `max_attempts` of the Rust runtime. Keyword arguments of `RuntimeOptions`, added after
63
+ the existing ones.
64
+ - `tests/test_replay_isolation.py` — regression tests that stop the process in the middle
65
+ of a replay for longer than the orchestration lock timeout (POSIX only).
66
+
10
67
  ## [0.1.28] - 2026-09-03
11
68
 
12
69
  ### Changed