fsanyoto commited on
Commit
5e98fbd
·
verified ·
1 Parent(s): c60dd73

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "27386a8d",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "1ee9dd6c",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- 27386a8d
 
1
+ 1ee9dd6c
api/automation_engine.py CHANGED
@@ -16506,6 +16506,10 @@ def start_scheduler(log=print):
16506
  external EventBridge tick (R5) does not depend on it either way, since that POSTs the
16507
  endpoint rather than riding this thread.
16508
  """
 
 
 
 
16509
  if os.environ.get("AIOS_AUTOMATIONS") != "1":
16510
  return False
16511
  # PostgreSQL production has one durable wake-up: EventBridge -> Lambda -> protected endpoint.
 
16506
  external EventBridge tick (R5) does not depend on it either way, since that POSTs the
16507
  endpoint rather than riding this thread.
16508
  """
16509
+ from core import freeze_notice
16510
+ if freeze_notice.enabled():
16511
+ log("[aios-auto] maintenance freeze holds automation scheduler")
16512
+ return False
16513
  if os.environ.get("AIOS_AUTOMATIONS") != "1":
16514
  return False
16515
  # PostgreSQL production has one durable wake-up: EventBridge -> Lambda -> protected endpoint.
api/main.py CHANGED
@@ -89,6 +89,7 @@ from core import grid_events # noqa: E402
89
  # ⚠ Neither is a `StoreUnavailable` subclass, on purpose: routes that degrade a store outage into a
90
  # session fallback must NOT degrade a refusal, or the user is told a change was saved that was not.
91
  from core import data_binding # noqa: E402
 
92
  from core import store # noqa: E402
93
  # W50-T28 clause 2 (C3 / R9) — the THIRD store refusal, and the only one of the three that is a
94
  # 409: a view write whose caller was looking at an older revision. See its handler below.
@@ -182,6 +183,32 @@ def _store_unavailable(request: Request, exc: grid_events.StoreUnavailable):
182
  status_code=503)
183
 
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  @app.exception_handler(data_binding.StoreWriteRefused)
186
  def _store_write_refused(request: Request, exc: data_binding.StoreWriteRefused):
187
  """D-315 — this deployment may not write that store. 503, with the REASON.
@@ -266,6 +293,12 @@ def _view_revision_unverifiable(request: Request, exc: view_audit.RevisionUnveri
266
  status_code=503)
267
 
268
 
 
 
 
 
 
 
269
  @app.get("/api/health")
270
  def health(challenge: str = ""):
271
  """Unauthenticated LIVENESS only — it must answer before anyone can sign in, so it may not
@@ -641,6 +674,14 @@ if _WEB_DIST.is_dir():
641
  # default envelope; scoped users still pay their own scope's first build, once.
642
  # Env-gated rather than a startup event so importing `api.main` in a gate (verify_api and friends
643
  # run against fakes) can never fire a live Odoo pull.
 
 
 
 
 
 
 
 
644
  def _seed_and_sync_store():
645
  """Bring the analytical store (harness.datastore) LIVE for this container — the app.py
646
  bootstrap, mirrored (2026-07-31, owner item 1).
@@ -656,6 +697,8 @@ def _seed_and_sync_store():
656
  passes). Fail-quiet throughout: no seed/token/Odoo → the columns stay blank, the rows still
657
  serve.
658
  """
 
 
659
  import time as _t
660
  t0 = _t.time()
661
  try:
@@ -2029,6 +2072,8 @@ def _store_resync_loop():
2029
  """Keep the analytical mirror current — the API-process stand-in for the re-sync the
2030
  Streamlit app piggybacks on page renders. Measure memos key on the pool stamp, so a
2031
  refreshed pool re-reads the freshly synced store."""
 
 
2032
  import time as _t
2033
  from core import connector_sync
2034
  passes = 0
@@ -2336,6 +2381,8 @@ def _store_resync_loop():
2336
 
2337
  def _boot_app_migrations(why):
2338
  """Apply tenant App retirement migrations independently of mirror sync and reads."""
 
 
2339
  try:
2340
  import application_registry
2341
  import timeseries_retirement
@@ -2359,6 +2406,8 @@ def _boot_app_migrations(why):
2359
 
2360
 
2361
  def _prewarm():
 
 
2362
  import time as _t
2363
  t0 = _t.time()
2364
  # The Odoo seed/sync can run for minutes and is separate from the finite cache warm below.
@@ -2457,6 +2506,8 @@ def _provision_qa_sandbox(pg=None):
2457
  does not open a PostgreSQL connection merely to learn it should refuse. Live has neither
2458
  deployment flag and returns before importing the PostgreSQL backend.
