fsanyoto commited on
Commit
5ef980e
·
verified ·
1 Parent(s): 5f2ac8b

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "19ff250",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "c5e85ef",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- 19ff250
 
1
+ c5e85ef
api/routes_sheet.py CHANGED
@@ -2047,6 +2047,10 @@ def refresh_sheet(workbook_id: str, session: Session = Depends(require_session))
2047
  if db not in tokens:
2048
  token_reads += 1
2049
  try:
 
 
 
 
2050
  tokens[db] = sheet_binding.database_change_token(store, db)
2051
  except Exception:
2052
  # Failure to prove unchanged means resolve, never silently reuse a value.
 
2047
  if db not in tokens:
2048
  token_reads += 1
2049
  try:
2050
+ # ⭐ Arms `core.sheet_binding.mirror_change_token` (SDLC 65 combine). The mirror
2051
+ # reader lives in `harness` because `core` never imports up, and the API is the
2052
+ # layer allowed to reach both ways, so the wiring belongs exactly here.
2053
+ import harness.mirror_tokens # noqa: F401 (registers the provider on import)
2054
  tokens[db] = sheet_binding.database_change_token(store, db)
2055
  except Exception:
2056
  # Failure to prove unchanged means resolve, never silently reuse a value.
platform/core/sheet_binding.py CHANGED
@@ -77,47 +77,34 @@ def database_change_token(st, database):
77
  return token
78
 
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  def mirror_change_token(st, database):
81
- """One SQL token read over source tables, not N binding queries or Python row copies.
82
 
83
- The current mirror has no per-table monotonic revision. Content fingerprints close
84
- that gap without changing its writer or adding a row cap. Count, xor and sum include
85
- entire records; schema and sync receipts cover field changes and no-op syncs too.
86
- Registry metrics depend on the Odoo observation set, so their token includes it.
87
  """
