tapio-py 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. tapio_py-0.1.0/.github/pull_request_template.md +40 -0
  2. tapio_py-0.1.0/.github/workflows/ci.yml +179 -0
  3. tapio_py-0.1.0/.gitignore +36 -0
  4. tapio_py-0.1.0/.pre-commit-config.yaml +28 -0
  5. tapio_py-0.1.0/AGENTS.md +175 -0
  6. tapio_py-0.1.0/CLAUDE.md +5 -0
  7. tapio_py-0.1.0/LICENSE +202 -0
  8. tapio_py-0.1.0/Makefile +133 -0
  9. tapio_py-0.1.0/PKG-INFO +273 -0
  10. tapio_py-0.1.0/README.md +246 -0
  11. tapio_py-0.1.0/docs/blocking.md +77 -0
  12. tapio_py-0.1.0/docs/getting-started.md +437 -0
  13. tapio_py-0.1.0/docs/index.md +24 -0
  14. tapio_py-0.1.0/docs/lifecycle.md +117 -0
  15. tapio_py-0.1.0/docs/reference.md +173 -0
  16. tapio_py-0.1.0/docs/remoting.md +153 -0
  17. tapio_py-0.1.0/docs/security.md +111 -0
  18. tapio_py-0.1.0/docs/supervision.md +120 -0
  19. tapio_py-0.1.0/docs/testing.md +139 -0
  20. tapio_py-0.1.0/docs/unreachable.md +114 -0
  21. tapio_py-0.1.0/examples/README.md +73 -0
  22. tapio_py-0.1.0/examples/pyproject.toml +19 -0
  23. tapio_py-0.1.0/examples/tapio_examples/__init__.py +8 -0
  24. tapio_py-0.1.0/examples/tapio_examples/ask_timeout.py +161 -0
  25. tapio_py-0.1.0/examples/tapio_examples/blocking_offload.py +181 -0
  26. tapio_py-0.1.0/examples/tapio_examples/chat_sessions.py +267 -0
  27. tapio_py-0.1.0/examples/tapio_examples/counter.py +101 -0
  28. tapio_py-0.1.0/examples/tapio_examples/dead_letters.py +106 -0
  29. tapio_py-0.1.0/examples/tapio_examples/death_watch.py +131 -0
  30. tapio_py-0.1.0/examples/tapio_examples/escalation.py +186 -0
  31. tapio_py-0.1.0/examples/tapio_examples/fastapi_app.py +214 -0
  32. tapio_py-0.1.0/examples/tapio_examples/graceful_shutdown.py +123 -0
  33. tapio_py-0.1.0/examples/tapio_examples/hello_world.py +93 -0
  34. tapio_py-0.1.0/examples/tapio_examples/node_failure.py +182 -0
  35. tapio_py-0.1.0/examples/tapio_examples/order_saga.py +283 -0
  36. tapio_py-0.1.0/examples/tapio_examples/partition.py +230 -0
  37. tapio_py-0.1.0/examples/tapio_examples/ping_pong.py +99 -0
  38. tapio_py-0.1.0/examples/tapio_examples/rate_limiter.py +158 -0
  39. tapio_py-0.1.0/examples/tapio_examples/remote_ask.py +158 -0
  40. tapio_py-0.1.0/examples/tapio_examples/remote_spawn.py +253 -0
  41. tapio_py-0.1.0/examples/tapio_examples/stash_on_startup.py +135 -0
  42. tapio_py-0.1.0/examples/tapio_examples/state_machine.py +207 -0
  43. tapio_py-0.1.0/examples/tapio_examples/supervision_backoff.py +174 -0
  44. tapio_py-0.1.0/examples/tapio_examples/two_nodes.py +143 -0
  45. tapio_py-0.1.0/examples/tapio_examples/worker_pool.py +180 -0
  46. tapio_py-0.1.0/examples/tapio_examples/worker_pool_remote.py +260 -0
  47. tapio_py-0.1.0/mkdocs.yml +51 -0
  48. tapio_py-0.1.0/pyproject.toml +167 -0
  49. tapio_py-0.1.0/src/tapio/__init__.py +122 -0
  50. tapio_py-0.1.0/src/tapio/actor/__init__.py +90 -0
  51. tapio_py-0.1.0/src/tapio/actor/adapter.py +217 -0
  52. tapio_py-0.1.0/src/tapio/actor/ask.py +375 -0
  53. tapio_py-0.1.0/src/tapio/actor/behavior.py +719 -0
  54. tapio_py-0.1.0/src/tapio/actor/cell.py +1403 -0
  55. tapio_py-0.1.0/src/tapio/actor/context.py +264 -0
  56. tapio_py-0.1.0/src/tapio/actor/dead_letters.py +370 -0
  57. tapio_py-0.1.0/src/tapio/actor/events.py +112 -0
  58. tapio_py-0.1.0/src/tapio/actor/mailbox.py +350 -0
  59. tapio_py-0.1.0/src/tapio/actor/path.py +92 -0
  60. tapio_py-0.1.0/src/tapio/actor/ref.py +193 -0
  61. tapio_py-0.1.0/src/tapio/actor/router.py +239 -0
  62. tapio_py-0.1.0/src/tapio/actor/signals.py +82 -0
  63. tapio_py-0.1.0/src/tapio/actor/stash.py +148 -0
  64. tapio_py-0.1.0/src/tapio/actor/supervision.py +231 -0
  65. tapio_py-0.1.0/src/tapio/actor/system.py +610 -0
  66. tapio_py-0.1.0/src/tapio/actor/timers.py +260 -0
  67. tapio_py-0.1.0/src/tapio/actor/watch.py +96 -0
  68. tapio_py-0.1.0/src/tapio/dispatch/__init__.py +10 -0
  69. tapio_py-0.1.0/src/tapio/dispatch/blocking.py +174 -0
  70. tapio_py-0.1.0/src/tapio/dispatch/dispatcher.py +76 -0
  71. tapio_py-0.1.0/src/tapio/errors.py +197 -0
  72. tapio_py-0.1.0/src/tapio/logging.py +57 -0
  73. tapio_py-0.1.0/src/tapio/message.py +30 -0
  74. tapio_py-0.1.0/src/tapio/py.typed +0 -0
  75. tapio_py-0.1.0/src/tapio/remote/__init__.py +10 -0
  76. tapio_py-0.1.0/src/tapio/remote/address.py +179 -0
  77. tapio_py-0.1.0/src/tapio/remote/association.py +1008 -0
  78. tapio_py-0.1.0/src/tapio/remote/codec.py +418 -0
  79. tapio_py-0.1.0/src/tapio/remote/context.py +108 -0
  80. tapio_py-0.1.0/src/tapio/remote/endpoint.py +729 -0
  81. tapio_py-0.1.0/src/tapio/remote/failure.py +195 -0
  82. tapio_py-0.1.0/src/tapio/remote/handshake.py +310 -0
  83. tapio_py-0.1.0/src/tapio/remote/protocol.py +37 -0
  84. tapio_py-0.1.0/src/tapio/remote/ref.py +289 -0
  85. tapio_py-0.1.0/src/tapio/remote/registry.py +165 -0
  86. tapio_py-0.1.0/src/tapio/remote/spawner.py +555 -0
  87. tapio_py-0.1.0/src/tapio/remote/transport.py +489 -0
  88. tapio_py-0.1.0/src/tapio/settings.py +199 -0
  89. tapio_py-0.1.0/src/tapio/testkit/__init__.py +47 -0
  90. tapio_py-0.1.0/src/tapio/testkit/behavior.py +499 -0
  91. tapio_py-0.1.0/src/tapio/testkit/leaks.py +69 -0
  92. tapio_py-0.1.0/src/tapio/testkit/plugin.py +104 -0
  93. tapio_py-0.1.0/src/tapio/testkit/probe.py +332 -0
  94. tapio_py-0.1.0/src/tapio/testkit/remote.py +329 -0
  95. tapio_py-0.1.0/src/tapio/validation.py +155 -0
  96. tapio_py-0.1.0/src/tapio/version.py +34 -0
  97. tapio_py-0.1.0/tests/__init__.py +1 -0
  98. tapio_py-0.1.0/tests/actor/__init__.py +1 -0
  99. tapio_py-0.1.0/tests/actor/test_adapter.py +397 -0
  100. tapio_py-0.1.0/tests/actor/test_ask.py +485 -0
  101. tapio_py-0.1.0/tests/actor/test_behavior.py +286 -0
  102. tapio_py-0.1.0/tests/actor/test_dead_letters.py +348 -0
  103. tapio_py-0.1.0/tests/actor/test_death_watch.py +231 -0
  104. tapio_py-0.1.0/tests/actor/test_delivery.py +171 -0
  105. tapio_py-0.1.0/tests/actor/test_events.py +64 -0
  106. tapio_py-0.1.0/tests/actor/test_mailbox.py +78 -0
  107. tapio_py-0.1.0/tests/actor/test_overflow.py +160 -0
  108. tapio_py-0.1.0/tests/actor/test_path.py +88 -0
  109. tapio_py-0.1.0/tests/actor/test_ref.py +99 -0
  110. tapio_py-0.1.0/tests/actor/test_router.py +273 -0
  111. tapio_py-0.1.0/tests/actor/test_stash.py +252 -0
  112. tapio_py-0.1.0/tests/actor/test_supervision.py +450 -0
  113. tapio_py-0.1.0/tests/actor/test_system.py +195 -0
  114. tapio_py-0.1.0/tests/actor/test_timers.py +301 -0
  115. tapio_py-0.1.0/tests/benchmarks/conftest.py +28 -0
  116. tapio_py-0.1.0/tests/benchmarks/machine.py +88 -0
  117. tapio_py-0.1.0/tests/benchmarks/resident.py +162 -0
  118. tapio_py-0.1.0/tests/benchmarks/test_benchmarks.py +447 -0
  119. tapio_py-0.1.0/tests/conftest.py +110 -0
  120. tapio_py-0.1.0/tests/dispatch/__init__.py +0 -0
  121. tapio_py-0.1.0/tests/dispatch/test_blocking.py +238 -0
  122. tapio_py-0.1.0/tests/docs/__init__.py +0 -0
  123. tapio_py-0.1.0/tests/docs/test_testing_page.py +230 -0
  124. tapio_py-0.1.0/tests/examples/test_suite.py +448 -0
  125. tapio_py-0.1.0/tests/failures.py +102 -0
  126. tapio_py-0.1.0/tests/messages.py +34 -0
  127. tapio_py-0.1.0/tests/remote/__init__.py +1 -0
  128. tapio_py-0.1.0/tests/remote/conftest.py +32 -0
  129. tapio_py-0.1.0/tests/remote/peers.py +242 -0
  130. tapio_py-0.1.0/tests/remote/test_address.py +121 -0
  131. tapio_py-0.1.0/tests/remote/test_ask.py +137 -0
  132. tapio_py-0.1.0/tests/remote/test_association.py +335 -0
  133. tapio_py-0.1.0/tests/remote/test_codec.py +557 -0
  134. tapio_py-0.1.0/tests/remote/test_endpoint.py +222 -0
  135. tapio_py-0.1.0/tests/remote/test_handshake.py +167 -0
  136. tapio_py-0.1.0/tests/remote/test_registry.py +204 -0
  137. tapio_py-0.1.0/tests/remote/test_spawner.py +499 -0
  138. tapio_py-0.1.0/tests/remote/test_transport.py +149 -0
  139. tapio_py-0.1.0/tests/remote/test_unreachable.py +196 -0
  140. tapio_py-0.1.0/tests/remote/test_watch.py +158 -0
  141. tapio_py-0.1.0/tests/test_logging.py +46 -0
  142. tapio_py-0.1.0/tests/test_package.py +27 -0
  143. tapio_py-0.1.0/tests/test_validation.py +253 -0
  144. tapio_py-0.1.0/tests/testkit/__init__.py +1 -0
  145. tapio_py-0.1.0/tests/testkit/test_behavior_kit.py +314 -0
  146. tapio_py-0.1.0/tests/testkit/test_leaks.py +62 -0
  147. tapio_py-0.1.0/tests/testkit/test_plugin.py +68 -0
  148. tapio_py-0.1.0/tests/testkit/test_probe.py +186 -0
  149. tapio_py-0.1.0/tests/testkit/test_remote.py +92 -0
  150. tapio_py-0.1.0/uv.lock +1827 -0
