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([hoist-loopback-host-helper-to-client-lib]): remove from PLAN.md and log to changelog
[._.]/ Adam Eivye8eae36ce17b
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 4a13905041..4e052b9e30 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -6,6 +6,8 @@- **[cleanplateprompt-migrate-to-rich-canon-fragments] Clean-plate descriptor body now flows through `richCanonDescriptorFragments('place', setting)`.** `composeCleanPlatePrompt` (`client/src/lib/cleanPlatePrompt.js`) was hand-rolling `description + Palette + recurringDetails` extraction at lines 26–30 and silently dropped `era` / `weather` — the same gap `[pipeline-visual-stages-setting-field-injection]` closed for storyboard + comic-panel renders. Migrated the descriptor body to `mapCanonDescriptorFragments(richCanonDescriptorFragments('place', setting), { trailingPeriod: true })`, matching the existing place-side helper call in `scenePrompt.js:104`. Output is byte-identical for the legacy three-field case (verified via the existing populated test) and now surfaces era + weather when populated. Two new tests in `cleanPlatePrompt.test.js` lock in both halves — the era/weather positive case and the blank/whitespace-only negative case. 242/242 client tests pass.+- **[hoist-loopback-host-helper-to-client-lib] Loopback / secure-context helpers hoisted to `client/src/lib/loopbackHost.js`.** `client/src/components/NetworkExposureWidget.jsx` previously re-declared `LOOPBACK_HOSTS` + `isLoopbackOrigin` + `describeMicAvailability` inline (the server's `isLoopbackHost` in `server/lib/networkExposure.js` isn't reachable from the browser). New shared client module exports `isLoopbackHost(host)` / `isLoopbackOrigin()` / `describeMicAvailability()` so future secure-context callers (mic, voice, clipboard heuristics) reuse one rule. The hoisted `isLoopbackHost` broadens the IPv4 check from the single literal `127.0.0.1` to the full `127.0.0.0/8` range (`/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/`) to match browser Secure Context behavior — the kernel routes the whole block to lo0, so `127.5.6.7` over plain HTTP is also a secure context in the browser. Widget swaps its three inline helpers for two imports. Barrel + README row added per the `client/src/lib/` maintenance rule; 30 new tests in `loopbackHost.test.js` cover the IPv4 range expansion, IPv6 bracketed form, case-insensitivity, and the three branches of `describeMicAvailability`. 270/270 client tests pass; lint clean.+- **[imagegen-local-defer-module-load-side-effects] Drop the module-load `IMAGE_MODELS` snapshot in `server/services/imageGen/local.js`.** The `export const IMAGE_MODELS = Object.fromEntries(getImageModels().map(...))` line ran `loadMediaModels()` at import time — which `mkdirSync`s the registry dir and `writeFileSync`s a default registry on first run. Any importer reaching `imageGen/local.js` via a test that mocks `PATHS.data` to a non-writable path (e.g. `routes/pipeline.test.js → routes/pipeline.js → universeBuilderCollectionHook.js`) failed on `mkdirSync('/mock/data')`. The export was dead (zero callers — grep confirmed) and `generateImage()` already reads the live registry via `getImageModels()`. Removed the export, reverted the 2026-05-19 lazy-import workaround in `services/universeBuilderCollectionHook.js` (now a normal static `import { readImageSidecar }`). Also tightened `enrichSidecar` to use `atomicWrite` (temp+rename) instead of `writeFile` — the prior plain write had a flaky race in tests where five-at-a-time batch enrichment let concurrent readers observe a mid-truncate empty file. 6090/6090 server tests + 234/234 client tests pass; the previously-flaky `enriches every sidecar in a batch` test now passes 10/10 runs.- **[promote-provider-type-constants-to-shared-module] Promote provider-type literals to a shared `PROVIDER_TYPES` enum.** `server/lib/aiToolkit/constants.js#PROVIDER_TYPES` grows `TUI: 'tui'` alongside the existing `CLI`/`API`, and the object is now `Object.freeze`d so callers can't mutate the shared enum. Server-side `LIGHT_CONTEXT_PROVIDER_TYPES` set + the `isTui` / `providerType` default in `server/services/agentPromptBuilder.js` now read from `PROVIDER_TYPES.{CLI,TUI,API}` instead of bare string literals. A mirror `PROVIDER_TYPES` is exported from `client/src/utils/providers.js` (the toolkit dir is intentionally kept self-contained per CLAUDE.md, so the client can't import the server copy directly), and the four client helpers (`isTuiProvider`, `isCliProvider`, `isProcessProvider`, `providerTypeClass`) now read from it. A new `providers.test.js` case statically imports the server enum and asserts the two enums stay in lockstep, so a future divergence fails CI instead of silently drifting. 13/13 provider helper tests pass; 25/25 agentPromptBuilder tests pass.diff --git a/PLAN.md b/PLAN.mdindex 865c63cf76..4208062fe8 100644--- a/PLAN.md+++ b/PLAN.md@@ -13,7 +13,6 @@ _Nothing currently parked — pick the next item from the Backlog._### Code quality / dedup (from `/simplify` passes)- [ ] [hoist-certmeta-to-top-level-lib] **Hoist `readCertMeta()` to top-level `lib/certMeta.js`.** The new helper at `server/lib/certMeta.js` bakes `PATHS.data` at module load, so `scripts/print-access-url.js:26-29` (the fourth bespoke `JSON.parse(readFileSync(META_PATH, 'utf-8')).mode` reader) can't share it without crossing the scripts/server boundary. Move next to `lib/certPaths.js` and change the signature to `readCertMeta(metaPath)` so both `server/` and `scripts/` can call it; update `print-access-url.js` to drop its inline try/catch. Surfaced by /simplify during `[extract-readcertmeta-helper]`; deferred to keep that PR scoped to the server-side consolidation. Low priority — `print-access-url.js` is a cold script-banner path and already wraps the parse in try/catch.-- [ ] [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. When hoisting, broaden the IPv4 check from a single literal `127.0.0.1` to the full `127.0.0.0/8` loopback range to match browser secure-context behavior — easy `/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/` regex. Surfaced by /simplify and the codex review during `[codex5-network-exposure-ui]`.- [ ] [image-gen-mode-enum-unify] **Unify image-gen mode enum across server + client.** Server has `IMAGE_GEN_MODES = ['external','local','codex']` (a Zod-validator alphabet) at `server/services/imageGen/index.js:21`; client has `IMAGE_GEN_MODE` constants at `client/src/lib/imageGenBackends.js:3`. Code reads strings (`'codex'`, `'local'`, `'external'`) inline at ~10 sites across `server/services/imageGen/{codex,local,external}.js`, `server/routes/imageGen.js`, and several client pages. `IMAGE_GEN_MODES` is actively used (Zod enum + voice tool enum), so the choice is "export a typed enum object on the server (`IMAGE_GEN_MODE = Object.freeze({ CODEX: 'codex', ... })`) alongside `IMAGE_GEN_MODES` and adopt it at dispatch sites" — not "drop `IMAGE_GEN_MODES`". Surfaced by /simplify after the per-render checkbox PR.- [ ] [unknown-instance-id-sentinel-extract] **Extract the `'unknown'` instanceId sentinel to a named constant.** The literal string `'unknown'` appears at 7+ sites across `server/services/instances.js#getInstanceId` (the default), `server/services/mediaAnnotations.js` (heal check in `readAll`, peer-merge guard, `setAnnotation` precondition), and `server/services/sharing/annotationsSync.js#flushAll` (export-refusal guard). Promote to `export const UNKNOWN_INSTANCE_ID = 'unknown'` in `instances.js` and import where compared, so the contract is greppable and typo-proof. Surfaced by /simplify during `[med-migration-scripts-migrations-014-attribute]`.