fsanyoto commited on
Commit
0645c1f
·
verified ·
1 Parent(s): aadfd74

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,11 +1,497 @@
1
  {
2
- "current": "v84 (7bb3a2e09e)",
3
  "releases": [
4
  {
5
- "version": "v84",
6
- "sha": "7bb3a2e09e",
7
- "date": "2026-10-24",
8
- "subject": "release v84"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
  ]
11
  }
 
1
  {
2
+ "current": "f75ce5527c (f75ce5527c67)",
3
  "releases": [
4
  {
5
+ "version": "v83",
6
+ "sha": "9b7471968e79",
7
+ "date": "2026-10-21",
8
+ "subject": "release v83"
9
+ },
10
+ {
11
+ "version": "v82",
12
+ "sha": "9c61b1ee94d0",
13
+ "date": "2026-10-17",
14
+ "subject": "release v82"
15
+ },
16
+ {
17
+ "version": "v81",
18
+ "sha": "e141ccc85ef0",
19
+ "date": "2026-10-15",
20
+ "subject": "release v81"
21
+ },
22
+ {
23
+ "version": "v80",
24
+ "sha": "869b8fcc62ac",
25
+ "date": "2026-10-13",
26
+ "subject": "release v80"
27
+ },
28
+ {
29
+ "version": "v79",
30
+ "sha": "406417b8ded0",
31
+ "date": "2026-10-13",
32
+ "subject": "release v79"
33
+ },
34
+ {
35
+ "version": "v78",
36
+ "sha": "aad6561d63e6",
37
+ "date": "2026-10-09",
38
+ "subject": "release v78: SDLC 71 with the D-7536 and D-7537 repairs"
39
+ },
40
+ {
41
+ "version": "v77",
42
+ "sha": "e741e5ca604d",
43
+ "date": "2026-10-05",
44
+ "subject": "release v77"
45
+ },
46
+ {
47
+ "version": "v76",
48
+ "sha": "7990f03e0254",
49
+ "date": "2026-10-01",
50
+ "subject": "release v76"
51
+ },
52
+ {
53
+ "version": "v75",
54
+ "sha": "2c5146981ccf",
55
+ "date": "2026-09-19",
56
+ "subject": "release v75"
57
+ },
58
+ {
59
+ "version": "v74",
60
+ "sha": "40dceba9262e",
61
+ "date": "2026-09-14",
62
+ "subject": "release v74: waves 58+59 incl. the Amazon credential door (W59-T21/22/23) and sync producer (W59-T42); hotfix promote so"
63
+ },
64
+ {
65
+ "version": "v73",
66
+ "sha": "bb94de5665e6",
67
+ "date": "2026-09-13",
68
+ "subject": "release v73"
69
+ },
70
+ {
71
+ "version": "v71",
72
+ "sha": "96143dc6fb65",
73
+ "date": "2026-09-04",
74
+ "subject": "release v71 - wave 51, QA'd 24 PASS / 6 FAIL / 5 UNPROVEN"
75
+ },
76
+ {
77
+ "version": "v70",
78
+ "sha": "eedfb6a00163",
79
+ "date": "2026-09-03",
80
+ "subject": "release v70 - wave 50 (grid analytics, the Sheet as a spreadsheet, view trash and audit)"
81
+ },
82
+ {
83
+ "version": "v69",
84
+ "sha": "8598f56293a0",
85
+ "date": "2026-09-02",
86
+ "subject": "release v69: wave48-continuation validated + hotfixes v67/v68/d4e3e31 + go-live QA repairs (Supplier option limit, optio"
87
+ },
88
+ {
89
+ "version": "v68",
90
+ "sha": "62b065a2610a",
91
+ "date": "2026-09-01",
92
+ "subject": "release v68: unified holiday date offsets"
93
+ },
94
+ {
95
+ "version": "v67",
96
+ "sha": "3b2241982cf7",
97
+ "date": "2026-09-01",
98
+ "subject": "release v67"
99
+ },
100
+ {
101
+ "version": "v66",
102
+ "sha": "73c94f076740",
103
+ "date": "2026-08-31",
104
+ "subject": "release v66"
105
+ },
106
+ {
107
+ "version": "v65",
108
+ "sha": "9f6cfedb8a43",
109
+ "date": "2026-08-31",
110
+ "subject": "release v65"
111
+ },
112
+ {
113
+ "version": "v64",
114
+ "sha": "bb8985c6e73e",
115
+ "date": "2026-08-31",
116
+ "subject": "release v64"
117
+ },
118
+ {
119
+ "version": "v63",
120
+ "sha": "ec75cb8f3412",
121
+ "date": "2026-08-31",
122
+ "subject": "release v63"
123
+ },
124
+ {
125
+ "version": "v62",
126
+ "sha": "2c8f702c964f",
127
+ "date": "2026-08-31",
128
+ "subject": "release v62"
129
+ },
130
+ {
131
+ "version": "v61",
132
+ "sha": "bbc4c0760ab5",
133
+ "date": "2026-08-30",
134
+ "subject": "v61 - wave 46 hotfix: D-590 schema overlay reaches the grid read (all three assemblies), D-599 route to zone association"
135
+ },
136
+ {
137
+ "version": "v60",
138
+ "sha": "dd1b0620210e",
139
+ "date": "2026-08-30",
140
+ "subject": "v60 - wave 46"
141
+ },
142
+ {
143
+ "version": "v59",
144
+ "sha": "3cb73ce8021e",
145
+ "date": "2026-08-29",
146
+ "subject": "release v59"
147
+ },
148
+ {
149
+ "version": "v58",
150
+ "sha": "c526cede82f9",
151
+ "date": "2026-08-29",
152
+ "subject": "release v58"
153
+ },
154
+ {
155
+ "version": "v57",
156
+ "sha": "4859c035e6a7",
157
+ "date": "2026-08-29",
158
+ "subject": "release v57"
159
+ },
160
+ {
161
+ "version": "v56",
162
+ "sha": "2970b729e8f0",
163
+ "date": "2026-08-28",
164
+ "subject": "release v56"
165
+ },
166
+ {
167
+ "version": "v55",
168
+ "sha": "b766b904b8fa",
169
+ "date": "2026-08-28",
170
+ "subject": "release v55"
171
+ },
172
+ {
173
+ "version": "v54",
174
+ "sha": "6a8e99a064d9",
175
+ "date": "2026-08-27",
176
+ "subject": "release v54"
177
+ },
178
+ {
179
+ "version": "v53",
180
+ "sha": "89ed2cb867da",
181
+ "date": "2026-08-24",
182
+ "subject": "release v53"
183
+ },
184
+ {
185
+ "version": "v52",
186
+ "sha": "826349376241",
187
+ "date": "2026-08-23",
188
+ "subject": "release v52"
189
+ },
190
+ {
191
+ "version": "v51",
192
+ "sha": "5740d20fa585",
193
+ "date": "2026-08-23",
194
+ "subject": "release v51"
195
+ },
196
+ {
197
+ "version": "v50",
198
+ "sha": "8027c83d1da6",
199
+ "date": "2026-08-23",
200
+ "subject": "release v50"
201
+ },
202
+ {
203
+ "version": "v49",
204
+ "sha": "9a14c01a48a4",
205
+ "date": "2026-08-23",
206
+ "subject": "release v49"
207
+ },
208
+ {
209
+ "version": "v48",
210
+ "sha": "3c69fd93da7c",
211
+ "date": "2026-08-23",
212
+ "subject": "release v48"
213
+ },
214
+ {
215
+ "version": "v47",
216
+ "sha": "917f9a0eb509",
217
+ "date": "2026-08-23",
218
+ "subject": "release v47"
219
+ },
220
+ {
221
+ "version": "v46",
222
+ "sha": "a8dc531b5078",
223
+ "date": "2026-08-23",
224
+ "subject": "release v46"
225
+ },
226
+ {
227
+ "version": "v45",
228
+ "sha": "0b2b5010d86f",
229
+ "date": "2026-08-23",
230
+ "subject": "release v45"
231
+ },
232
+ {
233
+ "version": "v44",
234
+ "sha": "a7877aaf20ff",
235
+ "date": "2026-08-23",
236
+ "subject": "Hotfix: allow renaming the active Map view"
237
+ },
238
+ {
239
+ "version": "v43",
240
+ "sha": "e2ba4616fa0f",
241
+ "date": "2026-08-23",
242
+ "subject": "release v43"
243
+ },
244
+ {
245
+ "version": "v42",
246
+ "sha": "25b885e6373a",
247
+ "date": "2026-08-23",
248
+ "subject": "release v42"
249
+ },
250
+ {
251
+ "version": "v41",
252
+ "sha": "1d6adcc3c3ac",
253
+ "date": "2026-08-22",
254
+ "subject": "v41 vertical route navigation"
255
+ },
256
+ {
257
+ "version": "v40",
258
+ "sha": "1451837168f3",
259
+ "date": "2026-08-22",
260
+ "subject": "release v40 route UI correction"
261
+ },
262
+ {
263
+ "version": "v39",
264
+ "sha": "a78bdf00e38e",
265
+ "date": "2026-08-21",
266
+ "subject": "W39 clean stale migration targets"
267
+ },
268
+ {
269
+ "version": "v38",
270
+ "sha": "a556631cf979",
271
+ "date": "2026-08-21",
272
+ "subject": "W39 reversible Live store cutover"
273
+ },
274
+ {
275
+ "version": "v37",
276
+ "sha": "1ddd8cf82379",
277
+ "date": "2026-08-21",
278
+ "subject": "W39: coalesce derived workspace reads"
279
+ },
280
+ {
281
+ "version": "v36",
282
+ "sha": "51db3b7fee2c",
283
+ "date": "2026-08-21",
284
+ "subject": "W39 share-field oid repair"
285
+ },
286
+ {
287
+ "version": "v35",
288
+ "sha": "0f642129c8f7",
289
+ "date": "2026-08-21",
290
+ "subject": "W39 visual QA fixture"
291
+ },
292
+ {
293
+ "version": "v34",
294
+ "sha": "cb4caa188e05",
295
+ "date": "2026-08-21",
296
+ "subject": "W39 Staging PostgreSQL egress controls"
297
+ },
298
+ {
299
+ "version": "v33",
300
+ "sha": "2b115e573d6a",
301
+ "date": "2026-08-21",
302
+ "subject": "W39: stop nonproduction Postgres background egress"
303
+ },
304
+ {
305
+ "version": "v32",
306
+ "sha": "b47b27ca7b2a",
307
+ "date": "2026-08-21",
308
+ "subject": "W39: repair Staging Postgres projection"
309
+ },
310
+ {
311
+ "version": "v31",
312
+ "sha": "8880a49a244e",
313
+ "date": "2026-08-21",
314
+ "subject": "v31: Wave 39 staging candidate"
315
+ },
316
+ {
317
+ "version": "v30",
318
+ "sha": "71776ca6c8df",
319
+ "date": "2026-08-20",
320
+ "subject": "v30: W39-T29 Member-owned View first-share hotfix"
321
+ },
322
+ {
323
+ "version": "v29",
324
+ "sha": "55ced5018ff2",
325
+ "date": "2026-08-18",
326
+ "subject": "v29: the build staging has been running since 2026-08-18 (55ced50)."
327
+ },
328
+ {
329
+ "version": "v28",
330
+ "sha": "2793e4ba53dc",
331
+ "date": "2026-08-18",
332
+ "subject": "release v28"
333
+ },
334
+ {
335
+ "version": "v27",
336
+ "sha": "c05a794837fc",
337
+ "date": "2026-08-18",
338
+ "subject": "release v27"
339
+ },
340
+ {
341
+ "version": "v25",
342
+ "sha": "bc248295ed66",
343
+ "date": "2026-08-14",
344
+ "subject": "v25 - wave 32's LIVE build (deployed 2026-08-13, bc24829)"
345
+ },
346
+ {
347
+ "version": "v26",
348
+ "sha": "6a642e139cfa",
349
+ "date": "2026-08-14",
350
+ "subject": "v26 - wave 33's build (deployed 2026-08-14, 6a642e1)"
351
+ },
352
+ {
353
+ "version": "v24",
354
+ "sha": "514d8292ce73",
355
+ "date": "2026-08-09",
356
+ "subject": "release v24"
357
+ },
358
+ {
359
+ "version": "v23",
360
+ "sha": "44cc28380fca",
361
+ "date": "2026-08-09",
362
+ "subject": "release v23"
363
+ },
364
+ {
365
+ "version": "v22",
366
+ "sha": "f14e199ff32f",
367
+ "date": "2026-08-09",
368
+ "subject": "release v22"
369
+ },
370
+ {
371
+ "version": "v21",
372
+ "sha": "5fdffce8b558",
373
+ "date": "2026-08-09",
374
+ "subject": "release v21"
375
+ },
376
+ {
377
+ "version": "v20",
378
+ "sha": "442e4a1430a7",
379
+ "date": "2026-08-09",
380
+ "subject": "release v20"
381
+ },
382
+ {
383
+ "version": "v19",
384
+ "sha": "94cb4a4dfdfe",
385
+ "date": "2026-08-09",
386
+ "subject": "release v19"
387
+ },
388
+ {
389
+ "version": "v18",
390
+ "sha": "0106ef949805",
391
+ "date": "2026-08-09",
392
+ "subject": "release v18"
393
+ },
394
+ {
395
+ "version": "v17",
396
+ "sha": "308240cc75e8",
397
+ "date": "2026-08-09",
398
+ "subject": "release v17"
399
+ },
400
+ {
401
+ "version": "v16",
402
+ "sha": "a804df54430f",
403
+ "date": "2026-08-09",
404
+ "subject": "release v16"
405
+ },
406
+ {
407
+ "version": "v15",
408
+ "sha": "6b84d7264c81",
409
+ "date": "2026-08-09",
410
+ "subject": "release v15"
411
+ },
412
+ {
413
+ "version": "v14",
414
+ "sha": "bee5eaf5b5cb",
415
+ "date": "2026-08-07",
416
+ "subject": "release v14"
417
+ },
418
+ {
419
+ "version": "v13",
420
+ "sha": "314c0e368b1d",
421
+ "date": "2026-08-06",
422
+ "subject": "release v13"
423
+ },
424
+ {
425
+ "version": "v12",
426
+ "sha": "4908f399785d",
427
+ "date": "2026-08-06",
428
+ "subject": "release v12"
429
+ },
430
+ {
431
+ "version": "v11",
432
+ "sha": "312661712b98",
433
+ "date": "2026-08-05",
434
+ "subject": "release v11"
435
+ },
436
+ {
437
+ "version": "v10",
438
+ "sha": "43f804287496",
439
+ "date": "2026-08-05",
440
+ "subject": "release v10"
441
+ },
442
+ {
443
+ "version": "v9",
444
+ "sha": "2e26f57396b1",
445
+ "date": "2026-08-05",
446
+ "subject": "release v9"
447
+ },
448
+ {
449
+ "version": "v8",
450
+ "sha": "8073b3ecbac3",
451
+ "date": "2026-08-05",
452
+ "subject": "release v8"
453
+ },
454
+ {
455
+ "version": "v7",
456
+ "sha": "b1c5a7e9b848",
457
+ "date": "2026-08-05",
458
+ "subject": "release v7"
459
+ },
460
+ {
461
+ "version": "v6",
462
+ "sha": "a344020f114a",
463
+ "date": "2026-08-05",
464
+ "subject": "release v6"
465
+ },
466
+ {
467
+ "version": "v5",
468
+ "sha": "c0b0fbb40a7b",
469
+ "date": "2026-08-05",
470
+ "subject": "release v5"
471
+ },
472
+ {
473
+ "version": "v4",
474
+ "sha": "de5037ff1c8f",
475
+ "date": "2026-08-05",
476
+ "subject": "release v4"
477
+ },
478
+ {
479
+ "version": "v3",
480
+ "sha": "6b9fa62d93e8",
481
+ "date": "2026-08-05",
482
+ "subject": "release v3"
483
+ },
484
+ {
485
+ "version": "v2",
486
+ "sha": "fd0586199858",
487
+ "date": "2026-08-04",
488
+ "subject": "release v2"
489
+ },
490
+ {
491
+ "version": "v1",
492
+ "sha": "5b4e2c4bc3f3",
493
+ "date": "2026-08-04",
494
+ "subject": "release v1"
495
  }
496
  ]
497
  }
VERSION CHANGED
@@ -1 +1 @@
1
- v84 (7bb3a2e09e)
 
1
+ f75ce5527c (f75ce5527c67)
api/main.py CHANGED
@@ -2128,6 +2128,16 @@ def _resolve_resync_cadence():
2128
  "manual": manual, "disagreement": disagreement}
