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
address review (round 7): mtime-based prune fast-path, abort on /ask root nav, validate API model
Adam Eivyc3cdf265251f
diff --git a/CODEX5.5_REVIEW.md b/CODEX5.5_REVIEW.mdnew file mode 100644index 0000000000..82e8817c39--- /dev/null+++ b/CODEX5.5_REVIEW.md@@ -0,0 +1,322 @@+# CODEX 5.5 Deep Product, Design, and Engineering Review++Review date: 2026-04-25++## Executive Summary++PortOS has a strong product thesis: a local-first personal operating system for one developer, combining app/process control, AI agent orchestration, second-brain capture, digital-twin modeling, health tracking, and private-network access. The project is unusually feature-rich and has several good execution patterns already in place: deep-linkable route tabs, command-palette/voice navigation backed by a shared manifest, server-side validation, a large test suite, source-backed Ask conversations, and a dashboard layout system.++The main product risk is now coherence, not capability. The app has outgrown a page-list navigation model. Important features are hidden, duplicated, or inconsistently reachable across sidebar, Cmd+K, voice, and tab bars. The dashboard and Ask surfaces are the right strategic direction, but they need to become the primary orchestration layer so the product feels like an operating system instead of a collection of powerful panels.++The main engineering risk is surface-area drift. Navigation is declared in multiple places, some routes point to non-existent tabs, some valid tabs are absent from sidebar/palette, lint is currently unusable, and the production client bundle still has a very large entry chunk. The server test suite is healthy, but client quality gates and route/nav contract tests need to catch regressions before they reach the UI.++## Verification Performed++- `npm test --prefix server`: passed, 95 test files and 2549 tests.+- `npm run build`: passed, but Vite warned that `dist/assets/index-*.js` is about 2.95 MB minified and about 736 KB gzip.+- `npm run lint --prefix client`: failed before linting source with `TypeError: expand is not a function` from `minimatch`, likely caused by the `brace-expansion` override forcing an incompatible major under ESLint's `minimatch@3` dependency.++## Highest-Priority Product and UX Findings++### P0: Navigation Has Drifted Across Sidebar, Page Tabs, Cmd+K, and Voice++PortOS declares navigation in at least three places: `client/src/components/Layout.jsx`, `server/lib/navManifest.js`, and each feature's local `TABS` constants. The comments say the nav manifest is the single source of truth for command palette and voice, but the visual sidebar still owns a separate large tree. This is now causing real UX defects.++Concrete examples:++- `Brain` has a valid `Feeds` tab in `client/src/components/brain/constants.js` and `Brain.jsx` renders it, but the sidebar omits `/brain/feeds` and `server/lib/navManifest.js` omits it. Users can only discover it if they already know the URL.+- `Digital Twin` has a valid `Time Capsule` tab in `client/src/components/digital-twin/constants.js` and `DigitalTwin.jsx` renders it, but the sidebar and nav manifest omit it.+- `Chief of Staff` sidebar and nav manifest include `/cos/scripts`, but `client/src/components/cos/constants.js` does not include a `scripts` tab. `ChiefOfStaff.jsx` derives valid tabs from that constants file, so selecting Scripts redirects/falls back to Tasks.++Recommendation: make `server/lib/navManifest.js` or a shared JSON/JS nav contract the real source for sidebar, palette, voice, and route/tab validation. Add a route/nav contract test that fails when a visible nav item points to an invalid tab or a feature tab is not discoverable unless intentionally hidden.++### P0: The Product Needs a Home-Level "Operating Loop"++The app has many domains, but the first-run and daily-return experience does not yet answer the user's core question: "What should I do now?" The dashboard is customizable and useful, but it is still a grid of widgets rather than a prioritized operating loop.++Recommended design update:++- Add a top-level daily command center with 3-5 prioritized cards: Critical System Issues, Today Calendar Commitments, Active Agent Work, Goal Next Action, Health/Recovery Signal.+- Give each card a single primary action and one secondary drill-down.+- Let the user explicitly mark a day mode: `Focus`, `Ops`, `Health`, `Review`, or `Autonomous`.+- Use the Digital Twin, chronotype, calendar, goals, and CoS state to rank the cards instead of showing each system equally.++This would turn PortOS from "everything available" into "the system makes judgment calls on my behalf", which directly matches the project goals.++### P1: Ask Yourself Should Become the Primary Cross-Domain Surface++The `/ask` implementation is strategically valuable because it finally unifies Brain, Memory, Autobiography, Goals, and Calendar. The current UI is credible, with modes and source chips, but it is still a standalone chat page.++Recommended functionality updates:++- Add one-click promotions per assistant answer: Save as Brain note, Create CoS task, Attach to Goal, Add calendar block, Draft message.+- Add source health warnings: "No calendar source used", "No goal source found", "Only stale memories found".+- Add answer confidence/provenance summaries so users know whether the system is guessing or grounded.+- Add typed prompt starters for common jobs: "What should I do today?", "What am I avoiding?", "Draft as me", "What changed since yesterday?", "What should CoS run next?"+- Make Ask callable inline from dashboard widgets and Cmd+K, not just as a destination page.++### P1: Sidebar Scale Is Past the Point Where Hierarchy Alone Works++The sidebar carries a very large number of items and nested sections. Cmd+K helps power users, but visual browsing on mobile and tablet is still too heavy. The current IA also mixes domains, tools, settings, social agents, and experiments at the same level.++Recommended design update:++- Keep the sidebar for 8-10 top-level domains only: Home, Ask, Apps, CoS, Brain, Calendar, Goals, Health, Dev Tools, Settings.+- Move deep tabs into each page's local tab bar and into Cmd+K.+- Add "Recent" and "Pinned" sections in the sidebar for the user's actual working set.+- Add contextual breadcrumbs or page header actions so a user knows which domain they are in without scanning the whole sidebar.++### P1: Dashboard Editing Is Powerful but Too Technical++Dashboard layout persistence and arranging are well-executed, but "Arrange" exposes a grid mechanic rather than a product concept. Users need intention-first controls.++Recommended design update:++- Rename layouts around user intent, not layout mechanics: `Morning Review`, `Deep Work`, `Ops`, `Health`, `Agent Watch`.+- Add "Make this my morning default" and time-window defaults.+- Add widget suggestions based on hidden available data: "You have calendar data but no calendar widget in this layout."+- On mobile, expose layout switching and widget order, but keep spatial arrangement disabled as it is today.++### P1: Health and Mortality Features Need Trust Framing++MeatSpace, genome, death clock, blood work, alcohol/nicotine tracking, and longevity scoring are compelling but sensitive. The UX should be explicit about whether a recommendation is data-backed, inferred, experimental, or just a prompt.++Recommended design update:++- Add confidence labels and source panels to health insights, mirroring Ask's source-chip approach.+- Separate tracking facts from recommendations and speculative projections.+- Add a disclaimer and "what would change this estimate?" explainer for mortality/longevity views.+- Add clinician/export views for blood and lifestyle data, even if the product is single-user.++## Concrete Bugs and Execution Issues++### P0: Client Lint Is Broken by Dependency Overrides++`npm run lint --prefix client` crashes before source linting. `client/package.json` overrides `brace-expansion` to `^5.0.5`, while ESLint's config stack depends on `minimatch@3`, which expects the older CommonJS `brace-expansion` API. The observed failure is `TypeError: expand is not a function`.++Impact: client lint currently cannot protect against regressions, unused code, hook dependency problems, or accessibility mistakes.++Recommended fix: narrow the security override so `minimatch@3` can resolve a compatible `brace-expansion`, or upgrade the ESLint dependency chain to versions compatible with `brace-expansion@5`. After fixing, add client lint to the normal verification path.++### P0: `/cos/scripts` Is a Dead Navigation Target++Evidence:++- Sidebar includes `{ to: '/cos/scripts', label: 'Scripts' }`.+- `server/lib/navManifest.js` includes `nav.cos.scripts`.+- `client/src/components/cos/constants.js` has no `scripts` tab.+- `ChiefOfStaff.jsx` treats valid tabs as `new Set(TABS.map(t => t.id))`, so unknown tabs fall back to Tasks.++Impact: sidebar, Cmd+K, and voice can route the user to a page that silently does not exist.++Recommended fix: either implement a Scripts tab or remove `/cos/scripts` from both sidebar and nav manifest.++### P1: Hidden Valid Tabs Reduce Feature Discoverability++Evidence:++- `Brain` supports `feeds`, but sidebar and nav manifest omit it.+- `Digital Twin` supports `time-capsule`, but sidebar and nav manifest omit it.++Impact: shipped features look missing, and voice/Cmd+K cannot reach them.++Recommended fix: add the missing entries or explicitly mark them hidden/experimental in a shared nav contract so the omission is deliberate and testable.++### P1: `/ask` Is Wrapped Like a Normal Content Page but Implements a Full-Height App++`Layout.jsx` only treats selected routes as full-width/full-height. `/ask` is not included, so it is rendered inside the default padded `max-w-7xl` wrapper. `Ask.jsx` then compensates with `h-[calc(100vh-4rem)] -m-4`, which is brittle and mismatched with the layout shell.++Impact: chat sidebars and transcript height can feel cramped on desktop and risk scroll/viewport issues on mobile.++Recommended fix: classify `/ask` as full-width in `Layout.jsx` and remove the negative-margin workaround from `Ask.jsx`.++### P1: Production Entry Chunk Is Too Large++The production build passes, but the main `index-*.js` chunk is about 2.95 MB minified / 736 KB gzip. `App.jsx` still statically imports several heavy pages and many dashboard widgets are pulled into the initial graph.++Impact: slower cold load over Tailscale/mobile, especially on phones and tablets, which are part of the product promise.++Recommended fix:++- Lazy-load more route pages, especially `Brain`, `DigitalTwin`, `MeatSpace`, `Messages`, `Dashboard` widget internals, and other non-home domains.+- Split dashboard widgets by registry entry using lazy components.+- Use bundle visualization in CI to track regressions.++### P2: Polling Is Inconsistent and Overused++Several pages use local `setInterval` polling while other systems already use Socket.IO. Examples include Brain, Digital Twin, Chief of Staff, Links, Processes, Browser, CyberCity, and many widgets.++Impact: unnecessary network chatter, duplicated loading logic, inconsistent freshness, and harder mobile battery behavior.++Recommended fix: standardize on `useAutoRefetch` for low-priority polling and Socket.IO subscriptions for event-driven domains. Add a route visibility pause so background tabs do not keep polling aggressively.++### P2: Global Error Handling Hides Client Failures From Product Feedback Loops++`main.jsx` logs global errors and unhandled rejections to console, but the product's premise is self-improvement and autonomous issue capture. These client errors should feed the same notification/review/CoS pathway as server errors.++Recommended fix: add a client error reporter endpoint with redaction and rate limits. Surface grouped client errors in Review Hub and optionally create CoS tasks.++## Design System Recommendations++### Establish Product-Specific Visual Modes++The current visual language is consistent but heavily default-dark-dashboard. CyberCity, CoS avatars, and some pixel fonts show a stronger identity. Bring that intentionality into the main surfaces:++- `Ops` mode: dense, terminal-like, high signal, minimal animation.+- `Focus` mode: quiet, spacious, only next actions.+- `Health` mode: warmer, less cyber, clearer trust/explanation.+- `Review` mode: document-like, optimized for reading and decisions.++### Add a Decision/Provenance Pattern Everywhere++Ask source chips are a good pattern. Reuse it across CoS, Insights, Health, Goals, and Dashboard:++- "Why am I seeing this?"+- "What data backs this?"+- "What changed?"+- "What can I do next?"++### Make Empty States Teach the Workflow++For a personal OS, empty states should not just say "no data". They should guide setup:++- "Connect calendar to unlock schedule-aware goals."+- "Add birth date and genome file to unlock longevity estimates."+- "Capture 10 notes to improve Ask Yourself."+- "Configure one API provider to enable autonomous CoS."++## Functionality Recommendations++### 1. Unified Review Queue++Create one cross-domain Review Queue that collects:++- Brain inbox items needing classification review.+- Ask answers ready for promotion.+- CoS completed tasks needing approval.+- Message drafts awaiting send.+- Health anomalies needing acknowledgement.+- Failed syncs/imports/backups.++This should be the user's "inbox zero" for PortOS.++### 2. Autonomy Guardrails and Audit Trail++The project goal includes full digital autonomy. Before expanding autonomy, add visible controls:++- Autonomy level per domain, not just CoS globally.+- Dry-run vs execute mode.+- Spending/time/token budgets.+- Destructive-action confirmation policy.+- "What did agents do while I was away?" briefing.++### 3. Onboarding and Capability Map++Even for a single-user product, setup debt matters. Add a capability map showing which systems are active, partially configured, or blocked:++- Providers+- Calendar+- Brain/memory embeddings+- Voice+- Tailscale HTTPS+- Genome/health imports+- Telegram/messages+- App registry/PM2++### 4. Mobile Task Flows++The README promises mobile-first access. Prioritize 5 phone-native flows:++- Check system health and restart an app.+- Capture a thought by voice/text.+- Ask "what should I do now?"+- Approve/reject CoS result.+- Log health/lifestyle event in under 10 seconds.++### 5. Personal Knowledge Legacy Export++GOALS.md calls out Knowledge Legacy as early. Add an export bundle that includes:++- Autobiography+- Brain notes and memories+- Key decisions+- Goals and milestones+- Digital twin prompt+- Health summaries with source caveats+- Machine-readable manifest++## Engineering Recommendations++### 1. Add Route/Nav Contract Tests++Tests should assert:++- Every sidebar route exists.+- Every nav manifest route exists.+- Every feature `TABS` entry is reachable by sidebar or Cmd+K unless marked hidden.+- No nav item points to a tab rejected by the destination page.++### 2. Fix Client Lint and Add Frontend Test Coverage++The server has strong coverage; the client has little visible automated protection. After lint is fixed, add targeted tests for:++- Command palette ranking and dispatch.+- Dashboard layout save/reconcile behavior.+- Ask streaming state transitions.+- Route/tab validation.+- Sidebar mobile open/close behavior.++### 3. Reduce App-Shell Bundle Weight++Move more pages and widget components behind lazy imports. Keep the shell, dashboard skeleton, command palette, theme, notifications, and current route in the initial bundle; everything else can load on demand.++### 4. Normalize API Error and Loading UX++Many client calls silently catch failures or return null. For an operating system UI, failures should be visible, grouped, and actionable.++Recommended pattern:++- Use a standard `LoadState` wrapper for loading/error/empty/success.+- Log swallowed errors with context.+- Route recurring failures into Review Hub.++### 5. Treat Local-Only Security as Product UX, Not Just Docs++The docs correctly say the app is meant for private Tailscale networks. The UI should still display network exposure state:++- Current bind address and scheme.+- Whether HTTPS is active.+- Whether voice/mic will work remotely.+- Whether public exposure is detected.+- Links to hardening docs.++## Suggested Roadmap++### Next 1-2 Days++- Fix client lint dependency conflict.+- Remove or implement `/cos/scripts`.+- Add missing nav entries for Brain Feeds and Digital Twin Time Capsule, or mark them intentionally hidden.+- Add `/ask` to the full-width route list and remove the negative-margin layout workaround.++### Next 1-2 Weeks++- Add route/nav contract tests.+- Add a unified Review Queue MVP.+- Convert dashboard into a prioritized "Today / Now / Next" operating loop.+- Add Ask answer promotion actions.+- Begin route-level lazy loading to reduce the entry chunk.++### Next 1-2 Months++- Collapse sidebar to top-level domains plus pinned/recent.+- Add capability map and setup health.+- Add autonomy guardrails and away-briefing.+- Add trust/provenance panels to health, insights, and CoS recommendations.+- Add legacy export format.++## Overall Assessment++PortOS is past the "can this work?" phase. It works, it has breadth, and the server-side execution discipline is better than typical personal tools. The next step is product editing: make the system more opinionated, reduce navigation entropy, and turn the dashboard/Ask/Review Hub triad into the center of gravity.++The highest-leverage technical work is not adding another feature. It is enforcing navigation contracts, restoring client lint, cutting the initial bundle, and making every autonomous or AI-generated output explainable and promotable.diff --git a/client/src/pages/Ask.jsx b/client/src/pages/Ask.jsxindex 4779138cba..1785cdebcd 100644--- a/client/src/pages/Ask.jsx+++ b/client/src/pages/Ask.jsx@@ -192,10 +192,12 @@ export default function Ask() {// conversation it belongs to. Brand-new conversations transition through// `/ask` → `/ask/<id>` once the server's `open` event arrives — that// self-navigation must NOT cancel the stream, so we compare against the- // ref the stream populates.+ // ref the stream populates. Covers the `/ask/<id>` → `/ask` case too:+ // `conversationId` becomes undefined and `streamingConvIdRef` is still+ // set, so the inequality fires and we abort.useEffect(() => {const streamConvId = streamingConvIdRef.current;- if (streamConvId && conversationId && streamConvId !== conversationId) {+ if (streamConvId && streamConvId !== conversationId) {abortRef.current?.abort();abortRef.current = null;streamingConvIdRef.current = null;diff --git a/server/services/askConversations.js b/server/services/askConversations.jsindex eb3f9c0b0a..aaefbab932 100644--- a/server/services/askConversations.js+++ b/server/services/askConversations.js@@ -23,7 +23,7 @@*/import { join } from 'path';-import { readdir, unlink } from 'fs/promises';+import { readdir, stat, unlink } from 'fs/promises';import { randomUUID } from 'crypto';import { PATHS, atomicWrite, ensureDir, readJSONFile, safeDate } from '../lib/fileUtils.js';import { VALID_MODES as VALID_MODES_SET } from './askService.js';@@ -89,13 +89,26 @@ export async function listConversations({ limit = 50 } = {}) {const now = Date.now();const expiryMs = EXPIRY_DAYS * 24 * 60 * 60 * 1000;- // Walk the whole directory so expired+unpinned conversations get pruned- // even if they live past the first `limit` results — otherwise a user with- // >limit conversations would silently violate the 30-day auto-expire- // contract (old files would persist indefinitely on disk).+ // Two-tier sweep: filenames are newest-first, so we only read JSON for+ // (a) the head of the list to fill `summaries`, and (b) anything whose+ // mtime is older than the expiry window — those are pruning candidates+ // and we still have to open them to honour the `promoted` flag. Fresh+ // files past the `limit` cutoff are skipped entirely.for (const id of ids) {- const conv = await readConversation(id);- if (!conv) continue;+ const headSlot = summaries.length < limit;+ let conv = null;+ if (headSlot) {+ conv = await readConversation(id);+ if (!conv) continue;+ } else {+ // Cheap check first — only open the JSON if mtime indicates the file+ // could be expired. atomicWrite touches mtime on every update.+ const mtime = await stat(pathFor(id)).then((s) => s.mtimeMs, () => null);+ if (mtime === null) continue;+ if ((now - mtime) <= expiryMs) continue;+ conv = await readConversation(id);+ if (!conv) continue;+ }const updated = safeDate(conv.updatedAt) || safeDate(conv.createdAt);if (!conv.promoted && updated && (now - updated) > expiryMs) {@@ -104,7 +117,7 @@ export async function listConversations({ limit = 50 } = {}) {continue;}- if (summaries.length < limit) {+ if (headSlot) {summaries.push({id: conv.id,title: conv.title || '(untitled)',diff --git a/server/services/askService.js b/server/services/askService.jsindex 51976a632b..a736b755b3 100644--- a/server/services/askService.js+++ b/server/services/askService.js@@ -545,6 +545,14 @@ export async function* runAsk({return;}const effectiveModel = model || provider.defaultModel;+ // API providers will fail with a vague upstream 4xx if `model` is null —+ // surface a clear actionable error before we even open the connection.+ // CLI providers can fall back to whatever the binary defaults to, so we+ // only enforce this for the `api` type.+ if (provider.type === 'api' && !effectiveModel) {+ yield { type: 'error', error: `Provider "${provider.id}" has no default model — pass an explicit model or set provider.defaultModel.` };+ return;+ }const prompt = await buildPrompt({ question, mode, sources, history });const startedAt = Date.now();