Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs: note that cutover target proofs are bound to process start time (#8851)

[._.]/ Adam Eivyca0d97363e4f
diff --git a/docs/STORAGE.md b/docs/STORAGE.md
index 5b60a47b99..fbef33a592 100644
--- a/docs/STORAGE.md
+++ b/docs/STORAGE.md
@@ -147,7 +147,7 @@ After a committed import the same worker (`runDatabaseCutover` in `server/servic
- **`importing` → `committing`**: only with this operation's import receipt.
- **`committing` → `verifying`**: `.env` `PGMODE` is rewritten to the RECORDED target mode (temporary file, fsync, rename; every other line kept). A fresh process then evaluates `ecosystem.config.cjs` and must resolve exactly the recorded target endpoint. Recovery at `committing` repeats this same write — it never reads the file's current mode as evidence and never restores the source mode.
-- **`verifying` → `verified`**: the worker restarts the recorded `portos-server` with `pm2 restart ecosystem.config.cjs --only portos-server --update-env` (so PM2's cached environment cannot supply the old `PGPORT`). `server/start.js` sees the fence and runs only the narrow handshake (`server/services/databaseCutoverHandshake.js`): it proves ITS OWN pool — the captured host/port/database/user must equal the recorded target, and a read-only transaction must find the schema — publishes `target-proof-<pid>.json`, and waits. Routes, migrations, schedulers and CoS never load before release. The worker accepts proof only for the pid PM2 reports for that server now. PM2 `online`, the saved mode, or an earlier pid's proof is not success; a wrong pool or unhealthy target makes the server exit and the worker time out (3 minutes) with the operation left at `verifying`.
+- **`verifying` → `verified`**: the worker restarts the recorded `portos-server` with `pm2 restart ecosystem.config.cjs --only portos-server --update-env` (so PM2's cached environment cannot supply the old `PGPORT`). `server/start.js` sees the fence and runs only the narrow handshake (`server/services/databaseCutoverHandshake.js`): it proves ITS OWN pool — the captured host/port/database/user must equal the recorded target, and a read-only transaction must find the schema — publishes `target-proof-<pid>.json` bound to its process start time, and waits. Routes, migrations, schedulers and CoS never load before release. The worker accepts proof only for the pid PM2 reports for that server now, with the same process start time (a reused pid never inherits an earlier proof). PM2 `online`, the saved mode, or an earlier pid's proof is not success; a wrong pool or unhealthy target makes the server exit and the worker time out (3 minutes) with the operation left at `verifying`.
- **release**: after re-checking that the saved configuration still names the target, the worker writes `data/database-authority.json` (operation id, retired source and released target endpoints), then moves `data/database-maintenance/` to `data/database-maintenance-completed/<operation-id>/`, which reopens admission. The waiting server continues only when that authority names this operation and its own pool as the target. CoS restarts last, if it was running before the cutover. The worker prints `{ stage: "released", importCommitted: true, sourceRetained: true, restartVerified: true, cosRestarted }`.
**Expected downtime** is the whole run: PortOS (UI, API, CoS, agents and schedules) is stopped from `quiescing` until release. It is roughly one export plus one import of the database (seconds for a small install, minutes for a large catalog/memory store) plus a server restart. The API answers the cutover request with `202`; the next page load is the restarted server.