fsanyoto commited on
Commit
7907db2
·
verified ·
1 Parent(s): 198b2dd

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "bd78ea62a",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "d89e0053bd",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- bd78ea62a
 
1
+ d89e0053bd
api/routes_assets.py CHANGED
@@ -55,16 +55,18 @@ def _application_error(exc):
55
  raise err(status, "application_not_found" if status == 404 else "bad_application", message)
56
 
57
 
58
- def application_access_context(session, databases, *, strict=False):
59
  """Return readable databases plus governed semantic records, without exposing refused names."""
60
  from core import perm_scope
61
- from harness import semantic as sem
62
  allowed, records = set(), {}
63
  for database in dict.fromkeys(str(value or "").strip() for value in databases or ()):
64
  if not database:
65
  continue
66
- topic = next((row for row in sem.topics().values()
67
- if isinstance(row, dict) and row.get("grid") == database), None)
 
 
 
68
  # S68-T42 / CA-F1: a user table has no semantic topic, and `perm_scope.may_read` already
69
  # answers it (creator, admin or a share grant). Refusing it left every App bound to a user
70
  # table unopenable and undeletable (S67-T39 finding). It carries no governed records, so a
@@ -77,7 +79,7 @@ def application_access_context(session, databases, *, strict=False):
77
  raise PermissionError("that database is not available")
78
  continue
79
  allowed.add(database)
80
- if user_table:
81
  records[database] = {}
82
  continue
83
  baseline = semantic_rt.topic_records(database, topic)
