fsanyoto commited on
Commit
cfabfa5
Β·
verified Β·
1 Parent(s): 876a3b9

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "58b0bbe3f",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "a23600cb7",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- 58b0bbe3f
 
1
+ a23600cb7
api/main.py CHANGED
@@ -2270,14 +2270,14 @@ def _resync_memory_read():
2270
  return {}
2271
 
2272
 
2273
- def _resync_memory_write(pass_at, full_rebuild_at, fingerprints):
2274
  """Persist the loop's restart memory. Best effort: a failed write only costs a rebuild."""
2275
  try:
2276
  import odoo_relational as _rel_memory
2277
  from harness import runtime as _runtime_memory
2278
  _rel_memory.record_resync_memory(
2279
  _runtime_memory.get_runtime(_resync_tenant()[0]), pass_at=pass_at,
2280
- full_rebuild_at=full_rebuild_at, fingerprints=fingerprints)
2281
  except Exception as e: # noqa: BLE001
2282
  print(f"[aios-api] store resync memory not saved ({type(e).__name__}); "
2283
  "the next restart rebuilds in full")
@@ -2325,6 +2325,8 @@ def _store_resync_loop():
2325
  last_relational_success_at = _memory.get("fullRebuildAt")
2326
  last_source_fingerprints = _memory.get("fingerprints")
2327
  last_good_pass_at = _memory.get("passAt") or _memory.get("lastGoodSyncAt")
 
 
2328
  catch_up_retries = 0
2329
  last_meta_fingerprint = None
2330
  last_meta_applied_at = None
@@ -2517,8 +2519,36 @@ def _store_resync_loop():
2517
  # correctly. A connector that can only ever be established at boot is one bad boot away
2518
  # from being permanently absent.
2519
  # ⚠ Cheap when there is nothing to do: no token => one line and return.
2520
- _meta_pull_confirmed = _pull_meta("resync")
2521
- _pull_amazon("resync")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2522
  _meta_now = _t.time()
2523
  _meta_reason = _meta_rebuild_force_reason(
2524
  _meta_pull_confirmed, last_meta_fingerprint, last_meta_applied_at, _meta_now)
@@ -2610,10 +2640,14 @@ def _store_resync_loop():
2610
  last_meta_fingerprint = None
2611
  last_meta_applied_at = None
2612
  # HOTFIX 2026-09-29: remember this pass for the next container (see the top of the loop).
2613
- if _err is None and _rebuild_ok:
2614
- last_good_pass_at = _meta_now
 
 
 
 
2615
  _resync_memory_write(last_good_pass_at, last_relational_success_at,
2616
- last_source_fingerprints)
2617
 
2618
 
2619
  def _boot_app_migrations(why):
 
2270
  return {}
2271
 
2272
 
2273
+ def _resync_memory_write(pass_at, full_rebuild_at, fingerprints, pulls=None):
2274
  """Persist the loop's restart memory. Best effort: a failed write only costs a rebuild."""
2275
  try:
2276
  import odoo_relational as _rel_memory
2277
  from harness import runtime as _runtime_memory
2278
  _rel_memory.record_resync_memory(
2279
  _runtime_memory.get_runtime(_resync_tenant()[0]), pass_at=pass_at,
2280
+ full_rebuild_at=full_rebuild_at, fingerprints=fingerprints, pulls=pulls)
2281
  except Exception as e: # noqa: BLE001
2282
  print(f"[aios-api] store resync memory not saved ({type(e).__name__}); "
2283
  "the next restart rebuilds in full")
 
2325
  last_relational_success_at = _memory.get("fullRebuildAt")
2326
  last_source_fingerprints = _memory.get("fingerprints")
2327
  last_good_pass_at = _memory.get("passAt") or _memory.get("lastGoodSyncAt")
2328
+ # The pulls an unfinished pass already made; its first pass after this boot resumes it.
2329
+ pending_pulls = _memory.get("pulls")
2330
  catch_up_retries = 0
2331
  last_meta_fingerprint = None
2332
  last_meta_applied_at = None
 
2519
  # correctly. A connector that can only ever be established at boot is one bad boot away
2520
  # from being permanently absent.
2521
  # ⚠ Cheap when there is nothing to do: no token => one line and return.
