@withgateway/sdk 0.3.1 → 0.4.0

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 (176) hide show
  1. package/README.md +8 -6
  2. package/dist/cli.js +4372 -2265
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +4362 -2256
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/files/index.d.mts +1 -1
  7. package/dist/files/index.d.ts +1 -1
  8. package/dist/files/index.js +259 -58
  9. package/dist/files/index.js.map +1 -1
  10. package/dist/files/index.mjs +249 -50
  11. package/dist/files/index.mjs.map +1 -1
  12. package/dist/hooks/index.d.mts +1 -1
  13. package/dist/hooks/index.d.ts +1 -1
  14. package/dist/hooks/index.js +124 -11
  15. package/dist/hooks/index.js.map +1 -1
  16. package/dist/hooks/index.mjs +124 -11
  17. package/dist/hooks/index.mjs.map +1 -1
  18. package/dist/{index-C3UzD0G3.d.mts → index-CDPQBsU5.d.mts} +19 -3
  19. package/dist/{index-C3UzD0G3.d.ts → index-CDPQBsU5.d.ts} +19 -3
  20. package/dist/{index-CBqbB_0J.d.ts → index-DUHmS74p.d.ts} +1 -1
  21. package/dist/{index-D-AMnAMa.d.mts → index-mJhG3vZU.d.mts} +1 -1
  22. package/dist/index.d.mts +5 -5
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +2240 -789
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +2150 -739
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/{media-CbcAfQvd.d.mts → media-BIApiPzS.d.mts} +21 -2
  29. package/dist/{media-CbcAfQvd.d.ts → media-BIApiPzS.d.ts} +21 -2
  30. package/dist/traces/index.d.mts +1 -1
  31. package/dist/traces/index.d.ts +1 -1
  32. package/dist/traces/index.js +253 -52
  33. package/dist/traces/index.js.map +1 -1
  34. package/dist/traces/index.mjs +243 -44
  35. package/dist/traces/index.mjs.map +1 -1
  36. package/dist/tracing/index.d.mts +2 -2
  37. package/dist/tracing/index.d.ts +2 -2
  38. package/dist/tracing/index.js +75 -13
  39. package/dist/tracing/index.js.map +1 -1
  40. package/dist/tracing/index.mjs +75 -13
  41. package/dist/tracing/index.mjs.map +1 -1
  42. package/dist/worlds/index.d.mts +893 -482
  43. package/dist/worlds/index.d.ts +893 -482
  44. package/dist/worlds/index.js +1968 -669
  45. package/dist/worlds/index.js.map +1 -1
  46. package/dist/worlds/index.mjs +1960 -662
  47. package/dist/worlds/index.mjs.map +1 -1
  48. package/package.json +1 -1
  49. package/runtime/gatewaysdk/environment/_bundle.py +2 -27
  50. package/runtime/gatewaysdk/environment/_materialize.py +48 -88
  51. package/runtime/gatewaysdk/environment/_world.py +155 -237
  52. package/runtime/gatewaysdk/environment/backing.py +133 -0
  53. package/runtime/gatewaysdk/environment/core.py +2 -17
  54. package/runtime/gatewaysdk/environment/legacy_sqlite.py +288 -0
  55. package/runtime/gatewaysdk/environment/reward_keys.py +25 -0
  56. package/runtime/gatewaysdk/environment/runtime.py +8 -13
  57. package/runtime/gatewaysdk/environment/schema/__init__.py +4 -4
  58. package/runtime/gatewaysdk/environment/schema/admin_routes.py +86 -0
  59. package/runtime/gatewaysdk/environment/schema/admission.py +174 -0
  60. package/runtime/gatewaysdk/environment/schema/api.py +347 -892
  61. package/runtime/gatewaysdk/environment/schema/assertions.py +458 -0
  62. package/runtime/gatewaysdk/environment/schema/batch.py +44 -39
  63. package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +17 -5
  64. package/runtime/gatewaysdk/environment/schema/cache_layout.py +5 -0
  65. package/runtime/gatewaysdk/environment/schema/call_capture.py +309 -0
  66. package/runtime/gatewaysdk/environment/schema/call_log.py +503 -0
  67. package/runtime/gatewaysdk/environment/schema/call_redaction.py +526 -0
  68. package/runtime/gatewaysdk/environment/schema/cast.py +15 -35
  69. package/runtime/gatewaysdk/environment/schema/compiler.py +334 -158
  70. package/runtime/gatewaysdk/environment/schema/conform.py +14 -39
  71. package/runtime/gatewaysdk/environment/schema/connector.py +113 -211
  72. package/runtime/gatewaysdk/environment/schema/connectors/confluence/connector.toml +1 -12
  73. package/runtime/gatewaysdk/environment/schema/connectors/github/connector.toml +1 -0
  74. package/runtime/gatewaysdk/environment/schema/connectors/servicenow/connector.toml +2 -5
  75. package/runtime/gatewaysdk/environment/schema/cors.py +54 -0
  76. package/runtime/gatewaysdk/environment/schema/credentials.py +313 -8
  77. package/runtime/gatewaysdk/environment/schema/data.py +60 -216
  78. package/runtime/gatewaysdk/environment/schema/database/__init__.py +24 -0
  79. package/runtime/gatewaysdk/environment/schema/database/audit.py +121 -0
  80. package/runtime/gatewaysdk/environment/schema/database/base.py +936 -0
  81. package/runtime/gatewaysdk/environment/schema/database/budget.py +33 -0
  82. package/runtime/gatewaysdk/environment/schema/database/connections.py +101 -0
  83. package/runtime/gatewaysdk/environment/schema/database/engines.py +8 -0
  84. package/runtime/gatewaysdk/environment/schema/database/guard.py +215 -0
  85. package/runtime/gatewaysdk/environment/schema/database/ingest.py +154 -0
  86. package/runtime/gatewaysdk/environment/schema/database/matching.py +58 -0
  87. package/runtime/gatewaysdk/environment/schema/database/provenance.py +30 -0
  88. package/runtime/gatewaysdk/environment/schema/database/reads.py +169 -0
  89. package/runtime/gatewaysdk/environment/schema/database/rows.py +53 -0
  90. package/runtime/gatewaysdk/environment/schema/database/runtime_rows.py +39 -0
  91. package/runtime/gatewaysdk/environment/schema/database/sqlite.py +393 -0
  92. package/runtime/gatewaysdk/environment/schema/declared_routes.py +210 -0
  93. package/runtime/gatewaysdk/environment/schema/domain_migration.py +236 -0
  94. package/runtime/gatewaysdk/environment/schema/door.py +899 -0
  95. package/runtime/gatewaysdk/environment/schema/envelope.py +227 -0
  96. package/runtime/gatewaysdk/environment/schema/extract.py +6 -13
  97. package/runtime/gatewaysdk/environment/schema/grading.py +90 -103
  98. package/runtime/gatewaysdk/environment/schema/handler_errors.py +163 -12
  99. package/runtime/gatewaysdk/environment/schema/host.py +237 -1795
  100. package/runtime/gatewaysdk/environment/schema/host_control.py +144 -0
  101. package/runtime/gatewaysdk/environment/schema/host_handoff.py +370 -0
  102. package/runtime/gatewaysdk/environment/schema/host_loops.py +97 -0
  103. package/runtime/gatewaysdk/environment/schema/host_owners.py +121 -0
  104. package/runtime/gatewaysdk/environment/schema/host_proxy.py +111 -0
  105. package/runtime/gatewaysdk/environment/schema/host_requests.py +6 -0
  106. package/runtime/gatewaysdk/environment/schema/host_session.py +126 -0
  107. package/runtime/gatewaysdk/environment/schema/host_surfaces.py +79 -21
  108. package/runtime/gatewaysdk/environment/schema/host_transfers.py +127 -0
  109. package/runtime/gatewaysdk/environment/schema/host_versions.py +242 -0
  110. package/runtime/gatewaysdk/environment/schema/host_workers.py +577 -0
  111. package/runtime/gatewaysdk/environment/schema/journal.py +437 -0
  112. package/runtime/gatewaysdk/environment/schema/lanes.py +53 -0
  113. package/runtime/gatewaysdk/environment/schema/ledger_spill.py +828 -0
  114. package/runtime/gatewaysdk/environment/schema/local.py +58 -170
  115. package/runtime/gatewaysdk/environment/schema/mapping.py +5 -25
  116. package/runtime/gatewaysdk/environment/schema/openapi_import.py +112 -73
  117. package/runtime/gatewaysdk/environment/schema/openapi_paging.py +147 -0
  118. package/runtime/gatewaysdk/environment/schema/openapi_payloads.py +288 -0
  119. package/runtime/gatewaysdk/environment/schema/openapi_routes.py +97 -102
  120. package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +113 -30
  121. package/runtime/gatewaysdk/environment/schema/platform.py +137 -187
  122. package/runtime/gatewaysdk/environment/schema/platform_import.py +2 -3
  123. package/runtime/gatewaysdk/environment/schema/platform_query.py +61 -5
  124. package/runtime/gatewaysdk/environment/schema/primary_key.py +61 -0
  125. package/runtime/gatewaysdk/environment/schema/proof.py +19 -12
  126. package/runtime/gatewaysdk/environment/schema/request_body.py +238 -0
  127. package/runtime/gatewaysdk/environment/schema/request_ledger.py +958 -0
  128. package/runtime/gatewaysdk/environment/schema/route_bindings.py +25 -3
  129. package/runtime/gatewaysdk/environment/schema/route_miss.py +54 -0
  130. package/runtime/gatewaysdk/environment/schema/runtime.py +178 -308
  131. package/runtime/gatewaysdk/environment/schema/served_names.py +58 -0
  132. package/runtime/gatewaysdk/environment/schema/session_files.py +275 -0
  133. package/runtime/gatewaysdk/environment/schema/session_move.py +275 -0
  134. package/runtime/gatewaysdk/environment/schema/skills/agents/connector-template-author.md +5 -1
  135. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +10 -11
  136. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +49 -16
  137. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +39 -9
  138. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +27 -27
  139. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +33 -33
  140. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +13 -7
  141. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +49 -1
  142. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +182 -0
  143. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/openapi-import.md +50 -21
  144. package/runtime/gatewaysdk/environment/schema/slack.py +4 -8
  145. package/runtime/gatewaysdk/environment/schema/snapshot.py +516 -140
  146. package/runtime/gatewaysdk/environment/schema/spill_files.py +228 -0
  147. package/runtime/gatewaysdk/environment/schema/store_contract.py +8 -14
  148. package/runtime/gatewaysdk/environment/schema/tasks.py +267 -276
  149. package/runtime/gatewaysdk/environment/schema/tools_world.py +146 -242
  150. package/runtime/gatewaysdk/environment/schema/ui.py +24 -5
  151. package/runtime/gatewaysdk/environment/schema/ui_static/app.js +100 -130
  152. package/runtime/gatewaysdk/environment/schema/ui_static/index.html +1 -8
  153. package/runtime/gatewaysdk/environment/schema/validation.py +235 -41
  154. package/runtime/gatewaysdk/environment/schema/verbs.py +32 -36
  155. package/runtime/gatewaysdk/environment/schema/worker.py +6 -4
  156. package/runtime/gatewaysdk/environment/schema/workers.py +345 -96
  157. package/runtime/gatewaysdk/environment/schema/world_host.py +953 -0
  158. package/runtime/gatewaysdk/environment/schema/world_sql.py +81 -0
  159. package/runtime/gatewaysdk/environment/schema/world_tests.py +80 -50
  160. package/runtime/gatewaysdk/environment/score.py +57 -0
  161. package/runtime/gatewaysdk/environment/secret_values.py +36 -0
  162. package/runtime/gatewaysdk/environment/world.py +43 -4
  163. package/runtime/gatewaysdk/environment/world_session_contract.py +46 -5
  164. package/skills/agents/connector-template-author.md +5 -1
  165. package/skills/benchmarks-getting-started/SKILL.md +10 -11
  166. package/skills/connector-schema-authoring/SKILL.md +49 -16
  167. package/skills/connector-schema-authoring/connector-worlds.md +142 -11
  168. package/skills/connector-schema-authoring/world-schema.md +103 -51
  169. package/skills/world-data-ingestion/ROWS.md +39 -9
  170. package/skills/world-data-ingestion/SKILL.md +27 -27
  171. package/skills/worlds-getting-started/SKILL.md +33 -33
  172. package/skills/worlds-getting-started/references/cli-mcp-map.md +13 -7
  173. package/skills/worlds-getting-started/references/gotchas.md +49 -1
  174. package/skills/worlds-getting-started/references/journal-checks.md +182 -0
  175. package/skills/worlds-getting-started/references/openapi-import.md +50 -21
  176. package/runtime/gatewaysdk/environment/schema/store.py +0 -1013
