From 5c9dc12cbd676a07c4a67e8134230bb196b78be6 Mon Sep 17 00:00:00 2001
From: Elliot Braem SSR unavailable, showing client app. ${error.message} Loading... SSR unavailable, showing client app. ${error.message} Loading...
- bos publish --deploy
- {" "}
- uploads new builds to Zephyr CDN, the host can reload without restarting.
- Admin users can call{" "}
-
- POST /api/_reload-config
- {" "}
- to swap in the latest config, or it re-fetches from the NEAR blockchain
- automatically.
- >
- }
-/>
-```
-
-Future: a button on the page that triggers deploy via opencode server + reload.
-
-**Complexity**: Low (UI text change)
-
-## Security considerations
-
-| Concern | Mitigation |
-|---------|-----------|
-| Unauthorized reload | Session cookie + admin role check on `POST /api/_reload-config` |
-| Malicious config injection | `RuntimeConfigSchema.parse()` validates the entire structure |
-| Config with wrong URLs | New scope health-check before swap; old scope stays if new fails |
-| Concurrent reloads | Mutex around `reloadWithConfig()` — only one reload at a time |
-| Memory during swap | Old scope disposed immediately after swap; brief 2x memory during transition |
-| Active sessions | Better Auth sessions persist in DB; new scope reads same DB; sessions survive reload |
-| DB connections | Old scope's DB connection closed in dispose; new scope opens its own |
-
-## File change summary
-
-| File | Change | Phase |
-|------|--------|-------|
-| `host/src/program.ts` | Extract `createScopedApp`, add mutable handler, add `reloadWithConfig()` | 1, 2 |
-| `host/src/program.ts` | Two-layer Hono app with `/api/_reload-config` | 3 |
-| `host/src/services/federation.server.ts` | Export `resetFederationInstance()` | 4 |
-| `packages/everything-dev/src/host.ts` | Add `resetState()` + `/api/_reload-config` | 5 |
-| `packages/everything-dev/src/plugin.ts` | Call reload endpoint after publish | 6 |
-| `ui/src/routes/_layout/opencode.tsx` | Add deploy & reload description | 7 |
-| `packages/everything-dev/src/fastkv.ts` | Export `fetchBosConfigFromFastKv` if not already | 3 |
-| `packages/everything-dev/src/config.ts` | Export `buildRuntimeConfig` if not already | 3 |
-
-## What this enables
-
-**Dev workflow (today):**
-
-```
-opencode edits file → HMR at :3003 → see changes instantly
-bos publish --deploy → host restart required → new UI live
-```
-
-**Dev workflow (after this refactor):**
-
-```
-opencode edits file → HMR at :3003 → see changes instantly
-bos publish --deploy → POST /api/_reload-config → new UI live without restart
-```
-
-**Browser-triggered workflow (future):**
-
-```
-/opencode page → prompt opencode server → edit + deploy → reload endpoint → live
-```
-
-**Production workflow (Docker/Railway):**
-
-```
-bos publish --deploy → FastKV updated → POST /api/_reload-config (empty body)
- → host re-fetches from FastKV → rebuilds scope → next request gets new UI
-```
-
-No SSH, no Docker restart, no Railway redeploy. The configuration governance
-stays on the NEAR blockchain where it belongs.
\ No newline at end of file