2522
+ # β›”β›” HOTFIX sdlc74 #3: a restart RESUMES an unfinished pass and never repeats its pulls.
2523
+ # Each pull checkpoints when it returns. The first pass after a boot skips a pull that an
2524
+ # unfinished pass younger than one cadence already made, and runs only the rest.
2525
+ _pending = (pending_pulls if passes == 1 and not _odoo_requested
2526
+ and isinstance(pending_pulls, dict) else {})
2527
+ _resumed = ({stage: _pending[stage] for stage in ("meta", "amazon") if _pending.get(stage)}
2528
+ if _resync_boot_recent(_pending.get("startedAt"), _t.time(), _every) else {})
2529
+ _pulls = {"startedAt": last_full_pass_at}
2530
+ if _resumed:
2531
+ _pulls = dict(_resumed, startedAt=_pending["startedAt"])
2532
+ last_full_pass_at = _pulls["startedAt"]
2533
+ _age = max(0, int(_t.time() - last_full_pass_at))
2534
+ print(f"[aios-api] store resync: restarted {_age}s into a pass that never finished; "
2535
+ f"its {' and '.join(sorted(_resumed))} pull already reached the store, so that "
2536
+ f"vendor is not called again and only the rest of the pass runs now; the next "
2537
+ f"scheduled pass is due in {max(0, _every - _age)}s")
2538
+ if _resumed.get("meta"):
2539
+ _meta_pull_confirmed = False
2540
+ else:
2541
+ _meta_pull_confirmed = _pull_meta("resync")
2542
+ _pulls["meta"] = _t.time()
2543
+ _resync_memory_write(last_good_pass_at, last_relational_success_at,
2544
+ last_source_fingerprints, dict(_pulls))
2545
+ if _resumed.get("amazon"):
2546
+ _pull_amazon("boot", False)
2547
+ else:
2548
+ _pull_amazon("resync")
2549
+ _pulls["amazon"] = _t.time()
2550
+ _resync_memory_write(last_good_pass_at, last_relational_success_at,
2551
+ last_source_fingerprints, dict(_pulls))
2552
  _meta_now = _t.time()
2553
  _meta_reason = _meta_rebuild_force_reason(
2554
  _meta_pull_confirmed, last_meta_fingerprint, last_meta_applied_at, _meta_now)
 
2640
  last_meta_fingerprint = None
2641
  last_meta_applied_at = None
2642
  # HOTFIX 2026-09-29: remember this pass for the next container (see the top of the loop).
2643
+ # A pass that did not end good keeps its pulls checkpoint, so a restart resumes it.
2644
+ _pass_good = _err is None and _rebuild_ok
2645
+ if _pass_good:
2646
+ # A resumed pass ended its pulls when they ran, so a restart never shifts the cadence.
2647
+ last_good_pass_at = (max(_pulls.get("meta") or 0, _pulls.get("amazon") or 0)
2648
+ if _resumed else _meta_now)
2649
  _resync_memory_write(last_good_pass_at, last_relational_success_at,
2650
+ last_source_fingerprints, None if _pass_good else dict(_pulls))
2651
 
2652
 
2653
  def _boot_app_migrations(why):
api/odoo_relational.py CHANGED
@@ -5312,6 +5312,8 @@ def record_sync_outcome(rt, ok, at=None):
5312
  #: * `passAt` the last scheduled pass that completed without a mirror error (ISO);
5313
  #: * `fullRebuildAt` the last FULL relational rebuild that succeeded (ISO), for the weekly recovery;
5314
  #: * `fingerprints` `{entity: [count, hash]}` as the last successful apply saw the mirror.
 
 
5315
  #: ⚠ The two numbers are STRINGS: `bit_xor(hash())` is an unsigned 64-bit value, and a JSON reader
5316
  #: that is not Python may round it. `read_resync_memory` turns them back into the int TUPLES the
5317
  #: loop compares, because a list never equals a tuple and every pass would read as changed.
@@ -5360,7 +5362,8 @@ def decode_fingerprints(stored):
5360
 
5361
  def read_resync_memory(rt):
5362
  """What the last container's resync loop knew, or empty values. Never raises."""
5363
- empty = {"passAt": None, "fullRebuildAt": None, "fingerprints": None, "lastGoodSyncAt": None}
 
5364
  try:
5365
  cur = rt.get(CONFIG_KEY) if rt is not None else None
5366
  except Exception: # noqa: BLE001
@@ -5368,14 +5371,17 @@ def read_resync_memory(rt):
5368
  cur = cur if isinstance(cur, dict) else {}
5369
  memory = cur.get(RESYNC_MEMORY_FIELD)
5370
  memory = memory if isinstance(memory, dict) else {}
 
5371
  return {"passAt": _memory_epoch(memory.get("passAt")),
5372
  "fullRebuildAt": _memory_epoch(memory.get("fullRebuildAt")),
5373
  "fingerprints": decode_fingerprints(memory.get("fingerprints")),
5374
- "lastGoodSyncAt": _memory_epoch(cur.get("lastGoodSyncAt"))}
 
 
5375
 
