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([issue-1842]): log issue #1842 to changelog

[._.]/ Adam Eivy3409083f8c33
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 0e914fe14c..4351ce7a60 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -36,6 +36,8 @@
## Internal
+- **[issue-1842] Replaced magic numbers with canonical constants** — consolidated the duplicated chars-per-token estimate (`Math.ceil(len / 4)`) onto the canonical `estimateTokens()` / `CHARS_PER_TOKEN` from `server/lib/contextBudget.js` at the usage-recording (`server/index.js`, `services/agentRunTracking.js`) and digital-twin-export (×5) sites, and dropped the shadow `estimateTokens` in `services/memoryEmbeddings.js` (now re-exported from `contextBudget` so existing importers are unaffected; `truncateToTokens` uses `CHARS_PER_TOKEN` too). The CoS runner port `5558` was a raw literal in `cos-runner/index.js`, `services/cosRunnerClient.js`, and `services/apps.js`; the importable `server/lib/ports.js` mirror (previously only API/API_LOCAL/UI) now carries the remaining static ecosystem ports (CDP, CDP_HEALTH, `COS`, AUTOFIXER, AUTOFIXER_UI) and those sites use `PORTS.COS` (and `PORTS.CDP`/`AUTOFIXER`/`AUTOFIXER_UI` for the sibling app definitions that were also literals). The CoS runner's kill/cleanup `setTimeout` literals are now named (`SIGKILL_GRACE_MS`, `ORPHAN_CLEANUP_DELAY_MS`, `SHUTDOWN_DRAIN_MS`) and the server's graceful-shutdown force-exit timeout is `GRACEFUL_SHUTDOWN_TIMEOUT_MS`. Behavior-preserving. (#1842)
+
- **[issue-1841] Stopped silently swallowing errors** — replaced `.catch(() => {})` / bare `catch {}` swallows that discarded failures with no log or user signal. The recovery-critical completion writes in `cos-runner/index.js` (output.txt + completion metadata) now log a `console.error` on failure instead of silently dropping a finished task, and `telegramClient.js`'s poll loop logs non-abort errors (JSON/Type errors that were previously retried blind) before retrying. On the client, the silent initial-load `.catch(() => {})` swallows in `ToolsTab.jsx` (rate-limit / submolt / draft refreshes), the `loraTraining/*` pickers (`CharacterLoraChip`, `TrainingPanel`, `LiveSampleGallery`, `CheckpointPicker`, `ImportGalleryDialog`, `UniverseCharacterPicker`), and `meatspace/post/*` (`MemoryBuilder`, `MemoryPractice`, `PostHistory`, `PostDrillConfig`, `PostSessionLauncher`, `ElementsSong`) now `console.warn` the error while keeping their zero-state fallbacks, so a failed load is visible in the console instead of a silent empty state. (#1841)
- **[issue-1843] Logging hygiene: single-line interpolated logs + `parseInt` radix** — enforced the single-line-log convention across a handful of stragglers flagged by the `/do:better` audit. `useErrorNotifications.js` passed `error.context` as a raw object arg to `console.warn/error` (expanding a multi-field console group); it now interpolates the context as a single-line JSON suffix via a shared `formatContext` helper. `routes/database.js` had an embedded `\n` that split a failed-command log into two records — the detail is now whitespace-collapsed onto one line. The per-request route-path `console.log`s in `routes/agentActivity.js`, `routes/platformAccounts.js`, and `routes/agentPersonalities.js` (pure noise — mutations already persist via `logAction`) were removed. And `routes/digital-twin.js`'s `parseInt(req.query.limit)` gained its missing radix `10`. No behavior change beyond log formatting. (#1843)