2459
  """
 
 
2460
  if os.environ.get("AIOS_ENABLE_QA_TENANT") != "1":
2461
  return False
2462
  granted = {s.strip().lower() for s in
@@ -2492,18 +2543,23 @@ except Exception as e: # noqa: BLE001
2492
  # never blocks health/readiness; the SQL procedure is idempotent, and `_provision_qa_sandbox`
2493
  # itself refuses before opening a pool on every other environment.
2494
  if (os.environ.get("AIOS_ENABLE_QA_TENANT") == "1"
2495
- and os.environ.get("STORE_BACKEND") == "pg"):
 
2496
  import threading as _threading_qa
2497
  _threading_qa.Thread(target=_provision_qa_sandbox, daemon=True,
2498
  name="qa-sandbox-schema").start()
2499
 
2500
  if (os.environ.get("AIOS_BOOT_APP_MIGRATIONS") != "0"
2501
- and (data_binding.is_space() or os.environ.get("AIOS_BOOT_APP_MIGRATIONS") == "1")):
 
2502
  import threading as _threading_apps
2503
  _threading_apps.Thread(target=_boot_app_migrations, args=("boot",), daemon=True,
2504
  name="app-migrations").start()
2505
 
2506
- if os.environ.get("AIOS_PREWARM") == "1":
 
 
 
2507
  import threading as _threading
2508
  _threading.Thread(target=_prewarm, daemon=True, name="prewarm").start()
2509
 
@@ -2538,6 +2594,6 @@ if os.environ.get("AIOS_PREWARM") == "1":
2538
  # The other structural cost remains outside that skip policy:
2539
  # * the whole-document store write itself. A partial-JSONB write is a wave.
2540
  # ⚠ SO DO NOT PUT THIS BACK TO 3600 to "fix staleness" without closing one of those two first.
2541
- if os.environ.get("AIOS_STORE_RESYNC") == "1":
2542
  import threading as _threading_resync
2543
  _threading_resync.Thread(target=_store_resync_loop, daemon=True, name="store-resync").start()
 
89
  # ⚠ Neither is a `StoreUnavailable` subclass, on purpose: routes that degrade a store outage into a
90
  # session fallback must NOT degrade a refusal, or the user is told a change was saved that was not.
91
  from core import data_binding # noqa: E402
92
+ from core import freeze_notice # noqa: E402
93
  from core import store # noqa: E402
94
  # W50-T28 clause 2 (C3 / R9) — the THIRD store refusal, and the only one of the three that is a
95
  # 409: a view write whose caller was looking at an older revision. See its handler below.
 
183
  status_code=503)
184
 
185
 
186
+ @app.exception_handler(freeze_notice.DataInputFrozen)
187
+ def _data_input_frozen(request: Request, exc: freeze_notice.DataInputFrozen):
188
+ """Use the existing readable error envelope for every maintenance refusal."""
189
+ return JSONResponse(
190
+ {"error": {"code": freeze_notice.ERROR_CODE, "message": freeze_notice.REFUSAL_TEXT}},
191
+ status_code=freeze_notice.STATUS_CODE)
192
+
193
+
194
+ @app.middleware("http")
195
+ async def _freeze_response(request: Request, call_next):
196
+ """Keep a refused write readable even when a route catches its store error."""
197
+ if request.method in {"GET", "HEAD", "OPTIONS"}:
198
+ return await call_next(request)
199
+ with freeze_notice.refusal_scope() as refused:
200
+ try:
201
+ response = await call_next(request)
202
+ except Exception:
203
+ if not refused[0]:
204
+ raise
205
+ return _data_input_frozen(request, freeze_notice.DataInputFrozen())
206
+ if refused[0]:
207
+ # Replace the response, including any cookie minted from unpersisted auth state.
208
+ return _data_input_frozen(request, freeze_notice.DataInputFrozen())
209
+ return response
210
+
211
+
212
  @app.exception_handler(data_binding.StoreWriteRefused)
213
  def _store_write_refused(request: Request, exc: data_binding.StoreWriteRefused):
214
  """D-315 — this deployment may not write that store. 503, with the REASON.
 
293
  status_code=503)
294
 
295
 
296
+ @app.get("/api/v1/freeze-notice")
297
+ def public_freeze_notice():
298
+ """Report public maintenance state without resolving a session or store."""
299
+ return JSONResponse(freeze_notice.notice(), headers={"Cache-Control": "no-store"})
300
+
301
+
302
  @app.get("/api/health")
303
  def health(challenge: str = ""):
304
  """Unauthenticated LIVENESS only — it must answer before anyone can sign in, so it may not
 
674
  # default envelope; scoped users still pay their own scope's first build, once.
675
  # Env-gated rather than a startup event so importing `api.main` in a gate (verify_api and friends
676
  # run against fakes) can never fire a live Odoo pull.
677
+ def _freeze_holds(writer):
678
+ """Log each held writer before it can start work."""
679
+ if not freeze_notice.enabled():
680
+ return False
681
+ print(f"[aios-api] maintenance freeze holds {writer}")
682
+ return True
683
+
684
+
685
  def _seed_and_sync_store():
686
  """Bring the analytical store (harness.datastore) LIVE for this container — the app.py
687
  bootstrap, mirrored (2026-07-31, owner item 1).
 
697
  passes). Fail-quiet throughout: no seed/token/Odoo → the columns stay blank, the rows still
698
  serve.
699
  """
700
+ if _freeze_holds("boot store sync"):
701
+ return
702
  import time as _t
703
  t0 = _t.time()
704
  try:
 
2072
  """Keep the analytical mirror current — the API-process stand-in for the re-sync the
2073
  Streamlit app piggybacks on page renders. Measure memos key on the pool stamp, so a
2074
  refreshed pool re-reads the freshly synced store."""
2075
+ if _freeze_holds("store resync"):
2076
+ return
2077
  import time as _t
2078
  from core import connector_sync
2079
  passes = 0
 
2381
 
2382
  def _boot_app_migrations(why):
2383
  """Apply tenant App retirement migrations independently of mirror sync and reads."""
2384
+ if _freeze_holds("app migrations"):
2385
+ return
2386
  try:
2387
  import application_registry
2388
  import timeseries_retirement
 
2406
 
2407
 
2408
  def _prewarm():
2409
+ if _freeze_holds("prewarm"):
2410
+ return
2411
  import time as _t
2412
  t0 = _t.time()
2413
  # The Odoo seed/sync can run for minutes and is separate from the finite cache warm below.
 
2506
  does not open a PostgreSQL connection merely to learn it should refuse. Live has neither
2507
  deployment flag and returns before importing the PostgreSQL backend.
2508
  """
2509
+ if _freeze_holds("QA schema provisioning"):
2510
+ return False
2511
  if os.environ.get("AIOS_ENABLE_QA_TENANT") != "1":
2512
  return False