5376
 
5377
- def record_resync_memory(rt, *, pass_at, full_rebuild_at, fingerprints):
5378
- """Persist the loop's three facts exactly as it now holds them (None clears one)."""
5379
  def _iso(epoch):
5380
  if epoch is None:
5381
  return None
@@ -5383,6 +5389,8 @@ def record_resync_memory(rt, *, pass_at, full_rebuild_at, fingerprints):
5383
 
5384
  memory = {"passAt": _iso(pass_at), "fullRebuildAt": _iso(full_rebuild_at),
5385
  "fingerprints": encode_fingerprints(fingerprints)}
 
 
5386
 
5387
  def _up(cur):
5388
  cur = dict(cur) if isinstance(cur, dict) else {}
 
5312
  #: * `passAt` the last scheduled pass that completed without a mirror error (ISO);
5313
  #: * `fullRebuildAt` the last FULL relational rebuild that succeeded (ISO), for the weekly recovery;
5314
  #: * `fingerprints` `{entity: [count, hash]}` as the last successful apply saw the mirror.
5315
+ #: * `pulls` `{startedAt, meta, amazon}` (ISO) of a pass whose vendor pulls finished but
5316
+ #: whose end was never written; a restart inside the cadence resumes it.
5317
  #: ⚠ The two numbers are STRINGS: `bit_xor(hash())` is an unsigned 64-bit value, and a JSON reader
5318
  #: that is not Python may round it. `read_resync_memory` turns them back into the int TUPLES the
5319
  #: loop compares, because a list never equals a tuple and every pass would read as changed.
 
5362
 
5363
  def read_resync_memory(rt):
5364
  """What the last container's resync loop knew, or empty values. Never raises."""
5365
+ empty = {"passAt": None, "fullRebuildAt": None, "fingerprints": None, "lastGoodSyncAt": None,
5366
+ "pulls": None}
5367
  try:
5368
  cur = rt.get(CONFIG_KEY) if rt is not None else None
5369
  except Exception: # noqa: BLE001
 
5371
  cur = cur if isinstance(cur, dict) else {}
5372
  memory = cur.get(RESYNC_MEMORY_FIELD)
5373
  memory = memory if isinstance(memory, dict) else {}
5374
+ pulls = memory.get("pulls")
5375
  return {"passAt": _memory_epoch(memory.get("passAt")),
5376
  "fullRebuildAt": _memory_epoch(memory.get("fullRebuildAt")),
5377
  "fingerprints": decode_fingerprints(memory.get("fingerprints")),
5378
+ "lastGoodSyncAt": _memory_epoch(cur.get("lastGoodSyncAt")),
5379
+ "pulls": ({str(k): _memory_epoch(v) for k, v in pulls.items()}
5380
+ if isinstance(pulls, dict) and pulls else None)}
5381
 
5382
 
5383
+ def record_resync_memory(rt, *, pass_at, full_rebuild_at, fingerprints, pulls=None):
5384
+ """Persist the loop's facts exactly as it now holds them (None clears one)."""
5385
  def _iso(epoch):
5386
  if epoch is None:
5387
  return None
 
5389
 
5390
  memory = {"passAt": _iso(pass_at), "fullRebuildAt": _iso(full_rebuild_at),
5391
  "fingerprints": encode_fingerprints(fingerprints)}
5392
+ if isinstance(pulls, dict) and pulls.get("startedAt") is not None:
5393
+ memory["pulls"] = {str(k): _iso(v) for k, v in pulls.items() if v is not None}
5394
 
5395
  def _up(cur):
5396
  cur = dict(cur) if isinstance(cur, dict) else {}
api/test_odoo_rank_refresh.py CHANGED
@@ -484,7 +484,7 @@ class RankRefreshTests(unittest.TestCase):
484
 
485
  # ── HOTFIX 2026-09-29 (owner): "only sync daily at the fastest", and only what changed ──────
486
  def run_daily_loop(self, memory, current, *, now=10_000.0, cadence=86400, manual=False,
487
- errors=(), max_sleeps=1, frozen=False):
488
  """Drive the real loop with a persisted memory; stop at its `max_sleeps`-th wait."""
489
  source = ast.parse(Path(__file__).with_name('main.py').read_text(encoding='utf-8'))
