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([agent-tui-spawn-truncation-warn-parity]): remove from PLAN.md and log to changelog
[._.]/ Adam Eivy9e1a66c655c2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 3f51d72537..714dd7baa8 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -8,6 +8,8 @@- **[med-ai-dispatch-server-lib-tuipromptrunner-js-198] TUI prompt-runner output buffer raised 1MB → 8MB and overflow no longer silent.** `server/lib/tuiHandshake.js` `OUTPUT_BUFFER_CAP` / `OUTPUT_BUFFER_HEADROOM` bumped from 1MB / 1.25MB to 8MB / 10MB so realistic full-context LLM replies (~600KB UTF-8 from a 200K-token window plus screen chrome) no longer head-truncate mid-token when the TUI fails to write its response file and the central handler falls back to the cleaned PTY scrape. `server/lib/tuiPromptRunner.js#executeTuiRun` now tracks an `outputBufferTruncated` flag, logs a one-time warning the first time the new cap is exceeded, and surfaces the flag in the run record's `extras` (`outputTruncated`) so /runs can flag responses where the start may have been lost. The pinned-constants test in `tuiHandshake.test.js` was updated with the new sizes; nothing else moved. 1537/1537 server lib tests pass.+- **[agent-tui-spawn-truncation-warn-parity] Agent TUI spawner mirrors the prompt-runner's overflow visibility.** `server/services/agentTuiSpawning.js` previously sliced the head off both `outputBuffer` (parsed-line, `appendLine` path) and `rawBuffer` (raw PTY stream, fed to `analyzeAgentFailure`) when they crossed `OUTPUT_BUFFER_HEADROOM` / `RAW_BUFFER_HEADROOM` with no signal — a long-running CoS agent whose failure tail got buried behind a long banner-redraw chatter could land in error analysis with the actual symptom already gone. The spawner now tracks `outputBufferTruncated` + `rawBufferTruncated` flags symmetric to `tuiPromptRunner.js`: warns once per buffer (`console.warn` with the agent id + headroom MB) and writes the flag to the agent record via `updateAgent(agentId, { metadata: { [flag]: true } })` so consumers can distinguish a long-run-with-overflow from a clean short run. The companion runner's flag flow stayed in place; this closes the parity gap deferred from `[med-ai-dispatch-server-lib-tuipromptrunner-js-198]`. Three new tests in `agentTuiSpawning.test.js` cover the warn-once + metadata-write for both buffers (via a `vi.mock` of `../lib/tuiHandshake.js` that shrinks the thresholds to ~200 bytes so the wiring is exercisable without pushing millions of bytes through the spawner) and the under-threshold negative case. 6154/6154 server tests pass.+- **[drop-redundant-getissue-precheck-comic-cover-render] Comic-cover render routes drop their redundant `getIssue` precheck.** The two comic-issue cover-render routes in `server/routes/pipeline.js` (`/issues/:id/stages/comicPages/cover/render` and `…/back-cover/render`) carried a `prepare: (req) => issuesSvc.getIssue(req.params.id)` callback that ran an extra `data/issues.json` read on every render request — `enqueueComicCover` / `enqueueComicBackCover` already call `loadBibleContext(issueId)` (`server/services/pipeline/visualStages.js:401`), whose first step at `loadBibleContext`:141 is the same `getIssue(issueId)` raising `PIPELINE_ISSUE_NOT_FOUND` with the same `mapServiceError` → 404 mapping. The precheck was a duplicate read with no behavior difference. Dropped the `prepare` callback at both routes and dropped the `prepare` knob from `makeCoverRenderHandler` entirely — there were no other callers. The route comment block now points at the real upstream source of the 404 instead of the misleading "before we spend the bible-context load" framing. Per-request `data/issues.json` reads on the affected routes drop from 2 to 1. 85/85 pipeline route tests pass (including the unchanged `404s for an unknown issue` case, now serviced from `loadBibleContext`). Captured `[audit-remaining-getissue-prechecks-in-pipeline-routes]` as a follow-up to sweep the same precheck pattern at ~10 other sites in pipeline.js where the called service may already raise the same error.- **[med-ai-dispatch-server-services-digital-twin] `callProviderAI` migrated to `runPromptThroughProvider` — TUI providers now work for Digital Twin AI calls.** `server/services/digital-twin-helpers.js#callProviderAI` previously had a hand-rolled `if (provider.type === 'api') fetch(...) else spawn(provider.command, ...)` split that silently routed TUI providers (claude-code, etc.) into the CLI spawn branch. That branch piped the prompt into stdin against a process expecting a PTY — depending on the binary either it hung until the per-call timeout or scraped its interactive banner chrome into the returned text, so every Digital Twin AI feature was unusable when the user's active provider was a TUI. Migrated to the shared `runPromptThroughProvider` from `server/lib/promptRunner.js` (`source: 'digital-twin'`) so dispatch goes through `executeCliRun` / `executeApiRun` / `executeTuiRun` per `provider.type`, with the same TUI-chrome stripping the rest of the codebase relies on. Return shape (`{ text }` / `{ error }`) is preserved so the 12 call sites across `digital-twin-testing.js`, `digital-twin-import.js`, `digital-twin-enrichment.js`, and `digital-twin-analysis.js` don't change behavior on the parse-and-fallback paths. The legacy `temperature` / `max_tokens` named options were dropped from both the function signature and all 12 call sites — the toolkit's `executeApiRun` doesn't forward them, matching every other unified-runner caller in the repo, so keeping them at call sites would have been cargo-culted. `server/services/digital-twin.test.js` switched from mocking `global.fetch` to mocking `../lib/promptRunner.js` for the goodreads-CSV provider-call test. 87/87 digital-twin tests pass; 6150/6150 server tests pass.diff --git a/PLAN.md b/PLAN.mdindex 4d6dd66ede..beb654389f 100644--- a/PLAN.md+++ b/PLAN.md@@ -16,7 +16,6 @@ _Nothing currently parked — pick the next item from the Backlog._### v2.1.0 pre-release review residue (deferred from main→release multi-agent review, 2026-05-16)-- [ ] [agent-tui-spawn-truncation-warn-parity] **[LOW][AI-DISPATCH]** `server/services/agentTuiSpawning.js:177-179` (and the `rawBuffer` slice at line ~273-274) silently slice the head of the same buffers when they cross `OUTPUT_BUFFER_HEADROOM` / `RAW_BUFFER_HEADROOM`, with no warning and no agent-metadata flag. The companion one-shot runner now sets `outputBufferTruncated` and surfaces it through the run record (see `[med-ai-dispatch-server-lib-tuipromptrunner-js-198]`). Long-running CoS agents using `agentTuiSpawning.js` mostly stream to `output.txt` via `appendAgentOutputLines`, so the buffer overflow here is less load-bearing — but the same warn-once + agent-metadata flag would close the visibility gap. Deferred from `[med-ai-dispatch-server-lib-tuipromptrunner-js-198]` to keep that PR scoped.- [ ] [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`.- [ ] [add-emitrunstarted-hook-shape-test-to-runner] **[LOW][TESTS]** `server/services/runner.test.js` has no coverage for `emitRunStarted`'s payload shape — `runner.js:198-204` flattens `provider` to `provider?.name || provider?.id` and falls back `model ?? provider?.defaultModel`, but no test pins that contract. The `executeTuiRun` PTY tests intentionally mock `emitRunStarted`, so a regression in the flattening logic (e.g. dropping the `name` preference or breaking the model fallback) would slip past `tuiPromptRunner.test.js`. Add a focused test that registers a `runnerConfig.hooks.onRunStarted` mock, calls `emitRunStarted({ runId, provider, model })` with `{ name, id, defaultModel }` variants, and asserts the hook payload shape. Surfaced by codex review iter 1 during `[med-tests-no-direct-tests-for-executetuirun-pty]`; deferred because the scope of that PR was `executeTuiRun` (not `runner.js`), and the fix touches a different test file.