88
- from core import connector_spec
89
- from harness import datastore
90
- from harness.runtime import mirror_cursor
91
- spec = connector_spec.spec_for(database)
92
- if database in ("customer_data", "product_data"):
93
- sources = set(datastore.ENTITIES)
94
- elif spec:
95
- sources = {spec.source}
96
- # A connector grid also reads joined label/identity columns declared by its spec.
97
- sources.update(target.source for _, key, _, _ in spec.links
98
- if (target := connector_spec.spec_for(key)) is not None)
99
- else:
100
- raise RuntimeError("The connector has no declared source for its change token.")
101
- if not sources or any(not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", s) for s in sources):
102
- raise RuntimeError("The connector source identity is invalid.")
103
- sources = sorted(sources)
104
- receipt_sources = sorted(set(sources) | ({"meta"} if any(s.startswith("meta_") for s in sources) else set()))
105
- clauses = [f"SELECT '{source}' AS source, CAST(count(*) AS VARCHAR) AS n, "
106
- f"CAST(bit_xor(hash(t)) AS VARCHAR) AS x, "
107
- f"CAST(sum(CAST(hash(t) AS HUGEINT)) AS VARCHAR) AS s FROM \"{source}\" t"
108
- for source in sources]
109
- placeholders = ",".join("?" for _ in sources)
110
- clauses.append("SELECT 'schema', table_name, column_name, data_type FROM duckdb_columns() "
111
- f"WHERE table_name IN ({placeholders})")
112
- # _sync_state is the resident mirror writer's receipt, not the app's status cache.
113
- clauses.append("SELECT 'sync', entity, phase, concat_ws('|', last_id, cursor_wd, rows, updated_at) "
114
- "FROM _sync_state WHERE split_part(entity, '.', 1) IN ("
115
- + ",".join("?" for _ in receipt_sources) + ")")
116
- rows = mirror_cursor(st).execute(" UNION ALL ".join(clauses) + " ORDER BY 1,2,3,4",
117
- [*sources, *receipt_sources]).fetchall()
118
- if not any(row[0] == "sync" for row in rows):
119
- raise RuntimeError("The connector has no sync receipt.")
120
- return fingerprint(rows)
121
 
122
 
123
  def read_refresh_cache(st, workbook_id):
 
77
  return token
78
 
79
 
80
+ #: ⛔⛔ THE MIRROR TOKEN IS PROVIDED FROM ABOVE, NOT IMPORTED FROM BELOW (SDLC 65 combine).
81
+ #: S65-T03 wrote `mirror_change_token` here and it reached for `harness.datastore` and
82
+ #: `harness.runtime` -- a NEW `core -> harness` edge, which `verify_layering.py` (D-460) caught as
83
+ #: the wave's own violation of ARCHITECTURE.md section 1. ⛔ It is FIXED rather than grandfathered:
84
+ #: `GRANDFATHERED_CORE` is the list of edges that PRE-DATE that gate, and adding this wave's own
85
+ #: edge to it would be granting an exemption to the wave that created it.
86
+ #: The body moved to `harness/mirror_tokens.py`, which registers itself here on import, so the
87
+ #: dependency points DOWN the way every other layer does.
88
+ _MIRROR_TOKEN_PROVIDER = None
89
+
90
+
91
+ def set_mirror_token_provider(fn):
92
+ """Register the mirror reader. Called by `harness.mirror_tokens` at import."""
93
+ global _MIRROR_TOKEN_PROVIDER
94
+ _MIRROR_TOKEN_PROVIDER = fn
95
+
96
+
97
  def mirror_change_token(st, database):
98
+ """One SQL token read over source tables, delegated to the layer that owns the mirror.
99
 
100
+ ⚠ NO PROVIDER IS A RAISE, DELIBERATELY, and it is the safe direction: `database_change_token`'s
101
+ contract is that a token which cannot be READ resolves rather than reusing a value, so an
102
+ unregistered provider costs a recompute and can never serve a stale number.
 
103
  """
104
+ if _MIRROR_TOKEN_PROVIDER is None:
105
+ raise RuntimeError("No mirror change-token provider is registered; import "
106
+ "harness.mirror_tokens before asking for one.")
107
+ return _MIRROR_TOKEN_PROVIDER(st, database)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
 
110
  def read_refresh_cache(st, workbook_id):
platform/harness/mirror_tokens.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """The mirror's own change token, in the layer that owns the mirror (SDLC 65 combine).
2
+
3
+ ⛔⛔ WHY IT LIVES HERE AND NOT IN `core/sheet_binding.py`, WHERE S65-T03 WROTE IT.
4
+ It reads the analytical mirror: `harness.datastore.ENTITIES` and `harness.runtime.mirror_cursor`.
5
+ `core` never imports up (ARCHITECTURE.md section 1), and `verify_layering.py`'s D-460 leg caught
6
+ the new `core -> harness` edge as this wave's own violation. Moving the body up and registering it
7
+ back down is the fix the gate's first remedy names -- "move it down" read from the other end. The
8
+ alternative, a `GRANDFATHERED_CORE` entry, was REFUSED: that list is edges which PRE-DATE the gate,
9
+ and a wave adding its own edge to it exempts itself from the rule it just broke.
10
+
11
+ ⭐ Importing this module is what arms `core.sheet_binding.mirror_change_token`; `routes_sheet`
12
+ does it. Until then that function RAISES, which `database_change_token` already treats as "cannot
13
+ prove unchanged, therefore resolve" -- the safe direction.
14
+ """
15
+ from __future__ import annotations
16
+ import re
17
+
18
+ from core import sheet_binding
19
+ from core.sheet_binding import fingerprint
20
+
21
+
22
+ def mirror_change_token(st, database):
23
+ """One SQL token read over source tables, not N binding queries or Python row copies.
24
+
25
+ The current mirror has no per-table monotonic revision. Content fingerprints close
26
+ that gap without changing its writer or adding a row cap. Count, xor and sum include
27
+ entire records; schema and sync receipts cover field changes and no-op syncs too.
28
+ Registry metrics depend on the Odoo observation set, so their token includes it.
29
+ """
30
+ from core import connector_spec
31
+ from harness import datastore
32
+ from harness.runtime import mirror_cursor
33
+ spec = connector_spec.spec_for(database)
34
+ if database in ("customer_data", "product_data"):
35
+ sources = set(datastore.ENTITIES)
36
+ elif spec:
37
+ sources = {spec.source}
38
+ # A connector grid also reads joined label/identity columns declared by its spec.
39
+ sources.update(target.source for _, key, _, _ in spec.links
40
+ if (target := connector_spec.spec_for(key)) is not None)
41
+ else:
42
+ raise RuntimeError("The connector has no declared source for its change token.")
43
+ if not sources or any(not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", s) for s in sources):
44
+ raise RuntimeError("The connector source identity is invalid.")
45
+ sources = sorted(sources)
46
+ receipt_sources = sorted(set(sources) | ({"meta"} if any(s.startswith("meta_") for s in sources) else set()))
47
+ clauses = [f"SELECT '{source}' AS source, CAST(count(*) AS VARCHAR) AS n, "
48
+ f"CAST(bit_xor(hash(t)) AS VARCHAR) AS x, "
49
+ f"CAST(sum(CAST(hash(t) AS HUGEINT)) AS VARCHAR) AS s FROM \"{source}\" t"
50
+ for source in sources]
51
+ placeholders = ",".join("?" for _ in sources)
52
+ clauses.append("SELECT 'schema', table_name, column_name, data_type FROM duckdb_columns() "
53
+ f"WHERE table_name IN ({placeholders})")
54
+ # _sync_state is the resident mirror writer's receipt, not the app's status cache.
55
+ clauses.append("SELECT 'sync', entity, phase, concat_ws('|', last_id, cursor_wd, rows, updated_at) "
56
+ "FROM _sync_state WHERE split_part(entity, '.', 1) IN ("
57
+ + ",".join("?" for _ in receipt_sources) + ")")
58
+ rows = mirror_cursor(st).execute(" UNION ALL ".join(clauses) + " ORDER BY 1,2,3,4",
59
+ [*sources, *receipt_sources]).fetchall()
60
+ if not any(row[0] == "sync" for row in rows):
61
+ raise RuntimeError("The connector has no sync receipt.")
62
+ return fingerprint(rows)
63
+
64
+ sheet_binding.set_mirror_token_provider(mirror_change_token)
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 1548a4da9ce9a7364d31b25a5b0d9ebd6546c18f93c2ba9e8b4b8658f1b60fb2
 
1
+ 5fc0ebaabe14937a1a653d10bb564fc5819fe020336cd70b6c01550c01b2ba58