2129
 
2130
 
 
 
 
 
 
 
 
 
 
 
2131
  # All import-time refusals run before any boot or resync thread can start.
2132
  _assert_contract_floor()
2133
  STORE_GUARDS = _assert_store_guards()
@@ -2375,6 +2385,17 @@ def _resync_memory_write(pass_at, full_rebuild_at, fingerprints, pulls=None):
2375
  "the next restart rebuilds in full")
2376
 
2377
 
 
 
 
 
 
 
 
 
 
 
 
2378
  def _resync_confirm_fresh(tenant, cadence_seconds):
2379
  """A pass that proved the mirror equals the last apply is a good sync: stamp both freshness
2380
  readers (the connector's `lastGoodSyncAt` and the per-database health), in two writes."""
@@ -2471,6 +2492,9 @@ def _store_resync_loop():
2471
  last_full_pass_at = _t.time()
2472
  # The least time between two desk-only passes of an Amazon first-load continuation.
2473
  desk_min_spacing_seconds = 30.0
 
 
 
2474
  while True:
2475
  # ⭐⭐ WAVE 32 · OWNER ITEM 11 / R11 — THE TENANT'S OWN CADENCE, NOT A HARDCODED 1800.
2476
  #
@@ -2539,8 +2563,11 @@ def _store_resync_loop():
2539
  # so staging served a provably stale customer population for its first hour. Subsequent
2540
  # passes still sleep at the freshly resolved cadence, and manual still skips only Odoo.
2541
  # The wait is now interruptible so an administrator's Sync now wakes this writer.
 
 
 
2542
  _woken = False
2543
- if passes:
2544
  # The wait is what remains of the cadence since the last scheduled pass STARTED, so
2545
  # continuations can never postpone the scheduled pass. HOTFIX 2026-09-29: after a
2546
  # full pass too, so passes start a day apart however long the pass ran (a daily pass
@@ -2549,13 +2576,32 @@ def _store_resync_loop():
2549
  _woken = bool(connector_sync.sync_wake_event().wait(
2550
  max(0.0, _every - (_t.time() - last_full_pass_at))))
2551
  connector_sync.sync_wake_event().clear()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2552
  # ⛔⛔ HOTFIX 2026-09-29 — A RESTART INSIDE THE DAILY WINDOW IS NOT A SYNC. The owner
2553
  # capped syncing at once a day, and a deploy is not a reason to sync again. So the first
2554
  # pass after a boot that lands within one cadence of the last scheduled pass only catches
2555
  # the disposable DuckDB mirror up (Odoo reads, no store; the dashboards read it, W58) and
2556
  # restores Amazon's saved mirror. The store-touching half (Meta and Amazon vendor pulls,
2557
  # the relational rebuild) waits for the pass that is actually due.
2558
- _boot_catch_up = ((not passes or catch_up_retries)
 
2559
  and _resync_boot_recent(last_good_pass_at, _t.time(), _every))
2560
  # ⛔⛔ HOTFIX 2026-09-24 — A DESK WAKE IS NOT A SCHEDULED PASS.
2561
  # An Amazon first load requeues itself after every bounded chunk, and each requeue SETS the
@@ -2565,7 +2611,7 @@ def _store_resync_loop():
2565
  # minutes for the 3+ hours of a first load, which restarts on every deploy, against a
2566
  # 4-hour cadence. So a wake before the cadence is due drains the desk and projects ONLY
2567
  # what the desk finished; an Odoo Sync now still gets the full pass it asked for.
2568
- if _woken and _t.time() - last_full_pass_at < _every:
2569
  _desk = {}
2570
  _desk_started = _t.time()
2571
  if not _run_sync_requests(_desk):
@@ -2577,8 +2623,27 @@ def _store_resync_loop():
2577
  _odoo_requested = True
2578
  else:
2579
  _odoo_requested = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2580
  passes += 1
2581
  last_full_pass_at = _t.time()
 
 
 
 
2582
  if _odoo_requested is None:
2583
  _odoo_requested = _run_sync_requests()
2584
  _warm_generation = _sheet_warm_generation()
 
2128
  "manual": manual, "disagreement": disagreement}
2129
 
2130
 
2131
+ def _resolve_resync_slot():
2132
+ """H73: this tenant's daily Odoo slot `{"at", "tz"}`, or None (manual, none set, any error)."""
2133
+ try:
2134
+ import odoo_relational as _rel_slot
2135
+ from harness import runtime as _rt_slot
2136
+ return _rel_slot.sync_slot(_rel_slot.read_config(_rt_slot.get_runtime(_resync_tenant()[0])))
2137
+ except Exception: # noqa: BLE001
2138
+ return None
2139
+
2140
+
2141
  # All import-time refusals run before any boot or resync thread can start.
2142
  _assert_contract_floor()
2143
  STORE_GUARDS = _assert_store_guards()
 
2385
  "the next restart rebuilds in full")
2386
 
2387
 
2388
+ def _resync_slot_pass_write(at):
2389
+ """H73: persist the start of a daily-slot pass. Best effort: a lost write repeats it once."""
2390
+ try:
2391
+ import odoo_relational as _rel_slot
2392
+ from harness import runtime as _runtime_slot
2393
+ _rel_slot.record_slot_pass(_runtime_slot.get_runtime(_resync_tenant()[0]), at)
2394
+ except Exception as e: # noqa: BLE001
2395
+ print(f"[aios-api] store resync slot stamp not saved ({type(e).__name__}); "
2396
+ "a restart before the next slot may run this one again")
2397
+
2398
+
2399
  def _resync_confirm_fresh(tenant, cadence_seconds):
2400
  """A pass that proved the mirror equals the last apply is a good sync: stamp both freshness
2401
  readers (the connector's `lastGoodSyncAt` and the per-database health), in two writes."""
 
2492
  last_full_pass_at = _t.time()
2493
  # The least time between two desk-only passes of an Amazon first-load continuation.
2494
  desk_min_spacing_seconds = 30.0
2495
+ # H73: the start of the last daily-slot pass, and whether the boot restore already ran.
2496
+ last_slot_pass_at = _memory.get("slotPassAt")
2497
+ slot_restored = False
2498
  while True:
2499
  # ⭐⭐ WAVE 32 · OWNER ITEM 11 / R11 — THE TENANT'S OWN CADENCE, NOT A HARDCODED 1800.
2500
  #
 
