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: log + persist editorial-health pause breakdown for series autopilot (#1579)
[._.]/ Adam Eivy3f11578c9172
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 7ff0522640..bb2cccda42 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -208,6 +208,7 @@- **A season synopsis is no longer truncated mid-sentence (which could hang Series Autopilot's arc-verify loop).** The season-synopsis cap was 4000 characters — half the arc-level summary cap (8000) — even though a season synopsis covers a whole season's worth of episodes. A full synopsis got hard-clipped mid-word, and because the arc-verify→resolve convergence loop re-flags a mid-sentence truncation while the resolver keeps regenerating an over-cap synopsis that gets re-clipped, the loop burned all its rounds and paused without ever converging. The season-synopsis cap is now 8000 (matching the arc summary), so a complete synopsis is stored intact. (`server/lib/storyArc.js`)- **Arc prose fields (logline, synopsis, ending hook) now clip on a sentence/word boundary instead of mid-word.** A hard character-cap `slice()` could clip a season logline or synopsis mid-word ("…starts tracing the brand and"), which the arc-verify pass flags as "truncated mid-sentence" — and because the resolver then regenerates an over-cap value that gets re-clipped identically, the verify→resolve loop could never converge and paused the autopilot. A new `trimToClause` helper backs an over-cap value off to the last sentence terminator within budget (or, for a run-on, the last whole-word boundary), so a capped field always reads as complete prose. Applied to the arc and season logline/summary/synopsis/ending-hook/protagonist-arc fields. (`server/lib/storyBible.js`, `server/lib/storyArc.js`)- **Hugging Face model search now fills category tabs with no search term.** Clicking a category tag (Coding, Vision, Lightweight, Multilingual) on the Local LLM install page with an empty search box rendered a blank list. The default browse phrase for each category was a multi-word string ("coding coder agentic code gguf", "small 4b 3b 2b gguf"), but the Hub `search` param AND-matches every space-separated token against the model id — and no repo's id contains all of them, so the query returned zero results. Each category now seeds a short keyword + "gguf" phrase ("coder gguf", "vision gguf", etc.) that reliably returns the top-downloaded models for the category, and "Lightweight" uses "1b gguf" so it surfaces genuinely small models instead of `Mistral-Small-24B`. (`server/services/huggingFaceCatalog.js`)+- **A Series Autopilot editorial-health pause now logs and records *why* it paused.** When the health gate stopped a run it only reported a score and a raw open-finding count ("editorial health not clean (score 41, 18 open finding(s))") — answering "which checks/issues blocked my 50-issue series?" meant manually hitting the health API. The gate now emits a single-line emoji-prefixed log listing the top blocking checks and issues (by open-finding count) and stamps that same breakdown onto the persisted pause marker + the broadcast `paused` frame, so the resume banner / UI can show the blocking breakdown without a follow-up request. The breakdown is sanitized into the marker (bounded rows, coerced counts, series-scoped findings bucketed under a null issue) as a transient field — no sync schema-gate bump. (`server/services/pipeline/editorialScore.js`, `server/services/pipeline/seriesAutopilot.js`, `server/services/pipeline/series.js`)## Internaldiff --git a/server/services/pipeline/editorialScore.js b/server/services/pipeline/editorialScore.jsindex 7ffc313310..678571c812 100644--- a/server/services/pipeline/editorialScore.js+++ b/server/services/pipeline/editorialScore.js@@ -120,6 +120,60 @@ export function openBlockers(comments, gate = DEFAULT_READINESS_GATE) {);}+/**+ * Summarize the blocking breakdown of a `computeHealth` result (#1579) — the+ * top checks and issues (by open-finding count, descending) that drove a pause.+ * Pure; feeds both the single-line autopilot pause log and the persisted pause+ * marker so "why did health reject my series?" no longer needs a manual API+ * hit. `null`/series-scoped issue findings bucket under `issueNumber: null`.+ *+ * @param {object} health — a `computeHealth` result+ * @param {object} [opts]+ * @param {number} [opts.topN=5] — how many checks/issues to keep+ * @returns {{ score, open, topChecks: [{checkId, count}], topIssues: [{issueNumber, open}] }}+ */+export function summarizeEditorialBlockers(health, { topN = 5 } = {}) {+ const h = health && typeof health === 'object' ? health : {};+ const byCheck = h.openByCheck && typeof h.openByCheck === 'object' ? h.openByCheck : {};+ const topChecks = Object.entries(byCheck)+ .filter(([, n]) => Number.isFinite(n) && n > 0)+ // Count desc, then checkId asc for a stable tie-break.+ .sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))+ .slice(0, topN)+ .map(([checkId, count]) => ({ checkId, count }));+ const perIssue = Array.isArray(h.perIssue) ? h.perIssue : [];+ const topIssues = perIssue+ .filter((p) => p && typeof p === 'object' && Number.isFinite(p.open) && p.open > 0)+ // Open desc, then issueNumber asc (series-scoped null bucket sorts last).+ .sort((a, b) => b.open - a.open || ((a.issueNumber ?? Infinity) - (b.issueNumber ?? Infinity)))+ .slice(0, topN)+ .map((p) => ({ issueNumber: Number.isInteger(p.issueNumber) ? p.issueNumber : null, open: p.open }));+ return {+ score: Number.isFinite(h.score) ? h.score : 0,+ open: Number.isFinite(h.open) ? h.open : 0,+ topChecks,+ topIssues,+ };+}++/**+ * Render a `summarizeEditorialBlockers` breakdown into a compact, single-line+ * string for the emoji-prefixed autopilot log (#1579). Series-scoped findings+ * (no issue number) render as `series`.+ */+export function formatBlockerSummary(breakdown) {+ const b = breakdown && typeof breakdown === 'object' ? breakdown : {};+ const checks = Array.isArray(b.topChecks) ? b.topChecks : [];+ const issues = Array.isArray(b.topIssues) ? b.topIssues : [];+ const checkStr = checks.length+ ? `top checks [${checks.map((c) => `${c.checkId}×${c.count}`).join(', ')}]`+ : 'no check breakdown';+ const issueStr = issues.length+ ? `top issues [${issues.map((i) => `${i.issueNumber == null ? 'series' : `#${i.issueNumber}`}×${i.open}`).join(', ')}]`+ : 'no issue breakdown';+ return `${checkStr}; ${issueStr}`;+}+// Tally one finding into an accumulator. OPEN findings drive the score +// breakdowns; accepted/dismissed are counted only for context (resolved totals).function tally(acc, comment) {diff --git a/server/services/pipeline/editorialScore.test.js b/server/services/pipeline/editorialScore.test.jsindex b5dd9ac313..ebedd59f45 100644--- a/server/services/pipeline/editorialScore.test.js+++ b/server/services/pipeline/editorialScore.test.js@@ -9,6 +9,8 @@ import {openBlockers,computeHealth,computeTrend,+ summarizeEditorialBlockers,+ formatBlockerSummary,__testing,} from './editorialScore.js';@@ -247,6 +249,66 @@ describe('computeTrend', () => {});});+describe('summarizeEditorialBlockers', () => {+ it('ranks checks by open-finding count (desc) and keeps topN, ties broken by checkId', () => {+ const health = {+ score: 72,+ open: 6,+ openByCheck: { continuity: 3, naming: 3, pacing: 1, clean: 0 },+ perIssue: [],+ };+ const b = summarizeEditorialBlockers(health, { topN: 2 });+ expect(b.score).toBe(72);+ expect(b.open).toBe(6);+ // Equal counts → checkId ascending; `clean` (0) is filtered out.+ expect(b.topChecks).toEqual([+ { checkId: 'continuity', count: 3 },+ { checkId: 'naming', count: 3 },+ ]);+ });++ it('ranks issues by open count (desc) and buckets the series-scoped (null) issue last', () => {+ const health = {+ score: 50,+ open: 10,+ openByCheck: {},+ perIssue: [+ { issueNumber: 5, open: 2 },+ { issueNumber: 3, open: 5 },+ { issueNumber: null, open: 5 },+ { issueNumber: 9, open: 0 },+ ],+ };+ const b = summarizeEditorialBlockers(health);+ // open desc, then issueNumber asc with null sorting last; the 0-open issue is dropped.+ expect(b.topIssues).toEqual([+ { issueNumber: 3, open: 5 },+ { issueNumber: null, open: 5 },+ { issueNumber: 5, open: 2 },+ ]);+ });++ it('tolerates a malformed/absent health object', () => {+ const b = summarizeEditorialBlockers(null);+ expect(b).toEqual({ score: 0, open: 0, topChecks: [], topIssues: [] });+ });+});++describe('formatBlockerSummary', () => {+ it('renders checks and issues on one line, series-scoped findings as `series`', () => {+ const line = formatBlockerSummary({+ topChecks: [{ checkId: 'continuity', count: 3 }, { checkId: 'naming', count: 1 }],+ topIssues: [{ issueNumber: 3, open: 5 }, { issueNumber: null, open: 2 }],+ });+ expect(line).toBe('top checks [continuity×3, naming×1]; top issues [#3×5, series×2]');+ });++ it('falls back to explicit "no breakdown" labels when empty', () => {+ expect(formatBlockerSummary({ topChecks: [], topIssues: [] })).toBe('no check breakdown; no issue breakdown');+ expect(formatBlockerSummary(null)).toBe('no check breakdown; no issue breakdown');+ });+});+describe('ledger sanitization', () => {it('drops malformed snapshots and coerces severity counts', () => {const ledger = __testing.sanitizeLedger({diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.jsindex 3fee4242d5..61bab19274 100644--- a/server/services/pipeline/series.js+++ b/server/services/pipeline/series.js@@ -164,10 +164,37 @@ export const sanitizeAutopilot = (raw) => {// the UI flags it instead of reporting clean. Same transient-marker rationale// as craftGap* / pauseKind: no schema-gate bump.editorialCheckErrors: toCount(raw.editorialCheckErrors),+ // #1579 — the per-check / per-issue breakdown that drove an editorial-health+ // pause, so the UI / resume banner can render *why* without re-hitting the+ // health API. Null on any non-health pause. Same transient-marker rationale+ // as pauseKind / craftGap*: no schema-gate bump.+ healthBreakdown: sanitizeHealthBreakdown(raw.healthBreakdown),updatedAt: isStr(raw.updatedAt) ? raw.updatedAt : null,};};+// Bound the wire shape of a `summarizeEditorialBlockers` breakdown stamped onto+// a paused marker (#1579). Null unless it carries at least a numeric score —+// drops a hand-edited/older-peer blob that lacks the expected shape.+const HEALTH_BREAKDOWN_MAX_ROWS = 10;+const HEALTH_CHECK_ID_MAX = 120;+const sanitizeHealthBreakdown = (raw) => {+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;+ const topChecks = (Array.isArray(raw.topChecks) ? raw.topChecks : [])+ .map((c) => (c && typeof c === 'object' && isStr(c.checkId) && Number.isFinite(c.count)+ ? { checkId: trimTo(c.checkId, HEALTH_CHECK_ID_MAX), count: toCount(c.count) }+ : null))+ .filter(Boolean)+ .slice(0, HEALTH_BREAKDOWN_MAX_ROWS);+ const topIssues = (Array.isArray(raw.topIssues) ? raw.topIssues : [])+ .map((i) => (i && typeof i === 'object' && Number.isFinite(i.open)+ ? { issueNumber: Number.isInteger(i.issueNumber) ? i.issueNumber : null, open: toCount(i.open) }+ : null))+ .filter(Boolean)+ .slice(0, HEALTH_BREAKDOWN_MAX_ROWS);+ return { score: toCount(raw.score), open: toCount(raw.open), topChecks, topIssues };+};+// Coerce a marker counter to a non-negative integer, defaulting to 0 (so an// older marker that predates the field reads as "no gaps", not undefined).const toCount = (v) => (Number.isInteger(v) && v >= 0 ? v : 0);diff --git a/server/services/pipeline/series.test.js b/server/services/pipeline/series.test.jsindex 67d83795db..8324dc494f 100644--- a/server/services/pipeline/series.test.js+++ b/server/services/pipeline/series.test.js@@ -741,4 +741,38 @@ describe('pipeline series service', () => {expect(after.styleNotes).toBe(''); // tombstone stays clean, no resurrection});});++ describe('sanitizeAutopilot healthBreakdown (#1579)', () => {+ it('persists a well-formed pause breakdown, bounding rows and coercing counts', () => {+ const a = svc.sanitizeAutopilot({+ status: 'paused',+ healthBreakdown: {+ score: 72,+ open: 6,+ topChecks: [+ { checkId: 'continuity', count: 3 },+ { checkId: 'naming', count: 1.0 },+ { checkId: 42, count: 1 }, // non-string checkId → dropped+ ],+ topIssues: [+ { issueNumber: 3, open: 5 },+ { issueNumber: null, open: 2 }, // series-scoped bucket kept+ { open: 'x' }, // non-finite open → dropped+ ],+ },+ });+ expect(a.healthBreakdown).toEqual({+ score: 72,+ open: 6,+ topChecks: [{ checkId: 'continuity', count: 3 }, { checkId: 'naming', count: 1 }],+ topIssues: [{ issueNumber: 3, open: 5 }, { issueNumber: null, open: 2 }],+ });+ });++ it('drops a malformed/absent breakdown to null (non-health pauses carry none)', () => {+ expect(svc.sanitizeAutopilot({ status: 'paused' }).healthBreakdown).toBeNull();+ expect(svc.sanitizeAutopilot({ status: 'paused', healthBreakdown: 'nope' }).healthBreakdown).toBeNull();+ expect(svc.sanitizeAutopilot({ status: 'paused', healthBreakdown: [] }).healthBreakdown).toBeNull();+ });+ });});diff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.jsindex 2b6bb06005..3c09c4ed71 100644--- a/server/services/pipeline/seriesAutopilot.js+++ b/server/services/pipeline/seriesAutopilot.js@@ -94,7 +94,7 @@ import * as autoRunner from './autoRunner.js';import { seedReviewFromFindings, getReview } from './manuscriptReview.js';import { runEditorialChecks, buildEditorialCheckPlan, enabledChecksConsumeReverseOutline, summarizeCheckErrors } from './editorial/checkRunner.js';import { generateReverseOutline, getReverseOutline } from './reverseOutline.js';-import { computeHealth, openBlockers, READINESS_GATES, resolveReadinessGate } from './editorialScore.js';+import { computeHealth, openBlockers, READINESS_GATES, resolveReadinessGate, summarizeEditorialBlockers, formatBlockerSummary } from './editorialScore.js';import { getSettings } from '../settings.js';import { readReadinessGate } from '../../lib/editorial/index.js';import { generateManuscriptFix, acceptManuscriptFix } from './manuscriptFix.js';@@ -1163,7 +1163,13 @@ async function runEditorialHealthGate(sId, record) {// loop, so it has no maxRounds/divergence distinction — leave it null. If this// ever gains a retry loop, thread pauseKind through trackConvergence then.const blockers = openBlockers(comments, gate);- return { pause: true, reason: `editorial health not clean (score ${health.score}, ${health.open} open finding(s))`, residual: blockers };+ // Surface the per-check / per-issue breakdown that drove the pause (#1579) —+ // a single emoji-prefixed line so "why did health reject my 50-issue series?"+ // is answerable from the logs, and the same breakdown on the marker so the UI+ // / resume banner can render it without re-hitting the health API.+ const healthBreakdown = summarizeEditorialBlockers(health);+ console.log(`🩺 editorial health gate not clean — series=${sId.slice(0, 12)} score=${health.score}, ${health.open} open: ${formatBlockerSummary(healthBreakdown)}`);+ return { pause: true, reason: `editorial health not clean (score ${health.score}, ${health.open} open finding(s))`, residual: blockers, healthBreakdown };}// Turn a render-enqueue result into the { slotKey, slot } pair the render@@ -1688,8 +1694,8 @@ export async function startSeriesAutopilot(sId, options = {}) {if (result?.canceled || record.cancelRequested) break;if (result?.pause) {- await persistMarker(sId, { status: 'paused', runId, currentStep: step.kind, residualFindings: result.residual || [], lastError: result.reason, pauseKind: result.pauseKind || null });- broadcast(sId, { type: 'paused', runId, scope: step.kind, reason: result.reason, residualFindings: result.residual || [], pauseKind: result.pauseKind || null, completedAt: new Date().toISOString() });+ await persistMarker(sId, { status: 'paused', runId, currentStep: step.kind, residualFindings: result.residual || [], lastError: result.reason, pauseKind: result.pauseKind || null, healthBreakdown: result.healthBreakdown || null });+ broadcast(sId, { type: 'paused', runId, scope: step.kind, reason: result.reason, residualFindings: result.residual || [], pauseKind: result.pauseKind || null, healthBreakdown: result.healthBreakdown || null, completedAt: new Date().toISOString() });// Only file the generic stalled task when the step didn't already file// a more specific gap (canon-undescribed, visual-no-pages, …) — else// fileGaps would create two CoS tasks for one underlying problem (the