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
fix([unknown-instance-id-sentinel-extract]): defer peerSelfHost META_PATH resolution to call time
[._.]/ Adam Eivy6ecee2e00a46
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex ce43d5f740..8d1302d049 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -8,7 +8,7 @@- **[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.-- **[unknown-instance-id-sentinel-extract] Promote `UNKNOWN_INSTANCE_ID = 'unknown'` to a shared export of `server/services/instances.js`.** The literal `'unknown'` instance-id sentinel was duplicated at ~10 sites — `getInstanceId()`'s default, `sharing/importer.js`'s local `const UNKNOWN_INSTANCE_ID`, plus comparisons / fallbacks in `mediaAnnotations.js` (readAll heal check, `instanceId === 'unknown'` skip, `mergePeerAnnotations` peer-id guard, `setAnnotation` precondition), `sharing/manifest.js` (`annotationManifestFilename`, `buildManifest` senderInstanceId, `subscriptionFilename`, `manifestFilename` slug fallback, `pruneBucketManifests` guard), and `sharing/annotationsSync.js#flushAll`. All instance-id usages now reach for the named constant from `instances.js`. Different sentinels that happen to share the same string value — peer health-status `status: 'unknown'`, `producedByVersion || 'unknown'`, `source || 'unknown'` display-name — are intentionally left as bare literals because they're not instance ids. `[extract-readcertmeta-helper]` (above) already deferred `peerSelfHost.js`'s `certPaths(PATHS.data)` read into the function body via `readCertMeta()`, so the new transitive import chain through `manifest.js → instances.js → peerSelfHost.js` doesn't reintroduce a module-load PATHS read. Closes both `[unknown-instance-id-sentinel-extract]` and `[promote-unknown-instance-id-constant]` — the two PLAN entries were duplicate framings of the same refactor. 6098/6098 server tests + 242/242 client tests pass.+- **[unknown-instance-id-sentinel-extract] Promote `UNKNOWN_INSTANCE_ID = 'unknown'` to a shared export of `server/services/instances.js`.** The literal `'unknown'` instance-id sentinel was duplicated at ~10 sites — `getInstanceId()`'s default, `sharing/importer.js`'s local `const UNKNOWN_INSTANCE_ID`, plus comparisons / fallbacks in `mediaAnnotations.js` (readAll heal check, `instanceId === 'unknown'` skip, `mergePeerAnnotations` peer-id guard, `setAnnotation` precondition), `sharing/manifest.js` (`annotationManifestFilename`, `buildManifest` senderInstanceId, `subscriptionFilename`, `manifestFilename` slug fallback, `pruneBucketManifests` guard), and `sharing/annotationsSync.js#flushAll`. All instance-id usages now reach for the named constant from `instances.js`. Different sentinels that happen to share the same string value — peer health-status `status: 'unknown'`, `producedByVersion || 'unknown'`, `source || 'unknown'` display-name — are intentionally left as bare literals because they're not instance ids. Codex review flagged that the new transitive import chain through `manifest.js → instances.js → peerSelfHost.js` pulled in a module-load `certPaths(PATHS.data)` read in `peerSelfHost.js`, making tests that proxy `PATHS.data` after import brittle. Moved that read into the `getSelfHost()` body — `PATHS.data` is now resolved at call time. Closes both `[unknown-instance-id-sentinel-extract]` and `[promote-unknown-instance-id-constant]` — the two PLAN entries were duplicate framings of the same refactor. 6136/6136 server tests + 242/242 client tests pass.- **[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.diff --git a/server/lib/peerSelfHost.js b/server/lib/peerSelfHost.jsindex b9f077313d..a36d66fd99 100644--- a/server/lib/peerSelfHost.js+++ b/server/lib/peerSelfHost.js@@ -5,11 +5,13 @@ import { PATHS } from './fileUtils.js';import { certPaths } from '../../lib/certPaths.js';import { readCertMeta } from '../../lib/certMeta.js';-const { meta: META_PATH } = certPaths(PATHS.data);-+// `PATHS.data` is resolved at call time (not module load) so test harnesses+// that proxy `fileUtils.PATHS` after import — and every transitive importer+// of this module via `instances.js` — see their override.export function getSelfHost() {if (process.env.PORTOS_HOST) return process.env.PORTOS_HOST;+ const { meta: META_PATH } = certPaths(PATHS.data);const meta = readCertMeta(META_PATH);if (!meta) return null;return meta.mode === 'tailscale' && typeof meta.hostname === 'string' && meta.hostname