Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/routes_odoo_tables.py +1 -2
- platform/core/store_pg.py +51 -3
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "e27c27a68",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
e27c27a68
|
api/routes_odoo_tables.py
CHANGED
|
@@ -4493,8 +4493,7 @@ def _materialised_revision(session, table_key):
|
|
| 4493 |
revisions = None
|
| 4494 |
if isinstance(reader, store_pg.PgStore):
|
| 4495 |
# Derived fields can read another database's authored cells or workspace.
|
| 4496 |
-
revisions = store_pg.
|
| 4497 |
-
'SELECT key, rev, updated_at FROM {tbl} ORDER BY key', 'store_kv', reader.tenant_slug), ())
|
| 4498 |
mirror = None
|
| 4499 |
if callable(getattr(runtime, 'assert_datastore_matches', None)):
|
| 4500 |
from harness.runtime import mirror_cursor
|
|
|
|
| 4493 |
revisions = None
|
| 4494 |
if isinstance(reader, store_pg.PgStore):
|
| 4495 |
# Derived fields can read another database's authored cells or workspace.
|
| 4496 |
+
revisions = store_pg._kv_revisions(reader.tenant_slug)
|
|
|
|
| 4497 |
mirror = None
|
| 4498 |
if callable(getattr(runtime, 'assert_datastore_matches', None)):
|
| 4499 |
from harness.runtime import mirror_cursor
|
platform/core/store_pg.py
CHANGED
|
@@ -2672,9 +2672,21 @@ def _read_revisions(names, tenant_slug=None):
|
|
| 2672 |
found = {}
|
| 2673 |
for name, raw_rev, stamp in rows:
|
| 2674 |
found[name] = _revision_value(raw_rev, stamp)
|
|
|
|
|
|
|
|
|
|
| 2675 |
return found
|
| 2676 |
|
| 2677 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2678 |
@_request_timing.store_operation("revision")
|
| 2679 |
def _revision(name, tenant_slug=None):
|
| 2680 |
"""`{'rev', 'updated_at', 'token'}` for ONE bucket — wave 29, item 20 / contract C6.
|
|
@@ -2844,9 +2856,8 @@ def _shared_prepare(con, name, tenant_slug):
|
|
| 2844 |
data = _parsed(row[0] if row else None)
|
| 2845 |
if data.get(_SHARED_LAYOUT) == 1:
|
| 2846 |
return
|
| 2847 |
-
|
| 2848 |
-
|
| 2849 |
-
_shared_cell(con, name, rid, key, value, tenant_slug)
|
| 2850 |
data.setdefault('fields', {})
|
| 2851 |
data[_SHARED_LAYOUT] = 1
|
| 2852 |
data[_SHARED_VERSION] = _shared_next_version(con, tenant_slug)
|
|
@@ -2864,6 +2875,23 @@ def _shared_cell(con, name, rid, key, value, tenant_slug):
|
|
| 2864 |
_schema_for(tenant_slug) + '.shared_overlay_cells', 'version'))
|
| 2865 |
|
| 2866 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2867 |
def _shared_next_version(con, tenant_slug):
|
| 2868 |
return con.execute('SELECT nextval(pg_get_serial_sequence(%s, %s))',
|
| 2869 |
(_schema_for(tenant_slug) + '.shared_overlay_cells', 'version')).fetchone()[0]
|
|
@@ -2886,6 +2914,26 @@ def _shared_revision(con, name, tenant_slug):
|
|
| 2886 |
return _revision_value(row[0] if row else 0, row[1] if row else None)
|
| 2887 |
|
| 2888 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2889 |
def _shared_patch(name, rows, validate, tenant_slug):
|
| 2890 |
"""Write addressed cells without acquiring or updating the whole bucket row."""
|
| 2891 |
check_write(tenant_slug, 'patch shared cells')
|
|
|
|
| 2672 |
found = {}
|
| 2673 |
for name, raw_rev, stamp in rows:
|
| 2674 |
found[name] = _revision_value(raw_rev, stamp)
|
| 2675 |
+
# A native cell write moves only its cell row, so a `__shared` token reads the cells too.
|
| 2676 |
+
found.update(_shared_revisions([name for name in found if str(name).endswith('__shared')],
|
| 2677 |
+
tenant_slug))
|
| 2678 |
return found
|
| 2679 |
|
| 2680 |
|
| 2681 |
+
def _kv_revisions(tenant_slug=None):
|
| 2682 |
+
"""`[key, token]` of every bucket, each `__shared` token including its native cells."""
|
| 2683 |
+
rows = _read(_pool(), _q('SELECT key, rev, updated_at FROM {tbl} ORDER BY key', 'store_kv',
|
| 2684 |
+
tenant_slug), ())
|
| 2685 |
+
shared = _shared_revisions([key for key, _rev, _stamp in rows if str(key).endswith('__shared')],
|
| 2686 |
+
tenant_slug)
|
| 2687 |
+
return [[key, shared.get(key) or _revision_value(rev, stamp)] for key, rev, stamp in rows]
|
| 2688 |
+
|
| 2689 |
+
|
| 2690 |
@_request_timing.store_operation("revision")
|
| 2691 |
def _revision(name, tenant_slug=None):
|
| 2692 |
"""`{'rev', 'updated_at', 'token'}` for ONE bucket — wave 29, item 20 / contract C6.
|
|
|
|
| 2856 |
data = _parsed(row[0] if row else None)
|
| 2857 |
if data.get(_SHARED_LAYOUT) == 1:
|
| 2858 |
return
|
| 2859 |
+
# One statement: a round trip per cell outran the write budget on a 25k cell bucket.
|
| 2860 |
+
_shared_cells(con, name, data.pop('cells', {}) or {}, tenant_slug)
|
|
|
|
| 2861 |
data.setdefault('fields', {})
|
| 2862 |
data[_SHARED_LAYOUT] = 1
|
| 2863 |
data[_SHARED_VERSION] = _shared_next_version(con, tenant_slug)
|
|
|
|
| 2875 |
_schema_for(tenant_slug) + '.shared_overlay_cells', 'version'))
|
| 2876 |
|
| 2877 |
|
| 2878 |
+
def _shared_cells(con, name, cells, tenant_slug):
|
| 2879 |
+
"""Write `{row_id: {field_key: value}}` in one statement, each cell as `_shared_cell` writes it."""
|
| 2880 |
+
rows = [(str(rid), str(key), json.dumps(value))
|
| 2881 |
+
for rid, values in cells.items() for key, value in (values or {}).items()]
|
| 2882 |
+
if not rows:
|
| 2883 |
+
return
|
| 2884 |
+
rids, keys, values = (list(column) for column in zip(*rows))
|
| 2885 |
+
con.execute(_q('INSERT INTO {tbl} (bucket, row_id, field_key, value) '
|
| 2886 |
+
'SELECT %s, cell.row_id, cell.field_key, cell.value::jsonb '
|
| 2887 |
+
'FROM unnest(%s::text[], %s::text[], %s::text[]) AS cell(row_id, field_key, value) '
|
| 2888 |
+
'ON CONFLICT (bucket, row_id, field_key) DO UPDATE SET value = EXCLUDED.value, '
|
| 2889 |
+
'version = nextval(pg_get_serial_sequence(%s, %s)), updated_at = clock_timestamp()',
|
| 2890 |
+
'shared_overlay_cells', tenant_slug),
|
| 2891 |
+
(str(name), rids, keys, values,
|
| 2892 |
+
_schema_for(tenant_slug) + '.shared_overlay_cells', 'version'))
|
| 2893 |
+
|
| 2894 |
+
|
| 2895 |
def _shared_next_version(con, tenant_slug):
|
| 2896 |
return con.execute('SELECT nextval(pg_get_serial_sequence(%s, %s))',
|
| 2897 |
(_schema_for(tenant_slug) + '.shared_overlay_cells', 'version')).fetchone()[0]
|
|
|
|
| 2914 |
return _revision_value(row[0] if row else 0, row[1] if row else None)
|
| 2915 |
|
| 2916 |
|
| 2917 |
+
def _shared_revisions(names, tenant_slug=None):
|
| 2918 |
+
"""`_shared_revision` of many buckets in one statement. A key absent from store_kv is left out."""
|
| 2919 |
+
from psycopg import sql
|
| 2920 |
+
names = sorted({str(name) for name in names})
|
| 2921 |
+
if not names:
|
| 2922 |
+
return {}
|
| 2923 |
+
with _pool().connection() as con:
|
| 2924 |
+
if not _shared_exists(con, tenant_slug):
|
| 2925 |
+
return {} # Without cell storage the store_kv token is the whole token.
|
| 2926 |
+
rows = con.execute(sql.SQL('SELECT kv.key, GREATEST(kv.rev, (kv.value ->> %s)::bigint, cell.version), '
|
| 2927 |
+
'GREATEST(kv.updated_at, cell.updated_at) FROM {} kv '
|
| 2928 |
+
'LEFT JOIN LATERAL (SELECT version, updated_at FROM {} '
|
| 2929 |
+
'WHERE bucket = kv.key ORDER BY version DESC LIMIT 1) cell ON true '
|
| 2930 |
+
'WHERE kv.key = ANY(%s::text[])').format(
|
| 2931 |
+
_table('store_kv', tenant_slug),
|
| 2932 |
+
_table('shared_overlay_cells', tenant_slug)),
|
| 2933 |
+
(_SHARED_VERSION, names)).fetchall()
|
| 2934 |
+
return {key: _revision_value(rev, stamp) for key, rev, stamp in rows}
|
| 2935 |
+
|
| 2936 |
+
|
| 2937 |
def _shared_patch(name, rows, validate, tenant_slug):
|
| 2938 |
"""Write addressed cells without acquiring or updating the whole bucket row."""
|
| 2939 |
check_write(tenant_slug, 'patch shared cells')
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
83c40f815a4d63830d68ae0164ff881ab1d8243f67576983f7ce21f456cb783a
|