Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/main.py +16 -8
- api/routes_forms.py +5 -0
- api/sync_worker.py +27 -0
- api/tickets.py +1 -1
- api/tool_groups/apps.py +3 -2
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "d178e26f6",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
d178e26f6
|
api/main.py
CHANGED
|
@@ -3768,7 +3768,7 @@ def _store_resync_loop():
|
|
| 3768 |
_slot_write(_t.time(), "slotDoneAt")
|
| 3769 |
|
| 3770 |
|
| 3771 |
-
def _boot_app_migrations(why):
|
| 3772 |
"""Apply tenant App retirement migrations independently of mirror sync and reads."""
|
| 3773 |
if _freeze_holds("app migrations"):
|
| 3774 |
return
|
|
@@ -3777,7 +3777,8 @@ def _boot_app_migrations(why):
|
|
| 3777 |
import timeseries_retirement
|
| 3778 |
import tenant_scan
|
| 3779 |
from harness import runtime as _runtime
|
| 3780 |
-
tenants = list(tenant_scan.live_tenants(_runtime)
|
|
|
|
| 3781 |
except Exception as exc:
|
| 3782 |
print(f"[aios-api] app migrations ({why}) skipped: {type(exc).__name__}: {exc}")
|
| 3783 |
return
|
|
@@ -4381,6 +4382,7 @@ if (not data_binding.gate_process()
|
|
| 4381 |
name="qa-sandbox-schema").start()
|
| 4382 |
|
| 4383 |
if (not data_binding.gate_process()
|
|
|
|
| 4384 |
and os.environ.get("AIOS_BOOT_APP_MIGRATIONS") != "0"
|
| 4385 |
and (bool(os.environ.get("SPACE_ID")) or os.environ.get("AIOS_BOOT_APP_MIGRATIONS") == "1")
|
| 4386 |
and not _freeze_holds("app migrations")):
|
|
@@ -4451,9 +4453,15 @@ if (not data_binding.gate_process()
|
|
| 4451 |
# The other structural cost remains outside that skip policy:
|
| 4452 |
# * the whole-document store write itself. A partial-JSONB write is a wave.
|
| 4453 |
# ⚠ SO DO NOT PUT THIS BACK TO 3600 to "fix staleness" without closing one of those two first.
|
| 4454 |
-
|
| 4455 |
-
|
| 4456 |
-
|
| 4457 |
-
|
| 4458 |
-
|
| 4459 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3768 |
_slot_write(_t.time(), "slotDoneAt")
|
| 3769 |
|
| 3770 |
|
| 3771 |
+
def _boot_app_migrations(why, tenant=None):
|
| 3772 |
"""Apply tenant App retirement migrations independently of mirror sync and reads."""
|
| 3773 |
if _freeze_holds("app migrations"):
|
| 3774 |
return
|
|
|
|
| 3777 |
import timeseries_retirement
|
| 3778 |
import tenant_scan
|
| 3779 |
from harness import runtime as _runtime
|
| 3780 |
+
tenants = list(tenant_scan.live_tenants(_runtime, tenants=[tenant]) if tenant is not None
|
| 3781 |
+
else tenant_scan.live_tenants(_runtime))
|
| 3782 |
except Exception as exc:
|
| 3783 |
print(f"[aios-api] app migrations ({why}) skipped: {type(exc).__name__}: {exc}")
|
| 3784 |
return
|
|
|
|
| 4382 |
name="qa-sandbox-schema").start()
|
| 4383 |
|
| 4384 |
if (not data_binding.gate_process()
|
| 4385 |
+
and process_role.role() != "worker"
|
| 4386 |
and os.environ.get("AIOS_BOOT_APP_MIGRATIONS") != "0"
|
| 4387 |
and (bool(os.environ.get("SPACE_ID")) or os.environ.get("AIOS_BOOT_APP_MIGRATIONS") == "1")
|
| 4388 |
and not _freeze_holds("app migrations")):
|
|
|
|
| 4453 |
# The other structural cost remains outside that skip policy:
|
| 4454 |
# * the whole-document store write itself. A partial-JSONB write is a wave.
|
| 4455 |
# ⚠ SO DO NOT PUT THIS BACK TO 3600 to "fix staleness" without closing one of those two first.
|
| 4456 |
+
def _start_store_resync():
|
| 4457 |
+
# The worker calls this after its boot migrations finish: a per-pass idle exit must wait.
|
| 4458 |
+
if (not data_binding.gate_process()
|
| 4459 |
+
and os.environ.get("AIOS_STORE_RESYNC") == "1" and not _freeze_holds("store resync")):
|
| 4460 |
+
import process_role as _role_resync
|
| 4461 |
+
_role_resync.thread(target=_store_resync_loop, daemon=True, kind="heavy", name="store-resync").start()
|
| 4462 |
+
import sheet_warm as _sheet_warm
|
| 4463 |
+
_sheet_warm.start()
|
| 4464 |
+
|
| 4465 |
+
|
| 4466 |
+
if process_role.role() != "worker":
|
| 4467 |
+
_start_store_resync()
|
api/routes_forms.py
CHANGED
|
@@ -772,6 +772,11 @@ async def submit_form(token: str, request: Request):
|
|
| 772 |
if problem:
|
| 773 |
raise err(400, "invalid_submission", problem)
|
| 774 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 775 |
# ⚠ THE DAILY CAP IS SPENT ON A WRITE, NOT ON A REQUEST, and the order is the whole point.
|
| 776 |
# Counted before validation — where it was first — 500 malformed POSTs take a LIVE form
|
| 777 |
# offline for 24 hours, and one address can send them in about 17 minutes under the per-IP
|
|
|
|
| 772 |
if problem:
|
| 773 |
raise err(400, "invalid_submission", problem)
|
| 774 |
|
| 775 |
+
from core import module_tables
|
| 776 |
+
add_refusal = module_tables.records_add_refusal(table_key)
|
| 777 |
+
if add_refusal:
|
| 778 |
+
raise err(403, "records_add_refused", add_refusal)
|
| 779 |
+
|
| 780 |
# ⚠ THE DAILY CAP IS SPENT ON A WRITE, NOT ON A REQUEST, and the order is the whole point.
|
| 781 |
# Counted before validation — where it was first — 500 malformed POSTs take a LIVE form
|
| 782 |
# offline for 24 hours, and one address can send them in about 17 minutes under the per-IP
|
api/sync_worker.py
CHANGED
|
@@ -88,6 +88,31 @@ def load_app(parent=None):
|
|
| 88 |
return importlib.import_module("api.main")
|
| 89 |
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
def main(argv=None):
|
| 92 |
import sync_runtime
|
| 93 |
args = sys.argv[1:] if argv is None else argv
|
|
@@ -118,6 +143,8 @@ def main(argv=None):
|
|
| 118 |
os._exit(0)
|
| 119 |
# Importing the app starts every role-allowed thread at module level. Startup hooks need a call.
|
| 120 |
app_main = load_app()
|
|
|
|
|
|
|
| 121 |
if getattr(app_main, "_SEED_THREAD", None) is None:
|
| 122 |
# No boot restore was scheduled, so no boot hand-off will come. Say so, or web readiness waits.
|
| 123 |
process_role.note_boot_restore("skipped")
|
|
|
|
| 88 |
return importlib.import_module("api.main")
|
| 89 |
|
| 90 |
|
| 91 |
+
def boot_app_migrations(app_main):
|
| 92 |
+
"""Run this worker's tenant migrations once, before any resync loop may exit the job."""
|
| 93 |
+
import process_role
|
| 94 |
+
if (os.environ.get("AIOS_BOOT_APP_MIGRATIONS") == "0"
|
| 95 |
+
or app_main.data_binding.gate_process()):
|
| 96 |
+
return
|
| 97 |
+
previous = getattr(app_main, "_WORKER_APP_MIGRATIONS_JOB", None)
|
| 98 |
+
if previous is not None:
|
| 99 |
+
previous.join()
|
| 100 |
+
return
|
| 101 |
+
tenant = process_role.writer_tenant()
|
| 102 |
+
# The general App migration scans all tenants and is refused in tenant workers. Only this
|
| 103 |
+
# worker entry registers the name, with a target bound to the tenant whose lease it holds.
|
| 104 |
+
allowed_jobs = process_role.TENANT_WORKER_JOBS
|
| 105 |
+
try:
|
| 106 |
+
process_role.TENANT_WORKER_JOBS = allowed_jobs | {"app-migrations"}
|
| 107 |
+
job = process_role.start("app-migrations", "heavy", app_main._boot_app_migrations,
|
| 108 |
+
args=("worker boot",), kwargs={"tenant": tenant})
|
| 109 |
+
finally:
|
| 110 |
+
process_role.TENANT_WORKER_JOBS = allowed_jobs
|
| 111 |
+
if job is not None:
|
| 112 |
+
app_main._WORKER_APP_MIGRATIONS_JOB = job
|
| 113 |
+
job.join()
|
| 114 |
+
|
| 115 |
+
|
| 116 |
def main(argv=None):
|
| 117 |
import sync_runtime
|
| 118 |
args = sys.argv[1:] if argv is None else argv
|
|
|
|
| 143 |
os._exit(0)
|
| 144 |
# Importing the app starts every role-allowed thread at module level. Startup hooks need a call.
|
| 145 |
app_main = load_app()
|
| 146 |
+
boot_app_migrations(app_main)
|
| 147 |
+
app_main._start_store_resync()
|
| 148 |
if getattr(app_main, "_SEED_THREAD", None) is None:
|
| 149 |
# No boot restore was scheduled, so no boot hand-off will come. Say so, or web readiness waits.
|
| 150 |
process_role.note_boot_restore("skipped")
|
api/tickets.py
CHANGED
|
@@ -328,7 +328,7 @@ def ensure_table(rt):
|
|
| 328 |
def _application_source(rt, app_id):
|
| 329 |
"""Read an App's current source metadata without copying its code or configuration."""
|
| 330 |
import application_registry as apps
|
| 331 |
-
app = apps.
|
| 332 |
if not isinstance(app, dict) or str(app.get("tenant")) != str(rt.key):
|
| 333 |
raise ValueError("The source App could not be found.")
|
| 334 |
return {key: copy.deepcopy(app.get(key)) for key in
|
|
|
|
| 328 |
def _application_source(rt, app_id):
|
| 329 |
"""Read an App's current source metadata without copying its code or configuration."""
|
| 330 |
import application_registry as apps
|
| 331 |
+
app = apps.load(rt, strict=True)["applications"].get(str(app_id))
|
| 332 |
if not isinstance(app, dict) or str(app.get("tenant")) != str(rt.key):
|
| 333 |
raise ValueError("The source App could not be found.")
|
| 334 |
return {key: copy.deepcopy(app.get(key)) for key in
|
api/tool_groups/apps.py
CHANGED
|
@@ -550,8 +550,9 @@ def guide(ctx, args):
|
|
| 550 |
def preview_documents(documents):
|
| 551 |
"""Project code bodies to a bounded excerpt before the host computes its diff."""
|
| 552 |
projected = copy.deepcopy(documents)
|
| 553 |
-
pair
|
| 554 |
-
|
|
|
|
| 555 |
for side in ("before", "after"):
|
| 556 |
if not isinstance(pair[side], dict):
|
| 557 |
continue
|
|
|
|
| 550 |
def preview_documents(documents):
|
| 551 |
"""Project code bodies to a bounded excerpt before the host computes its diff."""
|
| 552 |
projected = copy.deepcopy(documents)
|
| 553 |
+
for key, pair in projected.items():
|
| 554 |
+
if key != applications._KEY and not key.startswith(applications._RECORD_PREFIX):
|
| 555 |
+
continue
|
| 556 |
for side in ("before", "after"):
|
| 557 |
if not isinstance(pair[side], dict):
|
| 558 |
continue
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
47b740d000af12fbb4dd3f7e066a0c019ed6aae73325b980ed705f203d213588
|