Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/routes_starred.py +70 -0
- platform/core/store_pg.py +22 -0
- platform/harness/runtime.py +9 -0
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
RELEASES.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v74",
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "bc67fa8",
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v74",
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
bc67fa8
|
api/routes_starred.py
CHANGED
|
@@ -28,6 +28,7 @@ disagree — a view deleted, a view unmarked from inside the database, a store w
|
|
| 28 |
and not the other — the product has two answers to one question and no way to tell which is right.
|
| 29 |
The scan is the price of one flag, and it is paid off the critical path.
|
| 30 |
"""
|
|
|
|
| 31 |
import hashlib
|
| 32 |
import json
|
| 33 |
import time
|
|
@@ -72,6 +73,74 @@ VIEW_SCAN_BUDGET_S = 2.5
|
|
| 72 |
VIEW_SCAN_WORKERS = 4
|
| 73 |
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
def _clean_id(raw):
|
| 76 |
"""One id, or "" — the only shape this file stores."""
|
| 77 |
return str(raw or "").strip()[:_MAX_ID]
|
|
@@ -379,6 +448,7 @@ def _payload(session, keys=None, cache=None):
|
|
| 379 |
consumer forgets to test for.
|
| 380 |
⚠ `cache` is a scan an earlier pass in THIS request already paid for — see `_scan_starred_views`.
|
| 381 |
"""
|
|
|
|
| 382 |
lists = _read_lists(session)
|
| 383 |
if keys is None:
|
| 384 |
keys, _ = _database_keys(session)
|
|
|
|
| 28 |
and not the other — the product has two answers to one question and no way to tell which is right.
|
| 29 |
The scan is the price of one flag, and it is paid off the critical path.
|
| 30 |
"""
|
| 31 |
+
import copy
|
| 32 |
import hashlib
|
| 33 |
import json
|
| 34 |
import time
|
|
|
|
| 73 |
VIEW_SCAN_WORKERS = 4
|
| 74 |
|
| 75 |
|
| 76 |
+
class _RequestReadMemo:
|
| 77 |
+
"""Read-through snapshot for one Starred payload assembly, never a cross-request cache."""
|
| 78 |
+
|
| 79 |
+
def __init__(self, runtime):
|
| 80 |
+
self._runtime = runtime
|
| 81 |
+
self._docs = {}
|
| 82 |
+
self._projections = {}
|
| 83 |
+
|
| 84 |
+
def preload(self, names):
|
| 85 |
+
reader = getattr(self._runtime, "get_many", None)
|
| 86 |
+
if not callable(reader):
|
| 87 |
+
return
|
| 88 |
+
try:
|
| 89 |
+
answer = reader(names)
|
| 90 |
+
except Exception:
|
| 91 |
+
return
|
| 92 |
+
if isinstance(answer, dict):
|
| 93 |
+
self._docs.update(answer)
|
| 94 |
+
|
| 95 |
+
def get(self, name, fresh=False):
|
| 96 |
+
key = str(name)
|
| 97 |
+
if not fresh and key in self._docs:
|
| 98 |
+
return copy.deepcopy(self._docs[key])
|
| 99 |
+
answer = self._runtime.get(name, fresh=fresh)
|
| 100 |
+
if not fresh:
|
| 101 |
+
self._docs[key] = copy.deepcopy(answer)
|
| 102 |
+
return answer
|
| 103 |
+
|
| 104 |
+
def get_projection(self, name, drop=()):
|
| 105 |
+
stamp = (str(name), tuple(str(key) for key in drop))
|
| 106 |
+
if stamp not in self._projections:
|
| 107 |
+
self._projections[stamp] = self._runtime.get_projection(name, drop=drop)
|
| 108 |
+
return copy.deepcopy(self._projections[stamp])
|
| 109 |
+
|
| 110 |
+
def get_projections(self, names, drop=()):
|
| 111 |
+
keys = [str(name) for name in names or ()]
|
| 112 |
+
stamps = [(key, tuple(str(field) for field in drop)) for key in keys]
|
| 113 |
+
if all(stamp in self._projections for stamp in stamps):
|
| 114 |
+
return {key: copy.deepcopy(self._projections[stamp])
|
| 115 |
+
for key, stamp in zip(keys, stamps)}
|
| 116 |
+
reader = getattr(self._runtime, "get_projections", None)
|
| 117 |
+
if not callable(reader):
|
| 118 |
+
return None
|
| 119 |
+
answer = reader(keys, drop=drop)
|
| 120 |
+
if answer is None:
|
| 121 |
+
return None
|
| 122 |
+
for key, stamp in zip(keys, stamps):
|
| 123 |
+
self._projections[stamp] = copy.deepcopy(answer.get(key, {}))
|
| 124 |
+
return {key: copy.deepcopy(self._projections[stamp])
|
| 125 |
+
for key, stamp in zip(keys, stamps)}
|
| 126 |
+
|
| 127 |
+
def __getattr__(self, name):
|
| 128 |
+
return getattr(self._runtime, name)
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def _memoized_session(session):
|
| 132 |
+
"""Preload the four small registries Starred rereads while assembling one response."""
|
| 133 |
+
import application_registry
|
| 134 |
+
from core import shares
|
| 135 |
+
|
| 136 |
+
runtime = _RequestReadMemo(session.runtime)
|
| 137 |
+
runtime.preload((_STARRED_KEY, routes_nav._NAV_RECENTS_KEY,
|
| 138 |
+
shares.SHARES_KEY, application_registry._KEY))
|
| 139 |
+
wrapped = copy.copy(session)
|
| 140 |
+
wrapped.runtime = runtime
|
| 141 |
+
return wrapped
|
| 142 |
+
|
| 143 |
+
|
| 144 |
def _clean_id(raw):
|
| 145 |
"""One id, or "" — the only shape this file stores."""
|
| 146 |
return str(raw or "").strip()[:_MAX_ID]
|
|
|
|
| 448 |
consumer forgets to test for.
|
| 449 |
⚠ `cache` is a scan an earlier pass in THIS request already paid for — see `_scan_starred_views`.
|
| 450 |
"""
|
| 451 |
+
session = _memoized_session(session)
|
| 452 |
lists = _read_lists(session)
|
| 453 |
if keys is None:
|
| 454 |
keys, _ = _database_keys(session)
|
platform/core/store_pg.py
CHANGED
|
@@ -382,6 +382,24 @@ def _get_projections(names, drop=(), tenant_slug=None):
|
|
| 382 |
}
|
| 383 |
|
| 384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
def exists(name, tenant_slug=None):
|
| 386 |
"""True/False — and unlike the HF backend this is NEVER "True on uncertainty".
|
| 387 |
|
|
@@ -649,6 +667,10 @@ class PgStore:
|
|
| 649 |
"""Bound batch projection; absent keys keep the single-read empty-document shape."""
|
| 650 |
return _get_projections(names, drop=drop, tenant_slug=self.tenant_slug)
|
| 651 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 652 |
def _read_strict(self, name):
|
| 653 |
"""Interface parity with the HF Store. There, `get` is lenient (swallows a transient
|
| 654 |
failure) and `_read_strict` opts out so a failed read ABORTS a read-modify-write instead
|
|
|
|
| 382 |
}
|
| 383 |
|
| 384 |
|
| 385 |
+
def _get_many(names, tenant_slug=None):
|
| 386 |
+
"""Several ordinary documents in one round trip, keyed by requested store key."""
|
| 387 |
+
keys = list(dict.fromkeys(str(name) for name in (names or ()) if str(name)))
|
| 388 |
+
if not keys:
|
| 389 |
+
return {}
|
| 390 |
+
with _pool().connection() as con:
|
| 391 |
+
rows = con.execute(
|
| 392 |
+
_q('SELECT key, value FROM {tbl} WHERE key = ANY(%s::text[])',
|
| 393 |
+
'store_kv', tenant_slug),
|
| 394 |
+
(keys,)).fetchall()
|
| 395 |
+
found = {str(key): value for key, value in rows}
|
| 396 |
+
return {
|
| 397 |
+
key: (dict(found[key]) if isinstance(found.get(key), dict)
|
| 398 |
+
else (found[key] if key in found else {}))
|
| 399 |
+
for key in keys
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
|
| 403 |
def exists(name, tenant_slug=None):
|
| 404 |
"""True/False — and unlike the HF backend this is NEVER "True on uncertainty".
|
| 405 |
|
|
|
|
| 667 |
"""Bound batch projection; absent keys keep the single-read empty-document shape."""
|
| 668 |
return _get_projections(names, drop=drop, tenant_slug=self.tenant_slug)
|
| 669 |
|
| 670 |
+
def get_many(self, names):
|
| 671 |
+
"""Bound multi-key read used by request-scoped read snapshots."""
|
| 672 |
+
return _get_many(names, tenant_slug=self.tenant_slug)
|
| 673 |
+
|
| 674 |
def _read_strict(self, name):
|
| 675 |
"""Interface parity with the HF Store. There, `get` is lenient (swallows a transient
|
| 676 |
failure) and `_read_strict` opts out so a failed read ABORTS a read-modify-write instead
|
platform/harness/runtime.py
CHANGED
|
@@ -194,6 +194,15 @@ class TenantRuntime:
|
|
| 194 |
answer = reader([store_key for _name, store_key in keyed], drop=drop)
|
| 195 |
return {name: answer.get(store_key, {}) for name, store_key in keyed}
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
def revision(self, name):
|
| 198 |
"""Return the tiny durable change token for this tenant's addressed bucket."""
|
| 199 |
return self._store().revision(self.store_key(name))
|
|
|
|
| 194 |
answer = reader([store_key for _name, store_key in keyed], drop=drop)
|
| 195 |
return {name: answer.get(store_key, {}) for name, store_key in keyed}
|
| 196 |
|
| 197 |
+
def get_many(self, names):
|
| 198 |
+
"""Batch ordinary reads when the active bound store offers that optimization."""
|
| 199 |
+
reader = getattr(self._store(), "get_many", None)
|
| 200 |
+
if not callable(reader):
|
| 201 |
+
return None
|
| 202 |
+
keyed = [(str(name), self.store_key(name)) for name in (names or ())]
|
| 203 |
+
answer = reader([store_key for _name, store_key in keyed])
|
| 204 |
+
return {name: answer.get(store_key, {}) for name, store_key in keyed}
|
| 205 |
+
|
| 206 |
def revision(self, name):
|
| 207 |
"""Return the tiny durable change token for this tenant's addressed bucket."""
|
| 208 |
return self._store().revision(self.store_key(name))
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
70f861f42cdf616d29f453fb86069731ba84cd99c3ab32ebe32309a5c4fe8cea
|