@@ -0,0 +1,228 @@
1
+ """The files under the World Host's request ledger spill, as tenant code could have left them: version
2
+ workers share the host's user and cache, so every name is reached from a directory held open by
3
+ descriptor and never through a link, a file is written only when it is a regular one and opened without
4
+ waiting on a FIFO, a directory the host keeps is given back its owner's access before it is used and
5
+ again whenever tenant code took it, and every line carries a seal only the host can make
6
+ (:class:`SpillSeal`)."""
7
+
8
+ from __future__ import annotations
9
+
10
+ import errno
11
+ import hashlib
12
+ import hmac
13
+ import os
14
+ import shutil
15
+ import stat
16
+ import uuid
17
+ from collections.abc import Callable, Iterator
18
+ from contextlib import contextmanager
19
+ from functools import partial
20
+ from pathlib import Path
21
+ from typing import TypeVar
22
+
23
+ from .call_log import read_tail
24
+ from .handler_errors import log_line
25
+
26
+ TOMBSTONE = ".gone-"
27
+ DIRECTORY = os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW | os.O_NONBLOCK
28
+ WRITING = os.O_WRONLY | os.O_NOFOLLOW | os.O_NONBLOCK
29
+ Done = TypeVar("Done")
30
+
31
+
32
+ def _write_all(descriptor: int, data: bytes) -> None:
33
+ view = memoryview(data)
34
+ while view:
35
+ view = view[os.write(descriptor, view) :]
36
+
37
+
38
+ class SpillSeal:
39
+ """The seal on every spill line: an HMAC under a key derived from the control-plane secret, which a
40
+ version worker is never given, over the account's ``source``, the line's ``place`` (a segment line's
41
+ segment and ordinal, a record line's predecessor's tag) and the line, so a line written, changed,
42
+ copied or moved by anything but this host fails it."""
43
+
44
+ OVERHEAD = 66
45
+
46
+ def __init__(self, secret: str) -> None:
47
+ self._key = hmac.new(secret.encode("utf-8"), b"world-host-ledger-spill/2", hashlib.sha256).digest()
48
+
49
+ def seal(self, source: str, data: bytes, place: bytes = b"") -> bytes:
50
+ return self._tag(source, place, data) + b" " + data + b"\n"
51
+
52
+ def opened(self, source: str, line: bytes, place: bytes = b"") -> bytes | None:
53
+ tag, _, data = line.partition(b" ")
54
+ return data if hmac.compare_digest(tag, self._tag(source, place, data)) else None
55
+
56
+ @staticmethod
57
+ def tag(line: bytes) -> bytes:
58
+ return line.partition(b" ")[0]
59
+
60
+ def _tag(self, source: str, place: bytes, data: bytes) -> bytes:
61
+ message = source.encode("ascii") + b"\n" + place + b"\n" + data
62
+ return hmac.new(self._key, message, hashlib.sha256).hexdigest().encode("ascii")
63
+
64
+
65
+ class SpillDirectory:
66
+ """A directory held open by descriptor: every name in it is reached without following a link, every
67
+ file read as tenant code could have written it and written only as a regular file."""
68
+
69
+ def __init__(self, descriptor: int) -> None:
70
+ self.descriptor = descriptor
71
+
72
+ @classmethod
73
+ def opened(cls, name: str | Path, within: int | None = None) -> SpillDirectory:
74
+ return cls(os.open(name, DIRECTORY, dir_fd=within))
75
+
76
+ @classmethod
77
+ def owned(cls, name: str, within: int) -> SpillDirectory:
78
+ """``name`` opened and given its owner's access alone; one the host cannot make its own raises."""
79
+ directory = cls.opened(name, within)
80
+ try:
81
+ directory.own()
82
+ except OSError:
83
+ directory.close()
84
+ raise
85
+ return directory
86
+
87
+ def own(self) -> None:
88
+ """Its owner's access alone again, through the descriptor it is held by: tenant code can change
89
+ a held directory's mode, never which directory is held."""
90
+ os.fchmod(self.descriptor, 0o700)
91
+
92
+ def reowned(self, operation: Callable[[], Done]) -> Done:
93
+ """``operation`` on a name in this directory, run once more after the directory is made the host's
94
+ own again (:meth:`own`) when tenant code took the host's access to it, its write or search bit."""
95
+ try:
96
+ return operation()
97
+ except PermissionError:
98
+ self.own()
99
+ return operation()
100
+
101
+ def close(self) -> None:
102
+ os.close(self.descriptor)
103
+
104
+ @contextmanager
105
+ def child(self, name: str) -> Iterator[SpillDirectory]:
106
+ directory = self.reowned(partial(SpillDirectory.owned, name, self.descriptor))
107
+ try:
108
+ yield directory
109
+ finally:
110
+ directory.close()
111
+
112
+ def names(self) -> list[str]:
113
+ return sorted(os.listdir(self.descriptor))
114
+
115
+ def mode(self, name: str) -> int | None:
116
+ mode, _ = self._status(name)
117
+ return mode
118
+
119
+ def size(self, name: str) -> int | None:
120
+ mode, size = self._status(name)
121
+ return size if mode is not None and stat.S_ISREG(mode) else None
122
+
123
+ def ensure(self, name: str) -> None:
124
+ """A directory ``name`` here, made when missing (:meth:`child` refuses anything else at it)."""
125
+ try:
126
+ os.mkdir(name, 0o700, dir_fd=self.descriptor)
127
+ except FileExistsError:
128
+ return None
129
+
130
+ def make(self, name: str) -> None:
131
+ os.mkdir(name, 0o700, dir_fd=self.descriptor)
132
+
133
+ def create(self, name: str, data: bytes) -> None:
134
+ """``data`` as a new regular file ``name``; refused when anything, a link included, is there."""
135
+ descriptor = self._writable(name, os.O_CREAT | os.O_EXCL)
136
+ try:
137
+ _write_all(descriptor, data)
138
+ except OSError:
139
+ self.unlink(name)
140
+ raise
141
+ finally:
142
+ os.close(descriptor)
143
+
144
+ def add(self, name: str, data: bytes) -> None:
145
+ """``data`` appended to the regular file ``name``, made when missing."""
146
+ descriptor = self._writable(name, os.O_CREAT | os.O_APPEND)
147
+ try:
148
+ _write_all(descriptor, data)
149
+ finally:
150
+ os.close(descriptor)
151
+
152
+ def replace(self, name: str, data: bytes) -> None:
153
+ """``data`` as the whole of ``name`` at once: written beside it, then renamed over it."""
154
+ written = f".{name}-{uuid.uuid4().hex}"
155
+ self.create(written, data)
156
+ try:
157
+ os.rename(written, name, src_dir_fd=self.descriptor, dst_dir_fd=self.descriptor)
158
+ except OSError:
159
+ self.unlink(written)
160
+ raise
161
+
162
+ def tail(self, name: str, max_bytes: int) -> bytes | None:
163
+ """The newest ``max_bytes`` of ``name`` through :func:`~.call_log.read_tail` (anything but a regular
164
+ file reads as empty); None when it cannot be opened or read."""
165
+ try:
166
+ return read_tail(name, max_bytes, self.descriptor)
167
+ except OSError:
168
+ return None
169
+
170
+ def unlink(self, name: str) -> None:
171
+ try:
172
+ os.unlink(name, dir_fd=self.descriptor)
173
+ except FileNotFoundError:
174
+ return None
175
+
176
+ def discard(self, name: str) -> None:
177
+ """Move whatever is at ``name`` out of the way at once (a link as a link, a directory given its owner's
178
+ access first, which moving one needs on some kernels); :meth:`sweep` deletes it."""
179
+ if stat.S_ISDIR(self.mode(name) or 0):
180
+ self._own(name)
181
+ try:
182
+ os.rename(name, f"{TOMBSTONE}{uuid.uuid4().hex}", src_dir_fd=self.descriptor, dst_dir_fd=self.descriptor)
183
+ except FileNotFoundError:
184
+ return None
185
+
186
+ def sweep(self) -> None:
187
+ """Delete what :meth:`discard` set aside, as far as it can; what it cannot is logged and left."""
188
+ for name in (name for name in self.names() if name.startswith(TOMBSTONE)):
189
+ self._delete(name)
190
+
191
+ def _writable(self, name: str, flags: int) -> int:
192
+ descriptor = os.open(name, WRITING | flags, 0o600, dir_fd=self.descriptor)
193
+ try:
194
+ regular = stat.S_ISREG(os.fstat(descriptor).st_mode)
195
+ except OSError:
196
+ os.close(descriptor)
197
+ raise
198
+ if regular:
199
+ return descriptor
200
+ os.close(descriptor)
201
+ raise OSError(errno.EINVAL, "not a regular file", name)
202
+
203
+ def _own(self, name: str) -> None:
204
+ try:
205
+ os.chmod(name, 0o700, dir_fd=self.descriptor)
206
+ except OSError:
207
+ return None
208
+
209
+ def _delete(self, name: str) -> None:
210
+ mode, _ = self._status(name)
211
+ try:
212
+ self._remove(name, mode)
213
+ except OSError as error:
214
+ log_line(f"request ledger spill: {name} not removed: {type(error).__name__}")
215
+
216
+ def _remove(self, name: str, mode: int | None) -> None:
217
+ if mode is not None and stat.S_ISDIR(mode):
218
+ self._own(name)
219
+ shutil.rmtree(name, dir_fd=self.descriptor, ignore_errors=True)
220
+ return
221
+ self.unlink(name)
222
+
223
+ def _status(self, name: str) -> tuple[int | None, int]:
224
+ try:
225
+ found = os.stat(name, dir_fd=self.descriptor, follow_symlinks=False)
226
+ except OSError:
227
+ return None, 0
228
+ return found.st_mode, found.st_size
@@ -2,7 +2,7 @@
2
2
 
