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([med-tests-no-direct-tests-for-executetuirun-pty]): remove from PLAN.md, drop stale cover-render TODO, log to changelog

[._.]/ Adam Eivy29d1749fc1c0
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 6e5a19fb7f..3f51d72537 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,8 @@
## Changed
+- **[med-tests-no-direct-tests-for-executetuirun-pty] `executeTuiRun` PTY mechanics now have direct test coverage.** The existing `server/lib/tuiPromptRunner.test.js` only covered the two pure helpers (`cleanTuiResponse`, `resolveTuiResponseText`); the PTY-driven core that orchestrates spawn → ready-watch → paste → completion was entirely unverified. New `describe('executeTuiRun')` block mocks `node-pty` and the runner-service hooks so each completion path can be triggered deterministically from the test: input validation (3 cases), spawn failure wrapping, `registerActiveRun` + `emitRunStarted` shape, provider `envVars` merge + `CLAUDECODE` stripping, and the six completion paths — `idle-complete` (after first response chunk + idle window), `timeout` (exitCode 124), `command-not-found` early-fail probe (exitCode 127), clean `exit` (exitCode 0), `killed` (signal in error message), and non-zero exit with tail-bearing error. `fileUtils` stays real except for `ensureDir` (mocked no-op) so the existing `resolveTuiResponseText` tests keep using real `tryReadFile`. 12 new tests; 29/29 file-level tests pass; 6162/6162 server tests pass. PLAN.md drops the self-deferred `[cover-render-factory-target-binding]` entry alongside — it explicitly read "pick this up when a fifth cover-render variant appears," that trigger hasn't fired, and the entry was confusing `/claim`.
+
- **[med-importer-server-routes-importer-test-js-no] Pin `ERR_PARTIAL_COMMIT_ISSUES → 422` status mapping in importer route tests.** `server/routes/importer.test.js` previously covered the `ERR_VALIDATION → 400`, `ERR_LOCKED → 409`, and `universeSvc.ERR_NOT_FOUND → 404` entries in `SERVICE_ERROR_STATUS` but not the partial-commit entry that maps `IMPORTER_PARTIAL_COMMIT_ISSUES → 422`. A refactor that dropped the entry would fall through to `asyncHandler`'s generic 500 path, pager-alert on a user-action-recoverable state (universe + series already persisted, only the issue loop rolled back), and strip the `arcAlreadyPersisted` / `skipArcOnRetry` retry signals the client gates the retry-without-arc-overwrite path on — the exact regression `server/routes/importer.js:28-37`'s long comment warns against. New `commit` suite test mocks `commitImport` to reject with `{ code: ERR_PARTIAL_COMMIT_ISSUES, context: { universeId, seriesId, arcAlreadyPersisted, skipArcOnRetry } }`, asserts status 422, asserts `body.code === ERR_PARTIAL_COMMIT_ISSUES`, and asserts the full context object survives `sanitizeContext` and reaches the client. PLAN cited the historical status (`→ 207`); test pins the current implementation (`→ 422`) per the same in-code rationale (207 trips the client `request()` helper's `response.ok === true` branch and mis-toasts the partial commit as a success). 11/11 route tests pass.
- **[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.
diff --git a/PLAN.md b/PLAN.md
index 64a1707130..a247f30ef2 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -14,12 +14,9 @@ _Nothing currently parked — pick the next item from the Backlog._
- [ ] [audit-remaining-getissue-prechecks-in-pipeline-routes] **[LOW][EFF]** Audit the remaining `issuesSvc.getIssue(req.params.id).catch((err) => { throw mapServiceError(err); })` precheck pattern at `server/routes/pipeline.js:601, 683, 759, 785, 799, 1239, 1277, 1348, 1580, 1741`. Several of these handlers call services that themselves do `getIssue` internally on the first read (e.g. `generateStage` ~line 1267; `enqueueVisualImage` ~line 1729) — same pattern as the comic-cover routes we just consolidated, where the precheck was a duplicate `data/issues.json` read with no error-mapping difference. For each site, trace the called service to verify whether its first persisted read is `getIssue(id)` (or an equivalent `PIPELINE_ISSUE_NOT_FOUND` raiser) and drop the precheck where it is strictly redundant; leave precheck-only-error-shape cases alone. Surfaced by /simplify reuse-agent during `[drop-redundant-getissue-precheck-comic-cover-render]`; deferred to keep that PR a one-route consolidation.
-- [ ] [cover-render-factory-target-binding] **[LOW][CODE]** Collapse `makeCoverRenderHandler`'s 7-field config into a "target binding" object so volume / comic dispatch is one symbol per route. Today `applyWrite` + `buildResponse` are independently passed and a comic config could nonsensically mix `applyWrite: updateVolumeSeason` with `buildResponse: buildVolumeCoverResponse`. A `volumeTarget` / `comicTarget` binding (`{ update, buildResponse }`) makes invalid combos unrepresentable and shrinks the four route configs to `{ schema, slotField, scriptField, target }`. Also: promote `'cover' | 'backCover'` to a `COVER_TARGETS` enum in `server/services/pipeline/owners.js` and derive `scriptField` from it so the parallel `scriptField` field can drop entirely. Surfaced by /simplify during `[extract-cover-render-handler-factory]`; deferred because there are only two bindings (volume / comic) and no third caller is in sight, so today's parameter shape is fine — pick this up when a fifth cover-render variant appears.
-
### 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-tests-no-direct-tests-for-executetuirun-pty] **[MED][TESTS]** No direct tests for `executeTuiRun` PTY mechanics — idle-complete, hard-timeout, missing-binary early-fail, `emitRunStarted` shape, CLAUDECODE env stripping. The new `tuiPromptRunner.test.js` only covers `cleanTuiResponse`.
- [ ] [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`.