2563
  # so staging served a provably stale customer population for its first hour. Subsequent
2564
  # passes still sleep at the freshly resolved cadence, and manual still skips only Odoo.
2565
  # The wait is now interruptible so an administrator's Sync now wakes this writer.
2566
+ # H73: a tenant with a daily wall-clock slot reads Odoo only when that slot is due.
2567
+ # Looked up by name so loop fixtures that list main.py defs by hand keep running slotless.
2568
+ _slot = (globals().get("_resolve_resync_slot") or (lambda: None))()
2569
  _woken = False
2570
+ if passes and _slot is None:
2571
  # The wait is what remains of the cadence since the last scheduled pass STARTED, so
2572
  # continuations can never postpone the scheduled pass. HOTFIX 2026-09-29: after a
2573
  # full pass too, so passes start a day apart however long the pass ran (a daily pass
 
2576
  _woken = bool(connector_sync.sync_wake_event().wait(
2577
  max(0.0, _every - (_t.time() - last_full_pass_at))))
2578
  connector_sync.sync_wake_event().clear()
2579
+ _slot_due = False
2580
+ if _slot is not None:
2581
+ import odoo_relational as _rel_slot
2582
+ _slot_seen = [at for at in (last_slot_pass_at, last_good_pass_at) if at is not None]
2583
+ last_slot_pass_at = max(_slot_seen) if _slot_seen else None
2584
+ if passes or slot_restored:
2585
+ # Sleep to one second past the next slot; Sync now still interrupts the wait.
2586
+ _slot_now = _t.time()
2587
+ _woken = bool(connector_sync.sync_wake_event().wait(
2588
+ 0.0 if _rel_slot.slot_due(_slot_now, _slot, last_slot_pass_at)
2589
+ else max(0.0, _rel_slot.slot_after(_slot_now, _slot) + 1.0 - _slot_now)))
2590
+ connector_sync.sync_wake_event().clear()
2591
+ _slot_now = _t.time()
2592
+ _slot_due = _rel_slot.slot_due(_slot_now, _slot, last_slot_pass_at)
2593
+ # The scheduled pass after the one this cycle may run.
2594
+ RESYNC_STATE["nextPassAt"] = _rel_slot.slot_iso(_rel_slot.slot_after(_slot_now, _slot))
2595
+ else:
2596
+ RESYNC_STATE.pop("nextPassAt", None)
2597
  # ⛔⛔ HOTFIX 2026-09-29 — A RESTART INSIDE THE DAILY WINDOW IS NOT A SYNC. The owner
2598
  # capped syncing at once a day, and a deploy is not a reason to sync again. So the first
2599
  # pass after a boot that lands within one cadence of the last scheduled pass only catches
2600
  # the disposable DuckDB mirror up (Odoo reads, no store; the dashboards read it, W58) and
2601
  # restores Amazon's saved mirror. The store-touching half (Meta and Amazon vendor pulls,
2602
  # the relational rebuild) waits for the pass that is actually due.
2603
+ # H73: never in slot mode, because the catch-up itself reads Odoo.
2604
+ _boot_catch_up = (_slot is None and (not passes or catch_up_retries)
2605
  and _resync_boot_recent(last_good_pass_at, _t.time(), _every))
2606
  # ⛔⛔ HOTFIX 2026-09-24 — A DESK WAKE IS NOT A SCHEDULED PASS.
2607
  # An Amazon first load requeues itself after every bounded chunk, and each requeue SETS the
 
2611
  # minutes for the 3+ hours of a first load, which restarts on every deploy, against a
2612
  # 4-hour cadence. So a wake before the cadence is due drains the desk and projects ONLY
2613
  # what the desk finished; an Odoo Sync now still gets the full pass it asked for.
2614
+ if _woken and (_t.time() - last_full_pass_at < _every if _slot is None else not _slot_due):
2615
  _desk = {}
2616
  _desk_started = _t.time()
2617
  if not _run_sync_requests(_desk):
 
2623
  _odoo_requested = True
2624
  else:
2625
  _odoo_requested = None
2626
+ if _slot is not None and not _slot_due and _odoo_requested is None:
2627
+ # H73: outside the slot no Odoo call is made. Serve the stored mirror, drain the desk.
2628
+ _desk = {}
2629
+ if _run_sync_requests(_desk):
2630
+ _odoo_requested = True
2631
+ else:
2632
+ _project_desk(_desk, _cad["tenant"])
2633
+ if not slot_restored:
2634
+ _pull_amazon("boot", False)
2635
+ # The restored mirror warms the workbooks once; Sheet warm reads only the mirror.
2636
+ _sheet_warm_after_pass(_cad["tenant"], True, None, True)
2637
+ slot_restored = True
2638
+ print(f"[aios-api] store resync: no Odoo pass outside the daily slot; the next one "
2639
+ f"runs at {RESYNC_STATE['nextPassAt']} ({_slot['at']} {_slot['tz']})")
2640
+ continue
2641
  passes += 1
2642
  last_full_pass_at = _t.time()
2643
+ if _slot is not None and _slot_due:
2644
+ # H73: stamp the slot BEFORE any Odoo read, so a restart mid-pass never runs it twice.
2645
+ last_slot_pass_at = last_full_pass_at
2646
+ (globals().get("_resync_slot_pass_write") or (lambda _at: None))(last_full_pass_at)
2647
  if _odoo_requested is None:
2648
  _odoo_requested = _run_sync_requests()
2649
  _warm_generation = _sheet_warm_generation()
api/odoo_relational.py CHANGED
@@ -5273,6 +5273,34 @@ SYNC_PRESETS = {"daily": 86400, "manual": None}
5273
  SYNC_FLOOR_SECONDS = 86400
5274
  DEFAULT_SYNC = "daily"
5275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5276
 
5277
  def read_config(rt):
5278
  """This tenant's stored connector config, defaulted. Never raises — a store hiccup must not
@@ -5284,10 +5312,21 @@ def read_config(rt):
5284
  cur = cur if isinstance(cur, dict) else {}
5285
  grids = cur.get("grids") if isinstance(cur.get("grids"), dict) else {}
5286
  every = cur.get("syncEvery")
 
 
 
 
 
 
 
 
 
 
5287
  return {"grids": {str(k): bool(v) for k, v in grids.items()},
5288
  "syncEvery": every if every in SYNC_PRESETS else DEFAULT_SYNC,
5289
  "frozen": bool(cur.get("frozen")),
5290
- "frozenAt": str(cur.get("frozenAt") or "")}
 
5291
 
5292
 
5293
  def grid_choices(rt, connection_id=None):
@@ -5372,6 +5411,72 @@ def sync_seconds(rt):
5372
  return max(int(secs), SYNC_FLOOR_SECONDS)
5373
 
5374
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5375
  #: ⭐⭐ S67-T20 / C4 — how far past its cadence a sync may run before its data is called stale.
5376
  #: Two hours of grace on top of the interval: a daily sync is stale after 26 hours (C4's number),
5377
  #: long enough that one slow pass does not raise a warning and short enough that a dead sync is
@@ -5484,7 +5589,7 @@ def decode_fingerprints(stored):
5484
  def read_resync_memory(rt):
5485
  """What the last container's resync loop knew, or empty values. Never raises."""
5486
  empty = {"passAt": None, "fullRebuildAt": None, "fingerprints": None, "lastGoodSyncAt": None,
5487
- "pulls": None}
5488
  try:
5489
  cur = rt.get(CONFIG_KEY) if rt is not None else None
5490
  except Exception: # noqa: BLE001
@@ -5498,7 +5603,8 @@ def read_resync_memory(rt):
5498
  "fingerprints": decode_fingerprints(memory.get("fingerprints")),
5499
  "lastGoodSyncAt": _memory_epoch(cur.get("lastGoodSyncAt")),
5500
  "pulls": ({str(k): _memory_epoch(v) for k, v in pulls.items()}
5501
- if isinstance(pulls, dict) and pulls else None)}
 
5502
 
5503
 
5504
  def record_resync_memory(rt, *, pass_at, full_rebuild_at, fingerprints, pulls=None):