@@ -328,7 +330,8 @@ def application_index(database: str = "", type: str = "", starred: bool | None =
328
  raise err(400, "bad_application", "application type is not recognized")
329
  candidates = [database] if database else _application_databases(session.runtime)
330
  try:
331
- allowed, _ = application_access_context(session, candidates, strict=bool(database))
 
332
  except PermissionError as exc:
333
  _application_error(exc)
334
  return {"applications": applications.list_apps(
 
55
  raise err(status, "application_not_found" if status == 404 else "bad_application", message)
56
 
57
 
58
+ def application_access_context(session, databases, *, strict=False, include_records=True):
59
  """Return readable databases plus governed semantic records, without exposing refused names."""
60
  from core import perm_scope
 
61
  allowed, records = set(), {}
62
  for database in dict.fromkeys(str(value or "").strip() for value in databases or ()):
63
  if not database:
64
  continue
65
+ topic = None
66
+ if include_records or not database.startswith("ut_"):
67
+ from harness import semantic as sem
68
+ topic = next((row for row in sem.topics().values()
69
+ if isinstance(row, dict) and row.get("grid") == database), None)
70
  # S68-T42 / CA-F1: a user table has no semantic topic, and `perm_scope.may_read` already
71
  # answers it (creator, admin or a share grant). Refusing it left every App bound to a user
72
  # table unopenable and undeletable (S67-T39 finding). It carries no governed records, so a
 
79
  raise PermissionError("that database is not available")
80
  continue
81
  allowed.add(database)
82
+ if user_table or not include_records:
83
  records[database] = {}
84
  continue
85
  baseline = semantic_rt.topic_records(database, topic)
 
330
  raise err(400, "bad_application", "application type is not recognized")
331
  candidates = [database] if database else _application_databases(session.runtime)
332
  try:
333
+ allowed, _ = application_access_context(
334
+ session, candidates, strict=bool(database), include_records=False)
335
  except PermissionError as exc:
336
  _application_error(exc)
337
  return {"applications": applications.list_apps(
api/routes_sheet.py CHANGED
@@ -1593,7 +1593,13 @@ def activity_read_policy(session: Session, object):
1593
  if database in {"customer_data", "product_data"} and any(
1594
  perm_scope.derive_pool_scope(session.user, database)):
1595
  return False
1596
- grid = _registry_assembly(borrowed, database, with_rows=False)
 
 
 
 
 
 
1597
  fields = (grid.get("defn") or {}).get("fields", grid.get("fields", []))
1598
  if grid.get("hidden") or perm_scope.hidden_keys(session.user, database, fields, st=reader):
1599
  return False
 
1593
  if database in {"customer_data", "product_data"} and any(
1594
  perm_scope.derive_pool_scope(session.user, database)):
1595
  return False
1596
+ # Activity needs the complete field wall, without display usage and metric catalogs.
1597
+ resolve = (memo.get("activity_source_fields")
1598
+ if isinstance(memo, dict) and database.startswith("ut_") else None)
1599
+ grid = (resolve(database) if callable(resolve)
1600
+ else _registry_assembly(borrowed, database, with_rows=False))
1601
+ if grid is None:
1602
+ return False
1603
  fields = (grid.get("defn") or {}).get("fields", grid.get("fields", []))
1604
  if grid.get("hidden") or perm_scope.hidden_keys(session.user, database, fields, st=reader):
1605
  return False
api/routes_tables.py CHANGED
@@ -547,7 +547,7 @@ def _activity_cursor(session, query, position=None, token=None):
547
 
548
 
549
  def query_activity(session: Session, *, object=None, by=None, since=None, until=None,
550
- cursor=None, limit=100, scan_limit=10000):
551
  """Read a session-bound activity page through both activity and current source permissions."""
552
  import routes_agent_harness
553
  import routes_sheet
@@ -555,24 +555,40 @@ def query_activity(session: Session, *, object=None, by=None, since=None, until=
555
  with (routes_sheet._sheet_request_scope(session), activity_log.read_scope(session.runtime),
556
  routes_agent_harness.activity_read_scope(session)):
557
  return _query_activity_page(session, object=object, by=by, since=since, until=until,
558
- cursor=cursor, limit=limit, scan_limit=scan_limit)
 
559
 
560
 
561
  def _query_activity_page(session: Session, *, object=None, by=None, since=None, until=None,
562
- cursor=None, limit=100, scan_limit=10000):
563
  """Resolve one activity page within its caller's request scope."""
564
  from core import activity_log, perm_scope
565
 
566
  key = activity_log.DATABASE_KEY
567
  # Borrow definitions and grants for this call only; each cursor request rebuilds them.
568
  context_store = _table_lend(session.runtime, key, defs_only=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  memo = getattr(session, '_sheet_read_memo', None)
570
  if isinstance(memo, dict):
571
  memo['permission_reader'] = context_store
572
  memo['activity_permission_identity'] = (session.tenant, session.uname, id(session.runtime))
573
  own = _defn_or_refuse(session, key, st=context_store, defs_only=True, scope_applied=True)
574
- own_grid = _compute_ut_assembly(session, key, st=context_store, with_rows=False, fields_only=True,
575
- include_usage=False, include_measures=False)
 
576
  own_keys = {f['key'] for f in own_grid['fields']}
577
  query = [object, by, since, until]
578
  position = _activity_cursor(session, query, token=cursor) if cursor else None
@@ -598,9 +614,9 @@ def _query_activity_page(session: Session, *, object=None, by=None, since=None,
598
  definition = _defn_or_refuse(session, database, st=context_store,
599
  defs_only=True, scope_applied=True)
600
  windowed = not _ut().materialises(database, st=session.runtime, defn=definition)
601
- g = _compute_ut_assembly(session, database, st=context_store,
602
  with_rows=False, fields_only=True,
603
- include_usage=False, include_measures=False)
604
  page_sources.add(database)
605
  if windowed:
606
  connected.add(database)
@@ -649,6 +665,9 @@ def _query_activity_page(session: Session, *, object=None, by=None, since=None,
649
  partners[identity] = admitted
650
  return admitted
651
 
 
 
 
652
  def can_read_object(obj):
653
  # T64 gives this resolver the object only. Event-kind checks and value scrubbing follow.
654
  return source(str(obj['database'])) is not None if 'database' in obj else partner(obj)
@@ -747,8 +766,11 @@ def _query_activity_page(session: Session, *, object=None, by=None, since=None,
747
  break
748
  except ValueError as exc:
749
  raise err(400, 'bad_activity_query', str(exc)) from exc
750
- return {'records': records, 'next_cursor': _activity_cursor(session, query, position),
751
- 'fields': own_grid['fields']}
 
 
 
752
 
753
 
754
  def _activity_grid_rows(session):
@@ -1708,7 +1730,7 @@ def ut_assembly(session: Session, table_key: str, storage_key: str = "",
1708
  def _compute_ut_assembly(session: Session, table_key: str, storage_key: str = "",
1709
  consume_corrections: bool = False, with_rows: bool = True, st=None,
1710
  *, fields_only: bool = False, needed=None, include_usage: bool = True,
1711
- include_measures: bool = True):
1712
  """The user-table mirror of `grid_assembly` / `product_assembly` — SAME g-dict keys, so
1713
  `/workspace` and the events route consume any of the three interchangeably.
1714
 
@@ -1771,7 +1793,8 @@ def _compute_ut_assembly(session: Session, table_key: str, storage_key: str = ""
1771
  scope_key=table_key, table=ops)
1772
  ws = grid_events.table_workspace(ctx, allowed_pids=pids,
1773
  consume_corrections=consume_corrections,
1774
- capture_document=True)
 
1775
  workspace, fields, views, lists = aios_grid.workspace_wire(
1776
  ws, session.uname, set(pids), defs={}, scope_key=table_key,
1777
  storage_key=storage_key, fields_base=fields_base, st=st)
@@ -2672,10 +2695,8 @@ def table_rows(table_key: str, session: Session = Depends(require_session),
2672
  if table_key == 'ut_activity':
2673
  if related:
2674
  raise err(409, 'activity_related_unavailable', 'Open the Activity database to read events.')
2675
- page = query_activity(session, cursor=cursor, limit=limit)
2676
- g = _compute_ut_assembly(session, table_key,
2677
- storage_key=f'{session.tenant}:{table_key}:{session.uname}',
2678
- with_rows=False, fields_only=True)
2679
  json_keys = {field['key'] for field in g['fields'] if field.get('type') == 'json'}
2680
  rows = [{name: json.dumps(value, ensure_ascii=False, separators=(',', ':'))
2681
  if name in json_keys and isinstance(value, (dict, list)) else value
 
547
 
548
 
549
  def query_activity(session: Session, *, object=None, by=None, since=None, until=None,
550
+ cursor=None, limit=100, scan_limit=10000, _with_workspace=False):
551
  """Read a session-bound activity page through both activity and current source permissions."""
552
  import routes_agent_harness
553
  import routes_sheet
 
555
  with (routes_sheet._sheet_request_scope(session), activity_log.read_scope(session.runtime),
556
  routes_agent_harness.activity_read_scope(session)):
557
  return _query_activity_page(session, object=object, by=by, since=since, until=until,
558
+ cursor=cursor, limit=limit, scan_limit=scan_limit,
559
+ _with_workspace=_with_workspace)
560
 
561
 
562
  def _query_activity_page(session: Session, *, object=None, by=None, since=None, until=None,
563
+ cursor=None, limit=100, scan_limit=10000, _with_workspace=False):
564
  """Resolve one activity page within its caller's request scope."""
565
  from core import activity_log, perm_scope
566
 
567
  key = activity_log.DATABASE_KEY
568
  # Borrow definitions and grants for this call only; each cursor request rebuilds them.
569
  context_store = _table_lend(session.runtime, key, defs_only=True)
570
+ from core import route_system, schema_overlay
571
+ metadata = (route_system.STORE_KEY, _ut().ZONE_STORE_KEY, schema_overlay.STORE_KEY)
572
+ read_many = getattr(session.runtime, 'get_many', None)
573
+ if callable(read_many):
574
+ try:
575
+ documents = read_many(metadata)
576
+ except Exception:
577
+ documents = None
578
+ if isinstance(documents, dict):
579
+ context_store = _ut().lend(context_store, **{
580
+ name: documents[name] for name in metadata if isinstance(documents.get(name), dict)})
581
+ from copy import copy
582
+ field_session = copy(session)
583
+ field_session.runtime = context_store
584
  memo = getattr(session, '_sheet_read_memo', None)
585
  if isinstance(memo, dict):
586
  memo['permission_reader'] = context_store
587
  memo['activity_permission_identity'] = (session.tenant, session.uname, id(session.runtime))
588
  own = _defn_or_refuse(session, key, st=context_store, defs_only=True, scope_applied=True)
589
+ own_grid = _compute_ut_assembly(field_session, key, st=context_store, with_rows=False,
590
+ fields_only=True, storage_key=f'{session.tenant}:{key}:{session.uname}' if _with_workspace else '',
591
+ include_usage=_with_workspace, include_measures=_with_workspace, include_views=_with_workspace)
592
  own_keys = {f['key'] for f in own_grid['fields']}
593
  query = [object, by, since, until]
594
  position = _activity_cursor(session, query, token=cursor) if cursor else None
 
614
  definition = _defn_or_refuse(session, database, st=context_store,
615
  defs_only=True, scope_applied=True)
616
  windowed = not _ut().materialises(database, st=session.runtime, defn=definition)
617
+ g = _compute_ut_assembly(field_session, database, st=context_store,
618
  with_rows=False, fields_only=True,
619
+ include_usage=False, include_measures=False, include_views=False)
620
  page_sources.add(database)
621
  if windowed:
622
  connected.add(database)
 
665
  partners[identity] = admitted
666
  return admitted
667
 
668
+ if isinstance(memo, dict):
669
+ memo['activity_source_fields'] = source
670
+
671
  def can_read_object(obj):
672
  # T64 gives this resolver the object only. Event-kind checks and value scrubbing follow.
673
  return source(str(obj['database'])) is not None if 'database' in obj else partner(obj)
 
766
  break
767
  except ValueError as exc:
768
  raise err(400, 'bad_activity_query', str(exc)) from exc
769
+ result = {'records': records, 'next_cursor': _activity_cursor(session, query, position),
770
+ 'fields': own_grid['fields']}
771
+ if _with_workspace:
772
+ result['_grid'] = own_grid
773
+ return result
774
 
775
 
776
  def _activity_grid_rows(session):
 
1730
  def _compute_ut_assembly(session: Session, table_key: str, storage_key: str = "",
1731
  consume_corrections: bool = False, with_rows: bool = True, st=None,
1732
  *, fields_only: bool = False, needed=None, include_usage: bool = True,
1733
+ include_measures: bool = True, include_views: bool = True):
1734
  """The user-table mirror of `grid_assembly` / `product_assembly` — SAME g-dict keys, so
1735
  `/workspace` and the events route consume any of the three interchangeably.
1736
 
 
1793
  scope_key=table_key, table=ops)
1794
  ws = grid_events.table_workspace(ctx, allowed_pids=pids,
1795
  consume_corrections=consume_corrections,
1796
+ capture_document=True,
1797
+ **({"include_views": False} if not include_views else {}))
1798
  workspace, fields, views, lists = aios_grid.workspace_wire(
1799
  ws, session.uname, set(pids), defs={}, scope_key=table_key,
1800
  storage_key=storage_key, fields_base=fields_base, st=st)
 
2695
  if table_key == 'ut_activity':
2696
  if related:
2697
  raise err(409, 'activity_related_unavailable', 'Open the Activity database to read events.')
2698
+ page = query_activity(session, cursor=cursor, limit=limit, _with_workspace=True)
2699
+ g = page.pop('_grid')
 
 
2700
  json_keys = {field['key'] for field in g['fields'] if field.get('type') == 'json'}
2701
  rows = [{name: json.dumps(value, ensure_ascii=False, separators=(',', ':'))
2702
  if name in json_keys and isinstance(value, (dict, list)) else value
platform/core/grid_events.py CHANGED
@@ -59,7 +59,6 @@ MAX_VIEW_ORDER = 500
59
  import core.user_tables as _ut_limits # wave 23 (C7): MAX_JSON_CELL — one ceiling, one definer
60
  import harness.telemetry as _tel # _tel.error() = THE error sink (all caught errors log)
61
  import modules.cohort as cohort_mod
62
- import modules.customer_data as cl_mod
63
 
64
  #: C5 (owner item 12): customer documents. The cap is enforced HOST-side on the DECODED byte
65
  #: count — the client checks the same number first, but a client check only spares the user a
@@ -330,6 +329,7 @@ def _tops(ctx):
330
  """
331
  if ctx.table is not None:
332
  return ctx.table
 
333
  return cl_mod.TABLE_OPS
334
 
335
 
@@ -710,7 +710,8 @@ def workspace_corrections(st, table_key, uname, assembly):
710
  return assembly
711
 
712
 
713
- def table_workspace(ctx, allowed_pids=None, consume_corrections=True, capture_document=False):
 
714
  """Durable Airtable-style view/schema/overlay state, with an honest session fallback.
715
 
716
  Wave-9 I17: the returned `views` are this user's OWN views MERGED with every view SHARED
@@ -747,6 +748,9 @@ def table_workspace(ctx, allowed_pids=None, consume_corrections=True, capture_do
747
  ws, ctx.workspace_document = read
748
  else:
749
  ws = read
 
 
 
750
  document = ctx.workspace_document if capture_document else None
751
  # ⭐ WAVE 21 (item 9, C1): the R10 registry's named-user grants, PROJECTED at last.
752
  # Wave 20 wrote view grants and no reader ever consulted them — "Share view…" recorded
 
59
  import core.user_tables as _ut_limits # wave 23 (C7): MAX_JSON_CELL — one ceiling, one definer
60
  import harness.telemetry as _tel # _tel.error() = THE error sink (all caught errors log)
61
  import modules.cohort as cohort_mod
 
62
 
63
  #: C5 (owner item 12): customer documents. The cap is enforced HOST-side on the DECODED byte
64
  #: count — the client checks the same number first, but a client check only spares the user a
 
329
  """
330
  if ctx.table is not None:
331
  return ctx.table
332
+ import modules.customer_data as cl_mod
333
  return cl_mod.TABLE_OPS
334
 
335
 
 
710
  return assembly
711
 
712
 
713
+ def table_workspace(ctx, allowed_pids=None, consume_corrections=True, capture_document=False,
714
+ *, include_views=True):
715
  """Durable Airtable-style view/schema/overlay state, with an honest session fallback.
716
 
717
  Wave-9 I17: the returned `views` are this user's OWN views MERGED with every view SHARED
 
748
  ws, ctx.workspace_document = read
749
  else:
750
  ws = read
751
+ if not include_views:
752
+ # Field admission still receives the full authored field and shared-field documents.
753
+ return {**ws, 'views': {}}
754
  document = ctx.workspace_document if capture_document else None
755
  # ⭐ WAVE 21 (item 9, C1): the R10 registry's named-user grants, PROJECTED at last.
756
  # Wave 20 wrote view grants and no reader ever consulted them — "Share view…" recorded
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 92569cf22adda4323b510ee4879841ad5a6f22b243bafce8fb0a404b31ebca1f
 
1
+ 6abf783df8d49a69ef3aeb898fa5d5d124494e6c5998fb6d3221c673f5cad6a1