490
  functions = {'_store_resync_loop', '_resync_rebuild_reason',
@@ -516,7 +516,7 @@ class RankRefreshTests(unittest.TestCase):
516
 
517
  def rebuild(why, previous, meta_state, **scope):
518
  events.append(('rebuild', scope.get('table_keys')))
519
- return True
520
 
521
  clock = SimpleNamespace(sleep=sleep, time=lambda: now,
522
  strftime=lambda *_: 'synthetic-time', gmtime=lambda: ())
@@ -583,9 +583,64 @@ class RankRefreshTests(unittest.TestCase):
583
  events, _ = self.run_daily_loop(
584
  {'passAt': 10_000.0 - 90_000, 'fullRebuildAt': 10_000.0 - 90_000,
585
  'fingerprints': fps}, fps)
586
- self.assertEqual([e[0] for e in events], ['sync', 'meta', 'amazon', 'fresh', 'memory'])
587
- self.assertEqual(events[2], ('amazon', 'resync'))
588
- self.assertEqual(events[-1], ('memory', 10_000.0, 10_000.0 - 90_000, fps))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
589
 
590
  def test_persisted_fingerprints_skip_the_rebuild_after_a_restart(self):
591
  fps = {'res_partner': (3, 7)}
@@ -674,6 +729,14 @@ class RankRefreshTests(unittest.TestCase):
674
  memory = rel.read_resync_memory(rt)
675
  self.assertEqual((memory['passAt'], memory['fullRebuildAt'], memory['fingerprints']),
676
  (1_000.0, None, fps))
 
 
 
 
 
 
 
 
677
  self.assertEqual(rt.docs[rel.CONFIG_KEY]['syncEvery'], 'daily')
678
  self.assertIsNotNone(memory['lastGoodSyncAt'])
679
 
 
484
 
485
  # ── HOTFIX 2026-09-29 (owner): "only sync daily at the fastest", and only what changed ──────
486
  def run_daily_loop(self, memory, current, *, now=10_000.0, cadence=86400, manual=False,
487
+ errors=(), max_sleeps=1, frozen=False, rebuild_ok=True):
488
  """Drive the real loop with a persisted memory; stop at its `max_sleeps`-th wait."""
489
  source = ast.parse(Path(__file__).with_name('main.py').read_text(encoding='utf-8'))
490
  functions = {'_store_resync_loop', '_resync_rebuild_reason',
 
516
 
517
  def rebuild(why, previous, meta_state, **scope):
518
  events.append(('rebuild', scope.get('table_keys')))
519
+ return rebuild_ok
520
 
521
  clock = SimpleNamespace(sleep=sleep, time=lambda: now,
522
  strftime=lambda *_: 'synthetic-time', gmtime=lambda: ())
 
583
  events, _ = self.run_daily_loop(
584
  {'passAt': 10_000.0 - 90_000, 'fullRebuildAt': 10_000.0 - 90_000,
585
  'fingerprints': fps}, fps)
586
+ self.assertEqual([e[0] for e in events],
587
+ ['sync', 'meta', 'memory', 'amazon', 'memory', 'fresh', 'memory'])
588
+ self.assertEqual(events[3], ('amazon', 'resync'))
589
+ self.assertEqual(events[-1], ('memory', 10_000.0, 10_000.0 - 90_000, fps, None))
590
+
591
+ # ── HOTFIX sdlc74 #3 (owner): "we retired rebooting sync at deployment" ─────────────────────
592
+ def test_each_pull_checkpoints_before_the_rebuild_and_a_bad_end_keeps_it(self):
593
+ old, new = {'res_partner': (3, 7)}, {'res_partner': (4, 9)}
594
+ events, _ = self.run_daily_loop(
595
+ {'passAt': 10_000.0 - 90_000, 'fullRebuildAt': 10_000.0 - 90_000, 'fingerprints': old},
596
+ new, rebuild_ok=False)
597
+ kinds = [e[0] for e in events]
598
+ self.assertEqual(kinds, ['sync', 'meta', 'memory', 'amazon', 'memory', 'rebuild', 'memory'])
599
+ # The checkpoints change none of the three facts: a death in the rebuild leaves them as
600
+ # they were, plus the pulls the pass already made.
601
+ self.assertEqual(events[2], ('memory', 10_000.0 - 90_000, 10_000.0 - 90_000, old,
602
+ {'startedAt': 10_000.0, 'meta': 10_000.0}))
603
+ both = {'startedAt': 10_000.0, 'meta': 10_000.0, 'amazon': 10_000.0}
604
+ self.assertEqual(events[4], ('memory', 10_000.0 - 90_000, 10_000.0 - 90_000, old, both))
605
+ self.assertEqual(events[-1][-1], both)
606
+
607
+ def test_restart_after_an_unfinished_pass_calls_no_vendor_and_rebuilds(self):
608
+ old, new = {'res_partner': (3, 7)}, {'res_partner': (4, 9)}
609
+ events, sleeps = self.run_daily_loop(
610
+ {'passAt': 10_000.0 - 90_000, 'fullRebuildAt': 10_000.0 - 90_000, 'fingerprints': old,
611
+ 'pulls': {'startedAt': 10_000.0 - 3600, 'meta': 10_000.0 - 3400,
612
+ 'amazon': 10_000.0 - 600}}, new)
613
+ # No Meta pull and no Amazon vendor pull: Amazon's saved mirror is restored, the mirror
614
+ # catches up, and the rebuild that never reached the store runs.
615
+ self.assertEqual([e[0] for e in events], ['sync', 'amazon', 'rebuild', 'memory'])
616
+ self.assertEqual(events[1], ('amazon', 'boot', False))
617
+ self.assertIn('ut_odoo_orders', events[2][1])
618
+ # The pass ends good at the time its pulls ended, and its checkpoint is cleared.
619
+ self.assertEqual(events[-1], ('memory', 10_000.0 - 600, 10_000.0 - 90_000, new, None))
620
+ # The next scheduled pass is one cadence after the unfinished pass STARTED.
621
+ self.assertEqual(sleeps, [86400 - 3600])
622
+ self.assertIn('restarted 3600s into a pass that never finished', self.loop_output)
623
+
624
+ def test_restart_during_the_amazon_pull_repeats_only_amazon(self):
625
+ old, new = {'res_partner': (3, 7)}, {'res_partner': (4, 9)}
626
+ events, _ = self.run_daily_loop(
627
+ {'passAt': 10_000.0 - 90_000, 'fullRebuildAt': 10_000.0 - 90_000, 'fingerprints': old,
628
+ 'pulls': {'startedAt': 10_000.0 - 3600, 'meta': 10_000.0 - 3400}}, new)
629
+ self.assertEqual([e[0] for e in events], ['sync', 'amazon', 'memory', 'rebuild', 'memory'])
630
+ self.assertEqual(events[1], ('amazon', 'resync'))
631
+ self.assertEqual(events[2][-1], {'startedAt': 10_000.0 - 3600, 'meta': 10_000.0 - 3400,
632
+ 'amazon': 10_000.0})
633
+
634
+ def test_an_unfinished_pass_older_than_the_cadence_is_not_resumed(self):
635
+ """NC: the same checkpoint one cadence old runs the whole scheduled pass again"""
636
+ old, new = {'res_partner': (3, 7)}, {'res_partner': (4, 9)}
637
+ events, _ = self.run_daily_loop(
638
+ {'passAt': 10_000.0 - 190_000, 'fullRebuildAt': 10_000.0 - 190_000, 'fingerprints': old,
639
+ 'pulls': {'startedAt': 10_000.0 - 86_400, 'meta': 10_000.0 - 86_000,
640
+ 'amazon': 10_000.0 - 84_000}}, new)
641
+ self.assertIn(('meta', 'resync'), events)
642
+ self.assertIn(('amazon', 'resync'), events)
643
+ self.assertNotIn(('amazon', 'boot', False), events)
644
 
645
  def test_persisted_fingerprints_skip_the_rebuild_after_a_restart(self):
646
  fps = {'res_partner': (3, 7)}
 
729
  memory = rel.read_resync_memory(rt)
730
  self.assertEqual((memory['passAt'], memory['fullRebuildAt'], memory['fingerprints']),
731
  (1_000.0, None, fps))
732
+ self.assertIsNone(memory['pulls'])
733
+ # HOTFIX sdlc74 #3: the pulls checkpoint round-trips, and the next write without it clears it.
734
+ pulls = {'startedAt': 2_000.0, 'meta': 2_100.0, 'amazon': 4_900.0}
735
+ rel.record_resync_memory(rt, pass_at=1_000.0, full_rebuild_at=None, fingerprints=fps,
736
+ pulls=pulls)
737
+ self.assertEqual(rel.read_resync_memory(rt)['pulls'], pulls)
738
+ rel.record_resync_memory(rt, pass_at=5_000.0, full_rebuild_at=None, fingerprints=fps)
739
+ self.assertIsNone(rel.read_resync_memory(rt)['pulls'])
740
  self.assertEqual(rt.docs[rel.CONFIG_KEY]['syncEvery'], 'daily')
741
  self.assertIsNotNone(memory['lastGoodSyncAt'])
742
 
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 8eed4595a67e12793fe26b48119ccd280f32df302dbe65a8627359e956ddab6b
 
1
+ ba353da06ea4c8590c7825048aac4241964ad501b712b6cf6519fae3c100bf17