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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
docs: document missing env vars and boot CREATE INDEX lock risk (#2546)
Adam Eivy8353541a5513
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 4cb3eaebb2..e4f30cfc32 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -5,6 +5,10 @@- **First-run tutorial for POST cognitive drills.** The timed, stimulus-driven cognitive drills (n-back, digit-span, stroop, schulte-table, mental-rotation, reaction-time) start flashing a stimulus the instant they mount, which is disorienting the first time you meet one. Each drill type now shows a one-time how-to card — a plain-language goal, numbered steps, and the controls — the first time it's encountered, and holds the drill (and its timers) until you tap **Start drill**. The card is config-aware (it names the n-back lag, the digit-span direction, and the reaction-time mode), then never shows again for that type (tracked per type in `localStorage`). Non-timed drills (math/memory, LLM/verbal) are self-explanatory and are not gated.- **Voice fast-resolution cascade (lower CoS latency, opt-in).** The voice Chief of Staff can now triage each spoken/typed turn through fast client-side tiers before the (slow) server LLM: **tier 1 triggers** resolve navigation commands ("go to tasks", "open the daily log") instantly in the browser with no LLM; **tier 2** runs Chrome's on-device **Gemini Nano** (Prompt API — `window.LanguageModel` / legacy `self.ai.languageModel`) for simple/conversational turns, entirely local and private; **tier 3** is the existing server pipeline (recommend Ollama), which still handles every tool/action turn, personal-data retrieval, dictation, and confirmations. Off by default (existing installs keep all-server behavior); enable under **Settings → Voice → Fast resolution**, which also shows a live on-device-model availability pill with the `chrome://flags` hint. Applies to Web-Speech STT and typed input (whisper/hands-free audio turns stay server-driven); trigger/Nano replies are spoken through the configured TTS and keep barge-in + echo-suppression working. New `llm.fastPath` config (`enabled`/`triggers`/`browserLlm`/`browser.{temperature,topK}`); new client modules `browserLlm.js` (Nano client) and `voiceFastPath.js` (routing decision). Nothing runs a model the user hasn't triggered (no cold-bootstrap).+## Documentation++- **[issue-2546] Document missing `.env` vars and the boot `CREATE INDEX` lock window.** `.env.example` now carries commented entries with purpose notes for four vars the server actually reads but never documented: `PUBLIC_HOST` (public hostname baked into Google/Spotify OAuth redirect URIs), `SPOTIFY_REDIRECT_URI` (verbatim Spotify redirect override), `CODEX_HOME` (Codex CLI home scanned for provider-usage stats), and `HUGGINGFACE_TOKEN` (the fourth HF-token alias read by the Hugging Face catalog client). Separately, `ensureSchema()` in `server/lib/db.js` creates every index (incl. the HNSW vector index) non-`CONCURRENTLY`, so the first apply on a large pre-existing table takes a write-blocking lock at boot; a comment there and a new **Boot schema upgrades & the CREATE INDEX lock window** section in `docs/STORAGE.md` explain when this bites (existing-install upgrades, not fresh installs) and why the fix for a future large-table index is a `CONCURRENTLY` db-migration rather than changing `ensureSchema()`. Docs-only — no runtime behavior change.+## Fixed- **POST Digit Span: the form no longer jumps up as digits flash on and off.** During the show phase the visible-digit slot collapsed to zero height in the blank gaps between digits, so the container (padding + `min-h`) oscillated and the recall form/progress bar below shifted up on every flash. The slot now reserves its line box with a non-breaking space in the gaps, keeping the layout steady while digits flash.diff --git a/.env.example b/.env.exampleindex 07df40b321..b7eea641d1 100644--- a/.env.example+++ b/.env.example@@ -37,6 +37,18 @@ PGPASSWORD=portos# Server host binding for Express listen (default: 0.0.0.0)# HOST=0.0.0.0+# Public-facing hostname baked into OAuth redirect URIs for Google Calendar/Gmail+# (googleAuth.js) and Spotify (spotifyAuth.js). Defaults to "localhost". Set this to+# the host the OAuth provider will redirect back to (e.g. your Tailscale MagicDNS name)+# so the callback URL matches what you registered in the provider dashboard.+# PUBLIC_HOST=host-example.ts.net++# Explicit override for the Spotify OAuth redirect URI (spotifyAuth.js). When set, it is+# used verbatim instead of the auto-derived http://PUBLIC_HOST:PORT/api/spotify/oauth/callback.+# It must match the redirect URI registered in the Spotify dashboard byte-for-byte+# (use this when your public URL is HTTPS or differs from the auto-derived form).+# SPOTIFY_REDIRECT_URI=https://host-example.ts.net:5555/api/spotify/oauth/callback+# OpenClaw integration (configured via Settings UI; env overrides take precedence)# OPENCLAW_ENABLED=true# OPENCLAW_BASE_URL=https://your-openclaw-instance.example.com@@ -63,6 +75,11 @@ PGPASSWORD=portos# Path to the Claude CLI binary (defaults to system PATH)# CLAUDE_PATH=/usr/local/bin/claude+# Codex CLI home directory scanned for token-usage stats in the AI provider usage+# dashboard (providerUsage.js). Defaults to ~/.codex. Set this if your Codex CLI+# stores its session logs somewhere other than the default location.+# CODEX_HOME=/path/to/.codex+# Path to a specific pg_dump binary for database backups. By default PortOS# auto-selects one whose major version is >= the running server (it scans# Homebrew kegs + Postgres.app). Set this if auto-discovery can't find a new@@ -82,6 +99,9 @@ PGPASSWORD=portos# HF_TOKEN=hf_...# HUGGINGFACE_HUB_TOKEN=hf_...# HUGGINGFACEHUB_API_TOKEN=hf_...+# Additional alias read by the Hugging Face catalog API client (huggingFaceCatalog.js)+# for authenticated model-metadata lookups; falls back to HF_TOKEN when unset.+# HUGGINGFACE_TOKEN=hf_...# Google Gemini API key (used by the Google AI provider in Settings → AI Providers)# GOOGLE_API_KEY=AIza...diff --git a/docs/STORAGE.md b/docs/STORAGE.mdindex 47588f499a..017df184f6 100644--- a/docs/STORAGE.md+++ b/docs/STORAGE.md@@ -143,6 +143,14 @@ The escape hatch is **guarded from bitrot by the test suite** (tests boot with ``PGPASSWORD`/`PGUSER`/`PGDATABASE`/`PGPORT` are resolved from `process.env` first, then `.env`, then the backward-compatible defaults (`portos`/`portos`/`portos`/`5432`). The default `portos` password is an **intentional** local-development fallback (see the Distribution model note in [`CLAUDE.md`](../CLAUDE.md)); production deployments override it via `PGPASSWORD`.+### Boot schema upgrades & the CREATE INDEX lock window++`ensureSchema()` in `server/lib/db.js` applies **idempotent** schema upgrades on every boot (`CREATE TABLE IF NOT EXISTS`, `ADD COLUMN IF NOT EXISTS`, `CREATE INDEX IF NOT EXISTS`). Every index it creates — including the HNSW vector index and the GIN full-text index on `catalog_scraps` — is a plain, **non-`CONCURRENT`** build.++The **first** time a given index materializes on a table that **already holds many rows** (an existing install upgrading into a newly-added index), Postgres takes a `SHARE` lock that **blocks writes** (INSERT/UPDATE/DELETE) to that table until the build completes. So an existing install can see a one-time write stall at boot proportional to the table's row count — HNSW builds are the slowest. Fresh installs never see this: they build every index on an **empty** table, so the lock is effectively instant.++This is left as-is deliberately rather than switched to `CREATE INDEX CONCURRENTLY`, because `CONCURRENTLY` cannot run inside a transaction block, needs its own retry/cleanup path (a failed concurrent build leaves an `INVALID` index that must be dropped by hand), and roughly doubles build time — too fragile to run unattended on every boot for a stall that only bites large-table upgrades. **If a future migration adds an index to a table known to already carry a large row count on existing installs, prefer a versioned db-migration** (`server/scripts/db-migrations/`) that issues `CREATE INDEX CONCURRENTLY` **outside** a transaction, rather than adding it to `ensureSchema()`.+---## Adding a new data store? Answer thesediff --git a/server/lib/db.js b/server/lib/db.jsindex 8537a8c859..d67ef358a8 100644--- a/server/lib/db.js+++ b/server/lib/db.js@@ -337,6 +337,25 @@ export async function ensureSchema() {}async function ensureSchemaImpl() {+ // ⚠️ Boot CREATE INDEX lock window. Every `CREATE INDEX IF NOT EXISTS` below+ // (and in the catalogDDL block, incl. the HNSW vector index on catalog_scraps)+ // runs as a plain, non-CONCURRENT build. The FIRST time an index materializes+ // on a table that ALREADY holds many rows, Postgres takes a SHARE lock that+ // blocks writes (INSERT/UPDATE/DELETE) to that table until the build finishes —+ // so an existing install upgrading into a new index sees a one-time write stall+ // at boot proportional to that table's row count (HNSW builds are the slowest).+ // Why this is left as-is rather than switched to CONCURRENTLY:+ // - Fresh installs (the common case) build every index on an EMPTY table, so+ // the lock is effectively instant — there is nothing to block.+ // - CREATE INDEX CONCURRENTLY cannot run inside a transaction block, needs its+ // own retry/cleanup path (a failed CONCURRENT build leaves an INVALID index+ // that must be dropped by hand), and roughly doubles build time — fragile to+ // run unattended on every boot for a stall that only bites large-table upgrades.+ // If a future migration adds an index to a table known to already carry a large+ // row count on existing installs, prefer a versioned db-migration (see+ // server/scripts/db-migrations/) that issues CREATE INDEX CONCURRENTLY OUTSIDE a+ // transaction, rather than adding it here. See docs/STORAGE.md ("Boot schema+ // upgrades & the CREATE INDEX lock window").const upgrades = [`ALTER TABLE memories ADD COLUMN IF NOT EXISTS sync_sequence BIGSERIAL`,`ALTER TABLE memories ADD COLUMN IF NOT EXISTS origin_instance_id VARCHAR(36)`,