3
3
  A custom tool in ``tools/handlers.py`` reaches the world's rows through
4
4
  ``from gateway_env import store``. That object is a facade over the schema
5
- store (:class:`~gatewaysdk.environment.schema.store.SQLiteStore`) exposing
5
+ store (:class:`~gatewaysdk.environment.schema.database.WorldDatabase`) exposing
6
6
  exactly the methods named here — nothing else, so a handler can never reach
7
7
  the store's own transaction, snapshot or raw-SQL machinery.
8
8
 
@@ -10,7 +10,7 @@ This module is the single source of the contract: the runtime facade admits
10
10
  these names, ``schema check`` flags any other ``store.<name>`` statically,
11
11
  ``schema init`` writes them into the scaffolded handler docstring, and a test
12
12
  holds the skills and CLI help to the same list. ``describe_store`` reads the
13
- signature off the real class, so the printed contract cannot drift from it.
13
+ signature off the base class every engine extends, so the printed contract cannot drift from it.
14
14
  """
15
15
 
16
16
  from __future__ import annotations
@@ -18,14 +18,10 @@ from __future__ import annotations
18
18
  import inspect
19
19
  from dataclasses import dataclass
20
20
 
21
- from .store import SQLiteStore
21
+ from .database import WorldDatabase
22
22
 
23
- #: Every public method of the store class by name, read once with `inspect`
24
- #: so a contract entry resolves through an explicit table, not attribute lookup.
25
23
  _STORE_MEMBERS: dict[str, object] = {
26
- name: member
27
- for name, member in inspect.getmembers(SQLiteStore, inspect.isfunction)
28
- if not name.startswith("_")
24
+ name: member for name, member in inspect.getmembers(WorldDatabase, inspect.isfunction) if not name.startswith("_")
29
25
  }
30
26
 
31
27
 
@@ -38,7 +34,7 @@ class StoreMethod:
38
34
 
39
35
  @property
40
36
  def signature(self) -> str:
41
- """``name(entity, key) -> dict | None`` — read off :class:`SQLiteStore`."""
37
+ """``name(entity, key) -> dict | None`` — read off :class:`WorldDatabase`."""
42
38
  sig = inspect.signature(_STORE_MEMBERS[self.name])
43
39
  params = [p for p in sig.parameters.values() if p.name != "self"]
44
40
  # The store is written under `from __future__ import annotations`, so
@@ -51,8 +47,8 @@ class StoreMethod:
51
47
 
52
48
 
53
49
  #: The contract, in the order the docs list it. A name here MUST be a public
54
- #: method of ``SQLiteStore`` (tested); a method of the store that is not here
55
- #: is not a handler's to call.
50
+ #: method of ``WorldDatabase`` (tested); a method of the database that is not
51
+ #: here is not a handler's to call.
56
52
  STORE_METHODS: tuple[StoreMethod, ...] = (
57
53
  StoreMethod(
58
54
  "get",
@@ -71,9 +67,7 @@ STORE_METHODS: tuple[StoreMethod, ...] = (
71
67
  "update",
72
68
  "Merge `patch` into the row at `key` and validate the result; returns the row.",
73
69
  ),
74
- StoreMethod(
75
- "delete", "Remove the row at `key`; a missing row is a contract error."
76
- ),
70
+ StoreMethod("delete", "Remove the row at `key`; a missing row is a contract error."),
77
71
  StoreMethod(
78
72
  "apply_batch",
79
73
  "Apply one ingest batch {id, target, mapping, coverage, mutations} atomically; an exact retry is a no-op.",