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([codex5-network-exposure-ui]): archive to DONE.md
[._.]/ Adam Eivy1adcc78765a7
diff --git a/DONE.md b/DONE.mdindex 35bf6b7bb2..84eeafaeaf 100644--- a/DONE.md+++ b/DONE.md@@ -10,6 +10,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./### 2026-05-19+- **[codex5-network-exposure-ui] Network Exposure dashboard widget.** New `server/lib/networkExposure.js` snapshots boot-frozen exposure state (scheme + bind + cert mode from `meta.json` + Tailscale hostname + loopback mirror port) and a new `GET /api/network-exposure/status` route surfaces it. New `client/src/components/NetworkExposureWidget.jsx` renders an at-a-glance HTTPS/HTTP badge, bind audience (loopback-only / all-interfaces / specific-interface), Tailscale-trusted cert vs. self-signed pill, loopback HTTP mirror link, and a mic-availability hint computed client-side from `window.location.protocol` + loopback-host check. Flags an actionable warning when the server is bound on all interfaces over plain HTTP. Registered in `widgetRegistry.jsx` with `MicroGlyph` chrome and seeded into the `default` (Everything) and `ops` built-in layouts so the security posture is visible product UX, not a docs-only invariant. Two `/simplify` follow-ups deferred to PLAN: extract a shared `readCertMeta()` helper (third independent meta.json reader landed) and hoist `isLoopbackHost` to `client/src/lib/loopbackHost.js`.- **[extract-requiretoolkit-pattern-to-runner-js] Extend `requireToolkit()` pattern to `server/services/runner.js` + `promptService.js`.** The 13 inlined `if (!aiToolkitInstance) throw new Error('AI Toolkit not initialized')` sites in `runner.js` (across `createRun`, `finalizeRunRecord`, `executeCliRun`, `executeApiRun`, `registerActiveRun`, `stopRun`, `getRun`, `getRunOutput`, `getRunPrompt`, `listRuns`, `deleteRun`, `deleteFailedRuns`, `isRunActive`) plus 12 sibling sites in `promptService.js` (across `loadPrompts`, `getStages`, `getStage`, `getStageTemplate`, `updateStageTemplate`, `updateStageConfig`, `getVariables`, `getVariable`, `updateVariable`, `createVariable`, `deleteVariable`, `buildPrompt`) now go through a private `requireToolkit()` helper that throws `new ServerError('AI Toolkit not initialized', { status: 503, code: 'AI_TOOLKIT_NOT_INITIALIZED' })` — mirroring the helper `providers.js` already exports. Promoting `promptService.js` to the typed-error shape too was a /simplify finding from this PR — leaving prompt-service failures on the untyped string-throw while runner + providers were typed would have left callers (e.g. `visionTest.js`'s `err.code === 'AI_TOOLKIT_NOT_INITIALIZED'` gate) unable to discriminate by source. In runner.js, multi-use callsites (`finalizeRunRecord`, `executeCliRun`, `stopRun`, `registerActiveRun`) hoist `const toolkit = requireToolkit()` once so the `aiToolkitInstance.services.X` chains collapse to `toolkit.services.X` without re-checking. `unregisterActiveRun` is unchanged — its optional-chained `.delete` is deliberately best-effort cleanup that runs from child-process teardown callbacks and must not throw. Error message string preserved verbatim so `server/lib/promptRunner.test.js`'s `rejects.toThrow(/AI Toolkit not initialized/)` regex still matches. Follow-up deferred to PLAN.md as `[extract-shared-requiretoolkit-helper]` — three copies of the 8-line helper now exist; extract to `server/lib/aiToolkitState.js` when a 4th caller appears or somebody wants to consolidate. All 5832 server tests pass.- **[move-usenextevalcountdown-to-hooks] Move `useNextEvalCountdown` from `components/cos/` to `client/src/hooks/`.** Relocated `client/src/components/cos/useNextEvalCountdown.js` (1s-tick countdown to the next CoS evaluation) to `client/src/hooks/useNextEvalCountdown.js` to conform to the CLAUDE.md "Module Organization" rule that `useX` hooks live exclusively under `client/src/hooks/`. Dropped the re-export from `components/cos/index.js`, added the catalog row to `client/src/hooks/README.md` (Apps / Sessions / Domain), and added the barrel re-export to `client/src/hooks/index.js`. Only consumer (`client/src/pages/ChiefOfStaff.jsx`) now imports the hook directly from `../hooks/useNextEvalCountdown`, matching the existing direct-import pattern it already uses for `useSocket` and `useLocalStorageBool`. Pure relocation — no behavioral changes. All 154 client tests pass (the `hooks/index.test.js` barrel-shape invariant test confirms the move is correctly wired).- **[sharing-annotationssync-cache-bucket-asset-keys] Cache `listBucketAssetKeys` per (bucket, manifests-dir mtime).** `server/services/sharing/annotationsSync.js#listBucketAssetKeys` previously re-scanned every manifest in every auto-merge bucket on every 2s-debounced annotation flush. Manifests are the only source of truth post-v2 (content-addressed `assets/blobs/<hash>` paths don't carry filenames), so per-flush fan-out scaled O(buckets × manifests). The function now stats `<bucket>/manifests/` on each call and reuses the previously-parsed `Set<assetKey>` whenever the directory mtime matches — every manifest write/archive goes through `atomicWrite` (temp + rename) or `rename`, both of which bump the dir mtime, so the mtime is a complete invalidation signal. The legacy v1 `assets/{images,videos}/` dir scan stays uncached (small + rare fall-through). The annotation manifest emitted by `exportAnnotationsToBucket` rolls the cached mtime forward so the post-write bump doesn't immediately invalidate the same bucket's cache on the next flush. New `__resetBucketAssetKeysCache` test hook + 7 new vitest cases in `annotationsSync.test.js` covering hit, mtime-advance miss, per-bucket isolation, legacy-dir-scan-still-runs, ENOENT-on-manifests-dir as a stable cache key, non-ENOENT stat error bypasses caching, and post-write mtime-roll-forward keeps the next flush hot.diff --git a/PLAN.md b/PLAN.mdindex 25e8a3d9ad..ed1e877533 100644--- a/PLAN.md+++ b/PLAN.md@@ -34,6 +34,8 @@ _Nothing currently parked — pick the next item from the Backlog._- [ ] [consolidate-cert-path-constants] **Consolidate `CERT_DIR`/`CERT_PATH`/`KEY_PATH`/`META_PATH` constants.** Re-declared in `scripts/setup-cert.js`, `scripts/open-ui-in-browser.js`, `server/services/certProvisioner.js`, and `server/services/certRenewer.js` (4 sites). Surfaced by `/simplify` during the first-run HTTPS-auto-flip fix (2026-05-19); deferred to keep that PR scoped. Candidate home: `lib/certPaths.js` (alongside `lib/tailscale-https.js` so both runtime + bootstrap can import).- [ ] [imagegen-local-defer-module-load-side-effects] **Defer module-load side effects in `server/services/imageGen/local.js`.** Line 32 runs `IMAGE_MODELS = Object.fromEntries(getImageModels().map(...))` at module evaluation — `getImageModels()` calls `lib/mediaModels.js#loadMediaModels` which `mkdirSync`s `dirname(REGISTRY_FILE)` and `writeFileSync`s a default registry if missing. Any importer that loads via a mocked `PATHS.data` (e.g. `routes/pipeline.test.js` → `routes/pipeline.js` → `routes/universeBuilder.js` → `services/universeBuilderCollectionHook.js` → `services/imageGen/local.js`) fails on `mkdirSync('/mock/data')`. Worked around in 2026-05-19 by lazy-importing `readImageSidecar` in `universeBuilderCollectionHook.js`; real fix is to convert `IMAGE_MODELS` + sibling top-level constants to lazy getters and audit callers. Affects every consumer of `local.js` exports today.- [ ] [cleanplateprompt-migrate-to-rich-canon-fragments] **Migrate `client/src/lib/cleanPlatePrompt.js#composeCleanPlatePrompt` to `richCanonDescriptorFragments('place', setting)`.** Clean-plate prompt builder (Cluster A — A4 setting reference renders) hand-rolls `description + Palette + recurringDetails` extraction at `cleanPlatePrompt.js:26-30` and is missing `era` / `weather` for the same reason `[pipeline-visual-stages-setting-field-injection]` was missing them — both are visual prompts that benefit from period/atmosphere cues. Tightly scoped sibling change (one client file + one test file). Deferred from that PR because the PLAN item targeted storyboard+comic-panel specifically; clean plates are setting-reference renders, adjacent but distinct.+- [ ] [extract-readcertmeta-helper] **Extract a shared `readCertMeta()` helper from `data/certs/meta.json` readers.** Three independent readers exist: `server/lib/peerSelfHost.js:13-18` (hostname only), `server/services/certRenewer.js:30-31` (mode + hostname), `server/lib/networkExposure.js:25-29` (mode + hostname + ips). Each does its own `statSync({ throwIfNoEntry: false }) + readFileSync + safeJSONParse`. Consolidate into `server/lib/certMeta.js` exporting `readCertMeta() → { mode, hostname, ips } | null`. Surfaced by /simplify during `[codex5-network-exposure-ui]`; deferred to keep that PR scoped. Note `peerSelfHost.js` is in a hot path — verify perf when consolidating.+- [ ] [hoist-loopback-host-helper-to-client-lib] **Hoist `isLoopbackHost` to `client/src/lib/loopbackHost.js`.** `server/lib/networkExposure.js` exports `isLoopbackHost`, but `client/src/components/NetworkExposureWidget.jsx:22-30` re-declares the same `LOOPBACK_HOSTS` Set and `describeMicAvailability()` helper inline (server export isn't reachable from browser). Move the client copy into `client/src/lib/loopbackHost.js` + add a barrel entry so future secure-context callers (voiceClient, etc.) can reuse it. Surfaced by /simplify during `[codex5-network-exposure-ui]`.### v2.1.0 pre-release review residue (deferred from main→release multi-agent review, 2026-05-16)@@ -74,7 +76,6 @@ The 2026-04-25 CODEX 5.5 review's concrete bugs (Brain Feeds nav, Time Capsule n- [ ] [codex5-bundle-lazy-routes] **[P1][PERF]** Route-level + dashboard-widget lazy loading. Review measured `dist/assets/index-*.js` at ~2.95 MB minified / ~736 KB gzip. `App.jsx` statically imports several heavy pages (`Brain`, `DigitalTwin`, `MeatSpace`, `Messages`, `Dashboard`) and the widget registry pulls all widgets into the initial graph. Lazy-load via `React.lazy` + `Suspense`; convert `widgetRegistry.jsx` entries to lazy components so widgets only download when their layout includes them. Add a bundle-visualization step (`rollup-plugin-visualizer`) and track regressions.- [ ] [codex5-polling-consolidation] **[P2][PERF]** Standardize polling on `useAutoRefetch` + sockets + visibility pause. Brain, Digital Twin, CoS, Links, Processes, Browser, CyberCity, and several widgets still spin local `setInterval`s. Pick a single hook (`client/src/hooks/useAutoRefetch.js` if it exists, otherwise extract one), add `document.visibilityState === 'hidden'` short-circuit, and migrate domains that already have Socket.IO event streams to event-driven refetch.- [ ] [codex5-client-error-reporter] **[P2][OBSERVABILITY]** Funnel client errors into Review Hub. `client/src/main.jsx`'s `window.onerror` + `unhandledrejection` listeners only `console.log` today. Add `POST /api/client-errors` with redaction (drop tokens / long payloads) + rate-limit (~1/sec, drop duplicates by message+stack hash). Surface grouped client errors in the Review Hub feed; optionally raise a CoS task at a configurable threshold.-- [ ] [codex5-network-exposure-ui] **[P2][SECURITY-UX]** Network-exposure status banner / settings panel. Surface in-app: current bind address + scheme (HTTP vs HTTPS), whether the loopback HTTP mirror on `:5553` is active, voice/mic availability over the current scheme, Tailscale-vs-public bind detection, and a link to `docs/PORTS.md`. CLAUDE.md is explicit that PortOS is single-user behind Tailscale — this widget enforces that as visible product UX rather than a docs-only invariant.**Product UX — concrete, medium scope**