memoryking 0.1.0__py3-none-any.whl

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 (179) hide show
  1. memoryking/__init__.py +3 -0
  2. memoryking/__main__.py +1328 -0
  3. memoryking/adapters/__init__.py +1 -0
  4. memoryking/adapters/adapter_state.py +242 -0
  5. memoryking/adapters/anchor_schema.sql +7 -0
  6. memoryking/adapters/atlas.py +441 -0
  7. memoryking/adapters/browser_commands.py +125 -0
  8. memoryking/adapters/dashboard.py +510 -0
  9. memoryking/adapters/dense_search.py +86 -0
  10. memoryking/adapters/egress_policy.py +244 -0
  11. memoryking/adapters/egress_schema.sql +13 -0
  12. memoryking/adapters/embedding.schema.json +302 -0
  13. memoryking/adapters/embedding_store.py +469 -0
  14. memoryking/adapters/execution.py +369 -0
  15. memoryking/adapters/experience.py +423 -0
  16. memoryking/adapters/experience.schema.json +1508 -0
  17. memoryking/adapters/experience_records.py +239 -0
  18. memoryking/adapters/experience_schema.sql +23 -0
  19. memoryking/adapters/handoff.py +494 -0
  20. memoryking/adapters/handoff.schema.json +299 -0
  21. memoryking/adapters/handoff_schema.sql +17 -0
  22. memoryking/adapters/index_schema.sql +11 -0
  23. memoryking/adapters/inference.py +454 -0
  24. memoryking/adapters/inference.schema.json +541 -0
  25. memoryking/adapters/inspection.py +1128 -0
  26. memoryking/adapters/inspection.schema.json +568 -0
  27. memoryking/adapters/knowledge.schema.json +633 -0
  28. memoryking/adapters/knowledge_schema.sql +37 -0
  29. memoryking/adapters/knowledge_store.py +800 -0
  30. memoryking/adapters/legacy_snapshot.py +358 -0
  31. memoryking/adapters/legacy_tables.py +49 -0
  32. memoryking/adapters/local_contract.py +45 -0
  33. memoryking/adapters/local_embeddings.py +189 -0
  34. memoryking/adapters/local_files.py +242 -0
  35. memoryking/adapters/local_ipc.py +258 -0
  36. memoryking/adapters/local_schema.sql +44 -0
  37. memoryking/adapters/local_store.py +632 -0
  38. memoryking/adapters/local_wire.schema.json +7672 -0
  39. memoryking/adapters/models/minilm-l6-v2-onnx.json +57 -0
  40. memoryking/adapters/models/ms-marco-minilm-l6-v2-onnx.json +57 -0
  41. memoryking/adapters/optional_schema.sql +43 -0
  42. memoryking/adapters/plan_dashboard.py +51 -0
  43. memoryking/adapters/plans.py +253 -0
  44. memoryking/adapters/postgres_admin.py +300 -0
  45. memoryking/adapters/postgres_anchor_schema.sql +9 -0
  46. memoryking/adapters/postgres_counter.sql +14 -0
  47. memoryking/adapters/postgres_egress_schema.sql +15 -0
  48. memoryking/adapters/postgres_experience_schema.sql +39 -0
  49. memoryking/adapters/postgres_index_schema.sql +7 -0
  50. memoryking/adapters/postgres_optional_schema.sql +71 -0
  51. memoryking/adapters/postgres_pool.py +77 -0
  52. memoryking/adapters/postgres_recovery.py +525 -0
  53. memoryking/adapters/postgres_schema.sql +365 -0
  54. memoryking/adapters/postgres_sql.py +102 -0
  55. memoryking/adapters/postgres_store.py +428 -0
  56. memoryking/adapters/postgres_summary_schema.sql +12 -0
  57. memoryking/adapters/postgres_trust_schema.sql +20 -0
  58. memoryking/adapters/processing.schema.json +471 -0
  59. memoryking/adapters/processing_store.py +346 -0
  60. memoryking/adapters/projects.py +83 -0
  61. memoryking/adapters/proposals.py +238 -0
  62. memoryking/adapters/ranking.py +315 -0
  63. memoryking/adapters/repository.schema.json +664 -0
  64. memoryking/adapters/repository_git.py +264 -0
  65. memoryking/adapters/repository_schema.sql +25 -0
  66. memoryking/adapters/repository_store.py +960 -0
  67. memoryking/adapters/retrieval.py +1285 -0
  68. memoryking/adapters/retrieval.schema.json +553 -0
  69. memoryking/adapters/retrieval_schema.sql +10 -0
  70. memoryking/adapters/shared_control.py +40 -0
  71. memoryking/adapters/shared_dashboard.py +636 -0
  72. memoryking/adapters/shared_gateway.py +63 -0
  73. memoryking/adapters/shared_http.py +216 -0
  74. memoryking/adapters/shared_mcp.py +159 -0
  75. memoryking/adapters/shared_service.py +124 -0
  76. memoryking/adapters/stdio.py +193 -0
  77. memoryking/adapters/stdio.tools.json +6776 -0
  78. memoryking/adapters/summary_schema.sql +10 -0
  79. memoryking/adapters/team.py +253 -0
  80. memoryking/adapters/timeline.py +80 -0
  81. memoryking/adapters/token_count.py +55 -0
  82. memoryking/adapters/tokenizers/LICENSE +21 -0
  83. memoryking/adapters/tokenizers/cl100k_base.tiktoken +100256 -0
  84. memoryking/adapters/trust.py +123 -0
  85. memoryking/adapters/trust_schema.sql +13 -0
  86. memoryking/adapters/web/app.css +1251 -0
  87. memoryking/adapters/web/app.js +907 -0
  88. memoryking/adapters/web/brand.js +44 -0
  89. memoryking/adapters/web/crown-mono.svg +1 -0
  90. memoryking/adapters/web/crown.svg +8 -0
  91. memoryking/adapters/web/elephant.png +0 -0
  92. memoryking/adapters/web/favicon.svg +8 -0
  93. memoryking/adapters/web/graph-layout.js +52 -0
  94. memoryking/adapters/web/graph-worker.js +10 -0
  95. memoryking/adapters/web/graph.js +570 -0
  96. memoryking/adapters/web/index.html +208 -0
  97. memoryking/adapters/web/observatory.js +1208 -0
  98. memoryking/adapters/web/team.js +151 -0
  99. memoryking/adapters/web/wordmark.svg +1 -0
  100. memoryking/adapters/working.py +971 -0
  101. memoryking/adapters/working.schema.json +1717 -0
  102. memoryking/adapters/working_schema.sql +24 -0
  103. memoryking/application/__init__.py +1 -0
  104. memoryking/application/conformance.py +50 -0
  105. memoryking/application/legacy_import.py +337 -0
  106. memoryking/application/local_port.py +9 -0
  107. memoryking/application/storage.py +117 -0
  108. memoryking/application/store_core.py +1292 -0
  109. memoryking/backups.py +131 -0
  110. memoryking/contracts/__init__.py +6 -0
  111. memoryking/contracts/__main__.py +20 -0
  112. memoryking/contracts/canonical.py +88 -0
  113. memoryking/contracts/embedding.schema.json +302 -0
  114. memoryking/contracts/embedding_generated.py +65 -0
  115. memoryking/contracts/experience.schema.json +1508 -0
  116. memoryking/contracts/experience_generated.py +239 -0
  117. memoryking/contracts/generated.py +122 -0
  118. memoryking/contracts/handoff.schema.json +299 -0
  119. memoryking/contracts/handoff_generated.py +69 -0
  120. memoryking/contracts/inference.schema.json +541 -0
  121. memoryking/contracts/inference_generated.py +106 -0
  122. memoryking/contracts/processing.schema.json +471 -0
  123. memoryking/contracts/processing_generated.py +82 -0
  124. memoryking/contracts/py.typed +0 -0
  125. memoryking/contracts/repository.schema.json +664 -0
  126. memoryking/contracts/repository_generated.py +144 -0
  127. memoryking/contracts/retrieval.schema.json +553 -0
  128. memoryking/contracts/retrieval_generated.py +110 -0
  129. memoryking/contracts/schema.json +696 -0
  130. memoryking/contracts/validation.py +92 -0
  131. memoryking/contracts/working.schema.json +1717 -0
  132. memoryking/contracts/working_generated.py +291 -0
  133. memoryking/domain/__init__.py +1 -0
  134. memoryking/domain/anchors.py +97 -0
  135. memoryking/domain/briefing.py +108 -0
  136. memoryking/domain/briefing_text.py +222 -0
  137. memoryking/domain/checkpoint.py +118 -0
  138. memoryking/domain/compression.py +64 -0
  139. memoryking/domain/delta.py +129 -0
  140. memoryking/domain/embeddings.py +90 -0
  141. memoryking/domain/hints.py +465 -0
  142. memoryking/domain/http_status.py +45 -0
  143. memoryking/domain/learning.py +62 -0
  144. memoryking/domain/local.py +65 -0
  145. memoryking/domain/plans.py +140 -0
  146. memoryking/domain/repository.py +118 -0
  147. memoryking/domain/selectors.py +356 -0
  148. memoryking/domain/summary.py +88 -0
  149. memoryking/domain/usage.py +163 -0
  150. memoryking/embedding_loop.py +98 -0
  151. memoryking/embedding_worker.py +131 -0
  152. memoryking/harness.py +882 -0
  153. memoryking/harness_context.py +376 -0
  154. memoryking/hooks.py +171 -0
  155. memoryking/host_hooks.py +454 -0
  156. memoryking/lean.py +352 -0
  157. memoryking/memory_tool.py +776 -0
  158. memoryking/migration.py +194 -0
  159. memoryking/model_install.py +78 -0
  160. memoryking/observability.py +101 -0
  161. memoryking/observability_metrics.py +100 -0
  162. memoryking/profiles.py +150 -0
  163. memoryking/providers.py +330 -0
  164. memoryking/py.typed +0 -0
  165. memoryking/pytest_plugin.py +69 -0
  166. memoryking/reference_agent.py +152 -0
  167. memoryking/repository_worker.py +57 -0
  168. memoryking/resume_adapter.py +154 -0
  169. memoryking/sdk.py +302 -0
  170. memoryking/shared.py +301 -0
  171. memoryking/shared_sdk.py +101 -0
  172. memoryking/vault.py +176 -0
  173. memoryking-0.1.0.dist-info/METADATA +157 -0
  174. memoryking-0.1.0.dist-info/RECORD +179 -0
  175. memoryking-0.1.0.dist-info/WHEEL +5 -0
  176. memoryking-0.1.0.dist-info/entry_points.txt +7 -0
  177. memoryking-0.1.0.dist-info/licenses/LICENSE +202 -0
  178. memoryking-0.1.0.dist-info/licenses/NOTICE +12 -0
  179. memoryking-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,244 @@
