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([drop-redundant-getissue-precheck-comic-cover-render]): remove from PLAN.md and log to changelog
[._.]/ Adam Eivy356604f127b9
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 20ff8b9090..95b7896e43 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## Changed+- **[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.- **[extract-cover-render-handler-factory] Four cover-render route handlers collapsed into one config-driven factory.** The volume front/back + comic-issue front/back cover-render routes in `server/routes/pipeline.js` were 95% identical — differing only in { Zod schema, slot field (`cover` vs `backCover`), script body field (`coverScript` vs `backCoverScript`), optional precheck (issue routes ran `getIssue` for an early 404), enqueue fn (`enqueueVolumeCover` / `enqueueVolumeBackCover` / `enqueueComicCover` / `enqueueComicBackCover`), write fn (`seriesSvc.updateSeasonOnSeries` vs `issuesSvc.updateStageWithLatest`), and response shape (`{ season, series }` vs `{ cover|backCover, issue, stage }`) }. Extracted `makeCoverRenderHandler({ schema, slotField, scriptField, prepare, enqueue, applyWrite, buildResponse })` factory + a pure `buildCoverPatchFn` helper that owns the shared `compute` closure — same `typeof body[scriptField] === 'string'` script-gate semantics (absent preserves, empty-string clears) on all four routes, just defined once. Two named helpers (`updateVolumeSeason`, `updateComicPagesStage`) capture the per-record write signature so the route definitions only declare what's actually different. Net ~80 LOC → ~25 LOC across the four routes; 85/85 pipeline route tests pass (preserves the script-gate invariants pinned by `[med-pipeline-server-routes-pipeline-js-1416-1452]`); 6150/6150 server tests pass.diff --git a/PLAN.md b/PLAN.mdindex 5393f532bf..f5bdbc1171 100644--- a/PLAN.md+++ b/PLAN.md@@ -12,7 +12,7 @@ _Nothing currently parked — pick the next item from the Backlog._### Code quality / dedup (from `/simplify` passes)-- [ ] [drop-redundant-getissue-precheck-comic-cover-render] **[LOW][EFF]** Drop the `prepare: (req) => issuesSvc.getIssue(req.params.id)` precheck from the two comic-issue cover-render routes (`server/routes/pipeline.js:1518` + `:1532`). The follow-up `enqueueComicCover` / `enqueueComicBackCover` already calls `loadBibleContext(issueId)` (`server/services/pipeline/visualStages.js:401`), whose first step at `loadBibleContext`:141 is the same `getIssue(issueId)` — same `ERR_NOT_FOUND` → 404 mapping fires from there. The precheck is a duplicate `data/issues.json` read on every render request, and the inline comment's "before we spend the bible-context load" rationale is misleading because `loadBibleContext`'s first step IS that `getIssue`. Removing it also lets us drop the `prepare` knob from `makeCoverRenderHandler` if no other future caller needs it. Surfaced by /simplify during `[extract-cover-render-handler-factory]`; deferred to keep that PR a pure behavior-preserving refactor.+- [ ] [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.