Skip to content

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

docs([unknown-instance-id-sentinel-extract]): remove from PLAN.md and log to changelog

[._.]/ Adam Eivy0e0d4173a145
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 10ad191655..ce43d5f740 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -8,6 +8,8 @@
- **[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.
+
- **[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. `/simplify` reuse pass picked up a third inline loopback check in `client/src/components/settings/ImageGenTab.jsx#advertisedA1111Url` (`h === 'localhost' || h === '127.0.0.1' || h === '::1'`); migrated to `isLoopbackHost(h)` in the same diff so the advertised-A1111 hint now also rejects the browser-bracketed `[::1]` form and the full 127.x range. 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.
diff --git a/PLAN.md b/PLAN.md
index 1893bc6172..5729b01b8f 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -12,8 +12,6 @@ _Nothing currently parked — pick the next item from the Backlog._
### Code quality / dedup (from `/simplify` passes)
-- [ ] [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)
- [ ] [med-pipeline-server-services-pipeline-arcplanner-2] **[MED][PIPELINE]** `server/services/pipeline/arcPlanner.js:929-942` — `buildSeasonRemap` Pass 3 (positional fallback) silently invents wrong mappings when the LLM structurally reshapes the arc. Log a warning when Pass 3 fires; consider only firing when unmatched count ≤ 1.
@@ -25,8 +23,6 @@ _Nothing currently parked — pick the next item from the Backlog._
- [ ] [med-importer-server-routes-importer-test-js-no] **[MED][IMPORTER]** `server/routes/importer.test.js` — no test pins `ERR_PARTIAL_COMMIT_ISSUES → 207` status mapping. Future refactor that drops the entry from `SERVICE_ERROR_STATUS` would 500 on partial commits and trigger pager alerts (the in-code comment's stated regression).
- [ ] [med-importer-server-services-importer-test-js-no] **[MED][IMPORTER]** `server/services/importer.test.js` — no test exercises `existingCanonBlock` dedupe wiring. A regression that wires `null` would silently degrade second-pass imports. Assert `mockRunStagedLLM.mock.calls[0][1].existingCanonBlock` contains a seeded character name.
- [ ] [med-canon-server-services-canonusage-js-zero-test] **[MED][CANON]** `server/services/canonUsage.js` — zero test coverage for `getUniverseCanonUsage`. The "Appears-in sort: issueCount desc + alpha tiebreaker" invariant lives at line ~101 with no test. Add a `canonUsage.test.js`.
-- [ ] [promote-unknown-instance-id-constant] **[LOW][SHARING]** Promote `UNKNOWN_INSTANCE_ID` from `server/services/sharing/importer.js:41` to a shared module (likely `server/services/instances.js`) and replace the bare string `'unknown'` literal at the four other sites that compare against it: `server/services/sharing/manifest.js` (multiple), `server/services/sharing/annotationsSync.js` (`flushAll` early-return), `server/services/mediaAnnotations.js` (`mergePeerAnnotations` peer-id guard), and `server/services/sharing/importer.js` (additional `manifest.producedByVersion || 'unknown'` etc.). Surfaced by /simplify during the sharing-merge-hardening bundle; deferred to keep that PR scoped to behavior fixes.
-
### Better-audit residue
- [ ] [extract-shared-requiretoolkit-helper] **[LOW][CODE]** Three services now carry an identical private `requireToolkit()` helper that throws `ServerError('AI Toolkit not initialized', { status: 503, code: 'AI_TOOLKIT_NOT_INITIALIZED' })` — `server/services/providers.js`, `server/services/runner.js`, `server/services/promptService.js`. Three module-level `let aiToolkitInstance = null` declarations all receive the same toolkit object from `server/index.js` via per-service `setAIToolkit(toolkit)` setters. Candidate consolidation: extract to `server/lib/aiToolkitState.js` exporting `setAIToolkitInstance(toolkit)` + `requireToolkit()` so all three services import the same module-level state. Includes barrel + README row per `server/lib/` maintenance rule. Deferred from `[extract-requiretoolkit-pattern-to-runner-js]` — three callers crosses the threshold but the 8-line helper × 3 sites is low-maintenance enough that this can wait for a fourth caller or somebody actually wanting to consolidate.