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
Merge origin/main into better/devsecops-audit-2026-07-10
[._.]/ Adam Eivy12efa9d23121
diff --cc .changelog/NEXT.mdindex 80ba12554e,a31c1728f1..d15095a847--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@@ -45,10 -57,16 +57,18 @@@## Fixed+- **A DevSecOps hardening pass makes background services fail safely and persistent controls touch-accessible.** Autofixer process/history data now renders through safe DOM text nodes and its periodic scan cannot overlap itself; CLI runner terminal events finalize exactly once; port discovery fails closed with deterministic cross-platform parsing; backup `rsync` lookup is portable; task-watcher events, Spotify requests, and shared media streams now have bounded/owned lifecycles; repeated CyberCity district-bound calculations use one empty-safe helper; and persistent mobile navigation plus timeline removal controls provide 44×44 touch targets with accessible labels. Focused regression coverage accompanies each repaired path.++ - **CoS tasks with Review Loop turned off now explicitly disable saved external-review defaults when opening a PR.** Their completion prompt passes `--review-with none`, so an inherited Copilot (or other reviewer) default cannot launch a review that was not requested.++ - **[issue-2387] Theme initialization and switching now survive unavailable localStorage.** The `useTheme` and `useCitySettings` hooks read/wrote `localStorage` directly (persisted theme, and the CyberCity settings that render on the same theme path), so a browser where storage access throws (Safari private mode, blocked cookies, disabled storage) or is absent would throw inside a `useState` initializer and crash the initial render, and a failing `setItem` could break theme switching. Both hooks now route every read/write/remove through a shared, guarded `safeReadStorage`/`safeWriteStorage`/`safeRemoveStorage` helper (`client/src/lib/safeStorage.js`) that swallows access failures, and corrupt stored JSON falls back to defaults instead of throwing — so init always resolves to a valid default and in-memory switching keeps working when persistence fails. `setTheme` also applies the in-memory theme (DOM + state) before any persistence/side-effect work so a later failure can never leave the UI on the stale theme. Focused hook tests cover read-throws-on-init, corrupt/invalid stored value, and write-throws-on-switch for both hooks.++ - **[issue-2384] A usage-limit fallback signal now stops a direct-CLI CoS agent immediately even when an earlier transcript write is stalled, and the persisted transcript can no longer be reordered.** The direct-CLI spawn path (`spawnDirectly` in `server/services/agentCliSpawning.js`) let each stdout/stderr `data` event run its transcript-mutating body (`outputBuffer` append + `output.txt` write + batched live-tail push) as an independent async handler, so two chunks' interleaved `await`s could persist output out of order, and a blocked state/file write on an earlier chunk could sit in front of a later chunk that carried the `Now using extra usage` fallback marker. Fallback detection now runs **synchronously** in the raw listener — before any transcript work is enqueued — so the provider is killed the instant the signal arrives regardless of a stalled write, while the transcript body is serialized onto a single per-agent tail promise (mirroring `shell.js`'s `hookQueue` and `pipeline/issues.js`'s `issueWriteTail`) that the close/error/terminate paths drain before finalizing. A regression test blocks an earlier write, emits the fallback signal on a later chunk, and asserts termination stays immediate and final output stays ordered.+- **CoS agents (notably codex) now open their PR as the gh account that matches the repo owner, not gh's mutable active user.** PortOS's own `createPR` pins `GH_TOKEN` to the logged-in gh account whose login matches the repo owner (avoiding the multi-account "must be a collaborator" failure), but a spawned agent running its *own* `gh pr create` — a codex/Claude/CLI CoS agent finishing `/do:pr` — never received that pinning. TUI agents fared worst: `shell.js`'s `buildSafeEnv` strips `GH_TOKEN` from the inherited env entirely, so their `gh` fell back to whatever `hosts.yml` active user happened to be set. A new best-effort `resolveForgeTokenEnv(dir)` (in `server/services/git.js`) resolves just the owner-matched `GH_TOKEN` overlay and is injected into all three agent-spawn env paths — direct CLI (`spawnDirectly`), TUI shell session (`spawnTuiAgent`), and the CoS runner (`spawnViaRunner`). It's provider-agnostic (no codex special-case), returns `{}` when no owner-matched account exists (so single-account installs and GitLab repos are untouched), and is spread before `provider.envVars` so an explicit provider `GH_TOKEN` override still wins.+ - **Codex CoS agents no longer die `paste-not-rendered` while codex boots its MCP servers.** Codex boots any MCP servers configured in the user's global `~/.codex/config.toml` on every headless spawn — including heavyweight interactive ones like `playwright` (fetched via `npx`) or a `node_repl` with `startup_timeout_sec = 120`. That boot can run for tens of seconds up to ~2 minutes, during which codex swallows pastes, renders no `[Pasted Content N chars]` commit marker, and shows only the *tail* of a long paste in its input viewport (never the verified prefix) — so PortOS's paste-verify retry could not confirm delivery and killed the agent after only 3 short attempts (~19s), long before the boot finished (real incident 2026-07-10: `agent-c5a26b40` / `agent-3f4ae3b1`, both on gpt-5.6-sol; the same prompt succeeded days earlier when no MCP servers were configured and codex was ready in <10s). The spawner now detects codex's MCP-boot banner (`Booting MCP server` / `Starting MCP servers`) and extends the paste-retry budget from the fixed 3 attempts to a time budget (150s, covering `node_repl`'s 120s startup plus an `npx` cold download while staying under the idle-reap window), so a slow boot completes and the paste finally lands. If the boot genuinely never finishes, the failure now names the MCP-boot cause and points at the codex config instead of a misleading "still initializing" message. Non-codex TUIs and codex installs without MCP servers are unchanged.+- **Read-only CoS agents (e.g. reference-watch) on a TUI provider now signal completion via the `.agent-done` sentinel.** The prompt builder's completion decision tree gave every other task shape (reasoning-only, TUI push+PR, CLI) an explicit sentinel instruction, but the `isReadOnly` branch emitted only the bare "Read-Only Task" notice with no sentinel — so a read-only TUI run (reference-watch records its proposals directly in the tracker, then just needs to signal done) never wrote `.agent-done`. The 2s sentinel poll in `spawnTuiAgent` — the primary finalize path and the channel that ingests the run summary — therefore never fired, and the run only completed via the idle-reaper / shell-exit fallback with no clean resolution summary captured. `agentPromptBuilder.js` now routes the read-only branch through a new `buildReadOnlyCompletionSection({ isTui, sentinelPath })` that keeps the do-not-modify guidance and, for TUI agents, appends the write-`.agent-done`-then-stop instruction. CLI/API read-only agents complete on process exit and never poll a sentinel, so they still get the bare notice.- **Digital Twin Taste questionnaire no longer shows "Question 5 of 3" after follow-ups.** The progress header used total response count (core + follow-ups) as the current question number against a core-only total, so once branching follow-ups fired the counter overran the "of N". It now reports the 1-based index among core questions for that section, so the label stays "Question 2 of 3" even when follow-ups sit between cores.