Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- Dockerfile +15 -3
- RELEASES.json +1 -1
- VERSION +1 -1
- platform/harness/telemetry.py +7 -2
- web/index.html +25 -0
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
- web/src/main.tsx +20 -0
- web/src/net/edgeRetry.ts +78 -0
Dockerfile
CHANGED
|
@@ -98,6 +98,18 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
|
| 98 |
# '*' assumes the container is unreachable except through that trusted proxy, which must replace
|
| 99 |
# client-supplied forwarded headers. For any direct ingress, set FORWARDED_ALLOW_IPS to the actual
|
| 100 |
# proxy IPs/CIDRs before exposing the port; do not carry wildcard trust onto a public listener.
|
| 101 |
-
# Suppress the server banner
|
| 102 |
-
#
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
# '*' assumes the container is unreachable except through that trusted proxy, which must replace
|
| 99 |
# client-supplied forwarded headers. For any direct ingress, set FORWARDED_ALLOW_IPS to the actual
|
| 100 |
# proxy IPs/CIDRs before exposing the port; do not carry wildcard trust onto a public listener.
|
| 101 |
+
# Suppress the server banner. W59-T36 owns the API posture read-back and application host/header
|
| 102 |
+
# policy; these flags are its launcher seam.
|
| 103 |
+
#
|
| 104 |
+
# SDLC 67 close (2026-09-29): `--timeout-keep-alive 5` was the suspected cause of a measured
|
| 105 |
+
# 4-12% 502 rate at the HF proxy -- uvicorn closes an idle keep-alive socket after 5s, and if the
|
| 106 |
+
# proxy in front of it still believes that connection is reusable and forwards a request onto it,
|
| 107 |
+
# the client sees a 502 rather than a fresh connection (the classic reverse-proxy keep-alive race:
|
| 108 |
+
# https://adamcrowder.net/posts/node-express-api-and-aws-alb-502/ describes the same shape against
|
| 109 |
+
# an ALB). The fix is always the same direction -- make the BACKEND's idle timeout longer than
|
| 110 |
+
# whatever the front proxy holds a connection for, never shorter -- because only the side with the
|
| 111 |
+
# longer timeout can be the one to close first. HF's Spaces proxy timeout is not published; 75s is
|
| 112 |
+
# nginx's own keepalive_timeout default and comfortably exceeds the AWS ALB default (60s) other
|
| 113 |
+
# proxies in this class use, so it is the safest available floor without over-fitting to a number
|
| 114 |
+
# we cannot read. Re-aim this value again, never delete the flag, if a measurement finds otherwise.
|
| 115 |
+
CMD ["sh", "-c", "uvicorn api.main:app --host 0.0.0.0 --port ${PORT} --proxy-headers --forwarded-allow-ips \"${FORWARDED_ALLOW_IPS}\" --no-server-header --timeout-keep-alive 75"]
|
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "71091828",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
71091828
|
platform/harness/telemetry.py
CHANGED
|
@@ -70,8 +70,13 @@ def error(where, exc=None, **fields):
|
|
| 70 |
ERR_PATH.parent.mkdir(parents=True, exist_ok=True)
|
| 71 |
with ERR_PATH.open("a", encoding="utf-8") as f:
|
| 72 |
f.write(json.dumps(rec, default=str) + "\n")
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
except Exception:
|
| 76 |
pass
|
| 77 |
|
|
|
|
| 70 |
ERR_PATH.parent.mkdir(parents=True, exist_ok=True)
|
| 71 |
with ERR_PATH.open("a", encoding="utf-8") as f:
|
| 72 |
f.write(json.dumps(rec, default=str) + "\n")
|
| 73 |
+
# SDLC 67 sweep: an exc-less call (routes_activity forwarding a client error) left
|
| 74 |
+
# `type`/`msg` unset, so this mirror printed an empty ": " on every one -- the JSONL line
|
| 75 |
+
# kept the real `name`/`message`/`source` fields, only the container-log mirror lost them.
|
| 76 |
+
detail = f"{rec.get('type', '')} {rec.get('msg', '')}".strip()
|
| 77 |
+
if not detail:
|
| 78 |
+
detail = " ".join(f"{k}={v}" for k, v in fields.items() if v) or "(no detail)"
|
| 79 |
+
print(f"[app-error] {rec['ts']} {rec['where']}: {detail}", file=sys.stderr, flush=True)
|
| 80 |
except Exception:
|
| 81 |
pass
|
| 82 |
|
web/index.html
CHANGED
|
@@ -5,6 +5,31 @@
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title>Loopable</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
</head>
|
| 9 |
<body>
|
| 10 |
<!-- ⭐⭐ WAVE 37 · T48 — THE BOOT SKELETON, AND EVERY CHOICE HERE IS FORCED BY WHEN IT HAS TO
|
|
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title>Loopable</title>
|
| 8 |
+
<!-- SDLC 67 close (2026-09-29): THE BOOT WATCHDOG. HF's Space proxy answered 502 on 12-20% of
|
| 9 |
+
requests (measured on staging, public live and a third-party Space); the app needs ~12
|
| 10 |
+
static chunks to start, and ONE 502 among them leaves this skeleton on screen forever
|
| 11 |
+
(seen in the owner's Chrome: alertsModel-*.js 502, root never mounted). Inline, in <head>
|
| 12 |
+
and first, so its capture listener exists before Vite's module script and preload links.
|
| 13 |
+
A failed /assets/ fetch reloads the page, at most 4 times with a growing delay; chunks are
|
| 14 |
+
served `immutable`, so each reload refetches only what failed. main.tsx calls
|
| 15 |
+
__aiosBootOk() once every static chunk ran, which clears the counter. -->
|
| 16 |
+
<script>
|
| 17 |
+
(function () {
|
| 18 |
+
var KEY = "aios.bootRetry", MAX = 4, n = 0, armed = false;
|
| 19 |
+
try { n = +(sessionStorage.getItem(KEY) || 0) || 0; } catch (e) { n = MAX; }
|
| 20 |
+
window.addEventListener("error", function (ev) {
|
| 21 |
+
var t = ev.target, url = (t && (t.src || t.href)) || "";
|
| 22 |
+
if (armed || window.__aiosBooted || n >= MAX || !/\/assets\//.test(url)) return;
|
| 23 |
+
armed = true;
|
| 24 |
+
try { sessionStorage.setItem(KEY, String(n + 1)); } catch (e) { return; }
|
| 25 |
+
setTimeout(function () { location.reload(); }, 400 * (n + 1));
|
| 26 |
+
}, true);
|
| 27 |
+
window.__aiosBootOk = function () {
|
| 28 |
+
window.__aiosBooted = true;
|
| 29 |
+
try { sessionStorage.removeItem(KEY); } catch (e) {}
|
| 30 |
+
};
|
| 31 |
+
})();
|
| 32 |
+
</script>
|
| 33 |
</head>
|
| 34 |
<body>
|
| 35 |
<!-- ⭐⭐ WAVE 37 · T48 — THE BOOT SKELETON, AND EVERY CHOICE HERE IS FORCED BY WHEN IT HAS TO
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
0f51f515b311445aaeb900f756a66d6420013698aab804554ea5f9f4a5f8e3f2
|
web/src/main.tsx
CHANGED
|
@@ -5,10 +5,30 @@ import App, { HOSTED } from './App.tsx'
|
|
| 5 |
import { installStandaloneBridge } from './customer-grid/apiBridge'
|
| 6 |
import { initializeHostBridge } from './customer-grid/hostBridge'
|
| 7 |
import { installActivityLog } from './settings/activityLog'
|
|
|
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
initializeHostBridge()
|
|
|
|
|
|
|
| 10 |
installActivityLog()
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
// EXIT wave 1 (X2): the standalone write path. THE ONE WIRING POINT — the embed
|
| 13 |
// bundle runs this file too, and the branch below is the whole of the wave's
|
| 14 |
// "standalone-only branches" promise. `HOSTED` is App.tsx's own constant, not a
|
|
|
|
| 5 |
import { installStandaloneBridge } from './customer-grid/apiBridge'
|
| 6 |
import { initializeHostBridge } from './customer-grid/hostBridge'
|
| 7 |
import { installActivityLog } from './settings/activityLog'
|
| 8 |
+
import { installEdgeRetry } from './net/edgeRetry'
|
| 9 |
|
| 10 |
+
// SDLC 67 close: this module body runs only once EVERY static chunk arrived, so this is the
|
| 11 |
+
// moment the index.html boot watchdog stops retrying (it reloads when a boot chunk 502s).
|
| 12 |
+
window.__aiosBootOk?.()
|
| 13 |
initializeHostBridge()
|
| 14 |
+
// Before the activity log, so the log wraps the retrying fetch and records final statuses.
|
| 15 |
+
installEdgeRetry()
|
| 16 |
installActivityLog()
|
| 17 |
|
| 18 |
+
// SDLC 67 close (2026-09-29): a stale HTML page requests a hashed chunk (`ribbon-*.css`, a lazy
|
| 19 |
+
// route) that no longer exists once a redeploy replaces it, OR the HF proxy's 502 land mid-chunk --
|
| 20 |
+
// either way Vite's runtime dispatches this event instead of letting the broken `import()` reject
|
| 21 |
+
// into an unhandled rejection, and the page is left blank ("Sheet could not be shown"). One reload
|
| 22 |
+
// picks up the new HTML with the new chunk map; the session-storage guard stops a genuinely broken
|
| 23 |
+
// deploy from reload-looping the tab forever.
|
| 24 |
+
window.addEventListener("vite:preloadError", event => {
|
| 25 |
+
const KEY = "aios.preloadReloadedOnce"
|
| 26 |
+
if (sessionStorage.getItem(KEY)) return
|
| 27 |
+
try { sessionStorage.setItem(KEY, "1") } catch { /* private mode: reload once anyway */ }
|
| 28 |
+
event.preventDefault()
|
| 29 |
+
window.location.reload()
|
| 30 |
+
})
|
| 31 |
+
|
| 32 |
// EXIT wave 1 (X2): the standalone write path. THE ONE WIRING POINT — the embed
|
| 33 |
// bundle runs this file too, and the branch below is the whole of the wave's
|
| 34 |
// "standalone-only branches" promise. `HOSTED` is App.tsx's own constant, not a
|
web/src/net/edgeRetry.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// SDLC 67 close (2026-09-29): THE HOSTING EDGE DROPS REQUESTS, SO READS RETRY.
|
| 2 |
+
//
|
| 3 |
+
// Measured on 2026-09-29: HF's Space proxy answered 502 (its own HTML page, never reaching
|
| 4 |
+
// uvicorn) on 12-20% of requests under a browser-like burst, on staging, on public live AND on a
|
| 5 |
+
// third-party Space (gradio-hello-world, 3 of 24). After the app booted, `/nav` and
|
| 6 |
+
// `/nav/applications` came back 502 and the rail read "Navigation unavailable". Nothing in the
|
| 7 |
+
// app retried, so one dropped read was one broken panel.
|
| 8 |
+
//
|
| 9 |
+
// ⛔ ONLY SAFE METHODS RETRY (GET, HEAD). A POST that 502s may or may not have reached the server;
|
| 10 |
+
// replaying it could write twice. Those keep failing loudly, exactly as before.
|
| 11 |
+
// ⛔ ONLY SAME-ORIGIN. A third-party endpoint has its own retry semantics.
|
| 12 |
+
// ⛔ AN ABORTED READ NEVER RETRIES: aborting is how a component says "I no longer want this".
|
| 13 |
+
// Installed BEFORE `installActivityLog`, so the activity log wraps THIS fetch and records one
|
| 14 |
+
// request with its final status, not every attempt.
|
| 15 |
+
|
| 16 |
+
const RETRY_STATUS = new Set([502, 503, 504]);
|
| 17 |
+
const SAFE_METHODS = new Set(["GET", "HEAD"]);
|
| 18 |
+
/** Delays before attempts 2 and 3. Three attempts at a ~20% drop rate fail ~0.8% of reads. */
|
| 19 |
+
export const RETRY_DELAYS_MS = [250, 700];
|
| 20 |
+
|
| 21 |
+
let installed = false;
|
| 22 |
+
|
| 23 |
+
function methodOf(input: RequestInfo | URL, init?: RequestInit): string {
|
| 24 |
+
return String(init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function sameOrigin(input: RequestInfo | URL): boolean {
|
| 28 |
+
try {
|
| 29 |
+
const raw = input instanceof Request ? input.url : String(input);
|
| 30 |
+
return new URL(raw, window.location.origin).origin === window.location.origin;
|
| 31 |
+
} catch {
|
| 32 |
+
return false;
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
function aborted(input: RequestInfo | URL, init?: RequestInit): boolean {
|
| 37 |
+
return Boolean(init?.signal?.aborted || (input instanceof Request && input.signal?.aborted));
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
function wait(ms: number): Promise<void> {
|
| 41 |
+
return new Promise(resolve => window.setTimeout(resolve, ms));
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/** PURE over its inputs: may this request be retried after `status` (0 = network failure)? */
|
| 45 |
+
export function mayRetry(method: string, isSameOrigin: boolean, status: number): boolean {
|
| 46 |
+
return SAFE_METHODS.has(method) && isSameOrigin && (status === 0 || RETRY_STATUS.has(status));
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
export function withEdgeRetry(nativeFetch: typeof fetch, delays: number[] = RETRY_DELAYS_MS): typeof fetch {
|
| 50 |
+
return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
| 51 |
+
const method = methodOf(input, init);
|
| 52 |
+
const local = sameOrigin(input);
|
| 53 |
+
for (let attempt = 0; ; attempt++) {
|
| 54 |
+
const last = attempt >= delays.length;
|
| 55 |
+
try {
|
| 56 |
+
const response = await nativeFetch(input, init);
|
| 57 |
+
if (last || !mayRetry(method, local, response.status) || aborted(input, init)) return response;
|
| 58 |
+
void response.body?.cancel().catch(() => undefined); // free the dropped 502 page
|
| 59 |
+
} catch (error) {
|
| 60 |
+
if (last || !mayRetry(method, local, 0) || aborted(input, init)) throw error;
|
| 61 |
+
}
|
| 62 |
+
await wait(delays[attempt]);
|
| 63 |
+
}
|
| 64 |
+
};
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
export function installEdgeRetry(): void {
|
| 68 |
+
if (typeof window === "undefined" || installed) return;
|
| 69 |
+
installed = true;
|
| 70 |
+
window.fetch = withEdgeRetry(window.fetch.bind(window));
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
declare global {
|
| 74 |
+
interface Window {
|
| 75 |
+
/** Defined by index.html's boot watchdog; main.tsx calls it once every static chunk ran. */
|
| 76 |
+
__aiosBootOk?: () => void;
|
| 77 |
+
}
|
| 78 |
+
}
|