1
+ """The operator's egress policy: which providers, models and hosts retained context may reach.
2
+
3
+ A policy is a private TOML file loaded by `serve --egress-policy`. Without one, the only
4
+ provider is the local recorder and nothing leaves the machine. The daemon enforces the
5
+ policy where it cannot be skipped, at inference authorize and consume; the host process
6
+ that runs an adapter reads the same file to find its credentials.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import hashlib
12
+ import ipaddress
13
+ import json
14
+ import re
15
+ import tomllib
16
+ from dataclasses import dataclass, field
17
+ from pathlib import Path
18
+ from typing import Any
19
+
20
+ from memoryking.adapters.local_files import private_file
21
+ from memoryking.domain.local import LocalError
22
+
23
+ LOCAL_PROVIDER = "local-recording"
24
+ LOCAL_MODEL = "echo-v1"
25
+ LOCAL_REVISION = "local-recording-v1"
26
+ PROVIDERS = ("anthropic-messages", "openai-chat", "vertex-ai")
27
+ CLASSIFICATIONS = ("public", "internal", "restricted")
28
+ REVISION = re.compile(r"[A-Za-z0-9._-]{1,96}")
29
+ MODEL = re.compile(r"[A-Za-z0-9._:@/-]{1,128}")
30
+ HOST = re.compile(r"[A-Za-z0-9.-]{1,253}(:[0-9]{1,5})?")
31
+ REQUEST_BYTES_LIMIT = 98304
32
+
33
+
34
+ def rank(classification: str) -> int:
35
+ """Order classifications so a ceiling can be compared; unknown names rank highest."""
36
+ return CLASSIFICATIONS.index(classification) if classification in CLASSIFICATIONS else 99
37
+
38
+
39
+ def is_loopback(host: str) -> bool:
40
+ name = host.rsplit(":", 1)[0] if re.fullmatch(r".*:[0-9]+", host) else host
41
+ if name == "localhost":
42
+ return True
43
+ try:
44
+ return ipaddress.ip_address(name.strip("[]")).is_loopback
45
+ except ValueError:
46
+ return False
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ class ProviderPolicy:
51
+ """One permitted destination. Everything an adapter needs, nothing it may vary."""
52
+
53
+ name: str
54
+ host: str
55
+ models: tuple[str, ...]
56
+ max_classification: str = "internal"
57
+ max_request_bytes: int = REQUEST_BYTES_LIMIT
58
+ insecure_http: bool = False
59
+ key_file: Path | None = None
60
+ token_file: Path | None = None
61
+ token_command: tuple[str, ...] | None = None
62
+ path: str | None = None
63
+ publisher: str = "google"
64
+ location: str | None = None
65
+ project: str | None = None
66
+ timeout_s: int = 60
67
+ max_output_tokens: int = 1024
68
+ headers: dict[str, str] = field(default_factory=dict)
69
+
70
+ def allows(self, model: str) -> bool:
71
+ return model in self.models
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class EgressPolicy:
76
+ revision: str
77
+ providers: dict[str, ProviderPolicy]
78
+ source: Path | None = None
79
+ fingerprint: str = ""
80
+
81
+ @property
82
+ def binding(self) -> str:
83
+ """The revision every conversation binds to: the operator's label plus a digest
84
+ of the policy content, so editing a host or model without a new label still
85
+ retires every conversation instead of letting host and daemon disagree."""
86
+ if not self.fingerprint:
87
+ return self.revision
88
+ return f"{self.revision[:79]}.{self.fingerprint[:16]}"
89
+
90
+ @classmethod
91
+ def load(cls, path: Path) -> EgressPolicy:
92
+ private_file(path)
93
+ try:
94
+ data = tomllib.loads(path.read_text())
95
+ except (tomllib.TOMLDecodeError, UnicodeError) as exc:
96
+ raise LocalError("egress_policy_invalid") from exc
97
+ return cls.parse(data, path)
98
+
99
+ @classmethod
100
+ def parse(cls, data: Any, source: Path | None = None) -> EgressPolicy:
101
+ if not isinstance(data, dict) or set(data) - {"revision", "providers"}:
102
+ raise LocalError("egress_policy_invalid")
103
+ revision = data.get("revision")
104
+ if not isinstance(revision, str) or not REVISION.fullmatch(revision):
105
+ raise LocalError("egress_policy_invalid")
106
+ if revision == LOCAL_REVISION:
107
+ raise LocalError("egress_policy_invalid")
108
+ entries = data.get("providers", [])
109
+ if not isinstance(entries, list) or len(entries) > 16:
110
+ raise LocalError("egress_policy_invalid")
111
+ providers: dict[str, ProviderPolicy] = {}
112
+ for entry in entries:
113
+ provider = _provider(entry)
114
+ if provider.name in providers:
115
+ raise LocalError("egress_policy_invalid")
116
+ providers[provider.name] = provider
117
+ fingerprint = hashlib.sha256(
118
+ json.dumps(data, sort_keys=True, separators=(",", ":"), default=str).encode()
119
+ ).hexdigest()
120
+ return cls(revision, providers, source, fingerprint)
121
+
122
+ def provider(self, name: str) -> ProviderPolicy | None:
123
+ return self.providers.get(name)
124
+
125
+
126
+ def _provider(entry: Any) -> ProviderPolicy:
127
+ known = {
128
+ "name",
129
+ "host",
130
+ "models",
131
+ "max_classification",
132
+ "max_request_bytes",
133
+ "insecure_http",
134
+ "key_file",
135
+ "token_file",
136
+ "token_command",
137
+ "path",
138
+ "publisher",
139
+ "location",
140
+ "project",
141
+ "timeout_s",
142
+ "max_output_tokens",
143
+ "headers",
144
+ }
145
+ if not isinstance(entry, dict) or set(entry) - known:
146
+ raise LocalError("egress_policy_invalid")
147
+ name = entry.get("name")
148
+ if name not in PROVIDERS:
149
+ raise LocalError("egress_policy_invalid")
150
+ models = entry.get("models")
151
+ if (
152
+ not isinstance(models, list)
153
+ or not models
154
+ or len(models) > 64
155
+ or any(not isinstance(m, str) or not MODEL.fullmatch(m) for m in models)
156
+ ):
157
+ raise LocalError("egress_policy_invalid")
158
+ location = _optional_str(entry, "location", r"[a-z0-9-]{1,64}")
159
+ project = _optional_str(entry, "project", r"[a-z][a-z0-9-]{4,29}")
160
+ host = entry.get("host")
161
+ if host is None and name == "vertex-ai" and location:
162
+ host = f"{location}-aiplatform.googleapis.com"
163
+ if not isinstance(host, str) or not HOST.fullmatch(host):
164
+ raise LocalError("egress_policy_invalid")
165
+ insecure = entry.get("insecure_http", False)
166
+ if not isinstance(insecure, bool) or (insecure and not is_loopback(host)):
167
+ # Plain HTTP is for a model server on this machine only, never for a remote host.
168
+ raise LocalError("egress_policy_invalid")
169
+ classification = entry.get("max_classification", "internal")
170
+ if classification not in CLASSIFICATIONS:
171
+ raise LocalError("egress_policy_invalid")
172
+ size = entry.get("max_request_bytes", REQUEST_BYTES_LIMIT)
173
+ if isinstance(size, bool) or not isinstance(size, int) or not 1 <= size <= REQUEST_BYTES_LIMIT:
174
+ raise LocalError("egress_policy_invalid")
175
+ timeout = entry.get("timeout_s", 60)
176
+ if isinstance(timeout, bool) or not isinstance(timeout, int) or not 1 <= timeout <= 300:
177
+ raise LocalError("egress_policy_invalid")
178
+ output = entry.get("max_output_tokens", 1024)
179
+ if isinstance(output, bool) or not isinstance(output, int) or not 1 <= output <= 65536:
180
+ raise LocalError("egress_policy_invalid")
181
+ publisher = entry.get("publisher", "google")
182
+ if publisher not in {"google", "anthropic"}:
183
+ raise LocalError("egress_policy_invalid")
184
+ if name == "vertex-ai" and not (location and project):
185
+ raise LocalError("egress_policy_invalid")
186
+ command = entry.get("token_command")
187
+ if command is not None and (
188
+ not isinstance(command, list)
189
+ or not command
190
+ or len(command) > 16
191
+ or any(not isinstance(c, str) or not c for c in command)
192
+ or not Path(command[0]).is_absolute()
193
+ ):
194
+ raise LocalError("egress_policy_invalid")
195
+ headers = entry.get("headers", {})
196
+ if (
197
+ not isinstance(headers, dict)
198
+ or len(headers) > 8
199
+ or any(
200
+ not isinstance(k, str)
201
+ or not re.fullmatch(r"[A-Za-z0-9-]{1,64}", k)
202
+ or k.lower() in {"authorization", "x-api-key", "host", "content-length"}
203
+ or not isinstance(v, str)
204
+ or len(v) > 256
205
+ for k, v in headers.items()
206
+ )
207
+ ):
208
+ raise LocalError("egress_policy_invalid")
209
+ return ProviderPolicy(
210
+ name=name,
211
+ host=host,
212
+ models=tuple(models),
213
+ max_classification=classification,
214
+ max_request_bytes=size,
215
+ insecure_http=insecure,
216
+ key_file=_optional_path(entry, "key_file"),
217
+ token_file=_optional_path(entry, "token_file"),
218
+ token_command=tuple(command) if command else None,
219
+ path=_optional_str(entry, "path", r"/[A-Za-z0-9._/:-]{0,255}"),
220
+ publisher=publisher,
221
+ location=location,
222
+ project=project,
223
+ timeout_s=timeout,
224
+ max_output_tokens=output,
225
+ headers=dict(headers),
226
+ )
227
+
228
+
229
+ def _optional_str(entry: dict[str, Any], key: str, pattern: str) -> str | None:
230
+ value = entry.get(key)
231
+ if value is None:
232
+ return None
233
+ if not isinstance(value, str) or not re.fullmatch(pattern, value):
234
+ raise LocalError("egress_policy_invalid")
235
+ return value
236
+
237
+
238
+ def _optional_path(entry: dict[str, Any], key: str) -> Path | None:
239
+ value = entry.get(key)
240
+ if value is None:
241
+ return None
242
+ if not isinstance(value, str) or not Path(value).is_absolute():
243
+ raise LocalError("egress_policy_invalid")
244
+ return Path(value)
@@ -0,0 +1,13 @@
1
+ BEGIN IMMEDIATE;
2
+ CREATE TABLE IF NOT EXISTS egress_audit (
3
+ tenant TEXT NOT NULL REFERENCES tenants, id TEXT NOT NULL, principal TEXT NOT NULL,
4
+ project TEXT NOT NULL, incarnation TEXT NOT NULL, provider TEXT NOT NULL, model TEXT NOT NULL,
5
+ host TEXT NOT NULL, policy_revision TEXT NOT NULL, request_hash TEXT NOT NULL,
6
+ manifest_hash TEXT NOT NULL, manifest TEXT NOT NULL, classification TEXT NOT NULL,
7
+ request_bytes INTEGER NOT NULL, evaluated INTEGER NOT NULL, deadline INTEGER NOT NULL,
8
+ status TEXT NOT NULL, wire_hash TEXT, response_hash TEXT, input_tokens INTEGER,
9
+ output_tokens INTEGER, reported INTEGER, expires INTEGER NOT NULL,
10
+ PRIMARY KEY(tenant,id));
11
+ CREATE INDEX IF NOT EXISTS egress_audit_project ON egress_audit(tenant,project,evaluated);
12
+ PRAGMA user_version=10;
13
+ COMMIT;
@@ -0,0 +1,302 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://memoryking.invalid/embedding-v1",
4
+ "title": "MemoryKing optional embedding administration and workers v1",
5
+ "oneOf": [
6
+ {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "version": {
11
+ "const": 1
12
+ },
13
+ "incarnation": {
14
+ "type": "string",
15
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
16
+ },
17
+ "action": {
18
+ "const": "configure"
19
+ },
20
+ "args": {
21
+ "$ref": "#/$defs/Configure"
22
+ },
23
+ "key": {
24
+ "type": "string",
25
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
26
+ }
27
+ },
28
+ "required": [
29
+ "version",
30
+ "incarnation",
31
+ "action",
32
+ "args",
33
+ "key"
34
+ ]
35
+ },
36
+ {
37
+ "type": "object",
38
+ "additionalProperties": false,
39
+ "properties": {
40
+ "version": {
41
+ "const": 1
42
+ },
43
+ "incarnation": {
44
+ "type": "string",
45
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
46
+ },
47
+ "action": {
48
+ "const": "claim"
49
+ },
50
+ "args": {
51
+ "$ref": "#/$defs/Partition"
52
+ }
53
+ },
54
+ "required": [
55
+ "version",
56
+ "incarnation",
57
+ "action",
58
+ "args"
59
+ ]
60
+ },
61
+ {
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "properties": {
65
+ "version": {
66
+ "const": 1
67
+ },
68
+ "incarnation": {
69
+ "type": "string",
70
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
71
+ },
72
+ "action": {
73
+ "const": "complete"
74
+ },
75
+ "args": {
76
+ "$ref": "#/$defs/Complete"
77
+ }
78
+ },
79
+ "required": [
80
+ "version",
81
+ "incarnation",
82
+ "action",
83
+ "args"
84
+ ]
85
+ },
86
+ {
87
+ "type": "object",
88
+ "additionalProperties": false,
89
+ "properties": {
90
+ "version": {
91
+ "const": 1
92
+ },
93
+ "incarnation": {
94
+ "type": "string",
95
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
96
+ },
97
+ "action": {
98
+ "const": "fail"
99
+ },
100
+ "args": {
101
+ "$ref": "#/$defs/Fail"
102
+ }
103
+ },
104
+ "required": [
105
+ "version",
106
+ "incarnation",
107
+ "action",
108
+ "args"
109
+ ]
110
+ },
111
+ {
112
+ "type": "object",
113
+ "additionalProperties": false,
114
+ "properties": {
115
+ "version": {
116
+ "const": 1
117
+ },
118
+ "incarnation": {
119
+ "type": "string",
120
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
121
+ },
122
+ "action": {
123
+ "const": "status"
124
+ },
125
+ "args": {
126
+ "$ref": "#/$defs/Partition"
127
+ }
128
+ },
129
+ "required": [
130
+ "version",
131
+ "incarnation",
132
+ "action",
133
+ "args"
134
+ ]
135
+ }
136
+ ],
137
+ "$defs": {
138
+ "Configure": {
139
+ "type": "object",
140
+ "additionalProperties": false,
141
+ "properties": {
142
+ "project": {
143
+ "type": "string",
144
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
145
+ },
146
+ "model": {
147
+ "type": "string",
148
+ "enum": [
149
+ "minilm-l6-v2-onnx"
150
+ ]
151
+ },
152
+ "state": {
153
+ "type": "string",
154
+ "enum": [
155
+ "experimental",
156
+ "disabled"
157
+ ]
158
+ },
159
+ "expected_generation": {
160
+ "type": "integer",
161
+ "minimum": 0,
162
+ "maximum": 9007199254740991
163
+ }
164
+ },
165
+ "required": [
166
+ "project",
167
+ "model",
168
+ "state",
169
+ "expected_generation"
170
+ ]
171
+ },
172
+ "Partition": {
173
+ "type": "object",
174
+ "additionalProperties": false,
175
+ "properties": {
176
+ "project": {
177
+ "type": "string",
178
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
179
+ },
180
+ "fingerprint": {
181
+ "type": "string",
182
+ "pattern": "^[a-f0-9]{64}(?![\\s\\S])"
183
+ }
184
+ },
185
+ "required": [
186
+ "project",
187
+ "fingerprint"
188
+ ]
189
+ },
190
+ "Complete": {
191
+ "type": "object",
192
+ "additionalProperties": false,
193
+ "properties": {
194
+ "project": {
195
+ "type": "string",
196
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
197
+ },
198
+ "lease": {
199
+ "type": "string",
200
+ "minLength": 1,
201
+ "maxLength": 8192
202
+ },
203
+ "fingerprint": {
204
+ "type": "string",
205
+ "pattern": "^[a-f0-9]{64}(?![\\s\\S])"
206
+ },
207
+ "input_hash": {
208
+ "type": "string",
209
+ "pattern": "^[a-f0-9]{64}(?![\\s\\S])"
210
+ },
211
+ "vector": {
212
+ "type": "array",
213
+ "minItems": 1,
214
+ "maxItems": 4096,
215
+ "items": {
216
+ "type": "integer",
217
+ "minimum": -1000000,
218
+ "maximum": 1000000
219
+ }
220
+ },
221
+ "input_tokens": {
222
+ "anyOf": [
223
+ {
224
+ "type": "integer",
225
+ "minimum": 0,
226
+ "maximum": 1000000
227
+ },
228
+ {
229
+ "type": "null"
230
+ }
231
+ ]
232
+ },
233
+ "truncated": {
234
+ "type": "boolean"
235
+ },
236
+ "duration_ms": {
237
+ "type": "integer",
238
+ "minimum": 0,
239
+ "maximum": 600000
240
+ }
241
+ },
242
+ "required": [
243
+ "project",
244
+ "lease",
245
+ "fingerprint",
246
+ "input_hash",
247
+ "vector",
248
+ "input_tokens",
249
+ "truncated",
250
+ "duration_ms"
251
+ ]
252
+ },
253
+ "Fail": {
254
+ "type": "object",
255
+ "additionalProperties": false,
256
+ "properties": {
257
+ "project": {
258
+ "type": "string",
259
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
260
+ },
261
+ "lease": {
262
+ "type": "string",
263
+ "minLength": 1,
264
+ "maxLength": 8192
265
+ },
266
+ "reason": {
267
+ "type": "string",
268
+ "enum": [
269
+ "provider_unavailable",
270
+ "model_invalid",
271
+ "interrupted",
272
+ "provider_failure"
273
+ ]
274
+ },
275
+ "input_tokens": {
276
+ "anyOf": [
277
+ {
278
+ "type": "integer",
279
+ "minimum": 0,
280
+ "maximum": 1000000
281
+ },
282
+ {
283
+ "type": "null"
284
+ }
285
+ ]
286
+ },
287
+ "duration_ms": {
288
+ "type": "integer",
289
+ "minimum": 0,
290
+ "maximum": 600000
291
+ }
292
+ },
293
+ "required": [
294
+ "project",
295
+ "lease",
296
+ "reason",
297
+ "input_tokens",
298
+ "duration_ms"
299
+ ]
300
+ }
301
+ }
302
+ }