2513
  granted = {s.strip().lower() for s in
 
2543
  # never blocks health/readiness; the SQL procedure is idempotent, and `_provision_qa_sandbox`
2544
  # itself refuses before opening a pool on every other environment.
2545
  if (os.environ.get("AIOS_ENABLE_QA_TENANT") == "1"
2546
+ and os.environ.get("STORE_BACKEND") == "pg"
2547
+ and not _freeze_holds("QA schema provisioning")):
2548
  import threading as _threading_qa
2549
  _threading_qa.Thread(target=_provision_qa_sandbox, daemon=True,
2550
  name="qa-sandbox-schema").start()
2551
 
2552
  if (os.environ.get("AIOS_BOOT_APP_MIGRATIONS") != "0"
2553
+ and (data_binding.is_space() or os.environ.get("AIOS_BOOT_APP_MIGRATIONS") == "1")
2554
+ and not _freeze_holds("app migrations")):
2555
  import threading as _threading_apps
2556
  _threading_apps.Thread(target=_boot_app_migrations, args=("boot",), daemon=True,
2557
  name="app-migrations").start()
2558
 
2559
+ if os.environ.get("AIOS_BOOT_SYNC") == "1" and freeze_notice.enabled():
2560
+ _freeze_holds("boot store sync")
2561
+
2562
+ if os.environ.get("AIOS_PREWARM") == "1" and not _freeze_holds("prewarm"):
2563
  import threading as _threading
2564
  _threading.Thread(target=_prewarm, daemon=True, name="prewarm").start()
2565
 
 
2594
  # The other structural cost remains outside that skip policy:
2595
  # * the whole-document store write itself. A partial-JSONB write is a wave.
2596
  # ⚠ SO DO NOT PUT THIS BACK TO 3600 to "fix staleness" without closing one of those two first.
2597
+ if os.environ.get("AIOS_STORE_RESYNC") == "1" and not _freeze_holds("store resync"):
2598
  import threading as _threading_resync
2599
  _threading_resync.Thread(target=_store_resync_loop, daemon=True, name="store-resync").start()
api/routes_admin.py CHANGED
@@ -2530,7 +2530,9 @@ def settings(session: Session = Depends(require_session)):
2530
  would answer a question about our customer list.
2531
  """
2532
  modules = perms.allowed_modules(session.user)
 
2533
  return {
 
2534
  # The build this Space is running. Behind the session on purpose — see `main.py::health`,
2535
  # which refuses it for being the first URL a scanner finds. `deploy_web.py` stamps it as a
2536
  # Space secret at every deploy; absent means "somebody started this container by hand".
 
2530
  would answer a question about our customer list.
2531
  """
2532
  modules = perms.allowed_modules(session.user)
2533
+ from core import freeze_notice
2534
  return {
2535
+ "freezeNotice": freeze_notice.notice(),
2536
  # The build this Space is running. Behind the session on purpose — see `main.py::health`,
2537
  # which refuses it for being the first URL a scanner finds. `deploy_web.py` stamps it as a
2538
  # Space secret at every deploy; absent means "somebody started this container by hand".
api/routes_auth.py CHANGED
@@ -13,7 +13,7 @@ import re as _re
13
  from fastapi import APIRouter, Body, Depends, Request, Response
14
 
15
  import aios_session
16
- from core import audit
17
  from deps import Session, err, require_session, users, perms
18
 
19
  router = APIRouter(prefix="/api/v1/auth")
@@ -310,7 +310,7 @@ def login(request: Request, response: Response, body: dict = Body(default=None))
310
  _clear_failures(throttle_key)
311
  session_epoch = int(user.get("epoch") or 0)
312
  epoch_bumped = False
313
- if not user.get("qa_runner"):
314
  try:
315
  bumped = users.bump_epoch(user["username"])
316
  if bumped is not None:
 
13
  from fastapi import APIRouter, Body, Depends, Request, Response
14
 
15
  import aios_session
16
+ from core import audit, freeze_notice
17
  from deps import Session, err, require_session, users, perms
18
 
19
  router = APIRouter(prefix="/api/v1/auth")
 
310
  _clear_failures(throttle_key)
311
  session_epoch = int(user.get("epoch") or 0)
312
  epoch_bumped = False
313
+ if not user.get("qa_runner") and not freeze_notice.enabled():
314
  try:
315
  bumped = users.bump_epoch(user["username"])
316
  if bumped is not None:
api/routes_connectors.py CHANGED
@@ -2369,6 +2369,10 @@ def _record_database_dispatch(rt, exception_type=None):
2369
  @router.on_event("startup")
2370
  def _start_database_jobs():
2371
  """Discover durable work at boot, including tenants that have no active browser session."""
 
 
 
 
2372
  global _materialization_thread
2373
  def run():
2374
  global _materialization_thread
 
2369
  @router.on_event("startup")
2370
  def _start_database_jobs():
2371
  """Discover durable work at boot, including tenants that have no active browser session."""
2372
+ from core import freeze_notice
2373
+ if freeze_notice.enabled():
2374
+ print("[aios-api] maintenance freeze holds connector database jobs")
2375
+ return
2376
  global _materialization_thread
2377
  def run():
2378
  global _materialization_thread
platform/core/audit.py CHANGED
@@ -5,6 +5,7 @@ import re
5
  import time
6
 
7
  from harness import runtime
 
8
 
9
 
10
  AUDIT_KINDS = frozenset({
@@ -142,6 +143,8 @@ def ordered(doc, tenant, limit=200) -> list[dict]:
142
  def record(kind, tenant, principal, detail=None) -> dict | None:
143
  """Refusals raise before I/O. Store failures lose the event, never the user's sign-in."""
144
  item = event(kind, tenant, principal, detail)
 
 
145
  tenant = item["tenant"]
146
 
147
  def _append(doc):
 
5
  import time
6
 
7
  from harness import runtime
8
+ from core import freeze_notice
9
 
10
 
11
  AUDIT_KINDS = frozenset({
 
143
  def record(kind, tenant, principal, detail=None) -> dict | None:
144
  """Refusals raise before I/O. Store failures lose the event, never the user's sign-in."""
145
  item = event(kind, tenant, principal, detail)
146
+ if freeze_notice.enabled():
147
+ return None
148
  tenant = item["tenant"]
149
 
150
  def _append(doc):
platform/core/data_binding.py CHANGED
@@ -49,6 +49,7 @@ per D-160 the Space environment cannot be read from outside, so the container ha
49
  saw. One deploy then answers "does SPACE_ID exist here", instead of three.
50
  """
51
  import os
 
52
 
53
  #: The deployment that OWNS production data. A frozenset rather than a string because the product
54
  #: has had two public addresses before and will again.
@@ -284,6 +285,7 @@ def write_refusal(repo):
284
 
285
  def check_write(repo, operation='write'):
286
  """Raise `StoreWriteRefused` unless this deployment may write `repo`. The one enforcement door."""
 
287
  reason = gate_write_refusal(repo) or write_refusal(repo)
288
  if reason:
289
  raise StoreWriteRefused(f'{operation} to {repo!r} refused: {reason}')
 
49
  saw. One deploy then answers "does SPACE_ID exist here", instead of three.
50
  """
51
  import os
52
+ from core import freeze_notice
53
 
54
  #: The deployment that OWNS production data. A frozenset rather than a string because the product
55
  #: has had two public addresses before and will again.
 
285
 
286
  def check_write(repo, operation='write'):
287
  """Raise `StoreWriteRefused` unless this deployment may write `repo`. The one enforcement door."""
288
+ freeze_notice.check_write()
289
  reason = gate_write_refusal(repo) or write_refusal(repo)
290
  if reason:
291
  raise StoreWriteRefused(f'{operation} to {repo!r} refused: {reason}')
platform/core/freeze_notice.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Deployment maintenance state, independent of sessions and stored documents."""
2
+ import os
3
+ from contextlib import contextmanager
4
+ from contextvars import ContextVar
5
+
6
+ ENV_NAME = "AIOS_FREEZE_NOTICE"
7
+ DEFAULT_TEXT = "Data input is frozen for maintenance."
8
+ REFUSAL_TEXT = "Data input is frozen for maintenance. Try again shortly."
9
+ ERROR_CODE = "data_input_frozen"
10
+ STATUS_CODE = 423
11
+ _REFUSAL = ContextVar("aios_freeze_refusal", default=None)
12
+
13
+
14
+ class DataInputFrozen(RuntimeError):
15
+ """A maintenance freeze refused a durable mutation before acceptance."""
16
+
17
+ def __init__(self):
18
+ refusal = _REFUSAL.get()
19
+ if refusal is not None:
20
+ refusal[0] = True
21
+ super().__init__(REFUSAL_TEXT)
22
+
23
+
24
+ @contextmanager
25
+ def refusal_scope():
26
+ """Track a refusal through route wrappers and copied threadpool contexts."""
27
+ refusal = [False]
28
+ token = _REFUSAL.set(refusal)
29
+ try:
30
+ yield refusal
31
+ finally:
32
+ _REFUSAL.reset(token)
33
+
34
+
35
+ def enabled():
36
+ return bool(os.environ.get(ENV_NAME))
37
+
38
+
39
+ def notice():
40
+ """Return only the public on/off state and notice text."""
41
+ value = str(os.environ.get(ENV_NAME) or "")
42
+ text = DEFAULT_TEXT if value.lower() in {"1", "on"} else value
43
+ return {"enabled": bool(value), "text": text}
44
+
45
+
46
+ def check_write():
47
+ """Refuse before any store permission check, cache mutation or network call."""
48
+ if enabled():
49
+ raise DataInputFrozen()
platform/core/store_pg.py CHANGED
@@ -49,6 +49,7 @@ from pathlib import Path
49
  from urllib.parse import urlparse
50
 
51
  import core.data_binding as data_binding
 
52
  from core.user_tables import enforce_byte_budget as _BYTE_BUDGET_ENFORCER
53
 
54
  _URL_ENV = 'DATABASE_URL'
@@ -254,6 +255,7 @@ def check_write(tenant_slug=None, operation='write'):
254
  a session-scoped fallback and tell the user their change was saved. A new type would have had
255
  to re-earn both properties, and would have failed the second one silently.
256
  """
 
257
  reason = gate_write_refusal(tenant_slug) or write_refusal(tenant_slug)
258
  if reason:
259
  raise data_binding.StoreWriteRefused(
 
49
  from urllib.parse import urlparse
50
 
51
  import core.data_binding as data_binding
52
+ from core import freeze_notice
53
  from core.user_tables import enforce_byte_budget as _BYTE_BUDGET_ENFORCER
54
 
55
  _URL_ENV = 'DATABASE_URL'
 
255
  a session-scoped fallback and tell the user their change was saved. A new type would have had
256
  to re-earn both properties, and would have failed the second one silently.
257
  """
258
+ freeze_notice.check_write()
259
  reason = gate_write_refusal(tenant_slug) or write_refusal(tenant_slug)
260
  if reason:
261
  raise data_binding.StoreWriteRefused(
platform/core/users.py CHANGED
@@ -21,6 +21,7 @@ import time
21
  from urllib.parse import quote
22
 
23
  import core.store as store
 
24
 
25
  BU_LABELS = {5: 'Fisch', 6: 'Royal'}
26
  _ITER = 200_000
@@ -327,6 +328,7 @@ def set_mfa(username, secret, recovery_codes, *, require_unenrolled=False, expec
327
  enrolment check lets two workers both issue a first set of codes; an epoch check prevents
328
  regeneration racing an admin reset from silently reinstalling the lost factor.
329
  """
 
330
  username = (username or '').strip().lower()
331
  # The replay closure captures only hashes, never printable recovery codes: the HF store
332
  # journals closures for conflict replay, and that journal must not retain clear codes.
@@ -380,6 +382,14 @@ def clear_mfa(username):
380
  def consume_recovery_code(username, code) -> bool:
381
  username = (username or '').strip().lower()
382
  wanted = _recovery_key(code)
 
 
 
 
 
 
 
 
383
  consumed = [False]
384
 
385
  def _set(reg):
@@ -483,6 +493,8 @@ def login_lockout_remaining(identifier, now=None):
483
 
484
  def note_login_failure(identifier, now=None):
485
  """Atomically count one failed password/MFA proof and return lock seconds remaining."""
 
 
486
  now = time.time() if now is None else float(now)
487
  key = _login_lockout_key(identifier)
488
 
@@ -552,6 +564,8 @@ def note_login_failure(identifier, now=None):
552
 
553
  def clear_login_failures(identifier):
554
  """Clear the account's shared guessing budget after a complete successful proof."""
 
 
555
  key = _login_lockout_key(identifier)
556
 
557
  def _clear(doc):
@@ -785,6 +799,7 @@ def set_password(username, pw, enforce=True):
785
  `enforce=False` is only for a caller that already validated (or a future migration) to rotate
786
  without re-reading. The admin password route is that one caller; all others enforce here.
787
  """
 
788
  username = (username or '').strip().lower()
789
  if enforce:
790
  try:
@@ -918,6 +933,8 @@ _STAMPS_LOCK = __import__('threading').Lock()
918
 
919
  def _stamp(username, fields):
920
  """Merge `fields` into ONE account record, on a background thread, with a fresh read."""
 
 
921
  username = (username or '').strip().lower()
922
  if not username or not fields:
923
  return None
@@ -929,6 +946,8 @@ def _stamp(username, fields):
929
  return reg
930
 
931
  def _work():
 
 
932
  try:
933
  store.update('users', _set) # sync: fresh strict read + blocking upload
934
  except Exception:
 
21
  from urllib.parse import quote
22
 
23
  import core.store as store
24
+ from core import freeze_notice
25
 
26
  BU_LABELS = {5: 'Fisch', 6: 'Royal'}
27
  _ITER = 200_000
 
328
  enrolment check lets two workers both issue a first set of codes; an epoch check prevents
329
  regeneration racing an admin reset from silently reinstalling the lost factor.
330
  """
331
+ freeze_notice.check_write()
332
  username = (username or '').strip().lower()
333
  # The replay closure captures only hashes, never printable recovery codes: the HF store
334
  # journals closures for conflict replay, and that journal must not retain clear codes.
 
382
  def consume_recovery_code(username, code) -> bool:
383
  username = (username or '').strip().lower()
384
  wanted = _recovery_key(code)
385
+ if freeze_notice.enabled():
386
+ rec = (registry() or {}).get(username) or {}
387
+ matched = False
388
+ for stored in rec.get('recovery_codes') or []:
389
+ matched |= hmac.compare_digest(stored, wanted)
390
+ if matched:
391
+ freeze_notice.check_write()
392
+ return False
393
  consumed = [False]
394
 
395
  def _set(reg):
 
493
 
494
  def note_login_failure(identifier, now=None):
495
  """Atomically count one failed password/MFA proof and return lock seconds remaining."""
496
+ if freeze_notice.enabled():
497
+ return login_lockout_remaining(identifier, now=now)
498
  now = time.time() if now is None else float(now)
499
  key = _login_lockout_key(identifier)
500
 
 
564
 
565
  def clear_login_failures(identifier):
566
  """Clear the account's shared guessing budget after a complete successful proof."""
567
+ if freeze_notice.enabled():
568
+ return None
569
  key = _login_lockout_key(identifier)
570
 
571
  def _clear(doc):
 
799
  `enforce=False` is only for a caller that already validated (or a future migration) to rotate
800
  without re-reading. The admin password route is that one caller; all others enforce here.
801
  """
802
+ freeze_notice.check_write()
803
  username = (username or '').strip().lower()
804
  if enforce:
805
  try:
 
933
 
934
  def _stamp(username, fields):
935
  """Merge `fields` into ONE account record, on a background thread, with a fresh read."""
936
+ if freeze_notice.enabled():
937
+ return None
938
  username = (username or '').strip().lower()
939
  if not username or not fields:
940
  return None
 
946
  return reg
947
 
948
  def _work():
949
+ if freeze_notice.enabled():
950
+ return
951
  try:
952
  store.update('users', _set) # sync: fresh strict read + blocking upload
953
  except Exception:
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 60ad8ce744646211c2c4fb2121d60e5d7cedc293623a113c60784ea9ba12f6af
 
1
+ 6777d281a34dc2d99509eb6cf5189d6c7fc8f929264383f772513eab4919259c
web/src/customer-grid/apiBridge.ts CHANGED
@@ -103,7 +103,15 @@ export function savePersonalGridLayout(key: string, layout: PersonalGridLayout):
103
  keepalive: true,
104
  });
105
  if (handledSession(res)) { entry.next = null; return false; }
106
- if (!res.ok) throw new Error("layout write refused");
 
 
 
 
 
 
 
 
107
  } catch {
108
  saved = false;
109
  signal(TOAST_EVENT, "Your grid layout could not be saved. Change a view control to retry.");
@@ -2486,7 +2494,15 @@ async function drain(): Promise<void> {
2486
  // turn one expired cookie into an unbounded request loop.
2487
  if (!handledSession(res)) {
2488
  if (res.ok) applyEventResult(await readJson(res));
2489
- else requeue = true;
 
 
 
 
 
 
 
 
2490
  }
2491
  } catch {
2492
  requeue = true;
 
103
  keepalive: true,
104
  });
105
  if (handledSession(res)) { entry.next = null; return false; }
106
+ if (!res.ok) {
107
+ const body = await readJson(res);
108
+ if ((body as { error?: { code?: string } } | null)?.error?.code === "data_input_frozen") {
109
+ entry.next = null;
110
+ signal(TOAST_EVENT, refusalMessage(body, res.status));
111
+ return false;
112
+ }
113
+ throw new Error("layout write refused");
114
+ }
115
  } catch {
116
  saved = false;
117
  signal(TOAST_EVENT, "Your grid layout could not be saved. Change a view control to retry.");
 
2494
  // turn one expired cookie into an unbounded request loop.
2495
  if (!handledSession(res)) {
2496
  if (res.ok) applyEventResult(await readJson(res));
2497
+ else {
2498
+ const body = await readJson(res);
2499
+ if ((body as { error?: { code?: string } } | null)?.error?.code === "data_input_frozen") {
2500
+ signal(TOAST_EVENT, refusalMessage(body, res.status));
2501
+ clearCustomersCache();
2502
+ signal(ROWS_STALE_EVENT);
2503
+ signal(WORKSPACE_STALE_EVENT);
2504
+ } else requeue = true;
2505
+ }
2506
  }
2507
  } catch {
2508
  requeue = true;
web/src/forms/FormPublic.tsx CHANGED
@@ -120,7 +120,9 @@ function PublicForm({ token }: { token: string }) {
120
  }
121
  const body = await r.json().catch(() => null);
122
  if (controller.signal.aborted) return;
123
- if (!spec?.singleUse) {
 
 
124
  setError(String(body?.error?.message || "That could not be sent; check your answers and try again."));
125
  } else if (r.status === 403) {
126
  setPhase("gone");
 
120
  }
121
  const body = await r.json().catch(() => null);
122
  if (controller.signal.aborted) return;
123
+ if (body?.error?.code === "data_input_frozen") {
124
+ setError(String(body.error.message));
125
+ } else if (!spec?.singleUse) {
126
  setError(String(body?.error?.message || "That could not be sent; check your answers and try again."));
127
  } else if (r.status === 403) {
128
  setPhase("gone");
web/src/index.css CHANGED
@@ -63,6 +63,9 @@
63
  `-deep` weight; flat surfaces take the pastel base. */
64
  --cg-navy: var(--lp-blue-solid);
65
  --cg-gold: var(--lp-yellow-deep);
 
 
 
66
  --cg-ink: var(--lp-ink);
67
  --cg-text: var(--lp-ink);
68
  --cg-muted: var(--lp-muted);
@@ -3527,9 +3530,41 @@ body > .cg-overlay {
3527
  color: var(--lp-ink);
3528
  background: var(--lp-surface);
3529
  }
3530
- .login-root { align-items: flex-start; padding: 12vh 20px 40px; }
 
 
 
 
 
 
3531
  .shell-boot { align-items: center; }
3532
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3533
  .login-card {
3534
  --login-control-h: var(--lp-login-control-height);
3535
  width: 100%;
@@ -3730,6 +3765,16 @@ body > .cg-overlay {
3730
  background: var(--lp-surface);
3731
  border-bottom: 1px solid var(--lp-line);
3732
  }
 
 
 
 
 
 
 
 
 
 
3733
  /* ⛔ `min-height: 0` is load-bearing, not tidiness. A flex ITEM defaults to `min-height: auto`,
3734
  which refuses to shrink below its content — so without this the rail's own scroll box and the
3735
  grid host would size to their content and push the page past 100vh instead of scrolling inside
 
63
  `-deep` weight; flat surfaces take the pastel base. */
64
  --cg-navy: var(--lp-blue-solid);
65
  --cg-gold: var(--lp-yellow-deep);
66
+ /* Maintenance colors mirror the existing canvas NAVY and GOLD in theme.ts. */
67
+ --lp-freeze-navy: #1F4E78;
68
+ --lp-freeze-gold: #C8A24B;
69
  --cg-ink: var(--lp-ink);
70
  --cg-text: var(--lp-ink);
71
  --cg-muted: var(--lp-muted);
 
3530
  color: var(--lp-ink);
3531
  background: var(--lp-surface);
3532
  }
3533
+ .login-root {
3534
+ flex-direction: column;
3535
+ justify-content: flex-start;
3536
+ align-items: center;
3537
+ padding: 0 20px 40px;
3538
+ }
3539
+ .login-root > .login-card { margin-top: 12vh; }
3540
  .shell-boot { align-items: center; }
3541
 
3542
+ .freeze-page { display: flex; flex-direction: column; min-height: 100vh; }
3543
+ .freeze-page > .shell-boot { flex: 1; min-height: 0; }
3544
+ .freeze-notice-band {
3545
+ display: flex;
3546
+ flex: 0 0 auto;
3547
+ justify-content: flex-end;
3548
+ width: 100%;
3549
+ padding: 12px 16px;
3550
+ }
3551
+ .login-root > .freeze-notice-band { padding: 12px 0; }
3552
+ .freeze-notice {
3553
+ display: block;
3554
+ margin-left: auto;
3555
+ max-width: 100%;
3556
+ padding: 4px 8px;
3557
+ border: 1px solid var(--lp-freeze-gold);
3558
+ border-radius: var(--lp-r-sm);
3559
+ color: var(--lp-freeze-navy);
3560
+ background: var(--lp-surface);
3561
+ font-family: "Inter", system-ui, sans-serif;
3562
+ font-size: var(--lp-fs-2xs);
3563
+ line-height: 1.4;
3564
+ overflow-wrap: anywhere;
3565
+ text-align: right;
3566
+ }
3567
+
3568
  .login-card {
3569
  --login-control-h: var(--lp-login-control-height);
3570
  width: 100%;
 
3765
  background: var(--lp-surface);
3766
  border-bottom: 1px solid var(--lp-line);
3767
  }
3768
+ .shell-topbar:has(.freeze-notice) {
3769
+ flex: 0 0 auto;
3770
+ height: auto;
3771
+ min-height: var(--lp-rail-head-h);
3772
+ flex-wrap: wrap;
3773
+ row-gap: 4px;
3774
+ padding-top: 8px;
3775
+ padding-bottom: 8px;
3776
+ }
3777
+ .shell-topbar > .freeze-notice { flex: 0 1 auto; }
3778
  /* ⛔ `min-height: 0` is load-bearing, not tidiness. A flex ITEM defaults to `min-height: auto`,
3779
  which refuses to shrink below its content — so without this the rail's own scroll box and the
3780
  grid host would size to their content and push the page past 100vh instead of scrolling inside
web/src/settings/settingsApi.ts CHANGED
@@ -48,6 +48,7 @@ export interface AdminUser {
48
  }
49
 
50
  export interface SettingsPayload {
 
51
  user: { username: string; name: string; role: string };
52
  scope: {
53
  bus: string[] | "all";
@@ -83,6 +84,15 @@ export type ApiResult<T> =
83
  | { ok: true; data: T }
84
  | { ok: false; status: number; message: string };
85
 
 
 
 
 
 
 
 
 
 
86
  async function call<T>(
87
  path: string,
88
  init?: RequestInit & { body?: string }
 
48
  }
49
 
50
  export interface SettingsPayload {
51
+ freezeNotice?: FreezeNoticeState;
52
  user: { username: string; name: string; role: string };
53
  scope: {
54
  bus: string[] | "all";
 
84
  | { ok: true; data: T }
85
  | { ok: false; status: number; message: string };
86
 
87
+ export interface FreezeNoticeState {
88
+ enabled: boolean;
89
+ text: string;
90
+ }
91
+
92
+ export function getFreezeNotice(signal?: AbortSignal): Promise<ApiResult<FreezeNoticeState>> {
93
+ return call<FreezeNoticeState>("/freeze-notice", { cache: "no-store", signal });
94
+ }
95
+
96
  async function call<T>(
97
  path: string,
98
  init?: RequestInit & { body?: string }
web/src/shell/FreezeNotice.tsx ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useState } from "react";
2
+ import { getFreezeNotice } from "../settings/settingsApi";
3
+ import type { FreezeNoticeState } from "../settings/settingsApi";
4
+
5
+ export function useFreezeNotice(): FreezeNoticeState {
6
+ const [notice, setNotice] = useState<FreezeNoticeState>({ enabled: false, text: "" });
7
+ useEffect(() => {
8
+ let live = true;
9
+ let request: AbortController | null = null;
10
+ const refresh = () => {
11
+ if (document.hidden) return;
12
+ request?.abort();
13
+ const controller = new AbortController();
14
+ request = controller;
15
+ void getFreezeNotice(controller.signal).then((result) => {
16
+ if (!live || controller.signal.aborted || !result.ok) return;
17
+ const next = result.data;
18
+ if (typeof next?.enabled === "boolean" && typeof next.text === "string") {
19
+ setNotice((current) => current.enabled === next.enabled && current.text === next.text
20
+ ? current : { enabled: next.enabled, text: next.text });
21
+ }
22
+ });
23
+ };
24
+ refresh();
25
+ const timer = window.setInterval(refresh, 30_000);
26
+ window.addEventListener("focus", refresh);
27
+ document.addEventListener("visibilitychange", refresh);
28
+ return () => {
29
+ live = false;
30
+ request?.abort();
31
+ window.clearInterval(timer);
32
+ window.removeEventListener("focus", refresh);
33
+ document.removeEventListener("visibilitychange", refresh);
34
+ };
35
+ }, []);
36
+ return notice;
37
+ }
38
+
39
+ export default function FreezeNotice({ notice, standalone = false }: {
40
+ notice?: FreezeNoticeState;
41
+ standalone?: boolean;
42
+ }) {
43
+ if (!notice?.enabled) return null;
44
+ const message = <span className="freeze-notice" role="status">{notice.text}</span>;
45
+ return standalone ? <div className="freeze-notice-band">{message}</div> : message;
46
+ }
web/src/shell/LoginPage.tsx CHANGED
@@ -12,6 +12,8 @@
12
  import { useEffect, useRef, useState } from "react";
13
  import type { FormEvent } from "react";
14
  import { Brand } from "./Brand";
 
 
15
  import { changePassword, login, passwordPolicy } from "./session";
16
  import type { LoginOutcome, PasswordPolicy, SessionUser } from "./session";
17
  import SecurityPane from "../settings/SecurityPane";
@@ -31,7 +33,10 @@ function EyeIcon({ off }: { off: boolean }) {
31
  );
32
  }
33
 
34
- export default function LoginPage({ onSignedIn }: { onSignedIn: (user: SessionUser) => void }) {
 
 
 
35
  const [username, setUsername] = useState("");
36
  const [password, setPassword] = useState("");
37
  const [error, setError] = useState("");
@@ -151,6 +156,7 @@ export default function LoginPage({ onSignedIn }: { onSignedIn: (user: SessionUs
151
 
152
  return (
153
  <div className="login-root">
 
154
  <div className="login-card">
155
  <Brand size={44} className="login-brand" />
156
 
 
12
  import { useEffect, useRef, useState } from "react";
13
  import type { FormEvent } from "react";
14
  import { Brand } from "./Brand";
15
+ import FreezeNotice from "./FreezeNotice";
16
+ import type { FreezeNoticeState } from "../settings/settingsApi";
17
  import { changePassword, login, passwordPolicy } from "./session";
18
  import type { LoginOutcome, PasswordPolicy, SessionUser } from "./session";
19
  import SecurityPane from "../settings/SecurityPane";
 
33
  );
34
  }
35
 
36
+ export default function LoginPage({ onSignedIn, freezeNotice }: {
37
+ onSignedIn: (user: SessionUser) => void;
38
+ freezeNotice?: FreezeNoticeState;
39
+ }) {
40
  const [username, setUsername] = useState("");
41
  const [password, setPassword] = useState("");
42
  const [error, setError] = useState("");
 
156
 
157
  return (
158
  <div className="login-root">
159
+ <FreezeNotice notice={freezeNotice} standalone />
160
  <div className="login-card">
161
  <Brand size={44} className="login-brand" />
162
 
web/src/shell/Shell.tsx CHANGED
@@ -95,6 +95,7 @@ import type { DeletedItem } from "../starred/starredApi";
95
  import { Brand } from "./Brand";
96
  import { ErrorBoundary } from "./ErrorBoundary";
97
  import LoginPage from "./LoginPage";
 
98
  import { APP_ROUTE, ARTIFACTS_ROUTE, ASSISTANT_ROUTE, CONNECTORS_ROUTE, DATA_ROUTE, EMPTY_NAV_PREFS, ENVELOPE_KEYS, FEEDBACK_ROUTE, HOME_ROUTE, INBOX_ROUTE, NO_SUBSCRIPTION_TENANT, SUBSCRIPTION_ROUTE, USAGE_ROUTE, NAV_ATTEMPTS, NAV_MALFORMED_STATUS, NAV_RETRY_DELAYS_MS, NAV_STAYS_EXPANDED_ROUTES, NAV_TIMEOUT_STATUS, agentAddressHash, appLink, canonicalRoute, databaseEntries, defaultRoute, deleteTable, fetchNav, fetchNavPrefs, fetchSchema, fetchTableFootprint, postOpened, dataAddressHash, readAgentAddress, readDataAddress, reportNavTimeout, resolveRoute, rewrittenHash, routeKeyOf, saveNavMeta, shapeNav, splitChrome } from "./nav";
99
  import type { NavEntry, NavMetaPatch, NavPage, NavPrefs, RailSlot, Recent, SchemaField, SchemaPayload } from "./nav";
100
  // ⭐ 2026-08-14 — the database frame, extracted so the Query module can wear the SAME one.
@@ -1783,6 +1784,7 @@ function readNavFold(): NavFold {
1783
  }
1784
 
1785
  function ShellFrame() {
 
1786
  const [session, setSession] = useState<Session>({ phase: "checking" });
1787
  const [nav, setNav] = useState<Nav>({ phase: "idle" });
1788
  const [financeNav, setFinanceNav] = useState<FinanceNav>({ phase: "idle" });
@@ -3096,7 +3098,12 @@ function ShellFrame() {
3096
  // `#/form/<token>` has always loaded for free. What it adds is a client route that renders
3097
  // something there instead of the login page.
3098
  if (formToken) {
3099
- return <FormPublic token={formToken} />;
 
 
 
 
 
3100
  }
3101
 
3102
  // ⭐⭐ W33-T26 (item 8b, R5) — THE PUBLISHED VIEW, on the same seam and by the same argument as
@@ -3108,15 +3115,23 @@ function ShellFrame() {
3108
  // ⚠ It returns BEFORE the boot gate below, so a stranger never sees the shell's brand card
3109
  // flash while `/me` decides they are nobody.
3110
  if (publishToken) {
3111
- return <PublishedView token={publishToken} />;
 
 
 
 
 
3112
  }
3113
 
3114
  if (session.phase === "checking") {
3115
  // Deliberately wordless. A "Loading…" line here would flash for one round
3116
  // trip on every load, and the mark says everything the moment needs.
3117
  return (
3118
- <div className="shell-boot">
3119
- <Brand size={44} className="login-brand" />
 
 
 
3120
  </div>
3121
  );
3122
  }
@@ -3124,6 +3139,7 @@ function ShellFrame() {
3124
  if (session.phase === "anon") {
3125
  return (
3126
  <LoginPage
 
3127
  onSignedIn={(user) => {
3128
  // HOTFIX 2026-09-24: an AI app's OAuth approval sent a signed-out visitor here
3129
  // (`routes_external.py::_login_bounce`). Go back to that approval, and only to it.
@@ -3334,6 +3350,7 @@ function ShellFrame() {
3334
  <div className="shell-topbar-brand">
3335
  <Brand size={26} className="shell-brand" />
3336
  </div>
 
3337
  </header>
3338
  <div className="shell-frame">
3339
  <OverlayScroll element="aside"
 
95
  import { Brand } from "./Brand";
96
  import { ErrorBoundary } from "./ErrorBoundary";
97
  import LoginPage from "./LoginPage";
98
+ import FreezeNotice, { useFreezeNotice } from "./FreezeNotice";
99
  import { APP_ROUTE, ARTIFACTS_ROUTE, ASSISTANT_ROUTE, CONNECTORS_ROUTE, DATA_ROUTE, EMPTY_NAV_PREFS, ENVELOPE_KEYS, FEEDBACK_ROUTE, HOME_ROUTE, INBOX_ROUTE, NO_SUBSCRIPTION_TENANT, SUBSCRIPTION_ROUTE, USAGE_ROUTE, NAV_ATTEMPTS, NAV_MALFORMED_STATUS, NAV_RETRY_DELAYS_MS, NAV_STAYS_EXPANDED_ROUTES, NAV_TIMEOUT_STATUS, agentAddressHash, appLink, canonicalRoute, databaseEntries, defaultRoute, deleteTable, fetchNav, fetchNavPrefs, fetchSchema, fetchTableFootprint, postOpened, dataAddressHash, readAgentAddress, readDataAddress, reportNavTimeout, resolveRoute, rewrittenHash, routeKeyOf, saveNavMeta, shapeNav, splitChrome } from "./nav";
100
  import type { NavEntry, NavMetaPatch, NavPage, NavPrefs, RailSlot, Recent, SchemaField, SchemaPayload } from "./nav";
101
  // ⭐ 2026-08-14 — the database frame, extracted so the Query module can wear the SAME one.
 
1784
  }
1785
 
1786
  function ShellFrame() {
1787
+ const freezeNotice = useFreezeNotice();
1788
  const [session, setSession] = useState<Session>({ phase: "checking" });
1789
  const [nav, setNav] = useState<Nav>({ phase: "idle" });
1790
  const [financeNav, setFinanceNav] = useState<FinanceNav>({ phase: "idle" });
 
3098
  // `#/form/<token>` has always loaded for free. What it adds is a client route that renders
3099
  // something there instead of the login page.
3100
  if (formToken) {
3101
+ return (
3102
+ <div className="freeze-page">
3103
+ <FreezeNotice notice={freezeNotice} standalone />
3104
+ <FormPublic token={formToken} />
3105
+ </div>
3106
+ );
3107
  }
3108
 
3109
  // ⭐⭐ W33-T26 (item 8b, R5) — THE PUBLISHED VIEW, on the same seam and by the same argument as
 
3115
  // ⚠ It returns BEFORE the boot gate below, so a stranger never sees the shell's brand card
3116
  // flash while `/me` decides they are nobody.
3117
  if (publishToken) {
3118
+ return (
3119
+ <div className="freeze-page">
3120
+ <FreezeNotice notice={freezeNotice} standalone />
3121
+ <PublishedView token={publishToken} />
3122
+ </div>
3123
+ );
3124
  }
3125
 
3126
  if (session.phase === "checking") {
3127
  // Deliberately wordless. A "Loading…" line here would flash for one round
3128
  // trip on every load, and the mark says everything the moment needs.
3129
  return (
3130
+ <div className="freeze-page">
3131
+ <FreezeNotice notice={freezeNotice} standalone />
3132
+ <div className="shell-boot">
3133
+ <Brand size={44} className="login-brand" />
3134
+ </div>
3135
  </div>
3136
  );
3137
  }
 
3139
  if (session.phase === "anon") {
3140
  return (
3141
  <LoginPage
3142
+ freezeNotice={freezeNotice}
3143
  onSignedIn={(user) => {
3144
  // HOTFIX 2026-09-24: an AI app's OAuth approval sent a signed-out visitor here
3145
  // (`routes_external.py::_login_bounce`). Go back to that approval, and only to it.
 
3350
  <div className="shell-topbar-brand">
3351
  <Brand size={26} className="shell-brand" />
3352
  </div>
3353
+ <FreezeNotice notice={freezeNotice} />
3354
  </header>
3355
  <div className="shell-frame">
3356
  <OverlayScroll element="aside"