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: add pov.economy editorial check for viewpoint count vs run length (#1620)
[._.]/ Adam Eivy25978599337f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex aecdcd1059..84ebe743e1 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -23,6 +23,7 @@## Editorial checks+- **[issue-1620] A new editorial check flags POV economy — too many viewpoints for the run length, and viewpoints introduced too late to earn their place.** `pov.justified` asks whether each *individual* viewpoint earns an arc, but nothing judged the viewpoint *roster* as a whole. The new `pov.economy` check (series-scope, deterministic, default-on) reads the reverse-outline POV-per-scene map and flags two structural problems: **too many POVs for the run length** (e.g. 8 viewpoints across 12 issues, each barely developed — gated by an absolute floor so a one- or two-POV book is never called a crowd) and a **late-introduced, underdeveloped POV** (first takes the viewpoint in the final stretch of the run and holds only a scene or two). The acceptable POV-to-issue ratio, the minimum run length to judge, and the late-introduction window are all per-series tunable. Purely structural over the outline — no LLM call, no manuscript corpus — and degrades to silence when the outline carries no issue numbers (without a run length neither signal can be judged). (`server/lib/editorial/checkRegistry.js`)- **[issue-1619] A new editorial check flags character-arc regression, circular arcs, and premature closure.** `arc.transitions` finds the change *moments* but never judged whether each arc holds together end to end. The new `arc.regression` check (series-scope, default-on) tracks each character's progress across the issues and flags an unmotivated **regression** (a character grows then reverts with no earned reason — distinct from a dramatized relapse), a **circular arc** (ends in the same state they began, the growth cancelled out), or **premature closure** (the arc resolves early — e.g. issue 3 of 10 — then stays flat, deflating the back half). It reads the stitched manuscript plus the reverse-outline scene map and the authored per-character arcs (`series.characterArcs`), gates its whole-arc verdicts to the final manuscript part so a mid-arc character whose later growth is still ahead is not false-flagged, and degrades to a prose-only scan when no outline or authored arcs exist. Ships the prompt + stage-config for fresh installs and a boot migration (141) so existing installs seed the stage. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-arc-regression.md`, `scripts/migrations/141-editorial-arc-regression-stage.js`)- **[issue-1618] A new editorial check scores the series-wide pacing / intensity escalation curve.** `plot.structure-momentum` flags flat stakes as one of many macro pathologies, but nothing measured the *shape* of intensity across the whole series. The new `pacing.escalation-curve` check (series-scope, default-on) scores each issue's dramatic intensity and flags a curve that fails to build — **flat intensity** (issue 1 reads as intensely as issue N), a **front-loaded climax** (the biggest beat lands early and the back half coasts), **plateaued stakes**, or a **de-escalating arc**. It reads the stitched manuscript plus the reverse-outline scene map and a new deterministic per-issue conflict-marker density tally (a mechanical intensity proxy the model treats as a hint and confirms against the prose), gates its whole-curve verdict to the final manuscript part, and degrades to a prose-only scan when no outline exists. Subsumes "conflict escalation" as one signal of the same curve. Ships the prompt + stage-config for fresh installs and a boot migration (140) so existing installs seed the stage. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-pacing-escalation-curve.md`, `scripts/migrations/140-editorial-pacing-escalation-stage.js`)- **[issue-1697] Health-panel deep-links now honor the triage's session-local check mute.** Muting a check from the Editorial Findings triage (#1602) hid its findings group but the health panel kept advertising that check/category row as clickable — clicking it scrolled to an empty filtered view. The session mute state (`hiddenCheckIds`) was lifted from `EditorialFindingsTriage` up to `PipelineEditorialChecks`, which now subtracts muted checks from the filterable sets the health panel receives; a category stays clickable only while a non-muted check still contributes an open finding to it. (`client/src/pages/PipelineEditorialChecks.jsx`, `client/src/components/pipeline/editorial/EditorialFindingsTriage.jsx`)diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex 878e13df9a..f0a1a9d54f 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -3598,6 +3598,171 @@ export const EDITORIAL_CHECKS = [return findings;},},+ {+ id: 'pov.economy',+ sources: ['reverseOutline'],+ label: 'POV economy (count vs series length, late-introduced viewpoints)',+ description:+ 'Deterministic structural read of the reverse-outline POV-per-scene map at the SERIES level: flags too many viewpoints for the run length (N POV characters across M issues, each barely developed) and a POV introduced too late to earn its place (first appears in the final stretch of the run and holds only a scene or two). The acceptable POV-to-issue ratio and the late-introduction window are per-series tunable. Complements pov.justified (#1295, which asks whether each individual viewpoint earns an arc) by judging the viewpoint ROSTER as a whole. Degrades gracefully when the outline carries no issue numbers — without a series length neither signal can be judged, so the check stays silent.',+ scope: 'series',+ kind: 'deterministic',+ category: 'arc',+ severityDefault: 'low',+ defaultEnabled: true,+ configSchema: z.object({+ // Max POV holders per issue before the roster reads as too crowded for the+ // run length. 0.5 ≈ one viewpoint per two issues; a 12-issue run supports ~6+ // POVs, a 7th-and-up trips the check. Raise for ensemble books, lower for a+ // tight single-lead arc.+ maxPovPerIssue: z.number().min(0.05).max(10).default(0.5),+ // Don't judge POV economy on a run shorter than this many issues — a one- or+ // two-issue book is too short for a count-vs-length verdict.+ minIssues: z.number().int().min(1).max(100).default(3),+ // A POV whose FIRST appearance falls this far into the issue span (0–1) is+ // "late". 0.8 ⇒ the final fifth of the run. Only fires alongside the+ // underdevelopment guard below.+ lateIntroIssueFraction: z.number().min(0).max(1).default(0.8),+ // A late POV is flagged only when it is ALSO underdeveloped — held in this+ // many scenes or fewer. 0 disables the late-introduction check.+ lateIntroMaxScenes: z.number().int().min(0).max(50).default(2),+ }),+ configFields: [+ {+ key: 'maxPovPerIssue',+ label: 'Max POV characters per issue',+ type: 'number',+ min: 0.05,+ max: 10,+ step: 0.05,+ help: 'Flag the roster as too crowded when POV count exceeds this many viewpoints per issue. 0.5 ≈ one viewpoint every two issues (a 12-issue run supports ~6 POVs). Raise for an ensemble book, lower for a single-lead arc.',+ },+ {+ key: 'minIssues',+ label: 'Minimum issues to judge economy',+ type: 'number',+ min: 1,+ max: 100,+ step: 1,+ help: 'Skip the economy verdict for a run shorter than this — too short for a count-vs-length judgment.',+ },+ {+ key: 'lateIntroIssueFraction',+ label: 'Late-introduction window (fraction of run)',+ type: 'number',+ min: 0,+ max: 1,+ step: 0.05,+ help: 'A POV whose first appearance falls this far into the issue span is "late". 0.8 = the final fifth of the run.',+ },+ {+ key: 'lateIntroMaxScenes',+ label: 'Late POV underdevelopment threshold (max scenes)',+ type: 'number',+ min: 0,+ max: 50,+ step: 1,+ help: 'Flag a late-introduced POV only when it is also underdeveloped — held in this many scenes or fewer. 0 disables the late-introduction check.',+ },+ ],+ // Needs a generated reverse outline with at least one POV-tagged scene to read.+ gate: (ctx) => Array.isArray(ctx.reverseOutline)+ && ctx.reverseOutline.some((s) => s && typeof s.povCharacter === 'string' && s.povCharacter.trim()),+ run: (ctx) => {+ const scenes = Array.isArray(ctx.reverseOutline) ? ctx.reverseOutline : [];+ const cfg = ctx.config || {};+ const maxPovPerIssue = Number.isFinite(cfg.maxPovPerIssue) ? cfg.maxPovPerIssue : 0.5;+ const minIssues = Number.isInteger(cfg.minIssues) ? cfg.minIssues : 3;+ const lateFraction = Number.isFinite(cfg.lateIntroIssueFraction) ? cfg.lateIntroIssueFraction : 0.8;+ const lateMaxScenes = Number.isInteger(cfg.lateIntroMaxScenes) ? cfg.lateIntroMaxScenes : 2;+ const severity = ctx.severityDefault || 'low';++ // 1 or 2 POV characters is never a "too many viewpoints" roster, whatever the+ // ratio — the dilution concern is fundamentally about an absolute crowd, and a+ // 2-POV / 3-issue book shares the same 0.67 ratio as the 8-POV / 12-issue book+ // the check targets. So the count signal also requires this absolute floor; the+ // ratio is the tunable, this is a structural truth (not a knob).+ const MIN_POV_TO_FLAG = 3;++ // POV holder → { name, scenes[], firstIssue }, keyed by normalized name so+ // casing/spacing variants collapse into one holder (mirrors pov.justified).+ // Preserves first-appearance order (scenes arrive sequence-ordered).+ const holders = new Map();+ const issueSet = new Set();+ for (const s of scenes) {+ if (!s || typeof s !== 'object') continue;+ const issueNumber = Number.isInteger(s.issueNumber) ? s.issueNumber : null;+ if (issueNumber != null) issueSet.add(issueNumber);+ const pov = typeof s.povCharacter === 'string' ? s.povCharacter.trim() : '';+ if (!pov) continue;+ const key = normalizeName(pov);+ if (!key) continue;+ let entry = holders.get(key);+ if (!entry) { entry = { name: pov, key, scenes: [], firstIssue: issueNumber }; holders.set(key, entry); }+ entry.scenes.push(s);+ if (issueNumber != null && (entry.firstIssue == null || issueNumber < entry.firstIssue)) {+ entry.firstIssue = issueNumber;+ }+ }+ const povCount = holders.size;+ if (povCount === 0) return [];++ // Issue count drives the count-vs-length ratio AND locates "late". Without+ // issue numbers we can't judge against series length, so both signals stay+ // silent (graceful degradation — the outline rode peer sync and an older /+ // hand-edited peer may carry untagged scenes).+ const issueCount = issueSet.size;++ const findings = [];+ const flag = ({ location, problem, suggestion, anchorQuote = '', issueNumber = null }) =>+ findings.push({ severity, category: 'arc', location, problem, suggestion, anchorQuote, issueNumber });++ // 1) Too many POVs for the run length. Only when the run is long enough to+ // judge (minIssues), the roster clears the absolute floor, and the count+ // exceeds the configured viewpoints-per-issue budget.+ if (issueCount >= minIssues && maxPovPerIssue > 0 && povCount >= MIN_POV_TO_FLAG) {+ const budget = Math.floor(issueCount * maxPovPerIssue);+ if (povCount > budget) {+ const names = [...holders.values()].map((h) => h.name).join(', ');+ const perIssues = (1 / maxPovPerIssue).toFixed(1);+ flag({+ location: 'Series',+ problem: `${povCount} POV characters across ${issueCount} issue${issueCount === 1 ? '' : 's'} (${names}) — more viewpoints than the run length can develop. At roughly one viewpoint per ${perIssues} issues this run supports about ${budget}; each viewpoint past that gets less room and the narrative fragments.`,+ suggestion: `Consolidate viewpoints — fold the thinnest POVs into a stronger character's perspective, or cut them — until the roster fits the run (about ${budget} for ${issueCount} issues), or raise "Max POV characters per issue" if this is a deliberate ensemble.`,+ });+ }+ }++ // 2) Late-introduced, underdeveloped POV. A viewpoint whose first appearance+ // lands in the final stretch of the run AND that holds only a scene or two+ // never earns its place. Needs an issue span to locate "late".+ if (lateMaxScenes > 0 && issueCount >= minIssues) {+ const issues = [...issueSet];+ const minIssue = Math.min(...issues);+ const maxIssue = Math.max(...issues);+ const span = maxIssue - minIssue;+ if (span > 0) {+ for (const holder of holders.values()) {+ if (holder.firstIssue == null) continue;+ const sceneCount = holder.scenes.length;+ if (sceneCount > lateMaxScenes) continue;+ const position = (holder.firstIssue - minIssue) / span;+ if (position < lateFraction) continue;+ const first = holder.scenes[0];+ const anchorQuote = typeof first?.anchorQuote === 'string' ? first.anchorQuote : '';+ flag({+ location: `Issue ${holder.firstIssue}: ${sceneLabel(first)}`,+ problem: `"${holder.name}" first takes the viewpoint in issue ${holder.firstIssue} of ${minIssue}–${maxIssue} and holds POV in only ${sceneCount} scene${sceneCount === 1 ? '' : 's'} — a viewpoint introduced too late to develop. A fresh POV arriving in the final stretch reads as a structural seam rather than an earned perspective.`,+ suggestion: `Seed "${holder.name}"'s viewpoint earlier so it has room to pay off, route these late scenes through an established POV character, or cut the viewpoint if it exists only to deliver late information.`,+ anchorQuote,+ issueNumber: holder.firstIssue,+ });+ }+ }+ }++ return findings;+ },+ },{id: 'pov.head-hopping',sources: ['manuscript', 'reverseOutline', 'series.styleGuide'],diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 673ec50248..29c094c3e6 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -2914,6 +2914,149 @@ describe('pov.justified — deterministic check', () => {});});+describe('pov.economy — deterministic check (#1620)', () => {+ const POV = 'pov.economy';+ // Build a scene for a POV holder in a given issue. `seq` keeps first-appearance+ // order stable; `anchorQuote` lets the late-intro anchor assertion bite.+ const scene = (pov, issueNumber, over = {}) => ({+ heading: `${pov}-pov i${issueNumber}`, issueNumber, sequence: 0, anchorQuote: 'q', povCharacter: pov, ...over,+ });+ // Distinct alphabetic names — `normalizeName` strips digits, so "P1".."P8" would+ // all collapse to one holder. Real viewpoint rosters use names, so the fixtures do too.+ const NAMES = ['Aria', 'Bram', 'Cael', 'Dara', 'Enzo', 'Faye', 'Gwen', 'Hugo', 'Ivy', 'Jonas', 'Kira', 'Liam'];+ // N POV holders, one scene each, spread one-per-issue across issues 1..issueCount.+ const roster = (povCount, issueCount) => {+ const out = [];+ for (let i = 0; i < issueCount; i += 1) {+ // Only the first `povCount` holders are distinct viewpoints; the rest reuse+ // NAMES[0] so issue count grows without adding POVs.+ out.push(scene(i < povCount ? NAMES[i] : NAMES[0], i + 1));+ }+ return out;+ };+ const runEcon = (scenes, config = {}) =>+ getCheck(POV).run({ reverseOutline: scenes, config, severityDefault: 'low' });++ it('declares reverseOutline as its only source and is a series-scope deterministic check', () => {+ const c = getCheck(POV);+ expect(c.scope).toBe('series');+ expect(c.kind).toBe('deterministic');+ expect(c.sources).toEqual(['reverseOutline']);+ expect(c.defaultEnabled).toBe(true);+ // Must NOT pull in the manuscript corpus — purely structural over the outline.+ expect(c.sources).not.toContain('manuscript');+ });++ it('gate requires at least one POV-tagged scene', () => {+ const c = getCheck(POV);+ expect(c.gate({ reverseOutline: [] })).toBe(false);+ expect(c.gate({ reverseOutline: [scene('', 1)] })).toBe(false);+ expect(c.gate({ reverseOutline: [scene('Aria', 1)] })).toBe(true);+ });++ it('flags too many POVs for the run length (8 across 12 issues)', () => {+ const findings = runEcon(roster(8, 12));+ const crowded = findings.filter((f) => /more viewpoints than the run length/.test(f.problem));+ expect(crowded).toHaveLength(1);+ expect(crowded[0].location).toBe('Series');+ expect(crowded[0].category).toBe('arc');+ expect(crowded[0].severity).toBe('low');+ // 12 * 0.5 = budget 6, so 8 POVs > 6.+ expect(crowded[0].problem).toMatch(/8 POV characters across 12 issues/);+ expect(crowded[0].problem).toMatch(/supports about 6/);+ });++ it('does NOT flag a roster that fits the run length (6 across 12 issues)', () => {+ const findings = runEcon(roster(6, 12));+ expect(findings.filter((f) => /more viewpoints than the run length/.test(f.problem))).toHaveLength(0);+ });++ it('never flags 1–2 POVs as a crowd even at a high ratio (2 across 3 issues)', () => {+ // 2/3 shares the same 0.67 ratio as 8/12, but two viewpoints is not a crowd —+ // the absolute floor (3) suppresses it.+ const findings = runEcon([scene('A', 1), scene('B', 2), scene('A', 3)]);+ expect(findings.filter((f) => /more viewpoints than the run length/.test(f.problem))).toHaveLength(0);+ });++ it('skips the economy verdict for a run shorter than minIssues', () => {+ // 4 POVs but only 2 issues (< default minIssues 3) → no count finding.+ const findings = runEcon([scene('A', 1), scene('B', 1), scene('C', 2), scene('D', 2)]);+ expect(findings.filter((f) => /more viewpoints than the run length/.test(f.problem))).toHaveLength(0);+ });++ it('respects a custom maxPovPerIssue (ensemble tuning suppresses the crowd flag)', () => {+ // 8/12 trips at the 0.5 default but not at 1.0 (budget 12).+ expect(runEcon(roster(8, 12), { maxPovPerIssue: 1.0 })+ .filter((f) => /more viewpoints than the run length/.test(f.problem))).toHaveLength(0);+ });++ it('flags a late-introduced, underdeveloped POV (first appears in issue 11 of 12)', () => {+ // A 12-issue run carried by P1, plus a drive-by viewpoint that first shows up+ // in issue 11 with a single scene.+ const scenes = [];+ for (let i = 1; i <= 12; i += 1) scenes.push(scene('Lead', i));+ scenes.push(scene('Latecomer', 11));+ const findings = runEcon(scenes);+ const late = findings.filter((f) => /introduced too late to develop/.test(f.problem));+ expect(late).toHaveLength(1);+ expect(late[0].problem).toMatch(/"Latecomer" first takes the viewpoint in issue 11 of 1–12/);+ expect(late[0].issueNumber).toBe(11);+ expect(late[0].location).toBe('Issue 11: Latecomer-pov i11');+ expect(late[0].anchorQuote).toBe('q');+ });++ it('does NOT flag a late POV that is well developed (above the underdevelopment threshold)', () => {+ const scenes = [];+ for (let i = 1; i <= 12; i += 1) scenes.push(scene('Lead', i));+ // Latecomer first appears late but holds 3 scenes (> lateIntroMaxScenes 2).+ scenes.push(scene('Latecomer', 11));+ scenes.push(scene('Latecomer', 11, { heading: 'Latecomer-pov i11b' }));+ scenes.push(scene('Latecomer', 12));+ const findings = runEcon(scenes);+ expect(findings.filter((f) => /introduced too late to develop/.test(f.problem))).toHaveLength(0);+ });++ it('does NOT flag an early POV introduced before the late-intro window', () => {+ const scenes = [];+ for (let i = 1; i <= 12; i += 1) scenes.push(scene('Lead', i));+ // First appears in issue 8 of 12 → position (8-1)/11 = 0.64 < 0.8.+ scenes.push(scene('Earlybird', 8));+ const findings = runEcon(scenes);+ expect(findings.filter((f) => /introduced too late to develop/.test(f.problem))).toHaveLength(0);+ });++ it('lateIntroMaxScenes=0 disables the late-introduction check', () => {+ const scenes = [];+ for (let i = 1; i <= 12; i += 1) scenes.push(scene('Lead', i));+ scenes.push(scene('Latecomer', 11));+ expect(runEcon(scenes, { lateIntroMaxScenes: 0 })+ .filter((f) => /introduced too late to develop/.test(f.problem))).toHaveLength(0);+ });++ it('stays silent on both signals when the outline carries no issue numbers', () => {+ // No issue length to judge against → neither count nor timing can fire.+ const scenes = NAMES.slice(0, 8).map((n) => scene(n, null));+ expect(runEcon(scenes)).toEqual([]);+ });++ it('collapses casing/spacing variants of a POV name into one holder', () => {+ // Three spellings of one viewpoint across a 12-issue run → one holder, not three.+ const scenes = [];+ for (let i = 1; i <= 12; i += 1) scenes.push(scene('Lead', i));+ scenes.push(scene('Aria', 2));+ scenes.push(scene(' aria ', 5));+ scenes.push(scene('ARIA', 9));+ const findings = runEcon(scenes);+ // 2 holders (Lead, Aria) over 12 issues → under budget 6, no crowd finding.+ expect(findings.filter((f) => /more viewpoints than the run length/.test(f.problem))).toHaveLength(0);+ });++ it('tolerates an empty / malformed outline', () => {+ expect(runEcon([])).toEqual([]);+ expect(runEcon([null, 'x', {}, scene('', 1)])).toEqual([]);+ });+});+describe('arc.transitions — LLM check (#1293)', () => {const ARC = 'arc.transitions';const baseCtx = (overrides = {}) => ({