chickinfry 0.5.0.dev1__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 (32) hide show
  1. chickinfry-0.5.0.dev1/.gitignore +9 -0
  2. chickinfry-0.5.0.dev1/LICENSE +202 -0
  3. chickinfry-0.5.0.dev1/PKG-INFO +375 -0
  4. chickinfry-0.5.0.dev1/README.md +361 -0
  5. chickinfry-0.5.0.dev1/pyproject.toml +47 -0
  6. chickinfry-0.5.0.dev1/requirements-dev.txt +24 -0
  7. chickinfry-0.5.0.dev1/src/chickinfry/__init__.py +18 -0
  8. chickinfry-0.5.0.dev1/src/chickinfry/_auth_database.py +765 -0
  9. chickinfry-0.5.0.dev1/src/chickinfry/_conformance.py +208 -0
  10. chickinfry-0.5.0.dev1/src/chickinfry/_device.py +1405 -0
  11. chickinfry-0.5.0.dev1/src/chickinfry/_device_windows.py +250 -0
  12. chickinfry-0.5.0.dev1/src/chickinfry/_error_details.py +76 -0
  13. chickinfry-0.5.0.dev1/src/chickinfry/_http_common.py +165 -0
  14. chickinfry-0.5.0.dev1/src/chickinfry/_input.py +129 -0
  15. chickinfry-0.5.0.dev1/src/chickinfry/_origin.py +60 -0
  16. chickinfry-0.5.0.dev1/src/chickinfry/_password.py +38 -0
  17. chickinfry-0.5.0.dev1/src/chickinfry/_request_logs.py +66 -0
  18. chickinfry-0.5.0.dev1/src/chickinfry/_request_state.py +32 -0
  19. chickinfry-0.5.0.dev1/src/chickinfry/_sync_http.py +546 -0
  20. chickinfry-0.5.0.dev1/src/chickinfry/_sync_network.py +288 -0
  21. chickinfry-0.5.0.dev1/src/chickinfry/_workerd.py +731 -0
  22. chickinfry-0.5.0.dev1/src/chickinfry/auth.py +1227 -0
  23. chickinfry-0.5.0.dev1/src/chickinfry/errors.py +101 -0
  24. chickinfry-0.5.0.dev1/src/chickinfry/http.py +427 -0
  25. chickinfry-0.5.0.dev1/src/chickinfry/orm.py +506 -0
  26. chickinfry-0.5.0.dev1/src/chickinfry/postgres.py +281 -0
  27. chickinfry-0.5.0.dev1/src/chickinfry/py.typed +0 -0
  28. chickinfry-0.5.0.dev1/src/chickinfry/realtime.py +522 -0
  29. chickinfry-0.5.0.dev1/src/chickinfry/server.py +540 -0
  30. chickinfry-0.5.0.dev1/src/chickinfry/session.py +465 -0
  31. chickinfry-0.5.0.dev1/src/chickinfry/signup.py +134 -0
  32. chickinfry-0.5.0.dev1/src/chickinfry/wire.py +23 -0
