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
test([med-importer-server-services-importer-test-js-no]): pin existingCanonBlock dedupe wiring in importer service tests
[._.]/ Adam Eivy10ff077873e8
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 13f93cac70..9c17d6e183 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## Changed+- **[med-importer-server-services-importer-test-js-no] Pin `existingCanonBlock` dedupe wiring in importer service tests.** `server/services/importer.test.js` had no coverage for the `existingCanonBlock` argument that `analyzeImport` passes into the `importer-canon-extract` LLM call at `importer.js:472-479` — a refactor that dropped the arg or wired it to `null`/`''` would leave the canon-extract LLM blind to already-seeded characters / places / objects, and every second-pass import would silently re-extract duplicates. New `'wires existingCanonBlock into the canon-extract prompt for dedup on a second-pass import'` test in `analyzeImport`'s describe block seeds a universe with one character via `universeSvc.createUniverse` + `updateUniverse`, runs `analyzeImport` against the seeded universe name, looks up the `importer-canon-extract` call by stage name (defensive against future `Promise.all` scheduling changes vs. the brittle `calls[0]` shape from the PLAN ask), and asserts the seeded character name reaches `existingCanonBlock`. The lookup-by-stage-name is the only deviation from the PLAN ask's literal `calls[0][1]` shape — `analyzeImport` fires canon + arc via `Promise.all` and any future deferral / reorder would silently break the test. 46/46 importer tests pass.+- **[audit-remaining-getissue-prechecks-in-pipeline-routes] Audit of remaining `getIssue` prechecks in `pipeline.js`; music attach/delete routes drop the redundant read.** Followed up on the comic-cover consolidation by tracing each of the 10 sites cited in PLAN.md plus `:1427` found during the audit, so 11 sites total in `server/routes/pipeline.js`. Verdict: **8 stay, 2 drop, 1 keep-but-unbind**. **Drop** at `/issues/:id/stages/audio/music/attach` and `DELETE /issues/:id/stages/audio/music` — the only consumer was `audioStatusAfterMusicChange(issue)` (reads `issue.stages.audio.lines.length`), which now derives from `currentStage` inside `updateStageWithLatest`'s `computeFn` instead. Helper signature changed from `(issue) => …` to `(stage) => …`. **Keep-but-unbind** at `/issues/:id/stages/audio/music/upload` — the precheck must gate `importUploadedTrack` (a filesystem write) so a bad id doesn't orphan an imported file when the subsequent write 404s; the binding is dropped because the status computation now uses the freshest stage too. **Keep** at the other 8 sites because each route consumes issue data the called service can't supply: `extract-audio-lines` / `audio/lines/:lineIdx/render` / `storyboards/extract-scenes` / `comicPages/extract-pages` / `:stageId/extract-canon` all need `issue.seriesId` (or stage-locked guard against a sibling stage); `GET /issues/:id` IS the read; `comicPages/pages/:pageIndex/render` keeps the precheck-only-error-shape pageIndex bounds check (the inline comment explicitly justifies it as "avoids loading the bible context just to error out"); and `auto-run-text` keeps the precheck-only-error-shape sync 404 (the runner's IIFE is fire-and-forget, so without the precheck a bad id returns 200 with a runId that immediately errors out via SSE). Net: per-request `data/issues.json` reads on attach/delete music drop from 2 → 1, and the status computation moves from a stale snapshot to the freshest persisted state (eliminates a small TOCTOU window vs. a concurrent line edit). New tests pin the 404 status AND `PIPELINE_ISSUE_NOT_FOUND` error code for both refactored routes (the precheck-removal equivalence depends on the downstream not changing the error shape). 87/87 pipeline route tests pass; 6152/6152 server tests pass.- **[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`.diff --git a/PLAN.md b/PLAN.mdindex 31d2331acd..7465b0e54e 100644--- a/PLAN.md+++ b/PLAN.md@@ -14,7 +14,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)-- [ ] [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.diff --git a/server/services/importer.test.js b/server/services/importer.test.jsindex 1fd998b572..24c8bf7ade 100644--- a/server/services/importer.test.js+++ b/server/services/importer.test.js@@ -296,6 +296,32 @@ describe('analyzeImport', () => {});});+ it('wires existingCanonBlock into the canon-extract prompt for dedup on a second-pass import', async () => {+ // Regression-pin: a refactor that drops the `existingCanonBlock` arg+ // (or wires it to `null` / `''`) leaves the canon-extract LLM blind to+ // already-seeded canon and silently re-extracts duplicates on every+ // subsequent import.+ const uni = await universeSvc.createUniverse({ name: 'Seeded U' });+ await universeSvc.updateUniverse(uni.id, {+ characters: [{ name: 'Aria Existing' }],+ });++ wireDefaultLLMResponses();+ await importerSvc.analyzeImport({+ universeName: 'Seeded U',+ seriesName: 'New Series',+ contentType: 'short-story',+ source: 'A new story arrives.',+ });++ // Lookup by stage name rather than calls[0] — analyzeImport fires+ // canon + arc via Promise.all and any future scheduling change could+ // swap the order without breaking the contract.+ const canonCall = mockRunStagedLLM.mock.calls.find((c) => c[0] === 'importer-canon-extract');+ expect(canonCall).toBeDefined();+ expect(canonCall[1].existingCanonBlock).toContain('Aria Existing');+ });+it('rejects a locked-arc series with ERR_LOCKED before calling the LLM', async () => {// Pre-seed a series with locked.arc, then re-analyze with its name.const uni = await universeSvc.createUniverse({ name: 'Locked U' });