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-certmeta-to-top-level-lib]): remove from PLAN.md and log to changelog
[._.]/ Adam Eivy74c4076d1056
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 21a2849e18..10ad191655 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## Changed+- **[hoist-certmeta-to-top-level-lib] `readCertMeta()` hoisted to top-level `lib/certMeta.js` so `scripts/` and managed apps can share it.** The previous `server/lib/certMeta.js` baked `PATHS.data` at module load, so `scripts/print-access-url.js` couldn't reach it without crossing the scripts/server boundary and instead carried its own inline `try { JSON.parse(readFileSync(...)).mode } catch {}` block. Moved the module next to `lib/certPaths.js` (zero-dep, side-effect-free — same constraint set as the existing sibling) and changed the signature to `readCertMeta(metaPath)` so each caller passes the path it already resolved via `certPaths(PATHS.data).meta`. Four callers updated: `server/lib/peerSelfHost.js`, `server/lib/networkExposure.js`, `server/services/certRenewer.js` (two call sites), and `scripts/print-access-url.js` (drops the inline try/catch in favor of `readCertMeta(META_PATH)?.mode || ''`). The test file moved too and gained cases for the `metaPath` argument, `statSync`/`readFileSync` throwing (EACCES/EIO), and primitive JSON (parsed value gated on `typeof === 'object' && !Array.isArray`). The `JSON.parse` + try/catch is inlined rather than reusing `server/lib/fileUtils.js#safeJSONParse` — the JSDoc notes this is the cost of the zero-dep boundary that lets `scripts/` import the helper. `server/lib/{index.js, README.md}` barrel + catalog rows removed per the maintenance rule. All 6133 server tests + 270 client tests pass.+- **[image-gen-mode-enum-unify] Unify the image-gen mode enum across server + client.** The bare `'codex'` / `'local'` / `'external'` string literals that lived at ~25 dispatch sites across `server/services/imageGen/{index,codex,local,external}.js`, `server/services/mediaJobQueue/index.js`, `server/services/pipeline/visualStages.js`, `server/services/universeCharacterSheet.js`, `server/routes/{imageGen,universeBuilder,sdapi,pipeline}.js`, `server/services/pipeline/issues.js`, `server/services/voice/tools.js`, and the matching client surfaces (`ImageGen.jsx`, `ImageGenTab.jsx`, `VisualGenSettings.jsx`, `ImageGenControls.jsx`, `MediaJobsQueue.jsx`, `MediaLightbox.jsx`, `PromptRefineModal.jsx`, `normalize.js`, `imageGenResolutions.js`, `wrImageDefaults.js`, `ComicScriptStage.jsx`, `UniverseBuilder.jsx`) now flow through a typed enum. Server adds `IMAGE_GEN_MODE = Object.freeze({ EXTERNAL, LOCAL, CODEX })` in a new `server/services/imageGen/modes.js` (standalone so the dispatcher and the provider modules can both import without a cycle), re-exported from `imageGen/index.js`; `IMAGE_GEN_MODES` (the Zod-validator alphabet) is now derived from `Object.values(IMAGE_GEN_MODE)` so the two can't drift. Client `IMAGE_GEN_MODE` in `client/src/lib/imageGenBackends.js` is `Object.freeze`d to match. Zod schemas in `pipeline.js` and `universeBuilder.js` now consume the constants too so a future mode addition is one edit. Provider binary names (`DEFAULT_BIN = 'codex'`) and model-fallback strings stay as bare literals — they're not modes. Three test mocks (`imageGen.test.js`, `sdapi.test.js`, `voice/tools.test.js`) updated to export the new constant. Codex review caught five additional dispatch sites the first pass missed; second pass is CLEAN. 6096/6096 server tests + 240/240 client tests pass.- **[extract-readcertmeta-helper] Shared `readCertMeta()` reader extracted from three call sites.** `server/lib/peerSelfHost.js`, `server/services/certRenewer.js`, and `server/lib/networkExposure.js` each open-coded their own `data/certs/meta.json` reader — three slightly different shapes (`statSync({throwIfNoEntry:false}) + safeJSONParse` in the first two, brittle `existsSync + JSON.parse` in the renewer that would throw on a partial mid-`setup:cert` write). Consolidated into `server/lib/certMeta.js` exporting `readCertMeta() → { mode, hostname?, ips? } | null`, standardized on the safe-JSON pattern so the renewer no longer logs noise on partial writes. New `certMeta.test.js` covers missing/malformed/tailscale/self-signed; barrel + README catalog rows added per the `server/lib/` maintenance rule. `/simplify` also cleaned out two dead `tryReadFile: vi.fn()` mock entries in `peerSelfHost.test.js` and `networkExposure.test.js` (leftover from earlier iterations, neither file imports `tryReadFile`). All 6100 server tests pass. Captured `[hoist-certmeta-to-top-level-lib]` as a follow-up to share the helper with `scripts/print-access-url.js` (a fourth bespoke reader) once the path is parameterized.diff --git a/PLAN.md b/PLAN.mdindex 088439d7b4..1893bc6172 100644--- a/PLAN.md+++ b/PLAN.md@@ -12,7 +12,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.- [ ] [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]`.### v2.1.0 pre-release review residue (deferred from main→release multi-agent review, 2026-05-16)