@@ -0,0 +1,9 @@
1
+ .venv*/
2
+ .cache/
3
+ .pytest_cache/
4
+ .mypy_cache/
5
+ .ruff_cache/
6
+ __pycache__/
7
+ *.py[cod]
8
+ dist/
9
+ .evidence/
@@ -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 2026 Chickinfry
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.
@@ -0,0 +1,375 @@
1
+ Metadata-Version: 2.5
2
+ Name: chickinfry
3
+ Version: 0.5.0.dev1
4
+ Summary: Sync and async transport and sessions for Chickinfry clients
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: httpcore<2,>=1.0.9
9
+ Requires-Dist: httpx<0.29,>=0.28.1
10
+ Requires-Dist: websockets<17,>=16.0
11
+ Provides-Extra: server
12
+ Requires-Dist: asyncpg==0.32.0; (sys_platform != 'emscripten') and extra == 'server'
13
+ Description-Content-Type: text/markdown
14
+
15
+ # chickinfry
16
+
17
+ Status: not yet supported (preview). APIs may change before support is announced.
18
+
19
+ Synchronous and async HTTP transport and in-memory native sessions for
20
+ Chickinfry clients. Requires Python 3.11 or newer. Browser, WebAssembly, and
21
+ Python Worker transports are not supported yet; use a regular Python process.
22
+
23
+ This preview is not published to PyPI. Install from a local source checkout:
24
+
25
+ ```sh
26
+ python -m pip install .
27
+ ```
28
+
29
+ Use the synchronous transport in scripts and other blocking applications:
30
+
31
+ ```python
32
+ from chickinfry import HttpTransport, ClientError, OperationError
33
+
34
+ with HttpTransport("https://api.example.com") as transport:
35
+ try:
36
+ result = transport.invoke("account.get_status", {})
37
+ print(result)
38
+ except OperationError as error:
39
+ print(error)
40
+ except ClientError as error:
41
+ print(error)
42
+ ```
43
+
44
+ Use the async transport with asyncio:
45
+
46
+ ```python
47
+ import asyncio
48
+ from chickinfry import AsyncHttpTransport
49
+
50
+ async def main():
51
+ async with AsyncHttpTransport("https://api.example.com") as transport:
52
+ result = await transport.invoke("account.get_status", {})
53
+ print(result)
54
+
55
+ asyncio.run(main())
56
+ ```
57
+
58
+ `HttpTransport` can be shared by threads. `AsyncHttpTransport` stays on one asyncio event loop.
59
+ Generated synchronous clients consume `Transport`; generated async
60
+ clients consume `AsyncTransport`. Both return the same JSON values and use the
61
+ same errors and string-preserving readers in `chickinfry.wire`.
62
+
63
+ Use `transport.with_bearer(token)` for a separate authenticated transport, or
64
+ `transport.with_session(store)` with a `MemoryStore(origin, credentials)`.
65
+ Neither changes the anonymous transport or its other copies. The original
66
+ transport owns the pool: `HttpTransport` closes it with `close()` or `with`, and
67
+ `AsyncHttpTransport` with `aclose()` or `async with`. Copies cannot close the pool.
68
+
69
+ `SessionCredentials` contains `access_token`, `refresh_token`, `expires_at`,
70
+ `refresh_expires_at`, `user_id`, and `session_id`. Tokens are hidden from its
71
+ representation. `store.credentials()` returns the current snapshot or `None`;
72
+ `replace(credentials)` installs a login and `clear(expected)` clears only that
73
+ exact snapshot. A store can start empty. Generated public calls, including
74
+ sign-in and signup, send without credentials from an empty store and use the
75
+ current credentials from an active store. Protected calls from an empty store
76
+ fail locally with `unauthenticated` and no HTTP status. A successful sign-in
77
+ installs the returned credentials, and a successful logout clears the matching
78
+ session.
79
+ The first successful `with_session` permanently binds a store
80
+ to synchronous threads or one asyncio loop. Mixing both transports on that
81
+ store raises `ClientError("failed_precondition")`, including after logout or close.
82
+ Use separate stores for the two modes. Do not concurrently copy the same
83
+ rotating credentials into separate stores.
84
+
85
+ Session transports share one refresh on `invalid_token`/401 and retry at most
86
+ once, using the original request bytes. Other failures are never resent.
87
+ A caller's interrupted or expired wait does not cancel a shared refresh.
88
+ Late refresh responses cannot overwrite a new login or restore a logout.
89
+ A pending request cannot be replayed across a login or logout.
90
+ A refresh failure other than a well-formed 401 preserves credentials and
91
+ blocks further automatic refresh for that snapshot until `replace()` installs
92
+ new credentials. A well-formed 401 clears only the expected snapshot and does
93
+ not resend the original request. Invalid non-success error envelopes report
94
+ `ClientError("internal")` with the received HTTP status.
95
+
96
+ Origins must be HTTPS or explicit IP loopback HTTP. Redirects, cookies,
97
+ environment proxies, and invalid tokens are rejected. Requests are limited to
98
+ 4 MiB and responses to 1 MiB, including decompressed bytes. `timeout=30.0`
99
+ limits each complete network attempt, including pool waits, partial writes,
100
+ TLS, headers, and streamed bodies. A session call is bounded by three times
101
+ that value, with small platform scheduling and cleanup overhead.
102
+
103
+ Synchronous DNS resolution uses the operating system resolver, which cannot
104
+ be interrupted by this timeout. If DNS finishes after the deadline, no TCP
105
+ connection or request is started. The actual return time then depends on the
106
+ OS resolver; the 30-second attempt and 90-second call limits are not guaranteed
107
+ while DNS is blocked. A refresh producer remains tracked until it exits.
108
+
109
+ Generated clients use `create_client(transport)` and
110
+ `create_async_client(transport)` from the generated package, returning `Client`
111
+ and `AsyncClient` respectively. Both factories accept one transport argument.
112
+ The synchronous names are `Transport` and `HttpTransport`; async equivalents are
113
+ `AsyncTransport` and `AsyncHttpTransport`. No previous names are aliased.
114
+
115
+ Local `ClientError.code` values are `invalid_argument`, `failed_precondition`,
116
+ `resource_exhausted`, `deadline_exceeded`, `canceled`, `unavailable`, `data_loss`,
117
+ `unimplemented`, `internal`, `unknown`, and `unauthenticated`. Missing local
118
+ sessions use `unauthenticated`. Device storage access, capacity, corruption, and
119
+ unsupported versions use `failed_precondition`, `resource_exhausted`, `data_loss`,
120
+ and `unimplemented` respectively. Redirects and malformed responses use
121
+ `internal`. Local failures retain a received HTTP status or `None`; timeouts
122
+ and cancellation never invent one.
123
+
124
+ `OperationError` is a `ClientError` with the server's `code` and HTTP `status`.
125
+ Validated server descriptions are available as `response_message` (`None` when
126
+ absent or invalid; empty strings are preserved). For `invalid_input`, `fields`
127
+ is an immutable tuple of frozen `FieldError(path, code)` values. Invalid optional
128
+ details are discarded independently while code and HTTP status are preserved.
129
+ Session refresh failure snapshots preserve both details and the existing request
130
+ outcome uncertainty; they do not add automatic business retries.
131
+ Printing either error gives an English sentence with a next action; use the
132
+ `code` and `status` attributes for programmatic error handling.
133
+ Per-cause diagnostics retain their fixed, actionable wording; use common codes
134
+ for programmatic decisions. Local failures expose a common `code` and an optional
135
+ received `status`, without
136
+ request bodies, credentials, or raw network errors. Async cancellation and
137
+ synchronous `KeyboardInterrupt` propagate after cleanup. JSON retains strings,
138
+ including timestamps, without automatic date conversion.
139
+
140
+ ## Server operation errors
141
+
142
+ Raise `chickinfry.server.OperationError(code, status, message=None, fields=())`
143
+ for an intentional public business failure. The server accepts every integer HTTP
144
+ status from 400 through 599, including 422 and custom codes at 501. Invalid codes,
145
+ booleans, non-integer statuses and out-of-range statuses return
146
+ `{"error":"operation_failed"}` with HTTP 500 and no details.
147
+
148
+ ```python
149
+ from chickinfry.server import FieldError, OperationError
150
+
151
+ raise OperationError(
152
+ "invalid_input", 422, "Quantity must be 10 or less.",
153
+ (FieldError("quantity", "too_large"),),
154
+ )
155
+ ```
156
+
157
+ The optional message must be valid Unicode, at most 1024 UTF-8 bytes, and contain
158
+ no control characters. Fields are sent only for `invalid_input`, with at most 32
159
+ valid path/code entries. Generated operations supply declared input paths through
160
+ `Operation.input_fields`. Hand-written operations default to no declared paths,
161
+ so field details are omitted unless that metadata is supplied. Invalid optional
162
+ details are discarded independently; valid code and status are preserved.
163
+ `str(error)` never includes the public message. Server errors and received SDK
164
+ errors have distinct type identities; received SDK errors are never trusted as
165
+ public server errors. The former server error name has no compatibility alias.
166
+
167
+ Generated SDKs use `SignupBinding` with the synchronous and asynchronous
168
+ transports for required email verification. Signup preserves the server's
169
+ `accepted` and `attempt` response instead of treating it as session credentials.
170
+ Verification and resend omit an unspecified target, or use this client's last
171
+ successful signup attempt when both targets are omitted. Providing both `email`
172
+ and `attempt` raises `ClientError` with code `invalid_argument` before HTTP.
173
+ The same error is returned without HTTP when no target or pending attempt exists.
174
+ Failed verification retains the attempt. Successful verification clears it for
175
+ the verified email when that email is known to the SDK; an unrelated explicit
176
+ attempt does not identify or clear this client's pending signup.
177
+ Successful sign-out clears this client's pending attempt. Successful sign-in
178
+ clears it only for the same signup email, compared after server-compatible
179
+ trimming and lowercase conversion. Other emails and failed calls retain it.
180
+ Older in-flight signup replies cannot restore a cleared email's binding, and
181
+ sign-out invalidates every older signup. State changes follow successful
182
+ decoding of the complete generated result.
183
+
184
+ This binding lasts for the client instance. Connecting generated sign-in,
185
+ signup, and reset to device storage is a separate follow-up; this does not
186
+ establish persistence through those public authentication paths.
187
+
188
+ ## Server ORM
189
+
190
+ Generated repositories provide `upsert`, `increment`, and `increment_if` alongside
191
+ insert, lookup, update, and delete. Upserts require every primary key and update
192
+ only supplied mutable columns. Increments change integer columns atomically;
193
+ `increment_if` also checks a filter and applies a patch in the same statement.
194
+ An unmatched conditional write returns `None`; updating or incrementing a missing
195
+ row raises the public server `OperationError` with code `not_found` and status 404.
196
+ Column comparisons use `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, and `is_in`.
197
+
198
+ ## Contributing
199
+
200
+ Install development tools with `python -m pip install -r requirements-dev.txt`
201
+ and `python -m pip install --no-deps -e .`. Run `ruff check src tests`,
202
+ `ruff format --check src tests`, and `mypy --strict src tests`.
203
+
204
+ Runtime installation requirements are defined in `pyproject.toml`.
205
+
206
+ Install the development dependencies and package before running the full suite:
207
+
208
+ ```sh
209
+ python -m pip install -r requirements-dev.txt
210
+ python -m pip install --no-deps -e .
211
+ python -m pytest
212
+ python -m ruff check src tests
213
+ python -m mypy --strict src tests
214
+ ```
215
+
216
+ Server tests require asyncpg (included in the development dependencies), Docker,
217
+ and OpenSSL. They use
218
+ `postgres:18-alpine@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873`
219
+ and pull the image only when that digest is missing locally. They create a
220
+ disposable database bound to loopback and remove its container and volumes.
221
+ The temporary test filesystem needs at least 4 GiB free before startup;
222
+ tests stop below 3 GiB. Client installations do not need the server extra.
223
+
224
+ The pinned asyncpg driver does not provide SCRAM-SHA-256-PLUS.
225
+ `channel_binding=require` is rejected before connecting; `prefer` permits
226
+ ordinary SCRAM when binding is unavailable, and `disable` does not use it.
227
+ Omitting that option does not require binding. These options do not change the
228
+ explicit TLS certificate and hostname checks selected by `sslmode`.
229
+
230
+ ## Native session lifetime
231
+
232
+ Native bearer sessions use a 30-day idle timeout (2592000 seconds), with no
233
+ absolute lifetime cap by default (0). A successful refresh rolls the idle
234
+ expiry forward from its issue time; access tokens still expire after 900
235
+ seconds. Access checks do not renew the family. Expired or revoked credentials
236
+ are never revived, and refresh reuse revokes the entire family, including the
237
+ most recently issued credentials. Native responses never set or delete cookies.
238
+
239
+ The runtime accepts `idle_timeout_seconds` (3600–31536000 integer seconds) and
240
+ `absolute_lifetime_seconds` (0, or 3600–31536000 integer seconds) as keyword
241
+ arguments to `Auth`. The absolute cap may be shorter than idle and is measured
242
+ from the first login, including on access checks. Invalid values are rejected
243
+ before database use. Existing users may need to sign in again when a policy
244
+ is shortened or an absolute cap is enabled.
245
+
246
+ Existing sessions retain their stored refresh expiry until a successful
247
+ renewal converts them in the same transaction. Conversion preserves the
248
+ family's original creation time as first login and records the renewal time.
249
+ Before conversion, the current idle timeout is measured from the newest
250
+ successfully issued refresh credential's recorded creation time; rejected
251
+ requests and reuse do not move that baseline. The stored credential expiry
252
+ is checked separately, so a changed policy cannot revive an expired credential.
253
+
254
+ Cleanup selects ended families and preserves consumed credentials of live
255
+ families for reuse detection. For existing sessions without a recorded renewal
256
+ time, candidate selection can lag idle expiry by the access lifetime (900
257
+ seconds); families older than seven days are also selected. The final decision
258
+ is checked again under the family lock. Long-lived active families therefore
259
+ retain their credential history.
260
+
261
+ Non-default policy in generated Python applications is not supported yet:
262
+ the CLI's generator wiring and support gate remain separate work. Browser
263
+ cookie sessions are also unsupported. Cookie-only requests are anonymous in
264
+ this native-only runtime; the browser cookie/bearer mixing rule does not apply.
265
+
266
+ ## Device persistence bridge (preview)
267
+
268
+ The runtime includes a private bridge for generated clients to supply trusted
269
+ app, canonical API origin, project/environment, user and signup-screen context.
270
+ Generated default wiring is integrated separately. Existing explicit
271
+ `MemoryStore` injection remains in memory and retains its loop/mode contract.
272
+
273
+ `HttpTransport` and `AsyncHttpTransport` accept `persist` alongside `timeout` and pass it to the
274
+ private context-bound bridge. Explicit `with_session` injection remains caller-owned.
275
+ The bridge accepts `persist=False` for explicit memory-only operation and
276
+ `persist={"dir": path}` for a state directory. Relative directories are resolved once against the
277
+ working directory when the transport is constructed; a later chdir does not
278
+ move the store. An empty string raises `failed_precondition`. Defaults
279
+ never fall back to the working directory. Omission selects Linux
280
+ `XDG_STATE_HOME` (or `HOME/.local/state`), macOS `HOME/Library/Application Support`,
281
+ or Windows `LOCALAPPDATA`. No SQLite, keychain or encryption dependency is used.
282
+ A directory is created lazily with 0700 permissions; an existing directory must
283
+ be owned by the user and not writable by others. Files use 0600; Windows
284
+ uses explicit current-user-only ACLs. Insecure existing permissions, symlinks and
285
+ foreign ownership are rejected. State files are not encrypted.
286
+
287
+ Each app/origin/project/environment has its own bundle and lock file. A process
288
+ lock serializes generation comparison and replacement. Writes flush a temporary
289
+ file, replace within the same directory, then flush the directory on POSIX.
290
+ Windows holds non-delete-sharing directory handles for every ancestor throughout
291
+ the transaction and rechecks ancestors after file open; unsafe/reparse paths or
292
+ unavailable pinning are refused. Windows skips directory flushing. Native Windows
293
+ execution and power-loss durability remain **UNVERIFIED**; fake API tests do not
294
+ establish real-host support.
295
+ No lock is held over a network call. Storage I/O and an OS lock wait can outlast
296
+ the transport network timeout. Separate sync and async stores use the same
297
+ file contract while keeping transport pools and event-loop state separate.
298
+ Request-scoped `with_bearer` credentials are never stored.
299
+
300
+ Session replacement, auth-selected attempt cleanup and generation changes are
301
+ one replacement. Refresh consumption-unknown state is durable before sending;
302
+ a crash or lost response never authorizes resending an old refresh. Auth passes
303
+ expired/confirmed screen IDs to `_save_attempt(..., remove_screens=...)`; the
304
+ adapter does not decide expiry with its own clock. Version 1 permits three
305
+ pending attempts and an 8 KiB serialized UTF-8 bundle, without silent eviction.
306
+ Original ISO expiry strings are preserved and range-checked.
307
+
308
+ A verified server login uses `_accept_login`. If only the following write fails,
309
+ the login succeeds and the new session stays in memory for this run; persistence
310
+ is not promised. Location-creation failures remain configuration errors.
311
+ Restore, pre-refresh and deletion failures are not converted to memory success.
312
+ Corruption and unknown/newer versions preserve the original and block access.
313
+ The existing `ClientError` channel retains `failed_precondition`,
314
+ `data_loss`, `resource_exhausted`, and
315
+ `unimplemented`, with no fabricated HTTP status.
316
+
317
+ Core/auth must connect generated defaults, explicit `auth.refresh` pre-send
318
+ claims and conditional transitions. No cache, offline queue or automatic reset
319
+ is implemented. Future cache/queue work must use the same scope and generation
320
+ boundary, and must not store auth requests as queued operations.
321
+
322
+ After a successful server refresh, local read, lock or write failure during
323
+ commit keeps
324
+ them in this run's memory and the original operation uses its normal single
325
+ retry. The durable in-flight marker remains, so a restart does not resubmit the
326
+ old refresh. Recording that marker must still succeed before any refresh send.
327
+
328
+ The private auth bridge can read `_snapshot()` and use separate bundle and auth
329
+ generations in a conditional transition. Attempt writes do not advance the auth
330
+ generation; session installs/changes, logout and scoped deletion do. Exact
331
+ attempt-only cleanup preserves the active session and refresh marker. Bounded
332
+ local CAS retries, attempt-reference checks and same-email cleanup selection are
333
+ owned by generated auth integration; the adapter never resends the server RPC.
334
+
335
+
336
+ The device bridge records an account-transition-unknown marker before an auth
337
+ bridge sends a login, confirmation, code login or OAuth completion that can
338
+ replace an existing session. It uses the existing conditional transition;
339
+ first login has no previous account to mark. A marker write failure prevents
340
+ the send. A definite auth failure removes the marker and preserves the previous
341
+ account; verified success installs the new session. If only the final write
342
+ fails, the new session remains usable in memory for this run and the marker
343
+ remains durable. On restart, the previous account is not restored, even if its
344
+ best-effort local cleanup fails. Generated auth-method wiring is follow-up work.
345
+
346
+ POSIX operations stay relative to a validated directory descriptor, including
347
+ locks, temporary writes, replacement and directory flush. Unsafe writable
348
+ ancestors and macOS ACL allow entries are rejected before credentials are
349
+ written. The shared session coordinator retries refresh commits locally at most
350
+ three times while the authentication generation and expected session match;
351
+ it never resends the refresh RPC. Run-local credentials recheck the persisted
352
+ authentication generation before use, including another instance's logout.
353
+
354
+
355
+ An E1 memory session retains the authentication generation last read from disk
356
+ when it was accepted. An I/O failure during the pre-call generation check keeps
357
+ that memory session usable. A confirmed generation advance discards it and ends
358
+ that call without adopting another account; later calls use the ordinary store
359
+ read. The existing no-session result is mapped by the generated auth bridge.
360
+
361
+ A persistent or memory-only device call retains its starting authentication generation through refresh coordination
362
+ and the final retry. A confirmed account change ends that call with
363
+ `invalid_session`, without sending its operation under the new account. The next
364
+ independent call can use the newly stored account. This also fences the fast path
365
+ that reuses credentials refreshed by another caller. Post-success I/O fallback
366
+ never overrides a confirmed account boundary, corrupt data or unsupported format.
367
+ Rereading an attempt-only change preserves the expected session for a pending
368
+ deletion only when both its authentication generation and credentials still match.
369
+ A new authentication generation remains protected even if its credentials match.
370
+
371
+ File-backed and `persist=False` device sessions use the same bundle transitions,
372
+ refresh commits and account-transition markers; only bundle I/O changes.
373
+ Saving or removing another screen's signup attempt preserves a successful refresh,
374
+ a confirmed 401 deletion and a consumption-unknown block. Later attempt changes
375
+ cannot authorize another send of a consumed or uncertain refresh credential.