@@ -5515,6 +5621,10 @@ def record_resync_memory(rt, *, pass_at, full_rebuild_at, fingerprints, pulls=No
5515
 
5516
  def _up(cur):
5517
  cur = dict(cur) if isinstance(cur, dict) else {}
 
 
 
 
5518
  cur[RESYNC_MEMORY_FIELD] = memory
5519
  return cur
5520
 
@@ -5522,6 +5632,23 @@ def record_resync_memory(rt, *, pass_at, full_rebuild_at, fingerprints, pulls=No
5522
  return memory
5523
 
5524
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5525
  def _effective_sync_seconds(preset):
5526
  """The interval a sync can actually keep: the tenant's preset, floored, and never faster than
5527
  the deployment's own resync floor (`AIOS_STORE_RESYNC_SECONDS`), which `main.py` applies with
@@ -5549,6 +5676,12 @@ def sync_freshness(rt, now=None):
5549
  the last run's own reason, its code prefix removed, when that run ended in error.
5550
  """
5551
  now = now or _utc_now()
 
 
 
 
 
 
5552
  try:
5553
  raw = rt.get(CONFIG_KEY) if rt is not None else None
5554
  except Exception: # noqa: BLE001
@@ -5583,7 +5716,9 @@ def sync_freshness(rt, now=None):
5583
  return {"stale": bool(stale), "lastGoodSyncAt": last_good,
5584
  "schedule": cfg["syncEvery"], "staleAfterSeconds": allowed,
5585
  "lastRunAt": status.get("lastRun") or None, "phase": phase,
5586
- "frozen": cfg["frozen"], "failure": failure}
 
 
5587
 
5588
 
5589
  def frozen(rt):
 
5273
  SYNC_FLOOR_SECONDS = 86400
5274
  DEFAULT_SYNC = "daily"
5275
 
5276
+ #: H73 (owner): "i want it to sync at 1 pm Jakarta time." Tenant #0's daily slot when none is stored.
5277
+ TENANT0_SYNC_AT = "13:00"
5278
+ TENANT0_SYNC_TZ = "Asia/Jakarta"
5279
+ import re as _re_sync_at # noqa: E402 (kept beside the cadence code it serves)
5280
+ _SYNC_AT_RE = _re_sync_at.compile(r"^([01]\d|2[0-3]):[0-5]\d$")
5281
+
5282
+
5283
+ def valid_sync_at(value):
5284
+ """True when `value` is a 24-hour "HH:MM" wall-clock time."""
5285
+ return isinstance(value, str) and bool(_SYNC_AT_RE.match(value))
5286
+
5287
+
5288
+ def sync_zone(name):
5289
+ """The `zoneinfo` zone for an IANA name, or None when it does not load."""
5290
+ if not isinstance(name, str) or not name.strip():
5291
+ return None
5292
+ try:
5293
+ from zoneinfo import ZoneInfo
5294
+ return ZoneInfo(name.strip())
5295
+ except Exception: # noqa: BLE001
5296
+ return None
5297
+
5298
+
5299
+ def _tenant0_runtime(rt):
5300
+ """Tenant #0 by the runtime's own slug. A runtime with no slug is never tenant #0 here."""
5301
+ key = getattr(rt, "key", None)
5302
+ return isinstance(key, str) and bool(key.strip()) and is_royal(key)
5303
+
5304
 
5305
  def read_config(rt):
5306
  """This tenant's stored connector config, defaulted. Never raises — a store hiccup must not
 
5312
  cur = cur if isinstance(cur, dict) else {}
5313
  grids = cur.get("grids") if isinstance(cur.get("grids"), dict) else {}
5314
  every = cur.get("syncEvery")
5315
+ # A stored invalid value reads as absent; tenant #0 falls back field by field to its default.
5316
+ at = cur.get("syncAt") if valid_sync_at(cur.get("syncAt")) else None
5317
+ tz = cur.get("syncTz") if sync_zone(cur.get("syncTz")) is not None else None
5318
+ try:
5319
+ if _tenant0_runtime(rt):
5320
+ at, tz = at or TENANT0_SYNC_AT, tz or TENANT0_SYNC_TZ
5321
+ except Exception: # noqa: BLE001
5322
+ pass
5323
+ if at is None or tz is None:
5324
+ at = tz = None
5325
  return {"grids": {str(k): bool(v) for k, v in grids.items()},
5326
  "syncEvery": every if every in SYNC_PRESETS else DEFAULT_SYNC,
5327
  "frozen": bool(cur.get("frozen")),
5328
+ "frozenAt": str(cur.get("frozenAt") or ""),
5329
+ "syncAt": at, "syncTz": tz}
5330
 
5331
 
5332
  def grid_choices(rt, connection_id=None):
 
5411
  return max(int(secs), SYNC_FLOOR_SECONDS)
5412
 
5413
 
5414
+ # H73: the daily wall-clock slot. Every helper takes `now` as an epoch float and never reads the
5415
+ # clock, so the resident loop's fake clock drives them.
5416
+ def sync_slot(cfg):
5417
+ """`{"at", "tz"}` for a config with a valid daily slot, else None (manual or no valid pair)."""
5418
+ try:
5419
+ if not isinstance(cfg, dict) or cfg.get("syncEvery") == "manual":
5420
+ return None
5421
+ at, tz = cfg.get("syncAt"), cfg.get("syncTz")
5422
+ if not valid_sync_at(at) or sync_zone(tz) is None:
5423
+ return None
5424
+ return {"at": at, "tz": tz.strip()}
5425
+ except Exception: # noqa: BLE001
5426
+ return None
5427
+
5428
+
5429
+ def _slot_on(day, slot, zone):
5430
+ """The epoch of `slot` on local calendar `day`, built from the wall time so DST holds."""
5431
+ hour, minute = (int(part) for part in slot["at"].split(":"))
5432
+ return _dt.datetime(day.year, day.month, day.day, hour, minute, tzinfo=zone).timestamp()
5433
+
5434
+
5435
+ def slot_before(now, slot):
5436
+ """The latest occurrence of the slot at or before epoch `now`."""
5437
+ zone = sync_zone(slot["tz"])
5438
+ day = _dt.datetime.fromtimestamp(float(now), zone).date()
5439
+ for back in range(4):
5440
+ at = _slot_on(day - _dt.timedelta(days=back), slot, zone)
5441
+ if at <= float(now):
5442
+ return at
5443
+ raise ValueError("no slot occurrence found")
5444
+
5445
+
5446
+ def slot_after(now, slot):
5447
+ """The first occurrence of the slot strictly after epoch `now`."""
5448
+ zone = sync_zone(slot["tz"])
5449
+ day = _dt.datetime.fromtimestamp(float(now), zone).date()
5450
+ for ahead in range(4):
5451
+ at = _slot_on(day + _dt.timedelta(days=ahead), slot, zone)
5452
+ if at > float(now):
5453
+ return at
5454
+ raise ValueError("no slot occurrence found")
5455
+
5456
+
5457
+ def slot_due(now, slot, last_pass_at):
5458
+ """True when no pass has started since the latest slot occurrence."""
5459
+ return last_pass_at is None or float(last_pass_at) < slot_before(now, slot)
5460
+
5461
+
5462
+ def slot_iso(epoch):
5463
+ """An epoch as ISO UTC with a `Z`, the shape `nextSyncAt` speaks."""
5464
+ # isoformat, not strftime: strftime reads the `time` module, which the loop's tests replace.
5465
+ at = _dt.datetime.fromtimestamp(float(epoch), _dt.timezone.utc).replace(microsecond=0)
5466
+ return at.isoformat().replace("+00:00", "Z")
5467
+
5468
+
5469
+ def next_sync_at(cfg, now):
5470
+ """The next scheduled Odoo pass as ISO UTC, or None without a slot. Never raises."""
5471
+ slot = sync_slot(cfg)
5472
+ if slot is None:
5473
+ return None
5474
+ try:
5475
+ return slot_iso(slot_after(float(now), slot))
5476
+ except Exception: # noqa: BLE001
5477
+ return None
5478
+
5479
+
5480
  #: ⭐⭐ S67-T20 / C4 — how far past its cadence a sync may run before its data is called stale.
5481
  #: Two hours of grace on top of the interval: a daily sync is stale after 26 hours (C4's number),
5482
  #: long enough that one slow pass does not raise a warning and short enough that a dead sync is
 
5589
  def read_resync_memory(rt):
5590
  """What the last container's resync loop knew, or empty values. Never raises."""
5591
  empty = {"passAt": None, "fullRebuildAt": None, "fingerprints": None, "lastGoodSyncAt": None,
5592
+ "pulls": None, "slotPassAt": None}
5593
  try:
5594
  cur = rt.get(CONFIG_KEY) if rt is not None else None
5595
  except Exception: # noqa: BLE001
 
5603
  "fingerprints": decode_fingerprints(memory.get("fingerprints")),
5604
  "lastGoodSyncAt": _memory_epoch(cur.get("lastGoodSyncAt")),
5605
  "pulls": ({str(k): _memory_epoch(v) for k, v in pulls.items()}
5606
+ if isinstance(pulls, dict) and pulls else None),
5607
+ "slotPassAt": _memory_epoch(memory.get("slotPassAt"))}
5608
 
5609
 
5610
  def record_resync_memory(rt, *, pass_at, full_rebuild_at, fingerprints, pulls=None):
 
5621
 
5622
  def _up(cur):
5623
  cur = dict(cur) if isinstance(cur, dict) else {}
5624
+ # H73: the slot stamp is written by `record_slot_pass` alone, so a whole-dict write keeps it.
5625
+ prior = cur.get(RESYNC_MEMORY_FIELD)
5626
+ if isinstance(prior, dict) and prior.get("slotPassAt"):
5627
+ memory["slotPassAt"] = prior["slotPassAt"]
5628
  cur[RESYNC_MEMORY_FIELD] = memory
5629
  return cur
5630
 
 
5632
  return memory
5633
 
5634
 
5635
+ def record_slot_pass(rt, at):
5636
+ """Merge `slotPassAt` (ISO) into the resync memory: the start of the last slot pass."""
5637
+ stamp = (_dt.datetime.fromtimestamp(float(at), _dt.timezone.utc).isoformat()
5638
+ if isinstance(at, (int, float)) else str(at))
5639
+
5640
+ def _up(cur):
5641
+ cur = dict(cur) if isinstance(cur, dict) else {}
5642
+ memory = cur.get(RESYNC_MEMORY_FIELD)
5643
+ memory = dict(memory) if isinstance(memory, dict) else {}
5644
+ memory["slotPassAt"] = stamp
5645
+ cur[RESYNC_MEMORY_FIELD] = memory
5646
+ return cur
5647
+
5648
+ rt.update(CONFIG_KEY, _up, flush="sync")
5649
+ return stamp
5650
+
5651
+
5652
  def _effective_sync_seconds(preset):
5653
  """The interval a sync can actually keep: the tenant's preset, floored, and never faster than
5654
  the deployment's own resync floor (`AIOS_STORE_RESYNC_SECONDS`), which `main.py` applies with
 
5676
  the last run's own reason, its code prefix removed, when that run ended in error.
5677
  """
5678
  now = now or _utc_now()
5679
+ if isinstance(now, str):
5680
+ now = _parse_iso(now) or _utc_now()
5681
+ elif isinstance(now, (int, float)):
5682
+ now = _dt.datetime.fromtimestamp(float(now), _dt.timezone.utc)
5683
+ elif now.tzinfo is None:
5684
+ now = now.replace(tzinfo=_dt.timezone.utc)
5685
  try:
5686
  raw = rt.get(CONFIG_KEY) if rt is not None else None
5687
  except Exception: # noqa: BLE001
 
5716
  return {"stale": bool(stale), "lastGoodSyncAt": last_good,
5717
  "schedule": cfg["syncEvery"], "staleAfterSeconds": allowed,
5718
  "lastRunAt": status.get("lastRun") or None, "phase": phase,
5719
+ "frozen": cfg["frozen"], "failure": failure,
5720
+ "syncAt": cfg["syncAt"], "syncTz": cfg["syncTz"],
5721
+ "nextSyncAt": None if cfg["frozen"] else next_sync_at(cfg, now.timestamp())}
5722
 
5723
 
5724
  def frozen(rt):
api/routes_connectors.py CHANGED
@@ -2813,6 +2813,9 @@ def odoo_status(connection_id: str = None, session: Session = Depends(require_se
2813
  rt = _odoo_status_reads(session.runtime)
2814
  resolved_connection = _odoo_connection_slot(rt, connection_id)
2815
  cfg = odoo_relational.read_config(rt)
 
 
 
2816
  stored = rt.get(_ODOO_SYNC_STATUS) or {}
2817
  errors = stored.get("errors") if isinstance(stored.get("errors"), list) else []
2818
  phase = str(stored.get("phase") or "unknown")
@@ -2839,7 +2842,7 @@ def odoo_status(connection_id: str = None, session: Session = Depends(require_se
2839
  "errors": [dispatch_failure["message"], *(durable.get("errors") or [])][:20],
2840
  "errorsTotal": durable.get("errorsTotal", 0) + 1}
2841
  if durable:
2842
- return {"schedule": cfg.get("syncEvery"),
2843
  "health": "paused" if cfg.get("frozen") else durable["state"],
2844
  "lastRun": durable["at"], "frozen": cfg.get("frozen") is True,
2845
  **durable, "stateAt": durable["at"], "connectionId": resolved_connection,
@@ -2864,7 +2867,7 @@ def odoo_status(connection_id: str = None, session: Session = Depends(require_se
2864
  shown_errors = [dispatch_failure["message"], *shown_errors]
2865
  shown_phase, state = "error", "error"
2866
  errors_total += 1
2867
- return {"schedule": cfg.get("syncEvery"),
2868
  "health": "paused" if cfg.get("frozen") else
2869
  shown_phase if named else "error" if shown_errors else shown_phase,
2870
  "lastRun": shown_last_run, "errors": shown_errors[:20],
 
2813
  rt = _odoo_status_reads(session.runtime)
2814
  resolved_connection = _odoo_connection_slot(rt, connection_id)
2815
  cfg = odoo_relational.read_config(rt)
2816
+ # H73: the daily slot and the next scheduled pass, computed from config, never from the loop.
2817
+ slot = {"syncAt": cfg.get("syncAt"), "syncTz": cfg.get("syncTz"),
2818
+ "nextSyncAt": None if cfg.get("frozen") else odoo_relational.next_sync_at(cfg, time.time())}
2819
  stored = rt.get(_ODOO_SYNC_STATUS) or {}
2820
  errors = stored.get("errors") if isinstance(stored.get("errors"), list) else []
2821
  phase = str(stored.get("phase") or "unknown")
 
2842
  "errors": [dispatch_failure["message"], *(durable.get("errors") or [])][:20],
2843
  "errorsTotal": durable.get("errorsTotal", 0) + 1}
2844
  if durable:
2845
+ return {"schedule": cfg.get("syncEvery"), **slot,
2846
  "health": "paused" if cfg.get("frozen") else durable["state"],
2847
  "lastRun": durable["at"], "frozen": cfg.get("frozen") is True,
2848
  **durable, "stateAt": durable["at"], "connectionId": resolved_connection,
 
2867
  shown_errors = [dispatch_failure["message"], *shown_errors]
2868
  shown_phase, state = "error", "error"
2869
  errors_total += 1
2870
+ return {"schedule": cfg.get("syncEvery"), **slot,
2871
  "health": "paused" if cfg.get("frozen") else
2872
  shown_phase if named else "error" if shown_errors else shown_phase,
2873
  "lastRun": shown_last_run, "errors": shown_errors[:20],
api/routes_keychain.py CHANGED
@@ -1432,6 +1432,9 @@ def odoo_config(session: Session = Depends(require_session)):
1432
  "syncOptions": list(rel.SYNC_PRESETS),
1433
  "syncFloorSeconds": rel.SYNC_FLOOR_SECONDS,
1434
  "frozen": cfg["frozen"], "frozenAt": cfg["frozenAt"],
 
 
 
1435
  # ⚠ There is nothing to disconnect FROM when the source is the deployment environment:
1436
  # tenant #0's `.env` is not this tenant's to remove. Said as a field so the client renders
1437
  # no button rather than one that 400s.
@@ -1480,6 +1483,30 @@ def odoo_config_put(body: dict = Body(default=None),
1480
  f"often than once a day is not available at all; the sync interval was "
1481
  f"set to once a day instead")
1482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1483
  server_db = body.get("serverDb")
1484
  if server_db is not None:
1485
  server_db = " ".join(str(server_db).split())[:80]
@@ -1490,6 +1517,13 @@ def odoo_config_put(body: dict = Body(default=None),
1490
  cur.setdefault("grids", {}).update(clean_grids)
1491
  if clean_every is not None:
1492
  cur["syncEvery"] = clean_every
 
 
 
 
 
 
 
1493
  return cur
1494
 
1495
  try:
@@ -1500,6 +1534,16 @@ def odoo_config_put(body: dict = Body(default=None),
1500
  if server_db:
1501
  notes.append(_rewrite_server_db(session, server_db))
1502
 
 
 
 
 
 
 
 
 
 
 
1503
  # ⭐⭐ W33-T65 / W30-R6's SECOND SENTENCE — THE CADENCE IS SET AND ONLY PARTLY OBEYED, AND THE
1504
  # PERSON SETTING IT IS THE ONE WHO HAS TO BE TOLD. Measured, not guessed:
1505
  # · `main.py::_store_resync_loop` reads the interval from `sync_seconds(get_runtime(
 
1432
  "syncOptions": list(rel.SYNC_PRESETS),
1433
  "syncFloorSeconds": rel.SYNC_FLOOR_SECONDS,
1434
  "frozen": cfg["frozen"], "frozenAt": cfg["frozenAt"],
1435
+ # H73: the daily wall-clock slot, and the next scheduled pass (None when manual or frozen).
1436
+ "syncAt": cfg["syncAt"], "syncTz": cfg["syncTz"],
1437
+ "nextSyncAt": None if cfg["frozen"] else rel.next_sync_at(cfg, time.time()),
1438
  # ⚠ There is nothing to disconnect FROM when the source is the deployment environment:
1439
  # tenant #0's `.env` is not this tenant's to remove. Said as a field so the client renders
1440
  # no button rather than one that 400s.
 
1483
  f"often than once a day is not available at all; the sync interval was "
1484
  f"set to once a day instead")
1485
 
1486
+ # H73: the daily sync time. Each key is optional; null or "" clears it. Invalid saves nothing.
1487
+ slot_keys = [k for k in ("syncAt", "syncTz") if k in body]
1488
+ clean_at = clean_tz = None
1489
+ if "syncAt" in body:
1490
+ clean_at = str(body.get("syncAt") or "").strip()
1491
+ if clean_at and not rel.valid_sync_at(clean_at):
1492
+ raise err(400, "invalid_sync_at",
1493
+ "the sync time must be a 24 hour time such as 13:00")
1494
+ if "syncTz" in body:
1495
+ clean_tz = str(body.get("syncTz") or "").strip()
1496
+ if clean_tz and rel.sync_zone(clean_tz) is None:
1497
+ raise err(400, "invalid_sync_tz",
1498
+ "the time zone must be a name such as Asia/Jakarta")
1499
+ if clean_at and not rel.is_royal(session.tenant):
1500
+ try:
1501
+ stored = session.runtime.get(rel.CONFIG_KEY)
1502
+ except Exception: # noqa: BLE001
1503
+ stored = None
1504
+ stored_tz = (stored or {}).get("syncTz") if isinstance(stored, dict) else None
1505
+ tz_after = clean_tz if "syncTz" in body else stored_tz
1506
+ if rel.sync_zone(tz_after) is None:
1507
+ raise err(400, "missing_sync_tz",
1508
+ "choose a time zone for the daily sync time")
1509
+
1510
  server_db = body.get("serverDb")
1511
  if server_db is not None:
1512
  server_db = " ".join(str(server_db).split())[:80]
 
1517
  cur.setdefault("grids", {}).update(clean_grids)
1518
  if clean_every is not None:
1519
  cur["syncEvery"] = clean_every
1520
+ for key, value in (("syncAt", clean_at), ("syncTz", clean_tz)):
1521
+ if key not in slot_keys:
1522
+ continue
1523
+ if value:
1524
+ cur[key] = value
1525
+ else:
1526
+ cur.pop(key, None)
1527
  return cur
1528
 
1529
  try:
 
1534
  if server_db:
1535
  notes.append(_rewrite_server_db(session, server_db))
1536
 
1537
+ if slot_keys:
1538
+ saved = rel.read_config(session.runtime)
1539
+ if not saved["syncAt"]:
1540
+ notes.append("no daily sync time is set, so the sync runs once a day from its last pass")
1541
+ elif saved["syncEvery"] == "manual":
1542
+ notes.append(f"the daily time {saved['syncAt']} {saved['syncTz']} is saved and "
1543
+ f"applies when the sync interval is daily")
1544
+ else:
1545
+ notes.append(f"the Odoo sync runs once a day at {saved['syncAt']} {saved['syncTz']}")
1546
+
1547
  # ⭐⭐ W33-T65 / W30-R6's SECOND SENTENCE — THE CADENCE IS SET AND ONLY PARTLY OBEYED, AND THE
1548
  # PERSON SETTING IT IS THE ONE WHO HAS TO BE TOLD. Measured, not guessed:
1549
  # · `main.py::_store_resync_loop` reads the interval from `sync_seconds(get_runtime(
api/test_odoo_rank_refresh.py CHANGED
@@ -222,7 +222,7 @@ class RankRefreshTests(unittest.TestCase):
222
  nodes = _with_collaborators(source, nodes, ns)
223
  exec(compile(ast.Module(body=nodes, type_ignores=[]),
224
  'main.py:resident-loop', 'exec'), ns)
225
- runtime = SimpleNamespace(get_runtime=lambda *_: object())
226
  from core import connector_sync
227
  # The cadence wait is now an interruptible event, so it is routed to the synthetic clock.
228
  wake = SimpleNamespace(wait=sleep, clear=lambda: None)
@@ -539,7 +539,7 @@ class RankRefreshTests(unittest.TestCase):
539
  _resync_confirm_fresh=lambda *a: events.append(('fresh',) + a))
540
  nodes = _with_collaborators(source, nodes, ns)
541
  exec(compile(ast.Module(body=nodes, type_ignores=[]), 'main.py:daily-loop', 'exec'), ns)
542
- runtime = SimpleNamespace(get_runtime=lambda *_: object())
543
  import harness
544
  from core import connector_sync
545
  wake = SimpleNamespace(wait=sleep, clear=lambda: None)
@@ -747,6 +747,177 @@ class RankRefreshTests(unittest.TestCase):
747
  connect.assert_not_called()
748
  self.assertEqual(self.calls, [])
749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
750
 
751
  if __name__ == '__main__':
752
  unittest.main()
 
222
  nodes = _with_collaborators(source, nodes, ns)
223
  exec(compile(ast.Module(body=nodes, type_ignores=[]),
224
  'main.py:resident-loop', 'exec'), ns)
225
+ runtime = SimpleNamespace(get_runtime=lambda *_: object(), known_tenants=lambda: ())
226
  from core import connector_sync
227
  # The cadence wait is now an interruptible event, so it is routed to the synthetic clock.
228
  wake = SimpleNamespace(wait=sleep, clear=lambda: None)
 
539
  _resync_confirm_fresh=lambda *a: events.append(('fresh',) + a))
540
  nodes = _with_collaborators(source, nodes, ns)
541
  exec(compile(ast.Module(body=nodes, type_ignores=[]), 'main.py:daily-loop', 'exec'), ns)
542
+ runtime = SimpleNamespace(get_runtime=lambda *_: object(), known_tenants=lambda: ())
543
  import harness
544
  from core import connector_sync
545
  wake = SimpleNamespace(wait=sleep, clear=lambda: None)
 
747
  connect.assert_not_called()
748
  self.assertEqual(self.calls, [])
749
 
750
+ # ── H73 (owner): "i want it to sync at 1 pm Jakarta time" ──────────────────────────────────
751
+ class SlotStore:
752
+ """A tenant runtime with a slug and one KV document set."""
753
+ def __init__(self, key, docs=None):
754
+ self.key, self.docs = key, dict(docs or {})
755
+
756
+ def get(self, name, fresh=False):
757
+ return self.docs.get(name)
758
+
759
+ def update(self, name, fn, flush=None):
760
+ self.docs[name] = fn(self.docs.get(name))
761
+
762
+ @staticmethod
763
+ def utc(text):
764
+ from datetime import datetime
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
+ """Drive the real loop and its real slot resolver on a clock that advances at each wait."""
769
+ import odoo_relational as rel
770
+ source = ast.parse(Path(__file__).with_name('main.py').read_text(encoding='utf-8'))
771
+ # The loop reads both slot helpers by name, so they are extracted here explicitly.
772
+ functions = {'_store_resync_loop', '_resync_rebuild_reason', '_meta_rebuild_force_reason',
773
+ '_resync_boot_recent', '_resolve_resync_slot', '_resync_slot_pass_write'}
774
+ nodes = [node for node in source.body
775
+ if isinstance(node, ast.FunctionDef) and node.name in functions
776
+ or isinstance(node, ast.Assign) and any(
777
+ isinstance(target, ast.Name)
778
+ and target.id in ('_RESYNC_REBUILD_MAX_AGE_SECONDS', '_RESYNC_ENTITY_TABLE_KEYS')
779
+ for target in node.targets)]
780
+ now, events, sleeps = [float(boot)], [], []
781
+
782
+ def wait(seconds):
783
+ sleeps.append(seconds)
784
+ if len(sleeps) >= max_sleeps:
785
+ raise StopIteration('bounded synthetic resident loop')
786
+ now[0] += seconds
787
+ return False
788
+
789
+ def sync(manual_flag, passes, entities):
790
+ events.append(('mirror', now[0], manual_flag))
791
+ if manual_flag:
792
+ return None, None, None
793
+ return {'res_partner': {'phase': 'live', 'pulled': 0}}, {}, None
794
+
795
+ store = self.SlotStore(tenant, {rel.CONFIG_KEY: dict(config or {})})
796
+ clock = SimpleNamespace(sleep=wait, time=lambda: now[0],
797
+ strftime=lambda *_: 'synthetic-time', gmtime=lambda: ())
798
+ ns = dict(RESYNC_STATE={'consecutiveFailures': 0}, _RESYNC_NOTICE=[None], _SEED_THREAD=None,
799
+ _configured_mirror_entities=lambda *_: None, freeze_notice=FREEZE_OFF,
800
+ _resolve_resync_cadence=lambda: dict(
801
+ resolvedSeconds=86400, manual=False, tenant=tenant, tenantSource='test',
802
+ tenantSeconds=86400, envSeconds=None, disagreement=None),
803
+ _resync_memory_read=lambda: dict(memory),
804
+ _resync_memory_write=lambda *a: events.append(('memory', now[0])),
805
+ _resync_mirror_pass=sync,
806
+ _capture_resync_source_counts=lambda *_: events.append(('counts', now[0])),
807
+ _resync_source_fingerprints=lambda *_: {'res_partner': (3, 7)},
808
+ _pull_meta=lambda *a: events.append(('meta', now[0])) or True,
809
+ _pull_amazon=lambda *a: events.append(('amazon', now[0]) + a) or True,
810
+ _rebuild_odoo_relational=lambda *a, **k: events.append(('rebuild', now[0])) or True,
811
+ _rebuild_meta_relational=lambda *_a, **_k: {},
812
+ _rebuild_amazon_relational=lambda *_a, **_k: {},
813
+ _resync_confirm_fresh=lambda *a: events.append(('fresh', now[0])))
814
+ nodes = _with_collaborators(source, nodes, ns)
815
+ exec(compile(ast.Module(body=nodes, type_ignores=[]), 'main.py:slot-loop', 'exec'), ns)
816
+ runtime = SimpleNamespace(get_runtime=lambda *_: store, tenant_for_store_path=lambda: tenant,
817
+ known_tenants=lambda: ())
818
+ import harness
819
+ from core import connector_sync
820
+ wake = SimpleNamespace(wait=wait, clear=lambda: None)
821
+ out = io.StringIO()
822
+ with patch.dict(sys.modules, {'time': clock, 'harness.runtime': runtime}), \
823
+ patch.object(harness, 'runtime', runtime, create=True), \
824
+ patch.object(connector_sync, 'sync_wake_event', return_value=wake), \
825
+ patch.object(connector_sync, 'take_sync_requests', return_value=[]), \
826
+ redirect_stdout(out):
827
+ with self.assertRaisesRegex(StopIteration, 'bounded synthetic'):
828
+ ns['_store_resync_loop']()
829
+ self.loop_output = out.getvalue()
830
+ self.net.assert_not_called()
831
+ # No Odoo client read happened anywhere in the loop.
832
+ self.assertEqual(self.calls, [])
833
+ self.slot_state, self.slot_store = ns['RESYNC_STATE'], store
834
+ # Odoo work at the boundary: a mirror pass with Odoo on, and the source count.
835
+ odoo = [e for e in events if e[0] == 'mirror' and not e[2] or e[0] == 'counts']
836
+ return events, sleeps, odoo
837
+
838
+ def test_h73_restart_before_the_slot_makes_no_odoo_call_until_it(self):
839
+ """H73 a: boot 02:30Z, slot 13:00 Asia/Jakarta: zero Odoo work at boot, one pass at 06:00Z"""
840
+ last = self.utc('2026-10-23T06:05:00Z')
841
+ events, sleeps, odoo = self.run_slot_loop(
842
+ {'passAt': last, 'fullRebuildAt': last, 'fingerprints': {'res_partner': (3, 7)}},
843
+ boot=self.utc('2026-10-24T02:30:00Z'), max_sleeps=3)
844
+ slot, next_slot = self.utc('2026-10-24T06:00:00Z'), self.utc('2026-10-25T06:00:00Z')
845
+ boot_work = [e for e in events if e[1] < slot]
846
+ # Restore only at boot: the saved Amazon mirror, no mirror pass, no count, no store half.
847
+ self.assertEqual(boot_work, [('amazon', self.utc('2026-10-24T02:30:00Z'), 'boot', False)])
848
+ self.assertIn('2026-10-24T06:00:00Z (13:00 Asia/Jakarta)', self.loop_output)
849
+ # The first Odoo pass fires once, at the slot plus at most one second.
850
+ self.assertEqual(sleeps[0], slot + 1 - self.utc('2026-10-24T02:30:00Z'))
851
+ self.assertEqual([e[1] for e in odoo], [slot + 1, slot + 1, next_slot + 1, next_slot + 1])
852
+ self.assertTrue(0 < odoo[0][1] - slot <= 1)
853
+ # No second Odoo pass before the next day's slot: the wait after the pass targets it.
854
+ self.assertEqual(sleeps[1], 86400)
855
+ # The slot is stamped BEFORE the mirror pass reads Odoo, and the status names the next one.
856
+ import odoo_relational as rel
857
+ stamp = self.slot_store.docs[rel.CONFIG_KEY][rel.RESYNC_MEMORY_FIELD]['slotPassAt']
858
+ self.assertEqual(rel._memory_epoch(stamp), next_slot + 1)
859
+ self.assertEqual(self.slot_state['nextPassAt'], '2026-10-26T06:00:00Z')
860
+
861
+ def test_h73_a_missed_slot_runs_once_at_boot_then_at_the_next_slot(self):
862
+ """H73 b: last pass two days ago, boot 09:00Z: one Odoo pass at boot, the next at 06:00Z"""
863
+ last = self.utc('2026-10-22T06:05:00Z')
864
+ boot = self.utc('2026-10-24T09:00:00Z')
865
+ events, sleeps, odoo = self.run_slot_loop(
866
+ {'passAt': last, 'fullRebuildAt': last, 'fingerprints': {'res_partner': (3, 7)}},
867
+ boot=boot, max_sleeps=2)
868
+ next_slot = self.utc('2026-10-25T06:00:00Z')
869
+ mirror = [e[1] for e in odoo if e[0] == 'mirror']
870
+ self.assertEqual(mirror, [boot, next_slot + 1])
871
+ self.assertEqual(sleeps, [next_slot + 1 - boot, 86400])
872
+ self.assertNotIn(('amazon', boot, 'boot', False), events)
873
+
874
+ def test_h73_a_restart_inside_a_slot_pass_does_not_run_it_twice(self):
875
+ """H73: the slot is stamped before Odoo is read, so a restart mid-pass waits a day"""
876
+ stamp = self.utc('2026-10-24T06:00:01Z')
877
+ yesterday = self.utc('2026-10-23T06:30:00Z')
878
+ events, sleeps, odoo = self.run_slot_loop(
879
+ {'passAt': yesterday, 'fullRebuildAt': yesterday, 'slotPassAt': stamp,
880
+ 'fingerprints': {'res_partner': (3, 7)}},
881
+ boot=self.utc('2026-10-24T06:40:00Z'), max_sleeps=1)
882
+ self.assertEqual((odoo, sleeps), ([], [self.utc('2026-10-25T06:00:01Z')
883
+ - self.utc('2026-10-24T06:40:00Z')]))
884
+
885
+ def test_h73_a_tenant_without_a_slot_keeps_the_cadence_loop(self):
886
+ """H73 d: not tenant #0 and no stored time: the first pass runs at boot, then a cadence"""
887
+ import odoo_relational as rel
888
+ last = self.utc('2026-10-22T06:05:00Z')
889
+ boot = self.utc('2026-10-24T02:30:00Z')
890
+ self.assertIsNone(rel.read_config(self.SlotStore('acme'))['syncAt'])
891
+ events, sleeps, odoo = self.run_slot_loop(
892
+ {'passAt': last, 'fullRebuildAt': last, 'fingerprints': {'res_partner': (3, 7)}},
893
+ boot=boot, max_sleeps=1, tenant='acme')
894
+ self.assertEqual([e[1] for e in odoo if e[0] == 'mirror'], [boot])
895
+ self.assertEqual(sleeps, [86400])
896
+ self.assertNotIn('nextPassAt', self.slot_state)
897
+
898
+ def test_h73_manual_tenant0_has_no_slot(self):
899
+ """H73: "Manual" stays: tenant #0 on manual has no slot and no next pass"""
900
+ import odoo_relational as rel
901
+ rt = self.SlotStore('royal-imports', {rel.CONFIG_KEY: {'syncEvery': 'manual'}})
902
+ self.assertIsNone(rel.sync_slot(rel.read_config(rt)))
903
+ self.assertIsNone(rel.next_sync_at(rel.read_config(rt), self.utc('2026-10-24T02:30:00Z')))
904
+
905
+ def test_h73_freshness_reports_the_next_pass(self):
906
+ """H73 c: tenant #0 with no stored time reports 13:00 Asia/Jakarta, next 06:00Z"""
907
+ from datetime import datetime, timezone
908
+ import odoo_relational as rel
909
+ fresh = rel.sync_freshness(self.SlotStore('royal-imports'),
910
+ now=datetime(2026, 10, 24, 2, 30, tzinfo=timezone.utc))
911
+ self.assertEqual((fresh['syncAt'], fresh['syncTz'], fresh['nextSyncAt']),
912
+ ('13:00', 'Asia/Jakarta', '2026-10-24T06:00:00Z'))
913
+ # A stored invalid value reads as absent; a stored valid pair wins over the default.
914
+ bad = self.SlotStore('acme', {rel.CONFIG_KEY: {'syncAt': '25:00', 'syncTz': 'UTC'}})
915
+ self.assertIsNone(rel.sync_freshness(bad)['nextSyncAt'])
916
+ own = self.SlotStore('royal-imports', {rel.CONFIG_KEY: {'syncAt': '07:30', 'syncTz': 'UTC'}})
917
+ self.assertEqual(rel.sync_freshness(own, now=datetime(2026, 10, 24, 8, 0,
918
+ tzinfo=timezone.utc))['nextSyncAt'],
919
+ '2026-10-25T07:30:00Z')
920
+
921
 
922
  if __name__ == '__main__':
923
  unittest.main()
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 8b414243790f40291a06720082e07f23adf9fb657d1b3bdbee733c65fa3bc155
 
1
+ 1d9e63ee581e3c9e6699464a048e90769e4315562d243c9c28c0c0b07aa0abcd
web/src/connectors/ConnectorsPage.tsx CHANGED
@@ -81,6 +81,7 @@ import {
81
  import {
82
  freshnessWarnings,
83
  getOdooFreshness,
 
84
  OdooFreshnessNote,
85
  syncDate,
86
  type OdooFreshness,
@@ -1166,7 +1167,9 @@ export default function ConnectorsPage({
1166
  export function OdooSyncStatus({ onOpenDatabases }: { onOpenDatabases?: () => void } = {}) {
1167
  const catchUpStatus = useConnectorCatchUp(true);
1168
  const sync = useConnectorSyncStatus("odoo");
1169
- const [status, setStatus] = useState<OdooStatus | null>(null);
 
 
1170
  const [schema, setSchema] = useState<OdooSchema | null>(null);
1171
  const [problem, setProblem] = useState("");
1172
  // S67-T20 / C4: read beside the status, never blocking it; `null` shows no warning.
@@ -1191,6 +1194,7 @@ export function OdooSyncStatus({ onOpenDatabases }: { onOpenDatabases?: () => vo
1191
  return () => controller.abort();
1192
  }, [sync.status]);
1193
  const odooCatchUp = sourceCatchUp(catchUpStatus.catchUp, "odoo");
 
1194
  return (
1195
  <section className="w45-contract-card" aria-labelledby="odoo-sync-heading">
1196
  <h4 id="odoo-sync-heading">Sync</h4>
@@ -1198,7 +1202,7 @@ export function OdooSyncStatus({ onOpenDatabases }: { onOpenDatabases?: () => vo
1198
  {problem ? <p className="set-error">{problem}</p> : null}
1199
  <OdooFreshnessNote lines={freshnessWarnings(freshness)} />
1200
  {status ? <dl className="voice-agent-details">
1201
- <div><dt>Schedule</dt><dd>{status.schedule || "Not scheduled"}</dd></div>
1202
  <div><dt>Health</dt><dd>{odooCatchUp?.active ? catchUpLabel(odooCatchUp)
1203
  : catchUpStatus.error || (catchUpStatus.loading ? "Checking sync"
1204
  : odooCatchUp?.behind ? behindLabel(odooCatchUp.behind) : status.health)}
 
81
  import {
82
  freshnessWarnings,
83
  getOdooFreshness,
84
+ nextSyncSlot,
85
  OdooFreshnessNote,
86
  syncDate,
87
  type OdooFreshness,
 
1167
  export function OdooSyncStatus({ onOpenDatabases }: { onOpenDatabases?: () => void } = {}) {
1168
  const catchUpStatus = useConnectorCatchUp(true);
1169
  const sync = useConnectorSyncStatus("odoo");
1170
+ // H74: the status read also names the daily slot; all three keys may be absent or null.
1171
+ const [status, setStatus] = useState<(OdooStatus
1172
+ & { syncAt?: string | null; syncTz?: string | null; nextSyncAt?: string | null }) | null>(null);
1173
  const [schema, setSchema] = useState<OdooSchema | null>(null);
1174
  const [problem, setProblem] = useState("");
1175
  // S67-T20 / C4: read beside the status, never blocking it; `null` shows no warning.
 
1194
  return () => controller.abort();
1195
  }, [sync.status]);
1196
  const odooCatchUp = sourceCatchUp(catchUpStatus.catchUp, "odoo");
1197
+ const slot = nextSyncSlot(status);
1198
  return (
1199
  <section className="w45-contract-card" aria-labelledby="odoo-sync-heading">
1200
  <h4 id="odoo-sync-heading">Sync</h4>
 
1202
  {problem ? <p className="set-error">{problem}</p> : null}
1203
  <OdooFreshnessNote lines={freshnessWarnings(freshness)} />
1204
  {status ? <dl className="voice-agent-details">
1205
+ <div><dt>Schedule</dt><dd>{slot ? `Daily at ${slot}` : status.schedule || "Not scheduled"}</dd></div>
1206
  <div><dt>Health</dt><dd>{odooCatchUp?.active ? catchUpLabel(odooCatchUp)
1207
  : catchUpStatus.error || (catchUpStatus.loading ? "Checking sync"
1208
  : odooCatchUp?.behind ? behindLabel(odooCatchUp.behind) : status.health)}
web/src/connectors/OdooConfig.tsx CHANGED
@@ -64,6 +64,11 @@ export interface OdooConfig {
64
  frozen?: boolean;
65
  frozenAt?: string;
66
  canDisconnect?: boolean;
 
 
 
 
 
67
  /** What the server did with what it was sent — a clamp, a refusal, a rewrite (W30/R6). */
68
  notes?: string[];
69
  }
@@ -85,6 +90,29 @@ export interface OdooFreshness {
85
  lastRunAt?: string | null;
86
  phase?: string;
87
  failure?: { code?: string; message?: string; at?: string | null } | null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
 
90
  /** A sync time the way a person reads it: "Sep 27, 2026, 6:25 AM". An unreadable value is shown
@@ -103,10 +131,11 @@ export function freshnessWarnings(f: OdooFreshness | null | undefined): string[]
103
  if (!f) return [];
104
  const lines: string[] = [];
105
  if (f.stale) {
 
106
  lines.push(
107
- f.lastGoodSyncAt
108
  ? `Odoo data is stale: last synced ${syncDate(f.lastGoodSyncAt)}`
109
- : "Odoo data is stale: no sync has finished yet"
110
  );
111
  }
112
  const reason = (f.failure?.message ?? "").trim();
@@ -164,12 +193,44 @@ const EVERY_LABEL: Record<string, string> = {
164
  };
165
  export const everyLabel = (k: string): string => EVERY_LABEL[k] || k;
166
 
167
- /** The Overview frequency control writes only the tenant's sync preset. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  export function OdooSyncEvery() {
169
  const [cfg, setCfg] = useState<OdooConfig | null>(null);
170
  const [busy, setBusy] = useState(false);
171
  const [message, setMessage] = useState("");
172
  const [retry, setRetry] = useState(0);
 
 
173
  const saving = useRef(false);
174
  const writeController = useRef<AbortController | null>(null);
175
  const readConfig = useCallback(async (signal: AbortSignal) => {
@@ -181,42 +242,51 @@ export function OdooSyncEvery() {
181
  || !body.syncOptions.includes(body.syncEvery)) throw new Error("Sync settings unavailable.");
182
  return body;
183
  }, []);
 
 
 
 
 
 
184
 
185
  useEffect(() => {
186
  const controller = new AbortController();
187
  void readConfig(controller.signal).then((next) => {
188
- if (!controller.signal.aborted) { setCfg(next); setMessage(""); }
189
  }).catch((error: unknown) => {
190
  if (!controller.signal.aborted) setMessage(shortSyncCause(error instanceof Error ? error.message : ""));
191
  });
192
  return () => controller.abort();
193
- }, [readConfig, retry]);
194
 
195
  useEffect(() => () => writeController.current?.abort(), []);
196
 
197
- async function save(every: string) {
198
- if (saving.current || !cfg || cfg.frozen || !cfg.syncOptions?.includes(every)) return;
199
  saving.current = true;
 
200
  const controller = new AbortController();
201
  writeController.current = controller;
202
  setBusy(true);
203
  setMessage("");
 
204
  try {
205
  const response = await fetch(`${API_V1}/admin/connectors/odoo/config`, {
206
  method: "PUT", credentials: CREDENTIALS, signal: controller.signal,
207
- headers: { "content-type": "application/json" }, body: JSON.stringify({ syncEvery: every }),
208
  });
209
  const body = await response.json().catch(() => null) as (OdooConfig & { error?: { message?: string } }) | null;
210
- if (!response.ok) throw new Error(shortSyncCause(body?.error?.message, "Sync frequency could not be saved."));
 
211
  if (!controller.signal.aborted) setMessage((body?.notes ?? []).map((note) => shortSyncCause(note)).join(" "));
212
  } catch (error) {
213
- if (!controller.signal.aborted) setMessage(shortSyncCause(error instanceof Error ? error.message : "",
214
- "Sync frequency could not be saved."));
215
  } finally {
216
  if (!controller.signal.aborted) {
217
  try {
218
  const next = await readConfig(controller.signal);
219
- if (!controller.signal.aborted) setCfg(next);
 
220
  } catch {
221
  if (!controller.signal.aborted) setMessage("Sync frequency could not be confirmed.");
222
  }
@@ -226,15 +296,39 @@ export function OdooSyncEvery() {
226
  }
227
  }
228
 
 
 
 
 
 
 
 
 
229
  return <div className="conn-settings-frequency" aria-busy={busy}>
230
  <label htmlFor="conn-overview-sync-every">Sync every</label>
231
  <select id="conn-overview-sync-every" className="conn-odoo-every"
232
  value={cfg?.syncEvery ?? ""} disabled={!cfg || busy || cfg.frozen}
233
  title={cfg?.frozen ? "This connection is disconnected." : undefined}
234
- onChange={(event) => void save(event.target.value)}>
 
 
 
 
235
  {cfg ? cfg.syncOptions?.map((option) => <option key={option} value={option}>{everyLabel(option)}</option>)
236
  : <option value="">{message ? "Unavailable" : "Loading…"}</option>}
237
  </select>
 
 
 
 
 
 
 
 
 
 
 
 
238
  {message ? <span className="conn-settings-frequency-message" role="status">{message}
239
  <button type="button" className="conn-db-link" disabled={busy} onClick={() => setRetry((value) => value + 1)}>Try again</button>
240
  </span> : null}
@@ -516,6 +610,8 @@ export interface DailySyncStatus {
516
  canSync?: boolean;
517
  state?: string | null;
518
  errors?: string[];
 
 
519
  }
520
 
521
  type SyncReply = { state?: string; detail?: string; accepted?: boolean; error?: { message?: string } };
@@ -534,10 +630,11 @@ export function DailySyncPanel({ status, busy = false, message = "", onSync }: {
534
  : status.lastCompletedKnown === true ? "No sync yet" : "Last sync unavailable.";
535
  const cause = message || (status && ["failed", "error"].includes(status.state ?? "")
536
  ? shortSyncCause(status.errors?.[0]) : "");
 
537
  return (
538
  <div className="conn-odoo conn-daily-sync" aria-busy={busy || status === null}>
539
  <div className="conn-odoo-row"><span className="conn-odoo-k">Schedule</span>
540
- <span className="conn-odoo-v">Daily</span></div>
541
  <div className="conn-odoo-row"><span className="conn-odoo-k">Last sync</span>
542
  <span className="conn-odoo-v" role="status">{last}</span></div>
543
  <button type="button" className="conn-card-go" onClick={onSync}
 
64
  frozen?: boolean;
65
  frozenAt?: string;
66
  canDisconnect?: boolean;
67
+ /** The daily sync slot: "HH:MM" (24 h) in the IANA zone `syncTz`. */
68
+ syncAt?: string | null;
69
+ syncTz?: string | null;
70
+ /** The next scheduled sync, ISO UTC. Null when nothing is scheduled. */
71
+ nextSyncAt?: string | null;
72
  /** What the server did with what it was sent — a clamp, a refusal, a rewrite (W30/R6). */
73
  notes?: string[];
74
  }
 
90
  lastRunAt?: string | null;
91
  phase?: string;
92
  failure?: { code?: string; message?: string; at?: string | null } | null;
93
+ syncAt?: string | null;
94
+ syncTz?: string | null;
95
+ nextSyncAt?: string | null;
96
+ }
97
+
98
+ /** "1:00 PM (Jakarta)" from a stored "13:00" and "Asia/Jakarta". Reads the stored clock as is,
99
+ * never through the browser zone. Empty when there is no readable slot. */
100
+ export function syncSlotLabel(syncAt?: string | null, syncTz?: string | null): string {
101
+ const match = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec((syncAt ?? "").trim());
102
+ if (!match) return "";
103
+ const hour = Number(match[1]);
104
+ const clock = `${hour % 12 || 12}:${match[2]} ${hour < 12 ? "AM" : "PM"}`;
105
+ const zone = (syncTz ?? "").trim();
106
+ if (!zone) return clock;
107
+ const city = /^(Etc\/)?(UTC|UCT|GMT|Zulu|Universal)$/i.test(zone)
108
+ ? "UTC" : (zone.split("/").pop() ?? zone).replace(/_/g, " ");
109
+ return `${clock} (${city})`;
110
+ }
111
+
112
+ /** The slot label only while a next sync is scheduled, so a manual tenant reads today's copy. */
113
+ export function nextSyncSlot(f: { syncAt?: string | null; syncTz?: string | null; nextSyncAt?: string | null }
114
+ | null | undefined): string {
115
+ return f && typeof f.nextSyncAt === "string" && f.nextSyncAt ? syncSlotLabel(f.syncAt, f.syncTz) : "";
116
  }
117
 
118
  /** A sync time the way a person reads it: "Sep 27, 2026, 6:25 AM". An unreadable value is shown
 
131
  if (!f) return [];
132
  const lines: string[] = [];
133
  if (f.stale) {
134
+ const next = nextSyncSlot(f);
135
  lines.push(
136
+ (f.lastGoodSyncAt
137
  ? `Odoo data is stale: last synced ${syncDate(f.lastGoodSyncAt)}`
138
+ : "Odoo data is stale: no sync has finished yet") + (next ? `. Next sync ${next}` : "")
139
  );
140
  }
141
  const reason = (f.failure?.message ?? "").trim();
 
193
  };
194
  export const everyLabel = (k: string): string => EVERY_LABEL[k] || k;
195
 
196
+ /** The browser's IANA zone, or "UTC" when the runtime does not say. */
197
+ function browserZone(): string {
198
+ try {
199
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
200
+ } catch {
201
+ return "UTC";
202
+ }
203
+ }
204
+
205
+ /** Every zone the runtime knows, plus the stored, chosen and browser zones and UTC. */
206
+ function zoneOptions(...keep: Array<string | null | undefined>): string[] {
207
+ const intl = Intl as typeof Intl & { supportedValuesOf?: (key: "timeZone") => string[] };
208
+ let known: string[] = [];
209
+ if (typeof intl.supportedValuesOf === "function") {
210
+ try { known = intl.supportedValuesOf("timeZone"); } catch { known = []; }
211
+ }
212
+ const extra = [...keep, browserZone(), "UTC"].filter((zone): zone is string => !!zone && !known.includes(zone));
213
+ return [...new Set([...extra, ...known])];
214
+ }
215
+
216
+ /** "9:05" or "09:05:00" as the "09:05" a time input holds; anything else is empty. */
217
+ function slotValue(value: string | null | undefined): string {
218
+ const match = /^([01]?\d|2[0-3]):([0-5]\d)/.exec((value ?? "").trim());
219
+ return match ? `${match[1].padStart(2, "0")}:${match[2]}` : "";
220
+ }
221
+
222
+ const DEFAULT_SLOT = "13:00";
223
+
224
+ type SyncWrite = { syncEvery: string; syncAt?: string; syncTz?: string };
225
+
226
+ /** The Overview sync control: the tenant's preset and, for a daily sync, its time and zone. */
227
  export function OdooSyncEvery() {
228
  const [cfg, setCfg] = useState<OdooConfig | null>(null);
229
  const [busy, setBusy] = useState(false);
230
  const [message, setMessage] = useState("");
231
  const [retry, setRetry] = useState(0);
232
+ const [draftAt, setDraftAt] = useState(DEFAULT_SLOT);
233
+ const [draftTz, setDraftTz] = useState(browserZone);
234
  const saving = useRef(false);
235
  const writeController = useRef<AbortController | null>(null);
236
  const readConfig = useCallback(async (signal: AbortSignal) => {
 
242
  || !body.syncOptions.includes(body.syncEvery)) throw new Error("Sync settings unavailable.");
243
  return body;
244
  }, []);
245
+ // A fresh read resets the time and zone to the stored pair, else 13:00 in the browser zone.
246
+ const adopt = useCallback((next: OdooConfig) => {
247
+ setCfg(next);
248
+ setDraftAt(slotValue(next.syncAt) || DEFAULT_SLOT);
249
+ setDraftTz(next.syncTz || browserZone());
250
+ }, []);
251
 
252
  useEffect(() => {
253
  const controller = new AbortController();
254
  void readConfig(controller.signal).then((next) => {
255
+ if (!controller.signal.aborted) { adopt(next); setMessage(""); }
256
  }).catch((error: unknown) => {
257
  if (!controller.signal.aborted) setMessage(shortSyncCause(error instanceof Error ? error.message : ""));
258
  });
259
  return () => controller.abort();
260
+ }, [readConfig, adopt, retry]);
261
 
262
  useEffect(() => () => writeController.current?.abort(), []);
263
 
264
+ async function save(write: SyncWrite) {
265
+ if (saving.current || !cfg || cfg.frozen || !cfg.syncOptions?.includes(write.syncEvery)) return;
266
  saving.current = true;
267
+ const fallback = write.syncAt ? "Sync time could not be saved." : "Sync frequency could not be saved.";
268
  const controller = new AbortController();
269
  writeController.current = controller;
270
  setBusy(true);
271
  setMessage("");
272
+ let saved = false;
273
  try {
274
  const response = await fetch(`${API_V1}/admin/connectors/odoo/config`, {
275
  method: "PUT", credentials: CREDENTIALS, signal: controller.signal,
276
+ headers: { "content-type": "application/json" }, body: JSON.stringify(write),
277
  });
278
  const body = await response.json().catch(() => null) as (OdooConfig & { error?: { message?: string } }) | null;
279
+ if (!response.ok) throw new Error(shortSyncCause(body?.error?.message, fallback));
280
+ saved = true;
281
  if (!controller.signal.aborted) setMessage((body?.notes ?? []).map((note) => shortSyncCause(note)).join(" "));
282
  } catch (error) {
283
+ if (!controller.signal.aborted) setMessage(shortSyncCause(error instanceof Error ? error.message : "", fallback));
 
284
  } finally {
285
  if (!controller.signal.aborted) {
286
  try {
287
  const next = await readConfig(controller.signal);
288
+ // A refused time keeps what was typed beside its message.
289
+ if (!controller.signal.aborted) { if (saved) adopt(next); else setCfg(next); }
290
  } catch {
291
  if (!controller.signal.aborted) setMessage("Sync frequency could not be confirmed.");
292
  }
 
296
  }
297
  }
298
 
299
+ const daily = cfg?.syncEvery === "daily";
300
+ const storedAt = slotValue(cfg?.syncAt);
301
+ const storedTz = cfg?.syncTz ?? "";
302
+ const dirty = daily && (draftAt !== storedAt || draftTz !== storedTz);
303
+ const summary = syncSlotLabel(cfg?.syncAt, cfg?.syncTz);
304
+ const zones = useMemo(() => zoneOptions(cfg?.syncTz, draftTz), [cfg?.syncTz, draftTz]);
305
+ const locked = !cfg || busy || !!cfg.frozen;
306
+
307
  return <div className="conn-settings-frequency" aria-busy={busy}>
308
  <label htmlFor="conn-overview-sync-every">Sync every</label>
309
  <select id="conn-overview-sync-every" className="conn-odoo-every"
310
  value={cfg?.syncEvery ?? ""} disabled={!cfg || busy || cfg.frozen}
311
  title={cfg?.frozen ? "This connection is disconnected." : undefined}
312
+ onChange={(event) => {
313
+ const every = event.target.value;
314
+ // A first daily choice carries the slot shown, so "daily" always has a time.
315
+ void save(every === "daily" && !storedAt ? { syncEvery: every, syncAt: draftAt, syncTz: draftTz } : { syncEvery: every });
316
+ }}>
317
  {cfg ? cfg.syncOptions?.map((option) => <option key={option} value={option}>{everyLabel(option)}</option>)
318
  : <option value="">{message ? "Unavailable" : "Loading…"}</option>}
319
  </select>
320
+ {daily ? <div className="conn-settings-slot">
321
+ <label htmlFor="conn-overview-sync-at">At</label>
322
+ <input id="conn-overview-sync-at" type="time" step={60} className="conn-odoo-every conn-odoo-at"
323
+ value={draftAt} disabled={locked} onChange={(event) => setDraftAt(event.target.value)} />
324
+ <select id="conn-overview-sync-tz" className="conn-odoo-every conn-odoo-tz" aria-label="Time zone"
325
+ value={draftTz} disabled={locked} onChange={(event) => setDraftTz(event.target.value)}>
326
+ {zones.map((zone) => <option key={zone} value={zone}>{zone}</option>)}
327
+ </select>
328
+ {dirty ? <button type="button" className="set-primary" disabled={locked || !draftAt || !draftTz}
329
+ onClick={() => void save({ syncEvery: "daily", syncAt: draftAt, syncTz: draftTz })}>Save</button> : null}
330
+ {summary ? <span className="conn-settings-slot-line">{`Syncs daily at ${summary}`}</span> : null}
331
+ </div> : null}
332
  {message ? <span className="conn-settings-frequency-message" role="status">{message}
333
  <button type="button" className="conn-db-link" disabled={busy} onClick={() => setRetry((value) => value + 1)}>Try again</button>
334
  </span> : null}
 
610
  canSync?: boolean;
611
  state?: string | null;
612
  errors?: string[];
613
+ syncAt?: string | null;
614
+ syncTz?: string | null;
615
  }
616
 
617
  type SyncReply = { state?: string; detail?: string; accepted?: boolean; error?: { message?: string } };
 
630
  : status.lastCompletedKnown === true ? "No sync yet" : "Last sync unavailable.";
631
  const cause = message || (status && ["failed", "error"].includes(status.state ?? "")
632
  ? shortSyncCause(status.errors?.[0]) : "");
633
+ const slot = syncSlotLabel(status?.syncAt, status?.syncTz);
634
  return (
635
  <div className="conn-odoo conn-daily-sync" aria-busy={busy || status === null}>
636
  <div className="conn-odoo-row"><span className="conn-odoo-k">Schedule</span>
637
+ <span className="conn-odoo-v">{slot ? `Syncs daily at ${slot}` : "Daily"}</span></div>
638
  <div className="conn-odoo-row"><span className="conn-odoo-k">Last sync</span>
639
  <span className="conn-odoo-v" role="status">{last}</span></div>
640
  <button type="button" className="conn-card-go" onClick={onSync}
web/src/connectors/connectors.css CHANGED
@@ -59,6 +59,53 @@
59
  cursor: not-allowed;
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  .conn-settings-frequency-message {
63
  flex-basis: 100%;
64
  overflow-wrap: anywhere;
 
59
  cursor: not-allowed;
60
  }
61
 
62
+ .conn-settings-slot {
63
+ display: flex;
64
+ align-items: center;
65
+ flex-wrap: wrap;
66
+ flex-basis: 100%;
67
+ gap: calc(var(--lp-r-sm) * 2);
68
+ min-width: 0;
69
+ }
70
+
71
+ .conn-settings-frequency .conn-settings-slot .conn-odoo-at {
72
+ width: calc(var(--lp-r-sm) * 30);
73
+ font-variant-numeric: tabular-nums;
74
+ }
75
+
76
+ .conn-settings-slot .set-primary {
77
+ appearance: none;
78
+ border: 0;
79
+ min-height: calc(var(--lp-r-sm) * 8);
80
+ padding: 0 calc(var(--lp-r-sm) * 3);
81
+ border-radius: var(--lp-r-md);
82
+ background: var(--lp-primary);
83
+ color: var(--lp-surface);
84
+ font: inherit;
85
+ font-weight: var(--lp-fw-semibold);
86
+ cursor: pointer;
87
+ }
88
+
89
+ .conn-settings-slot .set-primary:hover:enabled {
90
+ background: var(--lp-primary-hover);
91
+ }
92
+
93
+ .conn-settings-slot .set-primary:focus-visible {
94
+ outline: 2px solid var(--lp-blue-deep);
95
+ outline-offset: 2px;
96
+ }
97
+
98
+ .conn-settings-slot .set-primary:disabled {
99
+ opacity: 0.5;
100
+ cursor: not-allowed;
101
+ }
102
+
103
+ .conn-settings-slot-line {
104
+ flex-basis: 100%;
105
+ color: var(--lp-ink);
106
+ overflow-wrap: anywhere;
107
+ }
108
+
109
  .conn-settings-frequency-message {
110
  flex-basis: 100%;
111
  overflow-wrap: anywhere;