Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/main.py +20 -0
- api/odoo_relational.py +49 -1
- api/test_odoo_rank_refresh.py +158 -3
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "c5b190baa",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
c5b190baa
|
api/main.py
CHANGED
|
@@ -2802,6 +2802,18 @@ def _resync_slot_exhausted_write(message):
|
|
| 2802 |
print(f"[aios-api] store resync slot cause not saved ({type(e).__name__}): {e}")
|
| 2803 |
|
| 2804 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2805 |
def _resync_confirm_fresh(tenant, cadence_seconds):
|
| 2806 |
"""A pass that proved the mirror equals the last apply is a good sync: stamp both freshness
|
| 2807 |
readers (the connector's `lastGoodSyncAt` and the per-database health), in two writes."""
|
|
@@ -2814,6 +2826,8 @@ def _resync_confirm_fresh(tenant, cadence_seconds):
|
|
| 2814 |
_rc_fresh.record_odoo_freshness_confirmed(
|
| 2815 |
rt, _rc_fresh._odoo_connection_slot(rt, None), at=stamp,
|
| 2816 |
cadence_seconds=cadence_seconds)
|
|
|
|
|
|
|
| 2817 |
except Exception as e: # noqa: BLE001
|
| 2818 |
print(f"[aios-api] odoo freshness stamp not saved ({type(e).__name__}: {e})")
|
| 2819 |
|
|
@@ -2965,6 +2979,7 @@ def _store_resync_loop():
|
|
| 2965 |
slot_resume_checked = False
|
| 2966 |
_slot_write = globals().get("_resync_slot_pass_write") or (lambda *_a, **_k: None)
|
| 2967 |
_slot_exhausted_write = globals().get("_resync_slot_exhausted_write") or (lambda *_a, **_k: None)
|
|
|
|
| 2968 |
# H1: a held Odoo backfill that moved queues a bounded Odoo-only pass, at most 24 per slot day.
|
| 2969 |
_backfill_read = globals().get("_odoo_backfill_checkpoints")
|
| 2970 |
backfill_next_at = None
|
|
@@ -3097,6 +3112,11 @@ def _store_resync_loop():
|
|
| 3097 |
f"waits for the next slot at {RESYNC_STATE['nextPassAt']}")
|
| 3098 |
_slot_exhausted_write(_cause)
|
| 3099 |
print(f"[aios-api] store resync: {_cause}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3100 |
else:
|
| 3101 |
RESYNC_STATE.pop("nextPassAt", None)
|
| 3102 |
# ⛔⛔ HOTFIX 2026-09-29 — A RESTART INSIDE THE DAILY WINDOW IS NOT A SYNC. The owner
|
|
|
|
| 2802 |
print(f"[aios-api] store resync slot cause not saved ({type(e).__name__}): {e}")
|
| 2803 |
|
| 2804 |
|
| 2805 |
+
def _resync_slot_interrupted_clear():
|
| 2806 |
+
"""Clear a stored slot-interrupted failure after a good pass. True when it cleared one. Never raises."""
|
| 2807 |
+
try:
|
| 2808 |
+
import odoo_relational as _rel_slot
|
| 2809 |
+
from harness import runtime as _runtime_slot
|
| 2810 |
+
return bool(_rel_slot.clear_slot_interrupted(
|
| 2811 |
+
_runtime_slot.get_runtime(_resync_tenant()[0])))
|
| 2812 |
+
except Exception as e: # noqa: BLE001
|
| 2813 |
+
print(f"[aios-api] store resync slot cause not cleared ({type(e).__name__}): {e}")
|
| 2814 |
+
return False
|
| 2815 |
+
|
| 2816 |
+
|
| 2817 |
def _resync_confirm_fresh(tenant, cadence_seconds):
|
| 2818 |
"""A pass that proved the mirror equals the last apply is a good sync: stamp both freshness
|
| 2819 |
readers (the connector's `lastGoodSyncAt` and the per-database health), in two writes."""
|
|
|
|
| 2826 |
_rc_fresh.record_odoo_freshness_confirmed(
|
| 2827 |
rt, _rc_fresh._odoo_connection_slot(rt, None), at=stamp,
|
| 2828 |
cadence_seconds=cadence_seconds)
|
| 2829 |
+
# A good pass ends a slot-interrupted failure; this path never rewrites the status doc itself.
|
| 2830 |
+
_rel_fresh.clear_slot_interrupted(rt)
|
| 2831 |
except Exception as e: # noqa: BLE001
|
| 2832 |
print(f"[aios-api] odoo freshness stamp not saved ({type(e).__name__}: {e})")
|
| 2833 |
|
|
|
|
| 2979 |
slot_resume_checked = False
|
| 2980 |
_slot_write = globals().get("_resync_slot_pass_write") or (lambda *_a, **_k: None)
|
| 2981 |
_slot_exhausted_write = globals().get("_resync_slot_exhausted_write") or (lambda *_a, **_k: None)
|
| 2982 |
+
_slot_interrupted_clear = globals().get("_resync_slot_interrupted_clear") or (lambda *_a, **_k: False)
|
| 2983 |
# H1: a held Odoo backfill that moved queues a bounded Odoo-only pass, at most 24 per slot day.
|
| 2984 |
_backfill_read = globals().get("_odoo_backfill_checkpoints")
|
| 2985 |
backfill_next_at = None
|
|
|
|
| 3112 |
f"waits for the next slot at {RESYNC_STATE['nextPassAt']}")
|
| 3113 |
_slot_exhausted_write(_cause)
|
| 3114 |
print(f"[aios-api] store resync: {_cause}")
|
| 3115 |
+
elif _rel_slot.slot_pass_satisfied(_slot_now, _slot, _memory):
|
| 3116 |
+
# A good pass ended after the slot, so a stored interrupted failure is stale.
|
| 3117 |
+
if _slot_interrupted_clear():
|
| 3118 |
+
print(f"[aios-api] store resync: a good pass ended after the {_slot['at']} "
|
| 3119 |
+
f"{_slot['tz']} slot; cleared the slot_pass_interrupted failure")
|
| 3120 |
else:
|
| 3121 |
RESYNC_STATE.pop("nextPassAt", None)
|
| 3122 |
# ⛔⛔ HOTFIX 2026-09-29 — A RESTART INSIDE THE DAILY WINDOW IS NOT A SYNC. The owner
|
api/odoo_relational.py
CHANGED
|
@@ -5887,14 +5887,40 @@ def slot_due(now, slot, last_pass_at):
|
|
| 5887 |
return last_pass_at is None or float(last_pass_at) < slot_before(now, slot)
|
| 5888 |
|
| 5889 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5890 |
def slot_pass_killed(now, slot, memory):
|
| 5891 |
"""The latest slot's epoch when its claimed pass never ended and has a resume left, else None.
|
| 5892 |
|
| 5893 |
A `passAt` at or after the claim also ends it, which covers memory from older code.
|
|
|
|
| 5894 |
"""
|
| 5895 |
memory = memory if isinstance(memory, dict) else {}
|
| 5896 |
claim = memory.get("slotPassAt")
|
| 5897 |
newest = slot_before(now, slot)
|
|
|
|
|
|
|
| 5898 |
if claim is None or float(claim) < newest:
|
| 5899 |
return None
|
| 5900 |
ends = [float(at) for at in (memory.get("slotDoneAt"), memory.get("passAt")) if at is not None]
|
|
@@ -5916,10 +5942,12 @@ def _slot_resumes(memory):
|
|
| 5916 |
|
| 5917 |
|
| 5918 |
def slot_pass_exhausted(now, slot, memory):
|
| 5919 |
-
"""The newest slot's epoch when its killed pass used every resume, else None."""
|
| 5920 |
memory = memory if isinstance(memory, dict) else {}
|
| 5921 |
claim = memory.get("slotPassAt")
|
| 5922 |
newest = slot_before(now, slot)
|
|
|
|
|
|
|
| 5923 |
if claim is None or float(claim) < newest:
|
| 5924 |
return None
|
| 5925 |
ends = [float(at) for at in (memory.get("slotDoneAt"), memory.get("passAt")) if at is not None]
|
|
@@ -6169,6 +6197,26 @@ def record_slot_pass(rt, at, field="slotPassAt"):
|
|
| 6169 |
return stamp
|
| 6170 |
|
| 6171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6172 |
def _effective_sync_seconds(preset):
|
| 6173 |
"""The interval a sync can actually keep: the tenant's preset, floored, and never faster than
|
| 6174 |
the deployment's own resync floor (`AIOS_STORE_RESYNC_SECONDS`), which `main.py` applies with
|
|
|
|
| 5887 |
return last_pass_at is None or float(last_pass_at) < slot_before(now, slot)
|
| 5888 |
|
| 5889 |
|
| 5890 |
+
def _good_epoch(value):
|
| 5891 |
+
"""A memory stamp as an epoch: a number, or an ISO string. None when unreadable."""
|
| 5892 |
+
if value is None or isinstance(value, bool):
|
| 5893 |
+
return None
|
| 5894 |
+
if isinstance(value, (int, float)):
|
| 5895 |
+
return float(value)
|
| 5896 |
+
try:
|
| 5897 |
+
return float(str(value))
|
| 5898 |
+
except ValueError:
|
| 5899 |
+
return _memory_epoch(value)
|
| 5900 |
+
|
| 5901 |
+
|
| 5902 |
+
def slot_pass_satisfied(now, slot, memory):
|
| 5903 |
+
"""True when a good pass (`lastGoodSyncAt` or `passAt`) ended at or after the newest slot. Never raises."""
|
| 5904 |
+
memory = memory if isinstance(memory, dict) else {}
|
| 5905 |
+
try:
|
| 5906 |
+
newest = slot_before(now, slot)
|
| 5907 |
+
except Exception: # noqa: BLE001
|
| 5908 |
+
return False
|
| 5909 |
+
goods = [_good_epoch(memory.get(field)) for field in ("lastGoodSyncAt", "passAt")]
|
| 5910 |
+
return any(at is not None and at >= newest for at in goods)
|
| 5911 |
+
|
| 5912 |
+
|
| 5913 |
def slot_pass_killed(now, slot, memory):
|
| 5914 |
"""The latest slot's epoch when its claimed pass never ended and has a resume left, else None.
|
| 5915 |
|
| 5916 |
A `passAt` at or after the claim also ends it, which covers memory from older code.
|
| 5917 |
+
A good pass that ended after the slot satisfies it, so nothing resumes.
|
| 5918 |
"""
|
| 5919 |
memory = memory if isinstance(memory, dict) else {}
|
| 5920 |
claim = memory.get("slotPassAt")
|
| 5921 |
newest = slot_before(now, slot)
|
| 5922 |
+
if slot_pass_satisfied(now, slot, memory):
|
| 5923 |
+
return None
|
| 5924 |
if claim is None or float(claim) < newest:
|
| 5925 |
return None
|
| 5926 |
ends = [float(at) for at in (memory.get("slotDoneAt"), memory.get("passAt")) if at is not None]
|
|
|
|
| 5942 |
|
| 5943 |
|
| 5944 |
def slot_pass_exhausted(now, slot, memory):
|
| 5945 |
+
"""The newest slot's epoch when its killed pass used every resume and no good pass ended after the slot, else None."""
|
| 5946 |
memory = memory if isinstance(memory, dict) else {}
|
| 5947 |
claim = memory.get("slotPassAt")
|
| 5948 |
newest = slot_before(now, slot)
|
| 5949 |
+
if slot_pass_satisfied(now, slot, memory):
|
| 5950 |
+
return None
|
| 5951 |
if claim is None or float(claim) < newest:
|
| 5952 |
return None
|
| 5953 |
ends = [float(at) for at in (memory.get("slotDoneAt"), memory.get("passAt")) if at is not None]
|
|
|
|
| 6197 |
return stamp
|
| 6198 |
|
| 6199 |
|
| 6200 |
+
#: The code `main.py` writes when a killed slot pass used every resume.
|
| 6201 |
+
SLOT_INTERRUPTED_CODE = "slot_pass_interrupted"
|
| 6202 |
+
|
| 6203 |
+
|
| 6204 |
+
def clear_slot_interrupted(rt):
|
| 6205 |
+
"""Rewrite a stored `slot_pass_interrupted` failure as phase ok and return True, else False. Never raises."""
|
| 6206 |
+
try:
|
| 6207 |
+
status = rt.get(_ut().ODOO_SYNC_STATUS_KEY) if rt is not None else None
|
| 6208 |
+
status = status if isinstance(status, dict) else {}
|
| 6209 |
+
errors = status.get("errors") if isinstance(status.get("errors"), list) else []
|
| 6210 |
+
if str(status.get("phase") or "") != "error" or not errors:
|
| 6211 |
+
return False
|
| 6212 |
+
if not str(errors[0]).startswith(SLOT_INTERRUPTED_CODE + ":"):
|
| 6213 |
+
return False
|
| 6214 |
+
_ut().record_odoo_sync_status(phase="ok", st=rt)
|
| 6215 |
+
return True
|
| 6216 |
+
except Exception: # noqa: BLE001
|
| 6217 |
+
return False
|
| 6218 |
+
|
| 6219 |
+
|
| 6220 |
def _effective_sync_seconds(preset):
|
| 6221 |
"""The interval a sync can actually keep: the tenant's preset, floored, and never faster than
|
| 6222 |
the deployment's own resync floor (`AIOS_STORE_RESYNC_SECONDS`), which `main.py` applies with
|
api/test_odoo_rank_refresh.py
CHANGED
|
@@ -765,14 +765,14 @@ class RankRefreshTests(unittest.TestCase):
|
|
| 765 |
return datetime.fromisoformat(text.replace('Z', '+00:00')).timestamp()
|
| 766 |
|
| 767 |
def run_slot_loop(self, memory, *, boot, max_sleeps, tenant='royal-imports', config=None,
|
| 768 |
-
reports=None, checkpoints=None, take=None, slot_flags=None):
|
| 769 |
"""Drive the real loop and its real slot resolver on a clock that advances at each wait."""
|
| 770 |
import odoo_relational as rel
|
| 771 |
source = ast.parse(Path(__file__).with_name('main.py').read_text(encoding='utf-8'))
|
| 772 |
-
# The loop reads
|
| 773 |
functions = {'_store_resync_loop', '_resync_rebuild_reason', '_meta_rebuild_force_reason',
|
| 774 |
'_resync_boot_recent', '_resolve_resync_slot', '_resync_slot_pass_write',
|
| 775 |
-
'_resync_slot_exhausted_write'}
|
| 776 |
nodes = [node for node in source.body
|
| 777 |
if isinstance(node, ast.FunctionDef) and node.name in functions
|
| 778 |
or isinstance(node, ast.Assign) and any(
|
|
@@ -798,6 +798,8 @@ class RankRefreshTests(unittest.TestCase):
|
|
| 798 |
return {'res_partner': {'phase': 'live', 'pulled': 0}}, {}, None
|
| 799 |
|
| 800 |
store = self.SlotStore(tenant, {rel.CONFIG_KEY: dict(config or {})})
|
|
|
|
|
|
|
| 801 |
clock = SimpleNamespace(sleep=wait, monotonic=lambda: now[0], time=lambda: now[0],
|
| 802 |
strftime=lambda *_: 'synthetic-time', gmtime=lambda: ())
|
| 803 |
ns = dict(os=os, _restore_sync_request_desks=lambda: None, RESYNC_STATE={'consecutiveFailures': 0}, _RESYNC_NOTICE=[None], _SEED_THREAD=None,
|
|
@@ -1142,6 +1144,159 @@ class RankRefreshTests(unittest.TestCase):
|
|
| 1142 |
self.assertEqual(sleeps, [next_slot + 1 - boot])
|
| 1143 |
self.assertNotIn('odoo backfill continues', self.loop_output)
|
| 1144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1145 |
|
| 1146 |
if __name__ == '__main__':
|
| 1147 |
unittest.main()
|
|
|
|
| 765 |
return datetime.fromisoformat(text.replace('Z', '+00:00')).timestamp()
|
| 766 |
|
| 767 |
def run_slot_loop(self, memory, *, boot, max_sleeps, tenant='royal-imports', config=None,
|
| 768 |
+
reports=None, checkpoints=None, take=None, slot_flags=None, status=None):
|
| 769 |
"""Drive the real loop and its real slot resolver on a clock that advances at each wait."""
|
| 770 |
import odoo_relational as rel
|
| 771 |
source = ast.parse(Path(__file__).with_name('main.py').read_text(encoding='utf-8'))
|
| 772 |
+
# The loop reads the slot helpers by name, so they are extracted here explicitly.
|
| 773 |
functions = {'_store_resync_loop', '_resync_rebuild_reason', '_meta_rebuild_force_reason',
|
| 774 |
'_resync_boot_recent', '_resolve_resync_slot', '_resync_slot_pass_write',
|
| 775 |
+
'_resync_slot_exhausted_write', '_resync_slot_interrupted_clear'}
|
| 776 |
nodes = [node for node in source.body
|
| 777 |
if isinstance(node, ast.FunctionDef) and node.name in functions
|
| 778 |
or isinstance(node, ast.Assign) and any(
|
|
|
|
| 798 |
return {'res_partner': {'phase': 'live', 'pulled': 0}}, {}, None
|
| 799 |
|
| 800 |
store = self.SlotStore(tenant, {rel.CONFIG_KEY: dict(config or {})})
|
| 801 |
+
if status is not None:
|
| 802 |
+
store.docs[rel._ut().ODOO_SYNC_STATUS_KEY] = dict(status)
|
| 803 |
clock = SimpleNamespace(sleep=wait, monotonic=lambda: now[0], time=lambda: now[0],
|
| 804 |
strftime=lambda *_: 'synthetic-time', gmtime=lambda: ())
|
| 805 |
ns = dict(os=os, _restore_sync_request_desks=lambda: None, RESYNC_STATE={'consecutiveFailures': 0}, _RESYNC_NOTICE=[None], _SEED_THREAD=None,
|
|
|
|
| 1144 |
self.assertEqual(sleeps, [next_slot + 1 - boot])
|
| 1145 |
self.assertNotIn('odoo backfill continues', self.loop_output)
|
| 1146 |
|
| 1147 |
+
# ── Hotfix 10-31: a good pass after the slot satisfies it, so a killed claim does not alarm ──
|
| 1148 |
+
INTERRUPTED = ('slot_pass_interrupted: the 13:00 Asia/Jakarta slot pass was interrupted by '
|
| 1149 |
+
'4 restarts and waits for the next slot at 2026-11-01T06:00:00Z')
|
| 1150 |
+
|
| 1151 |
+
def staging_slot_memory(self, **extra):
|
| 1152 |
+
"""The 10-31 staging memory: a good pass at 10:14Z, then a later claim with no end."""
|
| 1153 |
+
memory = {'passAt': self.utc('2026-10-29T06:30:00Z'),
|
| 1154 |
+
'fullRebuildAt': self.utc('2026-10-29T06:30:00Z'),
|
| 1155 |
+
'fingerprints': {'res_partner': (3, 7)},
|
| 1156 |
+
'lastGoodSyncAt': self.utc('2026-10-31T10:14:08Z'),
|
| 1157 |
+
'slotPassAt': self.utc('2026-10-31T10:57:21Z'),
|
| 1158 |
+
'slotDoneAt': self.utc('2026-10-30T06:40:00Z'),
|
| 1159 |
+
'slotResumedFor': self.utc('2026-10-31T06:00:00Z')}
|
| 1160 |
+
memory.update(extra)
|
| 1161 |
+
return memory
|
| 1162 |
+
|
| 1163 |
+
def stored_config(self, memory):
|
| 1164 |
+
"""The connector config that holds `memory`, so a write to the slot stamps shows."""
|
| 1165 |
+
import odoo_relational as rel
|
| 1166 |
+
stamps = {field: rel.slot_iso(memory[field])
|
| 1167 |
+
for field in ('passAt', 'slotPassAt', 'slotDoneAt', 'slotResumedFor')
|
| 1168 |
+
if memory.get(field) is not None}
|
| 1169 |
+
stamps['slotResumes'] = memory.get('slotResumes') or 0
|
| 1170 |
+
config = {rel.RESYNC_MEMORY_FIELD: stamps}
|
| 1171 |
+
if memory.get('lastGoodSyncAt') is not None:
|
| 1172 |
+
config['lastGoodSyncAt'] = rel.slot_iso(memory['lastGoodSyncAt'])
|
| 1173 |
+
return config
|
| 1174 |
+
|
| 1175 |
+
def test_hotfix_a_good_pass_after_the_slot_stops_resumes_and_the_alarm(self):
|
| 1176 |
+
"""A killed claim after a good pass that ended after the slot: no resume, no failure, any boot"""
|
| 1177 |
+
import odoo_relational as rel
|
| 1178 |
+
next_slot = self.utc('2026-11-01T06:00:00Z')
|
| 1179 |
+
# Control: without the good stamp, the same claim resumes, then alarms.
|
| 1180 |
+
control = self.staging_slot_memory(lastGoodSyncAt=None, slotResumes=1)
|
| 1181 |
+
events, sleeps, odoo = self.run_slot_loop(
|
| 1182 |
+
control, boot=self.utc('2026-10-31T11:05:00Z'), max_sleeps=1,
|
| 1183 |
+
config=self.stored_config(control))
|
| 1184 |
+
self.assertIn('never finished; running it again now (resume 2 of 3)', self.loop_output)
|
| 1185 |
+
control = self.staging_slot_memory(lastGoodSyncAt=None, slotResumes=3)
|
| 1186 |
+
self.run_slot_loop(control, boot=self.utc('2026-10-31T11:05:00Z'), max_sleeps=1,
|
| 1187 |
+
config=self.stored_config(control))
|
| 1188 |
+
self.assertIn(self.INTERRUPTED, self.loop_output)
|
| 1189 |
+
# The good pass at 10:14Z satisfies the 06:00Z slot on every boot, whatever the count.
|
| 1190 |
+
boots = ('2026-10-31T11:05:00Z', '2026-10-31T11:20:00Z', '2026-10-31T11:40:00Z',
|
| 1191 |
+
'2026-10-31T12:30:00Z', '2026-10-31T13:00:00Z')
|
| 1192 |
+
for count, text in zip((1, 2, 3, 3, 3), boots):
|
| 1193 |
+
boot = self.utc(text)
|
| 1194 |
+
memory = self.staging_slot_memory(slotResumes=count)
|
| 1195 |
+
events, sleeps, odoo = self.run_slot_loop(
|
| 1196 |
+
memory, boot=boot, max_sleeps=1, config=self.stored_config(memory))
|
| 1197 |
+
# The loop reached the slot block: it named the next pass and waits for that slot.
|
| 1198 |
+
self.assertEqual(self.slot_state['nextPassAt'], '2026-11-01T06:00:00Z')
|
| 1199 |
+
self.assertEqual(sleeps, [next_slot + 1 - boot])
|
| 1200 |
+
self.assertEqual(odoo, [])
|
| 1201 |
+
self.assertNotIn('never finished', self.loop_output)
|
| 1202 |
+
self.assertNotIn('slot_pass_interrupted', self.loop_output)
|
| 1203 |
+
self.assertIsNone(rel.sync_freshness(self.slot_store, now=boot)['failure'])
|
| 1204 |
+
stamps = rel.read_resync_memory(self.slot_store)
|
| 1205 |
+
self.assertEqual((stamps['slotResumes'], stamps['slotResumedFor'], stamps['slotPassAt']),
|
| 1206 |
+
(count, memory['slotResumedFor'], memory['slotPassAt']))
|
| 1207 |
+
|
| 1208 |
+
def test_hotfix_b_one_boot_clears_a_stored_interrupted_failure(self):
|
| 1209 |
+
"""A stored slot_pass_interrupted failure and a good pass after the slot: one boot clears it"""
|
| 1210 |
+
import odoo_relational as rel
|
| 1211 |
+
boot = self.utc('2026-10-31T12:00:00Z')
|
| 1212 |
+
status = {'phase': 'error', 'lastRun': '2026-10-31T11:00:00+00:00',
|
| 1213 |
+
'errors': [self.INTERRUPTED]}
|
| 1214 |
+
before = self.SlotStore('royal-imports', {rel._ut().ODOO_SYNC_STATUS_KEY: dict(status)})
|
| 1215 |
+
self.assertEqual(rel.sync_freshness(before, now=boot)['failure']['code'],
|
| 1216 |
+
'slot_pass_interrupted')
|
| 1217 |
+
for good in ({}, {'lastGoodSyncAt': None, 'passAt': self.utc('2026-10-31T10:14:08Z')}):
|
| 1218 |
+
memory = self.staging_slot_memory(slotResumes=3, **good)
|
| 1219 |
+
self.run_slot_loop(memory, boot=boot, max_sleeps=1, status=status,
|
| 1220 |
+
config=self.stored_config(memory))
|
| 1221 |
+
self.assertEqual(self.slot_state['nextPassAt'], '2026-11-01T06:00:00Z')
|
| 1222 |
+
self.assertIsNone(rel.sync_freshness(self.slot_store, now=boot)['failure'])
|
| 1223 |
+
stored = self.slot_store.docs[rel._ut().ODOO_SYNC_STATUS_KEY]
|
| 1224 |
+
self.assertNotEqual(stored['phase'], 'error')
|
| 1225 |
+
self.assertIn('cleared the slot_pass_interrupted failure', self.loop_output)
|
| 1226 |
+
self.assertNotRegex(self.loop_output, '[\u2013\u2014]')
|
| 1227 |
+
# Another failure code stays on the card, and the loop logs no clear.
|
| 1228 |
+
other = {'phase': 'error', 'lastRun': '2026-10-31T11:00:00+00:00', 'errors': ['sync_failed: x']}
|
| 1229 |
+
memory = self.staging_slot_memory(slotResumes=3)
|
| 1230 |
+
self.run_slot_loop(memory, boot=boot, max_sleeps=1, status=other,
|
| 1231 |
+
config=self.stored_config(memory))
|
| 1232 |
+
self.assertEqual(self.slot_state['nextPassAt'], '2026-11-01T06:00:00Z')
|
| 1233 |
+
self.assertEqual(rel.sync_freshness(self.slot_store, now=boot)['failure']['code'], 'sync_failed')
|
| 1234 |
+
self.assertNotIn('cleared the slot_pass_interrupted failure', self.loop_output)
|
| 1235 |
+
|
| 1236 |
+
def test_hotfix_c_slot_helpers_honour_a_good_pass_after_the_slot(self):
|
| 1237 |
+
"""killed and exhausted return None after a good pass at or after the slot, else unchanged"""
|
| 1238 |
+
import odoo_relational as rel
|
| 1239 |
+
slot = rel.sync_slot(rel.read_config(self.SlotStore('royal-imports')))
|
| 1240 |
+
slot_at, boot = self.utc('2026-10-31T06:00:00Z'), self.utc('2026-10-31T11:30:00Z')
|
| 1241 |
+
base = self.staging_slot_memory(lastGoodSyncAt=self.utc('2026-10-30T06:40:00Z'))
|
| 1242 |
+
fresh, spent = dict(base, slotResumes=1), dict(base, slotResumes=3)
|
| 1243 |
+
# Good stamp before the slot: today's behaviour.
|
| 1244 |
+
self.assertEqual(rel.slot_pass_killed(boot, slot, fresh), slot_at)
|
| 1245 |
+
self.assertEqual(rel.slot_pass_exhausted(boot, slot, spent), slot_at)
|
| 1246 |
+
self.assertFalse(rel.slot_pass_satisfied(boot, slot, fresh))
|
| 1247 |
+
# Unreadable stamps are ignored, never raised.
|
| 1248 |
+
for junk in ('not a time', [], True):
|
| 1249 |
+
self.assertEqual(rel.slot_pass_exhausted(boot, slot, dict(spent, lastGoodSyncAt=junk)), slot_at)
|
| 1250 |
+
self.assertFalse(rel.slot_pass_satisfied(boot, slot, None))
|
| 1251 |
+
# A good stamp at or after the slot (epoch or ISO, either field) satisfies it.
|
| 1252 |
+
for good in ({'lastGoodSyncAt': self.utc('2026-10-31T10:14:08Z')},
|
| 1253 |
+
{'lastGoodSyncAt': slot_at},
|
| 1254 |
+
{'lastGoodSyncAt': '2026-10-31T10:14:08Z'},
|
| 1255 |
+
{'passAt': self.utc('2026-10-31T10:14:08Z')}):
|
| 1256 |
+
self.assertTrue(rel.slot_pass_satisfied(boot, slot, dict(fresh, **good)))
|
| 1257 |
+
self.assertIsNone(rel.slot_pass_killed(boot, slot, dict(fresh, **good)))
|
| 1258 |
+
self.assertIsNone(rel.slot_pass_exhausted(boot, slot, dict(spent, **good)))
|
| 1259 |
+
# clear_slot_interrupted rewrites only the interrupted code.
|
| 1260 |
+
key = rel._ut().ODOO_SYNC_STATUS_KEY
|
| 1261 |
+
rt = self.SlotStore('royal-imports', {key: {'phase': 'error', 'errors': [self.INTERRUPTED]}})
|
| 1262 |
+
self.assertTrue(rel.clear_slot_interrupted(rt))
|
| 1263 |
+
self.assertEqual((rt.docs[key]['phase'], rt.docs[key]['errors']), ('ok', []))
|
| 1264 |
+
for kept in ({'phase': 'error', 'errors': ['sync_failed: x']},
|
| 1265 |
+
{'phase': 'ok', 'errors': []}, None):
|
| 1266 |
+
rt = self.SlotStore('royal-imports', {} if kept is None else {key: dict(kept)})
|
| 1267 |
+
self.assertFalse(rel.clear_slot_interrupted(rt))
|
| 1268 |
+
self.assertEqual(rt.docs.get(key), kept)
|
| 1269 |
+
broken = SimpleNamespace(get=lambda *_a, **_k: (_ for _ in ()).throw(RuntimeError('down')))
|
| 1270 |
+
self.assertFalse(rel.clear_slot_interrupted(broken))
|
| 1271 |
+
self.assertFalse(rel.clear_slot_interrupted(None))
|
| 1272 |
+
|
| 1273 |
+
def test_hotfix_d_confirm_fresh_clears_a_stored_interrupted_failure(self):
|
| 1274 |
+
"""The unchanged good pass stamps freshness and clears a slot_pass_interrupted failure"""
|
| 1275 |
+
import odoo_relational as rel
|
| 1276 |
+
import harness
|
| 1277 |
+
source = ast.parse(Path(__file__).with_name('main.py').read_text(encoding='utf-8'))
|
| 1278 |
+
node = next(node for node in source.body if isinstance(node, ast.FunctionDef)
|
| 1279 |
+
and node.name == '_resync_confirm_fresh')
|
| 1280 |
+
ns = {}
|
| 1281 |
+
exec(compile(ast.Module(body=[node], type_ignores=[]), 'main.py:confirm-fresh', 'exec'), ns)
|
| 1282 |
+
key = rel._ut().ODOO_SYNC_STATUS_KEY
|
| 1283 |
+
confirmed = []
|
| 1284 |
+
connectors = SimpleNamespace(
|
| 1285 |
+
_odoo_connection_slot=lambda *_: 'odoo',
|
| 1286 |
+
record_odoo_freshness_confirmed=lambda *a, **k: confirmed.append(k.get('at')))
|
| 1287 |
+
for status, phase in (({'phase': 'error', 'errors': [self.INTERRUPTED]}, 'ok'),
|
| 1288 |
+
({'phase': 'error', 'errors': ['sync_failed: x']}, 'error')):
|
| 1289 |
+
store = self.SlotStore('royal-imports', {rel.CONFIG_KEY: {}, key: dict(status)})
|
| 1290 |
+
runtime = SimpleNamespace(get_runtime=lambda *_: store)
|
| 1291 |
+
out = io.StringIO()
|
| 1292 |
+
with patch.dict(sys.modules, {'harness.runtime': runtime, 'routes_connectors': connectors}), \
|
| 1293 |
+
patch.object(harness, 'runtime', runtime, create=True), redirect_stdout(out):
|
| 1294 |
+
ns['_resync_confirm_fresh']('royal-imports', 86400)
|
| 1295 |
+
self.assertEqual(out.getvalue(), '')
|
| 1296 |
+
self.assertTrue(store.docs[rel.CONFIG_KEY].get('lastGoodSyncAt'))
|
| 1297 |
+
self.assertEqual(store.docs[key]['phase'], phase)
|
| 1298 |
+
self.assertEqual(len(confirmed), 2)
|
| 1299 |
+
|
| 1300 |
|
| 1301 |
if __name__ == '__main__':
|
| 1302 |
unittest.main()
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
833e0216456b671a3b0bb4a3a7034aee1d11bc452981f3d620e12bf2efab8975
|