@@ -0,0 +1,40 @@
1
+ <!--
2
+ Keep this short. The diff says what changed; this says why, and what a
3
+ reviewer should look at hardest. Delete any section that does not apply.
4
+ -->
5
+
6
+ ## What and why
7
+
8
+ <!-- One or two sentences. If it closes an issue: Closes #NNN. -->
9
+
10
+ ## Design notes
11
+
12
+ <!--
13
+ Anything a reviewer would otherwise have to reverse-engineer: a tradeoff you
14
+ made, an alternative you rejected and the reason, a semantic that is
15
+ observable and therefore load-bearing. If a decision here contradicts the
16
+ design doc, say so explicitly. That is a decision, not an oversight.
17
+ -->
18
+
19
+ ## Verification
20
+
21
+ <!--
22
+ How you know it works, beyond "CI is green". Name the tests that would fail
23
+ if this regressed.
24
+ -->
25
+
26
+ - [ ] `make check` passes locally (lint, mypy strict, tests)
27
+ - [ ] New behaviour has a test that fails without the change
28
+ - [ ] Public API changes are reflected in the docs
29
+
30
+ ## Risk
31
+
32
+ <!--
33
+ Breaking changes, new failure modes, anything that only shows up under
34
+ concurrency or shutdown. "None" is a fine answer, so say it rather than
35
+ leaving this blank.
36
+ -->
37
+
38
+ ## Not in this PR
39
+
40
+ <!-- Deliberate follow-ups, so they read as scoping rather than omissions. -->
@@ -0,0 +1,179 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: ${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ # The pipeline never re-spells the commands: it calls `make ci`, which is the
14
+ # same gate developers run locally.
15
+ ci:
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ python-version: ["3.11", "3.12", "3.13"]
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v5
26
+ with:
27
+ enable-cache: true
28
+
29
+ - name: Pin Python ${{ matrix.python-version }}
30
+ run: uv python pin ${{ matrix.python-version }}
31
+
32
+ - name: make ci
33
+ run: make ci
34
+
35
+ # The badge is written from one leg of the matrix only: three legs racing
36
+ # a PATCH against the same gist would publish whichever finished last.
37
+ #
38
+ # Dormant until the repository variable COVERAGE_GIST_ID is set, in the
39
+ # same spirit as PUBLISH_DOCS below. It also needs a GIST_TOKEN secret: a
40
+ # personal access token with the `gist` scope, because the built-in
41
+ # GITHUB_TOKEN is scoped to the repository and cannot write gists.
42
+ - name: Publish the coverage badge
43
+ if: >-
44
+ matrix.python-version == '3.12'
45
+ && github.ref == 'refs/heads/main'
46
+ && github.event_name == 'push'
47
+ && vars.COVERAGE_GIST_ID != ''
48
+ env:
49
+ GH_TOKEN: ${{ secrets.GIST_TOKEN }}
50
+ GIST_ID: ${{ vars.COVERAGE_GIST_ID }}
51
+ run: |
52
+ # The secrets context is not readable from a step `if`, so the token
53
+ # is checked here: a repository without GIST_TOKEN yet should skip
54
+ # the badge, not fail the gate.
55
+ if [ -z "${GH_TOKEN:-}" ]; then
56
+ echo "GIST_TOKEN is not set, skipping the coverage badge."
57
+ exit 0
58
+ fi
59
+ total=$(uv run coverage report --format=total)
60
+ if [ "$total" -ge 90 ]; then color=brightgreen
61
+ elif [ "$total" -ge 80 ]; then color=green
62
+ elif [ "$total" -ge 70 ]; then color=yellowgreen
63
+ elif [ "$total" -ge 60 ]; then color=yellow
64
+ else color=red
65
+ fi
66
+ jq -n --arg message "$total%" --arg color "$color" \
67
+ '{files: {"tapio-coverage.json": {content: (
68
+ {schemaVersion: 1, label: "coverage", message: $message, color: $color}
69
+ | tojson)}}}' \
70
+ | gh api -X PATCH "/gists/$GIST_ID" --input -
71
+
72
+ # Publishing is a step of the same pipeline, not a workflow of its own: the
73
+ # site only goes out if the gate above passed, on main, and it is built by
74
+ # the same `make docs-build` that runs locally.
75
+ #
76
+ # Dormant until the repository variable PUBLISH_DOCS is set to "true", which
77
+ # is the switch to flip once Pages is enabled for this repository. Pages on a
78
+ # private repository needs a paid plan, so a job that always ran would fail
79
+ # every push to main until then.
80
+ docs:
81
+ needs: ci
82
+ if: >-
83
+ github.ref == 'refs/heads/main'
84
+ && github.event_name == 'push'
85
+ && vars.PUBLISH_DOCS == 'true'
86
+ runs-on: ubuntu-latest
87
+ permissions:
88
+ pages: write
89
+ id-token: write
90
+ environment:
91
+ name: github-pages
92
+ url: ${{ steps.deploy.outputs.page_url }}
93
+ steps:
94
+ - uses: actions/checkout@v4
95
+
96
+ - name: Install uv
97
+ uses: astral-sh/setup-uv@v5
98
+ with:
99
+ enable-cache: true
100
+
101
+ - name: make docs-build
102
+ run: make docs-build
103
+
104
+ - uses: actions/configure-pages@v5
105
+
106
+ - uses: actions/upload-pages-artifact@v3
107
+ with:
108
+ path: site
109
+
110
+ - id: deploy
111
+ uses: actions/deploy-pages@v4
112
+
113
+ # Versions come from the commits. `feat:` moves the minor, `fix:` the patch,
114
+ # and the job tags what it bumped, so nobody edits two files by hand and
115
+ # nobody has to remember which release a change went out in.
116
+ #
117
+ # This is only safe because a link is pinned to PROTOCOL_VERSION rather than
118
+ # to the release: bumping the version no longer refuses a peer, so a rolling
119
+ # deploy survives a patch release and a bot may do the bumping.
120
+ #
121
+ # Dormant until the repository variable AUTORELEASE is set to "true", in the
122
+ # same spirit as PUBLISH_DOCS above. Publishing to PyPI is deliberately not
123
+ # here: this job tags, builds and attaches the artifacts to a GitHub release,
124
+ # and `uv publish` stays a decision somebody makes.
125
+ release:
126
+ needs: ci
127
+ if: >-
128
+ github.ref == 'refs/heads/main'
129
+ && github.event_name == 'push'
130
+ && vars.AUTORELEASE == 'true'
131
+ runs-on: ubuntu-latest
132
+ # Its own group, and never cancelled: the workflow-level concurrency
133
+ # cancels in progress, and a release interrupted between tagging and
134
+ # publishing leaves a tag nobody built.
135
+ concurrency:
136
+ group: release
137
+ cancel-in-progress: false
138
+ permissions:
139
+ contents: write
140
+ steps:
141
+ - uses: actions/checkout@v4
142
+ with:
143
+ # The whole history, because the next version is a function of every
144
+ # commit since the last tag.
145
+ fetch-depth: 0
146
+
147
+ - name: Install uv
148
+ uses: astral-sh/setup-uv@v5
149
+ with:
150
+ enable-cache: true
151
+
152
+ # The bump commit and the tag are pushed with the built-in token, and a
153
+ # push made with that token does not trigger workflows. That is what
154
+ # stops the release from starting this pipeline again.
155
+ - name: make release
156
+ env:
157
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158
+ run: make release
159
+
160
+ # Separate from the tag on purpose. Tagging is reversible and an upload
161
+ # is not: PyPI never lets a version be re-used, even after a deletion,
162
+ # so this waits on its own variable rather than riding on AUTORELEASE.
163
+ #
164
+ # The alternative to a token is trusted publishing, where PyPI accepts an
165
+ # OIDC identity from this workflow and no secret exists to leak. Worth
166
+ # moving to once the project exists on PyPI.
167
+ - name: make publish
168
+ if: vars.PUBLISH_PYPI == 'true'
169
+ env:
170
+ UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
171
+ run: |
172
+ # Checked here rather than in the step `if`, because the secrets
173
+ # context is not readable from one. A repository with the variable
174
+ # set and no token should say so, not upload nothing quietly.
175
+ if [ -z "${UV_PUBLISH_TOKEN:-}" ]; then
176
+ echo "PUBLISH_PYPI is true but UV_PUBLISH_TOKEN is not set."
177
+ exit 1
178
+ fi
179
+ make publish
@@ -0,0 +1,36 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.so
5
+
6
+ # Packaging / build
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+
11
+ # Environments — uv.lock IS committed; .venv is not
12
+ .venv/
13
+ .python-version
14
+
15
+ # Tooling caches
16
+ .pytest_cache/
17
+ .mypy_cache/
18
+ .ruff_cache/
19
+ .benchmarks/
20
+
21
+ # Coverage
22
+ .coverage
23
+ .coverage.*
24
+ htmlcov/
25
+ coverage.xml
26
+
27
+ # Docs build output
28
+ site/
29
+
30
+ # Local working docs (not versioned by choice)
31
+ PLAN.md
32
+
33
+ # Editors / OS
34
+ .idea/
35
+ .vscode/
36
+ .DS_Store
@@ -0,0 +1,28 @@
1
+ default_install_hook_types: [pre-commit]
2
+
3
+ repos:
4
+ - repo: https://github.com/pre-commit/pre-commit-hooks
5
+ rev: v4.6.0
6
+ hooks:
7
+ - id: check-added-large-files
8
+ - id: check-merge-conflict
9
+ - id: check-toml
10
+ - id: check-yaml
11
+ - id: end-of-file-fixer
12
+ - id: trailing-whitespace
13
+
14
+ - repo: https://github.com/astral-sh/ruff-pre-commit
15
+ rev: v0.5.7
16
+ hooks:
17
+ - id: ruff
18
+ args: [--fix]
19
+ - id: ruff-format
20
+
21
+ - repo: local
22
+ hooks:
23
+ - id: mypy
24
+ name: mypy --strict
25
+ entry: uv run mypy --strict src/tapio examples/tapio_examples
26
+ language: system
27
+ pass_filenames: false
28
+ types: [python]
@@ -0,0 +1,175 @@
1
+ # Working in this repository
2
+
3
+ tapio is a Pekko-inspired actor toolkit for Python: local, typed,
4
+ asyncio-native actors with supervision, and Pydantic models throughout.
5
+
6
+ ## Commands
7
+
8
+ `make` with no target lists everything. The Makefile is the single source of
9
+ truth for what CI runs, so use it rather than re-spelling commands.
10
+
11
+ ```bash
12
+ make install # create the venv, install deps
13
+ make check # pre-push gate: lint + types + tests
14
+ make test # pytest
15
+ make examples # run and assert every example
16
+ make ci # exactly what GitHub Actions runs
17
+ ```
18
+
19
+ Never invoke `python` or `pytest` directly: everything goes through `uv run`,
20
+ so there is no ambiguity about which interpreter ran.
21
+
22
+ CI calls `make ci` and nothing else, then publishes the built site to GitHub
23
+ Pages from `main`. That publish step waits on the repository variable
24
+ `PUBLISH_DOCS` being `"true"`, since Pages has to be enabled on the repository
25
+ first.
26
+
27
+ ## Layout
28
+
29
+ | Path | What lives there |
30
+ |---|---|
31
+ | `src/tapio/` | the library, shipped in the wheel |
32
+ | `src/tapio/actor/` | paths, refs, behaviors, cell, mailbox, system |
33
+ | `src/tapio/remote/` | addressing, the wire format, the link and the associations over it |
34
+ | `src/tapio/dispatch/` | the event loop a system's tasks run on |
35
+ | `src/tapio/testkit/` | helpers for testing actor code, shipped |
36
+ | `tests/` | unit tests, mirroring the source packages, plus `tests/examples/` and `tests/benchmarks/` |
37
+ | `examples/tapio_examples/` | runnable examples, dev-only, never shipped |
38
+ | `docs/` | mkdocs-material, code included from `examples/` |
39
+
40
+ ## Style
41
+
42
+ These are settled preferences. Follow them in new code and fix them in code
43
+ you are already editing.
44
+
45
+ - **No em dashes.** Not in prose, docstrings, comments, commit messages, or PR
46
+ bodies. Use a comma, a colon, parentheses, or a full stop.
47
+ - **No references to internal planning documents.** No section numbers, no
48
+ milestone labels, no "see the plan". Write the reasoning out in place. A
49
+ reader of this repository cannot follow those pointers.
50
+ - **Absolute imports only**, enforced by ruff. `from tapio.actor.path import
51
+ ActorPath`, never a relative import, including in tests.
52
+ - **Single backticks in docstrings.** Markdown, not RST: no double backticks
53
+ and no roles. Cross-reference with mkdocstrings syntax,
54
+ `[Name][tapio.module.Name]`.
55
+ - **No blanket `from __future__ import annotations`.** The floor is Python
56
+ 3.11. Quote the few genuinely forward references instead.
57
+ - **Plain English, everywhere.** Docstrings, comments, `docs/`, the README,
58
+ commit messages and pull request bodies. Subject, verb, object. One idea per
59
+ sentence. No inverted clauses, no aphorisms, no sentence written for its
60
+ cadence, nothing a reader has to decode before they can use it. Say the fact
61
+ and stop. Keep the reasons: *why* a decision was made is worth a sentence,
62
+ it just has to be a plain one. In tests this is strictest, since a test is
63
+ usually read while it is failing: a one-line module docstring, and a comment
64
+ only where the code is genuinely surprising.
65
+ - Google-style docstrings on every public module, class, and function. Ruff
66
+ enforces the convention; mypy runs `--strict` over `src` and `examples`.
67
+ - Explain *why* in comments, not *what*. The code says what it does.
68
+
69
+ ## Commit messages and pull requests
70
+
71
+ - **The commit type decides the version.** python-semantic-release reads the
72
+ history on `main`, so `feat:` moves the minor, `fix:` moves the patch, and
73
+ anything else moves nothing. Write the type you mean: a `fix:` that is
74
+ really a feature ships under a version number that lies about it. A
75
+ `BREAKING CHANGE:` footer moves the minor too while this is 0.x, since
76
+ going to 1.0.0 is a decision rather than a side effect. Nobody edits a
77
+ version by hand, and `make next-version` says what the current history
78
+ would produce.
79
+ - **Nothing in the repository holds a version number.** It is derived from the
80
+ git tag at build time, so a release is a tag and nothing else. Do not add a
81
+ literal version to `pyproject.toml` or `version.py`: the second copy is the
82
+ one that goes stale, and writing one would put the release job back to
83
+ pushing commits at a protected branch.
84
+ - **Wrap commit messages at 72 columns.** `git log` does not reflow, so an
85
+ unwrapped paragraph becomes one very long line in a terminal.
86
+ - **Do not wrap pull request bodies.** One line per paragraph and one per list
87
+ item, however long. GitHub renders Markdown, so a hard-wrapped body and an
88
+ unwrapped one look identical in the browser, and the wrapping only shows in
89
+ the raw editor. What it costs is in the permanent history: GitHub generates a
90
+ squash merge's message from the pull request body and wraps it at 72, so a
91
+ body already wrapped at 79 gets wrapped a second time and lands ragged, with
92
+ stray two-word lines. Wrapping once, at merge time, is the point. PR #3's
93
+ merge commit has the artifact, with "and a / shutdown / that drains the tree"
94
+ split across three lines.
95
+ - **Let the merge generate its own message.** `gh pr merge --squash` with no
96
+ `--body-file` uses the pull request body and applies the wrapping above.
97
+ Passing a body explicitly sends it verbatim and skips the wrapping entirely,
98
+ so an unwrapped body becomes an unwrapped commit: one paragraph, one
99
+ several-hundred-character line, unreadable in `git log`. PR #4's merge commit
100
+ has *that* artifact, which is how this rule got its second half. If a merge
101
+ message really has to be supplied by hand, wrap it at 72 first.
102
+ - **End the pull request body with the `Co-Authored-By` trailer**, not just the
103
+ branch commits. The squash message is built from the body and the branch
104
+ commits' trailers are discarded with their messages, so a trailer on every
105
+ commit of the branch still does not reach `main`. PR #4's merge commit has
106
+ none, while all four of its branch commits did.
107
+ - Say what changed and why, and where a decision contradicts the design notes,
108
+ say so explicitly. That is a decision, not an oversight.
109
+ - Name the tests that would fail if the change regressed. "CI is green" is not
110
+ verification, it is a precondition.
111
+
112
+ ## Testing
113
+
114
+ - **The test tree mirrors the source tree.** A test for `tapio.remote.codec`
115
+ lives in `tests/remote/test_codec.py`. Shared fixtures and fakes stay at
116
+ `tests/`, since they are shared by every package.
117
+ - `pytest-asyncio` runs in auto mode, so an `async def test_...` needs no
118
+ marker. Warnings are errors.
119
+ - **Stop an actor through its behavior, not with `cell.abort()`.** Abort
120
+ cancels the cell's task, and the `CancelledError` that follows lands in the
121
+ test rather than in the runtime. Send a message the behavior answers with
122
+ `Behaviors.stopped()` and wait for the effect with `eventually`.
123
+ - Anything that starts a system wraps itself in
124
+ `tapio.testkit.assert_no_leaked_tasks()`. The runtime deliberately does not
125
+ use `TaskGroup`, so "no orphaned tasks" is an invariant this suite has to
126
+ keep honest.
127
+ - Tests use the `system` fixture from `tests/conftest.py` when they need a live
128
+ tree; it terminates whatever the test leaves behind. A fixture only one
129
+ package needs lives in that package's own `conftest.py`, with its helpers
130
+ beside it: `tests/remote/conftest.py` holds the two systems every remoting
131
+ test starts, and `tests/remote/peers.py` the messages, behaviors and
132
+ misbehaving peer they share.
133
+ - **A test that listens binds port 0.** The OS picks, the canonical address
134
+ follows what it picked, and no two tests argue over a number somebody chose.
135
+ - Examples are tests. Every module in `examples/tapio_examples/` has an
136
+ assertion in `tests/examples/test_suite.py`, and a new example with no
137
+ assertion fails the suite on purpose.
138
+
139
+ ## Design invariants worth knowing before changing the runtime
140
+
141
+ - **A message's identity never depends on a setting.** Delivery-time validation
142
+ discards its result; the recipient always gets the object the sender passed.
143
+ The guarantee is local: a message that crossed a link was rebuilt from JSON,
144
+ so it is `==` to what was sent and never `is` it. Say which side of that line
145
+ a test is on.
146
+ - **`tell` never blocks and never raises about the recipient.** Errors about
147
+ the message belong to the sender. Errors about the recipient become dead
148
+ letters.
149
+ - **The mailbox has one consumer and one waiter.** Signals drain before user
150
+ messages, and the system lane is always unbounded so a stop cannot be
151
+ refused.
152
+ - **Shutdown races one deadline for the whole tree**, not one per actor, so
153
+ worst-case shutdown does not multiply by depth.
154
+ - **Every task belongs to a cell and is cancelled in its termination
155
+ sequence.** If you add a task, say which cell owns it. Remoting adds no
156
+ exception: an association is an actor whose reader is its own task, and the
157
+ endpoint actor owns the listener and any connection still mid-handshake.
158
+ - **The handshake pins the protocol version, not the package version.**
159
+ `PROTOCOL_VERSION` in `remote/protocol.py` describes the wire contract and
160
+ is what both ends must agree on. `__version__` travels in the hello as a
161
+ diagnostic and is never compared, so two nodes on different releases
162
+ interoperate and a rolling deploy is possible. Raising the protocol version
163
+ is a deployment event and belongs in the pull request body.
164
+ - **A type key on a frame is a registry key, never an import path.** Resolving
165
+ a dotted name that arrived on a socket into an importable object is remote
166
+ code execution. An unregistered key is a dead letter naming the key, and
167
+ nothing is imported to find out what it might have meant.
168
+ - **Remoting is off unless it is configured**, and when it is, the port is
169
+ bound while the system is being constructed. That is what settles the
170
+ canonical address before any ref can write itself down, and what makes a
171
+ configuration that would listen to the world fail to start rather than fail
172
+ to be secure.
173
+ - **Delivery across a link is at-most-once, FIFO per association**, the same
174
+ guarantee as a local send. No acks and no retries: upgrading that belongs to
175
+ the user's protocol, where they know what is safe to repeat.
@@ -0,0 +1,5 @@
1
+ # CLAUDE.md
2
+
3
+ The conventions for this repository live in one file, shared by every agent:
4
+
5
+ @AGENTS.md
tapio_py-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.