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
feat: per-series editorial-check config overrides (#1591)
Adam Eivy6f74e92b62d6
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 82b2dec857..61b73c8f3b 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -71,6 +71,8 @@- **[issue-1590] The telling-not-showing emotion check now catches the whole show-vs-tell family, not just named emotions.** `prose.telling-emotion` previously flagged only outright emotion labels ("she was sad", "he felt nervous"), missing three sibling forms of telling that weaken prose the same way: **agency-removing constructions** where the situation narrates itself with no one acting ("the story unfolded", "tension filled the room", "the argument escalated"), **reported-sensation filtering** where a feeling is routed through a perceiving verb instead of dramatized ("she saw the anger in his face" → "his jaw clenched"), and **asserted / unearned knowledge** handed to the reader with no grounding ("somehow she knew", "he just knew it was over"). The LLM stage prompt now covers all four, and explicitly defers purely mechanical filter words ("she saw the bus pull up") to the deterministic `prose.filter-words` check so the two don't double-flag the same line. Existing installs auto-upgrade the prompt via a hash-driven migration (customized copies are left intact and warned about). (`data.reference/prompts/stages/pipeline-editorial-telling-emotion.md`, `scripts/migrations/137-editorial-telling-emotion-broaden.js`)+- **[issue-1591] Editorial check thresholds can now be tuned per series, not just globally.** The comic lettering-density check (and every other check that exposes config — naming sensitivity, dialogue-tag thresholds, and so on) shipped one global set of thresholds for the whole install, so a YA graphic novel, a manga, and a prose-heavy webcomic all had to share the same `25 words/balloon` ceiling. Each check card on the **Editorial Checks** page now grows an **"Override for this series"** panel once a series is selected: tune any threshold for that one series, leave the rest to fall through to the global value, and a **Reset to global** link clears the override. Overrides live on the series record (a per-check `editorialCheckConfig` map), so the runner overlays them on top of the global config at run time — re-validating each merged blob through the check's own schema so an out-of-range per-series value can never corrupt a pass (it falls back to the global value, not the schema default). The new field is wire-gated (pipelineSeries schema v8) so an older federated peer can't strip-then-LWW the loss, and it syncs with the series like every other durable field. (`server/lib/editorial/checkRegistry.js`, `server/services/pipeline/editorial/checkRunner.js`, `server/services/pipeline/series.js`, `server/routes/pipeline/series.js`, `server/lib/schemaVersions.js`, `client/src/pages/PipelineEditorialChecks.jsx`, `client/src/components/pipeline/editorial/EditorialCheckCard.jsx`)+- **[issue-1592] The adverb check no longer flags invisible reporting dialogue tags like "said quietly" — only emotion-telling ones like "said angrily".** `prose.adverbs` treated *every* adverb on a dialogue tag as a weak attribution, but "said quietly / softly / sharply" is a near-invisible stage direction that tells the reader *how* a line was voiced, while "said angrily / happily / sorrowfully" *names the feeling* the dialogue itself should carry. Lumping them together produced false positives on legitimate reporting adverbs — which trains writers to ignore the check. The check now classifies each tag adverb as **reporting** (a curated manner/volume/pace allow-list) or **emotion-telling** (everything else, so a novel emotion adverb still gets caught) and flags only the emotion-telling bucket by default; the bulk per-1000-word adverb-density signal (the prose-body flagging) is unchanged. A new per-series **"Also flag reporting tags"** toggle restores the old flag-every-tag behavior for anyone who wants the strict pass. (`server/lib/editorial/proseTics.js`, `server/lib/editorial/checkRegistry.js`)## Series Autopilotdiff --git a/client/src/components/pipeline/editorial/EditorialCheckCard.jsx b/client/src/components/pipeline/editorial/EditorialCheckCard.jsxindex 7b67a3bac2..3e764fee0e 100644--- a/client/src/components/pipeline/editorial/EditorialCheckCard.jsx+++ b/client/src/components/pipeline/editorial/EditorialCheckCard.jsx@@ -4,10 +4,13 @@* form built from the check's `configFields` render descriptors.** Presentational — all persistence is lifted to PipelineEditorialChecks:- * onToggle(checkId, nextEnabled) → optimistic enable/disable PATCH- * onConfigSave(checkId, nextConfig) → PATCH the full config blob (Promise)+ * onToggle(checkId, nextEnabled) → optimistic enable/disable PATCH+ * onConfigSave(checkId, nextConfig) → PATCH the global config blob (Promise)+ * onSeriesConfigSave(checkId, nextOverride) → PATCH this series' override (#1591);+ * pass `null` to clear the override* The card only owns the in-progress *input* draft; committed values come back- * down through `check.config`.+ * down through `check.config` (global) and `seriesConfig` (the selected series'+ * override for this check, when a series is selected).*/import { memo, useEffect, useState } from 'react';import { ChevronDown, ChevronRight, Loader2, Pencil, Sliders, Trash2 } from 'lucide-react';@@ -77,11 +80,19 @@ function ConfigField({ checkId, field, value, disabled, onCommit }) {);}-function EditorialCheckCard({ check, saving = false, onToggle, onConfigSave, onEdit, onDelete }) {+function EditorialCheckCard({+ check, saving = false, onToggle, onConfigSave, onEdit, onDelete,+ seriesId = '', seriesConfig = null, seriesSaving = false, onSeriesConfigSave,+}) {const [expanded, setExpanded] = useState(false);+ const [seriesExpanded, setSeriesExpanded] = useState(false);const [confirmDelete, setConfirmDelete] = useState(false);const hasConfig = Array.isArray(check.configFields) && check.configFields.length > 0;const isCustom = !!check.isCustom;+ // A per-series override panel is only meaningful when a series is selected, the+ // check is tunable, and the parent wired a save handler (#1591).+ const canOverride = hasConfig && !!seriesId && typeof onSeriesConfigSave === 'function';+ const hasSeriesOverride = !!seriesConfig && Object.keys(seriesConfig).length > 0;return (<div className="rounded-lg border border-port-border bg-port-card p-3 space-y-2">@@ -143,6 +154,54 @@ function EditorialCheckCard({ check, saving = false, onToggle, onConfigSave, onE</div>) : null}+ {canOverride ? (+ <div className="border-t border-port-border/60 pt-2">+ <button+ type="button"+ onClick={() => setSeriesExpanded((v) => !v)}+ className="flex items-center gap-1 text-[11px] text-gray-400 hover:text-gray-200"+ aria-expanded={seriesExpanded}+ >+ {seriesExpanded ? <ChevronDown size={13} /> : <ChevronRight size={13} />}+ <Sliders size={12} />+ Override for this series+ {hasSeriesOverride ? (+ <span className="ml-1 rounded bg-port-accent/15 px-1.5 py-0.5 text-[10px] text-port-accent">active</span>+ ) : null}+ </button>+ {seriesExpanded ? (+ <div className="mt-2 space-y-2.5">+ <p className="text-[11px] text-gray-500">+ Tune this check for the selected series only. Untouched fields fall through to the global value above.+ </p>+ {check.configFields.map((field) => (+ <ConfigField+ // Prefix the checkId so the per-series input ids never collide+ // with the global form's (`cfg-<checkId>-<key>`).+ key={field.key}+ checkId={`series-${check.id}`}+ field={field}+ value={seriesConfig?.[field.key] ?? check.config?.[field.key]}+ disabled={seriesSaving}+ onCommit={(key, val) => onSeriesConfigSave(check.id, { ...(seriesConfig || {}), [key]: val })}+ />+ ))}+ {hasSeriesOverride ? (+ <button+ type="button"+ onClick={() => onSeriesConfigSave(check.id, null)}+ disabled={seriesSaving}+ className="inline-flex items-center gap-1 text-[11px] text-gray-400 hover:text-gray-200 disabled:opacity-50"+ >+ {seriesSaving ? <Loader2 size={12} className="animate-spin" /> : null}+ Reset to global+ </button>+ ) : null}+ </div>+ ) : null}+ </div>+ ) : null}+{isCustom && (onEdit || onDelete) ? (<div className="flex items-center justify-end gap-2 border-t border-port-border/60 pt-2">{confirmDelete ? (diff --git a/client/src/components/pipeline/editorial/EditorialCheckCard.test.jsx b/client/src/components/pipeline/editorial/EditorialCheckCard.test.jsxindex 0f8c926b2c..0fce58d7cd 100644--- a/client/src/components/pipeline/editorial/EditorialCheckCard.test.jsx+++ b/client/src/components/pipeline/editorial/EditorialCheckCard.test.jsx@@ -42,4 +42,50 @@ describe('EditorialCheckCard', () => {fireEvent.blur(input); // still 2expect(onConfigSave).not.toHaveBeenCalled();});++ describe('per-series override (#1591)', () => {+ it('hides the override panel when no series is selected', () => {+ render(<EditorialCheckCard check={check} onToggle={vi.fn()} onConfigSave={vi.fn()} onSeriesConfigSave={vi.fn()} />);+ expect(screen.queryByRole('button', { name: /override for this series/i })).toBeNull();+ });++ it('commits a per-series override, falling back to the global value, via onSeriesConfigSave', () => {+ const onSeriesConfigSave = vi.fn();+ render(+ <EditorialCheckCard+ check={check}+ seriesId="ser-1"+ seriesConfig={null}+ onToggle={vi.fn()}+ onConfigSave={vi.fn()}+ onSeriesConfigSave={onSeriesConfigSave}+ />,+ );+ fireEvent.click(screen.getByRole('button', { name: /override for this series/i }));+ const input = screen.getByLabelText('Minimum shared signals to flag');+ expect(input.value).toBe('2'); // seeded from the global config+ fireEvent.change(input, { target: { value: '4' } });+ fireEvent.blur(input);+ expect(onSeriesConfigSave).toHaveBeenCalledWith('naming.dissimilar-names', { minSharedSignals: 4 });+ });++ it('shows an active badge and clears the override via Reset to global', () => {+ const onSeriesConfigSave = vi.fn();+ render(+ <EditorialCheckCard+ check={check}+ seriesId="ser-1"+ seriesConfig={{ minSharedSignals: 4 }}+ onToggle={vi.fn()}+ onConfigSave={vi.fn()}+ onSeriesConfigSave={onSeriesConfigSave}+ />,+ );+ const overrideBtn = screen.getByRole('button', { name: /override for this series/i });+ expect(overrideBtn.textContent).toMatch(/active/i);+ fireEvent.click(overrideBtn);+ fireEvent.click(screen.getByRole('button', { name: /reset to global/i }));+ expect(onSeriesConfigSave).toHaveBeenCalledWith('naming.dissimilar-names', null);+ });+ });});diff --git a/client/src/pages/PipelineEditorialChecks.jsx b/client/src/pages/PipelineEditorialChecks.jsxindex 9f083fbc4f..aae59c91ee 100644--- a/client/src/pages/PipelineEditorialChecks.jsx+++ b/client/src/pages/PipelineEditorialChecks.jsx@@ -25,6 +25,7 @@ import { usePipelineProgress } from '../hooks/usePipelineProgress';import useProviderModels from '../hooks/useProviderModels';import {listPipelineSeries,+ updatePipelineSeries,getEditorialChecks,patchEditorialCheck,createEditorialCustomCheck,@@ -45,6 +46,10 @@ export default function PipelineEditorialChecks() {const [selectedIds, setSelectedIds] = useState(() => new Set());const [series, setSeries] = useState([]);+ // Per-series editorial-check config overrides (#1591) are saved through the+ // series PATCH; track in-flight saves per checkId so the run buttons gate on the+ // override landing (the runner reads the persisted series record).+ const [savingSeriesIds, setSavingSeriesIds] = useState(() => new Set());const seriesId = searchParams.get('series') || '';const [comments, setComments] = useState([]);const [loadingFindings, setLoadingFindings] = useState(false);@@ -198,6 +203,35 @@ export default function PipelineEditorialChecks() {.finally(() => setSavingIds((s) => { const n = new Set(s); n.delete(checkId); return n; }));}, []);+ // ---- Per-series config override (#1591). The override map lives on the SERIES+ // record (`editorialCheckConfig`), so a save PATCHes the series and the runner+ // overlays it on the global config. A ref gives the latest series list so the+ // handler can build the next map without a stale-closure race (editing two+ // checks in succession). `nextOverride === null`/`{}` clears that check. ----+ const seriesRef = useRef(series);+ useEffect(() => { seriesRef.current = series; }, [series]);++ const selectedSeries = useMemo(() => series.find((s) => s.id === seriesId) || null, [series, seriesId]);+ const seriesOverrides = selectedSeries?.editorialCheckConfig && typeof selectedSeries.editorialCheckConfig === 'object'+ ? selectedSeries.editorialCheckConfig+ : null;++ const handleSeriesConfigSave = useCallback((checkId, nextOverride) => {+ const sid = activeSeriesRef.current;+ if (!sid) return;+ const cur = seriesRef.current.find((r) => r.id === sid);+ const map = { ...(cur?.editorialCheckConfig && typeof cur.editorialCheckConfig === 'object' ? cur.editorialCheckConfig : {}) };+ if (!nextOverride || Object.keys(nextOverride).length === 0) delete map[checkId];+ else map[checkId] = nextOverride;+ // Optimistic local update; the server echoes the sanitized record back.+ setSeries((rows) => rows.map((r) => (r.id === sid ? { ...r, editorialCheckConfig: map } : r)));+ setSavingSeriesIds((s) => new Set(s).add(checkId));+ updatePipelineSeries(sid, { editorialCheckConfig: map }, { silent: true })+ .then((s) => { if (s) setSeries((rows) => rows.map((r) => (r.id === s.id ? s : r))); })+ .catch((err) => toast.error(err.message || 'Failed to save series override'))+ .finally(() => setSavingSeriesIds((s) => { const n = new Set(s); n.delete(checkId); return n; }));+ }, []);+// ---- Custom-check authoring (#1346). The form is URL-driven (?custom=new |// ?custom=<checkId>) so it's deep-linkable, not a stateful modal. ----const customParam = searchParams.get('custom') || '';@@ -294,7 +328,7 @@ export default function PipelineEditorialChecks() {// Gate runs on formSaving too: a run reads server-side settings, so starting// one while a custom-check create/edit PATCH is in flight would run the stale// (pre-save) definition. Mirrors the savingIds gate for per-check config saves.- const runDisabled = !seriesId || runActive || runStarting || anySaving || formSaving;+ const runDisabled = !seriesId || runActive || runStarting || anySaving || formSaving || savingSeriesIds.size > 0;return (<div className="mx-auto max-w-6xl space-y-4">@@ -436,6 +470,10 @@ export default function PipelineEditorialChecks() {saving={savingIds.has(check.id)}onToggle={handleToggle}onConfigSave={handleConfigSave}+ seriesId={seriesId}+ seriesConfig={seriesOverrides?.[check.id] || null}+ seriesSaving={savingSeriesIds.has(check.id)}+ onSeriesConfigSave={handleSeriesConfigSave}onEdit={check.isCustom ? openCustomForm : undefined}onDelete={check.isCustom ? handleDeleteCustom : undefined}/>diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex 204e14b10f..aff8d5381d 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -6204,6 +6204,36 @@ export function getEnabledChecks(settings, subsetIds = null) {.filter((x) => x.check);}+/**+ * Overlay a series' per-check config overrides (#1591) onto the GLOBAL+ * `{ check, config }` pairs from `getEnabledChecks`, returning new pairs with+ * the merged config. For each enabled check that carries an override, the+ * override keys win over the (already resolved + valid) global config; the+ * merged blob is re-validated through the check's own `configSchema` so a+ * malformed / out-of-range per-series value can't corrupt the run — on a failed+ * parse the global config is kept unchanged (NOT reset to schema defaults).+ *+ * Pure + side-effect-free. Returns the input array unchanged when `seriesOverrides`+ * is absent/non-object, so a series that tunes nothing pays no allocation.+ *+ * @param {Array<{check: object, config: object}>} enabled pairs from getEnabledChecks+ * @param {Record<string, object>|null|undefined} seriesOverrides series.editorialCheckConfig+ * @returns {Array<{check: object, config: object}>}+ */+export function applySeriesCheckConfig(enabled, seriesOverrides) {+ if (!Array.isArray(enabled)) return [];+ if (!seriesOverrides || typeof seriesOverrides !== 'object' || Array.isArray(seriesOverrides)+ || Object.keys(seriesOverrides).length === 0) {+ return enabled;+ }+ return enabled.map(({ check, config }) => {+ const override = seriesOverrides[check.id];+ if (!override || typeof override !== 'object' || Array.isArray(override)) return { check, config };+ const parsed = check.configSchema.safeParse({ ...config, ...override });+ return { check, config: parsed.success ? parsed.data : config };+ });+}+// ---------------------------------------------------------------------------// User-defined checks (#1346) — definition storage + synthesis.//diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 7d9f639878..60e0acd4f3 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -11,6 +11,7 @@ import {resolveCheckConfig,resolveCheckState,getEnabledChecks,+ applySeriesCheckConfig,buildCustomCheck,buildCustomCheckPrompt,isValidCustomCheckDef,@@ -252,6 +253,49 @@ describe('editorial check registry — config + state resolution', () => {});});+describe('applySeriesCheckConfig — per-series config overrides (#1591)', () => {+ const LETTERING = 'comic.lettering-density';+ const enabledFor = (id) => getEnabledChecks({}, [id]);++ it('returns the input unchanged when there are no overrides', () => {+ const enabled = enabledFor(NAMING);+ expect(applySeriesCheckConfig(enabled, null)).toBe(enabled);+ expect(applySeriesCheckConfig(enabled, undefined)).toBe(enabled);+ expect(applySeriesCheckConfig(enabled, [])).toBe(enabled); // non-plain-object → ignored+ expect(applySeriesCheckConfig(enabled, {})).toBe(enabled); // empty map, no matching id+ });++ it('overlays a per-series threshold over the global config (override key wins)', () => {+ const enabled = enabledFor(LETTERING);+ const globalBalloon = enabled[0].config.maxWordsPerBalloon;+ const out = applySeriesCheckConfig(enabled, { [LETTERING]: { maxWordsPerBalloon: 12 } });+ expect(out[0].config.maxWordsPerBalloon).toBe(12);+ // Untouched keys still resolve from the global config (merge, not replace).+ expect(out[0].config.maxWordsPerPanel).toBe(enabled[0].config.maxWordsPerPanel);+ // The input pair is not mutated.+ expect(enabled[0].config.maxWordsPerBalloon).toBe(globalBalloon);+ });++ it('keeps the global config when a per-series override is out of range (no reset to defaults)', () => {+ const enabled = enabledFor(LETTERING).map((p) => ({+ ...p,+ // Pretend the global config itself was tuned, to prove an invalid override+ // falls back to THAT (not the schema defaults).+ config: { ...p.config, maxWordsPerBalloon: 40 },+ }));+ const out = applySeriesCheckConfig(enabled, { [LETTERING]: { maxWordsPerBalloon: 99999 } });+ expect(out[0].config.maxWordsPerBalloon).toBe(40);+ });++ it('ignores an override keyed to a different check / non-object override', () => {+ const enabled = enabledFor(LETTERING);+ const base = enabled[0].config.maxWordsPerBalloon;+ expect(applySeriesCheckConfig(enabled, { [NAMING]: { minSharedSignals: 5 } })[0].config.maxWordsPerBalloon).toBe(base);+ expect(applySeriesCheckConfig(enabled, { [LETTERING]: 'nope' })[0].config.maxWordsPerBalloon).toBe(base);+ expect(applySeriesCheckConfig(enabled, { [LETTERING]: [1, 2] })[0].config.maxWordsPerBalloon).toBe(base);+ });+});+describe('prose.info-dumping — LLM check', () => {// Default ctx: the runner-injected chunker resolves to a single whole-corpus// chunk (the common "provider fits the book" case). Tests that exercisediff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.jsindex 8185311bfc..d74ee548d2 100644--- a/server/lib/schemaVersions.js+++ b/server/lib/schemaVersions.js@@ -115,7 +115,16 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({// would drop the reference (and reset the flag) and last-writer-wins the loss// back onto the newer peer. Bump makes the older peer reject the ahead-version// series transfer instead. Per-category gate → only series sync pauses with old peers.- pipelineSeries: 7,+ // v8 = `series.editorialCheckConfig` added (#1591) — a per-series map of+ // editorial-check config overrides ({ [checkId]: { [key]: value } }) that tune a+ // check's thresholds (e.g. comic lettering density) for one series without+ // touching the global catalog. Same silent-strip-then-LWW corruption as+ // styleGuide/characterArcs: a ≤v7 peer that re-sanitizes a series through its+ // editorialCheckConfig-unaware `sanitizeSeries` would drop the overrides and+ // last-writer-wins the loss back onto the newer peer. Bump makes the older peer+ // reject the ahead-version series transfer instead. Per-category gate → only+ // series sync pauses with old peers.+ pipelineSeries: 8,// NOT bumped for the manuscript-review sibling doc now bundled on series// pushes/exports (`data/pipeline-series/{id}/manuscript-review.json`).// Unlike `readerMap` (v2), the review is NOT a field inside the seriesdiff --git a/server/lib/schemaVersions.test.js b/server/lib/schemaVersions.test.jsindex ab40a7f15a..e2b8976a01 100644--- a/server/lib/schemaVersions.test.js+++ b/server/lib/schemaVersions.test.js@@ -27,10 +27,10 @@ describe('PORTOS_SCHEMA_VERSIONS', () => {it('declares pipeline collection layout versions', () => {// pipelineIssues bumped to 2 when stages.audio.audioMode + cues[] were added.expect(PORTOS_SCHEMA_VERSIONS.pipelineIssues).toBe(2);- // pipelineSeries bumped to 7 when series.factCritical + series.factReference- // were added (#1588) (v2 = readerMap, v3 = tickingClock, v4 = styleGuide,- // v5 = coverImage, v6 = characterArcs).- expect(PORTOS_SCHEMA_VERSIONS.pipelineSeries).toBe(7);+ // pipelineSeries bumped to 8 when series.editorialCheckConfig was added (#1591)+ // (v2 = readerMap, v3 = tickingClock, v4 = styleGuide, v5 = coverImage,+ // v6 = characterArcs, v7 = factCritical + factReference).+ expect(PORTOS_SCHEMA_VERSIONS.pipelineSeries).toBe(8);});it('declares mediaCollections layout version', () => {@@ -44,7 +44,7 @@ describe('buildPortosMeta', () => {expect(meta.portosVersion).toMatch(/^\d+\.\d+\.\d+/);expect(meta.schemaVersions.universes).toBe(7);expect(meta.schemaVersions.pipelineIssues).toBe(2);- expect(meta.schemaVersions.pipelineSeries).toBe(7);+ expect(meta.schemaVersions.pipelineSeries).toBe(8);});it('overrides merge into schemaVersions', async () => {diff --git a/server/routes/pipeline/series.js b/server/routes/pipeline/series.jsindex 32c0cd99c7..2420e21404 100644--- a/server/routes/pipeline/series.js+++ b/server/routes/pipeline/series.js@@ -223,6 +223,12 @@ const seriesPatchSchema = z.object({issueCountTarget: z.number().int().min(0).max(seriesSvc.ISSUE_COUNT_TARGET_MAX).optional(),llm: llmSchema,ephemeral: z.boolean().optional(),+ // Per-series editorial-check config overrides (#1591): { [checkId]: { [key]: value } }.+ // A free-form blob (like the global per-check `config`) — re-validated against each+ // check's own Zod configSchema at run time (applySeriesCheckConfig) and bounded by+ // sanitizeEditorialCheckConfig on persist; this gate just keeps the wire shape sane.+ // `null`/`{}` clears all overrides.+ editorialCheckConfig: z.record(z.record(z.unknown())).nullable().optional(),}).refine((p) => Object.keys(p).length > 0, { message: 'patch must include at least one field' });const arcFieldLockSchema = z.object({ locked: z.boolean() });diff --git a/server/services/dataSync.pipelineUniverse.test.js b/server/services/dataSync.pipelineUniverse.test.jsindex ce60df74fa..f1e408e59f 100644--- a/server/services/dataSync.pipelineUniverse.test.js+++ b/server/services/dataSync.pipelineUniverse.test.js@@ -1053,12 +1053,12 @@ describe('dataSync — per-category schema gate (cross-key isolation)', () => {const result = await dataSync.applyRemote('pipeline', {series: [{ id: 'ser-1', name: 'Foundry', updatedAt: '2026-05-17T11:00:00Z' }],issues: [],- }, { portosMeta: { portosVersion: '99.0.0', schemaVersions: { universes: 5, pipelineSeries: 8, pipelineIssues: 1, mediaCollections: 1 } } });+ }, { portosMeta: { portosVersion: '99.0.0', schemaVersions: { universes: 5, pipelineSeries: 9, pipelineIssues: 1, mediaCollections: 1 } } });expect(result.applied).toBe(false);expect(result.blockedBySchema).toBeDefined();// The reported gap is scoped to the relevant category — NOT mis-attributed.expect(result.blockedBySchema.ahead).toEqual([- { category: 'pipelineSeries', senderV: 8, receiverV: 7 },+ { category: 'pipelineSeries', senderV: 9, receiverV: 8 },]);expect(readSeriesState()).toEqual([]); // nothing written});diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.jsindex fb1a640fec..11035293f3 100644--- a/server/services/pipeline/editorial/checkRunner.js+++ b/server/services/pipeline/editorial/checkRunner.js@@ -19,7 +19,7 @@ import { randomUUID, createHash } from 'crypto';import { createSseRunner } from '../../../lib/sseUtils.js';import { runStagedLLM, runInlineLLM, runStageScopedInlineLLM, resolveStageContext } from '../../../lib/stageRunner.js';import { planManuscriptPass, fitContextToManuscriptFloor, estimateTokens, MANUSCRIPT_FLOOR_TOKENS } from '../../../lib/contextBudget.js';-import { getEnabledChecks, getEnabledCheckRows, getAllChecks, EDITORIAL_SOURCES, comicLetteringIssues, proseStageIssues } from '../../../lib/editorial/index.js';+import { getEnabledChecks, getEnabledCheckRows, getAllChecks, applySeriesCheckConfig, EDITORIAL_SOURCES, comicLetteringIssues, proseStageIssues } from '../../../lib/editorial/index.js';import { getSettings } from '../../settings.js';import { getSeries } from '../series.js';import { listIssuesForSeries } from '../issues.js';@@ -353,6 +353,11 @@ export async function runEditorialChecks(seriesId, options = {}) {// manuscript section-collection I/O when an enabled check actually consumes// the stitched corpus (deterministic checks like naming use only the canon).const series = await getSeries(seriesId);+ // Overlay this series' per-check config overrides (#1591) onto the global+ // resolved config. The `needs*` gates below read only `check` (config-+ // independent), so they keep using `enabled`; only the run loop consumes the+ // merged config via `enabledResolved`.+ const enabledResolved = applySeriesCheckConfig(enabled, series?.editorialCheckConfig);const needsManuscript = enabled.some(({ check }) => check.needsManuscript);// Reverse-outline fetch is gated on the declared source (#1296) so a run with no// scene-segmentation check pays no extra I/O — mirrors the needsManuscript gate.@@ -547,7 +552,7 @@ export async function runEditorialChecks(seriesId, options = {}) {// must dismiss their now-stale prior open comments.const deterministicRanIds = new Set();let canceled = false;- for (const { check, config } of enabled) {+ for (const { check, config } of enabledResolved) {if (signal?.aborted) { canceled = true; break; }onProgress?.({ type: 'check:start', checkId: check.id, label: check.label });const ctx = { ...baseCtx, config, severityDefault: check.severityDefault };diff --git a/server/services/pipeline/editorial/checkRunner.test.js b/server/services/pipeline/editorial/checkRunner.test.jsindex 3413852b52..82e930c973 100644--- a/server/services/pipeline/editorial/checkRunner.test.js+++ b/server/services/pipeline/editorial/checkRunner.test.js@@ -233,6 +233,40 @@ describe('runEditorialChecks', () => {expect(result.findings.some((f) => f.checkId === 'comic.panel-rhythm')).toBe(false);});+ // Per-series editorial-check config overrides (#1591). A clean 3-word balloon+ // is below the default 25-word ceiling, so it only trips when a per-series+ // override drops the ceiling — proving the runner overlays series config.+ const cleanComicScript = '## Page 1\n\nPanel 1\n**Description:** A quiet field.\n**Dialogue:**\n- ANYA: "We should go."\n';++ it('overlays a series editorialCheckConfig override onto a check\'s thresholds (#1591)', async () => {+ issuesState = [{ id: 'i1', seriesId: 's1', number: 1, stages: { comicScript: { output: cleanComicScript } } }];++ // Default thresholds → the 3-word balloon is clean.+ const before = await runEditorialChecks('s1', { checkIds: ['comic.lettering-density'] });+ expect(before.findings.some((f) => f.checkId === 'comic.lettering-density')).toBe(false);++ // Same series, but a per-series override drops the per-balloon ceiling to 2.+ getSeries.mockResolvedValueOnce({+ id: 's1', universeId: 'u1',+ editorialCheckConfig: { 'comic.lettering-density': { maxWordsPerBalloon: 2 } },+ });+ const after = await runEditorialChecks('s1', { checkIds: ['comic.lettering-density'] });+ expect(after.findings.some((f) => f.checkId === 'comic.lettering-density')).toBe(true);+ });++ it('ignores a malformed/out-of-range per-series override and keeps global thresholds (#1591)', async () => {+ issuesState = [{ id: 'i1', seriesId: 's1', number: 1, stages: { comicScript: { output: cleanComicScript } } }];+ // 999999 is far above the schema max (200): the merged config fails validation,+ // so the global default (25) holds and the clean balloon stays unflagged —+ // a bad override must NOT corrupt the run (nor reset to schema defaults).+ getSeries.mockResolvedValueOnce({+ id: 's1', universeId: 'u1',+ editorialCheckConfig: { 'comic.lettering-density': { maxWordsPerBalloon: 999999 } },+ });+ const result = await runEditorialChecks('s1', { checkIds: ['comic.lettering-density'] });+ expect(result.findings.some((f) => f.checkId === 'comic.lettering-density')).toBe(false);+ });+it('skips disabled checks', async () => {// Disable every LLM check → no provider call, only deterministic findings.// The mock canon has no objects/links, so naming is the only producer.diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.jsindex 37c6496e48..312e42db7c 100644--- a/server/services/pipeline/series.js+++ b/server/services/pipeline/series.js@@ -172,6 +172,48 @@ export const sanitizeAutopilot = (raw) => {// older marker that predates the field reads as "no gaps", not undefined).const toCount = (v) => (Number.isInteger(v) && v >= 0 ? v : 0);+// Per-series editorial-check config overrides (#1591). Shape:+// { [checkId]: { [configKey]: number|string|boolean } }+// Each entry overrides the GLOBAL per-check config (settings.pipelineEditorialChecks)+// for THIS series only — the runner overlays it via `applySeriesCheckConfig`, then+// re-validates the merged blob through the check's own Zod `configSchema`, so a+// malformed/out-of-range value is dropped at run time and can't corrupt a pass.+// This sanitizer therefore only bounds the WIRE shape: a plain object-of-objects+// with primitive leaves, size-capped against a hand-edited/older-peer file. Empty+// → `undefined` (omitted) so a series that sets no override keeps its byte-stable+// on-disk + wire shape against pre-feature peers (the v8 `pipelineSeries` gate+// protects only series that DO carry the field from strip-then-LWW loss).+const ECC_MAX_CHECKS = 200;+const ECC_MAX_KEYS_PER_CHECK = 40;+const ECC_CHECK_ID_MAX = 120;+const ECC_STRING_MAX = 1000;++const sanitizeCheckConfigOverride = (raw) => {+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;+ const out = {};+ for (const [key, value] of Object.entries(raw)) {+ if (Object.keys(out).length >= ECC_MAX_KEYS_PER_CHECK) break;+ if (typeof key !== 'string' || !key) continue;+ if (typeof value === 'number' && Number.isFinite(value)) out[key] = value;+ else if (typeof value === 'boolean') out[key] = value;+ else if (typeof value === 'string') out[key] = value.slice(0, ECC_STRING_MAX);+ // null/object/array leaves are dropped — config fields are primitives.+ }+ return Object.keys(out).length ? out : null;+};++const sanitizeEditorialCheckConfig = (raw) => {+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;+ const out = {};+ for (const [checkId, override] of Object.entries(raw)) {+ if (Object.keys(out).length >= ECC_MAX_CHECKS) break;+ if (typeof checkId !== 'string' || !checkId || checkId.length > ECC_CHECK_ID_MAX) continue;+ const clean = sanitizeCheckConfigOverride(override);+ if (clean) out[checkId] = clean;+ }+ return Object.keys(out).length ? out : undefined;+};+const sanitizeSeriesLocked = (raw = {}) => {if (!raw || typeof raw !== 'object') return {};const out = {};@@ -206,6 +248,7 @@ const sanitizeSeries = (raw) => {const createdAt = isStr(raw.createdAt) ? raw.createdAt : new Date().toISOString();const updatedAt = isStr(raw.updatedAt) ? raw.updatedAt : createdAt;const autopilot = sanitizeAutopilot(raw.autopilot);+ const editorialCheckConfig = sanitizeEditorialCheckConfig(raw.editorialCheckConfig);return {id: raw.id,name,@@ -292,6 +335,13 @@ const sanitizeSeries = (raw) => {// Older peers' sanitizeSeries simply drops the unknown field (forward/// back-compatible)....(autopilot ? { autopilot } : {}),+ // Per-series editorial-check config overrides (#1591). Persisted only when a+ // series actually carries an override so series that never tune a check keep+ // their byte-stable on-disk + wire shape (the v8 `pipelineSeries` gate guards+ // the loss for series that DO carry it). A ≤v7 peer that re-sanitizes a series+ // through its editorialCheckConfig-unaware sanitizeSeries would otherwise drop+ // the overrides and last-writer-wins the loss back onto the newer peer.+ ...(editorialCheckConfig ? { editorialCheckConfig } : {}),};};@@ -515,6 +565,10 @@ export async function updateSeries(id, patch = {}) {// boot-recovery demotion). Wholesale replace; sanitizer normalizes a// non-object back to absent....('autopilot' in patch ? { autopilot: patch.autopilot } : {}),+ // Per-series editorial-check config overrides (#1591). Wholesale replace —+ // `{}`/`null` clears every override; omission preserves. The sanitizer drops+ // empty/malformed entries and normalizes an empty map back to absent.+ ...('editorialCheckConfig' in patch ? { editorialCheckConfig: patch.editorialCheckConfig } : {}),llm: mergedLlm,updatedAt: new Date().toISOString(),});diff --git a/server/services/pipeline/series.test.js b/server/services/pipeline/series.test.jsindex eaed2c14e6..b3b854333e 100644--- a/server/services/pipeline/series.test.js+++ b/server/services/pipeline/series.test.js@@ -125,6 +125,46 @@ describe('pipeline series service', () => {expect(cleared.factReference).toBe('');});+ it('defaults editorialCheckConfig absent and round-trips per-series overrides (#1591)', async () => {+ const plain = await svc.createSeries({ name: 'Plain' });+ // Absent until a series actually tunes a check (byte-stable shape for old peers).+ expect(plain.editorialCheckConfig).toBeUndefined();++ const tuned = await svc.createSeries({+ name: 'YA Graphic Novel',+ editorialCheckConfig: { 'comic.lettering-density': { maxWordsPerBalloon: 18, x: true } },+ });+ expect(tuned.editorialCheckConfig).toEqual({ 'comic.lettering-density': { maxWordsPerBalloon: 18, x: true } });+ });++ it('sanitizes editorialCheckConfig: drops empty/non-object overrides and non-primitive leaves (#1591)', async () => {+ const s = await svc.createSeries({+ name: 'Messy',+ editorialCheckConfig: {+ 'comic.lettering-density': { maxWordsPerBalloon: 30, bad: null, nested: { a: 1 }, arr: [1] },+ 'empty.check': {}, // empty override → dropped+ 'bogus.check': 'not-an-object', // non-object override → dropped+ },+ });+ expect(s.editorialCheckConfig).toEqual({ 'comic.lettering-density': { maxWordsPerBalloon: 30 } });+ });++ it('updateSeries replaces overrides wholesale and clears them with {}/null (#1591)', async () => {+ const s = await svc.createSeries({+ name: 'Tunable',+ editorialCheckConfig: { 'comic.lettering-density': { maxWordsPerBalloon: 10 } },+ });+ // Omission preserves.+ const kept = await svc.updateSeries(s.id, { logline: 'L2' });+ expect(kept.editorialCheckConfig).toEqual({ 'comic.lettering-density': { maxWordsPerBalloon: 10 } });+ // Wholesale replace.+ const replaced = await svc.updateSeries(s.id, { editorialCheckConfig: { 'comic.panel-rhythm': { maxConsecutiveSplash: 1 } } });+ expect(replaced.editorialCheckConfig).toEqual({ 'comic.panel-rhythm': { maxConsecutiveSplash: 1 } });+ // {} clears (sanitizer normalizes the empty map back to absent).+ const cleared = await svc.updateSeries(s.id, { editorialCheckConfig: {} });+ expect(cleared.editorialCheckConfig).toBeUndefined();+ });+it('updateSeries throws ERR_NOT_FOUND for unknown id', async () => {await expect(svc.updateSeries('ser-nope', { name: 'x' })).rejects.toMatchObject({ code: svc.ERR_NOT_FOUND });});diff --git a/server/services/sharing/integration.test.js b/server/services/sharing/integration.test.jsindex dcf154630a..519100ba1f 100644--- a/server/services/sharing/integration.test.js+++ b/server/services/sharing/integration.test.js@@ -2333,7 +2333,7 @@ describe('sharing round-trip', () => {const result = await importer.processManifest(bucket.id, exp.filename);expect(result.skipped).toBe(true);expect(result.reason).toBe('portos-schema-ahead');- expect(result.ahead).toEqual([{ category: 'pipelineSeries', senderV: 99, receiverV: 7 }]);+ expect(result.ahead).toEqual([{ category: 'pipelineSeries', senderV: 99, receiverV: 8 }]);expect(result.producedByVersion).toBe('99.0.0');// Series stayed tombstoned (or absent) — apply was refused.await expect(series.getSeries(s.id)).rejects.toThrow();